* [dts] [PATCH 1/2] tests add TestSuite_VEB.py
@ 2016-10-14 13:50 Yuan Peng
2016-10-14 13:50 ` [dts] [PATCH 2/2] tests add TestSuite_VEB Yuan Peng
2016-10-14 14:40 ` [dts] [PATCH 1/2] tests add TestSuite_VEB.py Liu, Yong
0 siblings, 2 replies; 8+ messages in thread
From: Yuan Peng @ 2016-10-14 13:50 UTC (permalink / raw)
To: dts; +Cc: pengyuan
From: pengyuan <yuan.peng@intel.com>
Signed-off-by: pengyuan <yuan.peng@intel.com>
diff --git a/tests/TestSuite_VEB.py b/tests/TestSuite_VEB.py
new file mode 100644
index 0000000..6296ff1
--- /dev/null
+++ b/tests/TestSuite_VEB.py
@@ -0,0 +1,934 @@
+# 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
+# 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 VEB Switch and floating VEB Features by Poll Mode Drivers.
+"""
+
+import re
+import time
+
+import dts
+from virt_dut import VirtDut
+from project_dpdk import DPDKdut
+from dut import Dut
+from net_device import GetNicObj
+from net_device import RemoveNicObj
+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 == "vf0":
+ stats = self.pmdout.get_pmd_stats(portid)
+ elif vf0_vf1 == "vf1":
+ stats = self.pmdout_session_secondary.get_pmd_stats(portid)
+ else:
+ return None
+
+ if rx_tx == "rx":
+ return [stats['RX-packets'], stats['RX-errors'], stats['RX-bytes']]
+ elif rx_tx == "tx":
+ return [stats['TX-packets'], stats['TX-errors'], stats['TX-bytes']]
+ else:
+ return None
+
+ def veb_get_pmd_stats(self, dev, portid, rx_tx):
+ stats = {}
+ rx_pkts_prefix = "RX-packets:"
+ rx_bytes_prefix = "RX-bytes:"
+ rx_error_prefix = "RX-errors:"
+ tx_pkts_prefix = "TX-packets:"
+ tx_error_prefix = "TX-errors:"
+ tx_bytes_prefix = "TX-bytes:"
+
+ if dev == "first":
+ out = self.dut.send_expect("show port stats %d" % portid, "testpmd> ")
+ elif dev == "second":
+ out = self.session_secondary.send_expect("show port stats %d" % portid, "testpmd> ")
+ elif dev == "third":
+ out = self.session_third.send_expect("show port stats %d" % portid, "testpmd> ")
+ else:
+ return None
+
+ stats["RX-packets"] = self.veb_get_pmd_value(rx_pkts_prefix, out)
+ stats["RX-bytes"] = self.veb_get_pmd_value(rx_bytes_prefix, out)
+ stats["RX-errors"] = self.veb_get_pmd_value(rx_error_prefix, out)
+ stats["TX-packets"] = self.veb_get_pmd_value(tx_pkts_prefix, out)
+ stats["TX-errors"] = self.veb_get_pmd_value(tx_error_prefix, out)
+ stats["TX-bytes"] = self.veb_get_pmd_value(tx_bytes_prefix, out)
+
+ if rx_tx == "rx":
+ return [stats['RX-packets'], stats['RX-errors'], stats['RX-bytes']]
+ elif rx_tx == "tx":
+ return [stats['TX-packets'], stats['TX-errors'], stats['TX-bytes']]
+ else:
+ return None
+
+
+ def veb_get_pmd_value(self, prefix, out):
+ pattern = re.compile(prefix + "(\s+)([0-9]+)")
+ m = pattern.search(out)
+ if m is None:
+ return None
+ else:
+ return int(m.group(2))
+
+ def send_packet(self, vf_mac, itf, tran_type=""):
+ """
+ Send 1 packet
+ """
+ self.tester.scapy_foreground()
+ self.tester.scapy_append('sys.path.append("./")')
+ self.dut.send_expect("start", "testpmd>")
+ mac = self.dut.get_mac_address(0)
+
+ if tran_type == "vlan":
+ packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/Dot1Q(vlan=1)/IP(src="192.168.0.1", dst="192.168.0.2")], iface="%s")' % (vf_mac, itf, itf)
+ self.tester.scapy_append(packet)
+ self.tester.scapy_execute()
+ time.sleep(.5)
+ else:
+ packet = r'sendp([Ether(dst="%s", src=get_if_hwaddr("%s"))/IP(src="192.168.0.1", dst="192.168.0.2")], iface="%s")' % (vf_mac, itf, itf)
+ self.tester.scapy_append(packet)
+ self.tester.scapy_execute()
+ time.sleep(.5)
+
+ #
+ # Test cases.
+ #
+
+ 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 = self.dut.get_ports(self.nic)
+ self.verify(len(self.dut_ports) >= 1, "Insufficient ports")
+ # self.rx_port = self.dut_ports[0]
+ # self.tx_port = self.dut_ports[0]
+
+ # cores = self.dut.get_core_list("1S/2C/1T")
+ # self.coremask = dts.create_mask(cores)
+
+ # self.port_mask = dts.create_mask([self.rx_port, self.tx_port])
+ self.session_secondary = self.dut.new_session()
+ self.session_third = self.dut.new_session()
+ # self.pmdout = PmdOutput(self.dut)
+ # self.pmdout_session_secondary = PmdOutput(self.session_secondary)
+
+ def set_up(self):
+ """
+ This is to clear up environment before the case run.
+ """
+ self.dut.kill_all()
+ self.setup_1pf_kdriver_2vf_env_flag = 0
+ self.setup_1pf_ddriver_1vf_env_flag = 0
+ self.setup_1pf_ddriver_2vf_env_flag = 0
+ self.setup_1pf_ddriver_4vf_env_flag = 0
+ self.vf0_mac = "00:11:22:33:44:11"
+ self.vf1_mac = "00:11:22:33:44:12"
+ self.vf2_mac = "00:11:22:33:44:13"
+ self.vf3_mac = "00:11:22:33:44:14"
+
+ def setup_1pf_ddriver_4vf_env(self, driver='default'):
+ self.used_dut_port = self.dut_ports[0]
+ localPort = self.tester.get_local_port(self.dut_ports[0])
+ self.tester_itf = self.tester.get_interface(localPort)
+ self.pf_interface = self.dut.ports_info[self.used_dut_port]['intf']
+ self.pf_mac_address = self.dut.get_mac_address(0)
+ self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
+ self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
+ self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 4, driver='igb_uio')
+ self.sriov_vfs_port = self.dut.ports_info[self.used_dut_port]['vfs_port']
+ self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
+ try:
+
+ for port in self.sriov_vfs_port:
+ print port.pci
+ self.dut.send_expect("./tools/dpdk-devbind.py -b igb_uio %s" % (port.pci), "# ", 3)
+ self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
+ time.sleep(1)
+ vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
+ vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
+ vf2_prop = {'opt_host': self.sriov_vfs_port[2].pci}
+ vf3_prop = {'opt_host': self.sriov_vfs_port[3].pci}
+ for port_id in self.dut_ports:
+ if port_id == self.used_dut_port:
+ continue
+ port = self.dut.ports_info[port_id]['port']
+ port.bind_driver()
+
+ self.setup_1pf_ddriver_4vf_env_flag = 1
+ except Exception as e:
+ self.destroy_1pf_ddriver_4vf_env()
+ raise Exception(e)
+
+ def destroy_1pf_ddriver_4vf_env(self):
+ self.session_third.send_expect("quit", "# ")
+ self.session_secondary.send_expect("quit", "# ")
+ self.dut.send_expect("quit", "# ")
+ self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
+ port = self.dut.ports_info[self.used_dut_port]['port']
+ port.bind_driver()
+ self.used_dut_port = None
+
+ for port_id in self.dut_ports:
+ port = self.dut.ports_info[port_id]['port']
+ port.bind_driver()
+
+ self.setup_1pf_ddriver_4vf_env_flag = 0
+
+ def setup_1pf_ddriver_2vf_env(self, driver='default'):
+ self.used_dut_port = self.dut_ports[0]
+ localPort = self.tester.get_local_port(self.dut_ports[0])
+ self.tester_itf = self.tester.get_interface(localPort)
+ self.pf_interface = self.dut.ports_info[self.used_dut_port]['intf']
+ self.pf_mac_address = self.dut.get_mac_address(0)
+ self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
+ self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
+ self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2, driver='igb_uio')
+ self.sriov_vfs_port = self.dut.ports_info[self.used_dut_port]['vfs_port']
+ self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
+ try:
+
+ for port in self.sriov_vfs_port:
+ print port.pci
+ self.dut.send_expect("./tools/dpdk-devbind.py -b igb_uio %s" % (port.pci), "# ", 3)
+ self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
+ time.sleep(1)
+ vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
+ vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
+ for port_id in self.dut_ports:
+ if port_id == self.used_dut_port:
+ continue
+ port = self.dut.ports_info[port_id]['port']
+ port.bind_driver()
+
+ self.setup_1pf_ddriver_2vf_env_flag = 1
+ except Exception as e:
+ self.destroy_1pf_ddriver_2vf_env()
+ raise Exception(e)
+
+ def destroy_1pf_ddriver_2vf_env(self):
+ self.session_third.send_expect("quit", "# ")
+ self.session_secondary.send_expect("quit", "# ")
+ self.dut.send_expect("quit", "# ")
+ self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
+ port = self.dut.ports_info[self.used_dut_port]['port']
+ port.bind_driver()
+ self.used_dut_port = None
+
+ for port_id in self.dut_ports:
+ port = self.dut.ports_info[port_id]['port']
+ port.bind_driver()
+
+ self.setup_1pf_ddriver_2vf_env_flag = 0
+
+ def setup_1pf_ddriver_1vf_env(self, driver='default'):
+ self.used_dut_port = self.dut_ports[0]
+ localPort = self.tester.get_local_port(self.dut_ports[0])
+ self.tester_itf = self.tester.get_interface(localPort)
+ self.pf_interface = self.dut.ports_info[self.used_dut_port]['intf']
+ self.pf_mac_address = self.dut.get_mac_address(0)
+ self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
+ self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
+ # self.dut.send_expect("echo 1 > /sys/bus/pci/devices/%s/max_vfs" % self.pf_pci, "# ", 3)
+ self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 1, driver='igb_uio')
+ self.sriov_vfs_port = self.dut.ports_info[self.used_dut_port]['vfs_port']
+ self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
+
+ try:
+
+ for port in self.sriov_vfs_port:
+ print port.pci
+ self.dut.send_expect("./tools/dpdk-devbind.py -b igb_uio %s" % (port.pci), "# ", 3)
+ self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
+ time.sleep(1)
+ vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
+
+ for port_id in self.dut_ports:
+ if port_id == self.used_dut_port:
+ continue
+ port = self.dut.ports_info[port_id]['port']
+ port.bind_driver()
+
+ self.setup_1pf_ddriver_1vf_env_flag = 1
+ except Exception as e:
+ self.destroy_1pf_ddriver_1vf_env()
+ raise Exception(e)
+
+ def destroy_1pf_ddriver_1vf_env(self):
+
+ self.session_secondary.send_expect("quit", "# ")
+ self.dut.send_expect("quit", "# ")
+ self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
+ port = self.dut.ports_info[self.used_dut_port]['port']
+ port.bind_driver()
+ self.used_dut_port = None
+
+ for port_id in self.dut_ports:
+ port = self.dut.ports_info[port_id]['port']
+ port.bind_driver()
+
+ self.setup_1pf_ddriver_1vf_env_flag = 0
+
+ def setup_1pf_kdriver_2vf_env(self, driver='default'):
+ self.used_dut_port = self.dut_ports[0]
+ localPort = self.tester.get_local_port(self.dut_ports[0])
+ self.tester_itf = self.tester.get_interface(localPort)
+ for port_id in self.dut_ports:
+ port = self.dut.ports_info[port_id]['port']
+ port.bind_driver()
+ self.pf_interface = self.dut.ports_info[self.used_dut_port]['intf']
+ self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2, driver=driver)
+ self.sriov_vfs_port = self.dut.ports_info[self.used_dut_port]['vfs_port']
+ #self.vf0_mac = "00:11:22:33:44:11"
+ #self.vf1_mac = "00:11:22:33:44:12"
+ self.dut.send_expect("ip link set %s vf 0 mac %s" % (self.pf_interface, self.vf0_mac), "# ", 3)
+ self.dut.send_expect("ip link set %s vf 1 mac %s" % (self.pf_interface, self.vf1_mac), "# ", 3)
+
+ try:
+
+ for port in self.sriov_vfs_port:
+ print port.pci
+ self.dut.send_expect("./tools/dpdk-devbind.py -b igb_uio %s" % (port.pci), "# ", 3)
+ self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
+ time.sleep(1)
+ vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
+ vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
+
+ # for port_id in self.dut_ports:
+ # if port_id == self.used_dut_port:
+ # continue
+ # port = self.dut.ports_info[port_id]['port']
+ # port.bind_driver()
+
+ self.setup_1pf_kdriver_2vf_env_flag = 1
+ except Exception as e:
+ self.destroy_1pf_kdriver_2vf_env()
+ raise Exception(e)
+
+ def destroy_1pf_kdriver_2vf_env(self):
+
+ self.session_secondary.send_expect("quit", "# ")
+ self.dut.send_expect("quit", "# ")
+ self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
+ port = self.dut.ports_info[self.used_dut_port]['port']
+ port.bind_driver()
+ self.used_dut_port = None
+
+ for port_id in self.dut_ports:
+ port = self.dut.ports_info[port_id]['port']
+ port.bind_driver()
+
+ self.setup_1pf_kdriver_2vf_env_flag = 0
+
+ def test_VEB_switching_inter_vfs_MAC_switch_rxtx(self):
+ """
+ Kernel PF, then create 2VFs. VFs running dpdk testpmd, send traffic to VF1, and set the packet's DEST MAC to VF2, check if VF2 can receive the packets. Check Inter VF-VF MAC switch.
+ """
+ self.setup_1pf_kdriver_2vf_env(driver='')
+ self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci, "testpmd>", 120)
+ self.dut.send_expect("set fwd txonly", "testpmd>")
+ self.dut.send_expect("set promisc all off", "testpmd>")
+
+ self.session_secondary.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % 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)
+
+ self.dut.send_expect("stop", "testpmd>", 5)
+ self.session_secondary.send_expect("stop", "testpmd>", 5)
+
+ vf0_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
+ vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
+ self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
+ self.verify(vf0_tx_stats[0] * 0.5 < vf1_rx_stats[0], "VF1 failed to receive packets from VF0")
+
+ def test_VEB_switching_inter_vfs_MAC_switch_fwd(self):
+ """
+ Kernel PF, then create 2VFs. VFs running dpdk testpmd, send traffic to VF1, and set the packet's DEST MAC to VF2, check if VF2 can receive the packets. Check Inter VF-VF MAC switch.
+ """
+ self.setup_1pf_kdriver_2vf_env(driver='')
+ self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci, "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("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % 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)
+
+ 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 = self.veb_get_pmd_stats("first", 0, "tx")
+ vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
+ self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
+ self.verify(vf0_tx_stats == vf1_rx_stats, "VF1 failed to receive packets from VF0")
+
+ def test_VEB_switching_inter_vfs_MAC_switch_vlan(self):
+ """
+ Kernel PF, then create 2VFs, assign VF1 with VLAN=1 in, VF2 with VLAN=2. VFs are running dpdk testpmd, send traffic to VF1 with VLAN=1, then let it forwards to VF2, it should not work since they are not in the same VLAN; set VF2 with VLAN=1, then send traffic to VF1 with VLAN=1, and VF2 can receive the packets. Check inter VF MAC/VLAN switch.
+ """
+ self.setup_1pf_kdriver_2vf_env(driver='')
+ # the two vfs belongs to different vlans
+ self.dut.send_expect("ip link set %s vf 0 vlan 1" % self.pf_interface, "# ", 1)
+ self.dut.send_expect("ip link set %s vf 1 vlan 2" % self.pf_interface, "# ", 1)
+ self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci, "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("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % 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)
+
+ 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 = self.veb_get_pmd_stats("first", 0, "tx")
+ vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
+ self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
+ self.verify((vf0_tx_stats[0] == 1) and (vf1_rx_stats[0] == 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)
+
+ # the two vfs belongs to the same vlan
+ self.dut.send_expect("ip link set %s vf 1 vlan 1" % self.pf_interface, "# ", 1)
+ self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci, "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("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % 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)
+
+ 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 = self.veb_get_pmd_stats("first", 0, "tx")
+ vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
+ self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
+ self.verify((vf0_tx_stats[0] == 1) and (vf1_rx_stats[0] == 1), "VF1 didn't receive packets from VF0, the vlan filter doen't work")
+
+ def test_VEB_switching_inter_pf_vf_MAC_switch(self):
+ """
+ DPDK PF, then create 1VF, PF in the host running dpdk testpmd, send traffic from PF to VF1, ensure PF->VF1(let VF1 in promisc mode); send traffic from VF1 to PF, ensure VF1->PF can work.
+ """
+ # VF->PF
+ self.setup_1pf_ddriver_1vf_env(driver='')
+ self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" % self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip --eth-peer=0,%s" % (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
+ pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
+ self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
+ self.verify(pf_rx_stats[0] != 0, "no packet was received by PF")
+ self.verify(vf0_tx_stats[0]*0.5 < pf_rx_stats[0], "PF failed to receive most packets from VF0")
+ self.session_secondary.send_expect("quit", "# ")
+ time.sleep(2)
+ self.dut.send_expect("quit", "# ")
+ time.sleep(2)
+
+ #PF->VF
+ self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --eth-peer=0,%s" % (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>")
+
+ self.session_secondary.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
+ pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
+ self.verify(pf_tx_stats[0] != 0, "no packet was sent by PF")
+ self.verify(vf0_rx_stats[0] != 0, "no packet was received by VF0")
+ self.verify(vf0_rx_stats[0] > pf_tx_stats[0]*0.5, "VF0 failed to receive 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("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" % self.pf_pci, "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("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
+ pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
+ self.verify(pf_tx_stats[0] == 0, "PF received unexpected packet")
+ self.verify(vf0_rx_stats[0] == 1, "no packet was received by VF0")
+
+ 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 = self.veb_get_pmd_stats("second", 0, "rx")
+ pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
+ pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
+ self.verify(pf_tx_stats[0] == 1, "no packet was sent by VF0")
+ self.verify(pf_rx_stats[0] == 1, "no packet was received by VF0")
+ self.verify(vf0_rx_stats[0] == 1, "no packet was received by VF0")
+
+ def test_floating_VEB_switching_inter_pf_vf_MAC_switch(self):
+ """
+ DPDK PF, then create 1VF, PF in the host running dpdk testpmd, send traffic from PF to VF0, VF0 can't receive any packets; send traffic from VF0 to PF, PF can't rec eive any packets either.
+ """
+ # VF->PF
+ self.setup_1pf_ddriver_1vf_env(driver='')
+ self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-prefix=test1 -- -i" % self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip --eth-peer=0,%s" % (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
+ pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
+ self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
+ self.verify(pf_rx_stats[0] == 0, "PF can receive packet from VF0, the floating VEB doesn't work")
+ self.session_secondary.send_expect("quit", "# ")
+ time.sleep(2)
+ self.dut.send_expect("quit", "# ")
+ time.sleep(2)
+
+ #PF->VF
+ self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-prefix=test1 -- -i --eth-peer=0,%s" % (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>")
+
+ self.session_secondary.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
+ pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
+ self.verify(pf_tx_stats[0] != 0, "no packet was sent by PF")
+ self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from PF, the floating VEB doesn't work")
+ self.session_secondary.send_expect("quit", "# ")
+ time.sleep(2)
+ self.dut.send_expect("quit", "# ")
+ time.sleep(2)
+
+ #outside world ->VF
+ self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-prefix=test1 -- -i --eth-peer=0,%s" % (self.pf_pci, self.vf0_mac), "testpmd>", 120)
+ self.dut.send_expect("set fwd mac", "testpmd>")
+ self.dut.send_expect("set promisc all on", "testpmd>")
+ self.dut.send_expect("start", "testpmd>")
+ time.sleep(2)
+
+ self.session_secondary.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % (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 mac", "testpmd>")
+ self.session_secondary.send_expect("set promisc all on", "testpmd>")
+ self.session_secondary.send_expect("start", "testpmd>")
+ time.sleep(2)
+
+ self.send_packet(self.vf0_mac, self.tester_itf)
+ time.sleep(2)
+ self.dut.send_expect("stop", "testpmd>", 2)
+ self.session_secondary.send_expect("stop", "testpmd>", 2)
+
+ vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
+ self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from outside world, the floating VEB doesn't work")
+
+ def test_floating_VEB_switching_inter_vfs_MAC_switch(self):
+ """
+ 1 DPDK PF, then create 2VF, PF in the host running dpdk testpmd, and VF0 are running dpdk testpmd, VF0 send traffic, and set the packet's DEST MAC to VF1, check if VF1 can receive the packets. Check Inter VF-VF MAC switch when PF is link down as well as up.
+ """
+ # PF link up, VF0->VF1
+ self.setup_1pf_ddriver_2vf_env(driver='')
+ # start PF
+ self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-prefix=test1 -- -i" % self.pf_pci, "testpmd>", 120)
+ self.dut.send_expect("port start all", "testpmd>")
+ time.sleep(2)
+ # start VF0
+ self.session_secondary.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % 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)
+ # start VF1
+ self.session_third.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test3 -- -i --crc-strip --eth-peer=0,%s" % (self.sriov_vfs_port[1].pci, self.vf0_mac), "testpmd>", 120)
+ self.session_third.send_expect("set fwd txonly", "testpmd>")
+ self.session_third.send_expect("set promisc all off", "testpmd>")
+ self.session_third.send_expect("start", "testpmd>")
+ time.sleep(2)
+
+ self.session_third.send_expect("stop", "testpmd>", 2)
+ self.session_secondary.send_expect("stop", "testpmd>", 2)
+
+ vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
+ vf1_tx_stats = self.veb_get_pmd_stats("third", 0, "tx")
+ self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
+ self.verify(vf0_rx_stats[0] != 0, "no packet was received by VF0")
+ self.verify(vf1_tx_stats[0]*0.5 < vf0_rx_stats[0], "VF0 failed to receive most packets from VF1")
+
+ # PF link down, VF0 -> VF1
+ self.dut.send_expect("port stop all", "Port 0 Link Down", 20)
+ self.session_secondary.send_expect("start", "testpmd>")
+ time.sleep(2)
+ self.session_third.send_expect("start", "testpmd>")
+ time.sleep(2)
+ self.session_third.send_expect("stop", "testpmd>", 2)
+ self.session_secondary.send_expect("stop", "testpmd>", 2)
+ self.dut.send_expect("stop", "testpmd>", 2)
+
+ vf1_tx_stats_pfstop = self.veb_get_pmd_stats("third", 0, "tx")
+ vf0_rx_stats_pfstop = self.veb_get_pmd_stats("second", 0, "rx")
+ vf1_tx_stats_pfstop[0] = vf1_tx_stats_pfstop[0] - vf1_tx_stats[0]
+ vf0_rx_stats_pfstop[0] = vf0_rx_stats_pfstop[0] - vf0_rx_stats[0]
+ self.verify(vf1_tx_stats_pfstop[0] != 0, "no packet was sent by VF1")
+ self.verify(vf0_rx_stats_pfstop[0] != 0, "no packet was received by VF0")
+ self.verify(vf1_tx_stats_pfstop[0]*0.5 < vf0_rx_stats_pfstop[0], "VF0 failed to receive most packets from VF1")
+
+ def test_floating_VEB_VF_cannot_communicate_with_legacy_VEB_VF(self):
+ """
+ DPDK PF, then create 4VF, VF0,VF2,VF3 are floating VEB; VF1 is lagecy VEB. Make PF link down(the cable can be pluged out), VFs are running dpdk testpmd.
+ 1. VF0 send traffic, and set the packet's DEST MAC to VF1, check VF1 can not receive the packets.
+ 2. VF1 send traffic, and set the packet's DEST MAC to VF0, check VF0 can not receive the packets.
+ 3. VF0 send traffic, and set the packet's DEST MAC to VF2, check VF2 can receive the packets.
+ 4. VF3 send traffic, and set the packet's DEST MAC to VF2, check VF2 can receive the packets.
+ """
+ self.setup_1pf_ddriver_4vf_env(driver='')
+ # start PF
+ self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 \"-w %s,enable_floating_veb=1,floating_veb_list=0;2-3\" --file-prefix=test1 -- -i" % self.pf_pci, "testpmd>", 120)
+ self.dut.send_expect("port start all", "testpmd>")
+ time.sleep(2)
+ # VF1->VF0
+ # start VF0
+ self.session_secondary.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip --eth-peer=0,%s" % (self.sriov_vfs_port[0].pci, self.vf1_mac), "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>")
+ # start VF1
+ self.session_third.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test3 -- -i --crc-strip --eth-peer=0,%s" % (self.sriov_vfs_port[1].pci, self.vf0_mac), "testpmd>", 120)
+ self.session_secondary.send_expect("mac_addr add 0 %s" % self.vf1_mac, "testpmd>")
+ self.session_third.send_expect("set fwd txonly", "testpmd>")
+ self.session_third.send_expect("set promisc all off", "testpmd>")
+
+ # PF link down
+ self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
+ self.session_secondary.send_expect("start", "testpmd>")
+ time.sleep(2)
+ self.session_third.send_expect("start", "testpmd>")
+ time.sleep(2)
+
+ self.session_third.send_expect("stop", "testpmd>", 2)
+ self.session_secondary.send_expect("stop", "testpmd>", 2)
+
+ vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
+ vf1_tx_stats = self.veb_get_pmd_stats("third", 0, "tx")
+ self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
+ self.verify(vf0_rx_stats[0] == 0, "floating_VEB VF can communicate with legacy_VEB VF")
+
+ # VF0->VF1
+ self.session_secondary.send_expect("set fwd txonly", "testpmd>")
+ self.session_third.send_expect("set fwd rxonly", "testpmd>")
+ self.session_third.send_expect("start", "testpmd>")
+ time.sleep(2)
+ self.session_secondary.send_expect("start", "testpmd>")
+ time.sleep(2)
+ self.session_secondary.send_expect("stop", "testpmd>", 2)
+ self.session_third.send_expect("stop", "testpmd>", 2)
+ vf1_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
+ vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
+ self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
+ self.verify(vf1_rx_stats[0] == 0, "floating_VEB VF can communicate with legacy_VEB VF")
+
+ self.session_secondary.send_expect("quit", "# ")
+ time.sleep(2)
+ self.session_third.send_expect("quit", "# ")
+ time.sleep(2)
+
+ # VF0->VF2
+ # start VF0
+ self.dut.send_expect("port start all", "testpmd>")
+ self.session_secondary.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip --eth-peer=0,%s" % (self.sriov_vfs_port[0].pci, self.vf2_mac), "testpmd>", 120)
+ self.session_secondary.send_expect("mac_addr add 0 %s" % self.vf0_mac, "testpmd>")
+ self.session_secondary.send_expect("set fwd txonly", "testpmd>")
+ self.session_secondary.send_expect("set promisc all off", "testpmd>")
+ # start VF2
+ self.session_third.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test3 -- -i --crc-strip" % self.sriov_vfs_port[2].pci, "testpmd>", 120)
+ self.session_third.send_expect("mac_addr add 0 %s" % self.vf2_mac, "testpmd>")
+ self.session_third.send_expect("set fwd rxonly", "testpmd>")
+ self.session_third.send_expect("set promisc all off", "testpmd>")
+
+ # PF link down
+ self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
+ self.session_third.send_expect("start", "testpmd>")
+ time.sleep(2)
+ self.session_secondary.send_expect("start", "testpmd>")
+ time.sleep(2)
+ self.session_secondary.send_expect("stop", "testpmd>", 2)
+ self.session_third.send_expect("stop", "testpmd>", 2)
+
+ vf2_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
+ vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
+ self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
+ self.verify(vf2_rx_stats[0] != 0, "floating_VEB VFs cannot communicate with each other")
+ self.verify(vf0_tx_stats[0] * 0.5 < vf2_rx_stats[0], "VF2 failed to receive packets from VF0")
+
+ self.session_secondary.send_expect("quit", "# ")
+ time.sleep(2)
+ self.session_third.send_expect("quit", "# ")
+ time.sleep(2)
+
+ # VF3->VF2
+ # start VF3
+ self.dut.send_expect("port start all", "testpmd>")
+ self.session_secondary.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip --eth-peer=0,%s" % (self.sriov_vfs_port[3].pci, self.vf2_mac), "testpmd>", 120)
+ self.session_secondary.send_expect("mac_addr add 0 %s" % self.vf0_mac, "testpmd>")
+ self.session_secondary.send_expect("set fwd txonly", "testpmd>")
+ self.session_secondary.send_expect("set promisc all off", "testpmd>")
+ # start VF2
+ self.session_third.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test3 -- -i --crc-strip" % self.sriov_vfs_port[2].pci, "testpmd>", 120)
+ self.session_third.send_expect("mac_addr add 0 %s" % self.vf2_mac, "testpmd>")
+ self.session_third.send_expect("set fwd rxonly", "testpmd>")
+ self.session_third.send_expect("set promisc all off", "testpmd>")
+
+ # PF link down
+ self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
+ self.session_third.send_expect("start", "testpmd>")
+ time.sleep(2)
+ self.session_secondary.send_expect("start", "testpmd>")
+ time.sleep(2)
+ self.session_secondary.send_expect("stop", "testpmd>", 2)
+ self.session_third.send_expect("stop", "testpmd>", 2)
+
+ vf2_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
+ vf3_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
+ self.verify(vf3_tx_stats[0] != 0, "no packet was sent by VF0")
+ self.verify(vf2_rx_stats[0] != 0, "floating_VEB VFs cannot communicate with each other")
+ self.verify(vf3_tx_stats[0] * 0.5 < vf2_rx_stats[0], "VF2 failed to receive packets from VF3")
+
+ def test_floating_VEB_and_legacy_VEB_switching_inter_pf_vf_MAC_switch(self):
+ """
+ DPDK PF, then create 2VFs, VF0 is in floating VEB, VF1 is in legacy VEB.
+ 1. Send traffic from VF0 to PF, then check PF will not see any traffic;
+ 2. Send traffic from VF1 to PF, then check PF will receive all the packets.
+ 3. send traffic from tester to VF0, check VF0 can't receive traffic from tester.
+ 4. send traffic from tester to VF1, check VF1 can receive all the traffic from tester.
+ """
+ self.setup_1pf_ddriver_2vf_env(driver='')
+ # VF0->PF
+ self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 \"-w %s,enable_floating_veb=1,floating_veb_list=0\" --file-prefix=test1 -- -i" % self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip --eth-peer=0,%s" % (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
+ pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
+ self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
+ self.verify(pf_rx_stats[0] == 0, "PF can receive packet from VF0, the floating VEB doesn't work")
+ self.session_secondary.send_expect("quit", "# ")
+ time.sleep(2)
+
+ # VF1->PF
+ self.session_secondary.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip --eth-peer=0,%s" % (self.sriov_vfs_port[1].pci, self.pf_mac_address), "testpmd>", 120)
+ self.session_secondary.send_expect("set fwd txonly", "testpmd>")
+ self.session_secondary.send_expect("set promisc all off", "testpmd>")
+ self.dut.send_expect("start", "testpmd>")
+ time.sleep(2)
+ 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)
+
+ vf1_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
+ pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
+ self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
+ self.verify(pf_rx_stats[0] != 0, "PF can't receive packet from VF1, the VEB doesn't work")
+ self.verify(vf1_tx_stats[0] * 0.5 < pf_rx_stats[0], "PF failed to receive packets from VF1")
+ self.session_secondary.send_expect("quit", "# ")
+ time.sleep(2)
+ self.dut.send_expect("quit", "# ")
+ time.sleep(2)
+
+ # tester->VF0
+ self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 \"-w %s,enable_floating_veb=1,floating_veb_list=0\" --file-prefix=test1 -- -i" % self.pf_pci, "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("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % (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 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)
+ time.sleep(2)
+ self.session_secondary.send_expect("stop", "testpmd>", 2)
+ self.dut.send_expect("stop", "testpmd>", 2)
+
+ vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
+ self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from outside world, the floating VEB doesn't work")
+ self.session_secondary.send_expect("quit", "# ")
+ time.sleep(2)
+
+ # tester->VF1
+ self.session_secondary.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % (self.sriov_vfs_port[1].pci), "testpmd>", 120)
+ self.session_secondary.send_expect("mac_addr add 0 %s" % self.vf1_mac, "testpmd>")
+ 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.vf1_mac, self.tester_itf)
+ time.sleep(2)
+ self.session_secondary.send_expect("stop", "testpmd>", 2)
+ self.dut.send_expect("stop", "testpmd>", 2)
+
+ vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
+ self.verify(vf1_rx_stats[0] == 1, "VF1 can't receive packet from outside world, the VEB doesn't work")
+
+ def tear_down(self):
+ """
+ Run after each test case.
+ """
+ if self.setup_1pf_kdriver_2vf_env_flag == 1:
+ self.destroy_1pf_kdriver_2vf_env()
+ if self.setup_1pf_ddriver_1vf_env_flag == 1:
+ self.destroy_1pf_ddriver_1vf_env()
+ if self.setup_1pf_ddriver_2vf_env_flag == 1:
+ self.destroy_1pf_ddriver_2vf_env()
+ if self.setup_1pf_ddriver_4vf_env_flag == 1:
+ self.destroy_1pf_ddriver_4vf_env()
+
+ self.dut.kill_all()
+
+ pass
+
+ 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)
+
+ pass
--
2.5.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [dts] [PATCH 2/2] tests add TestSuite_VEB
2016-10-14 13:50 [dts] [PATCH 1/2] tests add TestSuite_VEB.py Yuan Peng
@ 2016-10-14 13:50 ` Yuan Peng
2016-10-14 14:05 ` Liu, Yong
2016-10-14 14:40 ` [dts] [PATCH 1/2] tests add TestSuite_VEB.py Liu, Yong
1 sibling, 1 reply; 8+ messages in thread
From: Yuan Peng @ 2016-10-14 13:50 UTC (permalink / raw)
To: dts; +Cc: pengyuan
From: pengyuan <yuan.peng@intel.com>
Signed-off-by: pengyuan <yuan.peng@intel.com>
diff --git a/tests/TestSuite_VEB.py b/tests/TestSuite_VEB.py
index 6296ff1..9b97a97 100644
--- a/tests/TestSuite_VEB.py
+++ b/tests/TestSuite_VEB.py
@@ -145,17 +145,8 @@ class TestVEBSwitching(TestCase):
"NIC Unsupported: " + str(self.nic))
self.dut_ports = self.dut.get_ports(self.nic)
self.verify(len(self.dut_ports) >= 1, "Insufficient ports")
- # self.rx_port = self.dut_ports[0]
- # self.tx_port = self.dut_ports[0]
-
- # cores = self.dut.get_core_list("1S/2C/1T")
- # self.coremask = dts.create_mask(cores)
-
- # self.port_mask = dts.create_mask([self.rx_port, self.tx_port])
self.session_secondary = self.dut.new_session()
self.session_third = self.dut.new_session()
- # self.pmdout = PmdOutput(self.dut)
- # self.pmdout_session_secondary = PmdOutput(self.session_secondary)
def set_up(self):
"""
@@ -206,8 +197,11 @@ class TestVEBSwitching(TestCase):
def destroy_1pf_ddriver_4vf_env(self):
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)
port = self.dut.ports_info[self.used_dut_port]['port']
port.bind_driver()
@@ -252,8 +246,11 @@ class TestVEBSwitching(TestCase):
def destroy_1pf_ddriver_2vf_env(self):
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)
port = self.dut.ports_info[self.used_dut_port]['port']
port.bind_driver()
@@ -273,7 +270,6 @@ class TestVEBSwitching(TestCase):
self.pf_mac_address = self.dut.get_mac_address(0)
self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
- # self.dut.send_expect("echo 1 > /sys/bus/pci/devices/%s/max_vfs" % self.pf_pci, "# ", 3)
self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 1, driver='igb_uio')
self.sriov_vfs_port = self.dut.ports_info[self.used_dut_port]['vfs_port']
self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
@@ -301,7 +297,9 @@ class TestVEBSwitching(TestCase):
def destroy_1pf_ddriver_1vf_env(self):
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)
port = self.dut.ports_info[self.used_dut_port]['port']
port.bind_driver()
@@ -323,8 +321,6 @@ class TestVEBSwitching(TestCase):
self.pf_interface = self.dut.ports_info[self.used_dut_port]['intf']
self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2, driver=driver)
self.sriov_vfs_port = self.dut.ports_info[self.used_dut_port]['vfs_port']
- #self.vf0_mac = "00:11:22:33:44:11"
- #self.vf1_mac = "00:11:22:33:44:12"
self.dut.send_expect("ip link set %s vf 0 mac %s" % (self.pf_interface, self.vf0_mac), "# ", 3)
self.dut.send_expect("ip link set %s vf 1 mac %s" % (self.pf_interface, self.vf1_mac), "# ", 3)
@@ -337,13 +333,7 @@ class TestVEBSwitching(TestCase):
time.sleep(1)
vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
-
- # for port_id in self.dut_ports:
- # if port_id == self.used_dut_port:
- # continue
- # port = self.dut.ports_info[port_id]['port']
- # port.bind_driver()
-
+
self.setup_1pf_kdriver_2vf_env_flag = 1
except Exception as e:
self.destroy_1pf_kdriver_2vf_env()
@@ -352,7 +342,9 @@ class TestVEBSwitching(TestCase):
def destroy_1pf_kdriver_2vf_env(self):
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)
port = self.dut.ports_info[self.used_dut_port]['port']
port.bind_driver()
@@ -470,7 +462,7 @@ class TestVEBSwitching(TestCase):
self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
self.verify((vf0_tx_stats[0] == 1) and (vf1_rx_stats[0] == 1), "VF1 didn't receive packets from VF0, the vlan filter doen't work")
- def test_VEB_switching_inter_pf_vf_MAC_switch(self):
+ def test_VEB_switching_inter_vfs_pf_MAC_switch(self):
"""
DPDK PF, then create 1VF, PF in the host running dpdk testpmd, send traffic from PF to VF1, ensure PF->VF1(let VF1 in promisc mode); send traffic from VF1 to PF, ensure VF1->PF can work.
"""
--
2.5.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dts] [PATCH 2/2] tests add TestSuite_VEB
2016-10-14 13:50 ` [dts] [PATCH 2/2] tests add TestSuite_VEB Yuan Peng
@ 2016-10-14 14:05 ` Liu, Yong
0 siblings, 0 replies; 8+ messages in thread
From: Liu, Yong @ 2016-10-14 14:05 UTC (permalink / raw)
To: Peng, Yuan, dts; +Cc: Peng, Yuan
This patch look like small patch for the first one. You can just send out the final version.
> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Yuan Peng
> Sent: Friday, October 14, 2016 8:51 AM
> To: dts@dpdk.org
> Cc: Peng, Yuan
> Subject: [dts] [PATCH 2/2] tests add TestSuite_VEB
>
> From: pengyuan <yuan.peng@intel.com>
>
> Signed-off-by: pengyuan <yuan.peng@intel.com>
>
> diff --git a/tests/TestSuite_VEB.py b/tests/TestSuite_VEB.py
> index 6296ff1..9b97a97 100644
> --- a/tests/TestSuite_VEB.py
> +++ b/tests/TestSuite_VEB.py
> @@ -145,17 +145,8 @@ class TestVEBSwitching(TestCase):
> "NIC Unsupported: " + str(self.nic))
> self.dut_ports = self.dut.get_ports(self.nic)
> self.verify(len(self.dut_ports) >= 1, "Insufficient ports")
> - # self.rx_port = self.dut_ports[0]
> - # self.tx_port = self.dut_ports[0]
> -
> - # cores = self.dut.get_core_list("1S/2C/1T")
> - # self.coremask = dts.create_mask(cores)
> -
> - # self.port_mask = dts.create_mask([self.rx_port, self.tx_port])
> self.session_secondary = self.dut.new_session()
> self.session_third = self.dut.new_session()
> - # self.pmdout = PmdOutput(self.dut)
> - # self.pmdout_session_secondary =
> PmdOutput(self.session_secondary)
>
> def set_up(self):
> """
> @@ -206,8 +197,11 @@ class TestVEBSwitching(TestCase):
>
> def destroy_1pf_ddriver_4vf_env(self):
> 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)
> port = self.dut.ports_info[self.used_dut_port]['port']
> port.bind_driver()
> @@ -252,8 +246,11 @@ class TestVEBSwitching(TestCase):
>
> def destroy_1pf_ddriver_2vf_env(self):
> 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)
> port = self.dut.ports_info[self.used_dut_port]['port']
> port.bind_driver()
> @@ -273,7 +270,6 @@ class TestVEBSwitching(TestCase):
> self.pf_mac_address = self.dut.get_mac_address(0)
> self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
> self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> - # self.dut.send_expect("echo 1 >
> /sys/bus/pci/devices/%s/max_vfs" % self.pf_pci, "# ", 3)
> self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 1,
> driver='igb_uio')
> self.sriov_vfs_port =
> self.dut.ports_info[self.used_dut_port]['vfs_port']
> self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> @@ -301,7 +297,9 @@ class TestVEBSwitching(TestCase):
> def destroy_1pf_ddriver_1vf_env(self):
>
> 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)
> port = self.dut.ports_info[self.used_dut_port]['port']
> port.bind_driver()
> @@ -323,8 +321,6 @@ class TestVEBSwitching(TestCase):
> self.pf_interface =
> self.dut.ports_info[self.used_dut_port]['intf']
> self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2,
> driver=driver)
> self.sriov_vfs_port =
> self.dut.ports_info[self.used_dut_port]['vfs_port']
> - #self.vf0_mac = "00:11:22:33:44:11"
> - #self.vf1_mac = "00:11:22:33:44:12"
> self.dut.send_expect("ip link set %s vf 0 mac %s" %
> (self.pf_interface, self.vf0_mac), "# ", 3)
> self.dut.send_expect("ip link set %s vf 1 mac %s" %
> (self.pf_interface, self.vf1_mac), "# ", 3)
>
> @@ -337,13 +333,7 @@ class TestVEBSwitching(TestCase):
> time.sleep(1)
> vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> -
> - # for port_id in self.dut_ports:
> - # if port_id == self.used_dut_port:
> - # continue
> - # port = self.dut.ports_info[port_id]['port']
> - # port.bind_driver()
> -
> +
> self.setup_1pf_kdriver_2vf_env_flag = 1
> except Exception as e:
> self.destroy_1pf_kdriver_2vf_env()
> @@ -352,7 +342,9 @@ class TestVEBSwitching(TestCase):
> def destroy_1pf_kdriver_2vf_env(self):
>
> 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)
> port = self.dut.ports_info[self.used_dut_port]['port']
> port.bind_driver()
> @@ -470,7 +462,7 @@ class TestVEBSwitching(TestCase):
> self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> self.verify((vf0_tx_stats[0] == 1) and (vf1_rx_stats[0] == 1),
> "VF1 didn't receive packets from VF0, the vlan filter doen't work")
>
> - def test_VEB_switching_inter_pf_vf_MAC_switch(self):
> + def test_VEB_switching_inter_vfs_pf_MAC_switch(self):
> """
> DPDK PF, then create 1VF, PF in the host running dpdk testpmd,
> send traffic from PF to VF1, ensure PF->VF1(let VF1 in promisc mode); send
> traffic from VF1 to PF, ensure VF1->PF can work.
> """
> --
> 2.5.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
2016-10-14 13:50 [dts] [PATCH 1/2] tests add TestSuite_VEB.py Yuan Peng
2016-10-14 13:50 ` [dts] [PATCH 2/2] tests add TestSuite_VEB Yuan Peng
@ 2016-10-14 14:40 ` Liu, Yong
2016-10-19 3:12 ` Peng, Yuan
1 sibling, 1 reply; 8+ messages in thread
From: Liu, Yong @ 2016-10-14 14:40 UTC (permalink / raw)
To: Peng, Yuan, dts; +Cc: Peng, Yuan
Yuan, some comments below. Please remember that your suite is not the only one in our execution.
You need keep the environment just the same as you use it.
And please try to keep line in 79 characters.
> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Yuan Peng
> Sent: Friday, October 14, 2016 8:51 AM
> To: dts@dpdk.org
> Cc: Peng, Yuan
> Subject: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
>
> From: pengyuan <yuan.peng@intel.com>
>
> Signed-off-by: pengyuan <yuan.peng@intel.com>
>
> diff --git a/tests/TestSuite_VEB.py b/tests/TestSuite_VEB.py
> new file mode 100644
> index 0000000..6296ff1
> --- /dev/null
> +++ b/tests/TestSuite_VEB.py
> @@ -0,0 +1,934 @@
> +# 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
> +# 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 VEB Switch and floating VEB Features by Poll Mode Drivers.
> +"""
> +
> +import re
> +import time
> +
> +import dts
Please remove dts dependency in your suite. All suite should have no dependency on this module.
> +from virt_dut import VirtDut
> +from project_dpdk import DPDKdut
> +from dut import Dut
> +from net_device import GetNicObj
> +from net_device import RemoveNicObj
> +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 == "vf0":
> + stats = self.pmdout.get_pmd_stats(portid)
> + elif vf0_vf1 == "vf1":
> + stats = self.pmdout_session_secondary.get_pmd_stats(portid)
> + else:
> + return None
> +
> + if rx_tx == "rx":
> + return [stats['RX-packets'], stats['RX-errors'], stats['RX-
> bytes']]
> + elif rx_tx == "tx":
> + return [stats['TX-packets'], stats['TX-errors'], stats['TX-
> bytes']]
> + else:
> + return None
> +
> + def veb_get_pmd_stats(self, dev, portid, rx_tx):
> + stats = {}
> + rx_pkts_prefix = "RX-packets:"
> + rx_bytes_prefix = "RX-bytes:"
> + rx_error_prefix = "RX-errors:"
> + tx_pkts_prefix = "TX-packets:"
> + tx_error_prefix = "TX-errors:"
> + tx_bytes_prefix = "TX-bytes:"
> +
> + if dev == "first":
> + out = self.dut.send_expect("show port stats %d" % portid,
> "testpmd> ")
> + elif dev == "second":
> + out = self.session_secondary.send_expect("show port
> stats %d" % portid, "testpmd> ")
> + elif dev == "third":
> + out = self.session_third.send_expect("show port stats %d" %
> portid, "testpmd> ")
> + else:
> + return None
> +
> + stats["RX-packets"] = self.veb_get_pmd_value(rx_pkts_prefix, out)
> + stats["RX-bytes"] = self.veb_get_pmd_value(rx_bytes_prefix, out)
> + stats["RX-errors"] = self.veb_get_pmd_value(rx_error_prefix, out)
> + stats["TX-packets"] = self.veb_get_pmd_value(tx_pkts_prefix, out)
> + stats["TX-errors"] = self.veb_get_pmd_value(tx_error_prefix, out)
> + stats["TX-bytes"] = self.veb_get_pmd_value(tx_bytes_prefix, out)
> +
> + if rx_tx == "rx":
> + return [stats['RX-packets'], stats['RX-errors'], stats['RX-
> bytes']]
> + elif rx_tx == "tx":
> + return [stats['TX-packets'], stats['TX-errors'], stats['TX-
> bytes']]
> + else:
> + return None
> +
> +
> + def veb_get_pmd_value(self, prefix, out):
> + pattern = re.compile(prefix + "(\s+)([0-9]+)")
> + m = pattern.search(out)
> + if m is None:
> + return None
> + else:
> + return int(m.group(2))
> +
> + def send_packet(self, vf_mac, itf, tran_type=""):
> + """
> + Send 1 packet
> + """
> + self.tester.scapy_foreground()
> + self.tester.scapy_append('sys.path.append("./")')
> + self.dut.send_expect("start", "testpmd>")
> + mac = self.dut.get_mac_address(0)
> +
> + if tran_type == "vlan":
> + packet = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/Dot1Q(vlan=1)/IP(src="192.168.0.1",
> dst="192.168.0.2")], iface="%s")' % (vf_mac, itf, itf)
> + self.tester.scapy_append(packet)
> + self.tester.scapy_execute()
> + time.sleep(.5)
> + else:
> + packet = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/IP(src="192.168.0.1", dst="192.168.0.2")],
> iface="%s")' % (vf_mac, itf, itf)
> + self.tester.scapy_append(packet)
> + self.tester.scapy_execute()
> + time.sleep(.5)
> +
> + #
> + # Test cases.
> + #
> +
> + 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 = self.dut.get_ports(self.nic)
> + self.verify(len(self.dut_ports) >= 1, "Insufficient ports")
> + # self.rx_port = self.dut_ports[0]
> + # self.tx_port = self.dut_ports[0]
> +
> + # cores = self.dut.get_core_list("1S/2C/1T")
> + # self.coremask = dts.create_mask(cores)
> +
> + # self.port_mask = dts.create_mask([self.rx_port, self.tx_port])
> + self.session_secondary = self.dut.new_session()
> + self.session_third = self.dut.new_session()
> + # self.pmdout = PmdOutput(self.dut)
> + # self.pmdout_session_secondary =
> PmdOutput(self.session_secondary)
> +
Please remove commented code.
> + def set_up(self):
> + """
> + This is to clear up environment before the case run.
> + """
> + self.dut.kill_all()
> + self.setup_1pf_kdriver_2vf_env_flag = 0
> + self.setup_1pf_ddriver_1vf_env_flag = 0
> + self.setup_1pf_ddriver_2vf_env_flag = 0
> + self.setup_1pf_ddriver_4vf_env_flag = 0
> + self.vf0_mac = "00:11:22:33:44:11"
> + self.vf1_mac = "00:11:22:33:44:12"
> + self.vf2_mac = "00:11:22:33:44:13"
> + self.vf3_mac = "00:11:22:33:44:14"
> +
> + def setup_1pf_ddriver_4vf_env(self, driver='default'):
> + self.used_dut_port = self.dut_ports[0]
> + localPort = self.tester.get_local_port(self.dut_ports[0])
> + self.tester_itf = self.tester.get_interface(localPort)
> + self.pf_interface =
> self.dut.ports_info[self.used_dut_port]['intf']
> + self.pf_mac_address = self.dut.get_mac_address(0)
Several function required these information, you can strip these information only once in setup_all function.
> + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
This code is useless here, is it just for debug?
> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 4,
> driver='igb_uio')
> + self.sriov_vfs_port =
> self.dut.ports_info[self.used_dut_port]['vfs_port']
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + try:
> +
> + for port in self.sriov_vfs_port:
> + print port.pci
Please remove debug code.
> + self.dut.send_expect("./tools/dpdk-devbind.py -b
> igb_uio %s" % (port.pci), "# ", 3)
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + time.sleep(1)
> + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> + vf2_prop = {'opt_host': self.sriov_vfs_port[2].pci}
> + vf3_prop = {'opt_host': self.sriov_vfs_port[3].pci}
> + for port_id in self.dut_ports:
> + if port_id == self.used_dut_port:
> + continue
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
I'm not sure about this logic, you can just get port object by self.dut.ports_info[self.used_dut_port].
There's no need to browser through all dut ports.
> +
> + self.setup_1pf_ddriver_4vf_env_flag = 1
> + except Exception as e:
> + self.destroy_1pf_ddriver_4vf_env()
> + raise Exception(e)
> +
> + def destroy_1pf_ddriver_4vf_env(self):
> + self.session_third.send_expect("quit", "# ")
> + self.session_secondary.send_expect("quit", "# ")
> + self.dut.send_expect("quit", "# ")
When there met some issues which caused testpmd can't start up normally. "Quit" command here will cause the session unavailable any more.
Use kill_all api to quit dpdk application is one more reliable way to do such thing.
> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> + port = self.dut.ports_info[self.used_dut_port]['port']
> + port.bind_driver()
> + self.used_dut_port = None
> +
> + for port_id in self.dut_ports:
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
Do not bind dut ports to default driver, this will cause that later suites can't work anymore.
There's one solution for this is that when test suite initializing, we bind all dut ports to igb_uio.
But please do not bind to default driver by now.
> + self.setup_1pf_ddriver_4vf_env_flag = 0
> +
> + def setup_1pf_ddriver_2vf_env(self, driver='default'):
> + self.used_dut_port = self.dut_ports[0]
> + localPort = self.tester.get_local_port(self.dut_ports[0])
> + self.tester_itf = self.tester.get_interface(localPort)
> + self.pf_interface =
> self.dut.ports_info[self.used_dut_port]['intf']
> + self.pf_mac_address = self.dut.get_mac_address(0)
> + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
These codes can be done only once in setup_all function.
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2,
> driver='igb_uio')
> + self.sriov_vfs_port =
> self.dut.ports_info[self.used_dut_port]['vfs_port']
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + try:
> +
> + for port in self.sriov_vfs_port:
> + print port.pci
> + self.dut.send_expect("./tools/dpdk-devbind.py -b
> igb_uio %s" % (port.pci), "# ", 3)
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + time.sleep(1)
> + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> + for port_id in self.dut_ports:
> + if port_id == self.used_dut_port:
> + continue
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
> + self.setup_1pf_ddriver_2vf_env_flag = 1
> + except Exception as e:
> + self.destroy_1pf_ddriver_2vf_env()
> + raise Exception(e)
> +
> + def destroy_1pf_ddriver_2vf_env(self):
> + self.session_third.send_expect("quit", "# ")
> + self.session_secondary.send_expect("quit", "# ")
> + self.dut.send_expect("quit", "# ")
> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> + port = self.dut.ports_info[self.used_dut_port]['port']
> + port.bind_driver()
> + self.used_dut_port = None
> +
> + for port_id in self.dut_ports:
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
> + self.setup_1pf_ddriver_2vf_env_flag = 0
> +
> + def setup_1pf_ddriver_1vf_env(self, driver='default'):
> + self.used_dut_port = self.dut_ports[0]
> + localPort = self.tester.get_local_port(self.dut_ports[0])
> + self.tester_itf = self.tester.get_interface(localPort)
> + self.pf_interface =
> self.dut.ports_info[self.used_dut_port]['intf']
> + self.pf_mac_address = self.dut.get_mac_address(0)
> + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + # self.dut.send_expect("echo 1 >
> /sys/bus/pci/devices/%s/max_vfs" % self.pf_pci, "# ", 3)
> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 1,
> driver='igb_uio')
> + self.sriov_vfs_port =
> self.dut.ports_info[self.used_dut_port]['vfs_port']
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> +
> + try:
> +
> + for port in self.sriov_vfs_port:
> + print port.pci
> + self.dut.send_expect("./tools/dpdk-devbind.py -b
> igb_uio %s" % (port.pci), "# ", 3)
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + time.sleep(1)
> + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> +
> + for port_id in self.dut_ports:
> + if port_id == self.used_dut_port:
> + continue
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
> + self.setup_1pf_ddriver_1vf_env_flag = 1
> + except Exception as e:
> + self.destroy_1pf_ddriver_1vf_env()
> + raise Exception(e)
> +
> + def destroy_1pf_ddriver_1vf_env(self):
> +
> + self.session_secondary.send_expect("quit", "# ")
> + self.dut.send_expect("quit", "# ")
> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> + port = self.dut.ports_info[self.used_dut_port]['port']
> + port.bind_driver()
> + self.used_dut_port = None
> +
> + for port_id in self.dut_ports:
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
> + self.setup_1pf_ddriver_1vf_env_flag = 0
> +
> + def setup_1pf_kdriver_2vf_env(self, driver='default'):
> + self.used_dut_port = self.dut_ports[0]
> + localPort = self.tester.get_local_port(self.dut_ports[0])
> + self.tester_itf = self.tester.get_interface(localPort)
> + for port_id in self.dut_ports:
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> + self.pf_interface =
> self.dut.ports_info[self.used_dut_port]['intf']
> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2,
> driver=driver)
> + self.sriov_vfs_port =
> self.dut.ports_info[self.used_dut_port]['vfs_port']
> + #self.vf0_mac = "00:11:22:33:44:11"
> + #self.vf1_mac = "00:11:22:33:44:12"
> + self.dut.send_expect("ip link set %s vf 0 mac %s" %
> (self.pf_interface, self.vf0_mac), "# ", 3)
> + self.dut.send_expect("ip link set %s vf 1 mac %s" %
> (self.pf_interface, self.vf1_mac), "# ", 3)
> +
> + try:
> +
> + for port in self.sriov_vfs_port:
> + print port.pci
> + self.dut.send_expect("./tools/dpdk-devbind.py -b
> igb_uio %s" % (port.pci), "# ", 3)
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + time.sleep(1)
> + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> +
> + # for port_id in self.dut_ports:
> + # if port_id == self.used_dut_port:
> + # continue
> + # port = self.dut.ports_info[port_id]['port']
> + # port.bind_driver()
> +
> + self.setup_1pf_kdriver_2vf_env_flag = 1
> + except Exception as e:
> + self.destroy_1pf_kdriver_2vf_env()
> + raise Exception(e)
> +
> + def destroy_1pf_kdriver_2vf_env(self):
> +
> + self.session_secondary.send_expect("quit", "# ")
> + self.dut.send_expect("quit", "# ")
> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> + port = self.dut.ports_info[self.used_dut_port]['port']
> + port.bind_driver()
> + self.used_dut_port = None
> +
> + for port_id in self.dut_ports:
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
> + self.setup_1pf_kdriver_2vf_env_flag = 0
> +
> + def test_VEB_switching_inter_vfs_MAC_switch_rxtx(self):
> + """
Please simplify the test case name, description below can explain the case.
> + Kernel PF, then create 2VFs. VFs running dpdk testpmd, send
> traffic to VF1, and set the packet's DEST MAC to VF2, check if VF2 can
> receive the packets. Check Inter VF-VF MAC switch.
> + """
> + self.setup_1pf_kdriver_2vf_env(driver='')
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> "testpmd>", 120)
Mac here should not hardcode, it has been defined in setup function.
> + self.dut.send_expect("set fwd txonly", "testpmd>")
> + self.dut.send_expect("set promisc all off", "testpmd>")
> +
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % self.sriov_vfs_port[1].pci, "testpmd>",
> 120)
Target should not be hard coded for we will do the validation with different targets.
You can use start_testpmd in pmd_ouput module to simplify the step.
> + 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)
> +
> + self.dut.send_expect("stop", "testpmd>", 5)
> + self.session_secondary.send_expect("stop", "testpmd>", 5)
> +
> + vf0_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(vf0_tx_stats[0] * 0.5 < vf1_rx_stats[0], "VF1 failed
> to receive packets from VF0")
> +
> + def test_VEB_switching_inter_vfs_MAC_switch_fwd(self):
> + """
> + Kernel PF, then create 2VFs. VFs running dpdk testpmd, send
> traffic to VF1, and set the packet's DEST MAC to VF2, check if VF2 can
> receive the packets. Check Inter VF-VF MAC switch.
> + """
> + self.setup_1pf_kdriver_2vf_env(driver='')
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> "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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % 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)
> +
> + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(vf0_tx_stats == vf1_rx_stats, "VF1 failed to receive
> packets from VF0")
> +
> + def test_VEB_switching_inter_vfs_MAC_switch_vlan(self):
> + """
> + Kernel PF, then create 2VFs, assign VF1 with VLAN=1 in, VF2 with
> VLAN=2. VFs are running dpdk testpmd, send traffic to VF1 with VLAN=1,
> then let it forwards to VF2, it should not work since they are not
> in the same VLAN; set VF2 with VLAN=1, then send traffic to VF1 with
> VLAN=1, and VF2 can receive the packets. Check inter VF MAC/VLAN
> switch.
> + """
> + self.setup_1pf_kdriver_2vf_env(driver='')
> + # the two vfs belongs to different vlans
> + self.dut.send_expect("ip link set %s vf 0 vlan 1" %
> self.pf_interface, "# ", 1)
> + self.dut.send_expect("ip link set %s vf 1 vlan 2" %
> self.pf_interface, "# ", 1)
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> "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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % 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)
> +
> + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify((vf0_tx_stats[0] == 1) and (vf1_rx_stats[0] == 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)
> +
> + # the two vfs belongs to the same vlan
> + self.dut.send_expect("ip link set %s vf 1 vlan 1" %
> self.pf_interface, "# ", 1)
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> "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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % 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)
> +
> + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify((vf0_tx_stats[0] == 1) and (vf1_rx_stats[0] == 1),
> "VF1 didn't receive packets from VF0, the vlan filter doen't work")
> +
> + def test_VEB_switching_inter_pf_vf_MAC_switch(self):
> + """
> + DPDK PF, then create 1VF, PF in the host running dpdk testpmd,
> send traffic from PF to VF1, ensure PF->VF1(let VF1 in promisc mode); send
> traffic from VF1 to PF, ensure VF1->PF can work.
> + """
> + # VF->PF
> + self.setup_1pf_ddriver_1vf_env(driver='')
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" %
> self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(pf_rx_stats[0] != 0, "no packet was received by PF")
> + self.verify(vf0_tx_stats[0]*0.5 < pf_rx_stats[0], "PF failed to
> receive most packets from VF0")
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> + self.dut.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + #PF->VF
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --eth-
> peer=0,%s" % (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>")
> +
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> + self.verify(pf_tx_stats[0] != 0, "no packet was sent by PF")
> + self.verify(vf0_rx_stats[0] != 0, "no packet was received by VF0")
> + self.verify(vf0_rx_stats[0] > pf_tx_stats[0]*0.5, "VF0 failed to
> receive 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("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" %
> self.pf_pci, "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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> + self.verify(pf_tx_stats[0] == 0, "PF received unexpected packet")
> + self.verify(vf0_rx_stats[0] == 1, "no packet was received by VF0")
> +
> + 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 = self.veb_get_pmd_stats("second", 0, "rx")
> + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> + self.verify(pf_tx_stats[0] == 1, "no packet was sent by VF0")
> + self.verify(pf_rx_stats[0] == 1, "no packet was received by VF0")
> + self.verify(vf0_rx_stats[0] == 1, "no packet was received by VF0")
> +
> + def test_floating_VEB_switching_inter_pf_vf_MAC_switch(self):
> + """
> + DPDK PF, then create 1VF, PF in the host running dpdk testpmd,
> send traffic from PF to VF0, VF0 can't receive any packets; send traffic
> from VF0 to PF, PF can't rec eive any packets either.
> + """
> + # VF->PF
> + self.setup_1pf_ddriver_1vf_env(driver='')
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> prefix=test1 -- -i" % self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(pf_rx_stats[0] == 0, "PF can receive packet from VF0,
> the floating VEB doesn't work")
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> + self.dut.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + #PF->VF
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> prefix=test1 -- -i --eth-peer=0,%s" % (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>")
> +
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> + self.verify(pf_tx_stats[0] != 0, "no packet was sent by PF")
> + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from PF,
> the floating VEB doesn't work")
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> + self.dut.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + #outside world ->VF
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> prefix=test1 -- -i --eth-peer=0,%s" % (self.pf_pci, self.vf0_mac),
> "testpmd>", 120)
> + self.dut.send_expect("set fwd mac", "testpmd>")
> + self.dut.send_expect("set promisc all on", "testpmd>")
> + self.dut.send_expect("start", "testpmd>")
> + time.sleep(2)
> +
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % (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 mac", "testpmd>")
> + self.session_secondary.send_expect("set promisc all on",
> "testpmd>")
> + self.session_secondary.send_expect("start", "testpmd>")
> + time.sleep(2)
> +
> + self.send_packet(self.vf0_mac, self.tester_itf)
> + time.sleep(2)
> + self.dut.send_expect("stop", "testpmd>", 2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> +
> + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from
> outside world, the floating VEB doesn't work")
> +
> + def test_floating_VEB_switching_inter_vfs_MAC_switch(self):
> + """
> + 1 DPDK PF, then create 2VF, PF in the host running dpdk testpmd,
> and VF0 are running dpdk testpmd, VF0 send traffic, and set the packet's
> DEST MAC to VF1, check if VF1 can receive the packets. Check Inter VF-VF
> MAC switch when PF is link down as well as up.
> + """
> + # PF link up, VF0->VF1
> + self.setup_1pf_ddriver_2vf_env(driver='')
> + # start PF
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> prefix=test1 -- -i" % self.pf_pci, "testpmd>", 120)
> + self.dut.send_expect("port start all", "testpmd>")
> + time.sleep(2)
> + # start VF0
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % 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)
> + # start VF1
> + self.session_third.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test3 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[1].pci, self.vf0_mac), "testpmd>", 120)
> + self.session_third.send_expect("set fwd txonly", "testpmd>")
> + self.session_third.send_expect("set promisc all off", "testpmd>")
> + self.session_third.send_expect("start", "testpmd>")
> + time.sleep(2)
> +
> + self.session_third.send_expect("stop", "testpmd>", 2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> +
> + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + vf1_tx_stats = self.veb_get_pmd_stats("third", 0, "tx")
> + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> + self.verify(vf0_rx_stats[0] != 0, "no packet was received by VF0")
> + self.verify(vf1_tx_stats[0]*0.5 < vf0_rx_stats[0], "VF0 failed to
> receive most packets from VF1")
> +
> + # PF link down, VF0 -> VF1
> + self.dut.send_expect("port stop all", "Port 0 Link Down", 20)
> + self.session_secondary.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_third.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_third.send_expect("stop", "testpmd>", 2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> + self.dut.send_expect("stop", "testpmd>", 2)
> +
> + vf1_tx_stats_pfstop = self.veb_get_pmd_stats("third", 0, "tx")
> + vf0_rx_stats_pfstop = self.veb_get_pmd_stats("second", 0, "rx")
> + vf1_tx_stats_pfstop[0] = vf1_tx_stats_pfstop[0] - vf1_tx_stats[0]
> + vf0_rx_stats_pfstop[0] = vf0_rx_stats_pfstop[0] - vf0_rx_stats[0]
> + self.verify(vf1_tx_stats_pfstop[0] != 0, "no packet was sent by
> VF1")
> + self.verify(vf0_rx_stats_pfstop[0] != 0, "no packet was received
> by VF0")
> + self.verify(vf1_tx_stats_pfstop[0]*0.5 < vf0_rx_stats_pfstop[0],
> "VF0 failed to receive most packets from VF1")
> +
> + def test_floating_VEB_VF_cannot_communicate_with_legacy_VEB_VF(self):
> + """
> + DPDK PF, then create 4VF, VF0,VF2,VF3 are floating VEB; VF1 is
> lagecy VEB. Make PF link down(the cable can be pluged out), VFs are
> running dpdk testpmd.
> + 1. VF0 send traffic, and set the packet's DEST MAC to VF1, check
> VF1 can not receive the packets.
> + 2. VF1 send traffic, and set the packet's DEST MAC to VF0, check
> VF0 can not receive the packets.
> + 3. VF0 send traffic, and set the packet's DEST MAC to VF2, check
> VF2 can receive the packets.
> + 4. VF3 send traffic, and set the packet's DEST MAC to VF2, check
> VF2 can receive the packets.
> + """
> + self.setup_1pf_ddriver_4vf_env(driver='')
> + # start PF
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 \"-
> w %s,enable_floating_veb=1,floating_veb_list=0;2-3\" --file-prefix=test1 -
> - -i" % self.pf_pci, "testpmd>", 120)
> + self.dut.send_expect("port start all", "testpmd>")
> + time.sleep(2)
> + # VF1->VF0
> + # start VF0
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[0].pci, self.vf1_mac), "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>")
> + # start VF1
> + self.session_third.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test3 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[1].pci, self.vf0_mac), "testpmd>", 120)
> + self.session_secondary.send_expect("mac_addr add 0 %s" %
> self.vf1_mac, "testpmd>")
> + self.session_third.send_expect("set fwd txonly", "testpmd>")
> + self.session_third.send_expect("set promisc all off", "testpmd>")
> +
> + # PF link down
> + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> + self.session_secondary.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_third.send_expect("start", "testpmd>")
> + time.sleep(2)
> +
> + self.session_third.send_expect("stop", "testpmd>", 2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> +
> + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + vf1_tx_stats = self.veb_get_pmd_stats("third", 0, "tx")
> + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> + self.verify(vf0_rx_stats[0] == 0, "floating_VEB VF can
> communicate with legacy_VEB VF")
> +
> + # VF0->VF1
> + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> + self.session_third.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_secondary.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> + self.session_third.send_expect("stop", "testpmd>", 2)
> + vf1_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> + vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(vf1_rx_stats[0] == 0, "floating_VEB VF can
> communicate with legacy_VEB VF")
> +
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> + self.session_third.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + # VF0->VF2
> + # start VF0
> + self.dut.send_expect("port start all", "testpmd>")
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[0].pci, self.vf2_mac), "testpmd>", 120)
> + self.session_secondary.send_expect("mac_addr add 0 %s" %
> self.vf0_mac, "testpmd>")
> + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> + self.session_secondary.send_expect("set promisc all off",
> "testpmd>")
> + # start VF2
> + self.session_third.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test3 -- -i --crc-strip" % self.sriov_vfs_port[2].pci, "testpmd>",
> 120)
> + self.session_third.send_expect("mac_addr add 0 %s" % self.vf2_mac,
> "testpmd>")
> + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> + self.session_third.send_expect("set promisc all off", "testpmd>")
> +
> + # PF link down
> + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> + self.session_third.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_secondary.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> + self.session_third.send_expect("stop", "testpmd>", 2)
> +
> + vf2_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> + vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(vf2_rx_stats[0] != 0, "floating_VEB VFs cannot
> communicate with each other")
> + self.verify(vf0_tx_stats[0] * 0.5 < vf2_rx_stats[0], "VF2 failed
> to receive packets from VF0")
> +
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> + self.session_third.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + # VF3->VF2
> + # start VF3
> + self.dut.send_expect("port start all", "testpmd>")
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[3].pci, self.vf2_mac), "testpmd>", 120)
> + self.session_secondary.send_expect("mac_addr add 0 %s" %
> self.vf0_mac, "testpmd>")
> + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> + self.session_secondary.send_expect("set promisc all off",
> "testpmd>")
> + # start VF2
> + self.session_third.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test3 -- -i --crc-strip" % self.sriov_vfs_port[2].pci, "testpmd>",
> 120)
> + self.session_third.send_expect("mac_addr add 0 %s" % self.vf2_mac,
> "testpmd>")
> + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> + self.session_third.send_expect("set promisc all off", "testpmd>")
> +
> + # PF link down
> + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> + self.session_third.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_secondary.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> + self.session_third.send_expect("stop", "testpmd>", 2)
> +
> + vf2_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> + vf3_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> + self.verify(vf3_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(vf2_rx_stats[0] != 0, "floating_VEB VFs cannot
> communicate with each other")
> + self.verify(vf3_tx_stats[0] * 0.5 < vf2_rx_stats[0], "VF2 failed
> to receive packets from VF3")
> +
> + def
> test_floating_VEB_and_legacy_VEB_switching_inter_pf_vf_MAC_switch(self):
> + """
> + DPDK PF, then create 2VFs, VF0 is in floating VEB, VF1 is in
> legacy VEB.
> + 1. Send traffic from VF0 to PF, then check PF will not see any
> traffic;
> + 2. Send traffic from VF1 to PF, then check PF will receive all
> the packets.
> + 3. send traffic from tester to VF0, check VF0 can't receive
> traffic from tester.
> + 4. send traffic from tester to VF1, check VF1 can receive all the
> traffic from tester.
> + """
> + self.setup_1pf_ddriver_2vf_env(driver='')
> + # VF0->PF
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 \"-
> w %s,enable_floating_veb=1,floating_veb_list=0\" --file-prefix=test1 -- -
> i" % self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(pf_rx_stats[0] == 0, "PF can receive packet from VF0,
> the floating VEB doesn't work")
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + # VF1->PF
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[1].pci, self.pf_mac_address), "testpmd>", 120)
> + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> + self.session_secondary.send_expect("set promisc all off",
> "testpmd>")
> + self.dut.send_expect("start", "testpmd>")
> + time.sleep(2)
> + 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)
> +
> + vf1_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> + self.verify(pf_rx_stats[0] != 0, "PF can't receive packet from
> VF1, the VEB doesn't work")
> + self.verify(vf1_tx_stats[0] * 0.5 < pf_rx_stats[0], "PF failed to
> receive packets from VF1")
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> + self.dut.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + # tester->VF0
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 \"-
> w %s,enable_floating_veb=1,floating_veb_list=0\" --file-prefix=test1 -- -
> i" % self.pf_pci, "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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % (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 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)
> + time.sleep(2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> + self.dut.send_expect("stop", "testpmd>", 2)
> +
> + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from
> outside world, the floating VEB doesn't work")
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + # tester->VF1
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % (self.sriov_vfs_port[1].pci), "testpmd>",
> 120)
> + self.session_secondary.send_expect("mac_addr add 0 %s" %
> self.vf1_mac, "testpmd>")
> + 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.vf1_mac, self.tester_itf)
> + time.sleep(2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> + self.dut.send_expect("stop", "testpmd>", 2)
> +
> + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + self.verify(vf1_rx_stats[0] == 1, "VF1 can't receive packet from
> outside world, the VEB doesn't work")
> +
> + def tear_down(self):
> + """
> + Run after each test case.
> + """
> + if self.setup_1pf_kdriver_2vf_env_flag == 1:
> + self.destroy_1pf_kdriver_2vf_env()
> + if self.setup_1pf_ddriver_1vf_env_flag == 1:
> + self.destroy_1pf_ddriver_1vf_env()
> + if self.setup_1pf_ddriver_2vf_env_flag == 1:
> + self.destroy_1pf_ddriver_2vf_env()
> + if self.setup_1pf_ddriver_4vf_env_flag == 1:
> + self.destroy_1pf_ddriver_4vf_env()
> +
> + self.dut.kill_all()
> +
> + pass
> +
> + 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)
Need restore dut ports bound to igb_uio driver.
> +
> + pass
> --
> 2.5.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
2016-10-14 14:40 ` [dts] [PATCH 1/2] tests add TestSuite_VEB.py Liu, Yong
@ 2016-10-19 3:12 ` Peng, Yuan
2016-10-19 3:16 ` Liu, Yong
0 siblings, 1 reply; 8+ messages in thread
From: Peng, Yuan @ 2016-10-19 3:12 UTC (permalink / raw)
To: Liu, Yong, dts
Hi Marvin,
I don't know why I can't bind the dut ports to default driver when the testsuite finished?
Thank you.
Yuan.
-----Original Message-----
From: Liu, Yong
Sent: Friday, October 14, 2016 10:40 PM
To: Peng, Yuan <yuan.peng@intel.com>; dts@dpdk.org
Cc: Peng, Yuan <yuan.peng@intel.com>
Subject: RE: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
Yuan, some comments below. Please remember that your suite is not the only one in our execution.
You need keep the environment just the same as you use it.
And please try to keep line in 79 characters.
> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Yuan Peng
> Sent: Friday, October 14, 2016 8:51 AM
> To: dts@dpdk.org
> Cc: Peng, Yuan
> Subject: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
>
> From: pengyuan <yuan.peng@intel.com>
>
> Signed-off-by: pengyuan <yuan.peng@intel.com>
>
> diff --git a/tests/TestSuite_VEB.py b/tests/TestSuite_VEB.py
> new file mode 100644
> index 0000000..6296ff1
> --- /dev/null
> +++ b/tests/TestSuite_VEB.py
> @@ -0,0 +1,934 @@
> +# 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
> +# 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 VEB Switch and floating VEB Features by Poll Mode Drivers.
> +"""
> +
> +import re
> +import time
> +
> +import dts
Please remove dts dependency in your suite. All suite should have no dependency on this module.
> +from virt_dut import VirtDut
> +from project_dpdk import DPDKdut
> +from dut import Dut
> +from net_device import GetNicObj
> +from net_device import RemoveNicObj
> +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 == "vf0":
> + stats = self.pmdout.get_pmd_stats(portid)
> + elif vf0_vf1 == "vf1":
> + stats = self.pmdout_session_secondary.get_pmd_stats(portid)
> + else:
> + return None
> +
> + if rx_tx == "rx":
> + return [stats['RX-packets'], stats['RX-errors'], stats['RX-
> bytes']]
> + elif rx_tx == "tx":
> + return [stats['TX-packets'], stats['TX-errors'], stats['TX-
> bytes']]
> + else:
> + return None
> +
> + def veb_get_pmd_stats(self, dev, portid, rx_tx):
> + stats = {}
> + rx_pkts_prefix = "RX-packets:"
> + rx_bytes_prefix = "RX-bytes:"
> + rx_error_prefix = "RX-errors:"
> + tx_pkts_prefix = "TX-packets:"
> + tx_error_prefix = "TX-errors:"
> + tx_bytes_prefix = "TX-bytes:"
> +
> + if dev == "first":
> + out = self.dut.send_expect("show port stats %d" % portid,
> "testpmd> ")
> + elif dev == "second":
> + out = self.session_secondary.send_expect("show port
> stats %d" % portid, "testpmd> ")
> + elif dev == "third":
> + out = self.session_third.send_expect("show port stats %d" %
> portid, "testpmd> ")
> + else:
> + return None
> +
> + stats["RX-packets"] = self.veb_get_pmd_value(rx_pkts_prefix, out)
> + stats["RX-bytes"] = self.veb_get_pmd_value(rx_bytes_prefix, out)
> + stats["RX-errors"] = self.veb_get_pmd_value(rx_error_prefix, out)
> + stats["TX-packets"] = self.veb_get_pmd_value(tx_pkts_prefix, out)
> + stats["TX-errors"] = self.veb_get_pmd_value(tx_error_prefix, out)
> + stats["TX-bytes"] = self.veb_get_pmd_value(tx_bytes_prefix, out)
> +
> + if rx_tx == "rx":
> + return [stats['RX-packets'], stats['RX-errors'], stats['RX-
> bytes']]
> + elif rx_tx == "tx":
> + return [stats['TX-packets'], stats['TX-errors'], stats['TX-
> bytes']]
> + else:
> + return None
> +
> +
> + def veb_get_pmd_value(self, prefix, out):
> + pattern = re.compile(prefix + "(\s+)([0-9]+)")
> + m = pattern.search(out)
> + if m is None:
> + return None
> + else:
> + return int(m.group(2))
> +
> + def send_packet(self, vf_mac, itf, tran_type=""):
> + """
> + Send 1 packet
> + """
> + self.tester.scapy_foreground()
> + self.tester.scapy_append('sys.path.append("./")')
> + self.dut.send_expect("start", "testpmd>")
> + mac = self.dut.get_mac_address(0)
> +
> + if tran_type == "vlan":
> + packet = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/Dot1Q(vlan=1)/IP(src="192.168.0.1",
> dst="192.168.0.2")], iface="%s")' % (vf_mac, itf, itf)
> + self.tester.scapy_append(packet)
> + self.tester.scapy_execute()
> + time.sleep(.5)
> + else:
> + packet = r'sendp([Ether(dst="%s",
> src=get_if_hwaddr("%s"))/IP(src="192.168.0.1", dst="192.168.0.2")],
> iface="%s")' % (vf_mac, itf, itf)
> + self.tester.scapy_append(packet)
> + self.tester.scapy_execute()
> + time.sleep(.5)
> +
> + #
> + # Test cases.
> + #
> +
> + 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 = self.dut.get_ports(self.nic)
> + self.verify(len(self.dut_ports) >= 1, "Insufficient ports")
> + # self.rx_port = self.dut_ports[0]
> + # self.tx_port = self.dut_ports[0]
> +
> + # cores = self.dut.get_core_list("1S/2C/1T")
> + # self.coremask = dts.create_mask(cores)
> +
> + # self.port_mask = dts.create_mask([self.rx_port, self.tx_port])
> + self.session_secondary = self.dut.new_session()
> + self.session_third = self.dut.new_session()
> + # self.pmdout = PmdOutput(self.dut)
> + # self.pmdout_session_secondary =
> PmdOutput(self.session_secondary)
> +
Please remove commented code.
> + def set_up(self):
> + """
> + This is to clear up environment before the case run.
> + """
> + self.dut.kill_all()
> + self.setup_1pf_kdriver_2vf_env_flag = 0
> + self.setup_1pf_ddriver_1vf_env_flag = 0
> + self.setup_1pf_ddriver_2vf_env_flag = 0
> + self.setup_1pf_ddriver_4vf_env_flag = 0
> + self.vf0_mac = "00:11:22:33:44:11"
> + self.vf1_mac = "00:11:22:33:44:12"
> + self.vf2_mac = "00:11:22:33:44:13"
> + self.vf3_mac = "00:11:22:33:44:14"
> +
> + def setup_1pf_ddriver_4vf_env(self, driver='default'):
> + self.used_dut_port = self.dut_ports[0]
> + localPort = self.tester.get_local_port(self.dut_ports[0])
> + self.tester_itf = self.tester.get_interface(localPort)
> + self.pf_interface =
> self.dut.ports_info[self.used_dut_port]['intf']
> + self.pf_mac_address = self.dut.get_mac_address(0)
Several function required these information, you can strip these information only once in setup_all function.
> + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
This code is useless here, is it just for debug?
> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 4,
> driver='igb_uio')
> + self.sriov_vfs_port =
> self.dut.ports_info[self.used_dut_port]['vfs_port']
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + try:
> +
> + for port in self.sriov_vfs_port:
> + print port.pci
Please remove debug code.
> + self.dut.send_expect("./tools/dpdk-devbind.py -b
> igb_uio %s" % (port.pci), "# ", 3)
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + time.sleep(1)
> + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> + vf2_prop = {'opt_host': self.sriov_vfs_port[2].pci}
> + vf3_prop = {'opt_host': self.sriov_vfs_port[3].pci}
> + for port_id in self.dut_ports:
> + if port_id == self.used_dut_port:
> + continue
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
I'm not sure about this logic, you can just get port object by self.dut.ports_info[self.used_dut_port].
There's no need to browser through all dut ports.
> +
> + self.setup_1pf_ddriver_4vf_env_flag = 1
> + except Exception as e:
> + self.destroy_1pf_ddriver_4vf_env()
> + raise Exception(e)
> +
> + def destroy_1pf_ddriver_4vf_env(self):
> + self.session_third.send_expect("quit", "# ")
> + self.session_secondary.send_expect("quit", "# ")
> + self.dut.send_expect("quit", "# ")
When there met some issues which caused testpmd can't start up normally. "Quit" command here will cause the session unavailable any more.
Use kill_all api to quit dpdk application is one more reliable way to do such thing.
> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> + port = self.dut.ports_info[self.used_dut_port]['port']
> + port.bind_driver()
> + self.used_dut_port = None
> +
> + for port_id in self.dut_ports:
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
Do not bind dut ports to default driver, this will cause that later suites can't work anymore.
There's one solution for this is that when test suite initializing, we bind all dut ports to igb_uio.
But please do not bind to default driver by now.
> + self.setup_1pf_ddriver_4vf_env_flag = 0
> +
> + def setup_1pf_ddriver_2vf_env(self, driver='default'):
> + self.used_dut_port = self.dut_ports[0]
> + localPort = self.tester.get_local_port(self.dut_ports[0])
> + self.tester_itf = self.tester.get_interface(localPort)
> + self.pf_interface =
> self.dut.ports_info[self.used_dut_port]['intf']
> + self.pf_mac_address = self.dut.get_mac_address(0)
> + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
These codes can be done only once in setup_all function.
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2,
> driver='igb_uio')
> + self.sriov_vfs_port =
> self.dut.ports_info[self.used_dut_port]['vfs_port']
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + try:
> +
> + for port in self.sriov_vfs_port:
> + print port.pci
> + self.dut.send_expect("./tools/dpdk-devbind.py -b
> igb_uio %s" % (port.pci), "# ", 3)
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + time.sleep(1)
> + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> + for port_id in self.dut_ports:
> + if port_id == self.used_dut_port:
> + continue
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
> + self.setup_1pf_ddriver_2vf_env_flag = 1
> + except Exception as e:
> + self.destroy_1pf_ddriver_2vf_env()
> + raise Exception(e)
> +
> + def destroy_1pf_ddriver_2vf_env(self):
> + self.session_third.send_expect("quit", "# ")
> + self.session_secondary.send_expect("quit", "# ")
> + self.dut.send_expect("quit", "# ")
> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> + port = self.dut.ports_info[self.used_dut_port]['port']
> + port.bind_driver()
> + self.used_dut_port = None
> +
> + for port_id in self.dut_ports:
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
> + self.setup_1pf_ddriver_2vf_env_flag = 0
> +
> + def setup_1pf_ddriver_1vf_env(self, driver='default'):
> + self.used_dut_port = self.dut_ports[0]
> + localPort = self.tester.get_local_port(self.dut_ports[0])
> + self.tester_itf = self.tester.get_interface(localPort)
> + self.pf_interface =
> self.dut.ports_info[self.used_dut_port]['intf']
> + self.pf_mac_address = self.dut.get_mac_address(0)
> + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + # self.dut.send_expect("echo 1 >
> /sys/bus/pci/devices/%s/max_vfs" % self.pf_pci, "# ", 3)
> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 1,
> driver='igb_uio')
> + self.sriov_vfs_port =
> self.dut.ports_info[self.used_dut_port]['vfs_port']
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> +
> + try:
> +
> + for port in self.sriov_vfs_port:
> + print port.pci
> + self.dut.send_expect("./tools/dpdk-devbind.py -b
> igb_uio %s" % (port.pci), "# ", 3)
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + time.sleep(1)
> + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> +
> + for port_id in self.dut_ports:
> + if port_id == self.used_dut_port:
> + continue
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
> + self.setup_1pf_ddriver_1vf_env_flag = 1
> + except Exception as e:
> + self.destroy_1pf_ddriver_1vf_env()
> + raise Exception(e)
> +
> + def destroy_1pf_ddriver_1vf_env(self):
> +
> + self.session_secondary.send_expect("quit", "# ")
> + self.dut.send_expect("quit", "# ")
> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> + port = self.dut.ports_info[self.used_dut_port]['port']
> + port.bind_driver()
> + self.used_dut_port = None
> +
> + for port_id in self.dut_ports:
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
> + self.setup_1pf_ddriver_1vf_env_flag = 0
> +
> + def setup_1pf_kdriver_2vf_env(self, driver='default'):
> + self.used_dut_port = self.dut_ports[0]
> + localPort = self.tester.get_local_port(self.dut_ports[0])
> + self.tester_itf = self.tester.get_interface(localPort)
> + for port_id in self.dut_ports:
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> + self.pf_interface =
> self.dut.ports_info[self.used_dut_port]['intf']
> + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2,
> driver=driver)
> + self.sriov_vfs_port =
> self.dut.ports_info[self.used_dut_port]['vfs_port']
> + #self.vf0_mac = "00:11:22:33:44:11"
> + #self.vf1_mac = "00:11:22:33:44:12"
> + self.dut.send_expect("ip link set %s vf 0 mac %s" %
> (self.pf_interface, self.vf0_mac), "# ", 3)
> + self.dut.send_expect("ip link set %s vf 1 mac %s" %
> (self.pf_interface, self.vf1_mac), "# ", 3)
> +
> + try:
> +
> + for port in self.sriov_vfs_port:
> + print port.pci
> + self.dut.send_expect("./tools/dpdk-devbind.py -b
> igb_uio %s" % (port.pci), "# ", 3)
> + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> + time.sleep(1)
> + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> +
> + # for port_id in self.dut_ports:
> + # if port_id == self.used_dut_port:
> + # continue
> + # port = self.dut.ports_info[port_id]['port']
> + # port.bind_driver()
> +
> + self.setup_1pf_kdriver_2vf_env_flag = 1
> + except Exception as e:
> + self.destroy_1pf_kdriver_2vf_env()
> + raise Exception(e)
> +
> + def destroy_1pf_kdriver_2vf_env(self):
> +
> + self.session_secondary.send_expect("quit", "# ")
> + self.dut.send_expect("quit", "# ")
> + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> + port = self.dut.ports_info[self.used_dut_port]['port']
> + port.bind_driver()
> + self.used_dut_port = None
> +
> + for port_id in self.dut_ports:
> + port = self.dut.ports_info[port_id]['port']
> + port.bind_driver()
> +
> + self.setup_1pf_kdriver_2vf_env_flag = 0
> +
> + def test_VEB_switching_inter_vfs_MAC_switch_rxtx(self):
> + """
Please simplify the test case name, description below can explain the case.
> + Kernel PF, then create 2VFs. VFs running dpdk testpmd, send
> traffic to VF1, and set the packet's DEST MAC to VF2, check if VF2 can
> receive the packets. Check Inter VF-VF MAC switch.
> + """
> + self.setup_1pf_kdriver_2vf_env(driver='')
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> "testpmd>", 120)
Mac here should not hardcode, it has been defined in setup function.
> + self.dut.send_expect("set fwd txonly", "testpmd>")
> + self.dut.send_expect("set promisc all off", "testpmd>")
> +
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % self.sriov_vfs_port[1].pci, "testpmd>",
> 120)
Target should not be hard coded for we will do the validation with different targets.
You can use start_testpmd in pmd_ouput module to simplify the step.
> + 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)
> +
> + self.dut.send_expect("stop", "testpmd>", 5)
> + self.session_secondary.send_expect("stop", "testpmd>", 5)
> +
> + vf0_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(vf0_tx_stats[0] * 0.5 < vf1_rx_stats[0], "VF1 failed
> to receive packets from VF0")
> +
> + def test_VEB_switching_inter_vfs_MAC_switch_fwd(self):
> + """
> + Kernel PF, then create 2VFs. VFs running dpdk testpmd, send
> traffic to VF1, and set the packet's DEST MAC to VF2, check if VF2 can
> receive the packets. Check Inter VF-VF MAC switch.
> + """
> + self.setup_1pf_kdriver_2vf_env(driver='')
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> "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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % 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)
> +
> + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(vf0_tx_stats == vf1_rx_stats, "VF1 failed to receive
> packets from VF0")
> +
> + def test_VEB_switching_inter_vfs_MAC_switch_vlan(self):
> + """
> + Kernel PF, then create 2VFs, assign VF1 with VLAN=1 in, VF2 with
> VLAN=2. VFs are running dpdk testpmd, send traffic to VF1 with VLAN=1,
> then let it forwards to VF2, it should not work since they are not
> in the same VLAN; set VF2 with VLAN=1, then send traffic to VF1 with
> VLAN=1, and VF2 can receive the packets. Check inter VF MAC/VLAN
> switch.
> + """
> + self.setup_1pf_kdriver_2vf_env(driver='')
> + # the two vfs belongs to different vlans
> + self.dut.send_expect("ip link set %s vf 0 vlan 1" %
> self.pf_interface, "# ", 1)
> + self.dut.send_expect("ip link set %s vf 1 vlan 2" %
> self.pf_interface, "# ", 1)
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> "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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % 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)
> +
> + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify((vf0_tx_stats[0] == 1) and (vf1_rx_stats[0] == 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)
> +
> + # the two vfs belongs to the same vlan
> + self.dut.send_expect("ip link set %s vf 1 vlan 1" %
> self.pf_interface, "# ", 1)
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> "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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % 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)
> +
> + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify((vf0_tx_stats[0] == 1) and (vf1_rx_stats[0] == 1),
> "VF1 didn't receive packets from VF0, the vlan filter doen't work")
> +
> + def test_VEB_switching_inter_pf_vf_MAC_switch(self):
> + """
> + DPDK PF, then create 1VF, PF in the host running dpdk testpmd,
> send traffic from PF to VF1, ensure PF->VF1(let VF1 in promisc mode); send
> traffic from VF1 to PF, ensure VF1->PF can work.
> + """
> + # VF->PF
> + self.setup_1pf_ddriver_1vf_env(driver='')
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" %
> self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(pf_rx_stats[0] != 0, "no packet was received by PF")
> + self.verify(vf0_tx_stats[0]*0.5 < pf_rx_stats[0], "PF failed to
> receive most packets from VF0")
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> + self.dut.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + #PF->VF
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --eth-
> peer=0,%s" % (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>")
> +
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> + self.verify(pf_tx_stats[0] != 0, "no packet was sent by PF")
> + self.verify(vf0_rx_stats[0] != 0, "no packet was received by VF0")
> + self.verify(vf0_rx_stats[0] > pf_tx_stats[0]*0.5, "VF0 failed to
> receive 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("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" %
> self.pf_pci, "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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> + self.verify(pf_tx_stats[0] == 0, "PF received unexpected packet")
> + self.verify(vf0_rx_stats[0] == 1, "no packet was received by VF0")
> +
> + 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 = self.veb_get_pmd_stats("second", 0, "rx")
> + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> + self.verify(pf_tx_stats[0] == 1, "no packet was sent by VF0")
> + self.verify(pf_rx_stats[0] == 1, "no packet was received by VF0")
> + self.verify(vf0_rx_stats[0] == 1, "no packet was received by VF0")
> +
> + def test_floating_VEB_switching_inter_pf_vf_MAC_switch(self):
> + """
> + DPDK PF, then create 1VF, PF in the host running dpdk testpmd,
> send traffic from PF to VF0, VF0 can't receive any packets; send traffic
> from VF0 to PF, PF can't rec eive any packets either.
> + """
> + # VF->PF
> + self.setup_1pf_ddriver_1vf_env(driver='')
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> prefix=test1 -- -i" % self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(pf_rx_stats[0] == 0, "PF can receive packet from VF0,
> the floating VEB doesn't work")
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> + self.dut.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + #PF->VF
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> prefix=test1 -- -i --eth-peer=0,%s" % (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>")
> +
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> + self.verify(pf_tx_stats[0] != 0, "no packet was sent by PF")
> + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from PF,
> the floating VEB doesn't work")
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> + self.dut.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + #outside world ->VF
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> prefix=test1 -- -i --eth-peer=0,%s" % (self.pf_pci, self.vf0_mac),
> "testpmd>", 120)
> + self.dut.send_expect("set fwd mac", "testpmd>")
> + self.dut.send_expect("set promisc all on", "testpmd>")
> + self.dut.send_expect("start", "testpmd>")
> + time.sleep(2)
> +
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % (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 mac", "testpmd>")
> + self.session_secondary.send_expect("set promisc all on",
> "testpmd>")
> + self.session_secondary.send_expect("start", "testpmd>")
> + time.sleep(2)
> +
> + self.send_packet(self.vf0_mac, self.tester_itf)
> + time.sleep(2)
> + self.dut.send_expect("stop", "testpmd>", 2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> +
> + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from
> outside world, the floating VEB doesn't work")
> +
> + def test_floating_VEB_switching_inter_vfs_MAC_switch(self):
> + """
> + 1 DPDK PF, then create 2VF, PF in the host running dpdk testpmd,
> and VF0 are running dpdk testpmd, VF0 send traffic, and set the packet's
> DEST MAC to VF1, check if VF1 can receive the packets. Check Inter VF-VF
> MAC switch when PF is link down as well as up.
> + """
> + # PF link up, VF0->VF1
> + self.setup_1pf_ddriver_2vf_env(driver='')
> + # start PF
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> prefix=test1 -- -i" % self.pf_pci, "testpmd>", 120)
> + self.dut.send_expect("port start all", "testpmd>")
> + time.sleep(2)
> + # start VF0
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % 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)
> + # start VF1
> + self.session_third.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test3 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[1].pci, self.vf0_mac), "testpmd>", 120)
> + self.session_third.send_expect("set fwd txonly", "testpmd>")
> + self.session_third.send_expect("set promisc all off", "testpmd>")
> + self.session_third.send_expect("start", "testpmd>")
> + time.sleep(2)
> +
> + self.session_third.send_expect("stop", "testpmd>", 2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> +
> + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + vf1_tx_stats = self.veb_get_pmd_stats("third", 0, "tx")
> + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> + self.verify(vf0_rx_stats[0] != 0, "no packet was received by VF0")
> + self.verify(vf1_tx_stats[0]*0.5 < vf0_rx_stats[0], "VF0 failed to
> receive most packets from VF1")
> +
> + # PF link down, VF0 -> VF1
> + self.dut.send_expect("port stop all", "Port 0 Link Down", 20)
> + self.session_secondary.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_third.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_third.send_expect("stop", "testpmd>", 2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> + self.dut.send_expect("stop", "testpmd>", 2)
> +
> + vf1_tx_stats_pfstop = self.veb_get_pmd_stats("third", 0, "tx")
> + vf0_rx_stats_pfstop = self.veb_get_pmd_stats("second", 0, "rx")
> + vf1_tx_stats_pfstop[0] = vf1_tx_stats_pfstop[0] - vf1_tx_stats[0]
> + vf0_rx_stats_pfstop[0] = vf0_rx_stats_pfstop[0] - vf0_rx_stats[0]
> + self.verify(vf1_tx_stats_pfstop[0] != 0, "no packet was sent by
> VF1")
> + self.verify(vf0_rx_stats_pfstop[0] != 0, "no packet was received
> by VF0")
> + self.verify(vf1_tx_stats_pfstop[0]*0.5 < vf0_rx_stats_pfstop[0],
> "VF0 failed to receive most packets from VF1")
> +
> + def test_floating_VEB_VF_cannot_communicate_with_legacy_VEB_VF(self):
> + """
> + DPDK PF, then create 4VF, VF0,VF2,VF3 are floating VEB; VF1 is
> lagecy VEB. Make PF link down(the cable can be pluged out), VFs are
> running dpdk testpmd.
> + 1. VF0 send traffic, and set the packet's DEST MAC to VF1, check
> VF1 can not receive the packets.
> + 2. VF1 send traffic, and set the packet's DEST MAC to VF0, check
> VF0 can not receive the packets.
> + 3. VF0 send traffic, and set the packet's DEST MAC to VF2, check
> VF2 can receive the packets.
> + 4. VF3 send traffic, and set the packet's DEST MAC to VF2, check
> VF2 can receive the packets.
> + """
> + self.setup_1pf_ddriver_4vf_env(driver='')
> + # start PF
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 \"-
> w %s,enable_floating_veb=1,floating_veb_list=0;2-3\" --file-prefix=test1 -
> - -i" % self.pf_pci, "testpmd>", 120)
> + self.dut.send_expect("port start all", "testpmd>")
> + time.sleep(2)
> + # VF1->VF0
> + # start VF0
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[0].pci, self.vf1_mac), "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>")
> + # start VF1
> + self.session_third.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test3 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[1].pci, self.vf0_mac), "testpmd>", 120)
> + self.session_secondary.send_expect("mac_addr add 0 %s" %
> self.vf1_mac, "testpmd>")
> + self.session_third.send_expect("set fwd txonly", "testpmd>")
> + self.session_third.send_expect("set promisc all off", "testpmd>")
> +
> + # PF link down
> + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> + self.session_secondary.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_third.send_expect("start", "testpmd>")
> + time.sleep(2)
> +
> + self.session_third.send_expect("stop", "testpmd>", 2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> +
> + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + vf1_tx_stats = self.veb_get_pmd_stats("third", 0, "tx")
> + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> + self.verify(vf0_rx_stats[0] == 0, "floating_VEB VF can
> communicate with legacy_VEB VF")
> +
> + # VF0->VF1
> + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> + self.session_third.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_secondary.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> + self.session_third.send_expect("stop", "testpmd>", 2)
> + vf1_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> + vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(vf1_rx_stats[0] == 0, "floating_VEB VF can
> communicate with legacy_VEB VF")
> +
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> + self.session_third.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + # VF0->VF2
> + # start VF0
> + self.dut.send_expect("port start all", "testpmd>")
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[0].pci, self.vf2_mac), "testpmd>", 120)
> + self.session_secondary.send_expect("mac_addr add 0 %s" %
> self.vf0_mac, "testpmd>")
> + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> + self.session_secondary.send_expect("set promisc all off",
> "testpmd>")
> + # start VF2
> + self.session_third.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test3 -- -i --crc-strip" % self.sriov_vfs_port[2].pci, "testpmd>",
> 120)
> + self.session_third.send_expect("mac_addr add 0 %s" % self.vf2_mac,
> "testpmd>")
> + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> + self.session_third.send_expect("set promisc all off", "testpmd>")
> +
> + # PF link down
> + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> + self.session_third.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_secondary.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> + self.session_third.send_expect("stop", "testpmd>", 2)
> +
> + vf2_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> + vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(vf2_rx_stats[0] != 0, "floating_VEB VFs cannot
> communicate with each other")
> + self.verify(vf0_tx_stats[0] * 0.5 < vf2_rx_stats[0], "VF2 failed
> to receive packets from VF0")
> +
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> + self.session_third.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + # VF3->VF2
> + # start VF3
> + self.dut.send_expect("port start all", "testpmd>")
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[3].pci, self.vf2_mac), "testpmd>", 120)
> + self.session_secondary.send_expect("mac_addr add 0 %s" %
> self.vf0_mac, "testpmd>")
> + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> + self.session_secondary.send_expect("set promisc all off",
> "testpmd>")
> + # start VF2
> + self.session_third.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test3 -- -i --crc-strip" % self.sriov_vfs_port[2].pci, "testpmd>",
> 120)
> + self.session_third.send_expect("mac_addr add 0 %s" % self.vf2_mac,
> "testpmd>")
> + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> + self.session_third.send_expect("set promisc all off", "testpmd>")
> +
> + # PF link down
> + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> + self.session_third.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_secondary.send_expect("start", "testpmd>")
> + time.sleep(2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> + self.session_third.send_expect("stop", "testpmd>", 2)
> +
> + vf2_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> + vf3_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> + self.verify(vf3_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(vf2_rx_stats[0] != 0, "floating_VEB VFs cannot
> communicate with each other")
> + self.verify(vf3_tx_stats[0] * 0.5 < vf2_rx_stats[0], "VF2 failed
> to receive packets from VF3")
> +
> + def
> test_floating_VEB_and_legacy_VEB_switching_inter_pf_vf_MAC_switch(self):
> + """
> + DPDK PF, then create 2VFs, VF0 is in floating VEB, VF1 is in
> legacy VEB.
> + 1. Send traffic from VF0 to PF, then check PF will not see any
> traffic;
> + 2. Send traffic from VF1 to PF, then check PF will receive all
> the packets.
> + 3. send traffic from tester to VF0, check VF0 can't receive
> traffic from tester.
> + 4. send traffic from tester to VF1, check VF1 can receive all the
> traffic from tester.
> + """
> + self.setup_1pf_ddriver_2vf_env(driver='')
> + # VF0->PF
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 \"-
> w %s,enable_floating_veb=1,floating_veb_list=0\" --file-prefix=test1 -- -
> i" % self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> + self.verify(pf_rx_stats[0] == 0, "PF can receive packet from VF0,
> the floating VEB doesn't work")
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + # VF1->PF
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> (self.sriov_vfs_port[1].pci, self.pf_mac_address), "testpmd>", 120)
> + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> + self.session_secondary.send_expect("set promisc all off",
> "testpmd>")
> + self.dut.send_expect("start", "testpmd>")
> + time.sleep(2)
> + 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)
> +
> + vf1_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> + self.verify(pf_rx_stats[0] != 0, "PF can't receive packet from
> VF1, the VEB doesn't work")
> + self.verify(vf1_tx_stats[0] * 0.5 < pf_rx_stats[0], "PF failed to
> receive packets from VF1")
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> + self.dut.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + # tester->VF0
> + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd -c
> 0xf -n 4 --socket-mem 1024,1024 \"-
> w %s,enable_floating_veb=1,floating_veb_list=0\" --file-prefix=test1 -- -
> i" % self.pf_pci, "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("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % (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 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)
> + time.sleep(2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> + self.dut.send_expect("stop", "testpmd>", 2)
> +
> + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from
> outside world, the floating VEB doesn't work")
> + self.session_secondary.send_expect("quit", "# ")
> + time.sleep(2)
> +
> + # tester->VF1
> + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> prefix=test2 -- -i --crc-strip" % (self.sriov_vfs_port[1].pci), "testpmd>",
> 120)
> + self.session_secondary.send_expect("mac_addr add 0 %s" %
> self.vf1_mac, "testpmd>")
> + 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.vf1_mac, self.tester_itf)
> + time.sleep(2)
> + self.session_secondary.send_expect("stop", "testpmd>", 2)
> + self.dut.send_expect("stop", "testpmd>", 2)
> +
> + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> + self.verify(vf1_rx_stats[0] == 1, "VF1 can't receive packet from
> outside world, the VEB doesn't work")
> +
> + def tear_down(self):
> + """
> + Run after each test case.
> + """
> + if self.setup_1pf_kdriver_2vf_env_flag == 1:
> + self.destroy_1pf_kdriver_2vf_env()
> + if self.setup_1pf_ddriver_1vf_env_flag == 1:
> + self.destroy_1pf_ddriver_1vf_env()
> + if self.setup_1pf_ddriver_2vf_env_flag == 1:
> + self.destroy_1pf_ddriver_2vf_env()
> + if self.setup_1pf_ddriver_4vf_env_flag == 1:
> + self.destroy_1pf_ddriver_4vf_env()
> +
> + self.dut.kill_all()
> +
> + pass
> +
> + 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)
Need restore dut ports bound to igb_uio driver.
> +
> + pass
> --
> 2.5.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
2016-10-19 3:12 ` Peng, Yuan
@ 2016-10-19 3:16 ` Liu, Yong
2016-10-19 3:19 ` Peng, Yuan
0 siblings, 1 reply; 8+ messages in thread
From: Liu, Yong @ 2016-10-19 3:16 UTC (permalink / raw)
To: Peng, Yuan, dts
Use Fortville as example, its default driver is i40e. After bind to default driver, dpdk won't able to use it.
When dts run suites, all ports have been bound to igb_uio. Each suite should guarantee that all ports still bind to igb_uio after each case finished.
> -----Original Message-----
> From: Peng, Yuan
> Sent: Tuesday, October 18, 2016 8:12 PM
> To: Liu, Yong; dts@dpdk.org
> Subject: RE: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
>
> Hi Marvin,
>
> I don't know why I can't bind the dut ports to default driver when the
> testsuite finished?
>
> Thank you.
> Yuan.
>
> -----Original Message-----
> From: Liu, Yong
> Sent: Friday, October 14, 2016 10:40 PM
> To: Peng, Yuan <yuan.peng@intel.com>; dts@dpdk.org
> Cc: Peng, Yuan <yuan.peng@intel.com>
> Subject: RE: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
>
> Yuan, some comments below. Please remember that your suite is not the only
> one in our execution.
> You need keep the environment just the same as you use it.
> And please try to keep line in 79 characters.
>
> > -----Original Message-----
> > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Yuan Peng
> > Sent: Friday, October 14, 2016 8:51 AM
> > To: dts@dpdk.org
> > Cc: Peng, Yuan
> > Subject: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
> >
> > From: pengyuan <yuan.peng@intel.com>
> >
> > Signed-off-by: pengyuan <yuan.peng@intel.com>
> >
> > diff --git a/tests/TestSuite_VEB.py b/tests/TestSuite_VEB.py
> > new file mode 100644
> > index 0000000..6296ff1
> > --- /dev/null
> > +++ b/tests/TestSuite_VEB.py
> > @@ -0,0 +1,934 @@
> > +# 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
> > +# 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 VEB Switch and floating VEB Features by Poll Mode Drivers.
> > +"""
> > +
> > +import re
> > +import time
> > +
> > +import dts
> Please remove dts dependency in your suite. All suite should have no
> dependency on this module.
>
> > +from virt_dut import VirtDut
> > +from project_dpdk import DPDKdut
> > +from dut import Dut
> > +from net_device import GetNicObj
> > +from net_device import RemoveNicObj
> > +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 == "vf0":
> > + stats = self.pmdout.get_pmd_stats(portid)
> > + elif vf0_vf1 == "vf1":
> > + stats = self.pmdout_session_secondary.get_pmd_stats(portid)
> > + else:
> > + return None
> > +
> > + if rx_tx == "rx":
> > + return [stats['RX-packets'], stats['RX-errors'], stats['RX-
> > bytes']]
> > + elif rx_tx == "tx":
> > + return [stats['TX-packets'], stats['TX-errors'], stats['TX-
> > bytes']]
> > + else:
> > + return None
> > +
> > + def veb_get_pmd_stats(self, dev, portid, rx_tx):
> > + stats = {}
> > + rx_pkts_prefix = "RX-packets:"
> > + rx_bytes_prefix = "RX-bytes:"
> > + rx_error_prefix = "RX-errors:"
> > + tx_pkts_prefix = "TX-packets:"
> > + tx_error_prefix = "TX-errors:"
> > + tx_bytes_prefix = "TX-bytes:"
> > +
> > + if dev == "first":
> > + out = self.dut.send_expect("show port stats %d" % portid,
> > "testpmd> ")
> > + elif dev == "second":
> > + out = self.session_secondary.send_expect("show port
> > stats %d" % portid, "testpmd> ")
> > + elif dev == "third":
> > + out = self.session_third.send_expect("show port stats %d" %
> > portid, "testpmd> ")
> > + else:
> > + return None
> > +
> > + stats["RX-packets"] = self.veb_get_pmd_value(rx_pkts_prefix,
> out)
> > + stats["RX-bytes"] = self.veb_get_pmd_value(rx_bytes_prefix, out)
> > + stats["RX-errors"] = self.veb_get_pmd_value(rx_error_prefix,
> out)
> > + stats["TX-packets"] = self.veb_get_pmd_value(tx_pkts_prefix,
> out)
> > + stats["TX-errors"] = self.veb_get_pmd_value(tx_error_prefix,
> out)
> > + stats["TX-bytes"] = self.veb_get_pmd_value(tx_bytes_prefix, out)
> > +
> > + if rx_tx == "rx":
> > + return [stats['RX-packets'], stats['RX-errors'], stats['RX-
> > bytes']]
> > + elif rx_tx == "tx":
> > + return [stats['TX-packets'], stats['TX-errors'], stats['TX-
> > bytes']]
> > + else:
> > + return None
> > +
> > +
> > + def veb_get_pmd_value(self, prefix, out):
> > + pattern = re.compile(prefix + "(\s+)([0-9]+)")
> > + m = pattern.search(out)
> > + if m is None:
> > + return None
> > + else:
> > + return int(m.group(2))
> > +
> > + def send_packet(self, vf_mac, itf, tran_type=""):
> > + """
> > + Send 1 packet
> > + """
> > + self.tester.scapy_foreground()
> > + self.tester.scapy_append('sys.path.append("./")')
> > + self.dut.send_expect("start", "testpmd>")
> > + mac = self.dut.get_mac_address(0)
> > +
> > + if tran_type == "vlan":
> > + packet = r'sendp([Ether(dst="%s",
> > src=get_if_hwaddr("%s"))/Dot1Q(vlan=1)/IP(src="192.168.0.1",
> > dst="192.168.0.2")], iface="%s")' % (vf_mac, itf, itf)
> > + self.tester.scapy_append(packet)
> > + self.tester.scapy_execute()
> > + time.sleep(.5)
> > + else:
> > + packet = r'sendp([Ether(dst="%s",
> > src=get_if_hwaddr("%s"))/IP(src="192.168.0.1", dst="192.168.0.2")],
> > iface="%s")' % (vf_mac, itf, itf)
> > + self.tester.scapy_append(packet)
> > + self.tester.scapy_execute()
> > + time.sleep(.5)
> > +
> > + #
> > + # Test cases.
> > + #
> > +
> > + 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 = self.dut.get_ports(self.nic)
> > + self.verify(len(self.dut_ports) >= 1, "Insufficient ports")
> > + # self.rx_port = self.dut_ports[0]
> > + # self.tx_port = self.dut_ports[0]
> > +
> > + # cores = self.dut.get_core_list("1S/2C/1T")
> > + # self.coremask = dts.create_mask(cores)
> > +
> > + # self.port_mask = dts.create_mask([self.rx_port, self.tx_port])
> > + self.session_secondary = self.dut.new_session()
> > + self.session_third = self.dut.new_session()
> > + # self.pmdout = PmdOutput(self.dut)
> > + # self.pmdout_session_secondary =
> > PmdOutput(self.session_secondary)
> > +
> Please remove commented code.
>
> > + def set_up(self):
> > + """
> > + This is to clear up environment before the case run.
> > + """
> > + self.dut.kill_all()
> > + self.setup_1pf_kdriver_2vf_env_flag = 0
> > + self.setup_1pf_ddriver_1vf_env_flag = 0
> > + self.setup_1pf_ddriver_2vf_env_flag = 0
> > + self.setup_1pf_ddriver_4vf_env_flag = 0
> > + self.vf0_mac = "00:11:22:33:44:11"
> > + self.vf1_mac = "00:11:22:33:44:12"
> > + self.vf2_mac = "00:11:22:33:44:13"
> > + self.vf3_mac = "00:11:22:33:44:14"
> > +
> > + def setup_1pf_ddriver_4vf_env(self, driver='default'):
> > + self.used_dut_port = self.dut_ports[0]
> > + localPort = self.tester.get_local_port(self.dut_ports[0])
> > + self.tester_itf = self.tester.get_interface(localPort)
> > + self.pf_interface =
> > self.dut.ports_info[self.used_dut_port]['intf']
> > + self.pf_mac_address = self.dut.get_mac_address(0)
>
> Several function required these information, you can strip these
> information only once in setup_all function.
>
> > + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> This code is useless here, is it just for debug?
>
> > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 4,
> > driver='igb_uio')
> > + self.sriov_vfs_port =
> > self.dut.ports_info[self.used_dut_port]['vfs_port']
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + try:
> > +
> > + for port in self.sriov_vfs_port:
> > + print port.pci
> Please remove debug code.
> > + self.dut.send_expect("./tools/dpdk-devbind.py -b
> > igb_uio %s" % (port.pci), "# ", 3)
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + time.sleep(1)
> > + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> > + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> > + vf2_prop = {'opt_host': self.sriov_vfs_port[2].pci}
> > + vf3_prop = {'opt_host': self.sriov_vfs_port[3].pci}
> > + for port_id in self.dut_ports:
> > + if port_id == self.used_dut_port:
> > + continue
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> I'm not sure about this logic, you can just get port object by
> self.dut.ports_info[self.used_dut_port].
> There's no need to browser through all dut ports.
> > +
> > + self.setup_1pf_ddriver_4vf_env_flag = 1
> > + except Exception as e:
> > + self.destroy_1pf_ddriver_4vf_env()
> > + raise Exception(e)
> > +
> > + def destroy_1pf_ddriver_4vf_env(self):
> > + self.session_third.send_expect("quit", "# ")
> > + self.session_secondary.send_expect("quit", "# ")
> > + self.dut.send_expect("quit", "# ")
> When there met some issues which caused testpmd can't start up normally.
> "Quit" command here will cause the session unavailable any more.
> Use kill_all api to quit dpdk application is one more reliable way to do
> such thing.
>
> > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> > + port = self.dut.ports_info[self.used_dut_port]['port']
> > + port.bind_driver()
> > + self.used_dut_port = None
> > +
> > + for port_id in self.dut_ports:
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > +
> Do not bind dut ports to default driver, this will cause that later suites
> can't work anymore.
> There's one solution for this is that when test suite initializing, we
> bind all dut ports to igb_uio.
> But please do not bind to default driver by now.
>
> > + self.setup_1pf_ddriver_4vf_env_flag = 0
> > +
> > + def setup_1pf_ddriver_2vf_env(self, driver='default'):
> > + self.used_dut_port = self.dut_ports[0]
> > + localPort = self.tester.get_local_port(self.dut_ports[0])
> > + self.tester_itf = self.tester.get_interface(localPort)
> > + self.pf_interface =
> > self.dut.ports_info[self.used_dut_port]['intf']
> > + self.pf_mac_address = self.dut.get_mac_address(0)
> > + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
> These codes can be done only once in setup_all function.
>
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2,
> > driver='igb_uio')
> > + self.sriov_vfs_port =
> > self.dut.ports_info[self.used_dut_port]['vfs_port']
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + try:
> > +
> > + for port in self.sriov_vfs_port:
> > + print port.pci
> > + self.dut.send_expect("./tools/dpdk-devbind.py -b
> > igb_uio %s" % (port.pci), "# ", 3)
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + time.sleep(1)
> > + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> > + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> > + for port_id in self.dut_ports:
> > + if port_id == self.used_dut_port:
> > + continue
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > +
> > + self.setup_1pf_ddriver_2vf_env_flag = 1
> > + except Exception as e:
> > + self.destroy_1pf_ddriver_2vf_env()
> > + raise Exception(e)
> > +
> > + def destroy_1pf_ddriver_2vf_env(self):
> > + self.session_third.send_expect("quit", "# ")
> > + self.session_secondary.send_expect("quit", "# ")
> > + self.dut.send_expect("quit", "# ")
> > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> > + port = self.dut.ports_info[self.used_dut_port]['port']
> > + port.bind_driver()
> > + self.used_dut_port = None
> > +
> > + for port_id in self.dut_ports:
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > +
> > + self.setup_1pf_ddriver_2vf_env_flag = 0
> > +
> > + def setup_1pf_ddriver_1vf_env(self, driver='default'):
> > + self.used_dut_port = self.dut_ports[0]
> > + localPort = self.tester.get_local_port(self.dut_ports[0])
> > + self.tester_itf = self.tester.get_interface(localPort)
> > + self.pf_interface =
> > self.dut.ports_info[self.used_dut_port]['intf']
> > + self.pf_mac_address = self.dut.get_mac_address(0)
> > + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + # self.dut.send_expect("echo 1 >
> > /sys/bus/pci/devices/%s/max_vfs" % self.pf_pci, "# ", 3)
> > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 1,
> > driver='igb_uio')
> > + self.sriov_vfs_port =
> > self.dut.ports_info[self.used_dut_port]['vfs_port']
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > +
> > + try:
> > +
> > + for port in self.sriov_vfs_port:
> > + print port.pci
> > + self.dut.send_expect("./tools/dpdk-devbind.py -b
> > igb_uio %s" % (port.pci), "# ", 3)
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + time.sleep(1)
> > + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> > +
> > + for port_id in self.dut_ports:
> > + if port_id == self.used_dut_port:
> > + continue
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > +
> > + self.setup_1pf_ddriver_1vf_env_flag = 1
> > + except Exception as e:
> > + self.destroy_1pf_ddriver_1vf_env()
> > + raise Exception(e)
> > +
> > + def destroy_1pf_ddriver_1vf_env(self):
> > +
> > + self.session_secondary.send_expect("quit", "# ")
> > + self.dut.send_expect("quit", "# ")
> > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> > + port = self.dut.ports_info[self.used_dut_port]['port']
> > + port.bind_driver()
> > + self.used_dut_port = None
> > +
> > + for port_id in self.dut_ports:
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > +
> > + self.setup_1pf_ddriver_1vf_env_flag = 0
> > +
> > + def setup_1pf_kdriver_2vf_env(self, driver='default'):
> > + self.used_dut_port = self.dut_ports[0]
> > + localPort = self.tester.get_local_port(self.dut_ports[0])
> > + self.tester_itf = self.tester.get_interface(localPort)
> > + for port_id in self.dut_ports:
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > + self.pf_interface =
> > self.dut.ports_info[self.used_dut_port]['intf']
> > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2,
> > driver=driver)
> > + self.sriov_vfs_port =
> > self.dut.ports_info[self.used_dut_port]['vfs_port']
> > + #self.vf0_mac = "00:11:22:33:44:11"
> > + #self.vf1_mac = "00:11:22:33:44:12"
> > + self.dut.send_expect("ip link set %s vf 0 mac %s" %
> > (self.pf_interface, self.vf0_mac), "# ", 3)
> > + self.dut.send_expect("ip link set %s vf 1 mac %s" %
> > (self.pf_interface, self.vf1_mac), "# ", 3)
> > +
> > + try:
> > +
> > + for port in self.sriov_vfs_port:
> > + print port.pci
> > + self.dut.send_expect("./tools/dpdk-devbind.py -b
> > igb_uio %s" % (port.pci), "# ", 3)
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + time.sleep(1)
> > + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> > + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> > +
> > + # for port_id in self.dut_ports:
> > + # if port_id == self.used_dut_port:
> > + # continue
> > + # port = self.dut.ports_info[port_id]['port']
> > + # port.bind_driver()
> > +
> > + self.setup_1pf_kdriver_2vf_env_flag = 1
> > + except Exception as e:
> > + self.destroy_1pf_kdriver_2vf_env()
> > + raise Exception(e)
> > +
> > + def destroy_1pf_kdriver_2vf_env(self):
> > +
> > + self.session_secondary.send_expect("quit", "# ")
> > + self.dut.send_expect("quit", "# ")
> > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> > + port = self.dut.ports_info[self.used_dut_port]['port']
> > + port.bind_driver()
> > + self.used_dut_port = None
> > +
> > + for port_id in self.dut_ports:
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > +
> > + self.setup_1pf_kdriver_2vf_env_flag = 0
> > +
> > + def test_VEB_switching_inter_vfs_MAC_switch_rxtx(self):
> > + """
>
> Please simplify the test case name, description below can explain the
> case.
>
> > + Kernel PF, then create 2VFs. VFs running dpdk testpmd, send
> > traffic to VF1, and set the packet's DEST MAC to VF2, check if VF2 can
> > receive the packets. Check Inter VF-VF MAC switch.
> > + """
> > + self.setup_1pf_kdriver_2vf_env(driver='')
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> > strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> > "testpmd>", 120)
> Mac here should not hardcode, it has been defined in setup function.
>
> > + self.dut.send_expect("set fwd txonly", "testpmd>")
> > + self.dut.send_expect("set promisc all off", "testpmd>")
> > +
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % self.sriov_vfs_port[1].pci, "testpmd>",
> > 120)
>
> Target should not be hard coded for we will do the validation with
> different targets.
> You can use start_testpmd in pmd_ouput module to simplify the step.
>
> > + 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)
> > +
> > + self.dut.send_expect("stop", "testpmd>", 5)
> > + self.session_secondary.send_expect("stop", "testpmd>", 5)
> > +
> > + vf0_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(vf0_tx_stats[0] * 0.5 < vf1_rx_stats[0], "VF1
> failed
> > to receive packets from VF0")
> > +
> > + def test_VEB_switching_inter_vfs_MAC_switch_fwd(self):
> > + """
> > + Kernel PF, then create 2VFs. VFs running dpdk testpmd, send
> > traffic to VF1, and set the packet's DEST MAC to VF2, check if VF2 can
> > receive the packets. Check Inter VF-VF MAC switch.
> > + """
> > + self.setup_1pf_kdriver_2vf_env(driver='')
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> > strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> > "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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % 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)
> > +
> > + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(vf0_tx_stats == vf1_rx_stats, "VF1 failed to
> receive
> > packets from VF0")
> > +
> > + def test_VEB_switching_inter_vfs_MAC_switch_vlan(self):
> > + """
> > + Kernel PF, then create 2VFs, assign VF1 with VLAN=1 in, VF2
> with
> > VLAN=2. VFs are running dpdk testpmd, send traffic to VF1 with VLAN=1,
> > then let it forwards to VF2, it should not work since they are
> not
> > in the same VLAN; set VF2 with VLAN=1, then send traffic to VF1 with
> > VLAN=1, and VF2 can receive the packets. Check inter VF
> MAC/VLAN
> > switch.
> > + """
> > + self.setup_1pf_kdriver_2vf_env(driver='')
> > + # the two vfs belongs to different vlans
> > + self.dut.send_expect("ip link set %s vf 0 vlan 1" %
> > self.pf_interface, "# ", 1)
> > + self.dut.send_expect("ip link set %s vf 1 vlan 2" %
> > self.pf_interface, "# ", 1)
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> > strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> > "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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % 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)
> > +
> > + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify((vf0_tx_stats[0] == 1) and (vf1_rx_stats[0] == 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)
> > +
> > + # the two vfs belongs to the same vlan
> > + self.dut.send_expect("ip link set %s vf 1 vlan 1" %
> > self.pf_interface, "# ", 1)
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> > strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> > "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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % 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)
> > +
> > + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify((vf0_tx_stats[0] == 1) and (vf1_rx_stats[0] == 1),
> > "VF1 didn't receive packets from VF0, the vlan filter doen't work")
> > +
> > + def test_VEB_switching_inter_pf_vf_MAC_switch(self):
> > + """
> > + DPDK PF, then create 1VF, PF in the host running dpdk testpmd,
> > send traffic from PF to VF1, ensure PF->VF1(let VF1 in promisc mode);
> send
> > traffic from VF1 to PF, ensure VF1->PF can work.
> > + """
> > + # VF->PF
> > + self.setup_1pf_ddriver_1vf_env(driver='')
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" %
> > self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(pf_rx_stats[0] != 0, "no packet was received by PF")
> > + self.verify(vf0_tx_stats[0]*0.5 < pf_rx_stats[0], "PF failed to
> > receive most packets from VF0")
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > + self.dut.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + #PF->VF
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --eth-
> > peer=0,%s" % (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>")
> > +
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> > + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > + self.verify(pf_tx_stats[0] != 0, "no packet was sent by PF")
> > + self.verify(vf0_rx_stats[0] != 0, "no packet was received by
> VF0")
> > + self.verify(vf0_rx_stats[0] > pf_tx_stats[0]*0.5, "VF0 failed
> to
> > receive 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("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" %
> > self.pf_pci, "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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> > + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > + self.verify(pf_tx_stats[0] == 0, "PF received unexpected
> packet")
> > + self.verify(vf0_rx_stats[0] == 1, "no packet was received by
> VF0")
> > +
> > + 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 = self.veb_get_pmd_stats("second", 0, "rx")
> > + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > + self.verify(pf_tx_stats[0] == 1, "no packet was sent by VF0")
> > + self.verify(pf_rx_stats[0] == 1, "no packet was received by
> VF0")
> > + self.verify(vf0_rx_stats[0] == 1, "no packet was received by
> VF0")
> > +
> > + def test_floating_VEB_switching_inter_pf_vf_MAC_switch(self):
> > + """
> > + DPDK PF, then create 1VF, PF in the host running dpdk testpmd,
> > send traffic from PF to VF0, VF0 can't receive any packets; send traffic
> > from VF0 to PF, PF can't rec eive any packets either.
> > + """
> > + # VF->PF
> > + self.setup_1pf_ddriver_1vf_env(driver='')
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> > prefix=test1 -- -i" % self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(pf_rx_stats[0] == 0, "PF can receive packet from
> VF0,
> > the floating VEB doesn't work")
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > + self.dut.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + #PF->VF
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> > prefix=test1 -- -i --eth-peer=0,%s" % (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>")
> > +
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> > + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > + self.verify(pf_tx_stats[0] != 0, "no packet was sent by PF")
> > + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from
> PF,
> > the floating VEB doesn't work")
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > + self.dut.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + #outside world ->VF
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> > prefix=test1 -- -i --eth-peer=0,%s" % (self.pf_pci, self.vf0_mac),
> > "testpmd>", 120)
> > + self.dut.send_expect("set fwd mac", "testpmd>")
> > + self.dut.send_expect("set promisc all on", "testpmd>")
> > + self.dut.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > +
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % (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 mac", "testpmd>")
> > + self.session_secondary.send_expect("set promisc all on",
> > "testpmd>")
> > + self.session_secondary.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > +
> > + self.send_packet(self.vf0_mac, self.tester_itf)
> > + time.sleep(2)
> > + self.dut.send_expect("stop", "testpmd>", 2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > +
> > + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from
> > outside world, the floating VEB doesn't work")
> > +
> > + def test_floating_VEB_switching_inter_vfs_MAC_switch(self):
> > + """
> > + 1 DPDK PF, then create 2VF, PF in the host running dpdk testpmd,
> > and VF0 are running dpdk testpmd, VF0 send traffic, and set the packet's
> > DEST MAC to VF1, check if VF1 can receive the packets. Check Inter VF-VF
> > MAC switch when PF is link down as well as up.
> > + """
> > + # PF link up, VF0->VF1
> > + self.setup_1pf_ddriver_2vf_env(driver='')
> > + # start PF
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> > prefix=test1 -- -i" % self.pf_pci, "testpmd>", 120)
> > + self.dut.send_expect("port start all", "testpmd>")
> > + time.sleep(2)
> > + # start VF0
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % 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)
> > + # start VF1
> > + self.session_third.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test3 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[1].pci, self.vf0_mac), "testpmd>", 120)
> > + self.session_third.send_expect("set fwd txonly", "testpmd>")
> > + self.session_third.send_expect("set promisc all off",
> "testpmd>")
> > + self.session_third.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > +
> > + self.session_third.send_expect("stop", "testpmd>", 2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > +
> > + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + vf1_tx_stats = self.veb_get_pmd_stats("third", 0, "tx")
> > + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> > + self.verify(vf0_rx_stats[0] != 0, "no packet was received by
> VF0")
> > + self.verify(vf1_tx_stats[0]*0.5 < vf0_rx_stats[0], "VF0 failed
> to
> > receive most packets from VF1")
> > +
> > + # PF link down, VF0 -> VF1
> > + self.dut.send_expect("port stop all", "Port 0 Link Down", 20)
> > + self.session_secondary.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_third.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_third.send_expect("stop", "testpmd>", 2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > + self.dut.send_expect("stop", "testpmd>", 2)
> > +
> > + vf1_tx_stats_pfstop = self.veb_get_pmd_stats("third", 0, "tx")
> > + vf0_rx_stats_pfstop = self.veb_get_pmd_stats("second", 0, "rx")
> > + vf1_tx_stats_pfstop[0] = vf1_tx_stats_pfstop[0] -
> vf1_tx_stats[0]
> > + vf0_rx_stats_pfstop[0] = vf0_rx_stats_pfstop[0] -
> vf0_rx_stats[0]
> > + self.verify(vf1_tx_stats_pfstop[0] != 0, "no packet was sent by
> > VF1")
> > + self.verify(vf0_rx_stats_pfstop[0] != 0, "no packet was
> received
> > by VF0")
> > + self.verify(vf1_tx_stats_pfstop[0]*0.5 < vf0_rx_stats_pfstop[0],
> > "VF0 failed to receive most packets from VF1")
> > +
> > + def
> test_floating_VEB_VF_cannot_communicate_with_legacy_VEB_VF(self):
> > + """
> > + DPDK PF, then create 4VF, VF0,VF2,VF3 are floating VEB; VF1 is
> > lagecy VEB. Make PF link down(the cable can be pluged out), VFs are
> > running dpdk testpmd.
> > + 1. VF0 send traffic, and set the packet's DEST MAC to VF1,
> check
> > VF1 can not receive the packets.
> > + 2. VF1 send traffic, and set the packet's DEST MAC to VF0,
> check
> > VF0 can not receive the packets.
> > + 3. VF0 send traffic, and set the packet's DEST MAC to VF2,
> check
> > VF2 can receive the packets.
> > + 4. VF3 send traffic, and set the packet's DEST MAC to VF2,
> check
> > VF2 can receive the packets.
> > + """
> > + self.setup_1pf_ddriver_4vf_env(driver='')
> > + # start PF
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 \"-
> > w %s,enable_floating_veb=1,floating_veb_list=0;2-3\" --file-prefix=test1
> -
> > - -i" % self.pf_pci, "testpmd>", 120)
> > + self.dut.send_expect("port start all", "testpmd>")
> > + time.sleep(2)
> > + # VF1->VF0
> > + # start VF0
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[0].pci, self.vf1_mac), "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>")
> > + # start VF1
> > + self.session_third.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test3 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[1].pci, self.vf0_mac), "testpmd>", 120)
> > + self.session_secondary.send_expect("mac_addr add 0 %s" %
> > self.vf1_mac, "testpmd>")
> > + self.session_third.send_expect("set fwd txonly", "testpmd>")
> > + self.session_third.send_expect("set promisc all off",
> "testpmd>")
> > +
> > + # PF link down
> > + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> > + self.session_secondary.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_third.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > +
> > + self.session_third.send_expect("stop", "testpmd>", 2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > +
> > + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + vf1_tx_stats = self.veb_get_pmd_stats("third", 0, "tx")
> > + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> > + self.verify(vf0_rx_stats[0] == 0, "floating_VEB VF can
> > communicate with legacy_VEB VF")
> > +
> > + # VF0->VF1
> > + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> > + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> > + self.session_third.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_secondary.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > + self.session_third.send_expect("stop", "testpmd>", 2)
> > + vf1_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> > + vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(vf1_rx_stats[0] == 0, "floating_VEB VF can
> > communicate with legacy_VEB VF")
> > +
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > + self.session_third.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + # VF0->VF2
> > + # start VF0
> > + self.dut.send_expect("port start all", "testpmd>")
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[0].pci, self.vf2_mac), "testpmd>", 120)
> > + self.session_secondary.send_expect("mac_addr add 0 %s" %
> > self.vf0_mac, "testpmd>")
> > + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> > + self.session_secondary.send_expect("set promisc all off",
> > "testpmd>")
> > + # start VF2
> > + self.session_third.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test3 -- -i --crc-strip" % self.sriov_vfs_port[2].pci, "testpmd>",
> > 120)
> > + self.session_third.send_expect("mac_addr add 0 %s" %
> self.vf2_mac,
> > "testpmd>")
> > + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> > + self.session_third.send_expect("set promisc all off",
> "testpmd>")
> > +
> > + # PF link down
> > + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> > + self.session_third.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_secondary.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > + self.session_third.send_expect("stop", "testpmd>", 2)
> > +
> > + vf2_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> > + vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(vf2_rx_stats[0] != 0, "floating_VEB VFs cannot
> > communicate with each other")
> > + self.verify(vf0_tx_stats[0] * 0.5 < vf2_rx_stats[0], "VF2
> failed
> > to receive packets from VF0")
> > +
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > + self.session_third.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + # VF3->VF2
> > + # start VF3
> > + self.dut.send_expect("port start all", "testpmd>")
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[3].pci, self.vf2_mac), "testpmd>", 120)
> > + self.session_secondary.send_expect("mac_addr add 0 %s" %
> > self.vf0_mac, "testpmd>")
> > + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> > + self.session_secondary.send_expect("set promisc all off",
> > "testpmd>")
> > + # start VF2
> > + self.session_third.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test3 -- -i --crc-strip" % self.sriov_vfs_port[2].pci, "testpmd>",
> > 120)
> > + self.session_third.send_expect("mac_addr add 0 %s" %
> self.vf2_mac,
> > "testpmd>")
> > + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> > + self.session_third.send_expect("set promisc all off",
> "testpmd>")
> > +
> > + # PF link down
> > + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> > + self.session_third.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_secondary.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > + self.session_third.send_expect("stop", "testpmd>", 2)
> > +
> > + vf2_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> > + vf3_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> > + self.verify(vf3_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(vf2_rx_stats[0] != 0, "floating_VEB VFs cannot
> > communicate with each other")
> > + self.verify(vf3_tx_stats[0] * 0.5 < vf2_rx_stats[0], "VF2
> failed
> > to receive packets from VF3")
> > +
> > + def
> > test_floating_VEB_and_legacy_VEB_switching_inter_pf_vf_MAC_switch(self):
> > + """
> > + DPDK PF, then create 2VFs, VF0 is in floating VEB, VF1 is in
> > legacy VEB.
> > + 1. Send traffic from VF0 to PF, then check PF will not see any
> > traffic;
> > + 2. Send traffic from VF1 to PF, then check PF will receive all
> > the packets.
> > + 3. send traffic from tester to VF0, check VF0 can't receive
> > traffic from tester.
> > + 4. send traffic from tester to VF1, check VF1 can receive all
> the
> > traffic from tester.
> > + """
> > + self.setup_1pf_ddriver_2vf_env(driver='')
> > + # VF0->PF
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 \"-
> > w %s,enable_floating_veb=1,floating_veb_list=0\" --file-prefix=test1 --
> -
> > i" % self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(pf_rx_stats[0] == 0, "PF can receive packet from
> VF0,
> > the floating VEB doesn't work")
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + # VF1->PF
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[1].pci, self.pf_mac_address), "testpmd>", 120)
> > + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> > + self.session_secondary.send_expect("set promisc all off",
> > "testpmd>")
> > + self.dut.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + 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)
> > +
> > + vf1_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> > + self.verify(pf_rx_stats[0] != 0, "PF can't receive packet from
> > VF1, the VEB doesn't work")
> > + self.verify(vf1_tx_stats[0] * 0.5 < pf_rx_stats[0], "PF failed
> to
> > receive packets from VF1")
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > + self.dut.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + # tester->VF0
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 \"-
> > w %s,enable_floating_veb=1,floating_veb_list=0\" --file-prefix=test1 --
> -
> > i" % self.pf_pci, "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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % (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 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)
> > + time.sleep(2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > + self.dut.send_expect("stop", "testpmd>", 2)
> > +
> > + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from
> > outside world, the floating VEB doesn't work")
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + # tester->VF1
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % (self.sriov_vfs_port[1].pci),
> "testpmd>",
> > 120)
> > + self.session_secondary.send_expect("mac_addr add 0 %s" %
> > self.vf1_mac, "testpmd>")
> > + 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.vf1_mac, self.tester_itf)
> > + time.sleep(2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > + self.dut.send_expect("stop", "testpmd>", 2)
> > +
> > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + self.verify(vf1_rx_stats[0] == 1, "VF1 can't receive packet
> from
> > outside world, the VEB doesn't work")
> > +
> > + def tear_down(self):
> > + """
> > + Run after each test case.
> > + """
> > + if self.setup_1pf_kdriver_2vf_env_flag == 1:
> > + self.destroy_1pf_kdriver_2vf_env()
> > + if self.setup_1pf_ddriver_1vf_env_flag == 1:
> > + self.destroy_1pf_ddriver_1vf_env()
> > + if self.setup_1pf_ddriver_2vf_env_flag == 1:
> > + self.destroy_1pf_ddriver_2vf_env()
> > + if self.setup_1pf_ddriver_4vf_env_flag == 1:
> > + self.destroy_1pf_ddriver_4vf_env()
> > +
> > + self.dut.kill_all()
> > +
> > + pass
> > +
> > + 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)
> Need restore dut ports bound to igb_uio driver.
> > +
> > + pass
> > --
> > 2.5.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
2016-10-19 3:16 ` Liu, Yong
@ 2016-10-19 3:19 ` Peng, Yuan
2016-10-19 3:23 ` Liu, Yong
0 siblings, 1 reply; 8+ messages in thread
From: Peng, Yuan @ 2016-10-19 3:19 UTC (permalink / raw)
To: Liu, Yong, dts
At the initiation of each suite, there are not steps to bind the dut ports to igb_uio?
-----Original Message-----
From: Liu, Yong
Sent: Wednesday, October 19, 2016 11:17 AM
To: Peng, Yuan <yuan.peng@intel.com>; dts@dpdk.org
Subject: RE: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
Use Fortville as example, its default driver is i40e. After bind to default driver, dpdk won't able to use it.
When dts run suites, all ports have been bound to igb_uio. Each suite should guarantee that all ports still bind to igb_uio after each case finished.
> -----Original Message-----
> From: Peng, Yuan
> Sent: Tuesday, October 18, 2016 8:12 PM
> To: Liu, Yong; dts@dpdk.org
> Subject: RE: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
>
> Hi Marvin,
>
> I don't know why I can't bind the dut ports to default driver when the
> testsuite finished?
>
> Thank you.
> Yuan.
>
> -----Original Message-----
> From: Liu, Yong
> Sent: Friday, October 14, 2016 10:40 PM
> To: Peng, Yuan <yuan.peng@intel.com>; dts@dpdk.org
> Cc: Peng, Yuan <yuan.peng@intel.com>
> Subject: RE: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
>
> Yuan, some comments below. Please remember that your suite is not the only
> one in our execution.
> You need keep the environment just the same as you use it.
> And please try to keep line in 79 characters.
>
> > -----Original Message-----
> > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Yuan Peng
> > Sent: Friday, October 14, 2016 8:51 AM
> > To: dts@dpdk.org
> > Cc: Peng, Yuan
> > Subject: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
> >
> > From: pengyuan <yuan.peng@intel.com>
> >
> > Signed-off-by: pengyuan <yuan.peng@intel.com>
> >
> > diff --git a/tests/TestSuite_VEB.py b/tests/TestSuite_VEB.py
> > new file mode 100644
> > index 0000000..6296ff1
> > --- /dev/null
> > +++ b/tests/TestSuite_VEB.py
> > @@ -0,0 +1,934 @@
> > +# 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
> > +# 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 VEB Switch and floating VEB Features by Poll Mode Drivers.
> > +"""
> > +
> > +import re
> > +import time
> > +
> > +import dts
> Please remove dts dependency in your suite. All suite should have no
> dependency on this module.
>
> > +from virt_dut import VirtDut
> > +from project_dpdk import DPDKdut
> > +from dut import Dut
> > +from net_device import GetNicObj
> > +from net_device import RemoveNicObj
> > +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 == "vf0":
> > + stats = self.pmdout.get_pmd_stats(portid)
> > + elif vf0_vf1 == "vf1":
> > + stats = self.pmdout_session_secondary.get_pmd_stats(portid)
> > + else:
> > + return None
> > +
> > + if rx_tx == "rx":
> > + return [stats['RX-packets'], stats['RX-errors'], stats['RX-
> > bytes']]
> > + elif rx_tx == "tx":
> > + return [stats['TX-packets'], stats['TX-errors'], stats['TX-
> > bytes']]
> > + else:
> > + return None
> > +
> > + def veb_get_pmd_stats(self, dev, portid, rx_tx):
> > + stats = {}
> > + rx_pkts_prefix = "RX-packets:"
> > + rx_bytes_prefix = "RX-bytes:"
> > + rx_error_prefix = "RX-errors:"
> > + tx_pkts_prefix = "TX-packets:"
> > + tx_error_prefix = "TX-errors:"
> > + tx_bytes_prefix = "TX-bytes:"
> > +
> > + if dev == "first":
> > + out = self.dut.send_expect("show port stats %d" % portid,
> > "testpmd> ")
> > + elif dev == "second":
> > + out = self.session_secondary.send_expect("show port
> > stats %d" % portid, "testpmd> ")
> > + elif dev == "third":
> > + out = self.session_third.send_expect("show port stats %d" %
> > portid, "testpmd> ")
> > + else:
> > + return None
> > +
> > + stats["RX-packets"] = self.veb_get_pmd_value(rx_pkts_prefix,
> out)
> > + stats["RX-bytes"] = self.veb_get_pmd_value(rx_bytes_prefix, out)
> > + stats["RX-errors"] = self.veb_get_pmd_value(rx_error_prefix,
> out)
> > + stats["TX-packets"] = self.veb_get_pmd_value(tx_pkts_prefix,
> out)
> > + stats["TX-errors"] = self.veb_get_pmd_value(tx_error_prefix,
> out)
> > + stats["TX-bytes"] = self.veb_get_pmd_value(tx_bytes_prefix, out)
> > +
> > + if rx_tx == "rx":
> > + return [stats['RX-packets'], stats['RX-errors'], stats['RX-
> > bytes']]
> > + elif rx_tx == "tx":
> > + return [stats['TX-packets'], stats['TX-errors'], stats['TX-
> > bytes']]
> > + else:
> > + return None
> > +
> > +
> > + def veb_get_pmd_value(self, prefix, out):
> > + pattern = re.compile(prefix + "(\s+)([0-9]+)")
> > + m = pattern.search(out)
> > + if m is None:
> > + return None
> > + else:
> > + return int(m.group(2))
> > +
> > + def send_packet(self, vf_mac, itf, tran_type=""):
> > + """
> > + Send 1 packet
> > + """
> > + self.tester.scapy_foreground()
> > + self.tester.scapy_append('sys.path.append("./")')
> > + self.dut.send_expect("start", "testpmd>")
> > + mac = self.dut.get_mac_address(0)
> > +
> > + if tran_type == "vlan":
> > + packet = r'sendp([Ether(dst="%s",
> > src=get_if_hwaddr("%s"))/Dot1Q(vlan=1)/IP(src="192.168.0.1",
> > dst="192.168.0.2")], iface="%s")' % (vf_mac, itf, itf)
> > + self.tester.scapy_append(packet)
> > + self.tester.scapy_execute()
> > + time.sleep(.5)
> > + else:
> > + packet = r'sendp([Ether(dst="%s",
> > src=get_if_hwaddr("%s"))/IP(src="192.168.0.1", dst="192.168.0.2")],
> > iface="%s")' % (vf_mac, itf, itf)
> > + self.tester.scapy_append(packet)
> > + self.tester.scapy_execute()
> > + time.sleep(.5)
> > +
> > + #
> > + # Test cases.
> > + #
> > +
> > + 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 = self.dut.get_ports(self.nic)
> > + self.verify(len(self.dut_ports) >= 1, "Insufficient ports")
> > + # self.rx_port = self.dut_ports[0]
> > + # self.tx_port = self.dut_ports[0]
> > +
> > + # cores = self.dut.get_core_list("1S/2C/1T")
> > + # self.coremask = dts.create_mask(cores)
> > +
> > + # self.port_mask = dts.create_mask([self.rx_port, self.tx_port])
> > + self.session_secondary = self.dut.new_session()
> > + self.session_third = self.dut.new_session()
> > + # self.pmdout = PmdOutput(self.dut)
> > + # self.pmdout_session_secondary =
> > PmdOutput(self.session_secondary)
> > +
> Please remove commented code.
>
> > + def set_up(self):
> > + """
> > + This is to clear up environment before the case run.
> > + """
> > + self.dut.kill_all()
> > + self.setup_1pf_kdriver_2vf_env_flag = 0
> > + self.setup_1pf_ddriver_1vf_env_flag = 0
> > + self.setup_1pf_ddriver_2vf_env_flag = 0
> > + self.setup_1pf_ddriver_4vf_env_flag = 0
> > + self.vf0_mac = "00:11:22:33:44:11"
> > + self.vf1_mac = "00:11:22:33:44:12"
> > + self.vf2_mac = "00:11:22:33:44:13"
> > + self.vf3_mac = "00:11:22:33:44:14"
> > +
> > + def setup_1pf_ddriver_4vf_env(self, driver='default'):
> > + self.used_dut_port = self.dut_ports[0]
> > + localPort = self.tester.get_local_port(self.dut_ports[0])
> > + self.tester_itf = self.tester.get_interface(localPort)
> > + self.pf_interface =
> > self.dut.ports_info[self.used_dut_port]['intf']
> > + self.pf_mac_address = self.dut.get_mac_address(0)
>
> Several function required these information, you can strip these
> information only once in setup_all function.
>
> > + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> This code is useless here, is it just for debug?
>
> > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 4,
> > driver='igb_uio')
> > + self.sriov_vfs_port =
> > self.dut.ports_info[self.used_dut_port]['vfs_port']
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + try:
> > +
> > + for port in self.sriov_vfs_port:
> > + print port.pci
> Please remove debug code.
> > + self.dut.send_expect("./tools/dpdk-devbind.py -b
> > igb_uio %s" % (port.pci), "# ", 3)
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + time.sleep(1)
> > + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> > + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> > + vf2_prop = {'opt_host': self.sriov_vfs_port[2].pci}
> > + vf3_prop = {'opt_host': self.sriov_vfs_port[3].pci}
> > + for port_id in self.dut_ports:
> > + if port_id == self.used_dut_port:
> > + continue
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> I'm not sure about this logic, you can just get port object by
> self.dut.ports_info[self.used_dut_port].
> There's no need to browser through all dut ports.
> > +
> > + self.setup_1pf_ddriver_4vf_env_flag = 1
> > + except Exception as e:
> > + self.destroy_1pf_ddriver_4vf_env()
> > + raise Exception(e)
> > +
> > + def destroy_1pf_ddriver_4vf_env(self):
> > + self.session_third.send_expect("quit", "# ")
> > + self.session_secondary.send_expect("quit", "# ")
> > + self.dut.send_expect("quit", "# ")
> When there met some issues which caused testpmd can't start up normally.
> "Quit" command here will cause the session unavailable any more.
> Use kill_all api to quit dpdk application is one more reliable way to do
> such thing.
>
> > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> > + port = self.dut.ports_info[self.used_dut_port]['port']
> > + port.bind_driver()
> > + self.used_dut_port = None
> > +
> > + for port_id in self.dut_ports:
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > +
> Do not bind dut ports to default driver, this will cause that later suites
> can't work anymore.
> There's one solution for this is that when test suite initializing, we
> bind all dut ports to igb_uio.
> But please do not bind to default driver by now.
>
> > + self.setup_1pf_ddriver_4vf_env_flag = 0
> > +
> > + def setup_1pf_ddriver_2vf_env(self, driver='default'):
> > + self.used_dut_port = self.dut_ports[0]
> > + localPort = self.tester.get_local_port(self.dut_ports[0])
> > + self.tester_itf = self.tester.get_interface(localPort)
> > + self.pf_interface =
> > self.dut.ports_info[self.used_dut_port]['intf']
> > + self.pf_mac_address = self.dut.get_mac_address(0)
> > + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
> These codes can be done only once in setup_all function.
>
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2,
> > driver='igb_uio')
> > + self.sriov_vfs_port =
> > self.dut.ports_info[self.used_dut_port]['vfs_port']
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + try:
> > +
> > + for port in self.sriov_vfs_port:
> > + print port.pci
> > + self.dut.send_expect("./tools/dpdk-devbind.py -b
> > igb_uio %s" % (port.pci), "# ", 3)
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + time.sleep(1)
> > + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> > + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> > + for port_id in self.dut_ports:
> > + if port_id == self.used_dut_port:
> > + continue
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > +
> > + self.setup_1pf_ddriver_2vf_env_flag = 1
> > + except Exception as e:
> > + self.destroy_1pf_ddriver_2vf_env()
> > + raise Exception(e)
> > +
> > + def destroy_1pf_ddriver_2vf_env(self):
> > + self.session_third.send_expect("quit", "# ")
> > + self.session_secondary.send_expect("quit", "# ")
> > + self.dut.send_expect("quit", "# ")
> > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> > + port = self.dut.ports_info[self.used_dut_port]['port']
> > + port.bind_driver()
> > + self.used_dut_port = None
> > +
> > + for port_id in self.dut_ports:
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > +
> > + self.setup_1pf_ddriver_2vf_env_flag = 0
> > +
> > + def setup_1pf_ddriver_1vf_env(self, driver='default'):
> > + self.used_dut_port = self.dut_ports[0]
> > + localPort = self.tester.get_local_port(self.dut_ports[0])
> > + self.tester_itf = self.tester.get_interface(localPort)
> > + self.pf_interface =
> > self.dut.ports_info[self.used_dut_port]['intf']
> > + self.pf_mac_address = self.dut.get_mac_address(0)
> > + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + # self.dut.send_expect("echo 1 >
> > /sys/bus/pci/devices/%s/max_vfs" % self.pf_pci, "# ", 3)
> > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 1,
> > driver='igb_uio')
> > + self.sriov_vfs_port =
> > self.dut.ports_info[self.used_dut_port]['vfs_port']
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > +
> > + try:
> > +
> > + for port in self.sriov_vfs_port:
> > + print port.pci
> > + self.dut.send_expect("./tools/dpdk-devbind.py -b
> > igb_uio %s" % (port.pci), "# ", 3)
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + time.sleep(1)
> > + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> > +
> > + for port_id in self.dut_ports:
> > + if port_id == self.used_dut_port:
> > + continue
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > +
> > + self.setup_1pf_ddriver_1vf_env_flag = 1
> > + except Exception as e:
> > + self.destroy_1pf_ddriver_1vf_env()
> > + raise Exception(e)
> > +
> > + def destroy_1pf_ddriver_1vf_env(self):
> > +
> > + self.session_secondary.send_expect("quit", "# ")
> > + self.dut.send_expect("quit", "# ")
> > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> > + port = self.dut.ports_info[self.used_dut_port]['port']
> > + port.bind_driver()
> > + self.used_dut_port = None
> > +
> > + for port_id in self.dut_ports:
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > +
> > + self.setup_1pf_ddriver_1vf_env_flag = 0
> > +
> > + def setup_1pf_kdriver_2vf_env(self, driver='default'):
> > + self.used_dut_port = self.dut_ports[0]
> > + localPort = self.tester.get_local_port(self.dut_ports[0])
> > + self.tester_itf = self.tester.get_interface(localPort)
> > + for port_id in self.dut_ports:
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > + self.pf_interface =
> > self.dut.ports_info[self.used_dut_port]['intf']
> > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2,
> > driver=driver)
> > + self.sriov_vfs_port =
> > self.dut.ports_info[self.used_dut_port]['vfs_port']
> > + #self.vf0_mac = "00:11:22:33:44:11"
> > + #self.vf1_mac = "00:11:22:33:44:12"
> > + self.dut.send_expect("ip link set %s vf 0 mac %s" %
> > (self.pf_interface, self.vf0_mac), "# ", 3)
> > + self.dut.send_expect("ip link set %s vf 1 mac %s" %
> > (self.pf_interface, self.vf1_mac), "# ", 3)
> > +
> > + try:
> > +
> > + for port in self.sriov_vfs_port:
> > + print port.pci
> > + self.dut.send_expect("./tools/dpdk-devbind.py -b
> > igb_uio %s" % (port.pci), "# ", 3)
> > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > + time.sleep(1)
> > + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> > + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> > +
> > + # for port_id in self.dut_ports:
> > + # if port_id == self.used_dut_port:
> > + # continue
> > + # port = self.dut.ports_info[port_id]['port']
> > + # port.bind_driver()
> > +
> > + self.setup_1pf_kdriver_2vf_env_flag = 1
> > + except Exception as e:
> > + self.destroy_1pf_kdriver_2vf_env()
> > + raise Exception(e)
> > +
> > + def destroy_1pf_kdriver_2vf_env(self):
> > +
> > + self.session_secondary.send_expect("quit", "# ")
> > + self.dut.send_expect("quit", "# ")
> > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> > + port = self.dut.ports_info[self.used_dut_port]['port']
> > + port.bind_driver()
> > + self.used_dut_port = None
> > +
> > + for port_id in self.dut_ports:
> > + port = self.dut.ports_info[port_id]['port']
> > + port.bind_driver()
> > +
> > + self.setup_1pf_kdriver_2vf_env_flag = 0
> > +
> > + def test_VEB_switching_inter_vfs_MAC_switch_rxtx(self):
> > + """
>
> Please simplify the test case name, description below can explain the
> case.
>
> > + Kernel PF, then create 2VFs. VFs running dpdk testpmd, send
> > traffic to VF1, and set the packet's DEST MAC to VF2, check if VF2 can
> > receive the packets. Check Inter VF-VF MAC switch.
> > + """
> > + self.setup_1pf_kdriver_2vf_env(driver='')
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> > strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> > "testpmd>", 120)
> Mac here should not hardcode, it has been defined in setup function.
>
> > + self.dut.send_expect("set fwd txonly", "testpmd>")
> > + self.dut.send_expect("set promisc all off", "testpmd>")
> > +
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % self.sriov_vfs_port[1].pci, "testpmd>",
> > 120)
>
> Target should not be hard coded for we will do the validation with
> different targets.
> You can use start_testpmd in pmd_ouput module to simplify the step.
>
> > + 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)
> > +
> > + self.dut.send_expect("stop", "testpmd>", 5)
> > + self.session_secondary.send_expect("stop", "testpmd>", 5)
> > +
> > + vf0_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(vf0_tx_stats[0] * 0.5 < vf1_rx_stats[0], "VF1
> failed
> > to receive packets from VF0")
> > +
> > + def test_VEB_switching_inter_vfs_MAC_switch_fwd(self):
> > + """
> > + Kernel PF, then create 2VFs. VFs running dpdk testpmd, send
> > traffic to VF1, and set the packet's DEST MAC to VF2, check if VF2 can
> > receive the packets. Check Inter VF-VF MAC switch.
> > + """
> > + self.setup_1pf_kdriver_2vf_env(driver='')
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> > strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> > "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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % 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)
> > +
> > + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(vf0_tx_stats == vf1_rx_stats, "VF1 failed to
> receive
> > packets from VF0")
> > +
> > + def test_VEB_switching_inter_vfs_MAC_switch_vlan(self):
> > + """
> > + Kernel PF, then create 2VFs, assign VF1 with VLAN=1 in, VF2
> with
> > VLAN=2. VFs are running dpdk testpmd, send traffic to VF1 with VLAN=1,
> > then let it forwards to VF2, it should not work since they are
> not
> > in the same VLAN; set VF2 with VLAN=1, then send traffic to VF1 with
> > VLAN=1, and VF2 can receive the packets. Check inter VF
> MAC/VLAN
> > switch.
> > + """
> > + self.setup_1pf_kdriver_2vf_env(driver='')
> > + # the two vfs belongs to different vlans
> > + self.dut.send_expect("ip link set %s vf 0 vlan 1" %
> > self.pf_interface, "# ", 1)
> > + self.dut.send_expect("ip link set %s vf 1 vlan 2" %
> > self.pf_interface, "# ", 1)
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> > strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> > "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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % 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)
> > +
> > + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify((vf0_tx_stats[0] == 1) and (vf1_rx_stats[0] == 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)
> > +
> > + # the two vfs belongs to the same vlan
> > + self.dut.send_expect("ip link set %s vf 1 vlan 1" %
> > self.pf_interface, "# ", 1)
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> > strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> > "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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % 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)
> > +
> > + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify((vf0_tx_stats[0] == 1) and (vf1_rx_stats[0] == 1),
> > "VF1 didn't receive packets from VF0, the vlan filter doen't work")
> > +
> > + def test_VEB_switching_inter_pf_vf_MAC_switch(self):
> > + """
> > + DPDK PF, then create 1VF, PF in the host running dpdk testpmd,
> > send traffic from PF to VF1, ensure PF->VF1(let VF1 in promisc mode);
> send
> > traffic from VF1 to PF, ensure VF1->PF can work.
> > + """
> > + # VF->PF
> > + self.setup_1pf_ddriver_1vf_env(driver='')
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" %
> > self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(pf_rx_stats[0] != 0, "no packet was received by PF")
> > + self.verify(vf0_tx_stats[0]*0.5 < pf_rx_stats[0], "PF failed to
> > receive most packets from VF0")
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > + self.dut.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + #PF->VF
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --eth-
> > peer=0,%s" % (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>")
> > +
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> > + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > + self.verify(pf_tx_stats[0] != 0, "no packet was sent by PF")
> > + self.verify(vf0_rx_stats[0] != 0, "no packet was received by
> VF0")
> > + self.verify(vf0_rx_stats[0] > pf_tx_stats[0]*0.5, "VF0 failed
> to
> > receive 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("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" %
> > self.pf_pci, "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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> > + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > + self.verify(pf_tx_stats[0] == 0, "PF received unexpected
> packet")
> > + self.verify(vf0_rx_stats[0] == 1, "no packet was received by
> VF0")
> > +
> > + 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 = self.veb_get_pmd_stats("second", 0, "rx")
> > + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > + self.verify(pf_tx_stats[0] == 1, "no packet was sent by VF0")
> > + self.verify(pf_rx_stats[0] == 1, "no packet was received by
> VF0")
> > + self.verify(vf0_rx_stats[0] == 1, "no packet was received by
> VF0")
> > +
> > + def test_floating_VEB_switching_inter_pf_vf_MAC_switch(self):
> > + """
> > + DPDK PF, then create 1VF, PF in the host running dpdk testpmd,
> > send traffic from PF to VF0, VF0 can't receive any packets; send traffic
> > from VF0 to PF, PF can't rec eive any packets either.
> > + """
> > + # VF->PF
> > + self.setup_1pf_ddriver_1vf_env(driver='')
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> > prefix=test1 -- -i" % self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(pf_rx_stats[0] == 0, "PF can receive packet from
> VF0,
> > the floating VEB doesn't work")
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > + self.dut.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + #PF->VF
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> > prefix=test1 -- -i --eth-peer=0,%s" % (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>")
> > +
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> > + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > + self.verify(pf_tx_stats[0] != 0, "no packet was sent by PF")
> > + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from
> PF,
> > the floating VEB doesn't work")
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > + self.dut.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + #outside world ->VF
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> > prefix=test1 -- -i --eth-peer=0,%s" % (self.pf_pci, self.vf0_mac),
> > "testpmd>", 120)
> > + self.dut.send_expect("set fwd mac", "testpmd>")
> > + self.dut.send_expect("set promisc all on", "testpmd>")
> > + self.dut.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > +
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % (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 mac", "testpmd>")
> > + self.session_secondary.send_expect("set promisc all on",
> > "testpmd>")
> > + self.session_secondary.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > +
> > + self.send_packet(self.vf0_mac, self.tester_itf)
> > + time.sleep(2)
> > + self.dut.send_expect("stop", "testpmd>", 2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > +
> > + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from
> > outside world, the floating VEB doesn't work")
> > +
> > + def test_floating_VEB_switching_inter_vfs_MAC_switch(self):
> > + """
> > + 1 DPDK PF, then create 2VF, PF in the host running dpdk testpmd,
> > and VF0 are running dpdk testpmd, VF0 send traffic, and set the packet's
> > DEST MAC to VF1, check if VF1 can receive the packets. Check Inter VF-VF
> > MAC switch when PF is link down as well as up.
> > + """
> > + # PF link up, VF0->VF1
> > + self.setup_1pf_ddriver_2vf_env(driver='')
> > + # start PF
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> > prefix=test1 -- -i" % self.pf_pci, "testpmd>", 120)
> > + self.dut.send_expect("port start all", "testpmd>")
> > + time.sleep(2)
> > + # start VF0
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % 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)
> > + # start VF1
> > + self.session_third.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test3 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[1].pci, self.vf0_mac), "testpmd>", 120)
> > + self.session_third.send_expect("set fwd txonly", "testpmd>")
> > + self.session_third.send_expect("set promisc all off",
> "testpmd>")
> > + self.session_third.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > +
> > + self.session_third.send_expect("stop", "testpmd>", 2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > +
> > + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + vf1_tx_stats = self.veb_get_pmd_stats("third", 0, "tx")
> > + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> > + self.verify(vf0_rx_stats[0] != 0, "no packet was received by
> VF0")
> > + self.verify(vf1_tx_stats[0]*0.5 < vf0_rx_stats[0], "VF0 failed
> to
> > receive most packets from VF1")
> > +
> > + # PF link down, VF0 -> VF1
> > + self.dut.send_expect("port stop all", "Port 0 Link Down", 20)
> > + self.session_secondary.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_third.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_third.send_expect("stop", "testpmd>", 2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > + self.dut.send_expect("stop", "testpmd>", 2)
> > +
> > + vf1_tx_stats_pfstop = self.veb_get_pmd_stats("third", 0, "tx")
> > + vf0_rx_stats_pfstop = self.veb_get_pmd_stats("second", 0, "rx")
> > + vf1_tx_stats_pfstop[0] = vf1_tx_stats_pfstop[0] -
> vf1_tx_stats[0]
> > + vf0_rx_stats_pfstop[0] = vf0_rx_stats_pfstop[0] -
> vf0_rx_stats[0]
> > + self.verify(vf1_tx_stats_pfstop[0] != 0, "no packet was sent by
> > VF1")
> > + self.verify(vf0_rx_stats_pfstop[0] != 0, "no packet was
> received
> > by VF0")
> > + self.verify(vf1_tx_stats_pfstop[0]*0.5 < vf0_rx_stats_pfstop[0],
> > "VF0 failed to receive most packets from VF1")
> > +
> > + def
> test_floating_VEB_VF_cannot_communicate_with_legacy_VEB_VF(self):
> > + """
> > + DPDK PF, then create 4VF, VF0,VF2,VF3 are floating VEB; VF1 is
> > lagecy VEB. Make PF link down(the cable can be pluged out), VFs are
> > running dpdk testpmd.
> > + 1. VF0 send traffic, and set the packet's DEST MAC to VF1,
> check
> > VF1 can not receive the packets.
> > + 2. VF1 send traffic, and set the packet's DEST MAC to VF0,
> check
> > VF0 can not receive the packets.
> > + 3. VF0 send traffic, and set the packet's DEST MAC to VF2,
> check
> > VF2 can receive the packets.
> > + 4. VF3 send traffic, and set the packet's DEST MAC to VF2,
> check
> > VF2 can receive the packets.
> > + """
> > + self.setup_1pf_ddriver_4vf_env(driver='')
> > + # start PF
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 \"-
> > w %s,enable_floating_veb=1,floating_veb_list=0;2-3\" --file-prefix=test1
> -
> > - -i" % self.pf_pci, "testpmd>", 120)
> > + self.dut.send_expect("port start all", "testpmd>")
> > + time.sleep(2)
> > + # VF1->VF0
> > + # start VF0
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[0].pci, self.vf1_mac), "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>")
> > + # start VF1
> > + self.session_third.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test3 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[1].pci, self.vf0_mac), "testpmd>", 120)
> > + self.session_secondary.send_expect("mac_addr add 0 %s" %
> > self.vf1_mac, "testpmd>")
> > + self.session_third.send_expect("set fwd txonly", "testpmd>")
> > + self.session_third.send_expect("set promisc all off",
> "testpmd>")
> > +
> > + # PF link down
> > + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> > + self.session_secondary.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_third.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > +
> > + self.session_third.send_expect("stop", "testpmd>", 2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > +
> > + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + vf1_tx_stats = self.veb_get_pmd_stats("third", 0, "tx")
> > + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> > + self.verify(vf0_rx_stats[0] == 0, "floating_VEB VF can
> > communicate with legacy_VEB VF")
> > +
> > + # VF0->VF1
> > + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> > + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> > + self.session_third.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_secondary.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > + self.session_third.send_expect("stop", "testpmd>", 2)
> > + vf1_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> > + vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(vf1_rx_stats[0] == 0, "floating_VEB VF can
> > communicate with legacy_VEB VF")
> > +
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > + self.session_third.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + # VF0->VF2
> > + # start VF0
> > + self.dut.send_expect("port start all", "testpmd>")
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[0].pci, self.vf2_mac), "testpmd>", 120)
> > + self.session_secondary.send_expect("mac_addr add 0 %s" %
> > self.vf0_mac, "testpmd>")
> > + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> > + self.session_secondary.send_expect("set promisc all off",
> > "testpmd>")
> > + # start VF2
> > + self.session_third.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test3 -- -i --crc-strip" % self.sriov_vfs_port[2].pci, "testpmd>",
> > 120)
> > + self.session_third.send_expect("mac_addr add 0 %s" %
> self.vf2_mac,
> > "testpmd>")
> > + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> > + self.session_third.send_expect("set promisc all off",
> "testpmd>")
> > +
> > + # PF link down
> > + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> > + self.session_third.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_secondary.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > + self.session_third.send_expect("stop", "testpmd>", 2)
> > +
> > + vf2_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> > + vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(vf2_rx_stats[0] != 0, "floating_VEB VFs cannot
> > communicate with each other")
> > + self.verify(vf0_tx_stats[0] * 0.5 < vf2_rx_stats[0], "VF2
> failed
> > to receive packets from VF0")
> > +
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > + self.session_third.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + # VF3->VF2
> > + # start VF3
> > + self.dut.send_expect("port start all", "testpmd>")
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[3].pci, self.vf2_mac), "testpmd>", 120)
> > + self.session_secondary.send_expect("mac_addr add 0 %s" %
> > self.vf0_mac, "testpmd>")
> > + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> > + self.session_secondary.send_expect("set promisc all off",
> > "testpmd>")
> > + # start VF2
> > + self.session_third.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test3 -- -i --crc-strip" % self.sriov_vfs_port[2].pci, "testpmd>",
> > 120)
> > + self.session_third.send_expect("mac_addr add 0 %s" %
> self.vf2_mac,
> > "testpmd>")
> > + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> > + self.session_third.send_expect("set promisc all off",
> "testpmd>")
> > +
> > + # PF link down
> > + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> > + self.session_third.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_secondary.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > + self.session_third.send_expect("stop", "testpmd>", 2)
> > +
> > + vf2_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> > + vf3_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> > + self.verify(vf3_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(vf2_rx_stats[0] != 0, "floating_VEB VFs cannot
> > communicate with each other")
> > + self.verify(vf3_tx_stats[0] * 0.5 < vf2_rx_stats[0], "VF2
> failed
> > to receive packets from VF3")
> > +
> > + def
> > test_floating_VEB_and_legacy_VEB_switching_inter_pf_vf_MAC_switch(self):
> > + """
> > + DPDK PF, then create 2VFs, VF0 is in floating VEB, VF1 is in
> > legacy VEB.
> > + 1. Send traffic from VF0 to PF, then check PF will not see any
> > traffic;
> > + 2. Send traffic from VF1 to PF, then check PF will receive all
> > the packets.
> > + 3. send traffic from tester to VF0, check VF0 can't receive
> > traffic from tester.
> > + 4. send traffic from tester to VF1, check VF1 can receive all
> the
> > traffic from tester.
> > + """
> > + self.setup_1pf_ddriver_2vf_env(driver='')
> > + # VF0->PF
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 \"-
> > w %s,enable_floating_veb=1,floating_veb_list=0\" --file-prefix=test1 --
> -
> > i" % self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > + self.verify(pf_rx_stats[0] == 0, "PF can receive packet from
> VF0,
> > the floating VEB doesn't work")
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + # VF1->PF
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > (self.sriov_vfs_port[1].pci, self.pf_mac_address), "testpmd>", 120)
> > + self.session_secondary.send_expect("set fwd txonly", "testpmd>")
> > + self.session_secondary.send_expect("set promisc all off",
> > "testpmd>")
> > + self.dut.send_expect("start", "testpmd>")
> > + time.sleep(2)
> > + 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)
> > +
> > + vf1_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> > + self.verify(pf_rx_stats[0] != 0, "PF can't receive packet from
> > VF1, the VEB doesn't work")
> > + self.verify(vf1_tx_stats[0] * 0.5 < pf_rx_stats[0], "PF failed
> to
> > receive packets from VF1")
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > + self.dut.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + # tester->VF0
> > + self.dut.send_expect("./x86_64-native-linuxapp-gcc/app/testpmd
> -c
> > 0xf -n 4 --socket-mem 1024,1024 \"-
> > w %s,enable_floating_veb=1,floating_veb_list=0\" --file-prefix=test1 --
> -
> > i" % self.pf_pci, "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("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % (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 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)
> > + time.sleep(2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > + self.dut.send_expect("stop", "testpmd>", 2)
> > +
> > + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet from
> > outside world, the floating VEB doesn't work")
> > + self.session_secondary.send_expect("quit", "# ")
> > + time.sleep(2)
> > +
> > + # tester->VF1
> > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > prefix=test2 -- -i --crc-strip" % (self.sriov_vfs_port[1].pci),
> "testpmd>",
> > 120)
> > + self.session_secondary.send_expect("mac_addr add 0 %s" %
> > self.vf1_mac, "testpmd>")
> > + 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.vf1_mac, self.tester_itf)
> > + time.sleep(2)
> > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > + self.dut.send_expect("stop", "testpmd>", 2)
> > +
> > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > + self.verify(vf1_rx_stats[0] == 1, "VF1 can't receive packet
> from
> > outside world, the VEB doesn't work")
> > +
> > + def tear_down(self):
> > + """
> > + Run after each test case.
> > + """
> > + if self.setup_1pf_kdriver_2vf_env_flag == 1:
> > + self.destroy_1pf_kdriver_2vf_env()
> > + if self.setup_1pf_ddriver_1vf_env_flag == 1:
> > + self.destroy_1pf_ddriver_1vf_env()
> > + if self.setup_1pf_ddriver_2vf_env_flag == 1:
> > + self.destroy_1pf_ddriver_2vf_env()
> > + if self.setup_1pf_ddriver_4vf_env_flag == 1:
> > + self.destroy_1pf_ddriver_4vf_env()
> > +
> > + self.dut.kill_all()
> > +
> > + pass
> > +
> > + 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)
> Need restore dut ports bound to igb_uio driver.
> > +
> > + pass
> > --
> > 2.5.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
2016-10-19 3:19 ` Peng, Yuan
@ 2016-10-19 3:23 ` Liu, Yong
0 siblings, 0 replies; 8+ messages in thread
From: Liu, Yong @ 2016-10-19 3:23 UTC (permalink / raw)
To: Peng, Yuan, dts
Yes, as I has mentioned that we can add bind action in suite instantiation. Otherwise we need make sure one suite not affect others.
> -----Original Message-----
> From: Peng, Yuan
> Sent: Tuesday, October 18, 2016 8:20 PM
> To: Liu, Yong; dts@dpdk.org
> Subject: RE: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
>
> At the initiation of each suite, there are not steps to bind the dut ports
> to igb_uio?
>
> -----Original Message-----
> From: Liu, Yong
> Sent: Wednesday, October 19, 2016 11:17 AM
> To: Peng, Yuan <yuan.peng@intel.com>; dts@dpdk.org
> Subject: RE: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
>
> Use Fortville as example, its default driver is i40e. After bind to
> default driver, dpdk won't able to use it.
> When dts run suites, all ports have been bound to igb_uio. Each suite
> should guarantee that all ports still bind to igb_uio after each case
> finished.
>
> > -----Original Message-----
> > From: Peng, Yuan
> > Sent: Tuesday, October 18, 2016 8:12 PM
> > To: Liu, Yong; dts@dpdk.org
> > Subject: RE: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
> >
> > Hi Marvin,
> >
> > I don't know why I can't bind the dut ports to default driver when the
> > testsuite finished?
> >
> > Thank you.
> > Yuan.
> >
> > -----Original Message-----
> > From: Liu, Yong
> > Sent: Friday, October 14, 2016 10:40 PM
> > To: Peng, Yuan <yuan.peng@intel.com>; dts@dpdk.org
> > Cc: Peng, Yuan <yuan.peng@intel.com>
> > Subject: RE: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
> >
> > Yuan, some comments below. Please remember that your suite is not the
> only
> > one in our execution.
> > You need keep the environment just the same as you use it.
> > And please try to keep line in 79 characters.
> >
> > > -----Original Message-----
> > > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of Yuan Peng
> > > Sent: Friday, October 14, 2016 8:51 AM
> > > To: dts@dpdk.org
> > > Cc: Peng, Yuan
> > > Subject: [dts] [PATCH 1/2] tests add TestSuite_VEB.py
> > >
> > > From: pengyuan <yuan.peng@intel.com>
> > >
> > > Signed-off-by: pengyuan <yuan.peng@intel.com>
> > >
> > > diff --git a/tests/TestSuite_VEB.py b/tests/TestSuite_VEB.py
> > > new file mode 100644
> > > index 0000000..6296ff1
> > > --- /dev/null
> > > +++ b/tests/TestSuite_VEB.py
> > > @@ -0,0 +1,934 @@
> > > +# 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
> > > +# 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 VEB Switch and floating VEB Features by Poll Mode Drivers.
> > > +"""
> > > +
> > > +import re
> > > +import time
> > > +
> > > +import dts
> > Please remove dts dependency in your suite. All suite should have no
> > dependency on this module.
> >
> > > +from virt_dut import VirtDut
> > > +from project_dpdk import DPDKdut
> > > +from dut import Dut
> > > +from net_device import GetNicObj
> > > +from net_device import RemoveNicObj
> > > +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 == "vf0":
> > > + stats = self.pmdout.get_pmd_stats(portid)
> > > + elif vf0_vf1 == "vf1":
> > > + stats =
> self.pmdout_session_secondary.get_pmd_stats(portid)
> > > + else:
> > > + return None
> > > +
> > > + if rx_tx == "rx":
> > > + return [stats['RX-packets'], stats['RX-errors'],
> stats['RX-
> > > bytes']]
> > > + elif rx_tx == "tx":
> > > + return [stats['TX-packets'], stats['TX-errors'],
> stats['TX-
> > > bytes']]
> > > + else:
> > > + return None
> > > +
> > > + def veb_get_pmd_stats(self, dev, portid, rx_tx):
> > > + stats = {}
> > > + rx_pkts_prefix = "RX-packets:"
> > > + rx_bytes_prefix = "RX-bytes:"
> > > + rx_error_prefix = "RX-errors:"
> > > + tx_pkts_prefix = "TX-packets:"
> > > + tx_error_prefix = "TX-errors:"
> > > + tx_bytes_prefix = "TX-bytes:"
> > > +
> > > + if dev == "first":
> > > + out = self.dut.send_expect("show port stats %d" % portid,
> > > "testpmd> ")
> > > + elif dev == "second":
> > > + out = self.session_secondary.send_expect("show port
> > > stats %d" % portid, "testpmd> ")
> > > + elif dev == "third":
> > > + out = self.session_third.send_expect("show port
> stats %d" %
> > > portid, "testpmd> ")
> > > + else:
> > > + return None
> > > +
> > > + stats["RX-packets"] = self.veb_get_pmd_value(rx_pkts_prefix,
> > out)
> > > + stats["RX-bytes"] = self.veb_get_pmd_value(rx_bytes_prefix,
> out)
> > > + stats["RX-errors"] = self.veb_get_pmd_value(rx_error_prefix,
> > out)
> > > + stats["TX-packets"] = self.veb_get_pmd_value(tx_pkts_prefix,
> > out)
> > > + stats["TX-errors"] = self.veb_get_pmd_value(tx_error_prefix,
> > out)
> > > + stats["TX-bytes"] = self.veb_get_pmd_value(tx_bytes_prefix,
> out)
> > > +
> > > + if rx_tx == "rx":
> > > + return [stats['RX-packets'], stats['RX-errors'],
> stats['RX-
> > > bytes']]
> > > + elif rx_tx == "tx":
> > > + return [stats['TX-packets'], stats['TX-errors'],
> stats['TX-
> > > bytes']]
> > > + else:
> > > + return None
> > > +
> > > +
> > > + def veb_get_pmd_value(self, prefix, out):
> > > + pattern = re.compile(prefix + "(\s+)([0-9]+)")
> > > + m = pattern.search(out)
> > > + if m is None:
> > > + return None
> > > + else:
> > > + return int(m.group(2))
> > > +
> > > + def send_packet(self, vf_mac, itf, tran_type=""):
> > > + """
> > > + Send 1 packet
> > > + """
> > > + self.tester.scapy_foreground()
> > > + self.tester.scapy_append('sys.path.append("./")')
> > > + self.dut.send_expect("start", "testpmd>")
> > > + mac = self.dut.get_mac_address(0)
> > > +
> > > + if tran_type == "vlan":
> > > + packet = r'sendp([Ether(dst="%s",
> > > src=get_if_hwaddr("%s"))/Dot1Q(vlan=1)/IP(src="192.168.0.1",
> > > dst="192.168.0.2")], iface="%s")' % (vf_mac, itf, itf)
> > > + self.tester.scapy_append(packet)
> > > + self.tester.scapy_execute()
> > > + time.sleep(.5)
> > > + else:
> > > + packet = r'sendp([Ether(dst="%s",
> > > src=get_if_hwaddr("%s"))/IP(src="192.168.0.1", dst="192.168.0.2")],
> > > iface="%s")' % (vf_mac, itf, itf)
> > > + self.tester.scapy_append(packet)
> > > + self.tester.scapy_execute()
> > > + time.sleep(.5)
> > > +
> > > + #
> > > + # Test cases.
> > > + #
> > > +
> > > + 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 = self.dut.get_ports(self.nic)
> > > + self.verify(len(self.dut_ports) >= 1, "Insufficient ports")
> > > + # self.rx_port = self.dut_ports[0]
> > > + # self.tx_port = self.dut_ports[0]
> > > +
> > > + # cores = self.dut.get_core_list("1S/2C/1T")
> > > + # self.coremask = dts.create_mask(cores)
> > > +
> > > + # self.port_mask = dts.create_mask([self.rx_port,
> self.tx_port])
> > > + self.session_secondary = self.dut.new_session()
> > > + self.session_third = self.dut.new_session()
> > > + # self.pmdout = PmdOutput(self.dut)
> > > + # self.pmdout_session_secondary =
> > > PmdOutput(self.session_secondary)
> > > +
> > Please remove commented code.
> >
> > > + def set_up(self):
> > > + """
> > > + This is to clear up environment before the case run.
> > > + """
> > > + self.dut.kill_all()
> > > + self.setup_1pf_kdriver_2vf_env_flag = 0
> > > + self.setup_1pf_ddriver_1vf_env_flag = 0
> > > + self.setup_1pf_ddriver_2vf_env_flag = 0
> > > + self.setup_1pf_ddriver_4vf_env_flag = 0
> > > + self.vf0_mac = "00:11:22:33:44:11"
> > > + self.vf1_mac = "00:11:22:33:44:12"
> > > + self.vf2_mac = "00:11:22:33:44:13"
> > > + self.vf3_mac = "00:11:22:33:44:14"
> > > +
> > > + def setup_1pf_ddriver_4vf_env(self, driver='default'):
> > > + self.used_dut_port = self.dut_ports[0]
> > > + localPort = self.tester.get_local_port(self.dut_ports[0])
> > > + self.tester_itf = self.tester.get_interface(localPort)
> > > + self.pf_interface =
> > > self.dut.ports_info[self.used_dut_port]['intf']
> > > + self.pf_mac_address = self.dut.get_mac_address(0)
> >
> > Several function required these information, you can strip these
> > information only once in setup_all function.
> >
> > > + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
> > > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > This code is useless here, is it just for debug?
> >
> > > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 4,
> > > driver='igb_uio')
> > > + self.sriov_vfs_port =
> > > self.dut.ports_info[self.used_dut_port]['vfs_port']
> > > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > > + try:
> > > +
> > > + for port in self.sriov_vfs_port:
> > > + print port.pci
> > Please remove debug code.
> > > + self.dut.send_expect("./tools/dpdk-devbind.py -b
> > > igb_uio %s" % (port.pci), "# ", 3)
> > > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ",
> 3)
> > > + time.sleep(1)
> > > + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> > > + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> > > + vf2_prop = {'opt_host': self.sriov_vfs_port[2].pci}
> > > + vf3_prop = {'opt_host': self.sriov_vfs_port[3].pci}
> > > + for port_id in self.dut_ports:
> > > + if port_id == self.used_dut_port:
> > > + continue
> > > + port = self.dut.ports_info[port_id]['port']
> > > + port.bind_driver()
> > I'm not sure about this logic, you can just get port object by
> > self.dut.ports_info[self.used_dut_port].
> > There's no need to browser through all dut ports.
> > > +
> > > + self.setup_1pf_ddriver_4vf_env_flag = 1
> > > + except Exception as e:
> > > + self.destroy_1pf_ddriver_4vf_env()
> > > + raise Exception(e)
> > > +
> > > + def destroy_1pf_ddriver_4vf_env(self):
> > > + self.session_third.send_expect("quit", "# ")
> > > + self.session_secondary.send_expect("quit", "# ")
> > > + self.dut.send_expect("quit", "# ")
> > When there met some issues which caused testpmd can't start up normally.
> > "Quit" command here will cause the session unavailable any more.
> > Use kill_all api to quit dpdk application is one more reliable way to do
> > such thing.
> >
> > > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> > > + port = self.dut.ports_info[self.used_dut_port]['port']
> > > + port.bind_driver()
> > > + self.used_dut_port = None
> > > +
> > > + for port_id in self.dut_ports:
> > > + port = self.dut.ports_info[port_id]['port']
> > > + port.bind_driver()
> > > +
> > Do not bind dut ports to default driver, this will cause that later
> suites
> > can't work anymore.
> > There's one solution for this is that when test suite initializing, we
> > bind all dut ports to igb_uio.
> > But please do not bind to default driver by now.
> >
> > > + self.setup_1pf_ddriver_4vf_env_flag = 0
> > > +
> > > + def setup_1pf_ddriver_2vf_env(self, driver='default'):
> > > + self.used_dut_port = self.dut_ports[0]
> > > + localPort = self.tester.get_local_port(self.dut_ports[0])
> > > + self.tester_itf = self.tester.get_interface(localPort)
> > > + self.pf_interface =
> > > self.dut.ports_info[self.used_dut_port]['intf']
> > > + self.pf_mac_address = self.dut.get_mac_address(0)
> > > + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
> > These codes can be done only once in setup_all function.
> >
> > > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2,
> > > driver='igb_uio')
> > > + self.sriov_vfs_port =
> > > self.dut.ports_info[self.used_dut_port]['vfs_port']
> > > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > > + try:
> > > +
> > > + for port in self.sriov_vfs_port:
> > > + print port.pci
> > > + self.dut.send_expect("./tools/dpdk-devbind.py -b
> > > igb_uio %s" % (port.pci), "# ", 3)
> > > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ",
> 3)
> > > + time.sleep(1)
> > > + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> > > + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> > > + for port_id in self.dut_ports:
> > > + if port_id == self.used_dut_port:
> > > + continue
> > > + port = self.dut.ports_info[port_id]['port']
> > > + port.bind_driver()
> > > +
> > > + self.setup_1pf_ddriver_2vf_env_flag = 1
> > > + except Exception as e:
> > > + self.destroy_1pf_ddriver_2vf_env()
> > > + raise Exception(e)
> > > +
> > > + def destroy_1pf_ddriver_2vf_env(self):
> > > + self.session_third.send_expect("quit", "# ")
> > > + self.session_secondary.send_expect("quit", "# ")
> > > + self.dut.send_expect("quit", "# ")
> > > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> > > + port = self.dut.ports_info[self.used_dut_port]['port']
> > > + port.bind_driver()
> > > + self.used_dut_port = None
> > > +
> > > + for port_id in self.dut_ports:
> > > + port = self.dut.ports_info[port_id]['port']
> > > + port.bind_driver()
> > > +
> > > + self.setup_1pf_ddriver_2vf_env_flag = 0
> > > +
> > > + def setup_1pf_ddriver_1vf_env(self, driver='default'):
> > > + self.used_dut_port = self.dut_ports[0]
> > > + localPort = self.tester.get_local_port(self.dut_ports[0])
> > > + self.tester_itf = self.tester.get_interface(localPort)
> > > + self.pf_interface =
> > > self.dut.ports_info[self.used_dut_port]['intf']
> > > + self.pf_mac_address = self.dut.get_mac_address(0)
> > > + self.pf_pci = self.dut.ports_info[self.used_dut_port]['pci']
> > > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > > + # self.dut.send_expect("echo 1 >
> > > /sys/bus/pci/devices/%s/max_vfs" % self.pf_pci, "# ", 3)
> > > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 1,
> > > driver='igb_uio')
> > > + self.sriov_vfs_port =
> > > self.dut.ports_info[self.used_dut_port]['vfs_port']
> > > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ", 3)
> > > +
> > > + try:
> > > +
> > > + for port in self.sriov_vfs_port:
> > > + print port.pci
> > > + self.dut.send_expect("./tools/dpdk-devbind.py -b
> > > igb_uio %s" % (port.pci), "# ", 3)
> > > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ",
> 3)
> > > + time.sleep(1)
> > > + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> > > +
> > > + for port_id in self.dut_ports:
> > > + if port_id == self.used_dut_port:
> > > + continue
> > > + port = self.dut.ports_info[port_id]['port']
> > > + port.bind_driver()
> > > +
> > > + self.setup_1pf_ddriver_1vf_env_flag = 1
> > > + except Exception as e:
> > > + self.destroy_1pf_ddriver_1vf_env()
> > > + raise Exception(e)
> > > +
> > > + def destroy_1pf_ddriver_1vf_env(self):
> > > +
> > > + self.session_secondary.send_expect("quit", "# ")
> > > + self.dut.send_expect("quit", "# ")
> > > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> > > + port = self.dut.ports_info[self.used_dut_port]['port']
> > > + port.bind_driver()
> > > + self.used_dut_port = None
> > > +
> > > + for port_id in self.dut_ports:
> > > + port = self.dut.ports_info[port_id]['port']
> > > + port.bind_driver()
> > > +
> > > + self.setup_1pf_ddriver_1vf_env_flag = 0
> > > +
> > > + def setup_1pf_kdriver_2vf_env(self, driver='default'):
> > > + self.used_dut_port = self.dut_ports[0]
> > > + localPort = self.tester.get_local_port(self.dut_ports[0])
> > > + self.tester_itf = self.tester.get_interface(localPort)
> > > + for port_id in self.dut_ports:
> > > + port = self.dut.ports_info[port_id]['port']
> > > + port.bind_driver()
> > > + self.pf_interface =
> > > self.dut.ports_info[self.used_dut_port]['intf']
> > > + self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2,
> > > driver=driver)
> > > + self.sriov_vfs_port =
> > > self.dut.ports_info[self.used_dut_port]['vfs_port']
> > > + #self.vf0_mac = "00:11:22:33:44:11"
> > > + #self.vf1_mac = "00:11:22:33:44:12"
> > > + self.dut.send_expect("ip link set %s vf 0 mac %s" %
> > > (self.pf_interface, self.vf0_mac), "# ", 3)
> > > + self.dut.send_expect("ip link set %s vf 1 mac %s" %
> > > (self.pf_interface, self.vf1_mac), "# ", 3)
> > > +
> > > + try:
> > > +
> > > + for port in self.sriov_vfs_port:
> > > + print port.pci
> > > + self.dut.send_expect("./tools/dpdk-devbind.py -b
> > > igb_uio %s" % (port.pci), "# ", 3)
> > > + self.dut.send_expect("./tools/dpdk-devbind.py -s", "# ",
> 3)
> > > + time.sleep(1)
> > > + vf0_prop = {'opt_host': self.sriov_vfs_port[0].pci}
> > > + vf1_prop = {'opt_host': self.sriov_vfs_port[1].pci}
> > > +
> > > + # for port_id in self.dut_ports:
> > > + # if port_id == self.used_dut_port:
> > > + # continue
> > > + # port = self.dut.ports_info[port_id]['port']
> > > + # port.bind_driver()
> > > +
> > > + self.setup_1pf_kdriver_2vf_env_flag = 1
> > > + except Exception as e:
> > > + self.destroy_1pf_kdriver_2vf_env()
> > > + raise Exception(e)
> > > +
> > > + def destroy_1pf_kdriver_2vf_env(self):
> > > +
> > > + self.session_secondary.send_expect("quit", "# ")
> > > + self.dut.send_expect("quit", "# ")
> > > + self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
> > > + port = self.dut.ports_info[self.used_dut_port]['port']
> > > + port.bind_driver()
> > > + self.used_dut_port = None
> > > +
> > > + for port_id in self.dut_ports:
> > > + port = self.dut.ports_info[port_id]['port']
> > > + port.bind_driver()
> > > +
> > > + self.setup_1pf_kdriver_2vf_env_flag = 0
> > > +
> > > + def test_VEB_switching_inter_vfs_MAC_switch_rxtx(self):
> > > + """
> >
> > Please simplify the test case name, description below can explain the
> > case.
> >
> > > + Kernel PF, then create 2VFs. VFs running dpdk testpmd, send
> > > traffic to VF1, and set the packet's DEST MAC to VF2, check if VF2 can
> > > receive the packets. Check Inter VF-VF MAC switch.
> > > + """
> > > + self.setup_1pf_kdriver_2vf_env(driver='')
> > > + self.dut.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd
> > -c
> > > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> > > strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> > > "testpmd>", 120)
> > Mac here should not hardcode, it has been defined in setup function.
> >
> > > + self.dut.send_expect("set fwd txonly", "testpmd>")
> > > + self.dut.send_expect("set promisc all off", "testpmd>")
> > > +
> > > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip" % self.sriov_vfs_port[1].pci,
> "testpmd>",
> > > 120)
> >
> > Target should not be hard coded for we will do the validation with
> > different targets.
> > You can use start_testpmd in pmd_ouput module to simplify the step.
> >
> > > + 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)
> > > +
> > > + self.dut.send_expect("stop", "testpmd>", 5)
> > > + self.session_secondary.send_expect("stop", "testpmd>", 5)
> > > +
> > > + vf0_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > > + self.verify(vf0_tx_stats[0] * 0.5 < vf1_rx_stats[0], "VF1
> > failed
> > > to receive packets from VF0")
> > > +
> > > + def test_VEB_switching_inter_vfs_MAC_switch_fwd(self):
> > > + """
> > > + Kernel PF, then create 2VFs. VFs running dpdk testpmd, send
> > > traffic to VF1, and set the packet's DEST MAC to VF2, check if VF2 can
> > > receive the packets. Check Inter VF-VF MAC switch.
> > > + """
> > > + self.setup_1pf_kdriver_2vf_env(driver='')
> > > + self.dut.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd
> > -c
> > > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> > > strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> > > "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("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip" % 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)
> > > +
> > > + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> > > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > > + self.verify(vf0_tx_stats == vf1_rx_stats, "VF1 failed to
> > receive
> > > packets from VF0")
> > > +
> > > + def test_VEB_switching_inter_vfs_MAC_switch_vlan(self):
> > > + """
> > > + Kernel PF, then create 2VFs, assign VF1 with VLAN=1 in, VF2
> > with
> > > VLAN=2. VFs are running dpdk testpmd, send traffic to VF1 with VLAN=1,
> > > then let it forwards to VF2, it should not work since they are
> > not
> > > in the same VLAN; set VF2 with VLAN=1, then send traffic to VF1 with
> > > VLAN=1, and VF2 can receive the packets. Check inter VF
> > MAC/VLAN
> > > switch.
> > > + """
> > > + self.setup_1pf_kdriver_2vf_env(driver='')
> > > + # the two vfs belongs to different vlans
> > > + self.dut.send_expect("ip link set %s vf 0 vlan 1" %
> > > self.pf_interface, "# ", 1)
> > > + self.dut.send_expect("ip link set %s vf 1 vlan 2" %
> > > self.pf_interface, "# ", 1)
> > > + self.dut.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd
> > -c
> > > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> > > strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> > > "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("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip" % 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)
> > > +
> > > + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> > > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > > + self.verify((vf0_tx_stats[0] == 1) and (vf1_rx_stats[0] == 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)
> > > +
> > > + # the two vfs belongs to the same vlan
> > > + self.dut.send_expect("ip link set %s vf 1 vlan 1" %
> > > self.pf_interface, "# ", 1)
> > > + self.dut.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd
> > -c
> > > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-
> > > strip --eth-peer=0,00:11:22:33:44:12" % self.sriov_vfs_port[0].pci,
> > > "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("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip" % 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)
> > > +
> > > + 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 = self.veb_get_pmd_stats("first", 0, "tx")
> > > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > > + self.verify((vf0_tx_stats[0] == 1) and (vf1_rx_stats[0] == 1),
> > > "VF1 didn't receive packets from VF0, the vlan filter doen't work")
> > > +
> > > + def test_VEB_switching_inter_pf_vf_MAC_switch(self):
> > > + """
> > > + DPDK PF, then create 1VF, PF in the host running dpdk testpmd,
> > > send traffic from PF to VF1, ensure PF->VF1(let VF1 in promisc mode);
> > send
> > > traffic from VF1 to PF, ensure VF1->PF can work.
> > > + """
> > > + # VF->PF
> > > + self.setup_1pf_ddriver_1vf_env(driver='')
> > > + self.dut.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd
> > -c
> > > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" %
> > > self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > > (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> > > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > > + self.verify(pf_rx_stats[0] != 0, "no packet was received by
> PF")
> > > + self.verify(vf0_tx_stats[0]*0.5 < pf_rx_stats[0], "PF failed
> to
> > > receive most packets from VF0")
> > > + self.session_secondary.send_expect("quit", "# ")
> > > + time.sleep(2)
> > > + self.dut.send_expect("quit", "# ")
> > > + time.sleep(2)
> > > +
> > > + #PF->VF
> > > + self.dut.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd
> > -c
> > > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --eth-
> > > peer=0,%s" % (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>")
> > > +
> > > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> > > + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > > + self.verify(pf_tx_stats[0] != 0, "no packet was sent by PF")
> > > + self.verify(vf0_rx_stats[0] != 0, "no packet was received by
> > VF0")
> > > + self.verify(vf0_rx_stats[0] > pf_tx_stats[0]*0.5, "VF0 failed
> > to
> > > receive 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("./x86_64-native-linuxapp-
> gcc/app/testpmd
> > -c
> > > 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" %
> > > self.pf_pci, "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("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> > > + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > > + self.verify(pf_tx_stats[0] == 0, "PF received unexpected
> > packet")
> > > + self.verify(vf0_rx_stats[0] == 1, "no packet was received by
> > VF0")
> > > +
> > > + 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 = self.veb_get_pmd_stats("second", 0, "rx")
> > > + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > > + self.verify(pf_tx_stats[0] == 1, "no packet was sent by VF0")
> > > + self.verify(pf_rx_stats[0] == 1, "no packet was received by
> > VF0")
> > > + self.verify(vf0_rx_stats[0] == 1, "no packet was received by
> > VF0")
> > > +
> > > + def test_floating_VEB_switching_inter_pf_vf_MAC_switch(self):
> > > + """
> > > + DPDK PF, then create 1VF, PF in the host running dpdk testpmd,
> > > send traffic from PF to VF0, VF0 can't receive any packets; send
> traffic
> > > from VF0 to PF, PF can't rec eive any packets either.
> > > + """
> > > + # VF->PF
> > > + self.setup_1pf_ddriver_1vf_env(driver='')
> > > + self.dut.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd
> > -c
> > > 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> > > prefix=test1 -- -i" % self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > > (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> > > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > > + self.verify(pf_rx_stats[0] == 0, "PF can receive packet from
> > VF0,
> > > the floating VEB doesn't work")
> > > + self.session_secondary.send_expect("quit", "# ")
> > > + time.sleep(2)
> > > + self.dut.send_expect("quit", "# ")
> > > + time.sleep(2)
> > > +
> > > + #PF->VF
> > > + self.dut.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd
> > -c
> > > 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> > > prefix=test1 -- -i --eth-peer=0,%s" % (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>")
> > > +
> > > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip" % (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 = self.veb_get_pmd_stats("second", 0, "rx")
> > > + pf_tx_stats = self.veb_get_pmd_stats("first", 0, "tx")
> > > + self.verify(pf_tx_stats[0] != 0, "no packet was sent by PF")
> > > + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet
> from
> > PF,
> > > the floating VEB doesn't work")
> > > + self.session_secondary.send_expect("quit", "# ")
> > > + time.sleep(2)
> > > + self.dut.send_expect("quit", "# ")
> > > + time.sleep(2)
> > > +
> > > + #outside world ->VF
> > > + self.dut.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd
> > -c
> > > 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> > > prefix=test1 -- -i --eth-peer=0,%s" % (self.pf_pci, self.vf0_mac),
> > > "testpmd>", 120)
> > > + self.dut.send_expect("set fwd mac", "testpmd>")
> > > + self.dut.send_expect("set promisc all on", "testpmd>")
> > > + self.dut.send_expect("start", "testpmd>")
> > > + time.sleep(2)
> > > +
> > > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip" % (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 mac", "testpmd>")
> > > + self.session_secondary.send_expect("set promisc all on",
> > > "testpmd>")
> > > + self.session_secondary.send_expect("start", "testpmd>")
> > > + time.sleep(2)
> > > +
> > > + self.send_packet(self.vf0_mac, self.tester_itf)
> > > + time.sleep(2)
> > > + self.dut.send_expect("stop", "testpmd>", 2)
> > > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > > +
> > > + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > > + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet
> from
> > > outside world, the floating VEB doesn't work")
> > > +
> > > + def test_floating_VEB_switching_inter_vfs_MAC_switch(self):
> > > + """
> > > + 1 DPDK PF, then create 2VF, PF in the host running dpdk
> testpmd,
> > > and VF0 are running dpdk testpmd, VF0 send traffic, and set the
> packet's
> > > DEST MAC to VF1, check if VF1 can receive the packets. Check Inter VF-
> VF
> > > MAC switch when PF is link down as well as up.
> > > + """
> > > + # PF link up, VF0->VF1
> > > + self.setup_1pf_ddriver_2vf_env(driver='')
> > > + # start PF
> > > + self.dut.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd
> > -c
> > > 0xf -n 4 --socket-mem 1024,1024 -w %s,enable_floating_veb=1 --file-
> > > prefix=test1 -- -i" % self.pf_pci, "testpmd>", 120)
> > > + self.dut.send_expect("port start all", "testpmd>")
> > > + time.sleep(2)
> > > + # start VF0
> > > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip" % 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)
> > > + # start VF1
> > > + self.session_third.send_expect("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test3 -- -i --crc-strip --eth-peer=0,%s" %
> > > (self.sriov_vfs_port[1].pci, self.vf0_mac), "testpmd>", 120)
> > > + self.session_third.send_expect("set fwd txonly", "testpmd>")
> > > + self.session_third.send_expect("set promisc all off",
> > "testpmd>")
> > > + self.session_third.send_expect("start", "testpmd>")
> > > + time.sleep(2)
> > > +
> > > + self.session_third.send_expect("stop", "testpmd>", 2)
> > > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > > +
> > > + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > > + vf1_tx_stats = self.veb_get_pmd_stats("third", 0, "tx")
> > > + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> > > + self.verify(vf0_rx_stats[0] != 0, "no packet was received by
> > VF0")
> > > + self.verify(vf1_tx_stats[0]*0.5 < vf0_rx_stats[0], "VF0
> failed
> > to
> > > receive most packets from VF1")
> > > +
> > > + # PF link down, VF0 -> VF1
> > > + self.dut.send_expect("port stop all", "Port 0 Link Down", 20)
> > > + self.session_secondary.send_expect("start", "testpmd>")
> > > + time.sleep(2)
> > > + self.session_third.send_expect("start", "testpmd>")
> > > + time.sleep(2)
> > > + self.session_third.send_expect("stop", "testpmd>", 2)
> > > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > > + self.dut.send_expect("stop", "testpmd>", 2)
> > > +
> > > + vf1_tx_stats_pfstop = self.veb_get_pmd_stats("third", 0, "tx")
> > > + vf0_rx_stats_pfstop = self.veb_get_pmd_stats("second", 0,
> "rx")
> > > + vf1_tx_stats_pfstop[0] = vf1_tx_stats_pfstop[0] -
> > vf1_tx_stats[0]
> > > + vf0_rx_stats_pfstop[0] = vf0_rx_stats_pfstop[0] -
> > vf0_rx_stats[0]
> > > + self.verify(vf1_tx_stats_pfstop[0] != 0, "no packet was sent
> by
> > > VF1")
> > > + self.verify(vf0_rx_stats_pfstop[0] != 0, "no packet was
> > received
> > > by VF0")
> > > + self.verify(vf1_tx_stats_pfstop[0]*0.5 <
> vf0_rx_stats_pfstop[0],
> > > "VF0 failed to receive most packets from VF1")
> > > +
> > > + def
> > test_floating_VEB_VF_cannot_communicate_with_legacy_VEB_VF(self):
> > > + """
> > > + DPDK PF, then create 4VF, VF0,VF2,VF3 are floating VEB; VF1
> is
> > > lagecy VEB. Make PF link down(the cable can be pluged out), VFs are
> > > running dpdk testpmd.
> > > + 1. VF0 send traffic, and set the packet's DEST MAC to VF1,
> > check
> > > VF1 can not receive the packets.
> > > + 2. VF1 send traffic, and set the packet's DEST MAC to VF0,
> > check
> > > VF0 can not receive the packets.
> > > + 3. VF0 send traffic, and set the packet's DEST MAC to VF2,
> > check
> > > VF2 can receive the packets.
> > > + 4. VF3 send traffic, and set the packet's DEST MAC to VF2,
> > check
> > > VF2 can receive the packets.
> > > + """
> > > + self.setup_1pf_ddriver_4vf_env(driver='')
> > > + # start PF
> > > + self.dut.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd
> > -c
> > > 0xf -n 4 --socket-mem 1024,1024 \"-
> > > w %s,enable_floating_veb=1,floating_veb_list=0;2-3\" --file-
> prefix=test1
> > -
> > > - -i" % self.pf_pci, "testpmd>", 120)
> > > + self.dut.send_expect("port start all", "testpmd>")
> > > + time.sleep(2)
> > > + # VF1->VF0
> > > + # start VF0
> > > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > > (self.sriov_vfs_port[0].pci, self.vf1_mac), "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>")
> > > + # start VF1
> > > + self.session_third.send_expect("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test3 -- -i --crc-strip --eth-peer=0,%s" %
> > > (self.sriov_vfs_port[1].pci, self.vf0_mac), "testpmd>", 120)
> > > + self.session_secondary.send_expect("mac_addr add 0 %s" %
> > > self.vf1_mac, "testpmd>")
> > > + self.session_third.send_expect("set fwd txonly", "testpmd>")
> > > + self.session_third.send_expect("set promisc all off",
> > "testpmd>")
> > > +
> > > + # PF link down
> > > + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> > > + self.session_secondary.send_expect("start", "testpmd>")
> > > + time.sleep(2)
> > > + self.session_third.send_expect("start", "testpmd>")
> > > + time.sleep(2)
> > > +
> > > + self.session_third.send_expect("stop", "testpmd>", 2)
> > > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > > +
> > > + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > > + vf1_tx_stats = self.veb_get_pmd_stats("third", 0, "tx")
> > > + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> > > + self.verify(vf0_rx_stats[0] == 0, "floating_VEB VF can
> > > communicate with legacy_VEB VF")
> > > +
> > > + # VF0->VF1
> > > + self.session_secondary.send_expect("set fwd txonly",
> "testpmd>")
> > > + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> > > + self.session_third.send_expect("start", "testpmd>")
> > > + time.sleep(2)
> > > + self.session_secondary.send_expect("start", "testpmd>")
> > > + time.sleep(2)
> > > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > > + self.session_third.send_expect("stop", "testpmd>", 2)
> > > + vf1_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> > > + vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> > > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > > + self.verify(vf1_rx_stats[0] == 0, "floating_VEB VF can
> > > communicate with legacy_VEB VF")
> > > +
> > > + self.session_secondary.send_expect("quit", "# ")
> > > + time.sleep(2)
> > > + self.session_third.send_expect("quit", "# ")
> > > + time.sleep(2)
> > > +
> > > + # VF0->VF2
> > > + # start VF0
> > > + self.dut.send_expect("port start all", "testpmd>")
> > > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > > (self.sriov_vfs_port[0].pci, self.vf2_mac), "testpmd>", 120)
> > > + self.session_secondary.send_expect("mac_addr add 0 %s" %
> > > self.vf0_mac, "testpmd>")
> > > + self.session_secondary.send_expect("set fwd txonly",
> "testpmd>")
> > > + self.session_secondary.send_expect("set promisc all off",
> > > "testpmd>")
> > > + # start VF2
> > > + self.session_third.send_expect("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test3 -- -i --crc-strip" % self.sriov_vfs_port[2].pci,
> "testpmd>",
> > > 120)
> > > + self.session_third.send_expect("mac_addr add 0 %s" %
> > self.vf2_mac,
> > > "testpmd>")
> > > + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> > > + self.session_third.send_expect("set promisc all off",
> > "testpmd>")
> > > +
> > > + # PF link down
> > > + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> > > + self.session_third.send_expect("start", "testpmd>")
> > > + time.sleep(2)
> > > + self.session_secondary.send_expect("start", "testpmd>")
> > > + time.sleep(2)
> > > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > > + self.session_third.send_expect("stop", "testpmd>", 2)
> > > +
> > > + vf2_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> > > + vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> > > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > > + self.verify(vf2_rx_stats[0] != 0, "floating_VEB VFs cannot
> > > communicate with each other")
> > > + self.verify(vf0_tx_stats[0] * 0.5 < vf2_rx_stats[0], "VF2
> > failed
> > > to receive packets from VF0")
> > > +
> > > + self.session_secondary.send_expect("quit", "# ")
> > > + time.sleep(2)
> > > + self.session_third.send_expect("quit", "# ")
> > > + time.sleep(2)
> > > +
> > > + # VF3->VF2
> > > + # start VF3
> > > + self.dut.send_expect("port start all", "testpmd>")
> > > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > > (self.sriov_vfs_port[3].pci, self.vf2_mac), "testpmd>", 120)
> > > + self.session_secondary.send_expect("mac_addr add 0 %s" %
> > > self.vf0_mac, "testpmd>")
> > > + self.session_secondary.send_expect("set fwd txonly",
> "testpmd>")
> > > + self.session_secondary.send_expect("set promisc all off",
> > > "testpmd>")
> > > + # start VF2
> > > + self.session_third.send_expect("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test3 -- -i --crc-strip" % self.sriov_vfs_port[2].pci,
> "testpmd>",
> > > 120)
> > > + self.session_third.send_expect("mac_addr add 0 %s" %
> > self.vf2_mac,
> > > "testpmd>")
> > > + self.session_third.send_expect("set fwd rxonly", "testpmd>")
> > > + self.session_third.send_expect("set promisc all off",
> > "testpmd>")
> > > +
> > > + # PF link down
> > > + self.dut.send_expect("port stop all", "Port 0 Link Down", 40)
> > > + self.session_third.send_expect("start", "testpmd>")
> > > + time.sleep(2)
> > > + self.session_secondary.send_expect("start", "testpmd>")
> > > + time.sleep(2)
> > > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > > + self.session_third.send_expect("stop", "testpmd>", 2)
> > > +
> > > + vf2_rx_stats = self.veb_get_pmd_stats("third", 0, "rx")
> > > + vf3_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> > > + self.verify(vf3_tx_stats[0] != 0, "no packet was sent by VF0")
> > > + self.verify(vf2_rx_stats[0] != 0, "floating_VEB VFs cannot
> > > communicate with each other")
> > > + self.verify(vf3_tx_stats[0] * 0.5 < vf2_rx_stats[0], "VF2
> > failed
> > > to receive packets from VF3")
> > > +
> > > + def
> > >
> test_floating_VEB_and_legacy_VEB_switching_inter_pf_vf_MAC_switch(self):
> > > + """
> > > + DPDK PF, then create 2VFs, VF0 is in floating VEB, VF1 is in
> > > legacy VEB.
> > > + 1. Send traffic from VF0 to PF, then check PF will not see
> any
> > > traffic;
> > > + 2. Send traffic from VF1 to PF, then check PF will receive
> all
> > > the packets.
> > > + 3. send traffic from tester to VF0, check VF0 can't receive
> > > traffic from tester.
> > > + 4. send traffic from tester to VF1, check VF1 can receive all
> > the
> > > traffic from tester.
> > > + """
> > > + self.setup_1pf_ddriver_2vf_env(driver='')
> > > + # VF0->PF
> > > + self.dut.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd
> > -c
> > > 0xf -n 4 --socket-mem 1024,1024 \"-
> > > w %s,enable_floating_veb=1,floating_veb_list=0\" --file-prefix=test1 -
> -
> > -
> > > i" % self.pf_pci, "testpmd>", 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("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > > (self.sriov_vfs_port[0].pci, self.pf_mac_address), "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 = self.veb_get_pmd_stats("second", 0, "tx")
> > > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > > + self.verify(vf0_tx_stats[0] != 0, "no packet was sent by VF0")
> > > + self.verify(pf_rx_stats[0] == 0, "PF can receive packet from
> > VF0,
> > > the floating VEB doesn't work")
> > > + self.session_secondary.send_expect("quit", "# ")
> > > + time.sleep(2)
> > > +
> > > + # VF1->PF
> > > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip --eth-peer=0,%s" %
> > > (self.sriov_vfs_port[1].pci, self.pf_mac_address), "testpmd>", 120)
> > > + self.session_secondary.send_expect("set fwd txonly",
> "testpmd>")
> > > + self.session_secondary.send_expect("set promisc all off",
> > > "testpmd>")
> > > + self.dut.send_expect("start", "testpmd>")
> > > + time.sleep(2)
> > > + 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)
> > > +
> > > + vf1_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
> > > + pf_rx_stats = self.veb_get_pmd_stats("first", 0, "rx")
> > > + self.verify(vf1_tx_stats[0] != 0, "no packet was sent by VF1")
> > > + self.verify(pf_rx_stats[0] != 0, "PF can't receive packet
> from
> > > VF1, the VEB doesn't work")
> > > + self.verify(vf1_tx_stats[0] * 0.5 < pf_rx_stats[0], "PF
> failed
> > to
> > > receive packets from VF1")
> > > + self.session_secondary.send_expect("quit", "# ")
> > > + time.sleep(2)
> > > + self.dut.send_expect("quit", "# ")
> > > + time.sleep(2)
> > > +
> > > + # tester->VF0
> > > + self.dut.send_expect("./x86_64-native-linuxapp-
> gcc/app/testpmd
> > -c
> > > 0xf -n 4 --socket-mem 1024,1024 \"-
> > > w %s,enable_floating_veb=1,floating_veb_list=0\" --file-prefix=test1 -
> -
> > -
> > > i" % self.pf_pci, "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("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip" % (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 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)
> > > + time.sleep(2)
> > > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > > + self.dut.send_expect("stop", "testpmd>", 2)
> > > +
> > > + vf0_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > > + self.verify(vf0_rx_stats[0] == 0, "VF0 can receive packet
> from
> > > outside world, the floating VEB doesn't work")
> > > + self.session_secondary.send_expect("quit", "# ")
> > > + time.sleep(2)
> > > +
> > > + # tester->VF1
> > > + self.session_secondary.send_expect("./x86_64-native-linuxapp-
> > > gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-
> > > prefix=test2 -- -i --crc-strip" % (self.sriov_vfs_port[1].pci),
> > "testpmd>",
> > > 120)
> > > + self.session_secondary.send_expect("mac_addr add 0 %s" %
> > > self.vf1_mac, "testpmd>")
> > > + 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.vf1_mac, self.tester_itf)
> > > + time.sleep(2)
> > > + self.session_secondary.send_expect("stop", "testpmd>", 2)
> > > + self.dut.send_expect("stop", "testpmd>", 2)
> > > +
> > > + vf1_rx_stats = self.veb_get_pmd_stats("second", 0, "rx")
> > > + self.verify(vf1_rx_stats[0] == 1, "VF1 can't receive packet
> > from
> > > outside world, the VEB doesn't work")
> > > +
> > > + def tear_down(self):
> > > + """
> > > + Run after each test case.
> > > + """
> > > + if self.setup_1pf_kdriver_2vf_env_flag == 1:
> > > + self.destroy_1pf_kdriver_2vf_env()
> > > + if self.setup_1pf_ddriver_1vf_env_flag == 1:
> > > + self.destroy_1pf_ddriver_1vf_env()
> > > + if self.setup_1pf_ddriver_2vf_env_flag == 1:
> > > + self.destroy_1pf_ddriver_2vf_env()
> > > + if self.setup_1pf_ddriver_4vf_env_flag == 1:
> > > + self.destroy_1pf_ddriver_4vf_env()
> > > +
> > > + self.dut.kill_all()
> > > +
> > > + pass
> > > +
> > > + 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)
> > Need restore dut ports bound to igb_uio driver.
> > > +
> > > + pass
> > > --
> > > 2.5.0
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-10-19 3:23 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-14 13:50 [dts] [PATCH 1/2] tests add TestSuite_VEB.py Yuan Peng
2016-10-14 13:50 ` [dts] [PATCH 2/2] tests add TestSuite_VEB Yuan Peng
2016-10-14 14:05 ` Liu, Yong
2016-10-14 14:40 ` [dts] [PATCH 1/2] tests add TestSuite_VEB.py Liu, Yong
2016-10-19 3:12 ` Peng, Yuan
2016-10-19 3:16 ` Liu, Yong
2016-10-19 3:19 ` Peng, Yuan
2016-10-19 3:23 ` Liu, Yong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).