[dts] patch v2 2/2: Add test suite for avf

Wang Fei feix.y.wang at intel.com
Fri Jun 29 02:41:00 CEST 2018


Signed-off-by: Wang Fei <feix.y.wang at intel.com>
---
 tests/TestSuite_avf.py | 917 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 917 insertions(+)
 create mode 100644 tests/TestSuite_avf.py

diff --git a/tests/TestSuite_avf.py b/tests/TestSuite_avf.py
new file mode 100644
index 0000000..86fe502
--- /dev/null
+++ b/tests/TestSuite_avf.py
@@ -0,0 +1,917 @@
+import utils
+
+from test_case import TestCase
+from etgen import IxiaPacketGenerator
+from packet import *
+#Packet, sniff_packets, load_sniff_packets
+from pdb import set_trace
+from settings import HEADER_SIZE
+from pmd_output import PmdOutput
+
+class TestAVF(TestCase, IxiaPacketGenerator):
+
+    def set_up_all(self):
+
+        self.tester.extend_external_packet_generator(TestAVF, self)
+
+        self.dut_ports = self.dut.get_ports(self.nic)
+        self.verify(len(self.dut_ports) >=2, "Insufficent DUT Ports")
+        self.socket = self.dut.get_numa_id(self.dut_ports[0])
+        self.cores = self.dut.get_core_list("1S/10C/1T", self.socket)
+
+        # config for AVF setting
+        self.dut.send_expect("sed -i -e '/AVF_DEV_ID_ADAPTIVE_VF/s/0x1889/0x154c/g' drivers/net/avf/base/avf_devids.h", "# ")
+        self.dut.send_expect("sed -i -e '/I40E_DEV_ID_VF/s/0x154C/0x164C/g'  drivers/net/i40e/base/i40e_devids.h", "# ")
+
+        self.dut.build_install_dpdk(self.target)
+
+        self.vf_mac0 = "00:12:34:56:78:01"
+        self.vf_mac1 = "00:12:34:56:78:02"
+
+        self.frame_sizes = [64, 128, 256, 512]
+
+        # flags to indicate if 2pf2vf or 1pf2vf environment is setup ready
+        self.env_2pf2vf_done = False
+        self.env_1pf2vf_done = False
+
+        self.testpmd_2pf2vf_done = False
+
+    def set_up(self):
+        pass
+
+    def set_2pf2vf_env(self):
+        '''
+        create 2 vf ports from 2 dpdk driver pf ports
+        '''
+        self.pf_pci0 = self.dut.ports_info[0]['pci']
+        self.pf_pci1 = self.dut.ports_info[1]['pci']
+
+        self.tx_interface = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
+        self.rx_interface = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
+
+        # bind 2 pf ports to kernel driver first  
+        self.dut.ports_info[0]['port'].bind_driver("default")
+        self.dut.ports_info[1]['port'].bind_driver("default")
+
+        #reinstall igb_uio driver and bind to the 2 pf ports
+        try:
+            self.dut.send_expect("rmmod igb_uio", "# ", 60)
+            self.dut.send_expect("insmod %s/kmod/igb_uio.ko" % self.target, "# ", 60)
+        except Exception as e:
+            raise Exception(e)
+
+        self.dut.ports_info[0]['port'].bind_driver("igb_uio")
+        self.dut.ports_info[1]['port'].bind_driver("igb_uio")
+
+        #create 2 vf from igb_uio driver
+        self.dut.generate_sriov_vfs_by_port(self.dut_ports[0], 1, "igb_uio") 
+        self.dut.generate_sriov_vfs_by_port(self.dut_ports[1], 1, "igb_uio")
+
+        self.vf0_port = self.dut.ports_info[0]['vfs_port']
+        self.vf1_port = self.dut.ports_info[1]['vfs_port']
+        self.vf0_port_pci = self.dut.ports_info[0]['sriov_vfs_pci'][0]
+        self.vf1_port_pci = self.dut.ports_info[1]['sriov_vfs_pci'][0]
+
+        #bind vf ports to igb_uio driver
+        self.vf0_port[0].bind_driver("igb_uio")
+        self.vf1_port[0].bind_driver("igb_uio")
+ 
+        #config the command line for vf
+        cores_2vf = self.cores[5:]
+        core_mask_2vf = utils.create_mask(cores_2vf)
+        self.cmdline_2vf = "./dpdk/{}/app/testpmd -c {} -n 4 --master-lcore={} --socket-mem=1024,1024 --file-prefix=vf replacement -- -i --txq=4 --rxq=4 --nb-cores=4".format(\
+            self.dut.target, core_mask_2vf, cores_2vf[0])
+
+        #start testpmd for pf
+        pf0_pci = self.dut.ports_info[0]['pci']
+        pf1_pci = self.dut.ports_info[1]['pci']
+        eal_param_2pf = "--socket-mem=1024,1024 --file-prefix=pf -w {} -w {}".format(self.pf_pci0, self.pf_pci1)
+        cores_2pf = self.cores[0:5]
+        self.testpmd_2pf = PmdOutput(self.dut)
+        out = self.testpmd_2pf.start_testpmd(cores_2pf, eal_param=eal_param_2pf, socket=self.socket)
+        print out
+
+        # set vf mac 
+        self.testpmd_2pf.execute_cmd("set vf mac addr 0 0 %s" % self.vf_mac0)
+        self.testpmd_2pf.execute_cmd("set vf mac addr 1 0 %s" % self.vf_mac1)
+
+        self.env_2pf2vf_done = True
+
+    def set_1pf2vf_env(self):
+        '''
+        create 2 vf ports from 1 dpdk driver pf port
+        '''
+        self.pf_pci0 = self.dut.ports_info[0]['pci']
+
+        self.tx_interface = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
+        self.rx_interface = self.tx_interface
+
+        # bind pf port to kernel driver first  
+        self.dut.ports_info[0]['port'].bind_driver("default")
+
+        #reinstall igb_uio driver and bind to the pf port
+        try:
+            self.dut.send_expect("rmmod igb_uio", "# ",60)
+            self.dut.send_expect("insmod %s/kmod/igb_uio.ko" % self.target, "# ",60)
+        except Exception as e:
+            raise Exception(e)
+
+        self.dut.ports_info[0]['port'].bind_driver("igb_uio")
+
+        #create 2 vf from igb_uio driver
+        self.dut.generate_sriov_vfs_by_port(self.dut_ports[0], 2, "igb_uio") 
+
+        self.vf_port = self.dut.ports_info[0]['vfs_port']
+        self.vf0_port_pci = self.dut.ports_info[0]['sriov_vfs_pci'][0]
+        self.vf1_port_pci = self.dut.ports_info[0]['sriov_vfs_pci'][1]
+
+        #bind vf ports to igb_uio driver
+        self.vf_port[0].bind_driver("igb_uio")
+        self.vf_port[1].bind_driver("igb_uio")
+ 
+        #config the command line for vf0
+        cores_for_vf0 = self.cores[2:5]
+        core_mask_for_vf0 = utils.create_mask(cores_for_vf0)
+        self.cmdline_for_vf0 = "./dpdk/{}/app/testpmd -c {} -n 4 --master-lcore={} --socket-mem=1024,1024 --file-prefix=vf0 -w {} -- -i --txq=2 --rxq=2 \
+              --txd=512 --rxd=512 --nb-cores=2 --rss-ip --eth-peer=0,00:12:34:56:78:02".format(self.dut.target, core_mask_for_vf0, cores_for_vf0[0], self.vf0_port_pci)
+
+        #config the command line for vf0
+        cores_for_vf1 = self.cores[5:8]
+        core_mask_for_vf1 = utils.create_mask(cores_for_vf1)
+        self.cmdline_for_vf1 = "./dpdk/{}/app/testpmd -c {} -n 4 --master-lcore={} --socket-mem=1024,1024 --file-prefix=vf1 -w {} -- -i --txq=2 --rxq=2 \
+              --txd=512 --rxd=512 --rss-ip --nb-cores=2".format(self.dut.target, core_mask_for_vf1, cores_for_vf1[0], self.vf1_port_pci) 
+
+        #start testpmd for pf
+        pf0_pci = self.dut.ports_info[0]['pci']
+        eal_param_1pf = "--socket-mem=1024,1024 --file-prefix=pf -w {}".format(self.pf_pci0)
+        cores_1pf = self.cores[0:2]
+        self.testpmd_1pf = PmdOutput(self.dut)
+        out = self.testpmd_1pf.start_testpmd(cores_1pf, eal_param=eal_param_1pf, socket=self.socket)
+        print out
+
+        # set vf MACs 
+        self.testpmd_1pf.execute_cmd("set vf mac addr 0 0 %s" % self.vf_mac0)
+        self.testpmd_1pf.execute_cmd("set vf mac addr 0 1 %s" % self.vf_mac1)
+
+        self.env_1pf2vf_done = True
+
+    def check_env_2pf2vf(self):
+        '''
+        check if enviroment for 2pf 2vf is ready
+        '''
+        if self.env_1pf2vf_done == True:
+            self.destory_1pf2vf()
+
+        if self.env_2pf2vf_done == True:
+            pass
+        else:
+            self.set_2pf2vf_env()
+
+    def check_env_1pf2vf(self):
+        '''
+        check if enviroment for 1pf 2vf is ready
+        '''
+        if self.env_2pf2vf_done == True:
+            self.destory_2pf2vf()
+
+        if self.env_1pf2vf_done == True:
+            pass
+        else:
+            self.set_1pf2vf_env()
+
+    def send_check_packet(self, pktType='UDP', dstMac='', pktLength=64, pktCount=10, VID=100):
+        '''
+        send configed packets and check received packet number
+        '''
+        self.logger.info("sending %s packets" % pktCount)
+
+        payload = pktLength - HEADER_SIZE['eth'] - HEADER_SIZE['ip'] - HEADER_SIZE['udp']
+        pkt = Packet(pkt_type=pktType)
+        pkt.config_layer('ether', {'dst': dstMac})
+        if pktType == "VLAN_UDP":
+            pkt.config_layer('vlan', {'vlan': VID})
+            #4 bype header size for vlan overhead
+            payload = payload - 4
+        pkt.config_layer('ipv4', {'dst': '2.1.1.1'})
+        pkt.config_layer('raw', {'payload': ['58'] * payload})
+        inst = sniff_packets(self.rx_interface, timeout=5)
+        pkt.send_pkt(tx_port=self.tx_interface, count=pktCount)
+        pkts = load_sniff_packets(inst)
+
+        self.logger.info("received %d packets" % len(pkts))
+        
+        return (len(pkts), pkts)
+
+    def destroy_2pf2vf(self):
+        try:
+            getattr(self, "vf0_port", None)
+            self.dut.destroy_sriov_vfs_by_port(self.dut_ports[0])
+            getattr(self, "vf1_port", None)
+            self.dut.destroy_sriov_vfs_by_port(self.dut_ports[1])
+        except Exception as e:
+            self.logger.info(e)
+
+        self.env_2pf2vf_done = False
+
+    def destroy_1pf2vf(self):
+        try:
+            getattr(self, "vf_port[0]", None) or getattr(self, "vf_port[1]", None) 
+            self.dut.destroy_sriov_vfs_by_port(self.dut_ports[0])
+        except Exception as e:
+            self.logger.info(e)
+
+        self.env_1pf2vf_done = False
+
+    def destroy_vf(self):
+        self.destroy_2pf2vf()
+        self.destroy_1pf2vf()
+
+    def test_a_basic_rxtx(self):
+        self.check_env_2pf2vf()
+
+        vf_pci_writelist = "-w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        commandline = self.cmdline_2vf.replace("replacement", vf_pci_writelist)
+        print commandline
+        out = self.dut.send_expect(commandline, "testpmd> ", alt_session=True)
+        print out
+        self.logger.info("Sending 10 packets")
+        self.dut.send_expect("set promisc all on", "testpmd> ", alt_session=True)
+        self.dut.send_expect("start", "testpmd> ", alt_session=True)
+
+        pkt = Packet(pkt_type='UDP')
+        pkt.config_layer('ether', {'dst': self.vf_mac0})
+        inst = sniff_packets(self.rx_interface, timeout=5)
+        pkt.send_pkt(tx_port=self.tx_interface, count=10)
+        pkts = load_sniff_packets(inst)
+        print len(pkts)
+        self.dut.send_expect("quit", "# ", alt_session=True)
+        self.verify(len(pkts) == 10, "Packets Receive Error")
+ 
+    def test_b_unicast(self):
+        self.check_env_2pf2vf()
+
+        vf_pci_writelist = "-w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        commandline = self.cmdline_2vf.replace("replacement", vf_pci_writelist)
+        print commandline
+        out = self.dut.send_expect(commandline, "testpmd> ", alt_session=True)
+        print out
+        self.dut.send_expect("set promisc all off", "testpmd> ", alt_session=True)
+        self.dut.send_expect("set allmulti all off", "testpmd> ", alt_session=True)
+        self.dut.send_expect("start", "testpmd> ", alt_session=True)
+
+        self.logger.info("Testing Unicast Packets")
+        self.logger.info("Sending 10 packets with vf0 mac")
+        pkt = Packet(pkt_type='UDP')
+        pkt.config_layer('ether', {'dst': self.vf_mac0})
+        inst = sniff_packets(self.rx_interface, timeout=5)
+        pkt.send_pkt(tx_port=self.tx_interface, count=10)
+        pkts = load_sniff_packets(inst)
+        self.logger.info("Recieved %d packets" % len(pkts))
+        try:
+            self.verify(len(pkts) == 10, "Not Expected Packet Number")
+        except:
+            pass
+
+        self.logger.info("Sending 10 packets with other mac")
+        pkt = Packet(pkt_type='UDP')
+        pkt.config_layer('ether', {'dst': "11:22:33:44:55:66"})
+        inst = sniff_packets(self.rx_interface, timeout=5)
+        pkt.send_pkt(tx_port=self.tx_interface, count=10)
+        pkts = load_sniff_packets(inst)
+        self.logger.info("Recieved %d packets" % len(pkts))
+        try:
+            self.verify(len(pkts) == 0, "Not Expected Packet Number")
+        except Exception as e:
+            rasie (e)
+        finally:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+
+    def test_c_multicast(self):
+        self.check_env_2pf2vf()
+
+        vf_pci_writelist = "-w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        commandline = self.cmdline_2vf.replace("replacement", vf_pci_writelist)
+        print commandline
+        out = self.dut.send_expect(commandline, "testpmd> ", alt_session=True)
+        print out
+        # test multicast packets 
+        self.logger.info("Testing Multicast packets")
+        self.dut.send_expect("set promisc all off", "testpmd> ", alt_session=True)
+        self.dut.send_expect("set allmulti all on", "testpmd> ", alt_session=True)
+        self.dut.send_expect("start", "testpmd> ", alt_session=True)
+
+        #send 10 multicast packets, and forward 10 packets
+        self.logger.info("Sending 10 multicast packets")
+        pkt = Packet(pkt_type='UDP')
+        pkt.config_layer('ether', {'dst': "01:80:C2:00:00:08"})
+        inst = sniff_packets(self.rx_interface, timeout=5)
+        pkt.send_pkt(tx_port=self.tx_interface, count=10)
+        pkts = load_sniff_packets(inst)
+        self.logger.info("Recieved %d packets" % len(pkts))
+        try:
+            self.verify(len(pkts) == 10, "Not Expected Packet Number")
+        except:
+            pass
+
+        # disable multicase
+        self.dut.send_expect("stop", "testpmd>", alt_session=True)
+        self.dut.send_expect("set allmulti all off", "testpmd> ", alt_session=True)
+        self.dut.send_expect("start", "testpmd> ", alt_session=True)
+
+        self.logger.info("Sending 10 multicast packets")
+        pkt = Packet(pkt_type='UDP', pktLength=100)
+        pkt.config_layer('ether', {'dst': "01:80:C2:00:00:08"})
+        inst = sniff_packets(self.rx_interface, timeout=5)
+        pkt.send_pkt(tx_port=self.tx_interface, count=10)
+        pkts = load_sniff_packets(inst)
+        self.logger.info("Recieved %d packets" % len(pkts))
+        print len(pkts)
+        try:
+            self.verify(len(pkts) == 0, "Not Expected Packet Number")
+        except Exception as e:
+            raise (e)
+        finally:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+
+    def test_d_broadcast(self):
+        self.check_env_2pf2vf()
+
+        vf_pci_writelist = "-w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        commandline = self.cmdline_2vf.replace("replacement", vf_pci_writelist)
+        print commandline
+
+        out = self.dut.send_expect(commandline, "testpmd> ", alt_session=True)
+        print out
+ 
+        self.dut.send_expect("set promisc all off", "testpmd> ", alt_session=True)
+        self.dut.send_expect("start", "testpmd> ", alt_session=True)
+
+        # test broadcast packets
+        self.logger.info("Testing Broadcast packet")
+        self.logger.info("Sending 10 broadcast packets")
+
+        pkt = Packet(pkt_type='UDP')
+        pkt.config_layer('ether', {'dst': "ff:ff:ff:ff:ff:ff"})
+        inst = sniff_packets(self.rx_interface, timeout=5)
+        pkt.send_pkt(tx_port=self.tx_interface, count=10)
+        pkts = load_sniff_packets(inst)
+        self.logger.info("Recieved %d packets" % len(pkts))
+        print len(pkts)
+        try:
+            self.verify(len(pkts) == 10, "Not Expected Packet Number")
+        except Exception as e:
+            raise (e)
+        finally:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+
+    def test_e_vf_vlan_filter(self):
+        self.check_env_2pf2vf()
+        vf_pci_writelist = "-w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        commandline = self.cmdline_2vf.replace("replacement", vf_pci_writelist)
+        print commandline
+
+        out = self.dut.send_expect(commandline, "testpmd> ", alt_session=True)
+        print out
+
+        self.dut.send_expect("port stop all", "testpmd> ", alt_session=True)
+        self.dut.send_expect("set promisc all off", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set filter off 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set filter off 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set strip off 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set strip off 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set filter on 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("port start all", "testpmd> ", alt_session=True)
+        self.dut.send_expect("start", "testpmd> ", alt_session=True)
+
+        #send 10 vlan tagged packets,and cat't forward the packets
+        rec_packets, _ = self.send_check_packet(pktType="VLAN_UDP", dstMac=self.vf_mac0, pktLength=100, VID=200)
+        self.verify(rec_packets == 0, "Not Expected Packets")
+
+        #send 10 untagged packets,and forward the packets
+        rec_packets, _ = self.send_check_packet(pktType="UDP", dstMac=self.vf_mac0, pktLength=100)
+        try:
+            self.verify(rec_packets == 10, "Not Expected Packets")
+        except Exception as e:
+            rasie (e)
+        finally:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+
+    def test_f_vf_rx_vlan(self):
+        self.check_env_2pf2vf()
+        vf_pci_writelist = "-w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        commandline = self.cmdline_2vf.replace("replacement", vf_pci_writelist)
+        print commandline
+
+        out = self.dut.send_expect(commandline, "testpmd> ", alt_session=True)
+        print out
+
+        out = self.dut.send_expect("port stop all", "testpmd> ", alt_session=True)
+        print out
+        out = self.dut.send_expect("set promisc all off", "testpmd> ", alt_session=True)
+        print out
+        out = self.dut.send_expect("vlan set filter off 0", "testpmd> ", alt_session=True)
+        print out 
+        self.dut.send_expect("vlan set filter off 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set strip off 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set strip off 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set filter on 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("rx_vlan add 20 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("set fwd mac", "testpmd> ", alt_session=True)
+        out = self.dut.send_expect("port start all", "testpmd> ", alt_session=True)
+        print out
+        out = self.dut.send_expect("start", "testpmd> ", alt_session=True)
+        print out
+
+        try:
+            #send 10 vid20 tagged packets,and can forward the packets
+            try:
+                rec_packets, _ = self.send_check_packet(pktType="VLAN_UDP", dstMac=self.vf_mac0, pktLength=100, VID=20)
+                self.verify(rec_packets == 10, "Not Expected Packets")
+            except Exception as e:
+                raise (e)
+
+            #send 10 vid200 tagged packets,and can't forward the packets
+            try:
+                rec_packets, _ = self.send_check_packet(pktType="VLAN_UDP", dstMac=self.vf_mac0, pktLength=100, VID=200)
+                self.verify(rec_packets == 0, "Not Expected Packets")
+            except Exception as e:
+                raise (e)
+
+            #send 10 vid0 tagged packets,and can forward the packets
+            try:
+                rec_packets, _ = self.send_check_packet(pktType="VLAN_UDP", dstMac=self.vf_mac0, pktLength=100, VID=0)
+                self.verify(rec_packets == 10, "Not Expected Packets")
+            except Exception as e:
+                raise (e)
+        except Exception as e:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+            raise (e)
+        else:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+
+    def test_g_vf_tx_vlan(self):
+        self.check_env_2pf2vf()
+        vf_pci_writelist = "-w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        commandline = self.cmdline_2vf.replace("replacement", vf_pci_writelist)
+        print commandline
+
+        out = self.dut.send_expect(commandline, "testpmd> ", alt_session=True)
+        print out
+
+        self.dut.send_expect("port stop all", "testpmd> ", alt_session=True)
+        self.dut.send_expect("set promisc all on", "testpmd> ", alt_session=True)
+        self.dut.send_expect("set fwd mac", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set filter off 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set filter off 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set strip off 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set strip off 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("tx_vlan set 1 20", "testpmd> ", alt_session=True)
+        self.dut.send_expect("port start all", "testpmd> ", alt_session=True)
+        self.dut.send_expect("start", "testpmd> ", alt_session=True)
+
+        #send 10 untagged packets,and check 10 tagged packets received
+        rec_packets, packets = self.send_check_packet(pktType="UDP", dstMac=self.vf_mac0, pktLength=64)
+
+        try:
+            self.verify(rec_packets == 10, "Not Expected Packets")
+        except Exception as e:
+            raise (e)
+        finally:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+
+        payload = strip_pktload(packets[0], "L2")
+        print(payload)
+
+    def test_h_vlan_strip(self):
+        self.check_env_2pf2vf()
+        vf_pci_writelist = "-w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        commandline = self.cmdline_2vf.replace("replacement", vf_pci_writelist)
+        print commandline
+
+        out = self.dut.send_expect(commandline, "testpmd> ", alt_session=True)
+        print out
+
+        self.dut.send_expect("port stop all", "testpmd> ", alt_session=True)
+        self.dut.send_expect("set promisc all on", "testpmd> ", alt_session=True)
+        self.dut.send_expect("set fwd mac", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set filter off 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set filter off 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set strip off 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set strip off 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set strip on 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("port start all", "testpmd> ", alt_session=True)
+        self.dut.send_expect("start", "testpmd> ", alt_session=True)
+
+        #send 10 tagged packets,and check 10 untagged packets received
+        rec_packets, packets = self.send_check_packet(pktType="UDP", dstMac=self.vf_mac0, pktLength=64, VID=100)
+
+        try:
+            self.verify(rec_packets == 10, "Not Expected Packets")
+        except Exception as e:
+            raise (e)
+        finally:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+
+        payload = strip_pktload(packets[0], "L2")
+        print(payload)
+
+    def test_i_vlan_promisc(self):
+        self.check_env_2pf2vf()
+        vf_pci_writelist = "-w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        commandline = self.cmdline_2vf.replace("replacement", vf_pci_writelist)
+        print commandline
+
+        out = self.dut.send_expect(commandline, "testpmd> ", alt_session=True)
+        print out
+
+        self.dut.send_expect("port stop all", "testpmd> ", alt_session=True)
+        self.dut.send_expect("set promisc all on", "testpmd> ", alt_session=True)
+        self.dut.send_expect("set fwd mac", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set filter off 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set filter off 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set strip off 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("vlan set strip off 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("port start all", "testpmd> ", alt_session=True)
+        self.dut.send_expect("start", "testpmd> ", alt_session=True)
+
+        #send 10 tagged packets,and check 10 tagged packets received
+        rec_packets, packets = self.send_check_packet(pktType="UDP", dstMac=self.vf_mac0, pktLength=64, VID=100)
+        try:
+            self.verify(rec_packets == 10, "Not Expected Packets")
+        except Exception as e:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+            raise (e)
+
+        #send 10 untagged packets,and check 10 untagged packets received
+        rec_packets, packets = self.send_check_packet(pktType="UDP", dstMac=self.vf_mac0, pktLength=64)
+        try:
+            self.verify(rec_packets == 10, "Not Expected Packets")
+        except Exception as e:
+            raise (e)
+        finally:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+
+    def test_j_vf_no_jumbo(self):
+        self.check_env_2pf2vf()
+
+        vf_pci_writelist = "-w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        commandline = self.cmdline_2vf.replace("replacement", vf_pci_writelist)
+        print commandline
+
+        out = self.dut.send_expect(commandline, "testpmd> ", alt_session=True)
+        print out
+
+        self.dut.send_expect("set fwd mac", "testpmd> ", alt_session=True)
+        self.dut.send_expect("start", "testpmd> ", alt_session=True)
+
+        # set tester port mtu
+        self.tester.send_expect("ifconfig %s mtu %d" % (self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0])), 9000), "# ")
+        self.tester.send_expect("ifconfig %s mtu %d" % (self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1])), 9000), "# ")
+
+        #send 10 1518 size  packets,and check 10 packets received
+        rec_packets, _ = self.send_check_packet(pktType="UDP", dstMac=self.vf_mac0, pktLength=1518)
+        try:
+            self.verify(rec_packets == 10, "Not Expected Packets")
+        except Exception as e:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+            raise (e)
+
+        #send 10 1519 size  packets,and check 0 packets received
+        rec_packets, _ = self.send_check_packet(pktType="UDP", dstMac=self.vf_mac0, pktLength=1519)
+        try:
+            self.verify(rec_packets == 0, "Not Expected Packets")
+        except Exception as e:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+            raise (e)
+        finally:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+
+    def test_k_vf_normal_jumbo(self):
+
+        self.check_env_2pf2vf()
+
+        vf_pci_writelist = "-w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        commandline = self.cmdline_2vf.replace("replacement", vf_pci_writelist)
+        commandline += " --max-pkt-len=3000 --tx-offloads=0x8000"
+        print commandline
+
+        out = self.dut.send_expect(commandline, "testpmd> ", alt_session=True)
+        print out
+
+        self.dut.send_expect("set fwd mac", "testpmd> ", alt_session=True)
+        self.dut.send_expect("start", "testpmd> ", alt_session=True)
+
+        # set tester port mtu
+        self.tester.send_expect("ifconfig %s mtu %d" % (self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0])), 9000), "# ")
+        self.tester.send_expect("ifconfig %s mtu %d" % (self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1])), 9000), "# ")
+
+        #send 10 1518 size  packets,and check 10 packets received
+        rec_packets, _ = self.send_check_packet(pktType="UDP", dstMac=self.vf_mac0, pktLength=1518)
+        try:
+            self.verify(rec_packets == 10, "Not Expected Packets")
+        except Exception as e:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+            raise (e)
+
+        #send 10 1519 size  packets,and check 0 packets received
+        rec_packets, _ = self.send_check_packet(pktType="UDP", dstMac=self.vf_mac0, pktLength=1519)
+        try:
+            self.verify(rec_packets == 10, "Not Expected Packets")
+        except Exception as e:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+            raise (e)
+        finally:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+
+    def validate_checksum_packet(self):
+        checksum_error_packets = {'IP/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IP(chksum=0x0)/UDP(chksum=0xf)/("X"*46)' % self.vf_mac0,
+                      'IP/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IP(chksum=0x0)/TCP(chksum=0xf)/("X"*46)' % self.vf_mac0,
+		      'IP/SCTP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IP(chksum=0x0)/SCTP(chksum=0xf)/("X"*48)' % self.vf_mac0,
+                      'IPv6/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="::1")/UDP(chksum=0xf)/("X"*46)' % self.vf_mac0,
+                      'IPv6/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="::1")/TCP(chksum=0xf)/("X"*46)' % self.vf_mac0}
+
+        normal_packets = {'IP/UDP': 'Ether(dst="02:00:00:00:00:00", src="%s")/IP(src="127.0.0.1")/UDP()/("X"*46)' % self.vf_mac0,
+                'IP/TCP': 'Ether(dst="02:00:00:00:00:00", src="%s")/IP(src="127.0.0.1")/TCP()/("X"*46)' % self.vf_mac0,
+                'IP/SCTP': 'Ether(dst="02:00:00:00:00:00", src="%s")/IP(src="127.0.0.1")/SCTP()/("X"*48)' % self.vf_mac0,
+                'IPv6/UDP': 'Ether(dst="02:00:00:00:00:00", src="%s")/IPv6(src="::1")/UDP()/("X"*46)' % self.vf_mac0,
+                'IPv6/TCP': 'Ether(dst="02:00:00:00:00:00", src="%s")/IPv6(src="::1")/TCP()/("X"*46)' % self.vf_mac0}
+
+        normal_checksum_values = {}
+        checksum_pattern = re.compile("chksum.*=.*(0x[0-9a-z]+)")
+        self.tester.send_expect("scapy", ">>> ")
+        for packet in normal_packets:
+            self.tester.send_expect("p = %s" % normal_packets[packet], ">>>")
+            out = self.tester.send_expect("p.show2()", ">>>")
+            chksums = checksum_pattern.findall(out)
+            if chksums:
+                normal_checksum_values[packet] = chksums
+        self.tester.send_expect("exit()", "#")
+        for index in normal_checksum_values:
+            self.logger.info("Good checksum value for %s Packet is: %s" % (index, normal_checksum_values[index]))
+        
+        # sends checksum error packets and check if the checksum fields were corrected
+        corrected_checksum_values = {}
+        for packet in checksum_error_packets:
+            inst = sniff_packets(self.rx_interface, timeout=5)
+            self.tester.scapy_foreground()
+            self.tester.scapy_append('sendp([%s], iface="%s")' % (checksum_error_packets[packet], self.tx_interface))
+            self.tester.scapy_execute()
+            rec_pkt = load_sniff_packets(inst)
+            # collect checksum values for received packet
+            chksum = rec_pkt[0].pktgen.pkt.sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%").split(";")
+            chksum = list(set(chksum))
+            chksum.remove("??")
+            corrected_checksum_values[packet] = chksum
+
+        for packet in corrected_checksum_values:
+            self.logger.info("Corrected checksum value for %s Packet is: %s" % (packet, corrected_checksum_values[packet]))
+
+        # check if the corrected checksum vaules are same with the normal packets checksum values
+        for packet in normal_packets:
+            #set_trace()
+            corrected_checksum_values[packet].sort()
+            normal_checksum_values[packet].sort()
+            self.verify(corrected_checksum_values[packet] == normal_checksum_values[packet], \
+                         "Unxpected Checksum Error For Packet %s" % packet)
+
+    def test_l_vf_checksum_sw(self):
+        self.check_env_2pf2vf()
+
+        vf_pci_writelist = "-w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        commandline = self.cmdline_2vf.replace("replacement", vf_pci_writelist)
+        print commandline
+
+        out = self.dut.send_expect(commandline, "testpmd> ", alt_session=True)
+        print out
+
+        self.dut.send_expect("port stop all", "testpmd> ", alt_session=True)
+        self.dut.send_expect("csum set ip sw 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("csum set udp sw 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("csum set tcp sw 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("csum set sctp sw 0", "testpmd> ", alt_session=True)
+
+        self.dut.send_expect("csum set ip sw 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("csum set udp sw 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("csum set tcp sw 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("csum set sctp sw 1", "testpmd> ", alt_session=True)
+
+        self.dut.send_expect("set fwd csum", "testpmd> ", alt_session=True)
+        self.dut.send_expect("set verbose 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("port start all", "testpmd> ", alt_session=True)
+        self.dut.send_expect("start", "testpmd> ", alt_session=True)
+
+        try:
+            self.validate_checksum_packet()
+        except Exception as e:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+            raise Exception(e)
+        else:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+
+    def test_m_vf_checksum_hw(self):
+        self.check_env_2pf2vf()
+
+        vf_pci_writelist = "-w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        commandline = self.cmdline_2vf.replace("replacement", vf_pci_writelist)
+        print commandline
+
+        out = self.dut.send_expect(commandline, "testpmd> ", alt_session=True)
+        print out
+
+        self.dut.send_expect("port stop all", "testpmd> ", alt_session=True)
+        self.dut.send_expect("csum set ip hw 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("csum set udp hw 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("csum set tcp hw 0", "testpmd> ", alt_session=True)
+        self.dut.send_expect("csum set sctp hw 0", "testpmd> ", alt_session=True)
+
+        self.dut.send_expect("csum set ip hw 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("csum set udp hw 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("csum set tcp hw 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("csum set sctp hw 1", "testpmd> ", alt_session=True)
+
+        self.dut.send_expect("set fwd csum", "testpmd> ", alt_session=True)
+        self.dut.send_expect("set verbose 1", "testpmd> ", alt_session=True)
+        self.dut.send_expect("port start all", "testpmd> ", alt_session=True)
+        self.dut.send_expect("start", "testpmd> ", alt_session=True)
+
+        try:
+            self.validate_checksum_packet()
+        except Exception as e:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+            raise Exception(e)
+        else:
+            self.dut.send_expect("quit", "# ", alt_session=True)
+
+    def test_n_rx_interrupt(self):
+
+        self.check_env_2pf2vf()
+        self.dut.send_expect("modprobe vfio-pci", "", alt_session=True)
+
+        app_to_make = "make -C dpdk/examples/l3fwd-power RTE_SDK=/root/dpdk T=%s" % self.target
+        out = self.dut.send_expect(app_to_make, "# ", alt_session=True)
+        print out
+
+        self.vf0_port[0].bind_driver("vfio-pci")
+        self.vf1_port[0].bind_driver("vfio-pci")
+
+        vf_pci_writelist = " -w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        interrupt_app_cmd = "./dpdk/examples/l3fwd-power/build/l3fwd-power -l %s,%s -n 4" % (self.cores[5], self.cores[6])
+        interrupt_app_cmd += vf_pci_writelist
+        interrupt_app_cmd += " -- -p 0x3 --config '(0,0,%s),(1,0,%s)'" % (self.cores[5], self.cores[6])
+        print interrupt_app_cmd 
+        out = self.dut.send_expect(interrupt_app_cmd, "", alt_session=True)
+        print out
+
+        rec_packets, _  = self.send_check_packet(dstMac=self.vf_mac0, pktCount=10)
+        try:
+            self.verify(rec_packets==10, "Packets Receive Error")
+        except Exception as e:
+            self.dut.send_expect("^c", "# ", alt_session=True)
+            raise (e)
+        #self.dut.send_expect("^c", "# ", alt_session=True)
+
+    def test_perf_veb_performance(self):
+        self.check_env_1pf2vf()
+
+        print self.cmdline_for_vf0 
+        out = self.dut.send_expect(self.cmdline_for_vf0, "testpmd> ", alt_session=True)
+        print out
+        out = self.dut.send_expect("set promisc all on", "testpmd> ", alt_session=True)
+        print out
+        out = self.dut.send_expect("set fwd mac", "testpmd> ", alt_session=True)
+        print out
+        out = self.dut.send_expect("start", "testpmd> ", alt_session=True)
+        print out
+        
+        self.vf1_session = self.dut.create_session(name='vf1')
+        self.vf1_session.send_expect(self.cmdline_for_vf1, "testpmd> ")
+        self.vf1_session.send_expect("set promisc all on", "testpmd> ")
+        self.vf1_session.send_expect("set fwd mac", "testpmd> ")
+        self.vf1_session.send_expect("start", "testpmd> ")
+
+        perf_test_pass = self.perf_test(veb=True)
+        
+        self.dut.send_expect("quit", "# ", alt_session=True)
+        self.vf1_session.send_expect("quit", "# ")
+        self.dut.destroy_session("vf1")
+
+        self.verify(perf_test_pass == 0, "Traffic Blocked")
+        
+    def test_perf_vector_vf_performance(self):
+        self.check_env_2pf2vf()
+
+        out = self.dut.send_expect("sed -i -e 's/CONFIG_RTE_LIBRTE_AVF_INC_VECTOR=.*$/CONFIG_RTE_LIBRTE_AVF_INC_VECTOR=y/g'  config/common_base", "# ")
+        print out
+        out = self.dut.send_expect("rm -fr %s" % self.target, "# ", alt_session=True)
+        print out
+        out = self.dut.send_expect("make -j install T=%s" % self.target, "# ", alt_session=True)
+        print out
+
+        self.vf_performance()
+
+    def test_perf_scalar_vf_performance(self):
+        
+        out = self.dut.send_expect("sed -i -e 's/CONFIG_RTE_LIBRTE_AVF_INC_VECTOR=.*$/CONFIG_RTE_LIBRTE_AVF_INC_VECTOR=n/g'  config/common_base", "# ") 
+        print out
+        out = self.dut.send_expect("rm -fr %s" % self.target, "# ", alt_session=True)
+        print out
+        set_trace()
+        out = self.dut.send_expect("make -j install T=%s" % self.target, "# ", alt_session=True)
+        print out
+
+        self.check_env_2pf2vf()
+        self.vf_performance()
+
+    def vf_performance(self):
+
+        #self.check_env_2pf2vf()
+
+        vf_pci_writelist = "-w {} -w {}".format(self.vf0_port_pci, self.vf1_port_pci)
+        commandline = self.cmdline_2vf.replace("replacement", vf_pci_writelist)
+        commandline += " --txd=512 --rxd=512 --rss-ip"
+        print commandline
+        out = self.dut.send_expect(commandline, "testpmd> ", alt_session=True)
+        print out
+        out = self.dut.send_expect("set promisc all on", "testpmd> ", alt_session=True)
+        print out
+        out = self.dut.send_expect("set fwd mac", "testpmd> ", alt_session=True)
+        print out
+        out = self.dut.send_expect("start", "testpmd> ", alt_session=True)
+        print out
+        perf_test_pass = self.perf_test()
+       
+        self.dut.send_expect("quit", "# ", alt_session=True)
+        self.verify(perf_test_pass == 0, "Traffic Blocked")
+        
+    def perf_test(self, veb=False):
+         
+        tgen_input = []
+        if veb:
+            tgen_input.append((self.tester.get_local_port(self.dut_ports[0]),
+                           self.tester.get_local_port(self.dut_ports[0]),
+                           "test1.pcap"))
+        else:
+            tgen_input.append((self.tester.get_local_port(self.dut_ports[0]),
+                           self.tester.get_local_port(self.dut_ports[1]),
+                           "test1.pcap"))
+            tgen_input.append((self.tester.get_local_port(self.dut_ports[1]),
+                               self.tester.get_local_port(self.dut_ports[0]),
+                               "test2.pcap"))
+        test_cycle = {}
+        test_cycle['Mpps'] = {}
+        test_cycle["pct"] = {}
+
+        for frame_size in self.frame_sizes:
+            self.logger.info("Running with frame size %d " % frame_size)
+
+            wirespeed = self.wirespeed(self.nic, frame_size, 2)
+            header_size = HEADER_SIZE['eth'] + HEADER_SIZE['ip'] + HEADER_SIZE['tcp']
+            payload_size = frame_size - header_size
+            self.tester.scapy_append(
+                    'wrpcap("test1.pcap", [Ether(dst=%s)/IP(src="1.2.3.4",dst="2.1.1.1")/TCP()/("X"*%d)])' % (self.vf_mac0, payload_size))
+            self.tester.scapy_execute()
+            self.tester.scapy_append(
+                    'wrpcap("test2.pcap", [Ether(dst=%s)/IP(src="1.2.3.4",dst="1.1.1.1")/TCP()/("X"*%d)])' % (self.vf_mac1, payload_size))
+            self.tester.scapy_execute()
+
+            _, pps = self.tester.traffic_generator_throughput(tgen_input, rate_percent=100, delay=60)
+
+            pps /= 1000000.0
+            # check if traffic was blocked
+            if pps == 0:
+                return -1
+            pct = pps * 100 / wirespeed
+            test_cycle['Mpps'][frame_size] = float('%.3f' % pps)
+            test_cycle['pct'][frame_size] = float('%.3f' % pct)
+
+        # print test result
+        table_header = ['frame_size', 'Mpps', 'Line Rate']
+        self.result_table_create(table_header)
+        for frame_size in self.frame_sizes:
+            table_row = [frame_size]
+            table_row.append(test_cycle['Mpps'][frame_size])
+            table_row.append(test_cycle['pct'][frame_size])
+            self.result_table_add(table_row)
+        self.result_table_print()
+        
+        return 0 
+
+    def tear_down(self):
+        """
+        Run after each test case.
+        """
+        # quit testpmd for PF ports
+        self.dut.send_expect("quit", "# ")
+ 
+        self.destroy_vf()
+
+    def tear_down_all(self):
+        """
+        Run after each test suite.
+        """
+        self.dut.send_expect("sed -i -e '/AVF_DEV_ID_ADAPTIVE_VF/s/0x154c/0x1889/g' drivers/net/avf/base/avf_devids.h", "# ")
+        self.dut.send_expect("sed -i -e '/I40E_DEV_ID_VF/s/0x164C/0x154C/g' drivers/net/i40e/base/i40e_devids.h", "# ")
-- 
2.7.4



More information about the dts mailing list