[dts] [PATCH] tests TSO: Add RRC support and some bug fix

Ding Heng hengx.ding at intel.com
Mon Nov 16 10:25:39 CET 2015


Add RRC support and some bug fix. Use testpmd output to verify the test result
instead of tcpdump, in order to avoid wrong test result caused by it.

Signed-off-by: Mihcael Qiu <michael.qiu at intel.com>
Signed-off-by: Ding Heng <hengx.ding at intel.com>

diff --git a/tests/TestSuite_tso.py b/tests/TestSuite_tso.py
index 5bd8592..94f69df 100644
--- a/tests/TestSuite_tso.py
+++ b/tests/TestSuite_tso.py
@@ -83,7 +83,8 @@ class TestTSO(TestCase):
         # this feature support Fortville, Niantic
         self.verify(self.nic in ["kawela_2", "niantic", "bartonhills", "82545EM",
                                  "82540EM", "springfountain", "fortville_eagle",
-                                 "fortville_spirit", "fortville_spirit_single"],
+                                 "fortville_spirit", "fortville_spirit_single",
+                                 "redrockcanyou"],
                     "NIC Unsupported: " + str(self.nic))
 
         # Based on h/w type, choose how many ports to use
@@ -98,6 +99,7 @@ class TestTSO(TestCase):
         self.ports_socket = self.dut.get_numa_id(self.dut_ports[0])
 
         self.frame_sizes = [128, 1458]
+        self.tso_size = [256, 500, 700, 900]
         self.rxfreet_values = [0, 8, 16, 32, 64, 128]
 
         # self.test_cycles = [{'cores': '1S/1C/1T', 'Mpps': {}, 'pct': {}},
@@ -116,7 +118,7 @@ class TestTSO(TestCase):
         self.blacklist = ""
 
         # self.coreMask = dts.create_mask(cores)
-
+        # This is for ipv4, for ipv6 need addtional 20
         self.headers_size = HEADER_SIZE['eth'] + HEADER_SIZE[
             'ip'] + HEADER_SIZE['tcp']
 
@@ -138,7 +140,7 @@ class TestTSO(TestCase):
 
         for iface in ifaces:
             command = ('tcpdump -w tcpdump_{0}.pcap -i {0} 2>tcpdump_{0}.out &').format(iface)
-            self.tester.send_expect('rm -f tcpdump_{0}.pcap', '#').format(iface)
+            self.tester.send_expect(('rm -f tcpdump_{0}.pcap').format(iface), '#')
             self.tester.send_expect(command, '#')
 
     def tcpdump_stop_sniff(self):
@@ -182,7 +184,7 @@ class TestTSO(TestCase):
         self.verify(cores is not None, "Insufficient cores for speed testing")
         self.coreMask = dts.create_mask(cores)
 
-        padding = self.frame_sizes[0] - self.headers_size
+        padding = [(frame_size - self.headers_size) for frame_size in self.frame_sizes]
 
         self.tester.send_expect("ethtool -K %s rx off tx off tso off gso off gro off lro off" % tx_interface, "# ")
         self.tester.send_expect("ip l set %s up" % tx_interface, "# ")
@@ -204,41 +206,45 @@ class TestTSO(TestCase):
         self.dut.send_expect("csum set outer-ip hw %d" % self.dut_ports[1], "testpmd> ", 120)
         self.dut.send_expect("csum parse_tunnel on %d" % self.dut_ports[1], "testpmd> ", 120)
 
-        self.dut.send_expect("tso set 800 %d" % self.dut_ports[1], "testpmd> ", 120)
-        self.dut.send_expect("set fwd csum", "testpmd> ", 120)
-        self.dut.send_expect("start", "testpmd> ")
 
         self.tester.scapy_foreground()
         time.sleep(5)
