DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
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 v2 3/5] app/testpmd: add Rx queue interrupts option
Date: Tue, 17 Nov 2026 23:59:59 +0200	[thread overview]
Message-ID: <20261117220001.965310-4-iboukris@gmail.com> (raw)
In-Reply-To: <20261117220001.965310-1-iboukris@gmail.com>

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


  parent reply	other threads:[~2026-11-17 22:00 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   ` Isaac Boukris [this message]
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

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=20261117220001.965310-4-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox