🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23958

[PATCH net-next v3] net: stmmac: Limit the MTU of normal descriptors to one RX buffer

#23958
From: Arun Iyengar via B4 Relay
Date: Sat, 28 Nov 2026 17:37
89 lines
14451 bytes
From: Arun Iyengar <aiyengar1990@gmail.com>

As Russell King pointed out in [1], max_mtu for normal descriptors,
SKB_MAX_HEAD() (3712 on arm64), is too high: ndesc_get_rx_status()
drops every frame that spans more than one descriptor, and the DMA does
not always fill the 2047-byte buffer. Chen-Yu Tsai found the reason in
the STM32F4 and Arria 10 manuals: the DMA writes whole bus words,
counted from the word that holds the buffer start. Andrew Lunn noted
that such an offset aligns the IP header; stmmac_rx_offset() adds
NET_IP_ALIGN. Maxime Chevallier found the first failing untagged MTU:
2025 on H2+ (arm32, chain mode), 2029 on A20 and 2031 on meson-g12a
(ring mode). On H616 (arm64, chain mode) it is 2027.

Take the widest bus, 16 bytes, NET_IP_ALIGN, the two bytes a Type-1
checksum engine appends, two VLAN tags and the FCS. max_mtu is then
2006 on arm64 and 2004 on arm32, two less with Type-1.

Link: https://lore.kernel.org/r/E1vLJcL-0000000ExBL-0GFe@rmk-PC.armlinux.org.uk [1]
Fixes: 48febf7e6476 ("stmmac: allow mtu bigger than 1500 in case of normal desc (V4)")
Cc: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
Tested on an Orange Pi Zero2 (H616, arm64, Type-2 COE, chain mode) on
net-next: before, MTU 2027 drops every full-size RX frame; after, max
MTU 2006, lossless. Untested: arm32, Type-1 COE, ring mode, dwmac1000
JE. Ring-mode RX buffer 2 and normal TX lengths: older bugs, separate
patches.

Claude (AI) helped write this patch; I reviewed and tested it.
---
Changes in v3:
- One generic limit (Chen-Yu, Andrew, Maxime's sweep); RX is the limit
  (Nicolai); sun8i patch dropped; net-next, no Cc stable.
- Sashiko: bus width, NET_IP_ALIGN, Type-1 bytes counted; RBS1 unchanged,
  frames end inside the aligned part; JE only lets longer frames in, and
  they are dropped as before.
- Link to v2: https://patch.msgid.link/20261122-sun8i-emac-mtu-limit-v2-0-c4081e5b83cf@gmail.com

Changes in v2:
- Limit normal descriptors in the core (patch 1, Andrew Lunn, Maxime
  Chevallier), keep the lower sun8i limit as patch 2
- Link to v1: https://patch.msgid.link/20261121-sun8i-emac-mtu-limit-v1-1-22492842d318@gmail.com
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index ca4c7fb11b73..bf688ee46c84 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1568,6 +1568,20 @@ static unsigned int stmmac_rx_offset(struct stmmac_priv *priv)
 	return NET_SKB_PAD + NET_IP_ALIGN;
 }
 
