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 v3 4/7] test/virtio_user: add unit test of Rx interrupts
Date: Wed, 18 Nov 2026 02:19:15 +0200 [thread overview]
Message-ID: <20261118001918.990884-5-iboukris@gmail.com> (raw)
In-Reply-To: <20261118001918.990884-1-iboukris@gmail.com>
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
next prev parent reply other threads:[~2026-11-18 0:20 UTC|newest]
Thread overview: 18+ 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 ` Isaac Boukris [this message]
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
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=20261118001918.990884-5-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.