All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC v1] net/af_packet: add io_uring TX acceleration
@ 2026-02-04 16:12 scott.k.mitch1
  2026-02-04 16:52 ` Stephen Hemminger
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: scott.k.mitch1 @ 2026-02-04 16:12 UTC (permalink / raw)
  To: dev; +Cc: Scott

From: Scott <scott.k.mitch1@gmail.com>

When user space application does sendto() to notify the kernel
there is data to process, the kernel synchronously processes
pending frames and the CPU cost is attributed to the application.
The kernel processing may also include kernel RX (netlink, ovs)
and packet manipulation. This can negatively impact performance
by limiting CPU to each dpdk network thread.

io_uring offers a mode (SQPOLL) to offload this processing
to a dedicated kernel thread. This makes the kernel processing
asynchronous, which can improve throughput by 30%+. The trade-off
is SQPOLL threads consume additional CPU but this follows the
same principle as virtio backends, and enables use cases that
can't adopt virtio (e.g. containerized workloads).

This patch adds optional io_uring support for TX kick operations
to replace synchronous sendto() syscalls. When enabled, uses
SQPOLL mode with kernel-side submission polling for reduced
syscall overhead.

Features:
- Optional liburing dependency (version >= 2.4 required)
- SQPOLL mode with configurable idle timeout
- CPU affinity for SQPOLL threads (IORING_SETUP_SQ_AFF)
- Shared workqueue support (IORING_SETUP_ATTACH_WQ)
- Registered file descriptors for IOSQE_FIXED_FILE optimization
- Single issuer and cooperative taskrun optimizations when available

New devargs:
- tx_io_uring_enabled: Enable io_uring TX (default: 0)
- tx_io_uring_sq_size: Submission queue size (default: 1024)
- tx_io_uring_sq_thread_idle: SQPOLL idle timeout in ms (default: 500)
- tx_io_uring_q_cpu: CPU affinity for SQPOLL threads (repeatable)
- tx_io_uring_wq_num: Number of shared workqueues (default: 0)

The TX path updates the ring tail pointer directly instead of calling
io_uring_submit() to avoid the io_uring_enter syscall, relying on
SQPOLL to pick up submissions. If the SQPOLL thread sleeps, we wake
it with IORING_ENTER_SQ_WAKEUP.

Falls back gracefully to sendto() when:
- liburing is not available at compile time
- SQPOLL is not supported by the kernel
- io_uring initialization fails for any reason

Signed-off-by: Scott <scott.k.mitch1@gmail.com>
---
Depends-on: series-37248 ("af_packet correctness, performance, cksum")

 doc/guides/nics/af_packet.rst             |  16 +-
 doc/guides/rel_notes/release_26_03.rst    |   1 +
 drivers/net/af_packet/meson.build         |  14 +
 drivers/net/af_packet/rte_eth_af_packet.c | 420 +++++++++++++++++++++-
 4 files changed, 435 insertions(+), 16 deletions(-)

diff --git a/doc/guides/nics/af_packet.rst b/doc/guides/nics/af_packet.rst
index 782a962c3f..b9f4ad9f69 100644
--- a/doc/guides/nics/af_packet.rst
+++ b/doc/guides/nics/af_packet.rst
@@ -33,6 +33,20 @@ Some of these, in turn, will be used to configure the PACKET_MMAP settings.
     space available to write to the kernel. If 1, call poll() and block until
     space is available to tx. If 0, don't call poll() and return from tx (optional,
     default 1).
+*   ``tx_io_uring_enabled`` - Use io_uring to notify the kernel on tx (optional,
+    default 0)
+*   ``tx_io_uring_sq_size`` - Number of entries for the io_uring ring (optional,
+    default 1024)
+*   ``tx_io_uring_sq_thread_idle`` - Idle time (in milliseconds) before an io_uring
+    SQPOLL thread goes to sleep (optional, default 500)
+*   ``tx_io_uring_q_cpu`` - This argument can be repeated to specify CPU core
+    affinity for each queue's io_uring SQPOLL kernel thread (see
+    ``io_uring_params.sq_thread_cpu``). The first value applies to queue 0,
+    the second to queue 1, etc. (optional, default empty)
+*   ``tx_io_uring_wq_num`` - Number of SQPOLL kernel threads. On kernels with
+    ``IORING_SETUP_ATTACH_WQ`` support, setting this lower than the queue count
+    enables thread sharing across queues. If 0 or unspecified, no sharing is configured
+    and each queue creates its own SQPOLL thread (optional, default 0)
 
 For details regarding ``fanout_mode`` argument, you can consult the
 `PACKET_FANOUT documentation <https://www.man7.org/linux/man-pages/man7/packet.7.html>`_.
@@ -79,7 +93,7 @@ framecnt=512):
 
 .. code-block:: console
 
-    --vdev=eth_af_packet0,iface=tap0,blocksz=4096,framesz=2048,framecnt=512,qpairs=1,qdisc_bypass=0,fanout_mode=hash,txpollnotrdy=0
+    --vdev=eth_af_packet0,iface=tap0,blocksz=4096,framesz=2048,framecnt=512,qpairs=1,qdisc_bypass=0,fanout_mode=hash,txpollnotrdy=0,tx_io_uring_enabled=1
 
 Features and Limitations
 ------------------------
diff --git a/doc/guides/rel_notes/release_26_03.rst b/doc/guides/rel_notes/release_26_03.rst
index 5abdd7cbb2..87081e8b98 100644
--- a/doc/guides/rel_notes/release_26_03.rst
+++ b/doc/guides/rel_notes/release_26_03.rst
@@ -62,6 +62,7 @@ New Features
   * Added ``txpollnotrdy`` devarg to avoid ``poll()`` blocking calls
   * Added checksum offload support for ``IPV4_CKSUM``, ``UDP_CKSUM``,
     and ``TCP_CKSUM``
+  * Added io_uring to notify the kernel on tx
 
 * **Updated AMD axgbe ethernet driver.**
 
diff --git a/drivers/net/af_packet/meson.build b/drivers/net/af_packet/meson.build
index f45e4491d4..a672262656 100644
--- a/drivers/net/af_packet/meson.build
+++ b/drivers/net/af_packet/meson.build
@@ -5,5 +5,19 @@ if not is_linux
     build = false
     reason = 'only supported on Linux'
 endif
+
+deps += ['ethdev']
+
+liburing_dep = dependency('liburing', required: false)
+if not liburing_dep.found()
+    message('AF_PACKET PMD: liburing not found, fallback to sendto()')
+elif not liburing_dep.version().version_compare('>=2.4')
+    message('AF_PACKET PMD: liburing version too old, need >= 2.4. fallback to sendto()')
+else
+    ext_deps += liburing_dep
+    cflags += '-DRTE_NET_AF_PACKET_HAVE_LIBURING'
+    message('AF_PACKET PMD: liburing @0@ support enabled'.format(liburing_dep.version()))
+endif
+
 sources = files('rte_eth_af_packet.c')
 require_iova_in_mbuf = false
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 1c5f17af34..5b94a513f4 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -19,6 +19,10 @@
 #include <rte_kvargs.h>
 #include <bus_vdev_driver.h>
 
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+#include <liburing.h>
+#endif
+
 #include <errno.h>
 #include <linux/if_ether.h>
 #include <linux/if_packet.h>
@@ -42,10 +46,21 @@
 #define ETH_AF_PACKET_QDISC_BYPASS_ARG	"qdisc_bypass"
 #define ETH_AF_PACKET_FANOUT_MODE_ARG	"fanout_mode"
 #define ETH_AF_PACKET_TX_POLL_NOT_READY_ARG	"txpollnotrdy"
+#define ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG	"tx_io_uring_enabled"
+#define ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG	"tx_io_uring_sq_size"
+#define ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG	"tx_io_uring_sq_thread_idle"
+#define ETH_AF_PACKET_TX_IO_URING_Q_CPU	"tx_io_uring_q_cpu"
+#define ETH_AF_PACKET_TX_IO_URING_WQ_NUM	"tx_io_uring_wq_num"
 
 #define DFLT_FRAME_SIZE		(1 << 11)
 #define DFLT_FRAME_COUNT	(1 << 9)
 #define DFLT_TX_POLL_NOT_RDY	true
+#define DFLT_TX_IO_URING_ENABLED	false
+#define DFLT_TX_IO_URING_SQ_SIZE	1024
+#define DFLT_TX_IO_URING_SQ_THREAD_IDLE_MS	500
+
+/* io_uring registered file descriptor index for the socket fd */
+#define ETH_AF_PACKET_URING_SOCKFD_INDEX	0
 
 static const uint16_t eth_af_packet_frame_size_max = RTE_IPV4_MAX_PKT_LEN;
 #define ETH_AF_PACKET_FRAME_OVERHEAD (TPACKET2_HDRLEN - sizeof(struct sockaddr_ll))
@@ -82,6 +97,12 @@ struct __rte_cache_aligned pkt_tx_queue {
 	unsigned int framecount;
 	unsigned int framenum;
 
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+	struct io_uring uring_ring;
+	bool uring_enabled;
+	uint32_t uring_sqe_since_cq_advance;
+#endif
+
 	bool txpollnotrdy;
 	bool sw_cksum;
 
@@ -104,6 +125,11 @@ struct pmd_internals {
 	uint8_t vlan_strip;
 	uint8_t timestamp_offloading;
 	bool tx_sw_cksum;
+
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+	struct io_uring **shared_uring_rings;
+	uint32_t shared_uring_count;
+#endif
 };
 
 static const char *valid_arguments[] = {
@@ -115,6 +141,11 @@ static const char *valid_arguments[] = {
 	ETH_AF_PACKET_QDISC_BYPASS_ARG,
 	ETH_AF_PACKET_FANOUT_MODE_ARG,
 	ETH_AF_PACKET_TX_POLL_NOT_READY_ARG,
+	ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG,
+	ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG,
+	ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG,
+	ETH_AF_PACKET_TX_IO_URING_Q_CPU,
+	ETH_AF_PACKET_TX_IO_URING_WQ_NUM,
 	NULL
 };
 
@@ -157,6 +188,195 @@ tpacket_write_status(volatile void *tp_status, uint32_t status)
 	rte_smp_wmb();
 }
 
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+static bool
+af_packet_io_uring_supports(const uint32_t flags)
+{
+	struct io_uring_params p = {
+		.flags = flags
+	};
+	const int ring_fd = io_uring_setup(1, &p);
+	if (ring_fd < 0)
+		return false;
+	close(ring_fd);
+	return true;
+}
+#endif /* RTE_NET_AF_PACKET_HAVE_LIBURING */
+
+static void
+af_packet_io_uring_share_uring_init(struct pmd_internals *internals,
+				const unsigned int numa_node,
+				const unsigned int nb_queues,
+				const bool tx_io_uring_enabled,
+				const uint32_t tx_io_uring_kq_cores_size,
+				const uint32_t tx_io_uring_wq_num)
+{
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+	if (!tx_io_uring_enabled)
+		return;
+
+	if (!af_packet_io_uring_supports(IORING_SETUP_SQPOLL)) {
+		PMD_LOG(NOTICE, "AF_PACKET PMD io_uring IORING_SETUP_SQPOLL not supported");
+		return;
+	}
+
+	if (tx_io_uring_wq_num <= 0)
+		return;
+
+	/* Allocate shared io_uring rings if ATTACH_WQ mode will be used */
+	if (!af_packet_io_uring_supports(IORING_SETUP_ATTACH_WQ | IORING_SETUP_SQPOLL)) {
+		PMD_LOG(WARNING, "AF_PACKET PMD IORING_SETUP_ATTACH_WQ not supported, "
+			"%s=%" PRIu32 " will be ignored", ETH_AF_PACKET_TX_IO_URING_WQ_NUM,
+			tx_io_uring_wq_num);
+	} else {
+		internals->shared_uring_rings =
+			rte_calloc_socket("af_packet_shared_uring", tx_io_uring_wq_num,
+				sizeof(*internals->shared_uring_rings), 0, numa_node);
+		if (!internals->shared_uring_rings) {
+			PMD_LOG(ERR, "Failed to allocate shared io_uring rings");
+			return;
+		}
+		internals->shared_uring_count = tx_io_uring_wq_num;
+
+		if (tx_io_uring_kq_cores_size > tx_io_uring_wq_num) {
+			PMD_LOG(WARNING,
+				"AF_PACKET PMD %s count=%" PRIu32 " > %s=%" PRIu32 ", "
+				"extra CPU affinities will be ignored",
+				ETH_AF_PACKET_TX_IO_URING_Q_CPU, tx_io_uring_kq_cores_size,
+				ETH_AF_PACKET_TX_IO_URING_WQ_NUM, tx_io_uring_wq_num);
+		}
+
+		if (nb_queues % tx_io_uring_wq_num != 0) {
+			PMD_LOG(INFO,
+				"AF_PACKET PMD %s=%u not divisible by %s=%" PRIu32 ", "
+				"SQPOLL thread work may be imbalanced",
+				ETH_AF_PACKET_NUM_Q_ARG, nb_queues,
+				ETH_AF_PACKET_TX_IO_URING_WQ_NUM, tx_io_uring_wq_num);
+		}
+	}
+#else
+	if (tx_io_uring_enabled) {
+		PMD_LOG(NOTICE,
+			"AF_PACKET PMD %s enabled, but feature not enabled at compile time.",
+			ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG);
+	}
+	RTE_SET_USED(internals);
+	RTE_SET_USED(numa_node);
+	RTE_SET_USED(nb_queues);
+	RTE_SET_USED(tx_io_uring_kq_cores_size);
+	RTE_SET_USED(tx_io_uring_wq_num);
+#endif /* RTE_NET_AF_PACKET_HAVE_LIBURING */
+}
+
+static void
+af_packet_io_uring_tx_queue_init(struct pmd_internals *internals,
+				const unsigned int q,
+				const bool tx_io_uring_enabled,
+				const uint32_t tx_io_uring_sq_size,
+				const uint32_t tx_io_uring_sq_thread_idle_ms,
+				const uint32_t *tx_io_uring_kq_cores,
+				const uint32_t tx_io_uring_kq_cores_size)
+{
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+	if (!tx_io_uring_enabled || !af_packet_io_uring_supports(IORING_SETUP_SQPOLL))
+		return;
+
+	int rc;
+	struct pkt_tx_queue *tx_queue = &internals->tx_queue[q];
+	struct io_uring_params uring_params = {
+		.sq_thread_idle = tx_io_uring_sq_thread_idle_ms,
+		.flags = IORING_SETUP_SQPOLL,
+	};
+
+	/* Determine if attaching to existing ring or creating new one */
+	uint32_t ring_idx = internals->shared_uring_rings ? q % internals->shared_uring_count : 0;
+	bool attach_mode = internals->shared_uring_rings && ring_idx < q &&
+			internals->shared_uring_rings[ring_idx];
+
+	if (attach_mode) {
+		/* Attach to existing ring queue, IORING_SETUP_ATTACH_WQ support already checked.
+		 * Each io_uring_queue_init_params initializes independent memory. Life cycle
+		 * management is still per-queue, and wq_fd shares the SQPOLL thread.
+		 */
+		uring_params.flags |= IORING_SETUP_ATTACH_WQ;
+		uring_params.wq_fd = internals->shared_uring_rings[ring_idx]->ring_fd;
+	} else {
+		/* Create new ring: add CPU affinity if configured */
+		if (tx_io_uring_kq_cores_size > 0) {
+			uint32_t cpu_idx = internals->shared_uring_rings ? ring_idx : q;
+			if (cpu_idx < tx_io_uring_kq_cores_size) {
+				if (af_packet_io_uring_supports(uring_params.flags |
+						IORING_SETUP_SQ_AFF)) {
+					uring_params.flags |= IORING_SETUP_SQ_AFF;
+					uring_params.sq_thread_cpu = tx_io_uring_kq_cores[cpu_idx];
+				} else if (q == 0) {
+					PMD_LOG(INFO,
+						"AF_PACKET PMD IORING_SETUP_SQ_AFF not supported, "
+						"SQPOLL CPU pinning disabled");
+				}
+			} else {
+				PMD_LOG(DEBUG,
+					"AF_PACKET PMD io_uring tx_queue=%u > %s size=%" PRIu32 " "
+					"and will not be CPU pinned", q,
+					ETH_AF_PACKET_TX_IO_URING_Q_CPU,
+					tx_io_uring_kq_cores_size);
+			}
+		}
+
+		/* Add optional optimizations for new rings */
+		if (af_packet_io_uring_supports(uring_params.flags | IORING_SETUP_SINGLE_ISSUER))
+			uring_params.flags |= IORING_SETUP_SINGLE_ISSUER;
+		else if (q == 0)
+			PMD_LOG(DEBUG, "AF_PACKET PMD IORING_SETUP_SINGLE_ISSUER not supported");
+
+		if (af_packet_io_uring_supports(uring_params.flags | IORING_SETUP_COOP_TASKRUN))
+			uring_params.flags |= IORING_SETUP_COOP_TASKRUN;
+		else if (q == 0)
+			PMD_LOG(DEBUG, "AF_PACKET PMD IORING_SETUP_COOP_TASKRUN not supported");
+	}
+
+	rc = io_uring_queue_init_params(tx_io_uring_sq_size, &tx_queue->uring_ring,
+			&uring_params);
+	if (rc < 0) {
+		PMD_LOG(WARNING, "AF_PACKET PMD Failed io_uring_queue_init_params (error %d: %s), "
+			"tx_queue=%u sq_size=%" PRIu32 " flags=0x%X sq_thread_cpu=%u "
+			"sq_thread_idle=%u, falling back to synchronous sendto()",
+			-rc, strerror(-rc), q, tx_io_uring_sq_size, uring_params.flags,
+			uring_params.sq_thread_cpu, uring_params.sq_thread_idle);
+		return;
+	}
+
+	/* Register the sockfd at index ETH_AF_PACKET_URING_SOCKFD_INDEX */
+	rc = io_uring_register_files(&tx_queue->uring_ring, &tx_queue->sockfd, 1);
+	if (rc < 0) {
+		PMD_LOG(WARNING, "AF_PACKET PMD Failed io_uring_register_files (error %d: %s)",
+				-rc, strerror(-rc));
+		io_uring_queue_exit(&tx_queue->uring_ring);
+		return;
+	}
+
+	tx_queue->uring_enabled = true;
+	tx_queue->uring_sqe_since_cq_advance = 0;
+
+	if (!attach_mode && internals->shared_uring_rings)
+		internals->shared_uring_rings[ring_idx] = &tx_queue->uring_ring;
+
+	PMD_LOG(DEBUG, "AF_PACKET PMD io_uring SQPOLL%s enabled tx_queue=%u ring_idx=%u "
+		"tx_io_uring_sq_size=%" PRIu32 " kthread_cpu=%u sq_thread_idle=%u flags=0x%X",
+		attach_mode ? "+ATTACH_WQ" : "", q, ring_idx, tx_io_uring_sq_size,
+		uring_params.sq_thread_cpu, uring_params.sq_thread_idle, uring_params.flags);
+
+#else
+	RTE_SET_USED(internals);
+	RTE_SET_USED(q);
+	RTE_SET_USED(tx_io_uring_enabled);
+	RTE_SET_USED(tx_io_uring_sq_size);
+	RTE_SET_USED(tx_io_uring_sq_thread_idle_ms);
+	RTE_SET_USED(tx_io_uring_kq_cores);
+	RTE_SET_USED(tx_io_uring_kq_cores_size);
+#endif /* RTE_NET_AF_PACKET_HAVE_LIBURING */
+}
+
 static uint16_t
 eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
@@ -251,6 +471,71 @@ tx_ring_status_available(uint32_t tp_status)
 	return tp_status == TP_STATUS_AVAILABLE;
 }
 
+/*
+ * Kick the kernel to transmit packets in the ring.
+ *
+ * The sendto() call with NULL buffer is a notification to the kernel that
+ * frames have been queued (marked TP_STATUS_SEND_REQUEST) in the ring.
+ * The kernel will eventually process all queued frames regardless of whether
+ * this kick succeeds or fails. We don't check for errors because:
+ *
+ * 1. Data is already in the ring - the PMD's work is complete
+ * 2. ENOBUFS/EAGAIN just mean "try again later" - kernel will still process ring
+ * 3. Fatal errors (EBADF) indicate socket is broken - subsequent ops will fail
+ * 4. Consistent with io_uring path which doesn't check completion status
+ */
+static inline void
+eth_af_packet_tx_kick(struct pkt_tx_queue *pkt_q)
+{
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+	if (pkt_q->uring_enabled) {
+		/* Batch CQ advancement: only advance every sq_size submissions to amortize
+		 * memory barrier cost (2 load_acquire + 1 store_release). With
+		 * IOSQE_CQE_SKIP_SUCCESS, CQ is mostly empty (successes don't generate CQEs).
+		 * This prevents rare failure CQEs from accumulating while minimizing overhead.
+		 */
+		if (++pkt_q->uring_sqe_since_cq_advance >= pkt_q->uring_ring.sq.ring_entries) {
+			io_uring_cq_advance(&pkt_q->uring_ring,
+					io_uring_cq_ready(&pkt_q->uring_ring));
+			pkt_q->uring_sqe_since_cq_advance = 0;
+		}
+
+		struct io_uring_sqe *sqe = io_uring_get_sqe(&pkt_q->uring_ring);
+		/* If no sqe available skip this notification and wait for kernel to catch up.
+		 * Avoid fall back sendto() so we don't block the application thread and it is
+		 * highly likely the kernel will process pending events and/or subsequent TX
+		 * will generate new notification.
+		 */
+		if (unlikely(sqe == NULL))
+			return;
+
+		/* Use registered fd (see io_uring_register_files call during setup) */
+		io_uring_prep_send(sqe, ETH_AF_PACKET_URING_SOCKFD_INDEX, NULL, 0, MSG_DONTWAIT);
+		io_uring_sqe_set_flags(sqe, IOSQE_FIXED_FILE | IOSQE_CQE_SKIP_SUCCESS);
+		io_uring_sqe_set_data(sqe, NULL);
+
+		/* io_uring_submit does a io_uring_enter syscall,
+		 * update tail pointer directly instead.
+		 */
+		io_uring_smp_store_release(pkt_q->uring_ring.sq.ktail,
+				pkt_q->uring_ring.sq.sqe_tail);
+
+		/* io_uring in sqpoll mode the kthread will sleep after sq_thread_idle
+		 * ms idle time. Check if we need to force wake up to avoid waiting
+		 * unknown time.
+		 */
+		if (unlikely(IO_URING_READ_ONCE(*pkt_q->uring_ring.sq.kflags) &
+				IORING_SQ_NEED_WAKEUP))
+			io_uring_enter(pkt_q->uring_ring.ring_fd, 0, 0, IORING_ENTER_SQ_WAKEUP,
+					NULL);
+	} else {
+		sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0);
+	}
+#else
+	sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0);
+#endif
+}
+
 /*
  * Callback to handle sending packets through a real NIC.
  */
@@ -342,19 +627,8 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 	rte_pktmbuf_free_bulk(&bufs[0], i);
 
-	/* kick-off transmits */
-	if (unlikely(num_tx > 0 &&
-		     sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1 &&
-		     errno != ENOBUFS && errno != EAGAIN)) {
-		/*
-		 * In case of a ENOBUFS/EAGAIN error all of the enqueued
-		 * packets will be considered successful even though only some
-		 * are sent.
-		 */
-
-		num_tx = 0;
-		num_tx_bytes = 0;
-	}
+	if (likely(num_tx > 0))
+		eth_af_packet_tx_kick(pkt_q);
 
 	pkt_q->framenum = framenum;
 	pkt_q->tx_pkts += num_tx;