+        for tso_s in self.tso_size:
+            self.dut.send_expect("tso set %d %d" % (tso_s, self.dut_ports[1]), "testpmd> ", 120)
+            self.dut.send_expect("set fwd csum", "testpmd> ", 120)
+	    self.dut.send_expect("set promisc all off", "testpmd> ", 120)
+            self.dut.send_expect("start", "testpmd> ")
+            self.dut.send_expect("clear port stats all", "testpmd> ")
+
+            for padd in padding:
+                expect_rx_stats = padd/tso_s + (1 if padd % tso_s else 0)
+                self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1", dst="192.168.1.2")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")'% (mac, padd, tx_interface))
+            	self.dut.send_expect("clear port stats all", "testpmd> ")
+                out = self.tester.scapy_execute()
+                out = self.dut.send_expect("show port stats %s" % self.dut_ports[1], "testpmd> ", 120)
+		rx_stats = int(dts.regexp(out, "TX-packets: ([0-9]+)"))
+                self.verify(rx_stats == expect_rx_stats, "FAIL: For TSO size %d and packet size %d, expect rx stats = %d, but actually received %d" %(tso_s, self.headers_size + padd, expect_rx_stats, rx_stats))
+
+                # IPv6 tcp test
+                expect_rx_stats = (padd -20)/tso_s + (1 if (padd - 20) % tso_s else 0)
+                self.tester.scapy_append('sendp([Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")' % (mac, padd - 20, tx_interface))
+            	self.dut.send_expect("clear port stats all", "testpmd> ")
+                out = self.tester.scapy_execute()
+                out = self.dut.send_expect("show port stats %s" % self.dut_ports[1], "testpmd> ", 120)
+		rx_stats = int(dts.regexp(out, "TX-packets: ([0-9]+)"))
+                self.verify(rx_stats == expect_rx_stats, "FAIL: For TSO size %d and packet size %d, expect rx stats = %d, but actually received %d" %(tso_s, self.headers_size + padd, expect_rx_stats, rx_stats))
 
-        # IPv4 tcp test
-
-        self.tcpdump_start_sniffing([tx_interface, rx_interface])
-        self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")' % (mac, padding, tx_interface))
-        out = self.tester.scapy_execute()
-        out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
-        print out
-        self.tcpdump_stop_sniff()
-        rx_stats = self.number_of_packets(rx_interface)
-        if (rx_stats == 2):
-            self.verify(1, "Pass")
-
-        # IPv6 tcp test
-
-        self.tcpdump_start_sniffing([tx_interface, rx_interface])
-        self.tester.scapy_append('sendp([Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="FE80:0:0:0:200:1FF:FE00:200", dst="3555:5555:6666:6666:7777:7777:8888:8888")/TCP(sport=1021,dport=1021)/("X"*%s)], iface="%s")' % (mac, padding, tx_interface))
-        out = self.tester.scapy_execute()
-        out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
-        print out
-        self.tcpdump_stop_sniff()
-        rx_stats = self.number_of_packets(rx_interface)
-        if (rx_stats == 2):
-            self.verify(1, "Pass")
+            self.dut.send_expect("stop", "testpmd> ")
 
     def test_tso_tunneling(self):
         """
         TSO IPv4 TCP, IPv6 TCP, VXLan testing
         """
+        # RedRockCanyou does not support Tunneling in DPDK yet.
+        if self.nic == "redrockcanyou":
+            print dts.RED("fm10k not support this case\n")
+            return
+
         tx_interface = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
         rx_interface = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1]))
 
@@ -248,7 +254,10 @@ class TestTSO(TestCase):
         self.verify(cores is not None, "Insufficient cores for speed testing")
         self.coreMask = dts.create_mask(cores)
 
-        padding = self.frame_sizes[0] - self.headers_size
+        self.headers_size_vxlan =  self.headers_size + HEADER_SIZE['eth'] + HEADER_SIZE['ip'] + HEADER_SIZE['udp'] + HEADER_SIZE['vxlan']
+        self.headers_size_nvgre = 2 * self.headers_size + HEADER_SIZE['nvgre']
+        padding_vxlan = [(frame_size - self.headers_size_vxlan) for frame_size in self.frame_sizes]
+        padding_nvgre = [(frame_size - self.headers_size_nvgre) for frame_size in self.frame_sizes]
 
         self.tester.send_expect("ethtool -K %s rx off tx off tso off gso off gro off lro off" % tx_interface, "# ")
         self.tester.send_expect("ip l set %s up" % tx_interface, "# ")
@@ -270,34 +279,39 @@ class TestTSO(TestCase):
         self.dut.send_expect("csum set outer-ip hw %d" % self.dut_ports[1], "testpmd> ", 120)
         self.dut.send_expect("csum parse_tunnel on %d" % self.dut_ports[1], "testpmd> ", 120)
 
-        self.dut.send_expect("tso set 800 %d" % self.dut_ports[1], "testpmd> ", 120)
-        self.dut.send_expect("set fwd csum", "testpmd> ", 120)
-        self.dut.send_expect("start", "testpmd> ")
-
         self.tester.scapy_foreground()
         time.sleep(5)
 
