test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] test_plans: add floating_veb_test_plan.rst
@ 2016-12-06  7:36 peng,yuan
  2016-12-06  7:36 ` [dts] [PATCH] test_plans: add veb_switch_test_plan.rst peng,yuan
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: peng,yuan @ 2016-12-06  7:36 UTC (permalink / raw)
  To: dts; +Cc: Peng Yuan

From: Peng Yuan <yuan.peng@intel.com>

Signed-off-by: Peng Yuan <yuan.peng@intel.com>

diff --git a/test_plans/floating_veb_test_plan.rst b/test_plans/floating_veb_test_plan.rst
new file mode 100644
index 0000000..ad69570
--- /dev/null
+++ b/test_plans/floating_veb_test_plan.rst
@@ -0,0 +1,409 @@
+.. Copyright (c) <2016>, Intel Corporation
+      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.
+
+=====================================
+VEB Switch and floating VEB Test Plan 
+=====================================
+
+VEB Switching Introduction
+==========================
+
+IEEE EVB tutorial: 
+http://www.ieee802.org/802_tutorials/2009-11
+/evb-tutorial-draft-20091116_v09.pdf
+
+Virtual Ethernet Bridge (VEB) - This is an IEEE EVB term. A VEB is a VLAN 
+Bridge internal to Fortville that bridges the traffic of multiple VSIs over
+ an internal virtual network. 
+
+Virtual Ethernet Port Aggregator (VEPA) - This is an IEEE EVB term. A VEPA
+multiplexes the traffic of one or more VSIs onto a single Fortville Ethernet
+port. The biggest difference between a VEB and a VEPA is that a VEB can
+switch packets internally between VSIs, whereas a VEPA cannot. 
+
+Virtual Station Interface (VSI) - This is an IEEE EVB term that defines 
+the properties of a virtual machine's (or a physical machine's) connection 
+to the network. Each downstream v-port on a Fortville VEB or VEPA defines 
+a VSI. A standards-based definition of VSI properties enables network 
+management tools to perform virtual machine migration and associated network 
+re-configuration in a vendor-neutral manner.
+
+My understanding of VEB is that it's an in-NIC switch(MAC/VLAN), and it can 
+support VF->VF, PF->VF, VF->PF packet forwarding according to the NIC internal 
+switch. It's similar as Niantic's SRIOV switch.
+
+Floating VEB Introduction
+=========================
+
+Floating VEB is based on VEB Switching. It will address 2 problems:
+
+Dependency on PF: When the physical port is link down, the functionality of 
+the VEB/VEPA will not work normally. Even only data forwarding between the VF 
+is required, one PF port will be wasted to create the related VEB.
+
+Ensure all the traffic from VF can only forwarding within the VFs connect 
+to the floating VEB, cannot forward to the outside world.
+
+Prerequisites for VEB testing
+=============================
+
+1. Get the pci device id of DUT, for example::
+
+    ./dpdk-devbind.py --st
+    0000:05:00.0 'Ethernet Controller X710 for 10GbE SFP+' if=ens785f0 drv=i40e 
+    unused=
+    
+2.1  Host PF in kernel driver. Create 2 VFs from 1 PF with kernel driver, 
+     and set the VF MAC address at PF::
+
+    echo 2 > /sys/bus/pci/devices/0000\:05\:00.0/sriov_numvfs
+    ./dpdk-devbind.py --st
+
+    0000:05:02.0 'XL710/X710 Virtual Function' unused=
+    0000:05:02.1 'XL710/X710 Virtual Function' unused=
+
+    ip link set ens785f0 vf 0 mac 00:11:22:33:44:11
+    ip link set ens785f0 vf 1 mac 00:11:22:33:44:12
+
+2.2  Host PF in DPDK driver. Create 2VFs from 1 PF with dpdk driver:: 
+    
+    ./dpdk-devbind.py -b igb_uio 05:00.0 
+    echo 2 >/sys/bus/pci/devices/0000:05:00.0/max_vfs
+    ./dpdk-devbind.py --st
+    0000:05:02.0 'XL710/X710 Virtual Function' unused=i40evf,igb_uio
+    0000:05:02.1 'XL710/X710 Virtual Function' unused=i40evf,igb_uio
+
+3. Bind the VFs to dpdk driver::
+
+    ./tools/dpdk-devbind.py -b igb_uio 05:02.0 05:02.1
+
+4. Reserve huge pages memory(before using DPDK)::
+
+    echo 4096 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB
+    /nr_hugepages 
+    mkdir /mnt/huge  
+    mount -t hugetlbfs nodev /mnt/huge    
+
+
+Test Case1: Floating VEB inter VF-VF 
+=======================================================
+
+Summary: 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.
+
+Launch PF testpmd::
+   ./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024
+   -w 05:00.0,enable_floating_veb=1 --file-prefix=test1 -- -i
+
+2. In the host, run testpmd with floating parameters and make the link down::
+
+   ./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024
+   -w 05:00.0,enable_floating_veb=1 --file-prefix=test1 -- -i
+   testpmd> port start all
+   testpmd> show port info all
+
+3. In VM1, run testpmd::
+
+   ./x86_64-native-linuxapp-gcc/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024
+   -w 05:02.0 --file-prefix=test2 -- -i --crc-strip 
+   testpmd>mac_addr add 0 vf1_mac_address
+   testpmd>set fwd rxonly
+   testpmd>start
+   testpmd>show port stats all
+   
+  In VM2, run testpmd::
+
+ ./testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w 05:02.1 --file-prefix=test3
+ -- -i --crc-strip --eth-peer=0,vf1_mac_address
+ testpmd>set fwd txonly
+ testpmd>start
+ testpmd>show port stats all
+
+4. check if VF1 can get all the packets. Check the packet content is no 
+   corrupted. RX-packets=TX-packets, but there is a little RX-error. 
+   RF receive no packets.
+
+5. Set "testpmd> port stop all" and "testpmd> start" in step2, 
+   then run the step3-4 again. same result.
+
+
+Test Case2: Floating VEB PF can't get traffic from VF    
+================================================================
+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 receive any packets either.
+ 
+
+1. In host, launch testpmd::
+
+   ./testpmd -c 0x3 -n 4 -w 82:00.0,enable_floating_veb=1 -- -i
+   testpmd> set fwd rxonly
+   testpmd> port start all
+   testpmd> start
+   testpmd> show port stats all
+
+3. In VM1, run testpmd::
+
+   ./testpmd -c 0x3 -n 4 -- -i --eth-peer=0,pf_mac_addr
+   testpmd>set fwd txonly
+   testpmd>start
+   testpmd>show port stats all
+
+4. Check if PF can not get any packets, so VF1->PF is not working. 
+
+5. Set "testpmd> port stop all" in step2, then run the test case again.
+   Same result.
+
+
+
+Test Case2-2 Floating VEB VF can't receive traffic from outside world 
+======================================================
+
+DPDK PF, then create 1VF, send traffic from tester to VF1, 
+in floating mode, check VF1 can't receive traffic from tester.
+
+1. Start VM1 with VF1, see the prerequisite part.
+
+2. In host, launch testpmd::
+
+   ./testpmd -c 0x3 -n 4 -w 82:00.0,enable_floating_veb=1 -- -i 
+   testpmd> set fwd mac
+   testpmd> port start all
+   testpmd> start
+   testpmd> show port stats all
+   
+
+   In VM1, run testpmd:
+
+   ./testpmd -c 0x3 -n 4 -- -i 
+    testpmd>show port info all    //get VF_mac_address
+    testpmd>set fwd rxonly
+    testpmd>start
+    testpmd>show port stats all
+
+   In tester, run scapy
+
+   packet=Ether(dst="VF_mac_address")/IP()/UDP()/Raw('x'*20)
+   sendp(packet,iface="enp132s0f0")
+   
+3. Check if VF1 can not get any packets, so tester->VF1 is not working.
+4. Set "testpmd> port stop all" in step2 in Host, then run the test case 
+   again. same result.PF can't receive any packets. 
+
+
+Test Case3: Floating VEB VF can not communicate with legacy VEB VF 
+======================================================
+
+Summary: DPDK PF, then create 4VFs and 4VMs, VF1,VF3,VF4, floating VEB; 
+VF2, lagecy VEB. Make PF link down(the cable can be pluged out), 
+VFs in VMs are running dpdk testpmd.
+1. VF1 send traffic, and set the packet's DEST MAC to VF2, 
+   check VF2 can not receive the packets. 
+2. VF1 send traffic, and set the packet's DEST MAC to VF3, 
+   check VF3 can receive the packets. 
+3. VF4 send traffic, and set the packet's DEST MAC to VF3, 
+   check VF3 can receive the packets.
+4. VF2 send traffic, and set the packet's DEST MAC to VF1, 
+   check VF1 can not receive the packets. 
+Check Inter-VM VF-VF MAC switch when PF is link down as well as up.
+
+Launch PF testpmd:: 
+  ./testpmd -c 0x3 -n 4 
+   -w "82:00.0,enable_floating_veb=1,floating_veb_list=0;2-3" -- -i
+
+1. Start VM1 with VF1, VM2 with VF2, VM3 with VF3, 
+   VM4 with VF4,see the prerequisite part.
+
+2. In the host, run testpmd with floating parameters and make the link down::
+
+   ./testpmd -c 0x3 -n 4 
+    -w "82:00.0,enable_floating_veb=1,floating_veb_list=0;2-3" -- -i     
+    //VF1 and VF3 in floating VEB, VF2 in legacy VEB
+   
+   testpmd> port stop all     
+   //this step should be executed after vf running testpmd.
+    
+   testpmd> show port info all
+
+3. VF1 send traffic, and set the packet's DEST MAC to VF2, 
+   check VF2 can not receive the packets.
+
+    In VM2, run testpmd::
+
+    ./testpmd -c 0x3 -n 4 -- -i 
+    testpmd>set fwd rxonly
+    testpmd>mac_addr add 0 vf2_mac_address     //set the vf2_mac_address
+    testpmd>start
+    testpmd>show port stats all
+   
+    In VM1, run testpmd::
+
+    ./testpmd -c 0x3 -n 4 -- -i --eth-peer=0,vf2_mac_address
+    testpmd>set fwd txonly
+    testpmd>start
+    testpmd>show port stats all
+
+    Check VF2 can not get any packets, so VF1->VF2 is not working.
+
+4. VF1 send traffic, and set the packet's DEST MAC to VF3, 
+   check VF3 can receive the packets.
+
+    In VM3, run testpmd::
+
+    ./testpmd -c 0x3 -n 4 -- -i 
+    testpmd>set fwd rxonly
+    testpmd>show port info all     //get the vf3_mac_address
+    testpmd>start
+    testpmd>show port stats all
+
+    In VM1, run testpmd::
+
+    ./testpmd -c 0x3 -n 4 -- -i --eth-peer=0,vf3_mac_address
+    testpmd>set fwd txonly
+    testpmd>start
+    testpmd>show port stats all
+
+ Check VF3 can get all the packets. Check the packet content is no corrupted.
+ so VF1->VF2 is working.
+
+5. VF2 send traffic, and set the packet's DEST MAC to VF1, 
+   check VF1 can not receive the packets. 
+
+    In VM1, run testpmd::
+
+    ./testpmd -c 0x3 -n 4 -- -i 
+    testpmd>set fwd rxonly
+    testpmd>show port info all     //get the vf1_mac_address
+    testpmd>start
+    testpmd>show port stats all
+
+    In VM2, run testpmd::
+
+    ./testpmd -c 0x3 -n 4 -- -i --eth-peer=0,vf1_mac_address
+    testpmd>set fwd txonly
+    testpmd>start
+    testpmd>show port stats all
+
+    Check VF1 can not get any packets, so VF2->VF1 is not working.
+
+6. Set "testpmd> port start all" and "testpmd> start" in step2, 
+   then run the step3-5 again. same result.
+
+
+Test Case4: PF can't get traffic from Floating VEB VF, but PF can get traffic 
+================================================================
+from legacy VEB VF.
+================================================================
+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.
+
+1. In host, launch testpmd::
+
+   ./testpmd -c 0x3 -n 4 
+    -w 82:00.0,enable_floating_veb=1,floating_veb_list=0 -- -i
+   testpmd> set fwd rxonly
+   testpmd> port start all
+   testpmd> start
+   testpmd> show port stats all
+
+3. In VF1, run testpmd::
+
+   ./testpmd -c 0x3 -n 4 -- -i --eth-peer=0,pf_mac_addr
+   testpmd>set fwd txonly
+   testpmd>start
+   testpmd>show port stats all
+
+   Check PF can not get any packets, so VF1->PF is not working. 
+
+4. In VF2, run testpmd::
+
+   ./testpmd -c 0x3 -n 4 -- -i --eth-peer=0,pf_mac_addr
+   testpmd>set fwd txonly
+   testpmd>start
+   testpmd>show port stats all
+
+   Check PF can get all the packets, so VF2->PF is working.
+
+5. Set "testpmd> port stop all" in step2 in Host, 
+   then run the test case again. same result.
+
+6. In host, launch testpmd::
+
+   ./testpmd -c 0x3 -n 4 
+    -w 82:00.0,enable_floating_veb=1,floating_veb_list=0 -- -i   
+   testpmd> set fwd mac
+   testpmd> port start all
+   testpmd> start
+   testpmd> show port stats all
+   
+
+7. In VF1, run testpmd::
+
+   ./testpmd -c 0x3 -n 4 -- -i 
+    testpmd>show port info all    //get VF1_mac_address
+    testpmd>set fwd rxonly
+    testpmd>start
+    testpmd>show port stats all
+
+   In tester, run scapy
+
+   packet=Ether(dst="VF1_mac_address")/IP()/UDP()/Raw('x'*20)
+   sendp(packet,iface="enp132s0f0")
+   
+   Check VF1 can not get any packets, so tester->VF1 is not working. 
+
+8. In VF2, run testpmd::
+
+   ./testpmd -c 0x3 -n 4 -- -i 
+    testpmd>show port info all    //get VF2_mac_address
+    testpmd>set fwd rxonly
+    testpmd>start
+    testpmd>show port stats all
+
+   In tester, run scapy
+
+   packet=Ether(dst="VF2_mac_address")/IP()/UDP()/Raw('x'*20)
+   sendp(packet,iface="enp132s0f0")
+   
+   Check VF1 can get all the packets, so tester->VF2 is working.
+
+5. Set "testpmd> port stop all" in step2 in Host, then run the test case again. 
+   VF1 and VF2 cannot receive any packets. (because PF link down, 
+   and PF can't receive any packets. so even if VF2 can't receive any packets.)
+
-- 
2.5.0

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [dts] [PATCH] tests: add TestSuite_veb_switch.py
@ 2016-12-29  8:52 Peng Yuan
  2017-01-04  3:27 ` Liu, Yong
  0 siblings, 1 reply; 7+ messages in thread
