* [PATCH net-next v3 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
@ 2026-12-01 17:17 Birger Koblitz
2026-12-01 17:17 ` [PATCH net-next v3 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz
2026-12-01 17:17 ` [PATCH net-next v3 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
0 siblings, 2 replies; 5+ messages in thread
From: Birger Koblitz @ 2026-12-01 17:17 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>
---
Changes in v3:
- In ax88179_set_multicast() make sure the behaviour for the older
AX88179 devices is not changed
- Improve error checking in set_features()
- Improve lower packet length check to take FCS into account
- Link to v2: https://lore.kernel.org/r/20261129-fcs-v2-0-f60d6b105a15@birger-koblitz.de
Changes in v2:
- Do not clobber rxctl in ax88179_set_multicast(): read and update it
- Use netdev_features_t for features in rx_fixup()
- Do not include FCS trailer when NETIF_F_RXFCS not set
- Count rx_errors together with crc_errors as per definition
- Link to v1: https://lore.kernel.org/r/20261127-fcs-v1-0-0c4ede015bf5@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 | 14 +++++++---
drivers/net/usb/ax88179a_devices.c | 52 +++++++++++++++++++++++++++++++++-----
2 files changed, 57 insertions(+), 9 deletions(-)
---
base-commit: eb6d6c80d35449c27471b1874f13066c09a8964d
change-id: 20261126-fcs-afccb4a76dd1
Best regards,
--
Birger Koblitz <mail@birger-koblitz.de>
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH net-next v3 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable 2026-12-01 17:17 [PATCH net-next v3 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz @ 2026-12-01 17:17 ` Birger Koblitz 2026-12-02 17:17 ` sashiko-bot 2026-12-01 17:17 ` [PATCH net-next v3 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz 1 sibling, 1 reply; 5+ messages in thread From: Birger Koblitz @ 2026-12-01 17:17 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 as well as on the AX88772D, which behaves the same as the AX88179A in respect of this flag, as this refers to MAC functionality and the AX88772D is merely a AX88179A with a different integrated 100Mbit PHY. 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. Fixes: 7d573278f9a5 ("ax88179_178a: Add HW support for AX179A-based chips") Signed-off-by: Birger Koblitz <mail@birger-koblitz.de> --- drivers/net/usb/ax88179_lib.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c index 821ee9cd8ded1b8f1e425bcef493fb175ed30376..353b3a74793084085c42c1068caf5922e0681ad3 100644 --- a/drivers/net/usb/ax88179_lib.c +++ b/drivers/net/usb/ax88179_lib.c @@ -352,14 +352,22 @@ void ax88179_set_multicast(struct net_device *net) struct usbnet *dev = netdev_priv(net); u8 *m_filter = ((u8 *)dev->data); struct ax88179_data *data; - u16 rxctl = 0; + u16 rxctl; data = dev->driver_priv; - rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR); + if (data->chip_version >= AX_VERSION_AX88179A) { + rxctl = READ_ONCE(data->rxctl); + rxctl &= ~(AX_RX_CTL_IPE | AX_RX_CTL_DROPCRCERR | AX_RX_CTL_PRO | + AX_RX_CTL_AMALL | AX_RX_CTL_AM); + } else { + rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR); + } 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] 5+ messages in thread
* Re: [PATCH net-next v3 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable 2026-12-01 17:17 ` [PATCH net-next v3 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz @ 2026-12-02 17:17 ` sashiko-bot 0 siblings, 0 replies; 5+ messages in thread From: sashiko-bot @ 2026-12-02 17:17 UTC (permalink / raw) To: Birger Koblitz; +Cc: linux-usb Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] net: usb: ax88179: Fixes tag cites 7d573278f9a5 instead of 192c7b09608a -- commit 79a991d773df39840a0525f70cb798b14289211f Author: Birger Koblitz <mail@birger-koblitz.de> > net: usb: ax88179: Make receiving FCS on AX88179A configurable > > 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 as well as on the AX88772D, which behaves the same > as the AX88179A in respect of this flag, as this refers to MAC > functionality and the AX88772D is merely a AX88179A with a different > integrated 100Mbit PHY. > 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. > > Fixes: 7d573278f9a5 ("ax88179_178a: Add HW support for AX179A-based chips") > Signed-off-by: Birger Koblitz <mail@birger-koblitz.de> [Severity: Low] Should the Fixes tag reference 192c7b09608a ("ax88179_178a: Add AX179A/AX279 multicast configuration") instead of 7d573278f9a5 ("ax88179_178a: Add HW support for AX179A-based chips")? Commit 192c7b09608a wired ax88179_set_multicast() to ax88179a_netdev_ops and added the AX_RX_CTL_DROPCRCERR setup in ax88179_set_multicast() modified here. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261201-fcs-v3-0-6c355917b17e@birger-koblitz.de?part=1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next v3 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A 2026-12-01 17:17 [PATCH net-next v3 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz 2026-12-01 17:17 ` [PATCH net-next v3 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz @ 2026-12-01 17:17 ` Birger Koblitz 2026-12-02 17:17 ` sashiko-bot 1 sibling, 1 reply; 5+ messages in thread From: Birger Koblitz @ 2026-12-01 17:17 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 FCS. Fixes: 7d573278f9a5 ("ax88179_178a: Add HW support for AX179A-based chips") Suggested-by: Benjamin Larsson <benjamin.larsson@genexis.eu> Signed-off-by: Birger Koblitz <mail@birger-koblitz.de> --- drivers/net/usb/ax88179a_devices.c | 52 +++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c index 69095110e70435806a99274c50d79e86016ec9a0..04d8f37bc7ebef3f2e530cb41f403dca9d0dd7d7 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,20 @@ 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); + ret = ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl); + if (ret < 0) + return ret; + } + return 0; } @@ -852,8 +868,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 +910,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 +1060,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); + netdev_features_t 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 +1076,19 @@ 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 + fcs_trailer) { 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++; + dev->net->stats.rx_errors++; + } /* Next RX Packet Descriptor */ pkt_desc_ptr++; continue; @@ -1063,6 +1098,9 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb) if (!ax_skb) goto err; + if (!(features & NETIF_F_RXFCS)) + pkt_len -= fcs_trailer; + skb_put(ax_skb, pkt_len); memcpy(ax_skb->data, skb->data + (ax179_data->ip_align ? AX179A_RX_HW_PAD : 0), pkt_len); @@ -1216,12 +1254,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] 5+ messages in thread
* Re: [PATCH net-next v3 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A 2026-12-01 17:17 ` [PATCH net-next v3 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz @ 2026-12-02 17:17 ` sashiko-bot 0 siblings, 0 replies; 5+ messages in thread From: sashiko-bot @ 2026-12-02 17:17 UTC (permalink / raw) To: Birger Koblitz; +Cc: linux-usb Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] net: usb: ax88179: unsynchronized rxctl update in ax88179a_set_features() - [Medium] net: usb: ax88179: FCS stripping race on features in ax88179a_rx_fixup() - [Medium] net: usb: ax88179: bad-FCS frames skip stats and checksum check on RXALL - [Low] net: usb: ax88179: ax88179a_set_features() enables RX while stopped -- commit 38bd5184999fcc79ca797c6f439fd670ad6ab639 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 chips, adjusts RX length validation and FCS stripping in ax88179a_rx_fixup(), and updates RX drop and CRC error counters. > diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c > index 69095110e7043..04d8f37bc7ebe 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,20 @@ 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); > + ret = ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl); > + if (ret < 0) > + return ret; > + } > + > return 0; > } [Severity: Medium] Can this unlocked update to ax179_data->rxctl and AX_RX_CTL race with ax88179_set_multicast()? __netdev_update_features() invokes ndo_set_features before updating net->features, while ax88179_set_multicast() runs in BH context under netif_addr_lock_bh(net) without rtnl_lock and recomputes AX_RX_CTL_DROPCRCERR from net->features: drivers/net/usb/ax88179_lib.c:ax88179_set_multicast() { ... if (data->chip_version >= AX_VERSION_AX88179A) { rxctl = READ_ONCE(data->rxctl); rxctl &= ~(AX_RX_CTL_IPE | AX_RX_CTL_DROPCRCERR | AX_RX_CTL_PRO | AX_RX_CTL_AMALL | AX_RX_CTL_AM); } else { rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR); } 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; ... WRITE_ONCE(data->rxctl, rxctl); ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &data->rxctl); } When ax88179_set_multicast() runs while ax88179a_set_features() is blocked in ax88179_write_u16(), it reads the old net->features value and overwrites both data->rxctl and AX_RX_CTL: CPU0 CPU1 (<softirq>) __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() __dev_set_rx_mode() ax88179_set_multicast() /* net->features still old */ rxctl &= ~AX_RX_CTL_DROPCRCERR WRITE_ONCE(data->rxctl, rxctl) ax88179_write_cmd_async(...) <-- reverts DROPCRCERR net->features = features Once AX_RX_CTL_DROPCRCERR in hardware disagrees with dev->net->features, ax88179a_rx_fixup() either strips 4 bytes of valid packet payload (when NETIF_F_RXALL is enabled without NETIF_F_RXFCS) or leaves 4 bytes of FCS attached and drops full-MTU packets. Conversely, if ax88179_set_multicast() updates AX_RX_CTL_PRO, AX_RX_CTL_AMALL, or AX_RX_CTL_AM between READ_ONCE() and WRITE_ONCE() in ax88179a_set_features(), those filter changes are lost. Also, WRITE_ONCE(ax179_data->rxctl, rxctl) happens before checking whether ax88179_write_u16() succeeded; if the USB control transfer fails, __netdev_update_features() keeps the old net->features while ax179_data->rxctl retains the new bit and is later written to hardware by ax88179a_mac_link_up(). [Severity: Low] Does toggling NETIF_F_RXFCS or NETIF_F_RXALL while the interface is down or mid-link-up re-enable RX in hardware? ax88179a_reset() sets AX_RX_CTL_START in ax179_data->rxctl, and ax88179a_stop() writes 0 to AX_RX_CTL without clearing AX_RX_CTL_START in ax179_data->rxctl. Similarly, ax88179a_mac_link_up() writes AX_RX_CTL_STOP to AX_RX_CTL while reconfiguring link registers before restoring ax179_data->rxctl under medium_status_mutex. Because ax88179a_set_features() unconditionally writes ax179_data->rxctl to AX_RX_CTL without checking netif_running(net) or synchronizing with ax88179a_mac_link_up(), changing rx-fcs or rx-all re-asserts AX_RX_CTL_START while the interface is stopped or while link registers are being reconfigured. [ ... ] > @@ -1039,9 +1060,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); > + netdev_features_t 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 +1076,19 @@ 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 + fcs_trailer) { > 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++; > + dev->net->stats.rx_errors++; > + } > /* Next RX Packet Descriptor */ > pkt_desc_ptr++; > continue; > } [Severity: Medium] When NETIF_F_RXALL is enabled, frames with !(pkt_desc & AX179A_RX_PD_RX_OK) or (pkt_desc & AX179A_RX_PD_DROP) bypass this discard block and reach ax88179a_rx_checksum(). Can those corrupted frames be marked CHECKSUM_UNNECESSARY and skip error accounting? drivers/net/usb/ax88179a_devices.c:ax88179a_rx_checksum() { ... skb->ip_summed = CHECKSUM_NONE; /* checksum error bit is set */ if (pkt_desc & AX179A_RX_PD_L4_ERR || pkt_desc & AX179A_RX_PD_L3_ERR) return; pkt_type = pkt_desc & AX179A_RX_PD_L4_TYPE_MASK; /* It must be a TCP or UDP packet with a valid checksum */ if (pkt_type == AX179A_RX_PD_L4_TCP || pkt_type == AX179A_RX_PD_L4_UDP) skb->ip_summed = CHECKSUM_UNNECESSARY; } Because ax88179a_rx_checksum() only checks AX179A_RX_PD_L4_ERR and AX179A_RX_PD_L3_ERR, a TCP or UDP packet with an L2 CRC error accepted via NETIF_F_RXALL can have skb->ip_summed set to CHECKSUM_UNNECESSARY. Bypassing the discard block also means rx_crc_errors and rx_errors are never incremented for bad-FCS packets when NETIF_F_RXALL is active. In addition, if a frame has AX179A_RX_PD_RX_OK set and AX179A_RX_PD_DROP clear but fails the pkt_len bounds checks, it enters the discard block and is dropped without incrementing any error or drop counter. > > ax_skb = netdev_alloc_skb_ip_align(dev->net, pkt_len); > if (!ax_skb) > goto err; > > + if (!(features & NETIF_F_RXFCS)) > + pkt_len -= fcs_trailer; > + > skb_put(ax_skb, pkt_len); > memcpy(ax_skb->data, skb->data + (ax179_data->ip_align ? AX179A_RX_HW_PAD : 0), > pkt_len); [Severity: Medium] Can reading dev->net->features in ax88179a_rx_fixup() truncate 4 bytes of payload from in-flight RX URBs when NETIF_F_RXALL is toggled on a live interface? Whether a frame in an RX URB carries a 4-byte FCS depends on whether AX_RX_CTL_DROPCRCERR was set in hardware when the frame was received, not on dev->net->features when the URB is later processed in BH context: CPU0 CPU1 (<softirq>) /* URB queued in dev->done without FCS */ __netdev_update_features() ax88179a_set_features() /* enables AX_RX_CTL_DROPCRCERR */ net->features |= NETIF_F_RXALL usbnet_bh() ax88179a_rx_fixup() fcs_trailer = ETH_FCS_LEN pkt_len -= fcs_trailer <-- strips 4B of payload Conversely, during the window after ax88179a_set_features() writes AX_RX_CTL and before __netdev_update_features() updates dev->net->features (or for in-flight URBs when disabling NETIF_F_RXALL or NETIF_F_RXFCS), frames captured with an appended FCS are processed with fcs_trailer == 0, leaving the 4-byte FCS attached and dropping full-MTU frames as oversized. -- Sashiko AI review · https://sashiko.dev/#/patchset/20261201-fcs-v3-0-6c355917b17e@birger-koblitz.de?part=2 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-12-02 17:17 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-12-01 17:17 [PATCH net-next v3 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz 2026-12-01 17:17 ` [PATCH net-next v3 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz 2026-12-02 17:17 ` sashiko-bot 2026-12-01 17:17 ` [PATCH net-next v3 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz 2026-12-02 17:17 ` sashiko-bot
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.