@@ -560,11 +834,22 @@ eth_dev_close(struct rte_eth_dev *dev)
 		internals->rx_queue[q].sockfd = -1;
 		internals->tx_queue[q].sockfd = -1;
 
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+		if (internals->tx_queue[q].uring_enabled) {
+			io_uring_unregister_files(&internals->tx_queue[q].uring_ring);
+			io_uring_queue_exit(&internals->tx_queue[q].uring_ring);
+			internals->tx_queue[q].uring_enabled = false;
+		}
+#endif
+
 		munmap(internals->rx_queue[q].map,
 			2 * req->tp_block_size * req->tp_block_nr);
 		rte_free(internals->rx_queue[q].rd);
 		rte_free(internals->tx_queue[q].rd);
 	}
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+	rte_free(internals->shared_uring_rings);
+#endif
 	rte_free(internals->if_name);
 	rte_free(internals->rx_queue);
 	rte_free(internals->tx_queue);
@@ -826,7 +1111,7 @@ get_fanout(const char *fanout_mode, int if_index)
 static int
 rte_pmd_init_internals(struct rte_vdev_device *dev,
                        const int sockfd,
-                       const unsigned nb_queues,
+			const unsigned int nb_queues,
                        unsigned int blocksize,
                        unsigned int blockcnt,
                        unsigned int framesize,
@@ -834,6 +1119,12 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 		       unsigned int qdisc_bypass,
 		       const char *fanout_mode,
 			bool txpollnotrdy,
+			bool tx_io_uring_enabled,
+			uint32_t tx_io_uring_sq_size,
+			uint32_t tx_io_uring_sq_thread_idle_ms,
+			uint32_t *tx_io_uring_kq_cores,
+			uint32_t tx_io_uring_kq_cores_size,
+			uint32_t tx_io_uring_wq_num,
                        struct pmd_internals **internals,
                        struct rte_eth_dev **eth_dev,
                        struct rte_kvargs *kvlist)
@@ -939,6 +1230,9 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 		goto error;
 	}
 
+	af_packet_io_uring_share_uring_init(*internals, numa_node, nb_queues,
+			tx_io_uring_enabled, tx_io_uring_kq_cores_size, tx_io_uring_wq_num);
+
 	for (q = 0; q < nb_queues; q++) {
 		/* Open an AF_PACKET socket for this queue... */
 		qsockfd = socket(AF_PACKET, SOCK_RAW, 0);
@@ -1073,6 +1367,10 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 				goto error;
 			}
 		}
+
+		af_packet_io_uring_tx_queue_init(*internals, q, tx_io_uring_enabled,
+			tx_io_uring_sq_size, tx_io_uring_sq_thread_idle_ms, tx_io_uring_kq_cores,
+			tx_io_uring_kq_cores_size);
 	}
 
 	/* reserve an ethdev entry */
@@ -1106,6 +1404,13 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 	if (qsockfd != -1)
 		close(qsockfd);
 	for (q = 0; q < nb_queues; q++) {
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+		if ((*internals)->tx_queue[q].uring_enabled) {
+			io_uring_unregister_files(&(*internals)->tx_queue[q].uring_ring);
+			io_uring_queue_exit(&(*internals)->tx_queue[q].uring_ring);
+			(*internals)->tx_queue[q].uring_enabled = false;
+		}
+#endif
 		if ((*internals)->rx_queue[q].map != MAP_FAILED)
 			munmap((*internals)->rx_queue[q].map,
 			       2 * req->tp_block_size * req->tp_block_nr);
@@ -1117,6 +1422,9 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 			close((*internals)->rx_queue[q].sockfd);
 	}
 free_internals:
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+	rte_free((*internals)->shared_uring_rings);
+#endif
 	rte_free((*internals)->rx_queue);
 	rte_free((*internals)->tx_queue);
 	rte_free((*internals)->if_name);
@@ -1143,6 +1451,12 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
 	unsigned int qdisc_bypass = 1;
 	const char *fanout_mode = NULL;
 	bool txpollnotrdy = DFLT_TX_POLL_NOT_RDY;
+	bool tx_io_uring_enabled = DFLT_TX_IO_URING_ENABLED;
+	uint32_t tx_io_uring_sq_size = DFLT_TX_IO_URING_SQ_SIZE;
+	uint32_t tx_io_uring_sq_thread_idle_ms = DFLT_TX_IO_URING_SQ_THREAD_IDLE_MS;
+	uint32_t tx_io_uring_kq_cores[RTE_MAX_QUEUES_PER_PORT] = {};
+	uint32_t tx_io_uring_kq_cores_size = 0;
+	uint32_t tx_io_uring_wq_num = 0;
 
 	/* do some parameter checking */
 	if (*sockfd < 0)
@@ -1211,6 +1525,61 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
 			txpollnotrdy = atoi(pair->value) != 0;
 			continue;
 		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG) != NULL) {
+			tx_io_uring_enabled = atoi(pair->value) != 0;
+			continue;
+		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG) != NULL) {
+			int tx_io_uring_sq_size_value = atoi(pair->value);
+			if (tx_io_uring_sq_size_value > 0) {
+				tx_io_uring_sq_size = tx_io_uring_sq_size_value;
+			} else {
+				PMD_LOG(ERR, "%s: invalid %s %d (must >0)", name,
+					ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG,
+					tx_io_uring_sq_size_value);
+				return -1;
+			}
+			continue;
+		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG) != NULL) {
+			int tx_io_uring_sq_thread_idle_value = atoi(pair->value);
+			if (tx_io_uring_sq_thread_idle_value >= 0) {
+				tx_io_uring_sq_thread_idle_ms = tx_io_uring_sq_thread_idle_value;
+			} else {
+				PMD_LOG(ERR, "%s: invalid %s %d (must >=0)", name,
+						ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG,
+						tx_io_uring_sq_thread_idle_value);
+				return -1;
+			}
+			continue;
+		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_Q_CPU) != NULL) {
+			char *end;
+			errno = 0;
+			long lvalue = strtol(pair->value, &end, 10);
+			if (*end != '\0' || errno != 0 || lvalue < 0 || lvalue > UINT32_MAX) {
+				PMD_LOG(ERR, "%s: CPU '%s' must be [0, %" PRIu32 "] for %s", name,
+					pair->value, UINT32_MAX, ETH_AF_PACKET_TX_IO_URING_Q_CPU);
+				return -1;
+			} else if (tx_io_uring_kq_cores_size >= RTE_MAX_QUEUES_PER_PORT) {
+				PMD_LOG(ERR, "%s: too many %s args, max of %d", name,
+					ETH_AF_PACKET_TX_IO_URING_Q_CPU, RTE_MAX_QUEUES_PER_PORT);
+				return -1;
+			}
+			tx_io_uring_kq_cores[tx_io_uring_kq_cores_size++] = (uint32_t)lvalue;
+			continue;
+		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_WQ_NUM) != NULL) {
+			int tx_io_uring_wq_num_value = atoi(pair->value);
+			if (tx_io_uring_wq_num_value >= 0) {
+				tx_io_uring_wq_num = (uint32_t)tx_io_uring_wq_num_value;
+			} else {
+				PMD_LOG(ERR, "%s: invalid %s %d (must >=0)", name,
+					ETH_AF_PACKET_TX_IO_URING_WQ_NUM, tx_io_uring_wq_num_value);
+				return -1;
+			}
+			continue;
+		}
 	}
 
 	if (framesize > blocksize) {
@@ -1281,12 +1650,28 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
 		PMD_LOG(DEBUG, "%s:\tfanout mode %s", name, "default PACKET_FANOUT_HASH");
 	PMD_LOG(INFO, "%s:\ttxpollnotrdy %d", name, txpollnotrdy ? 1 : 0);
 
+	PMD_LOG(INFO, "%s:\t%s %d", name,
+		ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG, tx_io_uring_enabled ? 1 : 0);
+	PMD_LOG(INFO, "%s:\t%s %" PRIu32, name,
+		ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG, tx_io_uring_sq_size);
+	PMD_LOG(INFO, "%s:\t%s %" PRIu32, name,
+		ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG, tx_io_uring_sq_thread_idle_ms);
+	for (uint32_t cpu_i = 0; cpu_i < tx_io_uring_kq_cores_size; cpu_i++) {
+		PMD_LOG(INFO, "%s:\t%s[%" PRIu32 "] %" PRIu32, name,
+			ETH_AF_PACKET_TX_IO_URING_Q_CPU, cpu_i, tx_io_uring_kq_cores[cpu_i]);
+	}
+	PMD_LOG(INFO, "%s:\t%s %" PRIu32, name,
+		ETH_AF_PACKET_TX_IO_URING_WQ_NUM, tx_io_uring_wq_num);
+
 	if (rte_pmd_init_internals(dev, *sockfd, qpairs,
 				   blocksize, blockcount,
 				   framesize, framecount,
 				   qdisc_bypass,
 				   fanout_mode,
 				   txpollnotrdy,
+				   tx_io_uring_enabled, tx_io_uring_sq_size,
+				   tx_io_uring_sq_thread_idle_ms, tx_io_uring_kq_cores,
+				   tx_io_uring_kq_cores_size, tx_io_uring_wq_num,
 				   &internals, &eth_dev,
 				   kvlist) < 0)
 		return -1;
@@ -1385,4 +1770,9 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_packet,
 	"framecnt=<int> "
 	"qdisc_bypass=<0|1> "
 	"fanout_mode=<hash|lb|cpu|rollover|rnd|qm> "
-	"txpollnotrdy=<0|1>");
+	"txpollnotrdy=<0|1> "
+	"tx_io_uring_enabled=<0|1> "
+	"tx_io_uring_sq_size=<int> "
+	"tx_io_uring_sq_thread_idle=<int> "
+	"tx_io_uring_q_cpu=<int> "
+	"tx_io_uring_wq_num=<int>");
-- 
2.39.5 (Apple Git-154)


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [RFC v1] net/af_packet: add io_uring TX acceleration
  2026-02-04 16:12 [RFC v1] net/af_packet: add io_uring TX acceleration scott.k.mitch1
@ 2026-02-04 16:52 ` Stephen Hemminger
  2026-02-05  0:08   ` Scott Mitchell
  2026-12-01 22:36 ` [RFC PATCH v2] " Scott Mitchell
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Stephen Hemminger @ 2026-02-04 16:52 UTC (permalink / raw)
  To: scott.k.mitch1; +Cc: dev

On Wed,  4 Feb 2026 08:12:02 -0800
scott.k.mitch1@gmail.com wrote:

> From: Scott <scott.k.mitch1@gmail.com>
> 
> When user space application does sendto() to notify the kernel
> there is data to process, the kernel synchronously processes
> pending frames and the CPU cost is attributed to the application.
> The kernel processing may also include kernel RX (netlink, ovs)
> and packet manipulation. This can negatively impact performance
> by limiting CPU to each dpdk network thread.
> 
> io_uring offers a mode (SQPOLL) to offload this processing
> to a dedicated kernel thread. This makes the kernel processing
> asynchronous, which can improve throughput by 30%+. The trade-off
> is SQPOLL threads consume additional CPU but this follows the
> same principle as virtio backends, and enables use cases that
> can't adopt virtio (e.g. containerized workloads).
> 
> This patch adds optional io_uring support for TX kick operations
> to replace synchronous sendto() syscalls. When enabled, uses
> SQPOLL mode with kernel-side submission polling for reduced
> syscall overhead.
> 
> Features:
> - Optional liburing dependency (version >= 2.4 required)
> - SQPOLL mode with configurable idle timeout
> - CPU affinity for SQPOLL threads (IORING_SETUP_SQ_AFF)
> - Shared workqueue support (IORING_SETUP_ATTACH_WQ)
> - Registered file descriptors for IOSQE_FIXED_FILE optimization
> - Single issuer and cooperative taskrun optimizations when available
> 
> New devargs:
> - tx_io_uring_enabled: Enable io_uring TX (default: 0)
> - tx_io_uring_sq_size: Submission queue size (default: 1024)
> - tx_io_uring_sq_thread_idle: SQPOLL idle timeout in ms (default: 500)
> - tx_io_uring_q_cpu: CPU affinity for SQPOLL threads (repeatable)
> - tx_io_uring_wq_num: Number of shared workqueues (default: 0)
> 
> The TX path updates the ring tail pointer directly instead of calling
> io_uring_submit() to avoid the io_uring_enter syscall, relying on
> SQPOLL to pick up submissions. If the SQPOLL thread sleeps, we wake
> it with IORING_ENTER_SQ_WAKEUP.
> 
> Falls back gracefully to sendto() when:
> - liburing is not available at compile time
> - SQPOLL is not supported by the kernel
> - io_uring initialization fails for any reason
> 
> Signed-off-by: Scott <scott.k.mitch1@gmail.com>
> ---
> Depends-on: series-37248 ("af_packet correctness, performance, cksum")
> 
>  doc/guides/nics/af_packet.rst             |  16 +-
>  doc/guides/rel_notes/release_26_03.rst    |   1 +
>  drivers/net/af_packet/meson.build         |  14 +
>  drivers/net/af_packet/rte_eth_af_packet.c | 420 +++++++++++++++++++++-
>  4 files changed, 435 insertions(+), 16 deletions(-)
> 
> diff --git a/doc/guides/nics/af_packet.rst b/doc/guides/nics/af_pac

I would rather it be a different driver than af_packet.
See my RFC patch for using io_uring 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC v1] net/af_packet: add io_uring TX acceleration
  2026-02-04 16:52 ` Stephen Hemminger
@ 2026-02-05  0:08   ` Scott Mitchell
  0 siblings, 0 replies; 15+ messages in thread
From: Scott Mitchell @ 2026-02-05  0:08 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

Can you send a link to the RFC patch? I found a discussion thread
https://mails.dpdk.org/archives/dev/2024-November/307925.html but some
of the discussion in this thread (use of epoll, independent FDs per Rx
and Tx, etc.) don't apply to af_packet which doesn't use system calls
on the data path, but only the sendto() notify on TX. Seems reasonable
that TAP could benefit from io_uring but not clear that needs to be
mutually exclusive to af_packet. Can you clarify?

On Wed, Feb 4, 2026 at 8:52 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Wed,  4 Feb 2026 08:12:02 -0800
> scott.k.mitch1@gmail.com wrote:
>
> > From: Scott <scott.k.mitch1@gmail.com>
> >
> > When user space application does sendto() to notify the kernel
> > there is data to process, the kernel synchronously processes
> > pending frames and the CPU cost is attributed to the application.
> > The kernel processing may also include kernel RX (netlink, ovs)
> > and packet manipulation. This can negatively impact performance
> > by limiting CPU to each dpdk network thread.
> >
> > io_uring offers a mode (SQPOLL) to offload this processing
> > to a dedicated kernel thread. This makes the kernel processing
> > asynchronous, which can improve throughput by 30%+. The trade-off
> > is SQPOLL threads consume additional CPU but this follows the
> > same principle as virtio backends, and enables use cases that
> > can't adopt virtio (e.g. containerized workloads).
> >
> > This patch adds optional io_uring support for TX kick operations
> > to replace synchronous sendto() syscalls. When enabled, uses
> > SQPOLL mode with kernel-side submission polling for reduced
> > syscall overhead.
> >
> > Features:
> > - Optional liburing dependency (version >= 2.4 required)
> > - SQPOLL mode with configurable idle timeout
> > - CPU affinity for SQPOLL threads (IORING_SETUP_SQ_AFF)
> > - Shared workqueue support (IORING_SETUP_ATTACH_WQ)
> > - Registered file descriptors for IOSQE_FIXED_FILE optimization
> > - Single issuer and cooperative taskrun optimizations when available
> >
> > New devargs:
> > - tx_io_uring_enabled: Enable io_uring TX (default: 0)
> > - tx_io_uring_sq_size: Submission queue size (default: 1024)
> > - tx_io_uring_sq_thread_idle: SQPOLL idle timeout in ms (default: 500)
> > - tx_io_uring_q_cpu: CPU affinity for SQPOLL threads (repeatable)
> > - tx_io_uring_wq_num: Number of shared workqueues (default: 0)
> >
> > The TX path updates the ring tail pointer directly instead of calling
> > io_uring_submit() to avoid the io_uring_enter syscall, relying on
> > SQPOLL to pick up submissions. If the SQPOLL thread sleeps, we wake
> > it with IORING_ENTER_SQ_WAKEUP.
> >
> > Falls back gracefully to sendto() when:
> > - liburing is not available at compile time
> > - SQPOLL is not supported by the kernel
> > - io_uring initialization fails for any reason
> >
> > Signed-off-by: Scott <scott.k.mitch1@gmail.com>
> > ---
> > Depends-on: series-37248 ("af_packet correctness, performance, cksum")
> >
> >  doc/guides/nics/af_packet.rst             |  16 +-
> >  doc/guides/rel_notes/release_26_03.rst    |   1 +
> >  drivers/net/af_packet/meson.build         |  14 +
> >  drivers/net/af_packet/rte_eth_af_packet.c | 420 +++++++++++++++++++++-
> >  4 files changed, 435 insertions(+), 16 deletions(-)
> >
> > diff --git a/doc/guides/nics/af_packet.rst b/doc/guides/nics/af_pac
>
> I would rather it be a different driver than af_packet.
> See my RFC patch for using io_uring

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC PATCH v2] net/af_packet: add io_uring TX acceleration
  2026-02-04 16:12 [RFC v1] net/af_packet: add io_uring TX acceleration scott.k.mitch1
  2026-02-04 16:52 ` Stephen Hemminger
@ 2026-12-01 22:36 ` Scott Mitchell
  2026-12-01 22:44   ` Scott Mitchell
  2026-12-02 18:54   ` [PATCH v3 0/2] net/af_packet: add io_uring Tx acceleration Scott Mitchell
  2026-12-02 16:59 ` [RFC v1] net/af_packet: add io_uring TX acceleration Stephen Hemminger
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 15+ messages in thread
From: Scott Mitchell @ 2026-12-01 22:36 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Scott Mitchell

The sendto() TX kick makes the kernel process queued frames
synchronously on the calling lcore. Optionally kick through an io_uring
SQPOLL ring instead, so a kernel thread does that work, as virtio
backends do. This improves throughput by 30%+ where virtio isn't an
option, such as containers.

New devargs: tx_io_uring_enabled, tx_io_uring_sq_size,
tx_io_uring_sq_thread_idle, tx_io_uring_q_cpu (SQPOLL CPU affinity)
and tx_io_uring_wq_num (queues share SQPOLL threads).

Requires liburing >= 2.4. Without it, or if SQPOLL setup fails, TX
falls back to sendto().

Signed-off-by: Scott Mitchell <scott.k.mitch1@gmail.com>
---
Depends-on: series-40223 ("net/af_packet: correctness, performance, cksum")

RFC v2:
- submit with io_uring_submit(); the open-coded SQ tail store lacked the
  full barrier before the IORING_SQ_NEED_WAKEUP check
- fix tx_io_uring_wq_num: the IORING_SETUP_ATTACH_WQ probe always failed
- create rings directly instead of probing, drop flags the kernel rejects
- drop IORING_SETUP_COOP_TASKRUN, which the kernel rejects with SQPOLL
- parse devargs with parse_uint()
- add tests
---
 app/test/test_pmd_af_packet.c             | 282 +++++++++++++++
 doc/guides/nics/af_packet.rst             |  18 +-
 doc/guides/rel_notes/release_27_03.rst    |   1 +
 drivers/net/af_packet/meson.build         |  14 +
 drivers/net/af_packet/rte_eth_af_packet.c | 399 +++++++++++++++++++++-
 5 files changed, 699 insertions(+), 15 deletions(-)

diff --git a/app/test/test_pmd_af_packet.c b/app/test/test_pmd_af_packet.c
index 7193d7505f..41433d829e 100644
--- a/app/test/test_pmd_af_packet.c
+++ b/app/test/test_pmd_af_packet.c
@@ -4,7 +4,9 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <dirent.h>
 #include <inttypes.h>
+#include <limits.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <linux/if.h>
@@ -99,6 +101,10 @@ struct tag_count {
 #define CKSUM_DST_PORT 0x5678
 #define CKSUM_PAYLOAD_LEN 32
 
+/* io_uring tests */
+#define IDLE_WAKE_ROUNDS 100
+#define SQPOLL_QUEUES 4
+
 static struct rte_mempool *mp;
 static uint16_t port_id = RTE_MAX_ETHPORTS;
 static int tap_fd = -1;
@@ -2188,6 +2194,277 @@ test_af_packet_tx_cksum(void)
 	return ret;
 }
 
+/*
+ * Test: io_uring devargs are validated
+ */
+static int
+test_af_packet_invalid_io_uring_args(void)
+{
+	static const char * const bad[] = {
+		"tx_io_uring_enabled=2",
+		"tx_io_uring_sq_size=0",
+		"tx_io_uring_sq_size=40000",
+		"tx_io_uring_sq_size=abc",
+		"tx_io_uring_sq_thread_idle=-1",
+		"tx_io_uring_q_cpu=-1",
+		"tx_io_uring_wq_num=99999",
+	};
+	char devargs[256];
+	unsigned int i;
+	int ret;
+
+	if (!tap_created) {
+		printf("SKIPPED: TAP interface not available (need root)\n");
+		return TEST_SKIPPED;
+	}
+
+	for (i = 0; i < RTE_DIM(bad); i++) {
+		snprintf(devargs, sizeof(devargs), "iface=%s,%s", TAP_DEV_NAME, bad[i]);
+		ret = rte_vdev_init("net_af_packet_uring_bad", devargs);
+		if (ret == 0)
+			rte_vdev_uninit("net_af_packet_uring_bad");
+		TEST_ASSERT(ret != 0, "Expected failure with %s", bad[i]);
+	}
+
+	return TEST_SUCCESS;
+}
+
+/*
+ * Test: TX with io_uring kicks. Passes on the sendto() fallback too, when
+ * liburing or SQPOLL is unavailable.
+ */
+static int
+test_af_packet_io_uring_tx(void)
+{
+	const char *name = "net_af_packet_uring";
+	char devargs[256];
+	uint16_t pid;
+	int flags, ret;
+
+	if (!tap_created) {
+		printf("SKIPPED: TAP interface not available (need root)\n");
+		return TEST_SKIPPED;
+	}
+
+	snprintf(devargs, sizeof(devargs),
+		 "iface=%s,blocksz=4096,framesz=%d,framecnt=%d,tx_io_uring_enabled=1",
+		 TAP_DEV_NAME, LAYOUT_FRAMESZ, LAYOUT_FRAMECNT);
+	ret = create_test_port(name, devargs, 0, &pid);
+	TEST_ASSERT(ret == 0, "Failed to create port");
+
+	flags = fcntl(tap_fd, F_GETFL, 0);
+	fcntl(tap_fd, F_SETFL, flags | O_NONBLOCK);
+	tap_drain();
+
+	ret = check_tx_seq(pid, LAYOUT_NB_FRAMES, LAYOUT_FRAME_LEN);
+
+	fcntl(tap_fd, F_SETFL, flags);
+	destroy_test_port(name, pid);
+	return ret;
+}
+
+/*
+ * Test: A frame sent after the SQPOLL thread went idle still goes out.
+ * With a 1 ms idle timeout and a 3 ms gap before each frame, every kick has
+ * to wake a sleeping SQ thread; a missed wakeup leaves the frame queued.
+ * This is a smoke test: the race window is small, so a pass is not proof.
+ */
+static int
+test_af_packet_io_uring_idle_wakeup(void)
+{
+	const char *name = "net_af_packet_uring_idle";
+	bool seen[IDLE_WAKE_ROUNDS] = { false };
+	unsigned int round, nb_seen = 0;
+	struct rte_mbuf *m;
+	char devargs[256];
+	uint8_t *data;
+	uint16_t pid;
+	int flags, ret;
+
+	if (!tap_created) {
+		printf("SKIPPED: TAP interface not available (need root)\n");
+		return TEST_SKIPPED;
+	}
+
+	snprintf(devargs, sizeof(devargs),
+		 "iface=%s,tx_io_uring_enabled=1,tx_io_uring_sq_thread_idle=1",
+		 TAP_DEV_NAME);
+	ret = create_test_port(name, devargs, 0, &pid);
+	TEST_ASSERT(ret == 0, "Failed to create port");
+
+	flags = fcntl(tap_fd, F_GETFL, 0);
+	fcntl(tap_fd, F_SETFL, flags | O_NONBLOCK);
+	tap_drain();
+
+	ret = TEST_FAILED;
+	for (round = 0; round < IDLE_WAKE_ROUNDS; round++) {
+		rte_delay_ms(3);
+		m = rte_pktmbuf_alloc(mp);
+		if (m == NULL)
+			goto out;
+		data = (uint8_t *)rte_pktmbuf_append(m, TEST_FRAME_LEN);
+		if (data == NULL) {
+			rte_pktmbuf_free(m);
+			goto out;
+		}
+		fill_seq_frame(data, TEST_FRAME_LEN, &DEV_MAC_TAG, round);
+		if (do_tx_burst(pid, 0, &m, 1) != 1)
+			goto out;
+		if (tap_collect_seq(seen, IDLE_WAKE_ROUNDS, &nb_seen, round + 1,
+				    TEST_FRAME_LEN, TAP_READ_TIMEOUT_US) != (int)(round + 1)) {
+			printf("Frame %u not sent after idle (seen %u)\n", round, nb_seen);
+			goto out;
+		}
+	}
+	ret = TEST_SUCCESS;
+out:
+	fcntl(tap_fd, F_SETFL, flags);
+	destroy_test_port(name, pid);
+	return ret;
+}
+
+/* Helper: Count open file descriptors of this process, or -1. */
+static int
+count_open_fds(void)
+{
+	struct dirent *de;
+	DIR *dir;
+	int n = 0;
+
+	dir = opendir("/proc/self/fd");
+	if (dir == NULL)
+		return -1;
+	while ((de = readdir(dir)) != NULL)
+		if (de->d_name[0] != '.')
+			n++;
+	closedir(dir);
+	return n;
+}
+
+/*
+ * Test: Creating and closing io_uring ports, including ones sharing an
+ * SQPOLL thread (tx_io_uring_wq_num), does not leak file descriptors.
+ */
+static int
+test_af_packet_io_uring_create_destroy(void)
+{
+	const char *name = "net_af_packet_uring_cd";
+	char devargs[256];
+	int before, after, i;
+	uint16_t pid;
+
+	if (!tap_created) {
+		printf("SKIPPED: TAP interface not available (need root)\n");
+		return TEST_SKIPPED;
+	}
+
+	snprintf(devargs, sizeof(devargs),
+		 "iface=%s,qpairs=2,tx_io_uring_enabled=1,tx_io_uring_wq_num=1",
+		 TAP_DEV_NAME);
+
+	before = count_open_fds();
+	for (i = 0; i < 10; i++) {
+		TEST_ASSERT(create_af_packet_port(name, devargs, &pid) == 0,
+			    "Failed to create port (iteration %d)", i);
+		TEST_ASSERT(configure_af_packet_port(pid, 2, 2) == 0,
+			    "Failed to configure port (iteration %d)", i);
+		destroy_test_port(name, pid);
+	}
+	after = count_open_fds();
+
+	TEST_ASSERT(before >= 0 && before == after,
+		    "Open fds %d before, %d after", before, after);
+	return TEST_SUCCESS;
+}
+
+/* Helper: Count this process's io_uring SQPOLL threads (comm "iou-sqp-<pid>"), or -1. */
+static int
+count_sqpoll_threads(void)
+{
+	char path[PATH_MAX], comm[32];
+	struct dirent *de;
+	DIR *dir;
+	FILE *f;
+	int n = 0;
+
+	dir = opendir("/proc/self/task");
+	if (dir == NULL)
+		return -1;
+	while ((de = readdir(dir)) != NULL) {
+		if (de->d_name[0] == '.')
+			continue;
+		snprintf(path, sizeof(path), "/proc/self/task/%s/comm", de->d_name);
+		f = fopen(path, "r");
+		if (f == NULL)
+			continue;
+		if (fgets(comm, sizeof(comm), f) != NULL && strncmp(comm, "iou-sqp-", 8) == 0)
+			n++;
+		fclose(f);
+	}
+	closedir(dir);
+	return n;
+}
+
+/* Helper: Wait up to 1s for the SQPOLL thread count to reach want. Returns the count. */
+static int
+wait_sqpoll_threads(int want)
+{
+	int i, n = count_sqpoll_threads();
+
+	for (i = 0; i < 100 && n != want; i++) {
+		rte_delay_ms(10);
+		n = count_sqpoll_threads();
+	}
+	return n;
+}
+
+/*
+ * Test: Queues share SQPOLL threads when tx_io_uring_wq_num is below the
+ * queue count (IORING_SETUP_ATTACH_WQ).
+ */
+static int
+test_af_packet_io_uring_shared_sqpoll(void)
+{
+	static const unsigned int wq_nums[] = { 1, 2 };
+	const char *name = "net_af_packet_uring_wq";
+	char devargs[256];
+	unsigned int i;
+	uint16_t pid;
+	int n;
+
+	if (!tap_created) {
+		printf("SKIPPED: TAP interface not available (need root)\n");
+		return TEST_SKIPPED;
+	}
+	TEST_ASSERT(wait_sqpoll_threads(0) == 0, "SQPOLL threads left from earlier tests");
+
+	for (i = 0; i < RTE_DIM(wq_nums); i++) {
+		snprintf(devargs, sizeof(devargs),
+			 "iface=%s,qpairs=%d,tx_io_uring_enabled=1,tx_io_uring_wq_num=%u",
+			 TAP_DEV_NAME, SQPOLL_QUEUES, wq_nums[i]);
+		TEST_ASSERT(create_af_packet_port(name, devargs, &pid) == 0,
+			    "Failed to create port");
+		if (configure_af_packet_port(pid, SQPOLL_QUEUES, SQPOLL_QUEUES) != 0) {
+			destroy_test_port(name, pid);
+			return TEST_FAILED;
+		}
+		/* SQPOLL threads start and exit asynchronously; let the count settle */
+		n = wait_sqpoll_threads(wq_nums[i]);
+		destroy_test_port(name, pid);
+
+		if (n == 0) {
+			printf("SKIPPED: io_uring SQPOLL not available\n");
+			return TEST_SKIPPED;
+		}
+		printf("%d queues, %s=%u: %d SQPOLL threads\n", SQPOLL_QUEUES,
+		       "tx_io_uring_wq_num", wq_nums[i], n);
+		TEST_ASSERT(n == (int)wq_nums[i], "Expected %u SQPOLL threads, got %d",
+			    wq_nums[i], n);
+		TEST_ASSERT(wait_sqpoll_threads(0) == 0, "SQPOLL threads did not exit");
+	}
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite af_packet_test_suite = {
 	.suite_name = "AF_PACKET PMD Unit Test Suite",
 	.setup = test_af_packet_setup,
@@ -2218,6 +2495,11 @@ static struct unit_test_suite af_packet_test_suite = {
 		TEST_CASE(test_af_packet_invalid_txpollnotrdy),
 		TEST_CASE(test_af_packet_txpollnotrdy_nonblocking),
 		TEST_CASE(test_af_packet_tx_cksum),
+		TEST_CASE(test_af_packet_invalid_io_uring_args),
+		TEST_CASE(test_af_packet_io_uring_tx),
+		TEST_CASE(test_af_packet_io_uring_idle_wakeup),
+		TEST_CASE(test_af_packet_io_uring_create_destroy),
+		TEST_CASE(test_af_packet_io_uring_shared_sqpoll),
 		TEST_CASE(test_af_packet_qdisc_bypass),
 		TEST_CASE(test_af_packet_multi_queue),
 		TEST_CASE(test_af_packet_fanout_modes),
diff --git a/doc/guides/nics/af_packet.rst b/doc/guides/nics/af_packet.rst
index 7a6cc4ebe9..6e00db5165 100644
--- a/doc/guides/nics/af_packet.rst
+++ b/doc/guides/nics/af_packet.rst
@@ -35,6 +35,22 @@ Some of these, in turn, will be used to configure the PACKET_MMAP settings.
     space available to write to the kernel. If 1, call poll() and block until
     space is available to tx. If 0, don't call poll() and return from tx (optional,
     default 1).
+*   ``tx_io_uring_enabled`` - Use io_uring to notify the kernel on tx (optional,
+    default 0)
+*   ``tx_io_uring_sq_size`` - Number of entries for the io_uring ring (optional,
+    default 1024)
+*   ``tx_io_uring_sq_thread_idle`` - Idle time (in milliseconds) before an io_uring
+    SQPOLL thread goes to sleep (optional, default 500)
+*   ``tx_io_uring_q_cpu`` - This argument can be repeated to specify CPU core
+    affinity for each queue's io_uring SQPOLL kernel thread (see
+    ``io_uring_params.sq_thread_cpu``). The first value applies to queue 0,
+    the second to queue 1, etc. (optional, default empty). An unpinned SQPOLL
+    thread may run on any CPU, so pin it when lcores run with real-time priority,
+    where it could otherwise be starved.
+*   ``tx_io_uring_wq_num`` - Number of SQPOLL kernel threads. On kernels with
+    ``IORING_SETUP_ATTACH_WQ`` support, setting this lower than the queue count
+    enables thread sharing across queues. If 0 or unspecified, no sharing is configured
+    and each queue creates its own SQPOLL thread (optional, default 0)
 
 For details regarding ``fanout_mode`` argument, you can consult the
 `PACKET_FANOUT documentation <https://www.man7.org/linux/man-pages/man7/packet.7.html>`_.
@@ -88,7 +104,7 @@ framecnt=512):
 
 .. code-block:: console
 
-    --vdev=eth_af_packet0,iface=tap0,blocksz=4096,framesz=2048,framecnt=512,qpairs=1,qdisc_bypass=1,fanout_mode=hash,txpollnotrdy=0
+    --vdev=eth_af_packet0,iface=tap0,blocksz=4096,framesz=2048,framecnt=512,qpairs=1,qdisc_bypass=1,fanout_mode=hash,txpollnotrdy=0,tx_io_uring_enabled=1
 
 Features and Limitations
 ------------------------
diff --git a/doc/guides/rel_notes/release_27_03.rst b/doc/guides/rel_notes/release_27_03.rst
index c2b25c1387..76bc028afc 100644
--- a/doc/guides/rel_notes/release_27_03.rst
+++ b/doc/guides/rel_notes/release_27_03.rst
@@ -60,6 +60,7 @@ New Features
   * Added ``txpollnotrdy`` devarg to avoid ``poll()`` blocking calls.
   * Added software checksum offload support for ``IPV4_CKSUM``, ``UDP_CKSUM``
     and ``TCP_CKSUM``.
+  * Added optional io_uring SQPOLL notification of the kernel on Tx.
 
 
 Removed Items
diff --git a/drivers/net/af_packet/meson.build b/drivers/net/af_packet/meson.build
index f45e4491d4..a672262656 100644
--- a/drivers/net/af_packet/meson.build
+++ b/drivers/net/af_packet/meson.build
@@ -5,5 +5,19 @@ if not is_linux
     build = false
     reason = 'only supported on Linux'
 endif
+
+deps += ['ethdev']
+
+liburing_dep = dependency('liburing', required: false)
+if not liburing_dep.found()
+    message('AF_PACKET PMD: liburing not found, fallback to sendto()')
+elif not liburing_dep.version().version_compare('>=2.4')
+    message('AF_PACKET PMD: liburing version too old, need >= 2.4. fallback to sendto()')
+else
+    ext_deps += liburing_dep
+    cflags += '-DRTE_NET_AF_PACKET_HAVE_LIBURING'
+    message('AF_PACKET PMD: liburing @0@ support enabled'.format(liburing_dep.version()))
+endif
+
 sources = files('rte_eth_af_packet.c')
 require_iova_in_mbuf = false
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index f21be21009..37e29048e9 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -20,6 +20,10 @@
 #include <bus_vdev_driver.h>
 
 #include <ctype.h>
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+#include <liburing.h>
+#endif
+
 #include <errno.h>
 #include <limits.h>
 #include <linux/if_ether.h>
@@ -55,10 +59,22 @@
 #define ETH_AF_PACKET_FANOUT_MODE_ARG	"fanout_mode"
 #define ETH_AF_PACKET_IGNORE_OUTGOING_ARG	"ignore_outgoing"
 #define ETH_AF_PACKET_TX_POLL_NOT_READY_ARG	"txpollnotrdy"
+#define ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG	"tx_io_uring_enabled"
+#define ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG	"tx_io_uring_sq_size"
+#define ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG	"tx_io_uring_sq_thread_idle"
+#define ETH_AF_PACKET_TX_IO_URING_Q_CPU	"tx_io_uring_q_cpu"
+#define ETH_AF_PACKET_TX_IO_URING_WQ_NUM	"tx_io_uring_wq_num"
 
 #define DFLT_FRAME_SIZE		(1 << 11)
 #define DFLT_FRAME_COUNT	(1 << 9)
 #define DFLT_TX_POLL_NOT_RDY	1
+#define DFLT_TX_IO_URING_ENABLED	false
+#define DFLT_TX_IO_URING_SQ_SIZE	1024
+#define ETH_AF_PACKET_URING_SQ_SIZE_MAX	32768
+#define DFLT_TX_IO_URING_SQ_THREAD_IDLE_MS	500
+
+/* io_uring registered file descriptor index for the socket fd */
+#define ETH_AF_PACKET_URING_SOCKFD_INDEX	0
 
 #define ETH_AF_PACKET_FRAME_OVERHEAD (TPACKET2_HDRLEN - sizeof(struct sockaddr_ll))
 
@@ -95,6 +111,12 @@ struct __rte_cache_aligned pkt_tx_queue {
 	unsigned int framecount;
 	unsigned int framenum;
 
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+	struct io_uring uring_ring;
+	bool uring_enabled;
+	uint32_t uring_sqe_since_cq_advance;
+#endif
+
 	bool txpollnotrdy;
 	bool sw_cksum;
 
@@ -117,6 +139,11 @@ struct pmd_internals {
 	uint8_t vlan_strip;
 	uint8_t timestamp_offloading;
 	bool tx_sw_cksum;
+
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+	struct io_uring **shared_uring_rings;
+	uint32_t shared_uring_count;
+#endif
 };
 
 static const char *valid_arguments[] = {
@@ -129,6 +156,11 @@ static const char *valid_arguments[] = {
 	ETH_AF_PACKET_FANOUT_MODE_ARG,
 	ETH_AF_PACKET_IGNORE_OUTGOING_ARG,
 	ETH_AF_PACKET_TX_POLL_NOT_READY_ARG,
+	ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG,
+	ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG,
+	ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG,
+	ETH_AF_PACKET_TX_IO_URING_Q_CPU,
+	ETH_AF_PACKET_TX_IO_URING_WQ_NUM,
 	NULL
 };
 
@@ -211,6 +243,198 @@ tpacket_write_status(volatile void *tp_status, uint32_t status)
 	*((volatile unaligned_uint32_t *)tp_status) = status;
 }
 
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+/*
+ * Create a ring. The kernel rejects unsupported setup flags with -EINVAL before
+ * creating anything, so optional flags are dropped one at a time and retried.
+ */
+static int
+af_packet_io_uring_init(struct io_uring *ring, uint32_t entries,
+			struct io_uring_params *params, unsigned int q)
+{
+	static const struct {
+		uint32_t flag;
+		const char *name;
+	} optional[] = {
+		{ IORING_SETUP_SINGLE_ISSUER, "IORING_SETUP_SINGLE_ISSUER" },
+		{ IORING_SETUP_SQ_AFF, "IORING_SETUP_SQ_AFF (SQPOLL CPU pinning)" },
+	};
+	struct io_uring_params p = *params;
+	unsigned int i;
+	int rc;
+
+	rc = io_uring_queue_init_params(entries, ring, &p);
+	for (i = 0; rc == -EINVAL && i < RTE_DIM(optional); i++) {
+		if ((params->flags & optional[i].flag) == 0)
+			continue;
+		params->flags &= ~optional[i].flag;
+		PMD_LOG(NOTICE, "AF_PACKET PMD io_uring tx_queue=%u: %s rejected, retrying without it",
+			q, optional[i].name);
+		p = *params;
+		rc = io_uring_queue_init_params(entries, ring, &p);
+	}
+	if (rc == 0)
+		*params = p;
+	return rc;
+}
+#endif /* RTE_NET_AF_PACKET_HAVE_LIBURING */
+
+static void
+af_packet_io_uring_share_uring_init(struct pmd_internals *internals,
+				const unsigned int numa_node,
+				const unsigned int nb_queues,
+				const bool tx_io_uring_enabled,
+				const uint32_t tx_io_uring_kq_cores_size,
+				const uint32_t tx_io_uring_wq_num)
+{
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+	if (!tx_io_uring_enabled)
+		return;
+
+	if (tx_io_uring_wq_num <= 0)
+		return;
+
+	/* Rings attach to a queue's SQPOLL thread with IORING_SETUP_ATTACH_WQ. Support
+	 * can't be probed without a ring to attach to, so failures are handled per queue.
+	 */
+	internals->shared_uring_rings =
+		rte_calloc_socket("af_packet_shared_uring", tx_io_uring_wq_num,
+			sizeof(*internals->shared_uring_rings), 0, numa_node);
+	if (!internals->shared_uring_rings) {
+		PMD_LOG(ERR, "Failed to allocate shared io_uring rings");
+		return;
+	}
+	internals->shared_uring_count = tx_io_uring_wq_num;
+
+	if (tx_io_uring_kq_cores_size > tx_io_uring_wq_num) {
+		PMD_LOG(WARNING,
+			"AF_PACKET PMD %s count=%" PRIu32 " > %s=%" PRIu32 ", "
+			"extra CPU affinities will be ignored",
+			ETH_AF_PACKET_TX_IO_URING_Q_CPU, tx_io_uring_kq_cores_size,
+			ETH_AF_PACKET_TX_IO_URING_WQ_NUM, tx_io_uring_wq_num);
+	}
+
+	if (nb_queues % tx_io_uring_wq_num != 0) {
+		PMD_LOG(INFO,
+			"AF_PACKET PMD %s=%u not divisible by %s=%" PRIu32 ", "
+			"SQPOLL thread work may be imbalanced",
+			ETH_AF_PACKET_NUM_Q_ARG, nb_queues,
+			ETH_AF_PACKET_TX_IO_URING_WQ_NUM, tx_io_uring_wq_num);
+	}
+#else
+	if (tx_io_uring_enabled) {
+		PMD_LOG(NOTICE,
+			"AF_PACKET PMD %s enabled, but feature not enabled at compile time.",
+			ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG);
+	}
+	RTE_SET_USED(internals);
+	RTE_SET_USED(numa_node);
+	RTE_SET_USED(nb_queues);
+	RTE_SET_USED(tx_io_uring_kq_cores_size);
+	RTE_SET_USED(tx_io_uring_wq_num);
+#endif /* RTE_NET_AF_PACKET_HAVE_LIBURING */
+}
+
+static void
+af_packet_io_uring_tx_queue_init(struct pmd_internals *internals,
+				const unsigned int q,
+				const bool tx_io_uring_enabled,
+				const uint32_t tx_io_uring_sq_size,
+				const uint32_t tx_io_uring_sq_thread_idle_ms,
+				const uint32_t *tx_io_uring_kq_cores,
+				const uint32_t tx_io_uring_kq_cores_size)
+{
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+	if (!tx_io_uring_enabled)
+		return;
+
+	int rc;
+	struct pkt_tx_queue *tx_queue = &internals->tx_queue[q];
+	struct io_uring_params uring_params = {
+		.sq_thread_idle = tx_io_uring_sq_thread_idle_ms,
+		.flags = IORING_SETUP_SQPOLL,
+	};
+
+	/* Determine if attaching to existing ring or creating new one */
+	uint32_t ring_idx = internals->shared_uring_rings ? q % internals->shared_uring_count : 0;
+	bool attach_mode = internals->shared_uring_rings && ring_idx < q &&
+			internals->shared_uring_rings[ring_idx];
+
+	if (attach_mode) {
+		/* Share the group's SQPOLL thread; the ring's memory and lifetime stay per queue */
+		uring_params.flags |= IORING_SETUP_ATTACH_WQ;
+		uring_params.wq_fd = internals->shared_uring_rings[ring_idx]->ring_fd;
+	} else {
+		/* Create new ring: add CPU affinity if configured */
+		if (tx_io_uring_kq_cores_size > 0) {
+			uint32_t cpu_idx = internals->shared_uring_rings ? ring_idx : q;
+			if (cpu_idx < tx_io_uring_kq_cores_size) {
+				uring_params.flags |= IORING_SETUP_SQ_AFF;
+				uring_params.sq_thread_cpu = tx_io_uring_kq_cores[cpu_idx];
+			} else {
+				PMD_LOG(DEBUG,
+					"AF_PACKET PMD io_uring tx_queue=%u > %s size=%" PRIu32 " "
+					"and will not be CPU pinned", q,
+					ETH_AF_PACKET_TX_IO_URING_Q_CPU,
+					tx_io_uring_kq_cores_size);
+			}
+		}
+
+		uring_params.flags |= IORING_SETUP_SINGLE_ISSUER;
+	}
+
+	rc = af_packet_io_uring_init(&tx_queue->uring_ring, tx_io_uring_sq_size,
+			&uring_params, q);
+	if (rc < 0 && attach_mode) {
+		PMD_LOG(WARNING, "AF_PACKET PMD io_uring IORING_SETUP_ATTACH_WQ failed (error %d: %s), "
+			"tx_queue=%u uses its own SQPOLL thread", -rc, strerror(-rc), q);
+		attach_mode = false;
+		uring_params.flags &= ~IORING_SETUP_ATTACH_WQ;
+		uring_params.wq_fd = 0;
+		rc = af_packet_io_uring_init(&tx_queue->uring_ring, tx_io_uring_sq_size,
+				&uring_params, q);
+	}
+	if (rc < 0) {
+		PMD_LOG(WARNING, "AF_PACKET PMD Failed io_uring_queue_init_params (error %d: %s), "
+			"tx_queue=%u sq_size=%" PRIu32 " flags=0x%X sq_thread_cpu=%u "
+			"sq_thread_idle=%u, falling back to synchronous sendto()",
+			-rc, strerror(-rc), q, tx_io_uring_sq_size, uring_params.flags,
+			uring_params.sq_thread_cpu, uring_params.sq_thread_idle);
+		return;
+	}
+
+	/* Register the sockfd at index ETH_AF_PACKET_URING_SOCKFD_INDEX */
+	rc = io_uring_register_files(&tx_queue->uring_ring, &tx_queue->sockfd, 1);
+	if (rc < 0) {
+		PMD_LOG(WARNING, "AF_PACKET PMD Failed io_uring_register_files (error %d: %s)",
+				-rc, strerror(-rc));
+		io_uring_queue_exit(&tx_queue->uring_ring);
+		return;
+	}
+
+	tx_queue->uring_enabled = true;
+	tx_queue->uring_sqe_since_cq_advance = 0;
+
+	if (!attach_mode && internals->shared_uring_rings &&
+	    !internals->shared_uring_rings[ring_idx])
+		internals->shared_uring_rings[ring_idx] = &tx_queue->uring_ring;
+
+	PMD_LOG(DEBUG, "AF_PACKET PMD io_uring SQPOLL%s enabled tx_queue=%u ring_idx=%u "
+		"tx_io_uring_sq_size=%" PRIu32 " kthread_cpu=%u sq_thread_idle=%u flags=0x%X",
+		attach_mode ? "+ATTACH_WQ" : "", q, ring_idx, tx_io_uring_sq_size,
+		uring_params.sq_thread_cpu, uring_params.sq_thread_idle, uring_params.flags);
+
+#else
+	RTE_SET_USED(internals);
+	RTE_SET_USED(q);
+	RTE_SET_USED(tx_io_uring_enabled);
+	RTE_SET_USED(tx_io_uring_sq_size);
+	RTE_SET_USED(tx_io_uring_sq_thread_idle_ms);
+	RTE_SET_USED(tx_io_uring_kq_cores);
+	RTE_SET_USED(tx_io_uring_kq_cores_size);
+#endif /* RTE_NET_AF_PACKET_HAVE_LIBURING */
+}
+
 static uint16_t
 eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
@@ -346,6 +570,61 @@ tx_ring_status_available(uint32_t tp_status)
 	return tp_status == TP_STATUS_AVAILABLE;
 }
 
+/*
+ * Kick the kernel to transmit packets in the ring.
+ *
+ * The sendto() call with NULL buffer is a notification to the kernel that
+ * frames have been queued (marked TP_STATUS_SEND_REQUEST) in the ring.
+ * The kernel will eventually process all queued frames regardless of whether
+ * this kick succeeds or fails. We don't check for errors because:
+ *
+ * 1. Data is already in the ring - the PMD's work is complete
+ * 2. ENOBUFS/EAGAIN just mean "try again later" - kernel will still process ring
+ * 3. Fatal errors (EBADF) indicate socket is broken - subsequent ops will fail
+ * 4. Consistent with io_uring path which doesn't check completion status
+ */
+static inline void
+eth_af_packet_tx_kick(struct pkt_tx_queue *pkt_q)
+{
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+	if (pkt_q->uring_enabled) {
+		/* Batch CQ advancement: only advance every sq_size submissions to amortize
+		 * memory barrier cost (2 load_acquire + 1 store_release). With
+		 * IOSQE_CQE_SKIP_SUCCESS, CQ is mostly empty (successes don't generate CQEs).
+		 * This prevents rare failure CQEs from accumulating while minimizing overhead.
+		 */
+		if (++pkt_q->uring_sqe_since_cq_advance >= pkt_q->uring_ring.sq.ring_entries) {
+			io_uring_cq_advance(&pkt_q->uring_ring,
+					io_uring_cq_ready(&pkt_q->uring_ring));
+			pkt_q->uring_sqe_since_cq_advance = 0;
+		}
+
+		struct io_uring_sqe *sqe = io_uring_get_sqe(&pkt_q->uring_ring);
+		/* If no sqe available skip this notification and wait for kernel to catch up.
+		 * Avoid fall back sendto() so we don't block the application thread and it is
+		 * highly likely the kernel will process pending events and/or subsequent TX
+		 * will generate new notification.
+		 */
+		if (unlikely(sqe == NULL))
+			return;
+
+		/* Use registered fd (see io_uring_register_files call during setup) */
+		io_uring_prep_send(sqe, ETH_AF_PACKET_URING_SOCKFD_INDEX, NULL, 0, MSG_DONTWAIT);
+		io_uring_sqe_set_flags(sqe, IOSQE_FIXED_FILE | IOSQE_CQE_SKIP_SUCCESS);
+		io_uring_sqe_set_data(sqe, NULL);
+
+		/* With SQPOLL this only enters the kernel to wake a sleeping SQ thread;
+		 * its full barrier orders the tail store before the NEED_WAKEUP check.
+		 */
+		io_uring_submit(&pkt_q->uring_ring);
+	} else {
+		sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0);
+	}
+#else
+	sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0);
+#endif
+}
+
 /*
  * Callback to handle sending packets through a real NIC.
  */
@@ -436,19 +715,8 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 
 	rte_pktmbuf_free_bulk(&bufs[0], i);
 
-	/* kick-off transmits */
-	if (unlikely(num_tx > 0 &&
-		     sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1 &&
-		     errno != ENOBUFS && errno != EAGAIN)) {
-		/*
-		 * In case of a ENOBUFS/EAGAIN error all of the enqueued
-		 * packets will be considered successful even though only some
-		 * are sent.
-		 */
-
-		num_tx = 0;
-		num_tx_bytes = 0;
-	}
+	if (likely(num_tx > 0))
+		eth_af_packet_tx_kick(pkt_q);
 
 	pkt_q->framenum = framenum;
 	pkt_q->tx_pkts += num_tx;
@@ -659,11 +927,22 @@ eth_dev_close(struct rte_eth_dev *dev)
 		internals->rx_queue[q].sockfd = -1;
 		internals->tx_queue[q].sockfd = -1;
 
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+		if (internals->tx_queue[q].uring_enabled) {
+			io_uring_unregister_files(&internals->tx_queue[q].uring_ring);
+			io_uring_queue_exit(&internals->tx_queue[q].uring_ring);
+			internals->tx_queue[q].uring_enabled = false;
+		}
+#endif
+
 		munmap(internals->rx_queue[q].map,
 			2 * req->tp_block_size * req->tp_block_nr);
 		rte_free(internals->rx_queue[q].rd);
 		rte_free(internals->tx_queue[q].rd);
 	}
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+	rte_free(internals->shared_uring_rings);
+#endif
 	rte_free(internals->if_name);
 	rte_free(internals->rx_queue);
 	rte_free(internals->tx_queue);
@@ -939,6 +1218,12 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 		       const char *fanout_mode,
 		       unsigned int ignore_outgoing,
 		       bool txpollnotrdy,
+		       bool tx_io_uring_enabled,
+		       uint32_t tx_io_uring_sq_size,
+		       uint32_t tx_io_uring_sq_thread_idle_ms,
+		       uint32_t *tx_io_uring_kq_cores,
+		       uint32_t tx_io_uring_kq_cores_size,
+		       uint32_t tx_io_uring_wq_num,
 		       struct pmd_internals **internals,
 		       struct rte_eth_dev **eth_dev,
 		       struct rte_kvargs *kvlist)
@@ -1053,6 +1338,9 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 	if (ignore_outgoing != 0 && nb_queues > 1)
 		fanout_arg |= PACKET_FANOUT_FLAG_IGNORE_OUTGOING << 16;
 
+	af_packet_io_uring_share_uring_init(*internals, numa_node, nb_queues,
+			tx_io_uring_enabled, tx_io_uring_kq_cores_size, tx_io_uring_wq_num);
+
 	for (q = 0; q < nb_queues; q++) {
 		/* Open an AF_PACKET socket for this queue... */
 		qsockfd = socket(AF_PACKET, SOCK_RAW, 0);
@@ -1206,6 +1494,10 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 				goto error;
 			}
 		}
+
+		af_packet_io_uring_tx_queue_init(*internals, q, tx_io_uring_enabled,
+			tx_io_uring_sq_size, tx_io_uring_sq_thread_idle_ms, tx_io_uring_kq_cores,
+			tx_io_uring_kq_cores_size);
 	}
 
 	/* reserve an ethdev entry */
@@ -1239,6 +1531,13 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 	if (qsockfd != -1)
 		close(qsockfd);
 	for (q = 0; q < nb_queues; q++) {
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+		if ((*internals)->tx_queue[q].uring_enabled) {
+			io_uring_unregister_files(&(*internals)->tx_queue[q].uring_ring);
+			io_uring_queue_exit(&(*internals)->tx_queue[q].uring_ring);
+			(*internals)->tx_queue[q].uring_enabled = false;
+		}
+#endif
 		if ((*internals)->rx_queue[q].map != MAP_FAILED)
 			munmap((*internals)->rx_queue[q].map,
 			       2 * req->tp_block_size * req->tp_block_nr);
@@ -1250,6 +1549,9 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 			close((*internals)->rx_queue[q].sockfd);
 	}
 free_internals:
+#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
+	rte_free((*internals)->shared_uring_rings);
+#endif
 	rte_free((*internals)->rx_queue);
 	rte_free((*internals)->tx_queue);
 	rte_free((*internals)->if_name);
@@ -1313,6 +1615,13 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
 	const char *fanout_mode = NULL;
 	unsigned int ignore_outgoing = 0;
 	unsigned int txpollnotrdy = DFLT_TX_POLL_NOT_RDY;
+	bool tx_io_uring_enabled = DFLT_TX_IO_URING_ENABLED;
+	uint32_t tx_io_uring_sq_size = DFLT_TX_IO_URING_SQ_SIZE;
+	uint32_t tx_io_uring_sq_thread_idle_ms = DFLT_TX_IO_URING_SQ_THREAD_IDLE_MS;
+	uint32_t tx_io_uring_kq_cores[RTE_MAX_QUEUES_PER_PORT] = {};
+	uint32_t tx_io_uring_kq_cores_size = 0;
+	uint32_t tx_io_uring_wq_num = 0;
+	unsigned int uval;
 
 	/* do some parameter checking */
 	if (*sockfd < 0)
@@ -1387,6 +1696,47 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
 				return -1;
 			continue;
 		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG) != NULL) {
+			if (parse_uint(pair->key, pair->value, &uval, 1) < 0)
+				return -1;
+			tx_io_uring_enabled = uval != 0;
+			continue;
+		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG) != NULL) {
+			if (parse_uint(pair->key, pair->value, &uval,
+				       ETH_AF_PACKET_URING_SQ_SIZE_MAX) < 0)
+				return -1;
+			if (uval == 0) {
+				PMD_LOG(ERR, "%s: %s must be > 0", name,
+					ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG);
+				return -1;
+			}
+			tx_io_uring_sq_size = uval;
+			continue;
+		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG) != NULL) {
+			if (parse_uint(pair->key, pair->value, &uval, UINT32_MAX) < 0)
+				return -1;
+			tx_io_uring_sq_thread_idle_ms = uval;
+			continue;
+		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_Q_CPU) != NULL) {
+			if (parse_uint(pair->key, pair->value, &uval, UINT32_MAX) < 0)
+				return -1;
+			if (tx_io_uring_kq_cores_size >= RTE_MAX_QUEUES_PER_PORT) {
+				PMD_LOG(ERR, "%s: too many %s args, max of %d", name,
+					ETH_AF_PACKET_TX_IO_URING_Q_CPU, RTE_MAX_QUEUES_PER_PORT);
+				return -1;
+			}
+			tx_io_uring_kq_cores[tx_io_uring_kq_cores_size++] = uval;
+			continue;
+		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_WQ_NUM) != NULL) {
+			if (parse_uint(pair->key, pair->value, &uval, RTE_MAX_QUEUES_PER_PORT) < 0)
+				return -1;
+			tx_io_uring_wq_num = uval;
+			continue;
+		}
 	}
 
 	if (framesize > blocksize) {
@@ -1458,6 +1808,19 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
 	PMD_LOG(DEBUG, "%s:\tignore outgoing %u", name, ignore_outgoing);
 	PMD_LOG(DEBUG, "%s:\ttxpollnotrdy %u", name, txpollnotrdy);
 
+	PMD_LOG(INFO, "%s:\t%s %d", name,
+		ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG, tx_io_uring_enabled ? 1 : 0);
+	PMD_LOG(INFO, "%s:\t%s %" PRIu32, name,
+		ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG, tx_io_uring_sq_size);
+	PMD_LOG(INFO, "%s:\t%s %" PRIu32, name,
+		ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG, tx_io_uring_sq_thread_idle_ms);
+	for (uint32_t cpu_i = 0; cpu_i < tx_io_uring_kq_cores_size; cpu_i++) {
+		PMD_LOG(INFO, "%s:\t%s[%" PRIu32 "] %" PRIu32, name,
+			ETH_AF_PACKET_TX_IO_URING_Q_CPU, cpu_i, tx_io_uring_kq_cores[cpu_i]);
+	}
+	PMD_LOG(INFO, "%s:\t%s %" PRIu32, name,
+		ETH_AF_PACKET_TX_IO_URING_WQ_NUM, tx_io_uring_wq_num);
+
 	if (rte_pmd_init_internals(dev, *sockfd, qpairs,
 				   blocksize, blockcount,
 				   framesize, framecount,
@@ -1465,6 +1828,9 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
 				   fanout_mode,
 				   ignore_outgoing,
 				   txpollnotrdy != 0,
+				   tx_io_uring_enabled, tx_io_uring_sq_size,
+				   tx_io_uring_sq_thread_idle_ms, tx_io_uring_kq_cores,
+				   tx_io_uring_kq_cores_size, tx_io_uring_wq_num,
 				   &internals, &eth_dev,
 				   kvlist) < 0)
 		return -1;
@@ -1564,4 +1930,9 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_packet,
 	"qdisc_bypass=<0|1> "
 	"fanout_mode=<hash|lb|cpu|rollover|rnd|qm> "
 	"ignore_outgoing=<0|1> "
-	"txpollnotrdy=<0|1>");
+	"txpollnotrdy=<0|1> "
+	"tx_io_uring_enabled=<0|1> "
+	"tx_io_uring_sq_size=<int> "
+	"tx_io_uring_sq_thread_idle=<int> "
+	"tx_io_uring_q_cpu=<int> "
+	"tx_io_uring_wq_num=<int>");
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH v2] net/af_packet: add io_uring TX acceleration
  2026-12-01 22:36 ` [RFC PATCH v2] " Scott Mitchell
@ 2026-12-01 22:44   ` Scott Mitchell
  2026-12-02 17:16     ` Stephen Hemminger
  2026-12-02 18:54   ` [PATCH v3 0/2] net/af_packet: add io_uring Tx acceleration Scott Mitchell
  1 sibling, 1 reply; 15+ messages in thread
From: Scott Mitchell @ 2026-12-01 22:44 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Hi Stephen,

RFCv2 is a rebase with tests and fixes. Before going further I'd
like to settle where this belongs, since the v1 feedback was
"I would rather it be a different driver than af_packet".

As far as I can tell the io_uring driver RFC wasn't merged, so I want
to understand what you'd like to see. The two solve different problems:

- A TAP-style io_uring driver replaces per-packet read()/write() with
  io_uring ops.
- af_packet has no per-packet syscalls; PACKET_MMAP rings carry the
  data. The only syscall is the sendto() TX notify, and that is all
  this patch replaces, so the kernel's TX processing runs on an SQPOLL
  thread instead of the PMD lcore.

A separate driver would duplicate the PACKET_MMAP ring handling to
change that one call. The feature is opt-in (tx_io_uring_enabled=0 by
default) and compiled out without liburing.

Would you accept it in af_packet in this form? If not, what would you
want changed, or is there a driver it should be built on instead?

