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 A8CF84CC5 for ; Wed, 4 Jan 2017 04:27:46 +0100 (CET) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP; 03 Jan 2017 19:27:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,458,1477983600"; d="scan'208";a="49817322" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga006.fm.intel.com with ESMTP; 03 Jan 2017 19:27:45 -0800 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 3 Jan 2017 19:27:45 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 3 Jan 2017 19:27:36 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.20]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.132]) with mapi id 14.03.0248.002; Wed, 4 Jan 2017 11:27:35 +0800 From: "Liu, Yong" To: "Peng, Yuan" , "dts@dpdk.org" CC: "Peng, Yuan" Thread-Topic: [dts] [PATCH] tests: add TestSuite_veb_switch.py Thread-Index: AQHSYbDvNBCxgYzQJECpEm4H3zcLK6EnsY4Q Date: Wed, 4 Jan 2017 03:27:35 +0000 Message-ID: <86228AFD5BCD8E4EBFD2B90117B5E81E62D38B31@SHSMSX103.ccr.corp.intel.com> References: <1483001568-21821-1-git-send-email-yuan.peng@intel.com> In-Reply-To: <1483001568-21821-1-git-send-email-yuan.peng@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] tests: add TestSuite_veb_switch.py 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, 04 Jan 2017 03:27:47 -0000 Thanks, applied into master branch. -----Original Message----- From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Peng Yuan Sent: Thursday, December 29, 2016 4:53 PM To: dts@dpdk.org Cc: Peng, Yuan Subject: [dts] [PATCH] tests: add TestSuite_veb_switch.py From: peng yuan Signed-off-by: peng yuan diff --git a/tests/TestSuite_veb_switch.py b/tests/TestSuite_veb_switch.py = new file mode 100644 index 0000000..1bfa776 --- /dev/null +++ b/tests/TestSuite_veb_switch.py @@ -0,0 +1,474 @@ +# BSD LICENSE +# +# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without #=20 +modification, are permitted provided that the following conditions #=20 +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 #=20 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT #=20 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR #=20 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT #=20 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, #=20 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT #=20 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, #=20 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY #=20 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT #=20 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE #=20 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +DPDK Test suite. + +Test VEB Switch and floating VEB Features by Poll Mode Drivers. +""" + +import re +import time + +from virt_dut import VirtDut +from project_dpdk import DPDKdut +from dut import Dut +from test_case import TestCase +from pmd_output import PmdOutput +from settings import HEADER_SIZE +from packet import Packet +from utils import RED + + +class TestVEBSwitching(TestCase): + + def VEB_get_stats(self, vf0_vf1, portid, rx_tx): + """ + Get packets number from port statistic + """ + if vf0_vf1 =3D=3D "vf0": + stats =3D self.pmdout.get_pmd_stats(portid) + elif vf0_vf1 =3D=3D "vf1": + stats =3D self.pmdout_session_secondary.get_pmd_stats(portid) + else: + return None + + if rx_tx =3D=3D "rx": + return [stats['RX-packets'], stats['RX-errors'], stats['RX-byt= es']] + elif rx_tx =3D=3D "tx": + return [stats['TX-packets'], stats['TX-errors'], stats['TX-byt= es']] + else: + return None + =20 + def veb_get_pmd_stats(self, dev, portid, rx_tx): + stats =3D {} + rx_pkts_prefix =3D "RX-packets:" + rx_bytes_prefix =3D "RX-bytes:" + rx_error_prefix =3D "RX-errors:" + tx_pkts_prefix =3D "TX-packets:" + tx_error_prefix =3D "TX-errors:" + tx_bytes_prefix =3D "TX-bytes:" + + if dev =3D=3D "first": + out =3D self.dut.send_expect("show port stats %d" % portid, "t= estpmd> ") + elif dev =3D=3D "second": + out =3D self.session_secondary.send_expect("show port stats %d= " % portid, "testpmd> ") + elif dev =3D=3D "third": + out =3D self.session_third.send_expect("show port stats %d" % = portid, "testpmd> ") + else: + return None + + stats["RX-packets"] =3D self.veb_get_pmd_value(rx_pkts_prefix, out= ) + stats["RX-bytes"] =3D self.veb_get_pmd_value(rx_bytes_prefix, out) + stats["RX-errors"] =3D self.veb_get_pmd_value(rx_error_prefix, out= ) + stats["TX-packets"] =3D self.veb_get_pmd_value(tx_pkts_prefix, out= ) + stats["TX-errors"] =3D self.veb_get_pmd_value(tx_error_prefix, out= ) + stats["TX-bytes"] =3D self.veb_get_pmd_value(tx_bytes_prefix,=20 + out) + + if rx_tx =3D=3D "rx": + return [stats['RX-packets'], stats['RX-errors'], stats['RX-byt= es']] + elif rx_tx =3D=3D "tx": + return [stats['TX-packets'], stats['TX-errors'], stats['TX-byt= es']] + else: + return None + + + def veb_get_pmd_value(self, prefix, out): + pattern =3D re.compile(prefix + "(\s+)([0-9]+)") + m =3D pattern.search(out) + if m is None: + return None + else: + return int(m.group(2)) + + def send_packet(self, vf_mac, itf, tran_type=3D""): + """ + Send 1 packet + """ + self.dut.send_expect("start", "testpmd>") + mac =3D self.dut.get_mac_address(0) + + if tran_type =3D=3D "vlan": + pkt =3D Packet(pkt_type=3D'VLAN_UDP') + pkt.config_layer('ether', {'dst': vf_mac}) + pkt.config_layer('vlan', {'vlan': 1}) + pkt.send_pkt(tx_port=3Ditf) + time.sleep(.5) + else: + pkt =3D Packet(pkt_type=3D'UDP') + pkt.config_layer('ether', {'dst': vf_mac}) + pkt.send_pkt(tx_port=3Ditf) + time.sleep(.5) + =20 + # Test cases. + =20 + def set_up_all(self): + """ + Prerequisite steps for each test suite. + """ + self.verify(self.nic in ["fortville_eagle", "fortville_spirit", + "fortville_spirit_single"], + "NIC Unsupported: " + str(self.nic)) + self.dut_ports =3D self.dut.get_ports(self.nic) + self.verify(len(self.dut_ports) >=3D 1, "Insufficient ports") + self.session_secondary =3D self.dut.new_session() + self.session_third =3D self.dut.new_session() + =20 + self.pf_kdriver_flag =3D 0 + self.pf_ddriver_flag =3D 0 + self.vf0_mac =3D "00:11:22:33:44:11" + self.vf1_mac =3D "00:11:22:33:44:12" + self.vf2_mac =3D "00:11:22:33:44:13" + self.vf3_mac =3D "00:11:22:33:44:14" + =20 + self.used_dut_port =3D self.dut_ports[0] + localPort =3D self.tester.get_local_port(self.dut_ports[0]) + self.tester_itf =3D self.tester.get_interface(localPort) + self.pf_interface =3D self.dut.ports_info[self.used_dut_port]['int= f'] + self.pf_mac_address =3D self.dut.get_mac_address(0) + self.pf_pci =3D self.dut.ports_info[self.used_dut_port]['pci'] + + def set_up(self): + """ + This is to clear up environment before the case run. + """ + self.dut.kill_all() + + def setup_env(self, driver): + """ + This is to set up 1pf and 2vfs environment, the pf can be bond to + kernel driver or dpdk driver. + """ + if driver =3D=3D 'default': + for port_id in self.dut_ports: + port =3D self.dut.ports_info[port_id]['port'] + port.bind_driver() + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2, driver) + self.sriov_vfs_port =3D self.dut.ports_info[self.used_dut_port]['v= fs_port'] + if driver =3D=3D 'default': + self.dut.send_expect("ip link set %s vf 0 mac %s" % (self.pf_i= nterface, self.vf0_mac), "# ", 3) + self.dut.send_expect("ip link set %s vf 1 mac %s" %=20 + (self.pf_interface, self.vf1_mac), "# ", 3) + + try: + + for port in self.sriov_vfs_port: + port.bind_driver(driver=3Dself.drivername) + if driver =3D=3D 'default': + self.pf_kdriver_flag =3D 1 + else: + self.pf_ddriver_flag =3D 1 + except Exception as e: + self.destroy_env(driver) + raise Exception(e) + + def destroy_env(self, driver): + """ + This is to destroy 1pf and 2vfs environment. + """ + if driver =3D=3D self.drivername: + self.session_third.send_expect("quit", "# ") + time.sleep(2) + self.session_secondary.send_expect("quit", "# ") + time.sleep(2) + self.dut.send_expect("quit", "# ") + time.sleep(2) + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port) + if driver =3D=3D self.drivername: + self.pf_ddriver_flag =3D 0 + else: + self.pf_kdriver_flag =3D 0 + + def test_VEB_switching_inter_vfs(self): + """ + Kernel PF, then create 2VFs. VFs running dpdk testpmd, send traffi= c to + VF1, and set the packet's DEST MAC to VF2, check if VF2 can receiv= e=20 + the packets. Check Inter VF-VF MAC switch. + """ + self.setup_env(driver=3D'default') + self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 10= 24,1024 -w %s --file-prefix=3Dtest1 -- -i --crc-strip --eth-peer=3D0,%s" % = (self.target, self.sriov_vfs_port[0].pci, self.vf1_mac), "testpmd>", 120) + self.dut.send_expect("set fwd txonly", "testpmd>") + self.dut.send_expect("set promisc all off", "testpmd>") + + self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 = --socket-mem 1024,1024 -w %s --file-prefix=3Dtest2 -- -i --crc-strip" % (se= lf.target, self.sriov_vfs_port[1].pci), "testpmd>", 120) + self.session_secondary.send_expect("set fwd rxonly", "testpmd>") + self.session_secondary.send_expect("set promisc all off", "testpmd= >") + self.session_secondary.send_expect("start", "testpmd>", 5) + self.dut.send_expect("start", "testpmd>", 5) + time.sleep(2) + =20 + self.dut.send_expect("stop", "testpmd>", 5) =20 + self.session_secondary.send_expect("stop", "testpmd>", 5) + + vf0_tx_stats =3D self.veb_get_pmd_stats("first", 0, "tx") + vf1_rx_stats =3D self.veb_get_pmd_stats("second", 0, "rx") + self.verify(vf0_tx_stats[0] !=3D 0, "no packet was sent by VF0") + self.verify(vf0_tx_stats[0] * 0.5 < vf1_rx_stats[0], "VF1 failed t= o receive packets from VF0") =20 + + def test_VEB_switching_inter_vfs_mac_fwd(self): + """ + Kernel PF, then create 2VFs. VFs running dpdk testpmd, send traffi= c to + VF1, and set the packet's DEST MAC to VF2, check if VF2 can receiv= e=20 + the packets. Check Inter VF-VF MAC switch. + """ + self.setup_env(driver=3D'default') + self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 10= 24,1024 -w %s --file-prefix=3Dtest1 -- -i --crc-strip --eth-peer=3D0,%s" % = (self.target, self.sriov_vfs_port[0].pci, self.vf1_mac), "testpmd>", 120) + self.dut.send_expect("set fwd mac", "testpmd>") + self.dut.send_expect("set promisc all off", "testpmd>") + self.dut.send_expect("start", "testpmd>") + time.sleep(2) + self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 = --socket-mem 1024,1024 -w %s --file-prefix=3Dtest2 -- -i --crc-strip" % (se= lf.target, self.sriov_vfs_port[1].pci), "testpmd>", 120) + self.session_secondary.send_expect("set fwd rxonly", "testpmd>") + self.session_secondary.send_expect("set promisc all off", "testpmd= >") + self.session_secondary.send_expect("start", "testpmd>") + time.sleep(2) + =20 + self.send_packet(self.vf0_mac, self.tester_itf) + + self.dut.send_expect("stop", "testpmd>", 2) + self.session_secondary.send_expect("stop", "testpmd>", 2) + + vf0_tx_stats =3D self.veb_get_pmd_stats("first", 0, "tx") + vf1_rx_stats =3D self.veb_get_pmd_stats("second", 0, "rx") + self.verify(vf0_tx_stats[0] !=3D 0, "no packet was sent by VF0") + self.verify(vf0_tx_stats =3D=3D vf1_rx_stats, "VF1 failed to=20 + receive packets from VF0") + =20 + def test_VEB_switching_inter_vfs_vlan(self): + """ + Kernel PF, then create 2VFs, assign VF1 with VLAN=3D1 in, VF2 with= =20 + VLAN=3D2. VFs are running dpdk testpmd, send traffic to VF1 with V= LAN=3D1, + then let it forwards to VF2, it should not work since they are not= in + the same VLAN; set VF2 with VLAN=3D1, then send traffic to VF1 wit= h + VLAN=3D1, and VF2 can receive the packets. Check inter VF MAC/VLAN= switch. + """ + self.setup_env(driver=3D'default') + # the two vfs belongs to different vlans + self.dut.send_expect("ip link set %s vf 0 vlan 1" % self.pf_interf= ace, "# ", 1) + self.dut.send_expect("ip link set %s vf 1 vlan 2" % self.pf_interf= ace, "# ", 1) + self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 10= 24,1024 -w %s --file-prefix=3Dtest1 -- -i --crc-strip --eth-peer=3D0,%s" % = (self.target, self.sriov_vfs_port[0].pci, self.vf1_mac), "testpmd>", 120) + self.dut.send_expect("set fwd mac", "testpmd>") + self.dut.send_expect("set promisc all off", "testpmd>") + self.dut.send_expect("start", "testpmd>") + time.sleep(2) + self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 = --socket-mem 1024,1024 -w %s --file-prefix=3Dtest2 -- -i --crc-strip" % (se= lf.target, self.sriov_vfs_port[1].pci), "testpmd>", 120) + self.session_secondary.send_expect("set fwd mac", "testpmd>") + self.session_secondary.send_expect("set promisc all off", "testpmd= >") + self.session_secondary.send_expect("start", "testpmd>") + time.sleep(2) + + self.send_packet(self.vf0_mac, self.tester_itf, "vlan") + + self.dut.send_expect("stop", "testpmd>", 2) + self.session_secondary.send_expect("stop", "testpmd>", 2) + + vf0_tx_stats =3D self.veb_get_pmd_stats("first", 0, "tx") + vf1_rx_stats =3D self.veb_get_pmd_stats("second", 0, "rx") + self.verify(vf0_tx_stats[0] !=3D 0, "no packet was sent by VF0") + self.verify((vf0_tx_stats[0] =3D=3D 1) and (vf1_rx_stats[0] =3D=3D= 0), "VF1 received packets from VF0, the vlan filter doen't work") + self.dut.send_expect("quit", "# ") + time.sleep(2) + self.session_secondary.send_expect("quit", "# ") + time.sleep(2) + =20 + # the two vfs belongs to the same vlan + self.dut.send_expect("ip link set %s vf 1 vlan 1" % self.pf_interf= ace, "# ", 1) + self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 10= 24,1024 -w %s --file-prefix=3Dtest1 -- -i --crc-strip --eth-peer=3D0,%s" % = (self.target, self.sriov_vfs_port[0].pci, self.vf1_mac), "testpmd>", 120) + self.dut.send_expect("set fwd mac", "testpmd>") + self.dut.send_expect("set promisc all off", "testpmd>") + self.dut.send_expect("start", "testpmd>") + time.sleep(2) + self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 = --socket-mem 1024,1024 -w %s --file-prefix=3Dtest2 -- -i --crc-strip" % (se= lf.target, self.sriov_vfs_port[1].pci), "testpmd>", 120) + self.session_secondary.send_expect("set fwd mac", "testpmd>") + self.session_secondary.send_expect("set promisc all off", "testpmd= >") + self.session_secondary.send_expect("start", "testpmd>") + time.sleep(2) + + self.send_packet(self.vf0_mac, self.tester_itf, "vlan") + + self.dut.send_expect("stop", "testpmd>", 2) + self.session_secondary.send_expect("stop", "testpmd>", 2) + + vf0_tx_stats =3D self.veb_get_pmd_stats("first", 0, "tx") + vf1_rx_stats =3D self.veb_get_pmd_stats("second", 0, "rx") + self.verify(vf0_tx_stats[0] !=3D 0, "no packet was sent by VF0") + self.verify((vf0_tx_stats[0] =3D=3D 1) and (vf1_rx_stats[0] =3D=3D= 1),=20 + "VF1 didn't receive packets from VF0, the vlan filter doen't work") + + def test_VEB_switching_inter_vfs_and_pf(self): + """ + DPDK PF, then create 2VFs, PF in the host running dpdk testpmd, VF= s + running dpdk testpmd, VF1 send traffic to VF2, check if VF2 can re= ceive + the packets. send tracfic from PF to VF1, ensure PF->VF1; send tra= ffic + from VF1 to PF, ensure VF1->PF can work. + """ + # VF->PF + self.setup_env(driver=3Dself.drivername) + self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 10= 24,1024 -w %s --file-prefix=3Dtest1 -- -i" % (self.target, self.pf_pci), "t= estpmd>", 120) + self.dut.send_expect("set fwd rxonly", "testpmd>") + self.dut.send_expect("set promisc all off", "testpmd>") + self.dut.send_expect("start", "testpmd>") + time.sleep(2) + self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 = --socket-mem 1024,1024 -w %s --file-prefix=3Dtest2 -- -i --crc-strip --eth-= peer=3D0,%s" % (self.target, self.sriov_vfs_port[0].pci, self.pf_mac_addres= s), "testpmd>", 120) + self.session_secondary.send_expect("set fwd txonly", "testpmd>") + self.session_secondary.send_expect("set promisc all off", "testpmd= >") + self.session_secondary.send_expect("start", "testpmd>") + time.sleep(2) + + self.session_secondary.send_expect("stop", "testpmd>", 2) + self.dut.send_expect("stop", "testpmd>", 2) + + vf0_tx_stats =3D self.veb_get_pmd_stats("second", 0, "tx") + pf_rx_stats =3D self.veb_get_pmd_stats("first", 0, "rx") + self.verify(vf0_tx_stats[0] !=3D 0, "no packet was sent by VF0") + self.verify(pf_rx_stats[0] !=3D 0, "no packet was received by PF") + self.verify(vf0_tx_stats[0]*0.5 < pf_rx_stats[0], "PF failed to re= ceive most packets from VF0") + self.session_secondary.send_expect("quit", "# ") + time.sleep(2) =20 + self.dut.send_expect("quit", "# ") + time.sleep(2) +=20 + #PF->VF + self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 10= 24,1024 -w %s --file-prefix=3Dtest1 -- -i --eth-peer=3D0,%s" % (self.target= , self.pf_pci, self.vf0_mac), "testpmd>", 120) + self.dut.send_expect("set fwd txonly", "testpmd>") + self.dut.send_expect("set promisc all off", "testpmd>") + =20 + self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 = --socket-mem 1024,1024 -w %s --file-prefix=3Dtest2 -- -i --crc-strip" % (se= lf.target, self.sriov_vfs_port[0].pci), "testpmd>", 120) + self.session_secondary.send_expect("mac_addr add 0 %s" % self.vf0_= mac, "testpmd>") + self.session_secondary.send_expect("set fwd rxonly", "testpmd>") + self.session_secondary.send_expect("set promisc all off", "testpmd= >") + self.session_secondary.send_expect("start", "testpmd>") + time.sleep(2) + self.dut.send_expect("start", "testpmd>") + time.sleep(2) + + self.dut.send_expect("stop", "testpmd>", 2) + self.session_secondary.send_expect("stop", "testpmd>", 2) + + vf0_rx_stats =3D self.veb_get_pmd_stats("second", 0, "rx") + pf_tx_stats =3D self.veb_get_pmd_stats("first", 0, "tx") + self.verify(pf_tx_stats[0] !=3D 0, "no packet was sent by PF") + self.verify(vf0_rx_stats[0] !=3D 0, "no packet was received by VF0= ") + self.verify(vf0_rx_stats[0] > pf_tx_stats[0]*0.5, "VF0 failed to r= eceive most packets from PF") + self.session_secondary.send_expect("quit", "# ") + time.sleep(2) + self.dut.send_expect("quit", "# ") + time.sleep(2) + + # tester->VF + self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 10= 24,1024 -w %s --file-prefix=3Dtest1 -- -i" % (self.target, self.pf_pci), "t= estpmd>", 120) + self.dut.send_expect("set fwd mac", "testpmd>") + self.dut.send_expect("set promisc all off", "testpmd>") + self.dut.send_expect("start", "testpmd>") + time.sleep(2) + + self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 = --socket-mem 1024,1024 -w %s --file-prefix=3Dtest2 -- -i --crc-strip" % (se= lf.target, self.sriov_vfs_port[0].pci), "testpmd>", 120) + self.session_secondary.send_expect("mac_addr add 0 %s" % self.vf0_= mac, "testpmd>") + self.session_secondary.send_expect("set fwd rxonly", "testpmd>") + self.session_secondary.send_expect("set promisc all off", "testpmd= >") + self.session_secondary.send_expect("start", "testpmd>") + time.sleep(2) + + self.send_packet(self.vf0_mac, self.tester_itf) + time.sleep(2) + self.session_secondary.send_expect("stop", "testpmd>", 2) + self.dut.send_expect("stop", "testpmd>", 2) + vf0_rx_stats =3D self.veb_get_pmd_stats("second", 0, "rx") + pf_tx_stats =3D self.veb_get_pmd_stats("first", 0, "tx") + self.verify(pf_tx_stats[0] =3D=3D 0, "PF received unexpected packe= t") + self.verify(vf0_rx_stats[0] =3D=3D 1, "no packet was received by=20 + VF0") +=20 + self.dut.send_expect("start", "testpmd>") + time.sleep(2) + self.session_secondary.send_expect("start", "testpmd>") + time.sleep(2) + self.send_packet(self.pf_mac_address, self.tester_itf) + time.sleep(2) + self.session_secondary.send_expect("stop", "testpmd>", 2) + self.dut.send_expect("stop", "testpmd>", 2) + vf0_rx_stats =3D self.veb_get_pmd_stats("second", 0, "rx") + pf_tx_stats =3D self.veb_get_pmd_stats("first", 0, "tx") + pf_rx_stats =3D self.veb_get_pmd_stats("first", 0, "rx") + self.verify(pf_tx_stats[0] =3D=3D 1, "no packet was sent by VF0") + self.verify(pf_rx_stats[0] =3D=3D 1, "no packet was received by VF= 0") + self.verify(vf0_rx_stats[0] =3D=3D 1, "no packet was received by V= F0") + self.session_secondary.send_expect("quit", "# ") + time.sleep(2) + self.dut.send_expect("quit", "# ") + time.sleep(2) + + # VF1->VF2 + self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 10= 24,1024 -w %s --file-prefix=3Dtest1 -- -i" % (self.target, self.pf_pci), "t= estpmd>", 120) + self.dut.send_expect("set promisc all off", "testpmd>") + + self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 = --socket-mem 1024,1024 -w %s --file-prefix=3Dtest2 -- -i --crc-strip --eth-= peer=3D0,%s" % (self.target, self.sriov_vfs_port[0].pci, self.vf1_mac), "te= stpmd>", 120) + self.session_secondary.send_expect("set fwd txonly", "testpmd>") + self.session_secondary.send_expect("set promisc all off", "testpmd= >") + time.sleep(2) + + self.session_third.send_expect("./%s/app/testpmd -c 0xf00 -n 4 --s= ocket-mem 1024,1024 -w %s --file-prefix=3Dtest3 -- -i --crc-strip" % (self.= target, self.sriov_vfs_port[1].pci), "testpmd>", 120) + self.session_third.send_expect("mac_addr add 0 %s" % self.vf1_mac,= "testpmd>") + self.session_third.send_expect("set fwd rxonly", "testpmd>") + self.session_third.send_expect("set promisc all off", "testpmd>") + self.session_third.send_expect("start", "testpmd>") + self.session_secondary.send_expect("start", "testpmd>") =20 + time.sleep(2) + + self.session_secondary.send_expect("stop", "testpmd>", 5) + self.session_third.send_expect("stop", "testpmd>", 5) + =20 + vf0_tx_stats =3D self.veb_get_pmd_stats("second", 0, "tx") + vf1_rx_stats =3D self.veb_get_pmd_stats("third", 0, "rx") + self.verify(vf0_tx_stats[0] !=3D 0, "no packet was sent by VF0") + self.verify(vf0_tx_stats[0] * 0.5 < vf1_rx_stats[0], "VF1=20 + failed to receive packets from VF0") + + =20 + def tear_down(self): + """ + Run after each test case. + """ + if self.pf_kdriver_flag =3D=3D 1: + self.destroy_env(driver=3D'default') + if self.pf_ddriver_flag =3D=3D 1: + self.destroy_env(driver=3Dself.drivername) + + self.dut.kill_all() + =20 + + def tear_down_all(self): + """ + Run after each test suite. + """ + self.dut.kill_all() + self.dut.close_session(self.session_secondary) + self.dut.close_session(self.session_third) + # Marvin recommended that all the dut ports should be bound to DPD= K. + for port_id in self.dut_ports: + port =3D self.dut.ports_info[port_id]['port'] + port.bind_driver(driver=3Dself.drivername) + -- 2.5.0