🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26830

Re: [PATCH net-next v3 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable

#26830
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 08:19
189 lines
15152 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · 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] ax88179_set_multicast()
  (drivers/net/usb/ax88179_lib.c:359-365) now picks its starting rxctl…
- [Medium] ax88179_set_multicast() now does an unlocked read-modify-write
  of data->rxctl: READ_ONCE, clear IPE/DROPCRCERR/PRO/AMALL/AM, then…
- [Low] For chip_version >= AX_VERSION_AX88179A (AX88179A, AX88772D,
  AX88279), ax88179_set_multicast()…

--

net: usb: ax88179: Make receiving FCS on AX88179A configurable

This patch changes ax88179_set_multicast() so that AX_RX_CTL_DROPCRCERR is
set on the AX88179A only when NETIF_F_RXFCS or NETIF_F_RXALL is enabled.
For chips with chip_version >= AX_VERSION_AX88179A, the rxctl value is now
built from the cached data->rxctl, not from a fixed baseline. The
behaviour of the older AX88179 is meant to stay the same.

> diff --git a/drivers/net/usb/ax88179_lib.c b/drivers/net/usb/ax88179_lib.c
> index 821ee9cd8ded1..353b3a7479308 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);

[Severity: Medium]

When chip_version >= AX_VERSION_AX88179A, this branch now starts from the
cached data->rxctl instead of AX_RX_CTL_START | AX_RX_CTL_AB. It never adds
START or AB back. The cache is only initialized by ax88179a_reset(). What
happens if this runs on the legacy ax88179_178a.c path?

ax88179_bind() zero-allocates the private data:

drivers/net/usb/ax88179_178a.c:ax88179_bind() {
    ...
	ax179_data = kzalloc_obj(*ax179_data);
    ...
}

It then reads chip_version from AX_CHIP_STATUS and does not reject values
>= AX_VERSION_AX88179A. The legacy driver_info is picked only by USB
VID/PID. That covers the 0b95:1790 vendor-interface catch-all entry and
the OEM entries (D-Link, Sitecom, Samsung, Lenovo, Belkin, Toshiba, MCT,
Allied Telesis).

ax88179_reset() starts RX from a stack buffer and never stores the value
in ax179_data->rxctl:

	*tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START |
		 AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB;
	ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16);

If AX179A-class silicon (chip_version 6 or 7) is bound through this path,
would open go like this?

__dev_open()
  dev_set_rx_mode()
    ax88179_set_multicast()
      rxctl = 0 & ~(...);              /* no START, no AB */
      WRITE_ONCE(data->rxctl, rxctl);
      ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL, ...);

ax88179_link_reset() would then write the same START-less value back on
every link reset:

		ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2,
				  &ax179_data->rxctl);

Wouldn't that leave the RX engine stopped and broadcast reception off?

Before this patch the legacy path always rebuilt the value with
START | AB, whatever chip_version said. The second patch in the series
does not seem to change this.

I could not confirm that any shipping device puts AX179A-class silicon
behind one of the legacy table entries. Still, nothing in the code
prevents it.

[Severity: Low]

AX_RX_CTL_AP is not in this mask, so is it intended that AP now stays set
on AX179A-family chips? ax88179a_reset() puts it into the cache:

	rxctl = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_START | AX_RX_CTL_AP |
		AX_RX_CTL_AMALL | AX_RX_CTL_AB;

Before this patch, the first ndo_set_rx_mode call rebuilt rxctl from
START | AB | DROPCRCERR, which cleared AP. Now AP survives every rx-mode
update on the AX88179A, AX88772D and AX88279.

The commit message only covers the DROPCRCERR/FCS change. Could it also
mention the switch to a read-modify-write of the cached value, and this
change to the filter mode? That switch is also what makes this function
depend on data->rxctl being initialized, as noted above.

> +	} 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;

[Severity: Medium]

This is an unlocked read-modify-write of data->rxctl, and DROPCRCERR is
derived from net->features. Can it race with ndo_set_features?

Later in this series, the "Support NETIF_F_RXFCS and NETIF_F_RXALL" patch
makes ax88179a_set_features() do its own read-modify-write. It calls
READ_ONCE() on ax179_data->rxctl, toggles DROPCRCERR, stores the result
with WRITE_ONCE() and then does a synchronous AX_RX_CTL write. All of this
runs under RTNL only.

