* [PATCH 0/1] net/virtio: fix Rx interrupts with MSI-X
@ 2026-11-17 12:43 Isaac Boukris
2026-11-17 12:43 ` [PATCH 1/1] net/virtio: fix Rx interrupt setup " Isaac Boukris
` (2 more replies)
0 siblings, 3 replies; 18+ messages in thread
From: Isaac Boukris @ 2026-11-17 12:43 UTC (permalink / raw)
To: Maxime Coquelin, Chenbo Xia
Cc: dev, Anatoly Burakov, David Marchand, Isaac Boukris
Since 26.11-rc2, a virtio-net PCI device on vfio-pci cannot be
configured with Rx interrupts and an offload or RSS, nor configured a
second time: l3fwd-power fails to start on it. This patch fixes it; it
is for 26.11 and stable.
Tested in a VM (QEMU 10.2, vhost-net):
- l3fwd-power in interrupt-only mode on a virtio-net PCI port. Without
the patch it fails as in the commit message. With it, it starts and
each packet wakes its lcore up.
- A port stopped, configured again and started: Rx interrupts still
wake the lcore up (testpmd, with a patch that makes it sleep on
them).
- Rx interrupts on a virtio-user port with a vhost-net backend, which
the patch leaves alone: they work as before.
The legacy DTS has a test plan for this very case,
vhost_virtio_pmd_interrupt (l3fwd-power in a VM, on a virtio-net device
bound to vfio-pci); I did not run it. I will try to come up with a follow
up test for the DTS in the main tree, adding an option for testpmd to
sleep on Rx interrupts and a suite that uses it.
Patch generated with AI assistance.
Isaac Boukris (1):
net/virtio: fix Rx interrupt setup with MSI-X
drivers/net/virtio/virtio_ethdev.c | 7 +++++++
1 file changed, 7 insertions(+)
--
2.56.1
^ permalink raw reply [flat|nested] 18+ messages in thread* [PATCH 1/1] net/virtio: fix Rx interrupt setup with MSI-X 2026-11-17 12:43 [PATCH 0/1] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris @ 2026-11-17 12:43 ` Isaac Boukris 2026-11-17 14:29 ` David Marchand 2026-11-17 21:59 ` [PATCH v2 0/5] net/virtio: fix Rx interrupts " Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 0/7] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris 2 siblings, 1 reply; 18+ messages in thread From: Isaac Boukris @ 2026-11-17 12:43 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, Anatoly Burakov, David Marchand, Isaac Boukris, stable With Rx interrupts enabled, configuring a port initializes the device, and a second time when an offload or RSS is requested. Each initialization enables the interrupt eventfds. EAL now refuses to enable MSI-X eventfds twice, so such a configuration fails, and so does configuring a port a second time: EAL: Interrupt eventfds are already enabled virtio_configure_intr(): Fail to create eventfd ETHDEV: Port0 dev_configure = -16 Before that EAL change, the previous eventfds were leaked. Disable the interrupts and release the eventfds before enabling them again. Do it for a VFIO MSI-X handle only, the type whose eventfds EAL creates. The other type that gets here is virtio-user's: its eventfds are the backend's call fds, set once when the device is created. Releasing them would reset their count, which nothing sets again, and registering an Rx queue's interrupt would then fail. To reproduce, with a virtio-net PCI device bound to vfio-pci: dpdk-l3fwd-power -l 0 -a 0000:0c:00.0 -- -p 1 --interrupt-only \ --parse-ptype --config="(0,0,0)" Fixes: 3ba6b689893f ("eal/linux: fix eventfd leaks when enabling interrupts") Cc: stable@dpdk.org Signed-off-by: Isaac Boukris <iboukris@gmail.com> --- drivers/net/virtio/virtio_ethdev.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index f2302089ee..37fc896fae 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1455,6 +1455,13 @@ virtio_configure_intr(struct rte_eth_dev *dev) return -ENOTSUP; } + /* Reinitialization: release the previous eventfds first. */ + if (rte_intr_type_get(dev->intr_handle) == RTE_INTR_HANDLE_VFIO_MSIX && + rte_intr_dp_is_en(dev->intr_handle)) { + virtio_intr_disable(dev); + rte_intr_efd_disable(dev->intr_handle); + } + ret = rte_intr_efd_enable(dev->intr_handle, dev->data->nb_rx_queues); if (ret < 0) { PMD_INIT_LOG(ERR, "Fail to create eventfd"); -- 2.56.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] net/virtio: fix Rx interrupt setup with MSI-X 2026-11-17 12:43 ` [PATCH 1/1] net/virtio: fix Rx interrupt setup " Isaac Boukris @ 2026-11-17 14:29 ` David Marchand 2026-11-17 19:51 ` Isaac Boukris 0 siblings, 1 reply; 18+ messages in thread From: David Marchand @ 2026-11-17 14:29 UTC (permalink / raw) To: Isaac Boukris, Maxime Coquelin; +Cc: Chenbo Xia, dev, Anatoly Burakov, stable Hello, On Tue, 17 Nov 2026 at 13:43, Isaac Boukris <iboukris@gmail.com> wrote: > > With Rx interrupts enabled, configuring a port initializes the device, > and a second time when an offload or RSS is requested. Each > initialization enables the interrupt eventfds. > > EAL now refuses to enable MSI-X eventfds twice, so such a configuration > fails, and so does configuring a port a second time: > > EAL: Interrupt eventfds are already enabled > virtio_configure_intr(): Fail to create eventfd > ETHDEV: Port0 dev_configure = -16 > > Before that EAL change, the previous eventfds were leaked. > > Disable the interrupts and release the eventfds before enabling them > again. > > Do it for a VFIO MSI-X handle only, the type whose eventfds EAL > creates. The other type that gets here is virtio-user's: its eventfds > are the backend's call fds, set once when the device is created. > Releasing them would reset their count, which nothing sets again, and > registering an Rx queue's interrupt would then fail. > > To reproduce, with a virtio-net PCI device bound to vfio-pci: > > dpdk-l3fwd-power -l 0 -a 0000:0c:00.0 -- -p 1 --interrupt-only \ > --parse-ptype --config="(0,0,0)" > > Fixes: 3ba6b689893f ("eal/linux: fix eventfd leaks when enabling interrupts") > Cc: stable@dpdk.org > > Signed-off-by: Isaac Boukris <iboukris@gmail.com> Thank you for the testing and report. > --- > drivers/net/virtio/virtio_ethdev.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c > index f2302089ee..37fc896fae 100644 > --- a/drivers/net/virtio/virtio_ethdev.c > +++ b/drivers/net/virtio/virtio_ethdev.c > @@ -1455,6 +1455,13 @@ virtio_configure_intr(struct rte_eth_dev *dev) > return -ENOTSUP; > } > > + /* Reinitialization: release the previous eventfds first. */ > + if (rte_intr_type_get(dev->intr_handle) == RTE_INTR_HANDLE_VFIO_MSIX && > + rte_intr_dp_is_en(dev->intr_handle)) { The rte_intr_cap_multiple() guard right before should enough (for the interrupt type check). > + virtio_intr_disable(dev); > + rte_intr_efd_disable(dev->intr_handle); > + } > + Can the number of rxq change at this point? I don't think it is the case. If it can't, why do we need to release/set up new eventfds? The fix could be a simple: + if (rte_intr_dp_is_en(dev->intr_handle)) { > ret = rte_intr_efd_enable(dev->intr_handle, dev->data->nb_rx_queues); > if (ret < 0) { > PMD_INIT_LOG(ERR, "Fail to create eventfd"); + } We could probably move the rte_intr_vec_list_alloc call under this check too, but iiuc, this helper does nothing when called multiple times. -- David Marchand ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/1] net/virtio: fix Rx interrupt setup with MSI-X 2026-11-17 14:29 ` David Marchand @ 2026-11-17 19:51 ` Isaac Boukris 0 siblings, 0 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-17 19:51 UTC (permalink / raw) To: David Marchand; +Cc: Maxime Coquelin, Chenbo Xia, dev, Anatoly Burakov, stable Hi David, On Tue, Nov 17, 2026 at 4:29 PM David Marchand <david.marchand@redhat.com> wrote: > > Hello, > > On Tue, 17 Nov 2026 at 13:43, Isaac Boukris <iboukris@gmail.com> wrote: > > > > With Rx interrupts enabled, configuring a port initializes the device, > > and a second time when an offload or RSS is requested. Each > > initialization enables the interrupt eventfds. > > > > EAL now refuses to enable MSI-X eventfds twice, so such a configuration > > fails, and so does configuring a port a second time: > > > > EAL: Interrupt eventfds are already enabled > > virtio_configure_intr(): Fail to create eventfd > > ETHDEV: Port0 dev_configure = -16 > > > > Before that EAL change, the previous eventfds were leaked. > > > > Disable the interrupts and release the eventfds before enabling them > > again. > > > > Do it for a VFIO MSI-X handle only, the type whose eventfds EAL > > creates. The other type that gets here is virtio-user's: its eventfds > > are the backend's call fds, set once when the device is created. > > Releasing them would reset their count, which nothing sets again, and > > registering an Rx queue's interrupt would then fail. > > > > To reproduce, with a virtio-net PCI device bound to vfio-pci: > > > > dpdk-l3fwd-power -l 0 -a 0000:0c:00.0 -- -p 1 --interrupt-only \ > > --parse-ptype --config="(0,0,0)" > > > > Fixes: 3ba6b689893f ("eal/linux: fix eventfd leaks when enabling interrupts") > > Cc: stable@dpdk.org > > > > Signed-off-by: Isaac Boukris <iboukris@gmail.com> > > Thank you for the testing and report. > > > > --- > > drivers/net/virtio/virtio_ethdev.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c > > index f2302089ee..37fc896fae 100644 > > --- a/drivers/net/virtio/virtio_ethdev.c > > +++ b/drivers/net/virtio/virtio_ethdev.c > > @@ -1455,6 +1455,13 @@ virtio_configure_intr(struct rte_eth_dev *dev) > > return -ENOTSUP; > > } > > > > + /* Reinitialization: release the previous eventfds first. */ > > + if (rte_intr_type_get(dev->intr_handle) == RTE_INTR_HANDLE_VFIO_MSIX && > > + rte_intr_dp_is_en(dev->intr_handle)) { > > The rte_intr_cap_multiple() guard right before should enough (for the > interrupt type check). Actually this check was added due to a real issue with virtio-user which also returns true for this guard. > > + virtio_intr_disable(dev); > > + rte_intr_efd_disable(dev->intr_handle); > > + } > > + > > Can the number of rxq change at this point? > I don't think it is the case. > > If it can't, why do we need to release/set up new eventfds? > > The fix could be a simple: > > + if (rte_intr_dp_is_en(dev->intr_handle)) { > > > ret = rte_intr_efd_enable(dev->intr_handle, dev->data->nb_rx_queues); > > if (ret < 0) { > > PMD_INIT_LOG(ERR, "Fail to create eventfd"); > > + } I think it could change if reconfigure is called multiple times, i'll try to test it but we could still limit iit to that case, which would make it even easier on the caller as it doesn't have to get the new efds if he didn't change rxq number (although for non-virtio drivers one probably still have to). > We could probably move the rte_intr_vec_list_alloc call under this > check too, but iiuc, this helper does nothing when called multiple > times. > > > -- > David Marchand > ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 0/5] net/virtio: fix Rx interrupts with MSI-X 2026-11-17 12:43 [PATCH 0/1] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris 2026-11-17 12:43 ` [PATCH 1/1] net/virtio: fix Rx interrupt setup " Isaac Boukris @ 2026-11-17 21:59 ` Isaac Boukris 2026-11-17 21:59 ` [PATCH v2 1/5] net/virtio: fix Rx interrupt setup " Isaac Boukris ` (4 more replies) 2026-11-18 0:19 ` [PATCH v3 0/7] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris 2 siblings, 5 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-17 21:59 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, David Marchand, Aman Singh, Luca Vizzarro, Patrick Robb, Isaac Boukris Since 26.11-rc2, a virtio-net PCI device on vfio-pci cannot be configured with Rx interrupts and an offload or RSS, and it cannot be configured a second time. For example, l3fwd-power fails to start on it. Patch 1 is the fix, for 26.11 and stable. The other patches are its tests and can wait for 27.03. - Patch 2 is a unit test of Rx interrupts on a virtio-user port. Without the check of the interrupt handle type in the fix, this test fails ("EAL: Wrong intr vector number"). This is why the fix has that check. - Patch 3 adds a testpmd option, --rxq-interrupt. With it, idle forwarding lcores sleep on the Rx queue interrupts, as l3fwd-power does. It will need a line in the 27.03 release notes. - Patches 4 and 5 add a DTS suite that uses this option. It has two test cases. In the first, each packet sent to the port must wake the lcore up, also after the port is configured a second time with the same number of queues. The second does the same after the number of queues changed, to two queues and back to one. With two queues, both must receive packets. It is skipped if the port cannot have two queues, or if the packets do not reach both. Tested in a VM (QEMU 10.2, vhost-net): - l3fwd-power in interrupt-only mode on a virtio-net PCI port. Without patch 1 it fails as in the commit message. With it, each packet wakes its lcore up. - The DTS suite on a virtio-net PCI port. Without patch 1 both test cases fail at the second configuration. With it, they pass. They also pass on an emulated Intel 82576 port (igb driver). On a virtio-net port with one queue pair, the second test case is skipped. - The unit test passes with and without patch 1. The unit test logs "Some interrupt handle is leaking an event FD" when it closes its port. This series does not cause it. main logs it for any virtio-user port, with testpmd too, since commit 67813957d8 ("interrupts: warn on leaked event FDs"), because virtio-user frees its interrupt handle before it closes its call fds. v2: - Patch 1 keeps the eventfds when the number of Rx queues did not change (David Marchand). It releases them only when the number changed, and only then must an application register the Rx queue interrupts again. - Patches 2 to 5 are new. Patches generated with AI assistance. Isaac Boukris (5): net/virtio: fix Rx interrupt setup with MSI-X test/virtio_user: add unit test of Rx interrupts app/testpmd: add Rx queue interrupts option dts: support virtio PCI ports dts: add Rx interrupt test suite MAINTAINERS | 1 + app/test-pmd/parameters.c | 8 + app/test-pmd/testpmd.c | 86 +++++- app/test-pmd/testpmd.h | 2 + app/test/meson.build | 1 + app/test/test_pmd_virtio_user.c | 296 +++++++++++++++++++ doc/api/dts/tests.TestSuite_rx_interrupt.rst | 8 + doc/guides/testpmd_app_ug/run_app.rst | 7 + drivers/net/virtio/virtio_ethdev.c | 18 +- dts/api/params/types.py | 1 + dts/api/testpmd/config.py | 2 + dts/framework/testbed_model/linux_session.py | 9 +- dts/tests/TestSuite_rx_interrupt.py | 122 ++++++++ 13 files changed, 554 insertions(+), 7 deletions(-) create mode 100644 app/test/test_pmd_virtio_user.c create mode 100644 doc/api/dts/tests.TestSuite_rx_interrupt.rst create mode 100644 dts/tests/TestSuite_rx_interrupt.py -- 2.56.1 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v2 1/5] net/virtio: fix Rx interrupt setup with MSI-X 2026-11-17 21:59 ` [PATCH v2 0/5] net/virtio: fix Rx interrupts " Isaac Boukris @ 2026-11-17 21:59 ` Isaac Boukris 2026-11-17 21:59 ` [PATCH v2 2/5] test/virtio_user: add unit test of Rx interrupts Isaac Boukris ` (3 subsequent siblings) 4 siblings, 0 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-17 21:59 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, David Marchand, Aman Singh, Luca Vizzarro, Patrick Robb, Isaac Boukris, stable With Rx interrupts enabled, configuring a port initializes the device, and a second time when an offload or RSS is requested. Each initialization enables the interrupt eventfds. EAL now refuses to enable MSI-X eventfds twice, so such a configuration fails, and so does configuring a port a second time: EAL: Interrupt eventfds are already enabled virtio_configure_intr(): Fail to create eventfd ETHDEV: Port0 dev_configure = -16 Before that EAL change, the previous eventfds were leaked. Enable the eventfds only when they are not enabled yet. There is one eventfd per Rx queue. So if the number of Rx queues changed, release the eventfds first, and new ones are created. The application must then register the Rx queue interrupts again. Release them for a VFIO MSI-X handle only, the type whose eventfds EAL creates. The other type that gets here is the virtio-user one. Its eventfds are the backend's call fds, one per queue pair, set once when the device is created. Releasing them would reset their count, which nothing sets again, and registering an Rx queue's interrupt would then fail. To reproduce, with a virtio-net PCI device bound to vfio-pci: dpdk-l3fwd-power -l 0 -a 0000:0c:00.0 -- -p 1 --interrupt-only \ --parse-ptype --config="(0,0,0)" Fixes: 3ba6b689893f ("eal/linux: fix eventfd leaks when enabling interrupts") Cc: stable@dpdk.org Signed-off-by: Isaac Boukris <iboukris@gmail.com> --- v2: keep the eventfds unless the number of Rx queues changed (David Marchand). drivers/net/virtio/virtio_ethdev.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index f2302089ee..8600f3899a 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1455,10 +1455,20 @@ virtio_configure_intr(struct rte_eth_dev *dev) return -ENOTSUP; } - ret = rte_intr_efd_enable(dev->intr_handle, dev->data->nb_rx_queues); - if (ret < 0) { - PMD_INIT_LOG(ERR, "Fail to create eventfd"); - return ret; + /* On reinitialization, release the eventfds if the number of Rx queues changed. */ + if (rte_intr_type_get(dev->intr_handle) == RTE_INTR_HANDLE_VFIO_MSIX && + rte_intr_dp_is_en(dev->intr_handle) && + rte_intr_nb_efd_get(dev->intr_handle) != dev->data->nb_rx_queues) { + virtio_intr_disable(dev); + rte_intr_efd_disable(dev->intr_handle); + } + + if (!rte_intr_dp_is_en(dev->intr_handle)) { + ret = rte_intr_efd_enable(dev->intr_handle, dev->data->nb_rx_queues); + if (ret < 0) { + PMD_INIT_LOG(ERR, "Fail to create eventfd"); + return ret; + } } ret = rte_intr_vec_list_alloc(dev->intr_handle, "intr_vec", -- 2.56.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 2/5] test/virtio_user: add unit test of Rx interrupts 2026-11-17 21:59 ` [PATCH v2 0/5] net/virtio: fix Rx interrupts " Isaac Boukris 2026-11-17 21:59 ` [PATCH v2 1/5] net/virtio: fix Rx interrupt setup " Isaac Boukris @ 2026-11-17 21:59 ` Isaac Boukris 2026-11-17 21:59 ` [PATCH v2 3/5] app/testpmd: add Rx queue interrupts option Isaac Boukris ` (2 subsequent siblings) 4 siblings, 0 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-17 21:59 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, David Marchand, Aman Singh, Luca Vizzarro, Patrick Robb, Isaac Boukris Add a test suite for the virtio PMD on a virtio-user port backed by vhost-net and a TAP interface, modeled on the test suite of the TAP PMD. It needs no VM and no PCI device. It is skipped where the port cannot be created (no root, no /dev/vhost-net). The first case configures the port with Rx interrupts and an Rx offload. It enables the interrupt of the Rx queue, sends a frame from the kernel and sleeps on the interrupt. The frame must end the sleep. Then it does the same after a second configure. The port has two queue pairs and the test configures one Rx queue, so the port has more interrupt eventfds than Rx queues. These eventfds are the backend's call fds, and the driver must not release them. If it does when it initializes the device again, the test fails. DPDK_TEST=virtio_user_pmd_autotest ./build/app/dpdk-test --no-huge Signed-off-by: Isaac Boukris <iboukris@gmail.com> --- MAINTAINERS | 1 + app/test/meson.build | 1 + app/test/test_pmd_virtio_user.c | 296 ++++++++++++++++++++++++++++++++ 3 files changed, 298 insertions(+) create mode 100644 app/test/test_pmd_virtio_user.c diff --git a/MAINTAINERS b/MAINTAINERS index 8fcb4ef5fa..36dd253f36 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1106,6 +1106,7 @@ T: git://dpdk.org/next/dpdk-next-virtio F: drivers/net/virtio/ F: doc/guides/nics/virtio.rst F: doc/guides/nics/features/virtio*.ini +F: app/test/test_pmd_virtio_user.c Wind River AVP M: Steven Webster <steven.webster@windriver.com> diff --git a/app/test/meson.build b/app/test/meson.build index 2f1cd817cd..e480353885 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -155,6 +155,7 @@ source_file_deps = { 'test_pmd_ring.c': ['net_ring', 'ethdev', 'bus_vdev'], 'test_pmd_ring_perf.c': ['ethdev', 'net_ring', 'bus_vdev'], 'test_pmd_tap.c': ['ethdev', 'net_tap', 'bus_vdev'], + 'test_pmd_virtio_user.c': ['ethdev', 'net_virtio', 'bus_vdev'], 'test_pmu.c': ['pmu'], 'test_power.c': ['power', 'power_acpi', 'power_kvm_vm', 'power_intel_pstate', 'power_amd_pstate', 'power_cppc'], diff --git a/app/test/test_pmd_virtio_user.c b/app/test/test_pmd_virtio_user.c new file mode 100644 index 0000000000..d62ce000fb --- /dev/null +++ b/app/test/test_pmd_virtio_user.c @@ -0,0 +1,296 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2026 Isaac Boukris + */ + +/* + * Tests of the virtio PMD on a virtio-user port backed by vhost-net and a TAP + * interface. They need no VM and no PCI device. The kernel's end is a packet + * socket on the TAP interface. + */ + +#include "test.h" + +#include <stdio.h> + +#ifndef RTE_EXEC_ENV_LINUX + +static int +test_pmd_virtio_user(void) +{ + printf("virtio-user with vhost-net is only available on Linux, skipping test\n"); + return TEST_SKIPPED; +} + +#else /* RTE_EXEC_ENV_LINUX */ + +#include <errno.h> +#include <string.h> +#include <unistd.h> +#include <net/if.h> +#include <sys/ioctl.h> +#include <sys/socket.h> +#include <linux/if_packet.h> +#include <linux/virtio_net.h> + +#include <rte_bus_vdev.h> +#include <rte_cycles.h> +#include <rte_epoll.h> +#include <rte_ethdev.h> +#include <rte_ether.h> +#include <rte_mbuf.h> + +#define VDEV_NAME "net_virtio_user_test" +#define TAP_NAME "dtap_vu_test" +#define RING_SIZE 256 +#define NB_MBUF 1024 +#define BURST 32 +#define WAIT_MS 1000 +/* The test frames' EtherType (IEEE 802 local experimental) */ +#define TEST_ETHER_TYPE 0x88b5 + +static struct rte_mempool *mp; +static uint16_t port_id = RTE_MAX_ETHPORTS; +static int ksock = -1; /* the kernel's end, each frame follows a virtio_net_hdr */ +static bool started; + +static int +port_stop(void) +{ + int ret; + + if (!started) + return TEST_SUCCESS; + started = false; + ret = rte_eth_dev_stop(port_id); + TEST_ASSERT_SUCCESS(ret, "stop failed: %s", rte_strerror(-ret)); + + return TEST_SUCCESS; +} + +/* Configure the port and start it. A failed case may have left it started. */ +static int +port_start(const struct rte_eth_conf *conf) +{ + int ret; + + TEST_ASSERT_SUCCESS(port_stop(), "port stop failed"); + ret = rte_eth_dev_configure(port_id, 1, 1, conf); + TEST_ASSERT_SUCCESS(ret, "configure failed: %s", rte_strerror(-ret)); + ret = rte_eth_rx_queue_setup(port_id, 0, RING_SIZE, SOCKET_ID_ANY, NULL, mp); + TEST_ASSERT_SUCCESS(ret, "Rx queue setup failed: %s", rte_strerror(-ret)); + ret = rte_eth_tx_queue_setup(port_id, 0, RING_SIZE, SOCKET_ID_ANY, NULL); + TEST_ASSERT_SUCCESS(ret, "Tx queue setup failed: %s", rte_strerror(-ret)); + ret = rte_eth_dev_start(port_id); + TEST_ASSERT_SUCCESS(ret, "start failed: %s", rte_strerror(-ret)); + started = true; + + return TEST_SUCCESS; +} + +/* A frame from the kernel's end to the port, recognized by its EtherType. */ +static int +kernel_send(void) +{ + struct { + struct virtio_net_hdr vnet; /* no offload */ + struct rte_ether_hdr eth; + uint8_t payload[RTE_ETHER_MIN_LEN]; + } frame; + ssize_t n; + + memset(&frame, 0, sizeof(frame)); + memset(&frame.eth.dst_addr, 0xff, RTE_ETHER_ADDR_LEN); + frame.eth.src_addr.addr_bytes[0] = RTE_ETHER_LOCAL_ADMIN_ADDR; + frame.eth.ether_type = rte_cpu_to_be_16(TEST_ETHER_TYPE); + n = send(ksock, &frame, sizeof(frame), 0); + TEST_ASSERT(n == (ssize_t)sizeof(frame), "send on %s failed: %s", TAP_NAME, + strerror(errno)); + + return TEST_SUCCESS; +} + +/* Receive what the queue holds. Return true if it holds the frame of kernel_send(). */ +static bool +port_receive(void) +{ + struct rte_mbuf *pkts[BURST]; + bool found = false; + uint16_t i, n; + + while ((n = rte_eth_rx_burst(port_id, 0, pkts, BURST)) != 0) { + for (i = 0; i < n; i++) { + const struct rte_ether_hdr *eth = + rte_pktmbuf_mtod(pkts[i], const struct rte_ether_hdr *); + + if (eth->ether_type == rte_cpu_to_be_16(TEST_ETHER_TYPE)) + found = true; + } + rte_pktmbuf_free_bulk(pkts, n); + } + + return found; +} + +/* Sleep on the Rx queue's interrupt. A frame from the kernel must end the sleep. */ +static int +rx_intr_wakes(void) +{ + uint64_t deadline = rte_get_timer_cycles() + rte_get_timer_hz() * WAIT_MS / 1000; + struct rte_epoll_event event; + bool found; + int ret; + + ret = rte_eth_dev_rx_intr_ctl_q(port_id, 0, RTE_EPOLL_PER_THREAD, RTE_INTR_EVENT_ADD, + NULL); + TEST_ASSERT_SUCCESS(ret, "no interrupt for the Rx queue: %s", rte_strerror(-ret)); + + do { + /* + * Enable the interrupt before the kernel sends. A frame that + * arrives from now on raises it, also before the sleep below. + */ + ret = rte_eth_dev_rx_intr_enable(port_id, 0); + TEST_ASSERT_SUCCESS(ret, "Rx interrupt enable failed: %s", rte_strerror(-ret)); + /* Drop the frames that the kernel sent earlier, and their event. */ + port_receive(); + rte_epoll_wait(RTE_EPOLL_PER_THREAD, &event, 1, 0); + + TEST_ASSERT_SUCCESS(kernel_send(), "kernel send failed"); + ret = rte_epoll_wait(RTE_EPOLL_PER_THREAD, &event, 1, WAIT_MS); + TEST_ASSERT(ret == 1, "no Rx interrupt within %d ms", WAIT_MS); + ret = rte_eth_dev_rx_intr_disable(port_id, 0); + TEST_ASSERT_SUCCESS(ret, "Rx interrupt disable failed: %s", rte_strerror(-ret)); + /* If another frame of the kernel raised the interrupt, send again. */ + found = port_receive(); + } while (!found && rte_get_timer_cycles() < deadline); + TEST_ASSERT(found, "frame from the kernel not received"); + + ret = rte_eth_dev_rx_intr_ctl_q(port_id, 0, RTE_EPOLL_PER_THREAD, RTE_INTR_EVENT_DEL, + NULL); + TEST_ASSERT_SUCCESS(ret, "Rx interrupt removal failed: %s", rte_strerror(-ret)); + + return TEST_SUCCESS; +} + +/* + * Rx interrupts with an offload, which makes configure initialize the device + * twice. Then a second configure. The interrupt eventfds belong to the + * backend, so the driver must not release them when it initializes the + * device again. + */ +static int +test_virtio_user_rx_intr(void) +{ + struct rte_eth_conf conf = { + .intr_conf.rxq = 1, + .rxmode.offloads = RTE_ETH_RX_OFFLOAD_UDP_CKSUM | RTE_ETH_RX_OFFLOAD_TCP_CKSUM, + }; + struct rte_eth_dev_info info; + int round, ret; + + ret = rte_eth_dev_info_get(port_id, &info); + TEST_ASSERT_SUCCESS(ret, "dev_info failed: %s", rte_strerror(-ret)); + conf.rxmode.offloads &= info.rx_offload_capa; + TEST_ASSERT(conf.rxmode.offloads != 0, "no Rx checksum offload to request"); + + for (round = 0; round < 2; round++) { + TEST_ASSERT_SUCCESS(port_start(&conf), "round %d: port start failed", round); + TEST_ASSERT_SUCCESS(rx_intr_wakes(), "round %d: Rx interrupt failed", round); + TEST_ASSERT_SUCCESS(port_stop(), "round %d: port stop failed", round); + } + + return TEST_SUCCESS; +} + +static void +test_virtio_user_cleanup(void) +{ + if (ksock >= 0) + close(ksock); + ksock = -1; + if (port_id != RTE_MAX_ETHPORTS) { + port_stop(); + rte_eth_dev_close(port_id); + rte_vdev_uninit(VDEV_NAME); + } + port_id = RTE_MAX_ETHPORTS; + rte_mempool_free(mp); + mp = NULL; +} + +/* Open the kernel's end. Set the TAP interface up and bind a packet socket to it. */ +static int +kernel_open(void) +{ + struct sockaddr_ll addr = { + .sll_family = AF_PACKET, + .sll_protocol = htons(ETH_P_ALL), + }; + struct ifreq ifr; + int one = 1; + + ksock = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); + if (ksock < 0) + return -1; + memset(&ifr, 0, sizeof(ifr)); + strlcpy(ifr.ifr_name, TAP_NAME, sizeof(ifr.ifr_name)); + if (ioctl(ksock, SIOCGIFFLAGS, &ifr) < 0) + return -1; + ifr.ifr_flags |= IFF_UP; + if (ioctl(ksock, SIOCSIFFLAGS, &ifr) < 0) + return -1; + addr.sll_ifindex = if_nametoindex(TAP_NAME); + if (addr.sll_ifindex == 0 || + bind(ksock, (const struct sockaddr *)&addr, sizeof(addr)) < 0 || + setsockopt(ksock, SOL_PACKET, PACKET_VNET_HDR, &one, sizeof(one)) < 0) + return -1; + + return 0; +} + +static int +test_virtio_user_setup(void) +{ + mp = rte_pktmbuf_pool_create("virtio_user_test", NB_MBUF, 32, 0, + RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id()); + TEST_ASSERT_NOT_NULL(mp, "mempool creation failed: %s", rte_strerror(rte_errno)); + + /* + * The port has two queue pairs and the tests configure one Rx queue, + * so the port has more interrupt eventfds than Rx queues. + * vhost-net creates the TAP interface, which takes root or CAP_NET_ADMIN. + */ + if (rte_vdev_init(VDEV_NAME, "path=/dev/vhost-net,iface=" TAP_NAME ",queues=2") < 0 || + rte_eth_dev_get_port_by_name(VDEV_NAME, &port_id) != 0) { + printf("No virtio-user port on /dev/vhost-net, skipping test\n"); + test_virtio_user_cleanup(); + return TEST_SKIPPED; + } + if (kernel_open() < 0) { + printf("No packet socket on %s (%s), skipping test\n", TAP_NAME, strerror(errno)); + test_virtio_user_cleanup(); + return TEST_SKIPPED; + } + + return TEST_SUCCESS; +} + +static struct unit_test_suite test_pmd_virtio_user_suite = { + .setup = test_virtio_user_setup, + .teardown = test_virtio_user_cleanup, + .suite_name = "virtio-user PMD Unit Test Suite", + .unit_test_cases = { + TEST_CASE(test_virtio_user_rx_intr), + TEST_CASES_END() + } +}; + +static int +test_pmd_virtio_user(void) +{ + return unit_test_suite_runner(&test_pmd_virtio_user_suite); +} + +#endif /* RTE_EXEC_ENV_LINUX */ + +REGISTER_FAST_TEST(virtio_user_pmd_autotest, NOHUGE_OK, ASAN_OK, test_pmd_virtio_user); -- 2.56.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 3/5] app/testpmd: add Rx queue interrupts option 2026-11-17 21:59 ` [PATCH v2 0/5] net/virtio: fix Rx interrupts " Isaac Boukris 2026-11-17 21:59 ` [PATCH v2 1/5] net/virtio: fix Rx interrupt setup " Isaac Boukris 2026-11-17 21:59 ` [PATCH v2 2/5] test/virtio_user: add unit test of Rx interrupts Isaac Boukris @ 2026-11-17 21:59 ` Isaac Boukris 2026-11-17 22:00 ` [PATCH v2 4/5] dts: support virtio PCI ports Isaac Boukris 2026-11-17 22:00 ` [PATCH v2 5/5] dts: add Rx interrupt test suite Isaac Boukris 4 siblings, 0 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-17 21:59 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, David Marchand, Aman Singh, Luca Vizzarro, Patrick Robb, Isaac Boukris testpmd cannot test the Rx queue interrupts of a driver, because it never asks for them. With --rxq-interrupt, the ports are configured with Rx queue interrupts, and a forwarding lcore whose Rx queues are all empty sleeps until a packet arrives on one of them, 10 ms at most, as l3fwd-power does. The forward statistics show the number of sleeps that an interrupt ended. Signed-off-by: Isaac Boukris <iboukris@gmail.com> --- app/test-pmd/parameters.c | 8 +++ app/test-pmd/testpmd.c | 86 ++++++++++++++++++++++++++- app/test-pmd/testpmd.h | 2 + doc/guides/testpmd_app_ug/run_app.rst | 7 +++ 4 files changed, 101 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 34a4f74e63..f958104f47 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -207,6 +207,8 @@ enum { TESTPMD_OPT_NO_LSC_INTERRUPT_NUM, #define TESTPMD_OPT_NO_RMV_INTERRUPT "no-rmv-interrupt" TESTPMD_OPT_NO_RMV_INTERRUPT_NUM, +#define TESTPMD_OPT_RXQ_INTERRUPT "rxq-interrupt" + TESTPMD_OPT_RXQ_INTERRUPT_NUM, #define TESTPMD_OPT_PRINT_EVENT "print-event" TESTPMD_OPT_PRINT_EVENT_NUM, #define TESTPMD_OPT_MASK_EVENT "mask-event" @@ -357,6 +359,7 @@ static const struct option long_options[] = { NO_ARG(TESTPMD_OPT_DISABLE_DEVICE_START), NO_ARG(TESTPMD_OPT_NO_LSC_INTERRUPT), NO_ARG(TESTPMD_OPT_NO_RMV_INTERRUPT), + NO_ARG(TESTPMD_OPT_RXQ_INTERRUPT), REQUIRED_ARG(TESTPMD_OPT_PRINT_EVENT), REQUIRED_ARG(TESTPMD_OPT_MASK_EVENT), REQUIRED_ARG(TESTPMD_OPT_TX_OFFLOADS), @@ -515,6 +518,8 @@ usage(char* progname) printf(" --disable-device-start: do not automatically start port\n"); printf(" --no-lsc-interrupt: disable link status change interrupt.\n"); printf(" --no-rmv-interrupt: disable device removal interrupt.\n"); + printf(" --rxq-interrupt: enable Rx queue interrupts, " + "idle forwarding lcores sleep.\n"); #ifdef RTE_LIB_BITRATESTATS printf(" --bitrate-stats=N: set the logical core N to perform " "bit-rate calculation.\n"); @@ -1638,6 +1643,9 @@ launch_args_parse(int argc, char** argv) case TESTPMD_OPT_NO_RMV_INTERRUPT_NUM: rmv_interrupt = 0; break; + case TESTPMD_OPT_RXQ_INTERRUPT_NUM: + rxq_interrupt = 1; + break; case TESTPMD_OPT_FLOW_ISOLATE_ALL_NUM: flow_isolate_all = 1; break; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index d6211a9a8a..0de7cdbeb6 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -43,6 +43,8 @@ #include <rte_mbuf.h> #include <rte_mbuf_pool_ops.h> #include <rte_interrupts.h> +#include <rte_epoll.h> +#include <rte_spinlock.h> #include <rte_ether.h> #include <rte_ethdev.h> #include <rte_dev.h> @@ -446,6 +448,11 @@ uint8_t lsc_interrupt = 1; /* enabled by default */ */ uint8_t rmv_interrupt = 1; /* enabled by default */ +/* + * Enable Rx queue interrupts. A forwarding lcore then sleeps when it is idle. + */ +uint8_t rxq_interrupt; + uint8_t hot_plug = 0; /**< hotplug disabled by default. */ /* After attach, port setup is called on event or by iterator */ @@ -2213,6 +2220,14 @@ fwd_stats_display(void) total_xmit, total_tx_dropped, total_xmit + total_tx_dropped); if (total_rx_nombuf > 0) printf(" RX-nombufs: %-14"PRIu64"\n", total_rx_nombuf); + if (rxq_interrupt) { + uint64_t rx_wakeups = 0; + lcoreid_t lc_id; + + for (lc_id = 0; lc_id < cur_fwd_config.nb_fwd_lcores; lc_id++) + rx_wakeups += fwd_lcores[lc_id]->rx_wakeups; + printf(" RX-wakeups: %-14"PRIu64"\n", rx_wakeups); + } printf(" %s++++++++++++++++++++++++++++++++++++++++++++++" "%s\n", acc_stats_border, acc_stats_border); @@ -2240,6 +2255,7 @@ void fwd_stats_reset(void) { streamid_t sm_id; + lcoreid_t lc_id; portid_t pt_id; int ret; int i; @@ -2267,6 +2283,8 @@ fwd_stats_reset(void) memset(&fs->tx_burst_stats, 0, sizeof(fs->tx_burst_stats)); fs->busy_cycles = 0; } + for (lc_id = 0; lc_id < cur_fwd_config.nb_fwd_lcores; lc_id++) + fwd_lcores[lc_id]->rx_wakeups = 0; } static void @@ -2323,6 +2341,42 @@ flush_fwd_rx_queues(void) } } +/* + * Rx queue interrupts work as in the l3fwd-power example. An lcore whose Rx + * queues are all empty enables their interrupts, sleeps until one of them + * is raised, 10 ms at most, and disables them. + */ +static rte_spinlock_t rxq_interrupt_locks[RTE_MAX_ETHPORTS]; + +static void +rxq_interrupt_turn(struct fwd_lcore *fc, bool on) +{ + struct fwd_stream **fsm = &fwd_streams[fc->stream_idx]; + streamid_t sm_id; + + for (sm_id = 0; sm_id < fc->stream_nb; sm_id++) { + struct fwd_stream *fs = fsm[sm_id]; + + rte_spinlock_lock(&rxq_interrupt_locks[fs->rx_port]); + if (on) + rte_eth_dev_rx_intr_enable(fs->rx_port, fs->rx_queue); + else + rte_eth_dev_rx_intr_disable(fs->rx_port, fs->rx_queue); + rte_spinlock_unlock(&rxq_interrupt_locks[fs->rx_port]); + } +} + +static void +rxq_interrupt_sleep(struct fwd_lcore *fc) +{ + struct rte_epoll_event event; + + rxq_interrupt_turn(fc, true); + if (rte_epoll_wait(RTE_EPOLL_PER_THREAD, &event, 1, 10) > 0) + fc->rx_wakeups++; + rxq_interrupt_turn(fc, false); +} + static void run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) { @@ -2330,6 +2384,7 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) uint64_t prev_tsc; streamid_t nb_fs; streamid_t sm_id; + bool idle; #ifdef RTE_LIB_BITRATESTATS uint64_t tics_per_1sec; uint64_t tics_datum; @@ -2344,6 +2399,7 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) nb_fs = fc->stream_nb; prev_tsc = rte_rdtsc(); do { + idle = true; for (sm_id = 0; sm_id < nb_fs; sm_id++) { struct fwd_stream *fs = fsm[sm_id]; uint64_t start_fs_tsc = 0; @@ -2354,9 +2410,13 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) if (record_core_cycles) start_fs_tsc = rte_rdtsc(); busy = (*pkt_fwd)(fs); + if (busy) + idle = false; if (record_core_cycles && busy) fs->busy_cycles += rte_rdtsc() - start_fs_tsc; } + if (rxq_interrupt && idle && !fc->stopped) + rxq_interrupt_sleep(fc); #ifdef RTE_LIB_BITRATESTATS if (bitrate_enabled != 0 && bitrate_lcore_id == rte_lcore_id()) { @@ -2409,11 +2469,31 @@ lcore_usage_callback(unsigned int lcore_id, struct rte_lcore_usage *usage) return 0; } +/* + * Add the Rx interrupts of the queues of an lcore to the epoll instance of + * its thread, or delete them from it. + */ +static void +rxq_interrupt_register(struct fwd_lcore *fc, int op) +{ + struct fwd_stream **fsm = &fwd_streams[fc->stream_idx]; + streamid_t sm_id; + + for (sm_id = 0; sm_id < fc->stream_nb; sm_id++) + rte_eth_dev_rx_intr_ctl_q(fsm[sm_id]->rx_port, fsm[sm_id]->rx_queue, + RTE_EPOLL_PER_THREAD, op, NULL); +} + static int start_pkt_forward_on_core(void *fwd_arg) { - run_pkt_fwd_on_lcore((struct fwd_lcore *) fwd_arg, - cur_fwd_config.fwd_eng->packet_fwd); + struct fwd_lcore *fc = fwd_arg; + + if (rxq_interrupt) + rxq_interrupt_register(fc, RTE_INTR_EVENT_ADD); + run_pkt_fwd_on_lcore(fc, cur_fwd_config.fwd_eng->packet_fwd); + if (rxq_interrupt) + rxq_interrupt_register(fc, RTE_INTR_EVENT_DEL); return 0; } @@ -4203,6 +4283,8 @@ init_port_config(void) port->dev_conf.intr_conf.lsc = 1; if (rmv_interrupt && (*port->dev_info.dev_flags & RTE_ETH_DEV_INTR_RMV)) port->dev_conf.intr_conf.rmv = 1; + if (rxq_interrupt) + port->dev_conf.intr_conf.rxq = 1; } } diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 2ca4aaf086..6d3f258263 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -405,6 +405,7 @@ struct fwd_lcore { lcoreid_t cpuid_idx; /**< index of logical core in CPU id table */ volatile char stopped; /**< stop forwarding when set */ uint64_t total_cycles; /**< used with --record-core-cycles */ + uint64_t rx_wakeups; /**< used with --rxq-interrupt */ }; /* @@ -541,6 +542,7 @@ extern uint8_t no_device_start; /**<set by "--disable-device-start" parameter */ extern volatile int test_done; /* stop packet forwarding when set to 1. */ extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */ extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */ +extern uint8_t rxq_interrupt; /**< enabled by "--rxq-interrupt" parameter */ extern uint32_t event_print_mask; /**< set by "--print-event xxxx" and "--mask-event xxxx parameters */ extern bool setup_on_probe_event; /**< disabled by port setup-on iterator */ diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index e34e414ce2..7956672e9d 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -462,6 +462,13 @@ The command line options are: Disable RMV interrupts for all ports, even those supporting it. +* ``--rxq-interrupt`` + + Enable Rx queue interrupts for all ports. + A forwarding lcore whose Rx queues are all empty sleeps + until a packet arrives on one of them, 10 ms at most. + The forward statistics show the number of sleeps that an interrupt ended (``RX-wakeups``). + * ``--bitrate-stats=N`` Set the logical core N to perform bitrate calculation. -- 2.56.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 4/5] dts: support virtio PCI ports 2026-11-17 21:59 ` [PATCH v2 0/5] net/virtio: fix Rx interrupts " Isaac Boukris ` (2 preceding siblings ...) 2026-11-17 21:59 ` [PATCH v2 3/5] app/testpmd: add Rx queue interrupts option Isaac Boukris @ 2026-11-17 22:00 ` Isaac Boukris 2026-11-17 22:00 ` [PATCH v2 5/5] dts: add Rx interrupt test suite Isaac Boukris 4 siblings, 0 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-17 22:00 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, David Marchand, Aman Singh, Luca Vizzarro, Patrick Robb, Isaac Boukris DTS reads the logical name and the MAC address of a port from the lshw entry of its PCI device. A virtio device has none there, because lshw lists its network interface as a device of its own, on the virtio bus, right after the PCI device. The test run setup then fails: Could not gather a valid MAC address and/or logical name for port port-0 in node SUT 1. Copy to the entry of the PCI device what it lacks from the entry of its interface. Signed-off-by: Isaac Boukris <iboukris@gmail.com> --- dts/framework/testbed_model/linux_session.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dts/framework/testbed_model/linux_session.py b/dts/framework/testbed_model/linux_session.py index 786e8c4eb4..40cc87adaf 100644 --- a/dts/framework/testbed_model/linux_session.py +++ b/dts/framework/testbed_model/linux_session.py @@ -438,7 +438,14 @@ def get_pci_addr_of_vfs(self, pf_port: Port) -> list[str]: @cached_property def _lshw_net_info(self) -> list[LshwOutput]: output = self.send_command("lshw -quiet -json -C network", verify=True) - return json.loads(output.stdout) + ports = json.loads(output.stdout) + # The network interface of a virtio device is an entry of its own, on the virtio bus, + # right after the entry of the PCI device. Copy from it what the PCI entry lacks. + for device, interface in zip(ports, ports[1:]): + if "logicalname" not in device and interface.get("businfo", "").startswith("virtio@"): + configuration = interface.get("configuration", {}) | device.get("configuration", {}) + device.update(interface | device | {"configuration": configuration}) + return ports def refresh_lshw(self) -> None: """Force refresh of cached lshw network info.""" -- 2.56.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v2 5/5] dts: add Rx interrupt test suite 2026-11-17 21:59 ` [PATCH v2 0/5] net/virtio: fix Rx interrupts " Isaac Boukris ` (3 preceding siblings ...) 2026-11-17 22:00 ` [PATCH v2 4/5] dts: support virtio PCI ports Isaac Boukris @ 2026-11-17 22:00 ` Isaac Boukris 4 siblings, 0 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-17 22:00 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, David Marchand, Aman Singh, Luca Vizzarro, Patrick Robb, Isaac Boukris Test that packets received on a port wake up a testpmd lcore that sleeps on the Rx queues' interrupts (testpmd's --rxq-interrupt). The first test case also tests it after the ports are configured a second time, with the same number of queues. The second test case tests it after the number of queues changed. It configures the ports with two queues, then with one queue. The packets differ in their source address, to spread over the queues, and with two queues both must receive packets. The test case is skipped if a port cannot have two queues, or if the packets do not reach both queues. The test cases run on the ingress port of the test run, so they test the driver of that port. For the virtio PCI driver, the SUT is a VM and its port a virtio-net device. Signed-off-by: Isaac Boukris <iboukris@gmail.com> --- doc/api/dts/tests.TestSuite_rx_interrupt.rst | 8 ++ dts/api/params/types.py | 1 + dts/api/testpmd/config.py | 2 + dts/tests/TestSuite_rx_interrupt.py | 122 +++++++++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 doc/api/dts/tests.TestSuite_rx_interrupt.rst create mode 100644 dts/tests/TestSuite_rx_interrupt.py diff --git a/doc/api/dts/tests.TestSuite_rx_interrupt.rst b/doc/api/dts/tests.TestSuite_rx_interrupt.rst new file mode 100644 index 0000000000..ff65daf78c --- /dev/null +++ b/doc/api/dts/tests.TestSuite_rx_interrupt.rst @@ -0,0 +1,8 @@ +.. SPDX-License-Identifier: BSD-3-Clause + +rx_interrupt Test Suite +======================= + +.. automodule:: tests.TestSuite_rx_interrupt + :members: + :show-inheritance: diff --git a/dts/api/params/types.py b/dts/api/params/types.py index c4b718eebe..3d852cf1fb 100644 --- a/dts/api/params/types.py +++ b/dts/api/params/types.py @@ -190,6 +190,7 @@ class TestPmdParamsDict(EalParamsDict, total=False): disable_device_start: Switch no_lsc_interrupt: Switch no_rmv_interrupt: Switch + rxq_interrupt: Switch bitrate_stats: int | None latencystats: int | None print_events: list[Event] | None diff --git a/dts/api/testpmd/config.py b/dts/api/testpmd/config.py index c72c1b2c90..92b5a23862 100644 --- a/dts/api/testpmd/config.py +++ b/dts/api/testpmd/config.py @@ -491,6 +491,7 @@ class TestPmdParams(EalParams): for the first time. no_lsc_interrupt: Disable LSC interrupts for all ports, even those supporting it. no_rmv_interrupt: Disable RMV interrupts for all ports, even those supporting it. + rxq_interrupt: Enable Rx queue interrupts for all ports. Idle forwarding lcores sleep. bitrate_stats: Set the logical core N to perform bitrate calculation. latencystats: Set the logical core N to perform latency and jitter calculations. print_events: Enable printing the occurrence of the designated events. @@ -596,6 +597,7 @@ class TestPmdParams(EalParams): disable_device_start: Switch = None no_lsc_interrupt: Switch = None no_rmv_interrupt: Switch = None + rxq_interrupt: Switch = None bitrate_stats: int | None = None latencystats: int | None = None print_events: list[Event] | None = field( diff --git a/dts/tests/TestSuite_rx_interrupt.py b/dts/tests/TestSuite_rx_interrupt.py new file mode 100644 index 0000000000..05d82487d5 --- /dev/null +++ b/dts/tests/TestSuite_rx_interrupt.py @@ -0,0 +1,122 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2026 Isaac Boukris + +"""Rx interrupt test suite. + +Test that packets received on a port wake up a testpmd lcore that sleeps on the Rx queues' +interrupts. Test it again after the ports are configured again, with the same number of queues +and with another number. +""" + +import re + +from scapy.layers.inet import IP, UDP +from scapy.layers.l2 import Ether +from scapy.packet import Raw + +from api.exception import InteractiveCommandExecutionError +from api.packet import send_packets +from api.test import fail, verify_else_skip +from api.test_suite import TestSuite, func_suite, func_test +from api.testpmd import TestPmd +from api.testpmd.config import SimpleForwardingModes + + +@func_suite +class TestRxInterrupt(TestSuite): + """Rx interrupt test suite.""" + + #: The number of packets to send. Each of them must wake the lcore up. + NUMBER_OF_WAKE_UPS = 8 + + def _wake_ups(self, testpmd: TestPmd) -> int: + match = re.search(r"RX-wakeups:\s+(\d+)", testpmd.send_command("show fwd stats all")) + return int(match.group(1)) if match else 0 + + def _verify_wake_ups(self, testpmd: TestPmd) -> str: + """Verify that packets wake up the lcore of `testpmd`, `NUMBER_OF_WAKE_UPS` times. + + The packets differ in their source address, to spread over the Rx queues. + + A packet is sent only after the previous one woke the lcore up. The lcore is awake for + a short time every 10 ms, to look at its queues. A packet that arrives then is received + without a wake-up, so send each packet up to three times. + + Returns: + The forward statistics that testpmd shows when it stops. + """ + testpmd.start() + for number in range(1, self.NUMBER_OF_WAKE_UPS + 1): + packet = Ether() / IP(src=f"192.168.0.{number}") / UDP() / Raw(b"\0" * 32) + wake_ups = self._wake_ups(testpmd) + for _ in range(3): + send_packets([packet]) + if self._wake_ups(testpmd) > wake_ups: + break + else: + fail(f"Packet {number} did not wake up the lcore.") + return testpmd.stop() + + def _configure_again(self, testpmd: TestPmd, number_of_queues: int) -> None: + """Stop the ports of `testpmd`, configure them with `number_of_queues` and start them.""" + testpmd.set_ports_queues(number_of_queues) + try: + testpmd.start_all_ports() + except InteractiveCommandExecutionError: + fail(f"The ports did not start, configured with {number_of_queues} queue(s).") + + @func_test + def wake_up_on_packet(self) -> None: + """Wake up a sleeping lcore with packets, also after a second configuration. + + Steps: + * Start testpmd with Rx queue interrupts, receiving. + * Send packets to the ingress port, one at a time. + * Stop the ports, configure them again with the same number of queues, start them + and send again. + + Verify: + * Each packet wakes up the lcore from the queue's interrupt. + * The ports start after the second configuration. + """ + with TestPmd(rxq_interrupt=True, forward_mode=SimpleForwardingModes.rxonly) as testpmd: + self._verify_wake_ups(testpmd) + self._configure_again(testpmd, 1) + self._verify_wake_ups(testpmd) + + @func_test + def wake_up_on_packet_after_queue_number_change(self) -> None: + """Wake up a sleeping lcore with packets after the number of queues changed. + + The test case is skipped if a port cannot have two queues, or if the packets do not + reach both queues. + + Steps: + * Start testpmd with Rx queue interrupts, receiving, with one queue. + * Stop the ports, configure them with two queues, start them and send packets to + the ingress port, one at a time. + * Do the same with one queue. + + Verify: + * Each packet wakes up the lcore from a queue's interrupt. + * With two queues, both queues receive packets. + * The ports start after each configuration. + """ + with TestPmd(rxq_interrupt=True, forward_mode=SimpleForwardingModes.rxonly) as testpmd: + max_queues = min( + min(port.max_rx_queues_num, port.max_tx_queues_num) + for port in testpmd.show_port_info_all() + ) + verify_else_skip( + max_queues >= 2, f"The test needs 2 queues, and a port has {max_queues} at most." + ) + self._configure_again(testpmd, 2) + statistics = self._verify_wake_ups(testpmd) + # Each packet woke the lcore up. So a queue that received packets woke it up. + for queue in (0, 1): + verify_else_skip( + f"RX Port= 0/Queue= {queue}" in statistics, + f"No packet reached Rx queue {queue} of the ingress port.", + ) + self._configure_again(testpmd, 1) + self._verify_wake_ups(testpmd) -- 2.56.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 0/7] net/virtio: fix Rx interrupts with MSI-X 2026-11-17 12:43 [PATCH 0/1] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris 2026-11-17 12:43 ` [PATCH 1/1] net/virtio: fix Rx interrupt setup " Isaac Boukris 2026-11-17 21:59 ` [PATCH v2 0/5] net/virtio: fix Rx interrupts " Isaac Boukris @ 2026-11-18 0:19 ` Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 1/7] net/virtio: fix Rx interrupt setup " Isaac Boukris ` (6 more replies) 2 siblings, 7 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-18 0:19 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, David Marchand, Aman Singh, Luca Vizzarro, Patrick Robb, Isaac Boukris Since 26.11-rc2, a virtio-net PCI device on vfio-pci cannot be configured with Rx interrupts and an offload or RSS, and it cannot be configured a second time. For example, l3fwd-power fails to start on it. Patch 1 is the fix, for 26.11 and stable. The other patches can wait for 27.03. - Patch 2 fixes a packet loss on virtio-user ports with vhost-net. The unit test of v2 found it. When the application uses fewer Rx queues than the port has queue pairs, the kernel still sends flows to the TAP queues of the unused queue pairs, and they are lost. The driver detached these queues before 21.11. - Patch 3 is a unit test of it, on a virtio-user port with two queue pairs and one Rx queue. - Patch 4 adds a unit test of Rx interrupts on that port. Without the check of the interrupt handle type in patch 1, this test fails ("EAL: Wrong intr vector number"). This is why patch 1 has that check. - Patch 5 adds a testpmd option, --rxq-interrupt. With it, idle forwarding lcores sleep on the Rx queue interrupts, as l3fwd-power does. It will need a line in the 27.03 release notes. - Patches 6 and 7 add a DTS suite that uses this option. It has two test cases. In the first, each packet sent to the port must wake the lcore up, also after the port is configured a second time with the same number of queues. The second does the same after the number of queues changed, to two queues and back to one. With two queues, both must receive packets. It is skipped if the port cannot have two queues, or if the packets do not reach both. Tested in a VM (QEMU 10.2, vhost-net): - l3fwd-power in interrupt-only mode on a virtio-net PCI port. Without patch 1 it fails as in the commit message. With it, each packet wakes its lcore up. - The DTS suite on a virtio-net PCI port. Without patch 1 both test cases fail at the second configuration. With it, they pass. They also pass on an emulated Intel 82576 port (igb driver). On a virtio-net port with one queue pair, the second test case is skipped. - testpmd, receiving, on a virtio-user port with two queue pairs, while the kernel sends 64 UDP flows on the TAP interface. With one Rx queue, 22 flows arrive without patch 2, and all 64 with it. With two Rx queues, all arrive with and without it. A port of the TAP driver, and a virtio-net PCI port of QEMU with four queue pairs, receive all 64 on one Rx queue. - The unit tests pass. Without patch 2, the first one fails. Without the handle type check of patch 1, the second one fails. The unit tests log "Some interrupt handle is leaking an event FD" when they close their port. This series does not cause it. main logs it for any virtio-user port, with testpmd too, since commit 67813957d8 ("interrupts: warn on leaked event FDs"), because virtio-user frees its interrupt handle before it closes its call fds. v3: - Patches 2 and 3 are new. In v2, the unit test of Rx interrupts failed on about half of the CI hosts, because the kernel sent its frame to the TAP queue of the unused queue pair. Patch 2 fixes that in the driver. - Patch 4 is that unit test, on top of patch 3. Its frame is now an IPv4 one. - Patch 5: testpmd logs an error when the interrupt of an Rx queue cannot be registered (AI review). - Patches 1, 6 and 7 are unchanged. v2: - Patch 1 keeps the eventfds when the number of Rx queues did not change (David Marchand). It releases them only when the number changed, and only then must an application register the Rx queue interrupts again. - The unit test, the testpmd option and the DTS suite are new. Patches generated with AI assistance. Isaac Boukris (7): net/virtio: fix Rx interrupt setup with MSI-X net/virtio-user: fix packet loss with unused queue pairs test/virtio_user: add unit test of unused queue pairs test/virtio_user: add unit test of Rx interrupts app/testpmd: add Rx queue interrupts option dts: support virtio PCI ports dts: add Rx interrupt test suite MAINTAINERS | 1 + app/test-pmd/parameters.c | 8 + app/test-pmd/testpmd.c | 93 ++++- app/test-pmd/testpmd.h | 2 + app/test/meson.build | 1 + app/test/test_pmd_virtio_user.c | 339 ++++++++++++++++++ doc/api/dts/tests.TestSuite_rx_interrupt.rst | 8 + doc/guides/testpmd_app_ug/run_app.rst | 8 + drivers/net/virtio/virtio_ethdev.c | 18 +- drivers/net/virtio/virtio_user/vhost_kernel.c | 12 + .../net/virtio/virtio_user/vhost_kernel_tap.c | 14 + .../net/virtio/virtio_user/vhost_kernel_tap.h | 4 + dts/api/params/types.py | 1 + dts/api/testpmd/config.py | 2 + dts/framework/testbed_model/linux_session.py | 9 +- dts/tests/TestSuite_rx_interrupt.py | 122 +++++++ 16 files changed, 635 insertions(+), 7 deletions(-) create mode 100644 app/test/test_pmd_virtio_user.c create mode 100644 doc/api/dts/tests.TestSuite_rx_interrupt.rst create mode 100644 dts/tests/TestSuite_rx_interrupt.py -- 2.56.1 ^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH v3 1/7] net/virtio: fix Rx interrupt setup with MSI-X 2026-11-18 0:19 ` [PATCH v3 0/7] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris @ 2026-11-18 0:19 ` Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 2/7] net/virtio-user: fix packet loss with unused queue pairs Isaac Boukris ` (5 subsequent siblings) 6 siblings, 0 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-18 0:19 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, David Marchand, Aman Singh, Luca Vizzarro, Patrick Robb, Isaac Boukris, stable With Rx interrupts enabled, configuring a port initializes the device, and a second time when an offload or RSS is requested. Each initialization enables the interrupt eventfds. EAL now refuses to enable MSI-X eventfds twice, so such a configuration fails, and so does configuring a port a second time: EAL: Interrupt eventfds are already enabled virtio_configure_intr(): Fail to create eventfd ETHDEV: Port0 dev_configure = -16 Before that EAL change, the previous eventfds were leaked. Enable the eventfds only when they are not enabled yet. There is one eventfd per Rx queue. So if the number of Rx queues changed, release the eventfds first, and new ones are created. The application must then register the Rx queue interrupts again. Release them for a VFIO MSI-X handle only, the type whose eventfds EAL creates. The other type that gets here is the virtio-user one. Its eventfds are the backend's call fds, one per queue pair, set once when the device is created. Releasing them would reset their count, which nothing sets again, and registering an Rx queue's interrupt would then fail. To reproduce, with a virtio-net PCI device bound to vfio-pci: dpdk-l3fwd-power -l 0 -a 0000:0c:00.0 -- -p 1 --interrupt-only \ --parse-ptype --config="(0,0,0)" Fixes: 3ba6b689893f ("eal/linux: fix eventfd leaks when enabling interrupts") Cc: stable@dpdk.org Signed-off-by: Isaac Boukris <iboukris@gmail.com> --- v2: keep the eventfds unless the number of Rx queues changed (David Marchand). drivers/net/virtio/virtio_ethdev.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index f2302089ee..8600f3899a 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1455,10 +1455,20 @@ virtio_configure_intr(struct rte_eth_dev *dev) return -ENOTSUP; } - ret = rte_intr_efd_enable(dev->intr_handle, dev->data->nb_rx_queues); - if (ret < 0) { - PMD_INIT_LOG(ERR, "Fail to create eventfd"); - return ret; + /* On reinitialization, release the eventfds if the number of Rx queues changed. */ + if (rte_intr_type_get(dev->intr_handle) == RTE_INTR_HANDLE_VFIO_MSIX && + rte_intr_dp_is_en(dev->intr_handle) && + rte_intr_nb_efd_get(dev->intr_handle) != dev->data->nb_rx_queues) { + virtio_intr_disable(dev); + rte_intr_efd_disable(dev->intr_handle); + } + + if (!rte_intr_dp_is_en(dev->intr_handle)) { + ret = rte_intr_efd_enable(dev->intr_handle, dev->data->nb_rx_queues); + if (ret < 0) { + PMD_INIT_LOG(ERR, "Fail to create eventfd"); + return ret; + } } ret = rte_intr_vec_list_alloc(dev->intr_handle, "intr_vec", -- 2.56.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 2/7] net/virtio-user: fix packet loss with unused queue pairs 2026-11-18 0:19 ` [PATCH v3 0/7] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 1/7] net/virtio: fix Rx interrupt setup " Isaac Boukris @ 2026-11-18 0:19 ` Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 3/7] test/virtio_user: add unit test of " Isaac Boukris ` (4 subsequent siblings) 6 siblings, 0 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-18 0:19 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, David Marchand, Aman Singh, Luca Vizzarro, Patrick Robb, Isaac Boukris, stable A virtio-user port on vhost-net loses received packets when the application configures fewer Rx queues than the port has queue pairs (the queues devarg). For example, with queues=2 and one Rx queue, testpmd receives 22 of 64 flows that the kernel sends on the TAP interface. The TAP interface has one queue per queue pair, and the kernel picks the queue of a packet by a hash of its flow. The driver unsets the vhost backend of a disabled queue pair, but the TAP queue stays attached. So the kernel still sends flows to it, and nothing reads them. The driver used to detach such a queue with TUNSETQUEUE. The commit below removed that when it moved the opening of the TAP queues to the initialization. Detach the TAP queue of a queue pair when it is disabled, and attach it when it is enabled. The queues after the first one are detached when they are opened, because a queue pair is disabled until the driver enables it. The first queue is never detached, because the interface needs a queue. A queue pair is also disabled for a moment when the memory table changes. Its TAP queue is then detached and attached again. Fixes: b72099be7f27 ("net/virtio-user: fix init when using existing tap") Cc: stable@dpdk.org Signed-off-by: Isaac Boukris <iboukris@gmail.com> --- v3: new patch. drivers/net/virtio/virtio_user/vhost_kernel.c | 12 ++++++++++++ drivers/net/virtio/virtio_user/vhost_kernel_tap.c | 14 ++++++++++++++ drivers/net/virtio/virtio_user/vhost_kernel_tap.h | 4 ++++ 3 files changed, 30 insertions(+) diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c b/drivers/net/virtio/virtio_user/vhost_kernel.c index 7914b517cd..5b70999393 100644 --- a/drivers/net/virtio/virtio_user/vhost_kernel.c +++ b/drivers/net/virtio/virtio_user/vhost_kernel.c @@ -455,6 +455,9 @@ vhost_kernel_setup(struct virtio_user_dev *dev) data->tapfds[i] = vhost_tap_open(dev->ifname, r_flags, true); if (data->tapfds[i] < 0) goto err_tapfds; + /* The queue stays detached until its queue pair is enabled. */ + if (vhost_tap_set_queue(data->tapfds[i], false) < 0) + goto err_tapfds; } dev->backend_data = data; @@ -546,6 +549,12 @@ vhost_kernel_enable_queue_pair(struct virtio_user_dev *dev, PMD_DRV_LOG(ERR, "fail to set backend for vhost kernel"); return -1; } + /* + * Detach the queue, so that the kernel sends its packets to the + * other queues. The interface keeps its first queue. + */ + if (pair_idx > 0 && vhost_tap_set_queue(tapfd, false) < 0) + return -1; dev->qp_enabled[pair_idx] = false; return 0; } @@ -561,6 +570,9 @@ vhost_kernel_enable_queue_pair(struct virtio_user_dev *dev, vhost_tap_set_mac(data->tapfds[pair_idx], dev->mac_addr) < 0) return -1; + if (pair_idx > 0 && vhost_tap_set_queue(tapfd, true) < 0) + return -1; + if (vhost_kernel_tap_setup(tapfd, hdr_size, dev->features) < 0) { PMD_DRV_LOG(ERR, "fail to setup tap for vhost kernel"); return -1; diff --git a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c index da55aba505..bfdc6f46c0 100644 --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c @@ -126,6 +126,20 @@ vhost_tap_set_mac(int tapfd, uint8_t *mac) return 0; } +int +vhost_tap_set_queue(int tapfd, bool attach) +{ + struct ifreq ifr; + + memset(&ifr, 0, sizeof(ifr)); + ifr.ifr_flags = attach ? IFF_ATTACH_QUEUE : IFF_DETACH_QUEUE; + if (ioctl(tapfd, TUNSETQUEUE, (void *)&ifr) == -1) { + PMD_DRV_LOG(ERR, "TUNSETQUEUE failed: %s", strerror(errno)); + return -1; + } + return 0; +} + static int vhost_kernel_tap_set_offload(int fd, uint64_t features) { diff --git a/drivers/net/virtio/virtio_user/vhost_kernel_tap.h b/drivers/net/virtio/virtio_user/vhost_kernel_tap.h index 1e026d7488..05fa8a9244 100644 --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.h +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.h @@ -16,12 +16,15 @@ #define TUNSETSNDBUF _IOW('T', 212, int) #define TUNGETVNETHDRSZ _IOR('T', 215, int) #define TUNSETVNETHDRSZ _IOW('T', 216, int) +#define TUNSETQUEUE _IOW('T', 217, int) /* TUNSETIFF ifr flags */ #define IFF_TAP 0x0002 #define IFF_NO_PI 0x1000 #define IFF_VNET_HDR 0x4000 #define IFF_MULTI_QUEUE 0x0100 +#define IFF_ATTACH_QUEUE 0x0200 +#define IFF_DETACH_QUEUE 0x0400 #define IFF_NAPI 0x0010 /* Features for GSO (TUNSETOFFLOAD). */ @@ -41,5 +44,6 @@ int vhost_tap_open(const char *ifname, unsigned int r_flags, bool multi_queue); int vhost_tap_get_name(int tapfd, char **ifname); int vhost_tap_get_flags(int tapfd, unsigned int *tap_flags); int vhost_tap_set_mac(int tapfd, uint8_t *mac); +int vhost_tap_set_queue(int tapfd, bool attach); #endif -- 2.56.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 3/7] test/virtio_user: add unit test of unused queue pairs 2026-11-18 0:19 ` [PATCH v3 0/7] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 1/7] net/virtio: fix Rx interrupt setup " Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 2/7] net/virtio-user: fix packet loss with unused queue pairs Isaac Boukris @ 2026-11-18 0:19 ` Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 4/7] test/virtio_user: add unit test of Rx interrupts Isaac Boukris ` (3 subsequent siblings) 6 siblings, 0 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-18 0:19 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, David Marchand, Aman Singh, Luca Vizzarro, Patrick Robb, Isaac Boukris Add a test suite for the virtio PMD on a virtio-user port backed by vhost-net and a TAP interface, modeled on the test suite of the TAP PMD. It needs no VM and no PCI device. It is skipped where the port cannot be created (no root, no /dev/vhost-net). The port has two queue pairs and the test configures one Rx queue. The first case sends frames of 16 flows from the kernel, through a packet socket on the TAP interface. All of them must arrive on the Rx queue. Without the fix of the unused queue pairs, the kernel sends about half of the flows to the TAP queue of the second queue pair, and they are lost. DPDK_TEST=virtio_user_pmd_autotest ./build/app/dpdk-test --no-huge Signed-off-by: Isaac Boukris <iboukris@gmail.com> --- v3: new patch. It has the test suite and the kernel socket that patch 2 of v2 added. MAINTAINERS | 1 + app/test/meson.build | 1 + app/test/test_pmd_virtio_user.c | 266 ++++++++++++++++++++++++++++++++ 3 files changed, 268 insertions(+) create mode 100644 app/test/test_pmd_virtio_user.c diff --git a/MAINTAINERS b/MAINTAINERS index 8fcb4ef5fa..36dd253f36 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1106,6 +1106,7 @@ T: git://dpdk.org/next/dpdk-next-virtio F: drivers/net/virtio/ F: doc/guides/nics/virtio.rst F: doc/guides/nics/features/virtio*.ini +F: app/test/test_pmd_virtio_user.c Wind River AVP M: Steven Webster <steven.webster@windriver.com> diff --git a/app/test/meson.build b/app/test/meson.build index 2f1cd817cd..e480353885 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -155,6 +155,7 @@ source_file_deps = { 'test_pmd_ring.c': ['net_ring', 'ethdev', 'bus_vdev'], 'test_pmd_ring_perf.c': ['ethdev', 'net_ring', 'bus_vdev'], 'test_pmd_tap.c': ['ethdev', 'net_tap', 'bus_vdev'], + 'test_pmd_virtio_user.c': ['ethdev', 'net_virtio', 'bus_vdev'], 'test_pmu.c': ['pmu'], 'test_power.c': ['power', 'power_acpi', 'power_kvm_vm', 'power_intel_pstate', 'power_amd_pstate', 'power_cppc'], diff --git a/app/test/test_pmd_virtio_user.c b/app/test/test_pmd_virtio_user.c new file mode 100644 index 0000000000..d8cf4f6a5d --- /dev/null +++ b/app/test/test_pmd_virtio_user.c @@ -0,0 +1,266 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2026 Isaac Boukris + */ + +/* + * Tests of the virtio PMD on a virtio-user port backed by vhost-net and a TAP + * interface. They need no VM and no PCI device. The kernel's end is a packet + * socket on the TAP interface. + */ + +#include "test.h" + +#include <stdio.h> + +#ifndef RTE_EXEC_ENV_LINUX + +static int +test_pmd_virtio_user(void) +{ + printf("virtio-user with vhost-net is only available on Linux, skipping test\n"); + return TEST_SKIPPED; +} + +#else /* RTE_EXEC_ENV_LINUX */ + +#include <errno.h> +#include <string.h> +#include <unistd.h> +#include <net/if.h> +#include <sys/ioctl.h> +#include <sys/socket.h> +#include <linux/if_packet.h> +#include <linux/virtio_net.h> + +#include <rte_bus_vdev.h> +#include <rte_cycles.h> +#include <rte_ethdev.h> +#include <rte_ether.h> +#include <rte_ip.h> +#include <rte_mbuf.h> + +#define VDEV_NAME "net_virtio_user_test" +#define TAP_NAME "dtap_vu_test" +#define RING_SIZE 256 +#define NB_MBUF 1024 +#define BURST 32 +#define WAIT_MS 1000 +/* The test frames' IP protocol (experimental, RFC 3692) */ +#define TEST_IP_PROTO 253 +#define NB_FLOWS 16 + +static struct rte_mempool *mp; +static uint16_t port_id = RTE_MAX_ETHPORTS; +static int ksock = -1; /* the kernel's end, each frame follows a virtio_net_hdr */ +static bool started; + +static int +port_stop(void) +{ + int ret; + + if (!started) + return TEST_SUCCESS; + started = false; + ret = rte_eth_dev_stop(port_id); + TEST_ASSERT_SUCCESS(ret, "stop failed: %s", rte_strerror(-ret)); + + return TEST_SUCCESS; +} + +/* Configure the port and start it. A failed case may have left it started. */ +static int +port_start(const struct rte_eth_conf *conf) +{ + int ret; + + TEST_ASSERT_SUCCESS(port_stop(), "port stop failed"); + ret = rte_eth_dev_configure(port_id, 1, 1, conf); + TEST_ASSERT_SUCCESS(ret, "configure failed: %s", rte_strerror(-ret)); + ret = rte_eth_rx_queue_setup(port_id, 0, RING_SIZE, SOCKET_ID_ANY, NULL, mp); + TEST_ASSERT_SUCCESS(ret, "Rx queue setup failed: %s", rte_strerror(-ret)); + ret = rte_eth_tx_queue_setup(port_id, 0, RING_SIZE, SOCKET_ID_ANY, NULL); + TEST_ASSERT_SUCCESS(ret, "Tx queue setup failed: %s", rte_strerror(-ret)); + ret = rte_eth_dev_start(port_id); + TEST_ASSERT_SUCCESS(ret, "start failed: %s", rte_strerror(-ret)); + started = true; + + return TEST_SUCCESS; +} + +/* + * A frame from the kernel's end to the port. The kernel picks a queue of the + * TAP interface by a hash of the frame's addresses, so the source address + * makes the flow. + */ +static int +kernel_send(uint8_t flow) +{ + struct { + struct virtio_net_hdr vnet; /* no offload */ + struct rte_ether_hdr eth; + struct rte_ipv4_hdr ip; + uint8_t payload[RTE_ETHER_MIN_LEN]; + } frame; + ssize_t n; + + memset(&frame, 0, sizeof(frame)); + memset(&frame.eth.dst_addr, 0xff, RTE_ETHER_ADDR_LEN); + frame.eth.src_addr.addr_bytes[0] = RTE_ETHER_LOCAL_ADMIN_ADDR; + frame.eth.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4); + frame.ip.version_ihl = RTE_IPV4_VHL_DEF; + frame.ip.total_length = rte_cpu_to_be_16(sizeof(frame.ip) + sizeof(frame.payload)); + frame.ip.time_to_live = 64; + frame.ip.next_proto_id = TEST_IP_PROTO; + frame.ip.src_addr = rte_cpu_to_be_32(RTE_IPV4(192, 0, 2, flow)); + frame.ip.dst_addr = rte_cpu_to_be_32(RTE_IPV4(198, 51, 100, 1)); + frame.ip.hdr_checksum = rte_ipv4_cksum(&frame.ip); + n = send(ksock, &frame, sizeof(frame), 0); + TEST_ASSERT(n == (ssize_t)sizeof(frame), "send on %s failed: %s", TAP_NAME, + strerror(errno)); + + return TEST_SUCCESS; +} + +/* Receive what the queue holds. Return the flows of the frames of kernel_send(), a bit each. */ +static uint32_t +port_receive(void) +{ + struct rte_mbuf *pkts[BURST]; + uint32_t flows = 0; + uint16_t i, n; + + while ((n = rte_eth_rx_burst(port_id, 0, pkts, BURST)) != 0) { + for (i = 0; i < n; i++) { + const struct rte_ether_hdr *eth = + rte_pktmbuf_mtod(pkts[i], const struct rte_ether_hdr *); + const struct rte_ipv4_hdr *ip = (const struct rte_ipv4_hdr *)(eth + 1); + + if (rte_pktmbuf_data_len(pkts[i]) >= sizeof(*eth) + sizeof(*ip) && + eth->ether_type == rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4) && + ip->next_proto_id == TEST_IP_PROTO) + flows |= UINT32_C(1) << (rte_be_to_cpu_32(ip->src_addr) & 0xff); + } + rte_pktmbuf_free_bulk(pkts, n); + } + + return flows; +} + +/* + * The port has two queue pairs and the test configures one Rx queue. The + * kernel picks a queue for each flow, so send frames of several flows. All of + * them must arrive on the one Rx queue. + */ +static int +test_virtio_user_rx_flows(void) +{ + const uint32_t all = RTE_LEN2MASK(NB_FLOWS, uint32_t); + struct rte_eth_conf conf = { 0 }; + uint32_t flows = 0; + uint64_t deadline; + uint8_t flow; + + TEST_ASSERT_SUCCESS(port_start(&conf), "port start failed"); + for (flow = 0; flow < NB_FLOWS; flow++) + TEST_ASSERT_SUCCESS(kernel_send(flow), "kernel send failed"); + deadline = rte_get_timer_cycles() + rte_get_timer_hz() * WAIT_MS / 1000; + while (flows != all && rte_get_timer_cycles() < deadline) + flows |= port_receive(); + TEST_ASSERT(flows == all, "received the flows 0x%x of 0x%x", flows, all); + TEST_ASSERT_SUCCESS(port_stop(), "port stop failed"); + + return TEST_SUCCESS; +} + +static void +test_virtio_user_cleanup(void) +{ + if (ksock >= 0) + close(ksock); + ksock = -1; + if (port_id != RTE_MAX_ETHPORTS) { + port_stop(); + rte_eth_dev_close(port_id); + rte_vdev_uninit(VDEV_NAME); + } + port_id = RTE_MAX_ETHPORTS; + rte_mempool_free(mp); + mp = NULL; +} + +/* Open the kernel's end. Set the TAP interface up and bind a packet socket to it. */ +static int +kernel_open(void) +{ + struct sockaddr_ll addr = { + .sll_family = AF_PACKET, + .sll_protocol = htons(ETH_P_ALL), + }; + struct ifreq ifr; + int one = 1; + + ksock = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); + if (ksock < 0) + return -1; + memset(&ifr, 0, sizeof(ifr)); + strlcpy(ifr.ifr_name, TAP_NAME, sizeof(ifr.ifr_name)); + if (ioctl(ksock, SIOCGIFFLAGS, &ifr) < 0) + return -1; + ifr.ifr_flags |= IFF_UP; + if (ioctl(ksock, SIOCSIFFLAGS, &ifr) < 0) + return -1; + addr.sll_ifindex = if_nametoindex(TAP_NAME); + if (addr.sll_ifindex == 0 || + bind(ksock, (const struct sockaddr *)&addr, sizeof(addr)) < 0 || + setsockopt(ksock, SOL_PACKET, PACKET_VNET_HDR, &one, sizeof(one)) < 0) + return -1; + + return 0; +} + +static int +test_virtio_user_setup(void) +{ + mp = rte_pktmbuf_pool_create("virtio_user_test", NB_MBUF, 32, 0, + RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id()); + TEST_ASSERT_NOT_NULL(mp, "mempool creation failed: %s", rte_strerror(rte_errno)); + + /* + * The port has two queue pairs and the tests configure one Rx queue. + * vhost-net creates the TAP interface, which takes root or CAP_NET_ADMIN. + */ + if (rte_vdev_init(VDEV_NAME, "path=/dev/vhost-net,iface=" TAP_NAME ",queues=2") < 0 || + rte_eth_dev_get_port_by_name(VDEV_NAME, &port_id) != 0) { + printf("No virtio-user port on /dev/vhost-net, skipping test\n"); + test_virtio_user_cleanup(); + return TEST_SKIPPED; + } + if (kernel_open() < 0) { + printf("No packet socket on %s (%s), skipping test\n", TAP_NAME, strerror(errno)); + test_virtio_user_cleanup(); + return TEST_SKIPPED; + } + + return TEST_SUCCESS; +} + +static struct unit_test_suite test_pmd_virtio_user_suite = { + .setup = test_virtio_user_setup, + .teardown = test_virtio_user_cleanup, + .suite_name = "virtio-user PMD Unit Test Suite", + .unit_test_cases = { + TEST_CASE(test_virtio_user_rx_flows), + TEST_CASES_END() + } +}; + +static int +test_pmd_virtio_user(void) +{ + return unit_test_suite_runner(&test_pmd_virtio_user_suite); +} + +#endif /* RTE_EXEC_ENV_LINUX */ + +REGISTER_FAST_TEST(virtio_user_pmd_autotest, NOHUGE_OK, ASAN_OK, test_pmd_virtio_user); -- 2.56.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 4/7] test/virtio_user: add unit test of Rx interrupts 2026-11-18 0:19 ` [PATCH v3 0/7] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris ` (2 preceding siblings ...) 2026-11-18 0:19 ` [PATCH v3 3/7] test/virtio_user: add unit test of " Isaac Boukris @ 2026-11-18 0:19 ` Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 5/7] app/testpmd: add Rx queue interrupts option Isaac Boukris ` (2 subsequent siblings) 6 siblings, 0 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-18 0:19 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, David Marchand, Aman Singh, Luca Vizzarro, Patrick Robb, Isaac Boukris Add a case that configures the port with Rx interrupts and an Rx offload. It enables the interrupt of the Rx queue, sends a frame from the kernel and sleeps on the interrupt. The frame must end the sleep. Then it does the same after a second configure. The port has two queue pairs and the test configures one Rx queue, so the port has more interrupt eventfds than Rx queues. These eventfds are the backend's call fds, and the driver must not release them. If it does when it initializes the device again, the test fails. Signed-off-by: Isaac Boukris <iboukris@gmail.com> --- v3: on top of the previous patch. The test frame is now an IPv4 one. app/test/test_pmd_virtio_user.c | 73 +++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/app/test/test_pmd_virtio_user.c b/app/test/test_pmd_virtio_user.c index d8cf4f6a5d..3b60b268ba 100644 --- a/app/test/test_pmd_virtio_user.c +++ b/app/test/test_pmd_virtio_user.c @@ -34,6 +34,7 @@ test_pmd_virtio_user(void) #include <rte_bus_vdev.h> #include <rte_cycles.h> +#include <rte_epoll.h> #include <rte_ethdev.h> #include <rte_ether.h> #include <rte_ip.h> @@ -173,6 +174,77 @@ test_virtio_user_rx_flows(void) return TEST_SUCCESS; } +/* Sleep on the Rx queue's interrupt. A frame from the kernel must end the sleep. */ +static int +rx_intr_wakes(void) +{ + uint64_t deadline = rte_get_timer_cycles() + rte_get_timer_hz() * WAIT_MS / 1000; + struct rte_epoll_event event; + bool found; + int ret; + + ret = rte_eth_dev_rx_intr_ctl_q(port_id, 0, RTE_EPOLL_PER_THREAD, RTE_INTR_EVENT_ADD, + NULL); + TEST_ASSERT_SUCCESS(ret, "no interrupt for the Rx queue: %s", rte_strerror(-ret)); + + do { + /* + * Enable the interrupt before the kernel sends. A frame that + * arrives from now on raises it, also before the sleep below. + */ + ret = rte_eth_dev_rx_intr_enable(port_id, 0); + TEST_ASSERT_SUCCESS(ret, "Rx interrupt enable failed: %s", rte_strerror(-ret)); + /* Drop the frames that the kernel sent earlier, and their event. */ + port_receive(); + rte_epoll_wait(RTE_EPOLL_PER_THREAD, &event, 1, 0); + + TEST_ASSERT_SUCCESS(kernel_send(0), "kernel send failed"); + ret = rte_epoll_wait(RTE_EPOLL_PER_THREAD, &event, 1, WAIT_MS); + TEST_ASSERT(ret == 1, "no Rx interrupt within %d ms", WAIT_MS); + ret = rte_eth_dev_rx_intr_disable(port_id, 0); + TEST_ASSERT_SUCCESS(ret, "Rx interrupt disable failed: %s", rte_strerror(-ret)); + /* If another frame of the kernel raised the interrupt, send again. */ + found = port_receive() != 0; + } while (!found && rte_get_timer_cycles() < deadline); + TEST_ASSERT(found, "frame from the kernel not received"); + + ret = rte_eth_dev_rx_intr_ctl_q(port_id, 0, RTE_EPOLL_PER_THREAD, RTE_INTR_EVENT_DEL, + NULL); + TEST_ASSERT_SUCCESS(ret, "Rx interrupt removal failed: %s", rte_strerror(-ret)); + + return TEST_SUCCESS; +} + +/* + * Rx interrupts with an offload, which makes configure initialize the device + * twice. Then a second configure. The port has more interrupt eventfds than + * Rx queues. They belong to the backend, so the driver must not release them + * when it initializes the device again. + */ +static int +test_virtio_user_rx_intr(void) +{ + struct rte_eth_conf conf = { + .intr_conf.rxq = 1, + .rxmode.offloads = RTE_ETH_RX_OFFLOAD_UDP_CKSUM | RTE_ETH_RX_OFFLOAD_TCP_CKSUM, + }; + struct rte_eth_dev_info info; + int round, ret; + + ret = rte_eth_dev_info_get(port_id, &info); + TEST_ASSERT_SUCCESS(ret, "dev_info failed: %s", rte_strerror(-ret)); + conf.rxmode.offloads &= info.rx_offload_capa; + TEST_ASSERT(conf.rxmode.offloads != 0, "no Rx checksum offload to request"); + + for (round = 0; round < 2; round++) { + TEST_ASSERT_SUCCESS(port_start(&conf), "round %d: port start failed", round); + TEST_ASSERT_SUCCESS(rx_intr_wakes(), "round %d: Rx interrupt failed", round); + TEST_ASSERT_SUCCESS(port_stop(), "round %d: port stop failed", round); + } + + return TEST_SUCCESS; +} + static void test_virtio_user_cleanup(void) { @@ -251,6 +323,7 @@ static struct unit_test_suite test_pmd_virtio_user_suite = { .suite_name = "virtio-user PMD Unit Test Suite", .unit_test_cases = { TEST_CASE(test_virtio_user_rx_flows), + TEST_CASE(test_virtio_user_rx_intr), TEST_CASES_END() } }; -- 2.56.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 5/7] app/testpmd: add Rx queue interrupts option 2026-11-18 0:19 ` [PATCH v3 0/7] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris ` (3 preceding siblings ...) 2026-11-18 0:19 ` [PATCH v3 4/7] test/virtio_user: add unit test of Rx interrupts Isaac Boukris @ 2026-11-18 0:19 ` Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 6/7] dts: support virtio PCI ports Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 7/7] dts: add Rx interrupt test suite Isaac Boukris 6 siblings, 0 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-18 0:19 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, David Marchand, Aman Singh, Luca Vizzarro, Patrick Robb, Isaac Boukris testpmd cannot test the Rx queue interrupts of a driver, because it never asks for them. With --rxq-interrupt, the ports are configured with Rx queue interrupts, and a forwarding lcore whose Rx queues are all empty sleeps until a packet arrives on one of them, 10 ms at most, as l3fwd-power does. The forward statistics show the number of sleeps that an interrupt ended. If the interrupt of an Rx queue cannot be registered, an error is logged with the port and the queue. Signed-off-by: Isaac Boukris <iboukris@gmail.com> --- v3: log an error when the interrupt of an Rx queue cannot be registered. app/test-pmd/parameters.c | 8 +++ app/test-pmd/testpmd.c | 93 ++++++++++++++++++++++++++- app/test-pmd/testpmd.h | 2 + doc/guides/testpmd_app_ug/run_app.rst | 8 +++ 4 files changed, 109 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 34a4f74e63..f958104f47 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -207,6 +207,8 @@ enum { TESTPMD_OPT_NO_LSC_INTERRUPT_NUM, #define TESTPMD_OPT_NO_RMV_INTERRUPT "no-rmv-interrupt" TESTPMD_OPT_NO_RMV_INTERRUPT_NUM, +#define TESTPMD_OPT_RXQ_INTERRUPT "rxq-interrupt" + TESTPMD_OPT_RXQ_INTERRUPT_NUM, #define TESTPMD_OPT_PRINT_EVENT "print-event" TESTPMD_OPT_PRINT_EVENT_NUM, #define TESTPMD_OPT_MASK_EVENT "mask-event" @@ -357,6 +359,7 @@ static const struct option long_options[] = { NO_ARG(TESTPMD_OPT_DISABLE_DEVICE_START), NO_ARG(TESTPMD_OPT_NO_LSC_INTERRUPT), NO_ARG(TESTPMD_OPT_NO_RMV_INTERRUPT), + NO_ARG(TESTPMD_OPT_RXQ_INTERRUPT), REQUIRED_ARG(TESTPMD_OPT_PRINT_EVENT), REQUIRED_ARG(TESTPMD_OPT_MASK_EVENT), REQUIRED_ARG(TESTPMD_OPT_TX_OFFLOADS), @@ -515,6 +518,8 @@ usage(char* progname) printf(" --disable-device-start: do not automatically start port\n"); printf(" --no-lsc-interrupt: disable link status change interrupt.\n"); printf(" --no-rmv-interrupt: disable device removal interrupt.\n"); + printf(" --rxq-interrupt: enable Rx queue interrupts, " + "idle forwarding lcores sleep.\n"); #ifdef RTE_LIB_BITRATESTATS printf(" --bitrate-stats=N: set the logical core N to perform " "bit-rate calculation.\n"); @@ -1638,6 +1643,9 @@ launch_args_parse(int argc, char** argv) case TESTPMD_OPT_NO_RMV_INTERRUPT_NUM: rmv_interrupt = 0; break; + case TESTPMD_OPT_RXQ_INTERRUPT_NUM: + rxq_interrupt = 1; + break; case TESTPMD_OPT_FLOW_ISOLATE_ALL_NUM: flow_isolate_all = 1; break; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index d6211a9a8a..52c511a85f 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -43,6 +43,8 @@ #include <rte_mbuf.h> #include <rte_mbuf_pool_ops.h> #include <rte_interrupts.h> +#include <rte_epoll.h> +#include <rte_spinlock.h> #include <rte_ether.h> #include <rte_ethdev.h> #include <rte_dev.h> @@ -446,6 +448,11 @@ uint8_t lsc_interrupt = 1; /* enabled by default */ */ uint8_t rmv_interrupt = 1; /* enabled by default */ +/* + * Enable Rx queue interrupts. A forwarding lcore then sleeps when it is idle. + */ +uint8_t rxq_interrupt; + uint8_t hot_plug = 0; /**< hotplug disabled by default. */ /* After attach, port setup is called on event or by iterator */ @@ -2213,6 +2220,14 @@ fwd_stats_display(void) total_xmit, total_tx_dropped, total_xmit + total_tx_dropped); if (total_rx_nombuf > 0) printf(" RX-nombufs: %-14"PRIu64"\n", total_rx_nombuf); + if (rxq_interrupt) { + uint64_t rx_wakeups = 0; + lcoreid_t lc_id; + + for (lc_id = 0; lc_id < cur_fwd_config.nb_fwd_lcores; lc_id++) + rx_wakeups += fwd_lcores[lc_id]->rx_wakeups; + printf(" RX-wakeups: %-14"PRIu64"\n", rx_wakeups); + } printf(" %s++++++++++++++++++++++++++++++++++++++++++++++" "%s\n", acc_stats_border, acc_stats_border); @@ -2240,6 +2255,7 @@ void fwd_stats_reset(void) { streamid_t sm_id; + lcoreid_t lc_id; portid_t pt_id; int ret; int i; @@ -2267,6 +2283,8 @@ fwd_stats_reset(void) memset(&fs->tx_burst_stats, 0, sizeof(fs->tx_burst_stats)); fs->busy_cycles = 0; } + for (lc_id = 0; lc_id < cur_fwd_config.nb_fwd_lcores; lc_id++) + fwd_lcores[lc_id]->rx_wakeups = 0; } static void @@ -2323,6 +2341,42 @@ flush_fwd_rx_queues(void) } } +/* + * Rx queue interrupts work as in the l3fwd-power example. An lcore whose Rx + * queues are all empty enables their interrupts, sleeps until one of them + * is raised, 10 ms at most, and disables them. + */ +static rte_spinlock_t rxq_interrupt_locks[RTE_MAX_ETHPORTS]; + +static void +rxq_interrupt_turn(struct fwd_lcore *fc, bool on) +{ + struct fwd_stream **fsm = &fwd_streams[fc->stream_idx]; + streamid_t sm_id; + + for (sm_id = 0; sm_id < fc->stream_nb; sm_id++) { + struct fwd_stream *fs = fsm[sm_id]; + + rte_spinlock_lock(&rxq_interrupt_locks[fs->rx_port]); + if (on) + rte_eth_dev_rx_intr_enable(fs->rx_port, fs->rx_queue); + else + rte_eth_dev_rx_intr_disable(fs->rx_port, fs->rx_queue); + rte_spinlock_unlock(&rxq_interrupt_locks[fs->rx_port]); + } +} + +static void +rxq_interrupt_sleep(struct fwd_lcore *fc) +{ + struct rte_epoll_event event; + + rxq_interrupt_turn(fc, true); + if (rte_epoll_wait(RTE_EPOLL_PER_THREAD, &event, 1, 10) > 0) + fc->rx_wakeups++; + rxq_interrupt_turn(fc, false); +} + static void run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) { @@ -2330,6 +2384,7 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) uint64_t prev_tsc; streamid_t nb_fs; streamid_t sm_id; + bool idle; #ifdef RTE_LIB_BITRATESTATS uint64_t tics_per_1sec; uint64_t tics_datum; @@ -2344,6 +2399,7 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) nb_fs = fc->stream_nb; prev_tsc = rte_rdtsc(); do { + idle = true; for (sm_id = 0; sm_id < nb_fs; sm_id++) { struct fwd_stream *fs = fsm[sm_id]; uint64_t start_fs_tsc = 0; @@ -2354,9 +2410,13 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd) if (record_core_cycles) start_fs_tsc = rte_rdtsc(); busy = (*pkt_fwd)(fs); + if (busy) + idle = false; if (record_core_cycles && busy) fs->busy_cycles += rte_rdtsc() - start_fs_tsc; } + if (rxq_interrupt && idle && !fc->stopped) + rxq_interrupt_sleep(fc); #ifdef RTE_LIB_BITRATESTATS if (bitrate_enabled != 0 && bitrate_lcore_id == rte_lcore_id()) { @@ -2409,11 +2469,38 @@ lcore_usage_callback(unsigned int lcore_id, struct rte_lcore_usage *usage) return 0; } +/* + * Add the Rx interrupts of the queues of an lcore to the epoll instance of + * its thread, or delete them from it. + */ +static void +rxq_interrupt_register(struct fwd_lcore *fc, int op) +{ + struct fwd_stream **fsm = &fwd_streams[fc->stream_idx]; + streamid_t sm_id; + int ret; + + for (sm_id = 0; sm_id < fc->stream_nb; sm_id++) { + struct fwd_stream *fs = fsm[sm_id]; + + ret = rte_eth_dev_rx_intr_ctl_q(fs->rx_port, fs->rx_queue, + RTE_EPOLL_PER_THREAD, op, NULL); + if (ret != 0 && op == RTE_INTR_EVENT_ADD) + TESTPMD_LOG(ERR, "Port %u Rx queue %u: cannot register the interrupt: %s\n", + fs->rx_port, fs->rx_queue, rte_strerror(-ret)); + } +} + static int start_pkt_forward_on_core(void *fwd_arg) { - run_pkt_fwd_on_lcore((struct fwd_lcore *) fwd_arg, - cur_fwd_config.fwd_eng->packet_fwd); + struct fwd_lcore *fc = fwd_arg; + + if (rxq_interrupt) + rxq_interrupt_register(fc, RTE_INTR_EVENT_ADD); + run_pkt_fwd_on_lcore(fc, cur_fwd_config.fwd_eng->packet_fwd); + if (rxq_interrupt) + rxq_interrupt_register(fc, RTE_INTR_EVENT_DEL); return 0; } @@ -4203,6 +4290,8 @@ init_port_config(void) port->dev_conf.intr_conf.lsc = 1; if (rmv_interrupt && (*port->dev_info.dev_flags & RTE_ETH_DEV_INTR_RMV)) port->dev_conf.intr_conf.rmv = 1; + if (rxq_interrupt) + port->dev_conf.intr_conf.rxq = 1; } } diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 2ca4aaf086..6d3f258263 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -405,6 +405,7 @@ struct fwd_lcore { lcoreid_t cpuid_idx; /**< index of logical core in CPU id table */ volatile char stopped; /**< stop forwarding when set */ uint64_t total_cycles; /**< used with --record-core-cycles */ + uint64_t rx_wakeups; /**< used with --rxq-interrupt */ }; /* @@ -541,6 +542,7 @@ extern uint8_t no_device_start; /**<set by "--disable-device-start" parameter */ extern volatile int test_done; /* stop packet forwarding when set to 1. */ extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */ extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */ +extern uint8_t rxq_interrupt; /**< enabled by "--rxq-interrupt" parameter */ extern uint32_t event_print_mask; /**< set by "--print-event xxxx" and "--mask-event xxxx parameters */ extern bool setup_on_probe_event; /**< disabled by port setup-on iterator */ diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index e34e414ce2..7396293c64 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -462,6 +462,14 @@ The command line options are: Disable RMV interrupts for all ports, even those supporting it. +* ``--rxq-interrupt`` + + Enable Rx queue interrupts for all ports. + A forwarding lcore whose Rx queues are all empty sleeps + until a packet arrives on one of them, 10 ms at most. + The forward statistics show the number of sleeps that an interrupt ended (``RX-wakeups``). + An error is logged for an Rx queue whose interrupt cannot be registered. + * ``--bitrate-stats=N`` Set the logical core N to perform bitrate calculation. -- 2.56.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 6/7] dts: support virtio PCI ports 2026-11-18 0:19 ` [PATCH v3 0/7] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris ` (4 preceding siblings ...) 2026-11-18 0:19 ` [PATCH v3 5/7] app/testpmd: add Rx queue interrupts option Isaac Boukris @ 2026-11-18 0:19 ` Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 7/7] dts: add Rx interrupt test suite Isaac Boukris 6 siblings, 0 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-18 0:19 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, David Marchand, Aman Singh, Luca Vizzarro, Patrick Robb, Isaac Boukris DTS reads the logical name and the MAC address of a port from the lshw entry of its PCI device. A virtio device has none there, because lshw lists its network interface as a device of its own, on the virtio bus, right after the PCI device. The test run setup then fails: Could not gather a valid MAC address and/or logical name for port port-0 in node SUT 1. Copy to the entry of the PCI device what it lacks from the entry of its interface. Signed-off-by: Isaac Boukris <iboukris@gmail.com> --- dts/framework/testbed_model/linux_session.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dts/framework/testbed_model/linux_session.py b/dts/framework/testbed_model/linux_session.py index 786e8c4eb4..40cc87adaf 100644 --- a/dts/framework/testbed_model/linux_session.py +++ b/dts/framework/testbed_model/linux_session.py @@ -438,7 +438,14 @@ def get_pci_addr_of_vfs(self, pf_port: Port) -> list[str]: @cached_property def _lshw_net_info(self) -> list[LshwOutput]: output = self.send_command("lshw -quiet -json -C network", verify=True) - return json.loads(output.stdout) + ports = json.loads(output.stdout) + # The network interface of a virtio device is an entry of its own, on the virtio bus, + # right after the entry of the PCI device. Copy from it what the PCI entry lacks. + for device, interface in zip(ports, ports[1:]): + if "logicalname" not in device and interface.get("businfo", "").startswith("virtio@"): + configuration = interface.get("configuration", {}) | device.get("configuration", {}) + device.update(interface | device | {"configuration": configuration}) + return ports def refresh_lshw(self) -> None: """Force refresh of cached lshw network info.""" -- 2.56.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH v3 7/7] dts: add Rx interrupt test suite 2026-11-18 0:19 ` [PATCH v3 0/7] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris ` (5 preceding siblings ...) 2026-11-18 0:19 ` [PATCH v3 6/7] dts: support virtio PCI ports Isaac Boukris @ 2026-11-18 0:19 ` Isaac Boukris 6 siblings, 0 replies; 18+ messages in thread From: Isaac Boukris @ 2026-11-18 0:19 UTC (permalink / raw) To: Maxime Coquelin, Chenbo Xia Cc: dev, David Marchand, Aman Singh, Luca Vizzarro, Patrick Robb, Isaac Boukris Test that packets received on a port wake up a testpmd lcore that sleeps on the Rx queues' interrupts (testpmd's --rxq-interrupt). The first test case also tests it after the ports are configured a second time, with the same number of queues. The second test case tests it after the number of queues changed. It configures the ports with two queues, then with one queue. The packets differ in their source address, to spread over the queues, and with two queues both must receive packets. The test case is skipped if a port cannot have two queues, or if the packets do not reach both queues. The test cases run on the ingress port of the test run, so they test the driver of that port. For the virtio PCI driver, the SUT is a VM and its port a virtio-net device. Signed-off-by: Isaac Boukris <iboukris@gmail.com> --- doc/api/dts/tests.TestSuite_rx_interrupt.rst | 8 ++ dts/api/params/types.py | 1 + dts/api/testpmd/config.py | 2 + dts/tests/TestSuite_rx_interrupt.py | 122 +++++++++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 doc/api/dts/tests.TestSuite_rx_interrupt.rst create mode 100644 dts/tests/TestSuite_rx_interrupt.py diff --git a/doc/api/dts/tests.TestSuite_rx_interrupt.rst b/doc/api/dts/tests.TestSuite_rx_interrupt.rst new file mode 100644 index 0000000000..ff65daf78c --- /dev/null +++ b/doc/api/dts/tests.TestSuite_rx_interrupt.rst @@ -0,0 +1,8 @@ +.. SPDX-License-Identifier: BSD-3-Clause + +rx_interrupt Test Suite +======================= + +.. automodule:: tests.TestSuite_rx_interrupt + :members: + :show-inheritance: diff --git a/dts/api/params/types.py b/dts/api/params/types.py index c4b718eebe..3d852cf1fb 100644 --- a/dts/api/params/types.py +++ b/dts/api/params/types.py @@ -190,6 +190,7 @@ class TestPmdParamsDict(EalParamsDict, total=False): disable_device_start: Switch no_lsc_interrupt: Switch no_rmv_interrupt: Switch + rxq_interrupt: Switch bitrate_stats: int | None latencystats: int | None print_events: list[Event] | None diff --git a/dts/api/testpmd/config.py b/dts/api/testpmd/config.py index c72c1b2c90..92b5a23862 100644 --- a/dts/api/testpmd/config.py +++ b/dts/api/testpmd/config.py @@ -491,6 +491,7 @@ class TestPmdParams(EalParams): for the first time. no_lsc_interrupt: Disable LSC interrupts for all ports, even those supporting it. no_rmv_interrupt: Disable RMV interrupts for all ports, even those supporting it. + rxq_interrupt: Enable Rx queue interrupts for all ports. Idle forwarding lcores sleep. bitrate_stats: Set the logical core N to perform bitrate calculation. latencystats: Set the logical core N to perform latency and jitter calculations. print_events: Enable printing the occurrence of the designated events. @@ -596,6 +597,7 @@ class TestPmdParams(EalParams): disable_device_start: Switch = None no_lsc_interrupt: Switch = None no_rmv_interrupt: Switch = None + rxq_interrupt: Switch = None bitrate_stats: int | None = None latencystats: int | None = None print_events: list[Event] | None = field( diff --git a/dts/tests/TestSuite_rx_interrupt.py b/dts/tests/TestSuite_rx_interrupt.py new file mode 100644 index 0000000000..05d82487d5 --- /dev/null +++ b/dts/tests/TestSuite_rx_interrupt.py @@ -0,0 +1,122 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2026 Isaac Boukris + +"""Rx interrupt test suite. + +Test that packets received on a port wake up a testpmd lcore that sleeps on the Rx queues' +interrupts. Test it again after the ports are configured again, with the same number of queues +and with another number. +""" + +import re + +from scapy.layers.inet import IP, UDP +from scapy.layers.l2 import Ether +from scapy.packet import Raw + +from api.exception import InteractiveCommandExecutionError +from api.packet import send_packets +from api.test import fail, verify_else_skip +from api.test_suite import TestSuite, func_suite, func_test +from api.testpmd import TestPmd +from api.testpmd.config import SimpleForwardingModes + + +@func_suite +class TestRxInterrupt(TestSuite): + """Rx interrupt test suite.""" + + #: The number of packets to send. Each of them must wake the lcore up. + NUMBER_OF_WAKE_UPS = 8 + + def _wake_ups(self, testpmd: TestPmd) -> int: + match = re.search(r"RX-wakeups:\s+(\d+)", testpmd.send_command("show fwd stats all")) + return int(match.group(1)) if match else 0 + + def _verify_wake_ups(self, testpmd: TestPmd) -> str: + """Verify that packets wake up the lcore of `testpmd`, `NUMBER_OF_WAKE_UPS` times. + + The packets differ in their source address, to spread over the Rx queues. + + A packet is sent only after the previous one woke the lcore up. The lcore is awake for + a short time every 10 ms, to look at its queues. A packet that arrives then is received + without a wake-up, so send each packet up to three times. + + Returns: + The forward statistics that testpmd shows when it stops. + """ + testpmd.start() + for number in range(1, self.NUMBER_OF_WAKE_UPS + 1): + packet = Ether() / IP(src=f"192.168.0.{number}") / UDP() / Raw(b"\0" * 32) + wake_ups = self._wake_ups(testpmd) + for _ in range(3): + send_packets([packet]) + if self._wake_ups(testpmd) > wake_ups: + break + else: + fail(f"Packet {number} did not wake up the lcore.") + return testpmd.stop() + + def _configure_again(self, testpmd: TestPmd, number_of_queues: int) -> None: + """Stop the ports of `testpmd`, configure them with `number_of_queues` and start them.""" + testpmd.set_ports_queues(number_of_queues) + try: + testpmd.start_all_ports() + except InteractiveCommandExecutionError: + fail(f"The ports did not start, configured with {number_of_queues} queue(s).") + + @func_test + def wake_up_on_packet(self) -> None: + """Wake up a sleeping lcore with packets, also after a second configuration. + + Steps: + * Start testpmd with Rx queue interrupts, receiving. + * Send packets to the ingress port, one at a time. + * Stop the ports, configure them again with the same number of queues, start them + and send again. + + Verify: + * Each packet wakes up the lcore from the queue's interrupt. + * The ports start after the second configuration. + """ + with TestPmd(rxq_interrupt=True, forward_mode=SimpleForwardingModes.rxonly) as testpmd: + self._verify_wake_ups(testpmd) + self._configure_again(testpmd, 1) + self._verify_wake_ups(testpmd) + + @func_test + def wake_up_on_packet_after_queue_number_change(self) -> None: + """Wake up a sleeping lcore with packets after the number of queues changed. + + The test case is skipped if a port cannot have two queues, or if the packets do not + reach both queues. + + Steps: + * Start testpmd with Rx queue interrupts, receiving, with one queue. + * Stop the ports, configure them with two queues, start them and send packets to + the ingress port, one at a time. + * Do the same with one queue. + + Verify: + * Each packet wakes up the lcore from a queue's interrupt. + * With two queues, both queues receive packets. + * The ports start after each configuration. + """ + with TestPmd(rxq_interrupt=True, forward_mode=SimpleForwardingModes.rxonly) as testpmd: + max_queues = min( + min(port.max_rx_queues_num, port.max_tx_queues_num) + for port in testpmd.show_port_info_all() + ) + verify_else_skip( + max_queues >= 2, f"The test needs 2 queues, and a port has {max_queues} at most." + ) + self._configure_again(testpmd, 2) + statistics = self._verify_wake_ups(testpmd) + # Each packet woke the lcore up. So a queue that received packets woke it up. + for queue in (0, 1): + verify_else_skip( + f"RX Port= 0/Queue= {queue}" in statistics, + f"No packet reached Rx queue {queue} of the ingress port.", + ) + self._configure_again(testpmd, 1) + self._verify_wake_ups(testpmd) -- 2.56.1 ^ permalink raw reply related [flat|nested] 18+ messages in thread
end of thread, other threads:[~2026-11-18 0:20 UTC | newest] Thread overview: 18+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-17 12:43 [PATCH 0/1] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris 2026-11-17 12:43 ` [PATCH 1/1] net/virtio: fix Rx interrupt setup " Isaac Boukris 2026-11-17 14:29 ` David Marchand 2026-11-17 19:51 ` Isaac Boukris 2026-11-17 21:59 ` [PATCH v2 0/5] net/virtio: fix Rx interrupts " Isaac Boukris 2026-11-17 21:59 ` [PATCH v2 1/5] net/virtio: fix Rx interrupt setup " Isaac Boukris 2026-11-17 21:59 ` [PATCH v2 2/5] test/virtio_user: add unit test of Rx interrupts Isaac Boukris 2026-11-17 21:59 ` [PATCH v2 3/5] app/testpmd: add Rx queue interrupts option Isaac Boukris 2026-11-17 22:00 ` [PATCH v2 4/5] dts: support virtio PCI ports Isaac Boukris 2026-11-17 22:00 ` [PATCH v2 5/5] dts: add Rx interrupt test suite Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 0/7] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 1/7] net/virtio: fix Rx interrupt setup " Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 2/7] net/virtio-user: fix packet loss with unused queue pairs Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 3/7] test/virtio_user: add unit test of " Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 4/7] test/virtio_user: add unit test of Rx interrupts Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 5/7] app/testpmd: add Rx queue interrupts option Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 6/7] dts: support virtio PCI ports Isaac Boukris 2026-11-18 0:19 ` [PATCH v3 7/7] dts: add Rx interrupt test suite Isaac Boukris
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox