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 6512AA0093; Fri, 23 Dec 2022 09:57:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 60B904282D; Fri, 23 Dec 2022 09:57:03 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id D4ECB40698 for ; Fri, 23 Dec 2022 09:57:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1671785822; x=1703321822; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2DqAhc9qM416mDMeeXmdR5erlATuWYcw5HBmBzjWWzI=; b=L8PcEcV9qOcGijs1e5zz8g4s8zLaspj3OcPeWHefmqDKtF+hJ5MyPB5u y5ndzItS4Y+VHrqD1PpE6FfePzJjVP9vVd6JNbAphvpPto7mekXmbH1ZD jbd7DWdw3XWGNWZ3H0Uu0mrpuAcfqx5vxzoJLhr525uphwmyOZizzvQtC YBqnUJ5GCnNdZpeXC3JxDPdvScMPYHHkvVtFhW4J1O9AJNPB6s0/SaQYR AvNGoruYMPmDTeEP1nOQnUMOt37a8G3ScBmE6DNtC6oWhJbdp0rMmTlkL NNA0PvLxpH++/hxav8bX7IORqfmKDDKYTcpo/0YMuri5Fa6ZsvETXAdwt w==; X-IronPort-AV: E=McAfee;i="6500,9779,10569"; a="303773493" X-IronPort-AV: E=Sophos;i="5.96,268,1665471600"; d="scan'208";a="303773493" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Dec 2022 00:57:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10569"; a="776304479" X-IronPort-AV: E=Sophos;i="5.96,268,1665471600"; d="scan'208";a="776304479" Received: from dpdk-xuke-lab.sh.intel.com ([10.67.119.8]) by orsmga004.jf.intel.com with ESMTP; 23 Dec 2022 00:56:59 -0800 From: Ke Xu To: dts@dpdk.org Cc: ke1.xu@intel.com, weiyuanx.li@intel.com, qi.fu@intel.com, lijuan.tu@intel.com Subject: [DTS][PATCH V6 4/5] tests/vf_offload: add new method to anayse tunnel packets. Date: Fri, 23 Dec 2022 16:55:26 +0800 Message-Id: <20221223085527.29760-5-ke1.xu@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221223085527.29760-1-ke1.xu@intel.com> References: <20221223085527.29760-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