mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] net: macb: limit jumbo frames to the RX buffer size
@ 2026-11-14  9:51 Han Gao via B4 Relay
  2026-11-15 21:04 ` netdev-bot+sashiko
  0 siblings, 1 reply; 2+ messages in thread
From: Han Gao via B4 Relay @ 2026-11-14  9:51 UTC (permalink / raw)
  To: Théo Lebrun, Conor Dooley, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Punnaiah Choudary Kalluri, Harini Katakam
  Cc: linux-riscv, Han Gao, netdev, linux-kernel, Jingkun Zheng, Han Gao

From: Han Gao <gaohan@iscas.ac.cn>

GEM variants with MACB_CAPS_JUMBO accept frames up to jumbo_max_len
regardless of the MTU, but the RX buffers are sized from the MTU. A
frame longer than one RX buffer is split over several descriptors and
dropped by gem_rx() with "not whole frame pointed by descriptor".

Set JML from the RX buffer size in macb_configure_dma(), so that it
follows MTU changes and longer frames are dropped by the MAC instead.

Fixes: 98b5a0f4a228 ("net: macb: Add support for jumbo frames")
Reported-by: Jingkun Zheng <zhengjingkun@iscas.ac.cn>
Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
---
Seen on a SiFive FU740 with the default MTU: every jumbo frame on the
network caused two "not whole frame pointed by descriptor" errors.
---
 drivers/net/ethernet/cadence/macb_main.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 5ad0e32e2b4001c37e230a2eb7badb468b14ab57..e7c9bb24c377babc8dfd57e82ebf55a8e996873d 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -3240,6 +3240,18 @@ static u32 macb_dbw(struct macb *bp)
 	}
 }
 
+/* Longest frame that fits in a single RX buffer */
+static u32 gem_jumbo_max_len(struct macb *bp)
+{
+	u32 len = bp->ctx->rx_buffer_size;
+
+	/* Frame data starts NET_IP_ALIGN bytes into the buffer without RSC */
+	if (!(bp->caps & MACB_CAPS_RSC))
+		len -= NET_IP_ALIGN;
+
+	return min(len, bp->jumbo_max_len);
+}
+
 /* Configure the receive DMA engine
  * - use the correct receive buffer size
  * - set best burst length for DMA operations
@@ -3286,6 +3298,13 @@ static void macb_configure_dma(struct macb *bp)
 		netdev_dbg(bp->netdev, "Cadence configure DMA with 0x%08x\n",
 			   dmacfg);
 		gem_writel(bp, DMACFG, dmacfg);
+
+		/* Jumbo frames are always enabled, so limit their length to
+		 * what fits in one RX buffer. Longer frames would otherwise be
+		 * split across several descriptors and dropped by gem_rx().
+		 */
+		if ((bp->caps & MACB_CAPS_JUMBO) && bp->jumbo_max_len)
+			gem_writel(bp, JML, gem_jumbo_max_len(bp));
 	}
 }
 
@@ -3422,8 +3441,6 @@ static void macb_init_hw(struct macb *bp)
 		config |= MACB_BIT(NBC);	/* No BroadCast */
 	config |= macb_dbw(bp);
 	macb_writel(bp, NCFGR, config);
-	if ((bp->caps & MACB_CAPS_JUMBO) && bp->jumbo_max_len)
-		gem_writel(bp, JML, bp->jumbo_max_len);
 	bp->rx_frm_len_mask = MACB_RX_FRMLEN_MASK;
 	if (bp->caps & MACB_CAPS_JUMBO)
 		bp->rx_frm_len_mask = MACB_RX_JFRMLEN_MASK;

---
base-commit: aa40afa831ebfe45e40a23721711059f2ac584d4
change-id: 20261111-macb-jumbo-jml-49d07c0cd9d2

Best regards,
-- 
Han Gao <gaohan@iscas.ac.cn>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-15 21:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-14  9:51 [PATCH net] net: macb: limit jumbo frames to the RX buffer size Han Gao via B4 Relay
2026-11-15 21:04 ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®