On 04/12/2026 9:19 am, netd…@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 8 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 4 · Low: 4
>
> 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] The commit message describes only feature work: new
> NETIF_F_RXFCS/NETIF_F_RXALL features, an FCS-aware length check and…
> - [Medium] The statistics in ax88179a_rx_fixup() are incomplete, and they
> change with an unrelated feature toggle.
> - [Medium] ax88179a_set_features() adds a new writer of ax179_data->rxctl
> and the AX_RX_CTL register: READ_ONCE, modify DROPCRCERR, WRITE_ONCE,…
> - [Medium] In ax88179a_set_features(), the cached value is committed with
> WRITE_ONCE(ax179_data->rxctl, rxctl) before…
> - [Low] The new code sets a bit named AX_RX_CTL_DROPCRCERR ('drop CRC-
> error frames') when the user asks for NETIF_F_RXALL ('also receive…
> - [Low] ax88179a_bind() ORs NETIF_F_RXFCS | NETIF_F_RXALL into
> dev->net->vlan_features.
> - [Low] Each packet in ax88179a_rx_fixup() reads dev->net->features
> without a lock to decide whether a 4-byte FCS trailer is present and…
> - [Low] The new branch in ax88179a_set_features() writes the whole cached
> ax179_data->rxctl to AX_RX_CTL, including AX_RX_CTL_START | AP | AMALL…
>
> --
>
> net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
>
> This patch adds NETIF_F_RXFCS and NETIF_F_RXALL support for the AX88179A.
> It sets AX_RX_CTL_DROPCRCERR only when those features are on, and accounts
> for a trailing FCS in the ax88179a_rx_fixup() length checks. It also counts
> dropped and CRC-errored frames.
>
>> 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
>
> [ ... ]
>
>> @@ -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;
>
> [Severity: Low]
> This isn't a bug, but this sets a bit named AX_RX_CTL_DROPCRCERR when
> rx-all (keep errored frames) or rx-fcs is requested, and clears it
> otherwise. Read literally, the logic looks inverted.
>
> ax88179a_rx_fixup() treats the set bit as "a 4 byte FCS trailer is
> present". The only place that explains this (on AX88179A the bit leaves
> the FCS attached rather than controlling dropping) is the commit message
> of the earlier patch "net: usb: ax88179: Make receiving FCS on AX88179A
> configurable".
>
> ax88179_178a.c and the older-chip branch of ax88179_set_multicast() also
> use this define. There it is set by default and there is no FCS handling.
>
> Could a comment here, or next to the define in ax88179_lib.h, describe
> the AX88179A semantics? That would stop a later cleanup from inverting
> this logic.
A comment will be added.
>
>> + WRITE_ONCE(ax179_data->rxctl, rxctl);
>> + ret = ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl);
>> + if (ret < 0)
>> + return ret;
>
> [Severity: Medium]
> What happens if ax88179_write_u16() fails here? The cached
> ax179_data->rxctl already holds the new DROPCRCERR state. Because of the
> error return, __netdev_update_features() keeps the old dev->features.
>
> ax88179a_mac_link_up() later writes the cached value to the hardware
> unchanged:
>
> ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, READ_ONCE(ax179_data->rxctl));
>
> After the next link-up, the hardware FCS mode no longer matches what
> dev->features tells ax88179a_rx_fixup().
>
> For example, a failed attempt to turn rx-all off with rx-fcs off leaves
> NETIF_F_RXALL set while DROPCRCERR is cleared. fcs_trailer is then 4, and
> every frame would lose 4 bytes of real payload.
>
> Should the cache only be updated after the register write succeeds?
>
If a write fails, this means the device has become unusable. So this is not relevant since the device will anyway be in such trouble that it likely needs a power cycle.
> [Severity: Medium]
> What serializes this read-modify-write of ax179_data->rxctl and
> AX_RX_CTL against the other writers?
>
> ax88179a_set_features() runs under RTNL only. The other two writers use
> different locks:
>
> - ax88179a_mac_link_up() runs from the phylink resolve worker without
> RTNL. It writes the cached value under medium_status_mutex, which is
> not taken here.
> - ax88179_set_multicast() runs as ndo_set_rx_mode and rebuilds
> DROPCRCERR from net->features. The core only updates net->features
> after ndo_set_features() returns.
>
> One possible interleaving:
>
> phylink worker ethtool -K ethX rx-all on
> ax88179a_mac_link_up()
> READ_ONCE(ax179_data->rxctl)
> (old DROPCRCERR)
> ax88179a_set_features()
> WRITE_ONCE(ax179_data->rxctl, new)
> ax88179_write_u16(.., AX_RX_CTL, new)
> ax88179_write_u16(.., AX_RX_CTL, old)
>
> The hardware FCS mode then disagrees with dev->features, which
> ax88179a_rx_fixup() uses to decide whether to strip 4 bytes. Could this
> leave every received frame either truncated by 4 bytes or carrying the
> FCS as payload until something else rewrites rxctl?
>
This is a duplicate and is fixed by the locking introduced to protect AX_RX_CTL.
> [Severity: Low]
> This writes the whole cached rxctl, including AX_RX_CTL_START, AP, AMALL
> and AB from the last ax88179a_reset(). ax88179a_stop() clears the
> register but not the cache:
>
> ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 0);
>
> Does toggling rx-fcs or rx-all while the interface is down re-arm the
> receive control register that stop() cleared on purpose? Before this
> patch nothing wrote AX_RX_CTL while the interface was down, because
> ndo_set_rx_mode only runs with IFF_UP.
>
> A related case is a link-up in progress. ax88179a_mac_link_up() writes
> AX_RX_CTL_STOP and MAC_PATH = 0, reprograms the bulk-in and medium
> settings, and only then restores rxctl under medium_status_mutex.
>
> Can this write set START in the middle of that sequence and restart RX
> while the link is still being reconfigured?
>
The link-up case is fixed by the locking introduced.
>> + }
>> +
>> return 0;
>> }
>
> [ ... ]
>
>> @@ -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;
>
> [Severity: Low]
> Do these bits have any effect in vlan_features?
>
> vlan_dev_init() builds the VLAN device's hw_features from a fixed set
> that does not include NETIF_F_RXFCS or NETIF_F_RXALL.
> vlan_dev_fix_features() only intersects with the lower device's
> vlan_features, so a VLAN upper device can never enable them.
>
> These are port level RX controls, and no other driver under drivers/net/
> adds them to vlan_features. Can this line be dropped?
>
The line will be dropped.
>> + }
>> +
>> netif_set_tso_max_size(dev->net, 16384);
>
> [ ... ]
>
>> @@ -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;
>
> [Severity: Low]
> FCS handling for each frame is decided from a lockless read of
> dev->net->features. That is not necessarily the setting the hardware
> used when it framed this data.
>
> ax88179a_set_features() changes DROPCRCERR in AX_RX_CTL while RX is
> live, and dev->features is only updated after ndo_set_features()
> returns. Some data may have been framed under the old setting: data
> still buffered in the device, URBs in flight, or skbs queued on
> dev->done.
>
> When rx-fcs or rx-all is enabled, frames carrying the FCS would be
> parsed with fcs_trailer = 0, so the FCS is delivered as payload.
>
> When rx-all is disabled with rx-fcs off, frames without an FCS would go
> through this with fcs_trailer = 4 and lose 4 bytes of real payload:
>
> if (!(features & NETIF_F_RXFCS))
> pkt_len -= fcs_trailer;
>
> Is a short burst of mis-sized frames after each toggle acceptable here?
> Drivers such as igb and e1000e reset the device when these features
> change.
Indeed, this is preferred over clearing the entire packet pipeline or resetting the device which would mean packet loss. FCS is used during debugging, not normal operations, the user will be aware of what is going on.
>
>> 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;
>> +
>
> [ ... ]
>
>> @@ -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++;
>> + }
>
> [Severity: Medium]
> The commit message says "Count dropped packets and those with incorrect
> FCS", but some cases don't seem to be counted.
>
> Frames dropped only by the length checks, with AX179A_RX_PD_RX_OK set and
> AX179A_RX_PD_DROP clear, are discarded without bumping any counter.
> Should those increment rx_length_errors and rx_errors?
>
> With NETIF_F_RXALL enabled, frames with AX179A_RX_PD_RX_OK clear skip
> this branch entirely. rx_crc_errors and rx_errors therefore stop counting
> exactly when rx-all is turned on.
>
> If such a frame also fails a length check, it is counted after all. Could
> the error accounting be done whether or not the frame is dropped?
>
> AX179A_RX_PD_RX_OK also looks like a generic receive status bit:
>
> #define AX179A_RX_PD_RX_OK BIT(11)
>
> Is every frame without it really a CRC error? Or should only rx_errors be
> incremented when the descriptor doesn't give the cause?
>
>> /* Next RX Packet Descriptor */
>> pkt_desc_ptr++;
>> continue;
>
> [ ... ]
>
This has been answered before. The AI is wrong because its assumptions are wrong, given the lack of information on the actual behaviour of AX179A_RX_PD_RX_OK, the code is correct. The AI should not do guesswork.
>> @@ -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;
>
> [Severity: Medium]
> This changes the default AX_RX_CTL value programmed for every AX88179A
> and AX88772D user. AX_RX_CTL_DROPCRCERR used to be set unconditionally.
> It is now set only when rx-fcs or rx-all is on, or when the chip is
> AX88279. The commit message doesn't mention this.
>
> This hunk also seems to complete the previous patch in the series, "net:
> usb: ax88179: Make receiving FCS on AX88179A configurable", which only
> changed ax88179_set_multicast(). With that patch alone, the resume path
> goes:
>
> ax88179a_resume()
> ax88179a_reset()
> sets DROPCRCERR and caches it in rxctl
> ax88179a_mac_link_up()
> writes the cached rxctl back to AX_RX_CTL
>
> So the FCS is attached again after every resume, and nothing in
> ax88179a_rx_fixup() strips it.
>
> This patch carries a Fixes: tag but also adds new rx-fcs and rx-all
> toggles that show up in ethtool -k. A stable backport can't take the fix
> without the feature.
>
> Would it make sense to move this reset() change into the earlier fix and
> describe it there, so this patch only adds the feature?
>
>> WRITE_ONCE(ax179_data->rxctl, rxctl);
>> ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl);
>
The fix has been moved into the first patch.