From: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
To: Sagar Cheluvegowda <sagar.cheluvegowda@oss.qualcomm.com>
Cc: maxime.chevallier@bootlin.com, 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,
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,
hongmei.xu@oss.qualcomm.com, abhishek.chauhan@oss.qualcomm.com,
sarosh.hasan@oss.qualcomm.com
Subject: Re: [PATCH net] net: stmmac: xgmac: fix RX split header length on multi-descriptor frames
Date: Wed, 2 Dec 2026 22:26:52 +0100 [thread overview]
Message-ID: <axCNHKJBVnaQM8kI@lore-desk> (raw)
In-Reply-To: <20261125192531.1940982-1-sagar.cheluvegowda@oss.qualcomm.com>
[-- Attachment #1: Type: text/plain, Size: 4169 bytes --]
On Nov 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 <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>
Reviewed-by: Lorenzo Bianconi <lorenzo.bianconi@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
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
prev parent reply other threads:[~2026-12-02 21:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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
2026-11-26 19:26 ` netdev-bot+sashiko
2026-11-30 20:33 ` Sagar Cheluvegowda
2026-12-02 18:40 ` Maxime Chevallier
2026-12-02 21:26 ` Lorenzo Bianconi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=axCNHKJBVnaQM8kI@lore-desk \
--to=lorenzo.bianconi@oss.qualcomm.com \
--cc=Jose.Abreu@synopsys.com \
--cc=abhishek.chauhan@oss.qualcomm.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hongmei.xu@oss.qualcomm.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sagar.cheluvegowda@oss.qualcomm.com \
--cc=sarosh.hasan@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox