Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: bcmgenet: Support for NETIF_F_RXFCS
@ 2026-12-04 23:00 Florian Fainelli
  2026-12-04 23:00 ` [PATCH net-next 1/2] net: bcmgenet: keep FCS forwarding when exiting Wake-on-LAN Florian Fainelli
  2026-12-04 23:00 ` [PATCH net-next 2/2] net: bcmgenet: add support for NETIF_F_RXFCS Florian Fainelli
  0 siblings, 2 replies; 7+ messages in thread
From: Florian Fainelli @ 2026-12-04 23:00 UTC (permalink / raw)
  To: netdev
  Cc: Florian Fainelli, Doug Berger, Nicolai Buchwitz,
	Broadcom internal kernel review list, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni

This patch series adds support for passing the FCS up the networking
stack which is a feature that the GENET controller has always had but we
did not wire it up to NETIF_F_RXFCS.

To simplify the implementation, we mandate that the interface be
administratively brought down in order to toggle the 'rx-fcs' ethtool
feature bit. Doing this live would require draining the entire RX path.

This was tested on a GENETv5 board using a BCX972160DV reference board
using runtime tests as well as across Suspend-to-DRAM (S3) to ensure FCS
on/off survives properly.

Florian Fainelli (2):
  net: bcmgenet: keep FCS forwarding when exiting Wake-on-LAN
  net: bcmgenet: add support for NETIF_F_RXFCS

 .../net/ethernet/broadcom/genet/bcmgenet.c    | 46 ++++++++++++++++---
 .../ethernet/broadcom/genet/bcmgenet_wol.c    |  8 ++--
 2 files changed, 45 insertions(+), 9 deletions(-)

-- 
2.56.1


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

* [PATCH net-next 1/2] net: bcmgenet: keep FCS forwarding when exiting Wake-on-LAN
  2026-12-04 23:00 [PATCH net-next 0/2] net: bcmgenet: Support for NETIF_F_RXFCS Florian Fainelli
@ 2026-12-04 23:00 ` Florian Fainelli
  2026-12-05 12:16   ` Nicolai Buchwitz
  2026-12-05 23:30   ` netdev-bot+sashiko
  2026-12-04 23:00 ` [PATCH net-next 2/2] net: bcmgenet: add support for NETIF_F_RXFCS Florian Fainelli
  1 sibling, 2 replies; 7+ messages in thread
From: Florian Fainelli @ 2026-12-04 23:00 UTC (permalink / raw)
  To: netdev
  Cc: Florian Fainelli, Doug Berger, Nicolai Buchwitz,
	Broadcom internal kernel review list, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni

bcmgenet_wol_power_down_cfg() forces CMD_CRC_FWD on so that the
UniMAC can match magic packets, and bcmgenet_wol_power_up_cfg()
unconditionally turns it back off and clears priv->crc_fwd_en.

That is fine as long as the driver never forwards the FCS on its own,
but a following change makes this depend on NETIF_F_RXFCS. On a
successful WoL exit bcmgenet_resume() does not re-apply the features,
so clearing the state here would silently drop the user's setting.

Derive priv->crc_fwd_en from dev->features when leaving WoL and only
clear CMD_CRC_FWD when the FCS is not wanted. Since NETIF_F_RXFCS is
not advertised yet, there is no functional change.

Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c b/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
index 984432952963..ff34c4df4f4a 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
@@ -223,7 +223,8 @@ int bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv,
 	}
 
 	clk_disable_unprepare(priv->clk_wol);
-	priv->crc_fwd_en = 0;
+	/* Keep forwarding the FCS if the user asked for it */
+	priv->crc_fwd_en = !!(dev->features & NETIF_F_RXFCS);
 
 	bcmgenet_intrl2_0_writel(priv, UMAC_IRQ_WAKE_EVENT,
 				 INTRL2_CPU_MASK_SET);
@@ -248,10 +249,11 @@ int bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv,
 	reg &= ~RBUF_ACPI_EN;
 	bcmgenet_hfb_reg_writel(priv, reg, HFB_CTRL);
 
