From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 29DBBA0471 for ; Wed, 14 Aug 2019 10:50:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1B8041BE0C; Wed, 14 Aug 2019 10:50:10 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id B6DDC1BDAE for ; Wed, 14 Aug 2019 10:50:07 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Aug 2019 01:50:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,384,1559545200"; d="scan'208";a="194462976" Received: from unknown (HELO dpdk-wenjielx-dtspatch135.sh.intel.com) ([10.240.176.135]) by fmsmga001.fm.intel.com with ESMTP; 14 Aug 2019 01:50:05 -0700 From: Peng Yuan To: dts@dpdk.org Cc: Peng Yuan Date: Wed, 14 Aug 2019 16:54:41 +0800 Message-Id: <1565772881-91873-1-git-send-email-yuan.peng@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dts] [PATCH v2]tests: add tx checksum case to TestSuite_rxtx_offload.py 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: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Add tx checksum case to TestSuite_rxtx_offload.py Signed-off-by: Peng Yuan diff --git a/tests/TestSuite_rxtx_offload.py b/tests/TestSuite_rxtx_offload.py index 77d4f3f..2166c16 100644 --- a/tests/TestSuite_rxtx_offload.py +++ b/tests/TestSuite_rxtx_offload.py @@ -107,10 +107,6 @@ class TestRxTx_Offload(TestCase): self.pf_pci = self.dut.ports_info[self.dut_ports[0]]['pci'] self.pmdout = PmdOutput(self.dut) self.cores = "1S/4C/1T" - self.jumbo_pkt1 = r'sendp([Ether(dst="%s")/IP(dst="192.168.0.1",src="192.168.0.2", len=8981)/Raw(load="P"*8961)], iface="%s")' % (self.pf_mac, self.tester_itf0) - self.jumbo_pkt2 = r'sendp([Ether(dst="%s")/IP(dst="192.168.0.1",src="192.168.0.3", len=8981)/Raw(load="P"*8961)], iface="%s")' % (self.pf_mac, self.tester_itf0) - self.vlan_pkt1 = r'sendp([Ether(dst="%s")/Dot1Q(vlan=1)/IP(src="192.168.0.1",dst="192.168.0.3")/UDP(sport=33, dport=34)/Raw("x"*20)], iface="%s")' % (self.pf_mac, self.tester_itf0) - self.vlan_pkt2 = r'sendp([Ether(dst="%s")/Dot1Q(vlan=1)/IP(src="192.168.0.2",dst="192.168.0.3")/UDP(sport=33, dport=34)/Raw("x"*20)], iface="%s")' % (self.pf_mac, self.tester_itf0) def set_up(self): """ @@ -118,7 +114,6 @@ class TestRxTx_Offload(TestCase): """ pass - def verify_link_up(self, max_delay=10): ports = self.dut.get_ports(self.nic) for port_id in range(len(ports)): @@ -153,20 +148,20 @@ class TestRxTx_Offload(TestCase): i = i + 1 return offload_keys - def check_port_config(self, rxtx, offload): + def check_port_config(self, rxtx, offload, port_id=0): """ Check configuration per port. """ global offloads - result_config = self.dut.send_expect("port start 0", "testpmd> ") + result_config = self.dut.send_expect("port start %d" % port_id, "testpmd> ") self.verify("Fail" not in result_config, "Fail to configure port") self.verify_link_up(20) if rxtx == "rx": - outstring = self.dut.send_expect("show port 0 rx_offload configuration", "testpmd> ") + outstring = self.dut.send_expect("show port %d rx_offload configuration" % port_id, "testpmd> ") elif rxtx == "tx": - outstring = self.dut.send_expect("show port 0 tx_offload configuration", "testpmd> ") + outstring = self.dut.send_expect("show port %d tx_offload configuration" % port_id, "testpmd> ") result_scanner = r"Port : (.*?)\n" scanner = re.compile(result_scanner, re.DOTALL) @@ -255,6 +250,47 @@ class TestRxTx_Offload(TestCase): self.verify("PKT_RX_VLAN_STRIPPED" not in outstring, "Fail to configure offload by queue.") self.dut.send_expect("stop", "testpmd>") + def checksum_valid_flags(self, packet, direction, flags): + """ + Sends packets and check the checksum valid-flags. + """ + self.dut.send_expect("start", "testpmd>") + self.tester.scapy_foreground() + self.tester.scapy_append(packet) + self.tester.scapy_execute() + out = self.dut.get_session_output(timeout=1) + lines = out.split("\r\n") + + # collect the rx checksum result + if (direction == "rx"): + for line in lines: + line = line.strip() + if len(line) != 0 and line.startswith("rx") and ("flags" in line): + if ("ipv4" in flags): + self.verify("PKT_RX_IP_CKSUM_BAD" in line, "ipv4 checksum flag is wrong!") + else: + self.verify("PKT_RX_IP_CKSUM_GOOD" in line, "ipv4 checksum flag is wrong!") + if ("udp" in flags) or ("tcp" in flags): + self.verify("PKT_RX_L4_CKSUM_BAD" in line, "L4 checksum flag is wrong!") + else: + self.verify(("PKT_RX_L4_CKSUM_GOOD" in line) or ("PKT_RX_L4_CKSUM_UNKNOWN" in line), "L4 checksum flag is wrong!") + # collect the tx checksum result + if (direction == "tx"): + for line in lines: + line = line.strip() + if len(line) != 0 and line.startswith("tx") and ("flags" in line): + if ("ipv4" in flags): + self.verify("PKT_TX_IP_CKSUM" in line, "There is no ipv4 tx checksum flag!") + if ("udp" in flags): + self.verify("PKT_TX_UDP_CKSUM" in line, "There is no udp tx checksum flag!") + if ("tcp") in flags: + self.verify("PKT_TX_TCP_CKSUM" in line, "There is no tcp tx checksum flag!") + if ("sctp") in flags: + self.verify("PKT_TX_SCTP_CKSUM" in line, "There is no sctp tx checksum flag!") + if (flags == []): + self.verify(("PKT_TX_L4_NO_CKSUM" in line) and ("PKT_TX_IP_CKSUM" not in line), "The tx checksum flag is wrong!") + self.dut.send_expect("stop", "testpmd>") + def verify_result(self, packet, expect_rxpkts, expect_queue): """ verify if the packet is to the expected queue @@ -294,6 +330,10 @@ class TestRxTx_Offload(TestCase): """ Set Rx offload by port. """ + # Define jumboframe packets + self.jumbo_pkt1 = r'sendp([Ether(dst="%s")/IP(dst="192.168.0.1",src="192.168.0.2", len=8981)/Raw(load="P"*8961)], iface="%s")' % (self.pf_mac, self.tester_itf0) + self.jumbo_pkt2 = r'sendp([Ether(dst="%s")/IP(dst="192.168.0.1",src="192.168.0.3", len=8981)/Raw(load="P"*8961)], iface="%s")' % (self.pf_mac, self.tester_itf0) + self.pmdout.start_testpmd("%s" % self.cores, "--rxq=4 --txq=4 --max-pkt-len=9000") self.dut.send_expect("set fwd rxonly", "testpmd> ") self.dut.send_expect("set verbose 1", "testpmd> ") @@ -337,10 +377,25 @@ class TestRxTx_Offload(TestCase): """ Set Rx offload by port in cmdline. """ + # Define rx checksum packets + self.rxcksum_pkt1 = r'sendp([Ether(dst="%s")/IP(dst="192.168.0.1")/TCP(sport=33, dport=34)/Raw("x"*20)], iface="%s")' % (self.pf_mac, self.tester_itf0) + self.rxcksum_pkt2 = r'sendp([Ether(dst="%s")/IP(chksum=0x0)/TCP(chksum=0xf)/Raw("x"*20)], iface="%s")' % (self.pf_mac, self.tester_itf0) + self.rxcksum_pkt3 = r'sendp([Ether(dst="%s")/IP(dst="192.168.0.1")/UDP(chksum=0xf)/Raw("x"*20)], iface="%s")' % (self.pf_mac, self.tester_itf0) + self.rxcksum_pkt4 = r'sendp([Ether(dst="%s")/IP(chksum=0x0)/UDP(sport=33, dport=34)/Raw("x"*20)], iface="%s")' % (self.pf_mac, self.tester_itf0) + flags = [] + self.pmdout.start_testpmd("%s" % self.cores, "--rxq=4 --txq=4 --enable-rx-cksum") + self.dut.send_expect("set fwd csum", "testpmd> ") + self.dut.send_expect("set verbose 1", "testpmd> ") offload = ['ipv4_cksum', 'udp_cksum', 'tcp_cksum'] self.check_port_config("rx", offload) + # Check the rx checksum flags + self.checksum_valid_flags(self.rxcksum_pkt1, "rx", []) + self.checksum_valid_flags(self.rxcksum_pkt2, "rx", ["ipv4","tcp"]) + self.checksum_valid_flags(self.rxcksum_pkt3, "rx", ["udp"]) + self.checksum_valid_flags(self.rxcksum_pkt4, "rx", ["ipv4"]) + # Disable the rx cksum per_port self.dut.send_expect("port stop 0", "testpmd> ") self.dut.send_expect("port config 0 rx_offload udp_cksum off", "testpmd> ") @@ -390,6 +445,9 @@ class TestRxTx_Offload(TestCase): """ # Only support ixgbe NICs self.verify(self.nic in ["niantic", "twinpond", "sagepond", "sageville"], "%s nic not support rx offload setting by queue." % self.nic) + # Define the vlan packets + self.vlan_pkt1 = r'sendp([Ether(dst="%s")/Dot1Q(vlan=1)/IP(src="192.168.0.1",dst="192.168.0.3")/UDP(sport=33, dport=34)/Raw("x"*20)], iface="%s")' % (self.pf_mac, self.tester_itf0) + self.vlan_pkt2 = r'sendp([Ether(dst="%s")/Dot1Q(vlan=1)/IP(src="192.168.0.2",dst="192.168.0.3")/UDP(sport=33, dport=34)/Raw("x"*20)], iface="%s")' % (self.pf_mac, self.tester_itf0) self.pmdout.start_testpmd("%s" % self.cores, "--rxq=4 --txq=4") self.dut.send_expect("set fwd rxonly", "testpmd> ") @@ -543,6 +601,54 @@ class TestRxTx_Offload(TestCase): out = self.get_tcpdump_package() self.verify("vlan 1" in out, "There is no vlan insert.") + def test_txoffload_port_checksum(self): + """ + Set Tx offload cksum. + """ + # Define tx checksum packets + self.txcksum_ipv4 = r'sendp([Ether(dst="%s")/IP(dst="192.168.0.1")/Raw("x"*20)], iface="%s")' % (self.pf_mac, self.tester_itf0) + self.txcksum_tcp = r'sendp([Ether(dst="%s")/IP(dst="192.168.0.1")/TCP(sport=33, dport=34)/Raw("x"*20)], iface="%s")' % (self.pf_mac, self.tester_itf0) + self.txcksum_udp = r'sendp([Ether(dst="%s")/IP(dst="192.168.0.1")/UDP(sport=33, dport=34)/Raw("x"*20)], iface="%s")' % (self.pf_mac, self.tester_itf0) + self.txcksum_sctp = r'sendp([Ether(dst="%s")/IP(dst="192.168.0.1")/SCTP(sport=33, dport=34)/Raw("x"*20)], iface="%s")' % (self.pf_mac, self.tester_itf0) + + flags = [] + self.pmdout.start_testpmd("%s" % self.cores, "--rxq=4 --txq=4") + self.dut.send_expect("set fwd csum", "testpmd> ") + self.dut.send_expect("set verbose 1", "testpmd> ") + + # Check the tx checksum flags + self.checksum_valid_flags(self.txcksum_ipv4, "tx", []) + self.checksum_valid_flags(self.txcksum_tcp, "tx", []) + self.checksum_valid_flags(self.txcksum_udp, "tx", []) + self.checksum_valid_flags(self.txcksum_sctp, "tx", []) + + # Disable the tx cksum per_port + self.dut.send_expect("port stop 1", "testpmd> ") + self.dut.send_expect("port config 1 tx_offload ipv4_cksum on", "testpmd> ") + self.dut.send_expect("port start 1", "testpmd> ") + offload = ['ipv4_cksum'] + self.check_port_config("tx", offload, 1) + self.checksum_valid_flags(self.txcksum_ipv4, "tx", ["ipv4"]) + + self.dut.send_expect("port stop 1", "testpmd> ") + self.dut.send_expect("port config 1 tx_offload tcp_cksum on", "testpmd> ") + self.dut.send_expect("port start 1", "testpmd> ") + offload = ['ipv4_cksum', 'tcp_cksum'] + self.check_port_config("tx", offload, 1) + self.checksum_valid_flags(self.txcksum_tcp, "tx", ["ipv4","tcp"]) + + self.dut.send_expect("port stop 1", "testpmd> ") + self.dut.send_expect("port config 1 tx_offload udp_cksum on", "testpmd> ") + offload = ['ipv4_cksum', 'tcp_cksum', 'udp_cksum'] + self.check_port_config("tx", offload, 1) + self.checksum_valid_flags(self.txcksum_udp, "tx", ["ipv4","udp"]) + + self.dut.send_expect("port stop 1", "testpmd> ") + self.dut.send_expect("port config 1 tx_offload sctp_cksum on", "testpmd> ") + offload = ['ipv4_cksum', 'tcp_cksum', 'udp_cksum', 'sctp_cksum'] + self.check_port_config("tx", offload, 1) + self.checksum_valid_flags(self.txcksum_sctp, "tx", ["ipv4","sctp"]) + def test_txoffload_port_all(self): """ Set all Tx offload capabilities by port. -- 2.7.4