Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: ruanjinjie@huawei.com
Cc: cai.huoqing@linux.dev, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net: hinic: Don't fail probe when firmware lacks rx-vlan-filter
Date: Thu, 19 Nov 2026 02:21:34 +0000	[thread overview]
Message-ID: <179505489450.3136.816467311238981764@kernel.org> (raw)
In-Reply-To: <20261116021858.273519-1-ruanjinjie@huawei.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 1 · 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).

- [High] set_features() in drivers/net/ethernet/huawei/hinic/hinic_main.c
  turns a HINIC_MGMT_CMD_UNSUPPORTED reply to…
- [Medium] The patch now treats a HINIC_MGMT_CMD_UNSUPPORTED (0xFF)
  return from hinic_set_vlan_fliter() as reliable proof that the…
- [Low] The comment the patch adds in set_features() says a firmware-
  rejected feature 'is dropped from the advertised set, whether it was…

--

net: hinic: Don't fail probe when firmware lacks rx-vlan-filter

With this patch, set_features() in the hinic driver no longer fails probe
when HINIC_PORT_CMD_SET_VLAN_FILTER gets a HINIC_MGMT_CMD_UNSUPPORTED
reply. NETIF_F_HW_VLAN_CTAG_FILTER goes into failed_features instead, and
netdev->features is now written back whenever failed_features is non-empty,
not only on the fatal path.

> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c
> index 34ed5ea9e46ef..e837140f7c178 100644
> --- a/drivers/net/ethernet/huawei/hinic/hinic_main.c
> +++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c
> @@ -1098,16 +1098,26 @@ static int set_features(struct hinic_dev *nic_dev,
>  		ret = hinic_set_vlan_fliter(nic_dev,
>  					    !!(features &
>  					       NETIF_F_HW_VLAN_CTAG_FILTER));
> -		if (ret) {
> +		if (ret == HINIC_MGMT_CMD_UNSUPPORTED) {

[Severity: Medium]

Can a management channel failure end up on this non-fatal path?

In hinic_set_vlan_fliter(), vlan_filter is an uninitialized stack
variable. Only func_idx and enable are set, and status is checked before
err and out_size:

drivers/net/ethernet/huawei/hinic/hinic_port.c:hinic_set_vlan_fliter() {
	struct hinic_vlan_filter vlan_filter;
    ...
	err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_SET_VLAN_FILTER,
				 &vlan_filter, sizeof(vlan_filter),
				 &vlan_filter, &out_size);
	if (vlan_filter.status == HINIC_MGMT_CMD_UNSUPPORTED) {
		err = HINIC_MGMT_CMD_UNSUPPORTED;
    ...
}

On a send failure, a -ETIMEDOUT or a msg_id mismatch, msg_to_mgmt_sync()
returns without copying anything into buf_out. hinic_mbox_to_func() does
the same on its send error and timeout paths on the VF side. In those
cases status still holds whatever was left on the stack.

Before this patch any non-zero return failed probe, so it didn't matter if
the status was misread. Now, if the leftover byte happens to be 0xff, a
failed or timed-out command only logs "Firmware does not support
rx-vlan-filter". CTAG_FILTER is then dropped for good, and nic_dev_init()
goes on to register_netdev().

Other users of the same status convention, such as
hinic_set_link_settings(), check err and out_size before trusting an
unsupported status:

drivers/net/ethernet/huawei/hinic/hinic_port.c:hinic_set_link_settings() {
    ...
	if ((info->status != HINIC_MGMT_CMD_UNSUPPORTED &&
	     info->status) || err || !out_size) {
    ...
}

Should vlan_filter be zero-initialized? And should hinic_set_vlan_fliter()
require !err && out_size before it honours the status? The uninitialized
status, version and reserved bytes are also sent to the device as buf_in.

> +			dev_info(&nic_dev->hwdev->hwif->pdev->dev,
> +				 "Firmware does not support rx-vlan-filter, feature disabled\n");
> +			failed_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
> +		} else if (ret) {
>  			err = ret;
>  			failed_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
>  		}
>  	}
>  
> -	if (err) {
> +	/*
> +	 * A feature the firmware rejects is dropped from the advertised set,
> +	 * whether it was rejected fatally or not (e.g. rx-vlan-filter on
> +	 * firmware that predates it).
> +	 */
> +	if (failed_features)
>  		nic_dev->netdev->features = features ^ failed_features;

[Severity: High]

On firmware that answers SET_VLAN_FILTER with HINIC_MGMT_CMD_UNSUPPORTED,
this write-back clears NETIF_F_HW_VLAN_CTAG_FILTER from netdev->features
during probe, via nic_dev_init()->set_features() with force_change set.
Does that break VLAN receive on exactly the firmware this patch targets?

The 8021q core only calls ndo_vlan_rx_add_vid while that bit is set:

net/8021q/vlan_core.c:vlan_add_rx_filter_info() {
    ...
	if (!vlan_hw_filter_capable(dev, proto))
		return 0;
    ...
}

hinic_vlan_rx_add_vid() is the only code that programs the hardware VLAN
table and the per-VID MAC entry, and the only code that fills vlan_bitmap:

hinic_vlan_rx_add_vid() {
    ...
	err = hinic_port_add_vlan(nic_dev, vid);
    ...
	err = hinic_port_add_mac(nic_dev, netdev->dev_addr, vid);
    ...
	bitmap_set(nic_dev->vlan_bitmap, vid, 1);
    ...
}

add_mac_addr() also walks vlan_bitmap to install secondary unicast and
multicast addresses for each VID. change_mac() sends port_mac_cmd.vlan_id,
so the hardware MAC filter appears to be keyed by (MAC, VID).

Before 2acf960e3be6 the driver never sent SET_VLAN_FILTER. CTAG_FILTER has
also been a fixed feature since 2017:

netdev_features_init() {
    ...
	netdev->features = netdev->hw_features | NETIF_F_HW_VLAN_CTAG_FILTER;
    ...
}

So older firmware has always run with the driver programming VLAN
membership.

After this patch, "ip link add link ethX name ethX.N type vlan id N" never
reaches hinic_vlan_rx_add_vid(). Frames tagged with VID N and sent to the
port MAC would then seem to miss the (MAC, N) entry and be dropped, unless
the port is promiscuous. CTAG_FILTER is not in hw_features, so ethtool
can't turn it back on.

VFs hit the same path, because hinic_set_vlan_fliter() also maps
HINIC_MBOX_VF_CMD_ERROR to HINIC_MGMT_CMD_UNSUPPORTED.

Given that, is this part of the commit message accurate?

    and the device stays unusable although nothing is actually broken.

Would it be better to treat HINIC_MGMT_CMD_UNSUPPORTED as non-fatal and
keep NETIF_F_HW_VLAN_CTAG_FILTER set? That would match the behaviour before
2acf960e3be6, without dropping the feature or adding the new write-back.

[Severity: Low]

This isn't a bug, but the new comment says a rejected feature "is dropped
from the advertised set, whether it was rejected fatally or not". The XOR
below it flips the requested state rather than clearing the bit.

For example, if "ethtool -K ethX tso off" fails in hinic_port_set_tso(),
features has NETIF_F_TSO clear and failed_features has it set. So
features ^ failed_features sets TSO again. That restores the previous
state rather than dropping the feature, and hw_features is never changed.

Could the comment say that the previous state is restored instead?

> +
> +	if (err)
>  		return -EIO;
> -	}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116021858.273519-1-ruanjinjie%40huawei.com

      reply	other threads:[~2026-11-19  2:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  2:18 [PATCH net] net: hinic: Don't fail probe when firmware lacks rx-vlan-filter Jinjie Ruan
2026-11-19  2:21 ` netdev-bot+sashiko [this message]

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=179505489450.3136.816467311238981764@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=cai.huoqing@linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ruanjinjie@huawei.com \
    /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