* [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-04 23:00 ` [PATCH net-next 2/2] net: bcmgenet: add support for NETIF_F_RXFCS Florian Fainelli
1 sibling, 0 replies; 3+ 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] 3+ 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
1 sibling, 0 replies; 3+ 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] 3+ messages in thread