* [PATCH v1 1/2] dts: add start Tx first method to testpmd shell
@ 2025-09-16 20:04 Dean Marx
2025-09-16 20:04 ` [PATCH v1 2/2] dts: add virtio forwarding test suite Dean Marx
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Dean Marx @ 2025-09-16 20:04 UTC (permalink / raw)
To: probb, luca.vizzarro, yoan.picchi, Honnappa.Nagarahalli, paul.szczepanek
Cc: dev, Dean Marx
Add start tx_first method to testpmd shell, which sends
a specified number of burst packets prior to starting
packet forwarding.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
dts/framework/remote_session/testpmd_shell.py | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/dts/framework/remote_session/testpmd_shell.py b/dts/framework/remote_session/testpmd_shell.py
index 1df3d5f792..44be5ed44f 100644
--- a/dts/framework/remote_session/testpmd_shell.py
+++ b/dts/framework/remote_session/testpmd_shell.py
@@ -1578,6 +1578,27 @@ def start(self, verify: bool = True) -> None:
self._logger.debug(f"Failed to start packet forwarding: \n{start_cmd_output}")
raise InteractiveCommandExecutionError("Testpmd failed to start packet forwarding.")
+ @requires_started_ports
+ def start_tx_first(self, burst_num: int, verify: bool = True) -> None:
+ """Start packet forwarding after sending specified number of bursts of packets.
+
+ Args:
+ burst_num: Number of packets to send before stopping transmission.
+ verify: If :data:`True` , a second start command will be sent in an attempt to verify
+ packet forwarding started as expected.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and forwarding fails to
+ start or ports fail to come up.
+ """
+ self.send_command(f"start tx_first {burst_num if burst_num is not None else ""}")
+ if verify:
+ # If forwarding was already started, sending "start" again should tell us
+ start_cmd_output = self.send_command("start")
+ if "Packet forwarding already started" not in start_cmd_output:
+ self._logger.debug(f"Failed to start packet forwarding: \n{start_cmd_output}")
+ raise InteractiveCommandExecutionError("Testpmd failed to start packet forwarding.")
+
def stop(self, verify: bool = True) -> str:
"""Stop packet forwarding.
--
2.51.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v1 2/2] dts: add virtio forwarding test suite
2025-09-16 20:04 [PATCH v1 1/2] dts: add start Tx first method to testpmd shell Dean Marx
@ 2025-09-16 20:04 ` Dean Marx
2025-09-23 11:38 ` Luca Vizzarro
2025-10-09 13:04 ` Patrick Robb
2025-09-23 11:27 ` [PATCH v1 1/2] dts: add start Tx first method to testpmd shell Luca Vizzarro
2025-10-03 19:27 ` [PATCH v2 " Dean Marx
2 siblings, 2 replies; 10+ messages in thread
From: Dean Marx @ 2025-09-16 20:04 UTC (permalink / raw)
To: probb, luca.vizzarro, yoan.picchi, Honnappa.Nagarahalli, paul.szczepanek
Cc: dev, Dean Marx
Add test suite covering virtio-user and vhost
server/client forwarding scenarios with
testpmd packet validation.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
doc/api/dts/tests.TestSuite_virtio_fwd.rst | 8 +
dts/tests/TestSuite_virtio_fwd.py | 179 +++++++++++++++++++++
2 files changed, 187 insertions(+)
create mode 100644 doc/api/dts/tests.TestSuite_virtio_fwd.rst
create mode 100644 dts/tests/TestSuite_virtio_fwd.py
diff --git a/doc/api/dts/tests.TestSuite_virtio_fwd.rst b/doc/api/dts/tests.TestSuite_virtio_fwd.rst
new file mode 100644
index 0000000000..782eddad2d
--- /dev/null
+++ b/doc/api/dts/tests.TestSuite_virtio_fwd.rst
@@ -0,0 +1,8 @@
+.. SPDX-License-Identifier: BSD-3-Clause
+
+virtio_fwd Test Suite
+===========================
+
+.. automodule:: tests.TestSuite_virtio_fwd
+ :members:
+ :show-inheritance:
\ No newline at end of file
diff --git a/dts/tests/TestSuite_virtio_fwd.py b/dts/tests/TestSuite_virtio_fwd.py
new file mode 100644
index 0000000000..3521fdfc08
--- /dev/null
+++ b/dts/tests/TestSuite_virtio_fwd.py
@@ -0,0 +1,179 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2025 University of New Hampshire
+
+"""Virtio forwarding test suite.
+
+Verify vhost/virtio pvp and loopback topology functionalities.
+"""
+
+import re
+
+from scapy.layers.inet import IP
+from scapy.layers.l2 import Ether
+
+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 requires
+from framework.testbed_model.linux_session import LinuxSession
+from framework.testbed_model.topology import TopologyType
+from framework.testbed_model.virtual_device import VirtualDevice
+
+
+@requires(topology_type=TopologyType.two_links)
+class TestVirtioFwd(TestSuite):
+ """Virtio forwarding test suite."""
+
+ @func_test
+ def virtio_server(self) -> None:
+ """Test virtio server packet transmission.
+
+ Steps:
+ * Launch a testpmd session with a vhost-user virtual device (client side).
+ * Launch a testpmd session with a virtio-user virtual device (server side).
+ * Set the forwarding mode to mac in both sessions.
+ * Start packet forwarding on vhost session.
+ * Send a burst of packets from the virtio session.
+ * Stop packet forwarding on vhost session and collect Rx packet stats.
+
+ Verify:
+ * Vhost session receives packets from virtio session.
+ """
+ with (
+ TestPmdShell(
+ prefix="vhost",
+ no_pci=True,
+ memory_channels=4,
+ vdevs=[VirtualDevice("eth_vhost0,iface=/tmp/vhost-net,client=1")],
+ ) as vhost,
+ TestPmdShell(
+ prefix="virtio",
+ no_pci=True,
+ memory_channels=4,
+ vdevs=[
+ VirtualDevice(
+ "net_virtio_user0,mac=00:01:02:03:04:05,path=/tmp/vhost-net,server=1"
+ )
+ ],
+ ) as virtio,
+ ):
+ vhost.set_forward_mode(SimpleForwardingModes.mac)
+ virtio.set_forward_mode(SimpleForwardingModes.mac)
+
+ vhost.start()
+ virtio.start_tx_first(burst_num=32)
+
+ forwarding_stats = vhost.stop()
+
+ match_rx = re.search(r"RX-packets:\s*(\d+)", forwarding_stats)
+ match_tx = re.search(r"TX-packets:\s*(\d+)", forwarding_stats)
+ rx_packets = int(match_rx[1]) if match_rx else 0
+ tx_packets = int(match_tx[1]) if match_tx else 0
+
+ self.verify(
+ rx_packets != 0 and tx_packets != 0,
+ "Vhost session failed to receive packets from virtio session.",
+ )
+
+ @func_test
+ def virtio_server_reconnect(self) -> None:
+ """Test virtio server reconnection.
+
+ Steps:
+ * Launch a testpmd session with a vhost-user virtual device (client side).
+ * Launch a testpmd session with a virtio-user virtual device (server side).
+ * Close the virtio session and relaunch it.
+ * Start packet forwarding on vhost session.
+ * Send a burst of packets from the virtio session.
+ * Stop packet forwarding on vhost session and collect Rx packet stats.
+
+ Verify:
+ * Vhost session receives packets from relaunched virtio session.
+ """
+ with TestPmdShell(
+ prefix="vhost",
+ no_pci=True,
+ memory_channels=4,
+ vdevs=[VirtualDevice("eth_vhost0,iface=/tmp/vhost-net,client=1")],
+ ) as vhost:
+ with TestPmdShell(
+ prefix="virtio",
+ no_pci=True,
+ memory_channels=4,
+ vdevs=[
+ VirtualDevice(
+ "net_virtio_user0,mac=00:01:02:03:04:05,path=/tmp/vhost-net,server=1"
+ )
+ ],
+ ) as virtio:
+ pass
+ # end session and reconnect
+ with TestPmdShell(
+ prefix="virtio",
+ no_pci=True,
+ memory_channels=4,
+ vdevs=[
+ VirtualDevice(
+ "net_virtio_user0,mac=00:01:02:03:04:05,path=/tmp/vhost-net,server=1"
+ )
+ ],
+ ) as virtio:
+ virtio.set_forward_mode(SimpleForwardingModes.mac)
+ vhost.set_forward_mode(SimpleForwardingModes.mac)
+
+ vhost.start()
+ virtio.start_tx_first(burst_num=32)
+
+ forwarding_stats = vhost.stop()
+
+ match_rx = re.search(r"RX-packets:\s*(\d+)", forwarding_stats)
+ match_tx = re.search(r"TX-packets:\s*(\d+)", forwarding_stats)
+ rx_packets = int(match_rx[1]) if match_rx else 0
+ tx_packets = int(match_tx[1]) if match_tx else 0
+
+ self.verify(
+ rx_packets != 0 and tx_packets != 0,
+ "Vhost session failed to receive packets from virtio session.",
+ )
+
+ @func_test
+ def pvp_loop(self) -> None:
+ """Test vhost/virtio physical-virtual-physical loop topology.
+
+ Steps:
+ * Launch testpmd session with a physical NIC and virtio-user vdev
+ connected to a vhost-net socket.
+ * Configure the tap interface that is created with IP address and
+ set link state to UP.
+ * Launch second testpmd session with af_packet vdev connected to
+ the tap interface.
+ * Start packet forwarding on both testpmd sessions.
+ * Send 100 packets to the physical interface from external tester.
+ * Capture packets on the same physical interface.
+
+ Verify:
+ * Physical interface receives all 100 sent packets.
+ """
+ self.sut_node = self._ctx.sut_node
+ if not isinstance(self._ctx.sut_node.main_session, LinuxSession):
+ self.verify(False, "Must be running on a Linux environment.")
+ with TestPmdShell(
+ prefix="virtio",
+ vdevs=[VirtualDevice("virtio_user0,path=/dev/vhost-net,queues=1,queue_size=1024")],
+ ) as virtio:
+ self.sut_node.main_session.send_command("ip link set dev tap0 up", privileged=True)
+ with TestPmdShell(
+ prefix="vhost", no_pci=True, vdevs=[VirtualDevice("net_af_packet0,iface=tap0")]
+ ) as vhost:
+ virtio.set_forward_mode(SimpleForwardingModes.mac)
+ vhost.set_forward_mode(SimpleForwardingModes.mac)
+ vhost.start()
+ virtio.start()
+
+ packet = Ether() / IP()
+ packets = [packet] * 100
+ captured_packets = self.send_packets_and_capture(packets)
+
+ self.verify(
+ len(captured_packets) >= 100, "Sent packets not received on physical interface."
+ )
--
2.51.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 1/2] dts: add start Tx first method to testpmd shell
2025-09-16 20:04 [PATCH v1 1/2] dts: add start Tx first method to testpmd shell Dean Marx
2025-09-16 20:04 ` [PATCH v1 2/2] dts: add virtio forwarding test suite Dean Marx
@ 2025-09-23 11:27 ` Luca Vizzarro
2025-10-03 19:27 ` [PATCH v2 " Dean Marx
2 siblings, 0 replies; 10+ messages in thread
From: Luca Vizzarro @ 2025-09-23 11:27 UTC (permalink / raw)
To: Dean Marx; +Cc: probb, yoan.picchi, Honnappa.Nagarahalli, paul.szczepanek, dev
Looks good to me.
Reviewed-by: Luca Vizzarro <luca.vizzarro@arm.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 2/2] dts: add virtio forwarding test suite
2025-09-16 20:04 ` [PATCH v1 2/2] dts: add virtio forwarding test suite Dean Marx
@ 2025-09-23 11:38 ` Luca Vizzarro
2025-10-03 18:14 ` Dean Marx
2025-10-09 13:04 ` Patrick Robb
1 sibling, 1 reply; 10+ messages in thread
From: Luca Vizzarro @ 2025-09-23 11:38 UTC (permalink / raw)
To: Dean Marx; +Cc: probb, yoan.picchi, Honnappa.Nagarahalli, paul.szczepanek, dev
On Tue, Sep 16, 2025 at 04:04:58PM +0000, Dean Marx wrote:
> diff --git a/dts/tests/TestSuite_virtio_fwd.py b/dts/tests/TestSuite_virtio_fwd.py
> new file mode 100644
> index 0000000000..3521fdfc08
> --- /dev/null
> +++ b/dts/tests/TestSuite_virtio_fwd.py
> @@ -0,0 +1,179 @@
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright(c) 2025 University of New Hampshire
> +
> +"""Virtio forwarding test suite.
> +
> +Verify vhost/virtio pvp and loopback topology functionalities.
> +"""
> +
> +import re
> +
> +from scapy.layers.inet import IP
> +from scapy.layers.l2 import Ether
> +
> +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 requires
> +from framework.testbed_model.linux_session import LinuxSession
> +from framework.testbed_model.topology import TopologyType
> +from framework.testbed_model.virtual_device import VirtualDevice
> +
> +
> +@requires(topology_type=TopologyType.two_links)
> +class TestVirtioFwd(TestSuite):
> + """Virtio forwarding test suite."""
> +
> + @func_test
> + def virtio_server(self) -> None:
> + """Test virtio server packet transmission.
> +
> + Steps:
> + * Launch a testpmd session with a vhost-user virtual device (client side).
> + * Launch a testpmd session with a virtio-user virtual device (server side).
> + * Set the forwarding mode to mac in both sessions.
> + * Start packet forwarding on vhost session.
> + * Send a burst of packets from the virtio session.
> + * Stop packet forwarding on vhost session and collect Rx packet stats.
> +
> + Verify:
> + * Vhost session receives packets from virtio session.
> + """
> + with (
> + TestPmdShell(
> + prefix="vhost",
> + no_pci=True,
> + memory_channels=4,
> + vdevs=[VirtualDevice("eth_vhost0,iface=/tmp/vhost-net,client=1")],
> + ) as vhost,
> + TestPmdShell(
> + prefix="virtio",
> + no_pci=True,
> + memory_channels=4,
> + vdevs=[
> + VirtualDevice(
> + "net_virtio_user0,mac=00:01:02:03:04:05,path=/tmp/vhost-net,server=1"
> + )
> + ],
> + ) as virtio,
> + ):
> + vhost.set_forward_mode(SimpleForwardingModes.mac)
> + virtio.set_forward_mode(SimpleForwardingModes.mac)
> +
> + vhost.start()
> + virtio.start_tx_first(burst_num=32)
> +
> + forwarding_stats = vhost.stop()
> +
> + match_rx = re.search(r"RX-packets:\s*(\d+)", forwarding_stats)
> + match_tx = re.search(r"TX-packets:\s*(\d+)", forwarding_stats)
> + rx_packets = int(match_rx[1]) if match_rx else 0
> + tx_packets = int(match_tx[1]) if match_tx else 0
Would it be worth introducing a TextParser class that will actually
parse the forwarding stats and present them properly to the test?
> +
> + self.verify(
> + rx_packets != 0 and tx_packets != 0,
> + "Vhost session failed to receive packets from virtio session.",
> + )
> +
> + @func_test
> + def virtio_server_reconnect(self) -> None:
> + """Test virtio server reconnection.
> +
> + Steps:
> + * Launch a testpmd session with a vhost-user virtual device (client side).
> + * Launch a testpmd session with a virtio-user virtual device (server side).
> + * Close the virtio session and relaunch it.
> + * Start packet forwarding on vhost session.
> + * Send a burst of packets from the virtio session.
> + * Stop packet forwarding on vhost session and collect Rx packet stats.
> +
> + Verify:
> + * Vhost session receives packets from relaunched virtio session.
> + """
> + with TestPmdShell(
> + prefix="vhost",
> + no_pci=True,
> + memory_channels=4,
> + vdevs=[VirtualDevice("eth_vhost0,iface=/tmp/vhost-net,client=1")],
> + ) as vhost:
> + with TestPmdShell(
> + prefix="virtio",
> + no_pci=True,
> + memory_channels=4,
> + vdevs=[
> + VirtualDevice(
> + "net_virtio_user0,mac=00:01:02:03:04:05,path=/tmp/vhost-net,server=1"
> + )
> + ],
> + ) as virtio:
> + pass
> + # end session and reconnect
how could this is launched twice? Could use some explanation here.
> + with TestPmdShell(
> + prefix="virtio",
> + no_pci=True,
> + memory_channels=4,
> + vdevs=[
> + VirtualDevice(
> + "net_virtio_user0,mac=00:01:02:03:04:05,path=/tmp/vhost-net,server=1"
> + )
Wouldn't it make more sense to store the vdev in a variable and re-use
it?
> + ],
> + ) as virtio:
> + virtio.set_forward_mode(SimpleForwardingModes.mac)
> + vhost.set_forward_mode(SimpleForwardingModes.mac)
> +
> + vhost.start()
> + virtio.start_tx_first(burst_num=32)
> +
> + forwarding_stats = vhost.stop()
> +
> + match_rx = re.search(r"RX-packets:\s*(\d+)", forwarding_stats)
> + match_tx = re.search(r"TX-packets:\s*(\d+)", forwarding_stats)
> + rx_packets = int(match_rx[1]) if match_rx else 0
> + tx_packets = int(match_tx[1]) if match_tx else 0
> +
> + self.verify(
> + rx_packets != 0 and tx_packets != 0,
> + "Vhost session failed to receive packets from virtio session.",
> + )
> +
> + @func_test
> + def pvp_loop(self) -> None:
> + """Test vhost/virtio physical-virtual-physical loop topology.
> +
> + Steps:
> + * Launch testpmd session with a physical NIC and virtio-user vdev
> + connected to a vhost-net socket.
> + * Configure the tap interface that is created with IP address and
> + set link state to UP.
> + * Launch second testpmd session with af_packet vdev connected to
> + the tap interface.
> + * Start packet forwarding on both testpmd sessions.
> + * Send 100 packets to the physical interface from external tester.
> + * Capture packets on the same physical interface.
> +
> + Verify:
> + * Physical interface receives all 100 sent packets.
> + """
> + self.sut_node = self._ctx.sut_node
> + if not isinstance(self._ctx.sut_node.main_session, LinuxSession):
surely you could just use the `self.sut_node` you've just created :D
> + self.verify(False, "Must be running on a Linux environment.")
> + with TestPmdShell(
> + prefix="virtio",
> + vdevs=[VirtualDevice("virtio_user0,path=/dev/vhost-net,queues=1,queue_size=1024")],
> + ) as virtio:
> + self.sut_node.main_session.send_command("ip link set dev tap0 up", privileged=True)
> + with TestPmdShell(
> + prefix="vhost", no_pci=True, vdevs=[VirtualDevice("net_af_packet0,iface=tap0")]
> + ) as vhost:
> + virtio.set_forward_mode(SimpleForwardingModes.mac)
> + vhost.set_forward_mode(SimpleForwardingModes.mac)
> + vhost.start()
> + virtio.start()
> +
> + packet = Ether() / IP()
> + packets = [packet] * 100
> + captured_packets = self.send_packets_and_capture(packets)
> +
> + self.verify(
> + len(captured_packets) >= 100, "Sent packets not received on physical interface."
> + )
> --
> 2.51.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 2/2] dts: add virtio forwarding test suite
2025-09-23 11:38 ` Luca Vizzarro
@ 2025-10-03 18:14 ` Dean Marx
0 siblings, 0 replies; 10+ messages in thread
From: Dean Marx @ 2025-10-03 18:14 UTC (permalink / raw)
To: Luca Vizzarro
Cc: probb, yoan.picchi, Honnappa.Nagarahalli, paul.szczepanek, dev
> Would it be worth introducing a TextParser class that will actually
> parse the forwarding stats and present them properly to the test?
Yes I think that would be useful moving forward, I'll add one to the
next version.
<snip>
> > + with TestPmdShell(
> > + prefix="vhost",
> > + no_pci=True,
> > + memory_channels=4,
> > + vdevs=[VirtualDevice("eth_vhost0,iface=/tmp/vhost-net,client=1")],
> > + ) as vhost:
> > + with TestPmdShell(
> > + prefix="virtio",
> > + no_pci=True,
> > + memory_channels=4,
> > + vdevs=[
> > + VirtualDevice(
> > + "net_virtio_user0,mac=00:01:02:03:04:05,path=/tmp/vhost-net,server=1"
> > + )
> > + ],
> > + ) as virtio:
> > + pass
> > + # end session and reconnect
> how could this is launched twice? Could use some explanation here.
Essentially the way it works is by launching a vhost-user testpmd
session, which waits for a virtio-user testpmd session to connect to:
EAL: Detected CPU lcores: 32
EAL: Detected NUMA nodes: 2
EAL: Detected static linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/virtio_27338_20251003172250/mp_socket
EAL: Selected IOVA mode 'VA'
EAL: VFIO support initialized
VIRTIO_DRIVER: vhost_user_start_server(): (/tmp/vhost-net) waiting for
client connection...
Then, when the virtio-user session is launched, it connects to the
vhost-user socket /tmp/vhost-net:
VHOST_CONFIG: (/tmp/vhost-net) connected
...
VHOST_CONFIG: (/tmp/vhost-net) new device status(0x0000000f):
VHOST_CONFIG: (/tmp/vhost-net) -RESET: 0
VHOST_CONFIG: (/tmp/vhost-net) -ACKNOWLEDGE: 1
VHOST_CONFIG: (/tmp/vhost-net) -DRIVER: 1
VHOST_CONFIG: (/tmp/vhost-net) -FEATURES_OK: 1
VHOST_CONFIG: (/tmp/vhost-net) -DRIVER_OK: 1
VHOST_CONFIG: (/tmp/vhost-net) -DEVICE_NEED_RESET: 0
VHOST_CONFIG: (/tmp/vhost-net) -FAILED: 0
By launching the virtio-user session through the context manager, then
closing it and starting a new session with a new context manager, the
original virtio-user session is closed, disconnecting the client. The
test case is verifying that the vhost-user socket can support multiple
sequential client connections.
> > + with TestPmdShell(
> > + prefix="virtio",
> > + no_pci=True,
> > + memory_channels=4,
> > + vdevs=[
> > + VirtualDevice(
> > + "net_virtio_user0,mac=00:01:02:03:04:05,path=/tmp/vhost-net,server=1"
> > + )
> Wouldn't it make more sense to store the vdev in a variable and re-use
> it?
Definitely, I'll fix that
<snip>
> > + self.sut_node = self._ctx.sut_node
> > + if not isinstance(self._ctx.sut_node.main_session, LinuxSession):
> surely you could just use the `self.sut_node` you've just created :D
Good catch thanks
I'll send out a new version within the next week addressing these
points. Thanks for the review!
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/2] dts: add start Tx first method to testpmd shell
2025-09-16 20:04 [PATCH v1 1/2] dts: add start Tx first method to testpmd shell Dean Marx
2025-09-16 20:04 ` [PATCH v1 2/2] dts: add virtio forwarding test suite Dean Marx
2025-09-23 11:27 ` [PATCH v1 1/2] dts: add start Tx first method to testpmd shell Luca Vizzarro
@ 2025-10-03 19:27 ` Dean Marx
2025-10-03 19:27 ` [PATCH v2 2/2] dts: add virtio forwarding test suite Dean Marx
2 siblings, 1 reply; 10+ messages in thread
From: Dean Marx @ 2025-10-03 19:27 UTC (permalink / raw)
To: probb, luca.vizzarro, yoan.picchi, Honnappa.Nagarahalli, paul.szczepanek
Cc: dev, Dean Marx
Add start tx_first method to testpmd shell, which sends
a specified number of burst packets prior to starting
packet forwarding.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
Reviewed-by: Luca Vizzarro <luca.vizzarro@arm.com>
---
dts/api/testpmd/__init__.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/dts/api/testpmd/__init__.py b/dts/api/testpmd/__init__.py
index a060ab5639..5cf1ae7fac 100644
--- a/dts/api/testpmd/__init__.py
+++ b/dts/api/testpmd/__init__.py
@@ -199,6 +199,27 @@ def start(self, verify: bool = True) -> None:
self._logger.debug(f"Failed to start packet forwarding: \n{start_cmd_output}")
raise InteractiveCommandExecutionError("Testpmd failed to start packet forwarding.")
+ @_requires_started_ports
+ def start_tx_first(self, burst_num: int, verify: bool = True) -> None:
+ """Start packet forwarding after sending specified number of bursts of packets.
+
+ Args:
+ burst_num: Number of packets to send before stopping transmission.
+ verify: If :data:`True` , a second start command will be sent in an attempt to verify
+ packet forwarding started as expected.
+
+ Raises:
+ InteractiveCommandExecutionError: If `verify` is :data:`True` and forwarding fails to
+ start or ports fail to come up.
+ """
+ self.send_command(f"start tx_first {burst_num if burst_num is not None else ""}")
+ if verify:
+ # If forwarding was already started, sending "start" again should tell us
+ start_cmd_output = self.send_command("start")
+ if "Packet forwarding already started" not in start_cmd_output:
+ self._logger.debug(f"Failed to start packet forwarding: \n{start_cmd_output}")
+ raise InteractiveCommandExecutionError("Testpmd failed to start packet forwarding.")
+
def stop(self, verify: bool = True) -> str:
"""Stop packet forwarding.
--
2.51.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 2/2] dts: add virtio forwarding test suite
2025-10-03 19:27 ` [PATCH v2 " Dean Marx
@ 2025-10-03 19:27 ` Dean Marx
2025-10-21 15:13 ` Luca Vizzarro
0 siblings, 1 reply; 10+ messages in thread
From: Dean Marx @ 2025-10-03 19:27 UTC (permalink / raw)
To: probb, luca.vizzarro, yoan.picchi, Honnappa.Nagarahalli, paul.szczepanek
Cc: dev, Dean Marx
Add test suite covering virtio-user and vhost
server/client forwarding scenarios with
testpmd packet validation.
Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
---
doc/api/tests.TestSuite_virtio_fwd.rst | 8 ++
dts/tests/TestSuite_virtio_fwd.py | 180 +++++++++++++++++++++++++
2 files changed, 188 insertions(+)
create mode 100644 doc/api/tests.TestSuite_virtio_fwd.rst
create mode 100644 dts/tests/TestSuite_virtio_fwd.py
diff --git a/doc/api/tests.TestSuite_virtio_fwd.rst b/doc/api/tests.TestSuite_virtio_fwd.rst
new file mode 100644
index 0000000000..782eddad2d
--- /dev/null
+++ b/doc/api/tests.TestSuite_virtio_fwd.rst
@@ -0,0 +1,8 @@
+.. SPDX-License-Identifier: BSD-3-Clause
+
+virtio_fwd Test Suite
+===========================
+
+.. automodule:: tests.TestSuite_virtio_fwd
+ :members:
+ :show-inheritance:
\ No newline at end of file
diff --git a/dts/tests/TestSuite_virtio_fwd.py b/dts/tests/TestSuite_virtio_fwd.py
new file mode 100644
index 0000000000..194bd24257
--- /dev/null
+++ b/dts/tests/TestSuite_virtio_fwd.py
@@ -0,0 +1,180 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2025 University of New Hampshire
+
+"""Virtio forwarding test suite.
+
+Verify vhost/virtio pvp and loopback topology functionalities.
+"""
+
+from scapy.layers.inet import IP
+from scapy.layers.l2 import Ether
+
+from api.capabilities import LinkTopology
+from api.testpmd import TestPmd
+from api.testpmd.config import SimpleForwardingModes
+from framework.parser import TextParser
+from framework.test_suite import TestSuite, func_test
+from framework.testbed_model.capability import requires
+from framework.testbed_model.linux_session import LinuxSession
+from framework.testbed_model.virtual_device import VirtualDevice
+
+
+@requires(topology_type=LinkTopology.TWO_LINKS)
+class TestVirtioFwd(TestSuite):
+ """Virtio forwarding test suite."""
+
+ class ForwardingParsers:
+ """Class for gathering Rx/Tx packets from testpmd stats."""
+
+ rx_packets = TextParser.find_int(r"RX-packets:\s*(\d+)")
+ tx_packets = TextParser.find_int(r"TX-packets:\s*(\d+)")
+
+ class vdevs:
+ """Class containing virtio-user and vhost-user virtual devices."""
+
+ virtio_user = VirtualDevice(
+ "net_virtio_user0,mac=00:01:02:03:04:05,path=/tmp/vhost-net,server=1"
+ )
+ vhost_user = VirtualDevice("eth_vhost0,iface=/tmp/vhost-net,client=1")
+
+ @func_test
+ def virtio_server(self) -> None:
+ """Test virtio server packet transmission.
+
+ Steps:
+ * Launch a testpmd session with a vhost-user virtual device (client side).
+ * Launch a testpmd session with a virtio-user virtual device (server side).
+ * Set the forwarding mode to mac in both sessions.
+ * Start packet forwarding on vhost session.
+ * Send a burst of packets from the virtio session.
+ * Stop packet forwarding on vhost session and collect Rx packet stats.
+
+ Verify:
+ * Vhost session receives packets from virtio session.
+ """
+ with (
+ TestPmd(
+ prefix="vhost",
+ no_pci=True,
+ memory_channels=4,
+ vdevs=[self.vdevs.vhost_user],
+ ) as vhost,
+ TestPmd(
+ prefix="virtio",
+ no_pci=True,
+ memory_channels=4,
+ vdevs=[self.vdevs.virtio_user],
+ ) as virtio,
+ ):
+ vhost.set_forward_mode(SimpleForwardingModes.mac)
+ virtio.set_forward_mode(SimpleForwardingModes.mac)
+
+ vhost.start()
+ virtio.start_tx_first(burst_num=32)
+
+ forwarding_stats = vhost.stop()
+
+ rx_packets = self.ForwardingParsers.rx_packets["TextParser_fn"](forwarding_stats) or 0
+ tx_packets = self.ForwardingParsers.tx_packets["TextParser_fn"](forwarding_stats) or 0
+
+ self.verify(
+ rx_packets != 0 and tx_packets != 0,
+ "Vhost session failed to receive packets from virtio session.",
+ )
+
+ @func_test
+ def virtio_server_reconnect(self) -> None:
+ """Test virtio server reconnection.
+
+ Steps:
+ * Launch a testpmd session with a vhost-user virtual device (client side).
+ * Launch a testpmd session with a virtio-user virtual device (server side).
+ * Close the virtio session and relaunch it.
+ * Start packet forwarding on vhost session.
+ * Send a burst of packets from the virtio session.
+ * Stop packet forwarding on vhost session and collect Rx packet stats.
+
+ Verify:
+ * Vhost session receives packets from relaunched virtio session.
+ """
+ with TestPmd(
+ prefix="vhost",
+ no_pci=True,
+ memory_channels=4,
+ vdevs=[self.vdevs.vhost_user],
+ ) as vhost:
+ with TestPmd(
+ prefix="virtio",
+ no_pci=True,
+ memory_channels=4,
+ vdevs=[self.vdevs.virtio_user],
+ ) as virtio:
+ pass
+ # end session and reconnect
+ with TestPmd(
+ prefix="virtio",
+ no_pci=True,
+ memory_channels=4,
+ vdevs=[self.vdevs.virtio_user],
+ ) as virtio:
+ virtio.set_forward_mode(SimpleForwardingModes.mac)
+ vhost.set_forward_mode(SimpleForwardingModes.mac)
+
+ vhost.start()
+ virtio.start_tx_first(burst_num=32)
+
+ forwarding_stats = vhost.stop()
+
+ rx_packets = (
+ self.ForwardingParsers.rx_packets["TextParser_fn"](forwarding_stats) or 0
+ )
+ tx_packets = (
+ self.ForwardingParsers.tx_packets["TextParser_fn"](forwarding_stats) or 0
+ )
+
+ self.verify(
+ rx_packets != 0 and tx_packets != 0,
+ "Vhost session failed to receive packets from virtio session.",
+ )
+
+ @func_test
+ def pvp_loop(self) -> None:
+ """Test vhost/virtio physical-virtual-physical loop topology.
+
+ Steps:
+ * Launch testpmd session with a physical NIC and virtio-user vdev
+ connected to a vhost-net socket.
+ * Configure the tap interface that is created with IP address and
+ set link state to UP.
+ * Launch second testpmd session with af_packet vdev connected to
+ the tap interface.
+ * Start packet forwarding on both testpmd sessions.
+ * Send 100 packets to the physical interface from external tester.
+ * Capture packets on the same physical interface.
+
+ Verify:
+ * Physical interface receives all 100 sent packets.
+ """
+ self.sut_node = self._ctx.sut_node
+ if not isinstance(self.sut_node.main_session, LinuxSession):
+ self.verify(False, "Must be running on a Linux environment.")
+ with TestPmd(
+ prefix="virtio",
+ vdevs=[VirtualDevice("virtio_user0,path=/dev/vhost-net,queues=1,queue_size=1024")],
+ ) as virtio:
+ self.sut_node.main_session.send_command("ip link set dev tap0 up", privileged=True)
+ with TestPmd(
+ prefix="vhost", no_pci=True, vdevs=[VirtualDevice("net_af_packet0,iface=tap0")]
+ ) as vhost:
+ virtio.set_forward_mode(SimpleForwardingModes.mac)
+ vhost.set_forward_mode(SimpleForwardingModes.mac)
+ vhost.start()
+ virtio.start()
+
+ packet = Ether() / IP()
+ packets = [packet] * 100
+ captured_packets = self.send_packets_and_capture(packets)
+
+ self.verify(
+ len(captured_packets) >= 100, "Sent packets not received on physical interface."
+ )
--
2.51.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 2/2] dts: add virtio forwarding test suite
2025-09-16 20:04 ` [PATCH v1 2/2] dts: add virtio forwarding test suite Dean Marx
2025-09-23 11:38 ` Luca Vizzarro
@ 2025-10-09 13:04 ` Patrick Robb
1 sibling, 0 replies; 10+ messages in thread
From: Patrick Robb @ 2025-10-09 13:04 UTC (permalink / raw)
To: Dean Marx
Cc: luca.vizzarro, yoan.picchi, Honnappa.Nagarahalli, paul.szczepanek, dev
[-- Attachment #1: Type: text/plain, Size: 1065 bytes --]
On Tue, Sep 16, 2025 at 4:05 PM Dean Marx <dmarx@iol.unh.edu> wrote:
> Add test suite covering virtio-user and vhost
> server/client forwarding scenarios with
> testpmd packet validation.
>
> Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
> ---
> doc/api/dts/tests.TestSuite_virtio_fwd.rst | 8 +
> dts/tests/TestSuite_virtio_fwd.py | 179 +++++++++++++++++++++
> 2 files changed, 187 insertions(+)
> create mode 100644 doc/api/dts/tests.TestSuite_virtio_fwd.rst
> create mode 100644 dts/tests/TestSuite_virtio_fwd.py
>
> diff --git a/doc/api/dts/tests.TestSuite_virtio_fwd.rst
> b/doc/api/dts/tests.TestSuite_virtio_fwd.rst
> new file mode 100644
> index 0000000000..782eddad2d
> --- /dev/null
> +++ b/doc/api/dts/tests.TestSuite_virtio_fwd.rst
> @@ -0,0 +1,8 @@
> +.. SPDX-License-Identifier: BSD-3-Clause
> +
> +virtio_fwd Test Suite
> +===========================
>
I think this might break the build as I think the ==== line needs to be the
same in length as the above testsuite name. Can you check?
> +
>
>
[-- Attachment #2: Type: text/html, Size: 1666 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/2] dts: add virtio forwarding test suite
2025-10-03 19:27 ` [PATCH v2 2/2] dts: add virtio forwarding test suite Dean Marx
@ 2025-10-21 15:13 ` Luca Vizzarro
2025-10-21 17:35 ` Dean Marx
0 siblings, 1 reply; 10+ messages in thread
From: Luca Vizzarro @ 2025-10-21 15:13 UTC (permalink / raw)
To: Dean Marx; +Cc: probb, yoan.picchi, Honnappa.Nagarahalli, paul.szczepanek, dev
On Fri, Oct 03, 2025 at 03:27:16PM +0000, Dean Marx wrote:
> Add test suite covering virtio-user and vhost
> server/client forwarding scenarios with
> testpmd packet validation.
>
> Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
> ---
> doc/api/tests.TestSuite_virtio_fwd.rst | 8 ++
> dts/tests/TestSuite_virtio_fwd.py | 180 +++++++++++++++++++++++++
> 2 files changed, 188 insertions(+)
> create mode 100644 doc/api/tests.TestSuite_virtio_fwd.rst
> create mode 100644 dts/tests/TestSuite_virtio_fwd.py
>
> diff --git a/doc/api/tests.TestSuite_virtio_fwd.rst b/doc/api/tests.TestSuite_virtio_fwd.rst
> new file mode 100644
> index 0000000000..782eddad2d
> --- /dev/null
> +++ b/doc/api/tests.TestSuite_virtio_fwd.rst
> @@ -0,0 +1,8 @@
> +.. SPDX-License-Identifier: BSD-3-Clause
> +
> +virtio_fwd Test Suite
> +===========================
this is fine, but ideally should be aligned with the heading.
> +
> +.. automodule:: tests.TestSuite_virtio_fwd
> + :members:
> + :show-inheritance:
> \ No newline at end of file
> diff --git a/dts/tests/TestSuite_virtio_fwd.py b/dts/tests/TestSuite_virtio_fwd.py
> new file mode 100644
> index 0000000000..194bd24257
> --- /dev/null
> +++ b/dts/tests/TestSuite_virtio_fwd.py
> @@ -0,0 +1,180 @@
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright(c) 2025 University of New Hampshire
> +
> +"""Virtio forwarding test suite.
> +
> +Verify vhost/virtio pvp and loopback topology functionalities.
> +"""
> +
> +from scapy.layers.inet import IP
> +from scapy.layers.l2 import Ether
> +
> +from api.capabilities import LinkTopology
> +from api.testpmd import TestPmd
> +from api.testpmd.config import SimpleForwardingModes
> +from framework.parser import TextParser
> +from framework.test_suite import TestSuite, func_test
> +from framework.testbed_model.capability import requires
> +from framework.testbed_model.linux_session import LinuxSession
> +from framework.testbed_model.virtual_device import VirtualDevice
> +
> +
> +@requires(topology_type=LinkTopology.TWO_LINKS)
> +class TestVirtioFwd(TestSuite):
> + """Virtio forwarding test suite."""
> +
> + class ForwardingParsers:
> + """Class for gathering Rx/Tx packets from testpmd stats."""
> +
> + rx_packets = TextParser.find_int(r"RX-packets:\s*(\d+)")
> + tx_packets = TextParser.find_int(r"TX-packets:\s*(\d+)")
> +
> + class vdevs:
> + """Class containing virtio-user and vhost-user virtual devices."""
is it actually vhost-user? or just vhost?
> +
> + virtio_user = VirtualDevice(
> + "net_virtio_user0,mac=00:01:02:03:04:05,path=/tmp/vhost-net,server=1"
> + )
> + vhost_user = VirtualDevice("eth_vhost0,iface=/tmp/vhost-net,client=1")
How come you put these properties under some internal classes? Not sure
how this helps. The vdevs class should technically be capitalised as
well. Either way if these are just class variables, they should be made
as such. Doing the following:
parse_rx_packets: ClassVar[ParserFn] = TextParser...
parse_tx_packets: ...
virtio_user_vdev: ClassVar[VirtualDevice] = ...
vhost_user_vdev: ...
is perfectly fine and acceptable.
I've changed the naming of the parser functions, because you are
effectively treating these as functions, then they should be named as
such.
> +
> + @func_test
> + def virtio_server(self) -> None:
> + """Test virtio server packet transmission.
> +
> + Steps:
> + * Launch a testpmd session with a vhost-user virtual device (client side).
> + * Launch a testpmd session with a virtio-user virtual device (server side).
> + * Set the forwarding mode to mac in both sessions.
> + * Start packet forwarding on vhost session.
> + * Send a burst of packets from the virtio session.
> + * Stop packet forwarding on vhost session and collect Rx packet stats.
> +
> + Verify:
> + * Vhost session receives packets from virtio session.
> + """
> + with (
> + TestPmd(
> + prefix="vhost",
> + no_pci=True,
> + memory_channels=4,
> + vdevs=[self.vdevs.vhost_user],
> + ) as vhost,
> + TestPmd(
> + prefix="virtio",
> + no_pci=True,
> + memory_channels=4,
> + vdevs=[self.vdevs.virtio_user],
> + ) as virtio,
> + ):
> + vhost.set_forward_mode(SimpleForwardingModes.mac)
> + virtio.set_forward_mode(SimpleForwardingModes.mac)
> +
> + vhost.start()
> + virtio.start_tx_first(burst_num=32)
> +
> + forwarding_stats = vhost.stop()
> +
> + rx_packets = self.ForwardingParsers.rx_packets["TextParser_fn"](forwarding_stats) or 0
> + tx_packets = self.ForwardingParsers.tx_packets["TextParser_fn"](forwarding_stats) or 0
So I understand you are basically reusing the functionality of the
TextParser functions here. I guess it's not a bad shout but I would not
expose the internals which are only meant to be used within the
TextParser class for handling with generic dataclass metadata.
Ideally we want this:
rx_packets = self.parse_rx_packets(forwarding_stats) or 0
You can implement __call__ in ParserFn to make this happen. In the best
scenario we'd want the return type to be correct as well instead of just
Any. If you want to, you can play around and implement a Generic[T] in
ParserFn to replace Any with T. This will probably require you to make
changes elsewhere though. It may get tricky easily, so it's not really
mandatory.
> +
> + self.verify(
> + rx_packets != 0 and tx_packets != 0,
> + "Vhost session failed to receive packets from virtio session.",
> + )
> +
> + @func_test
> + def virtio_server_reconnect(self) -> None:
> + """Test virtio server reconnection.
> +
> + Steps:
> + * Launch a testpmd session with a vhost-user virtual device (client side).
> + * Launch a testpmd session with a virtio-user virtual device (server side).
> + * Close the virtio session and relaunch it.
> + * Start packet forwarding on vhost session.
> + * Send a burst of packets from the virtio session.
> + * Stop packet forwarding on vhost session and collect Rx packet stats.
> +
> + Verify:
> + * Vhost session receives packets from relaunched virtio session.
> + """
> + with TestPmd(
> + prefix="vhost",
> + no_pci=True,
> + memory_channels=4,
> + vdevs=[self.vdevs.vhost_user],
> + ) as vhost:
> + with TestPmd(
> + prefix="virtio",
> + no_pci=True,
> + memory_channels=4,
> + vdevs=[self.vdevs.virtio_user],
> + ) as virtio:
> + pass
> + # end session and reconnect
> + with TestPmd(
> + prefix="virtio",
> + no_pci=True,
> + memory_channels=4,
> + vdevs=[self.vdevs.virtio_user],
> + ) as virtio:
> + virtio.set_forward_mode(SimpleForwardingModes.mac)
> + vhost.set_forward_mode(SimpleForwardingModes.mac)
> +
> + vhost.start()
> + virtio.start_tx_first(burst_num=32)
> +
> + forwarding_stats = vhost.stop()
> +
> + rx_packets = (
> + self.ForwardingParsers.rx_packets["TextParser_fn"](forwarding_stats) or 0
> + )
> + tx_packets = (
> + self.ForwardingParsers.tx_packets["TextParser_fn"](forwarding_stats) or 0
> + )
> +
> + self.verify(
> + rx_packets != 0 and tx_packets != 0,
> + "Vhost session failed to receive packets from virtio session.",
> + )
> +
> + @func_test
> + def pvp_loop(self) -> None:
> + """Test vhost/virtio physical-virtual-physical loop topology.
> +
> + Steps:
> + * Launch testpmd session with a physical NIC and virtio-user vdev
> + connected to a vhost-net socket.
> + * Configure the tap interface that is created with IP address and
> + set link state to UP.
> + * Launch second testpmd session with af_packet vdev connected to
> + the tap interface.
> + * Start packet forwarding on both testpmd sessions.
> + * Send 100 packets to the physical interface from external tester.
> + * Capture packets on the same physical interface.
> +
> + Verify:
> + * Physical interface receives all 100 sent packets.
> + """
> + self.sut_node = self._ctx.sut_node
> + if not isinstance(self.sut_node.main_session, LinuxSession):
> + self.verify(False, "Must be running on a Linux environment.")
> + with TestPmd(
> + prefix="virtio",
> + vdevs=[VirtualDevice("virtio_user0,path=/dev/vhost-net,queues=1,queue_size=1024")],
> + ) as virtio:
> + self.sut_node.main_session.send_command("ip link set dev tap0 up", privileged=True)
This should have been implemented as part of main_session. If it's not,
it should. Shouldn't call send_command directly like this.
> + with TestPmd(
> + prefix="vhost", no_pci=True, vdevs=[VirtualDevice("net_af_packet0,iface=tap0")]
> + ) as vhost:
> + virtio.set_forward_mode(SimpleForwardingModes.mac)
> + vhost.set_forward_mode(SimpleForwardingModes.mac)
> + vhost.start()
> + virtio.start()
> +
> + packet = Ether() / IP()
> + packets = [packet] * 100
> + captured_packets = self.send_packets_and_capture(packets)
> +
> + self.verify(
> + len(captured_packets) >= 100, "Sent packets not received on physical interface."
> + )
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 2/2] dts: add virtio forwarding test suite
2025-10-21 15:13 ` Luca Vizzarro
@ 2025-10-21 17:35 ` Dean Marx
0 siblings, 0 replies; 10+ messages in thread
From: Dean Marx @ 2025-10-21 17:35 UTC (permalink / raw)
To: Luca Vizzarro
Cc: probb, yoan.picchi, Honnappa.Nagarahalli, paul.szczepanek, dev
On Tue, Oct 21, 2025 at 11:13 AM Luca Vizzarro <luca.vizzarro@arm.com> wrote:
>
> On Fri, Oct 03, 2025 at 03:27:16PM +0000, Dean Marx wrote:
> > Add test suite covering virtio-user and vhost
> > server/client forwarding scenarios with
> > testpmd packet validation.
> >
> > Signed-off-by: Dean Marx <dmarx@iol.unh.edu>
<snip>
> > +
> > +virtio_fwd Test Suite
> > +===========================
> this is fine, but ideally should be aligned with the heading.
I'll change this, I just noticed I put it in the wrong directory too
so thanks to you and Patrick for pointing that out
<snip>
> > + class vdevs:
> > + """Class containing virtio-user and vhost-user virtual devices."""
> is it actually vhost-user? or just vhost?
It's vhost-user since it's using a unix socket path (/tmp/vhost-net),
whereas a vhost version would use a kernel network interface like tap0
or something similar.
> > +
> > + virtio_user = VirtualDevice(
> > + "net_virtio_user0,mac=00:01:02:03:04:05,path=/tmp/vhost-net,server=1"
> > + )
> > + vhost_user = VirtualDevice("eth_vhost0,iface=/tmp/vhost-net,client=1")
>
> How come you put these properties under some internal classes? Not sure
> how this helps. The vdevs class should technically be capitalised as
> well. Either way if these are just class variables, they should be made
> as such. Doing the following:
>
> parse_rx_packets: ClassVar[ParserFn] = TextParser...
> parse_tx_packets: ...
> virtio_user_vdev: ClassVar[VirtualDevice] = ...
> vhost_user_vdev: ...
>
> is perfectly fine and acceptable.
>
> I've changed the naming of the parser functions, because you are
> effectively treating these as functions, then they should be named as
> such.
Got it, I'll change this
<snip>
> > +
> > + rx_packets = self.ForwardingParsers.rx_packets["TextParser_fn"](forwarding_stats) or 0
> > + tx_packets = self.ForwardingParsers.tx_packets["TextParser_fn"](forwarding_stats) or 0
>
> So I understand you are basically reusing the functionality of the
> TextParser functions here. I guess it's not a bad shout but I would not
> expose the internals which are only meant to be used within the
> TextParser class for handling with generic dataclass metadata.
>
> Ideally we want this:
>
> rx_packets = self.parse_rx_packets(forwarding_stats) or 0
>
> You can implement __call__ in ParserFn to make this happen. In the best
> scenario we'd want the return type to be correct as well instead of just
> Any. If you want to, you can play around and implement a Generic[T] in
> ParserFn to replace Any with T. This will probably require you to make
> changes elsewhere though. It may get tricky easily, so it's not really
> mandatory.
Hmm okay, I'll try to write a workaround for this without
overcomplicating things
<snip>
> > + with TestPmd(
> > + prefix="virtio",
> > + vdevs=[VirtualDevice("virtio_user0,path=/dev/vhost-net,queues=1,queue_size=1024")],
> > + ) as virtio:
> > + self.sut_node.main_session.send_command("ip link set dev tap0 up", privileged=True)
>
> This should have been implemented as part of main_session. If it's not,
> it should. Shouldn't call send_command directly like this.
I'll add this to the next version
>
> > + with TestPmd(
> > + prefix="vhost", no_pci=True, vdevs=[VirtualDevice("net_af_packet0,iface=tap0")]
> > + ) as vhost:
> > + virtio.set_forward_mode(SimpleForwardingModes.mac)
> > + vhost.set_forward_mode(SimpleForwardingModes.mac)
> > + vhost.start()
> > + virtio.start()
> > +
> > + packet = Ether() / IP()
> > + packets = [packet] * 100
> > + captured_packets = self.send_packets_and_capture(packets)
> > +
> > + self.verify(
> > + len(captured_packets) >= 100, "Sent packets not received on physical interface."
> > + )
> > --
> > 2.51.0
> >
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-10-21 17:35 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-16 20:04 [PATCH v1 1/2] dts: add start Tx first method to testpmd shell Dean Marx
2025-09-16 20:04 ` [PATCH v1 2/2] dts: add virtio forwarding test suite Dean Marx
2025-09-23 11:38 ` Luca Vizzarro
2025-10-03 18:14 ` Dean Marx
2025-10-09 13:04 ` Patrick Robb
2025-09-23 11:27 ` [PATCH v1 1/2] dts: add start Tx first method to testpmd shell Luca Vizzarro
2025-10-03 19:27 ` [PATCH v2 " Dean Marx
2025-10-03 19:27 ` [PATCH v2 2/2] dts: add virtio forwarding test suite Dean Marx
2025-10-21 15:13 ` Luca Vizzarro
2025-10-21 17:35 ` Dean Marx
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).