On Tue, Dec 1, 2026 at 2:37 PM Scott Mitchell <scott.k.mitch1@gmail.com> wrote:
>
> The sendto() TX kick makes the kernel process queued frames
> synchronously on the calling lcore. Optionally kick through an io_uring
> SQPOLL ring instead, so a kernel thread does that work, as virtio
> backends do. This improves throughput by 30%+ where virtio isn't an
> option, such as containers.
>
> New devargs: tx_io_uring_enabled, tx_io_uring_sq_size,
> tx_io_uring_sq_thread_idle, tx_io_uring_q_cpu (SQPOLL CPU affinity)
> and tx_io_uring_wq_num (queues share SQPOLL threads).
>
> Requires liburing >= 2.4. Without it, or if SQPOLL setup fails, TX
> falls back to sendto().
>
> Signed-off-by: Scott Mitchell <scott.k.mitch1@gmail.com>
> ---
> Depends-on: series-40223 ("net/af_packet: correctness, performance, cksum")
>
> RFC v2:
> - submit with io_uring_submit(); the open-coded SQ tail store lacked the
>   full barrier before the IORING_SQ_NEED_WAKEUP check
> - fix tx_io_uring_wq_num: the IORING_SETUP_ATTACH_WQ probe always failed
> - create rings directly instead of probing, drop flags the kernel rejects
> - drop IORING_SETUP_COOP_TASKRUN, which the kernel rejects with SQPOLL
> - parse devargs with parse_uint()
> - add tests
> ---
>  app/test/test_pmd_af_packet.c             | 282 +++++++++++++++
>  doc/guides/nics/af_packet.rst             |  18 +-
>  doc/guides/rel_notes/release_27_03.rst    |   1 +
>  drivers/net/af_packet/meson.build         |  14 +
>  drivers/net/af_packet/rte_eth_af_packet.c | 399 +++++++++++++++++++++-
>  5 files changed, 699 insertions(+), 15 deletions(-)
>
> diff --git a/app/test/test_pmd_af_packet.c b/app/test/test_pmd_af_packet.c
> index 7193d7505f..41433d829e 100644
> --- a/app/test/test_pmd_af_packet.c
> +++ b/app/test/test_pmd_af_packet.c
> @@ -4,7 +4,9 @@
>
>  #include <errno.h>
>  #include <fcntl.h>
> +#include <dirent.h>
>  #include <inttypes.h>
> +#include <limits.h>
>  #include <sys/ioctl.h>
>  #include <sys/socket.h>
>  #include <linux/if.h>
> @@ -99,6 +101,10 @@ struct tag_count {
>  #define CKSUM_DST_PORT 0x5678
>  #define CKSUM_PAYLOAD_LEN 32
>
> +/* io_uring tests */
> +#define IDLE_WAKE_ROUNDS 100
> +#define SQPOLL_QUEUES 4
> +
>  static struct rte_mempool *mp;
>  static uint16_t port_id = RTE_MAX_ETHPORTS;
>  static int tap_fd = -1;
> @@ -2188,6 +2194,277 @@ test_af_packet_tx_cksum(void)
>         return ret;
>  }
>
> +/*
> + * Test: io_uring devargs are validated
> + */
> +static int
> +test_af_packet_invalid_io_uring_args(void)
> +{
> +       static const char * const bad[] = {
> +               "tx_io_uring_enabled=2",
> +               "tx_io_uring_sq_size=0",
> +               "tx_io_uring_sq_size=40000",
> +               "tx_io_uring_sq_size=abc",
> +               "tx_io_uring_sq_thread_idle=-1",
> +               "tx_io_uring_q_cpu=-1",
> +               "tx_io_uring_wq_num=99999",
> +       };
> +       char devargs[256];
> +       unsigned int i;
> +       int ret;
> +
> +       if (!tap_created) {
> +               printf("SKIPPED: TAP interface not available (need root)\n");
> +               return TEST_SKIPPED;
> +       }
> +
> +       for (i = 0; i < RTE_DIM(bad); i++) {
> +               snprintf(devargs, sizeof(devargs), "iface=%s,%s", TAP_DEV_NAME, bad[i]);
> +               ret = rte_vdev_init("net_af_packet_uring_bad", devargs);
> +               if (ret == 0)
> +                       rte_vdev_uninit("net_af_packet_uring_bad");
> +               TEST_ASSERT(ret != 0, "Expected failure with %s", bad[i]);
> +       }
> +
> +       return TEST_SUCCESS;
> +}
> +
> +/*
> + * Test: TX with io_uring kicks. Passes on the sendto() fallback too, when
> + * liburing or SQPOLL is unavailable.
> + */
> +static int
> +test_af_packet_io_uring_tx(void)
> +{
> +       const char *name = "net_af_packet_uring";
> +       char devargs[256];
> +       uint16_t pid;
> +       int flags, ret;
> +
> +       if (!tap_created) {
> +               printf("SKIPPED: TAP interface not available (need root)\n");
> +               return TEST_SKIPPED;
> +       }
> +
> +       snprintf(devargs, sizeof(devargs),
> +                "iface=%s,blocksz=4096,framesz=%d,framecnt=%d,tx_io_uring_enabled=1",
> +                TAP_DEV_NAME, LAYOUT_FRAMESZ, LAYOUT_FRAMECNT);
> +       ret = create_test_port(name, devargs, 0, &pid);
> +       TEST_ASSERT(ret == 0, "Failed to create port");
> +
> +       flags = fcntl(tap_fd, F_GETFL, 0);
> +       fcntl(tap_fd, F_SETFL, flags | O_NONBLOCK);
> +       tap_drain();
> +
> +       ret = check_tx_seq(pid, LAYOUT_NB_FRAMES, LAYOUT_FRAME_LEN);
> +
> +       fcntl(tap_fd, F_SETFL, flags);
> +       destroy_test_port(name, pid);
> +       return ret;
> +}
> +
> +/*
> + * Test: A frame sent after the SQPOLL thread went idle still goes out.
> + * With a 1 ms idle timeout and a 3 ms gap before each frame, every kick has
> + * to wake a sleeping SQ thread; a missed wakeup leaves the frame queued.
> + * This is a smoke test: the race window is small, so a pass is not proof.
> + */
> +static int
> +test_af_packet_io_uring_idle_wakeup(void)
> +{
> +       const char *name = "net_af_packet_uring_idle";
> +       bool seen[IDLE_WAKE_ROUNDS] = { false };
> +       unsigned int round, nb_seen = 0;
> +       struct rte_mbuf *m;
> +       char devargs[256];
> +       uint8_t *data;
> +       uint16_t pid;
> +       int flags, ret;
> +
> +       if (!tap_created) {
> +               printf("SKIPPED: TAP interface not available (need root)\n");
> +               return TEST_SKIPPED;
> +       }
> +
> +       snprintf(devargs, sizeof(devargs),
> +                "iface=%s,tx_io_uring_enabled=1,tx_io_uring_sq_thread_idle=1",
> +                TAP_DEV_NAME);
> +       ret = create_test_port(name, devargs, 0, &pid);
> +       TEST_ASSERT(ret == 0, "Failed to create port");
> +
> +       flags = fcntl(tap_fd, F_GETFL, 0);
> +       fcntl(tap_fd, F_SETFL, flags | O_NONBLOCK);
> +       tap_drain();
> +
> +       ret = TEST_FAILED;
> +       for (round = 0; round < IDLE_WAKE_ROUNDS; round++) {
> +               rte_delay_ms(3);
> +               m = rte_pktmbuf_alloc(mp);
> +               if (m == NULL)
> +                       goto out;
> +               data = (uint8_t *)rte_pktmbuf_append(m, TEST_FRAME_LEN);
> +               if (data == NULL) {
> +                       rte_pktmbuf_free(m);
> +                       goto out;
> +               }
> +               fill_seq_frame(data, TEST_FRAME_LEN, &DEV_MAC_TAG, round);
> +               if (do_tx_burst(pid, 0, &m, 1) != 1)
> +                       goto out;
> +               if (tap_collect_seq(seen, IDLE_WAKE_ROUNDS, &nb_seen, round + 1,
> +                                   TEST_FRAME_LEN, TAP_READ_TIMEOUT_US) != (int)(round + 1)) {
> +                       printf("Frame %u not sent after idle (seen %u)\n", round, nb_seen);
> +                       goto out;
> +               }
> +       }
> +       ret = TEST_SUCCESS;
> +out:
> +       fcntl(tap_fd, F_SETFL, flags);
> +       destroy_test_port(name, pid);
> +       return ret;
> +}
> +
> +/* Helper: Count open file descriptors of this process, or -1. */
> +static int
> +count_open_fds(void)
> +{
> +       struct dirent *de;
> +       DIR *dir;
> +       int n = 0;
> +
> +       dir = opendir("/proc/self/fd");
> +       if (dir == NULL)
> +               return -1;
> +       while ((de = readdir(dir)) != NULL)
> +               if (de->d_name[0] != '.')
> +                       n++;
> +       closedir(dir);
> +       return n;
> +}
> +
> +/*
> + * Test: Creating and closing io_uring ports, including ones sharing an
> + * SQPOLL thread (tx_io_uring_wq_num), does not leak file descriptors.
> + */
> +static int
> +test_af_packet_io_uring_create_destroy(void)
> +{
> +       const char *name = "net_af_packet_uring_cd";
> +       char devargs[256];
> +       int before, after, i;
> +       uint16_t pid;
> +
> +       if (!tap_created) {
> +               printf("SKIPPED: TAP interface not available (need root)\n");
> +               return TEST_SKIPPED;
> +       }
> +
> +       snprintf(devargs, sizeof(devargs),
> +                "iface=%s,qpairs=2,tx_io_uring_enabled=1,tx_io_uring_wq_num=1",
> +                TAP_DEV_NAME);
> +
> +       before = count_open_fds();
> +       for (i = 0; i < 10; i++) {
> +               TEST_ASSERT(create_af_packet_port(name, devargs, &pid) == 0,
> +                           "Failed to create port (iteration %d)", i);
> +               TEST_ASSERT(configure_af_packet_port(pid, 2, 2) == 0,
> +                           "Failed to configure port (iteration %d)", i);
> +               destroy_test_port(name, pid);
> +       }
> +       after = count_open_fds();
> +
> +       TEST_ASSERT(before >= 0 && before == after,
> +                   "Open fds %d before, %d after", before, after);
> +       return TEST_SUCCESS;
> +}
> +
> +/* Helper: Count this process's io_uring SQPOLL threads (comm "iou-sqp-<pid>"), or -1. */
> +static int
> +count_sqpoll_threads(void)
> +{
> +       char path[PATH_MAX], comm[32];
> +       struct dirent *de;
> +       DIR *dir;
> +       FILE *f;
> +       int n = 0;
> +
> +       dir = opendir("/proc/self/task");
> +       if (dir == NULL)
> +               return -1;
> +       while ((de = readdir(dir)) != NULL) {
> +               if (de->d_name[0] == '.')
> +                       continue;
> +               snprintf(path, sizeof(path), "/proc/self/task/%s/comm", de->d_name);
> +               f = fopen(path, "r");
> +               if (f == NULL)
> +                       continue;
> +               if (fgets(comm, sizeof(comm), f) != NULL && strncmp(comm, "iou-sqp-", 8) == 0)
> +                       n++;
> +               fclose(f);
> +       }
> +       closedir(dir);
> +       return n;
> +}
> +
> +/* Helper: Wait up to 1s for the SQPOLL thread count to reach want. Returns the count. */
> +static int
> +wait_sqpoll_threads(int want)
> +{
> +       int i, n = count_sqpoll_threads();
> +
> +       for (i = 0; i < 100 && n != want; i++) {
> +               rte_delay_ms(10);
> +               n = count_sqpoll_threads();
> +       }
> +       return n;
> +}
> +
> +/*
> + * Test: Queues share SQPOLL threads when tx_io_uring_wq_num is below the
> + * queue count (IORING_SETUP_ATTACH_WQ).
> + */
> +static int
> +test_af_packet_io_uring_shared_sqpoll(void)
> +{
> +       static const unsigned int wq_nums[] = { 1, 2 };
> +       const char *name = "net_af_packet_uring_wq";
> +       char devargs[256];
> +       unsigned int i;
> +       uint16_t pid;
> +       int n;
> +
> +       if (!tap_created) {
> +               printf("SKIPPED: TAP interface not available (need root)\n");
> +               return TEST_SKIPPED;
> +       }
> +       TEST_ASSERT(wait_sqpoll_threads(0) == 0, "SQPOLL threads left from earlier tests");
> +
> +       for (i = 0; i < RTE_DIM(wq_nums); i++) {
> +               snprintf(devargs, sizeof(devargs),
> +                        "iface=%s,qpairs=%d,tx_io_uring_enabled=1,tx_io_uring_wq_num=%u",
> +                        TAP_DEV_NAME, SQPOLL_QUEUES, wq_nums[i]);
> +               TEST_ASSERT(create_af_packet_port(name, devargs, &pid) == 0,
> +                           "Failed to create port");
> +               if (configure_af_packet_port(pid, SQPOLL_QUEUES, SQPOLL_QUEUES) != 0) {
> +                       destroy_test_port(name, pid);
> +                       return TEST_FAILED;
> +               }
> +               /* SQPOLL threads start and exit asynchronously; let the count settle */
> +               n = wait_sqpoll_threads(wq_nums[i]);
> +               destroy_test_port(name, pid);
> +
> +               if (n == 0) {
> +                       printf("SKIPPED: io_uring SQPOLL not available\n");
> +                       return TEST_SKIPPED;
> +               }
> +               printf("%d queues, %s=%u: %d SQPOLL threads\n", SQPOLL_QUEUES,
> +                      "tx_io_uring_wq_num", wq_nums[i], n);
> +               TEST_ASSERT(n == (int)wq_nums[i], "Expected %u SQPOLL threads, got %d",
> +                           wq_nums[i], n);
> +               TEST_ASSERT(wait_sqpoll_threads(0) == 0, "SQPOLL threads did not exit");
> +       }
> +       return TEST_SUCCESS;
> +}
> +
>  static struct unit_test_suite af_packet_test_suite = {
>         .suite_name = "AF_PACKET PMD Unit Test Suite",
>         .setup = test_af_packet_setup,
> @@ -2218,6 +2495,11 @@ static struct unit_test_suite af_packet_test_suite = {
>                 TEST_CASE(test_af_packet_invalid_txpollnotrdy),
>                 TEST_CASE(test_af_packet_txpollnotrdy_nonblocking),
>                 TEST_CASE(test_af_packet_tx_cksum),
> +               TEST_CASE(test_af_packet_invalid_io_uring_args),
> +               TEST_CASE(test_af_packet_io_uring_tx),
> +               TEST_CASE(test_af_packet_io_uring_idle_wakeup),
> +               TEST_CASE(test_af_packet_io_uring_create_destroy),
> +               TEST_CASE(test_af_packet_io_uring_shared_sqpoll),
>                 TEST_CASE(test_af_packet_qdisc_bypass),
>                 TEST_CASE(test_af_packet_multi_queue),
>                 TEST_CASE(test_af_packet_fanout_modes),
> diff --git a/doc/guides/nics/af_packet.rst b/doc/guides/nics/af_packet.rst
> index 7a6cc4ebe9..6e00db5165 100644
> --- a/doc/guides/nics/af_packet.rst
> +++ b/doc/guides/nics/af_packet.rst
> @@ -35,6 +35,22 @@ Some of these, in turn, will be used to configure the PACKET_MMAP settings.
>      space available to write to the kernel. If 1, call poll() and block until
>      space is available to tx. If 0, don't call poll() and return from tx (optional,
>      default 1).
> +*   ``tx_io_uring_enabled`` - Use io_uring to notify the kernel on tx (optional,
> +    default 0)
> +*   ``tx_io_uring_sq_size`` - Number of entries for the io_uring ring (optional,
> +    default 1024)
> +*   ``tx_io_uring_sq_thread_idle`` - Idle time (in milliseconds) before an io_uring
> +    SQPOLL thread goes to sleep (optional, default 500)
> +*   ``tx_io_uring_q_cpu`` - This argument can be repeated to specify CPU core
> +    affinity for each queue's io_uring SQPOLL kernel thread (see
> +    ``io_uring_params.sq_thread_cpu``). The first value applies to queue 0,
> +    the second to queue 1, etc. (optional, default empty). An unpinned SQPOLL
> +    thread may run on any CPU, so pin it when lcores run with real-time priority,
> +    where it could otherwise be starved.
> +*   ``tx_io_uring_wq_num`` - Number of SQPOLL kernel threads. On kernels with
> +    ``IORING_SETUP_ATTACH_WQ`` support, setting this lower than the queue count
> +    enables thread sharing across queues. If 0 or unspecified, no sharing is configured
> +    and each queue creates its own SQPOLL thread (optional, default 0)
>
>  For details regarding ``fanout_mode`` argument, you can consult the
>  `PACKET_FANOUT documentation <https://www.man7.org/linux/man-pages/man7/packet.7.html>`_.
> @@ -88,7 +104,7 @@ framecnt=512):
>
>  .. code-block:: console
>
> -    --vdev=eth_af_packet0,iface=tap0,blocksz=4096,framesz=2048,framecnt=512,qpairs=1,qdisc_bypass=1,fanout_mode=hash,txpollnotrdy=0
> +    --vdev=eth_af_packet0,iface=tap0,blocksz=4096,framesz=2048,framecnt=512,qpairs=1,qdisc_bypass=1,fanout_mode=hash,txpollnotrdy=0,tx_io_uring_enabled=1
>
>  Features and Limitations
>  ------------------------
> diff --git a/doc/guides/rel_notes/release_27_03.rst b/doc/guides/rel_notes/release_27_03.rst
> index c2b25c1387..76bc028afc 100644
> --- a/doc/guides/rel_notes/release_27_03.rst
> +++ b/doc/guides/rel_notes/release_27_03.rst
> @@ -60,6 +60,7 @@ New Features
>    * Added ``txpollnotrdy`` devarg to avoid ``poll()`` blocking calls.
>    * Added software checksum offload support for ``IPV4_CKSUM``, ``UDP_CKSUM``
>      and ``TCP_CKSUM``.
> +  * Added optional io_uring SQPOLL notification of the kernel on Tx.
>
>
>  Removed Items
> diff --git a/drivers/net/af_packet/meson.build b/drivers/net/af_packet/meson.build
> index f45e4491d4..a672262656 100644
> --- a/drivers/net/af_packet/meson.build
> +++ b/drivers/net/af_packet/meson.build
> @@ -5,5 +5,19 @@ if not is_linux
>      build = false
>      reason = 'only supported on Linux'
>  endif
> +
> +deps += ['ethdev']
> +
> +liburing_dep = dependency('liburing', required: false)
> +if not liburing_dep.found()
> +    message('AF_PACKET PMD: liburing not found, fallback to sendto()')
> +elif not liburing_dep.version().version_compare('>=2.4')
> +    message('AF_PACKET PMD: liburing version too old, need >= 2.4. fallback to sendto()')
> +else
> +    ext_deps += liburing_dep
> +    cflags += '-DRTE_NET_AF_PACKET_HAVE_LIBURING'
> +    message('AF_PACKET PMD: liburing @0@ support enabled'.format(liburing_dep.version()))
> +endif
> +
>  sources = files('rte_eth_af_packet.c')
>  require_iova_in_mbuf = false
> diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
> index f21be21009..37e29048e9 100644
> --- a/drivers/net/af_packet/rte_eth_af_packet.c
> +++ b/drivers/net/af_packet/rte_eth_af_packet.c
> @@ -20,6 +20,10 @@
>  #include <bus_vdev_driver.h>
>
>  #include <ctype.h>
> +#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
> +#include <liburing.h>
> +#endif
> +
>  #include <errno.h>
>  #include <limits.h>
>  #include <linux/if_ether.h>
> @@ -55,10 +59,22 @@
>  #define ETH_AF_PACKET_FANOUT_MODE_ARG  "fanout_mode"
>  #define ETH_AF_PACKET_IGNORE_OUTGOING_ARG      "ignore_outgoing"
>  #define ETH_AF_PACKET_TX_POLL_NOT_READY_ARG    "txpollnotrdy"
> +#define ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG  "tx_io_uring_enabled"
> +#define ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG  "tx_io_uring_sq_size"
> +#define ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG   "tx_io_uring_sq_thread_idle"
> +#define ETH_AF_PACKET_TX_IO_URING_Q_CPU        "tx_io_uring_q_cpu"
> +#define ETH_AF_PACKET_TX_IO_URING_WQ_NUM       "tx_io_uring_wq_num"
>
>  #define DFLT_FRAME_SIZE                (1 << 11)
>  #define DFLT_FRAME_COUNT       (1 << 9)
>  #define DFLT_TX_POLL_NOT_RDY   1
> +#define DFLT_TX_IO_URING_ENABLED       false
> +#define DFLT_TX_IO_URING_SQ_SIZE       1024
> +#define ETH_AF_PACKET_URING_SQ_SIZE_MAX        32768
> +#define DFLT_TX_IO_URING_SQ_THREAD_IDLE_MS     500
> +
> +/* io_uring registered file descriptor index for the socket fd */
> +#define ETH_AF_PACKET_URING_SOCKFD_INDEX       0
>
>  #define ETH_AF_PACKET_FRAME_OVERHEAD (TPACKET2_HDRLEN - sizeof(struct sockaddr_ll))
>
> @@ -95,6 +111,12 @@ struct __rte_cache_aligned pkt_tx_queue {
>         unsigned int framecount;
>         unsigned int framenum;
>
> +#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
> +       struct io_uring uring_ring;
> +       bool uring_enabled;
> +       uint32_t uring_sqe_since_cq_advance;
> +#endif
> +
>         bool txpollnotrdy;
>         bool sw_cksum;
>
> @@ -117,6 +139,11 @@ struct pmd_internals {
>         uint8_t vlan_strip;
>         uint8_t timestamp_offloading;
>         bool tx_sw_cksum;
> +
> +#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
> +       struct io_uring **shared_uring_rings;
> +       uint32_t shared_uring_count;
> +#endif
>  };
>
>  static const char *valid_arguments[] = {
> @@ -129,6 +156,11 @@ static const char *valid_arguments[] = {
>         ETH_AF_PACKET_FANOUT_MODE_ARG,
>         ETH_AF_PACKET_IGNORE_OUTGOING_ARG,
>         ETH_AF_PACKET_TX_POLL_NOT_READY_ARG,
> +       ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG,
> +       ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG,
> +       ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG,
> +       ETH_AF_PACKET_TX_IO_URING_Q_CPU,
> +       ETH_AF_PACKET_TX_IO_URING_WQ_NUM,
>         NULL
>  };
>
> @@ -211,6 +243,198 @@ tpacket_write_status(volatile void *tp_status, uint32_t status)
>         *((volatile unaligned_uint32_t *)tp_status) = status;
>  }
>
> +#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
> +/*
> + * Create a ring. The kernel rejects unsupported setup flags with -EINVAL before
> + * creating anything, so optional flags are dropped one at a time and retried.
> + */
> +static int
> +af_packet_io_uring_init(struct io_uring *ring, uint32_t entries,
> +                       struct io_uring_params *params, unsigned int q)
> +{
> +       static const struct {
> +               uint32_t flag;
> +               const char *name;
> +       } optional[] = {
> +               { IORING_SETUP_SINGLE_ISSUER, "IORING_SETUP_SINGLE_ISSUER" },
> +               { IORING_SETUP_SQ_AFF, "IORING_SETUP_SQ_AFF (SQPOLL CPU pinning)" },
> +       };
> +       struct io_uring_params p = *params;
> +       unsigned int i;
> +       int rc;
> +
> +       rc = io_uring_queue_init_params(entries, ring, &p);
> +       for (i = 0; rc == -EINVAL && i < RTE_DIM(optional); i++) {
> +               if ((params->flags & optional[i].flag) == 0)
> +                       continue;
> +               params->flags &= ~optional[i].flag;
> +               PMD_LOG(NOTICE, "AF_PACKET PMD io_uring tx_queue=%u: %s rejected, retrying without it",
> +                       q, optional[i].name);
> +               p = *params;
> +               rc = io_uring_queue_init_params(entries, ring, &p);
> +       }
> +       if (rc == 0)
> +               *params = p;
> +       return rc;
> +}
> +#endif /* RTE_NET_AF_PACKET_HAVE_LIBURING */
> +
> +static void
> +af_packet_io_uring_share_uring_init(struct pmd_internals *internals,
> +                               const unsigned int numa_node,
> +                               const unsigned int nb_queues,
> +                               const bool tx_io_uring_enabled,
> +                               const uint32_t tx_io_uring_kq_cores_size,
> +                               const uint32_t tx_io_uring_wq_num)
> +{
> +#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
> +       if (!tx_io_uring_enabled)
> +               return;
> +
> +       if (tx_io_uring_wq_num <= 0)
> +               return;
> +
> +       /* Rings attach to a queue's SQPOLL thread with IORING_SETUP_ATTACH_WQ. Support
> +        * can't be probed without a ring to attach to, so failures are handled per queue.
> +        */
> +       internals->shared_uring_rings =
> +               rte_calloc_socket("af_packet_shared_uring", tx_io_uring_wq_num,
> +                       sizeof(*internals->shared_uring_rings), 0, numa_node);
> +       if (!internals->shared_uring_rings) {
> +               PMD_LOG(ERR, "Failed to allocate shared io_uring rings");
> +               return;
> +       }
> +       internals->shared_uring_count = tx_io_uring_wq_num;
> +
> +       if (tx_io_uring_kq_cores_size > tx_io_uring_wq_num) {
> +               PMD_LOG(WARNING,
> +                       "AF_PACKET PMD %s count=%" PRIu32 " > %s=%" PRIu32 ", "
> +                       "extra CPU affinities will be ignored",
> +                       ETH_AF_PACKET_TX_IO_URING_Q_CPU, tx_io_uring_kq_cores_size,
> +                       ETH_AF_PACKET_TX_IO_URING_WQ_NUM, tx_io_uring_wq_num);
> +       }
> +
> +       if (nb_queues % tx_io_uring_wq_num != 0) {
> +               PMD_LOG(INFO,
> +                       "AF_PACKET PMD %s=%u not divisible by %s=%" PRIu32 ", "
> +                       "SQPOLL thread work may be imbalanced",
> +                       ETH_AF_PACKET_NUM_Q_ARG, nb_queues,
> +                       ETH_AF_PACKET_TX_IO_URING_WQ_NUM, tx_io_uring_wq_num);
> +       }
> +#else
> +       if (tx_io_uring_enabled) {
> +               PMD_LOG(NOTICE,
> +                       "AF_PACKET PMD %s enabled, but feature not enabled at compile time.",
> +                       ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG);
> +       }
> +       RTE_SET_USED(internals);
> +       RTE_SET_USED(numa_node);
> +       RTE_SET_USED(nb_queues);
> +       RTE_SET_USED(tx_io_uring_kq_cores_size);
> +       RTE_SET_USED(tx_io_uring_wq_num);
> +#endif /* RTE_NET_AF_PACKET_HAVE_LIBURING */
> +}
> +
> +static void
> +af_packet_io_uring_tx_queue_init(struct pmd_internals *internals,
> +                               const unsigned int q,
> +                               const bool tx_io_uring_enabled,
> +                               const uint32_t tx_io_uring_sq_size,
> +                               const uint32_t tx_io_uring_sq_thread_idle_ms,
> +                               const uint32_t *tx_io_uring_kq_cores,
> +                               const uint32_t tx_io_uring_kq_cores_size)
> +{
> +#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
> +       if (!tx_io_uring_enabled)
> +               return;
> +
> +       int rc;
> +       struct pkt_tx_queue *tx_queue = &internals->tx_queue[q];
> +       struct io_uring_params uring_params = {
> +               .sq_thread_idle = tx_io_uring_sq_thread_idle_ms,
> +               .flags = IORING_SETUP_SQPOLL,
> +       };
> +
> +       /* Determine if attaching to existing ring or creating new one */
> +       uint32_t ring_idx = internals->shared_uring_rings ? q % internals->shared_uring_count : 0;
> +       bool attach_mode = internals->shared_uring_rings && ring_idx < q &&
> +                       internals->shared_uring_rings[ring_idx];
> +
> +       if (attach_mode) {
> +               /* Share the group's SQPOLL thread; the ring's memory and lifetime stay per queue */
> +               uring_params.flags |= IORING_SETUP_ATTACH_WQ;
> +               uring_params.wq_fd = internals->shared_uring_rings[ring_idx]->ring_fd;
> +       } else {
> +               /* Create new ring: add CPU affinity if configured */
> +               if (tx_io_uring_kq_cores_size > 0) {
> +                       uint32_t cpu_idx = internals->shared_uring_rings ? ring_idx : q;
> +                       if (cpu_idx < tx_io_uring_kq_cores_size) {
> +                               uring_params.flags |= IORING_SETUP_SQ_AFF;
> +                               uring_params.sq_thread_cpu = tx_io_uring_kq_cores[cpu_idx];
> +                       } else {
> +                               PMD_LOG(DEBUG,
> +                                       "AF_PACKET PMD io_uring tx_queue=%u > %s size=%" PRIu32 " "
> +                                       "and will not be CPU pinned", q,
> +                                       ETH_AF_PACKET_TX_IO_URING_Q_CPU,
> +                                       tx_io_uring_kq_cores_size);
> +                       }
> +               }
> +
> +               uring_params.flags |= IORING_SETUP_SINGLE_ISSUER;
> +       }
> +
> +       rc = af_packet_io_uring_init(&tx_queue->uring_ring, tx_io_uring_sq_size,
> +                       &uring_params, q);
> +       if (rc < 0 && attach_mode) {
> +               PMD_LOG(WARNING, "AF_PACKET PMD io_uring IORING_SETUP_ATTACH_WQ failed (error %d: %s), "
> +                       "tx_queue=%u uses its own SQPOLL thread", -rc, strerror(-rc), q);
> +               attach_mode = false;
> +               uring_params.flags &= ~IORING_SETUP_ATTACH_WQ;
> +               uring_params.wq_fd = 0;
> +               rc = af_packet_io_uring_init(&tx_queue->uring_ring, tx_io_uring_sq_size,
> +                               &uring_params, q);
> +       }
> +       if (rc < 0) {
> +               PMD_LOG(WARNING, "AF_PACKET PMD Failed io_uring_queue_init_params (error %d: %s), "
> +                       "tx_queue=%u sq_size=%" PRIu32 " flags=0x%X sq_thread_cpu=%u "
> +                       "sq_thread_idle=%u, falling back to synchronous sendto()",
> +                       -rc, strerror(-rc), q, tx_io_uring_sq_size, uring_params.flags,
> +                       uring_params.sq_thread_cpu, uring_params.sq_thread_idle);
> +               return;
> +       }
> +
> +       /* Register the sockfd at index ETH_AF_PACKET_URING_SOCKFD_INDEX */
> +       rc = io_uring_register_files(&tx_queue->uring_ring, &tx_queue->sockfd, 1);
> +       if (rc < 0) {
> +               PMD_LOG(WARNING, "AF_PACKET PMD Failed io_uring_register_files (error %d: %s)",
> +                               -rc, strerror(-rc));
> +               io_uring_queue_exit(&tx_queue->uring_ring);
> +               return;
> +       }
> +
> +       tx_queue->uring_enabled = true;
> +       tx_queue->uring_sqe_since_cq_advance = 0;
> +
> +       if (!attach_mode && internals->shared_uring_rings &&
> +           !internals->shared_uring_rings[ring_idx])
> +               internals->shared_uring_rings[ring_idx] = &tx_queue->uring_ring;
> +
> +       PMD_LOG(DEBUG, "AF_PACKET PMD io_uring SQPOLL%s enabled tx_queue=%u ring_idx=%u "
> +               "tx_io_uring_sq_size=%" PRIu32 " kthread_cpu=%u sq_thread_idle=%u flags=0x%X",
> +               attach_mode ? "+ATTACH_WQ" : "", q, ring_idx, tx_io_uring_sq_size,
> +               uring_params.sq_thread_cpu, uring_params.sq_thread_idle, uring_params.flags);
> +
> +#else
> +       RTE_SET_USED(internals);
> +       RTE_SET_USED(q);
> +       RTE_SET_USED(tx_io_uring_enabled);
> +       RTE_SET_USED(tx_io_uring_sq_size);
> +       RTE_SET_USED(tx_io_uring_sq_thread_idle_ms);
> +       RTE_SET_USED(tx_io_uring_kq_cores);
> +       RTE_SET_USED(tx_io_uring_kq_cores_size);
> +#endif /* RTE_NET_AF_PACKET_HAVE_LIBURING */
> +}
> +
>  static uint16_t
>  eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
>  {
> @@ -346,6 +570,61 @@ tx_ring_status_available(uint32_t tp_status)
>         return tp_status == TP_STATUS_AVAILABLE;
>  }
>
> +/*
> + * Kick the kernel to transmit packets in the ring.
> + *
> + * The sendto() call with NULL buffer is a notification to the kernel that
> + * frames have been queued (marked TP_STATUS_SEND_REQUEST) in the ring.
> + * The kernel will eventually process all queued frames regardless of whether
> + * this kick succeeds or fails. We don't check for errors because:
> + *
> + * 1. Data is already in the ring - the PMD's work is complete
> + * 2. ENOBUFS/EAGAIN just mean "try again later" - kernel will still process ring
> + * 3. Fatal errors (EBADF) indicate socket is broken - subsequent ops will fail
> + * 4. Consistent with io_uring path which doesn't check completion status
> + */
> +static inline void
> +eth_af_packet_tx_kick(struct pkt_tx_queue *pkt_q)
> +{
> +#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
> +       if (pkt_q->uring_enabled) {
> +               /* Batch CQ advancement: only advance every sq_size submissions to amortize
> +                * memory barrier cost (2 load_acquire + 1 store_release). With
> +                * IOSQE_CQE_SKIP_SUCCESS, CQ is mostly empty (successes don't generate CQEs).
> +                * This prevents rare failure CQEs from accumulating while minimizing overhead.
> +                */
> +               if (++pkt_q->uring_sqe_since_cq_advance >= pkt_q->uring_ring.sq.ring_entries) {
> +                       io_uring_cq_advance(&pkt_q->uring_ring,
> +                                       io_uring_cq_ready(&pkt_q->uring_ring));
> +                       pkt_q->uring_sqe_since_cq_advance = 0;
> +               }
> +
> +               struct io_uring_sqe *sqe = io_uring_get_sqe(&pkt_q->uring_ring);
> +               /* If no sqe available skip this notification and wait for kernel to catch up.
> +                * Avoid fall back sendto() so we don't block the application thread and it is
> +                * highly likely the kernel will process pending events and/or subsequent TX
> +                * will generate new notification.
> +                */
> +               if (unlikely(sqe == NULL))
> +                       return;
> +
> +               /* Use registered fd (see io_uring_register_files call during setup) */
> +               io_uring_prep_send(sqe, ETH_AF_PACKET_URING_SOCKFD_INDEX, NULL, 0, MSG_DONTWAIT);
> +               io_uring_sqe_set_flags(sqe, IOSQE_FIXED_FILE | IOSQE_CQE_SKIP_SUCCESS);
> +               io_uring_sqe_set_data(sqe, NULL);
> +
> +               /* With SQPOLL this only enters the kernel to wake a sleeping SQ thread;
> +                * its full barrier orders the tail store before the NEED_WAKEUP check.
> +                */
> +               io_uring_submit(&pkt_q->uring_ring);
> +       } else {
> +               sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0);
> +       }
> +#else
> +       sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0);
> +#endif
> +}
> +
>  /*
>   * Callback to handle sending packets through a real NIC.
>   */
> @@ -436,19 +715,8 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
>
>         rte_pktmbuf_free_bulk(&bufs[0], i);
>
> -       /* kick-off transmits */
> -       if (unlikely(num_tx > 0 &&
> -                    sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1 &&
> -                    errno != ENOBUFS && errno != EAGAIN)) {
> -               /*
> -                * In case of a ENOBUFS/EAGAIN error all of the enqueued
> -                * packets will be considered successful even though only some
> -                * are sent.
> -                */
> -
> -               num_tx = 0;
> -               num_tx_bytes = 0;
> -       }
> +       if (likely(num_tx > 0))
> +               eth_af_packet_tx_kick(pkt_q);
>
>         pkt_q->framenum = framenum;
>         pkt_q->tx_pkts += num_tx;
> @@ -659,11 +927,22 @@ eth_dev_close(struct rte_eth_dev *dev)
>                 internals->rx_queue[q].sockfd = -1;
>                 internals->tx_queue[q].sockfd = -1;
>
> +#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
> +               if (internals->tx_queue[q].uring_enabled) {
> +                       io_uring_unregister_files(&internals->tx_queue[q].uring_ring);
> +                       io_uring_queue_exit(&internals->tx_queue[q].uring_ring);
> +                       internals->tx_queue[q].uring_enabled = false;
> +               }
> +#endif
> +
>                 munmap(internals->rx_queue[q].map,
>                         2 * req->tp_block_size * req->tp_block_nr);
>                 rte_free(internals->rx_queue[q].rd);
>                 rte_free(internals->tx_queue[q].rd);
>         }
> +#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
> +       rte_free(internals->shared_uring_rings);
> +#endif
>         rte_free(internals->if_name);
>         rte_free(internals->rx_queue);
>         rte_free(internals->tx_queue);
> @@ -939,6 +1218,12 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
>                        const char *fanout_mode,
>                        unsigned int ignore_outgoing,
>                        bool txpollnotrdy,
> +                      bool tx_io_uring_enabled,
> +                      uint32_t tx_io_uring_sq_size,
> +                      uint32_t tx_io_uring_sq_thread_idle_ms,
> +                      uint32_t *tx_io_uring_kq_cores,
> +                      uint32_t tx_io_uring_kq_cores_size,
> +                      uint32_t tx_io_uring_wq_num,
>                        struct pmd_internals **internals,
>                        struct rte_eth_dev **eth_dev,
>                        struct rte_kvargs *kvlist)
> @@ -1053,6 +1338,9 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
>         if (ignore_outgoing != 0 && nb_queues > 1)
>                 fanout_arg |= PACKET_FANOUT_FLAG_IGNORE_OUTGOING << 16;
>
> +       af_packet_io_uring_share_uring_init(*internals, numa_node, nb_queues,
> +                       tx_io_uring_enabled, tx_io_uring_kq_cores_size, tx_io_uring_wq_num);
> +
>         for (q = 0; q < nb_queues; q++) {
>                 /* Open an AF_PACKET socket for this queue... */
>                 qsockfd = socket(AF_PACKET, SOCK_RAW, 0);
> @@ -1206,6 +1494,10 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
>                                 goto error;
>                         }
>                 }
> +
> +               af_packet_io_uring_tx_queue_init(*internals, q, tx_io_uring_enabled,
> +                       tx_io_uring_sq_size, tx_io_uring_sq_thread_idle_ms, tx_io_uring_kq_cores,
> +                       tx_io_uring_kq_cores_size);
>         }
>
>         /* reserve an ethdev entry */
> @@ -1239,6 +1531,13 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
>         if (qsockfd != -1)
>                 close(qsockfd);
>         for (q = 0; q < nb_queues; q++) {
> +#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
> +               if ((*internals)->tx_queue[q].uring_enabled) {
> +                       io_uring_unregister_files(&(*internals)->tx_queue[q].uring_ring);
> +                       io_uring_queue_exit(&(*internals)->tx_queue[q].uring_ring);
> +                       (*internals)->tx_queue[q].uring_enabled = false;
> +               }
> +#endif
>                 if ((*internals)->rx_queue[q].map != MAP_FAILED)
>                         munmap((*internals)->rx_queue[q].map,
>                                2 * req->tp_block_size * req->tp_block_nr);
> @@ -1250,6 +1549,9 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
>                         close((*internals)->rx_queue[q].sockfd);
>         }
>  free_internals:
> +#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
> +       rte_free((*internals)->shared_uring_rings);
> +#endif
>         rte_free((*internals)->rx_queue);
>         rte_free((*internals)->tx_queue);
>         rte_free((*internals)->if_name);
> @@ -1313,6 +1615,13 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
>         const char *fanout_mode = NULL;
>         unsigned int ignore_outgoing = 0;
>         unsigned int txpollnotrdy = DFLT_TX_POLL_NOT_RDY;
> +       bool tx_io_uring_enabled = DFLT_TX_IO_URING_ENABLED;
> +       uint32_t tx_io_uring_sq_size = DFLT_TX_IO_URING_SQ_SIZE;
> +       uint32_t tx_io_uring_sq_thread_idle_ms = DFLT_TX_IO_URING_SQ_THREAD_IDLE_MS;
> +       uint32_t tx_io_uring_kq_cores[RTE_MAX_QUEUES_PER_PORT] = {};
> +       uint32_t tx_io_uring_kq_cores_size = 0;
> +       uint32_t tx_io_uring_wq_num = 0;
> +       unsigned int uval;
>
>         /* do some parameter checking */
>         if (*sockfd < 0)
> @@ -1387,6 +1696,47 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
>                                 return -1;
>                         continue;
>                 }
> +               if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG) != NULL) {
> +                       if (parse_uint(pair->key, pair->value, &uval, 1) < 0)
> +                               return -1;
> +                       tx_io_uring_enabled = uval != 0;
> +                       continue;
> +               }
> +               if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG) != NULL) {
> +                       if (parse_uint(pair->key, pair->value, &uval,
> +                                      ETH_AF_PACKET_URING_SQ_SIZE_MAX) < 0)
> +                               return -1;
> +                       if (uval == 0) {
> +                               PMD_LOG(ERR, "%s: %s must be > 0", name,
> +                                       ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG);
> +                               return -1;
> +                       }
> +                       tx_io_uring_sq_size = uval;
> +                       continue;
> +               }
> +               if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG) != NULL) {
> +                       if (parse_uint(pair->key, pair->value, &uval, UINT32_MAX) < 0)
> +                               return -1;
> +                       tx_io_uring_sq_thread_idle_ms = uval;
> +                       continue;
> +               }
> +               if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_Q_CPU) != NULL) {
> +                       if (parse_uint(pair->key, pair->value, &uval, UINT32_MAX) < 0)
> +                               return -1;
> +                       if (tx_io_uring_kq_cores_size >= RTE_MAX_QUEUES_PER_PORT) {
> +                               PMD_LOG(ERR, "%s: too many %s args, max of %d", name,
> +                                       ETH_AF_PACKET_TX_IO_URING_Q_CPU, RTE_MAX_QUEUES_PER_PORT);
> +                               return -1;
> +                       }
> +                       tx_io_uring_kq_cores[tx_io_uring_kq_cores_size++] = uval;
> +                       continue;
> +               }
> +               if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_WQ_NUM) != NULL) {
> +                       if (parse_uint(pair->key, pair->value, &uval, RTE_MAX_QUEUES_PER_PORT) < 0)
> +                               return -1;
> +                       tx_io_uring_wq_num = uval;
> +                       continue;
> +               }
>         }
>
>         if (framesize > blocksize) {
> @@ -1458,6 +1808,19 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
>         PMD_LOG(DEBUG, "%s:\tignore outgoing %u", name, ignore_outgoing);
>         PMD_LOG(DEBUG, "%s:\ttxpollnotrdy %u", name, txpollnotrdy);
>
> +       PMD_LOG(INFO, "%s:\t%s %d", name,
> +               ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG, tx_io_uring_enabled ? 1 : 0);
> +       PMD_LOG(INFO, "%s:\t%s %" PRIu32, name,
> +               ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG, tx_io_uring_sq_size);
> +       PMD_LOG(INFO, "%s:\t%s %" PRIu32, name,
> +               ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG, tx_io_uring_sq_thread_idle_ms);
> +       for (uint32_t cpu_i = 0; cpu_i < tx_io_uring_kq_cores_size; cpu_i++) {
> +               PMD_LOG(INFO, "%s:\t%s[%" PRIu32 "] %" PRIu32, name,
> +                       ETH_AF_PACKET_TX_IO_URING_Q_CPU, cpu_i, tx_io_uring_kq_cores[cpu_i]);
> +       }
> +       PMD_LOG(INFO, "%s:\t%s %" PRIu32, name,
> +               ETH_AF_PACKET_TX_IO_URING_WQ_NUM, tx_io_uring_wq_num);
> +
>         if (rte_pmd_init_internals(dev, *sockfd, qpairs,
>                                    blocksize, blockcount,
>                                    framesize, framecount,
> @@ -1465,6 +1828,9 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
>                                    fanout_mode,
>                                    ignore_outgoing,
>                                    txpollnotrdy != 0,
> +                                  tx_io_uring_enabled, tx_io_uring_sq_size,
> +                                  tx_io_uring_sq_thread_idle_ms, tx_io_uring_kq_cores,
> +                                  tx_io_uring_kq_cores_size, tx_io_uring_wq_num,
>                                    &internals, &eth_dev,
>                                    kvlist) < 0)
>                 return -1;
> @@ -1564,4 +1930,9 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_packet,
>         "qdisc_bypass=<0|1> "
>         "fanout_mode=<hash|lb|cpu|rollover|rnd|qm> "
>         "ignore_outgoing=<0|1> "
> -       "txpollnotrdy=<0|1>");
> +       "txpollnotrdy=<0|1> "
> +       "tx_io_uring_enabled=<0|1> "
> +       "tx_io_uring_sq_size=<int> "
> +       "tx_io_uring_sq_thread_idle=<int> "
> +       "tx_io_uring_q_cpu=<int> "
> +       "tx_io_uring_wq_num=<int>");
> --
> 2.54.0 (Apple Git-157)
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC v1] net/af_packet: add io_uring TX acceleration
  2026-02-04 16:12 [RFC v1] net/af_packet: add io_uring TX acceleration scott.k.mitch1
  2026-02-04 16:52 ` Stephen Hemminger
  2026-12-01 22:36 ` [RFC PATCH v2] " Scott Mitchell
