From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796372351; b=HBPWTExh5YNw9aZSfNf8B9L7JN2PJ8Xnkca2WkiZi5X5eoWQ2IWvqpnAh1nc5uxfiNEj zyZyJaRcSFsFhTPR9HQk2P3nTTZeLxKYRK0FiifNaqAJT6VOBAU8H7ET3G5DCTV8xMlCR XusGxsmRnCzZT8xwSq9JlU4q8IW4d/LBmzaVkVni3fwjGOtf88vxZlyWRZ3TgTIcFo56j lTIQ1G9snGWx9YdqjrFLBSydRk95eGxgI/XquXle8fml61cJPDQHyu4KyZDo90xvcZb72 +tz1H5zw2tkJxGBZoQWygKjN3nTCTqkerozShmZQwuo6V6fP0VLNlDF3gk3MZbBR+1A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796372351; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=0euw12Kze3iN6WBVTyHjtDKUUghTyN8UxwfoCjU6BvA=; b=c8lgVGnW18s8IaOyaIHjUVzemhQFALwJI9OyTJE98GumVC/WxIWHH8mRq8udSXLpfrzz aVHzpquWecG3RLo9X/1evfq2qhedbSllOUWra4mJfWnDS11U7R+DdJr6lh2LoxjuocRYa oR0Kroj6NdG3txog9vt44g3Od4hesJ0v4QozoNUqji2HdKDJksXkyoUYIizysdGVb5mA2 2pY4yRlmroTfog2xIUiWDePMhJr3NbFBSH+kfmIkXbWzw4blegfEKfgecAgbreMLfRu23 F1vPlA8dZCtVA6N9mYfmoGOOAhco1cZCSnk118vCn37ft2ecmEmVSUCySNAT3PPFeJg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LWxxQoVT; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D04E606A33A; Fri, 4 Dec 2026 08:19:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=LWxxQoVT Received: by smtp.kernel.org (Postfix) with ESMTPSA id 479A21F000CE; Fri, 4 Dec 2026 08:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796372350; bh=0euw12Kze3iN6WBVTyHjtDKUUghTyN8UxwfoCjU6BvA=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=LWxxQoVT2tSwM0/IARdSUEKEPUwfSy46kGs/cXEMnkJh21Zs+ePeJmdXeF37epASd XPl8Tzl+YRAFXXUY5e+RcsnM0+Kk3edQMJfJDbwll4NYMCvVWMRlZEeYNLVz3RwoxO 3QXgCT6u0v7MA8V1JrF8TQ6/aeWR72FUURg03EJrVjl6I9pL96r3dfJZPZyoZmkEmF DFjK8DOOoavNTTwyWquHRYGdC6Nu8rzel/d2znv1wpiuuNxzrzlubi1KWGgB9/Vt75 mTr3alaMvJqDv/P4hZrqOb6ApdimrNA0+nqZYNnFgM7HBMKYfAVtnl2VWvy8KxLJ7t kjczO19sbL8ZQ== Subject: Re: [PATCH net-next v3 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A From: netdev-bot+sashiko@kernel.org To: mail@birger-koblitz.de Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-usb@vger.kernel.org, benjamin.larsson@genexis.eu Date: Fri, 04 Dec 2026 08:19:09 +0000 Message-ID: <179637234987.3146.10912674813170656449@kernel.org> In-Reply-To: <20261201-fcs-v3-2-6c355917b17e@birger-koblitz.de> References: <20261201-fcs-v3-2-6c355917b17e@birger-koblitz.de> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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. > + 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? [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? [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? > + } > + > 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? > + } > + > 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. > 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; [ ... ] > @@ -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); -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-fcs-v3-0-6c355917b17e%40birger-koblitz.de