linux/Documentation/networking
Maciej Fijalkowski 72f2b4516f xsk: reclaim invalid Tx descriptors in ZC batch path
The zero-copy Tx batch parser stops when it encounters an invalid
descriptor. If this happens after one or more continuation descriptors,
the Tx consumer can be advanced past fragments that are neither submitted
to the driver nor returned to userspace through the completion ring.

A similar problem occurs when a packet exceeds xdp_zc_max_segs. The
descriptors consumed up to the limit are released without completion, and
the remaining continuation descriptors can subsequently be interpreted
as the beginning of another packet.

Parse Tx batches in packet units and distinguish descriptors belonging to
complete valid packets from descriptors consumed while draining an
invalid or oversized packet. Return the former to the driver and append
the latter to the CQ address area so userspace can reclaim their UMEM
frames.

Treat a standalone invalid descriptor as a one-descriptor reclaim-only
packet. Advancing the Tx-ring consumer releases the ring slot, but does
not by itself return ownership of the referenced UMEM frame to userspace.

Once draining starts, continue until the packet's end-of-packet
descriptor is consumed. Preserve the drain state on the socket when EOP
has not yet been supplied, so draining can continue during a later call.
Leave incomplete but otherwise valid packets on the Tx ring.

Shared-UMEM pools using multi-buffer Tx also need packet-framed parsing.
Walk their Tx sockets one packet at a time, preserving the existing
per-socket fairness scheme, instead of using the legacy one-descriptor
fallback. Keep that fallback for shared pools that do not use
multi-buffer Tx. Since the drain state is maintained per socket and both
the singular and shared paths can resume an interrupted drain, changing
the socket list from singular to shared requires no special bind-time
transition.

CQ entries are positional, and drivers may complete only part of the Tx
work returned by xsk_tx_peek_release_desc_batch(). Therefore, reclaim-only
entries cannot be published immediately when earlier driver-visible
descriptors are still outstanding.

Track the number of driver-visible CQ entries preceding the reclaim
entries. Let xsk_tx_completed() publish partial hardware Tx completions,
and publish the reclaim entries only after every earlier Tx descriptor
has completed. Complete a reclaim-only batch immediately when there is no
driver-visible work in front of it, and prevent another Tx batch from
being appended while reclaim entries remain pending.

Also cap batch processing by the size of the pool's temporary descriptor
array, as Tx rings belonging to sockets sharing a UMEM may have different
sizes.

This ensures that every invalid Tx descriptor consumed by the ZC batch
path is either submitted to the driver as part of a valid packet or
returned to userspace without violating CQ completion ordering.

