From patchwork Wed Dec 28 05:14:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121431 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 DDD8EA04FD; Wed, 28 Dec 2022 06:16:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D97C241143; Wed, 28 Dec 2022 06:16:38 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id F0D3D41143 for ; Wed, 28 Dec 2022 06:16:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672204597; x=1703740597; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=19WoPP1G6TEDMewGt1H6mxIFQVzu71eOB5WLnBzZZSI=; b=JFHbQcIrCnom9EhrfXr84rnFITeOwRk+fZpnEOum4b9y+6o5B3yohgtG yg98CoeRW7LGU9H4o2ITfZgGr+VBHrnaowRP6l8kc7RZwjpoMlrvPP5AJ WnRLDdNDU40lwNXJLF1bcPI1pzWfvzKfNnMYBmhHPuP+M32iPcSp58J1u yHWuzkZ2T6fTF6QAo2FOITtHRs2GSWMcoDV2ca+nZ0j/p5hhRk0IkOonC aUzbMlG8DONTEGmIqTepEZccmenmj27DVXUspaxU0XWt7qyFBl/eMpaFY Z8Q5rpDXsKwx9ez/XKzn/yjYcjFdMepw7DTYuL1MX9ldQrWxQR0vueJsh g==; X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="348008004" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="348008004" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 21:16:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="603234355" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="603234355" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by orsmga003.jf.intel.com with ESMTP; 27 Dec 2022 21:16:33 -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 V3 1/5] tests/vf_offload: Improve checksum_validate method. Date: Wed, 28 Dec 2022 13:14:59 +0800 Message-Id: <20221228051503.36747-2-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221228051503.36747-1-ke1.xu@intel.com> References: <20221228051503.36747-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 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 --- tests/TestSuite_vf_offload.py | 93 +++++++++++++++-------------------- 1 file changed, 39 insertions(+), 54 deletions(-) diff --git a/tests/TestSuite_vf_offload.py b/tests/TestSuite_vf_offload.py index 62e74c33..279b38d8 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,34 @@ 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, + 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) ) - - 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" - + 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): From patchwork Wed Dec 28 05:15:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121432 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 14CFFA04FD; Wed, 28 Dec 2022 06:16:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0FE1042C29; Wed, 28 Dec 2022 06:16:40 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 0318A40FDF for ; Wed, 28 Dec 2022 06:16:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672204598; x=1703740598; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KMeRiXia82JZ7qVx8Uucp+H6CfCu6xh6sIlJqEtrqRU=; b=LszNqQLs6GRQkWm3SahsN4kICYbQpL7jKuf6AemBKU4UFdxH/ef9dT/C qwd8q9+M5PPnI2lcgsejXc76LBwdU86a9TIxf0NqxgskDLA8AWSGGLHR5 iuUUKEb6g0+8YtEVqIhIDUb7NBLcVngHi8hDjsM0uonJNCTDYN/VOXJZ/ EtuDOZroO7KwT4tdeylm6me+NA19o//9KJv0tNU5NQaJp3Ii83sIJx1fG 6Jr67sib+heSHor+9cdyD2whJmRjiVmStxzAdFccLfCY0zA1CAnSBieL/ GeNHoKPQvMSFAuSujR+HZDGL7lfVseX6c1fFEqS0rUoTjWS1iPEKP6X0k w==; X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="348008009" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="348008009" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 21:16:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="603234360" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="603234360" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by orsmga003.jf.intel.com with ESMTP; 27 Dec 2022 21:16: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 V3 2/5] tests/vf_offload: Remove redundant variable used. Date: Wed, 28 Dec 2022 13:15:00 +0800 Message-Id: <20221228051503.36747-3-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221228051503.36747-1-ke1.xu@intel.com> References: <20221228051503.36747-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 279b38d8..f922b6d9 100644 --- a/tests/TestSuite_vf_offload.py +++ b/tests/TestSuite_vf_offload.py @@ -354,7 +354,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 Wed Dec 28 05:15:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121433 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 33A4CA04FD; Wed, 28 Dec 2022 06:16:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2B96542C24; Wed, 28 Dec 2022 06:16:42 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 0076540FDF for ; Wed, 28 Dec 2022 06:16:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672204600; x=1703740600; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SxPRFSK/v4IVdDtbL5ScCXbamMQPLZ6U83tu8fi/bE8=; b=UVhIGEWEaLg/4pOVvUJ35/F99HYpBCNdDVCfCRVOcAGsX2XwpXUVlUt/ iVfnr1x/cqdBQZxCeFqslHO3kZjaOFNsED+xOO25ZMH4sF5hTeEErCTC2 sAQFq8haDKJtYrtAoOFnHLs8R9b+D0cJwlck39i0i9ThzBOMpvVI2+WsK CX+BnTbX9YoyrNMZ9luW8ls4sPMSqU4GCUVo8qz/Raa9VPTavHjnCE5vJ iPeX3bfu0XueTY1TtsqhX6nAJMjQ1Qm+REmjPaPuQIorJWfDaQrOYvoo0 Uxf+NNbK1Opje75Wuqwn5ArIE2z8fCcyy+KUkGcEnz3tlibPhW2vuIY5u g==; X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="348008014" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="348008014" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 21:16:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="603234365" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="603234365" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by orsmga003.jf.intel.com with ESMTP; 27 Dec 2022 21:16:37 -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 V3 3/5] tests/vf_offload: Use modified checksum_validate to replace checksum_validate_tunnel. Date: Wed, 28 Dec 2022 13:15:01 +0800 Message-Id: <20221228051503.36747-4-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221228051503.36747-1-ke1.xu@intel.com> References: <20221228051503.36747-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 f922b6d9..51313743 100644 --- a/tests/TestSuite_vf_offload.py +++ b/tests/TestSuite_vf_offload.py @@ -400,64 +400,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"] ) @@ -576,7 +518,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) @@ -594,6 +536,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 Wed Dec 28 05:15:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121434 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 55C2CA04FD; Wed, 28 Dec 2022 06:16:43 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 516D5410E5; Wed, 28 Dec 2022 06:16:43 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id CBB7B40FDF for ; Wed, 28 Dec 2022 06:16:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672204601; x=1703740601; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nF13wOY19r+dvVwLhkFyA2gU3PsUsDbV8VYxe2R1/1M=; b=MKG7EV6nYV4o6g2UrONfxCrGpT1T8VLanJjDYcNv7WMBMIfm+1LMtMJ/ DQT1aLY2JNBhp+wIoSFuLpy0MmAgPQcrs/HRozU9qkRGu/ZF4SaeauKzd MjblnrjmXqHk8WIiTrdXQMBS3wCiE75yWWv+aQdN3AUY9Zj4nNymtRU8v gOCxGyyT0lJ8SYi2SaxtvbZc7NdC5LfY5inG79BYS91FpsJxUhR2tJGgX DN8+oDxTwgp3EomY6F8R9SXfJcAH+nLjreSfNkcwBZE6OUikdN0dT5gyE d23ZqcpahCS2jnqzHRa+mCyFVRRXESoy0eimkNXOy0Uo7I+v6vjxG3DHD g==; X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="348008018" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="348008018" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 21:16:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="603234372" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="603234372" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by orsmga003.jf.intel.com with ESMTP; 27 Dec 2022 21:16:39 -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 V3 4/5] tests/vf_offload: Improve tcpdump_analyse_sniff method Date: Wed, 28 Dec 2022 13:15:02 +0800 Message-Id: <20221228051503.36747-5-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221228051503.36747-1-ke1.xu@intel.com> References: <20221228051503.36747-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 | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/TestSuite_vf_offload.py b/tests/TestSuite_vf_offload.py index 51313743..7a66229a 100644 --- a/tests/TestSuite_vf_offload.py +++ b/tests/TestSuite_vf_offload.py @@ -628,17 +628,11 @@ 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 Wed Dec 28 05:15:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121435 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 7BB36A04FD; Wed, 28 Dec 2022 06:16:46 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 77AE242D15; Wed, 28 Dec 2022 06:16:46 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id E52B440FDF for ; Wed, 28 Dec 2022 06:16:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672204604; x=1703740604; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nU2DulV421nuwo3TdFmDoJpTDajWHkjl/4WaOPy6MvU=; b=DBWLLRMzYnpq7bMOEQaTkg7e4+UbCM6fkO2BSqh10LyD49DjpWVSWW84 5sstxUCAnuficEfPsbRNbt7jafv6SmhlNBdQT81J0kxe44yUx6Yq74ZAr nU2WZlCmZqyfobRfSbIw+sk67RgLn6+G/QIzzSbKYTpq4MDl1o5nadI0K lbkSSFq8742fetVOH22Hk52bEKbqzy7i2jWYyojuutD6/EI8OBOaa8R3v 9UjbU2lzvQBeJKqj3wKRpmfmBod2n4FWFyZoF1rZpVbMDYMRApFvssbsH fyDTmiCRd0AwqM16P2yC0ck8ecE+QzRV8XwH06pEZvXq221bNUouK0Xbh A==; X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="348008025" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="348008025" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 21:16:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="603234382" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="603234382" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by orsmga003.jf.intel.com with ESMTP; 27 Dec 2022 21:16:41 -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 V3 5/5] tests/vf_offload: Replace the tcpdump implementation to a packet reading implementation. Date: Wed, 28 Dec 2022 13:15:03 +0800 Message-Id: <20221228051503.36747-6-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221228051503.36747-1-ke1.xu@intel.com> References: <20221228051503.36747-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 Tested-by: Weiyuan Li --- 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 7a66229a..7a55c791 100644 --- a/tests/TestSuite_vf_offload.py +++ b/tests/TestSuite_vf_offload.py @@ -635,43 +635,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. @@ -769,27 +732,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: @@ -804,27 +766,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( @@ -923,6 +884,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( @@ -966,6 +928,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(