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 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 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 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): -- 2.25.1