Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.85.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796236855; b=c6m0BuzPphcayMXn1TbF79i7bFSYu0ld7hjqO7kaTOtaBNZlgb1RJ56GM2OsECs7rPDO +Ae9x16OSZCxuMdK2H9OPc0ybSpU40J/vsSG3RgKNWS/JKVQ8Baw9cupu9oSkL46RwIt7 O3JwGUUJptqo8epv8sXJwRwf1b4HpX6JJ2anSjH3l3F+WPw0KOFxD/rWaBrSgdGYjm1Be Zp5ait68ALGCGp+zY6eWCdrh6FsuEuK2IIr/l8gqxxPAnma0//3ep8fAaqCpUv2rdaKcE r3Zz8Q2x2T25fWuMJoxZVrfSHgwuaCMyOADxatYzm4fX4uhezjEPIEtdO3RoWua6ufg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796236855; 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=fP2TffZBgm1nPEwblRvijHtpdM/2N5zwPqddxtKFr7g=; b=yNTzOtWXkB6dppUlsVtk8FiHgFAIMUMIu9g92q8lYY6heYU2QUuY9S2H7fIG5qbolxHd CCKxss1ijCDXmstPm+RpIutZjG9xvyZa8dYRjn0zrEtV/26tyHT/2MT0pSnxHE8+LAsMo ggpnN23m/snAN0FAJlwCWylt4O5fhAiCvCWX9WKi7o8l0zhzYC6ldjTEb8bZuQio8neTG XHeKZum9+YgD3IeOQTieL/NMxvjZPToLr3gGWGK15Zqn0rNSPjuy04SU9Br7PgLQ4biQH +jE8Hz9zI5TlVfqDjT5xuX3cion6c5SOOZHKFkZZzLikfWoYbZdKijcsmu76GOg4TPA== 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="EYNPC/Vo"; arc=none smtp.remote-ip=185.246.85.4 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 D8AAB606A6B3 for ; Wed, 2 Dec 2026 18:40:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D8AAB606A6B3 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=EYNPC/Vo Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 153034E4184E; Wed, 2 Dec 2026 18:40:48 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D3BA96075F; Wed, 2 Dec 2026 18:40:47 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5FE4211EA1CD4; Wed, 02 Dec 2026 19:40:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1796236842; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:content-language:in-reply-to:references; bh=fP2TffZBgm1nPEwblRvijHtpdM/2N5zwPqddxtKFr7g=; b=EYNPC/VoSGSMUdifmocHs4XDuoCo1HIoMWaNKDc8ticD93/JBz2Cj3hyLkm5TkVk1dXK2N vxvN7BVgM3X1DtXqJlTt9AjtREhTfDtpDgys0VE+XRq9i5mppNs1rmNyW2wF2ElAujx4+k KGybjNQqM9Z+1BEBI0sjB9zHA+K815UyHoI3SYf1QynJ0vzoVDv4yRvjy84i5eoZH1wYVQ mxTsvg4YpddWEcFYhwRmhKI33ksFR4ytjp4rxPfjGRrt0IYVB3wwYIZf2LsQfxtmAPIUsm m4XizxBZ9xTZjJ7UsfC1Cp+x703KJCFGu2RSjzyVwYYXSa9N+e5SXLwKFuNvuA== Message-ID: <1d7fd36f-12bc-462e-b363-a390cc8453a5@bootlin.com> Date: Wed, 2 Dec 2026 19:40:33 +0100 X-Mailing-List: linux-arm-msm@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: xgmac: fix RX split header length on multi-descriptor frames To: Sagar Cheluvegowda , andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, Jose.Abreu@synopsys.com Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, lorenzo.bianconi@oss.qualcomm.com, hongmei.xu@oss.qualcomm.com, abhishek.chauhan@oss.qualcomm.com, sarosh.hasan@oss.qualcomm.com References: <20261125192531.1940982-1-sagar.cheluvegowda@oss.qualcomm.com> From: Maxime Chevallier Content-Language: en-US In-Reply-To: <20261125192531.1940982-1-sagar.cheluvegowda@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Last-TLS-Session-Version: TLSv1.3 Hi, On 11/25/26 20:25, Sagar Cheluvegowda wrote: > dwxgmac2_get_rx_header_len() only reads the split header length (HL) > from RDES2 when RDES3.L34T is non-zero. L34T, like all RDES3 status > fields other than bits [31:28], is only valid on the last descriptor > (LD set). HL, on the other hand, is only valid on the first descriptor > (FD set), and the databook's "Header Length Availability in RDES2" > table states that HL is available in RDES2[9:0] when FD=1 and LD=0, > without any dependency on L34T. > > A frame spans multiple descriptors when it is larger than the RX buffer > size. This can happen at any MTU, as XGMAC_CORE_INIT_RX sets GPSLCE and > WD with GPSL = XGMAC_JUMBO_LEN (16368), so the MAC accepts frames up to > 16368 bytes while dma_buf_sz is only 1536 at an MTU of 1500. > > For such a frame, the first descriptor has FD set and LD clear, and > L34T is not valid there. When it reads as zero, hlen stays 0 and > stmmac_rx_buf1_len() falls through to the rx_not_ls path, which counts > buffer 1 as a full dma_buf_sz although it only holds the split header. > The frame length accounting is then wrong and the skb is built with > the wrong data. > > Read HL whenever the first descriptor is not also the last one, and > keep the L34T check for single-descriptor frames. Also return early > when FD is not set, as HL is not defined there. The caller already > ignores the header length for non-first descriptors, so this part > does not change the current behaviour. > > Fixes: 96147375d49f ("net: stmmac: xgmac: Only get SPH header len if available") > Co-developed-by: Abhishek Chauhan > Signed-off-by: Abhishek Chauhan > Co-developed-by: Sarosh Hasan > Signed-off-by: Sarosh Hasan > Signed-off-by: Sagar Cheluvegowda Reviewed-by: Maxime Chevallier Thanks for addressing this, Maxime > --- > This fix was split out of the net-next L2 split header series after > review of v5, where the multi-descriptor case was pointed out to be > reachable with the current GPSL setting and to need a separate fix. > The net-next patch will be reposted on top of this once it is in > net-next. > > v5 of the net-next patch: > https://lore.kernel.org/netdev/20261120005243.3724402-1-sagar.cheluvegowda@oss.qualcomm.com/ > Review comment: > https://lore.kernel.org/netdev/179548403438.3135.1804854034587814346@kernel.org/ > > drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h | 1 + > drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c | 9 ++++++++- > 2 files changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h > index f8ab347f7b5b..0cdc0bc695c2 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h > +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h > @@ -437,6 +437,7 @@ > #define XGMAC_RDES3_OWN BIT(31) > #define XGMAC_RDES3_CTXT BIT(30) > #define XGMAC_RDES3_IOC BIT(30) > +#define XGMAC_RDES3_FD BIT(29) > #define XGMAC_RDES3_LD BIT(28) > #define XGMAC_RDES3_CDA BIT(27) > #define XGMAC_RDES3_RSV BIT(26) > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c > index 6719ac6e395b..ed38aa358642 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_descs.c > @@ -292,7 +292,14 @@ static int dwxgmac2_get_rx_hash(struct dma_desc *p, u32 *hash, > > static void dwxgmac2_get_rx_header_len(struct dma_desc *p, unsigned int *len) > { > - if (le32_to_cpu(p->des3) & XGMAC_RDES3_L34T) > + u32 rdes3 = le32_to_cpu(p->des3); > + > + /* HL is only defined on the first descriptor */ > + if (!(rdes3 & XGMAC_RDES3_FD)) > + return; > + > + /* L34T is only valid on the last descriptor */ > + if (!(rdes3 & XGMAC_RDES3_LD) || (rdes3 & XGMAC_RDES3_L34T)) > *len = le32_to_cpu(p->des2) & XGMAC_RDES2_HL; > } >