Skip to content

XDP with io_uring zero-copy RX and devmem

Björn Töpel bpf io-uring linux-doc linux-kselftest lkml netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7bpf: Keep XDP helpers within readable datainclude/linux/filter.h include/net/xdp.h kernel/bpf/helpers.c +1 more+45 -171 reply
2/7xdp: Reject frames with unreadable fragmentsinclude/net/xdp.h net/xdp/xsk.c+8 -00 replies
3/7net: Admit native XDP on provider queuesDocumentation/networking/netmem.rst include/net/netdev_queues.h include/net/xdp.h +3 more+44 -61 reply
4/7eth: fbnic: Run XDP on provider queuesdrivers/net/ethernet/meta/fbnic/fbnic_txrx.c+3 -10 replies
5/7netdevsim: Run native XDP next to devmemdrivers/net/netdevsim/netdev.c+2 -00 replies
6/7selftests: net: Test XDP with devmem bindingstools/testing/selftests/net/nl_netdev.py+52 -20 replies
7/7selftests: net: Test XDP on io_uring RXMAINTAINERS tools/testing/selftests/drivers/net/hw/.gitignore tools/testing/selftests/drivers/net/hw/Makefile +5 more+492 -211 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH net-next 0/7] XDP with io_uring zero-copy RX and devmem

Hi!

I had a long chat on page-pool providers with Magnus and Maciej earlier this week, and the topic of "XDP on unreadable providers" came up. Magnus suggested building on the xdp.frags mode, to support this.

Here goes...

Devmem and io_uring zero-copy RX place packet payload in memory that the kernel cannot read through the normal packet APIs. Header split keeps the headers in ordinary kernel memory. Today, the core rejects XDP and these memory providers on the same device, in either attach order.

A program that checks headers should not need to copy the payload or turn off zero-copy receive. Keep the payload in fragments and run a native XDP program with frags support. Frags support means that the program accepts a packet whose data_end does not cover the whole packet. It does not give the program permission to read provider data.

Kuba added XDP_FLAGS_FRAGS_UNREADABLE, which already records this kind of payload. xdp_buff_add_frag() sets it for net_iov fragments, and skb construction copies it to skb->unreadable. Drivers use this path even without an XDP program. The series uses the same flag to stop helpers from reading or writing provider fragments. Header access still works.

XDP_PASS keeps the payload for the normal receive path. XDP_DROP frees it without reading it. Frame redirects and AF_XDP copies reject a buffer while the flag is set. The driver must also reject XDP_TX:
provider payload is mapped for receive, not transmit. Tail trimming can remove the payload without reading it; after the last fragment is removed, the remaining header buffer has no unreadable fragments.

Only drivers that declare xdp_unreadable support accept the combination. fbnic is the real driver in this series. Its XDP_TX path drops packets while unreadable fragments remain. netdevsim tests the attachment rules, but it does not test packet access to provider memory.

Generic XDP remains rejected. Its receive path first copies or linearizes nonlinear skbs, which fails when it reaches provider data. Even if that step were skipped, skb-to-XDP conversion does not carry the unreadable flag, and generic transmit and redirect use skb paths outside the native driver's XDP_TX guard. Supporting generic XDP needs separate handling; admitting it here would not be enough.

Björn

Björn Töpel (7):
bpf: Keep XDP helpers within readable data
xdp: Reject frames with unreadable fragments
net: Admit native XDP on provider queues
eth: fbnic: Run XDP on provider queues
netdevsim: Run native XDP next to devmem
selftests: net: Test XDP with devmem bindings
selftests: net: Test XDP on io_uring RX

 Documentation/networking/netmem.rst           |   8 +
 MAINTAINERS                                   |   2 +
 drivers/net/ethernet/meta/fbnic/fbnic_txrx.c  |   4 +-
 drivers/net/netdevsim/netdev.c                |   2 +
 include/linux/filter.h                        |   9 +-
 include/net/netdev_queues.h                   |   6 +
 include/net/xdp.h                             |  20 +-
 kernel/bpf/helpers.c                          |   4 +-
 net/core/dev.c                                |  28 +-
 net/core/dev.h                                |   1 +
 net/core/filter.c                             |  37 ++-
 net/core/netdev_rx_queue.c                    |   2 +-
 net/xdp/xsk.c                                 |   5 +
 .../selftests/drivers/net/hw/.gitignore       |   1 +
 .../testing/selftests/drivers/net/hw/Makefile |  10 +-
 tools/testing/selftests/drivers/net/hw/config |   5 +
 .../selftests/drivers/net/hw/iou-zcrx.c       | 242 +++++++++++++++++-
 .../selftests/drivers/net/hw/iou-zcrx.py      | 108 +++++++-
 .../selftests/drivers/net/hw/iou_zcrx.bpf.c   | 111 ++++++++
 .../selftests/drivers/net/hw/iou_zcrx.h       |  34 +++
 tools/testing/selftests/net/nl_netdev.py      |  54 +++-
 21 files changed, 646 insertions(+), 47 deletions(-)
 create mode 100644 tools/testing/selftests/drivers/net/hw/iou_zcrx.bpf.c
 create mode 100644 tools/testing/selftests/drivers/net/hw/iou_zcrx.h

base-commit: f23dcd8055612eb37c666c67fe0cfe38b3c65021

Signature · 1 line
2.56.1