-	/* Disable CRC Forward */
+	/* Disable CRC Forward unless NETIF_F_RXFCS needs it */
 	spin_lock_bh(&priv->reg_lock);
 	reg = bcmgenet_umac_readl(priv, UMAC_CMD);
-	reg &= ~CMD_CRC_FWD;
+	if (!priv->crc_fwd_en)
+		reg &= ~CMD_CRC_FWD;
 	bcmgenet_umac_writel(priv, reg, UMAC_CMD);
 
 	/*
-- 
2.56.1


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

* [PATCH net-next 2/2] net: bcmgenet: add support for NETIF_F_RXFCS
  2026-12-04 23:00 [PATCH net-next 0/2] net: bcmgenet: Support for NETIF_F_RXFCS Florian Fainelli
  2026-12-04 23:00 ` [PATCH net-next 1/2] net: bcmgenet: keep FCS forwarding when exiting Wake-on-LAN Florian Fainelli
@ 2026-12-04 23:00 ` Florian Fainelli
  2026-12-05 12:23   ` Nicolai Buchwitz
  2026-12-05 23:30   ` netdev-bot+sashiko
  1 sibling, 2 replies; 7+ messages in thread
From: Florian Fainelli @ 2026-12-04 23:00 UTC (permalink / raw)
  To: netdev
  Cc: Florian Fainelli, Doug Berger, Nicolai Buchwitz,
	Broadcom internal kernel review list, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni

Allow the Ethernet FCS to be delivered to the network stack, which is
useful for packet capture and for debugging link-level corruption.
The feature is off by default and is toggled with "ethtool -K <dev>
rx-fcs on|off".

bcmgenet_set_features() now programs CMD_CRC_FWD in UMAC_CMD according
to NETIF_F_RXFCS, and keeps RBUF_SKIP_FCS in RBUF_CHK_CTRL in sync so
the RX checksum block ignores the forwarded FCS. This replaces the
previous read-back of CMD_CRC_FWD into priv->crc_fwd_en, which is
still updated and still used by the Wake-on-LAN code.

In bcmgenet_desc_rx() the FCS is only trimmed when it was forwarded and
NETIF_F_RXFCS is off. The hardware checksum does not cover the FCS, so
it cannot be reported as CHECKSUM_COMPLETE for frames that still carry
it; such frames are left to the stack to verify.

Frames already queued in the RX rings were written with the previous
setting and cannot be told apart from new ones, so a change on a running
interface is refused with -EBUSY. The request is kept in the device's
wanted features, and bcmgenet_close() calls netdev_update_features() so
that it takes effect once the interface is down. Changing the feature
while the interface is down only needs the register update. The open
and resume paths re-apply the current features and are not affected.

Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
 .../net/ethernet/broadcom/genet/bcmgenet.c    | 46 ++++++++++++++++---
 1 file changed, 40 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 93a773d0ccf3..35a0fe425acd 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -814,14 +814,40 @@ static int bcmgenet_set_features(struct net_device *dev,
 	u32 reg;
 	int ret;
 
+	/* Frames already queued in the RX rings were written with the old FCS
+	 * setting and cannot be told apart from new ones, so refuse a live
+	 * change. The request stays in wanted_features and is applied by
+	 * bcmgenet_close(). Re-applying the current features from open and
+	 * resume does not change the flag and is not affected.
+	 */
+	if (netif_running(dev) && ((features ^ dev->features) & NETIF_F_RXFCS))
+		return -EBUSY;
+
 	ret = clk_prepare_enable(priv->clk);
 	if (ret)
 		return ret;
 
-	/* Make sure we reflect the value of CRC_CMD_FWD */
+	/* Forward the FCS to the host when NETIF_F_RXFCS is requested.
+	 * RBUF_SKIP_FCS tells the RX checksum block to ignore the forwarded
+	 * FCS, so keep it in sync with CMD_CRC_FWD.
+	 */
+	spin_lock_bh(&priv->reg_lock);
 	reg = bcmgenet_umac_readl(priv, UMAC_CMD);