@ 2026-12-02 16:59 ` Stephen Hemminger
  2026-12-02 17:02 ` Stephen Hemminger
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2026-12-02 16:59 UTC (permalink / raw)
  To: scott.k.mitch1; +Cc: dev

On Wed,  4 Feb 2026 08:12:02 -0800
scott.k.mitch1@gmail.com wrote:

> +	RTE_SET_USED(internals);
> +	RTE_SET_USED(numa_node);
> +	RTE_SET_USED(nb_queues);
> +	RTE_SET_USED(tx_io_uring_kq_cores_size);
> +	RTE_SET_USED(tx_io_uring_wq_num);

My personal preference is to use __rte_unused attribute on the parameters
rather than these kind of macros.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC v1] net/af_packet: add io_uring TX acceleration
  2026-02-04 16:12 [RFC v1] net/af_packet: add io_uring TX acceleration scott.k.mitch1
                   ` (2 preceding siblings ...)
  2026-12-02 16:59 ` [RFC v1] net/af_packet: add io_uring TX acceleration Stephen Hemminger
@ 2026-12-02 17:02 ` Stephen Hemminger
  2026-12-02 17:03 ` Stephen Hemminger
  2026-12-02 17:04 ` Stephen Hemminger
  5 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2026-12-02 17:02 UTC (permalink / raw)
  To: scott.k.mitch1; +Cc: dev

On Wed,  4 Feb 2026 08:12:02 -0800
scott.k.mitch1@gmail.com wrote:

> +	if (rc < 0) {
> +		PMD_LOG(WARNING, "AF_PACKET PMD Failed io_uring_queue_init_params (error %d: %s), "
> +			"tx_queue=%u sq_size=%" PRIu32 " flags=0x%X sq_thread_cpu=%u "
> +			"sq_thread_idle=%u, falling back to synchronous sendto()",
> +			-rc, strerror(-rc), q, tx_io_uring_sq_size, uring_params.flags,
> +			uring_params.sq_thread_cpu, uring_params.sq_thread_idle);
> +		return;

The log messages here are getting too long. If you really need debug info better
done by tracing.

Also it looks like if any of this fails driver will be left in a bad state
without telling user.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC v1] net/af_packet: add io_uring TX acceleration
  2026-02-04 16:12 [RFC v1] net/af_packet: add io_uring TX acceleration scott.k.mitch1
                   ` (3 preceding siblings ...)
  2026-12-02 17:02 ` Stephen Hemminger
@ 2026-12-02 17:03 ` Stephen Hemminger
  2026-12-02 17:04 ` Stephen Hemminger
  5 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2026-12-02 17:03 UTC (permalink / raw)
  To: scott.k.mitch1; +Cc: dev

On Wed,  4 Feb 2026 08:12:02 -0800
scott.k.mitch1@gmail.com wrote:

> @@ -834,6 +1119,12 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
>  		       unsigned int qdisc_bypass,
>  		       const char *fanout_mode,
>  			bool txpollnotrdy,
> +			bool tx_io_uring_enabled,
> +			uint32_t tx_io_uring_sq_size,
> +			uint32_t tx_io_uring_sq_thread_idle_ms,
> +			uint32_t *tx_io_uring_kq_cores,
> +			uint32_t tx_io_uring_kq_cores_size,
> +			uint32_t tx_io_uring_wq_num,

These all look like they should be in one struct.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC v1] net/af_packet: add io_uring TX acceleration
  2026-02-04 16:12 [RFC v1] net/af_packet: add io_uring TX acceleration scott.k.mitch1
                   ` (4 preceding siblings ...)
  2026-12-02 17:03 ` Stephen Hemminger
@ 2026-12-02 17:04 ` Stephen Hemminger
  5 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2026-12-02 17:04 UTC (permalink / raw)
  To: scott.k.mitch1; +Cc: dev

On Wed,  4 Feb 2026 08:12:02 -0800
scott.k.mitch1@gmail.com wrote:

> +#ifdef RTE_NET_AF_PACKET_HAVE_LIBURING
> +	rte_free(internals->shared_uring_rings);
> +#endif

you might be able to skip #ifdef if shared_uring_rings is not inside #ifdef.
If not using uring then it will always be NULL and rte_free(NULL) is like free(NULL)
and always ok.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH v2] net/af_packet: add io_uring TX acceleration
  2026-12-01 22:44   ` Scott Mitchell
@ 2026-12-02 17:16     ` Stephen Hemminger
  2026-12-02 18:52       ` Scott Mitchell
  0 siblings, 1 reply; 15+ messages in thread
From: Stephen Hemminger @ 2026-12-02 17:16 UTC (permalink / raw)
  To: Scott Mitchell; +Cc: dev

On Tue, 1 Dec 2026 14:44:56 -0800
Scott Mitchell <scott.k.mitch1@gmail.com> wrote:

> Hi Stephen,
> 
> RFCv2 is a rebase with tests and fixes. Before going further I'd
> like to settle where this belongs, since the v1 feedback was
> "I would rather it be a different driver than af_packet".
> 
> As far as I can tell the io_uring driver RFC wasn't merged, so I want
> to understand what you'd like to see. The two solve different problems:
> 
> - A TAP-style io_uring driver replaces per-packet read()/write() with
>   io_uring ops.
> - af_packet has no per-packet syscalls; PACKET_MMAP rings carry the
>   data. The only syscall is the sendto() TX notify, and that is all
>   this patch replaces, so the kernel's TX processing runs on an SQPOLL
>   thread instead of the PMD lcore.
> 
> A separate driver would duplicate the PACKET_MMAP ring handling to
> change that one call. The feature is opt-in (tx_io_uring_enabled=0 by
> default) and compiled out without liburing.
> 
> Would you accept it in af_packet in this form? If not, what would you
> want changed, or is there a driver it should be built on instead?

Several items here:
  - yes af_packet and tap are solving different things. So both need to
    stay in DPDK and be as efficient as possible.
  - I never went farther with rtap because it only had small gains over tap
    and virtio was better. Virtio with ring buffer is going to win over syscalls.
  - Testing using liburing for pcapng write path and probably other places will
    need it over time.

Put detection in common place:

diff --git a/config/meson.build b/config/meson.build
index bfac1cd93d..8212cb2cb2 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -301,6 +301,12 @@ if (pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
     dpdk_extra_ldflags += '-l@0@'.format(pcap_lib)
 endif
 
+# check for liburing
+iouring_dep = dependency('liburing', required: false, method: 'pkg-config')
+if iouring_dep.found()
+    dpdk_conf.set('RTE_HAS_LIBURING', 1)
+endif
+
 # for clang 32-bit compiles we need libatomic for 64-bit atomic ops
 if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
     atomic_dep = cc.find_library('atomic', required: true)

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH v2] net/af_packet: add io_uring TX acceleration
  2026-12-02 17:16     ` Stephen Hemminger
@ 2026-12-02 18:52       ` Scott Mitchell
  0 siblings, 0 replies; 15+ messages in thread
From: Scott Mitchell @ 2026-12-02 18:52 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

Thanks for the feedback Stephen! I will address your feedback in
followup and move from RFC to patch.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v3 0/2] net/af_packet: add io_uring Tx acceleration
  2026-12-01 22:36 ` [RFC PATCH v2] " Scott Mitchell
  2026-12-01 22:44   ` Scott Mitchell
@ 2026-12-02 18:54   ` Scott Mitchell
  2026-12-02 18:54     ` [PATCH v3 1/2] config: detect liburing Scott Mitchell
  2026-12-02 18:54     ` [PATCH v3 2/2] net/af_packet: add iouring Tx acceleration Scott Mitchell
  1 sibling, 2 replies; 15+ messages in thread
From: Scott Mitchell @ 2026-12-02 18:54 UTC (permalink / raw)
  To: dev; +Cc: stephen, thomas, david.marchand, mb, Scott Mitchell

Kick the af_packet Tx ring through an io_uring SQPOLL thread instead of
sendto(), so the kernel's Tx processing runs on a kernel thread rather
than the PMD lcore. Patch 1 adds common liburing detection, patch 2 uses
it in af_packet.

Depends-on: series-40243 ("net/af_packet fixes and Tx features")

v3:
* No longer an RFC: io_uring stays in af_packet. (Stephen)
* New patch 1/2 detects liburing (>= 2.4) in config/meson.build and sets
  RTE_HAS_LIBURING. (Stephen)
* Probe fails if tx_io_uring_enabled is set and io_uring can't be set
  up, instead of falling back to sendto(). (Stephen)
* io_uring devargs are passed in one struct; __rte_unused replaces
  RTE_SET_USED(); shared_uring_rings needs no #ifdef; shorter logs.
  (Stephen)
* A kick that finds the submission queue full falls back to sendto()
  instead of being dropped.
* Probe fails if the kernel lacks IORING_OP_SEND (Linux 5.6), and
  IOSQE_CQE_SKIP_SUCCESS is used only where supported (5.17); before,
  every kick failed on older kernels and Tx stalled.
* The kick runs on every non-empty burst; sendto() error accounting is
  unchanged.
* Docs: tx_io_uring_q_cpu indexing with tx_io_uring_wq_num,
  sq_thread_idle=0, and Tx queue selection by the SQPOLL thread CPU.
* Tests skip when io_uring SQPOLL is unavailable, check that the SQPOLL
  thread exists, wait long enough for it to sleep at HZ=100, and require
  stable thread counts; a new test checks that probe fails cleanly.

Scott Mitchell (2):
  config: detect liburing
  net/af_packet: add iouring Tx acceleration

 app/test/test_pmd_af_packet.c             | 391 ++++++++++++++++++++++
 config/meson.build                        |   6 +
 doc/guides/nics/af_packet.rst             |  24 ++
 doc/guides/rel_notes/release_27_03.rst    |   1 +
 drivers/net/af_packet/meson.build         |   7 +
 drivers/net/af_packet/rte_eth_af_packet.c | 327 +++++++++++++++++-
 6 files changed, 752 insertions(+), 4 deletions(-)