ndo_set_rx_mode runs under netif_addr_lock and can be reached without
RTNL, for example by an unprivileged IPV6_ADD_MEMBERSHIP:

ipv6_sock_mc_join()
  dev_mc_add()
    __dev_set_rx_mode()
      ax88179_set_multicast()

Also, __netdev_update_features() only updates dev->features after
ndo_set_features() returns:

	err = dev->netdev_ops->ndo_set_features(dev, features);
	...
		dev->features = features;

With "ethtool -K ethX rx-all on", the interleaving could be:

CPU1 (set_features)               CPU2 (ax88179_set_multicast)
sets DROPCRCERR in cache and hw
                                  sees RXALL still clear
                                  clears DROPCRCERR
                                  async AX_RX_CTL write lands last
dev->features gains RXALL

After that, ax88179a_rx_fixup() sets fcs_trailer = ETH_FCS_LEN and
subtracts it from pkt_len because RXFCS is off, but the hardware no
longer appends the FCS. Wouldn't every received frame then lose 4 bytes
of payload until the next rx-mode change? Turning rx-fcs or rx-all off
would hit the reverse case and leave a 4-byte trailer on every frame.

The two read-modify-write paths can also lose each other's PRO/AM/AMALL
updates. ax88179a_mac_link_up() then writes the stale cache back to the
hardware. It holds medium_status_mutex, which neither writer takes:

	ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, READ_ONCE(ax179_data->rxctl));

The second patch in the series fixes the resume case by deriving
DROPCRCERR from the features in ax88179a_reset(). It doesn't seem to fix
this race, and it adds the second writer. Should these writers share a
lock?

>  	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/20261201-fcs-v3-0-6c355917b17e%40birger-koblitz.de
Technical Details
Message-ID: <179637234868.3146.1585314112375922296@kernel.org>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377182-linux-kernel-netdev=dewy.ru
References: <20261201-fcs-v3-1-6c355917b17e@birger-koblitz.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377182-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v3 1/2] net: usb: ax88179: Make receiving FCS on
 AX88179A configurable
Date: Fri, 04 Dec 2026 08:19:08 +0000
Organization: Usenet Network
Message-ID: <179637234868.3146.1585314112375922296@kernel.org>
References: <20261201-fcs-v3-1-6c355917b17e@birger-koblitz.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2714633"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:o0+5PXMOxbveMvyxlqsxuiBQt7I= sha256:eVCLQFNCuHVt9nVmI0Sapux9DTWOmLfb6iGu0fTA2VY=
	sha1:mehOUsb8s2ByHICRwD3jT4Gx1uY= sha256:umJjq20f7dSLslHluBPCU2Q23/m8QNACBNXr3gzP3xg=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 62586117B67; Fri,  4 Dec 2026 11:19:31 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.639
X-Spam-Status: No, score=-2.639 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 5nJEM07UcNMX;
	Fri,  4 Dec 2026 11:19:28 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377182-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id BD977117AFF; Fri,  4 Dec 2026 11:19:17 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id DBF0124668; Fri,  4 Dec 2026 08:19:14 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796372351;
	b=KYy2DHUn/Ce31EfNWMnbabMtdyv8GhGpbYoxxoA2FY4w57nUuRz0SHRSI9gWgR3Md44W
	 Gx0jZUtGVIDgVBL3WkVFpAnDGAL/XkOAJ8rEHe+HOTMd6GkDj+o4ouO38jU1MA0h0S5i2
	 tR2g6AtKdVslcU8I5jrkEwTFPn8oaX+s8ffIKuqNhhmTSG2lN+PEEBW5DNsVY3ZcWxd/g
	 mSvLIk7NXkJmEbkuxq/19ZLAAm4qk2CVcGOPdyIcz9NFQOIDZrMHLj1QZQDcLN+e5qQBS
	 n9DHCpr1Brgk2WlhBVkqQlWTCmqAx5g/bHf5TthJ0bGaxrfnj7vy+/xG18lCybmet7w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796372351;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=1I3DwlUhRDF7c50wpE9Ep6/CamPGX+tP3w63g6YiExg=;
	b=s+OCkgH8uhmVm/mJ6FqM7dwyxGEoTySDlXhRupqihlTT0PjB5maZikOk2iqlBhXzNAv1
	 riPzE6U5vYrB+qneNRABClyMuVM17sCAvp4NvdmX7am8CpW0tH9ybwEyv1nouZCYjHUx5
	 I5eMVYPxDm0ACE6HABTcCnbK47V+8Z0gLEqNs5ESq9bHHhlnzdK6RZRse7PMphPb02XZN
	 +GitkHg1zOZRH2F/n4021ur7S3ynke3Sn9S8zG78LlOPMwJEZghmHH2v9YmPfdh/+1Mp3
	 lq+wpgpU+SqEgmEXqDCPeW7NlFuxvsUFjRlIFyNzR9iafJH08ApAAKHZMlZeLXrNHqg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FFJzw1bf;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 040CD606A338;
	Fri,  4 Dec 2026 08:19:11 +0000 (UTC)