+	if (features & NETIF_F_RXFCS)
+		reg |= CMD_CRC_FWD;
+	else
+		reg &= ~CMD_CRC_FWD;
+	bcmgenet_umac_writel(priv, reg, UMAC_CMD);
 	priv->crc_fwd_en = !!(reg & CMD_CRC_FWD);
 
+	reg = bcmgenet_rbuf_readl(priv, RBUF_CHK_CTRL);
+	if (priv->crc_fwd_en)
+		reg |= RBUF_SKIP_FCS;
+	else
+		reg &= ~RBUF_SKIP_FCS;
+	bcmgenet_rbuf_writel(priv, reg, RBUF_CHK_CTRL);
+	spin_unlock_bh(&priv->reg_lock);
+
 	clk_disable_unprepare(priv->clk);
 
 	return ret;
@@ -2461,12 +2487,15 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring,
 		skb_reserve(skb, GENET_RSB_PAD);
 		__skb_put(skb, len - GENET_RSB_PAD);
 
-		if (priv->crc_fwd_en) {
+		/* Strip the FCS unless the user asked to receive it */
+		if (priv->crc_fwd_en && !(dev->features & NETIF_F_RXFCS))
 			skb_trim(skb, skb->len - ETH_FCS_LEN);
-		}
 
-		/* Set up checksum offload */
-		if (dev->features & NETIF_F_RXCSUM) {
+		/* Set up checksum offload. The hardware checksum excludes the
+		 * FCS, so it cannot be used when the FCS is passed up.
+		 */
+		if ((dev->features & NETIF_F_RXCSUM) &&
+		    !(dev->features & NETIF_F_RXFCS)) {
 			rx_csum = (__force __be16)(status->rx_csum & 0xffff);
 			if (rx_csum) {
 				skb->csum = (__force __wsum)ntohs(rx_csum);
@@ -3552,6 +3581,11 @@ static int bcmgenet_close(struct net_device *dev)
 
 	clk_disable_unprepare(priv->clk);
 
+	/* Apply a feature change, e.g. NETIF_F_RXFCS, that was refused while
+	 * the interface was running. The device is not running anymore.
+	 */
+	netdev_update_features(dev);
+
 	return ret;
 }
 
@@ -4098,7 +4132,7 @@ static int bcmgenet_probe(struct platform_device *pdev)
 	/* Set default features */
 	dev->features |= NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_HW_CSUM |
 			 NETIF_F_RXCSUM;
-	dev->hw_features |= dev->features;
+	dev->hw_features |= dev->features | NETIF_F_RXFCS;
 	dev->vlan_features |= dev->features;
 
 	netdev_sw_irq_coalesce_default_on(dev);
-- 
2.56.1


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

* Re: [PATCH net-next 1/2] net: bcmgenet: keep FCS forwarding when exiting Wake-on-LAN
  2026-12-04 23:00 ` [PATCH net-next 1/2] net: bcmgenet: keep FCS forwarding when exiting Wake-on-LAN Florian Fainelli
@ 2026-12-05 12:16   ` Nicolai Buchwitz
  2026-12-05 23:30   ` netdev-bot+sashiko
  1 sibling, 0 replies; 7+ messages in thread
From: Nicolai Buchwitz @ 2026-12-05 12:16 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: netdev, Doug Berger, Broadcom internal kernel review list,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni

On 5.12.2026 00:00, Florian Fainelli wrote:
> bcmgenet_wol_power_down_cfg() forces CMD_CRC_FWD on so that the
> UniMAC can match magic packets, and bcmgenet_wol_power_up_cfg()
> unconditionally turns it back off and clears priv->crc_fwd_en.
> 
> That is fine as long as the driver never forwards the FCS on its own,
> but a following change makes this depend on NETIF_F_RXFCS. On a
> successful WoL exit bcmgenet_resume() does not re-apply the features,
> so clearing the state here would silently drop the user's setting.
> 
> Derive priv->crc_fwd_en from dev->features when leaving WoL and only
> clear CMD_CRC_FWD when the FCS is not wanted. Since NETIF_F_RXFCS is
> not advertised yet, there is no functional change.
> 
> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>

> [...]

Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>

Thanks,
Nicolai

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

* Re: [PATCH net-next 2/2] net: bcmgenet: add support for NETIF_F_RXFCS
  2026-12-04 23:00 ` [PATCH net-next 2/2] net: bcmgenet: add support for NETIF_F_RXFCS Florian Fainelli
@ 2026-12-05 12:23   ` Nicolai Buchwitz
  2026-12-05 23:30   ` netdev-bot+sashiko
  1 sibling, 0 replies; 7+ messages in thread
From: Nicolai Buchwitz @ 2026-12-05 12:23 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: netdev, Doug Berger, Broadcom internal kernel review list,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni

Hi Florian

On 5.12.2026 00:00, Florian Fainelli wrote:

> [...]

> @@ -814,14 +814,40 @@ static int bcmgenet_set_features(struct 
> net_device *dev,
>  	u32 reg;
>  	int ret;
> 
> +	/* Frames already queued in the RX rings were written with the old 
> FCS
> +	 * setting and cannot be told apart from new ones, so refuse a live
> +	 * change. The request stays in wanted_features and is applied by
> +	 * bcmgenet_close(). Re-applying the current features from open and
> +	 * resume does not change the flag and is not affected.
> +	 */
> +	if (netif_running(dev) && ((features ^ dev->features) & 
> NETIF_F_RXFCS))
> +		return -EBUSY;

-EBUSY never reaches userspace? ethtool reports OK, but dmesg an
error. The change shows up at the next ifdown. Every other ethtool -K 
fails too.

Maybe pin RXFCS in ndo_fix_features() while running instead?

> [...]

>  	return ret;
> @@ -2461,12 +2487,15 @@ static unsigned int bcmgenet_desc_rx(struct 
> bcmgenet_rx_ring *ring,
>  		skb_reserve(skb, GENET_RSB_PAD);
>  		__skb_put(skb, len - GENET_RSB_PAD);
> 
> -		if (priv->crc_fwd_en) {
> +		/* Strip the FCS unless the user asked to receive it */
> +		if (priv->crc_fwd_en && !(dev->features & NETIF_F_RXFCS))

Can this still hit? crc_fwd_en mirrors RXFCS now, so it could probably
go away?

>  			skb_trim(skb, skb->len - ETH_FCS_LEN);
> -		}
> 
> -		/* Set up checksum offload */
> -		if (dev->features & NETIF_F_RXCSUM) {
> +		/* Set up checksum offload. The hardware checksum excludes the
> +		 * FCS, so it cannot be used when the FCS is passed up.
> +		 */
> +		if ((dev->features & NETIF_F_RXCSUM) &&
> +		    !(dev->features & NETIF_F_RXFCS)) {

Nit: ethtool -k still shows rx-checksumming on here. Clear RXCSUM in
ndo_fix_features() while RXFCS is set (or csum_block_add() the FCS)?

> [...]

Thanks,
Nicolai

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

* Re: [PATCH net-next 1/2] net: bcmgenet: keep FCS forwarding when exiting Wake-on-LAN
  2026-12-04 23:00 ` [PATCH net-next 1/2] net: bcmgenet: keep FCS forwarding when exiting Wake-on-LAN Florian Fainelli
  2026-12-05 12:16   ` Nicolai Buchwitz
@ 2026-12-05 23:30   ` netdev-bot+sashiko
  1 sibling, 0 replies; 7+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 23:30 UTC (permalink / raw)
  To: florian.fainelli
  Cc: netdev, opendmb, nb, bcm-kernel-feedback-list, andrew+netdev,
	davem, edumazet, kuba, pabeni

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] Not a bug in the final state of the series; kept only because
  requires_validation=true.
- [Low] Not a bug in the final state of the series; kept only because
  requires_validation=true.

--

net: bcmgenet: keep FCS forwarding when exiting Wake-on-LAN

Before this change, bcmgenet_wol_power_up_cfg() always cleared
priv->crc_fwd_en. It now sets it from NETIF_F_RXFCS in dev->features and
clears CMD_CRC_FWD in UMAC_CMD only when the FCS is not wanted. This
prepares for a later change that adds NETIF_F_RXFCS support.

> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c b/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
> index 984432952963a..ff34c4df4f4ab 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
> @@ -223,7 +223,8 @@ int bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv,
>  	}
>  
>  	clk_disable_unprepare(priv->clk_wol);
> -	priv->crc_fwd_en = 0;
> +	/* Keep forwarding the FCS if the user asked for it */
> +	priv->crc_fwd_en = !!(dev->features & NETIF_F_RXFCS);

[Severity: Low]
In bcmgenet_wol_power_up_cfg(), this assignment runs before the two
"already reset" early returns:

	reg = bcmgenet_umac_readl(priv, UMAC_MPD_CTRL);
	if (!(reg & MPD_EN))
		return -EPERM;	/* already reset so skip the rest */
	...
	reg = bcmgenet_hfb_reg_readl(priv, HFB_CTRL);
	if (!(reg & RBUF_ACPI_EN))
		return -EPERM;	/* already reset so skip the rest */

If either return is taken, bcmgenet_resume_noirq() falls through to
bcmgenet_umac_reset(). bcmgenet_resume() then takes the "MAC was reset"
path and calls init_umac().

In init_umac(), reset_umac() clears CMD_CRC_FWD. RBUF_SKIP_FCS, though,
is set from crc_fwd_en:

	if (priv->crc_fwd_en)
		reg |= RBUF_SKIP_FCS;
	else
		reg &= ~RBUF_SKIP_FCS;

Once RXFCS can be turned on, could RBUF_SKIP_FCS end up set while
CMD_CRC_FWD is clear?

At this commit, crc_fwd_en is always 0 on this path, because
NETIF_F_RXFCS is not in hw_features.

The follow-up patch "net: bcmgenet: add support for NETIF_F_RXFCS" covers
this. bcmgenet_resume() calls bcmgenet_set_features(dev, dev->features)
after init_umac() and before bcmgenet_netif_start() enables RX. After
that patch, this call writes CMD_CRC_FWD, crc_fwd_en and RBUF_SKIP_FCS
together. So by the end of the series, received frames should never see
the mismatch.

[ ... ]

> @@ -248,10 +249,11 @@ int bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv,
>  	reg &= ~RBUF_ACPI_EN;
>  	bcmgenet_hfb_reg_writel(priv, reg, HFB_CTRL);
>  
> -	/* Disable CRC Forward */
> +	/* Disable CRC Forward unless NETIF_F_RXFCS needs it */
>  	spin_lock_bh(&priv->reg_lock);
>  	reg = bcmgenet_umac_readl(priv, UMAC_CMD);
> -	reg &= ~CMD_CRC_FWD;
> +	if (!priv->crc_fwd_en)
> +		reg &= ~CMD_CRC_FWD;
>  	bcmgenet_umac_writel(priv, reg, UMAC_CMD);

[Severity: Low]
With this change, priv->crc_fwd_en is set from two different sources.
bcmgenet_wol_power_up_cfg() sets it from the user's NETIF_F_RXFCS
setting. bcmgenet_set_features() still reads it back from the hardware
and never writes CMD_CRC_FWD:

	/* Make sure we reflect the value of CRC_CMD_FWD */
	reg = bcmgenet_umac_readl(priv, UMAC_CMD);
	priv->crc_fwd_en = !!(reg & CMD_CRC_FWD);

bcmgenet_desc_rx() also strips the FCS whenever crc_fwd_en is set:

	if (priv->crc_fwd_en) {
		skb_trim(skb, skb->len - ETH_FCS_LEN);
	}

Looking at this commit alone, wouldn't bcmgenet_desc_rx() trim the FCS
that the new comment says the user asked to keep?

As the commit message says, this has no runtime effect at this commit.
NETIF_F_RXFCS is not in hw_features, so the expression always evaluates
to 0.

The follow-up patch "net: bcmgenet: add support for NETIF_F_RXFCS"
resolves this by the end of the series. It makes bcmgenet_set_features()
program CMD_CRC_FWD from NETIF_F_RXFCS. It also changes bcmgenet_desc_rx()
to trim only when crc_fwd_en is set and NETIF_F_RXFCS is not.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204230048.3554713-1-florian.fainelli%40broadcom.com

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

* Re: [PATCH net-next 2/2] net: bcmgenet: add support for NETIF_F_RXFCS
  2026-12-04 23:00 ` [PATCH net-next 2/2] net: bcmgenet: add support for NETIF_F_RXFCS Florian Fainelli
  2026-12-05 12:23   ` Nicolai Buchwitz
@ 2026-12-05 23:30   ` netdev-bot+sashiko
  1 sibling, 0 replies; 7+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 23:30 UTC (permalink / raw)
  To: florian.fainelli
  Cc: netdev, opendmb, nb, bcm-kernel-feedback-list, andrew+netdev,
	davem, edumazet, kuba, pabeni

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] If NETIF_F_RXFCS is changed on a running interface,
  bcmgenet_set_features()…
- [Low] net: bcmgenet: NETIF_F_RXCSUM stays reported active when
  NETIF_F_RXFCS is on

--

net: bcmgenet: add support for NETIF_F_RXFCS

This commit adds NETIF_F_RXFCS support to bcmgenet. CMD_CRC_FWD and
RBUF_SKIP_FCS are programmed from bcmgenet_set_features(), and the FCS
trim in bcmgenet_desc_rx() is skipped when the feature is on. Changing
rx-fcs on a running interface is refused with -EBUSY and is applied later
by a netdev_update_features() call in bcmgenet_close().

> diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> index 93a773d0ccf34..35a0fe425acdf 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
> @@ -814,14 +814,40 @@ static int bcmgenet_set_features(struct net_device *dev,
>  	u32 reg;
>  	int ret;
>  
> +	/* Frames already queued in the RX rings were written with the old FCS
> +	 * setting and cannot be told apart from new ones, so refuse a live
> +	 * change. The request stays in wanted_features and is applied by
> +	 * bcmgenet_close(). Re-applying the current features from open and
> +	 * resume does not change the flag and is not affected.
> +	 */
> +	if (netif_running(dev) && ((features ^ dev->features) & NETIF_F_RXFCS))
> +		return -EBUSY;

[Severity: Medium]
Does this block every other feature change on the device while an rx-fcs
request is pending?

The comment says the refused RXFCS bit stays in dev->wanted_features.
__netdev_update_features() rebuilds the candidate set from wanted_features
on every call and passes the whole set to ndo_set_features. On error it
leaves dev->features alone for every bit:

net/core/dev.c:__netdev_update_features() {
    ...
	if (dev->netdev_ops->ndo_set_features)
		err = dev->netdev_ops->ndo_set_features(dev, features);
	...
	if (unlikely(err < 0)) {
		netdev_err(dev,
			"set_features() failed (%d); wanted %pNF, left %pNF\n",
			err, &features, &dev->features);
		...
		return -1;
	}
    ...
}

So after "ethtool -K eth0 rx-fcs on" on a running eth0, every later update
carries the same RXFCS difference and gets -EBUSY here as well. That
includes user toggles such as "ethtool -K eth0 gro off", "sg off",
"rx off" and "tx off". It also includes updates the stack makes itself,
for example:

netif_disable_lro()
    dev->wanted_features &= ~NETIF_F_LRO;
    netdev_update_features(dev);

which runs on bridge enslavement or when IP forwarding is enabled, and the
upper/lower feature syncs.

None of these take effect until bcmgenet_close() runs, or until the
rx-fcs request is withdrawn. Each attempt logs "set_features() failed
(-16)" through netdev_err. The -1 return also makes
netdev_update_features() send a spurious NETDEV_FEAT_CHANGE.

The commit message says:

    so a change on a running
    interface is refused with -EBUSY.

Userspace never sees -EBUSY here. ethtool just reports requested and
active features that do not match.

Would it work better to pin NETIF_F_RXFCS to its current dev->features
value in an ndo_fix_features callback while netif_running()? Other bits
would still apply, no error would be logged, and the deferred change
would still be picked up by the netdev_update_features() call in
bcmgenet_close().

> +
>  	ret = clk_prepare_enable(priv->clk);
>  	if (ret)
>  		return ret;

[ ... ]

> @@ -3552,6 +3581,11 @@ static int bcmgenet_close(struct net_device *dev)
>  
>  	clk_disable_unprepare(priv->clk);
>  
> +	/* Apply a feature change, e.g. NETIF_F_RXFCS, that was refused while
> +	 * the interface was running. The device is not running anymore.
> +	 */
> +	netdev_update_features(dev);
> +
>  	return ret;
>  }

[ ... ]

> @@ -2461,12 +2487,15 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring,
>  		skb_reserve(skb, GENET_RSB_PAD);
>  		__skb_put(skb, len - GENET_RSB_PAD);
>  
> -		if (priv->crc_fwd_en) {
> +		/* Strip the FCS unless the user asked to receive it */
> +		if (priv->crc_fwd_en && !(dev->features & NETIF_F_RXFCS))
>  			skb_trim(skb, skb->len - ETH_FCS_LEN);
> -		}
>  
> -		/* Set up checksum offload */
> -		if (dev->features & NETIF_F_RXCSUM) {
> +		/* Set up checksum offload. The hardware checksum excludes the
> +		 * FCS, so it cannot be used when the FCS is passed up.
> +		 */
> +		if ((dev->features & NETIF_F_RXCSUM) &&
> +		    !(dev->features & NETIF_F_RXFCS)) {
>  			rx_csum = (__force __be16)(status->rx_csum & 0xffff);
>  			if (rx_csum) {
>  				skb->csum = (__force __wsum)ntohs(rx_csum);

[Severity: Low]
With rx-fcs on, this branch is never taken, so no frame is handed up
with CHECKSUM_COMPLETE. NETIF_F_RXCSUM is still set in dev->features,
though, so "ethtool -k" keeps reporting rx-checksumming: on while the
offload is in fact disabled for every received frame.

The core does not resolve this for the driver. netdev_fix_features()
only drops NETIF_F_LRO and NETIF_F_GRO_HW when NETIF_F_RXFCS is
requested and leaves NETIF_F_RXCSUM alone. bcmgenet_netdev_ops has no
ndo_fix_features, so nothing else clears it either.
Documentation/networking/netdev-features.rst says this kind of
dependency between features belongs in ndo_fix_features.

Reception still works because the stack verifies the checksum in
software. The feature state shown to userspace is wrong, and nothing
tells the user that turning on rx-fcs also costs them RX checksum
offload.

Could NETIF_F_RXCSUM be cleared in an ndo_fix_features callback
whenever NETIF_F_RXFCS is set? That keeps ethtool -k accurate. The bit
comes back from dev->wanted_features on its own once rx-fcs is turned
off, and the extra NETIF_F_RXFCS test in bcmgenet_desc_rx() can go
away. That callback could also be where the live NETIF_F_RXFCS change
is held back, instead of the -EBUSY in bcmgenet_set_features().

If you would rather keep the offload with rx-fcs on, is it practical
to fold the four trailing FCS bytes into skb->csum before setting
CHECKSUM_COMPLETE?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204230048.3554713-1-florian.fainelli%40broadcom.com

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

end of thread, other threads:[~2026-12-05 23:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 23:00 [PATCH net-next 0/2] net: bcmgenet: Support for NETIF_F_RXFCS Florian Fainelli
2026-12-04 23:00 ` [PATCH net-next 1/2] net: bcmgenet: keep FCS forwarding when exiting Wake-on-LAN Florian Fainelli
2026-12-05 12:16   ` Nicolai Buchwitz
2026-12-05 23:30   ` netdev-bot+sashiko
2026-12-04 23:00 ` [PATCH net-next 2/2] net: bcmgenet: add support for NETIF_F_RXFCS Florian Fainelli
2026-12-05 12:23   ` Nicolai Buchwitz
2026-12-05 23:30   ` netdev-bot+sashiko

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