-        # Vxlan test
-        self.tcpdump_start_sniffing([tx_interface, rx_interface])
-        self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/UDP(sport="1021",dport="4789")/VXLAN()/Ether(dst=%s,src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport="1021",dport="1021")/("X"*%s)], iface="%s")' % (mac, mac, padding, tx_interface))
-        out = self.tester.scapy_execute()
-        out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
-        print out
-        self.tcpdump_stop_sniff()
-        rx_stats = self.number_of_packets(rx_interface)
-        if (rx_stats == 2):
-            self.verify(1, "Pass")
-
-        # Nvgre test
-        self.tcpdump_start_sniffing([tx_interface, rx_interface])
-        self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2",proto=47)/NVGRE()/Ether(dst=%s,src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport="1021",dport="1021")/("X"*%s)], iface="%s")' % (mac, mac, padding, tx_interface))
-        out = self.tester.scapy_execute()
-        out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
-        print out
-        self.tcpdump_stop_sniff()
-        rx_stats = self.number_of_packets(rx_interface)
-        if (rx_stats == 2):
-            self.verify(1, "Pass")
+        for tso_s in self.tso_size:
+            self.dut.send_expect("tso set %d %d" % (tso_s, self.dut_ports[1]), "testpmd> ", 120)
+            self.dut.send_expect("set fwd csum", "testpmd> ", 120)
+            self.dut.send_expect("set promisc all off", "testpmd> ", 120)
+            self.dut.send_expect("start", "testpmd> ")
+
+            for padd in padding_vxlan:
+                # Vxlan test
+                expect_rx_stats = padd/tso_s + 0 if padd % tso_s else 1
+                self.tcpdump_start_sniffing([tx_interface, rx_interface])
+                self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/UDP(sport="1021",dport="4789")/VXLAN()/Ether(dst=%s,src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport="1021",dport="1021")/("X"*%s)], iface="%s")' % (mac, mac, padd, tx_interface))
+                out = self.tester.scapy_execute()
+                out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
+                self.tcpdump_stop_sniff()
+                rx_stats = self.number_of_packets(rx_interface)
+                self.verify(rx_stats == expect_rx_stats, "FAIL: For TSO size %d and packet size %d, expect rx stats = %d, \
+                                                          but actually received %d" %(tso_s, self.headers_size_vxlan + padd, expect_rx_stats, rx_stats))
+
+            for padd in padding_nvgre:
+                # Nvgre test
+                expect_rx_stats = padd/tso_s + 0 if padd % tso_s else 1
+                #self.tcpdump_start_sniffing([tx_interface, rx_interface])
+                self.tester.scapy_append('sendp([Ether(dst="%s",src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2",proto=47)/NVGRE()/Ether(dst=%s,src="52:00:00:00:00:00")/IP(src="192.168.1.1",dst="192.168.1.2")/TCP(sport="1021",dport="1021")/("X"*%s)], iface="%s")' % (mac, mac, padd, tx_interface))
+                out = self.tester.scapy_execute()
+                out = self.dut.send_expect("show port stats all", "testpmd> ", 120)
+                self.tcpdump_stop_sniff()
+                rx_stats = self.number_of_packets(rx_interface)
+                self.verify(rx_stats == expect_rx_stats, "FAIL: For TSO size %d and packet size %d, expect rx stats = %d, \
+                                                          but actually received %d" %(tso_s, self.headers_size_nvgre + padd, expect_rx_stats, rx_stats))
+            self.dut.send_expect("stop", "testpmd> ")
 
     def test_perf_TSO_2ports(self):
         """
@@ -339,6 +353,7 @@ class TestTSO(TestCase):
             self.dut.send_expect("csum parse_tunnel on %d" % self.dut_ports[1], "testpmd> ", 120)
             self.dut.send_expect("tso set 800 %d" % self.dut_ports[1], "testpmd> ", 120)
             self.dut.send_expect("set fwd csum", "testpmd> ", 120)
+            self.dut.send_expect("set promisc all off", "testpmd> ", 120)
             self.dut.send_expect("start", "testpmd> ")
             for frame_size in self.frame_sizes:
                 wirespeed = self.wirespeed(self.nic, frame_size, 2)
-- 
1.9.3



More information about the dts mailing list