DPDK patches and discussions
 help / color / mirror / Atom feed
From: jspewock@iol.unh.edu
To: alex.chapman@arm.com, Luca.Vizzarro@arm.com,
	Honnappa.Nagarahalli@arm.com, juraj.linkes@pantheon.tech,
	paul.szczepanek@arm.com, npratte@iol.unh.edu, probb@iol.unh.edu,
	yoan.picchi@foss.arm.com, wathsala.vithanage@arm.com,
	thomas@monjalon.net
Cc: dev@dpdk.org, Jeremy Spewock <jspewock@iol.unh.edu>
Subject: [RFC PATCH v1 2/3] dts: add pf smoke testing suite
Date: Tue,  6 Aug 2024 14:56:30 -0400	[thread overview]
Message-ID: <20240806185631.335737-3-jspewock@iol.unh.edu> (raw)
In-Reply-To: <20240806185631.335737-1-jspewock@iol.unh.edu>

From: Jeremy Spewock <jspewock@iol.unh.edu>

This patch adds a smoke testing suite for Physical Function features.
The goal of this suite is to test some of the most basic features of
DPDK on a physical function and bail out early if any of these features
aren't supported as expected. Unlike DTS smoke tests, these ones are not
included as a switch in the config file and thus are an additional test
suite that developers can include alongside others at their own
discretion.

