From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 15C57A046B for ; Tue, 25 Jun 2019 11:14:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C968F1B9F3; Tue, 25 Jun 2019 11:14:34 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 299005F11 for ; Tue, 25 Jun 2019 11:14:32 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jun 2019 02:14:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,415,1557212400"; d="scan'208";a="172293108" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga002.jf.intel.com with ESMTP; 25 Jun 2019 02:14:31 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 25 Jun 2019 02:14:31 -0700 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 25 Jun 2019 02:14:30 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.185]) by SHSMSX154.ccr.corp.intel.com ([169.254.7.156]) with mapi id 14.03.0439.000; Tue, 25 Jun 2019 17:14:28 +0800 From: "Lin, Xueqin" To: "Zhao, MeijuanX" , "dts@dpdk.org" Thread-Topic: [dts][PATCH V1] tests/kernelpf_iavf: add new test suite kernelpf iavf Thread-Index: AQHVKzVB+ALH4ogL70+CN2f+/6kPFaasFjWg Date: Tue, 25 Jun 2019 09:14:28 +0000 Message-ID: <0D300480287911409D9FF92C1FA2A3355B51CF32@SHSMSX104.ccr.corp.intel.com> References: <20190625170645.88676-1-meijuanx.zhao@intel.com> In-Reply-To: <20190625170645.88676-1-meijuanx.zhao@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 V1] tests/kernelpf_iavf: add new test suite kernelpf iavf 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: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Acked-by: Lin Xueqin > -----Original Message----- > From: Zhao, MeijuanX > Sent: Wednesday, June 26, 2019 1:07 AM > To: dts@dpdk.org > Cc: Lin, Xueqin ; Zhao, MeijuanX > > Subject: [dts][PATCH V1] tests/kernelpf_iavf: add new test suite kernelpf= iavf >=20 > Signed-off-by: zhaomeijuan > --- > tests/TestSuite_kernelpf_iavf.py | 873 > +++++++++++++++++++++++++++++++ > 1 file changed, 873 insertions(+) > create mode 100644 tests/TestSuite_kernelpf_iavf.py >=20 > diff --git a/tests/TestSuite_kernelpf_iavf.py > b/tests/TestSuite_kernelpf_iavf.py > new file mode 100644 > index 0000000..2dcd717 > --- /dev/null > +++ b/tests/TestSuite_kernelpf_iavf.py > @@ -0,0 +1,873 @@ > +# BSD LICENSE > +# > +# Copyright(c) <2019> Intel Corporation. All rights reserved. > +# All rights reserved. > +# > +# Redistribution and use in source and binary forms, with or without # > +modification, are permitted provided that the following conditions # > +are met: > +# > +# * Redistributions of source code must retain the above copyright > +# notice, this list of conditions and the following disclaimer. > +# * Redistributions in binary form must reproduce the above copyright > +# notice, this list of conditions and the following disclaimer in > +# the documentation and/or other materials provided with the > +# distribution. > +# * Neither the name of Intel Corporation nor the names of its > +# contributors may be used to endorse or promote products derived > +# from this software without specific prior written permission. > +# > +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND > CONTRIBUTORS # > +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT > # > +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND > FITNESS FOR # > +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE > COPYRIGHT # > +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > INCIDENTAL, # > +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > NOT # > +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF > USE, # > +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND > ON ANY # > +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT > # > +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF > THE USE # > +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > DAMAGE. > + > + > +""" > +DPDK Test suite. > + > +Test some vf function in ice driver > + > +""" > + > +import re > +import time > +import random > +import utils > +from virt_common import VM > +from test_case import TestCase > +from pmd_output import PmdOutput > +from settings import HEADER_SIZE > +from packet import Packet > +from utils import RED > + > +VM_CORES_MASK =3D 'all' > +MAX_VLAN =3D 4095 > +ETHER_STANDARD_MTU =3D 1518 > +ETHER_JUMBO_FRAME_MTU =3D 9000 > + > + > +class TestKernelpfIavf(TestCase): > + > + supported_vf_driver =3D ['pci-stub', 'vfio-pci'] > + > + def set_up_all(self): > + self.dut_ports =3D self.dut.get_ports(self.nic) > + self.verify(len(self.dut_ports) >=3D 2, "Insufficient ports") > + self.vm0 =3D None > + self.env_done =3D False > + self.interrupt_flag =3D False > + self.vf_mac =3D '00:01:23:45:67:89' > + self.add_addr =3D '00:11:22:33:44:55' > + self.wrong_mac =3D '00:11:22:33:44:99' > + > + self.port =3D self.dut_ports[0] > + self.vm_port =3D 0 > + cores =3D self.dut.get_core_list("1S/1C/1T") > + self.port_mask =3D utils.create_mask([self.port]) > + > + # set vf assign method and vf driver > + self.dut.send_expect('modprobe vfio-pci', '#') > + self.vf_driver =3D self.get_suite_cfg()['vf_driver'] > + if self.vf_driver is None: > + self.vf_driver =3D 'pci-stub' > + self.verify(self.vf_driver in self.supported_vf_driver, "Unsppor= ted vf > driver") > + if self.vf_driver =3D=3D 'pci-stub': > + self.vf_assign_method =3D 'pci-assign' > + else: > + self.vf_assign_method =3D 'vfio-pci' > + self.dut.send_expect('modprobe vfio-pci', '#') > + self.used_dut_port =3D self.dut_ports[0] > + self.host_intf =3D self.dut.ports_info[self.used_dut_port]['intf= '] > + tester_port =3D self.tester.get_local_port(self.used_dut_port) > + self.tester_intf =3D self.tester.get_interface(tester_port) > + self.tester_mac =3D self.tester.get_mac(tester_port) > + > + tester_port1 =3D self.tester.get_local_port(self.dut_ports[1]) > + self.tester_intf1 =3D self.tester.get_interface(tester_port1) > + > + def set_up(self): > + > + if self.running_case =3D=3D "test_vf_mac_filter": > + self.destroy_vm_env() > + if self.env_done is False: > + self.setup_vm_env(driver=3D'', set_vf_mac=3DFalse) > + elif self.running_case =3D=3D "test_vf_rx_interrupt": > + self.destroy_vm_env() > + elif self.env_done is False: > + 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 is None: > + driver =3D netdev.default_driver > + if driver !=3D driver_now: > + netdev.bind_driver(driver=3Ddriver) > + > + def setup_vm_env(self, driver=3D'default', set_vf_mac=3DTrue): > + """ > + Create testing environment with 1VF generated from 1PF > + """ > + if self.env_done: > + return > + > + # bind to default driver > + self.bind_nic_driver(self.dut_ports, driver=3D"") > + self.used_dut_port =3D self.dut_ports[0] > + self.dut.generate_sriov_vfs_by_port( > + self.used_dut_port, 1, driver=3Ddriver) > + self.sriov_vfs_port =3D self.dut.ports_info[ > + self.used_dut_port]['vfs_port'] > + out =3D self.dut.send_expect('ethtool %s' % self.host_intf, '#') > + self.speed =3D re.findall('Supported link modes: (\d*)', out)[= 0] > + if set_vf_mac is True: > + self.vf_mac =3D "00:01:23:45:67:89" > + self.dut.send_expect("ip link set %s vf 0 mac %s" % > + (self.host_intf, self.vf_mac), "# ") > + > + try: > + > + for port in self.sriov_vfs_port: > + port.bind_driver(self.vf_driver) > + > + time.sleep(1) > + vf_popt =3D {'opt_host': self.sriov_vfs_port[0].pci} > + > + # set up VM ENV > + self.vm =3D VM(self.dut, 'vm0', 'kernelpf_iavf') > + self.vm.set_vm_device(driver=3Dself.vf_assign_method, **vf_p= opt) > + self.vm_dut =3D self.vm.start() > + if self.vm_dut is None: > + raise Exception("Set up VM ENV failed!") > + > + self.vm_testpmd =3D PmdOutput(self.vm_dut) > + except Exception as e: > + self.destroy_vm_env() > + raise Exception(e) > + > + self.env_done =3D True > + > + def destroy_vm_env(self): > + if getattr(self, 'vm', None): > + if getattr(self, 'vm_dut', None): > + self.vm_dut.kill_all() > + self.vm_testpmd =3D None > + self.vm_dut_ports =3D None > + # destroy vm0 > + self.vm.stop() > + self.dut.virt_exit() > + time.sleep(3) > + self.vm =3D None > + > + if getattr(self, 'used_dut_port', None) is not None: > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port) > + self.used_dut_port =3D None > + > + self.bind_nic_driver(self.dut_ports, driver=3D'default') > + > + self.env_done =3D False > + > + def jumboframes_get_stat(self, portid, rx_tx): > + """ > + Get packets number from port statistic > + """ > + stats =3D self.vm_testpmd.get_pmd_stats(portid) > + if rx_tx =3D=3D "rx": > + return [stats['RX-packets'], stats['RX-errors'], stats['RX-b= ytes']] > + elif rx_tx =3D=3D "tx": > + return [stats['TX-packets'], stats['TX-errors'], stats['TX-b= ytes']] > + else: > + return None > + > + def send_random_pkt(self, dts, count=3D1): > + tgen_ports =3D [] > + tx_port =3D self.tester.get_local_port(self.dut_ports[0]) > + rx_port =3D self.tester.get_local_port(self.dut_ports[1]) > + tgen_ports.append((tx_port, rx_port)) > + src_mac =3D self.tester.get_mac(tx_port) > + dst_mac =3D dts > + pkt_param =3D [("ether", {'dst': dst_mac, 'src': src_mac})] > + result =3D self.tester.check_random_pkts(tgen_ports, pktnum=3Dco= unt, > allow_miss=3DFalse, params=3Dpkt_param) > + return result > + > + def test_vf_basic_rxtx(self): > + ''' > + Set rxonly forward,Send 100 random packets from tester, check pa= ckets > can be received > + ''' > + self.vm_testpmd.start_testpmd("all") > + self.vm_testpmd.execute_cmd("set fwd rxonly") > + self.vm_testpmd.execute_cmd("set verbose 1") > + self.vm_testpmd.execute_cmd("start") > + self.send_random_pkt(self.vf_mac, count=3D100) > + time.sleep(1) > + out =3D self.vm_dut.get_session_output() > + self.verify(self.vf_mac in out, "vf receive packet fail") > + stats =3D self.vm_testpmd.get_pmd_stats(0) > + self.verify(stats['RX-packets'] =3D=3D 100, 'vf receive packet n= um is not > match') > + ''' > + Set txonly forward,check packets can be received by tester > + ''' > + self.vm_testpmd.execute_cmd("stop") > + self.vm_testpmd.execute_cmd("set fwd txonly") > + self.tester.send_expect('rm -f tcpdump.pcap', '#') > + self.tester.send_expect("tcpdump -i %s 2>tcpdump.out &" % > self.tester_intf, "#") > + self.vm_testpmd.execute_cmd("start") > + time.sleep(1) > + self.vm_testpmd.execute_cmd("stop") > + self.tester.send_expect('killall tcpdump', '#') > + time.sleep(1) > + cap_packet =3D self.tester.send_expect('cat tcpdump.out', '#', 3= 0) > + stats =3D self.vm_testpmd.get_pmd_stats(0) > + cap_tcp_num =3D re.findall('(\d+) packets', cap_packet) > + self.verify(stats['TX-packets'] <=3D int(cap_tcp_num[1]), 'vf > + send packet num is not match') > + > + def test_vf_mac_filter(self): > + """ > + Not set VF MAC from kernel PF for this case, if set, will print > + "not permitted error" when add new MAC for VF. > + """ > + out =3D self.vm_testpmd.start_testpmd("all") > + self.testpmd_mac =3D self.get_testpmd_vf_mac(out) > + self.vm_testpmd.execute_cmd("set fwd mac") > + self.vm_testpmd.execute_cmd("set promisc all off") > + self.vm_testpmd.execute_cmd("mac_addr add 0 %s" % self.add_addr) > + self.vm_testpmd.execute_cmd("start") > + # send packet with current mac > + self.send_random_pkt(self.testpmd_mac, count=3D100) > + self.verify_packet_count(100) > + self.vm_testpmd.execute_cmd('clear port stats all') > + # send packet with add mac > + self.send_random_pkt(self.add_addr, count=3D100) > + self.verify_packet_count(100) > + self.vm_testpmd.execute_cmd('clear port stats all') > + # send packet with wrong mac > + self.send_random_pkt(self.wrong_mac, count=3D100) > + self.verify_packet_count(0) > + > + def get_testpmd_vf_mac(self, out): > + result =3D re.search("([a-f0-9]{2}:){5}[a-f0-9]{2}", out, re.IGN= ORECASE) > + mac =3D result.group() > + return mac > + > + def verify_packet_count(self, count): > + > + pmd0_vf0_stats =3D self.vm_testpmd.get_pmd_stats(0) > + vf0_rx_cnt =3D pmd0_vf0_stats['RX-packets'] > + vf0_tx_cnt =3D pmd0_vf0_stats['TX-packets'] > + self.verify(vf0_rx_cnt =3D=3D vf0_tx_cnt =3D=3D count, "vf recei= ve > + packet count not match!") > + > + def test_vf_promisc_mode(self): > + """ > + Enable kernel trust mode > + """ > + self.dut.send_expect("ip link set dev %s vf 0 trust on" % self.h= ost_intf, > "# ") > + self.vm_testpmd.start_testpmd("all") > + self.vm_testpmd.execute_cmd("set fwd mac") > + self.vm_testpmd.execute_cmd("set verbose 1") > + self.vm_testpmd.execute_cmd("start") > + # send packet with current mac, vf can receive and forward packe= t > + self.send_random_pkt(self.vf_mac, count=3D1) > + out =3D self.vm_dut.get_session_output() > + self.verify(self.vf_mac in out, 'vf receive pkt fail with curren= t mac') > + # send packet with wrong mac, vf can receive and forward packet > + self.send_random_pkt(self.wrong_mac, count=3D1) > + out =3D self.vm_dut.get_session_output() > + self.verify(self.wrong_mac in out, 'vf receive pkt fail with > + wrong mac') > + > + self.vm_testpmd.execute_cmd("set promisc all off") > + # send packet with current mac, vf can receive and forward packe= t > + self.send_random_pkt(self.vf_mac, count=3D1) > + out =3D self.vm_dut.get_session_output() > + self.verify(self.vf_mac in out, 'vf receive pkt fail with curren= t mac') > + # send packet with wrong mac, vf can not receive and forward pac= ket > + self.send_random_pkt(self.wrong_mac, count=3D1) > + out =3D self.vm_dut.get_session_output() > + self.verify(self.wrong_mac not in out, 'vf receive pkt with > + wrong mac') > + > + self.vm_testpmd.execute_cmd("set promisc all on") > + # send packet with current mac, vf can receive and forward packe= t > + self.send_random_pkt(self.vf_mac, count=3D1) > + out =3D self.vm_dut.get_session_output() > + self.verify(self.vf_mac in out, 'vf receive pkt fail with curren= t mac') > + # send packet with wrong mac, vf can receive and forward packet > + self.send_random_pkt(self.wrong_mac, count=3D1) > + out =3D self.vm_dut.get_session_output() > + self.verify(self.wrong_mac in out, 'vf receive pkt fail with > + wrong mac') > + > + self.dut.send_expect("ip link set dev %s vf 0 trust off" % > + self.host_intf, "# ") > + > + def test_vf_multicast(self): > + """ > + enable kernel trust mode > + """ > + multicast_mac =3D '01:80:C2:00:00:08' > + self.dut.send_expect("ip link set dev %s vf 0 trust on" % self.h= ost_intf, > "# ") > + self.vm_testpmd.start_testpmd("all") > + self.vm_testpmd.execute_cmd("set fwd mac") > + self.vm_testpmd.execute_cmd("set promisc all off") > + self.vm_testpmd.execute_cmd("set allmulti all off") > + self.vm_testpmd.execute_cmd("set verbose 1") > + self.vm_testpmd.execute_cmd("start") > + self.send_random_pkt(self.vf_mac, count=3D1) > + out =3D self.vm_dut.get_session_output() > + self.verify(self.vf_mac in out, 'vf receive pkt fail with curren= t mac') > + self.send_random_pkt(multicast_mac, count=3D1) > + out =3D self.vm_dut.get_session_output() > + self.verify(multicast_mac not in out, 'vf receive pkt with > + multicast mac') > + > + self.vm_testpmd.execute_cmd("set allmulti all on") > + self.send_random_pkt(self.vf_mac, count=3D1) > + out =3D self.vm_dut.get_session_output() > + self.verify(self.vf_mac in out, 'vf receive pkt fail with curren= t mac') > + self.send_random_pkt(multicast_mac, count=3D1) > + out =3D self.vm_dut.get_session_output() > + self.verify(multicast_mac in out, 'vf receive pkt fail with mult= icast mac') > + self.dut.send_expect("ip link set dev %s vf 0 trust off" % > + self.host_intf, "# ") > + > + def test_vf_broadcast(self): > + """ > + """ > + broadcast_mac =3D 'ff:ff:ff:ff:ff:ff' > + self.vm_testpmd.start_testpmd("all") > + self.vm_testpmd.execute_cmd("set fwd mac") > + self.vm_testpmd.execute_cmd("set promisc all off") > + self.vm_testpmd.execute_cmd("set verbose 1") > + self.vm_testpmd.execute_cmd("start") > + self.send_random_pkt(broadcast_mac, count=3D1) > + time.sleep(1) > + out =3D self.vm_dut.get_session_output() > + print out > + self.verify(broadcast_mac.upper() in out and > + self.tester_mac.upper() in out, 'vf receive pkt fail with broadcast > + mac') > + > + def test_vf_add_pvid(self): > + ''' > + vf can receive packet with right vlan id, can't receive wrong vl= an id > packet > + ''' > + random_vlan =3D random.randint(1, MAX_VLAN) > + self.dut.send_expect("ip link set %s vf 0 vlan %s" % (self.host_= intf, > random_vlan), "# ") > + out =3D self.dut.send_expect("ip link show %s" % self.host_intf,= "# ") > + self.verify("vlan %d" % random_vlan in out, "Failed to add pvid > + on VF0") > + > + self.vm_testpmd.start_testpmd("all") > + self.vm_testpmd.execute_cmd("set fwd mac") > + self.vm_testpmd.execute_cmd("set verbose 1") > + self.vm_testpmd.execute_cmd("start") > + out =3D self.send_and_getout(vlan=3Drandom_vlan, pkt_type=3D"VLA= N_UDP") > + self.verify("VLAN tci=3D%s" % hex(random_vlan) in out and self.v= f_mac in > out, "Failed to received vlan packet!!!") > + wrong_vlan =3D (random_vlan + 1) % 4096 > + out =3D self.send_and_getout(vlan=3Dwrong_vlan, pkt_type=3D"VLAN= _UDP") > + self.verify("VLAN tci=3D%s" % hex(wrong_vlan) not in out and > + self.vf_mac not in out, "received wrong vlan packet!!!") > + > + # remove vlan > + self.dut.send_expect("ip link set %s vf 0 vlan 0" % self.host_in= tf, "# ") > + out =3D self.dut.send_expect("ip link show %s" % self.host_intf,= "# ") > + self.verify("vlan %d" % random_vlan not in out, "Failed to remov= e pvid > on VF0") > + # send packet without vlan > + out =3D self.send_and_getout(vlan=3D0, pkt_type=3D"UDP") > + self.verify(self.vf_mac in out and "VLAN tci=3D0x0" in out, "Not > + received packet without vlan!!!") > + > + # send packet with vlan 0 > + out =3D self.send_and_getout(vlan=3D0, pkt_type=3D"VLAN_UDP") > + self.verify( > + self.vf_mac in out and "VLAN tci=3D0x0" in out, "Not recevie= d > + packet with vlan 0!!!") > + > + # send random vlan packet > + out =3D self.send_and_getout(vlan=3Drandom_vlan, pkt_type=3D"VLA= N_UDP") > + self.verify(self.vf_mac not in out and "VLAN tci=3D%s" % > + hex(random_vlan) not in out, "Failed to received vlan packet!!!") > + > + 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.vf_mac}) > + elif pkt_type =3D=3D "VLAN_UDP": > + pkt =3D Packet(pkt_type=3D'VLAN_UDP') > + pkt.config_layer('vlan', {'vlan': vlan}) > + pkt.config_layer('ether', {'dst': self.vf_mac}) > + > + pkt.send_pkt(tx_port=3Dself.tester_intf) > + out =3D self.vm_dut.get_session_output(timeout=3D2) > + > + return out > + > + def test_vf_vlan_rx(self): > + self.vm_testpmd.start_testpmd("all") > + self.vm_testpmd.execute_cmd("set fwd rxonly") > + self.vm_testpmd.execute_cmd("set verbose 1") > + self.vm_testpmd.execute_cmd("vlan set filter on 0") > + self.vm_testpmd.execute_cmd("vlan set strip on 0") > + self.vm_testpmd.execute_cmd("start") > + # send packet without vlan, vf can receive packet > + out =3D self.send_and_getout(pkt_type=3D"UDP") > + self.verify(self.vf_mac in out, "Failed to received without > + vlan packet!!!") > + > + # send packet vlan 0, vf can receive packet > + out =3D self.send_and_getout(vlan=3D0, pkt_type=3D"VLAN_UDP") > + self.verify(self.vf_mac in out, "Failed to received vlan 0 > + packet!!!") > + > + self.vm_testpmd.execute_cmd("rx_vlan add 1 0") > + > + # send packet vlan 1, vf can receive packet > + out =3D self.send_and_getout(vlan=3D1, pkt_type=3D"VLAN_UDP") > + self.verify("VLAN tci=3D%s" % hex(1) in out and self.vf_mac in > + out, "Failed to received vlan 1 packet!!!") > + > + # send random vlan packet, vf can not receive packet > + random_vlan =3D random.randint(1, MAX_VLAN) > + out =3D self.send_and_getout(vlan=3Drandom_vlan, pkt_type=3D"VLA= N_UDP") > + self.verify("VLAN tci=3D%s" % hex(random_vlan) not in out and > + self.vf_mac not in out, "received random vlan packet!!!") > + > + # send max vlan 4095, vf can not receive packet > + out =3D self.send_and_getout(vlan=3DMAX_VLAN, pkt_type=3D"VLAN_U= DP") > + self.verify("VLAN tci=3D%s" % hex(MAX_VLAN) not in out and > + self.vf_mac not in out, "received max vlan packet!!!") > + > + # remove vlan > + self.vm_testpmd.execute_cmd("rx_vlan rm 1 0") > + > + # send packet without vlan, vf can receive packet > + out =3D self.send_and_getout(pkt_type=3D"UDP") > + self.verify(self.vf_mac in out, "Failed to received without > + vlan packet!!!") > + > + # send packet vlan 0, vf can receive packet > + out =3D self.send_and_getout(vlan=3D0, pkt_type=3D"VLAN_UDP") > + self.verify(self.vf_mac in out, "Failed to received vlan 0 > + packet!!!") > + > + # send vlan 1 packet, vf can not receive packet > + out =3D self.send_and_getout(vlan=3D1, pkt_type=3D"VLAN_UDP") > + self.verify(self.vf_mac not in out, "received vlan 1 > + packet!!!") > + > + def test_vf_vlan_insertion(self): > + self.vm_testpmd.start_testpmd("all") > + random_vlan =3D random.randint(1, MAX_VLAN) > + self.vm_testpmd.execute_cmd("vlan set strip off 0") > + self.vm_testpmd.execute_cmd("port stop all") > + self.vm_testpmd.execute_cmd("tx_vlan set 0 %s" % random_vlan) > + self.vm_testpmd.execute_cmd("port start all") > + self.vm_testpmd.execute_cmd("set fwd mac") > + self.vm_testpmd.execute_cmd("set verbose 1") > + self.vm_testpmd.execute_cmd("start") > + > + out =3D self.send_and_getout(pkt_type=3D"UDP") > + print out > + time.sleep(1) > + vlan_hex =3D hex(random_vlan) > + self.verify("VLAN tci=3D%s" % vlan_hex in out, 'add vlan tag fai= l > + !!') > + > + def test_vf_vlan_strip(self): > + random_vlan =3D random.randint(1, MAX_VLAN) > + self.vm_testpmd.start_testpmd("all") > + self.vm_testpmd.execute_cmd("vlan set strip on 0") > + self.vm_testpmd.execute_cmd("set fwd mac") > + self.vm_testpmd.execute_cmd("set verbose 1") > + self.vm_testpmd.execute_cmd("start") > + out =3D self.send_and_getout(vlan=3Drandom_vlan, pkt_type=3D"VLA= N_UDP") > + self.verify('VLAN tci=3D' not in out and self.vf_mac not in out, > + 'vlan tag in out') > + > + # disable strip > + self.vm_testpmd.execute_cmd("vlan set strip off 0") > + out =3D self.send_and_getout(vlan=3Drandom_vlan, pkt_type=3D"VLA= N_UDP") > + vlan_hex =3D hex(random_vlan) > + self.verify("VLAN tci=3D%s" % vlan_hex in out, 'vlan tag not in > + out') > + > + def test_vf_without_jumboframe(self): > + self.tester.send_expect('ifconfig %s mtu %s' % > + (self.tester_intf, ETHER_JUMBO_FRAME_MTU), '#') > + > + self.vm_testpmd.start_testpmd("all") > + self.vm_testpmd.execute_cmd("set fwd mac") > + self.vm_testpmd.execute_cmd("set promisc all off") > + self.vm_testpmd.execute_cmd("start") > + self.jumboframes_send_packet(ETHER_STANDARD_MTU - 1, True) > + self.jumboframes_send_packet(ETHER_STANDARD_MTU + 1, False) > + self.tester.send_expect("ifconfig %s mtu %s" % > + (self.tester_intf, ETHER_STANDARD_MTU)) > + > + def test_vf_with_jumboframe(self): > + self.tester.send_expect('ifconfig %s mtu %d' % (self.tester_intf= , > ETHER_JUMBO_FRAME_MTU), '#') > + conf_pkt_len =3D 3000 > + self.vm_testpmd.start_testpmd("all", "--max-pkt-len=3D%d" % > conf_pkt_len) > + self.jumboframes_send_packet(conf_pkt_len - 1, True) > + self.jumboframes_send_packet(conf_pkt_len + 1, False) > + self.tester.send_expect("ifconfig %s mtu %d" % > + (self.tester_intf, ETHER_STANDARD_MTU)) > + > + def jumboframes_send_packet(self, pktsize, received=3DTrue): > + """ > + Send 1 packet to portid > + """ > + tx_pkts_ori, _, tx_bytes_ori =3D [int(_) for _ in > self.jumboframes_get_stat(self.vm_port, "tx")] > + rx_pkts_ori, rx_err_ori, rx_bytes_ori =3D [int(_) for _ in > + self.jumboframes_get_stat(self.vm_port, "rx")] > + > + pkt =3D Packet(pkt_type=3D'UDP', pkt_len=3Dpktsize) > + pkt.config_layer('ether', {'dst': self.vf_mac, 'src': self.teste= r_mac}) > + self.vm_testpmd.execute_cmd("clear port stats all") > + pkt.send_pkt(tx_port=3Dself.tester_intf) > + > + time.sleep(1) > + > + tx_pkts, _, tx_bytes =3D [int(_) for _ in self.jumboframes_get_s= tat(self.port, > "tx")] > + rx_pkts, rx_err, rx_bytes =3D [int(_) for _ in > + self.jumboframes_get_stat(self.vm_port, "rx")] > + > + tx_pkts -=3D tx_pkts_ori > + tx_bytes -=3D tx_bytes_ori > + rx_pkts -=3D rx_pkts_ori > + rx_bytes -=3D rx_bytes_ori > + rx_err -=3D rx_err_ori > + if received: > + self.verify((rx_pkts =3D=3D 1) and (tx_pkts =3D=3D 1), "Pack= et > + forward assert error") > + > + self.verify(rx_bytes =3D=3D pktsize, "Rx packet size should = be > + packet size") > + > + self.verify(tx_bytes =3D=3D pktsize, "Tx packet size should = be packet size") > + else: > + self.verify(rx_err =3D=3D 1 or tx_pkts =3D=3D 0, "Packet dro= p > + assert error") > + > + def test_vf_rss(self): > + self.vm_testpmd.start_testpmd("all", "--txq=3D4 --rxq=3D4") > + self.vm_testpmd.execute_cmd("set fwd mac") > + self.vm_testpmd.execute_cmd("set verbose 1") > + for i, j in zip(range(64), [0, 1, 2, 3]*16): > + self.vm_testpmd.execute_cmd("port config 0 rss reta (%d,%d)"= % (i, j)) > + self.vm_testpmd.execute_cmd("port config all rss ip") > + self.vm_testpmd.execute_cmd("port config all rss tcp") > + self.vm_testpmd.execute_cmd("port config all rss udp") > + self.vm_testpmd.execute_cmd("start") > + self.send_packet(self.tester_intf, 'IPV4') > + time.sleep(2) > + out =3D self.vm_dut.get_session_output() > + self.verify_packet_number(out) > + > + self.vm_testpmd.execute_cmd("clear port stats all") > + self.send_packet(self.tester_intf, 'IPV4&TCP') > + time.sleep(2) > + out =3D self.vm_dut.get_session_output() > + self.verify_packet_number(out) > + > + self.vm_testpmd.execute_cmd("clear port stats all") > + self.send_packet(self.tester_intf, 'IPV4&UDP') > + time.sleep(2) > + out =3D self.vm_dut.get_session_output() > + self.verify_packet_number(out) > + > + def verify_packet_number(self, out): > + queue0_number =3D len(re.findall('port 0/queue 0', out)) > + queue1_number =3D len(re.findall('port 0/queue 1', out)) > + queue2_number =3D len(re.findall('port 0/queue 2', out)) > + queue3_number =3D len(re.findall('port 0/queue 3', out)) > + queue_numbers =3D [queue0_number, queue1_number, > queue2_number, queue3_number] > + self.verify('queue 0' in out and 'queue 1' in out and 'queue 2' = in out and > 'queue 3' in out, "some queue can't receive packet when send ip packet") > + self.verify(max(queue_numbers)-min(queue_numbers) <=3D 3, 'packe= t > + number on each queue should be similar') > + > + def send_packet(self, itf, tran_type): > + """ > + Sends packets. > + """ > + mac =3D self.vf_mac > + # send packet with different source and dest ip > + if tran_type =3D=3D "IPV4": > + for i in range(30): > + packet =3D r'sendp([Ether(dst=3D"%s", > src=3D"02:00:00:00:00:00")/IP(src=3D"192.168.0.%d", '\ > + 'dst=3D"192.168.0.%d")], iface=3D"%s")= ' % (mac, i + 1, i + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "IPV4&TCP": > + for i in range(30): > + packet =3D r'sendp([Ether(dst=3D"%s", > src=3D"02:00:00:00:00:00")/IP(src=3D"192.168.0.%d", dst=3D"192.168.0.%d")= /'\ > + 'TCP(sport=3D1024,dport=3D1024)], ifac= e=3D"%s")' % (mac, i + 1, i > + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "IPV4&UDP": > + for i in range(30): > + packet =3D r'sendp([Ether(dst=3D"%s", > src=3D"02:00:00:00:00:00")/IP(src=3D"192.168.0.%d", dst=3D"192.168.0.%d")= /'\ > + 'UDP(sport=3D1024,dport=3D1024)], ifac= e=3D"%s")' % (mac, i + 1, i > + 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + self.tester.scapy_execute() > + time.sleep(1) > + > + def enable_hw_checksum(self): > + self.vm_testpmd.execute_cmd("port stop all") > + self.vm_testpmd.execute_cmd("csum set ip hw 0") > + self.vm_testpmd.execute_cmd("csum set udp hw 0") > + self.vm_testpmd.execute_cmd("csum set tcp hw 0") > + self.vm_testpmd.execute_cmd("csum set sctp hw 0") > + self.vm_testpmd.execute_cmd("set fwd csum") > + self.vm_testpmd.execute_cmd("set verbose 1") > + > + def enable_sw_checksum(self): > + self.vm_testpmd.execute_cmd("port stop all") > + self.vm_testpmd.execute_cmd("csum set ip sw 0") > + self.vm_testpmd.execute_cmd("csum set udp sw 0") > + self.vm_testpmd.execute_cmd("csum set tcp sw 0") > + self.vm_testpmd.execute_cmd("csum set sctp sw 0") > + self.vm_testpmd.execute_cmd("set fwd csum") > + self.vm_testpmd.execute_cmd("set verbose 1") > + > + def checksum_verify(self): > + packets_sent =3D {'IP/': 'Ether(dst=3D"%s", > src=3D"52:00:00:00:00:00")/IP(chksum=3D0x1234)/UDP()/("X"*46)' % self.vf_= mac, > + 'IP/UDP': 'Ether(dst=3D"%s", > src=3D"52:00:00:00:00:00")/IP()/UDP(chksum=3D0x1234)/("X"*46)' % self.vf_= mac, > + 'IP/TCP': 'Ether(dst=3D"%s", > + src=3D"52:00:00:00:00:00")/IP()/TCP(chksum=3D0x1234)/("X"*46)' % > + self.vf_mac} > + > + # Send packet. > + self.tester.scapy_foreground() > + > + for packet_type in packets_sent.keys(): > + self.tester.scapy_append('sendp([%s], iface=3D"%s")' % > (packets_sent[packet_type], self.tester_intf)) > + self.start_tcpdump(self.tester_intf) > + self.tester.scapy_execute() > + time.sleep(1) > + tcpdump_out =3D self.get_tcpdump_package() > + if packet_type =3D=3D 'IP/UDP': > + # verify udp checksum > + self.verify('bad udp cksum' in tcpdump_out and 'udp sum = ok' in > tcpdump_out, 'udp checksum verify fail') > + elif packet_type =3D=3D 'IP/TCP': > + # verify tcp checksum > + self.verify("cksum 0x1234 (incorrect" in tcpdump_out and= 'correct' > in tcpdump_out, 'tcp checksum verify fail') > + else: > + # verify ip checksum > + self.verify('bad cksum 1234' in tcpdump_out and 'udp sum= ok' in > tcpdump_out, 'ip checksum verify fail') > + out =3D self.vm_testpmd.execute_cmd("stop") > + bad_ipcsum =3D self.vm_testpmd.get_pmd_value("Bad-ipcsum:", out) > + bad_l4csum =3D self.vm_testpmd.get_pmd_value("Bad-l4csum:", out) > + self.verify(bad_ipcsum =3D=3D 1, "Bad-ipcsum check error") > + self.verify(bad_l4csum =3D=3D 2, "Bad-ipcsum check error") > + > + def test_vf_hw_checksum_offload(self): > + self.vm_testpmd.start_testpmd("all") > + self.enable_hw_checksum() > + self.vm_testpmd.execute_cmd("port start all") > + self.vm_testpmd.execute_cmd("set verbose 1") > + self.vm_testpmd.execute_cmd("start") > + self.checksum_verify() > + > + def test_vf_sw_checksum_offload(self): > + self.vm_testpmd.start_testpmd("all") > + self.enable_sw_checksum() > + self.vm_testpmd.execute_cmd("port start all") > + self.vm_testpmd.execute_cmd("start") > + self.checksum_verify() > + > + def test_vf_tso(self): > + self.tester.send_expect("ethtool -K %s rx off tx off tso off gso= off gro off > lro off" % self.tester_intf, "#") > + self.tester.send_expect("ifconfig %s mtu %d" % (self.tester_intf= , > ETHER_JUMBO_FRAME_MTU), "#") > + self.vm_testpmd.start_testpmd("all", "--port-topology=3Dchained = --max- > pkt-len=3D%d" % ETHER_JUMBO_FRAME_MTU) > + self.vm_testpmd.execute_cmd("set fwd csum") > + self.vm_testpmd.execute_cmd("set verbose 1") > + self.enable_hw_checksum() > + self.vm_testpmd.execute_cmd("tso set 1460 0") > + self.vm_testpmd.execute_cmd("port start all") > + self.vm_testpmd.execute_cmd("start") > + self.tester.scapy_foreground() > + time.sleep(5) > + self.start_tcpdump(self.tester_intf) > + pkt =3D > 'sendp([Ether(dst=3D"%s")/IP(chksum=3D0x1234)/TCP(flags=3D0x10,chksum=3D0= x1234 > )/'\ > + 'Raw(RandString(5214))], iface=3D"%s")' % (self.vf= _mac, > self.tester_intf) > + self.tester.scapy_append(pkt) > + self.tester.scapy_execute() > + time.sleep(2) > + out =3D self.get_tcpdump_package() > + self.verify_packet_segmentation(out) > + self.vm_testpmd.execute_cmd("stop") > + self.vm_testpmd.execute_cmd("port stop all") > + self.vm_testpmd.execute_cmd("tso set 0 0") > + self.vm_testpmd.execute_cmd("port start all") > + self.vm_testpmd.execute_cmd("start") > + > + self.start_tcpdump(self.tester_intf) > + self.tester.scapy_append(pkt) > + self.tester.scapy_execute() > + time.sleep(2) > + out =3D self.get_tcpdump_package() > + self.verify_packet_segmentation(out, seg=3DFalse) > + > + def start_tcpdump(self, rxItf): > + self.tester.send_expect("rm -rf getPackageByTcpdump.cap", "#") > + self.tester.send_expect("tcpdump -A -nn -e -vv -w > + getPackageByTcpdump.cap -i %s 2> /dev/null& " % rxItf, "#") > + > + def get_tcpdump_package(self): > + self.tester.send_expect("killall tcpdump", "#") > + return self.tester.send_expect("tcpdump -A -nn -e -vv -r > + getPackageByTcpdump.cap", "#") > + > + def verify_packet_segmentation(self, out, seg=3DTrue): > + if seg: > + number1 =3D re.findall('length 1460: HTTP', out) > + number2 =3D re.findall('length 834: HTTP', out) > + self.verify(len(number1) =3D=3D 3 and len(number2) =3D=3D 1,= 'packet has no > segment') > + else: > + self.verify('length 1460: HTTP' not in out, 'packet has segm= ent') > + # tester send packet with incorrect checksum > + # vf fwd packet with corrent checksum > + self.verify('incorrect' in out and 'correct' in out, 'checks= um has > incorrect') > + self.tester.send_expect("^C", "#") > + > + def test_vf_port_start_stop(self): > + self.vm_testpmd.start_testpmd("all") > + for i in range(10): > + self.vm_testpmd.execute_cmd("port stop all") > + self.vm_testpmd.execute_cmd("port start all") > + self.vm_testpmd.execute_cmd("set fwd mac") > + self.vm_testpmd.execute_cmd("start") > + self.send_random_pkt(self.vf_mac, count=3D100) > + port_id_0 =3D 0 > + vf0_stats =3D self.vm_testpmd.get_pmd_stats(port_id_0) > + vf0_rx_cnt =3D vf0_stats['RX-packets'] > + self.verify(vf0_rx_cnt =3D=3D 100, "no packet was received by > + vm0_VF0") > + > + vf0_rx_err =3D vf0_stats['RX-errors'] > + self.verify(vf0_rx_err =3D=3D 0, "vm0_VF0 rx-errors") > + > + vf0_tx_cnt =3D vf0_stats['TX-packets'] > + self.verify(vf0_tx_cnt =3D=3D 100, "no packet was fwd by vm0_VF0= ") > + > + def test_vf_statistic_reset(self): > + self.vm_testpmd.start_testpmd("all") > + self.vm_testpmd.execute_cmd("set fwd mac") > + self.vm_testpmd.execute_cmd("set verbose 1") > + self.vm_testpmd.execute_cmd("start") > + out =3D self.vm_testpmd.execute_cmd("show port stats all") > + self.verify("RX-packets: 0" in out and "TX-packets: 0" in out, "= receive > some misc packet") > + self.vm_testpmd.execute_cmd("clear port stats all") > + self.send_random_pkt(self.vf_mac, count=3D100) > + out =3D self.vm_testpmd.execute_cmd("show port stats all") > + self.verify("RX-packets: 100" in out and "TX-packets: 100" in ou= t, > "receive packet fail") > + self.vm_testpmd.execute_cmd("clear port stats all") > + out =3D self.vm_testpmd.execute_cmd("show port stats all") > + self.verify("RX-packets: 0" in out and "TX-packets: 0" in out, > + "clear port stats fail") > + > + def test_vf_information(self): > + self.vm_testpmd.start_testpmd("all") > + out =3D self.vm_testpmd.execute_cmd("show port info 0") > + self.verify('Link status: up' in out, 'link stats has error') > + self.verify('Link speed: %s' % self.speed in out, 'link speed ha= s error') > + print out > + self.vm_testpmd.execute_cmd("set fwd mac") > + self.vm_testpmd.execute_cmd("set verbose 1") > + self.vm_testpmd.execute_cmd("start") > + self.send_random_pkt(self.vf_mac, count=3D100) > + out =3D self.vm_testpmd.execute_cmd("show port stats all") > + print out > + self.verify("RX-packets: 100" in out and "TX-packets: 100" in > + out, "receive packet fail") > + > + def test_vf_rx_interrupt(self): > + # build l3-power > + out =3D self.dut.build_dpdk_apps("./examples/l3fwd-power") > + self.verify("Error" not in out, "Compilation error") > + self.verify("No such" not in out, "Compilation error") > + self.bind_nic_driver(self.dut_ports, driver=3D"") > + self.create_2vf_in_host() > + # start l3fwd-power > + l3fwd_app =3D "./examples/l3fwd-power/build/l3fwd-power" > + > + cmd =3D l3fwd_app + " -l 6,7 -n 4 -- -p 0x3 --config " + \ > + "'(0,0,6),(1,0,7)'" > + self.dut.send_expect(cmd, "POWER", timeout=3D40) > + out =3D self.dut.get_session_output() > + print out > + pattern =3D re.compile(r"(([a-f0-9]{2}:){5}[a-f0-9]{2})") > + mac_list =3D pattern.findall(out.lower()) > + vf0_mac =3D mac_list[0][0] > + vf1_mac =3D mac_list[1][0] > + # send packet to vf0 and vf1 > + self.scapy_send_packet(vf0_mac, self.tester_intf) > + self.scapy_send_packet(vf1_mac, self.tester_intf1) > + out =3D self.dut.get_session_output() > + self.verify('L3FWD_POWER: lcore 6 is waked up from rx interrupt'= in out, > 'lcore 6 is not waked up') > + self.verify('L3FWD_POWER: lcore 7 is waked up from rx interrupt'= in out, > 'lcore 7 is not waked up') > + self.verify('L3FWD_POWER: lcore 6 sleeps until interrupt trigger= s' in out, > 'lcore 6 not sleep') > + self.verify('L3FWD_POWER: lcore 7 sleeps until interrupt trigger= s' in out, > 'lcore 7 not sleep') > + self.scapy_send_packet(vf0_mac, self.tester_intf, count=3D16) > + self.scapy_send_packet(vf1_mac, self.tester_intf1, count=3D16) > + out =3D self.dut.get_session_output() > + self.verify('L3FWD_POWER: lcore 6 is waked up from rx interrupt'= in out, > 'lcore 6 is not waked up') > + self.verify('L3FWD_POWER: lcore 7 is waked up from rx interrupt'= in out, > 'lcore 7 is not waked up') > + self.dut.send_expect("^C", "# ", 60) > + self.interrupt_flag =3D True > + time.sleep(1) > + self.destroy_2vf_in_2pf() > + > + def scapy_send_packet(self, mac, testinterface, count=3D1): > + """ > + Send a packet to port > + """ > + if count =3D=3D 1: > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP()/UDP()/'\ > + 'Raw(\'X\'*18)], iface=3D"%s")' % (mac, testinte= rface)) > + else: > + for i in range(16): > + self.tester.scapy_append( > + 'sendp([Ether(dst=3D"%s")/IP(dst=3D"127.0.0.%d")/UDP= ()/'\ > + 'Raw(\'X\'*18)], iface=3D"%s")' % (mac, i, t= estinterface)) > + self.tester.scapy_execute() > + > + def create_2vf_in_host(self, driver=3D''): > + self.used_dut_port_0 =3D self.dut_ports[0] > + 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.used_dut_port_1 =3D self.dut_ports[1] > + 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'] > + self.dut.send_expect('modprobe vfio', "#") > + self.dut.send_expect('modprobe vfio-pci', "#") > + for port in self.sriov_vfs_port_0: > + port.bind_driver('vfio-pci') > + > + for port in self.sriov_vfs_port_1: > + port.bind_driver('vfio-pci') > + > + def destroy_2vf_in_2pf(self): > + if getattr(self, 'used_dut_port_0', None) is not None: > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_0) > + self.used_dut_port_0 =3D None > + if getattr(self, 'used_dut_port_1', None) is not None: > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port_1) > + self.used_dut_port_1 =3D None > + > + def tear_down(self): > + """ > + Run after each test case. > + """ > + if self.interrupt_flag is True: > + self.interrupt_flag =3D False > + else: > + self.vm_testpmd.execute_cmd("quit", "#") > + time.sleep(1) > + if self.running_case =3D=3D 'test_vf_mac_filter': > + self.destroy_vm_env() > + if self.running_case =3D=3D 'test_vf_add_pvid': > + self.dut.send_expect("ip link set %s vf 0 vlan 0" % self.hos= t_intf, "# ") > + self.dut.send_expect("ip link set dev %s vf 0 trust off" % > + self.host_intf, "# ") > + > + def tear_down_all(self): > + """ > + When the case of this test suite finished, the environment shoul= d > + clear up. > + """ > + if self.env_done: > + self.destroy_vm_env() > + > -- > 2.17.1