Reviewed-by: Jason Xing <kernelxing@tencent.com>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Fixes: cf24f5a5fe ("xsk: add support for AF_XDP multi-buffer on Tx path")
Link: https://patch.msgid.link/20260719135609.147823-5-maciej.fijalkowski@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-24 15:12:14 -07:00
..
device_drivers Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2026-05-21 15:09:02 -07:00
devlink docs: net: fix minor issues with devlink docs 2026-06-15 15:42:53 -07:00
diagnostic Documentation: use a source-read extension for the index link boilerplate 2026-01-23 11:59:34 -07:00
dsa dt-bindings: net: dsa: Convert lan9303.txt to yaml format 2026-06-13 15:00:07 -07:00
mac80211_hwsim
net_cachelines appletalk: stop storing per-interface state in struct net_device 2026-06-16 14:37:06 -07:00
pse-pd net: pse-pd: Add support for PSE PIs 2024-04-18 18:27:33 -07:00
xfrm xfrm: add documentation for XFRM_MSG_MIGRATE_STATE 2026-06-04 12:22:50 +02:00
6lowpan.rst
af_xdp.rst xsk: reclaim invalid Tx descriptors in ZC batch path 2026-07-24 15:12:14 -07:00
alias.rst
arcnet-hardware.rst docs: net: arcnet: remove outdated/irrelevant information; improve style 2026-05-22 17:20:57 -07:00
arcnet.rst docs: net: arcnet: remove outdated/irrelevant information; improve style 2026-05-22 17:20:57 -07:00
atm.rst
bareudp.rst docs: net: bareudp: fix spelling and grammar mistakes 2024-11-30 13:54:28 -08:00
batman-adv.rst batman-adv: Use consistent name for mesh interface 2025-02-22 11:36:22 +01:00
bonding.rst bonding: 3ad: add lacp_strict configuration knob 2026-06-10 07:53:26 -07:00
bridge.rst docs: net: bridge: document stp_mode attribute 2026-04-10 15:52:25 -07:00
can_ucan_protocol.rst Documentation: networking: correct spelling 2023-01-31 13:00:47 +01:00
can.rst linux-can-fixes-for-6.18-20251014 2025-10-15 17:56:20 -07:00
cdc_mbim.rst Fix spelling mistake 2024-11-28 12:08:32 +01:00
checksum-offloads.rst docs: net: render the checksum comment in checksum-offloads.rst 2026-05-28 14:37:47 -07:00
dctcp.rst
devmem.rst docs: net: update devmem code examples 2026-05-28 14:37:46 -07:00
dns_resolver.rst net: dns_resolver: Fix request-key cross-reference 2025-09-26 15:21:38 -07:00
driver.rst docs: networking: add guidance on what to push via extack 2026-06-12 17:55:48 -07:00
eql.rst
ethtool-netlink.rst net: ethtool: add ethtool COALESCE_RX_CQE_FRAMES/NSECS 2026-03-18 20:01:10 -07:00
failover.rst
fib_trie.rst
filter.rst ARC: Add eBPF JIT support 2024-05-12 16:51:36 -07:00
gen_stats.rst
generic_netlink.rst
generic-hdlc.rst
gtp.rst Documentation: networking: correct spelling 2023-01-31 13:00:47 +01:00
ieee802154.rst Documentation: ieee802154: fix grammar 2024-10-28 21:14:27 +01:00
ila.rst
index.rst net: remove ax25 and amateur radio (hamradio) subsystem 2026-04-23 10:24:02 -07:00
ioam6-sysctl.rst
iou-zcrx.rst io_uring/zcrx: document area chunking parameter 2026-01-14 02:13:37 +00:00
ip_dynaddr.rst
ip-sysctl.rst tcp: rehash onto different local ECMP path on retransmit timeout 2026-06-15 15:57:31 -07:00
ipsec.rst
ipv6.rst
ipvlan.rst Documentation: networking: correct spelling 2023-01-31 13:00:47 +01:00
ipvs-sysctl.rst ipvs: fix doc syntax for conn_max sysctl 2026-06-14 12:51:55 +02:00
iso15765-2.rst Documentation/networking: fix basic node example document ISO 15765-2 2025-02-08 11:28:11 +01:00
j1939.rst can: j1939: Extend stack documentation with buffer size behavior 2025-02-19 11:10:53 +01:00
kapi.rst net-shapers: implement NL get operation 2024-10-10 08:30:22 -07:00
kcm.rst docs/kcm: Fix typo "BFP" 2025-03-24 12:20:42 -07:00
l2tp.rst documentation/networking: update l2tp docs 2024-08-11 04:38:49 +01:00
lapb-module.rst
mac80211-auth-assoc-deauth.txt
mac80211-injection.rst
mctp.rst
mpls-sysctl.rst
mptcp-sysctl.rst mptcp: introduce add_addr_v6_port_drop_ts sysctl knob 2026-06-11 15:33:37 -07:00
mptcp.rst Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-09-11 17:40:13 -07:00
msg_zerocopy.rst docs: net: description of MSG_ZEROCOPY for AF_VSOCK 2023-10-15 13:19:42 +01:00
multi-pf-netdev.rst tools: ynl: move python code to separate sub-directory 2025-01-09 12:53:27 -08:00
multiqueue.rst
napi.rst docs: net: fix minor issues with the NAPI guide 2026-05-28 14:37:46 -07:00
net_dim.rst dim: pass dim_sample to net_dim() by reference 2024-11-03 12:36:54 -08:00
net_failover.rst Documentation: net: net_failover: Separate cloud-ifupdown-helper and reattach-vf.sh code blocks marker 2025-10-17 16:28:29 -07:00
netconsole.rst Documentation: netconsole: Separate literal code blocks for full and short netcat command name versions 2025-10-31 16:54:22 -07:00
netdev-features.rst docs: net: ethtool: document ops-locked drivers and op_needs_rtnl 2026-06-09 10:13:06 -07:00
netdevices.rst vlan: defer real device state propagation to netdev_work 2026-06-25 10:18:40 -07:00
netfilter-sysctl.rst
netif-msg.rst
netmem.rst net: netkit: declare NETMEM_TX_NO_DMA mode 2026-05-18 18:49:06 -07:00
nexthop-group-resilient.rst
nf_conntrack-sysctl.rst netfilter: conntrack: remove DCCP protocol support 2025-07-03 13:51:39 +02:00
nf_flowtable.rst
nfc.rst net: nfc: Format userspace interface subsection headings 2025-10-21 10:57:45 +02:00
oa-tc6-framework.rst Documentation: networking: add OPEN Alliance 10BASE-T1x MAC-PHY serial interface 2024-09-11 20:53:42 -07:00
openvswitch.rst
operstates.rst
packet_mmap.rst docs: networking: packet_mmap: replace dead links with archive.org links 2024-10-28 15:47:10 -07:00
page_pool.rst docs: page_pool: drop the mention of the legacy stats API 2026-05-28 18:10:03 -07:00
phonet.rst Documentation: networking: correct spelling 2023-01-31 13:00:47 +01:00
phy-link-topology.rst Documentation: networking: document phy_link_topology 2024-08-23 13:04:35 +01:00
phy-port.rst Documentation: networking: Document the phy_port infrastructure 2026-01-13 18:52:36 -08:00
phy.rst net: phy: remove unused fixup unregistering functions 2026-01-15 19:48:26 -08:00
pktgen.rst pktgen: Introducing 'SHARED' flag for testing with non-shared skb 2023-09-28 16:25:14 +02:00
plip.rst
ppp_generic.rst
proc_net_tcp.rst
psp.rst psp: add documentation 2025-09-18 12:32:06 +02:00
radiotap-headers.rst
rds.rst Documentation: Fix networking typos 2025-08-18 10:31:20 -06:00
regulatory.rst Documentation: networking: correct spelling 2023-01-31 13:00:47 +01:00
representors.rst Documentation: Add documentation for eswitch attribute 2024-03-28 18:20:08 -07:00
rxrpc.rst Documentation: rxrpc: Demote three sections 2025-09-24 18:12:10 -07:00
scaling.rst net-sysfs: use rps_tag_ptr and remove metadata from rps_sock_flow_table 2026-03-04 16:54:09 -08:00
sctp.rst
secid.rst
seg6-sysctl.rst doc: fix seg6_flowlabel path 2025-10-12 22:51:37 +01:00
segmentation-offloads.rst docs: net: fix minor issues with segmentation offloads 2026-05-28 14:37:47 -07:00
sfp-phylink.rst doc: sfp-phylink: update the porting guide with PCS handling 2024-03-07 15:27:05 +01:00
skbuff.rst docs: net: render the checksum comment in checksum-offloads.rst 2026-05-28 14:37:47 -07:00
smc-sysctl.rst Documentation: net/smc: correct old value of smcr_max_recv_wr 2026-04-27 16:49:39 -07:00
snmp_counter.rst docs: automarkup: linkify git revs 2023-11-17 13:13:24 -07:00
sriov.rst docs: net: document guidance of implementing the SR-IOV NDOs 2024-06-21 10:18:45 +01:00
statistics.rst docs: net: statistics: fix kernel-internal stats list 2026-05-28 14:37:46 -07:00
strparser.rst docs: net: fix minor issues with strparser docs 2026-06-15 15:42:53 -07:00
switchdev.rst net: rename netns_local to netns_immutable 2025-03-04 12:44:48 +01:00
sysfs-tagging.rst Documentation: networking: correct spelling 2023-01-31 13:00:47 +01:00
tc-actions-env-rules.rst
tc-queue-filters.rst
tcp_ao.rst Documentation/tcp_ao: Document the supported MAC algorithms and lengths 2026-05-02 10:18:09 -07:00
tcp-thin.rst
team.rst
timestamping.rst net: remove legacy way to get/set HW timestamp config 2026-01-20 18:21:27 -08:00
tipc.rst Documentation: tipc: fix formatting issue in tipc.rst 2024-11-19 11:17:13 +01:00
tls-handshake.rst net/handshake: Fixed grammar mistake 2026-02-27 19:24:08 -08:00
tls-offload-layers.svg
tls-offload-reorder-bad.svg
tls-offload-reorder-good.svg
tls-offload.rst docs: net: tls-offload: document tls_dev_del, tls_dev_resync, and rekey 2026-06-15 15:42:52 -07:00
tls.rst net/tls: support setting the maximum payload size 2025-10-27 16:13:42 -07:00
tproxy.rst docs: tproxy: fix formatting for nft code block 2025-04-29 00:00:26 +02:00
tuntap.rst
udplite.rst
vrf.rst
vxlan.rst
x25-iface.rst docs: networking: fix x25-iface.rst heading & index order 2023-05-10 10:31:46 +01:00
x25.rst
xdp-rx-metadata.rst docs: net: fix minor issues with XDP metadata docs 2026-06-12 15:58:02 -07:00
xsk-tx-metadata.rst docs: net: fix minor issues with XDP metadata docs 2026-06-12 15:58:02 -07:00