+/* A normal descriptor frame must fit one RX buffer. The DMA writes whole bus
+ * words of up to 16 bytes, from the word that holds the NET_IP_ALIGN offset.
+ * Type-1 checksum engines append two bytes.
+ */
+static int stmmac_ndesc_max_mtu(struct stmmac_priv *priv)
+{
+	int len = ALIGN_DOWN(BUF_SIZE_2KiB - 1, 16) - NET_IP_ALIGN;
+
+	if (priv->plat->rx_coe == STMMAC_RX_COE_TYPE1)
+		len -= 2;
+
+	return len - ETH_HLEN - 2 * VLAN_HLEN - ETH_FCS_LEN;
+}
+
 static int stmmac_set_bfsize(int len)
 {
 	int ret;
@@ -8315,6 +8329,8 @@ static int __stmmac_dvr_probe(struct device *device,
 		ndev->max_mtu = XGMAC_JUMBO_LEN;
 	else if (priv->plat->enh_desc || priv->synopsys_id >= DWMAC_CORE_4_00)
 		ndev->max_mtu = JUMBO_LEN;
+	else if (priv->hw->desc == &ndesc_ops)
+		ndev->max_mtu = stmmac_ndesc_max_mtu(priv);
 	else
 		ndev->max_mtu = SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN);
 

---
base-commit: f89726ffabef1b08c52e6163b7ab94b0d5f15503
change-id: 20261121-sun8i-emac-mtu-limit-66a936064965

Best regards,
--  
Arun Iyengar <aiyengar1990@gmail.com>
Technical Details
Message-ID: <20261128-sun8i-emac-mtu-limit-v3-1-1ddcb25eba45@gmail.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373250-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373250-linux-kernel-netdev=dewy.ru
From: devnull+aiyengar1990.gmail.com@kernel.org (Arun Iyengar via B4 Relay)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v3] net: stmmac: Limit the MTU of normal
 descriptors to one RX buffer
Date: Sat, 28 Nov 2026 17:37:41 +0000
Organization: Usenet Network
Message-ID: <20261128-sun8i-emac-mtu-limit-v3-1-1ddcb25eba45@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="997638"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:x4YmktfNRUgZJNIGnRsPikmwPA4= sha256:E8S517NmolAzroCg77fzok7uRCoPWTE2+2AVpEAkwqM=
	sha1:jHqvPG/aXZuuTuHdq8pzH6jGgsg= sha256:HWEAJP+lH/IQ9aRJfm4nbTadw8Ph/6VL2BKG5PXRvNU=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id D0C88125F84; Sat, 28 Nov 2026 20:38:10 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.251
