* [PATCH net-next 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
@ 2026-11-27 6:36 Birger Koblitz
2026-11-27 6:36 ` [PATCH net-next 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Birger Koblitz @ 2026-11-27 6:36 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: netdev, linux-usb, Benjamin Larsson, Birger Koblitz
The AX88179A-Chip family supports reception of the FCS
at the host. This is configured by enabling the AX_RX_CTL_DROPCRCERR
flag in the USB-adapters RX-controls. For AX88279-based adapters,
the flag has already been always set in order to receive
complete frames, however, the FCS is not necessarily usable, as it
is only part of the transferred up-to 8-byte padding area, and for
some frame-lengths only 2 of the 4 bytes of the FCS are transferred
to the host.
Note, that the AX_RX_CTL_DROPCRCERR flag has no influence on dropping
of corrupt frames already by the USB adapter, even corrupt frames
are always transferred to the host.
Add Add NETIF_F_RXFCS and NETIF_F_RXALL features for
the AX88179A and take a trailing FCS into account for MTU
verification when checking packet length in rx_fixup().
Also add code rx_fixup() in order to Count dropped packets and those
with incorrect checksum.
Suggested-by: Benjamin Larsson <benjamin.larsson@genexis.eu>
Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
---
Birger Koblitz (2):
net: usb: ax88179: Make receiving FCS on AX88179A configurable
net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
drivers/net/usb/ax88179_lib.c | 6 +++--
drivers/net/usb/ax88179a_devices.c | 46 +++++++++++++++++++++++++++++++++-----
2 files changed, 44 insertions(+), 8 deletions(-)
---
base-commit: eb6d6c80d35449c27471b1874f13066c09a8964d
change-id: 20261126-fcs-afccb4a76dd1
Best regards,
--
Birger Koblitz <mail@birger-koblitz.de>
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH net-next 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable 2026-11-27 6:36 [PATCH net-next 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz @ 2026-11-27 6:36 ` Birger Koblitz 2026-11-28 6:42 ` netdev-bot+sashiko 2026-11-28 17:54 ` Andrew Lunn 2026-11-27 6:36 ` [PATCH net-next 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz 2026-11-28 6:37 ` [PATCH net-next 0/2] " sashiko-bot 2 siblings, 2 replies; 8+ messages in thread From: Birger Koblitz @ 2026-11-27 6:36 UTC (permalink / raw) To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni Cc: netdev, linux-usb, Benjamin Larsson, Birger Koblitz Make reception of FCS on AX88179A configuration-dependent. In contrast to what the name suggests, AX_RX_CTL_DROPCRCERR actually instructs the MAC to leave the FCS attached to the end of the Ethernet frame when sent by the USB-adapter to the host. This was tested for AX88179A. For the older AX88179, the behaviour does not change. For AX88279-based adapters, the flag must be set in order to receive complete frames, however, the FCS is not necessarily usable, as it is only part of the transferred up-to 8-byte padding area, and for some frame-lengths only 2 of the 4 bytes of the FCS are transferred to the host. The AX_RX_CTL_DROPCRCERR flag has no influence on dropping of corrupt frames already by the USB adapter. Signed-off-by: Birger Koblitz <mail@birger-koblitz.de> --- drivers/net/usb/ax88179_lib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c index 821ee9cd8ded1b8f1e425bcef493fb175ed30376..85d774bf214f8d228d3828d15af6fbfda89421bd 100644 --- a/drivers/net/usb/ax88179_lib.c +++ b/drivers/net/usb/ax88179_lib.c @@ -356,10 +356,12 @@ void ax88179_set_multicast(struct net_device *net) data = dev->driver_priv; - rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR); + rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB); if (data->ip_align) rxctl |= AX_RX_CTL_IPE; - + if (net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) || + data->chip_version != AX_VERSION_AX88179A) + rxctl |= AX_RX_CTL_DROPCRCERR; if (net->flags & IFF_PROMISC) { rxctl |= AX_RX_CTL_PRO; } else if (net->flags & IFF_ALLMULTI || -- 2.47.3 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable 2026-11-27 6:36 ` [PATCH net-next 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz @ 2026-11-28 6:42 ` netdev-bot+sashiko 2026-11-28 17:54 ` Andrew Lunn 1 sibling, 0 replies; 8+ messages in thread From: netdev-bot+sashiko @ 2026-11-28 6:42 UTC (permalink / raw) To: mail Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev, linux-usb, benjamin.larsson Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 2 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] ax88179_set_multicast() (drivers/net/usb/ax88179_lib.c:362-364) treats NETIF_F_RXALL the same… - [Low] The commit is titled as making FCS reception 'configurable', but what it really does is fix a bug. - [Low] The new condition `data->chip_version != AX_VERSION_AX88179A` in ax88179_set_multicast() (drivers/net/usb/ax88179_lib.c:363) also… -- net: usb: ax88179: Make receiving FCS on AX88179A configurable With this commit, ax88179_set_multicast() no longer always sets AX_RX_CTL_DROPCRCERR. That bit keeps the FCS attached to received frames. On AX88179A it is now only set when NETIF_F_RXFCS or NETIF_F_RXALL is enabled. Other chip versions behave as before. > diff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c > index 821ee9cd8ded1..85d774bf214f8 100644 > --- a/drivers/net/usb/ax88179_lib.c > +++ b/drivers/net/usb/ax88179_lib.c > @@ -356,10 +356,12 @@ void ax88179_set_multicast(struct net_device *net) > > data = dev->driver_priv; > > - rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR); > + rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB); > if (data->ip_align) > rxctl |= AX_RX_CTL_IPE; > - > + if (net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) || [Severity: Medium] Should NETIF_F_RXALL by itself cause the FCS to be kept? NETIF_F_RXALL is about delivering frames with errors, such as a bad FCS. NETIF_F_RXFCS is the flag that tells the stack skbs end with the FCS. Other drivers keep the two separate. For example, e1000 trims the 4 bytes unless NETIF_F_RXFCS is set. This branch can't be reached in this patch alone, because hw_features doesn't include these bits yet. The follow-up commit "net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A" adds them to hw_features in ax88179a_bind(). It also copies the same mapping into ax88179a_set_features() and ax88179a_reset(): if (features & (NETIF_F_RXFCS | NETIF_F_RXALL)) rxctl |= AX_RX_CTL_DROPCRCERR; In that series, ax88179a_rx_fixup() only uses the flags to widen the MTU check: if (features & (NETIF_F_RXFCS | NETIF_F_RXALL)) fcs_trailer = ETH_FCS_LEN; After that check, it copies the full pkt_len without trimming: skb_put(ax_skb, pkt_len); memcpy(ax_skb->data, skb->data + (ax179_data->ip_align ? AX179A_RX_HW_PAD : 0), pkt_len); Take "ethtool -K <dev> rx-all on" with rx-fcs off. Wouldn't every frame then reach the stack with 4 extra trailing bytes, and nothing to show that they are an FCS? Could AX_RX_CTL_DROPCRCERR depend only on NETIF_F_RXFCS? Another option is to trim ETH_FCS_LEN in ax88179a_rx_fixup() when only NETIF_F_RXALL is set. > + data->chip_version != AX_VERSION_AX88179A) [Severity: Low] This isn't a bug, but the subject says FCS reception is being made "configurable", and the change also fixes existing behaviour. Before this patch, AX_RX_CTL_DROPCRCERR was always set on AX88179A, and ax88179a_rx_fixup() doesn't trim the FCS. So every frame received on AX88179A/AX88772D reached the stack with the 4-byte FCS still attached. Could the commit message say this directly? Could it also add a Fixes: tag for 7d573278f9a5 ("ax88179_178a: Add HW support for AX179A-based chips")? That commit is where DROPCRCERR became always-on for these chips. It was merged to net-next on 2026-11-14 and is probably not in a released kernel yet, so this is mostly for traceability. The commit message also doesn't mention that the new chip_version test affects the AX88772D. [Severity: Low] Does the chip_version != AX_VERSION_AX88179A test also change behaviour on the AX88772D? ax88179_lib.h has: AX_VERSION_AX88179A = 0x6, /* Also AX88772D */ ax88179a_bind() tells the two chips apart only through is_ax88772d: if (ax179_data->chip_version == AX_VERSION_AX88179A) { if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x300) ax179_data->is_ax88772d = 1; } So AX_RX_CTL_DROPCRCERR is now cleared on AX88772D as well. The commit message says this was only tested on AX88179A. According to the comment in ax88179a_bind(), AX88279 needs the same bit for correct RX URB framing. The follow-up commit "net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A" keeps this behaviour. ax88179a_reset() only forces DROPCRCERR for AX88279, and RXFCS/RXALL are advertised on AX88772D too. Has this been tested on an AX88772D, or should that chip be excluded using is_ax88772d? Either way, could the commit message mention the AX88772D? > + rxctl |= AX_RX_CTL_DROPCRCERR; > if (net->flags & IFF_PROMISC) { > rxctl |= AX_RX_CTL_PRO; > } else if (net->flags & IFF_ALLMULTI || [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127-fcs-v1-0-0c4ede015bf5%40birger-koblitz.de ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable 2026-11-27 6:36 ` [PATCH net-next 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz 2026-11-28 6:42 ` netdev-bot+sashiko @ 2026-11-28 17:54 ` Andrew Lunn 1 sibling, 0 replies; 8+ messages in thread From: Andrew Lunn @ 2026-11-28 17:54 UTC (permalink / raw) To: Birger Koblitz Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-usb, Benjamin Larsson On Fri, Nov 27, 2026 at 07:36:26AM +0100, Birger Koblitz wrote: > Make reception of FCS on AX88179A configuration-dependent. > > In contrast to what the name suggests, AX_RX_CTL_DROPCRCERR > actually instructs the MAC to leave the FCS attached to the end of the > Ethernet frame when sent by the USB-adapter to the host. Do you have any idea where the name comes from? Does it makes sense to change it to something which indicates what it actually does? Andrew ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A 2026-11-27 6:36 [PATCH net-next 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz 2026-11-27 6:36 ` [PATCH net-next 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz @ 2026-11-27 6:36 ` Birger Koblitz 2026-11-28 6:37 ` sashiko-bot 2026-11-28 6:42 ` netdev-bot+sashiko 2026-11-28 6:37 ` [PATCH net-next 0/2] " sashiko-bot 2 siblings, 2 replies; 8+ messages in thread From: Birger Koblitz @ 2026-11-27 6:36 UTC (permalink / raw) To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni Cc: netdev, linux-usb, Benjamin Larsson, Birger Koblitz Add NETIF_F_RXFCS and NETIF_F_RXALL features for the AX88179A and take a trailing FCS into account for MTU verification when checking packet length in rx_fixup(). Count dropped packets and those with incorrect checksum. Suggested-by: Benjamin Larsson <benjamin.larsson@genexis.eu> Signed-off-by: Birger Koblitz <mail@birger-koblitz.de> --- drivers/net/usb/ax88179a_devices.c | 46 +++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c index 69095110e70435806a99274c50d79e86016ec9a0..a6b35ad7d5404068a71507bf5f981d32c455d63d 100644 --- a/drivers/net/usb/ax88179a_devices.c +++ b/drivers/net/usb/ax88179a_devices.c @@ -717,10 +717,12 @@ static int ax88179a_mii_ioctl(struct net_device *net, struct ifreq *rq, int cmd) static int ax88179a_set_features(struct net_device *net, netdev_features_t features) { struct usbnet *dev = netdev_priv(net); + struct ax88179_data *ax179_data; netdev_features_t changed; int ret; u8 tmp; + ax179_data = dev->driver_priv; changed = net->features ^ features; ret = ax88179_set_features(net, features); @@ -780,6 +782,18 @@ static int ax88179a_set_features(struct net_device *net, netdev_features_t featu if (ret < 0) return ret; } + + if (changed & (NETIF_F_RXFCS | NETIF_F_RXALL)) { + u16 rxctl = READ_ONCE(ax179_data->rxctl); + + if (features & (NETIF_F_RXFCS | NETIF_F_RXALL)) + rxctl |= AX_RX_CTL_DROPCRCERR; + else + rxctl &= ~AX_RX_CTL_DROPCRCERR; + WRITE_ONCE(ax179_data->rxctl, rxctl); + ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl); + } + return 0; } @@ -852,8 +866,8 @@ static int ax88179a_bind(struct usbnet *dev, struct usb_interface *intf) ax179_data->fw_version[2], ax179_data->fw_version[3]); /* The AX88279 requires both the AX_RX_CTL_IPE and AX_RX_CTL_DROPCRCERR - * bits set in AX_RX_CTL for creating correct RX-URBs. AX_RX_CTL_DROPCRCERR - * is anyway set for all chips, make sure AX_RX_CTL_IPE is set via ip_align. + * bits set in AX_RX_CTL for creating correct RX-URBs. Make sure + * AX_RX_CTL_IPE is set via ip_align. * Also configure eeprom access parameters. */ if (ax179_data->chip_version == AX_VERSION_AX88279) { @@ -894,6 +908,11 @@ static int ax88179a_bind(struct usbnet *dev, struct usb_interface *intf) dev->net->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM | NETIF_F_TSO; + if (ax179_data->chip_version == AX_VERSION_AX88179A) { + dev->net->hw_features |= NETIF_F_RXFCS | NETIF_F_RXALL; + dev->net->vlan_features |= NETIF_F_RXFCS | NETIF_F_RXALL; + } + netif_set_tso_max_size(dev->net, 16384); /* Enable Transmission of Link Speed byte in interrupt URB */ @@ -1039,9 +1058,14 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb) pkt_end = 0; while (pkt_cnt--) { u64 pkt_desc = get_unaligned_le64(pkt_desc_ptr); + long features = dev->net->features; u32 pkt_len_plus_padd; + u32 fcs_trailer = 0; u32 pkt_len; + if (features & (NETIF_F_RXFCS | NETIF_F_RXALL)) + fcs_trailer = ETH_FCS_LEN; + pkt_len = FIELD_GET(AX179A_RX_PD_LEN, pkt_desc); pkt_len -= (ax179_data->ip_align ? 2 : 0); pkt_len_plus_padd = ((pkt_len + 7 + (ax179_data->ip_align ? 2 : 0)) & 0x7FFF8); @@ -1050,10 +1074,18 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb) if (pkt_end > hdr_off || (pkt_cnt == 0 && pkt_end != hdr_off)) goto err; - if (pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK) || - pkt_len > (dev->hard_mtu + AX179A_RX_HW_PAD) || pkt_len < 2 + ETH_HLEN) { + if (((pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK)) && + !(features & NETIF_F_RXALL)) || + pkt_len > dev->hard_mtu + AX179A_RX_HW_PAD + fcs_trailer || + pkt_len < 2 + ETH_HLEN) { skb_pull(skb, pkt_len_plus_padd); + if (pkt_desc & AX179A_RX_PD_DROP) + dev->net->stats.rx_dropped++; + + if (!(pkt_desc & AX179A_RX_PD_RX_OK)) + dev->net->stats.rx_crc_errors++; + /* Next RX Packet Descriptor */ pkt_desc_ptr++; continue; @@ -1216,12 +1248,14 @@ static int ax88179a_reset(struct usbnet *dev) ax88179_write_u8(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, *tmp); /* Configure RX control register => start operation */ - rxctl = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_START | AX_RX_CTL_AP | - AX_RX_CTL_AMALL | AX_RX_CTL_AB; + rxctl = AX_RX_CTL_START | AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; if (ax179_data->ip_align) rxctl |= AX_RX_CTL_IPE; if (dev->net->flags & IFF_PROMISC) rxctl |= AX_RX_CTL_PRO; + if (dev->net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) || + ax179_data->chip_version == AX_VERSION_AX88279) + rxctl |= AX_RX_CTL_DROPCRCERR; WRITE_ONCE(ax179_data->rxctl, rxctl); ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl); -- 2.47.3 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A 2026-11-27 6:36 ` [PATCH net-next 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz @ 2026-11-28 6:37 ` sashiko-bot 2026-11-28 6:42 ` netdev-bot+sashiko 1 sibling, 0 replies; 8+ messages in thread From: sashiko-bot @ 2026-11-28 6:37 UTC (permalink / raw) To: Birger Koblitz; +Cc: linux-usb Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [High] net: usb: ax88179: 32-bit truncation of features in ax88179a_rx_fixup() - [Medium] net: usb: ax88179: unwanted FCS appended on RXALL in ax88179a_rx_fixup() - [Medium] net: usb: ax88179: unsynchronized rxctl update in ax88179a_set_features() - [Low] net: usb: ax88179: incomplete CRC error stats in ax88179a_rx_fixup() -- commit 1060139744fbd9f7c43f8f37047d38dafe16412f Author: Birger Koblitz <mail@birger-koblitz.de> net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A This commit adds NETIF_F_RXFCS and NETIF_F_RXALL support for AX88179A, adjusts the RX length check for the trailing FCS, and updates RX drop and CRC error statistics in ax88179a_rx_fixup(). > diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c > index 69095110e7043..a6b35ad7d5404 100644 > --- a/drivers/net/usb/ax88179a_devices.c > +++ b/drivers/net/usb/ax88179a_devices.c > @@ -717,10 +717,12 @@ static int ax88179a_mii_ioctl(struct net_device *net, struct ifreq *rq, int cmd) > static int ax88179a_set_features(struct net_device *net, netdev_features_t features) > { > struct usbnet *dev = netdev_priv(net); > + struct ax88179_data *ax179_data; > netdev_features_t changed; > int ret; > u8 tmp; > > + ax179_data = dev->driver_priv; > changed = net->features ^ features; > > ret = ax88179_set_features(net, features); > @@ -780,6 +782,18 @@ static int ax88179a_set_features(struct net_device *net, netdev_features_t featu > if (ret < 0) > return ret; > } > + > + if (changed & (NETIF_F_RXFCS | NETIF_F_RXALL)) { > + u16 rxctl = READ_ONCE(ax179_data->rxctl); > + > + if (features & (NETIF_F_RXFCS | NETIF_F_RXALL)) > + rxctl |= AX_RX_CTL_DROPCRCERR; > + else > + rxctl &= ~AX_RX_CTL_DROPCRCERR; > + WRITE_ONCE(ax179_data->rxctl, rxctl); > + ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl); > + } > + > return 0; > } [Severity: Medium] Can this unlocked update to ax179_data->rxctl and AX_RX_CTL race with ax88179_set_multicast() and ax88179a_mac_link_up()? __netdev_update_features() calls ndo_set_features() before assigning net->features = features, while ax88179_set_multicast() runs under netif_addr_lock_bh(net) without rtnl_lock and rebuilds rxctl from net->features: CPU0 CPU1 __netdev_update_features() ax88179a_set_features() rxctl |= AX_RX_CTL_DROPCRCERR WRITE_ONCE(ax179_data->rxctl, ...) ax88179_write_u16(..., AX_RX_CTL) dev_mc_add() ax88179_set_multicast() reads old net->features WRITE_ONCE(data->rxctl, rxctl) ax88179_write_cmd_async(...) <-- reverts AX_RX_CTL_DROPCRCERR net->features = features If ax88179_set_multicast() instead runs between READ_ONCE() and WRITE_ONCE() in ax88179a_set_features(), ax88179a_set_features() overwrites the new multicast bits in rxctl. In addition, ax88179a_mac_link_up() runs from the phylink workqueue under ax179_data->medium_status_mutex without rtnl_lock, temporarily writing AX_RX_CTL_STOP to AX_RX_CTL before restoring ax179_data->rxctl, so an unsynchronized ax88179_write_u16() here can re-enable RX in the middle of link configuration. [ ... ] > @@ -1039,9 +1058,14 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb) > pkt_end = 0; > while (pkt_cnt--) { > u64 pkt_desc = get_unaligned_le64(pkt_desc_ptr); > + long features = dev->net->features; > u32 pkt_len_plus_padd; > + u32 fcs_trailer = 0; > u32 pkt_len; > > + if (features & (NETIF_F_RXFCS | NETIF_F_RXALL)) > + fcs_trailer = ETH_FCS_LEN; [Severity: High] Does storing dev->net->features in a long truncate away NETIF_F_RXFCS and NETIF_F_RXALL on 32-bit architectures? netdev_features_t is u64, with NETIF_F_RXFCS at bit 43 and NETIF_F_RXALL at bit 44. On 32-bit platforms a long is 32 bits, so features never has either bit set: fcs_trailer remains 0 even though AX_RX_CTL_DROPCRCERR causes the hardware to append the 4-byte FCS, dropping full-MTU frames as oversized and still discarding errored frames when NETIF_F_RXALL is enabled. Declaring features as netdev_features_t avoids the truncation. [Severity: Medium] When NETIF_F_RXALL is enabled without NETIF_F_RXFCS, does this deliver an unwanted 4-byte FCS at the end of every received skb? Setting AX_RX_CTL_DROPCRCERR for NETIF_F_RXALL causes the AX88179A to append the 4-byte FCS to received frames, and ax88179a_rx_fixup() copies all pkt_len bytes into ax_skb without stripping ETH_FCS_LEN when NETIF_F_RXFCS is off. > pkt_len = FIELD_GET(AX179A_RX_PD_LEN, pkt_desc); > pkt_len -= (ax179_data->ip_align ? 2 : 0); > pkt_len_plus_padd = ((pkt_len + 7 + (ax179_data->ip_align ? 2 : 0)) & 0x7FFF8); > @@ -1050,10 +1074,18 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb) > if (pkt_end > hdr_off || (pkt_cnt == 0 && pkt_end != hdr_off)) > goto err; > > - if (pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK) || > - pkt_len > (dev->hard_mtu + AX179A_RX_HW_PAD) || pkt_len < 2 + ETH_HLEN) { > + if (((pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK)) && > + !(features & NETIF_F_RXALL)) || > + pkt_len > dev->hard_mtu + AX179A_RX_HW_PAD + fcs_trailer || > + pkt_len < 2 + ETH_HLEN) { > skb_pull(skb, pkt_len_plus_padd); > > + if (pkt_desc & AX179A_RX_PD_DROP) > + dev->net->stats.rx_dropped++; > + > + if (!(pkt_desc & AX179A_RX_PD_RX_OK)) > + dev->net->stats.rx_crc_errors++; > + > /* Next RX Packet Descriptor */ > pkt_desc_ptr++; > continue; [Severity: Low] Should CRC errors also increment dev->net->stats.rx_errors and be counted when NETIF_F_RXALL is enabled? Because ax88179a_info sets FLAG_MULTI_PACKET and ax88179a_rx_fixup() skips bad sub-packets with continue before returning 1, usbnet's rx_process() does not increment dev->net->stats.rx_errors for them, leaving rx_crc_errors unreflected in the total rx_errors count. Also, because the check is inside the !(features & NETIF_F_RXALL) discard branch, frames with bad CRC received while NETIF_F_RXALL is enabled are not counted in rx_crc_errors at all. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261127-fcs-v1-0-0c4ede015bf5@birger-koblitz.de?part=2 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A 2026-11-27 6:36 ` [PATCH net-next 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz 2026-11-28 6:37 ` sashiko-bot @ 2026-11-28 6:42 ` netdev-bot+sashiko 1 sibling, 0 replies; 8+ messages in thread From: netdev-bot+sashiko @ 2026-11-28 6:42 UTC (permalink / raw) To: mail Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev, linux-usb, benjamin.larsson Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 4 · Low: 3 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] In ax88179a_rx_fixup() (drivers/net/usb/ax88179a_devices.c:1061) the patch copies the 64-bit… - [Medium] Enabling only NETIF_F_RXALL, with NETIF_F_RXFCS off, also turns on FCS appending. - [Medium] The new error accounting in ax88179a_rx_fixup() (lines 1083-1087) breaks the rtnl_link_stats64 rules. - [Medium] The new RXFCS/RXALL block in ax88179a_set_features() (lines 786-795) does an unlocked read-modify-write of ax179_data->rxctl… - [Low] The two functions that rebuild AX_RX_CTL use different chip- version tests to force AX_RX_CTL_DROPCRCERR. - [Low] In ax88179a_set_features() the new RXFCS/RXALL block ignores the return value of `ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2,… - [Low] The new AX_RX_CTL write in ax88179a_set_features() (line 794) writes the cached rxctl, which always has AX_RX_CTL_START set,… -- net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A This commit advertises NETIF_F_RXFCS and NETIF_F_RXALL on the AX88179A. It makes AX_RX_CTL_DROPCRCERR (FCS append) depend on those features. It also allows for a trailing FCS in the ax88179a_rx_fixup() length check and counts dropped and errored frames. > diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c > index 69095110e7043..a6b35ad7d5404 100644 > --- a/drivers/net/usb/ax88179a_devices.c > +++ b/drivers/net/usb/ax88179a_devices.c [ ... ] > @@ -780,6 +782,18 @@ static int ax88179a_set_features(struct net_device *net, netdev_features_t featu > if (ret < 0) > return ret; > } > + > + if (changed & (NETIF_F_RXFCS | NETIF_F_RXALL)) { > + u16 rxctl = READ_ONCE(ax179_data->rxctl); > + > + if (features & (NETIF_F_RXFCS | NETIF_F_RXALL)) > + rxctl |= AX_RX_CTL_DROPCRCERR; [Severity: Medium] Should enabling only rx-all also turn on FCS appending here? The same coupling is in ax88179a_reset() and ax88179_set_multicast(). The earlier commit in this series, "net: usb: ax88179: Make receiving FCS on AX88179A configurable", says this bit makes the MAC keep the FCS. It also says the bit "has no influence on dropping of corrupt frames". So rx-all does not seem to need it. ax88179a_rx_fixup() expects the FCS under RXALL, but never trims it when NETIF_F_RXFCS is off: skb_put(ax_skb, pkt_len); With "ethtool -K <dev> rx-all on" and rx-fcs off, won't every frame reach the stack with 4 trailing FCS bytes? netdev-features.rst says rx-fcs is the feature that asks the NIC to append the FCS. It says rx-all only asks for errored frames to be received. Other RXALL implementations such as e1000e keep the two features independent. Bridged or non-IP frames would carry the stale FCS as payload. > + else > + rxctl &= ~AX_RX_CTL_DROPCRCERR; > + WRITE_ONCE(ax179_data->rxctl, rxctl); > + ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl); [Severity: Medium] Is this read-modify-write of ax179_data->rxctl serialized against the other paths that write AX_RX_CTL? ax88179a_mac_link_up() runs from the phylink resolve work and only holds medium_status_mutex: ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, READ_ONCE(ax179_data->rxctl)); It can read rxctl before this block updates it and write after the hardware write here. The MAC then keeps the old DROPCRCERR state while dev->features shows the new one. ax88179_set_multicast() also rebuilds rxctl and calls WRITE_ONCE(). If that happens between the READ_ONCE() and WRITE_ONCE() here, this block writes back stale PRO/AMALL/AM bits and the promiscuous or multicast change is lost. Also, __netdev_update_features() calls ndo_set_features() before it updates dev->features. A set_multicast in that window computes DROPCRCERR from the old features and undoes the new setting. Could this block share a lock with those paths? [Severity: Low] The return value of ax88179_write_u16() is ignored and the function returns 0. If the control transfer fails, the core still commits the new RXFCS/RXALL bits to dev->features. ax179_data->rxctl also holds the new value, but the MAC keeps the old DROPCRCERR setting. Should this check for ret < 0 and return it, like the VLAN control accesses earlier in this function? [Severity: Low] The cached rxctl always has AX_RX_CTL_START set, so this write restarts the receiver. ax88179a_mac_link_up() deliberately stops RX while it reprograms the speed-dependent registers: /* Stop RX/TX for link configuration */ ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, AX_RX_CTL_STOP); ax88179_write_u8(dev, AX_ACCESS_MAC, AX88179A_MAC_PATH, 1, 0); It restores AX_RX_CTL only at the end. set_features is not serialized with that sequence. Can it restart the receiver while the bulk-in setup is only partly programmed? ax88179a_stop() writes 0 to AX_RX_CTL but leaves START set in ax179_data->rxctl. Toggling rx-fcs or rx-all on a down interface then turns the MAC receiver back on until the next ax88179a_reset(). ax88179_set_multicast() skips devices that are not IFF_UP, but this path has no such check. > + } > + > return 0; > } [ ... ] > @@ -1039,9 +1058,14 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb) > pkt_end = 0; > while (pkt_cnt--) { > u64 pkt_desc = get_unaligned_le64(pkt_desc_ptr); > + long features = dev->net->features; [Severity: Medium] Does this truncate the feature mask on 32-bit kernels? netdev_features_t is u64. NETIF_F_RXFCS_BIT and NETIF_F_RXALL_BIT are bits 43 and 44 in include/linux/netdev_features.h, and a 32-bit long cannot hold them. So both this check and the !(features & NETIF_F_RXALL) test below would always see the features as off: if (features & (NETIF_F_RXFCS | NETIF_F_RXALL)) fcs_trailer = ETH_FCS_LEN; ax88179a_set_features(), ax88179a_reset() and ax88179_set_multicast() program the hardware from the full u64 net->features. So the MAC appends the FCS while rx_fixup() assumes it does not. On a 32-bit host rx-all would never deliver errored frames. Frames near the maximum MTU that carry the extra 4 FCS bytes would exceed hard_mtu + AX179A_RX_HW_PAD and be dropped without being counted. Should this local be netdev_features_t, perhaps read with READ_ONCE()? > u32 pkt_len_plus_padd; > + u32 fcs_trailer = 0; > u32 pkt_len; > > + if (features & (NETIF_F_RXFCS | NETIF_F_RXALL)) > + fcs_trailer = ETH_FCS_LEN; > + > pkt_len = FIELD_GET(AX179A_RX_PD_LEN, pkt_desc); > pkt_len -= (ax179_data->ip_align ? 2 : 0); > pkt_len_plus_padd = ((pkt_len + 7 + (ax179_data->ip_align ? 2 : 0)) & 0x7FFF8); > @@ -1050,10 +1074,18 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb) > if (pkt_end > hdr_off || (pkt_cnt == 0 && pkt_end != hdr_off)) > goto err; > > - if (pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK) || > - pkt_len > (dev->hard_mtu + AX179A_RX_HW_PAD) || pkt_len < 2 + ETH_HLEN) { > + if (((pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK)) && > + !(features & NETIF_F_RXALL)) || > + pkt_len > dev->hard_mtu + AX179A_RX_HW_PAD + fcs_trailer || > + pkt_len < 2 + ETH_HLEN) { > skb_pull(skb, pkt_len_plus_padd); > > + if (pkt_desc & AX179A_RX_PD_DROP) > + dev->net->stats.rx_dropped++; > + > + if (!(pkt_desc & AX179A_RX_PD_RX_OK)) > + dev->net->stats.rx_crc_errors++; [Severity: Medium] Should rx_errors be incremented along with rx_crc_errors? The rtnl_link_stats64 comment in include/uapi/linux/if_link.h says rx_errors "must include events counted by @rx_length_errors, @rx_crc_errors". rx_fixup() returns 1 on this path, so usbnet's rx_process() does not add to rx_errors either. These counters are only updated inside the drop branch. With NETIF_F_RXALL on, frames with RX_OK clear or DROP set skip this branch and go up the stack. Should they still be counted in rx_crc_errors? Frames dropped only by the length checks (pkt_len > hard_mtu + ... or pkt_len < 2 + ETH_HLEN) don't update any counter, such as rx_length_errors. That doesn't match the commit message, which says dropped packets are counted. Is every !RX_OK frame actually a CRC error? The same frame can also be counted in both rx_dropped and rx_crc_errors. The commit message says: Count dropped packets and those with incorrect checksum. Would "incorrect FCS" be clearer here, since "checksum" suggests L3/L4 checksums? > + > /* Next RX Packet Descriptor */ > pkt_desc_ptr++; > continue; > @@ -1216,12 +1248,14 @@ static int ax88179a_reset(struct usbnet *dev) > ax88179_write_u8(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, *tmp); > > /* Configure RX control register => start operation */ > - rxctl = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_START | AX_RX_CTL_AP | > - AX_RX_CTL_AMALL | AX_RX_CTL_AB; > + rxctl = AX_RX_CTL_START | AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; > if (ax179_data->ip_align) > rxctl |= AX_RX_CTL_IPE; > if (dev->net->flags & IFF_PROMISC) > rxctl |= AX_RX_CTL_PRO; > + if (dev->net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) || > + ax179_data->chip_version == AX_VERSION_AX88279) > + rxctl |= AX_RX_CTL_DROPCRCERR; [Severity: Low] This forces AX_RX_CTL_DROPCRCERR only when chip_version is AX_VERSION_AX88279. ax88179_set_multicast() uses a different test: if (net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) || data->chip_version != AX_VERSION_AX88179A) rxctl |= AX_RX_CTL_DROPCRCERR; ax88179a_bind() stores whatever AX_CHIP_STATUS reports and does not reject unknown values. For a chip version other than AX88179A or AX88279, reset() would clear the FCS-append bit and every later set_rx_mode would set it again. Such devices don't advertise RXFCS, so rx_fixup() would not expect the FCS. No current hardware is known to report such a version. Could both sites share one predicate or helper? > WRITE_ONCE(ax179_data->rxctl, rxctl); > ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl); > -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127-fcs-v1-0-0c4ede015bf5%40birger-koblitz.de ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A 2026-11-27 6:36 [PATCH net-next 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz 2026-11-27 6:36 ` [PATCH net-next 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz 2026-11-27 6:36 ` [PATCH net-next 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz @ 2026-11-28 6:37 ` sashiko-bot 2 siblings, 0 replies; 8+ messages in thread From: sashiko-bot @ 2026-11-28 6:37 UTC (permalink / raw) To: Birger Koblitz; +Cc: linux-usb Sashiko has finished reviewing this 2-patch series: - Patch 1: no issues found. - Patch 2 ("net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F..."): 4 potential issues (1 High, 2 Medium, 1 Low) A detailed review has been sent as a separate reply to patch 2. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261127-fcs-v1-0-0c4ede015bf5@birger-koblitz.de ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-11-28 17:54 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-27 6:36 [PATCH net-next 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz 2026-11-27 6:36 ` [PATCH net-next 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz 2026-11-28 6:42 ` netdev-bot+sashiko 2026-11-28 17:54 ` Andrew Lunn 2026-11-27 6:36 ` [PATCH net-next 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz 2026-11-28 6:37 ` sashiko-bot 2026-11-28 6:42 ` netdev-bot+sashiko 2026-11-28 6:37 ` [PATCH net-next 0/2] " sashiko-bot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox