[PATCH RFC net-next 00/12] enic: add native XDP and AF_XDP support
From: Satish Kharat
Date: Mon Nov 30 2026 - 20:16:26 EST
This RFC adds native XDP RX, TX, and redirect, followed by AF_XDP
zero-copy RX and TX, to enic on physical VIC vNICs with mixed RQ
descriptor support. It also adds WQ descriptor ownership and completion
accounting, RX page geometry, queue counters, and an XSK detach selftest.
The driver advertises XDP features only on capable vNICs. It stops RX
before publishing a replacement XDP program, disables RX VLAN stripping
while XDP is active so packet actions see tag bytes, and restores the
requested strip mode on detach. When RX VLAN stripping is disabled for
XDP, receive buffers are sized for a full-MTU packet with two in-band
VLAN tags. XSK bind checks that the frame can hold such a packet even
if XDP is attached later; a bound socket stayed active across that
attach in testing. Partial RQ refill batches are published before RX
wakeup is cleared. RX and TX updates to a shared XSK pool's NEED_WAKEUP
state are serialized. A zero-budget NAPI poll completes only whole
skb-owned WQ CQ spans and defers RX, XDP, and XSK work.
This revision folds a final-XDP-detach ownership and transient-reopen
fix into 08/12. Once a BPF link is released, a failed queue reopen must
not restore its old program. The driver keeps NULL published, releases
its program reference, and retries the reopen once before considering
reset work.
AF_XDP zero-copy XDP_PASS also needs the generic
xdp_build_skb_from_zc() head-sizing fix posted separately by Björn Töpel
as [PATCH net v2 2/4] on 2026-11-30:
https://lore.kernel.org/netdev/20261130123737.125432-3-bjorn@xxxxxxxxxx/
That patch is a prerequisite for this RFC's AF_XDP path. It is not one
of the 12 patches below; the prerequisite-patch-id at the end of this
cover identifies the exact posted v2 diff. Its upstream merge was not
verified when this candidate was prepared.
LLM assistance was used for design review, code review, and test case
development for this RFC.
Validation:
- The previous 12-patch RFC tip was built as an enic module for a
7.4.0-rc2 test kernel and loaded on a VIC 15237 PCI-passthrough vNIC
(firmware 5.3(4.75)), with a separate hardware peer. Its applicable
single-buffer IPv4/IPv6 xdp.py cases passed 12/12, covering XDP_PASS,
XDP_DROP, XDP_TX, and queue statistics. AF_XDP zero-copy TX posted
and completed 64/64 frames.
- On E1, a fail-closed guard on the original generic helper recorded
five would-overruns at 2048-byte UMEM chunks and MTU 1500:
need=1776, avail=1728. It dropped those packets before the unchecked
copy. A locally drafted helper fix delivered 5/5 probes with the same
fixture. That targeted result does not test Björn's exact v2 diff.
- On E1, the original final BPF-link detach with an injected one-shot
enic_open() error retained the ENIC-owned program after the link
disappeared. The ENIC change folded into 08/12 was tested under the
same fault: the link and program were gone, the direct retry restored
service, and E1 and E2 each passed 10/10 IPv4 and 10/10 IPv6 probes.
- This exact candidate, including Björn's posted v2 patch, passed a
focused CONFIG_WERROR=y object build and a full 7.4.0-rc2 kernel and
2,590-module build. It booted on the E1 VIC 15237 guest. The first
applicable native XDP selftest run passed 11/12; qstats.drop_ipv4
failed in bpftool map selection before traffic because more than one
map matched its global name. The identical full retry passed 12/12
single-buffer IPv4/IPv6 PASS, DROP, TX, and qstats cases. The duplicate
map's owner was not captured, so its cause remains open.
- A bound zero-copy XSK smoke test on this candidate recorded 151 ENIC
XSK RX packets and 151 xdp_build_skb_from_zc() calls. The BPF link and
program disappeared after detach with the socket open; peer IPv4 and
IPv6 probes passed 3/3 each. The fixture did not consume RX descriptors
or check their payload and did not test AF_XDP TX. Its undrained fill
ring produced a large fill-empty count. The dedicated 2048-byte
near-MTU test of Björn's exact v2 patch remains deferred.
- After the suite, E1 returned to its saved known-good kernel with native
Cilium XDP attached; all three nodes and Cilium pods were Ready and
two-way peer traffic passed. The candidate kernel remains non-default.
- On the 11-patch precursor, Cilium native load balancing, devmap
redirect, XSK bind/unbind, program replacement, MTU changes, and
zero-budget netpoll were exercised. The full Cilium CLI run had an
intermittent IPv6 timeout and two pre-existing cluster-health
failures. The native regression suite had two bounded timing
failures. These broader runs were not repeated after the queue
statistics and detach fixes.
Persistent reopen failure/reset recovery, deterministic partial-FILL
and NEED_WAKEUP interleavings, mixed XSK/XDP completions in zero-budget
netpoll, pool-bound reset/reload, AF_XDP userspace RX/TX, Cilium service
end-to-end qualification, full 9K QinQ, a real firmware-command failure,
and other VIC families remain untested on this candidate. This
is a request for review of the driver and teardown design, not a claim
of merge readiness or a support announcement.
Signed-off-by: Satish Kharat <satishkh@xxxxxxxxx>
---
Satish Kharat (12):
net: enic: bound skb TX rollback to current packet
net: enic: tag work queue descriptor ownership
net: enic: gate native XDP on mixed RQ descriptor capability
net: enic: expose per-queue XDP and AF_XDP counters
net: enic: complete XDP frames by WQ descriptor ownership
net: enic: reserve XDP head and tailroom in RX pages
net: enic: publish partial receive descriptor batches
net: enic: add native XDP RX, TX, and redirect
net: enic: batch AF_XDP TX completions by pool
net: enic: add AF_XDP zero-copy RX and TX
selftests/xsk: exercise XDP detach with bound socket
net: enic: count XDP and AF_XDP TX in queue statistics
drivers/net/ethernet/cisco/enic/Makefile | 3 +-
drivers/net/ethernet/cisco/enic/enic.h | 49 ++
drivers/net/ethernet/cisco/enic/enic_admin.c | 8 +-
drivers/net/ethernet/cisco/enic/enic_api.c | 9 +
drivers/net/ethernet/cisco/enic/enic_dev.c | 8 +
drivers/net/ethernet/cisco/enic/enic_dev.h | 1 +
drivers/net/ethernet/cisco/enic/enic_ethtool.c | 15 +
drivers/net/ethernet/cisco/enic/enic_main.c | 755 ++++++++++++++++++++---
drivers/net/ethernet/cisco/enic/enic_rq.c | 86 ++-
drivers/net/ethernet/cisco/enic/enic_wq.c | 121 +++-
drivers/net/ethernet/cisco/enic/enic_wq.h | 2 +-
drivers/net/ethernet/cisco/enic/enic_xdp.c | 726 ++++++++++++++++++++++
drivers/net/ethernet/cisco/enic/enic_xdp.h | 53 ++
drivers/net/ethernet/cisco/enic/vnic_dev.c | 16 +-
drivers/net/ethernet/cisco/enic/vnic_dev.h | 2 +
drivers/net/ethernet/cisco/enic/vnic_enet.h | 1 +
drivers/net/ethernet/cisco/enic/vnic_rq.h | 21 +-
drivers/net/ethernet/cisco/enic/vnic_wq.h | 15 +
tools/testing/selftests/net/lib/xsk/test_xsk.c | 51 +-
tools/testing/selftests/net/lib/xsk/test_xsk.h | 2 +
tools/testing/selftests/net/lib/xsk/xsk.c | 4 +-
tools/testing/selftests/net/lib/xsk/xsk.h | 2 +-
tools/testing/selftests/net/lib/xsk/xskxceiver.c | 23 +-
23 files changed, 1829 insertions(+), 144 deletions(-)
---
base-commit: cf0dd134a16e2e5bb090b385acdbd745d4395807
change-id: 20261130-enic-xdp-rfc-p1-20261130-388b0907802a
prerequisite-patch-id: e90ee2f97349eb5a3bf16169aeeb928a28ec6bf7
Best regards,
--
Satish Kharat <satishkh@xxxxxxxxx>