From: Jakub Kicinski <kuba@kernel.org>
To: pvalerio@redhat.com
Cc: Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, nicolas.ferre@microchip.com,
claudiu.beznea@tuxon.dev, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
lorenzo@kernel.org, theo.lebrun@bootlin.com, nb@tipi-net.de
Subject: Re: [PATCH net-next v6 7/7] net: macb: introduce ndo_xdp_xmit support
Date: Sun, 29 Mar 2026 12:47:51 -0700 [thread overview]
Message-ID: <20260329194751.2781563-1-kuba@kernel.org> (raw)
In-Reply-To: <20260323221047.2749577-8-pvalerio@redhat.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
net: macb: introduce ndo_xdp_xmit support
This commit introduces ndo_xdp_xmit support for the macb driver to
enable XDP redirection. It adds the gem_xdp_xmit function and updates
macb_xdp_submit_frame to handle DMA mapping for redirected frames.
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 537d02264851..38b15d1e7127 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
[ ... ]
> @@ -1708,8 +1723,8 @@ static int macb_xdp_submit_frame(struct macb *bp, struct xdp_frame *xdpf,
> desc = macb_tx_desc(queue, queue->tx_head);
> tx_buff = macb_tx_buff(queue, queue->tx_head);
> tx_buff->ptr = xdpf;
> - tx_buff->type = MACB_TYPE_XDP_TX;
> - tx_buff->mapping = 0;
> + tx_buff->type = buff_type;
> + tx_buff->mapping = dma_map ? mapping : 0;
> tx_buff->size = xdpf->len;
Is a bounds check needed on the frame length here?
Since ndo_xdp_xmit can receive frames redirected from other devices,
the frame length could potentially be up to ~64KB on architectures with
64KB pages.
macb_xdp_submit_frame() casts this length to a 32-bit integer and
bitwise-ORs it into the descriptor's control word, which has a 14-bit
length field (maximum 16383 bytes). Frame lengths exceeding this limit
could silently overflow into adjacent control bits like TX_LAST,
corrupting the descriptor ring.
[ ... ]
> +static int gem_xdp_xmit(struct net_device *dev, int num_frame,
> + struct xdp_frame **frames, u32 flags)
> +{
> + struct macb *bp = netdev_priv(dev);
> + u32 xmitted = 0;
> + int i;
> +
> + if (!macb_is_gem(bp))
> + return -EOPNOTSUPP;
> +
> + if (unlikely(!netif_carrier_ok(dev)))
> + return -ENETDOWN;
> +
> + if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
> + return -EINVAL;
> +
> + for (i = 0; i < num_frame; i++) {
> + if (macb_xdp_submit_frame(bp, frames[i], dev, true, 0))
> + break;
Should this loop batch the doorbell rings based on the XDP_XMIT_FLUSH flag?
Currently, the code calls macb_xdp_submit_frame() for each frame, which
independently acquires the global bp->lock and performs an MMIO write to the
NCR register to ring the hardware doorbell per packet.
Doing this per packet ignores the batching semantics of the bulk transmission
API and could cause severe lock contention and MMIO overhead.
> +
> + xmitted++;
> + }
> +
> + return xmitted;
> +}
prev parent reply other threads:[~2026-03-29 19:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-23 22:10 [PATCH net-next v6 0/7] net: macb: Add XDP support and page pool integration Paolo Valerio
2026-03-23 22:10 ` [PATCH net-next v6 1/7] net: macb: move Rx buffers alloc from link up to open Paolo Valerio
2026-03-29 19:47 ` Jakub Kicinski
2026-03-23 22:10 ` [PATCH net-next v6 2/7] net: macb: rename rx_skbuff into rx_buff Paolo Valerio
2026-03-29 19:47 ` Jakub Kicinski
2026-03-23 22:10 ` [PATCH net-next v6 3/7] net: macb: Add page pool support handle multi-descriptor frame rx Paolo Valerio
2026-03-25 17:45 ` Simon Horman
2026-03-29 19:47 ` Jakub Kicinski
2026-03-23 22:10 ` [PATCH net-next v6 4/7] net: macb: make macb_tx_skb generic Paolo Valerio
2026-03-29 19:47 ` Jakub Kicinski
2026-03-23 22:10 ` [PATCH net-next v6 5/7] net: macb: generalize tx buffer handling Paolo Valerio
2026-03-29 19:47 ` Jakub Kicinski
2026-03-23 22:10 ` [PATCH net-next v6 6/7] net: macb: add XDP support for gem Paolo Valerio
2026-03-24 4:57 ` Mohsin Bashir
2026-03-29 19:47 ` Jakub Kicinski
2026-03-29 19:50 ` Jakub Kicinski
2026-03-23 22:10 ` [PATCH net-next v6 7/7] net: macb: introduce ndo_xdp_xmit support Paolo Valerio
2026-03-29 19:47 ` Jakub Kicinski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260329194751.2781563-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.beznea@tuxon.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=lorenzo@kernel.org \
--cc=nb@tipi-net.de \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pabeni@redhat.com \
--cc=pvalerio@redhat.com \
--cc=theo.lebrun@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox