| Message ID | 20261112-sun8i-emac-jumbo-v2-2-aca0cf23cf17@gmail.com (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-27553-sunxi=pue.re@lists.linux.dev> X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id D15861C09E4 for <noreply@patchwork.local>; Thu, 12 Nov 2026 10:32:20 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=kernel.org; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-27553-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-27553-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 4511E143AB9 for <noreply@patchwork.local>; Thu, 12 Nov 2026 08:46:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794472909; b=eqkcop74Y2V40G6UqPa56xl0+3nPiJtKHn/zUXVInlbNY8zcY5eeFs2/EYQq7BFkO1lB 0Kkfrr2cn8NVa8BR0RWpJZ/ImIxjxTpsEBS0FwDWt2XPHfDAU+GVFs8wD/9q1EGW7HXjS gYYj+kSLIDHCbOYwZzxE1q+wasipLUCEeAQhC6eKyD5aM7OI7pyj6A7h5WF1z0wnoUOBy liwLTQjOWEVa3rQ41TWXVUkqUsuBe/IwAnVlNN+WMKT6eUl8VzLH+RdLeEGpZ6/VuZB6b RiTrJdzi7wsTvhZE5/LvRnNcs06dtfw367gAdUAuFPI8Xh6tdS36TtNiBXc+BAtfOMA== ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794472909; 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=1rOqR7TkE/35LEFize/2+0Ai0tBPvg8hN7Kb/CD2R6nqCV7qjEmVQaBamg/tBzkqMWSq aajsRNKrtbhxbPo9CP34+1KpAsa7TnYpgIKctF1sxFRVrIHQf2mA48ik4z8CWA2OxcOVL dymyyOjZyj2l7D+ThiTILiL0H5GI96KgjvIy4YJt8tAsSSosxyvtao6MoneZmbEDWtMDH 3+tTTpt3bWPcO8p73pmnBu5QWKUWxL1pEiRMYQx/yUSeGbc1dKBjvqVQe1ReFR2tl7rQi DQQvgDUFRpknhnS8ttCgRVLaUx3cdKmcmlKNxpHnjsZjWsZcdQzr+rsppLL2KBTdeNA== 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=HNt4lR5O; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1DFD3606C832; Thu, 12 Nov 2026 08:41:49 +0000 (UTC) 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=HNt4lR5O X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794472909; b=kBHdQNDWxtdAtIeJRKw69bXPSHtgLXXTGO140cRluS1aRdcfiIdnsX+BOT3xOeJAe1bQ 97R1zlaMdtgQrL2RvNOMsEr6QMINn4s02Gy+qX/IpNe8RWJgdTgjn/x+wR2ORzCx/rpk0 joscYNahyBRGABmviZCro129q+p+AWbqKNIMdDqidigUhqdpr9l4DNY7gdBZCSwuxWyX7 T0sXwpCi1so9caE4ryqWnBXwGFhawMJVmLTWTMupZu666EfDEAynTHb0OZgkADgzq9bk4 nPbp0VuPEAM3K0URZrLVtKJSi7h2ciXYfWBzSuLVQxJcxLc8OIEywIge3AU6YZbV5kA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794472909; 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=kzZkjWF97VpPSvG/58AW3a9AR2NfhcwRkgcMiERuUSD6agtw6suyjUK2WHnn1zegFS/4 y/A5JezciBCCji6M3wZMt2bXZP6CUzQ5Yqs8dPHjGFR3TmCuaTQS6D3m6/zYshuoESpwq 2t22Z4dyzDFNkYsoyGf02d/qonNfBc2k8CuBZJP3sy6E/8RhkCVZj8BD3Dw73g5rrJjkq Tk21Wc87dniklpytQBe5fUwN3l/S2z+aJumkH4upaK2nAnWB2YarSJNNC//RnAUHLt4jl SjIQTtfV+IzD1nJw7dimg3GBOJo1ZgBP9Hm/xsHaTzBV7jmfQdinKAO32m6yywiwIBw== 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=HNt4lR5O; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 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 EFB52606C839; Thu, 12 Nov 2026 08:41:48 +0000 (UTC) Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1794472908; b=Kfh5sG2hjb3rydiXRatVMywSRDQocLG9KlbGYohSdZIMQIMW74GBGpjWN39KcXG8Xd0Q u58LDdXOEVrB6ArL9e/JfS66imXMUVxrfTxVcNH9XdhA7vmH9EV1UCbToIUXEyEGU2y/W 9q+T+1a7kFSt1NllEigWW7ouOqN7Fmvjdl1ARzArTFPUysTPPEBoH/YODy3vfwOnWCxoN pi9cK08sWjM288tPE0LnIc6+iTW3s3eq7HD/fxICdeTJhD1EBwZYR2fJPkXpMA2d4Z27Y 1QF/Gio6SnNJW+ugwlcz1SMpyQxzjBZk3zMeMz3BQb21PUvFeZXfDcK7qzo/+5vim3g== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1794472908; 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=CveUSkcr2SeZx1160NxomlqsQWTCF+O/bFPNRcsDyMZK45SJ2NV2wWOSRHfeSBkkSt8d bkwTIh0N4LbC5gb8ff9SFYFGur7QTu2ES060SwImG34qV1RE/yhZPyjYyaIy3lZc7tGcf IzifoHHBvPtuhe8XX5XIkEPpk/yUfZbGJo3C0roeZZdMN7LEntlTDPpTLdsN4++gExRVN DMwXEuSDhY7bheqraPfE3IzfxZzmYialdbJRf7hM7/i2YVFSSGygbwqe3W2jGILi8T7YV WNLPFjriHyHaEBYKBnKfp8mf9ReMb8TB9jrkwE1JuEAmlveaSKn/0jAnfwzVbHhSfPw== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 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 B1AD51F00A0B; Thu, 12 Nov 2026 08:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794472908; bh=7j4ZkRwyXw7fmRhYE9lsi9fnMe99t0IsGQ1HSh6+zso=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=HNt4lR5OCdkNXd2V606MySq0Y6wAGv95tQGRUV80IVqb0slK+mJoDh0BsNjBCYdKt 5nI/f870NJK1QQgCt9TYKtaR1VjtTBWcUyYPGdySFrvhG/Jpbs9dd/Pll00W8HSXUF pUixb33jzrB+hz3TWlnNbADABXPs7KnMIZcBqxCHW1mD+Jd1VB2+ebbYrN+QViqc2w HkGFSExDi8usTB7SUWQXhYV8f9eAxuWaxT51tGfnZpkJriU8gUvOuHZD7Iil2WbMzR CKZVp1cjbWcRVhfC5pcJlq92LKRrTZeFPqX98ToBNuEeaBIraG6lmwL+V4O9oJybjV 9gQWMCVsaOdzw== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 3DBD9493D5; Thu, 12 Nov 2026 08:41:47 +0000 (UTC) From: Arun Iyengar via B4 Relay <devnull+aiyengar1990.gmail.com@kernel.org> Date: Thu, 12 Nov 2026 08:41:48 +0000 Subject: [PATCH net-next v2 2/2] net: stmmac: dwmac-sun8i: Enable jumbo frames up to MTU 2018 X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: <linux-sunxi.lists.linux.dev> List-Post: <mailto:linux-sunxi@lists.linux.dev> List-Help: <mailto:linux-sunxi+help@lists.linux.dev> List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev> List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev> List-Owner: <mailto:linux-sunxi+owner@lists.linux.dev> Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Message-Id: <20261112-sun8i-emac-jumbo-v2-2-aca0cf23cf17@gmail.com> References: <20261112-sun8i-emac-jumbo-v2-0-aca0cf23cf17@gmail.com> In-Reply-To: <20261112-sun8i-emac-jumbo-v2-0-aca0cf23cf17@gmail.com> To: Maxime Chevallier <maxime.chevallier@bootlin.com>, Andrew Lunn <andrew+netdev@lunn.ch>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Chen-Yu Tsai <wens@kernel.org>, Jernej Skrabec <jernej.skrabec@gmail.com>, Samuel Holland <samuel@sholland.org>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Alexandre Torgue <alexandre.torgue@foss.st.com> 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, Corentin Labbe <clabbe.montjoie@gmail.com>, Arun Iyengar <aiyengar1990@gmail.com> X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1794472906; l=4734; i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id; bh=ZPiyfCZmfSnwUUZ2KWrlwC/8CYyWh0WpVDKIRZLdbyA=; b=0IUWEE0Wk0sl3sXsxfCbIwPqGk+0GPYaoUwZ0ZQ9e3Gu9EoHTdRH04zVOqGDJWJA31Sb3Mjw7 2BID/ohoa4nCptmWbC2IZbGeDXOTyFq/y57Y/myP9y7JLcMJEQKQiFv 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> Reply-To: aiyengar1990@gmail.com Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-2.19 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; MAILLIST(-0.18)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; HAS_REPLYTO(0.00)[aiyengar1990@gmail.com]; TAGGED_RCPT(0.00)[netdev]; FROM_HAS_DN(0.00)[]; FREEMAIL_REPLYTO(0.00)[gmail.com]; REPLYTO_DOM_NEQ_FROM_DOM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:helo,sea.lore.kernel.org:rdns]; RCPT_COUNT_TWELVE(0.00)[18]; FORGED_SENDER_MAILLIST(0.00)[]; FREEMAIL_CC(0.00)[vger.kernel.org,lists.infradead.org,lists.linux.dev,st-md-mailman.stormreply.com,gmail.com]; R_DKIM_ALLOW(0.00)[kernel.org:s=k20260515]; RCVD_COUNT_FIVE(0.00)[6]; ARC_ALLOW(0.00)[kernel.org:s=arc20260519:i=3]; DKIM_TRACE(0.00)[kernel.org:+]; DMARC_POLICY_ALLOW(0.00)[kernel.org,quarantine]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[100.103.45.18:received,100.77.114.92:received,100.80.115.77:received]; TO_DN_SOME(0.00)[]; FROM_NEQ_ENVFROM(0.00)[devnull@kernel.org,linux-sunxi@lists.linux.dev]; FREEMAIL_TO(0.00)[bootlin.com,lunn.ch,davemloft.net,kernel.org,redhat.com,gmail.com,sholland.org,foss.st.com]; MIME_TRACE(0.00)[0:+]; TAGGED_FROM(0.00)[bounces-27553-noreply=patchwork.local,aiyengar1990.gmail.com]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[172.234.253.10:from] X-Rspamd-Queue-Id: D15861C09E4 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX |
| Series |
net: stmmac: dwmac-sun8i: Jumbo frames and an RX_TH fix
|
|
Commit Message
Arun Iyengar via B4 Relay
Nov. 12, 2026, 8:41 a.m. UTC
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(+)
Comments
Hi Arun On 12.11.2026 09:41, Arun Iyengar via B4 Relay wrote: > From: Arun Iyengar <aiyengar1990@gmail.com> > [...] > 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. max-frame-size is only parsed for the snps,dwmac compatibles, not for sun8i. > [...] Thanks, Nicolai
On Thu, Nov 12, 2026 at 5:41 PM Arun Iyengar via B4 Relay <devnull+aiyengar1990.gmail.com@kernel.org> wrote: > > 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 The hardware only supports normal descriptors, period. > 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. If that's true, that sounds like a serious bug. But that's just the limit of each descriptor. The stmmac driver already has code for both chained and ring mode descriptors to split one fragment across multiple descriptors for TX. I think what should be done is just remove the "if (enh_desc)" check before is_jumbo = priv->hw->mode->is_jumbo_frm(skb->len, enh_desc); Now if the jumbo frame code is buggy (because no one ever ran into for who knows how long), then that should be fixed. > 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. And it also has code to deal with a frame spanning multiple descriptors or buffers in the RX path. So if you say 2045 bytes is spilling over to the next buffer, then the size limit for each descriptor's buffer should be 2044. I think this should be done somewhere in stmmac_setup_dma_desc() by aligning bfsize or ultimately dma_conf->dma_buf_sz to a multiple of 4. The limiting to 2047 bytes in ndesc_init_rx_desc() also seems suspect, as the rest of the driver is not aware of this limiting, and would likely cause misalignment or dropped bytes when reassembling a frame from multiple descriptors. > 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. So what you are doing is just papering over what is broken underneath. Fix the actual problem so we can have MTU up to 9 KB. > 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"). I doubt that's the case. This commit said it only covers AF_XDP, which is not your normal network transfers. ChenYu > 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 > >
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] net: stmmac: dwmac-sun8i: DT max-frame-size ignored in sun8i_dwmac_probe() -- commit 51742ecb57f35bd210c0c45ef051593dd802ce68 Author: Arun Iyengar <aiyengar1990@gmail.com> net: stmmac: dwmac-sun8i: Enable jumbo frames up to MTU 2018 This commit sets EMAC_RX_JUMBO_FRM_EN in sun8i_dwmac_core_init() and bounds plat_dat->maxmtu to 2018 bytes so frames fit within a single 2044-byte DMA descriptor buffer. > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c > index 0c82662fbe6ea..a18d3daf6a3ff 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c [ ... ] > @@ -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); [Severity: Medium] Does min(plat_dat->maxmtu, EMAC_MAX_MTU) honor a device tree max-frame-size property as intended? devm_stmmac_probe_config_dt() initializes plat_dat->maxmtu to JUMBO_LEN (9000), and stmmac_probe_config_dt() only reads max-frame-size for specific compatibles: drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:stmmac_probe_config_dt() { ... if (of_device_is_compatible(np, "st,spear600-gmac") || of_device_is_compatible(np, "snps,dwmac-3.50a") || of_device_is_compatible(np, "snps,dwmac-3.70a") || of_device_is_compatible(np, "snps,dwmac-3.72a") || of_device_is_compatible(np, "snps,dwmac")) { ... of_property_read_u32(np, "max-frame-size", &plat->maxmtu); ... } Because dwmac-sun8i device tree nodes only use allwinner,sun8i-* and allwinner,sun50i-* compatibles, plat_dat->maxmtu is always JUMBO_LEN here and a max-frame-size property in the device tree will never lower it below EMAC_MAX_MTU.
> So what you are doing is just papering over what is broken underneath. > Fix the actual problem so we can have MTU up to 9 KB. Agreed. I'm fixing the multi-descriptor jumbo paths in stmmac itself, aiming at the 16 KB the hardware allows. It's nearing completion; v3 follows once it passes on hardware, with 1/2 included.
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The commit message says "A device tree max-frame-size can
still lower it", but for this driver that is false.
- [Low] The max_mtu clamp fixes a real, user-visible bug, but the commit
is framed as a feature ("Enable jumbo frames") and has no Fixes: tag.
--
net: stmmac: dwmac-sun8i: Enable jumbo frames up to MTU 2018
This patch sets the JUMBO_FRM_EN bit in EMAC_RX_CTL0 from
sun8i_dwmac_core_init(), so the sun8i EMAC accepts frames longer than 1518
bytes. It also clamps plat_dat->maxmtu to 2018 in sun8i_dwmac_probe(). With
that limit, a frame with two VLAN tags and the FCS fits in a single 2044
byte descriptor buffer.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> index 0c82662fbe6ea..a18d3daf6a3ff 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
[ ... ]
> @@ -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);
> }
[Severity: Low]
JUMBO_FRM_EN is now set unconditionally. A peer can therefore send oversized
frames that reach the RX DMA even at the default MTU of 1500, and those
frames span several descriptors.
Dropping them correctly depends on commit 834ec9530832 ("net: stmmac: drop
split frames on AF_XDP zero-copy RX"). That commit made
ndesc_get_rx_status() return discard_frame | rx_not_ls for non-last
descriptors, and made stmmac_rx() test status & discard_frame and drain the
split frame.
On a tree without that commit, wouldn't stmmac_rx() treat the last fragment
of such a frame as a new packet? The commit message cites 834ec9530832 only
as background. Could it be listed as a prerequisite for backporters?
Related to this, the max_mtu clamp in sun8i_dwmac_probe() also fixes an
existing problem, but the patch has no Fixes: tag. Before this patch, the
driver advertised a max_mtu of 3712 and was in this state:
- stmmac_hw_init() forces chain mode for STMMAC_FLAG_HAS_SUN8I.
- stmmac_xmit() calls stmmac_is_jumbo_frm() only for enh_desc.
- norm_set_tx_desc_len_on_chain() masks the length to 11 bits:
p->des1 |= cpu_to_le32(len & TDES1_BUFFER1_SIZE_MASK);
So with an MTU between 2048 and 3712, a linear TX frame longer than 2047
bytes was silently truncated. Would a Fixes: tag make sense for that part?
[ ... ]
> @@ -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);
[Severity: Medium]
The commit message says:
A device tree max-frame-size can still lower it.
Is that true for this driver? stmmac_probe_config_dt() reads the property
only for a few compatibles:
stmmac_platform.c:stmmac_probe_config_dt() {
...
if (of_device_is_compatible(np, "st,spear600-gmac") ||
of_device_is_compatible(np, "snps,dwmac-3.50a") ||
of_device_is_compatible(np, "snps,dwmac-3.70a") ||
of_device_is_compatible(np, "snps,dwmac-3.72a") ||
of_device_is_compatible(np, "snps,dwmac")) {
...
of_property_read_u32(np, "max-frame-size", &plat->maxmtu);
...
}
None of the compatibles in sun8i_dwmac_match[] can carry an snps,dwmac
fallback under allwinner,sun8i-a83t-emac.yaml. So plat_dat->maxmtu always
holds the JUMBO_LEN default (9000) when this min() runs, and the line always
sets it to 2018.
The binding does accept max-frame-size on these nodes, because it includes
snps,dwmac.yaml through allOf, and that pulls in ethernet-controller.yaml.
If a board sets max-frame-size to cap the MTU for a PHY or switch limit, the
driver ignores it without a warning.
Should the commit message be corrected, or should the driver parse
max-frame-size itself?
If the property is ever parsed for these nodes, the min() has a second
problem. plat->maxmtu is an int filled by of_property_read_u32(). A value
below min_mtu, or one that is negative as an int, passes straight through
min(). stmmac_dvr_probe() then only warns:
if (priv->plat->maxmtu < ndev->min_mtu)
dev_warn(priv->device,
"%s: warning: maxmtu having invalid value (%d)\n",
__func__, priv->plat->maxmtu);
else if (priv->plat->maxmtu < ndev->max_mtu)
ndev->max_mtu = priv->plat->maxmtu;
In that case ndev->max_mtu stays at SKB_MAX_HEAD(NET_SKB_PAD + NET_IP_ALIGN).
Wouldn't that bring back the TX truncation and the RX split-frame drops that
this patch is meant to prevent?
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)