Re: [PATCH net-next v10 4/8] net: bcmgenet: derive the receive buffer length from the MTU
From: netdev-bot+sashiko
Date: Sat Nov 28 2026 - 06:26:16 EST
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In drivers/net/ethernet/broadcom/genet/bcmgenet.c,
bcmgenet_set_mtu_regs() now writes RBUF_PKT_RDY_THLD (RBUF + 0x08)…
--
net: bcmgenet: derive the receive buffer length from the MTU
This patch drops the fixed 2048 byte receive buffer length. The length is
now derived from an MTU-based packet ready threshold, which the patch also
programs into RBUF_PKT_RDY_THLD. UMAC_MAX_FRAME_LEN and the TDMA flow
period are also derived from the MTU, with a floor at ETH_DATA_LEN.
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index 5c050331da690..15b7c8a525201 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
[ ... ]
> @@ -2653,6 +2677,41 @@ static void bcmgenet_link_intr_enable(struct bcmgenet_priv *priv)
> bcmgenet_intrl2_0_writel(priv, int0_enable, INTRL2_CPU_MASK_CLEAR);
> }
>
> +/* Receive threshold in register units. Covers the alignment bytes and the
> + * frame, but not the status block, which the hardware adds on top.
> + */
> +static unsigned int bcmgenet_pkt_rdy_thld(unsigned int mtu)
> +{
> + unsigned int len = GENET_RBUF_ALIGN + mtu + ETH_HLEN + VLAN_HLEN;
> +
> + len = round_up(len, ENET_THLD_BURST) / ENET_THLD_UNIT;
> +
> + /* Keep the reset default for the common MTUs */
> + return clamp_t(unsigned int, len, ENET_THLD_DEFAULT,
> + ENET_THLD_MAX_LEN / ENET_THLD_UNIT);
> +}
[ ... ]
> +/* Call with the MAC disabled */
> +static void bcmgenet_set_mtu_regs(struct bcmgenet_priv *priv, unsigned int mtu)
> +{
> + u32 thld = bcmgenet_pkt_rdy_thld(mtu);
> +
> + bcmgenet_umac_writel(priv, ENET_MAC_FRAME_LEN(mtu), UMAC_MAX_FRAME_LEN);
> +
> + /* GENET v1 maps other registers at these offsets */
> + if (GENET_IS_V1(priv))
> + return;
> +
> + bcmgenet_rbuf_writel(priv, thld, RBUF_PKT_RDY_THLD);
[Severity: Low]
The commit message treats this write as a no-op:
"so the threshold comes out at 0x80, the value a v5 holds out of reset"
Before this patch the driver never wrote RBUF_PKT_RDY_THLD. Now every
open and resume on v2, v3, v4 and v5 writes it, via
init_umac()->bcmgenet_set_mtu_regs().
Is it known that v2-v4 match v5 here? That covers the reset value, the
RBUF + 0x08 offset, the 8 bit field in 16 byte units and the 256 byte
burst rule.
The driver's own register map already shows that the RBUF block differs
between revisions:
#define RBUF_OVFL_CNT_V2 0x80
#define RBUF_OVFL_CNT_V3PLUS 0x94
...
#define RBUF_ERR_CNT_V2 0x84
#define RBUF_ERR_CNT_V3PLUS 0x98
Also, init_umac() writes RBUF_TBUF_SIZE_CTRL only on v3 and later.
If something else lives at RBUF + 0x08 on v2, or the units differ, could
RX frames end up split across descriptors? At this commit,
bcmgenet_desc_rx() drops those:
if (unlikely(!(dma_flag & DMA_EOP) || !(dma_flag & DMA_SOP))) {
netif_err(priv, rx_status, dev,
"dropping fragmented packet!\n");
v1 skips the write, but bcmgenet_probe() still sizes rx_buf_len from the
threshold formula on every revision:
priv->rx_buf_len = bcmgenet_rx_buf_len(dev->mtu);
So on v1, the rule "A buffer has to hold everything the threshold lets
the hardware deliver" depends on a threshold that is never programmed.
The later patch "net: bcmgenet: split frames that end just past the
transmit threshold" adds an unconditional TBUF_PKT_RDY_THLD write on the
same revisions, with the same v5-only reasoning.
Could the commit message state that the v2-v4 reset values and register
semantics match v5? Alternatively, the write could be limited to
revisions where it is known to change nothing.
> +}
> +
> static void init_umac(struct bcmgenet_priv *priv)
[ ... ]
> @@ -4156,6 +4216,7 @@ static int bcmgenet_probe(struct platform_device *pdev)
> /* Mii wait queue */
> init_waitqueue_head(&priv->wq);
> bcmgenet_hfb_init(priv);
> + priv->rx_buf_len = bcmgenet_rx_buf_len(dev->mtu);
> INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task);
[ ... ]
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
> index afaccb7699336..b40e56872132c 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h
[ ... ]
> @@ -218,6 +226,8 @@ struct bcmgenet_rx_stats64 {
> #define RBUF_ALIGN_2B (1 << 1)
> #define RBUF_BAD_DIS (1 << 2)
>
> +#define RBUF_PKT_RDY_THLD 0x08
> +
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127-nb-genet-mtu-nn-v2-v10-0-749c7cc45d97%40tipi-net.de