Netdev List
 help / color / mirror / Atom feed
* [PATCH net v2] net: stmmac: Advertise TX checksum offload only when supported
@ 2026-11-24 13:28 Prabhakar
  2026-11-25 13:30 ` netdev-bot+sashiko
  2026-12-02 18:41 ` Maxime Chevallier
  0 siblings, 2 replies; 4+ messages in thread
From: Prabhakar @ 2026-11-24 13:28 UTC (permalink / raw)
  To: Maxime Chevallier, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
	Corinna Vinschen
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-renesas-soc,
	Prabhakar, Biju Das, Fabrizio Castro, Lad Prabhakar

From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

stmmac unconditionally adds IPv4 and IPv6 TX checksum offload to
hw_features and copies the resulting features to vlan_features. When
tx_coe is false, for example in threshold DMA mode on hardware with a
capability register, stmmac_fix_features() removes the flags from the
active features at registration, but vlan_features retains them.

DSA user ports inherit vlan_features and can therefore advertise TX
checksum offload even though the conduit cannot perform it.

Only add NETIF_F_IP_CSUM and NETIF_F_IPV6_CSUM to hw_features when
tx_coe is enabled. This prevents the unsupported features from being
propagated to DSA user ports and reports them as fixed off on the
conduit.

The issue was discovered while using stmmac as the DSA CPU port on
RZ/T2H and RZ/N2H EVKs. The fix was tested with ethtool on the switch
ports of both EVKs.

Fixes: 6b2c6e4a938f ("net: stmmac: propagate feature flags to vlan")
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
v2:
  - Added fixes tag
  - Updated commit message
  - Targetted the patch to net instead of net-next
v1: https://lore.kernel.org/all/20261119185016.1789843-1-prabhakar.mahadev-lad.rj@bp.renesas.com/
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a685ce4638f61..d32d3e7b1b8c6 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -8147,8 +8147,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;
 	ndev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
 			     NETDEV_XDP_ACT_XSK_ZEROCOPY;
 
-- 
2.56.1


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

* Re: [PATCH net v2] net: stmmac: Advertise TX checksum offload only when supported
  2026-11-24 13:28 [PATCH net v2] net: stmmac: Advertise TX checksum offload only when supported Prabhakar
@ 2026-11-25 13:30 ` netdev-bot+sashiko
  2026-11-26 11:37   ` Lad, Prabhakar
  2026-12-02 18:41 ` Maxime Chevallier
  1 sibling, 1 reply; 4+ messages in thread
From: netdev-bot+sashiko @ 2026-11-25 13:30 UTC (permalink / raw)
  To: prabhakar.csengg
  Cc: maxime.chevallier, andrew+netdev, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, alexandre.torgue, vinschen, netdev, linux-stm32,
	linux-arm-kernel, linux-renesas-soc, prabhakar.csengg+renesas,
	biju.das.jz, fabrizio.castro.jz, prabhakar.mahadev-lad.rj

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

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

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 fix does not cover the bugged_jumbo case, so DSA user
  ports can still advertise TX checksum offload that the stmmac conduit…

--

I found one possible regression: on bugged_jumbo cores, DSA user ports can still show TX checksum offload after the conduit has turned it off. The draft reply for the list follows.

net: stmmac: Advertise TX checksum offload only when supported

This patch changes __stmmac_dvr_probe() to add NETIF_F_IP_CSUM and
NETIF_F_IPV6_CSUM to hw_features only when priv->plat->tx_coe is set.
The aim is to keep TX checksum flags that stmmac_fix_features() later
clears out of vlan_features. DSA user ports inherit vlan_features.

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index a685ce4638f61..d32d3e7b1b8c6 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -8147,8 +8147,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]
Does this cover every case where the conduit drops TX checksum offload?
stmmac_fix_features() has a second reason to clear these flags, and it
depends on the MTU:

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_fix_features() {
    ...
	if (priv->plat->bugged_jumbo && (dev->mtu > ETH_DATA_LEN))
		features &= ~NETIF_F_CSUM_MASK;
    ...
}

In stmmac_probe_config_dt(), the snps,dwmac-3.40a compatible sets both
tx_coe and bugged_jumbo. The snps,dwmac-3.610 and snps,dwmac-3.710
compatibles set bugged_jumbo, and tx_coe comes from dma_cap.

On those cores the new tx_coe check still passes. The checksum flags are
then copied into vlan_features once, during probe, while the MTU is still
1500:

	ndev->vlan_features |= ndev->features;

When such a stmmac is a DSA conduit, the DSA setup raises its MTU:

dsa_conduit_setup()
  dev_set_mtu(dev, ETH_DATA_LEN + tag overhead)
    stmmac_change_mtu()
      netdev_update_features()
        stmmac_fix_features()    /* clears NETIF_F_CSUM_MASK */

This clears the checksum bits from conduit->features only. vlan_features
is not updated afterwards.

The user ports take their features from conduit->vlan_features in
dsa_user_setup_tagger() and dsa_user_create():

	user->features = conduit->vlan_features | NETIF_F_HW_TC;
	...
	user_dev->vlan_features = conduit->vlan_features;

Nothing in net/dsa appears to react to NETDEV_FEAT_CHANGE on the conduit.

So could the user ports still advertise IP_CSUM and IPV6_CSUM while the
conduit has them turned off? That looks like the same symptom the commit
message says this patch removes:

  "DSA user ports inherit vlan_features and can therefore advertise TX
  checksum offload even though the conduit cannot perform it."

Packets should still be correct, because validate_xmit_skb() on the
conduit falls back to software checksumming. The problem is limited to
which features are reported.

Would it make sense to also clear in vlan_features whatever
stmmac_fix_features() clears, or to handle this on the DSA side, so that
bugged_jumbo conduits are covered as well?

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

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

* Re: [PATCH net v2] net: stmmac: Advertise TX checksum offload only when supported
  2026-11-25 13:30 ` netdev-bot+sashiko
