Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Birger Koblitz" <mail@birger-koblitz.de>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH net-next v17 07/13] ax88179_178a: Add VLAN offload support for AX88179A
Date: Wed, 07 Oct 2026 03:05:40 +0000	[thread overview]
Message-ID: <sashiko-outbox-162602@kernel.org> (raw)
In-Reply-To: <20261006-ax88179a-v17-7-252814fe35ea@birger-koblitz.de>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] net: missing disable logic and brittle XOR toggling in VLAN state machine
- [High] net: VLAN filter initialization clobbers AX88179A_VLAN_ID_CONTROL register
--

commit a9c0fbb36ee5fddc570645020a27d1096396251d
Author: Birger Koblitz <mail@birger-koblitz.de>

ax88179_178a: Add VLAN offload support for AX88179A

This commit adds VLAN offload configuration support in netdev_ops for
AX88179A-based chips. The supported features include NETIF_F_HW_VLAN_CTAG_TX,
NETIF_F_HW_VLAN_CTAG_RX, and NETIF_F_HW_VLAN_CTAG_FILTER.

> diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
> --- a/drivers/net/usb/ax88179a_devices.c
> +++ b/drivers/net/usb/ax88179a_devices.c

[ ... ]

> @@ -517,6 +599,58 @@ static int ax88179a_mii_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
>  	return phylink_mii_ioctl(data->phylink, rq, cmd);
>  }
>  
> +static int ax88179a_set_features(struct net_device *net, netdev_features_t features)
> +{
> +	struct usbnet *dev = netdev_priv(net);
> +	netdev_features_t changed;
> +	int ret;
> +	u8 tmp;
> +
> +	changed = net->features ^ features;
> +
> +	ret = ax88179_set_features(net, features);
> +	if (ret)
> +		return ret;
> +
> +	if (changed & NETIF_F_HW_VLAN_CTAG_FILTER) {
> +		if (features & NETIF_F_HW_VLAN_CTAG_FILTER) {

[Severity: High]
Is there a missing else block here for disabling the filter?

Without an else branch, it appears that disabling NETIF_F_HW_VLAN_CTAG_FILTER
via ethtool will have no effect on the hardware since the disable path is
completely skipped.

> +			for (int i = 0; i < 256; i++) {
> +				/* Address */
> +				tmp = i;
> +				ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_ADDRESS,
> +						  1, 1, &tmp);
> +				/* Data */
> +				ax88179_write_u16(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_DATA0,
> +						  2, 0);
> +				ax88179_write_u8(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL,
> +						 1, AX_VLAN_CONTROL_WE);

[Severity: High]
Does writing AX_VLAN_CONTROL_WE directly clobber the rest of the control
register?

Inside this loop, ax88179_write_u8() blindly overwrites the entire control
register with 0x01 instead of using a read-modify-write. This seems to clear
other active configuration bits in the register, such as AX_VLAN_CONTROL_VSO,
which could silently break RX VLAN hardware acceleration if it is enabled.

> +			}
> +			ret = ax88179_read_cmd(dev, AX_ACCESS_MAC,
> +					       AX88179A_VLAN_ID_CONTROL, 1, 1, &tmp);
> +			if (ret < 0)
> +				return ret;
> +			tmp ^= AX_VLAN_CONTROL_VFE;

[Severity: High]
Does this XOR operation lead to an inverted state if the hardware and OS states
desynchronize?

Using XOR to toggle AX_VLAN_CONTROL_VFE instead of explicitly setting or
clearing the bit based on the features flag means a subsequent state change
could invert the configuration, leading to incorrectly filtered packets.

> +			ret = ax88179_write_cmd(dev, AX_ACCESS_MAC,
> +						AX88179A_VLAN_ID_CONTROL, 1, 1, &tmp);
> +			if (ret < 0)
> +				return ret;
> +		}
> +	}
> +
> +	if (changed & NETIF_F_HW_VLAN_CTAG_RX) {
> +		ret = ax88179_read_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL,
> +				       1, 1, &tmp);
> +		if (ret < 0)
> +			return ret;
> +		tmp ^= AX_VLAN_CONTROL_VSO;

[Severity: High]
Similarly, does this XOR logic for the RX VLAN offload risk state inversion?

If the OS state and hardware state desynchronize, the bit will be flipped
the wrong way, potentially causing packets to be incorrectly untagged or
causing dropped network traffic.

> +		ret = ax88179_write_cmd(dev, AX_ACCESS_MAC, AX88179A_VLAN_ID_CONTROL,
> +					1, 1, &tmp);
> +		if (ret < 0)
> +			return ret;
> +	}
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261006-ax88179a-v17-0-252814fe35ea@birger-koblitz.de?part=7

  reply	other threads:[~2026-10-07  3:05 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06  3:05 [PATCH net-next v17 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 01/13] phylink: Add phylink_mac_interrupt Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-07  3:55     ` Fwd: " Birger Koblitz
2026-10-07 12:18       ` Andrew Lunn
2026-10-07 14:16         ` Birger Koblitz
2026-10-08  3:34     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 02/13] phylib: Add support for PHYs with broken forced mode Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:36     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 03/13] ax88179_178a: Split driver into library and device specific code Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:38     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 04/13] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:41     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 05/13] ax88179_178a: Add EEE configuration support for AX88179A MACs Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 06/13] ax88179_178a: Add EEE configuration support for AX88179A PHYs Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 07/13] ax88179_178a: Add VLAN offload support for AX88179A Birger Koblitz
2026-10-07  3:05   ` sashiko-bot [this message]
2026-10-08  3:44     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 08/13] ax88179_178a: Add AX179A/AX279 multicast configuration Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 09/13] ax88179_178a: Add Suspend/resume support for AX88179A/772D/279 Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:47     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 10/13] ax88179_178a: Add ethtool get_drvinfo Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 11/13] ax88179_178a: Update driver name and information Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:48     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 12/13] ax88179_178a: Add support for AX88179A/772D/279 EEPROM access Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:50     ` Birger Koblitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-162602@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mail@birger-koblitz.de \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox