From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 562FEA0613 for ; Wed, 28 Aug 2019 12:25:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4DE7B1BFA1; Wed, 28 Aug 2019 12:25:10 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 786C21BF52 for ; Wed, 28 Aug 2019 12:25:08 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Aug 2019 03:25:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,440,1559545200"; d="scan'208";a="332122904" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga004.jf.intel.com with ESMTP; 28 Aug 2019 03:25:06 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 28 Aug 2019 03:25:06 -0700 Received: from shsmsx107.ccr.corp.intel.com (10.239.4.96) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 28 Aug 2019 03:25:05 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.80]) by SHSMSX107.ccr.corp.intel.com ([169.254.9.65]) with mapi id 14.03.0439.000; Wed, 28 Aug 2019 18:25:04 +0800 From: "Tu, Lijuan" To: "Zhu, WenhuiX" , "dts@dpdk.org" CC: "Lin, Xueqin" , "Zhu, WenhuiX" Thread-Topic: [dts] [PATCH V1] tests:add testsuite iavf Thread-Index: AQHVVjax+4Z5ZvbI50mC6BqxgifZ2qcQaT6Q Date: Wed, 28 Aug 2019 10:25:03 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BB06B87@SHSMSX101.ccr.corp.intel.com> References: <1566182321-9027-1-git-send-email-wenhuix.zhu@intel.com> In-Reply-To: <1566182321-9027-1-git-send-email-wenhuix.zhu@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNWQ0NWY1YzctZGUyOS00ZDI1LWIyZjAtZDNhNTljOGVjNTYxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiQ3lmTjgrXC9xK090aW9TeFJkaGtDSUcwbWlWaVFBUjVWaEJuOE55dmIwZXlJTjNRNDRTQ1Q3dzJoVjVDXC80U1R6In0= 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:add testsuite 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" Applied, thanks > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of zhuwenhui > Sent: Monday, August 19, 2019 10:39 AM > To: dts@dpdk.org > Cc: Lin, Xueqin ; Zhu, WenhuiX > > Subject: [dts] [PATCH V1] tests:add testsuite iavf >=20 > Add new suite. >=20 > Signed-off-by: zhuwenhui > --- > tests/TestSuite_iavf.py | 777 > ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 777 insertions(+) > create mode 100644 tests/TestSuite_iavf.py >=20 > diff --git a/tests/TestSuite_iavf.py b/tests/TestSuite_iavf.py new file m= ode > 100644 index 0000000..1ee5f77 > --- /dev/null > +++ b/tests/TestSuite_iavf.py > @@ -0,0 +1,777 @@ > +# 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 iavf function in i40e driver > + > +""" > + > +import re > +import time > +import math > + > +from virt_common import VM > +from test_case import TestCase > +from pmd_output import PmdOutput > +from packet import Packet > +from settings import get_nic_name > +import random > +from settings import HEADER_SIZE > + > +VM_CORES_MASK =3D 'Default' > + > + > + > +class TestIavf(TestCase): > + > + supported_vf_driver =3D ['pci-stub', 'vfio-pci'] > + > + def set_up_all(self): > + self.tester.extend_external_packet_generator(TestIavf, 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 > + self.interrupt_flag =3D False > + self.broadcast_mac =3D "ff:ff:ff:ff:ff:ff" > + self.promiscuous_mac =3D '00:11:22:33:44:99' > + self.multicast_mac =3D '01:80:C2:00:00:08' > + self.vf0_mac =3D "00:12:34:56:78:01" > + self.vf1_mac =3D "00:12:34:56:78:02" > + self.wrong_mac =3D '11:22:33:44:55:66' > + self.loading_sizes =3D [128, 800, 801, 1700, 2500] > + self.ETHER_JUMBO_FRAME_MTU =3D 9000 > + self.tester_intf0 =3D > self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0])) > + self.tester_intf1 =3D > + self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1] > + )) > + > + # set vf assign method and vf driver > + 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, "Unsuppo= rted 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.dut.send_expect("sed -i -e > '/IAVF_DEV_ID_ADAPTIVE_VF/s/0x1889/0x154c/g' > drivers/net/iavf/base/iavf_devids.h", "# ") > + self.dut.send_expect("sed -i -e '/I40E_DEV_ID_VF/s/0x154C/0x164C= /g' > drivers/net/i40e/base/i40e_devids.h", "# ") > + self.dut.build_install_dpdk(self.target) > + self.setup_vm_env() > + > + def set_up(self): > + pass > + > + def setup_vm_env(self): > + """ > + Create testing environment with 2VF generated from 2PF > + """ > + if self.env_done: > + return > + try: > + self.dut.send_expect("rmmod igb_uio", "# ", 60) > + self.dut.send_expect("insmod %s/kmod/igb_uio.ko" % self.targ= et, "# > ", 60) > + except Exception as e: > + raise Exception(e) > + self.pf_pci0 =3D self.dut.ports_info[0]['pci'] > + self.pf_pci1 =3D self.dut.ports_info[1]['pci'] > + > + # bind to default driver > + self.dut.ports_info[0]['port'].bind_driver("igb_uio") > + self.dut.ports_info[1]['port'].bind_driver("igb_uio") > + self.dut.generate_sriov_vfs_by_port(self.dut_ports[0], 1, "igb_u= io") > + self.dut.generate_sriov_vfs_by_port(self.dut_ports[1], 1, "igb_u= io") > + self.vf0_port =3D self.dut.ports_info[0]['vfs_port'] > + self.vf1_port =3D self.dut.ports_info[1]['vfs_port'] > + self.vf0_port_pci =3D self.dut.ports_info[0]['sriov_vfs_pci'][0] > + self.vf1_port_pci =3D self.dut.ports_info[1]['sriov_vfs_pci'][0] > + > + # start testpmd for pf > + self.dut_testpmd =3D PmdOutput(self.dut) > + host_eal_param =3D '-w %s -w %s' % (self.pf_pci0, self.pf_pci1) > + self.dut_testpmd.start_testpmd( > + "Default", "--rxq=3D4 --txq=3D4 --port-topology=3Dchained", > + eal_param=3Dhost_eal_param) > + > + # set vf mac > + self.dut_testpmd.execute_cmd("set vf mac addr 0 0 %s" % self.vf0= _mac) > + self.dut_testpmd.execute_cmd("set vf mac addr 1 0 %s" % self.vf1= _mac) > + self.used_dut_port_0 =3D self.dut_ports[0] > + self.used_dut_port_1 =3D self.dut_ports[1] > + self.sriov_vfs_port_0 =3D > self.dut.ports_info[self.used_dut_port_0]['vfs_port'] > + self.sriov_vfs_port_1 =3D > self.dut.ports_info[self.used_dut_port_1]['vfs_port'] > + try: > + for port in self.sriov_vfs_port_0: > + port.bind_driver(self.vf_driver) > + > + for port in self.sriov_vfs_port_1: > + port.bind_driver(self.vf_driver) > + 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 VM(self.dut, 'vm0', 'iavf') > + self.vm0.set_vm_device(driver=3Dself.vf_assign_method, **vf0= _prop) > + self.vm0.set_vm_device(driver=3Dself.vf_assign_method, **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.vm0_dut_ports =3D self.vm_dut_0.get_ports('any') > + self.vm0_testpmd =3D PmdOutput(self.vm_dut_0) > + self.vm_dut_0.send_expect("sed -i -e > '/IAVF_DEV_ID_ADAPTIVE_VF/s/0x1889/0x154c/g' > drivers/net/iavf/base/iavf_devids.h", "# ") > + self.vm_dut_0.send_expect("sed -i -e > '/I40E_DEV_ID_VF/s/0x154C/0x164C/g' drivers/net/i40e/base/i40e_devids.h"= , > "# ") > + self.vm_dut_0.build_install_dpdk(self.target) > + self.env_done =3D True > + > + 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 destroy_vm_env(self): > + self.vm_dut_0.send_expect("sed -i -e > '/IAVF_DEV_ID_ADAPTIVE_VF/s/0x154c/0x1889/g' > drivers/net/iavf/base/iavf_devids.h", "# ") > + self.vm_dut_0.send_expect("sed -i -e > '/I40E_DEV_ID_VF/s/0x164C/0x154C/g' drivers/net/i40e/base/i40e_devids.h", > "# ") > + self.vm_dut_0.build_install_dpdk(self.target) > + if getattr(self, 'vm0', None): > + if getattr(self, 'vm_dut_0', None): > + self.vm_dut_0.kill_all() > + self.vm0_testpmd =3D None > + self.vm0_dut_ports =3D None > + # destroy vm0 > + self.vm0.stop() > + self.dut.virt_exit() > + self.vm0 =3D None > + if getattr(self, 'used_dut_port_0', None) !=3D 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) !=3D 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'default') > + self.env_done =3D False > + > + def send_packet(self, mac, itf, tran_type=3D'udp',count =3D 1, pktLe= ngth=3D64, > VID=3D100): > + """ > + Sends packets. > + """ > + # send packet with different source and dest ip > + if tran_type =3D=3D "ip": > + for i in range(count): > + packet =3D r'sendp([Ether(dst=3D"%s", > src=3Dget_if_hwaddr("%s"))/IP(src=3D"192.168.0.%d", '\ > + 'dst=3D"192.168.0.%d")], iface=3D"%s")= ' % (mac, itf, i + 1, i + > 2, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + if tran_type =3D=3D "tcp": > + for i in range(count): > + 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) > + if tran_type =3D=3D "ip/udp": > + for i in range(count): > + packet =3D r'sendp([Ether(dst=3D"%s")/IP()/UDP()/Raw("X"= *%s)], > iface=3D"%s")' % (mac, pktLength, itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + if tran_type =3D=3D "vlan": > + for i in range(count): > + packet =3D r'sendp(Ether(src=3D"00:00:20:00:00:00", > dst=3D"%s")/Dot1Q(id=3D0x8100,vlan=3D%s)/IP()/UDP()/'\ > + 'Raw(load=3D"XXXXXXXXXXXXXX"), iface= =3D"%s")' % (mac, VID, > itf) > + self.tester.scapy_append(packet) > + self.tester.scapy_execute() > + time.sleep(.5) > + elif tran_type =3D=3D "udp": > + for i in range(count): > + 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) > + time.sleep(1) > + > + def number_of_bytes(self, iface): > + """ > + Get the length of loading_sizes > + """ > + scanner =3D ('tcpdump -vv -r tcpdump_{iface}.pcap 2>/dev/null |= grep > "seq" | grep "length"') > + scanner_result =3D scanner.format(**locals()) > + scanner_result =3D self.tester.send_expect(scanner_result, '#') > + fially_result =3D re.findall(r'length( \d+)', scanner_result) > + return list(fially_result) > + > + def number_of_packets(self, iface): > + """ > + By reading the file generated by tcpdump it counts how many pack= ets > were > + forwarded by the sample app and received in the self.tester. The > sample app > + will add a known MAC address for the test to look for. > + """ > + command =3D ('tcpdump -A -nn -e -v -r tcpdump_{iface}.pcap 2>/de= v/null > | grep -c "seq"') > + command_result =3D command.format(**locals()) > + result =3D self.tester.send_expect(command_result, '#') > + return int(result.strip()) > + > + def tcpdump_stop_sniff(self): > + """ > + Stop the tcpdump process running in the background. > + """ > + self.tester.send_expect('killall tcpdump', '#') > + time.sleep(1) > + self.tester.send_expect('echo "Cleaning buffer"', '#') > + time.sleep(1) > + > + def get_tcpdump_vlan(self): > + command =3D ('tcpdump -A -nn -e -v -r tcpdump_{0}.pcap > 2>/dev/null').format(self.tester_intf0) > + result =3D self.tester.send_expect(command, '#') > + return result > + > + def tcpdump_start_sniffing(self, ifaces=3D[]): > + """ > + Start tcpdump in the background to sniff the tester interface wh= ere > + the packets are transmitted to and from the self.dut. > + All the captured packets are going to be stored in a file for a > + post-analysis. > + """ > + for iface in ifaces: > + command =3D ('tcpdump -w tcpdump_{0}.pcap -i {0} > 2>tcpdump_{0}.out &').format(iface) > + del_cmd =3D ('rm -f tcpdump_{0}.pcap').format(iface) > + self.tester.send_expect(del_cmd, '#') > + self.tester.send_expect(command, '#') > + > + def test_vf_basic_rx_tx(self): > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) > + self.vf_mac =3D self.vm0_testpmd.get_port_mac(self.vm0_dut_ports= [0]) > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd('set fwd mac') > + self.vm0_testpmd.execute_cmd("start") > + self.send_packet(self.vf1_mac, self.tester_intf1, "ip/udp", coun= t =3D 10) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets=3D=3D10, "Not receive expected packet") > + > + def test_vf_unicast(self): > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd('set fwd mac') > + self.vm0_testpmd.execute_cmd("set promisc all off") > + self.vm0_testpmd.execute_cmd("set allmulti all off") > + self.vm0_testpmd.execute_cmd('set fwd mac') > + self.vm0_testpmd.execute_cmd("start") > + self.send_packet(self.wrong_mac, self.tester_intf1, "ip/udp", co= unt =3D > 10) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets=3D=3D0, "Not receive expected packet") > + > + self.send_packet(self.vf1_mac, self.tester_intf1, "ip/udp", coun= t =3D 10) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets=3D=3D10, "Not receive expected packet") > + > + def test_vf_multicast(self): > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) > + self.vm0_testpmd.execute_cmd("set promisc all off") > + self.vm0_testpmd.execute_cmd("set allmulti all off") > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd("start") > + self.send_packet(self.vf0_mac, self.tester_intf0, "ip/udp") > + out =3D self.vm_dut_0.get_session_output() > + self.verify(self.vf0_mac in out, 'vf receive pkt fail with curre= nt mac') > + self.send_packet(self.multicast_mac, self.tester_intf0, "ip/udp"= ) > + out =3D self.vm_dut_0.get_session_output() > + self.verify(self.multicast_mac not in out, 'vf receive pkt with = multicast > mac') > + self.vm0_testpmd.execute_cmd("set allmulti all on") > + self.send_packet(self.vf0_mac, self.tester_intf0, "ip/udp") > + out =3D self.vm_dut_0.get_session_output() > + self.verify(self.vf0_mac in out, 'vf receive pkt fail with curre= nt mac') > + self.send_packet(self.multicast_mac, self.tester_intf0, "ip/udp"= ) > + out =3D self.vm_dut_0.get_session_output(timeout=3D2) > + self.verify(self.multicast_mac in out, 'vf receive pkt fail > + with multicast mac') > + > + def test_vf_broadcast(self): > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) > + self.vm0_testpmd.execute_cmd("set promisc all off") > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd('set fwd mac') > + self.vm0_testpmd.execute_cmd("start") > + self.send_packet(self.broadcast_mac, self.tester_intf0, "ip/udp"= , > count=3D10) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets=3D=3D10, "Not receive expected packet") > + > + def test_vf_promiscuous_mode(self): > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) > + self.vm0_testpmd.execute_cmd("set promisc all on") > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd("start") > + self.send_packet(self.vf0_mac, self.tester_intf0, "ip/udp") > + out =3D self.vm_dut_0.get_session_output() > + self.verify(self.vf0_mac in out, 'vf receive pkt with current ma= c') > + self.send_packet(self.promiscuous_mac, self.tester_intf0, "ip/ud= p") > + out =3D self.vm_dut_0.get_session_output(timeout=3D2) > + self.verify(self.promiscuous_mac in out, 'vf receive pkt fail > + with different mac') > + > + def test_vf_vlan_filter(self): > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) > + self.vm0_testpmd.execute_cmd("port stop all") > + self.vm0_testpmd.execute_cmd('set verbose 1') > + self.vm0_testpmd.execute_cmd("set promisc all off") > + self.vm0_testpmd.execute_cmd("vlan set filter off 0") > + self.vm0_testpmd.execute_cmd("vlan set filter off 1") > + self.vm0_testpmd.execute_cmd("vlan set strip off 0") > + self.vm0_testpmd.execute_cmd("vlan set strip off 1") > + self.vm0_testpmd.execute_cmd("vlan set filter on 0") > + self.vm0_testpmd.execute_cmd("port start all") > + self.vm0_testpmd.execute_cmd('set fwd mac') > + self.vm0_testpmd.execute_cmd("start") > + > + # send 10 vlan tagged packets, and can't forward the packets > + self.send_packet(self.vf0_mac, self.tester_intf0, "vlan", count = =3D 10, > VID=3D200) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets=3D=3D0, "Not receive expected packet") > + > + # send 10 untagged packets, and forward the packets > + self.send_packet(self.vf0_mac, self.tester_intf0, "ip/udp", coun= t =3D 10) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets=3D=3D10, "Not receive expected packet") > + > + def test_vf_rx_vlan(self): > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) > + self.vm0_testpmd.execute_cmd("port stop all") > + self.vm0_testpmd.execute_cmd("set promisc all off") > + self.vm0_testpmd.execute_cmd("vlan set filter off 0") > + self.vm0_testpmd.execute_cmd("vlan set filter off 1") > + self.vm0_testpmd.execute_cmd("vlan set strip off 0") > + self.vm0_testpmd.execute_cmd("vlan set strip off 1") > + self.vm0_testpmd.execute_cmd("vlan set filter on 0") > + self.vm0_testpmd.execute_cmd("rx_vlan add 20 0") > + self.vm0_testpmd.execute_cmd("set fwd mac") > + self.vm0_testpmd.execute_cmd("set verbose 1") > + self.vm0_testpmd.execute_cmd("port start all") > + self.vm0_testpmd.execute_cmd("start") > + > + # send 10 vid20 tagged packets, and can forward the packets > + self.send_packet(self.vf0_mac, self.tester_intf0, "vlan", count = =3D 10, > pktLength=3D100, VID=3D20) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets =3D=3D 10, "Not receive expected packet") > + > + # send 10 vid200 tagged packets, and can't forward the packets > + self.send_packet(self.vf0_mac, self.tester_intf0, "vlan", count = =3D 10, > pktLength=3D100, VID=3D200) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets =3D=3D 0, "Not receive expected packet") > + > + # send 10 udp packets, and can forward the packets > + self.send_packet(self.vf0_mac, self.tester_intf0, "udp", count = =3D 10) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets =3D=3D 10, "Not receive expected packet") > + > + def test_vf_tx_vlan(self): > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) > + self.vm0_testpmd.execute_cmd("port stop all") > + self.vm0_testpmd.execute_cmd("set promisc all off") > + self.vm0_testpmd.execute_cmd("set fwd mac") > + self.vm0_testpmd.execute_cmd("vlan set filter off 0") > + self.vm0_testpmd.execute_cmd("vlan set filter off 1") > + self.vm0_testpmd.execute_cmd("vlan set strip off 0") > + self.vm0_testpmd.execute_cmd("vlan set strip off 1") > + self.vm0_testpmd.execute_cmd("tx_vlan set 1 20") > + self.vm0_testpmd.execute_cmd("tx_vlan set 0 20") > + self.vm0_testpmd.execute_cmd("port start all") > + self.vm0_testpmd.execute_cmd("start") > + self.tcpdump_start_sniffing([self.tester_intf0]) > + self.send_packet(self.vf1_mac, self.tester_intf1, "ip/udp") > + self.tcpdump_stop_sniff() > + out =3D self.get_tcpdump_vlan() > + self.verify(self.vf0_mac and "vlan 20" in out, 'vlan tag not in > + out') > + > + def test_vf_vlan_strip(self): > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) > + self.vm0_testpmd.execute_cmd("set promisc all on") > + self.vm0_testpmd.execute_cmd("set fwd mac") > + self.vm0_testpmd.execute_cmd("set verbose 1") > + self.vm0_testpmd.execute_cmd("vlan set filter off 0") > + self.vm0_testpmd.execute_cmd("vlan set filter off 1") > + self.vm0_testpmd.execute_cmd("vlan set strip off 0") > + self.vm0_testpmd.execute_cmd("vlan set strip off 1") > + self.vm0_testpmd.execute_cmd("vlan set strip on 1") > + self.vm0_testpmd.execute_cmd("vlan set strip on 0") > + self.vm0_testpmd.execute_cmd("port start all") > + self.vm0_testpmd.execute_cmd("start") > + self.tcpdump_start_sniffing([self.tester_intf0]) > + self.send_packet(self.vf1_mac, self.tester_intf1, "vlan") > + self.tcpdump_stop_sniff() > + out =3D self.get_tcpdump_vlan() > + self.verify('vlan 100' not in out and self.vf0_mac in out, > + 'vlan tag in out') > + > + # disable strip > + self.vm0_testpmd.execute_cmd("vlan set strip off 1") > + self.tcpdump_start_sniffing([self.tester_intf0]) > + self.send_packet(self.vf1_mac, self.tester_intf1, "vlan") > + self.tcpdump_stop_sniff() > + out =3D self.get_tcpdump_vlan() > + self.verify("vlan 100" in out and self.vf0_mac in out, 'vlan > + tag not in out') > + > + def test_vf_vlan_promisc(self): > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) > + self.vm0_testpmd.execute_cmd("port stop all") > + self.vm0_testpmd.execute_cmd("set promisc all on") > + self.vm0_testpmd.execute_cmd("set fwd mac") > + self.vm0_testpmd.execute_cmd("set verbose 1") > + self.vm0_testpmd.execute_cmd("vlan set filter off 0") > + self.vm0_testpmd.execute_cmd("vlan set filter off 1") > + self.vm0_testpmd.execute_cmd("vlan set strip off 0") > + self.vm0_testpmd.execute_cmd("vlan set strip off 1") > + self.vm0_testpmd.execute_cmd("port start all") > + self.vm0_testpmd.execute_cmd("start") > + > + # send 10 tagged packets, and check 10 tagged packets received > + self.send_packet(self.vf1_mac, self.tester_intf1, "vlan", count = =3D 10, > VID=3D100) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets =3D=3D 10, "Not receive expected packet") > + > + # send 10 untagged packets, and check 10 untagged packets receiv= ed > + self.send_packet(self.vf1_mac,self.tester_intf1, "udp", count = =3D 10) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets =3D=3D 10, "Not receive expected packet") > + > + def test_vf_no_jumbo(self): > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) > + self.vm0_testpmd.execute_cmd("set fwd mac") > + self.vm0_testpmd.execute_cmd("set verbose 1") > + self.vm0_testpmd.execute_cmd("start") > + > + # set tester port mtu > + self.tester.send_expect("ifconfig %s mtu %d" % (self.tester_intf= 0, > self.ETHER_JUMBO_FRAME_MTU), "# ") > + self.tester.send_expect("ifconfig %s mtu %d" % > + (self.tester_intf1, self.ETHER_JUMBO_FRAME_MTU), "# ") > + > + # send 10 1518 size packets, and check 10 packets received > + pktLength =3D 1518 > + payload =3D pktLength - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] - > HEADER_SIZE['udp'] > + self.send_packet(self.vf1_mac, self.tester_intf1, "ip/udp", coun= t =3D 10, > pktLength=3Dpayload) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets =3D=3D 10, "Not receive expected packet") > + > + # send 10 1519 size packets, and check 0 packets received > + pktLength =3D 1519 > + payload =3D pktLength - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] - > HEADER_SIZE['udp'] > + self.send_packet(self.vf1_mac, self.tester_intf1, "ip/udp", coun= t =3D 10, > pktLength=3Dpayload) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets =3D=3D 0, "Not receive expected packet") > + > + def test_vf_normal_jumbo(self): > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, "--max-pkt- > len=3D3000 --tx-offloads=3D0x8000") > + self.vm0_testpmd.execute_cmd("set verbose 1") > + self.vm0_testpmd.execute_cmd("set fwd mac") > + self.vm0_testpmd.execute_cmd("start") > + > + # set tester port mtu > + self.tester.send_expect("ifconfig %s mtu %d" % (self.tester_intf= 0, > self.ETHER_JUMBO_FRAME_MTU), "# ") > + self.tester.send_expect("ifconfig %s mtu %d" % > + (self.tester_intf1, self.ETHER_JUMBO_FRAME_MTU), "# ") > + > + # send 10 1517 size packets, and check 10 packets received > + pktLength =3D 1517 > + payload =3D pktLength - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] - > HEADER_SIZE['udp'] > + self.send_packet(self.vf1_mac, self.tester_intf1, "ip/udp", coun= t =3D 10, > pktLength=3Dpayload) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets =3D=3D 10, "Not receive expected packet") > + > + # send 10 1518 size packets, and check 10 packets received > + pktLength =3D 1518 > + payload =3D pktLength - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] - > HEADER_SIZE['udp'] > + self.send_packet(self.vf1_mac, self.tester_intf1, "ip/udp", coun= t =3D 10, > pktLength=3Dpayload) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets =3D=3D 10, "Not receive expected packet") > + > + # send 10 1519 size packets, and check 10 packets received > + pktLength =3D 1519 > + payload =3D pktLength - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] - > HEADER_SIZE['udp'] > + self.send_packet(self.vf1_mac, self.tester_intf1, "ip/udp", coun= t =3D 10, > pktLength=3Dpayload) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets =3D=3D 10, "Not receive expected packet") > + > + # send 10 4500 size packets, and check 0 packets received > + pktLength =3D 4500 > + payload =3D pktLength - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] - > HEADER_SIZE['udp'] > + self.send_packet(self.vf1_mac, self.tester_intf1, "ip/udp", coun= t =3D 10, > pktLength=3D4500) > + out =3D self.vm_dut_0.get_session_output() > + packets =3D len(re.findall('received 1 packets', out)) > + self.verify(packets =3D=3D 0, "Not receive expected packet") > + > + def validate_checksum_packet(self): > + normal_checksum_values =3D {} > + checksum_pattern =3D re.compile("chksum.*=3D.*(0x[0-9a-z]+)") > + self.tester.send_expect("scapy", ">>> ") > + for packet in normal_packets: > + self.tester.send_expect("p =3D %s" % normal_packets[packet],= ">>>") > + out =3D self.tester.send_expect("p.show2()", ">>>") > + chksums =3D checksum_pattern.findall(out) > + if chksums: > + normal_checksum_values[packet] =3D chksums > + self.tester.send_expect("exit()", "#") > + for index in normal_checksum_values: > + self.logger.info("Good checksum value for %s Packet is: %s" > + % (index, normal_checksum_values[index])) > + > + # Send bad checksum packters and check if the checksum fields ar= e > correct. > + corrected_checksum_values =3D {} > + for packet in checksum_error_packets: > + inst =3D self.tester.tcpdump_sniff_packets(self.tester_intf0= ) > + self.tester.scapy_foreground() > + self.tester.scapy_append('sendp([%s], iface=3D"%s")' % > (checksum_error_packets[packet], self.tester_intf1)) > + self.tester.scapy_execute() > + rec_pkt =3D self.tester.load_tcpdump_sniff_packets(inst) > + # collect checksum values for received packet > + chksum =3D > rec_pkt[0].pktgen.pkt.s("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP > .chksum%").split(";") > + chksum =3D list(set(chksum)) > + chksum.remove("??") > + corrected_checksum_values[packet] =3D chksum > + for packet in corrected_checksum_values: > + self.logger.info("Corrected checksum value for %s Packet > + is: %s" % (packet, corrected_checksum_values[packet])) > + > + # check if the corrected checksum values are same with the norma= l > packets checksum values > + for packet in normal_packets: > + corrected_checksum_values[packet].sort() > + normal_checksum_values[packet].sort() > + self.verify(corrected_checksum_values[packet] =3D=3D > normal_checksum_values[packet], \ > + "Unexpected Checksum Error For Packet %s" % > + packet) > + > + def test_vf_checksum_sw(self): > + global checksum_error_packets > + global normal_packets > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) > + > + # SW checksum not support SCTP packet SW checksum, DPDK-5886 > + checksum_error_packets =3D {'IP/UDP': 'Ether(dst=3D"%s", > src=3D"52:00:00:00:00:00")/IP(chksum=3D0x0)/UDP(chksum=3D0xf)/("X"*46)' % > self.vf1_mac, > + 'IP/TCP': 'Ether(dst=3D"%s", > src=3D"52:00:00:00:00:00")/IP(chksum=3D0x0)/TCP(chksum=3D0xf)/("X"*46)' % > self.vf1_mac, > + 'IPv6/UDP': 'Ether(dst=3D"%s", > src=3D"52:00:00:00:00:00")/IPv6(src=3D"::1")/UDP(chksum=3D0xf)/("X"*46)' = % > self.vf1_mac, > + 'IPv6/TCP': 'Ether(dst=3D"%s", > src=3D"52:00:00:00:00:00")/IPv6(src=3D"::1")/TCP(chksum=3D0xf)/("X"*46)' = % > self.vf1_mac} > + normal_packets =3D {'IP/UDP': 'Ether(dst=3D"02:00:00:00:00:00", > src=3D"%s")/IP(src=3D"127.0.0.1")/UDP()/("X"*46)' % self.vf1_mac, > + 'IP/TCP': 'Ether(dst=3D"02:00:00:00:00:00", > src=3D"%s")/IP(src=3D"127.0.0.1")/TCP()/("X"*46)' % self.vf1_mac, > + 'IPv6/UDP': 'Ether(dst=3D"02:00:00:00:00:00", > src=3D"%s")/IPv6(src=3D"::1")/UDP()/("X"*46)' % self.vf1_mac, > + 'IPv6/TCP': 'Ether(dst=3D"02:00:00:00:00:00", > src=3D"%s")/IPv6(src=3D"::1")/TCP()/("X"*46)' % self.vf1_mac} > + self.vm0_testpmd.execute_cmd("port stop all") > + self.vm0_testpmd.execute_cmd("csum set ip sw 0") > + self.vm0_testpmd.execute_cmd("csum set udp sw 0") > + self.vm0_testpmd.execute_cmd("csum set tcp sw 0") > + self.vm0_testpmd.execute_cmd("csum set sctp sw 0") > + self.vm0_testpmd.execute_cmd("csum set ip sw 1") > + self.vm0_testpmd.execute_cmd("csum set udp sw 1") > + self.vm0_testpmd.execute_cmd("csum set tcp sw 1") > + self.vm0_testpmd.execute_cmd("csum set sctp sw 1") > + self.vm0_testpmd.execute_cmd("set fwd csum") > + self.vm0_testpmd.execute_cmd("set verbose 1") > + self.vm0_testpmd.execute_cmd("port start all") > + self.vm0_testpmd.execute_cmd("start") > + self.validate_checksum_packet() > + > + def test_vf_checksum_hw(self): > + global checksum_error_packets > + global normal_packets > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK) > + checksum_error_packets =3D {'IP/UDP': 'Ether(dst=3D"%s", > src=3D"52:00:00:00:00:00")/IP(chksum=3D0x0)/UDP(chksum=3D0xf)/("X"*46)' % > self.vf1_mac, > + 'IP/TCP': 'Ether(dst=3D"%s", > src=3D"52:00:00:00:00:00")/IP(chksum=3D0x0)/TCP(chksum=3D0xf)/("X"*46)' % > self.vf1_mac, > + 'IPv6/UDP': 'Ether(dst=3D"%s", > src=3D"52:00:00:00:00:00")/IPv6(src=3D"::1")/UDP(chksum=3D0xf)/("X"*46)' = % > self.vf1_mac, > + 'IP/SCTP': 'Ether(dst=3D"%s", > src=3D"52:00:00:00:00:00")/IP(chksum=3D0x0)/SCTP(chksum=3D0xf)/("X"*48)' = % > self.vf1_mac, > + 'IPv6/TCP': 'Ether(dst=3D"%s", > src=3D"52:00:00:00:00:00")/IPv6(src=3D"::1")/TCP(chksum=3D0xf)/("X"*46)' = % > self.vf1_mac} > + normal_packets =3D {'IP/UDP': 'Ether(dst=3D"02:00:00:00:00:00", > src=3D"%s")/IP(src=3D"127.0.0.1")/UDP()/("X"*46)' % self.vf1_mac, > + 'IP/TCP': 'Ether(dst=3D"02:00:00:00:00:00", > src=3D"%s")/IP(src=3D"127.0.0.1")/TCP()/("X"*46)' % self.vf1_mac, > + 'IPv6/UDP': 'Ether(dst=3D"02:00:00:00:00:00", > src=3D"%s")/IPv6(src=3D"::1")/UDP()/("X"*46)' % self.vf1_mac, > + 'IP/SCTP': 'Ether(dst=3D"02:00:00:00:00:00", > src=3D"%s")/IP(src=3D"127.0.0.1")/SCTP()/("X"*48)' % self.vf1_mac, > + 'IPv6/TCP': 'Ether(dst=3D"02:00:00:00:00:00", > src=3D"%s")/IPv6(src=3D"::1")/TCP()/("X"*46)' % self.vf1_mac} > + self.vm0_testpmd.execute_cmd("port stop all") > + self.vm0_testpmd.execute_cmd("csum set ip hw 0") > + self.vm0_testpmd.execute_cmd("csum set udp hw 0") > + self.vm0_testpmd.execute_cmd("csum set tcp hw 0") > + self.vm0_testpmd.execute_cmd("csum set sctp hw 0") > + self.vm0_testpmd.execute_cmd("csum set ip hw 1") > + self.vm0_testpmd.execute_cmd("csum set udp hw 1") > + self.vm0_testpmd.execute_cmd("csum set tcp hw 1") > + self.vm0_testpmd.execute_cmd("csum set sctp hw 1") > + self.vm0_testpmd.execute_cmd("set fwd csum") > + self.vm0_testpmd.execute_cmd("set verbose 1") > + self.vm0_testpmd.execute_cmd("port start all") > + self.vm0_testpmd.execute_cmd("start") > + self.validate_checksum_packet() > + > + def test_vf_tso(self): > + self.tester.send_expect("ifconfig %s mtu %d" % (self.tester_intf= 0, > self.ETHER_JUMBO_FRAME_MTU), "#") > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, " --max-pkt-len=3D= %s > " % self.ETHER_JUMBO_FRAME_MTU) > + self.vm0_testpmd.execute_cmd("port stop all") > + self.vm0_testpmd.execute_cmd("csum set ip hw 0") > + self.vm0_testpmd.execute_cmd("csum set udp hw 0") > + self.vm0_testpmd.execute_cmd("csum set tcp hw 0") > + self.vm0_testpmd.execute_cmd("csum set sctp hw 0") > + self.vm0_testpmd.execute_cmd("csum set outer-ip hw 0") > + self.vm0_testpmd.execute_cmd("csum parse-tunnel on 0") > + self.vm0_testpmd.execute_cmd("csum set ip hw 1") > + self.vm0_testpmd.execute_cmd("csum set udp hw 1") > + self.vm0_testpmd.execute_cmd("csum set tcp hw 1") > + self.vm0_testpmd.execute_cmd("csum set sctp hw 1") > + self.vm0_testpmd.execute_cmd("csum set outer-ip hw 1") > + self.vm0_testpmd.execute_cmd("csum parse-tunnel on 1") > + self.vm0_testpmd.execute_cmd("tso set 800 1") > + self.vm0_testpmd.execute_cmd("set fwd csum") > + self.vm0_testpmd.execute_cmd("port start all") > + self.vm0_testpmd.execute_cmd("set promisc all off") > + self.vm0_testpmd.execute_cmd("start") > + self.tester.scapy_foreground() > + time.sleep(5) > + for loading_size in self.loading_sizes: > + self.tcpdump_start_sniffing([self.tester_intf0, self.tester_= intf1]) > + > self.tester.scapy_append('sendp([Ether(dst=3D"%s",src=3D"52:00:00:00:00:0= 0")/IP( > src=3D"192.168.1.1",dst=3D"192.168.1.2") \ > + /TCP(sport=3D1021,dport=3D1021)/("X"*%s)], iface=3D"= %s")' % > (self.vf0_mac, loading_size, self.tester_intf0)) > + self.tester.scapy_execute() > + self.tcpdump_stop_sniff() > + rx_stats =3D self.number_of_packets(self.tester_intf1) > + tx_stats =3D self.number_of_packets(self.tester_intf0) > + tx_outlist =3D self.number_of_bytes(self.tester_intf1) > + self.logger.info(tx_outlist) > + if (loading_size <=3D 800): > + self.verify(rx_stats =3D=3D tx_stats and int(tx_outlist[= 0]) =3D=3D > loading_size, "the packet segmentation incorrect, %s" % tx_outlist) > + else: > + num =3D loading_size/800 > + for i in range(num): > + self.verify(tx_outlist !=3D [], "the packet segmenta= tion > incorrect, %s" % tx_outlist) > + self.verify(int(tx_outlist[i]) =3D=3D 800, "the pack= et segmentation > incorrect, %s" % tx_outlist) > + if loading_size% 800 !=3D 0: > + self.verify(int(tx_outlist[num]) =3D=3D loading_size= % > + 800, "the packet segmentation incorrect, %s" % tx_outlist) > + > + def verify_packet_number(self, out): > + queue0_number =3D len(re.findall('port 1/queue 0', out)) > + queue1_number =3D len(re.findall('port 1/queue 1', out)) > + queue2_number =3D len(re.findall('port 1/queue 2', out)) > + queue3_number =3D len(re.findall('port 1/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 queues can't receive packets when send > expected packets") > + self.verify(max(queue_numbers)-min(queue_numbers) <=3D 3, 'packe= t > + number on each queue should be similar') > + > + def test_vf_rss(self): > + self.vm0_testpmd.start_testpmd(VM_CORES_MASK, "--txq=3D4 --rxq= =3D4") > + self.vm0_testpmd.execute_cmd("set verbose 1") > + for i, j in zip(range(64), [0, 1, 2, 3]*16): > + self.vm0_testpmd.execute_cmd("port config 1 rss reta (%d,%d)= " % (i, > j)) > + pkt_types =3D ["ip", "tcp", "udp"] > + for pkt_type in pkt_types: > + self.vm0_testpmd.execute_cmd("port config all rss %s" % pkt_= type) > + self.vm0_testpmd.execute_cmd("start") > + self.send_packet(self.vf1_mac, self.tester_intf1, pkt_type, = count =3D 30) > + time.sleep(2) > + out =3D self.vm_dut_0.get_session_output() > + self.verify_packet_number(out) > + self.vm0_testpmd.execute_cmd("clear port stats all") > + > + def test_vf_rx_interrupt(self): > + # build l3fwd-power > + out =3D self.vm_dut_0.build_dpdk_apps("./examples/l3fwd-power") > + self.verify("Error" not in out, "Compilation error") > + self.verify("No such" not in out, "Compilation error") > + self.vm_dut_0.unbind_interfaces_linux() > + self.vm_dut_0.send_expect("modprobe vfio", "# ", 60) > + self.vm_dut_0.send_expect("modprobe -r vfio_iommu_type1", "# ", = 60) > + self.vm_dut_0.send_expect("modprobe vfio > enable_unsafe_noiommu_mode=3D1", "# ", 60) > + self.vm_dut_0.send_expect("modprobe vfio-pci", "# ", 60) > + self.vm_dut_0.bind_interfaces_linux(driver=3D"vfio-pci") > + # start l3fwd-power > + l3fwd_app =3D "./examples/l3fwd-power/build/l3fwd-power" > + cmd =3D l3fwd_app + " -l 0,1 -n 4 -- -p 0x3 --config '(0,0,0),= (1,0,1)'" > + self.vm_dut_0.send_expect(cmd, "POWER", timeout=3D40) > + time.sleep(10) > + self.send_packet(self.vf0_mac, self.tester_intf0, "ip/udp") > + self.send_packet(self.vf1_mac, self.tester_intf1, "ip/udp") > + out =3D self.vm_dut_0.get_session_output() > + self.verify('L3FWD_POWER: lcore 0 is waked up from rx interrupt'= in out, > 'lcore 0 is not waked up') > + self.verify('L3FWD_POWER: lcore 1 is waked up from rx interrupt'= in out, > 'lcore 1 is not waked up') > + self.verify('L3FWD_POWER: lcore 0 sleeps until interrupt trigger= s' in out, > 'lcore 0 not sleep') > + self.verify('L3FWD_POWER: lcore 1 sleeps until interrupt trigger= s' in out, > 'lcore 1 not sleep') > + self.send_packet(self.vf0_mac, self.tester_intf0, "udp", count = =3D 10) > + self.send_packet(self.vf1_mac, self.tester_intf1, "udp", count = =3D 10) > + out =3D self.vm_dut_0.get_session_output() > + self.verify('L3FWD_POWER: lcore 0 is waked up from rx interrupt'= in out, > 'lcore 0 is not waked up') > + self.verify('L3FWD_POWER: lcore 1 is waked up from rx interrupt'= in out, > 'lcore 1 is not waked up') > + self.vm_dut_0.send_expect("^C", "# ", 60) > + self.vm_dut_0.bind_interfaces_linux(driver=3D"igb_uio") > + self.interrupt_flag =3D True > + > + def tear_down(self): > + if self.running_case =3D=3D "test_vf_rx_interrupt": > + self.vm_dut_0.send_expect("^C", "# ", 60) > + else: > + self.vm0_testpmd.quit() > + > + def tear_down_all(self): > + self.dut.send_expect("quit", "# ") > + if self.env_done is True: > + self.destroy_vm_env() > + self.dut.send_expect("sed -i -e > '/IAVF_DEV_ID_ADAPTIVE_VF/s/0x154c/0x1889/g' > drivers/net/iavf/base/iavf_devids.h", "# ") > + self.dut.send_expect("sed -i -e > '/I40E_DEV_ID_VF/s/0x164C/0x154C/g' drivers/net/i40e/base/i40e_devids.h", > "# ") > + self.dut.build_install_dpdk(self.target) > + self.env_done =3D False > + else: > + pass > -- > 2.17.2