@ 2026-11-26 11:37   ` Lad, Prabhakar
  0 siblings, 0 replies; 4+ messages in thread
From: Lad, Prabhakar @ 2026-11-26 11:37 UTC (permalink / raw)
  To: netdev-bot+sashiko
  Cc: maxime.chevallier, andrew+netdev, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, alexandre.torgue, vinschen, netdev, linux-stm32,
	linux-arm-kernel, linux-renesas-soc, prabhakar.csengg+renesas,
	biju.das.jz, fabrizio.castro.jz, prabhakar.mahadev-lad.rj

On Wed, Nov 25, 2026 at 1:30 PM <netdev-bot+sashiko@kernel.org> wrote:
>
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 1 · Low: 0
>
> 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 fix does not cover the bugged_jumbo case, so DSA user
>   ports can still advertise TX checksum offload that the stmmac conduit…
>
> --
>
> I found one possible regression: on bugged_jumbo cores, DSA user ports can still show TX checksum offload after the conduit has turned it off. The draft reply for the list follows.
>
> net: stmmac: Advertise TX checksum offload only when supported
>
> This patch changes __stmmac_dvr_probe() to add NETIF_F_IP_CSUM and
> NETIF_F_IPV6_CSUM to hw_features only when priv->plat->tx_coe is set.
> The aim is to keep TX checksum flags that stmmac_fix_features() later
> clears out of vlan_features. DSA user ports inherit vlan_features.
>
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > index a685ce4638f61..d32d3e7b1b8c6 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > @@ -8147,8 +8147,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]
> Does this cover every case where the conduit drops TX checksum offload?
> stmmac_fix_features() has a second reason to clear these flags, and it
> depends on the MTU:
>
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_fix_features() {
>     ...
>         if (priv->plat->bugged_jumbo && (dev->mtu > ETH_DATA_LEN))
>                 features &= ~NETIF_F_CSUM_MASK;
>     ...
> }
>
> In stmmac_probe_config_dt(), the snps,dwmac-3.40a compatible sets both
> tx_coe and bugged_jumbo. The snps,dwmac-3.610 and snps,dwmac-3.710
> compatibles set bugged_jumbo, and tx_coe comes from dma_cap.
>
> On those cores the new tx_coe check still passes. The checksum flags are
> then copied into vlan_features once, during probe, while the MTU is still
> 1500:
>
>         ndev->vlan_features |= ndev->features;
>
> When such a stmmac is a DSA conduit, the DSA setup raises its MTU:
>
> dsa_conduit_setup()
>   dev_set_mtu(dev, ETH_DATA_LEN + tag overhead)
>     stmmac_change_mtu()
>       netdev_update_features()
>         stmmac_fix_features()    /* clears NETIF_F_CSUM_MASK */
>
> This clears the checksum bits from conduit->features only. vlan_features
> is not updated afterwards.
>
> The user ports take their features from conduit->vlan_features in
> dsa_user_setup_tagger() and dsa_user_create():
>
>         user->features = conduit->vlan_features | NETIF_F_HW_TC;
>         ...
>         user_dev->vlan_features = conduit->vlan_features;
>
> Nothing in net/dsa appears to react to NETDEV_FEAT_CHANGE on the conduit.
>
> So could the user ports still advertise IP_CSUM and IPV6_CSUM while the
> conduit has them turned off? That looks like the same symptom the commit
> message says this patch removes:
>
Yes, this can still happen when bugged_jumbo clears the checksum
features after an MTU change. DSA user ports copy
conduit->vlan_features when they are created and don't update them
when the conduit's features change.

This patch only fixes the case where tx_coe is disabled. There, the
conduit never has TX checksum offload, but vlan_features still
advertised IP_CSUM and IPV6_CSUM from probe time. I'll reword the
commit message so it doesn't suggest the patch covers the bugged_jumbo
case.

A proper fix for bugged_jumbo would have DSA sync user port features
when the conduit's features change. That's a DSA change rather than an
stmmac one, and I don't have the affected hardware to test it.

Cheers,
Prabhakar

>   "DSA user ports inherit vlan_features and can therefore advertise TX
>   checksum offload even though the conduit cannot perform it."
>
> Packets should still be correct, because validate_xmit_skb() on the
> conduit falls back to software checksumming. The problem is limited to
> which features are reported.
>
> Would it make sense to also clear in vlan_features whatever
> stmmac_fix_features() clears, or to handle this on the DSA side, so that
> bugged_jumbo conduits are covered as well?
>
> --
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124132802.2003605-1-prabhakar.mahadev-lad.rj%40bp.renesas.com

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

* Re: [PATCH net v2] net: stmmac: Advertise TX checksum offload only when supported
  2026-11-24 13:28 [PATCH net v2] net: stmmac: Advertise TX checksum offload only when supported Prabhakar
  2026-11-25 13:30 ` netdev-bot+sashiko
