From: Isaac Boukris <iboukris@gmail.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>,
Chenbo Xia <chenbox@nvidia.com>
Cc: dev@dpdk.org, David Marchand <david.marchand@redhat.com>,
Aman Singh <aman.deep.singh@intel.com>,
Luca Vizzarro <luca.vizzarro@arm.com>,
Patrick Robb <patrickrobb1997@gmail.com>,
Isaac Boukris <iboukris@gmail.com>
Subject: [PATCH v4 5/8] test/virtio_user: add unit test of Rx interrupts
Date: Wed, 18 Nov 2026 10:27:49 +0200 [thread overview]
Message-ID: <20261118082752.1043794-6-iboukris@gmail.com> (raw)
In-Reply-To: <20261118082752.1043794-1-iboukris@gmail.com>
Configure the port with Rx interrupts and an Rx offload, enable the
interrupt of the Rx queue, send a frame from the kernel and sleep on
the interrupt. The frame must end the sleep. Do the same after a
second configure.
The port has two queue pairs and one Rx queue, so it has more
interrupt eventfds than Rx queues. They are the backend's call fds.
If the driver releases them when it initializes the device again,
the test fails.
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
---
v4: ask for the Rx offload without checking the capability first. Shorter comments.
v3: on top of the previous patch. The test frame is now an IPv4 one.
app/test/test_pmd_virtio_user.c | 63 +++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/app/test/test_pmd_virtio_user.c b/app/test/test_pmd_virtio_user.c
index c47d5a833b..f70f0c3d7f 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>
@@ -174,6 +175,67 @@ 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 {
+ /* From here on a frame raises the interrupt, 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;
+}
+
+/*
+ * Configure with Rx interrupts and an offload, which initializes the device
+ * twice, then configure again. The port has more interrupt eventfds than Rx
+ * queues. They are the backend's, so the driver must not release them.
+ */
+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,
+ };
+ int round;
+
+ 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)
{
@@ -249,6 +311,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
next prev parent reply other threads:[~2026-11-18 8:28 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
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
2026-11-18 8:27 ` [PATCH v4 0/8] net/virtio: fix Rx interrupts with MSI-X Isaac Boukris
2026-11-18 8:27 ` [PATCH v4 1/8] net/virtio: fix Rx interrupt setup " Isaac Boukris
2026-11-18 8:27 ` [PATCH v4 2/8] net/virtio-user: fix packet loss with unused queue pairs Isaac Boukris
2026-11-18 8:27 ` [PATCH v4 3/8] net/virtio-user: fix unaligned reads of control commands Isaac Boukris
2026-11-18 8:27 ` [PATCH v4 4/8] test/virtio_user: add unit test of unused queue pairs Isaac Boukris
2026-11-18 8:27 ` Isaac Boukris [this message]
2026-11-18 8:27 ` [PATCH v4 6/8] app/testpmd: add Rx queue interrupts option Isaac Boukris
2026-11-18 8:27 ` [PATCH v4 7/8] dts: support virtio PCI ports Isaac Boukris
2026-11-18 8:27 ` [PATCH v4 8/8] dts: add Rx interrupt test suite Isaac Boukris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118082752.1043794-6-iboukris@gmail.com \
--to=iboukris@gmail.com \
--cc=aman.deep.singh@intel.com \
--cc=chenbox@nvidia.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=luca.vizzarro@arm.com \
--cc=maxime.coquelin@redhat.com \
--cc=patrickrobb1997@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.