From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 07C132C71 for ; Wed, 8 Mar 2017 09:49:26 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Mar 2017 00:49:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,262,1486454400"; d="scan'208";a="57529031" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga002.jf.intel.com with ESMTP; 08 Mar 2017 00:48:57 -0800 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 8 Mar 2017 00:48:57 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 8 Mar 2017 00:48:56 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.59]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.204]) with mapi id 14.03.0248.002; Wed, 8 Mar 2017 16:48:54 +0800 From: "Lin, Xueqin" To: "Liu, Yong" , "dts@dpdk.org" Thread-Topic: [dts] [PATCH] test suite:vf daemon DPDK PF + DPDK VF test suite Thread-Index: AQHSl+Yqe5cF4WLlBUWnKXzjtIrqLKGKoHSw Date: Wed, 8 Mar 2017 08:48:54 +0000 Message-ID: <0D300480287911409D9FF92C1FA2A3355B1B5A60@SHSMSX104.ccr.corp.intel.com> References: <1488858073-5775-1-git-send-email-xueqin.lin@intel.com> <58BFBF07.2030909@intel.com> In-Reply-To: <58BFBF07.2030909@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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] test suite:vf daemon DPDK PF + DPDK VF test suite 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: Wed, 08 Mar 2017 08:49:28 -0000 Reply as below and I will add more description for each case.=20 Thanks for review. Best regards, Xueqin -----Original Message----- From: Liu, Yong=20 Sent: Wednesday, March 8, 2017 4:21 PM To: Lin, Xueqin ; dts@dpdk.org Subject: Re: [dts] [PATCH] test suite:vf daemon DPDK PF + DPDK VF test suit= e Xueqin, Two comments below. Since lots of cases added by this suite, we need more d= escription for each case. Thanks, Marvin On 03/07/2017 11:41 AM, Xueqin Lin wrote: > --- > tests/TestSuite_vf_daemon.py | 575 ++++++++++++++++++++++++++++++++++++= +++++++ > 1 file changed, 575 insertions(+) > create mode 100644 tests/TestSuite_vf_daemon.py > > diff --git a/tests/TestSuite_vf_daemon.py=20 > b/tests/TestSuite_vf_daemon.py new file mode 100644 index=20 > 0000000..d54fc96 > --- /dev/null > +++ b/tests/TestSuite_vf_daemon.py > @@ -0,0 +1,575 @@ > +# > + > +import time > +import sys > +import utils > +from scapy.utils import rdpcap > + > +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' > +MAX_VLAN =3D 4095 > + > + > +class Testvf_daemon(TestCase): > + > + def set_up_all(self): > + > + self.dut_ports =3D self.dut.get_ports(self.nic) > + self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports") > + self.vm0 =3D None > + self.vm1 =3D None > + self.env_done =3D False > + > + > + def set_up(self): > + self.setup_vm_env() > + > + def bind_nic_driver(self, ports, driver=3D""): > + > + 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') > + > + def setup_vm_env(self, driver=3D'igb_uio'): > + """ > + Create testing environment with 2VFs generated from 1PF > + """ > + if self.env_done: > + return > + > + self.bind_nic_driver(self.dut_ports[:1], driver=3D"") > + > + self.used_dut_port =3D self.dut_ports[0] > + tester_port =3D self.tester.get_local_port(self.used_dut_port) > + self.tester_intf =3D self.tester.get_interface(tester_port) > + > + self.dut.generate_sriov_vfs_by_port( > + self.used_dut_port, 2, driver=3Ddriver) > + self.sriov_vfs_port =3D self.dut.ports_info[ > + self.used_dut_port]['vfs_port'] > + self.dut.send_expect("rmmod %svf" %self.kdriver , "# ") Rmmod is critical action, may cause system unstable and recommend not to do= that. Can bind to igb_uio later. Stable for my environment now, can change it if future need. > + self.dut_testpmd =3D PmdOutput(self.dut) > + time.sleep(1) > + vf0_prop =3D {'opt_host': self.sriov_vfs_port[0].pci} > + > + # set up VM0 ENV > + self.vm0 =3D QEMUKvm(self.dut, 'vm0', 'vf_daemon') > + self.vm0.set_vm_device(driver=3D'pci-assign', **vf0_prop) > + try: > + self.vm0_dut =3D self.vm0.start() > + if self.vm0_dut is None: > + raise Exception("Set up VM0 ENV failed!") > + except Exception as e: > + self.destroy_vm_env() > + raise Exception(e) > + > + self.vm0_dut_ports =3D self.vm0_dut.get_ports('any') > + self.vm0_testpmd =3D PmdOutput(self.vm0_dut) > + > + vf1_prop =3D {'opt_host': self.sriov_vfs_port[1].pci} > + self.vm1 =3D QEMUKvm(self.dut, 'vm1', 'vf_daemon') > + self.vm1.set_vm_device(driver=3D'pci-assign', **vf1_prop) > + try: > + self.vm1_dut =3D self.vm1.start() > + if self.vm1_dut is None: > + raise Exception("Set up VM1 ENV failed!") > + except Exception as e: > + self.destroy_vm_env() > + raise Exception(e) > + self.vm1_dut_ports =3D self.vm1_dut.get_ports('any') > + self.vm1_testpmd =3D PmdOutput(self.vm1_dut) > + > + self.env_done =3D True > + > + def destroy_vm_env(self): > + > + if getattr(self, 'vm0', None): > + self.vm0_dut.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, 'vm1', None): > + self.vm1_dut.kill_all() > + self.vm1_testpmd =3D None > + self.vm1_dut_ports =3D None > + # destroy vm1 > + self.vm1.stop() > + self.vm1 =3D None > + > + if getattr(self, 'used_dut_port', None): > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port) > + port =3D self.dut.ports_info[self.used_dut_port]['port'] > + self.used_dut_port =3D None > + > + self.env_done =3D False > + > + > + def send_packet(self, dst_mac, vlan_id, pktsize, num): > + if vlan_id =3D=3D 0: > + pkt =3D Packet(pkt_type=3D'UDP', pkt_len =3D pktsize) > + else: > + pkt =3D Packet(pkt_type=3D'VLAN_UDP', pkt_len =3D pktsize) > + pkt.config_layer('vlan', {'vlan': vlan_id}) > + pkt.config_layer('ether', {'dst': dst_mac}) > + inst =3D sniff_packets(self.tester_intf, timeout=3D5) > + pkt.send_pkt(tx_port=3Dself.tester_intf, count=3Dnum) > + return inst > + > + def strip_mac(self, inst, element =3D "src"): > + pkts =3D load_sniff_packets(inst) > + srcs =3D [] > + for pkt in pkts: > + src =3D pkt.strip_element_layer2(element) > + srcs.append(src) > + return srcs > + > + def strip_vlan(self, inst): > + pkts =3D load_sniff_packets(inst) > + vlans =3D [] > + for pkt in pkts: > + vlan =3D pkt.strip_element_vlan("vlan") > + vlans.append(vlan) > + return vlans > + > + > + def send_and_pmdout(self, dst_mac, vlan_id =3D 0, pktsize =3D 64 , n= um =3D 1): > + inst =3D self.send_packet(dst_mac, vlan_id , pktsize, num) > + out =3D self.vm0_dut.get_session_output(timeout=3D2) > + return out > + Please add some descriptions for each function. Help message should contain of function/input/output clarification: """ Send packets to dut and return testpmd output message Input: dst_mac, vlan_id, packet size, packet number Output: testpmd output message """ OK, I will add description. > + def send_and_vlancheck(self, dst_mac, vlan_id =3D 0, pktsize =3D 64,= num =3D 1): > + inst =3D self.send_packet(dst_mac, vlan_id , pktsize, num) > + vlans =3D self.strip_vlan(inst) > + return vlans > + > + def send_and_maccheck(self, dst_mac, vlan_id =3D 0, pktsize =3D 64, = num =3D 1): > + inst =3D self.send_packet(dst_mac, vlan_id , pktsize, num) > + srcs =3D self.strip_mac(inst) > + return srcs > + > + > + def test_vlan_insert(self): > + self.dut_testpmd.start_testpmd("Default", "--port-topology=3Dcha= ined") > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK,=20 > + '--port-topology=3Dchained') > + > + self.vf0_mac =3D self.vm0_testpmd.get_port_mac(0) > + > + self.vm0_testpmd.execute_cmd('set fwd mac') > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd('start') > + #Disable vlan insert which means insert vlan id as 0 > + rx_vlan =3D 0 > + self.dut_testpmd.execute_cmd('set vf vlan insert 0 0 %s' %rx_vla= n) > + time.sleep(1) > + vlans =3D self.send_and_vlancheck(self.vf0_mac) > + self.verify(rx_vlan not in vlans, > + "Failed to disable vlan insert!!!") > + > + #Enable vlan insert which means insert vlan id as 1~4095 > + random_vlan =3D random.randint(1, MAX_VLAN - 1) > + rx_vlans =3D [1, random_vlan, MAX_VLAN] > + for rx_vlan in rx_vlans: > + self.dut_testpmd.execute_cmd('set vf vlan insert 0 0 %s'%rx_= vlan) > + time.sleep(1) > + vlans =3D self.send_and_vlancheck(self.vf0_mac) > + self.verify(rx_vlan in vlans,"Failed to enable vlan=20 > + insert packet!!!") > + > + self.vm0_testpmd.quit() > + self.dut_testpmd.quit() > + > + > + def test_multicast_mode(self): > + self.dut_testpmd.start_testpmd("Default", "--port-topology=3Dcha= ined") > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK,=20 > + '--port-topology=3Dchained') > + > + self.vf0_mac =3D self.vm0_testpmd.get_port_mac(0) > + > + self.vm0_testpmd.execute_cmd('set fwd rxonly') > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd('start') > + self.dut_testpmd.execute_cmd('set vf promisc 0 0 off') > + self.dut_testpmd.execute_cmd('set vf allmulti 0 0 off') > + multi_mac =3D 'F3:00:33:22:11:00' > + out =3D self.send_and_pmdout(multi_mac) > + self.verify("received" not in out, > + "Failed to disable vf multicast mode!!!") > + > + out =3D self.send_and_pmdout(self.vf0_mac) > + self.verify("received" in out, "Failed to disable vf multicast m= ode!!!") > + self.verify("dst=3D%s" %self.vf0_mac in out, > + "Failed to disable vf multicast mode!!!") > + > + self.dut_testpmd.execute_cmd('set vf allmulti 0 0 on') > + out =3D self.send_and_pmdout(multi_mac) > + self.verify("received" in out, "Failed to enable vf multicast mo= de!!!") > + self.verify("dst=3D%s" %multi_mac in out, > + "Failed to enable vf multicast mode!!!") > + > + out =3D self.send_and_pmdout(self.vf0_mac) > + self.verify("received" in out, "Failed to enable vf multicast mo= de!!!") > + self.verify("dst=3D%s" %self.vf0_mac in out, > + "Failed to enable vf multicast mode!!!") > + > + self.vm0_testpmd.quit() > + self.dut_testpmd.quit() > + > + > + def test_promisc_mode(self): > + self.dut_testpmd.start_testpmd("Default", "--port-topology=3Dcha= ined") > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK,=20 > + '--port-topology=3Dchained') > + > + self.vf0_mac =3D self.vm0_testpmd.get_port_mac(0) > + > + self.vm0_testpmd.execute_cmd('set fwd rxonly') > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd('start') > + self.dut_testpmd.execute_cmd('set vf promisc 0 0 off') > + > + wrong_mac =3D '9E:AC:72:49:43:11' > + out =3D self.send_and_pmdout(wrong_mac) > + self.verify("received" not in out, > + "Failed to disable vf promisc mode!!!") > + > + out =3D self.send_and_pmdout(self.vf0_mac) > + self.verify("received" in out, "Failed to disable vf promisc mod= e!!!") > + self.verify("dst=3D%s" %self.vf0_mac in out, > + "Failed to disable vf promisc mode!!!") > + > + self.dut_testpmd.execute_cmd('set vf promisc 0 0 on') > + out =3D self.send_and_pmdout(wrong_mac) > + self.verify("received" in out, "Failed to enable vf promisc mode= !!!") > + self.verify("dst=3D%s" %wrong_mac in out, > + "Failed to enable vf promisc mode!!!") > + > + out =3D self.send_and_pmdout(self.vf0_mac) > + self.verify("received" in out, "Failed to enable vf promisc mode= !!!") > + self.verify("dst=3D%s" %self.vf0_mac in out, > + "Failed to enable vf promisc mode!!!") > + > + self.vm0_testpmd.quit() > + self.dut_testpmd.quit() > + > + > + def test_broadcast_mode(self): > + self.dut_testpmd.start_testpmd("Default", "--port-topology=3Dcha= ined") > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK,=20 > + '--port-topology=3Dchained') > + > + self.vf0_mac =3D self.vm0_testpmd.get_port_mac(0) > + > + self.vm0_testpmd.execute_cmd('set fwd rxonly') > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd('start') > + self.dut_testpmd.execute_cmd('set vf broadcast 0 0 off') > + > + dst_mac =3D 'FF:FF:FF:FF:FF:FF' > + out =3D self.send_and_pmdout(dst_mac) > + self.verify("received" not in out, > + "Failed to disable vf broadcast mode!!!") > + > + self.dut_testpmd.execute_cmd('set vf broadcast 0 0 on') > + out =3D self.send_and_pmdout(dst_mac) > + self.verify("received" in out, "Failed to enable vf broadcast mo= de!!!") > + self.verify("dst=3D%s" %dst_mac in out, > + "Failed to enable vf broadcast mode!!!") > + > + self.vm0_testpmd.quit() > + self.dut_testpmd.quit() > + > + > + def test_vf_mtu(self): > + self.dut.send_expect("ifconfig %s mtu 9000" %self.tester_intf, "= #") > + self.dut_testpmd.start_testpmd("Default", "--port-topology=3Dcha= ined") > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK,=20 > + '--port-topology=3Dchained') > + > + self.vf0_mac =3D self.vm0_testpmd.get_port_mac(0) > + > + self.vm0_testpmd.execute_cmd('set fwd mac') > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd('start') > + pktsize =3D random.randint(1500, 9000) > + out =3D self.send_and_maccheck(self.vf0_mac, 0, pktsize) > + self.vm0_testpmd.execute_cmd('stop') > + self.verify(self.vf0_mac.lower() not in out, > + "Failed to receive and forward this length packet!!!") > + > + self.vm0_testpmd.execute_cmd('port stop all') > + self.vm0_testpmd.execute_cmd('port config mtu 0 %s' %(pktsize+10= 0)) > + self.vm0_testpmd.execute_cmd('port start all') > + self.vm0_testpmd.execute_cmd('start') > + out =3D self.send_and_maccheck(self.vf0_mac, 0, pktsize) > + self.vm0_testpmd.execute_cmd('stop') > + self.verify(self.vf0_mac.lower() in out, > + "Failed to receive and forward this length packet!!!") > + > + self.vm0_testpmd.quit() > + self.dut_testpmd.quit() > + self.dut.send_expect("ifconfig %s mtu 1500"=20 > + %self.tester_intf, "#") > + > + > + def test_vlan_tag(self): > + self.dut_testpmd.start_testpmd("Default", "--port-topology=3Dcha= ined") > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK,=20 > + '--port-topology=3Dchained') > + > + self.vf0_mac =3D self.vm0_testpmd.get_port_mac(0) > + > + random_vlan =3D random.randint(1, MAX_VLAN - 1) > + rx_vlans =3D [1, random_vlan, MAX_VLAN] > + self.vm0_testpmd.execute_cmd('set fwd mac') > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd('start') > + for rx_vlan in rx_vlans: > + self.vm0_testpmd.execute_cmd('rx_vlan add %s 0' %rx_vlan) > + self.dut_testpmd.execute_cmd('set vf vlan tag 0 0 off') > + time.sleep(1) > + out =3D self.send_and_maccheck(self.vf0_mac, rx_vlan) > + self.verify(self.vf0_mac.lower() not in out, > + "Failed to disable vlan tag!!!") > + > + self.dut_testpmd.execute_cmd('set vf vlan tag 0 0 on') > + time.sleep(1) > + out =3D self.send_and_maccheck(self.vf0_mac, rx_vlan) > + self.verify(self.vf0_mac.lower() in out, > + "Failed to enable vlan tag!!!") > + > + self.vm0_testpmd.quit() > + self.dut_testpmd.quit() > + > + > + def test_tx_loopback(self): > + self.dut_testpmd.start_testpmd("Default", "--port-topology=3Dcha= ined") > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, '--port-topology= =3Dchained') > + self.vf0_mac =3D self.vm0_testpmd.get_port_mac(0) > + self.vm1_testpmd.start_testpmd(VM_CORES_MASK, > + '--port-topology=3Dchained --eth-peer=3D0,%s'=20 > + %self.vf0_mac) > + > + self.vm0_testpmd.execute_cmd('set fwd rxonly') > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd('start') > + self.dut_testpmd.execute_cmd('set tx loopback 0 off') > + > + inst =3D sniff_packets(self.tester_intf, timeout=3D5) > + > + self.vm1_testpmd.execute_cmd('set burst 5') > + self.vm1_testpmd.execute_cmd('start tx_first') > + > + dumpout =3D self.strip_mac(inst, "dst") > + out =3D self.vm0_testpmd.execute_cmd('stop') > + self.verify(self.vf0_mac.lower() in dumpout, > + "Failed to disable tx loopback!!!") > + self.verify("RX-packets: 0" in out, > + "Failed to disable tx loopback!!!") > + > + self.vm0_testpmd.execute_cmd('start') > + self.dut_testpmd.execute_cmd('set tx loopback 0 on') > + > + inst =3D sniff_packets(self.tester_intf, timeout=3D5) > + > + self.vm1_testpmd.execute_cmd('stop') > + self.vm1_testpmd.execute_cmd('start tx_first') > + dumpout =3D self.strip_mac(inst, "dst") > + out =3D self.vm0_testpmd.execute_cmd('stop') > + self.verify(self.vf0_mac.lower() not in dumpout, > + "Failed to enable tx loopback!!!") > + self.verify("RX-packets: 5" in out, "Failed to enable tx=20 > + loopback!!!") > + > + self.vm0_testpmd.quit() > + self.vm1_testpmd.quit() > + self.dut_testpmd.quit() > + > + > + def test_all_queues_drop(self): > + self.dut_testpmd.start_testpmd("Default", "--port-topology=3Dcha= ined") > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, '--port-topology= =3Dchained') > + self.vm1_testpmd.start_testpmd(VM_CORES_MASK,=20 > + '--port-topology=3Dchained') > + > + self.vm0_testpmd.execute_cmd('set fwd rxonly') > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd('start') > + self.dut_testpmd.execute_cmd('set all queues drop 0 off') > + self.vf0_mac =3D self.vm0_testpmd.get_port_mac(0) > + self.vf1_mac =3D self.vm1_testpmd.get_port_mac(0) > + out =3D self.send_and_pmdout(self.vf1_mac, 0, 64, 200) > + out =3D self.vm1_testpmd.execute_cmd('show port stats 0') > + self.verify("RX-packets: 127" in out, > + "Failed to let vf1 full of queues!!!") > + out =3D self.send_and_pmdout(self.vf0_mac, 0, 64, 20) > + out =3D self.vm0_testpmd.execute_cmd('show port stats 0') > + self.verify("RX-packets: 0" in out, > + "Failed to disable all queues drop!!!") > + self.dut_testpmd.execute_cmd('set all queues drop 0 on') > + out =3D self.vm0_testpmd.execute_cmd('show port stats 0') > + self.verify("RX-packets: 20" in out, > + "Failed to enable all queues drop!!!") > + out =3D self.send_and_pmdout(self.vf0_mac, 0, 64, 20) > + out =3D self.vm0_testpmd.execute_cmd('show port stats 0') > + self.verify("RX-packets: 40" in out, > + "Failed to enable all queues drop!!!") > + > + self.vm0_testpmd.quit() > + self.vm1_testpmd.quit() > + self.dut_testpmd.quit() > + > + > + def test_mac_antispoof(self): > + fake_mac =3D '00:11:22:33:44:55' > + self.vm0_dut.send_expect("sed -i -e '/uint64_t ol_flags =3D 0;/a= " +\ > + "\struct ether_addr fake_mac =3D {.addr_bytes =3D {0x00, 0x1= 1, 0x22, 0x33, 0x44, 0x55},};'" +\ > + " app/test-pmd/macswap.c", "# ", 30) > + self.vm0_dut.send_expect("sed -i -e '/ether_addr_copy(&addr, &et= h_hdr->s_addr);/d' " +\ > + " app/test-pmd/macswap.c", "# ", 30) > + self.vm0_dut.send_expect("sed -i -e '/ether_addr_copy(ð_hdr->= s_addr, ð_hdr->d_addr);/a " +\ > + "\ether_addr_copy(&fake_mac, ð_hdr->s_addr);' app/test-pm= d/macswap.c", "# ", 30) > + self.vm0_dut.build_install_dpdk(self.target) > + self.dut_testpmd.start_testpmd("Default", "--port-topology=3Dcha= ined") > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, '--port-topology= =3Dchained') > + self.vf0_mac =3D self.vm0_testpmd.get_port_mac(0) > + > + self.vm0_testpmd.execute_cmd('set fwd macswap') > + self.dut_testpmd.execute_cmd('set vf mac antispoof 0 0 off') > + self.vm0_testpmd.execute_cmd('start') > + dumpout =3D self.send_and_maccheck(self.vf0_mac) > + out =3D self.vm0_testpmd.execute_cmd('stop') > + self.verify(fake_mac in dumpout, > + "Failed to disable vf mac anspoof!!!") > + self.verify("RX-packets: 1" in out, "Failed to receive packet!!!= ") > + self.verify("TX-packets: 1" in out, > + "Failed to disable mac antispoof!!!") > + > + self.dut_testpmd.execute_cmd('set vf mac antispoof 0 0 on') > + out =3D self.vm0_testpmd.execute_cmd('start') > + dumpout =3D self.send_and_maccheck(self.vf0_mac) > + out =3D self.vm0_testpmd.execute_cmd('stop') > + self.verify(fake_mac not in dumpout, "Failed to enable vf mac an= spoof!!!") > + self.verify("RX-packets: 1" in out, "Failed to receive packet!!!= ") > + self.verify("TX-packets: 0" in out, "Failed to enable mac=20 > + antispoof!!!") > + > + self.vm0_testpmd.quit() > + self.dut_testpmd.quit() > + self.vm0_dut.send_expect("sed -i '/struct ether_addr fake_mac = =3D {.addr_bytes =3D " +\ > + "{0x00, 0x11, 0x22, 0x33, 0x44, 0x55},};/d' app/test-pmd/mac= swap.c", "# ", 30) > + self.vm0_dut.send_expect("sed -i '/ether_addr_copy(&fake_mac, &e= th_hdr->s_addr);/d' " +\ > + "app/test-pmd/macswap.c", "# ", 30) > + self.vm0_dut.send_expect("sed -i '/ether_addr_copy(ð_hdr->s_a= ddr, ð_hdr->d_addr);/a " +\ > + "\ether_addr_copy(&addr, ð_hdr->s_addr);' app/test-pmd/ma= cswap.c", "# ", 30) > + self.vm0_dut.build_install_dpdk(self.target) > + > + > + def test_vf_mac_set(self): > + expect_mac =3D 'A2:22:33:44:55:66' > + self.dut_testpmd.start_testpmd("Default", "--port-topology=3Dcha= ined") > + self.dut_testpmd.execute_cmd('set vf mac addr 0 0 %s' %expect_ma= c) > + out =3D self.vm0_testpmd.start_testpmd( > + VM_CORES_MASK, '--port-topology=3Dchained') > + self.verify("%s" %expect_mac in out, "Failed to set vf mac!!!") > + self.vf0_mac =3D self.vm0_testpmd.get_port_mac(0) > + > + self.vm0_testpmd.execute_cmd('set fwd mac') > + self.vm0_testpmd.execute_cmd('start') > + out =3D self.send_and_maccheck(self.vf0_mac) > + self.verify(expect_mac.lower() in out, > + "Failed to receive packet on setted vf mac!!!") > + > + self.vm0_testpmd.quit() > + self.dut_testpmd.quit() > + > + > + def test_vlan_antispoof(self): > + > + self.dut_testpmd.start_testpmd("Default", "--port-topology=3Dcha= ined") > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK,=20 > + '--port-topology=3Dchained') > + > + self.vf0_mac =3D self.vm0_testpmd.get_port_mac(0) > + vf0_mac_lower =3D self.vf0_mac.lower() > + random_vlan =3D random.randint(1, MAX_VLAN) > + match_vlan =3D random_vlan > + unmatch_vlan =3D (random_vlan + 2) % 4096 > + self.vm0_testpmd.execute_cmd('set fwd mac') > + self.vm0_testpmd.execute_cmd('start') > + self.dut_testpmd.execute_cmd('rx_vlan add %d port 0 vf 1' %match= _vlan) > + if self.kdriver =3D=3D "i40e": > + self.dut_testpmd.execute_cmd('set vf vlan stripq 0 0 off') > + else: > + self.dut_testpmd.execute_cmd('vlan set filter off 0') > + self.dut_testpmd.execute_cmd('vlan set strip off 0') > + self.vm0_testpmd.execute_cmd('vlan set strip off 0') > + > + self.dut_testpmd.execute_cmd('set vf vlan antispoof 0 0 off') > + time.sleep(1) > + out =3D self.send_and_maccheck(self.vf0_mac,match_vlan) > + self.verify(vf0_mac_lower in out, > + "Failed to disable vlan antispoof with match vlan!!!") > + out =3D self.send_and_maccheck(self.vf0_mac,unmatch_vlan) > + self.verify(vf0_mac_lower in out, > + "Failed to disable vlan antispoof with unmatch vlan!!!") > + out =3D self.send_and_maccheck(self.vf0_mac) > + self.verify(vf0_mac_lower in out, > + "Failed to disable vlan antispoof with no vlan!!!") > + > + if self.kdriver =3D=3D "ixgbe": > + self.dut_testpmd.execute_cmd('set vf mac antispoof 0 0 on') > + self.dut_testpmd.execute_cmd('set vf vlan antispoof 0 0 on') > + time.sleep(1) > + > + out =3D self.send_and_maccheck(self.vf0_mac,match_vlan) > + self.verify(vf0_mac_lower in out, > + "Failed to enable vlan antispoof with match vlan!!!") > + > + out =3D self.send_and_maccheck(self.vf0_mac,unmatch_vlan) > + self.verify(vf0_mac_lower not in out, > + "Failed to enable vlan antispoof with unmatch vlan!!!") > + > + out =3D self.send_and_maccheck(self.vf0_mac) > + self.verify(vf0_mac_lower not in out, > + "Failed to enable vlan antispoof with no vlan!!!") > + > + self.vm0_testpmd.quit() > + self.dut_testpmd.quit() > + > + > + def test_vlan_strip(self): > + self.dut_testpmd.start_testpmd("Default", "--port-topology=3Dcha= ined") > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK,=20 > + '--port-topology=3Dchained') > + > + self.vf0_mac =3D self.vm0_testpmd.get_port_mac(0) > + > + random_vlan =3D random.randint(1, MAX_VLAN - 1) > + rx_vlans =3D [1, random_vlan, MAX_VLAN] > + self.vm0_testpmd.execute_cmd('set fwd mac') > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd('start') > + for rx_vlan in rx_vlans: > + self.vm0_testpmd.execute_cmd('rx_vlan add %s 0' %rx_vlan) > + self.dut_testpmd.execute_cmd('set vf vlan stripq 0 0 off') > + time.sleep(1) > + out =3D self.send_and_vlancheck(self.vf0_mac,rx_vlan) > + self.verify(rx_vlan in out, "Failed to disable strip=20 > + vlan!!!") > + > + self.dut_testpmd.execute_cmd('set vf vlan stripq 0 0 on') > + time.sleep(1) > + out =3D self.send_and_vlancheck(self.vf0_mac,rx_vlan) > + self.verify(rx_vlan not in out, "Failed to disable strip=20 > + vlan!!!") > + > + self.vm0_testpmd.quit() > + self.dut_testpmd.quit() > + > + > + def tear_down(self): > + self.vm0_dut.kill_all() > + self.vm1_dut.kill_all() > + pass > + > + > + def tear_down_all(self): > + self.destroy_vm_env() > + pass