-- 
2.54.0 (Apple Git-157)


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v3 1/2] config: detect liburing
  2026-12-02 18:54   ` [PATCH v3 0/2] net/af_packet: add io_uring Tx acceleration Scott Mitchell
@ 2026-12-02 18:54     ` Scott Mitchell
  2026-12-02 18:54     ` [PATCH v3 2/2] net/af_packet: add iouring Tx acceleration Scott Mitchell
  1 sibling, 0 replies; 15+ messages in thread
From: Scott Mitchell @ 2026-12-02 18:54 UTC (permalink / raw)
  To: dev; +Cc: stephen, thomas, david.marchand, mb, Scott Mitchell

Detect liburing once and set RTE_HAS_LIBURING, as done for libpcap, so
drivers and libraries can share the check. Require version 2.4, which
provides the io_uring setup flags and helpers af_packet needs.

Suggested-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Scott Mitchell <scott.k.mitch1@gmail.com>
---
 config/meson.build | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/config/meson.build b/config/meson.build
index bfac1cd93d..6b60971bc3 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -301,6 +301,12 @@ if (pcap_dep.found() and cc.has_header('pcap.h', dependencies: pcap_dep)
     dpdk_extra_ldflags += '-l@0@'.format(pcap_lib)
 endif
 
+# check for liburing
+iouring_dep = dependency('liburing', version: '>= 2.4', required: false, method: 'pkg-config')
+if iouring_dep.found()
+    dpdk_conf.set('RTE_HAS_LIBURING', 1)
+endif
+
 # for clang 32-bit compiles we need libatomic for 64-bit atomic ops
 if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
     atomic_dep = cc.find_library('atomic', required: true)
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v3 2/2] net/af_packet: add iouring Tx acceleration
  2026-12-02 18:54   ` [PATCH v3 0/2] net/af_packet: add io_uring Tx acceleration Scott Mitchell
  2026-12-02 18:54     ` [PATCH v3 1/2] config: detect liburing Scott Mitchell
@ 2026-12-02 18:54     ` Scott Mitchell
  2026-12-02 23:43       ` Stephen Hemminger
  1 sibling, 1 reply; 15+ messages in thread
From: Scott Mitchell @ 2026-12-02 18:54 UTC (permalink / raw)
  To: dev; +Cc: stephen, thomas, david.marchand, mb, Scott Mitchell

The sendto() Tx kick makes the kernel process queued frames
synchronously on the calling lcore. Optionally kick through an io_uring
SQPOLL ring instead, so a kernel thread does that work, as virtio
backends do. This improves throughput by 30%+ where virtio isn't an
option, such as containers.

New devargs: tx_io_uring_enabled, tx_io_uring_sq_size,
tx_io_uring_sq_thread_idle, tx_io_uring_q_cpu (SQPOLL CPU affinity)
and tx_io_uring_wq_num (queues share SQPOLL threads).

Requires DPDK built with liburing (RTE_HAS_LIBURING). If
tx_io_uring_enabled is set and the io_uring can't be set up, probe
fails. A kick that finds the submission queue full uses sendto(), so
frames queued since the last kick aren't left waiting for the next
burst.

Signed-off-by: Scott Mitchell <scott.k.mitch1@gmail.com>
---
 app/test/test_pmd_af_packet.c             | 391 ++++++++++++++++++++++
 doc/guides/nics/af_packet.rst             |  24 ++
 doc/guides/rel_notes/release_27_03.rst    |   1 +
 drivers/net/af_packet/meson.build         |   7 +
 drivers/net/af_packet/rte_eth_af_packet.c | 327 +++++++++++++++++-
 5 files changed, 746 insertions(+), 4 deletions(-)

diff --git a/app/test/test_pmd_af_packet.c b/app/test/test_pmd_af_packet.c
index b42121d8ee..3a0597a7a6 100644
--- a/app/test/test_pmd_af_packet.c
+++ b/app/test/test_pmd_af_packet.c
@@ -4,7 +4,9 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <dirent.h>
 #include <inttypes.h>
+#include <limits.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <linux/if.h>
@@ -34,6 +36,11 @@
 
 #include "test.h"
 
+#ifdef RTE_HAS_LIBURING
+#include <sys/syscall.h>
+#include <linux/io_uring.h>
+#endif
+
 #ifndef RTE_EXEC_ENV_LINUX
 static int
 test_pmd_af_packet(void)
@@ -104,6 +111,12 @@ struct tag_count {
 #define CKSUM_BAD 0xdead
 #define CKSUM_TCI 0x123
 
+/* io_uring tests */
+#define IDLE_WAKE_ROUNDS 40
+#define IDLE_WAKE_GAP_MS 25	/* > 2 jiffies at HZ=100, so an idle SQ thread sleeps */
+#define SQPOLL_QUEUES 4
+#define SQPOLL_STABLE_SAMPLES 5	/* 10 ms apart */
+
 static struct rte_mempool *mp;
 static uint16_t port_id = RTE_MAX_ETHPORTS;
 static int tap_fd = -1;
@@ -2404,6 +2417,378 @@ test_af_packet_tx_cksum(void)
 	return ret;
 }
 
+/*
+ * Test: io_uring devargs are validated
+ */
+static int
+test_af_packet_invalid_io_uring_args(void)
+{
+	static const char * const bad[] = {
+		"tx_io_uring_enabled=2",
+		"tx_io_uring_sq_size=0",
+		"tx_io_uring_sq_size=40000",
+		"tx_io_uring_sq_size=abc",
+		"tx_io_uring_sq_thread_idle=-1",
+		"tx_io_uring_q_cpu=-1",
+		"tx_io_uring_wq_num=99999",
+	};
+	char devargs[256];
+	unsigned int i;
+	int ret;
+
+	if (!tap_created) {
+		printf("SKIPPED: TAP interface not available (need root)\n");
+		return TEST_SKIPPED;
+	}
+
+	for (i = 0; i < RTE_DIM(bad); i++) {
+		snprintf(devargs, sizeof(devargs), "iface=%s,%s", TAP_DEV_NAME, bad[i]);
+		ret = rte_vdev_init("net_af_packet_uring_bad", devargs);
+		if (ret == 0)
+			rte_vdev_uninit("net_af_packet_uring_bad");
+		TEST_ASSERT(ret != 0, "Expected failure with %s", bad[i]);
+	}
+
+	return TEST_SUCCESS;
+}
+
+/* Helper: Count this process's io_uring SQPOLL threads (comm "iou-sqp-<pid>"), or -1. */
+static int
+count_sqpoll_threads(void)
+{
+	char path[PATH_MAX], comm[32];
+	struct dirent *de;
+	DIR *dir;
+	FILE *f;
+	int n = 0;
+
+	dir = opendir("/proc/self/task");
+	if (dir == NULL)
+		return -1;
+	while ((de = readdir(dir)) != NULL) {
+		if (de->d_name[0] == '.')
+			continue;
+		snprintf(path, sizeof(path), "/proc/self/task/%s/comm", de->d_name);
+		f = fopen(path, "r");
+		if (f == NULL)
+			continue;
+		if (fgets(comm, sizeof(comm), f) != NULL && strncmp(comm, "iou-sqp-", 8) == 0)
+			n++;
+		fclose(f);
+	}
+	closedir(dir);
+	return n;
+}
+
+/*
+ * Helper: Wait up to 1s for the SQPOLL thread count to hold at want for
+ * SQPOLL_STABLE_SAMPLES samples. Returns want, or the last other count.
+ */
+static int
+wait_sqpoll_threads(int want)
+{
+	int i, n, stable = 0, other = -1;
+
+	for (i = 0; i < 100; i++) {
+		n = count_sqpoll_threads();
+		if (n == want) {
+			if (++stable >= SQPOLL_STABLE_SAMPLES)
+				return want;
+		} else {
+			stable = 0;
+			other = n;
+		}
+		rte_delay_ms(10);
+	}
+	return other;
+}
+
+/* Helper: Whether the io_uring SQPOLL tests can run here; prints why not. */
+static bool
+io_uring_sqpoll_testable(void)
+{
+#ifdef RTE_HAS_LIBURING
+	struct io_uring_params p = { .flags = IORING_SETUP_SQPOLL };
+	long fd;
+
+	fd = syscall(__NR_io_uring_setup, 1, &p);
+	if (fd < 0) {
+		printf("SKIPPED: io_uring SQPOLL unavailable: %s\n", strerror(errno));
+		return false;
+	}
+	close((int)fd);
+	return true;
+#else
+	printf("SKIPPED: af_packet built without liburing\n");
+	return false;
+#endif
+}
+
+/* Helper: Fail if an io_uring port runs no SQPOLL thread. */
+static int
+check_sqpoll_active(int want)
+{
+	int n = wait_sqpoll_threads(want);
+
+	if (n < 1) {
+		printf("No io_uring SQPOLL thread (count %d)\n", n);
+		return TEST_FAILED;
+	}
+	return TEST_SUCCESS;
+}
+
+/*
+ * Test: TX with io_uring kicks
+ */
+/*
+ * Test: A port that asks for io_uring fails probe if it can't have it, and
+ * leaves no SQPOLL thread behind.
+ */
+static int
+test_af_packet_io_uring_setup_fails(void)
+{
+	const char *name = "net_af_packet_uring_fail";
+	char devargs[256];
+	int n, ret;
+
+	if (!tap_created) {
+		printf("SKIPPED: TAP interface not available (need root)\n");
+		return TEST_SKIPPED;
+	}
+
+#ifdef RTE_HAS_LIBURING
+	if (!io_uring_sqpoll_testable())
+		return TEST_SKIPPED;
+	/* the kernel rejects an SQPOLL CPU at or above nr_cpu_ids */
+	snprintf(devargs, sizeof(devargs),
+		 "iface=%s,tx_io_uring_enabled=1,tx_io_uring_q_cpu=1000000", TAP_DEV_NAME);
+#else
+	snprintf(devargs, sizeof(devargs), "iface=%s,tx_io_uring_enabled=1", TAP_DEV_NAME);
+#endif
+	ret = rte_vdev_init(name, devargs);
+	if (ret == 0)
+		rte_vdev_uninit(name);
+	TEST_ASSERT(ret != 0, "Expected probe failure with %s", devargs);
+
+	n = wait_sqpoll_threads(0);
+	TEST_ASSERT(n == 0, "%d SQPOLL threads left after failed probe", n);
+	return TEST_SUCCESS;
+}
+
+static int
+test_af_packet_io_uring_tx(void)
+{
+	const char *name = "net_af_packet_uring";
+	char devargs[256];
+	unsigned int framecnt;
+	uint16_t pid;
+	int flags, ret;
+
+	if (!tap_created) {
+		printf("SKIPPED: TAP interface not available (need root)\n");
+		return TEST_SKIPPED;
+	}
+
+	if (!io_uring_sqpoll_testable())
+		return TEST_SKIPPED;
+
+	framecnt = layout_devargs(devargs, sizeof(devargs), ",tx_io_uring_enabled=1");
+	ret = create_test_port(name, devargs, 0, &pid);
+	TEST_ASSERT(ret == 0, "Failed to create port");
+
+	ret = check_sqpoll_active(1);
+	if (ret != TEST_SUCCESS) {
+		destroy_test_port(name, pid);
+		return ret;
+	}
+
+	flags = fcntl(tap_fd, F_GETFL, 0);
+	fcntl(tap_fd, F_SETFL, flags | O_NONBLOCK);
+	tap_drain();
+
+	ret = check_tx_seq(pid, 3 * framecnt, LAYOUT_FRAME_LEN);
+
+	fcntl(tap_fd, F_SETFL, flags);
+	destroy_test_port(name, pid);
+	return ret;
+}
+
+/*
+ * Test: A frame sent after the SQPOLL thread went idle still goes out.
+ * With a 1 ms idle timeout and an IDLE_WAKE_GAP_MS gap before each frame, every
+ * kick has to wake a sleeping SQ thread; a missed wakeup leaves the frame queued.
+ * This is a smoke test: the race window is small, so a pass is not proof.
+ */
+static int
+test_af_packet_io_uring_idle_wakeup(void)
+{
+	const char *name = "net_af_packet_uring_idle";
+	bool seen[IDLE_WAKE_ROUNDS] = { false };
+	unsigned int round, nb_seen = 0;
+	struct rte_mbuf *m;
+	char devargs[256];
+	uint8_t *data;
+	uint16_t pid;
+	int flags, ret;
+
+	if (!tap_created) {
+		printf("SKIPPED: TAP interface not available (need root)\n");
+		return TEST_SKIPPED;
+	}
+
+	if (!io_uring_sqpoll_testable())
+		return TEST_SKIPPED;
+
+	snprintf(devargs, sizeof(devargs),
+		 "iface=%s,tx_io_uring_enabled=1,tx_io_uring_sq_thread_idle=1",
+		 TAP_DEV_NAME);
+	ret = create_test_port(name, devargs, 0, &pid);
+	TEST_ASSERT(ret == 0, "Failed to create port");
+
+	ret = check_sqpoll_active(1);
+	if (ret != TEST_SUCCESS) {
+		destroy_test_port(name, pid);
+		return ret;
+	}
+
+	flags = fcntl(tap_fd, F_GETFL, 0);
+	fcntl(tap_fd, F_SETFL, flags | O_NONBLOCK);
+	tap_drain();
+
+	ret = TEST_FAILED;
+	for (round = 0; round < IDLE_WAKE_ROUNDS; round++) {
+		rte_delay_ms(IDLE_WAKE_GAP_MS);
+		m = rte_pktmbuf_alloc(mp);
+		if (m == NULL)
+			goto out;
+		data = (uint8_t *)rte_pktmbuf_append(m, TEST_FRAME_LEN);
+		if (data == NULL) {
+			rte_pktmbuf_free(m);
+			goto out;
+		}
+		fill_seq_frame(data, TEST_FRAME_LEN, &DEV_MAC_TAG, round);
+		if (do_tx_burst(pid, 0, &m, 1) != 1)
+			goto out;
+		if (tap_collect_seq(seen, IDLE_WAKE_ROUNDS, &nb_seen, round + 1,
+				    TEST_FRAME_LEN, TAP_READ_TIMEOUT_US) != (int)(round + 1)) {
+			printf("Frame %u not sent after idle (seen %u)\n", round, nb_seen);
+			goto out;
+		}
+	}
+	ret = TEST_SUCCESS;
+out:
+	fcntl(tap_fd, F_SETFL, flags);
+	destroy_test_port(name, pid);
+	return ret;
+}
+
+/* Helper: Count open file descriptors of this process, or -1. */
+static int
+count_open_fds(void)
+{
+	struct dirent *de;
+	DIR *dir;
+	int n = 0;
+
+	dir = opendir("/proc/self/fd");
+	if (dir == NULL)
+		return -1;
+	while ((de = readdir(dir)) != NULL)
+		if (de->d_name[0] != '.')
+			n++;
+	closedir(dir);
+	return n;
+}
+
+/*
+ * Test: Creating and closing io_uring ports, including ones sharing an
+ * SQPOLL thread (tx_io_uring_wq_num), does not leak file descriptors.
+ */
+static int
+test_af_packet_io_uring_create_destroy(void)
+{
+	const char *name = "net_af_packet_uring_cd";
+	char devargs[256];
+	int before, after, i;
+	uint16_t pid;
+
+	if (!tap_created) {
+		printf("SKIPPED: TAP interface not available (need root)\n");
+		return TEST_SKIPPED;
+	}
+
+	if (!io_uring_sqpoll_testable())
+		return TEST_SKIPPED;
+
+	snprintf(devargs, sizeof(devargs),
+		 "iface=%s,qpairs=2,tx_io_uring_enabled=1,tx_io_uring_wq_num=1",
+		 TAP_DEV_NAME);
+
+	before = count_open_fds();
+	for (i = 0; i < 10; i++) {
+		TEST_ASSERT(create_af_packet_port(name, devargs, &pid) == 0,
+			    "Failed to create port (iteration %d)", i);
+		TEST_ASSERT(configure_af_packet_port(pid, 2, 2) == 0,
+			    "Failed to configure port (iteration %d)", i);
+		/* Without io_uring rings there would be nothing to leak */
+		if (i == 0 && check_sqpoll_active(1) != TEST_SUCCESS) {
+			destroy_test_port(name, pid);
+			return TEST_FAILED;
+		}
+		destroy_test_port(name, pid);
+	}
+	after = count_open_fds();
+
+	TEST_ASSERT(before >= 0 && before == after,
+		    "Open fds %d before, %d after", before, after);
+	return TEST_SUCCESS;
+}
+
+/*
+ * Test: Queues share SQPOLL threads when tx_io_uring_wq_num is below the
+ * queue count (IORING_SETUP_ATTACH_WQ).
+ */
+static int
+test_af_packet_io_uring_shared_sqpoll(void)
+{
+	static const unsigned int wq_nums[] = { 1, 2 };
+	const char *name = "net_af_packet_uring_wq";
+	char devargs[256];
+	unsigned int i;
+	uint16_t pid;
+	int n;
+
+	if (!tap_created) {
+		printf("SKIPPED: TAP interface not available (need root)\n");
+		return TEST_SKIPPED;
+	}
+	if (!io_uring_sqpoll_testable())
+		return TEST_SKIPPED;
+	TEST_ASSERT(wait_sqpoll_threads(0) == 0, "SQPOLL threads left from earlier tests");
+
+	for (i = 0; i < RTE_DIM(wq_nums); i++) {
+		snprintf(devargs, sizeof(devargs),
+			 "iface=%s,qpairs=%d,tx_io_uring_enabled=1,tx_io_uring_wq_num=%u",
+			 TAP_DEV_NAME, SQPOLL_QUEUES, wq_nums[i]);
+		TEST_ASSERT(create_af_packet_port(name, devargs, &pid) == 0,
+			    "Failed to create port");
+		if (configure_af_packet_port(pid, SQPOLL_QUEUES, SQPOLL_QUEUES) != 0) {
+			destroy_test_port(name, pid);
+			return TEST_FAILED;
+		}
+		/* SQPOLL threads start and exit asynchronously; let the count settle */
+		n = wait_sqpoll_threads(wq_nums[i]);
+		destroy_test_port(name, pid);
+
+		printf("%d queues, %s=%u: %d SQPOLL threads\n", SQPOLL_QUEUES,
+		       "tx_io_uring_wq_num", wq_nums[i], n);
+		TEST_ASSERT(n == (int)wq_nums[i], "Expected %u SQPOLL threads, got %d",
+			    wq_nums[i], n);
+		TEST_ASSERT(wait_sqpoll_threads(0) == 0, "SQPOLL threads did not exit");
+	}
+	return TEST_SUCCESS;
+}
+
 static struct unit_test_suite af_packet_test_suite = {
 	.suite_name = "AF_PACKET PMD Unit Test Suite",
 	.setup = test_af_packet_setup,
@@ -2434,6 +2819,12 @@ static struct unit_test_suite af_packet_test_suite = {
 		TEST_CASE(test_af_packet_tx_mbuf_accounting),
 		TEST_CASE(test_af_packet_tx_ring_full),
 		TEST_CASE(test_af_packet_tx_cksum),
+		TEST_CASE(test_af_packet_invalid_io_uring_args),
+		TEST_CASE(test_af_packet_io_uring_setup_fails),
+		TEST_CASE(test_af_packet_io_uring_tx),
+		TEST_CASE(test_af_packet_io_uring_idle_wakeup),
+		TEST_CASE(test_af_packet_io_uring_create_destroy),
+		TEST_CASE(test_af_packet_io_uring_shared_sqpoll),
 		TEST_CASE(test_af_packet_qdisc_bypass),
 		TEST_CASE(test_af_packet_multi_queue),
 		TEST_CASE(test_af_packet_fanout_modes),
diff --git a/doc/guides/nics/af_packet.rst b/doc/guides/nics/af_packet.rst
index 93c307175a..c3cb692703 100644
--- a/doc/guides/nics/af_packet.rst
+++ b/doc/guides/nics/af_packet.rst
@@ -33,6 +33,26 @@ Some of these, in turn, will be used to configure the PACKET_MMAP settings.
     of 16B, at least 64B);
 *   ``framecnt`` - PACKET_MMAP frame count (optional, default 512; Note: multiple
     of ``blocksz`` / ``framesz``).
+*   ``tx_io_uring_enabled`` - Use an io_uring SQPOLL thread to notify the kernel
+    on Tx. Needs DPDK built with liburing 2.4 or later; probe fails if io_uring
+    can't be set up (optional, default 0)
+*   ``tx_io_uring_sq_size`` - Number of entries for the io_uring ring (optional,
+    default 1024)
+*   ``tx_io_uring_sq_thread_idle`` - Idle time (in milliseconds) before an io_uring
+    SQPOLL thread goes to sleep; 0 selects the kernel default of 1 second
+    (optional, default 500)
+*   ``tx_io_uring_q_cpu`` - This argument can be repeated to specify CPU core
+    affinity for each queue's io_uring SQPOLL kernel thread (see
+    ``io_uring_params.sq_thread_cpu``). The first value applies to queue 0,
+    the second to queue 1, etc. With ``tx_io_uring_wq_num``, values apply to
+    SQPOLL threads instead: value i pins the thread shared by queues whose index
+    modulo ``tx_io_uring_wq_num`` is i (optional, default empty). An unpinned SQPOLL
+    thread may run on any CPU, so pin it when lcores run with real-time priority,
+    where it could otherwise be starved.
+*   ``tx_io_uring_wq_num`` - Number of SQPOLL kernel threads. On kernels with
+    ``IORING_SETUP_ATTACH_WQ`` support, setting this lower than the queue count
+    enables thread sharing across queues. If 0 or unspecified, no sharing is configured
+    and each queue creates its own SQPOLL thread (optional, default 0)
 
 For details regarding ``fanout_mode`` argument, you can consult the
 `PACKET_FANOUT documentation <https://www.man7.org/linux/man-pages/man7/packet.7.html>`_.
@@ -96,3 +116,7 @@ Features and Limitations
    application.
 *  The PMD will add the kernel packet timestamp with nanoseconds resolution and
    UNIX origo, i.e. time since 1-JAN-1970 UTC, if ``RTE_ETH_RX_OFFLOAD_TIMESTAMP`` is enabled.
+*  With ``tx_io_uring_enabled``, the kernel transmits from the SQPOLL thread, and the
+   CPU it runs on selects the interface Tx queue. Pin SQPOLL threads with
+   ``tx_io_uring_q_cpu`` so a queue's packets are not reordered across interface
+   Tx queues. Queues sharing an SQPOLL thread also share an interface Tx queue.
diff --git a/doc/guides/rel_notes/release_27_03.rst b/doc/guides/rel_notes/release_27_03.rst
index dd9e8a57bb..88cc6a67d8 100644
--- a/doc/guides/rel_notes/release_27_03.rst
+++ b/doc/guides/rel_notes/release_27_03.rst
@@ -58,6 +58,7 @@ New Features
 * **Updated af_packet net driver.**
 
   * Added software TX checksum offload for IPv4, UDP and TCP.
+  * Added optional io_uring SQPOLL notification of the kernel on Tx.
 
 
 Removed Items
diff --git a/drivers/net/af_packet/meson.build b/drivers/net/af_packet/meson.build
index f45e4491d4..7546bf31ed 100644
--- a/drivers/net/af_packet/meson.build
+++ b/drivers/net/af_packet/meson.build
@@ -5,5 +5,12 @@ if not is_linux
     build = false
     reason = 'only supported on Linux'
 endif
+
+deps += ['ethdev']
+
+if dpdk_conf.has('RTE_HAS_LIBURING')
+    ext_deps += iouring_dep
+endif
+
 sources = files('rte_eth_af_packet.c')
 require_iova_in_mbuf = false
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index bf847ab602..8d5aa63f11 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -20,6 +20,11 @@
 #include <bus_vdev_driver.h>
 
 #include <ctype.h>
+#ifdef RTE_HAS_LIBURING
+#include <liburing.h>
+#endif
+struct io_uring;
+
 #include <errno.h>
 #include <limits.h>
 #include <linux/if_ether.h>
@@ -53,9 +58,21 @@
 #define ETH_AF_PACKET_QDISC_BYPASS_ARG	"qdisc_bypass"
 #define ETH_AF_PACKET_FANOUT_MODE_ARG	"fanout_mode"
 #define ETH_AF_PACKET_IGNORE_OUTGOING_ARG	"ignore_outgoing"