X-Spam-Status: No, score=-3.251 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	FREEMAIL_REPLYTO_END_DIGIT=0.25, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id J-axlpEzBf9p;
	Sat, 28 Nov 2026 20:38:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-373250-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 3199F125F87; Sat, 28 Nov 2026 20:37:58 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 90AC627DE6; Sat, 28 Nov 2026 17:37:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795887475;
	b=lm2LOATOmL4Vp2pE6O4bql+d9WrJNwX3nDWYrptRbqKv/nlhlx2y9+LV4B7ZrBXXnKyG
	 K6FFfZ+j2wDO8ORtBVluRaC46ZwWa5KbqPACXaZFniC/N39/d6C89xB0c7RPtiPjnwSy3
	 CvXY+7n6U84IoWtN7D2M3P4eY4ac+OnBvcvs87dr6QpoOriRgvtvA7R5rcSqZb+EKmYHH
	 tbkZ9D1AuF2jB1F3YYf9nevan/0PIuQ/1JW2220+gFgrnxAjeaf69yD5NwllsaNVxotRC
	 GiJ19wcQn5ohMZtv2D4knJ7my5gf2aMne8GOEK5INijEzfgwzmAOl1kNLVyq8TjT9uA==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795887475;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Date:
	 Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=+hOlJA3EgGU4Lc64wMo3HJzPCDUUGBmFkgvYNVyoEdw=;
	b=nP/Bjv2zWD73G3kX+3/MVu/jcacZutPZqIBJNkYv8xAhRqlUC1ojkSKHIL/IyCC3hrUV
	 yG3Ie8jynMyQRj05b3sLkgsjCGf/4awKQ8SLSmriumpV+SohyzSvFyMIS8xokWP2UGIHd
	 mZn9iwS3Z780BRy/d4WUg1XpKdNhwcXXW8zf6Dpem9BXGD0aGcH2PfWJ4RyAnTVmaLVSt
	 N9gqCpfL2QPrlZ91AnosaS1yAKP8Au+XUwpBFmTUFfZwsyKy4L4OxqQXa5SEcvhkW0XXn
	 mUOwua/G9HRzvq2eg5QwQjcl1yPuXIq4pixDrorMCqIt86t7FDCcsgdVexLb05Tbr5g==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="Z4/zdJEM";
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id E3FE7606A329;
	Sat, 28 Nov 2026 17:37:54 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Z4/zdJEM
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795887474;
	b=OuiFFPMgzfAizt8gkIFFDyM9B3IVCZ8UzdskSvUrOWZwz41FEel43L292/xR9MW2QEsf
	 FA0+EE5YpVot9gJWGCWPHo9lvHuQwfp48kk8HVeSyvj2szV1kG2MCjUb5SIO7MbrJQiCI
	 Ym92jRQdc42GlV6Fur71IeAnHMvTrhUlrkYkf0JsReDZeSo/eUrsnoGNJ16NtVWelzMSh
	 xS25wAWI0tsGx+zvCBuDCOwCYbMnGD7PiWswjL7qIb5J2H+TMtuGbB6ZK8id5kGObHfbW
	 NT5ZhFn3GWJn7nGFzXKbv2TbcOodPBF6UqvVJwun6ckQVhfnUjDIXRTIXPuBvK3AJsA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795887474;
	h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version:
	 Content-Type:Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=+hOlJA3EgGU4Lc64wMo3HJzPCDUUGBmFkgvYNVyoEdw=;
	b=afYuYWINrygMyLQEsP7dt/ZmZWwwVlYaEyWC1gLWmXEqH7rCgKFfk3eFgiFgxKCHsXeX
	 6Ug+iNeCe45yw0Vs6bCdpoy8C13HTkfsfaF65nAR+CQGW8xvmXvizpX+TGWjiyOxALWfH
	 +W2XRE6tVu+8qwUrGkGmhs4nnd9TgiI3DqZoAu2Zlmp9pSM2nURSwr2xNhKkBxjss/exD
	 oGJNvsEi6yQ9ZJ2uJYUKdnXkonmzNN/zZwKnJpfvxw1EgAM2NXMIHrB09QbwDTE8nIHC1
	 43Z86eJHptHdzalVZnMvcDo4N8Xww69EhaiXEPNJh3teTKJnraqU+OHrJ/I+iVGhffA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="Z4/zdJEM";
	arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09159606A31C;
	Sat, 28 Nov 2026 17:37:53 +0000 (UTC)
X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77
X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none;
	t=1795887473;
	b=oiZo74QkAHP7TA499PWXQcWzvHQ4DG9+G8qfSBktlcMNUCB42OpUf2oEs2a9zTBKs0c0
	 9PoVCNo54avMLvHtRUKaN/M3gCRNEZXAKdYrdWjE6cxA0fDx4eJGQ0vqTI2KcG2otwbhO
	 TR5WuacT/j37+PpYSgHCUdEncmb4f420P3UBG9qCwEhn9caQTZ7jo9uv2Oso5KkHvnJ0U
	 Rf9lnAQ/7sVCPWu6kqDnnisWHqXdVBaUgVVI/SCkEvAmIll4kVmurxbXpVkpaGDSWTDpy
	 Gx15jl31tSxPbkob0QL2XvcBeYSizjcNri6uRnWn7q/cmZdEeTK88IEvoyBXOtG+EEg==
X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256;
	c=relaxed/relaxed; t=1795887473;
	h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type:
	 Message-Id:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=+hOlJA3EgGU4Lc64wMo3HJzPCDUUGBmFkgvYNVyoEdw=;
	b=sNVf+PsCLW8L8rVzWkgLIMUkIqpNy60C8zg3FuPqdcxTbIRpB/Jc1KaGngJzeYNe4wO7
	 62MLs7uBWOztiV3ARvTF8hA7+/oXMfWbUisboZW5JmvSVxhhPEWV+kTDcbjS0mtgNA6rd
	 YZ2fIe/+J7QNGT5bgmPvHVU6qEMsfGLJHKQBl7AkvUEH69L6efRmryOA67hHXU0oCvQL3
	 qLmjGrHcA4X27fUMsrZUHuDBf5b02ZoaoETegSGgGGt48lSJy543uYBPQ6cR7czj+8yq9
	 ZI8EreOjt76C6Ojc9WoONvVR5K7UyZnMnR8qWC1C0FrkkUjPT4mLTMdTwol1nDImz4g==
