<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, Oct 3, 2025 at 3:27 PM Dean Marx <<a href="mailto:dmarx@iol.unh.edu">dmarx@iol.unh.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Add test suite covering virtio-user and vhost<br>
server/client forwarding scenarios with<br>
testpmd packet validation.<br>
<br>
Signed-off-by: Dean Marx <<a href="mailto:dmarx@iol.unh.edu" target="_blank">dmarx@iol.unh.edu</a>><br>
---<br>
 doc/api/tests.TestSuite_virtio_fwd.rst |   8 ++<br>
 dts/tests/TestSuite_virtio_fwd.py      | 180 +++++++++++++++++++++++++<br>
 2 files changed, 188 insertions(+)<br>
 create mode 100644 doc/api/tests.TestSuite_virtio_fwd.rst<br>
 create mode 100644 dts/tests/TestSuite_virtio_fwd.py<br>
<br>
diff --git a/doc/api/tests.TestSuite_virtio_fwd.rst b/doc/api/tests.TestSuite_virtio_fwd.rst<br>
new file mode 100644<br>
index 0000000000..782eddad2d<br>
--- /dev/null<br>
+++ b/doc/api/tests.TestSuite_virtio_fwd.rst<br>
@@ -0,0 +1,8 @@<br>
+.. SPDX-License-Identifier: BSD-3-Clause<br>
+<br>
+virtio_fwd Test Suite<br>
+===========================<br>
+<br>
+.. automodule:: tests.TestSuite_virtio_fwd<br>
+   :members:<br>
+   :show-inheritance:<br>
\ No newline at end of file<br>
diff --git a/dts/tests/TestSuite_virtio_fwd.py b/dts/tests/TestSuite_virtio_fwd.py<br>
new file mode 100644<br>
index 0000000000..194bd24257<br>
--- /dev/null<br>
+++ b/dts/tests/TestSuite_virtio_fwd.py<br>
@@ -0,0 +1,180 @@<br>
+# SPDX-License-Identifier: BSD-3-Clause<br>
+# Copyright(c) 2025 University of New Hampshire<br>
+<br>
+"""Virtio forwarding test suite.<br>
+<br>
+Verify vhost/virtio pvp and loopback topology functionalities.<br></blockquote><div><br></div><div>Loopback doesn't seem quite right. Maybe you can just say pvp and fully virtual?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+"""<br>
+<br>
+from scapy.layers.inet import IP<br>
+from scapy.layers.l2 import Ether<br>
+<br>
+from api.capabilities import LinkTopology<br>
+from api.testpmd import TestPmd<br>
+from api.testpmd.config import SimpleForwardingModes<br>
+from framework.parser import TextParser<br>
+from framework.test_suite import TestSuite, func_test<br>
+from framework.testbed_model.capability import requires<br>
+from framework.testbed_model.linux_session import LinuxSession<br>
+from framework.testbed_model.virtual_device import VirtualDevice<br>
+<br>
+<br>
+@requires(topology_type=LinkTopology.TWO_LINKS)<br></blockquote><div><br></div><div>two links is true for the pvp test, but the other two dont require any links, right?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+class TestVirtioFwd(TestSuite):<br>
+    """Virtio forwarding test suite."""<br>
+<br>
+    class ForwardingParsers:<br>
+        """Class for gathering Rx/Tx packets from testpmd stats."""<br>
+<br>
+        rx_packets = TextParser.find_int(r"RX-packets:\s*(\d+)")<br>
+        tx_packets = TextParser.find_int(r"TX-packets:\s*(\d+)")<br>
+<br>
+    class vdevs:<br>
+        """Class containing virtio-user and vhost-user virtual devices."""<br>
+<br>
+        virtio_user = VirtualDevice(<br>
+            "net_virtio_user0,mac=00:01:02:03:04:05,path=/tmp/vhost-net,server=1"<br>
+        )<br>
+        vhost_user = VirtualDevice("eth_vhost0,iface=/tmp/vhost-net,client=1")<br></blockquote><div><br></div><div>+1 to Luca's comment about not needing these to be internal classes.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+    @func_test<br>
+    def virtio_server(self) -> None:<br>
+        """Test virtio server packet transmission.<br>
+<br>
+        Steps:<br>
+            * Launch a testpmd session with a vhost-user virtual device (client side).<br>
+            * Launch a testpmd session with a virtio-user virtual device (server side).<br>
+            * Set the forwarding mode to mac in both sessions.<br>
+            * Start packet forwarding on vhost session.<br>
+            * Send a burst of packets from the virtio session.<br>
+            * Stop packet forwarding on vhost session and collect Rx packet stats.<br>
+<br>
+        Verify:<br>
+            * Vhost session receives packets from virtio session.<br>
+        """<br>
+        with (<br>
+            TestPmd(<br>
+                prefix="vhost",<br>
+                no_pci=True,<br>
+                memory_channels=4,<br>
+                vdevs=[self.vdevs.vhost_user],<br>
+            ) as vhost,<br>
+            TestPmd(<br>
+                prefix="virtio",<br>
+                no_pci=True,<br>
+                memory_channels=4,<br>
+                vdevs=[self.vdevs.virtio_user],<br>
+            ) as virtio,<br>
+        ):<br>
+            vhost.set_forward_mode(SimpleForwardingModes.mac)<br>
+            virtio.set_forward_mode(SimpleForwardingModes.mac)<br>
+<br>
+            vhost.start()<br>
+            virtio.start_tx_first(burst_num=32)<br>
+<br>
+            forwarding_stats = vhost.stop()<br>
+<br>
+            rx_packets = self.ForwardingParsers.rx_packets["TextParser_fn"](forwarding_stats) or 0<br>
+            tx_packets = self.ForwardingParsers.tx_packets["TextParser_fn"](forwarding_stats) or 0<br>
+<br>
+            self.verify(<br>
+                rx_packets != 0 and tx_packets != 0,<br>
+                "Vhost session failed to receive packets from virtio session.",<br>
+            )<br>
+<br>
+    @func_test<br>
+    def virtio_server_reconnect(self) -> None:<br>
+        """Test virtio server reconnection.<br>
+<br>
+        Steps:<br>
+            * Launch a testpmd session with a vhost-user virtual device (client side).<br>
+            * Launch a testpmd session with a virtio-user virtual device (server side).<br>
+            * Close the virtio session and relaunch it.<br>
+            * Start packet forwarding on vhost session.<br>
+            * Send a burst of packets from the virtio session.<br>
+            * Stop packet forwarding on vhost session and collect Rx packet stats.<br>
+<br>
+        Verify:<br>
+            * Vhost session receives packets from relaunched virtio session.<br>
+        """<br>
+        with TestPmd(<br>
+            prefix="vhost",<br>
+            no_pci=True,<br>
+            memory_channels=4,<br>
+            vdevs=[self.vdevs.vhost_user],<br>
+        ) as vhost:<br>
+            with TestPmd(<br>
+                prefix="virtio",<br>
+                no_pci=True,<br>
+                memory_channels=4,<br>
+                vdevs=[self.vdevs.virtio_user],<br>
+            ) as virtio:<br>
+                pass<br>
+            # end session and reconnect<br>
+            with TestPmd(<br>
+                prefix="virtio",<br>
+                no_pci=True,<br>
+                memory_channels=4,<br>
+                vdevs=[self.vdevs.virtio_user],<br>
+            ) as virtio:<br>
+                virtio.set_forward_mode(SimpleForwardingModes.mac)<br>
+                vhost.set_forward_mode(SimpleForwardingModes.mac)<br>
+<br>
+                vhost.start()<br>
+                virtio.start_tx_first(burst_num=32)<br>
+<br>
+                forwarding_stats = vhost.stop()<br>
+<br>
+                rx_packets = (<br>
+                    self.ForwardingParsers.rx_packets["TextParser_fn"](forwarding_stats) or 0<br>
+                )<br>
+                tx_packets = (<br>
+                    self.ForwardingParsers.tx_packets["TextParser_fn"](forwarding_stats) or 0<br>
+                )<br>
+<br>
+                self.verify(<br>
+                    rx_packets != 0 and tx_packets != 0,<br>
+                    "Vhost session failed to receive packets from virtio session.",<br>
+                )<br>
+<br>
+    @func_test<br>
+    def pvp_loop(self) -> None:<br>
+        """Test vhost/virtio physical-virtual-physical loop topology.<br>
+<br>
+        Steps:<br>
+            * Launch testpmd session with a physical NIC and virtio-user vdev<br>
+                connected to a vhost-net socket.<br>
+            * Configure the tap interface that is created with IP address and<br>
+                set link state to UP.<br>
+            * Launch second testpmd session with af_packet vdev connected to<br>
+                the tap interface.<br>
+            * Start packet forwarding on both testpmd sessions.<br>
+            * Send 100 packets to the physical interface from external tester.<br>
+            * Capture packets on the same physical interface.<br>
+<br>
+        Verify:<br>
+            * Physical interface receives all 100 sent packets.<br>
+        """<br>
+        self.sut_node = self._ctx.sut_node<br>
+        if not isinstance(self.sut_node.main_session, LinuxSession):<br>
+            self.verify(False, "Must be running on a Linux environment.")<br>
+        with TestPmd(<br>
+            prefix="virtio",<br>
+            vdevs=[VirtualDevice("virtio_user0,path=/dev/vhost-net,queues=1,queue_size=1024")],<br>
+        ) as virtio:<br>
+            self.sut_node.main_session.send_command("ip link set dev tap0 up", privileged=True)<br>
+            with TestPmd(<br>
+                prefix="vhost", no_pci=True, vdevs=[VirtualDevice("net_af_packet0,iface=tap0")]<br>
+            ) as vhost:<br>
+                virtio.set_forward_mode(SimpleForwardingModes.mac)<br>
+                vhost.set_forward_mode(SimpleForwardingModes.mac)<br>
+                vhost.start()<br>
+                virtio.start()<br>
+<br>
+                packet = Ether() / IP()<br>
+                packets = [packet] * 100<br>
+                captured_packets = self.send_packets_and_capture(packets)<br>
+<br>
+                self.verify(<br>
+                    len(captured_packets) >= 100, "Sent packets not received on physical interface."<br>
+                )<br></blockquote><div><br></div><div>Can you remind me what docs you were working from for setting up the pvp test? I'm guessing how you've done it is valid, but I originally thought we needed 2 tap interfaces and that vhost had to run in --no-pci, not virtio. Better safe than sorry. :)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
-- <br>
2.51.0<br>
<br></blockquote><div><br></div><div>Reviewed-by: Patrick Robb <<a href="mailto:probb@iol.unh.edu">probb@iol.unh.edu</a>> </div></div></div>