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/2026…%40broadcom.com