From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 22556271 for ; Fri, 2 Mar 2018 08:49:30 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Mar 2018 23:49:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,411,1515484800"; d="scan'208";a="24539381" Received: from unknown (HELO dpdk-fedora20.icx.intel.com) ([10.240.176.135]) by fmsmga002.fm.intel.com with ESMTP; 01 Mar 2018 23:49:28 -0800 From: Peng Yuan To: dts@dpdk.org Cc: Peng Yuan Date: Fri, 2 Mar 2018 15:50:42 +0800 Message-Id: <1519977042-67516-1-git-send-email-yuan.peng@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dts] [PATCH] tests: count the number of packet from vf to pf using printing information 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: Fri, 02 Mar 2018 07:49:31 -0000 modify the test_VEB_switching_inter_vfs_and_pf which belongs to TestSuite_veb_switch.py. because pf's status doesn't count the packet from vf which is rooted to itself. Signed-off-by: Peng Yuan diff --git a/tests/TestSuite_veb_switch.py b/tests/TestSuite_veb_switch.py index c1953e2..0dc570a 100644 --- a/tests/TestSuite_veb_switch.py +++ b/tests/TestSuite_veb_switch.py @@ -37,6 +37,7 @@ Test VEB Switch and floating VEB Features by Poll Mode Drivers. import re import time +import utils from virt_dut import VirtDut from project_dpdk import DPDKdut @@ -67,7 +68,7 @@ class TestVEBSwitching(TestCase): 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:" @@ -100,7 +101,6 @@ class TestVEBSwitching(TestCase): else: return None - def veb_get_pmd_value(self, prefix, out): pattern = re.compile(prefix + "(\s+)([0-9]+)") m = pattern.search(out) @@ -127,9 +127,8 @@ class TestVEBSwitching(TestCase): 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. @@ -141,14 +140,14 @@ class TestVEBSwitching(TestCase): 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) @@ -209,9 +208,9 @@ class TestVEBSwitching(TestCase): 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 + 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 --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>") @@ -224,18 +223,18 @@ class TestVEBSwitching(TestCase): self.dut.send_expect("start", "testpmd>", 5) time.sleep(2) - self.dut.send_expect("stop", "testpmd>", 5) + 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") + 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 + 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') @@ -262,7 +261,7 @@ class TestVEBSwitching(TestCase): def test_VEB_switching_inter_vfs_vlan(self): """ - Kernel PF, then create 2VFs, assign VF1 with VLAN=1 in, VF2 with + 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 @@ -331,29 +330,47 @@ class TestVEBSwitching(TestCase): 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 verbose 1", "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 --eth-peer=0,%s" % (self.target, self.sriov_vfs_port[0].pci, self.pf_mac_address), "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>") self.session_secondary.send_expect("start", "testpmd>") time.sleep(2) - + # print the packets which received by pf, this caused most packets missed. + out = self.dut.get_session_output(timeout=1) self.session_secondary.send_expect("stop", "testpmd>", 2) self.dut.send_expect("stop", "testpmd>", 2) - + lines = out.split("\r\n") + cnt = 0 + count_pkt = 0 + # count the packet received by pf from vf. + for line in lines: + line = line.strip() + if len(line) != 0 and line.startswith(("src=",)): + for item in line.split(" "): + item = item.strip() + if(item == ("src=%s" % self.vf0_mac)): + cnt = cnt + 1 + elif(item == "L4_UDP"): + cnt = cnt + 1 + if (cnt == 2): + count_pkt = count_pkt + 1 + cnt = 0 + print utils.GREEN("The number of UDP packets received by pf is %d." % count_pkt) 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.verify(vf0_tx_stats[0] > 0, "no packet was sent by VF0") + self.verify(count_pkt > 0, "no packet was received by PF") self.session_secondary.send_expect("quit", "# ") - time.sleep(2) + time.sleep(2) self.dut.send_expect("quit", "# ") time.sleep(2) - #PF->VF + # 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>") @@ -366,15 +383,12 @@ class TestVEBSwitching(TestCase): 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") + print utils.GREEN("The number of UDP packets received by vf is %d." % vf0_rx_stats[0]) + self.verify(vf0_rx_stats[0] > 0, "no packet was received by VF0") self.session_secondary.send_expect("quit", "# ") time.sleep(2) self.dut.send_expect("quit", "# ") @@ -438,7 +452,7 @@ class TestVEBSwitching(TestCase): 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>") + self.session_secondary.send_expect("start", "testpmd>") time.sleep(2) self.session_secondary.send_expect("stop", "testpmd>", 5) @@ -449,7 +463,6 @@ class TestVEBSwitching(TestCase): 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. @@ -461,7 +474,6 @@ class TestVEBSwitching(TestCase): self.dut.kill_all() - def tear_down_all(self): """ Run after each test suite. @@ -473,4 +485,3 @@ class TestVEBSwitching(TestCase): for port_id in self.dut_ports: port = self.dut.ports_info[port_id]['port'] port.bind_driver(driver=self.drivername) - -- 2.5.0