mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] net: stmmac: xgmac: fix RX split header length on multi-descriptor frames
@ 2026-11-25 19:25 Sagar Cheluvegowda
  2026-11-25 19:27 ` netdev-bot+sinfo
  0 siblings, 1 reply; 2+ messages in thread
From: Sagar Cheluvegowda @ 2026-11-25 19:25 UTC (permalink / raw)
  To: maxime.chevallier, andrew+netdev, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, alexandre.torgue, Jose.Abreu
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-arm-msm,
	linux-kernel, lorenzo.bianconi, hongmei.xu, abhishek.chauhan,
	sarosh.hasan, Sagar Cheluvegowda

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 <abhishek.chauhan@oss.qualcomm.com>
Signed-off-by: Abhishek Chauhan <abhishek.chauhan@oss.qualcomm.com>
Co-developed-by: Sarosh Hasan <sarosh.hasan@oss.qualcomm.com>
Signed-off-by: Sarosh Hasan <sarosh.hasan@oss.qualcomm.com>
Signed-off-by: Sagar Cheluvegowda <sagar.cheluvegowda@oss.qualcomm.com>
---
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;
 }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net: stmmac: xgmac: fix RX split header length on multi-descriptor frames
  2026-11-25 19:25 [PATCH net] net: stmmac: xgmac: fix RX split header length on multi-descriptor frames Sagar Cheluvegowda
@ 2026-11-25 19:27 ` netdev-bot+sinfo
  0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sinfo @ 2026-11-25 19:27 UTC (permalink / raw)
  To: Sagar Cheluvegowda
  Cc: maxime.chevallier, andrew+netdev, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, alexandre.torgue, Jose.Abreu, netdev,
	linux-stm32, linux-arm-kernel, linux-arm-msm, linux-kernel,
	lorenzo.bianconi, hongmei.xu, abhishek.chauhan, sarosh.hasan

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by LLM and not proven at runtime). If it was triggered
   please include the symptoms, like the stack trace or kernel messages.

 - What hardware the change was tested on. For driver fixes please
   mention the device (and if relevant firmware version) used for
   testing, or say that the change was not tested on real hardware.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-25 19:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 19:25 [PATCH net] net: stmmac: xgmac: fix RX split header length on multi-descriptor frames Sagar Cheluvegowda
2026-11-25 19:27 ` netdev-bot+sinfo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®