From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id C5087559C for ; Mon, 18 Jan 2016 02:37:17 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 17 Jan 2016 17:37:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,310,1449561600"; d="scan'208";a="729195078" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga003.jf.intel.com with ESMTP; 17 Jan 2016 17:37:16 -0800 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 17 Jan 2016 17:37:16 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 17 Jan 2016 17:37:15 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.172]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.215]) with mapi id 14.03.0248.002; Mon, 18 Jan 2016 09:37:14 +0800 From: "Xu, Qian Q" To: "Liu, Yong" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH 5/6] tests vf_vlan: add test suite for VF vlan validation Thread-Index: AQHRTD6LoPR/5OqwiUqK/6Rb/f7k2J8AiBZw Date: Mon, 18 Jan 2016 01:37:13 +0000 Message-ID: <82F45D86ADE5454A95A89742C8D1410E031BA0F1@shsmsx102.ccr.corp.intel.com> References: <1452495940-9681-1-git-send-email-yong.liu@intel.com> <1452495940-9681-5-git-send-email-yong.liu@intel.com> In-Reply-To: <1452495940-9681-5-git-send-email-yong.liu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZWUyMzg2YmUtMTA3NS00NTg1LTk4YWUtN2VmYzNiZjJmM2Y5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjQuMTAuMTkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiN1FcLzBETFdEc2V1czl1R1RoXC9pa085V1lwVjJ1SzRRUFdkVFBvQ1N5TFJBPSJ9 x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH 5/6] tests vf_vlan: add test suite for VF vlan validation 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: Mon, 18 Jan 2016 01:37:18 -0000 When doing vf testing, we many need add crc config on or else the packet RX= /TX may have problems.=20 >port stop all >port config all crc-strip on >port start all Thanks Qian -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Yong Liu Sent: Monday, January 11, 2016 3:06 PM To: dts@dpdk.org Subject: [dts] [PATCH 5/6] tests vf_vlan: add test suite for VF vlan valida= tion Signed-off-by: Marvin Liu diff --git a/tests/TestSuite_vf_vlan.py b/tests/TestSuite_vf_vlan.py new fi= le mode 100644 index 0000000..62fda22 --- /dev/null +++ b/tests/TestSuite_vf_vlan.py @@ -0,0 +1,362 @@ +# + +import re +import time + +import dts +from qemu_kvm import QEMUKvm +from test_case import TestCase +from pmd_output import PmdOutput +from packet import Packet, sniff_packets, load_sniff_packets from=20 +settings import get_nic_name import random + +VM_CORES_MASK =3D 'all' + + +class TestVfVlan(TestCase): + + def set_up_all(self): + + self.dut_ports =3D self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) > 1, "Insufficient ports") + self.vm0 =3D None + self.env_done =3D False + + def set_up(self): + self.setup_vm_env() + + def bind_nic_driver(self, ports, driver=3D""): + # modprobe vfio driver + if driver =3D=3D "vfio-pci": + for port in ports: + netdev =3D self.dut.ports_info[port]['port'] + driver =3D netdev.get_nic_driver() + if driver !=3D 'vfio-pci': + netdev.bind_driver(driver=3D'vfio-pci') + + elif driver =3D=3D "igb_uio": + # igb_uio should insmod as default, no need to check + for port in ports: + netdev =3D self.dut.ports_info[port]['port'] + driver =3D netdev.get_nic_driver() + if driver !=3D 'igb_uio': + netdev.bind_driver(driver=3D'igb_uio') + else: + for port in ports: + netdev =3D self.dut.ports_info[port]['port'] + driver_now =3D netdev.get_nic_driver() + if driver =3D=3D "": + driver =3D netdev.default_driver + if driver !=3D driver_now: + netdev.bind_driver(driver=3Ddriver) + + def setup_vm_env(self, driver=3D'default'): + """ + Create testing environment with 2VFs generated from 2PFs + """ + if self.env_done: + return + + # bind to default driver + self.bind_nic_driver(self.dut_ports[:2], driver=3D"") + + self.used_dut_port_0 =3D self.dut_ports[0] + self.host_intf0 =3D self.dut.ports_info[self.used_dut_port_0]['int= f'] + tester_port =3D self.tester.get_local_port(self.used_dut_port_0) + self.tester_intf0 =3D self.tester.get_interface(tester_port) + + self.dut.generate_sriov_vfs_by_port( + self.used_dut_port_0, 1, driver=3Ddriver) + self.sriov_vfs_port_0 =3D self.dut.ports_info[ + self.used_dut_port_0]['vfs_port'] + self.vf0_mac =3D "00:10:00:00:00:00" + self.dut.send_expect("ip link set %s vf 0 mac %s" % + (self.host_intf0, self.vf0_mac), "# ") + + self.used_dut_port_1 =3D self.dut_ports[1] + self.host_intf1 =3D self.dut.ports_info[self.used_dut_port_1]['int= f'] + self.dut.generate_sriov_vfs_by_port( + self.used_dut_port_1, 1, driver=3Ddriver) + self.sriov_vfs_port_1 =3D self.dut.ports_info[ + self.used_dut_port_1]['vfs_port'] + tester_port =3D self.tester.get_local_port(self.used_dut_port_1) + self.tester_intf1 =3D self.tester.get_interface(tester_port) + + self.vf1_mac =3D "00:20:00:00:00:00" + self.dut.send_expect("ip link set %s vf 0 mac %s" % + (self.host_intf1, self.vf1_mac), "# ") + + try: + + for port in self.sriov_vfs_port_0: + port.bind_driver('pci-stub') + + for port in self.sriov_vfs_port_1: + port.bind_driver('pci-stub') + + time.sleep(1) + vf0_prop =3D {'opt_host': self.sriov_vfs_port_0[0].pci} + vf1_prop =3D {'opt_host': self.sriov_vfs_port_1[0].pci} + + # set up VM0 ENV + self.vm0 =3D QEMUKvm(self.dut, 'vm0', 'vf_vlan') + self.vm0.set_vm_device(driver=3D'pci-assign', **vf0_prop) + self.vm0.set_vm_device(driver=3D'pci-assign', **vf1_prop) + self.vm_dut_0 =3D self.vm0.start() + if self.vm_dut_0 is None: + raise Exception("Set up VM0 ENV failed!") + + except Exception as e: + self.destroy_vm_env() + raise Exception(e) + + self.env_done =3D True + + def destroy_vm_env(self): + if getattr(self, 'vm0', None): + self.vm_dut_0.kill_all() + self.vm0_testpmd =3D None + self.vm0_dut_ports =3D None + # destroy vm0 + self.vm0.stop() + self.vm0 =3D None + + if getattr(self, 'used_dut_port_0', None): + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0) + port =3D self.dut.ports_info[self.used_dut_port_0]['port'] + self.used_dut_port_0 =3D None + + if getattr(self, 'used_dut_port_1', None): + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_1) + port =3D self.dut.ports_info[self.used_dut_port_1]['port'] + self.used_dut_port_1 =3D None + + self.bind_nic_driver(self.dut_ports[:2], driver=3D"igb_uio") + + self.env_done =3D False + + def test_pvid_vf_tx(self): + """ + Add port based vlan on vf device and check vlan tx work + """ + random_vlan =3D random.randint(1, 4095) + + self.dut.send_expect( + "ip link set %s vf 0 vlan %d" % (self.host_intf0, random_vlan)= , "# ") + out =3D self.dut.send_expect("ip link show %s" % self.host_intf0, = "# ") + self.verify("vlan %d" % + random_vlan in out, "Failed to add pvid on VF0") + + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') + + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) + self.vm0_testpmd.execute_cmd('set fwd mac') + self.vm0_testpmd.execute_cmd('start') + + pkt =3D Packet(pkt_type=3D'UDP') + pkt.config_layer('ether', {'dst': self.vf1_mac}) + inst =3D sniff_packets(self.tester_intf0, timeout=3D5) + pkt.send_pkt(tx_port=3Dself.tester_intf1) + pkts =3D load_sniff_packets(inst) + + self.verify(len(pkts), "Not receive expected packet") + self.vm0_testpmd.quit() + + # disable pvid + self.dut.send_expect( + "ip link set %s vf 0 vlan 0" % (self.host_intf0), "# ") + + def send_and_getout(self, vlan=3D0, pkt_type=3D"UDP"): + + if pkt_type =3D=3D "UDP": + pkt =3D Packet(pkt_type=3D'UDP') + pkt.config_layer('ether', {'dst': self.vf0_mac}) + elif pkt_type =3D=3D "VLAN_UDP": + pkt =3D Packet(pkt_type=3D'VLAN_UDP') + pkt.config_layer('dot1q', {'vlan': vlan}) + pkt.config_layer('ether', {'dst': self.vf0_mac}) + + pkt.send_pkt(tx_port=3Dself.tester_intf0) + out =3D self.vm_dut_0.get_session_output(timeout=3D2) + + return out + + def test_add_pvid_vf(self): + random_vlan =3D random.randint(1, 4095) + + self.dut.send_expect( + "ip link set %s vf 0 vlan %d" % (self.host_intf0, random_vlan)= , "# ") + out =3D self.dut.send_expect("ip link show %s" % self.host_intf0, = "# ") + self.verify("vlan %d" % + random_vlan in out, "Failed to add pvid on VF0") + + # start testpmd in VM + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') + + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) + self.vm0_testpmd.execute_cmd('set fwd rxonly') + self.vm0_testpmd.execute_cmd('set verbose 1') + self.vm0_testpmd.execute_cmd('start') + + out =3D self.send_and_getout(vlan=3Drandom_vlan, pkt_type=3D"VLAN_= UDP") + self.verify("received" in out, "Failed to received vlan=20 + packet!!!") + + # send packet without vlan + out =3D self.send_and_getout(pkt_type=3D"UDP") + self.verify("received" not in out, "Received packet without=20 + vlan!!!") + + # send packet with vlan not matched + wrong_vlan =3D (random_vlan + 1) % 4096 + out =3D self.send_and_getout(vlan=3Dwrong_vlan, pkt_type=3D"VLAN_U= DP") + self.verify( + "received" not in out, "Received pacekt with wrong=20 + vlan!!!") + + # remove vlan + self.dut.send_expect( + "ip link set %s vf 0 vlan 0" % self.host_intf0, "# ") + + # send packet with vlan + out =3D self.send_and_getout(vlan=3Drandom_vlan, pkt_type=3D"VLAN_= UDP") + self.verify( + "received" not in out, "Received vlan packet without=20 + pvid!!!") + + # send packe with vlan 0 + out =3D self.send_and_getout(vlan=3D0, pkt_type=3D"VLAN_UDP") + self.verify( + "received" in out, "Not recevied packet with vlan 0!!!") + + # send packet without vlan + out =3D self.send_and_getout(vlan=3D0, pkt_type=3D"UDP") + self.verify("received" in out, "Not received packet without=20 + vlan!!!") + + self.vm0_testpmd.quit() + + # disable pvid + self.dut.send_expect( + "ip link set %s vf 0 vlan 0" % (self.host_intf0), "# ") + + def test_vf_vlan_tx(self): + random_vlan =3D random.randint(1, 4095) + # start testpmd in VM + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') + + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) + self.vm0_testpmd.execute_cmd('set verbose 1') + + self.vm0_testpmd.execute_cmd('tx_vlan set 0 %d' % random_vlan) + + inst =3D sniff_packets(self.tester_intf0, timeout=3D5) + self.vm0_testpmd.execute_cmd('set burst 1') + self.vm0_testpmd.execute_cmd('start tx_first') + + # strip sniffered vlans + pkts =3D load_sniff_packets(inst) + vlans =3D [] + for pkt in pkts: + vlan =3D pkt.strip_element_dot1q("vlan") + vlans.append(vlan) + + self.verify( + random_vlan in vlans, "Tx packet with vlan not=20 + received!!!") + + self.vm0_testpmd.quit() + + def test_vf_vlan_rx(self): + random_vlan =3D random.randint(1, 4095) + # start testpmd in VM + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') + + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) + self.vm0_testpmd.execute_cmd('set fwd rxonly') + self.vm0_testpmd.execute_cmd('set verbose 1') + self.vm0_testpmd.execute_cmd('vlan set strip off 0') + self.vm0_testpmd.execute_cmd('start') + + # send packet without vlan + out =3D self.send_and_getout(vlan=3D0, pkt_type=3D"UDP") + self.verify( + "received 1 packets" in out, "Not received normal packet as=20 + default!!!") + + # send packet with vlan 0 + out =3D self.send_and_getout(vlan=3D0, pkt_type=3D"VLAN_UDP") + self.verify("VLAN tci=3D0x0" + in out, "Not received vlan 0 packet as default!!!") + + self.vm0_testpmd.execute_cmd('rx_vlan add %d 0' % random_vlan) + # send packet with same vlan + out =3D self.send_and_getout(vlan=3Drandom_vlan, pkt_type=3D"VLAN_= UDP") + vlan_hex =3D hex(random_vlan) + self.verify("VLAN tci=3D%s" % + vlan_hex in out, "Not received expected vlan=20 + packet!!!") + + pkt =3D Packet(pkt_type=3D'VLAN_UDP') + wrong_vlan =3D (random_vlan + 1) % 4096 + # send packet with wrong vlan + out =3D self.send_and_getout(vlan=3Dwrong_vlan, pkt_type=3D"VLAN_U= DP") + self.verify( + "received 1 packets" not in out, "Received filtered vlan=20 + packet!!!") + + self.vm0_testpmd.execute_cmd('rx_vlan rm 0 %d' % random_vlan) + # send packet with vlan 0 + out =3D self.send_and_getout(vlan=3D0, pkt_type=3D"VLAN_UDP") + self.verify("VLAN tci=3D0x0" + in out, "Not received vlan 0 packet as default!!!") + + # send packet without vlan + out =3D self.send_and_getout(pkt_type=3D"UDP") + self.verify("received 1 packets" in out, + "Not received normal packet after remove vlan=20 + filter!!!") + + # send packet without vlan + out =3D self.send_and_getout(vlan=3Drandom_vlan, pkt_type=3D"VLAN_= UDP") + self.verify( + "received 1 packets" in out, "Not received vlan packet=20 + without vlan filter!!!") + + self.vm0_testpmd.quit() + + def test_vf_vlan_strip(self): + random_vlan =3D random.randint(1, 4095) + # start testpmd in VM + self.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') + + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) + self.vm0_testpmd.execute_cmd('set fwd rxonly') + self.vm0_testpmd.execute_cmd('set verbose 1') + self.vm0_testpmd.execute_cmd('vlan set strip on 0') + self.vm0_testpmd.execute_cmd('rx_vlan add %d 0' % random_vlan) + self.vm0_testpmd.execute_cmd('start') + + out =3D self.send_and_getout(vlan=3Drandom_vlan, pkt_type=3D"VLAN_= UDP") + # enable strip, vlan will be in mbuf + vlan_hex =3D hex(random_vlan) + self.verify("VLAN tci=3D%s" % + vlan_hex in out, "Failed to strip vlan packet!!!") + + self.vm0_testpmd.execute_cmd('vlan set strip off 0') + + out =3D self.send_and_getout(vlan=3Drandom_vlan, pkt_type=3D"VLAN_= UDP") + self.verify( + "received 1 packets" in out, "Not received vlan packet as expe= cted!!!") + nic_type =3D self.vm_dut_0.ports_info[0]['type'] + nic_name =3D get_nic_name(nic_type) + if nic_name in ['fvl10g_vf']: + self.verify("VLAN tci=3D%s" % + vlan_hex in out, "Failed to disable strip vlan!!!"= ) + else: + self.verify("VLAN tci=3D0x0" in out, "Failed to disable strip= =20 + vlan!!!") + + self.vm0_testpmd.quit() + + def tear_down(self): + self.vm_dut_0.kill_all() + pass + + def tear_down_all(self): + self.destroy_vm_env() + pass -- 1.9.3