+#define ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG	"tx_io_uring_enabled"
+#define ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG	"tx_io_uring_sq_size"
+#define ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG	"tx_io_uring_sq_thread_idle"
+#define ETH_AF_PACKET_TX_IO_URING_Q_CPU	"tx_io_uring_q_cpu"
+#define ETH_AF_PACKET_TX_IO_URING_WQ_NUM	"tx_io_uring_wq_num"
 
 #define DFLT_FRAME_SIZE		(1 << 11)
 #define DFLT_FRAME_COUNT	(1 << 9)
+#define DFLT_TX_IO_URING_ENABLED	false
+#define DFLT_TX_IO_URING_SQ_SIZE	1024
+#define ETH_AF_PACKET_URING_SQ_SIZE_MAX	32768
+#define DFLT_TX_IO_URING_SQ_THREAD_IDLE_MS	500
+
+/* io_uring registered file descriptor index for the socket fd */
+#define ETH_AF_PACKET_URING_SOCKFD_INDEX	0
 
 /* Rx data starts at tp_mac, past the header aligned as in the kernel's tpacket_rcv() */
 #define ETH_AF_PACKET_RX_FRAME_OVERHEAD \
@@ -97,6 +114,13 @@ struct __rte_cache_aligned pkt_tx_queue {
 	unsigned int framecount;
 	unsigned int framenum;
 
+#ifdef RTE_HAS_LIBURING
+	struct io_uring uring_ring;
+	bool uring_enabled;
+	uint32_t uring_sqe_since_cq_advance;
+	uint8_t uring_sqe_flags;
+#endif
+
 	volatile unsigned long tx_pkts;
 	volatile unsigned long err_pkts;
 	volatile unsigned long tx_bytes;
@@ -115,6 +139,18 @@ struct pmd_internals {
 	struct pkt_tx_queue *tx_queue;
 	uint8_t vlan_strip;
 	uint8_t timestamp_offloading;
+	struct io_uring **shared_uring_rings;
+	uint32_t shared_uring_count;
+};
+
+/* io_uring Tx kick devargs */
+struct af_packet_io_uring_args {
+	bool enabled;
+	uint32_t sq_size;
+	uint32_t sq_thread_idle_ms;
+	uint32_t kq_cores[RTE_MAX_QUEUES_PER_PORT];
+	uint32_t kq_cores_size;
+	uint32_t wq_num;
 };
 
 static const char *valid_arguments[] = {
@@ -126,6 +162,11 @@ static const char *valid_arguments[] = {
 	ETH_AF_PACKET_QDISC_BYPASS_ARG,
 	ETH_AF_PACKET_FANOUT_MODE_ARG,
 	ETH_AF_PACKET_IGNORE_OUTGOING_ARG,
+	ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG,
+	ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG,
+	ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG,
+	ETH_AF_PACKET_TX_IO_URING_Q_CPU,
+	ETH_AF_PACKET_TX_IO_URING_WQ_NUM,
 	NULL
 };
 
@@ -199,6 +240,150 @@ tpacket_write_status(struct tpacket2_hdr *ppd, uint32_t status)
 			rte_memory_order_release);
 }
 
+#ifdef RTE_HAS_LIBURING
+/*
+ * Create a ring. Kernels before 6.0 reject IORING_SETUP_SINGLE_ISSUER with
+ * -EINVAL; it is only an optimization, so retry without it.
+ */
+static int
+af_packet_io_uring_init(struct io_uring *ring, uint32_t entries,
+			struct io_uring_params *params)
+{
+	struct io_uring_params p = *params;
+	int rc;
+
+	rc = io_uring_queue_init_params(entries, ring, &p);
+	if (rc == -EINVAL && (params->flags & IORING_SETUP_SINGLE_ISSUER)) {
+		params->flags &= ~IORING_SETUP_SINGLE_ISSUER;
+		p = *params;
+		rc = io_uring_queue_init_params(entries, ring, &p);
+	}
+	if (rc == 0)
+		*params = p;
+	return rc;
+}
+
+/* Flags for a ring that creates its own SQPOLL thread, pinned if a CPU is configured */
+static void
+af_packet_io_uring_own_thread(struct io_uring_params *params, uint32_t cpu_idx,
+			      const struct af_packet_io_uring_args *args)
+{
+	if (cpu_idx < args->kq_cores_size) {
+		params->flags |= IORING_SETUP_SQ_AFF;
+		params->sq_thread_cpu = args->kq_cores[cpu_idx];
+	}
+	params->flags |= IORING_SETUP_SINGLE_ISSUER;
+}
+#endif /* RTE_HAS_LIBURING */
+
+/* Prepare SQPOLL thread sharing. Fails if io_uring is requested but not built in. */
+static int
+af_packet_io_uring_share_init(struct pmd_internals *internals __rte_unused,
+			      unsigned int numa_node __rte_unused,
+			      const struct af_packet_io_uring_args *args)
+{
+	if (!args->enabled)
+		return 0;
+#ifdef RTE_HAS_LIBURING
+	if (args->wq_num == 0)
+		return 0;
+	if (args->kq_cores_size > args->wq_num)
+		PMD_LOG(WARNING, "only the first %u %s values are used",
+			args->wq_num, ETH_AF_PACKET_TX_IO_URING_Q_CPU);
+
+	/* Rings attach to a group's SQPOLL thread with IORING_SETUP_ATTACH_WQ */
+	internals->shared_uring_rings = rte_calloc_socket("af_packet_shared_uring",
+			args->wq_num, sizeof(*internals->shared_uring_rings), 0, numa_node);
+	if (internals->shared_uring_rings == NULL)
+		return -ENOMEM;
+	internals->shared_uring_count = args->wq_num;
+	return 0;
+#else
+	PMD_LOG(ERR, "%s=1 needs liburing, which this build lacks",
+		ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG);
+	return -ENOTSUP;
+#endif
+}
+
+/* Create the io_uring that kicks Tx queue q. Fails if it can't be set up. */
+static int
+af_packet_io_uring_tx_queue_init(struct pmd_internals *internals __rte_unused,
+				 unsigned int q __rte_unused,
+				 const struct af_packet_io_uring_args *args)
+{
+	if (!args->enabled)
+		return 0;
+#ifdef RTE_HAS_LIBURING
+	struct pkt_tx_queue *tx_queue = &internals->tx_queue[q];
+	struct io_uring_params params = {
+		.sq_thread_idle = args->sq_thread_idle_ms,
+		.flags = IORING_SETUP_SQPOLL,
+	};
+	/* q_cpu is indexed by SQPOLL thread group when threads are shared */
+	uint32_t ring_idx = internals->shared_uring_rings ? q % internals->shared_uring_count : 0;
+	uint32_t cpu_idx = internals->shared_uring_rings ? ring_idx : q;
+	bool attach = internals->shared_uring_rings && ring_idx < q &&
+		internals->shared_uring_rings[ring_idx];
+	int rc;
+
+	if (attach) {
+		/* Share the group's SQPOLL thread; the ring's memory and lifetime stay per queue */
+		params.flags |= IORING_SETUP_ATTACH_WQ;
+		params.wq_fd = internals->shared_uring_rings[ring_idx]->ring_fd;
+	} else {
+		af_packet_io_uring_own_thread(&params, cpu_idx, args);
+	}
+
+	rc = af_packet_io_uring_init(&tx_queue->uring_ring, args->sq_size, &params);
+	if (rc < 0 && attach) {
+		PMD_LOG(NOTICE, "tx_queue %u: can't share SQPOLL thread: %s", q, strerror(-rc));
+		attach = false;
+		params.flags &= ~IORING_SETUP_ATTACH_WQ;
+		params.wq_fd = 0;
+		af_packet_io_uring_own_thread(&params, cpu_idx, args);
+		rc = af_packet_io_uring_init(&tx_queue->uring_ring, args->sq_size, &params);
+	}
+	if (rc < 0) {
+		PMD_LOG(ERR, "tx_queue %u: io_uring setup failed: %s", q, strerror(-rc));
+		return rc;
+	}
+
+	/* The kick needs IORING_OP_SEND (Linux 5.6); skipping its CQEs (5.17) is optional */
+	struct io_uring_probe *probe = io_uring_get_probe_ring(&tx_queue->uring_ring);
+	bool send_ok = probe != NULL && io_uring_opcode_supported(probe, IORING_OP_SEND);
+
+	if (probe != NULL)
+		io_uring_free_probe(probe);
+	if (!send_ok) {
+		PMD_LOG(ERR, "tx_queue %u: kernel lacks io_uring send", q);
+		io_uring_queue_exit(&tx_queue->uring_ring);
+		return -ENOTSUP;
+	}
+	tx_queue->uring_sqe_flags = IOSQE_FIXED_FILE;
+	if (params.features & IORING_FEAT_CQE_SKIP)
+		tx_queue->uring_sqe_flags |= IOSQE_CQE_SKIP_SUCCESS;
+
+	/* Register the sockfd at index ETH_AF_PACKET_URING_SOCKFD_INDEX */
+	rc = io_uring_register_files(&tx_queue->uring_ring, &tx_queue->sockfd, 1);
+	if (rc < 0) {
+		PMD_LOG(ERR, "tx_queue %u: io_uring file registration failed: %s",
+			q, strerror(-rc));
+		io_uring_queue_exit(&tx_queue->uring_ring);
+		return rc;
+	}
+
+	tx_queue->uring_enabled = true;
+	tx_queue->uring_sqe_since_cq_advance = 0;
+	if (!attach && internals->shared_uring_rings && !internals->shared_uring_rings[ring_idx])
+		internals->shared_uring_rings[ring_idx] = &tx_queue->uring_ring;
+	PMD_LOG(DEBUG, "tx_queue %u: io_uring SQPOLL%s, flags 0x%x",
+		q, attach ? " shared" : "", params.flags);
+	return 0;
+#else
+	return -ENOTSUP;
+#endif
+}
+
 static uint16_t
 eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
@@ -422,6 +607,52 @@ af_packet_tx_cksum(uint8_t *data, const struct rte_mbuf *m)
 	return true;
 }
 
+/*
+ * Kick the kernel to process frames in SEND_REQUEST. Returns false if the
+ * kernel rejected a synchronous kick with an error other than ENOBUFS/EAGAIN.
+ * io_uring kick errors aren't observed; the frames are in the ring either way.
+ */
+static inline bool
+eth_af_packet_tx_kick(struct pkt_tx_queue *pkt_q)
+{
+#ifdef RTE_HAS_LIBURING
+	if (pkt_q->uring_enabled) {
+		/* Batch CQ advancement: only advance every sq_size submissions to amortize
+		 * memory barrier cost (2 load_acquire + 1 store_release). With
+		 * IOSQE_CQE_SKIP_SUCCESS only failures post CQEs; without it every kick does.
+		 * Either way the CQ stays within its default 2 * sq_size entries.
+		 */
+		if (++pkt_q->uring_sqe_since_cq_advance >= pkt_q->uring_ring.sq.ring_entries) {
+			io_uring_cq_advance(&pkt_q->uring_ring,
+					io_uring_cq_ready(&pkt_q->uring_ring));
+			pkt_q->uring_sqe_since_cq_advance = 0;
+		}
+
+		struct io_uring_sqe *sqe = io_uring_get_sqe(&pkt_q->uring_ring);
+		if (likely(sqe != NULL)) {
+			/* Use registered fd (see io_uring_register_files call during setup) */
+			io_uring_prep_send(sqe, ETH_AF_PACKET_URING_SOCKFD_INDEX, NULL, 0,
+					MSG_DONTWAIT);
+			io_uring_sqe_set_flags(sqe, pkt_q->uring_sqe_flags);
+			io_uring_sqe_set_data(sqe, NULL);
+
+			/* With SQPOLL this only enters the kernel to wake a sleeping SQ thread;
+			 * its full barrier orders the tail store before the NEED_WAKEUP check.
+			 */
+			io_uring_submit(&pkt_q->uring_ring);
+			return true;
+		}
+		/*
+		 * SQ full: the kernel publishes the SQ head only after issuing a whole
+		 * batch, so a pending kick may already have scanned the ring. Kick
+		 * synchronously so frames queued since then aren't left behind.
+		 */
+	}
+#endif
+	return sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) != -1 ||
+		errno == ENOBUFS || errno == EAGAIN;
+}
+
 /*
  * Callback to handle sending packets through a real NIC.
  */
@@ -490,14 +721,12 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	rte_pktmbuf_free_bulk(bufs, i);
 
 	/* kick-off transmits, even if nothing new was queued */
-	if (unlikely(sendto(pkt_q->sockfd, NULL, 0, MSG_DONTWAIT, NULL, 0) == -1 &&
-		     errno != ENOBUFS && errno != EAGAIN)) {
+	if (unlikely(!eth_af_packet_tx_kick(pkt_q))) {
 		/*
 		 * In case of a ENOBUFS/EAGAIN error all of the enqueued
 		 * packets will be considered successful even though only some
 		 * are sent.
 		 */
-
 		num_tx = 0;
 		num_tx_bytes = 0;
 	}
@@ -708,11 +937,20 @@ eth_dev_close(struct rte_eth_dev *dev)
 		internals->rx_queue[q].sockfd = -1;
 		internals->tx_queue[q].sockfd = -1;
 
+#ifdef RTE_HAS_LIBURING
+		if (internals->tx_queue[q].uring_enabled) {
+			io_uring_unregister_files(&internals->tx_queue[q].uring_ring);
+			io_uring_queue_exit(&internals->tx_queue[q].uring_ring);
+			internals->tx_queue[q].uring_enabled = false;
+		}
+#endif
+
 		munmap(internals->rx_queue[q].map,
 			2 * req->tp_block_size * req->tp_block_nr);
 		rte_free(internals->rx_queue[q].rd);
 		rte_free(internals->tx_queue[q].rd);
 	}
+	rte_free(internals->shared_uring_rings);
 	rte_free(internals->if_name);
 	rte_free(internals->rx_queue);
 	rte_free(internals->tx_queue);
@@ -996,6 +1234,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 		       unsigned int qdisc_bypass,
 		       const char *fanout_mode,
 		       unsigned int ignore_outgoing,
+		       const struct af_packet_io_uring_args *uring_args,
 		       struct pmd_internals **internals,
 		       struct rte_eth_dev **eth_dev,
 		       struct rte_kvargs *kvlist)
@@ -1110,6 +1349,9 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 	if (ignore_outgoing != 0 && nb_queues > 1)
 		fanout_arg |= PACKET_FANOUT_FLAG_IGNORE_OUTGOING << 16;
 
+	if (af_packet_io_uring_share_init(*internals, numa_node, uring_args) < 0)
+		goto error;
+
 	for (q = 0; q < nb_queues; q++) {
 		/* Open an AF_PACKET socket for this queue... */
 		qsockfd = socket(AF_PACKET, SOCK_RAW, 0);
@@ -1247,6 +1489,9 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 				goto error;
 			}
 		}
+
+		if (af_packet_io_uring_tx_queue_init(*internals, q, uring_args) < 0)
+			goto error;
 	}
 
 	/* reserve an ethdev entry */
@@ -1280,6 +1525,13 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 	if (qsockfd != -1)
 		close(qsockfd);
 	for (q = 0; q < nb_queues; q++) {
+#ifdef RTE_HAS_LIBURING
+		if ((*internals)->tx_queue[q].uring_enabled) {
+			io_uring_unregister_files(&(*internals)->tx_queue[q].uring_ring);
+			io_uring_queue_exit(&(*internals)->tx_queue[q].uring_ring);
+			(*internals)->tx_queue[q].uring_enabled = false;
+		}
+#endif
 		if ((*internals)->rx_queue[q].map != MAP_FAILED)
 			munmap((*internals)->rx_queue[q].map,
 			       2 * req->tp_block_size * req->tp_block_nr);
@@ -1291,6 +1543,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev,
 			close((*internals)->rx_queue[q].sockfd);
 	}
 free_internals:
+	rte_free((*internals)->shared_uring_rings);
 	rte_free((*internals)->rx_queue);
 	rte_free((*internals)->tx_queue);
 	rte_free((*internals)->if_name);
@@ -1353,6 +1606,12 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
 	unsigned int qdisc_bypass = 1;
 	const char *fanout_mode = NULL;
 	unsigned int ignore_outgoing = 0;
+	struct af_packet_io_uring_args uring_args = {
+		.enabled = DFLT_TX_IO_URING_ENABLED,
+		.sq_size = DFLT_TX_IO_URING_SQ_SIZE,
+		.sq_thread_idle_ms = DFLT_TX_IO_URING_SQ_THREAD_IDLE_MS,
+	};
+	unsigned int uval;
 
 	/* do some parameter checking */
 	if (*sockfd < 0)
@@ -1424,6 +1683,47 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
 				return -1;
 			continue;
 		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG) != NULL) {
+			if (parse_uint(pair->key, pair->value, &uval, 1) < 0)
+				return -1;
+			uring_args.enabled = uval != 0;
+			continue;
+		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG) != NULL) {
+			if (parse_uint(pair->key, pair->value, &uval,
+				       ETH_AF_PACKET_URING_SQ_SIZE_MAX) < 0)
+				return -1;
+			if (uval == 0) {
+				PMD_LOG(ERR, "%s: %s must be > 0", name,
+					ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG);
+				return -1;
+			}
+			uring_args.sq_size = uval;
+			continue;
+		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG) != NULL) {
+			if (parse_uint(pair->key, pair->value, &uval, UINT32_MAX) < 0)
+				return -1;
+			uring_args.sq_thread_idle_ms = uval;
+			continue;
+		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_Q_CPU) != NULL) {
+			if (parse_uint(pair->key, pair->value, &uval, UINT32_MAX) < 0)
+				return -1;
+			if (uring_args.kq_cores_size >= RTE_MAX_QUEUES_PER_PORT) {
+				PMD_LOG(ERR, "%s: too many %s args, max of %d", name,
+					ETH_AF_PACKET_TX_IO_URING_Q_CPU, RTE_MAX_QUEUES_PER_PORT);
+				return -1;
+			}
+			uring_args.kq_cores[uring_args.kq_cores_size++] = uval;
+			continue;
+		}
+		if (strstr(pair->key, ETH_AF_PACKET_TX_IO_URING_WQ_NUM) != NULL) {
+			if (parse_uint(pair->key, pair->value, &uval, RTE_MAX_QUEUES_PER_PORT) < 0)
+				return -1;
+			uring_args.wq_num = uval;
+			continue;
+		}
 	}
 
 	if (framesize > blocksize) {
@@ -1458,12 +1758,26 @@ rte_eth_from_packet(struct rte_vdev_device *dev,
 		PMD_LOG(DEBUG, "%s:\tfanout mode %s", name, "default PACKET_FANOUT_HASH");
 	PMD_LOG(DEBUG, "%s:\tignore outgoing %u", name, ignore_outgoing);
 
+	PMD_LOG(INFO, "%s:\t%s %d", name,
+		ETH_AF_PACKET_TX_IO_URING_ENABLED_ARG, uring_args.enabled ? 1 : 0);
+	PMD_LOG(INFO, "%s:\t%s %" PRIu32, name,
+		ETH_AF_PACKET_TX_IO_URING_SQ_SIZE_ARG, uring_args.sq_size);
+	PMD_LOG(INFO, "%s:\t%s %" PRIu32, name,
+		ETH_AF_PACKET_TX_IO_URING_SQ_THREAD_IDLE_ARG, uring_args.sq_thread_idle_ms);
+	for (uint32_t cpu_i = 0; cpu_i < uring_args.kq_cores_size; cpu_i++) {
+		PMD_LOG(INFO, "%s:\t%s[%" PRIu32 "] %" PRIu32, name,
+			ETH_AF_PACKET_TX_IO_URING_Q_CPU, cpu_i, uring_args.kq_cores[cpu_i]);
+	}
+	PMD_LOG(INFO, "%s:\t%s %" PRIu32, name,
+		ETH_AF_PACKET_TX_IO_URING_WQ_NUM, uring_args.wq_num);
+
 	if (rte_pmd_init_internals(dev, *sockfd, qpairs,
 				   blocksize, blockcount,
 				   framesize, framecount,
 				   qdisc_bypass,
 				   fanout_mode,
 				   ignore_outgoing,
+				   &uring_args,
 				   &internals, &eth_dev,
 				   kvlist) < 0)
 		return -1;
@@ -1562,4 +1876,9 @@ RTE_PMD_REGISTER_PARAM_STRING(net_af_packet,
 	"framecnt=<int> "
 	"qdisc_bypass=<0|1> "
 	"fanout_mode=<hash|lb|cpu|rollover|rnd|qm> "
-	"ignore_outgoing=<0|1>");
+	"ignore_outgoing=<0|1> "
+	"tx_io_uring_enabled=<0|1> "
+	"tx_io_uring_sq_size=<int> "
+	"tx_io_uring_sq_thread_idle=<int> "
+	"tx_io_uring_q_cpu=<int> "
+	"tx_io_uring_wq_num=<int>");
-- 
2.54.0 (Apple Git-157)


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v3 2/2] net/af_packet: add iouring Tx acceleration
  2026-12-02 18:54     ` [PATCH v3 2/2] net/af_packet: add iouring Tx acceleration Scott Mitchell
@ 2026-12-02 23:43       ` Stephen Hemminger
  0 siblings, 0 replies; 15+ messages in thread
From: Stephen Hemminger @ 2026-12-02 23:43 UTC (permalink / raw)
  To: Scott Mitchell; +Cc: dev, thomas, david.marchand, mb

On Wed,  2 Dec 2026 10:54:20 -0800
Scott Mitchell <scott.k.mitch1@gmail.com> wrote:

> +/* Helper: Count this process's io_uring SQPOLL threads (comm "iou-sqp-<pid>"), or -1. */
> +static int
> +count_sqpoll_threads(void)
> +{
> +	char path[PATH_MAX], comm[32];
> +	struct dirent *de;
> +	DIR *dir;
> +	FILE *f;
> +	int n = 0;
> +
> +	dir = opendir("/proc/self/task");
> +	if (dir == NULL)
> +		return -1;
> +	while ((de = readdir(dir)) != NULL) {
> +		if (de->d_name[0] == '.')
> +			continue;
> +		snprintf(path, sizeof(path), "/proc/self/task/%s/comm", de->d_name);
> +		f = fopen(path, "r");
> +		if (f == NULL)
> +			continue;
> +		if (fgets(comm, sizeof(comm), f) != NULL && strncmp(comm, "iou-sqp-", 8) == 0)
> +			n++;
> +		fclose(f);
> +	}
> +	closedir(dir);
> +	return n;
> +}

NAK
Depending on internals like this is recipe for future disaster.

The test should not be looking at how ring is implemented.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-12-02 23:43 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-04 16:12 [RFC v1] net/af_packet: add io_uring TX acceleration scott.k.mitch1
2026-02-04 16:52 ` Stephen Hemminger
2026-02-05  0:08   ` Scott Mitchell
2026-12-01 22:36 ` [RFC PATCH v2] " Scott Mitchell
2026-12-01 22:44   ` Scott Mitchell
2026-12-02 17:16     ` Stephen Hemminger
2026-12-02 18:52       ` Scott Mitchell
2026-12-02 18:54   ` [PATCH v3 0/2] net/af_packet: add io_uring Tx acceleration Scott Mitchell
2026-12-02 18:54     ` [PATCH v3 1/2] config: detect liburing Scott Mitchell
2026-12-02 18:54     ` [PATCH v3 2/2] net/af_packet: add iouring Tx acceleration Scott Mitchell
2026-12-02 23:43       ` Stephen Hemminger
2026-12-02 16:59 ` [RFC v1] net/af_packet: add io_uring TX acceleration Stephen Hemminger
2026-12-02 17:02 ` Stephen Hemminger
2026-12-02 17:03 ` Stephen Hemminger
2026-12-02 17:04 ` Stephen Hemminger

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.