DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dean Marx <dmarx@iol.unh.edu>
To: probb@iol.unh.edu, npratte@iol.unh.edu, luca.vizzarro@arm.com,
	yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com,
	paul.szczepanek@arm.com
Cc: dev@dpdk.org, Dean Marx <dmarx@iol.unh.edu>
Subject: [PATCH v7 2/2] dts: port over dynamic config test suite
Date: Thu, 10 Oct 2024 16:21:04 -0400	[thread overview]
Message-ID: <20241010202104.15364-3-dmarx@iol.unh.edu> (raw)
In-Reply-To: <20241010202104.15364-1-dmarx@iol.unh.edu>

Suite for testing ability of Poll Mode Driver to turn promiscuous
mode on/off, allmulticast mode on/off, and show expected behavior
when sending packets with known, unknown, broadcast, and multicast
destination MAC addresses.

Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
 dts/framework/config/conf_yaml_schema.json |   3 +-
 dts/tests/TestSuite_dynamic_config.py      | 143 +++++++++++++++++++++
 2 files changed, 145 insertions(+), 1 deletion(-)
 create mode 100644 dts/tests/TestSuite_dynamic_config.py

diff --git a/dts/framework/config/conf_yaml_schema.json b/dts/framework/config/conf_yaml_schema.json
index df390e8ae2..5b70600f1f 100644
--- a/dts/framework/config/conf_yaml_schema.json
+++ b/dts/framework/config/conf_yaml_schema.json
@@ -187,7 +187,8 @@
       "enum": [
         "hello_world",
         "os_udp",
-        "pmd_buffer_scatter"
+        "pmd_buffer_scatter",
+        "dynamic_config"
       ]
     },
     "test_target": {
diff --git a/dts/tests/TestSuite_dynamic_config.py b/dts/tests/TestSuite_dynamic_config.py
new file mode 100644
index 0000000000..e07a95ceb8
--- /dev/null
+++ b/dts/tests/TestSuite_dynamic_config.py
@@ -0,0 +1,143 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 University of New Hampshire
+
+"""Dynamic configuration capabilities test suite.
+
+This suite checks that it is possible to change the configuration of a port
+dynamically. The Poll Mode Driver should be able to enable and disable
+promiscuous mode on each port, as well as check the Rx and Tx packets of
+each port. Promiscuous mode in networking passes all traffic a NIC receives
+to the CPU, rather than just frames with matching MAC addresses. Each test
+case sends a packet with a matching address, and one with an unknown address,
+to ensure this behavior is shown.
+
+If packets should be received and forwarded, or received and not forwarded,
+depending on the configuration, the port info should match the expected behavior.
+"""
+
+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.params.testpmd import SimpleForwardingModes
+from framework.remote_session.testpmd_shell import TestPmdShell
+from framework.test_suite import TestSuite, func_test
+from framework.testbed_model.capability import TopologyType, requires
+
+
+@requires(topology_type=TopologyType.two_links)
+class TestDynamicConfig(TestSuite):
+    """Dynamic config suite.
+
+    Use the show port commands to see the MAC address and promisc mode status
+    of the Rx port on the DUT. The suite will check the Rx and Tx packets
+    of each port after configuring promiscuous, multicast, and default mode
+    on the DUT to verify the expected behavior. It consists of four test cases:
+
+    1. Default mode: verify packets are received and forwarded.
+    2. Disable promiscuous mode: verify that packets are received
+    only for the packet with destination address matching the port address.
+    3. Disable promiscuous mode broadcast: verify that packets with destination
+    MAC address not matching the port are received and not forwarded, and verify
+    that broadcast packets are received and forwarded.
+    4. Disable promiscuous mode multicast: verify that packets with destination
+    MAC address not matching the port are received and not forwarded, and verify
+    that multicast packets are received and forwarded.
+    """
+
+    def send_packet_and_verify(self, should_receive: bool, mac_address: str) -> None:
+        """Generate, send and verify packets.
+
+        Generate a packet and send to the DUT, verify that packet is forwarded from DUT to
+        traffic generator if that behavior is expected.
+
+        Args:
+            should_receive: Indicate whether the packet should be received.
+            mac_address: Destination MAC address to generate in packet.
+        """
+        packet = Ether(dst=mac_address) / IP() / Raw(load="xxxxx")
+        received = self.send_packet_and_capture(packet)
+        contains_packet = any(
+            packet.haslayer(Raw) and b"xxxxx" in packet.load for packet in received
+        )
+        self.verify(
+            should_receive == contains_packet,
+            f"Packet was {'dropped' if should_receive else 'received'}",
+        )
+
+    def disable_promisc_setup(self, testpmd: TestPmdShell, port_id: int) -> TestPmdShell:
+        """Sets up testpmd shell config for cases where promisc mode is disabled.
+
+        Args:
+            testpmd: Testpmd session that is being configured.
+            port_id: Port number to disable promisc mode on.
+
+        Returns:
+            TestPmdShell: interactive testpmd shell object.
+        """
+        testpmd.start()
+        testpmd.set_promisc(port=port_id, enable=False)
+        testpmd.set_forward_mode(SimpleForwardingModes.io)
+        return testpmd
+
+    @func_test
+    def test_default_mode(self) -> None:
+        """Tests default configuration.
+
+        Creates a testpmd shell, verifies that promiscuous mode is enabled by default,
+        and sends two packets; one matching source MAC address and one unknown.
+        Verifies that both are received.
+        """
+        with TestPmdShell(node=self.sut_node) as testpmd:
+            isPromisc = testpmd.show_port_info(0).is_promiscuous_mode_enabled
+            self.verify(isPromisc, "Promiscuous mode was not enabled by default.")
+            testpmd.start()
+            mac = testpmd.show_port_info(0).mac_address
+            # send a packet with Rx port mac address
+            self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+            # send a packet with mismatched mac address
+            self.send_packet_and_verify(should_receive=True, mac_address="00:00:00:00:00:01")
+
+    @func_test
+    def test_disable_promisc(self) -> None:
+        """Tests disabled promiscuous mode configuration.
+
+        Creates an interactive testpmd shell, disables promiscuous mode,
+        and sends two packets; one matching source MAC address and one unknown.
+        Verifies that only the matching address packet is received.
+        """
+        with TestPmdShell(node=self.sut_node) as testpmd:
+            testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+            mac = testpmd.show_port_info(0).mac_address
+            self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+            self.send_packet_and_verify(should_receive=False, mac_address="00:00:00:00:00:01")
+
+    @func_test
+    def test_disable_promisc_broadcast(self) -> None:
+        """Tests broadcast reception with disabled promisc mode config.
+
+        Creates an interactive testpmd shell, disables promiscuous mode,
+        and sends two packets; one matching source MAC address and one broadcast.
+        Verifies that both packets are received.
+        """
+        with TestPmdShell(node=self.sut_node) as testpmd:
+            testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+            mac = testpmd.show_port_info(0).mac_address
+            self.send_packet_and_verify(should_receive=True, mac_address=str(mac))
+            self.send_packet_and_verify(should_receive=True, mac_address="ff:ff:ff:ff:ff:ff")
+
+    @func_test
+    def test_disable_promisc_multicast(self) -> None:
+        """Tests allmulticast mode with disabled promisc config.
+
+        Creates an interactive testpmd shell, disables promiscuous mode,
+        and sends two packets; one matching source MAC address and one multicast.
+        Verifies that the multicast packet is only received once allmulticast mode is enabled.
+        """
+        with TestPmdShell(node=self.sut_node) as testpmd:
+            testpmd = self.disable_promisc_setup(testpmd=testpmd, port_id=0)
+            testpmd.set_multicast_all(on=False)
+            # 01:00:5E:00:00:01 is the first of the multicast MAC range of addresses
+            self.send_packet_and_verify(should_receive=False, mac_address="01:00:5E:00:00:01")
+            testpmd.set_multicast_all(on=True)
+            self.send_packet_and_verify(should_receive=True, mac_address="01:00:05E:00:00:01")
-- 
2.44.0


      parent reply	other threads:[~2024-10-10 20:20 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-08 19:19 [PATCH v2 0/4] dts: initial dynamic config suite Dean Marx
2024-07-08 19:19 ` [PATCH v2 1/4] dts: add multicast set function to shell Dean Marx
2024-07-10 16:44   ` Jeremy Spewock
2024-07-08 19:19 ` [PATCH v2 2/4] dts: add toggle option to send and capture Dean Marx
2024-07-08 19:19 ` [PATCH v2 3/4] dts: dynamic config conf schema Dean Marx
2024-07-08 19:19 ` [PATCH v2 4/4] dts: dynamic config test suite Dean Marx
2024-07-08 19:30 ` [PATCH v3 1/4] dts: add multicast set function to shell Dean Marx
2024-07-08 19:30   ` [PATCH v3 2/4] dts: add toggle option to send and capture Dean Marx
2024-07-10 16:13     ` Jeremy Spewock
2024-07-08 19:30   ` [PATCH v3 3/4] dts: dynamic config conf schema Dean Marx
2024-07-10 16:45     ` Jeremy Spewock
2024-07-08 19:30   ` [PATCH v3 4/4] dts: dynamic config test suite Dean Marx
2024-07-10 16:45     ` Jeremy Spewock
2024-07-15 16:00 ` [PATCH v4 1/3] dts: add multicast set function to shell Dean Marx
2024-07-15 16:00   ` [PATCH v4 2/3] dts: dynamic config conf schema Dean Marx
2024-07-15 20:22     ` Jeremy Spewock
2024-07-15 16:00   ` [PATCH v4 3/3] dts: dynamic config test suite Dean Marx
2024-07-15 20:22     ` Jeremy Spewock
2024-07-15 20:22   ` [PATCH v4 1/3] dts: add multicast set function to shell Jeremy Spewock
2024-07-24 19:21 ` [PATCH v5 0/3] dts: refactored dynamic config test suite Dean Marx
2024-07-24 19:21   ` [PATCH v5 1/3] dts: add multicast set function to shell Dean Marx
2024-08-07 15:50     ` Luca Vizzarro
2024-07-24 19:21   ` [PATCH v5 2/3] dts: dynamic config conf schema Dean Marx
2024-07-26 19:35     ` Jeremy Spewock
2024-08-07 15:56     ` Luca Vizzarro
2024-07-24 19:21   ` [PATCH v5 3/3] dts: dynamic config test suite Dean Marx
2024-07-26 19:35     ` Jeremy Spewock
2024-08-07 19:18   ` [PATCH v6 0/2] dts: refactored " Dean Marx
2024-08-07 19:18     ` [PATCH v6 1/2] dts: add multicast set function to shell Dean Marx
2024-08-07 19:18     ` [PATCH v6 2/2] dts: dynamic config test suite Dean Marx
2024-10-10 20:17     ` [PATCH v7 0/2] dts: port over dynamic config suite Dean Marx
2024-10-10 20:17       ` [PATCH v7 1/2] dts: add multicast set funciton to shell Dean Marx
2024-10-10 20:17       ` [PATCH v7 2/2] dts: port over dynamic config test suite Dean Marx
2024-10-10 20:21     ` [PATCH v7 0/2] dts: port over dynamic config suite Dean Marx
2024-10-10 20:21       ` [PATCH v7 1/2] dts: add multicast set function to shell Dean Marx
2024-10-10 20:21       ` Dean Marx [this message]

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=20241010202104.15364-3-dmarx@iol.unh.edu \
    --to=dmarx@iol.unh.edu \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=dev@dpdk.org \
    --cc=luca.vizzarro@arm.com \
    --cc=npratte@iol.unh.edu \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    --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).