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 AAC81A04FD; Thu, 22 Dec 2022 10:39:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 927F642D17; Thu, 22 Dec 2022 10:39:01 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id ADD0D400D7 for ; Thu, 22 Dec 2022 10:39:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1671701940; x=1703237940; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2DqAhc9qM416mDMeeXmdR5erlATuWYcw5HBmBzjWWzI=; b=SWlaRGyXYBLPfwS4RRy0eS0EYoeMCi0ZhuqtsW7+HqQ7Zwz7cr3HMwNt TTckjLVR/KjG+Ykjm4VkARP8B4Ja8FrdPfZzBXzfgdqRarl3oKYrNt2hd UZ6Ud+YG+8K7p4mSR1+a2G1CX2cmd+9li8WQRyGvMfeFho4UsAhbs6tH5 uu40g0nwjVV1L5XJaoYKaccRLxdwrfMafql617H1T/d0N8/SzU19+p0CU IWn9aA8Q1HQQRDFCdA1llXc1eVgpeVywm+JlO43ls+JDnzM7sUZDERZBf kKHK60XoE9Ijh6attfcj6sVF61AxM++n3ENeFldN5W4Ogf0rp6KejJSM+ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10568"; a="299758335" X-IronPort-AV: E=Sophos;i="5.96,265,1665471600"; d="scan'208";a="299758335" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Dec 2022 01:39:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10568"; a="684130112" X-IronPort-AV: E=Sophos;i="5.96,265,1665471600"; d="scan'208";a="684130112" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by orsmga001.jf.intel.com with ESMTP; 22 Dec 2022 01:38:58 -0800 From: Ke Xu To: dts@dpdk.org Cc: weiyuanx.li@intel.com, qi.fu@intel.com, lijuan.tu@intel.com, Ke Xu Subject: [DTS][PATCH V4 5/5] tests/vf_offload: add new method to anayse tunnel packets. Date: Thu, 22 Dec 2022 17:37:15 +0800 Message-Id: <20221222093715.116863-6-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221222093715.116863-1-ke1.xu@intel.com> References: <20221222093715.116863-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 As tcpdump not supporting some of the packet organizations we are to cover, a newly implemented function is introduced to replace number_of_packets and number_of_bytes in tunnel cases. Signed-off-by: Ke Xu --- tests/TestSuite_vf_offload.py | 64 +++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/tests/TestSuite_vf_offload.py b/tests/TestSuite_vf_offload.py index 3d89729d..6765fcc5 100644 --- a/tests/TestSuite_vf_offload.py +++ b/tests/TestSuite_vf_offload.py @@ -6,8 +6,19 @@ import re import string import time +from scapy.contrib.lldp import LLDPDU, LLDPDUManagementAddress +from scapy.contrib.mpls import MPLS +from scapy.contrib.nsh import NSH +from scapy.layers.inet import ICMP, IP, TCP, UDP +from scapy.layers.inet6 import IPv6, IPv6ExtHdrFragment, IPv6ExtHdrRouting +from scapy.layers.l2 import ARP, GRE, Dot1Q, Ether +from scapy.layers.sctp import SCTP +from scapy.layers.vxlan import VXLAN +from scapy.packet import Raw + import framework.utils as utils from framework.crb import Crb +from framework.packet import Packet from framework.pmd_output import PmdOutput from framework.settings import DPDK_DCFMODE_SETTING, HEADER_SIZE, load_global_setting from framework.test_case import TestCase, check_supported_nic, skip_unsupported_pkg @@ -687,6 +698,25 @@ class TestVfOffload(TestCase): self.tester.send_expect('echo "Cleaning buffer"', "#") time.sleep(1) + def tcpdump_analyse_sniff(self, iface): + """ + Analyse the tcpdump captured packets. Returning the number of + 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 + ] + rx_packet_count = len(pkts) + rx_packet_size = [len(p[Raw]) 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. @@ -973,26 +1003,25 @@ 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) - self.logger.info(tx_outlist) + rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface) + tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface) + 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 payload_size_list[0] == loading_size, f"{key_outer} tunnel 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, + 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, + payload_size_list[num] == loading_size % 800, + "the packet segmentation incorrect, %s" % payload_size_list, ) for loading_size in self.loading_sizes: @@ -1017,26 +1046,25 @@ 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) - self.logger.info(tx_outlist) + rx_stats, payload_size_list = self.tcpdump_analyse_sniff(rx_interface) + tx_stats, _ = self.tcpdump_analyse_sniff(tx_interface) + 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 payload_size_list[0] == loading_size, f"{key_outer} tunnel 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, + 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, + payload_size_list[num] == loading_size % 800, + "the packet segmentation incorrect, %s" % payload_size_list, ) def tear_down(self): -- 2.25.1