X-ARC-Authentication-Results: i=1; smtp.kernel.org; 
	arc=none smtp.remote-ip=100.80.115.77
X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.kernel.org (Postfix) with ESMTPS id 8C26E1F00893;
	Sat, 28 Nov 2026 17:37:41 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795887473;
	bh=+hOlJA3EgGU4Lc64wMo3HJzPCDUUGBmFkgvYNVyoEdw=;
	h=From:Date:Subject:To:Cc:Reply-To;
	b=Z4/zdJEM5T1YcDwY9TxOjVctVZZK5vlen/OcL9nxb38gkDmQpbmvglweo6jy+R0km
	 C3vTk0+dRKCoYz6Wj/LSNH4HV05i4d+cPeiSBH7XY8l2vyyhWMMquQlZDIaHhXiZfN
	 xAJzWY6/jZ1xkue+hRuzKZnbIIL27MaPLrJSKfThPv7tCfDIpGxAas83zQR6wJr481
	 oJHVGfEZfeWkQAKkIRrhGP3GcENFFacp4bBTLhG4QtiI2Hkny3qSDXNzPhG1+tRnAg
	 qYqRHG43ZUt6wZi4WS9snOBNK9aYcRpVxMFZpirVZOnZNpReHejL1ZorpXmiOgTd85
	 kFqyrzCo4Fpag==
X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1])
	by lkml.kernel.org (Postfix) with ESMTP id 1ECE44E16F;
	Sat, 28 Nov 2026 17:37:41 +0000 (UTC)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-B4-Tracking: v=1; b=H4sIAAAAAAAC/32OwQ6CMBBEf8X07Bq6QFM8+R/GA5QF1tBiaCEYw
 r8LeOGix8nMvJlZeOqZvLieZtHTyJ47t4r4fBKmyV1NwOWqBUaopEQJfnCagWxuwIYBWrYcQKk
 8i1WkkkylYq2+eqp42rF34SiAoymIx9fxQ/EkEzbqlm3Yh65/7w9GuTf+j40SJCAmGeoEy1jqW
 21zbi+ms/vEiEcI/oAgRGCSSEtKCx2b6ghZluUDEkR/fhkBAAA=
X-Change-ID: 20261121-sun8i-emac-mtu-limit-66a936064965
X-Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, 
 linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, 
 Nicolai Buchwitz <nb@tipi-net.de>, 
 Russell King <rmk+kernel@armlinux.org.uk>, 
 Arun Iyengar <aiyengar1990@gmail.com>
X-Mailer: b4 0.15.2
X-Developer-Signature: v=1; a=ed25519-sha256; t=1795887460; l=3795;
 i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id;
 bh=EOAQQASp3KKXbGGsfxH5IrLe6j8bWGL7hxffH/bUSt0=;
 b=xaxXmrqVQxWldqAtHuVkx+tK5cCKsDoSdhtu+lm71t4ojLkWLQCrwYGhH1I8E2z5j0g1gNsPN
 4fV63T1tSLeCmYelFJ0+WH/nyxYEC7b1CuMagCvrbi6afXoOKvSESCp
X-Developer-Key: i=aiyengar1990@gmail.com; a=ed25519;
 pk=zXpRgUTrhaFe6jLyPqbBy3ccfkj04w0g2690Wv3mg+0=
X-Endpoint-Received: by B4 Relay for aiyengar1990@gmail.com/20261110 with
 auth_id=1480
X-Original-From: Arun Iyengar <aiyengar1990@gmail.com>
X-Reply-To: aiyengar1990@gmail.com