Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: prabhakar.csengg@gmail.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, netdev@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-renesas-soc@vger.kernel.org,
	prabhakar.csengg+renesas@gmail.com, biju.das.jz@bp.renesas.com,
	fabrizio.castro.jz@renesas.com,
	prabhakar.mahadev-lad.rj@bp.renesas.com
Subject: Re: [PATCH net-next] net: stmmac: Advertise TX checksum offload only when supported
Date: Mon, 23 Nov 2026 20:06:07 +0000	[thread overview]
Message-ID: <179546436704.3135.12593345717335656860@kernel.org> (raw)
In-Reply-To: <20261119185016.1789843-1-prabhakar.mahadev-lad.rj@bp.renesas.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The new advertisement gate in __stmmac_dvr_probe() trusts
  plat->tx_coe.
- [Low] The commit message presents this as a bug fix ('This can cause
  DSA user ports to inherit checksum offload through vlan_features…

--

net: stmmac: Advertise TX checksum offload only when supported

With this patch, __stmmac_dvr_probe() adds NETIF_F_IP_CSUM and
NETIF_F_IPV6_CSUM to hw_features only when plat->tx_coe is set.
Previously they were always advertised. The goal is to stop DSA user
ports from inheriting TX checksum offload through vlan_features when the
conduit can't do it, for example in threshold DMA mode.

> The driver unconditionally advertises TX checksum offload, even when
> the hardware capability check disables it, such as when threshold DMA
> mode is selected. This can cause DSA user ports to inherit checksum
> offload through vlan_features despite the conduit not supporting it.

[Severity: Low]
This reads as a bug fix, but there's no Fixes: tag, and the message
doesn't say what actually breaks. Is this meant for net or net-next?

Before this patch the conduit's own dev->features was already correct.
stmmac_fix_features() removes the TX checksum bits:

stmmac_fix_features() {
    ...
	if (!priv->plat->tx_coe)
		features &= ~NETIF_F_CSUM_MASK;
    ...
}

So only hw_features and vlan_features were wrong.

For header-tagged DSA traffic, validate_xmit_skb()->skb_csum_hwoffload_help()
on the conduit already falls back to software checksums. Also,
stmmac_features_check() drops CSUM for non-IP ethertypes. In that case
the only effect looks like wrong feature reporting.

Wrong L4 checksums on the wire would come from trailer taggers that rely
on the conduit (tag_trailer, tag_xrs700x). Is that the case this patch
fixes, and could the message say so?

There is also a change users can see in ethtool when tx_coe is false.
tx-checksumming on the stmmac netdev now shows "off [fixed]" instead of
"off [requested on]". Should the message mention that as well?

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index f256244ce0d11..8cb1e3b4030e2 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -8224,8 +8224,9 @@ static int __stmmac_dvr_probe(struct device *device,
>  	ndev->xdp_metadata_ops = &stmmac_xdp_metadata_ops;
>  	ndev->xsk_tx_metadata_ops = &stmmac_xsk_tx_metadata_ops;
>  
> -	ndev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
> -			    NETIF_F_RXCSUM;
> +	ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM;
> +	if (priv->plat->tx_coe)
> +		ndev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;

[Severity: Medium]
On cores without the DMA HW feature register, does plat->tx_coe reflect
threshold DMA mode by the time this check runs?

The threshold-mode override is applied only inside the hw_cap_support
branch of stmmac_hw_init():

stmmac_hw_init() {
    ...
	if (priv->hw_cap_support) {
		...
		/* TXCOE doesn't work in thresh DMA mode */
		if (priv->plat->force_thresh_dma_mode)
			priv->plat->tx_coe = false;
		else
			priv->plat->tx_coe = priv->dma_cap.tx_coe;
		...
	} else {
		dev_info(priv->device, "No HW DMA feature register supported\n");
	}
    ...
}

Older GMACs such as 3.40a don't have this register. There,
dwmac1000_get_hw_feature() reads 0 and returns -EOPNOTSUPP, so the else
branch runs and tx_coe keeps the value the platform set.

For "snps,dwmac-3.40a", stmmac_probe_config_dt() sets that value
statically:

	if (of_device_is_compatible(np, "snps,dwmac-3.40a")) {
		...
		plat->tx_coe = true;

It reads "snps,force_thresh_dma_mode" for any compatible. Nothing makes
the two settings agree.

If both are set, stmmac_dma_operation_mode() checks force_thresh_dma_mode
first:

	if (priv->plat->force_thresh_dma_mode) {
		rxmode = tc;
	} else if (priv->plat->force_sf_dma_mode || priv->plat->tx_coe) {

The TX channels are then programmed in threshold mode with tx_threshold[],
while tx_coe stays true.

In that setup the new check still adds NETIF_F_IP_CSUM and
NETIF_F_IPV6_CSUM to hw_features, features and vlan_features. That is the
DSA case the commit message describes. stmmac_fix_features() keeps the
bits because it also checks only tx_coe. stmmac_xmit() then requests HW
checksum insertion for CHECKSUM_PARTIAL skbs.

The driver comment says TX COE doesn't work in threshold mode. If the
hardware really skips it, won't those frames go out with only the
pseudo-header partial checksum?

No in-tree DT seems to combine dwmac-3.40a with
snps,force_thresh_dma_mode (spear3xx.dtsi uses 3.40a without it). This
may not be reachable with current in-tree users.

Would it fix this to move the force_thresh_dma_mode check that clears
tx_coe out of the hw_cap_support branch?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119185016.1789843-1-prabhakar.mahadev-lad.rj%40bp.renesas.com


      reply	other threads:[~2026-11-23 20:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 18:50 [PATCH net-next] net: stmmac: Advertise TX checksum offload only when supported Prabhakar
2026-11-23 20:06 ` netdev-bot+sashiko [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=179546436704.3135.12593345717335656860@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fabrizio.castro.jz@renesas.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-renesas-soc@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=prabhakar.csengg+renesas@gmail.com \
    --cc=prabhakar.csengg@gmail.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.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