From: Simon Horman <horms@kernel.org>
To: pvalerio@redhat.com
Cc: Simon Horman <horms@kernel.org>,
edumazet@google.com, claudiu.beznea@tuxon.dev, nb@tipi-net.de,
theo.lebrun@bootlin.com, lorenzo@kernel.org, kuba@kernel.org,
nicolas.ferre@microchip.com, davem@davemloft.net,
andrew+netdev@lunn.ch, pabeni@redhat.com, netdev@vger.kernel.org
Subject: Re: [PATCH net-next v6 3/7] net: macb: Add page pool support handle multi-descriptor frame rx
Date: Wed, 25 Mar 2026 17:45:25 +0000 [thread overview]
Message-ID: <20260325174525.340041-1-horms@kernel.org> (raw)
In-Reply-To: <20260323221047.2749577-4-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.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: macb: Add page pool support handle multi-descriptor frame rx
This commit adds page pool support for the Cadence MACB/GEM Ethernet
driver and enables multi-descriptor frame reception. It replaces
netdev_alloc_skb() with page pool allocation and removes the limitation
that frames must fit in a single descriptor.
> diff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig
> index 5b2a461dfd28..ae500f717433 100644
> --- a/drivers/net/ethernet/cadence/Kconfig
> +++ b/drivers/net/ethernet/cadence/Kconfig
[ ... ]
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index fca7b9c6b670..84989ff0c3a9 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
[ ... ]
> @@ -2600,12 +2700,22 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
> return ret;
> }
>
> -static void macb_init_rx_buffer_size(struct macb *bp, size_t size)
> +static void macb_init_rx_buffer_size(struct macb *bp, unsigned int mtu)
> {
> + unsigned int overhead;
> + size_t size;
> +
> if (!macb_is_gem(bp)) {
> bp->rx_buffer_size = MACB_RX_BUFFER_SIZE;
> } else {
> - bp->rx_buffer_size = MIN(size, RX_BUFFER_MAX);
> + size = mtu + ETH_HLEN + ETH_FCS_LEN;
> + bp->rx_buffer_size = SKB_DATA_ALIGN(size + bp->rx_ip_align);
> + if (gem_total_rx_buffer_size(bp) > PAGE_SIZE) {
> + overhead = bp->rx_headroom +
> + SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
> + bp->rx_buffer_size = rounddown(PAGE_SIZE - overhead,
> + RX_BUFFER_MULTIPLE);
> + }
>
> if (bp->rx_buffer_size % RX_BUFFER_MULTIPLE) {
> netdev_dbg(bp->dev,
Can this overflow the hardware register field? The old code clamped size
against RX_BUFFER_MAX (16320), but the new code only guards against
PAGE_SIZE. Looking at the RXBS field in the hardware (GEM_RXBS_SIZE=8 bits
at macb.h:356), it can only represent values 0-255, encoding buffer sizes
0-16320 (value * RX_BUFFER_MULTIPLE where RX_BUFFER_MULTIPLE=64).
On systems with large page sizes (e.g., ARM64 with CONFIG_ARM64_64K_PAGES),
the PAGE_SIZE guard doesn't trigger for jumbo MTU values. If rx_buffer_size
reaches 16384 (SKB_DATA_ALIGN(16320+2)), then buffer_size = 16384/64 = 256,
which overflows the 8-bit field to 0 when written via GEM_BF(RXBS,
buffer_size) in macb_configure_dma():
drivers/net/ethernet/cadence/macb_main.c:macb_configure_dma() {
buffer_size = bp->rx_buffer_size / RX_BUFFER_MULTIPLE;
...
for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
if (q)
queue_writel(queue, RBQS, buffer_size);
else
dmacfg |= GEM_BF(RXBS, buffer_size);
}
}
This would cause the hardware to use an incorrect (zero) buffer size.
Should the code clamp rx_buffer_size to ensure buffer_size stays within
0-255 after the division?
next prev parent reply other threads:[~2026-03-25 17:45 UTC|newest]
Thread overview: 10+ 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-23 22:10 ` [PATCH net-next v6 2/7] net: macb: rename rx_skbuff into rx_buff Paolo Valerio
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 [this message]
2026-03-23 22:10 ` [PATCH net-next v6 4/7] net: macb: make macb_tx_skb generic Paolo Valerio
2026-03-23 22:10 ` [PATCH net-next v6 5/7] net: macb: generalize tx buffer handling Paolo Valerio
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-23 22:10 ` [PATCH net-next v6 7/7] net: macb: introduce ndo_xdp_xmit support Paolo Valerio
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=20260325174525.340041-1-horms@kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.beznea@tuxon.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--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