Depends-on: patch-142691 ("dts: add send_packets to test suites and
 rework packet addressing")

Signed-off-by: Jeremy Spewock <jspewock@iol.unh.edu>
---
 dts/tests/TestSuite_pf_smoke_tests.py | 129 ++++++++++++++++++++++++++
 1 file changed, 129 insertions(+)
 create mode 100644 dts/tests/TestSuite_pf_smoke_tests.py

diff --git a/dts/tests/TestSuite_pf_smoke_tests.py b/dts/tests/TestSuite_pf_smoke_tests.py
new file mode 100644
index 0000000000..82c84c7c8d
--- /dev/null
+++ b/dts/tests/TestSuite_pf_smoke_tests.py
@@ -0,0 +1,129 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 University of New Hampshire
+"""Physical Function (PF) smoke testing suite.
+
+This test suite tests some of the more common DPDK functionality on a PF. Things such as
+jumbroframes, Receive Side Scaling (RSS) functions, and being able to modify the number of queues
+at runtime should all be supported by PMDs that are capable of running DPDK. Since this is a smoke
+testing suite, it is considered a blocking suite that will stop following ones from running.
+"""
+
+from typing import ClassVar
+
+from scapy.layers.inet import IP  # type: ignore[import-untyped]
+from scapy.layers.l2 import Ether  # type: ignore[import-untyped]
+from scapy.packet import Raw  # type: ignore[import-untyped]
+
+from framework.exception import InteractiveCommandExecutionError, TestCaseVerifyError
+from framework.params.testpmd import SimpleForwardingModes
+from framework.remote_session.testpmd_shell import TestPmdShell, VerboseOLFlag
+from framework.test_suite import TestSuite
+
+
+class TestPfSmokeTests(TestSuite):
+    """DPDK Physical Function Testing Suite.
+
+    This test suite is designed to verify the basic functions of DPDK on a PF. The MTU of the ports
+    on the traffic generator are increased to 9000 to support jumboframes for one of the test
+    cases, and then reverted back to 1500 once the test suite is complete. Some functionality in
+    this test suite also relies on the ability of testpmd to recognize and flag invalid checksum
+    values in its verbose output.
+
+    Attributes:
+        is_blocking: This test suite will block the execution of all other test suites
+            in the build target after it.
+    """
+
+    is_blocking: ClassVar[bool] = True
+    jumbo_frame_len: ClassVar[int] = 9000
+    num_queues: int = 4
+    rx_port: int = 0
+
+    def set_up_suite(self) -> None:
+        """Increase the MTU of the traffic generator to support jumboframes."""
+        for port_link in self._port_links:
+            self.tg_node.main_session.configure_port_mtu(self.jumbo_frame_len, port_link.tg_port)
+
+    def test_jumbo_frame_support(self) -> None:
+        """Verify that the PF is able to send and receive jumboframes."""
+        with TestPmdShell(
+            self.sut_node,
+            max_pkt_len=self.jumbo_frame_len,
+            mbuf_size=[self.jumbo_frame_len + 128],
+            forward_mode=SimpleForwardingModes.mac,
+        ) as testpmd:
+            testpmd.start()
+            # Take 26 bytes off the MTU size to account for Ethernet headers
+            payload_len = self.jumbo_frame_len - 26
+            packet = Ether() / Raw("X" * payload_len)
+            recv = self.send_packet_and_capture(packet)
+            self.verify(
+                any(hasattr(p, "load") and "X" * 20 in str(p.load) for p in recv),
+                f"Jumboframe was not received even when MTU was set to {self.jumbo_frame_len}.",
+            )
+
+    def test_rss_functionality(self) -> None:
+        """Test that Receive Side Scaling functions are working as intended.
+
+        The primary things to test in this case are that packets that are sent with different
+        destination IP addresses are handled by different queues and that the RSS hash of every
+        packet is unique. Verification of these functionalities is done by sending packets with
+        invalid checksums so that the packets sent by this test suite can be differentiated from
+        other packets sent to the same port. This makes the assumption that other packets sent to
+        the port will all have valid checksums.
+        """
+        with TestPmdShell(
+            self.sut_node,
+            forward_mode=SimpleForwardingModes.rxonly,
+            rx_queues=self.num_queues,
+            tx_queues=self.num_queues,
+        ) as testpmd:
+            testpmd.set_verbose(1)
+            send_pkts = [
+                Ether() / IP(dst=f"192.168.0.{i+1}", chksum=0x0) for i in range(self.num_queues * 4)
+            ]
+            testpmd.start()
+            self.send_packets(send_pkts)
+            verbose_stats = TestPmdShell.extract_verbose_output(testpmd.stop())
+            # Filter down the packets to only the ones with back checksums
+            for block in verbose_stats:
+                block.packets = list(
+                    filter(
+                        lambda x: VerboseOLFlag.RTE_MBUF_F_RX_IP_CKSUM_BAD in x.ol_flags,
+                        block.packets,
+                    )
+                )
+            # Remove any output blocks that don't have any packets left after filtering
+            verbose_stats = list(filter(lambda x: len(x.packets) > 0, verbose_stats))
+            rss_hashes = [p.rss_hash for block in verbose_stats for p in block.packets]
+            self.verify(
+                all(rss_h is not None for rss_h in rss_hashes),
+                "At least one packet did not have an RSS hash.",
+            )
+            self.verify(
+                len(set(rss_hashes)) == len(rss_hashes),
+                "RSS hashes were not unique.",
+            )
+            self.verify(
+                all(any(q == b.queue_id for b in verbose_stats) for q in range(self.num_queues)),
+                "Not all ports were used when packets were sent with different source addresses.",
+            )
+
+    def test_runtime_modify_num_queues(self) -> None:
+        """Ensure that the number of queues on a port can be changed at runtime."""
+        with TestPmdShell(
+            self.sut_node, rx_queues=self.num_queues, tx_queues=self.num_queues
+        ) as testpmd:
+            testpmd.port_stop_all()
+            try:
+                testpmd.set_num_queues_all(2, True, verify=True)
+                testpmd.set_num_queues_all(2, False, verify=True)
+            except InteractiveCommandExecutionError as e:
+                raise TestCaseVerifyError(
+                    "Failed to change the number of queues on a port at runtime."
+                ) from e
+
+    def tear_down_suite(self) -> None:
+        """Revert MTU back to a standard value of 1500."""
+        for port_link in self._port_links:
+            self.tg_node.main_session.configure_port_mtu(1500, port_link.tg_port)
-- 
2.45.2


  parent reply	other threads:[~2024-08-06 18:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-06 18:56 [RFC PATCH v1 0/3] dts: pf_smoke port jspewock
2024-08-06 18:56 ` [RFC PATCH v1 1/3] dts: add ability to modify number of queues on a port to testpmd jspewock
2024-08-06 18:56 ` jspewock [this message]
2024-08-06 18:56 ` [RFC PATCH v1 3/3] dts: added pf_smoke_tests to yaml schema jspewock
2024-09-06 16:51 ` [PATCH v2 0/2] dts: pf_smoke port jspewock
2024-09-06 16:51   ` [PATCH v2 1/2] dts: add ability to modify number of queues on a port to testpmd jspewock
2024-09-06 16:51   ` [PATCH v2 2/2] dts: add pf smoke testing suite jspewock
2024-09-26 19:49 ` [PATCH v3 0/2] dts: pf_smoke port jspewock
2024-09-26 19:49   ` [PATCH v3 1/2] dts: add ability to modify number of queues on a port to testpmd jspewock
2024-09-26 19:49   ` [PATCH v3 2/2] dts: add pf smoke testing suite jspewock

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=20240806185631.335737-3-jspewock@iol.unh.edu \
    --to=jspewock@iol.unh.edu \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=Luca.Vizzarro@arm.com \
    --cc=alex.chapman@arm.com \
    --cc=dev@dpdk.org \
    --cc=juraj.linkes@pantheon.tech \
    --cc=npratte@iol.unh.edu \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    --cc=thomas@monjalon.net \
    --cc=wathsala.vithanage@arm.com \
    --cc=yoan.picchi@foss.arm.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).