From: Peng Yuan @ 2016-12-29  8:52 UTC (permalink / raw)
  To: dts; +Cc: peng yuan

From: peng yuan <yuan.peng@intel.com>

Signed-off-by: peng yuan <yuan.peng@intel.com>

diff --git a/tests/TestSuite_veb_switch.py b/tests/TestSuite_veb_switch.py
new file mode 100644
index 0000000..1bfa776
--- /dev/null
+++ b/tests/TestSuite_veb_switch.py
@@ -0,0 +1,474 @@
+# BSD LICENSE
+#
+# Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# 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
+
+from virt_dut import VirtDut
+from project_dpdk import DPDKdut
+from dut import Dut
+from test_case import TestCase
+from pmd_output import PmdOutput
+from settings import HEADER_SIZE
+from packet import Packet
+from utils import RED
+
+
+class TestVEBSwitching(TestCase):
+
+    def VEB_get_stats(self, vf0_vf1, portid, rx_tx):
+        """
+        Get packets number from port statistic
+        """
+        if vf0_vf1 == "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.dut.send_expect("start", "testpmd>")
+        mac = self.dut.get_mac_address(0)
+
+        if tran_type == "vlan":
+            pkt = Packet(pkt_type='VLAN_UDP')
+            pkt.config_layer('ether', {'dst': vf_mac})
+            pkt.config_layer('vlan', {'vlan': 1})
+            pkt.send_pkt(tx_port=itf)
+            time.sleep(.5)
+        else:
+            pkt = Packet(pkt_type='UDP')
+            pkt.config_layer('ether', {'dst': vf_mac})
+            pkt.send_pkt(tx_port=itf)
+            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.session_secondary = self.dut.new_session()
+        self.session_third = self.dut.new_session()
+        
+        self.pf_kdriver_flag = 0
+        self.pf_ddriver_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"
+        
+        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']
+
+    def set_up(self):
+        """
+        This is to clear up environment before the case run.
+        """
+        self.dut.kill_all()
+
+    def setup_env(self, driver):
+        """
+        This is to set up 1pf and 2vfs environment, the pf can be bond to
+        kernel driver or dpdk driver.
+        """
+        if driver == 'default':
+            for port_id in self.dut_ports:
+                port = self.dut.ports_info[port_id]['port']
+                port.bind_driver()
+        self.dut.generate_sriov_vfs_by_port(self.used_dut_port, 2, driver)
+        self.sriov_vfs_port = self.dut.ports_info[self.used_dut_port]['vfs_port']
+        if driver == 'default':
+            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:
+                port.bind_driver(driver=self.drivername)
+            if driver == 'default':
+                self.pf_kdriver_flag = 1
+            else:
+                self.pf_ddriver_flag = 1
+        except Exception as e:
+            self.destroy_env(driver)
+            raise Exception(e)
+
+    def destroy_env(self, driver):
+        """
+        This is to destroy 1pf and 2vfs environment.
+        """
+        if driver == self.drivername:
+            self.session_third.send_expect("quit", "# ")
+            time.sleep(2)
+        self.session_secondary.send_expect("quit", "# ")
+        time.sleep(2)
+        self.dut.send_expect("quit", "# ")
+        time.sleep(2)
+        self.dut.destroy_sriov_vfs_by_port(self.used_dut_port)
+        if driver == self.drivername:
+            self.pf_ddriver_flag = 0
+        else:
+            self.pf_kdriver_flag = 0
+
+    def test_VEB_switching_inter_vfs(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_env(driver='default')
+        self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-strip --eth-peer=0,%s" % (self.target, self.sriov_vfs_port[0].pci, self.vf1_mac), "testpmd>", 120)
+        self.dut.send_expect("set fwd txonly", "testpmd>")
+        self.dut.send_expect("set promisc all off", "testpmd>")
+
+        self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % (self.target, self.sriov_vfs_port[1].pci), "testpmd>", 120)
+        self.session_secondary.send_expect("set fwd rxonly", "testpmd>")
+        self.session_secondary.send_expect("set promisc all off", "testpmd>")
+        self.session_secondary.send_expect("start", "testpmd>", 5)
+        self.dut.send_expect("start", "testpmd>", 5)
+        time.sleep(2)
+    
+        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_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_env(driver='default')
+        self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-strip --eth-peer=0,%s" % (self.target, self.sriov_vfs_port[0].pci, self.vf1_mac), "testpmd>", 120)
+        self.dut.send_expect("set fwd mac", "testpmd>")
+        self.dut.send_expect("set promisc all off", "testpmd>")
+        self.dut.send_expect("start", "testpmd>")
+        time.sleep(2)
+        self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % (self.target, self.sriov_vfs_port[1].pci), "testpmd>", 120)
+        self.session_secondary.send_expect("set fwd rxonly", "testpmd>")
+        self.session_secondary.send_expect("set promisc all off", "testpmd>")
+        self.session_secondary.send_expect("start", "testpmd>")
+        time.sleep(2)
+  
+        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_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_env(driver='default')
+        # 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("./%s/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-strip --eth-peer=0,%s" % (self.target, self.sriov_vfs_port[0].pci, self.vf1_mac), "testpmd>", 120)
+        self.dut.send_expect("set fwd mac", "testpmd>")
+        self.dut.send_expect("set promisc all off", "testpmd>")
+        self.dut.send_expect("start", "testpmd>")
+        time.sleep(2)
+        self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % (self.target, self.sriov_vfs_port[1].pci), "testpmd>", 120)
+        self.session_secondary.send_expect("set fwd mac", "testpmd>")
+        self.session_secondary.send_expect("set promisc all off", "testpmd>")
+        self.session_secondary.send_expect("start", "testpmd>")
+        time.sleep(2)
+
+        self.send_packet(self.vf0_mac, self.tester_itf, "vlan")
+
+        self.dut.send_expect("stop", "testpmd>", 2)
+        self.session_secondary.send_expect("stop", "testpmd>", 2)
+
+        vf0_tx_stats = 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("./%s/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --crc-strip --eth-peer=0,%s" % (self.target, self.sriov_vfs_port[0].pci, self.vf1_mac), "testpmd>", 120)
+        self.dut.send_expect("set fwd mac", "testpmd>")
+        self.dut.send_expect("set promisc all off", "testpmd>")
+        self.dut.send_expect("start", "testpmd>")
+        time.sleep(2)
+        self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % (self.target, self.sriov_vfs_port[1].pci), "testpmd>", 120)
+        self.session_secondary.send_expect("set fwd mac", "testpmd>")
+        self.session_secondary.send_expect("set promisc all off", "testpmd>")
+        self.session_secondary.send_expect("start", "testpmd>")
+        time.sleep(2)
+
+        self.send_packet(self.vf0_mac, self.tester_itf, "vlan")
+
+        self.dut.send_expect("stop", "testpmd>", 2)
+        self.session_secondary.send_expect("stop", "testpmd>", 2)
+
+        vf0_tx_stats = 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_vfs_and_pf(self):
+        """
+        DPDK PF, then create 2VFs, PF in the host running dpdk testpmd, VFs
+        running dpdk testpmd, VF1 send traffic to VF2, check if VF2 can receive
+        the packets. send tracfic from PF to VF1, ensure PF->VF1; send traffic
+        from VF1 to PF, ensure VF1->PF can work.
+        """
+        # VF->PF
+        self.setup_env(driver=self.drivername)
+        self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" % (self.target, 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("./%s/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip --eth-peer=0,%s" % (self.target, 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("./%s/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i --eth-peer=0,%s" % (self.target, self.pf_pci, self.vf0_mac), "testpmd>", 120)
+        self.dut.send_expect("set fwd txonly", "testpmd>")
+        self.dut.send_expect("set promisc all off", "testpmd>")
+        
+        self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % (self.target, self.sriov_vfs_port[0].pci), "testpmd>", 120)
+        self.session_secondary.send_expect("mac_addr add 0 %s" % self.vf0_mac, "testpmd>")
+        self.session_secondary.send_expect("set fwd rxonly", "testpmd>")
+        self.session_secondary.send_expect("set promisc all off", "testpmd>")
+        self.session_secondary.send_expect("start", "testpmd>")
+        time.sleep(2)
+        self.dut.send_expect("start", "testpmd>")
+        time.sleep(2)
+
+        self.dut.send_expect("stop", "testpmd>", 2)
+        self.session_secondary.send_expect("stop", "testpmd>", 2)
+
+        vf0_rx_stats = 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("./%s/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" % (self.target, 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("./%s/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip" % (self.target, self.sriov_vfs_port[0].pci), "testpmd>", 120)
+        self.session_secondary.send_expect("mac_addr add 0 %s" % self.vf0_mac, "testpmd>")
+        self.session_secondary.send_expect("set fwd rxonly", "testpmd>")
+        self.session_secondary.send_expect("set promisc all off", "testpmd>")
+        self.session_secondary.send_expect("start", "testpmd>")
+        time.sleep(2)
+
+        self.send_packet(self.vf0_mac, self.tester_itf)
+        time.sleep(2)
+        self.session_secondary.send_expect("stop", "testpmd>", 2)
+        self.dut.send_expect("stop", "testpmd>", 2)
+        vf0_rx_stats = 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")
+        self.session_secondary.send_expect("quit", "# ")
+        time.sleep(2)
+        self.dut.send_expect("quit", "# ")
+        time.sleep(2)
+
+        # VF1->VF2
+        self.dut.send_expect("./%s/app/testpmd -c 0xf -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test1 -- -i" % (self.target, self.pf_pci), "testpmd>", 120)
+        self.dut.send_expect("set promisc all off", "testpmd>")
+
+        self.session_secondary.send_expect("./%s/app/testpmd -c 0xf0 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test2 -- -i --crc-strip --eth-peer=0,%s" % (self.target, self.sriov_vfs_port[0].pci, self.vf1_mac), "testpmd>", 120)
+        self.session_secondary.send_expect("set fwd txonly", "testpmd>")
+        self.session_secondary.send_expect("set promisc all off", "testpmd>")
+        time.sleep(2)
+
+        self.session_third.send_expect("./%s/app/testpmd -c 0xf00 -n 4 --socket-mem 1024,1024 -w %s --file-prefix=test3 -- -i --crc-strip" % (self.target, self.sriov_vfs_port[1].pci), "testpmd>", 120)
+        self.session_third.send_expect("mac_addr add 0 %s" % self.vf1_mac, "testpmd>")
+        self.session_third.send_expect("set fwd rxonly", "testpmd>")
+        self.session_third.send_expect("set promisc all off", "testpmd>")
+        self.session_third.send_expect("start", "testpmd>")
+        self.session_secondary.send_expect("start", "testpmd>")        
+        time.sleep(2)
+
+        self.session_secondary.send_expect("stop", "testpmd>", 5)
+        self.session_third.send_expect("stop", "testpmd>", 5)
+        
+        vf0_tx_stats = self.veb_get_pmd_stats("second", 0, "tx")
+        vf1_rx_stats = self.veb_get_pmd_stats("third", 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 tear_down(self):
+        """
+        Run after each test case.
+        """
+        if self.pf_kdriver_flag == 1:
+            self.destroy_env(driver='default')
+        if self.pf_ddriver_flag == 1:
+            self.destroy_env(driver=self.drivername)
+
+        self.dut.kill_all()
+    
+
+    def tear_down_all(self):
+        """
+        Run after each test suite.
+        """
+        self.dut.kill_all()
+        self.dut.close_session(self.session_secondary)
+        self.dut.close_session(self.session_third)
+        # Marvin recommended that all the dut ports should be bound to DPDK.
+        for port_id in self.dut_ports:
+            port = self.dut.ports_info[port_id]['port']
+            port.bind_driver(driver=self.drivername)
+
-- 
2.5.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-01-04  3:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-06  7:36 [dts] [PATCH] test_plans: add floating_veb_test_plan.rst peng,yuan
2016-12-06  7:36 ` [dts] [PATCH] test_plans: add veb_switch_test_plan.rst peng,yuan
2016-12-06  7:36 ` [dts] [PATCH] tests: add TestSuite_floating_veb.py peng,yuan
2016-12-06  7:36 ` [dts] [PATCH] tests: add TestSuite_veb_switch.py peng,yuan
2016-12-07  2:18   ` Liu, Yong
2016-12-29  8:52 Peng Yuan
2017-01-04  3:27 ` 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).