[dts] [PATCH] checksum offload: add hardware checksum checks case
Owen Hilyard
ohilyard at iol.unh.edu
Tue Jul 14 16:53:55 CEST 2020
add test case for hardware checksum checks
add test documentation for test case
Signed-off-by: Owen Hilyard <ohilyard at iol.unh.edu>
---
test_plans/checksum_offload_test_plan.rst | 134 +---------
tests/TestSuite_checksum_offload.py | 287 +++++++++++++++-------
2 files changed, 200 insertions(+), 221 deletions(-)
diff --git a/test_plans/checksum_offload_test_plan.rst b/test_plans/checksum_offload_test_plan.rst
index a42e28e..4fd8c5a 100644
--- a/test_plans/checksum_offload_test_plan.rst
+++ b/test_plans/checksum_offload_test_plan.rst
@@ -221,8 +221,13 @@ combination: good/bad ip checksum + good/bad udp/tcp checksum.
Check the Rx checksum flags consistent with expected flags.
-Test Case: Hardware Checksum Check IP UDP
+Test Case: Hardware Checksum Check L4
===========================================
+This test involves testing many different scenarios with a L4 checksum.
+A variety of tunneling protocols, L3 protocols and L4 protocols are combined
+to test as many scenarios as possible. Currently, UDP, TCP and SCTP are used
+as L4 protocols, with IP and IPv6 being used at level 3. The tested tunneling
+protocols are VXLAN and GRE.
Setup the ``csum`` forwarding mode::
@@ -251,131 +256,4 @@ Send a packet with a bad checksum::
rx: l2_len=18 ethertype=800 l3_len=20 l4_proto=17 l4_len=8 flags=PKT_RX_L4_CKSUM_BAD PKT_RX_IP_CKSUM_BAD PKT_RX_OUTER_L4_CKSUM_UNKNOWN
tx: flags=PKT_TX_L4_NO_CKSUM PKT_TX_IPV4
-Verify flags are as expected.
-Test Case: Hardware Checksum Check IP TCP
-===========================================
-
-Setup the ``csum`` forwarding mode::
-
- testpmd> set fwd csum
- Set csum packet forwarding mode
-
-Start the packet forwarding::
-
- testpmd> start
- csum packet forwarding - CRC stripping disabled - packets/burst=32
- nb forwarding cores=1 - nb forwarding ports=10
- RX queues=1 - RX desc=128 - RX free threshold=64
- RX threshold registers: pthresh=8 hthresh=8 wthresh=4
- TX queues=1 - TX desc=512 - TX free threshold=0
- TX threshold registers: pthresh=32 hthresh=8 wthresh=8
-
-Send a packet with a good checksum::
-
- port=0, mbuf=0x2269df7500, pkt_len=108, nb_segs=1:
- rx: l2_len=18 ethertype=800 l3_len=20 l4_proto=6 l4_len=20 flags=PKT_RX_L4_CKSUM_GOOD PKT_RX_IP_CKSUM_GOOD PKT_RX_OUTER_L4_CKSUM_UNKNOWN
- tx: flags=PKT_TX_L4_NO_CKSUM PKT_TX_IPV4
-
-Send a packet with a bad checksum::
-
- port=0, mbuf=0x2269df6bc0, pkt_len=108, nb_segs=1:
- rx: l2_len=18 ethertype=800 l3_len=20 l4_proto=6 l4_len=20 flags=PKT_RX_L4_CKSUM_BAD PKT_RX_IP_CKSUM_BAD PKT_RX_OUTER_L4_CKSUM_UNKNOWN
- tx: flags=PKT_TX_L4_NO_CKSUM PKT_TX_IPV4
-
-Verify flags are as expected.
-
-Test Case: Hardware Checksum Check IP SCTP
-===========================================
-
-Setup the ``csum`` forwarding mode::
-
- testpmd> set fwd csum
- Set csum packet forwarding mode
-
-Start the packet forwarding::
-
- testpmd> start
- csum packet forwarding - CRC stripping disabled - packets/burst=32
- nb forwarding cores=1 - nb forwarding ports=10
- RX queues=1 - RX desc=128 - RX free threshold=64
- RX threshold registers: pthresh=8 hthresh=8 wthresh=4
- TX queues=1 - TX desc=512 - TX free threshold=0
- TX threshold registers: pthresh=32 hthresh=8 wthresh=8
-
-Send a packet with a good checksum::
-
- port=0, mbuf=0x2269df6280, pkt_len=100, nb_segs=1:
- rx: l2_len=18 ethertype=800 l3_len=20 l4_proto=132 l4_len=0 flags=PKT_RX_L4_CKSUM_GOOD PKT_RX_IP_CKSUM_GOOD PKT_RX_OUTER_L4_CKSUM_UNKNOWN
- tx: flags=PKT_TX_L4_NO_CKSUM PKT_TX_IPV4
-
-Send a packet with a bad checksum::
-
- port=0, mbuf=0x2269df5940, pkt_len=100, nb_segs=1:
- rx: l2_len=18 ethertype=800 l3_len=20 l4_proto=132 l4_len=0 flags=PKT_RX_L4_CKSUM_BAD PKT_RX_IP_CKSUM_BAD PKT_RX_OUTER_L4_CKSUM_UNKNOWN
- tx: flags=PKT_TX_L4_NO_CKSUM PKT_TX_IPV4
-
-Verify flags are as expected.
-Test Case: Hardware Checksum Check IPv6 UDP
-===========================================
-
-Setup the ``csum`` forwarding mode::
-
- testpmd> set fwd csum
- Set csum packet forwarding mode
-
-Start the packet forwarding::
-
- testpmd> start
- csum packet forwarding - CRC stripping disabled - packets/burst=32
- nb forwarding cores=1 - nb forwarding ports=10
- RX queues=1 - RX desc=128 - RX free threshold=64
- RX threshold registers: pthresh=8 hthresh=8 wthresh=4
- TX queues=1 - TX desc=512 - TX free threshold=0
- TX threshold registers: pthresh=32 hthresh=8 wthresh=8
-
-Send a packet with a good checksum::
-
- port=0, mbuf=0x2269df5000, pkt_len=116, nb_segs=1:
- rx: l2_len=18 ethertype=86dd l3_len=40 l4_proto=17 l4_len=8 flags=PKT_RX_L4_CKSUM_GOOD PKT_RX_IP_CKSUM_GOOD PKT_RX_OUTER_L4_CKSUM_UNKNOWN
- tx: flags=PKT_TX_L4_NO_CKSUM PKT_TX_IPV6
-
-
-Send a packet with a bad checksum::
-
- port=0, mbuf=0x2269df46c0, pkt_len=116, nb_segs=1:
- rx: l2_len=18 ethertype=86dd l3_len=40 l4_proto=17 l4_len=8 flags=PKT_RX_L4_CKSUM_BAD PKT_RX_IP_CKSUM_GOOD PKT_RX_OUTER_L4_CKSUM_UNKNOWN
- tx: flags=PKT_TX_L4_NO_CKSUM PKT_TX_IPV6
-
-Verify flags are as expected.
-Test Case: Hardware Checksum Check IPv6 TCP
-===========================================
-
-Setup the ``csum`` forwarding mode::
-
- testpmd> set fwd csum
- Set csum packet forwarding mode
-
-Start the packet forwarding::
-
- testpmd> start
- csum packet forwarding - CRC stripping disabled - packets/burst=32
- nb forwarding cores=1 - nb forwarding ports=10
- RX queues=1 - RX desc=128 - RX free threshold=64
- RX threshold registers: pthresh=8 hthresh=8 wthresh=4
- TX queues=1 - TX desc=512 - TX free threshold=0
- TX threshold registers: pthresh=32 hthresh=8 wthresh=8
-
-Send a packet with a good checksum::
-
- port=0, mbuf=0x2269df3d80, pkt_len=128, nb_segs=1:
- rx: l2_len=18 ethertype=86dd l3_len=40 l4_proto=6 l4_len=20 flags=PKT_RX_L4_CKSUM_GOOD PKT_RX_IP_CKSUM_GOOD PKT_RX_OUTER_L4_CKSUM_UNKNOWN
- tx: flags=PKT_TX_L4_NO_CKSUM PKT_TX_IPV6
-
-
-Send a packet with a bad checksum::
-
- port=0, mbuf=0x2269df3440, pkt_len=128, nb_segs=1:
- rx: l2_len=18 ethertype=86dd l3_len=40 l4_proto=6 l4_len=20 flags=PKT_RX_L4_CKSUM_BAD PKT_RX_IP_CKSUM_GOOD PKT_RX_OUTER_L4_CKSUM_UNKNOWN
- tx: flags=PKT_TX_L4_NO_CKSUM PKT_TX_IPV6
-
Verify flags are as expected.
\ No newline at end of file
diff --git a/tests/TestSuite_checksum_offload.py b/tests/TestSuite_checksum_offload.py
index 53eb918..9ff5a41 100644
--- a/tests/TestSuite_checksum_offload.py
+++ b/tests/TestSuite_checksum_offload.py
@@ -39,6 +39,10 @@ Test support of RX/TX Checksum Offload Features by Poll Mode Drivers.
import os
import re
+import subprocess
+import time
+from typing import List, Union, Tuple, Pattern
+
import time
from rst import RstReport
@@ -48,8 +52,11 @@ from test_case import TestCase
from framework.pmd_output import PmdOutput
from test_capabilities import DRIVER_TEST_LACK_CAPA
from pktgen import PacketGeneratorHelper
+from exception import VerifyFailure
import packet
+from settings import FOLDERS
+
class TestChecksumOffload(TestCase):
@@ -91,6 +98,9 @@ class TestChecksumOffload(TestCase):
self.dut.send_expect("csum set udp hw %d" % port, "testpmd>")
self.dut.send_expect("csum set tcp hw %d" % port, "testpmd>")
self.dut.send_expect("csum set sctp hw %d" % port, "testpmd>")
+ self.dut.send_expect("csum set outer-ip hw %d" % port, "testpmd>")
+ self.dut.send_expect("csum set outer-udp hw %d" % port, "testpmd>")
+ self.dut.send_expect("csum parse-tunnel on %d" % port, "testpmd>")
self.dut.send_expect("port start all", "testpmd>")
def checksum_enablesw(self, port):
@@ -146,11 +156,9 @@ class TestChecksumOffload(TestCase):
self.verify("PKT_RX_L4_CKSUM_GOOD" in line, "Packet Rx L4 checksum valid-flags error!")
elif (flag == 0):
if self.nic == "cavium_a063":
- self.verify("PKT_RX_L4_CKSUM_BAD" in line or "PKT_RX_L4_CKSUM_UNKNOWN" in line,
- "Packet Rx L4 checksum valid-flags error!")
+ self.verify("PKT_RX_L4_CKSUM_BAD" in line or "PKT_RX_L4_CKSUM_UNKNOWN" in line, "Packet Rx L4 checksum valid-flags error!")
else:
- self.verify("PKT_RX_L4_CKSUM_BAD" in line,
- "Packet Rx L4 checksum valid-flags error!")
+ self.verify("PKT_RX_L4_CKSUM_BAD" in line, "Packet Rx L4 checksum valid-flags error!")
else:
if "PKT_RX_L4_CKSUM" not in line:
self.verify(0, "There is no L4 checksum flags appeared!")
@@ -178,8 +186,8 @@ class TestChecksumOffload(TestCase):
chksum = self.get_chksum_values(packets_expected)
- inst = self.tester.tcpdump_sniff_packets(intf=rx_interface, count=len(packets_sent) * 4,
- filters=[{'layer': 'ether', 'config': {'src': sniff_src}}])
+ inst = self.tester.tcpdump_sniff_packets(intf=rx_interface, count=len(packets_sent)*4,
+ filters=[{'layer': 'ether', 'config': {'src': sniff_src}}])
self.pkt = packet.Packet()
for packet_type in list(packets_sent.keys()):
@@ -189,10 +197,9 @@ class TestChecksumOffload(TestCase):
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 = [p[i].sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%") for i in range(nr_packets)]
print(len(packets_sent), len(packets_received))
- self.verify(len(packets_sent) * 4 == len(packets_received), "Unexpected Packets Drop")
+ self.verify(len(packets_sent)*4 == len(packets_received), "Unexpected Packets Drop")
for packet_received in packets_received:
ip_checksum, tcp_checksum, udp_checksum, sctp_checksum = packet_received.split(';')
@@ -227,47 +234,47 @@ class TestChecksumOffload(TestCase):
self.tester.scapy_append(f'sendp({packet}, iface="{itf}")')
return self.tester.scapy_execute()
- def checksum_flags_are_good(self, flag: str, testpmd_output: str) -> bool:
- good_flag_in_output: bool = flag + "GOOD" in testpmd_output
- self.verify(good_flag_in_output or flag + "BAD" in testpmd_output,
- f"Flag {flag[:-1]} not found, please run test_rx_checksum_valid_flags.")
- return good_flag_in_output
-
def get_pkt_rx_l4_cksum(self, testpmd_output: str) -> bool:
return self.checksum_flags_are_good("PKT_RX_L4_CKSUM_", testpmd_output)
def get_pkt_rx_ip_cksum(self, testpmd_output: str) -> bool:
return self.checksum_flags_are_good("PKT_RX_IP_CKSUM_", testpmd_output)
- def send_pkt_expect_good_bad_from_flag(self, pkt_str: str, do_l3_csum: bool = False, good: bool = True):
- self.send_scapy_packet(pkt_str)
- out: str = self.pmdout.get_output(timeout=5)
- # self.logger.info("Packet Result:\n" + out)
- self.verify(self.get_pkt_rx_l4_cksum(out) == good, "L4 checksum was not correctly checked.")
- if do_l3_csum:
- self.verify(self.get_pkt_rx_ip_cksum(out) == good, "L3 checksum was not correctly checked.")
+ def send_pkt_expect_good_bad_from_flag(self, pkt_str: str, flag: str, test_name: str, should_pass: bool = True):
+ self.pmdout.get_output(timeout=5) # Remove any old output
+ self.scapy_exec(f"sendp({pkt_str}, iface=iface)")
+ time.sleep(1)
+ testpmd_output: str = self.pmdout.get_output(timeout=5)
+ self.verify(flag in testpmd_output,
+ f"Flag {flag[:-1]} not found for test {test_name}, please run test_rx_checksum_valid_flags.")
+ self.verify((flag + "UNKNOWN") not in testpmd_output,
+ f"Flag {flag[:-1]} was found to be unknown for test {test_name}, indicating a possible lack of support")
+ if should_pass:
+ if flag + "GOOD" in testpmd_output:
+ return
+ else: # flag + "BAD" in testpmd_output
+ self.verify(False, f"{flag}BAD was found in output, expecting {flag}GOOD.")
+ else:
+ if flag + "BAD" in testpmd_output:
+ return
+ else: # flag + "GOOD" in testpmd_output
+ self.verify(False, f"{flag}GOOD was found in output, expecting {flag}BAD.")
- def helper_hardware_checksum_check(self, pkt_str: str, do_l3_csum: bool = False):
- self.dut.send_expect("start", "testpmd>")
+ def send_pkt_expect_good_bad_from_flag_catch_failure(self, pkt_str: str, flag: str, test_name: str,
+ should_pass: bool = True) -> Union[VerifyFailure, None]:
+ try:
+ self.send_pkt_expect_good_bad_from_flag(pkt_str, flag, test_name, should_pass=should_pass)
+ except VerifyFailure as vf:
+ return vf
- self.checksum_enablehw(self.dut_ports[0])
- dut_mac = self.dut.get_mac_address(self.dut_ports[0])
- tester_mac = self.tester.get_mac(self.tester.get_local_port(self.dut_ports[0]))
+ return None
- good_pkt: str
- bad_pkt: str
- if do_l3_csum:
- # Blank out the fields where a checksum would go for the good packet
- good_pkt = pkt_str % (dut_mac, tester_mac, "", "")
- bad_pkt = pkt_str % (dut_mac, tester_mac, "chksum=0xf", "chksum=0xf")
- else:
- good_pkt = pkt_str % (dut_mac, tester_mac, "")
- bad_pkt = pkt_str % (dut_mac, tester_mac, "chksum=0xf")
+ def scapy_exec(self, cmd: str):
+ return self.tester.send_expect(cmd, ">>>")
- self.send_pkt_expect_good_bad_from_flag(good_pkt, do_l3_csum=do_l3_csum, good=True)
- self.send_pkt_expect_good_bad_from_flag(bad_pkt, do_l3_csum=do_l3_csum, good=False)
+ def scapy_send_append(self, packet: str):
+ return self.tester.scapy_append(f'sendp({packet}, iface=iface)')
- self.dut.send_expect("stop", "testpmd>")
#
#
#
@@ -281,19 +288,17 @@ class TestChecksumOffload(TestCase):
"""
mac = self.dut.get_mac_address(self.dut_ports[0])
- pktsChkErr = {
- 'IP/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/Dot1Q(vlan=1)/IP(chksum=0x0)/UDP(chksum=0xf)/("X"*46)' % mac,
- 'IP/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/Dot1Q(vlan=1)/IP(chksum=0x0)/TCP(chksum=0xf)/("X"*46)' % mac,
- 'IP/SCTP': 'Ether(dst="%s", src="52:00:00:00:00:00")/Dot1Q(vlan=1)/IP(chksum=0x0)/SCTP(chksum=0xf)/("X"*48)' % mac,
- 'IPv6/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/Dot1Q(vlan=1)/IPv6(src="::1")/UDP(chksum=0xf)/("X"*46)' % mac,
- 'IPv6/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/Dot1Q(vlan=1)/IPv6(src="::1")/TCP(chksum=0xf)/("X"*46)' % mac}
+ pktsChkErr = {'IP/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/Dot1Q(vlan=1)/IP(chksum=0x0)/UDP(chksum=0xf)/("X"*46)' % mac,
+ 'IP/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/Dot1Q(vlan=1)/IP(chksum=0x0)/TCP(chksum=0xf)/("X"*46)' % mac,
+ 'IP/SCTP': 'Ether(dst="%s", src="52:00:00:00:00:00")/Dot1Q(vlan=1)/IP(chksum=0x0)/SCTP(chksum=0xf)/("X"*48)' % mac,
+ 'IPv6/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/Dot1Q(vlan=1)/IPv6(src="::1")/UDP(chksum=0xf)/("X"*46)' % mac,
+ 'IPv6/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/Dot1Q(vlan=1)/IPv6(src="::1")/TCP(chksum=0xf)/("X"*46)' % mac}
- pkts = {
- 'IP/UDP': 'Ether(dst="02:00:00:00:00:00", src="%s")/Dot1Q(vlan=1)/IP(src="127.0.0.1")/UDP()/("X"*46)' % mac,
- 'IP/TCP': 'Ether(dst="02:00:00:00:00:00", src="%s")/Dot1Q(vlan=1)/IP(src="127.0.0.1")/TCP()/("X"*46)' % mac,
- 'IP/SCTP': 'Ether(dst="02:00:00:00:00:00", src="%s")/Dot1Q(vlan=1)/IP(src="127.0.0.1")/SCTP()/("X"*48)' % mac,
- 'IPv6/UDP': 'Ether(dst="02:00:00:00:00:00", src="%s")/Dot1Q(vlan=1)/IPv6(src="::1")/UDP()/("X"*46)' % mac,
- 'IPv6/TCP': 'Ether(dst="02:00:00:00:00:00", src="%s")/Dot1Q(vlan=1)/IPv6(src="::1")/TCP()/("X"*46)' % mac}
+ pkts = {'IP/UDP': 'Ether(dst="02:00:00:00:00:00", src="%s")/Dot1Q(vlan=1)/IP(src="127.0.0.1")/UDP()/("X"*46)' % mac,
+ 'IP/TCP': 'Ether(dst="02:00:00:00:00:00", src="%s")/Dot1Q(vlan=1)/IP(src="127.0.0.1")/TCP()/("X"*46)' % mac,
+ 'IP/SCTP': 'Ether(dst="02:00:00:00:00:00", src="%s")/Dot1Q(vlan=1)/IP(src="127.0.0.1")/SCTP()/("X"*48)' % mac,
+ 'IPv6/UDP': 'Ether(dst="02:00:00:00:00:00", src="%s")/Dot1Q(vlan=1)/IPv6(src="::1")/UDP()/("X"*46)' % mac,
+ 'IPv6/TCP': 'Ether(dst="02:00:00:00:00:00", src="%s")/Dot1Q(vlan=1)/IPv6(src="::1")/TCP()/("X"*46)' % mac}
if self.kdriver in DRIVER_TEST_LACK_CAPA['sctp_tx_offload']:
del pktsChkErr['IP/SCTP']
@@ -325,17 +330,11 @@ class TestChecksumOffload(TestCase):
result = self.get_chksum_values(pkts_ref)
# set the expected checksum values same with the actual values
- pkts_good = {
- 'IP/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IP(chksum=int(%s))/UDP(chksum=int(%s))/("X"*46)' % (
- mac, result['IP/UDP'][0], result['IP/UDP'][1]),
- 'IP/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IP(src="10.0.0.1",chksum=int(%s))/TCP(chksum=int(%s))/("X"*46)' % (
- mac, result['IP/TCP'][0], result['IP/TCP'][1]),
- 'IP/SCTP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IP(src="10.0.0.1",chksum=int(%s))/SCTP(chksum=int(%s))/("X"*48)' % (
- mac, result['IP/SCTP'][0], result['IP/SCTP'][1]),
- 'IPv6/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="::1")/UDP(chksum=int(%s))/("X"*46)' % (
- mac, result['IPv6/UDP'][0]),
- 'IPv6/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="::1")/TCP(chksum=int(%s))/("X"*46)' % (
- mac, result['IPv6/TCP'][0])}
+ pkts_good = {'IP/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IP(chksum=int(%s))/UDP(chksum=int(%s))/("X"*46)' % (mac, result['IP/UDP'][0], result['IP/UDP'][1]),
+ 'IP/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IP(src="10.0.0.1",chksum=int(%s))/TCP(chksum=int(%s))/("X"*46)' % (mac, result['IP/TCP'][0], result['IP/TCP'][1]),
+ 'IP/SCTP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IP(src="10.0.0.1",chksum=int(%s))/SCTP(chksum=int(%s))/("X"*48)' % (mac, result['IP/SCTP'][0], result['IP/SCTP'][1]),
+ 'IPv6/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="::1")/UDP(chksum=int(%s))/("X"*46)' % (mac, result['IPv6/UDP'][0]),
+ 'IPv6/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="::1")/TCP(chksum=int(%s))/("X"*46)' % (mac, result['IPv6/TCP'][0])}
# set the expected checksum values different from the actual values
pkts_bad = {'IP/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IP(chksum=0x0)/UDP(chksum=0xf)/("X"*46)' % mac,
@@ -399,24 +398,17 @@ class TestChecksumOffload(TestCase):
mac = self.dut.get_mac_address(self.dut_ports[0])
sndIP = '10.0.0.1'
sndIPv6 = '::1'
- sndPkts = {
- 'IP/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IP(src="%s",chksum=0x0)/UDP(chksum=0xf)/("X"*46)' % (
- mac, sndIP),
- 'IP/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IP(src="%s",chksum=0x0)/TCP(chksum=0xf)/("X"*46)' % (
- mac, sndIP),
- 'IPv6/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="%s")/UDP(chksum=0xf)/("X"*46)' % (
- mac, sndIPv6),
- 'IPv6/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="%s")/TCP(chksum=0xf)/("X"*46)' % (
- mac, sndIPv6)}
+ sndPkts = {'IP/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IP(src="%s",chksum=0x0)/UDP(chksum=0xf)/("X"*46)' % (mac, sndIP),
+ 'IP/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IP(src="%s",chksum=0x0)/TCP(chksum=0xf)/("X"*46)' % (mac, sndIP),
+ 'IPv6/UDP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="%s")/UDP(chksum=0xf)/("X"*46)' % (mac, sndIPv6),
+ 'IPv6/TCP': 'Ether(dst="%s", src="52:00:00:00:00:00")/IPv6(src="%s")/TCP(chksum=0xf)/("X"*46)' % (mac, sndIPv6)}
expIP = sndIP
expIPv6 = sndIPv6
expPkts = {'IP/UDP': 'Ether(dst="02:00:00:00:00:00", src="%s")/IP(src="%s")/UDP()/("X"*46)' % (mac, expIP),
'IP/TCP': 'Ether(dst="02:00:00:00:00:00", src="%s")/IP(src="%s")/TCP()/("X"*46)' % (mac, expIP),
- 'IPv6/UDP': 'Ether(dst="02:00:00:00:00:00", src="%s")/IPv6(src="%s")/UDP()/("X"*46)' % (
- mac, expIPv6),
- 'IPv6/TCP': 'Ether(dst="02:00:00:00:00:00", src="%s")/IPv6(src="%s")/TCP()/("X"*46)' % (
- mac, expIPv6)}
+ 'IPv6/UDP': 'Ether(dst="02:00:00:00:00:00", src="%s")/IPv6(src="%s")/UDP()/("X"*46)' % (mac, expIPv6),
+ 'IPv6/TCP': 'Ether(dst="02:00:00:00:00:00", src="%s")/IPv6(src="%s")/TCP()/("X"*46)' % (mac, expIPv6)}
self.dut.send_expect("start", "testpmd>")
result = self.checksum_validate(sndPkts, expPkts)
@@ -458,12 +450,12 @@ class TestChecksumOffload(TestCase):
self.tester.pktgen.clear_streams()
# run packet generator
streams = self.pktgen_helper.prepare_stream_from_tginput(tgenInput, 100,
- None, self.tester.pktgen)
+ None, self.tester.pktgen)
Bps[str(size)], Pps[str(size)] = self.tester.pktgen.measure_throughput(stream_ids=streams)
self.verify(Pps[str(size)] > 0, "No traffic detected")
Pps[str(size)] /= 1E6
Pct[str(size)] = (Pps[str(size)] * 100) / \
- self.wirespeed(self.nic, size, 2)
+ self.wirespeed(self.nic, size, 2)
result.append(Pps[str(size)])
result.append(Pct[str(size)])
@@ -500,7 +492,7 @@ class TestChecksumOffload(TestCase):
self.result_table_create(tblheader)
self.pmdout.start_testpmd(
lcore, "--portmask=%s" % self.portMask + " --enable-rx-cksum " +
- "--port-topology=loop", socket=self.ports_socket)
+ "--port-topology=loop", socket=self.ports_socket)
self.dut.send_expect("set fwd csum", "testpmd> ")
if mode == "hw":
@@ -519,25 +511,134 @@ class TestChecksumOffload(TestCase):
self.dut.send_expect("quit", "#", 10)
self.result_table_print()
- def test_hardware_checksum_check_ip_udp(self):
- self.helper_hardware_checksum_check('Ether(dst="%s", src="%s")/IP(%s)/UDP(%s)/("X"*50)',
- do_l3_csum=True)
+ def test_hardware_checksum_check_ip(self):
+ self.dut.send_expect("start", "testpmd>")
+ self.checksum_enablehw(self.dut_ports[0])
+
+ verification_errors: List[VerifyFailure] = []
- def test_hardware_checksum_check_ip_tcp(self):
- self.helper_hardware_checksum_check('Ether(dst="%s", src="%s")/IP(%s)/TCP(%s)/("X"*50)',
- do_l3_csum=True)
+ # untunnelled
+ vf = self.try_helper_hardware_checksum_check_catch_failure('Ether(dst="%s", src="%s")/IP(%s)/UDP()/("X"*50)',
+ "PKT_RX_IP_CKSUM_")
+ if vf is not None:
+ verification_errors.append(vf)
- def test_hardware_checksum_check_ip_sctp(self):
- self.helper_hardware_checksum_check('Ether(dst="%s", src="%s")/IP(%s)/SCTP(%s)/("X"*50)',
- do_l3_csum=True)
+ # tunneled inner
+ vf = self.try_helper_hardware_checksum_check_catch_failure(
+ 'Ether(dst="%s", src="%s")/IP()/UDP()/IP(%s)/("X"*50)',
+ "PKT_RX_OUTER_IP_CKSUM_")
+ if vf is not None:
+ verification_errors.append(vf)
- def test_hardware_checksum_check_ipv6_udp(self):
- self.helper_hardware_checksum_check('Ether(dst="%s", src="%s")/IPv6(src="::1")/UDP(%s)/("X"*50)',
- do_l3_csum=False)
+ # tunneled outer
+ vf = self.try_helper_hardware_checksum_check_catch_failure(
+ 'Ether(dst="%s", src="%s")/IP()/UDP()/IP(%s)/("X"*50)',
+ "PKT_RX_OUTER_IP_CKSUM_")
+ if vf is not None:
+ verification_errors.append(vf)
- def test_hardware_checksum_check_ipv6_tcp(self):
- self.helper_hardware_checksum_check('Ether(dst="%s", src="%s")/IPv6(src="::1")/TCP(%s)/("X"*50)',
- do_l3_csum=False)
+ self.verify(len(verification_errors) == 0, "\n".join(verification_errors))
+
+ self.dut.send_expect("stop", "testpmd>")
+
+ def test_hardware_checksum_check_l4(self):
+ self.checksum_enablehw(self.dut_ports[0])
+ self.dut.send_expect("start", "testpmd>")
+
+ verification_errors: List[VerifyFailure] = []
+
+ l3_protos: List[str] = [
+ "IP",
+ "IPv6"
+ ]
+
+ l4_protos: List[str] = [
+ "UDP",
+ "TCP",
+ "SCTP",
+ ]
+
+ iface = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0]))
+ dut_mac = self.dut.get_mac_address(self.dut_ports[0])
+ tester_mac = self.tester.get_mac(self.tester.get_local_port(self.dut_ports[0]))
+
+ self.tester.send_expect("scapy", ">>> ")
+ self.scapy_exec(f"eth = Ether(dst='{dut_mac}', src='{tester_mac}')")
+ self.scapy_exec(f"iface = '{iface}'")
+ # Untunneled
+ for l3 in l3_protos:
+ for l4 in l4_protos:
+ for chksum in "", "chksum=0xf":
+ vf = self.send_pkt_expect_good_bad_from_flag_catch_failure(
+ f"eth/{l3}()/{l4}({chksum})/('X'*50)",
+ "PKT_RX_L4_CKSUM_", f"{l3}/{l4}",
+ should_pass=(chksum == ""))
+ if vf is not None:
+ verification_errors.append(vf)
+
+ # Tunneled
+ # VXLAN
+ for l3 in l3_protos:
+ for l4 in l4_protos:
+ for outer_arg in "", "chksum=0xf":
+ for inner_arg in "", "chksum=0xf":
+ for flag in "PKT_RX_L4_CKSUM_", "PKT_RX_OUTER_L4_CKSUM_":
+ if flag == "PKT_RX_L4_CKSUM_":
+ should_pass = inner_arg == ""
+ else: # flag == PKT_RX_OUTER_L4_CKSUM_
+ should_pass = outer_arg == ""
+ vf = self.send_pkt_expect_good_bad_from_flag_catch_failure(
+ f"eth/{l3}()/{l4}({outer_arg})/VXLAN()/{l3}()/"
+ f"{l4}({inner_arg})/('X'*50)",
+ flag, f"{l3}/{l4}/VXLAN/{l3}/{l4}",
+ should_pass=should_pass)
+
+ if vf is not None:
+ verification_errors.append(vf)
+
+ # GRE
+ for l3 in l3_protos:
+ for l4 in l4_protos:
+ for inner_arg in "", "chksum=0xf":
+ should_pass: bool = inner_arg == ""
+ vf = self.send_pkt_expect_good_bad_from_flag_catch_failure(
+ f"eth/{l3}()/GRE()/{l3}()/"
+ f"{l4}({inner_arg})/('X'*50)",
+ "PKT_RX_L4_CKSUM_", f"{l3}/GRE/{l3}/{l4}",
+ should_pass=should_pass)
+
+ if vf is not None:
+ verification_errors.append(vf)
+
+ # This section is commented out because GENEVE is not supported in the current version (2.3.3) that is used
+ # in dts. This will be available in scapy 2.4.3, so this was added and commented out so that when scapy is
+ # updated this test case can easily take advantage of the new functionality.
+
+ # # GENEVE
+ # for l3_outer in l3_protos:
+ # for l4_outer in l4_protos:
+ # for l3_inner in l3_protos:
+ # for l4 in l4_protos:
+ # for outer_arg in "", "chksum=0xf":
+ # for inner_arg in "", "chksum=0xf":
+ # for flag in "PKT_RX_L4_CKSUM_", "PKT_RX_OUTER_L4_CKSUM_":
+ # should_pass: bool = inner_arg == "" if flag == "PKT_RX_L4_CKSUM_" else outer_arg == ""
+ # vf = self.send_pkt_expect_good_bad_from_flag_catch_failure(
+ # f"eth/{l3_outer}()/{l4_outer}({outer_arg})/GENEVE()/eth/{l3_inner}()/"
+ # f"{l4}({inner_arg})/('X'*50)",
+ # flag, f"{l3_outer}/{l4_outer}/VXLAN/{l3_inner}/{l4}",
+ # should_pass=should_pass)
+ #
+ # if vf is not None:
+ # verification_errors.append(vf)
+
+ # tunneled inner
+
+ for err in verification_errors:
+ self.logger.error(str(err))
+ self.verify(len(verification_errors) == 0, "See previous output")
+
+ self.dut.send_expect("stop", "testpmd>")
def tear_down(self):
"""
--
2.25.1
More information about the dts
mailing list