🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #13665

[PATCH net-next 2/2] net: stmmac: dwmac-sun8i: Enable jumbo frames up to MTU 2018

#13665
From: Arun Iyengar via B4 Relay
Date: Tue, 10 Nov 2026 06:03
112 lines
15214 bytes
From: Arun Iyengar <aiyengar1990@gmail.com>

The sun8i EMAC advertises a maximum MTU of 3712, but no frame larger
than the standard 1518 bytes is actually received: on an H616 board
(Orange Pi Zero2, RTL8211F over RGMII) every ping above 1472 bytes with
DF set is lost, and the rx_length counter goes up for each one.

There are two independent limits:

1. EMAC_RX_CTL0 bit 29 (JUMBO_FRM_EN) is never set, so the receiver
   rejects frames longer than 1518 (1522 with a VLAN tag) bytes. The
   Allwinner BSP driver (sunxi-gmac) sets this bit unconditionally at
   init. Set it in core_init as well; core_init runs after every DMA
   soft reset, including the one done by an MTU change.

2. The EMAC has no Synopsys HW feature register, so stmmac uses normal
   descriptors in chain mode and, without enh_desc, sets max_mtu to
   SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN), which is 3712 with 4K
   pages. That value is not a hardware limit. The descriptor buffer
   size field is 11 bits wide (the same in the BSP and the QEMU model),
   so ndesc_init_rx_desc() caps each RX buffer at 2047 bytes, and
   ndesc_get_rx_status() discards any frame that needs a second
   descriptor. On TX, stmmac_xmit() only splits jumbo frames for
   enh_desc, and norm_set_tx_desc_len_on_chain() masks the length to
   11 bits, so a linear frame longer than 2047 bytes would be silently
   truncated.

Moreover, the RX DMA only fills a multiple of 4 bytes of a buffer: on
the H616, with 2047 programmed, a 2044 byte frame (FCS included) is
received in one descriptor and a 2045 byte frame already spills into a
second one. The usable size is therefore 2044 bytes, the same value as
DESC_BUF_MAX in the original sun8i-emac submission and in the U-Boot
driver.

Limit max_mtu so that a frame with two VLAN tags and the FCS fits in
2044 bytes (MTU 2018). A device tree max-frame-size can still lower it.
Longer frames from the wire span two descriptors and are dropped as a
whole by stmmac_rx(), which drains the descriptors of a split frame
since commit 834ec9530832 ("net: stmmac: drop split frames on AF_XDP
zero-copy RX").

Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 24 +++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 0c82662fbe6e..a18d3daf6a3f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -6,6 +6,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/if_vlan.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
 #include <linux/mdio-mux.h>
@@ -219,12 +220,25 @@ static const struct emac_variant emac_variant_h616_emac1 = {
 
 /* Used in RX_CTL0 */
 #define EMAC_RX_RECEIVER_EN             BIT(31)
+#define EMAC_RX_JUMBO_FRM_EN		BIT(29)
 #define EMAC_RX_DO_CRC BIT(27)
 #define EMAC_RX_FLOW_CTL_EN             BIT(16)
 
 /* Used in TX_CTL0 */
 #define EMAC_TX_TRANSMITTER_EN  BIT(31)
 
+/* The buffer size field of the EMAC DMA descriptors is 11 bits wide, and
+ * the RX DMA only fills a multiple of 4 bytes of a buffer: with 2047
+ * programmed, frames longer than 2044 bytes spill into a second
+ * descriptor. The stmmac normal descriptor code used for this EMAC only
+ * handles frames that fit in a single RX descriptor and a single TX
+ * descriptor buffer. Bound the MTU so that a frame, including two VLAN
+ * tags and the FCS, always fits in 2044 bytes.
+ */
+#define EMAC_MAX_FRAME_LEN	2044
+#define EMAC_MAX_MTU		(EMAC_MAX_FRAME_LEN - ETH_HLEN - \
+				 2 * VLAN_HLEN - ETH_FCS_LEN)
+
 /* Used in EMAC_TX_FLOW_CTL */
 #define EMAC_TX_FLOW_CTL_EN             BIT(0)
 
@@ -645,6 +659,15 @@ static void sun8i_dwmac_core_init(struct mac_device_info *hw,
 
 	v = (8 << EMAC_BURSTLEN_SHIFT); /* burst len */
 	writel(v, ioaddr + EMAC_BASIC_CTL1);
+
+	/* Without JUMBO_FRM_EN the receiver flags every frame longer than
+	 * 1518 bytes (1522 with a VLAN tag) as a length error, so any MTU
+	 * above 1500 is unusable. Frames are still bounded by the RX
+	 * descriptor buffer size, see EMAC_MAX_MTU.
+	 */
+	v = readl(ioaddr + EMAC_RX_CTL0);
+	v |= EMAC_RX_JUMBO_FRM_EN;
+	writel(v, ioaddr + EMAC_RX_CTL0);
 }
 
 static void sun8i_dwmac_set_mac(void __iomem *ioaddr, bool enable)
@@ -1209,6 +1232,7 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
 	plat_dat->mac_setup = sun8i_dwmac_setup;
 	plat_dat->tx_fifo_size = 4096;
 	plat_dat->rx_fifo_size = 16384;
+	plat_dat->maxmtu = min(plat_dat->maxmtu, EMAC_MAX_MTU);
 
 	ret = sun8i_dwmac_set_syscon(&pdev->dev, plat_dat);
 	if (ret)

-- 
2.55.0
Technical Details
Message-ID: <20261110-sun8i-emac-jumbo-v1-2-84bf00e9ffa3@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359899-linux-kernel-netdev=dewy.ru
References: <20261110-sun8i-emac-jumbo-v1-0-84bf00e9ffa3@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359899-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 2/2] net: stmmac: dwmac-sun8i: Enable jumbo frames
 up to MTU 2018
