test suite reviews and discussions
 help / color / mirror / Atom feed
From: Ke Xu <ke1.xu@intel.com>
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	[thread overview]
Message-ID: <20221223085527.29760-5-ke1.xu@intel.com> (raw)
In-Reply-To: <20221223085527.29760-1-ke1.xu@intel.com>

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 <ke1.xu@intel.com>
---
 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


  parent reply	other threads:[~2022-12-23  8:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-23  8:55 [DTS][PATCH V6 0/5] add vf checksum offload and tso case for " Ke Xu
2022-12-23  8:55 ` [DTS][PATCH V6 1/5] tests/vf_offload: fix 2 typos and a bug Ke Xu
2022-12-23  8:55 ` [DTS][PATCH V6 2/5] tests/vf_offload: add vf checksum hw offload case for tunneling packets Ke Xu
2022-12-23  8:55 ` [DTS][PATCH V6 3/5] tests/vf_offload: add vf tso " Ke Xu
2022-12-23  8:55 ` Ke Xu [this message]
2022-12-23  8:55 ` [DTS][PATCH V6 5/5] tests/vf_offload: fix and improve unstable implementations Ke Xu
2022-12-23  9:03   ` Li, WeiyuanX
2022-12-26  1:53 ` [DTS][PATCH V6 0/5] add vf checksum offload and tso case for tunnel packets Fu, Qi
2022-12-26  4:41 ` Tu, Lijuan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221223085527.29760-5-ke1.xu@intel.com \
    --to=ke1.xu@intel.com \
    --cc=dts@dpdk.org \
    --cc=lijuan.tu@intel.com \
    --cc=qi.fu@intel.com \
    --cc=weiyuanx.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).