From patchwork Wed Dec 28 05:08:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121425 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 79E10A0540; Wed, 28 Dec 2022 06:10:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 115554161A; Wed, 28 Dec 2022 06:10:24 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id DCA1C40FDF for ; Wed, 28 Dec 2022 06:10:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672204223; x=1703740223; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NO/XTrGHV0LapGI69dz9JKmzVp9xjaeGJlJ1U9xKSrM=; b=LhlPj3uxRcBYV52EWs3xRJeNPLxkuBURQPpFkmJn1fQVx2xYoOC41es4 77tqvN7+fynmPXCWf9TageD7jVUjLpy2i/nX0biY44E+NsMhthDhXpybj 70dOUa9jk4zTNLG8DGGgT+4+NH/XkkkKwalbspJx26efbGlscPFhAn0I2 jAk9LjaWqyxxcQbUex9FPcUydPSRTK6RNNyq2gkCfDWcm9gCRLx4mA39E cqzlFmhNL6NvjojT8pKTzlB9tFi/FO8EkErTy3qqjBmLy6w9x4peYbcd2 dqxBC8D+VQjigabQbsaLcoyzKnx3tqeGDbx+DJf2peZ8N11Y0Yv7I+e1n A==; X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="300499465" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="300499465" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 21:10:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="760536347" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="760536347" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by fmsmga002.fm.intel.com with ESMTP; 27 Dec 2022 21:10:20 -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 V2 1/5] tests/vf_offload: Improve checksum_validate method. Date: Wed, 28 Dec 2022 13:08:46 +0800 Message-Id: <20221228050850.33004-2-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221228050850.33004-1-ke1.xu@intel.com> References: <20221228050850.33004-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 | 89 +++++++++++++---------------------- 1 file changed, 34 insertions(+), 55 deletions(-) diff --git a/tests/TestSuite_vf_offload.py b/tests/TestSuite_vf_offload.py index 62e74c33..abe7d752 100644 --- a/tests/TestSuite_vf_offload.py +++ b/tests/TestSuite_vf_offload.py @@ -253,6 +253,16 @@ class TestVfOffload(TestCase): dut.send_expect("tunnel_tso set 800 %d" % port, "testpmd>") dut.send_expect("port start %d" % port, "testpmd>") + def filter_packets(self, packets): + return [ + p + for p in packets + if len(p.layers()) >= 3 + and p.layers()[1] in {IP, IPv6} + and p.layers()[2] in {IP, IPv6, UDP, TCP, SCTP, GRE, MPLS} + and Raw in p + ] + def checksum_validate(self, packets_sent, packets_expected): """ Validate the checksum. @@ -266,17 +276,16 @@ class TestVfOffload(TestCase): sniff_src = self.vm0_testpmd.get_port_mac(0) checksum_pattern = re.compile("chksum.*=.*(0x[0-9a-z]+)") sniff_src = "52:00:00:00:00:00" - chksum = dict() + expected_chksum_list = dict() result = dict() - self.tester.send_expect("scapy", ">>> ") - + self.tester.send_expect("from scapy.contrib.gtp import GTP_U_Header", ">>>") for packet_type in list(packets_expected.keys()): self.tester.send_expect("p = %s" % packets_expected[packet_type], ">>>") out = self.tester.send_expect("p.show2()", ">>>") - chksums = checksum_pattern.findall(out) - chksum[packet_type] = chksums - print(packet_type, ": ", chksums) + chksum = checksum_pattern.findall(out) + expected_chksum_list[packet_type] = chksum + print(packet_type, ": ", chksum) self.tester.send_expect("exit()", "#") @@ -289,7 +298,7 @@ class TestVfOffload(TestCase): # Send packet. self.tester.scapy_foreground() - + self.tester.scapy_append("from scapy.contrib.gtp import GTP_U_Header") for packet_type in list(packets_sent.keys()): self.tester.scapy_append( 'sendp([%s], iface="%s")' % (packets_sent[packet_type], tx_interface) @@ -297,58 +306,28 @@ class TestVfOffload(TestCase): self.tester.scapy_execute() out = self.tester.scapy_get_result() - - p = self.tester.load_tcpdump_sniff_packets(inst) - nr_packets = len(p) - print(p) - packets_received = [ - p[i].sprintf("%IP.chksum%;%TCP.chksum%;%UDP.chksum%;%SCTP.chksum%") - for i in range(nr_packets) - ] + packets_received = self.filter_packets(self.tester.load_tcpdump_sniff_packets(inst)) + print(list(packets_received)) self.verify( len(packets_sent) == len(packets_received), "Unexpected Packets Drop" ) - - for packet_received in packets_received: - ( - ip_checksum, - tcp_checksum, - udp_checksum, - sctp_checksum, - ) = packet_received.split(";") - print( - "ip_checksum: ", - ip_checksum, - "tcp_checksum:, ", - tcp_checksum, - "udp_checksum: ", - udp_checksum, - "sctp_checksum: ", - sctp_checksum, - ) - - packet_type = "" - l4_checksum = "" - if tcp_checksum != "??": - packet_type = "TCP" - l4_checksum = tcp_checksum - elif udp_checksum != "??": - packet_type = "UDP" - l4_checksum = udp_checksum - elif sctp_checksum != "??": - packet_type = "SCTP" - l4_checksum = sctp_checksum - - if ip_checksum != "??": - packet_type = "IP/" + packet_type - if chksum[packet_type] != [ip_checksum, l4_checksum]: - result[packet_type] = packet_type + " checksum error" - else: - packet_type = "IPv6/" + packet_type - if chksum[packet_type] != [l4_checksum]: - result[packet_type] = packet_type + " checksum error" - + for i in range(len(packets_sent)): + packet_type = list(packets_sent.keys())[i] + checksum_received = checksum_pattern.findall(packets_received[i].show2(dump=True)) + checksum_expected = expected_chksum_list[list(packets_sent.keys())[i]] + self.logger.debug(f"checksum_received: {checksum_received}") + self.logger.debug(f"checksum_expected: {checksum_expected}") + if not len(checksum_expected) == len(checksum_received): + result[packet_type] = ( + packet_type + " Failed:" + + f"The chksum type {packet_type} length of the actual result is inconsistent with the expected length!" + ) + elif not (checksum_received == checksum_expected): + result[packet_type] = ( + packet_type + " Failed:" + + f"The actually received chksum {packet_type} is inconsistent with the expectation" + ) return result def test_checksum_offload_enable(self): From patchwork Wed Dec 28 05:08:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121426 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 55771A04FD; Wed, 28 Dec 2022 06:10:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4F04741143; Wed, 28 Dec 2022 06:10:26 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 80CFC42C4D for ; Wed, 28 Dec 2022 06:10:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672204224; x=1703740224; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4l/pIY+Xb3QGFqpaLrO/jecTYDWi/J/B4Pk5TdIL4Yo=; b=LTzD0igQDrE7ISBCt/HFKh1i5tWKPBBLeBU9zhsJv4Zmd+H7jSztUrIo hp6mUUqwiT3CArQxhePA4QMCThze3shdDgtxgrW0kQLNgL0crnq7ooUVb pZ0VymEKDFVL5FKDoy2Ih7tGD8a8VuAPrKHGjywGWWWqLXR3iPC0Aekik y7kX0TNpKOK26Kg0BugWXoHje8ZcH2kT6hPzBnItG9QFJ8quVy+ag01xC 094hv5wLaUMZrOjHbfXg2I/rw8Fy+ZhmwWz2VhfFnzfRusCwIq2JKhNEW iOOJMzIRJSlpuU82rqN7BkL5FE5L5WSXxMZZN75lLnWSvYqrnWZVECU+H w==; X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="300499470" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="300499470" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 21:10:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="760536355" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="760536355" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by fmsmga002.fm.intel.com with ESMTP; 27 Dec 2022 21:10:22 -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 V2 2/5] tests/vf_offload: Remove redundant variable used. Date: Wed, 28 Dec 2022 13:08:47 +0800 Message-Id: <20221228050850.33004-3-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221228050850.33004-1-ke1.xu@intel.com> References: <20221228050850.33004-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 abe7d752..42af482f 100644 --- a/tests/TestSuite_vf_offload.py +++ b/tests/TestSuite_vf_offload.py @@ -348,7 +348,6 @@ class TestVfOffload(TestCase): self.vm0_testpmd.execute_cmd("set promisc 0 on") time.sleep(2) - port_id_0 = 0 mac = self.vm0_testpmd.get_port_mac(0) sndIP = "10.0.0.1" sndIPv6 = "::1" From patchwork Wed Dec 28 05:08:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121427 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 CA9CEA04FD; Wed, 28 Dec 2022 06:10:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C569F40FDF; Wed, 28 Dec 2022 06:10:28 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 5921342D12 for ; Wed, 28 Dec 2022 06:10:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672204226; x=1703740226; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CHXS1kQ3cpMVP4/aHEkZkJB5ITZ0QD5bAdFGV/Yvot8=; b=SqjdwduFij5O5UkwbNQCcpiZI1ZN1bs/Vr+0Z2pTz0QgZdpNcwlD//mN RN49LgBzGpyeGRNFslIdXZOKB1j9UD06jccCqSIIXZhwhltQFLmaNUQ3O ob6I0DbThdzFxKkb32SiW7AYurhmOsG5Dln0/xLkk/qZDotWeWUsRidRa WUWv28pXZhByDGEP/zMjmvLWFRREpcFkebo0Y9um2pXwlNU9iXTcUD+Ek WUvVZrl0tm/8+FEaoDVKehOlmY/raNzJxytoMOtE0bc9hamx/f0XcjdBl U5COLxix/gGM9dHLPyXSjfO6i3Vs+CYjO1CcIwXrDfFJ0HecwnmR52RkU w==; X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="300499474" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="300499474" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 21:10:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="760536364" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="760536364" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by fmsmga002.fm.intel.com with ESMTP; 27 Dec 2022 21:10:24 -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 V2 3/5] tests/vf_offload: Use modified checksum_validate to replace checksum_validate_tunnel. Date: Wed, 28 Dec 2022 13:08:48 +0800 Message-Id: <20221228050850.33004-4-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221228050850.33004-1-ke1.xu@intel.com> References: <20221228050850.33004-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 42af482f..bccffb3d 100644 --- a/tests/TestSuite_vf_offload.py +++ b/tests/TestSuite_vf_offload.py @@ -394,64 +394,6 @@ class TestVfOffload(TestCase): self.verify(len(result) == 0, ",".join(list(result.values()))) - def checksum_validate_tunnel(self, packets_sent, packets_expected): - """ - Validate the checksum. - """ - tx_interface = self.tester.get_interface( - self.tester.get_local_port(self.dut_ports[0]) - ) - rx_interface = self.tester.get_interface( - self.tester.get_local_port(self.dut_ports[1]) - ) - sniff_src = self.vm0_testpmd.get_port_mac(0) - checksum_pattern = re.compile("chksum.*=.*(0x[0-9a-z]+)") - sniff_src = "52:00:00:00:00:00" - chksum = dict() - # self.tester.send_expect("scapy", ">>> ") - - for packet_type in list(packets_expected.keys()): - self.tester.send_expect("scapy", ">>> ") - self.tester.send_expect("p = %s" % packets_expected[packet_type], ">>>") - out = self.tester.send_expect("p.show2()", ">>>") - chksums = checksum_pattern.findall(out) - expected_chksum = chksums - chksum[packet_type] = chksums - print(packet_type, ": ", chksums) - - self.tester.send_expect("exit()", "#") - - self.tester.scapy_background() - inst = self.tester.tcpdump_sniff_packets( - intf=rx_interface, - count=len(packets_sent), - filters=[{"layer": "ether", "config": {"src": sniff_src}}], - ) - - # Send packet. - self.tester.scapy_foreground() - - self.tester.scapy_append( - 'sendp([%s], iface="%s")' % (packets_sent[packet_type], tx_interface) - ) - self.tester.scapy_execute() - out = self.tester.scapy_get_result() - p = self.tester.load_tcpdump_sniff_packets(inst) - nr_packets = len(p) - print(p) - chksums = checksum_pattern.findall(p[0].show2(dump=True)) - packets_received = chksums - self.logger.debug(f"packets_received: {packets_received}") - self.logger.debug(f"expected_chksum: {expected_chksum}") - self.verify( - len(expected_chksum) == len(packets_received), - f"The chksum type {packet_type} length of the actual result is inconsistent with the expected length!", - ) - self.verify( - packets_received == expected_chksum, - f"The actually received chksum {packet_type} is inconsistent with the expectation", - ) - @check_supported_nic( ["ICE_100G-E810C_QSFP", "ICE_25G-E810C_SFP", "ICE_25G-E810_XXV_SFP"] ) @@ -570,7 +512,7 @@ class TestVfOffload(TestCase): self.vm0_testpmd.execute_cmd("start") self.vm0_testpmd.wait_link_status_up(0) self.vm0_testpmd.wait_link_status_up(1) - self.checksum_validate_tunnel(pkts, pkts_ref) + result = self.checksum_validate(pkts, pkts_ref) # Validate checksum on the receive packet out = self.vm0_testpmd.execute_cmd("stop") bad_outer_ipcsum = self.vm0_testpmd.get_pmd_value("Bad-outer-ipcsum:", out) @@ -588,6 +530,8 @@ class TestVfOffload(TestCase): self.verify(bad_inner_ipcsum == 36, "Bad-ipcsum check error") self.verify(bad_inner_l4csum == 72, "Bad-l4csum check error") + self.verify(len(result) == 0, ",".join(list(result.values()))) + def test_checksum_offload_disable(self): """ Enable SW checksum offload. From patchwork Wed Dec 28 05:08:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121428 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 EDEC8A0540; Wed, 28 Dec 2022 06:10:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E8B0542D17; Wed, 28 Dec 2022 06:10:29 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id EB9D740FDF for ; Wed, 28 Dec 2022 06:10:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672204228; x=1703740228; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kGbxOvz4rNOyqZwTCK1rzJPQyis6O8PCtmxbkDSE0Ec=; b=jx8vU8q7maoaof/pzc3WmGInY2oxy6shYEeFju/FGipL6qV3rnkhvU67 R39mjseMUGWJSjSrW5ZFnyrikdIWc7gATstWgxREGGaBpImNDox4AEN15 7KY6XEaRmsIdIBzFqun6AFLMRQ3yxPXu5vGiWerqPFTWAlbt1d84TEzvP P9rPkfoDsXp9Cpqy5ye8YYaqKk1msOKlWvhnWa3xVRzy4KMO3tzOA7vOS sG/W/ZD18V/hzZKH+YXtPfBgKfBYdYYbdyIuVU3Leiw+6MRrnRp/Ymb+z 2T5qxuhtPjerjEMf1VwycIkXzeCMpZtO+WoU3ZtDDL14EyAfIhqc5jIMW A==; X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="300499476" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="300499476" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 21:10:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="760536370" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="760536370" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by fmsmga002.fm.intel.com with ESMTP; 27 Dec 2022 21:10:26 -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 V2 4/5] tests/vf_offload: Improve tcpdump_analyse_sniff method Date: Wed, 28 Dec 2022 13:08:49 +0800 Message-Id: <20221228050850.33004-5-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221228050850.33004-1-ke1.xu@intel.com> References: <20221228050850.33004-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 bccffb3d..a9d587e9 100644 --- a/tests/TestSuite_vf_offload.py +++ b/tests/TestSuite_vf_offload.py @@ -622,17 +622,9 @@ class TestVfOffload(TestCase): packets and the bytes of packets payload. """ packet = Packet() - pkts = packet.read_pcapfile("tcpdump_{0}.pcap".format(iface), self.tester) - pkts = [ - p - for p in pkts - if len(p.layers()) >= 3 - and p.layers()[1] in {IP, IPv6} - and p.layers()[2] in {IP, IPv6, UDP, TCP, SCTP, GRE, MPLS} - and Raw in p - ] + pkts = self.filter_packets(packet.read_pcapfile("tcpdump_{0}.pcap".format(iface), self.tester)) rx_packet_count = len(pkts) - rx_packet_size = [len(p[Raw]) for p in pkts] + rx_packet_size = [len(p[Raw].load) for p in pkts] return rx_packet_count, rx_packet_size def tcpdump_command(self, command): From patchwork Wed Dec 28 05:08:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ke Xu X-Patchwork-Id: 121429 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 201D7A04FD; Wed, 28 Dec 2022 06:10:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1BC2642C29; Wed, 28 Dec 2022 06:10:31 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id C5FEC42C29 for ; Wed, 28 Dec 2022 06:10:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672204230; x=1703740230; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yH02kApkDcv7vLhVcvNOfWLxngK53hQNiYBheQHyh8s=; b=QDBdMBghE7RyV8vuENsYYMK7KEKU1465WyKSoFkutTjJzP7G6swYpBYi Ln19DCFNy9pnJ1J3Hdo6BWhHcHgGWA35HlftOuuRgjULd5eT1QhsDq5/T DUHH7pGrd0Y3FUMnMAWGn25dgQOXJey9ftP0Lqu5iNADxks8p3yXzQ7FQ H2pb/OYMzVKbBFrI6vk0E7waIcfwDTm/7akNKiIXXAey1Tn6uNVJB28y0 fkYdWwWA6hInhwWDiaKOQm28gFz62S1SameMHH1G3raL6FT+RvEPidrfo 8mzPbrO1iLnxWfW+x+XGYS/hJn212nm+k16U8aUHw7HARyRO/Wr60H7lx A==; X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="300499481" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="300499481" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2022 21:10:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10573"; a="760536375" X-IronPort-AV: E=Sophos;i="5.96,280,1665471600"; d="scan'208";a="760536375" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by fmsmga002.fm.intel.com with ESMTP; 27 Dec 2022 21:10: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 V2 5/5] tests/vf_offload: Replace the tcpdump implementation to a packet reading implementation. Date: Wed, 28 Dec 2022 13:08:50 +0800 Message-Id: <20221228050850.33004-6-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221228050850.33004-1-ke1.xu@intel.com> References: <20221228050850.33004-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 a9d587e9..084f2249 100644 --- a/tests/TestSuite_vf_offload.py +++ b/tests/TestSuite_vf_offload.py @@ -627,43 +627,6 @@ class TestVfOffload(TestCase): rx_packet_size = [len(p[Raw].load) for p in pkts] return rx_packet_count, rx_packet_size - def tcpdump_command(self, command): - """ - Send a tcpdump related command and return an integer from the output. - """ - - result = self.tester.send_expect(command, "#") - print(result) - return int(result.strip()) - - def number_of_packets(self, iface): - """ - By reading the file generated by tcpdump it counts how many packets are - forwarded by the sample app and received in the self.tester. The sample app - will add a known MAC address for the test to look for. - """ - - command = ( - "tcpdump -A -nn -e -v -r tcpdump_{iface}.pcap 2>/dev/null | " - + 'grep -c "seq"' - ) - return self.tcpdump_command(command.format(**locals())) - - def tcpdump_scanner(self, scanner): - """ - Execute scanner to return results - """ - scanner_result = self.tester.send_expect(scanner, "#") - finally_result = re.findall(r"length( \d+)", scanner_result) - return list(finally_result) - - def number_of_bytes(self, iface): - """ - Get the length of loading_sizes - """ - scanner = 'tcpdump -n -vv -r tcpdump_{iface}.pcap 2>/dev/null | grep "seq" | grep "length"' - return self.tcpdump_scanner(scanner.format(**locals())) - def test_tso(self): """ TSO IPv4 TCP, IPv6 TCP testing. @@ -761,27 +724,26 @@ class TestVfOffload(TestCase): out = self.vm0_testpmd.execute_cmd("show port stats all") print(out) self.tcpdump_stop_sniff() - rx_stats = self.number_of_packets(rx_interface) - tx_stats = self.number_of_packets(tx_interface) - tx_outlist = self.number_of_bytes(rx_interface) - tx_outlist.sort(reverse=True) - self.logger.info(tx_outlist) + rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface) + tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface) + payload_size_list.sort(reverse=True) + self.logger.info(payload_size_list) if loading_size <= 800: self.verify( - rx_stats == tx_stats and int(tx_outlist[0]) == loading_size, + rx_stats == tx_stats and int(payload_size_list[0]) == loading_size, "IPV4 RX or TX packet number not correct", ) else: num = loading_size // 800 for i in range(num): self.verify( - int(tx_outlist[i]) == 800, - "the packet segmentation incorrect, %s" % tx_outlist, + int(payload_size_list[i]) == 800, + "the packet segmentation incorrect, %s" % payload_size_list, ) if loading_size % 800 != 0: self.verify( - int(tx_outlist[num]) == loading_size % 800, - "the packet segmentation incorrect, %s" % tx_outlist, + int(payload_size_list[num]) == loading_size % 800, + "the packet segmentation incorrect, %s" % payload_size_list, ) for loading_size in self.loading_sizes: @@ -796,27 +758,26 @@ class TestVfOffload(TestCase): out = self.vm0_testpmd.execute_cmd("show port stats all") print(out) self.tcpdump_stop_sniff() - rx_stats = self.number_of_packets(rx_interface) - tx_stats = self.number_of_packets(tx_interface) - tx_outlist = self.number_of_bytes(rx_interface) - tx_outlist.sort(reverse=True) - self.logger.info(tx_outlist) + rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface) + tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface) + payload_size_list.sort(reverse=True) + self.logger.info(payload_size_list) if loading_size <= 800: self.verify( - rx_stats == tx_stats and int(tx_outlist[0]) == loading_size, + rx_stats == tx_stats and int(payload_size_list[0]) == loading_size, "IPV6 RX or TX packet number not correct", ) else: num = loading_size // 800 for i in range(num): self.verify( - int(tx_outlist[i]) == 800, - "the packet segmentation incorrect, %s" % tx_outlist, + int(payload_size_list[i]) == 800, + "the packet segmentation incorrect, %s" % payload_size_list, ) if loading_size % 800 != 0: self.verify( - int(tx_outlist[num]) == loading_size % 800, - "the packet segmentation incorrect, %s" % tx_outlist, + int(payload_size_list[num]) == loading_size % 800, + "the packet segmentation incorrect, %s" % payload_size_list, ) @check_supported_nic( @@ -915,6 +876,7 @@ class TestVfOffload(TestCase): self.tcpdump_stop_sniff() rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface) tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface) + payload_size_list.sort(reverse=True) self.logger.info(payload_size_list) if loading_size <= 800: self.verify( @@ -958,6 +920,7 @@ class TestVfOffload(TestCase): self.tcpdump_stop_sniff() rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface) tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface) + payload_size_list.sort(reverse=True) self.logger.info(payload_size_list) if loading_size <= 800: self.verify(