Skip to content

experimental backport of net-next macb xdp support#7271

Draft
nbuchwitz wants to merge 9 commits intoraspberrypi:rpi-6.18.yfrom
nbuchwitz:rpi/macb-xdp
Draft

experimental backport of net-next macb xdp support#7271
nbuchwitz wants to merge 9 commits intoraspberrypi:rpi-6.18.yfrom
nbuchwitz:rpi/macb-xdp

Conversation

@nbuchwitz
Copy link
Contributor

Experimental backport of https://lore.kernel.org/netdev/20260309144353.1213770-1-pvalerio@redhat.com/ to 6.18
Just meant for having a proper build, so interested parties can test this

CC @ghollingworth

tleb and others added 9 commits March 13, 2026 09:26
mog_alloc_rx_buffers(), getting called at open, does not do rx buffer
alloc on GEM. The bulk of the work is done by gem_rx_refill() filling
up all slots with valid buffers.

gem_rx_refill() is called at link up by
gem_init_rings() == bp->macbgem_ops.mog_init_rings().

Move operation to macb_open(), mostly to allow it to fail early and
loudly rather than init the device with Rx mostly broken.

About `bool fail_early`:
 - When called from macb_open(), ring init fails as soon as a queue
   cannot be refilled.
 - When called from macb_hresp_error_task(), we do our best to reinit
   the device: we still iterate over all queues and try refilling all
   even if a previous queue failed.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
This is a preparation commit as the field in later patches will no
longer accomomdate skbuffs, but more generic frames.

Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
Use the page pool allocator for the data buffers and enable skb
recycling support, instead of relying on netdev_alloc_skb
allocating the entire skb during the refill.

The patch also add support for receiving network frames that span
multiple DMA descriptors in the Cadence MACB/GEM Ethernet driver.

The patch removes the requirement that limited frame reception to
a single descriptor (RX_SOF && RX_EOF), also avoiding potential
contiguous multi-page allocation for large frames.

Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
gem_get_ethtool_stats calculates the size of the statistics
data to copy always considering maximum number of queues.

The patch makes sure the statistics are copied only for the
active queues as returned in the string set count op.

Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
The macb_tx_skb structure is renamed to macb_tx_buff with
no functional changes.

This is a preparatory step for adding xdp xmit support.

Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
Rename struct macb_tx_buff member skb to ptr and introduce
macb_tx_buff_type to identify the buffer type macb_tx_buff
represents.

Currently the buffer can only be MACB_TYPE_SKB, so the sk_buff
case is handled unconditionally in the tx path.
The remaining type handling will be handled by subsequent patches.

This is the last preparatory step for XDP xmit support.

Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
Introduce basic XDP support for macb/gem with the XDP_TX, XDP_PASS,
XDP_DROP, XDP_REDIRECT verdict support.

Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
Introduce ndo_xdp_xmit function for redirection,
update macb_xdp_submit_frame() accordingly, and advertise
NETDEV_XDP_ACT_NDO_XMIT capability.

Signed-off-by: Paolo Valerio <pvalerio@redhat.com>
macb_xdp_submit_frame() writes TSTART without first waking the MAC from
LPI. When EEE is active, TXLPIEN blocks all TX and the GEM MAC has no
auto-wake mechanism, so XDP frames will stall in the FIFO indefinitely.

Add macb_tx_lpi_wake() before TSTART, matching the regular TX path in
macb_start_xmit(). It's a no-op when EEE is not active.

Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
@P33M
Copy link
Contributor

P33M commented Mar 13, 2026

Does this need CONFIG_XDP_SOCKETS=y turned on to be of use?

@nbuchwitz
Copy link
Contributor Author

Does this need CONFIG_XDP_SOCKETS=y turned on to be of use?

AF_XDP (CONFIG_XDP_SOCKETS) is only needed if you want to do something like a userspace packet processor that receives raw frames directly from the NIC via XDP_REDIRECT to an xsk socket. For basic testing with ip link set dev eth0 xdp ... only BPF_SYSCALL is needed.

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.

4 participants