@ 2026-12-02 18:41 ` Maxime Chevallier
  1 sibling, 0 replies; 4+ messages in thread
From: Maxime Chevallier @ 2026-12-02 18:41 UTC (permalink / raw)
  To: Prabhakar, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Maxime Coquelin, Alexandre Torgue,
	Corinna Vinschen
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-renesas-soc,
	Prabhakar, Biju Das, Fabrizio Castro, Lad Prabhakar

Hi,

On 11/24/26 14:28, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> 
> stmmac unconditionally adds IPv4 and IPv6 TX checksum offload to
> hw_features and copies the resulting features to vlan_features. When
> tx_coe is false, for example in threshold DMA mode on hardware with a
> capability register, stmmac_fix_features() removes the flags from the
> active features at registration, but vlan_features retains them.
> 
> DSA user ports inherit vlan_features and can therefore advertise TX
> checksum offload even though the conduit cannot perform it.
> 
> Only add NETIF_F_IP_CSUM and NETIF_F_IPV6_CSUM to hw_features when
> tx_coe is enabled. This prevents the unsupported features from being
> propagated to DSA user ports and reports them as fixed off on the
> conduit.
> 
> The issue was discovered while using stmmac as the DSA CPU port on
> RZ/T2H and RZ/N2H EVKs. The fix was tested with ethtool on the switch
> ports of both EVKs.
> 
> Fixes: 6b2c6e4a938f ("net: stmmac: propagate feature flags to vlan")
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>

Maxime

> ---
> v2:
>   - Added fixes tag
>   - Updated commit message
>   - Targetted the patch to net instead of net-next
> v1: https://lore.kernel.org/all/20261119185016.1789843-1-prabhakar.mahadev-lad.rj@bp.renesas.com/
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index a685ce4638f61..d32d3e7b1b8c6 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -8147,8 +8147,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;
>  	ndev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
>  			     NETDEV_XDP_ACT_XSK_ZEROCOPY;
>  


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

end of thread, other threads:[~2026-12-02 18:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 13:28 [PATCH net v2] net: stmmac: Advertise TX checksum offload only when supported Prabhakar
2026-11-25 13:30 ` netdev-bot+sashiko
2026-11-26 11:37   ` Lad, Prabhakar
2026-12-02 18:41 ` Maxime Chevallier

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