X-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=FFJzw1bf
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796372350;
	b=elrldeAxwyXMC/4IZFYn0jaauvCWJOXkENfq+HJUchVLjm8kADdYLcCcYVs/VO3vP109
	 GU4cZFluJAy7+oYZopMqA1HELSJthUhzn8+iXSjmG+OuSZkHQ6ItTAUuv82lbmz2lAEaO
	 GG+SZkRE2Kohy8L7PSWGc2Uk1x9X9PKFiBnapkZI6LfVHYwNF7SCrP4mNui72rqvY9lHc
	 7fBMu2XISK+B48YFMvrsDW2iKssF4bqMltflNRlsagyKj3xOGBK0IXMZT1XOa2qyjaAJK
	 fC4VVO7tgsQXYh6Ur8WcxgNNpuPoy726f7C2mvnR2VE8pU6Qcaxz3TDLE3EEJDU+V6g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796372350;
	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=1I3DwlUhRDF7c50wpE9Ep6/CamPGX+tP3w63g6YiExg=;
	b=eMo+mnoDaDOM2S/fiQRN29KeyuidztaV5COYreYZrglrkg3h8iyVlrlCjsh52youdnd8
	 ylBJuT9qcfQ/IAUQPXaOau1RKNzKIQe442O30PyPIOanrmUn07k3qN0CM+eH5Yt5l32qE
	 SuFC+or6aUehSxweNi6Gzo+XJCsugW1rwcff9LWMkMR0NCZVpjB/XW5y5o9WQYaEMLeV+
	 Q+MkUwgtebvHrsDDLSvhhMpi9jnf8xB7AVoQlrxJDmQnQ7ya85r37Dc1o7uWnGbMP30T2
	 5he5KCCYDPTe4HzymEjXGFLYUkbXqnjMxDTVGCjHLx2JyKuHBHH+uzg9EB9/thXZupA==
X-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=FFJzw1bf;
	arc=none smtp.remote-ip=100.103.45.18
X-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 210EA606A322;
	Fri,  4 Dec 2026 08:19:09 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CA721F000CE;
	Fri,  4 Dec 2026 08:19:09 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796372349;
	bh=1I3DwlUhRDF7c50wpE9Ep6/CamPGX+tP3w63g6YiExg=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=FFJzw1bfqa5lpsi5fWK0vvkdJKRaroUzwnXVXN96DCofD25lavDX77fQK+dpaYvvp
	 MHKnh5PCS0nG3xXHqGwuZIQZRE+gm2bNiLelThoCwsNLjQZVMJILBrFHcP08tT4lM4
	 0kdE553j0my5goCOCCOme3+96/mJytJLzK8OMXgpPxiND2QtIxum/eIYRpVuqkWq0O
	 SDweP0fl3myqwRoRaGEme31QtwMmIxFx6mXuvoXcsFUhNbNYVAMuCwMlxB/p44zQkW
	 nfznQ/VvQfjvoj09LCGqNUDqNttqfdanrEXSh1t9CQl988ReVDQvc5D/n1xeVkozWC
	 NrAZ6TJrvEbxA==
X-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
X-In-Reply-To: <20261201-fcs-v3-1-6c355917b17e@birger-koblitz.de>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list