From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 4E48A968 for ; Mon, 26 Jun 2017 04:19:32 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP; 25 Jun 2017 19:19:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,393,1493708400"; d="scan'208";a="1186889316" Received: from unknown (HELO dpdk-fedora20.icx.intel.com) ([10.240.176.135]) by fmsmga002.fm.intel.com with ESMTP; 25 Jun 2017 19:19:31 -0700 From: "xu,gang" To: dts@dpdk.org Cc: "xu,gang" Date: Mon, 26 Jun 2017 10:20:53 +0800 Message-Id: <1498443653-18235-1-git-send-email-gangx.xu@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dts] [PATCH V2] fix issue 2vf_k2d_scapy_stream receive miscellaneous packet X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Jun 2017 02:19:33 -0000 Signed-off-by: xu,gang --- tests/TestSuite_vf_to_vf_nic_bridge.py | 87 +++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 34 deletions(-) diff --git a/tests/TestSuite_vf_to_vf_nic_bridge.py b/tests/TestSuite_vf_to_vf_nic_bridge.py index b890be0..efdb9fb 100644 --- a/tests/TestSuite_vf_to_vf_nic_bridge.py +++ b/tests/TestSuite_vf_to_vf_nic_bridge.py @@ -46,7 +46,9 @@ VF_NUMS_ON_ONE_PF = 2 VF_TEMP_MAC = "52:54:12:45:67:1%d" SEND_PACKET = 100 + class TestVF2VFBridge(TestCase): + def set_up_all(self): self.dut_ports = self.dut.get_ports(self.nic) self.verify(len(self.dut_ports) >= 1, "Insufficient ports") @@ -59,21 +61,23 @@ class TestVF2VFBridge(TestCase): def set_up_vf_to_vf_env(self, driver='default'): self.pf_port_for_vfs = self.dut_ports[0] self.dut.restore_interfaces() - self.dut.generate_sriov_vfs_by_port(self.pf_port_for_vfs, VF_NUMS_ON_ONE_PF, driver=driver) - self.sriov_vfs_ports = self.dut.ports_info[self.pf_port_for_vfs]['vfs_port'] + self.dut.generate_sriov_vfs_by_port( + self.pf_port_for_vfs, VF_NUMS_ON_ONE_PF, driver=driver) + self.sriov_vfs_ports = self.dut.ports_info[ + self.pf_port_for_vfs]['vfs_port'] self.host_port_intf = self.dut.ports_info[self.pf_port_for_vfs]['intf'] for i in range(VF_NUMS_ON_ONE_PF): - self.dut.send_expect('ip link set dev %s vf %d mac %s' % \ - (self.host_port_intf, i, VF_TEMP_MAC % i), '#', 10) + self.dut.send_expect('ip link set dev %s vf %d mac %s' % + (self.host_port_intf, i, VF_TEMP_MAC % i), '#', 10) try: for port in self.sriov_vfs_ports: port.bind_driver('pci-stub') time.sleep(1) except Exception as e: raise Exception(e) - - vf0_prop = {'opt_host' : self.sriov_vfs_ports[0].pci} - vf1_prop = {'opt_host' : self.sriov_vfs_ports[1].pci} + + vf0_prop = {'opt_host': self.sriov_vfs_ports[0].pci} + vf1_prop = {'opt_host': self.sriov_vfs_ports[1].pci} time.sleep(1) self.vm0 = QEMUKvm(self.dut, 'vm0', 'vf_to_vf_bridge') self.vm0.set_vm_device(driver='pci-assign', **vf0_prop) @@ -83,7 +87,7 @@ class TestVF2VFBridge(TestCase): raise Exception('Set up VM0 failed') except Exception as e: print utils.RED(str(e)) - + self.vm1 = QEMUKvm(self.dut, 'vm1', 'vf_to_vf_bridge') self.vm1.set_vm_device(driver='pci-assign', **vf1_prop) try: @@ -92,7 +96,7 @@ class TestVF2VFBridge(TestCase): raise Exception('Set up VM1 failed') except Exception as e: print utils.RED(str(e)) - + def clear_vf_to_vf_env(self): if self.vm0 is not None: self.vm0.stop() @@ -106,7 +110,7 @@ class TestVF2VFBridge(TestCase): port = self.dut.ports_info[self.pf_port_for_vfs]['port'] port.bind_driver() self.pf_port_for_vfs = 0 - + def generate_pcap_pkt(self, dst, src, load, pktname='flow.pcap'): """ dst: @@ -126,20 +130,24 @@ class TestVF2VFBridge(TestCase): length: content length """ context = '[Ether(dst="%s", src="%s")/IP()/Raw(load=%s)]' % \ - (str(dst['ether']), str(src['ether']),load['content']) + (str(dst['ether']), str(src['ether']), load['content']) src['server'].send_expect('scapy', '>>> ', 10) - src['server'].send_expect('wrpcap("%s", %s)'% (pktname, context), '>>> ', 10) + src['server'].send_expect( + 'wrpcap("%s", %s)' % (pktname, context), '>>> ', 10) src['server'].send_expect('quit()', '#', 10) - + def prepare_pktgen(self, vm): vm.session.copy_file_to('./dep/tgen.tgz') vm.send_expect("cd /root", "#", 10) vm.send_expect("tar xvf tgen.tgz", '#', 20) - + def send_stream_pktgen(self, vm, pktname='flow.pcap'): - vm.send_expect("echo 2048 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages", "#", 10) + vm.send_expect( + "echo 2048 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages", "#", 10) vm.send_expect(" mount -t hugetlbfs nodedev /mnt/huge/", "#", 10) - vm.send_expect("./pktgen -c 0xf -n 2 --proc-type auto -- -P -T -m '1.0' -s 0:%s" % pktname, "", 100) + vm.send_expect( + "./pktgen -c 0xf -n 2 --proc-type auto -- -P -T -m '1.0' -s 0:%s" % + pktname, "", 100) time.sleep(60) vm.send_expect("set 0 rate 50", "", 20) time.sleep(5) @@ -152,7 +160,7 @@ class TestVF2VFBridge(TestCase): vm.send_expect("stop all", "", 20) time.sleep(5) vm.send_expect("quit", "#", 20) - + def test_2vf_d2d_pktgen_stream(self): self.vm0_ports = self.vm0_dut.get_ports('any') self.vm0_pmd = PmdOutput(self.vm0_dut) @@ -178,9 +186,10 @@ class TestVF2VFBridge(TestCase): self.stop_stream_pktgen(self.vm1_dut) self.vm0_pmd.execute_cmd('stop') self.vm0_pmd.execute_cmd('quit', '# ') - - self.verify(recv_num is SEND_PACKET,'Rx port recv error: %d' % recv_num) - + + self.verify(recv_num is SEND_PACKET, + 'Rx port recv error: %d' % recv_num) + def test_2vf_d2k_pktgen_stream(self): self.vm0_dut.restore_interfaces() self.vm0_ports = self.vm0_dut.get_ports('any') @@ -198,7 +207,9 @@ class TestVF2VFBridge(TestCase): load = {} load['content'] = "'X'*46" self.generate_pcap_pkt(dst, src, load) - self.vm0_dut.send_expect('tcpdump -i %s -s 1000 "ether src %s and ether dst %s"' % (vf0_intf, src['ether'], dst['ether']), 'tcpdump', 30) + self.vm0_dut.send_expect( + 'tcpdump -i %s -s 1000 "ether src %s and ether dst %s"' % + (vf0_intf, src['ether'], dst['ether']), 'tcpdump', 30) self.send_stream_pktgen(self.vm1_dut) self.stop_stream_pktgen(self.vm1_dut) @@ -209,18 +220,14 @@ class TestVF2VFBridge(TestCase): recv_str = recv_info.group(0).split(' ')[0] recv_number = int(recv_str, 10) self.vm0_dut.bind_interfaces_linux(self.drivername) - - self.verify(recv_number is SEND_PACKET, 'Rx port recv error: %d' % recv_number) - + + self.verify(recv_number is SEND_PACKET, + 'Rx port recv error: %d' % recv_number) + def test_2vf_k2d_scapy_stream(self): self.vm0_ports = self.vm0_dut.get_ports('any') self.vm0_pmd = PmdOutput(self.vm0_dut) self.vm0_pmd.start_testpmd('all') - self.vm0_pmd.execute_cmd('set fwd rxonly') - self.vm0_pmd.execute_cmd('start') - # disable promisc to filter misc packets from tester. - self.vm0_pmd.execute_cmd('set promisc all off') - self.vm0_pmd.execute_cmd('clear port stats all') self.vm1_ports = self.vm1_dut.get_ports('any') self.vm1_dut.restore_interfaces() @@ -231,17 +238,29 @@ class TestVF2VFBridge(TestCase): pkt_content = 'Ether(dst="%s", src="%s")/IP()/Raw(load="X"*46)' % \ (dst_mac, src_mac) self.vm1_dut.send_expect('scapy', '>>> ', 10) - self.vm1_dut.send_expect('sendp([%s], iface="%s", count=%d)' % (pkt_content, vf1_intf, SEND_PACKET), '>>> ', 30) + + self.vm0_pmd.execute_cmd('set promisc all off') + self.vm0_pmd.execute_cmd('set fwd rxonly') + self.vm0_pmd.execute_cmd('set verbose 1') + self.vm0_pmd.execute_cmd('start') + + self.vm1_dut.send_expect('sendp([%s], iface="%s", count=%d)' % + (pkt_content, vf1_intf, SEND_PACKET), '>>> ', 30) + + out = self.vm0_dut.get_session_output(timeout=60) + rx_packets = re.findall("src=%s - dst=%s" % (src_mac, dst_mac), out) + recv_num = len(rx_packets) + self.vm1_dut.send_expect('quit()', '# ', 10) self.vm1_dut.bind_interfaces_linux(self.drivername) - recv_num = self.vm0_pmd.get_pmd_stats(0)['RX-packets'] self.vm0_pmd.execute_cmd('stop') self.vm0_pmd.execute_cmd('quit', '# ') - self.verify(recv_num is SEND_PACKET, 'Rx port recv error: %d' % recv_num) - + self.verify(recv_num is SEND_PACKET, + 'Rx port recv error: %d' % recv_num) + def tear_down(self): self.clear_vf_to_vf_env() - + def tear_down_all(self): pass -- 1.9.3