From patchwork Tue Dec 27 10:21:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121415 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5A7C6A04FD; Tue, 27 Dec 2022 11:24:32 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 50FAF410FC; Tue, 27 Dec 2022 11:24:32 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id DD2BC40E2D for ; Tue, 27 Dec 2022 11:24:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672136671; x=1703672671; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QnYSzv1qAly3QG9EW2rFSU8frqj/EAVuPxevsuOYUXo=; b=axBtif6+HlPGzB16xmh3U6kIlNAht2KWxoZ4AhxyzCZmX8p+1kfcLZAN hLjodnWhNSoGsaSyfBR+qUlVarnECps07uO9+OtgNB+bfaN/99JG3eWjY Q4xVJfOgi1M7YVAqcDxSE9h3OagDtaaDQYAX0yj1FZY/bs5rzv4jxC8eA 944zgofdRgbXxzGhaK/ZdyOpnyOTY4rwYQYLp8XNx/LLhSFF6lBm2UId+ SJRIxpEDNZJcNVfACdeOoOIY4xshBsTaUxSBgVJMZRL4tXzZJZ6xm6/k4 PwyerWh623f9dZfcek4ziQUDwSK2m1Ll20kAZgjPXS4OfKP2GlqfvGw45 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="322656413" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="322656413" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 02:24:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="760292028" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="760292028" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by fmsmga002.fm.intel.com with ESMTP; 27 Dec 2022 02:24:27 -0800 From: Ke Xu To: dts@dpdk.org Cc: qi.fu@intel.com, weiyuanx.li@intel.com, lijuan.tu@intel.com, ke1.xu@intel.com Subject: [DTS][PATCH V1 1/5] tests/vf_offload: Improve checksum_validate method. Date: Tue, 27 Dec 2022 18:21:29 +0800 Message-Id: <20221227102131.529684-2-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221227102131.529684-1-ke1.xu@intel.com> References: <20221227102131.529684-1-ke1.xu@intel.com> MIME-Version: 1.0 X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 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 Use packet.show(dump) methods and packet reading to validate 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 --- 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..009da148 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[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): From patchwork Tue Dec 27 10:21:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121416 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 75006A04FD; Tue, 27 Dec 2022 11:24:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6FE9B41144; Tue, 27 Dec 2022 11:24:39 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 7310140E2D for ; Tue, 27 Dec 2022 11:24:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672136678; x=1703672678; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1WmL0g99YrafmE+/9uLjuDrgPn8JsBIRHME/nmxC5hQ=; b=ixr68te+TwdW96CjEMA59Aobh2sW2yUhhAGFm9Cr65iPEmSethRLCTj9 YHPq0LqhkJarWa+aYP3mEcmzqStWiOUDmEQiSYraJ1/X3XaDP4U6D1irx JVFOKiqUxHYko5+FGvJA0Txc5JSKt1oSTg1emhr4BXc3BXHi6fVrcs64R 4QJgopIXcaB+Fh4cmih1+fnaHkGU5l2dmtqjLYFHRHdwoOrK/1o8ei8yg cjSB2lw7M3yi8Y9cPzaEMt/UZIk4/QmbZQfT/DF66AVahMnXDV5az5ZV3 VnKMcY40w3ZYRwuFXkmwyrG3ALDUFSZSw7Dtu0ZdRpobTVyiRVCdp8fiT Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="322656419" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="322656419" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 02:24:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="760292042" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="760292042" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by fmsmga002.fm.intel.com with ESMTP; 27 Dec 2022 02:24:35 -0800 From: Ke Xu To: dts@dpdk.org Cc: qi.fu@intel.com, weiyuanx.li@intel.com, lijuan.tu@intel.com, ke1.xu@intel.com Subject: [DTS][PATCH V1 2/5] tests/vf_offload: Remove redundant variable used. Date: Tue, 27 Dec 2022 18:21:31 +0800 Message-Id: <20221227102131.529684-3-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221227102131.529684-1-ke1.xu@intel.com> References: <20221227102131.529684-1-ke1.xu@intel.com> MIME-Version: 1.0 X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 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 Signed-off-by: Ke Xu --- 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 009da148..fa56578b 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" From patchwork Tue Dec 27 10:21:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121417 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9C029A04FD; Tue, 27 Dec 2022 11:25:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 968C741143; Tue, 27 Dec 2022 11:25:11 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 0D31740E2D for ; Tue, 27 Dec 2022 11:25:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672136710; x=1703672710; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ax8d1oOAJTnOexRBv0RMJgSkzPwyzjrYSDEbZorn7nQ=; b=GdIQEZn3GR0oK/G2es5GrJ24KRIovBy/RXM/bYyyhpWVb5E7x4hR+7MP 9DqnH3+q0zC4h9iSMu5LtVqM6Oc9uRdRoa1h+T9sHQ3MBzwy9x/PlPePE DPbRop+HfD4gY2EYz5ecy5pFWE/4UcwiCmGgmg+vakf6e4VlMoBcuVBGf JQzRRnx7gjOsPt7IuM9NusTae+uYvrX+LMV3yAl/ZOHsw1MA67AJO6knz AWyIFHokTDch+phEPVkiCjcCoem9DT0DO6u+y6Z3BpHY9elZm+UG8TO2j APgNMJxRCoKlA7vE/NaP6eMc/py87b9CwmV47ezrsijWIC4CaVaM0N+5q g==; X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="322656462" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="322656462" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 02:25:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="760292185" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="760292185" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by fmsmga002.fm.intel.com with ESMTP; 27 Dec 2022 02:25:06 -0800 From: Ke Xu To: dts@dpdk.org Cc: qi.fu@intel.com, weiyuanx.li@intel.com, lijuan.tu@intel.com, ke1.xu@intel.com Subject: [DTS][PATCH V1 3/5] tests/vf_offload: Use modified checksum_validate to replace checksum_validate_tunnel. Date: Tue, 27 Dec 2022 18:21:33 +0800 Message-Id: <20221227102131.529684-4-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221227102131.529684-1-ke1.xu@intel.com> References: <20221227102131.529684-1-ke1.xu@intel.com> MIME-Version: 1.0 X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 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 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 --- 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 fa56578b..d6f2a134 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. From patchwork Tue Dec 27 10:21:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121418 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 73C06A04FD; Tue, 27 Dec 2022 11:25:33 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6DC48410FC; Tue, 27 Dec 2022 11:25:33 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 2DF0640E2D for ; Tue, 27 Dec 2022 11:25:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672136731; x=1703672731; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X7Bnt1WTgmyszdwlgr4TPk0pCFNccZq++5dL8Y3JWWA=; b=YB2m4T0rZaXRxujDrVyYdb/rlVK3f4VnH9wOBv4NuOmivCe4xW96O+nu 8RikM6bVDltp8CKf7VHWGBhq5HCfNxWLzAmpGCQS2osGFxo/8VX2j3D69 OitzRG4HnwE38CAtMarM/ji8CMoEN/zgQO1+kwuFoZH7Etat3JaozRPUg 2KjCaBj4594FX5FlcNsk4PvsAdXqEluzersaFSRqHr2c+QCjfawq6XQ6i rVN62ZjfgsJpmG1GD/Oj7KiZOAM4wFf7Rxm0kEDXl0+QTtNnIpYw9FyIs yfRg5JE3HMLRHciFOKxBEcyPPIr8Gs7v0dS2ztAmxkMwOZIyjDdHuDZqC w==; X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="322656489" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="322656489" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 02:25:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="760292263" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="760292263" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by fmsmga002.fm.intel.com with ESMTP; 27 Dec 2022 02:25:28 -0800 From: Ke Xu To: dts@dpdk.org Cc: qi.fu@intel.com, weiyuanx.li@intel.com, lijuan.tu@intel.com, ke1.xu@intel.com Subject: [DTS][PATCH V1 4/5] tests/vf_offload: Improve tcpdump_analyse_sniff method Date: Tue, 27 Dec 2022 18:21:35 +0800 Message-Id: <20221227102131.529684-5-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221227102131.529684-1-ke1.xu@intel.com> References: <20221227102131.529684-1-ke1.xu@intel.com> MIME-Version: 1.0 X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 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 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 --- 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 d6f2a134..eb702559 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): From patchwork Tue Dec 27 10:21:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121419 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 989D3A04FD; Tue, 27 Dec 2022 11:25:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 936F241143; Tue, 27 Dec 2022 11:25:58 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 3919C40E2D for ; Tue, 27 Dec 2022 11:25:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672136757; x=1703672757; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8VvSmRqotTiHOh+yO0ZvJM8E68b1WHOdT6X6aou0HJY=; b=koFX2+Ts0Rx1DI535DG5t5HwkX4vX+A7OUXn1ne0zEzAlbiRy2ObSvCw wAr5I/k/moVu6hh17qH8OtWJWGMke1e0H42S7BDzoEOtwCxwEnk3FwEOw PTa7brKSaE0Bh9HvYkyYoHK1rH7EVjzkH7tu+RCjgEqMluzl7v9sPzYMD McIl/1twpMobw6VxSDw7fu0IvXZS5ntcZV1cUmSIfcwNJVRoH7bKzR+B4 SzxotDQ7xMoWDAOvT8esPloLDSejFGTFYOVGPAGTQPrweDtI1wZKaSckw M83nTklAKhhYKwP3CPlAGCkmNMbvweU/L0kmy8pysr51onhtDmy+u1jAX w==; X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="322656504" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="322656504" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 02:25:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="760292314" X-IronPort-AV: E=Sophos;i="5.96,278,1665471600"; d="scan'208";a="760292314" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by fmsmga002.fm.intel.com with ESMTP; 27 Dec 2022 02:25:54 -0800 From: Ke Xu To: dts@dpdk.org Cc: qi.fu@intel.com, weiyuanx.li@intel.com, lijuan.tu@intel.com, ke1.xu@intel.com Subject: [DTS][PATCH V1 5/5] tests/vf_offload: Replace the tcpdump implementation to a packet reading implementation. Date: Tue, 27 Dec 2022 18:21:37 +0800 Message-Id: <20221227102131.529684-6-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221227102131.529684-1-ke1.xu@intel.com> References: <20221227102131.529684-1-ke1.xu@intel.com> MIME-Version: 1.0 X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 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 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 --- 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 eb702559..f2356c76 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(