Article View: linux.kernel.netdev
Article #27013Re: [PATCH net] net: stmmac: Drop TX buffers too long for normal descriptors
From: Chen-Yu Tsai
Date: Fri, 04 Dec 2026 15:50
Date: Fri, 04 Dec 2026 15:50
118 lines
13388 bytes
13388 bytes
Hi,
On Fri, Dec 4, 2026 at 9:28 PM Maxime Chevallier
<maxime.chevallier@bootlin.com> wrote:
>
> Hi,
>
> On 11/28/26 20:00, Arun Iyengar via B4 Relay wrote:
> > From: Arun Iyengar <aiyengar1990@gmail.com>
> >
> > Sashiko found in [1] that stmmac_xmit() does not check buffer sizes for
> > normal descriptors, whose size field has 11 bits. As Chen-Yu Tsai noted
> > in [2], only enhanced descriptors take the jumbo path that splits
> > buffers, since commit 29896a674c8e ("stmmac: fix chained mode"). A
> > longer buffer gets its size cut in chain mode, and in ring mode its
> > rest goes to buffer 2 at DES3, which is 0.
> >
> > Such skbs come from MTUs above one buffer, and from act_mirred and BPF
> > redirect, which do not check the MTU. Drop them and count them in
> > tx_dropped.
> >
> > Link: https://lore.kernel.org/r/179542841718.3135.3290374626862889297@kernel.org [1]
> > Link: https://lore.kernel.org/r/CAGb2v66oxp7G92psuF-pQsha5doh47j2gSMiTY7PAB2dYfozUw@mail.gmail.com [2]
> > Fixes: 48febf7e6476 ("stmmac: allow mtu bigger than 1500 in case of normal desc (V4)")
> > Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
> > ---
>
> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
>
> Maxime
>
> > Tested on an H616 (chain mode) with skbs of 1600 to 9000 bytes from
> > tc mirred at MTU 1500. Without this patch, TX stops at a 2048-byte
> > linear skb until the TX watchdog resets it. With it, every skb with a
> > buffer of 2048 bytes or more is dropped and counted, and TX stays up.
> > Ring mode is untested. AF_XDP zero-copy TX has the same gap and is not
> > covered.
> >
> > Developed with Claude (Anthropic), which wrote the code and the commit
> > message. I reviewed every change.
> > ---
> > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 25 +++++++++++++++++++++++
> > 1 file changed, 25 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > index a685ce4638f6..f21f7fc1beb7 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > @@ -2033,6 +2033,25 @@ static void stmmac_set_tx_dma_last_segment(struct stmmac_tx_queue *tx_q,
> > tx_q->tx_skbuff_dma[entry].last_segment = true;
> > }
> >
> > +/* Normal descriptors have an 11-bit buffer size */
> > +static bool stmmac_ndesc_tx_too_long(struct stmmac_priv *priv,
> > + struct sk_buff *skb)
> > +{
> > + unsigned int i;
> > +
> > + if (priv->hw->desc != &ndesc_ops)
> > + return false;
> > +
> > + if (skb_headlen(skb) >= BUF_SIZE_2KiB)
I plan on sending a patch to drop BUF_SIZE_2KiB down to 2044 to fix the
RX path, and align it with BUF_SIZE_8KiB and BUF_SIZE_16KiB size reductions.
It will still work here, just be constrained a bit more. Or you could use
FIELD_MAX(TDES1_BUFFER1_SIZE_MASK) here instead?
ChenYu
> > + return true;
> > +
> > + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
> > + if (skb_frag_size(&skb_shinfo(skb)->frags[i]) >= BUF_SIZE_2KiB)
> > + return true;
> > +
> > + return false;
> > +}
> > +
> > /**
> > * __init_dma_tx_desc_rings - init the TX descriptor ring (per queue)
> > * @priv: driver private structure
> > @@ -4889,6 +4908,12 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
> > }
> > }
> >
> > + if (unlikely(stmmac_ndesc_tx_too_long(priv, skb))) {
> > + dev_kfree_skb(skb);
> > + priv->xstats.tx_dropped++;
> > + return NETDEV_TX_OK;
> > + }
> > +
> > if (unlikely(stmmac_tx_avail(priv, queue) < nfrags + 1)) {
> > if (!netif_tx_queue_stopped(netdev_get_tx_queue(dev, queue))) {
> > netif_tx_stop_queue(netdev_get_tx_queue(priv->dev,
> >
> > ---
> > base-commit: 28a371228d4eb4857cc31eeb1a0d7d01e9c3ea2f
> > change-id: 20261127-stmmac-ndesc-tx-len-ef99cde11a8b
> >
> > Best regards,
> > --
> > Arun Iyengar <aiyengar1990@gmail.com>
>
Technical Details
Message-ID:
<CAGb2v65je-3YxZbxvW4c3s8WtOKLNzSZWY5+6cuQE=9C5fj-Eg@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!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-377459-linux-kernel-netdev=dewy.ruReferences:
<20261128-stmmac-ndesc-tx-len-v1-1-69f737224dc0@gmail.com> <f12f2638-df9a-403e-a5e5-481d0badf1a8@bootlin.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!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-377459-linux-kernel-netdev=dewy.ru
From: wens@kernel.org (Chen-Yu Tsai)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net: stmmac: Drop TX buffers too long for normal descriptors
Date: Sat, 5 Dec 2026 00:50:47 +0900
Organization: Usenet Network
Message-ID: <CAGb2v65je-3YxZbxvW4c3s8WtOKLNzSZWY5+6cuQE=9C5fj-Eg@mail.gmail.com>
References: <20261128-stmmac-ndesc-tx-len-v1-1-69f737224dc0@gmail.com> <f12f2638-df9a-403e-a5e5-481d0badf1a8@bootlin.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="2798255"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:q5qhZ/IdzT8MULvPN3EIQFh5jSQ= sha256:Rq14pPp2npminBIOGE9F5MJ83JJGi9B7ysJzHIJI1U0=
sha1:ifiKpaYE2T9SwYoZH5XMIPhC98g= sha256:PP65UcsbzyAXgnqdVLYEJLA85Y3NZoO3NUAnrfYNgFU=
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 BEF8B117C5C; Fri, 4 Dec 2026 18:51:16 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.542
X-Spam-Status: No, score=-3.542 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1,
DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
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 5IU1siJNgO20;
Fri, 4 Dec 2026 18:51:13 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377459-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 5B9A0117C57; Fri, 4 Dec 2026 18:51:05 +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 AC7D733AEC; Fri, 4 Dec 2026 15:51:03 +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=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796399463;
b=E850aIuJBMCLCb/FU9KuOhavD5todq7HuSPo4bDrAM5fw5x1QsHY3EhofUNc7M1kCc/w
XxRseKk4XUOe+cwir7iIjqC/zCUtzPjueiRyCU5wpFMGPpwMN6fjKzMWmRN9AZUrEyQU/
8Row/6HnfbKAAkgUVeZp/v3quNlclFBpGfBwQIV2MsJ2wb2nnGqqVNG8C3gUh86TjGrmO
u81li005H7Ne6PNRI/oXs1DuEqFeGpx1y54IQLrG+UjOvkHwUm0AapXWrEBtkrFivzzDf
ATMA0LY3dbtDTaFbC0WgkYHN7yyBxJWxMYaUoNufnUKDu6OZ+LDv7uyLafv1N5WgnJQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796399463;
h=X-Original-To:Received:Received:DKIM-Signature:Received:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:X-Mailing-List:
List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
List-Owner:Precedence:MIME-Version:References:In-Reply-To:Reply-To:
From:Date:X-Gmail-Original-Message-ID:X-Gm-Features:Message-ID:
Subject:To:Cc:Content-Type:Content-Transfer-Encoding;
bh=4Jcg/+mkaMkzC0ULkel+FCuq1cvSfNgnWKJ81JFIOSs=;
b=XN3M+Nq8QNGhoJ7O8qFc7dXeMHweqvSZtsiHKb//HQEnxgQDGwSfOCTaeXZ7+ho/Nc2/
cSyThol9fmZqDBEymRcFzzEx3Pl/6MStZ/j/xWPhAPihVGIS3uK0783mEzp4NqQmlhwcO
Ze0HzCCajyRsDmfxAgGSGVXHS1DwXKEq19jXER/4Vu9CyHYx8Qlf1j5vwu7CvwMwDJyNq
Q4z4z/7hZ1kGcLvL4TRVH1PoGFRvcGoiphygUG0jVvjvmt9hiKVGf5SeHK6eNzWVEqaTy
m8q5tHwh2ROwJBaiBBw+MwMrVN/vEa6krNTr7+XR3ZDC6NR/Q06cCFjZ8bnXWWWubwQ==
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=hkSXJiIv;
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 8192F606A333;
Fri, 4 Dec 2026 15:51:03 +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=hkSXJiIv
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796399462;
b=P0r8Aqed0XBkbrsPpDXfze8wKl8dB73aEY1U0NOiGFTXmoS5cu7BCytYVG/PndrrcJiT
hL/vqb3MU1C/Ze9cEOt8ExviiSvCDAfhOKWA5Y3RQ3uIgtsFTMSl9YTFlgtHB3ohW/Jxp
z084uVc5I0h/REPoX3Sr7WG1KKfAxzW10zGVg88Wo+fI2WYMO05LvfyNT57QNckYRkuE7
lgMsRv2UwGKg/Ecfqy1MM43NALGoT4bjnauLKFzvlIsa6hSp6NsLujG9eyqub7+jdMLqA
yTK4VDfhno6xGaRm9kCrGz1MZzPCB1Rwgx3dSOx96m5/yjNT9mJbYyph801BxXbNr5A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796399462;
h=Received:DKIM-Signature:Received:X-Forwarded-Encrypted:
X-Gm-Message-State:X-Received:MIME-Version:References:In-Reply-To:
Reply-To:From:Date:X-Gmail-Original-Message-ID:X-Gm-Features:
Message-ID:Subject:To:Cc:Content-Type:Content-Transfer-Encoding;
bh=4Jcg/+mkaMkzC0ULkel+FCuq1cvSfNgnWKJ81JFIOSs=;
b=EE5CcVPgSNaBloBQvhkg9yk01myV24pIY44vch2ZYz2aaeIL5o5RSUGbMxUB9HAS4maY
3dK9OQ850yFa7nZs26uC4vi7YrWBck8xxSCDe8/aVKhCbz9Mvlp6Cmu+0cXuGAbIMrjq/
flcyH1AnTKbGttOwP1osH0dd4J9jehJLJuvX7QTKcyPQ8kTgoafBl84iUGV9Ov9uJz6cA
8hSISgh4aGnryM3GgvO30hJ6xX5/R6wWgta9W8kK2GtB8Gl7Rj2z4FwZjYpzvVntr0qEG
smJX/p6Sxw7ZshajgTOdLVffZMguoEX153iKAikQqNp49+wFxugg7rVWbsRPJ0nfk6w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hkSXJiIv;
arc=none 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 9D98F606A322
for <netdev@vger.kernel.org>; Fri, 4 Dec 2026 15:51:02 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B1691F00936
for <netdev@vger.kernel.org>; Fri, 4 Dec 2026 15:51:02 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
s=k20260515; t=1796399462;
bh=4Jcg/+mkaMkzC0ULkel+FCuq1cvSfNgnWKJ81JFIOSs=;
h=References:In-Reply-To:Reply-To:From:Date:Subject:To:Cc;
b=hkSXJiIv1/4xJCuRnE3GodMztNLQMHk4DCiigersU4uNNbVph7MBaVJL6IRMtXUTU
neAoBA2kykH7WoRXokJxxbnnNQHT4McQs7x32YwFDpzS0YWtxTepaZ8GJWu6yhtjZ5
YpMrDDmG+sNOA6oakjDmI+gFjkIzm37rva1MnTHU00Cd04Gs/TqT/z1PKyxzz7euPT
5eP8b0iecX/9d6RPk7bBDZyqSM16GcqHYKexNGIVv9BG8rQB2bP2LqkOo7Vl0qg17M
MgRSbcNcCrZ5U7VrknWtccuB1uM8Sr1qZFrY25BZZ7CQeG7cLP8unMJS7A0oxOweBr
aMcQW/q5jIWcg==
X-Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-5c3369bdbd4so593715e87.3
for <netdev@vger.kernel.org>; Fri, 04 Dec 2026 07:51:02 -0800 (PST)
X-Forwarded-Encrypted: i=1; AL+hErFivkqgsD2ipVmJs5EwC9FZdb4YJ5dURe54IOazbkhyYHqRyXMWFS+oUEriWVjskXr0bNfOy5g=@vger.kernel.org
X-Gm-Message-State: APuU4Z8rKD3M7ECe5cPiVMhBBlc8oUHtMox0qb8C0DUyv1NXhFZAQfJ3
yhXOd34QJcuftbKmNaqCTPsGE+attKW6x5InaAIOQIumCEY3O5r/cMDygdi0KHyVsH4ib1jrBCo
au543cHrplpMD0fU9CgljYLOG5cu0i8I=
X-Received: by 2002:a05:6512:31d5:b0:5c1:4f88:9af6 with SMTP id
2adb3069b0e04-5c38619ca28mr578203e87.54.1796399460874; Fri, 04 Dec 2026
07:51:00 -0800 (PST)
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: <f12f2638-df9a-403e-a5e5-481d0badf1a8@bootlin.com>
X-Reply-To: wens@kernel.org
X-Gmail-Original-Message-ID: <CAGb2v65je-3YxZbxvW4c3s8WtOKLNzSZWY5+6cuQE=9C5fj-Eg@mail.gmail.com>
X-Gm-Features: Aa3M54pDTNu2JmUq0RDQRECzSNHX5aj5qrwCRfNxv_pv5j0gQ1t2QTmGexiBz0Q
X-Cc: 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>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>, Alexandre Torgue <alexandre.torgue@foss.st.com>,
netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org