Skip to content

linux/ena: Add AF_XDP zero-copy multi-buffer support - #378

Open
zz85 wants to merge 1 commit into
amzn:masterfrom
zz85:ena/af-xdp-zc-multi-buffer
Open

zz85 wants to merge 1 commit into
amzn:masterfrom
zz85:ena/af-xdp-zc-multi-buffer

Conversation

@zz85

@zz85 zz85 commented Jun 26, 2026

Copy link
Copy Markdown

Add multi-buffer (scatter-gather) support for AF_XDP zero-copy mode on kernels >= 6.6 that expose the xsk_buff_add_frag() API.

Tx path:

  • Add a frame-atomic batch fast path (xsk_tx_peek_release_desc_batch) that guarantees complete frames are never truncated on the wire.
  • Fall back to per-descriptor peek for shared-pool configurations.
  • Track per-packet descriptor count (xsk_tx_nr_descs) for correct completion accounting.

Rx path:

  • Assemble multi-descriptor packets into xdp_buff frag chains.
  • Size XDP_PASS skbs for the full reassembled packet to prevent skb_shared_info corruption on __skb_put().
  • Properly free frag chains on FORWARD/DROP/RECYCLE/alloc-failure to prevent double-free and use-after-free.

Advertise xdp_zc_max_segs clamped to min(tx_sgl, rx_sgl, MAX_SKB_FRAGS+1) so the stack never hands frames the datapath cannot fit.

Guarded by ENA_XSK_MB_SUPPORT (ENA_AF_XDP_SUPPORT && ENA_HAVE_XSK_MULTI_BUFF).

Issue #, if available:

Description of changes:

This challenge allows receiving and sending of Jumbo frames using AF_XDP + Zero copy with the ENA driver

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Add multi-buffer (scatter-gather) support for AF_XDP zero-copy mode
on kernels >= 6.6 that expose the xsk_buff_add_frag() API.

Tx path:
- Add a frame-atomic batch fast path (xsk_tx_peek_release_desc_batch)
  that guarantees complete frames are never truncated on the wire.
- Fall back to per-descriptor peek for shared-pool configurations.
- Track per-packet descriptor count (xsk_tx_nr_descs) for correct
  completion accounting.

Rx path:
- Assemble multi-descriptor packets into xdp_buff frag chains.
- Size XDP_PASS skbs for the full reassembled packet to prevent
  skb_shared_info corruption on __skb_put().
- Properly free frag chains on FORWARD/DROP/RECYCLE/alloc-failure
  to prevent double-free and use-after-free.

Advertise xdp_zc_max_segs clamped to min(tx_sgl, rx_sgl, MAX_SKB_FRAGS+1)
so the stack never hands frames the datapath cannot fit.

Guarded by ENA_XSK_MB_SUPPORT (ENA_AF_XDP_SUPPORT && ENA_HAVE_XSK_MULTI_BUFF).
@davidarinzon

Copy link
Copy Markdown
Contributor

Hi @zz85

Thank you for submitting this pull request, apologies for not replying sooner.
The feature is indeed on our agenda, we will take a look and analyze the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants