* [DTS][PATCH V2 1/5] tests/vf_offload: Improve checksum_validate method.
2022-12-28 5:08 [DTS][PATCH V2 0/5] Improve checksum validate and tso packet counting Ke Xu
@ 2022-12-28 5:08 ` Ke Xu
2022-12-28 5:08 ` [DTS][PATCH V2 2/5] tests/vf_offload: Remove redundant variable used Ke Xu
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Ke Xu @ 2022-12-28 5:08 UTC (permalink / raw)
To: dts; +Cc: qi.fu, weiyuanx.li, lijuan.tu, ke1.xu
Use packet show dump methods and packet reading to
validate the packets in a faster, more common and more stable way.
This allows packets other than the plain packets can
be verified by this method checksum_validate.
Signed-off-by: Ke Xu <ke1.xu@intel.com>
---
tests/TestSuite_vf_offload.py | 89 +++++++++++++----------------------
1 file changed, 34 insertions(+), 55 deletions(-)
diff --git a/tests/TestSuite_vf_offload.py b/tests/TestSuite_vf_offload.py
index 62e74c33..abe7d752 100644
--- a/tests/TestSuite_vf_offload.py
+++ b/tests/TestSuite_vf_offload.py
@@ -253,6 +253,16 @@ class TestVfOffload(TestCase):
dut.send_expect("tunnel_tso set 800 %d" % port, "testpmd>")
dut.send_expect("port start %d" % port, "testpmd>")
+ def filter_packets(self, packets):
+ return [
+ p
+ for p in packets
+ if len(p.layers()) >= 3
+ and p.layers()[1] in {IP, IPv6}
+ and p.layers()[2] in {IP, IPv6, UDP, TCP, SCTP, GRE, MPLS}
+ and Raw in p
+ ]
+
def checksum_validate(self, packets_sent, packets_expected):
"""
Validate the checksum.
@@ -266,17 +276,16 @@ class TestVfOffload(TestCase):
sniff_src = self.vm0_testpmd.get_port_mac(0)
checksum_pattern = re.compile("chksum.*=.*(0x[0-9a-z]+)")
sniff_src = "52:00:00:00:00:00"
- chksum = dict()
+ expected_chksum_list = dict()
result = dict()
-
self.tester.send_expect("scapy", ">>> ")
-
+ self.tester.send_expect("from scapy.contrib.gtp import GTP_U_Header", ">>>")
for packet_type in list(packets_expected.keys()):
self.tester.send_expect("p = %s" % packets_expected[packet_type], ">>>")
out = self.tester.send_expect("p.show2()", ">>>")
- chksums = checksum_pattern.findall(out)
- chksum[packet_type] = chksums
- print(packet_type, ": ", chksums)
+ chksum = checksum_pattern.findall(out)
+ expected_chksum_list[packet_type] = chksum
+ print(packet_type, ": ", chksum)
self.tester.send_expect("exit()", "#")
@@ -289,7 +298,7 @@ class TestVfOffload(TestCase):
# Send packet.
self.tester.scapy_foreground()
-
+ self.tester.scapy_append("from scapy.contrib.gtp import GTP_U_Header")
for packet_type in list(packets_sent.keys()):
self.tester.scapy_append(
'sendp([%s], iface="%s")' % (packets_sent[packet_type], tx_interface)
@@ -297,58 +306,28 @@ class TestVfOffload(TestCase):
self.tester.scapy_execute()
out = self.tester.scapy_get_result()
-
- p = self.tester.load_tcpdump_sniff_packets(inst)
- nr_packets = len(p)
- print(p)
- packets_received = [
- p[i].sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%")
- for i in range(nr_packets)
- ]
+ packets_received = self.filter_packets(self.tester.load_tcpdump_sniff_packets(inst))
+ print(list(packets_received))
self.verify(
len(packets_sent) == len(packets_received), "Unexpected Packets Drop"
)
-
- for packet_received in packets_received:
- (
- ip_checksum,
- tcp_checksum,
- udp_checksum,
- sctp_checksum,
- ) = packet_received.split(";")
- print(
- "ip_checksum: ",
- ip_checksum,
- "tcp_checksum:, ",
- tcp_checksum,
- "udp_checksum: ",
- udp_checksum,
- "sctp_checksum: ",
- sctp_checksum,
- )
-
- packet_type = ""
- l4_checksum = ""
- if tcp_checksum != "??":
- packet_type = "TCP"
- l4_checksum = tcp_checksum
- elif udp_checksum != "??":
- packet_type = "UDP"
- l4_checksum = udp_checksum
- elif sctp_checksum != "??":
- packet_type = "SCTP"
- l4_checksum = sctp_checksum
-
- if ip_checksum != "??":
- packet_type = "IP/" + packet_type
- if chksum[packet_type] != [ip_checksum, l4_checksum]:
- result[packet_type] = packet_type + " checksum error"
- else:
- packet_type = "IPv6/" + packet_type
- if chksum[packet_type] != [l4_checksum]:
- result[packet_type] = packet_type + " checksum error"
-
+ for i in range(len(packets_sent)):
+ packet_type = list(packets_sent.keys())[i]
+ checksum_received = checksum_pattern.findall(packets_received[i].show2(dump=True))
+ checksum_expected = expected_chksum_list[list(packets_sent.keys())[i]]
+ self.logger.debug(f"checksum_received: {checksum_received}")
+ self.logger.debug(f"checksum_expected: {checksum_expected}")
+ if not len(checksum_expected) == len(checksum_received):
+ result[packet_type] = (
+ packet_type + " Failed:"
+ + f"The chksum type {packet_type} length of the actual result is inconsistent with the expected length!"
+ )
+ elif not (checksum_received == checksum_expected):
+ result[packet_type] = (
+ packet_type + " Failed:"
+ + f"The actually received chksum {packet_type} is inconsistent with the expectation"
+ )
return result
def test_checksum_offload_enable(self):
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [DTS][PATCH V2 2/5] tests/vf_offload: Remove redundant variable used.
2022-12-28 5:08 [DTS][PATCH V2 0/5] Improve checksum validate and tso packet counting Ke Xu
2022-12-28 5:08 ` [DTS][PATCH V2 1/5] tests/vf_offload: Improve checksum_validate method Ke Xu
@ 2022-12-28 5:08 ` Ke Xu
2022-12-28 5:08 ` [DTS][PATCH V2 3/5] tests/vf_offload: Use modified checksum_validate to replace checksum_validate_tunnel Ke Xu
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Ke Xu @ 2022-12-28 5:08 UTC (permalink / raw)
To: dts; +Cc: qi.fu, weiyuanx.li, lijuan.tu, ke1.xu
Signed-off-by: Ke Xu <ke1.xu@intel.com>
---
tests/TestSuite_vf_offload.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/TestSuite_vf_offload.py b/tests/TestSuite_vf_offload.py
index abe7d752..42af482f 100644
--- a/tests/TestSuite_vf_offload.py
+++ b/tests/TestSuite_vf_offload.py
@@ -348,7 +348,6 @@ class TestVfOffload(TestCase):
self.vm0_testpmd.execute_cmd("set promisc 0 on")
time.sleep(2)
- port_id_0 = 0
mac = self.vm0_testpmd.get_port_mac(0)
sndIP = "10.0.0.1"
sndIPv6 = "::1"
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [DTS][PATCH V2 3/5] tests/vf_offload: Use modified checksum_validate to replace checksum_validate_tunnel.
2022-12-28 5:08 [DTS][PATCH V2 0/5] Improve checksum validate and tso packet counting Ke Xu
2022-12-28 5:08 ` [DTS][PATCH V2 1/5] tests/vf_offload: Improve checksum_validate method Ke Xu
2022-12-28 5:08 ` [DTS][PATCH V2 2/5] tests/vf_offload: Remove redundant variable used Ke Xu
@ 2022-12-28 5:08 ` Ke Xu
2022-12-28 5:08 ` [DTS][PATCH V2 4/5] tests/vf_offload: Improve tcpdump_analyse_sniff method Ke Xu
2022-12-28 5:08 ` [DTS][PATCH V2 5/5] tests/vf_offload: Replace the tcpdump implementation to a packet reading implementation Ke Xu
4 siblings, 0 replies; 6+ messages in thread
From: Ke Xu @ 2022-12-28 5:08 UTC (permalink / raw)
To: dts; +Cc: qi.fu, weiyuanx.li, lijuan.tu, ke1.xu
Use checksum_validate method to validate and remove the tunnel one. The
checksum_validate is updated to cover tunnel packet validation, the
checksum_validate_tunnel is no longer necessary.
Signed-off-by: Ke Xu <ke1.xu@intel.com>
---
tests/TestSuite_vf_offload.py | 62 ++---------------------------------
1 file changed, 3 insertions(+), 59 deletions(-)
diff --git a/tests/TestSuite_vf_offload.py b/tests/TestSuite_vf_offload.py
index 42af482f..bccffb3d 100644
--- a/tests/TestSuite_vf_offload.py
+++ b/tests/TestSuite_vf_offload.py
@@ -394,64 +394,6 @@ class TestVfOffload(TestCase):
self.verify(len(result) == 0, ",".join(list(result.values())))
- def checksum_validate_tunnel(self, packets_sent, packets_expected):
- """
- Validate the checksum.
- """
- 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])
- )
- sniff_src = self.vm0_testpmd.get_port_mac(0)
- checksum_pattern = re.compile("chksum.*=.*(0x[0-9a-z]+)")
- sniff_src = "52:00:00:00:00:00"
- chksum = dict()
- # self.tester.send_expect("scapy", ">>> ")
-
- for packet_type in list(packets_expected.keys()):
- self.tester.send_expect("scapy", ">>> ")
- self.tester.send_expect("p = %s" % packets_expected[packet_type], ">>>")
- out = self.tester.send_expect("p.show2()", ">>>")
- chksums = checksum_pattern.findall(out)
- expected_chksum = chksums
- chksum[packet_type] = chksums
- print(packet_type, ": ", chksums)
-
- self.tester.send_expect("exit()", "#")
-
- self.tester.scapy_background()
- inst = self.tester.tcpdump_sniff_packets(
- intf=rx_interface,
- count=len(packets_sent),
- filters=[{"layer": "ether", "config": {"src": sniff_src}}],
- )
-
- # Send packet.
- self.tester.scapy_foreground()
-
- self.tester.scapy_append(
- 'sendp([%s], iface="%s")' % (packets_sent[packet_type], tx_interface)
- )
- self.tester.scapy_execute()
- out = self.tester.scapy_get_result()
- p = self.tester.load_tcpdump_sniff_packets(inst)
- nr_packets = len(p)
- print(p)
- chksums = checksum_pattern.findall(p[0].show2(dump=True))
- packets_received = chksums
- self.logger.debug(f"packets_received: {packets_received}")
- self.logger.debug(f"expected_chksum: {expected_chksum}")
- self.verify(
- len(expected_chksum) == len(packets_received),
- f"The chksum type {packet_type} length of the actual result is inconsistent with the expected length!",
- )
- self.verify(
- packets_received == expected_chksum,
- f"The actually received chksum {packet_type} is inconsistent with the expectation",
- )
-
@check_supported_nic(
["ICE_100G-E810C_QSFP", "ICE_25G-E810C_SFP", "ICE_25G-E810_XXV_SFP"]
)
@@ -570,7 +512,7 @@ class TestVfOffload(TestCase):
self.vm0_testpmd.execute_cmd("start")
self.vm0_testpmd.wait_link_status_up(0)
self.vm0_testpmd.wait_link_status_up(1)
- self.checksum_validate_tunnel(pkts, pkts_ref)
+ result = self.checksum_validate(pkts, pkts_ref)
# Validate checksum on the receive packet
out = self.vm0_testpmd.execute_cmd("stop")
bad_outer_ipcsum = self.vm0_testpmd.get_pmd_value("Bad-outer-ipcsum:", out)
@@ -588,6 +530,8 @@ class TestVfOffload(TestCase):
self.verify(bad_inner_ipcsum == 36, "Bad-ipcsum check error")
self.verify(bad_inner_l4csum == 72, "Bad-l4csum check error")
+ self.verify(len(result) == 0, ",".join(list(result.values())))
+
def test_checksum_offload_disable(self):
"""
Enable SW checksum offload.
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [DTS][PATCH V2 4/5] tests/vf_offload: Improve tcpdump_analyse_sniff method
2022-12-28 5:08 [DTS][PATCH V2 0/5] Improve checksum validate and tso packet counting Ke Xu
` (2 preceding siblings ...)
2022-12-28 5:08 ` [DTS][PATCH V2 3/5] tests/vf_offload: Use modified checksum_validate to replace checksum_validate_tunnel Ke Xu
@ 2022-12-28 5:08 ` Ke Xu
2022-12-28 5:08 ` [DTS][PATCH V2 5/5] tests/vf_offload: Replace the tcpdump implementation to a packet reading implementation Ke Xu
4 siblings, 0 replies; 6+ messages in thread
From: Ke Xu @ 2022-12-28 5:08 UTC (permalink / raw)
To: dts; +Cc: qi.fu, weiyuanx.li, lijuan.tu, ke1.xu
Use newly added filter_packets method to replace the packet filtering.
Calculate p[Raw].load to fix possible wrongly calculated payload
size when there are paddings.
Signed-off-by: Ke Xu <ke1.xu@intel.com>
---
tests/TestSuite_vf_offload.py | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/tests/TestSuite_vf_offload.py b/tests/TestSuite_vf_offload.py
index bccffb3d..a9d587e9 100644
--- a/tests/TestSuite_vf_offload.py
+++ b/tests/TestSuite_vf_offload.py
@@ -622,17 +622,9 @@ class TestVfOffload(TestCase):
packets and the bytes of packets payload.
"""
packet = Packet()
- pkts = packet.read_pcapfile("tcpdump_{0}.pcap".format(iface), self.tester)
- pkts = [
- p
- for p in pkts
- if len(p.layers()) >= 3
- and p.layers()[1] in {IP, IPv6}
- and p.layers()[2] in {IP, IPv6, UDP, TCP, SCTP, GRE, MPLS}
- and Raw in p
- ]
+ pkts = self.filter_packets(packet.read_pcapfile("tcpdump_{0}.pcap".format(iface), self.tester))
rx_packet_count = len(pkts)
- rx_packet_size = [len(p[Raw]) for p in pkts]
+ rx_packet_size = [len(p[Raw].load) for p in pkts]
return rx_packet_count, rx_packet_size
def tcpdump_command(self, command):
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [DTS][PATCH V2 5/5] tests/vf_offload: Replace the tcpdump implementation to a packet reading implementation.
2022-12-28 5:08 [DTS][PATCH V2 0/5] Improve checksum validate and tso packet counting Ke Xu
` (3 preceding siblings ...)
2022-12-28 5:08 ` [DTS][PATCH V2 4/5] tests/vf_offload: Improve tcpdump_analyse_sniff method Ke Xu
@ 2022-12-28 5:08 ` Ke Xu
4 siblings, 0 replies; 6+ messages in thread
From: Ke Xu @ 2022-12-28 5:08 UTC (permalink / raw)
To: dts; +Cc: qi.fu, weiyuanx.li, lijuan.tu, ke1.xu
Packet reading implementation is more common to use when to verify the
received packet count and payload size. The tcpdump method is not
able to recognize some of the tunnel packets, leading to a wrong output
failing the validation. Newly added tcpdump_analyse_sniff method is
implemented by sniff packet reading and analysing and can replace
the lagacy methods number_of_packets and number_of_bytes.
Signed-off-by: Ke Xu <ke1.xu@intel.com>
---
tests/TestSuite_vf_offload.py | 77 +++++++++--------------------------
1 file changed, 20 insertions(+), 57 deletions(-)
diff --git a/tests/TestSuite_vf_offload.py b/tests/TestSuite_vf_offload.py
index a9d587e9..084f2249 100644
--- a/tests/TestSuite_vf_offload.py
+++ b/tests/TestSuite_vf_offload.py
@@ -627,43 +627,6 @@ class TestVfOffload(TestCase):
rx_packet_size = [len(p[Raw].load) for p in pkts]
return rx_packet_count, rx_packet_size
- def tcpdump_command(self, command):
- """
- Send a tcpdump related command and return an integer from the output.
- """
-
- result = self.tester.send_expect(command, "#")
- print(result)
- return int(result.strip())
-
- def number_of_packets(self, iface):
- """
- By reading the file generated by tcpdump it counts how many packets are
- forwarded by the sample app and received in the self.tester. The sample app
- will add a known MAC address for the test to look for.
- """
-
- command = (
- "tcpdump -A -nn -e -v -r tcpdump_{iface}.pcap 2>/dev/null | "
- + 'grep -c "seq"'
- )
- return self.tcpdump_command(command.format(**locals()))
-
- def tcpdump_scanner(self, scanner):
- """
- Execute scanner to return results
- """
- scanner_result = self.tester.send_expect(scanner, "#")
- finally_result = re.findall(r"length( \d+)", scanner_result)
- return list(finally_result)
-
- def number_of_bytes(self, iface):
- """
- Get the length of loading_sizes
- """
- scanner = 'tcpdump -n -vv -r tcpdump_{iface}.pcap 2>/dev/null | grep "seq" | grep "length"'
- return self.tcpdump_scanner(scanner.format(**locals()))
-
def test_tso(self):
"""
TSO IPv4 TCP, IPv6 TCP testing.
@@ -761,27 +724,26 @@ class TestVfOffload(TestCase):
out = self.vm0_testpmd.execute_cmd("show port stats all")
print(out)
self.tcpdump_stop_sniff()
- rx_stats = self.number_of_packets(rx_interface)
- tx_stats = self.number_of_packets(tx_interface)
- tx_outlist = self.number_of_bytes(rx_interface)
- tx_outlist.sort(reverse=True)
- self.logger.info(tx_outlist)
+ rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface)
+ tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface)
+ payload_size_list.sort(reverse=True)
+ self.logger.info(payload_size_list)
if loading_size <= 800:
self.verify(
- rx_stats == tx_stats and int(tx_outlist[0]) == loading_size,
+ rx_stats == tx_stats and int(payload_size_list[0]) == loading_size,
"IPV4 RX or TX packet number not correct",
)
else:
num = loading_size // 800
for i in range(num):
self.verify(
- int(tx_outlist[i]) == 800,
- "the packet segmentation incorrect, %s" % tx_outlist,
+ int(payload_size_list[i]) == 800,
+ "the packet segmentation incorrect, %s" % payload_size_list,
)
if loading_size % 800 != 0:
self.verify(
- int(tx_outlist[num]) == loading_size % 800,
- "the packet segmentation incorrect, %s" % tx_outlist,
+ int(payload_size_list[num]) == loading_size % 800,
+ "the packet segmentation incorrect, %s" % payload_size_list,
)
for loading_size in self.loading_sizes:
@@ -796,27 +758,26 @@ class TestVfOffload(TestCase):
out = self.vm0_testpmd.execute_cmd("show port stats all")
print(out)
self.tcpdump_stop_sniff()
- rx_stats = self.number_of_packets(rx_interface)
- tx_stats = self.number_of_packets(tx_interface)
- tx_outlist = self.number_of_bytes(rx_interface)
- tx_outlist.sort(reverse=True)
- self.logger.info(tx_outlist)
+ rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface)
+ tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface)
+ payload_size_list.sort(reverse=True)
+ self.logger.info(payload_size_list)
if loading_size <= 800:
self.verify(
- rx_stats == tx_stats and int(tx_outlist[0]) == loading_size,
+ rx_stats == tx_stats and int(payload_size_list[0]) == loading_size,
"IPV6 RX or TX packet number not correct",
)
else:
num = loading_size // 800
for i in range(num):
self.verify(
- int(tx_outlist[i]) == 800,
- "the packet segmentation incorrect, %s" % tx_outlist,
+ int(payload_size_list[i]) == 800,
+ "the packet segmentation incorrect, %s" % payload_size_list,
)
if loading_size % 800 != 0:
self.verify(
- int(tx_outlist[num]) == loading_size % 800,
- "the packet segmentation incorrect, %s" % tx_outlist,
+ int(payload_size_list[num]) == loading_size % 800,
+ "the packet segmentation incorrect, %s" % payload_size_list,
)
@check_supported_nic(
@@ -915,6 +876,7 @@ class TestVfOffload(TestCase):
self.tcpdump_stop_sniff()
rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface)
tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface)
+ payload_size_list.sort(reverse=True)
self.logger.info(payload_size_list)
if loading_size <= 800:
self.verify(
@@ -958,6 +920,7 @@ class TestVfOffload(TestCase):
self.tcpdump_stop_sniff()
rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface)
tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface)
+ payload_size_list.sort(reverse=True)
self.logger.info(payload_size_list)
if loading_size <= 800:
self.verify(
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread