From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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.subspace.kernel.org (Postfix) with ESMTPS id 3B8EB606A680 for ; Fri, 4 Dec 2026 13:34:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=fc2p77OZ; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=S35DtuEP DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=RqK3HVnBxPpe1uqmqSbrEgObnH0F6Pa2tVBY0xbHBr8=; b=fc2p77OZGbFPoM +u7Zd5fQfdbFGXszUTWl8dyJHpjt5ynIZogOJEQFENZgoc3gmctTkfD7LuPiuIyZpBZkBTeoTBggD FPCEDRBdVCuqNm0cEdB0Q8LrMgVaWSMp0eoSD6SrBqS/U9XDVGnYc5+dmhN3L771aQ7A4MwptmHDO yVLf4Ykn8SU0VOyualti210roEPf9gQu4PbITZ98hiJ5yHU2vKt/Mm5Z4aSBhy35fTFU1MutVDbBc tAKwPPu16V4HKZsd9QaU02JxrrQPEddBZ1eEq7F0+730EZElFuzYylcVqMhiwZW2yQLJ2jKWIWz+7 uhiimQs5+KZSKV3IIK2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZSPN-00000000HZ9-30sk; Fri, 04 Dec 2026 12:29:01 +0000 Received: from smtpout-04.galae.net ([185.171.202.116]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZSPJ-00000000HXY-0Ih2 for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 12:28:59 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 24815C026D7; Fri, 4 Dec 2026 12:29:06 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 3FEC3603C4; Fri, 4 Dec 2026 12:28:54 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1ECF011EA093F; Fri, 04 Dec 2026 13:28:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1796387329; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:content-language:in-reply-to:references; bh=RqK3HVnBxPpe1uqmqSbrEgObnH0F6Pa2tVBY0xbHBr8=; b=S35DtuEPXyikKUH4dPmZHfVUcnMGwSLzt/iFfXvGRY9WLyGFcrpoOMzF5F2lQvfGC1pEGi iFpARke/7g04eDam386yWVkbwLqeXD+oJztqP2jy/3eZm2VZRq+h3Y/VlWuX80D9Z8UKHL PeO15nlN5KSlhKHv0cjOnBNyRz993OMM3OgzNfOoRiHxrZ2WLlUpQi9p2iO6SRjgNcdA5n wh5HbiyEqXesH0+g56iDoI9bInddBNHIl8LxoY3qHHSKowHlFGt0tK48ppkvm66eVyBKuQ kULo+rxt0zPoCTJV3LgIyuACfcdjBuWGnKasoXEfFxNjwymWfALQZDbzeKBObA== Message-ID: Date: Fri, 4 Dec 2026 13:28:39 +0100 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net] net: stmmac: Drop TX buffers too long for normal descriptors To: aiyengar1990@gmail.com, Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexandre Torgue , Chen-Yu Tsai Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org References: <20261128-stmmac-ndesc-tx-len-v1-1-69f737224dc0@gmail.com> From: Maxime Chevallier Content-Language: en-US In-Reply-To: <20261128-stmmac-ndesc-tx-len-v1-1-69f737224dc0@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_042857_407410_FD7B300B X-CRM114-Status: GOOD ( 24.31 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-17.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hi, On 11/28/26 20:00, Arun Iyengar via B4 Relay wrote: > From: Arun Iyengar > > 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 > --- Reviewed-by: Maxime Chevallier 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) > + 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