From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 32290C1CC for ; Fri, 24 Jun 2016 10:44:25 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 24 Jun 2016 01:44:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,518,1459839600"; d="scan'208";a="1008757342" Received: from unknown (HELO dpdk-fedora20.icx.intel.com) ([10.238.55.12]) by fmsmga002.fm.intel.com with ESMTP; 24 Jun 2016 01:44:23 -0700 From: Lijuan Tu To: dts@dpdk.org Cc: Lijuan Tu Date: Fri, 24 Jun 2016 16:40:02 +0800 Message-Id: <1466757602-27290-1-git-send-email-lijuanx.a.tu@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dts] [PATCH v2]tests sriov_kvm: test vlan mirror with random vlan id X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Jun 2016 08:44:25 -0000 vlan 0 is not a validated vlan id. validated vlan id is between 1 to 4095 Signed-off-by: Lijuan Tu --- tests/TestSuite_sriov_kvm.py | 83 ++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/tests/TestSuite_sriov_kvm.py b/tests/TestSuite_sriov_kvm.py index cc63804..7903317 100644 --- a/tests/TestSuite_sriov_kvm.py +++ b/tests/TestSuite_sriov_kvm.py @@ -11,6 +11,7 @@ Test userland 10Gb PMD. import re import time from functools import wraps +import random import dts from qemu_kvm import QEMUKvm @@ -19,6 +20,7 @@ from test_case import TestCase from pmd_output import PmdOutput FRAME_SIZE_64 = 64 VM_CORES_MASK = 'all' +MAX_VLAN = 4095 class TestSriovKvm(TestCase): @@ -76,7 +78,7 @@ class TestSriovKvm(TestCase): 'dest_mac':False 'src_mac':"52:00:00:00:00:00" } - 'dot1q': + 'vlan': { 'vlan':1 } @@ -93,7 +95,7 @@ class TestSriovKvm(TestCase): """ ret_ether_ip = {} ether = {} - dot1q = {} + vlan = {} ip = {} udp = {} @@ -120,13 +122,13 @@ class TestSriovKvm(TestCase): else: ether['src_mac'] = ether_ip["ether"]["src_mac"] - if not ether_ip.get('dot1q'): + if not ether_ip.get('vlan'): pass else: - if not ether_ip['dot1q'].get('vlan'): - dot1q['vlan'] = '1' + if not ether_ip['vlan'].get('vlan'): + vlan['vlan'] = '1' else: - dot1q['vlan'] = ether_ip['dot1q']['vlan'] + vlan['vlan'] = ether_ip['vlan']['vlan'] if not ether_ip.get('ip'): ip['dest_ip'] = "10.239.129.88" @@ -155,7 +157,7 @@ class TestSriovKvm(TestCase): udp['src_port'] = ether_ip['udp']['src_port'] ret_ether_ip['ether'] = ether - ret_ether_ip['dot1q'] = dot1q + ret_ether_ip['vlan'] = vlan ret_ether_ip['ip'] = ip ret_ether_ip['udp'] = udp @@ -183,7 +185,7 @@ class TestSriovKvm(TestCase): 'dest_mac':False 'src_mac':"52:00:00:00:00:00" } - 'dot1q': + 'vlan': { 'vlan':1 } @@ -234,9 +236,9 @@ class TestSriovKvm(TestCase): self.tester.scapy_append( 'srcmac="%s"' % ret_ether_ip['ether']['src_mac']) - if ether_ip.get('dot1q'): + if ether_ip.get('vlan'): self.tester.scapy_append( - 'vlanvalue=%d' % int(ret_ether_ip['dot1q']['vlan'])) + 'vlanvalue=%d' % int(ret_ether_ip['vlan']['vlan'])) self.tester.scapy_append( 'destip="%s"' % ret_ether_ip['ip']['dest_ip']) self.tester.scapy_append( @@ -245,7 +247,7 @@ class TestSriovKvm(TestCase): 'destport=%d' % ret_ether_ip['udp']['dest_port']) self.tester.scapy_append( 'srcport=%d' % ret_ether_ip['udp']['src_port']) - if not ret_ether_ip.get('dot1q'): + if not ret_ether_ip.get('vlan'): send_cmd = 'sendp([Ether(dst=nutmac, src=srcmac)/' + \ 'IP(dst=destip, src=srcip, len=%s)/' % pktlen + \ 'UDP(sport=srcport, dport=destport)/' + \ @@ -628,6 +630,8 @@ class TestSriovKvm(TestCase): self.reset_port_mirror_rule(port, rule_id) def setup_two_vm_common_prerequisite(self): + self.host_testpmd.execute_cmd('port stop all') + self.host_testpmd.execute_cmd('port start all') self.vm0_dut_ports = self.vm_dut_0.get_ports('any') self.vm0_testpmd = PmdOutput(self.vm_dut_0) self.vm0_testpmd.start_testpmd(VM_CORES_MASK) @@ -821,36 +825,39 @@ class TestSriovKvm(TestCase): vlan_id = 0 vf_mask = '0x1' packet_num = 10 + random_vlan = random.randint(1, MAX_VLAN - 1) + vlan_ids = [0, 1, random_vlan, MAX_VLAN] - if self.nic.startswith('fortville'): - vm_testpmd = self.get_vm_testpmd_by_mask(vf_mask) - vm_testpmd.execute_cmd('rx_vlan add %d %d' % (vlan_id, port_id_0)) - else: - self.host_testpmd.execute_cmd( - 'rx_vlan add %d port %d vf %s' % (vlan_id, port_id_0, vf_mask)) - rule_id = self.set_port_vlan_mirror(port_id_0, '0 dst-pool 1 on') + for vlan_id in vlan_ids: + if self.nic.startswith('fortville'): + vm_testpmd = self.get_vm_testpmd_by_mask(vf_mask) + vm_testpmd.execute_cmd('rx_vlan add %d %d' % (vlan_id, port_id_0)) + else: + self.host_testpmd.execute_cmd( + 'rx_vlan add %d port %d vf %s' % (vlan_id, port_id_0, vf_mask)) + rule_id = self.set_port_vlan_mirror(port_id_0, '%d dst-pool 1 on' % vlan_id) - vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) - vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) - ether_ip = {} - ether_ip['dot1q'] = {'vlan': '%d' % vlan_id} - self.send_packet( - self.vm_dut_0, - self.vm0_dut_ports, - port_id_0, - count=packet_num, - **ether_ip) - vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) - vm0_end_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) + vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) + vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + ether_ip = {} + ether_ip['vlan'] = {'vlan': '%d' % vlan_id} + self.send_packet( + self.vm_dut_0, + self.vm0_dut_ports, + port_id_0, + count=packet_num, + **ether_ip) + vm1_end_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) + vm0_end_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) - vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) - vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats) + vm1_ret_stats = self.calculate_stats(vm1_start_stats, vm1_end_stats) + vm0_ret_stats = self.calculate_stats(vm0_start_stats, vm0_end_stats) - self.verify(vm1_ret_stats['RX-packets'] == packet_num and - vm1_ret_stats['TX-packets'] == packet_num, - "Vlan mirror failed between VM0 and VM1!") + self.verify(vm1_ret_stats['RX-packets'] == packet_num and + vm1_ret_stats['TX-packets'] == packet_num, + "Vlan mirror failed between VM0 and VM1!") - self.reset_port_mirror_rule(port_id_0, rule_id) + self.reset_port_mirror_rule(port_id_0, rule_id) def test_two_vms_vlan_and_pool_mirror(self): self.setup_2vm_2vf_env() @@ -886,7 +893,7 @@ class TestSriovKvm(TestCase): vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) ether_ip = {} - ether_ip['dot1q'] = {'vlan': '%d' % vlan_id} + ether_ip['vlan'] = {'vlan': '%d' % vlan_id} self.send_packet( self.vm_dut_1, self.vm1_dut_ports, @@ -1016,7 +1023,7 @@ class TestSriovKvm(TestCase): self.vm0_testpmd.execute_cmd('start') ether_ip = {} - ether_ip['dot1q'] = {'vlan': '%d' % vlan_id} + ether_ip['vlan'] = {'vlan': '%d' % vlan_id} vm1_start_stats = self.vm1_testpmd.get_pmd_stats(port_id_0) vm0_start_stats = self.vm0_testpmd.get_pmd_stats(port_id_0) self.send_packet( -- 1.9.3