Skip to contentSkip to conversation

net/af_packet: add io_uring TX acceleration

RFC In review [email protected] 2 participants 3 messages Feb 4 – Feb 5

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 net/af_packet: add io_uring TX acceleration

From: Scott <[email protected]>

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

---
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(-)
doc/guides/nics/af_packet.rst +15 -1
index 782a962c3f..b9f4ad9f69 100644
@@ -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
 ------------------------
doc/guides/rel_notes/release_26_03.rst +1 -0
index 5abdd7cbb2..87081e8b98 100644
@@ -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.**
 
drivers/net/af_packet/meson.build +14 -0
index f45e4491d4..a672262656 100644
@@ -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
drivers/net/af_packet/rte_eth_af_packet.c +405 -15

546 lines not on this page · raw message

Signature · 1 line
2.39.5 (Apple Git-154)
#1 lore raw

doc/guides/nics/af_pac

Quoted 57 lines · On Wed, 4 Feb 2026 08:12:02 -0800 [email protected] wrote:

From: Scott <[email protected]>

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

---
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(-)
doc/guides/nics/af_pac renamed from doc/guides/nics/af_packet.rst +0 -0

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

#2 lore raw

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?

Quoted 64 lines · Stephen Hemminger

doc/guides/nics/af_pac

Quoted 57 lines · On Wed, 4 Feb 2026 08:12:02 -0800 [email protected] wrote:

From: Scott <[email protected]>

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

---
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(-)
doc/guides/nics/af_pac renamed from doc/guides/nics/af_packet.rst +0 -0

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