From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.84.56 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387338; b=CLHN4SH8yatvRXjPdaKVa8rpyskIVtcvt9YCES9goGcqj3hVgDryDoByjhmBnYiOgXn7 LLogLQso56L3H0C8Ut+VDdZ23DrzJrlwsgku3jwgUt77/1M0ClBsN6d0r0wiJk1Z92l8q 7WNsjfatkhU7iOjDfEEx6STDMlTUBdI9UGRYQzGcS5yn8Ivp0HKzw2puujym3CeOwU3Qk czXkWHT/eZe6MCUOaiGuIUQSStk9jzoVNxCCpAefXib0528LCRor3SeKJXW/eX0zWbkI2 SjKL6w53TDaAnT1M8EvyHN/h/vKZhb40CN3ZTsxfRwxg8B9jAPRega/WAF02UzXSkGA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387338; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References:From: Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding: X-Last-TLS-Session-Version; bh=RqK3HVnBxPpe1uqmqSbrEgObnH0F6Pa2tVBY0xbHBr8=; b=UsZDVkKj/3yp4iQj8POyKISNqKaFjUYwIQy3icZkhDIZVNRe85IIdlBuvEod0f3nvQuV P85tEgDli9Akclx4tBNsWy4hFeomZw/sqHmmKc9hDUTPZcwM/n4PAR1REUMfsuT3nl/jk Uy1RtWt5ZsTKW1iz8YamLOsTVGWO08D8UIZ4mophdgVcVFefX9Mgh38F8HnLnUeMjzuTz LGTkFYZVJpH7wgcG2vHtmamaptC50O/Nr6EaubYRA2nRpk2O9921UliwObpw9osaWsaWC LZqh/xV89rDtSE/qjluxHTqeiidQ7Ipk8yYtdZ+VoISzTdODJwJah8hHclIDHJ0k0KA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=S35DtuEP; arc=none smtp.remote-ip=185.246.84.56 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 6F21B606A322 for ; Fri, 4 Dec 2026 12:28:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6F21B606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=S35DtuEP Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 75B4D1A194D; Fri, 4 Dec 2026 12:28:54 +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-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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