Date: Tue, 10 Nov 2026 06:03:36 +0000
Organization: Usenet Network
Message-ID: <20261110-sun8i-emac-jumbo-v1-2-84bf00e9ffa3@gmail.com>
References: <20261110-sun8i-emac-jumbo-v1-0-84bf00e9ffa3@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="534845"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:t4rbTtTAaXTHXm8QCt8KFxPXpUw= sha256:mMS9mZ6YQypkw5Obb0ezUzJT3hoUxKWEfWTVG5Kqy5Q=
	sha1:/7W5lihLBdYeYP5+7BvuLLcc2SY= sha256:P56rZagevpWN0ZrfmEQoU0IzjreivnoiVIltR4nGYxk=
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 7C070113A49; Tue, 10 Nov 2026 09:07:53 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.051
X-Spam-Status: No, score=-2.051 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, 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 mJLY3SqvQEZa;
	Tue, 10 Nov 2026 09:07:50 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-359899-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 52CE7113A35; Tue, 10 Nov 2026 09:07:42 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 3F674C4F60; Tue, 10 Nov 2026 06:04:04 +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=1794290627;
	b=eTs1MntItFq+x5BS1pIlV7QjTIS4hL3aehSoCTkSv4WPyoG+XWBIEE3HHTBAWZ2duig7
	 7ywFsX1MvBcR4qm2pbrggpDbW55jddf2YgJCkrjLka7d/9kFaY7QVNBj/ZQ/6qYDpoewO
	 q47/4sakz8MUwKvtw/9QgaLLj4MK0a2ejBs78iYirIDgPKpI+QQ2ECrq0hkNo0utMBvGx
	 9Y0m6LIbo2aHod7u1MliKOKb/CeZC9DEjGfuQv6G79g+1rh5M7K7kiiaochiscLf30Q9i
	 XqT4VQpm1mnbBEeHU9fpF9K/D+TwdvsRp6wVApwArjOBW72qKSnHSr8+ScwB+rYsamQ==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794290627;
	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:References:In-Reply-To:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=7j4ZkRwyXw7fmRhYE9lsi9fnMe99t0IsGQ1HSh6+zso=;
	b=MwQimm8CWgcAX4dx0oM+6sjBpokzug5tiXyzyxlPrhzJDDae4Zl1c92J78psy0UHeoLQ
	 mIKVLK+FrJ/7RCjD/1x7h6dORKf4lNq/DsCND5TYDAI1G76Jw9mrZpb/s5qSEijd5kZLS
	 UL1xK4FVLGUMDvVnovEbfR7LlBJtLRLNXM9p7xXV354Yt4Jl9acfGb0HV82ogtyQnl2jP
	 BHP8rdv5Io2nIPRZi8hEX+VZwh8xaYZxE3SqG0OcUGn2kL/BCqNMs5HhI2SgVUdhFDWV9
	 6DxcNf6VnVLRFeeVP82L7VYKSGNZCQpDXx09Y4xHrwMhTUOclztkTr+BXY3uvbqXfdQ==
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=iqkhoaJi;
	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 CCDB1606A331;
	Tue, 10 Nov 2026 06:03:47 +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=iqkhoaJi
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=1794290617;
	b=wiEezKCFlQ7YnJ12Ktz6zWg7lCx09wWLiw8OcaSMv/qKW7R2oE//kLsP94sSBqX7LxK1
	 ZSLLpVIY3h8NMj4zI5ZfiXlUWyTqYDoXCaLm6DK86aBgQEpXWd6NvpMQnBD4MrRfyqrtF
	 Ql3pYS4vBd0s9PjY5HaEWUQS51NTk4wowBxoCNZMLy6za+SPl/9LMEm3tNvy5zNubnXBs
	 J2LvjK0FMGlq6RDf9zh/ipnSdEieAz22ZFzMhp/yaM/4wXXrxFtK7cz4KCxoeJBRcu3Hj
	 xitqXPu0R3eI2oNO/2n2a5cqJ9mISrCgMwX2kmF7J8ULl8rUCSrDmQ7oLg/49d2qPJA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794290617;
	h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version:
	 Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=7j4ZkRwyXw7fmRhYE9lsi9fnMe99t0IsGQ1HSh6+zso=;
	b=K9F79ee3cAcCu4PeOX1wQ23cF6sbmDFoxjeI5O8OggWAhH09EAz6wz2UT9m6byANBTjL
	 LKMo3Gyu5uJ2ywN+HntmUD/rHlXduWymNQlMyzjIotJkkaLffHS9J6gy3EVie73D5Bxtn
	 wQezm8J0O6+7ZlzUpk0da7hTp4jiBQMl68xKuiAVMF0ifaTOtIZEkJzeFmAK9oJXefRty
	 5yWzWPWC9QGj87mcZe1VQcOJUG5OodgYqFnTVJ1iKxxIgm08zQD7RANylUaCJjERcsZVE
	 KqMUlL13ZpkQZzZhRCPRAn/gWsBu96Ot7378zOdQVhHM+mxX7QjOySRMcpXmGyLWGmw==
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=iqkhoaJi;
	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 9E6C3606A330;
	Tue, 10 Nov 2026 06:03:36 +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=1794290616;
	b=QggrAHDbBrnUc+MyotqVhpy13EUQt8T+HR30YVvgnF2cdZvdKcaAsvoeom7oNTzSPgg7
	 rLU3u+ronNR35xPEJCOJ7uE2lP6bziGtSLYXnyF9QTzxYnwQ6Fb7t+oy7k/60/cwD9LDi
	 Uj9FFUAeZ4vzgSNmTSuPWFUZiSxfbpnHSULilj99YTBhR5gxwQN6hWXXXilnxkXzPvZ7n
	 geUh1krCrBoZdblnWtGJGDV6qDzEG2ydFkkFN7Jq788lRNapRA5kjWiznm20s0Wm6lfHe
	 5vLrgK5n1so+jfS0DyuKXvryMsWPkglezNgm5AHrkdXNVjpqn8kqxRDM44GkEg6HEYw==
X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256;
	c=relaxed/relaxed; t=1794290616;
	h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type:
	 Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=7j4ZkRwyXw7fmRhYE9lsi9fnMe99t0IsGQ1HSh6+zso=;
	b=ovRGRoGJAzLlTGXqeWoU72IwtTeDVxabr+WLu2WIr1fZlOjspv6HhLwZOLrL/rA968/J
	 owlN9JJTAt62hWK9NoJYgmghV5+4XSEk+lLgL+njd+cuD338lnjD7YKsUEaJTPzg5NZVy
	 onQPi3atPXPIiT1DCP5WeCT6KcQs4XnxS+22ABBhpbsh/hVn1z9qJAeB/b8zG1JBCcNRY
	 qI5wqqFVcjlz2fGZ2IvkxQg0DtYdj5XYrtbT5YweMUbvOE+wkI9Kwc64zzKRXqNG7+s/4
	 D7iSn/uSsiCPUtl/B04DIo5LuyDbB92ik9DREmnTo7rgM8QKToBKRxxgJ1LddB0ViQg==
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 9AAA31F008A2;
	Tue, 10 Nov 2026 06:03:35 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794290616;
	bh=7j4ZkRwyXw7fmRhYE9lsi9fnMe99t0IsGQ1HSh6+zso=;
	h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To;
	b=iqkhoaJixNaEZGwlP7iaOv6TR8+TrD4wN10VDtod2gSKgSyRPSmfR8Ac+x+5OqgHb
	 tRI/1Hpe05gCqnPIsX+F0q66az29PkEcq7I9uAcZCpIZDF99p/gbGo+DYswGybO0Yr
	 VIrZvriqzg6RSO3qxRbXmIVtDV0B7r6S+AgczqBOEjZjcAl/Fg2or3BNQwaWJd6lkf
	 nXG9hAf9L094Ze0QG4XmWRgrow+OzDOr9tdl97iinfTSuyZ/UrJ+JCUfgoixwTUDRo
	 aonlhhmWxLhztR1ZS3kbHy2ZaFWs1GAFZ3SJ6pgkBbnb5VBi3WJhGgBBsAVi2av2L4
	 5KgmhjIK13WRQ==
X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1])
	by lkml.kernel.org (Postfix) with ESMTP id 2C8A0488D7;
	Tue, 10 Nov 2026 06:03:35 +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-In-Reply-To: <20261110-sun8i-emac-jumbo-v1-0-84bf00e9ffa3@gmail.com>
X-Cc: netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, 
 linux-sunxi@lists.linux.dev, linux-stm32@st-md-mailman.stormreply.com, 
 linux-kernel@vger.kernel.org
X-Mailer: b4 0.15.2
X-Developer-Signature: v=1; a=ed25519-sha256; t=1794290614; l=4734;
 i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id;
 bh=ZPiyfCZmfSnwUUZ2KWrlwC/8CYyWh0WpVDKIRZLdbyA=;
 b=rKIpUVWHTnbdoyIqofyDn2uTAGdmjCHH77Y6R/mjiVOYw8kDcJLjl3SUGBGfdQBu84DirQ8YF
 B2bwr757bDBBc8ygm8GGZTULgHil+lI7aryjIKAjQ5wGak7UDLbjNPR
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