From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Content-Transfer-Encoding: 8bit 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): -- 2.25.1