🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27241

Re: [PATCH net-next v19 4/4] hinic3: Add ethtool pause param ops

#27241
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 04:17
221 lines
16196 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 3

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 patch makes PF probe fail whenever the firmware pause
  query fails.
- [Low] The commit message does not match the code.
- [Low] hinic3_set_pauseparam() normalizes rx_pause/tx_pause with `!!`
  but compares the raw uAPI `pause->autoneg` (__u32, where any non-zero…
- [Low] The new field comment in struct hinic3_nic_cfg
  (hinic3_nic_cfg.h:271) says cfg_mutex is the 'lock for getting nic…

--

hinic3: Add ethtool pause param ops

This commit adds .get_pauseparam and .set_pauseparam ethtool callbacks to
the hinic3 PF driver, using a new hinic3_set_pause_info() helper. It also
adds a nic_cfg member with a cfg_mutex to struct hinic3_nic_dev. During PF
probe it queries the firmware pause state to fill a cache.

> Also initialize nic_cfg.cfg_mutex and use it to protect the cached pause
> state, and skip the pause query for VF during probe.
>
> The getter reports the firmware values whenever the query succeeds and
> falls back to the cached state on error.  The setter preserves the
> existing auto_neg because pause autonegotiation is not user
> configurable.

[Severity: Low]
Does this description match what hinic3_set_pauseparam() does?

"The setter preserves the existing auto_neg" reads as if a request with a
different autoneg value is accepted and autoneg is simply left alone. The
code rejects such a request instead:

	if (pause->autoneg != nic_pause.auto_neg) {
		mutex_unlock(&nic_dev->nic_cfg.cfg_mutex);
		return -EOPNOTSUPP;
	}

The comment above that check says it does this "instead of silently ignoring
it". So a request whose autoneg doesn't match the current value fails, and
the rx/tx change is not applied.

"initialize nic_cfg.cfg_mutex" also suggests the field already exists. In
the parent commit, struct hinic3_nic_dev has no nic_cfg member, and struct
hinic3_nic_cfg has bool pause_set but no cfg_mutex. This patch adds the
nic_cfg member, removes pause_set and adds cfg_mutex.

Could the commit message describe the -EOPNOTSUPP behavior and these struct
changes?

> diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c b/drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c
> index 1a62668a65f77..f27cd0b2d9acf 100644
> --- a/drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c
> +++ b/drivers/net/ethernet/huawei/hinic3/hinic3_ethtool.c

[ ... ]

> +static int hinic3_set_pauseparam(struct net_device *netdev,
> +				 struct ethtool_pauseparam *pause)
> +{
> +	struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
> +	struct hinic3_nic_pause_config nic_pause = {};
> +	struct hinic3_nic_pause_config cur = {};
> +	int err;
> +
> +	nic_pause.rx_pause = !!pause->rx_pause;
> +	nic_pause.tx_pause = !!pause->tx_pause;
> +
> +	mutex_lock(&nic_dev->nic_cfg.cfg_mutex);
> +
> +	if (!hinic3_get_pause_info(nic_dev, &cur))
> +		nic_pause.auto_neg = cur.auto_neg;
> +	else
> +		nic_pause.auto_neg = nic_dev->nic_cfg.nic_pause.auto_neg;
> +	/* Pause autoneg is not user-configurable.  Reject an explicit
> +	 * change instead of silently ignoring it.
> +	 */
> +	if (pause->autoneg != nic_pause.auto_neg) {

[Severity: Low]
rx_pause and tx_pause are normalized with !!, but pause->autoneg (a __u32
where any non-zero value means enabled) is compared raw against the
firmware u8. Can this reject a request that only asks for the current
autoneg state?

The ETHTOOL_SPAUSEPARAM ioctl path passes the user struct through without
normalizing it:

net/ethtool/ioctl.c:ethtool_set_pauseparam() {
    ...
	if (copy_from_user(&pauseparam, useraddr, sizeof(pauseparam)))
		return -EFAULT;

	ret = dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
    ...
}

An ioctl caller that passes autoneg=2 while firmware reports 1 would get
-EOPNOTSUPP, and its rx/tx pause change would be refused. The same thing
happens if firmware ever reports an auto_neg value other than 0 or 1 and
userspace asks for autoneg on.

The netlink path isn't affected, because ethnl_update_bool32() keeps the
raw value when the new one is logically equal.

hinic3_get_pauseparam() also copies the raw firmware or cached byte into
the uAPI struct:

	pause->autoneg  = nic_pause.auto_neg;

Would comparing !!pause->autoneg with !!nic_pause.auto_neg, and reporting
!!auto_neg in the getter, avoid this?

[ ... ]

> diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_main.c b/drivers/net/ethernet/huawei/hinic3/hinic3_main.c
> index a288957a94123..d1469d67b55dc 100644
> --- a/drivers/net/ethernet/huawei/hinic3/hinic3_main.c
> +++ b/drivers/net/ethernet/huawei/hinic3/hinic3_main.c
> @@ -240,10 +240,18 @@ static int hinic3_sw_init(struct net_device *netdev)
>  	int err;
>  
>  	mutex_init(&nic_dev->port_state_mutex);
> +	mutex_init(&nic_dev->nic_cfg.cfg_mutex);
>  
>  	nic_dev->q_params.sq_depth = HINIC3_SQ_DEPTH;
>  	nic_dev->q_params.rq_depth = HINIC3_RQ_DEPTH;
>  
> +	if (!HINIC3_IS_VF(hwdev)) {
> +		err = hinic3_get_pause_info(nic_dev,
> +					    &nic_dev->nic_cfg.nic_pause);
> +		if (err)
> +			return err;
> +	}

[Severity: Medium]
Should a failed pause query make PF probe fail here?

hinic3_cfg_hw_pause() turns any mailbox error, and any non-zero firmware
status including MGMT_STATUS_CMD_UNSUPPORTED, into -EFAULT:

	if (err || pause_info.msg_head.status) {
		...
		return -EFAULT;
	}

That error goes back through hinic3_nic_probe()->hinic3_sw_init(), and
hinic3_nic_probe() handles it like this:

	err = hinic3_sw_init(netdev);
	if (err)
		goto err_free_nic_io;

So the PF netdev is never registered.

The value read here only fills the nic_cfg.nic_pause cache. That cache is
read in only two places, and both run after a runtime firmware query has
already failed:

  - the fallback branch of hinic3_get_pauseparam()
  - the auto_neg selection in hinic3_set_pauseparam()

The commit message also says the getter "falls back to the cached state on
error", which suggests this query is expected to fail sometimes.

Before this patch, the same failure only affected the pause part of
get_link_ksettings, and probe still succeeded. Other L2NIC commands in the
driver, such as hinic3_set_force_pkt_drop() and hinic3_set_rss_type(),
already tolerate CMD_UNSUPPORTED.

Would it be better to warn and continue with the zeroed cache?

>  	hinic3_try_to_enable_rss(netdev);
>  
>  	if (HINIC3_IS_VF(hwdev)) {

[ ... ]

> diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.h b/drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.h
> index bcfdc8c7367d0..9b498a539f818 100644
> --- a/drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.h
> +++ b/drivers/net/ethernet/huawei/hinic3/hinic3_nic_cfg.h
> @@ -268,8 +268,8 @@ struct hinic3_nic_pause_config {
>  };
>  
>  struct hinic3_nic_cfg {
> -	/* Valid when pfc is disabled */
> -	bool                           pause_set;
> +	/* lock for getting nic cfg */
> +	struct mutex                   cfg_mutex;

[Severity: Low]
This isn't a bug, but is "lock for getting nic cfg" accurate?

hinic3_set_pauseparam() holds cfg_mutex across the firmware GET, the
autoneg check, the firmware SET and the update of nic_cfg.nic_pause.
hinic3_get_pauseparam() takes it only on the fallback path that reads the
cache. The successful firmware query path doesn't take it at all.

Could the comment say that the mutex protects the cached nic_cfg.nic_pause
and serializes pause configuration updates?

>  	struct hinic3_nic_pause_config nic_pause;
>  
>  	u8                             pfc_en;

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1796348433.git.gongfan1%40huawei.com
Technical Details
Message-ID: <179644427846.3146.11969061479529550723@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-377829-linux-kernel-netdev=dewy.ru
References: <e6517f439af43958005e92eac1422d9872aa6a3e.1796348433.git.gongfan1@huawei.com>

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-377829-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v19 4/4] hinic3: Add ethtool pause param ops
Date: Sat, 05 Dec 2026 04:17:58 +0000
Organization: Usenet Network
Message-ID: <179644427846.3146.11969061479529550723@kernel.org>
References: <e6517f439af43958005e92eac1422d9872aa6a3e.1796348433.git.gongfan1@huawei.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2951421"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ZssTFhpPBpsFaESzI9n3honeFng= sha256:I1q2LwiokWIeOF/9aghM5Asz7q3HK0rtP6Eb+sSkooM=
	sha1:lEN/G15j4tlKlMYuGpVW+HTzJg0= sha256:ld6I78lPIcH7+nnNP/L2GptgpknV2RXFGiqVvQunVqg=
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 530B8117D69; Sat,  5 Dec 2026 07:18:32 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.542
X-Spam-Status: No, score=-3.542 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, 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] 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 D3Yfna7QNICM;
	Sat,  5 Dec 2026 07:18:29 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377829-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 04351116DB3; Sat,  5 Dec 2026 07:18:20 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id F10283DB40; Sat,  5 Dec 2026 04:18:04 +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=1796444281;
	b=xdF44K3CNYkOxcx3LDSMt6o5Xg8nHqMZ3eB568sAQw1AsZTs1V+59aXqNpOqip1aZ94T
	 EoPgaNrp2CpeohAVQDxNVBR/b2mAUbrm4VmlhL/si1l9UG1bVEVf7W5GkN3mdbJ6LIZbH
	 bl7Y+fORA0aqg4vIsbc8v5rUFsrdw8HW+7ZQxupSA8wwHg5Y74NX5BcJ1cef7GcuSlJzx
	 oLB9dDEz/jSH0PLWwo5QXHaabbkUbQ0F4D1yNRHncmN5NNJbSdKv6zN50Z+y8kDdE0OAE
	 ev90RLab50HaGAM63jLQea5r8CG9AjX0A1jl1yMuIq/VIlHEsQocsDeizvhKorbJaGw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796444281;
	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=otvXuEHS/bNwdzfmcGGBizbGGL0IxkR3gAbRNCRROX4=;
	b=Rmo2HXY1dK1ZP5r1SJLypT7ITkQef3W1YG+nNRqq34WQ9fvhmYWWcZMQcznVX+1gcZIy
	 QMec0yo2p3/MBO9z0zqHJr/30rw5NcAnqxC2SaJI3euoorGuPeddte26KMxJHeBCy+g+d
	 wG8j//jd6mj0kFyBqka6Y7G47bamrCGwtSojpCvFOl+rSb2XPXvbtujd9jxUunD0su7KB
	 s24OYEdQUrzuE78A1xjkIemH60Fh9g/zkzmxZLMDnDDvQ7ghlLcUOdkvb2llsDobRVVGL
	 5cAIDXXsmvZvOF/5p88/vtikBYNfgvSlhF44ClYxEEsunpXYifTpIbFdWZg1gE5cXhg==
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=Sm2jURRu;
	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 3FEA6606A6AE;
	Sat,  5 Dec 2026 04:18:01 +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=Sm2jURRu
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=1796444280;
	b=RC6cHcN6PHuvtC1ivQzEdAJZdkp/WHvt3GOdQCw/l9IeEWBk8gzkUa8kz4V6FgDMYC6G
	 yDzwuA3RRDOtcm/FGfipFISP8CoXp7ha7ancTnRlcYI6ht9z7pyGZvak7uSTAorLvumaX
	 QwR8gDsRJ/FQK8Dbt4cbdUql/GQ0WpEiX3zBx5qnzkBkNbFhJK3M9M722UfCg0ByYnOwu
	 s/lYbcMHBhtx+TUElv8Ra7w2+H+diqFGi7X1Dq9/c8V28FE44gj6ZFNDYnarxyVPTpaUH
	 SImFcjh9Ld6ercL4g0u8Vpsiink80ByyA5ggdwbuXJPqavuyfbGdTUiIQRZVUUgoQyA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796444280;
	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=otvXuEHS/bNwdzfmcGGBizbGGL0IxkR3gAbRNCRROX4=;
	b=aBznJ9C3LWB/JfDJ3aRoPz+wUQi3syTICy1NfkRsm8+rwXMh95eJErdZuj0ZKuzmwxTH
	 /oFSWRXlngGyjNq7jmkmkDFfs7Cih7/Fnt3go6NxA/7Hiii3l8iGawfxoLtS1TFCWPo10
	 rriqhoBO9ji5xWXV455P7QrymWniK395kdSOadw7VkHLcrKsqSdldFEWSXUy3+FLbRJIK
	 x0RRMbAvHLcmnRqAqdeSh8J2yYlM5wh8KcNjB0gSw8v8JNmjrX/CclIleKRaW2mQY5WYW
	 0JSrcIvEjKkj3rsf0o09KqJIW1iNjDZc3am9nlK3TuC3rxaYguxP2vDD+mGJbXqNgWw==
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=Sm2jURRu;
	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 6261F606A33B;
	Sat,  5 Dec 2026 04:18:00 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id E51391F00A1D;
	Sat,  5 Dec 2026 04:17:58 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796444280;
	bh=otvXuEHS/bNwdzfmcGGBizbGGL0IxkR3gAbRNCRROX4=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Sm2jURRu3ZJ5rjyIIjA/cps0dHoWD+Xk0f8tqWVNbSp/U0furyWfSxiw1+JHlFZkQ
	 XcMAW+lILIY4bPLNH8nS+azg4QuzvWwCtNX4+6th27SY+KZkUlbQ4/b1DPySjR7Kn/
	 AhcEMJ4H1MWjhvhggRvL1F9gf1LPH3crt2G0HY+cbCIf6ot3mlmk+hi2Qo31/+jxw1
	 +SoSTpV2s0P2QXHY3lDH8VzsDkb/L+c9WBaQmfQmooHlp5j+s3ETB0gl5G7Xx7UKBn
	 RVI/RkAQjRXwM8MbVnDYHWgj3Ru4300Hmus+209mKYs16j4WmHbHGtd2f4TBBHFXXk
	 gyc+Y+9MoI17Q==
X-Cc: wudi234@huawei.com, tengpeisen@huawei.com, netdev@vger.kernel.org,
 davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
 horms@kernel.org, andrew+netdev@lunn.ch, ioana.ciornei@nxp.com,
 maxime.chevallier@bootlin.com, mohsin.bashr@gmail.com,
 dimitri.daskalakis1@gmail.com, hramamurthy@google.com,
 larysa.zaremba@intel.com, vadim.fedorenko@linux.dev,
 linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
 zhoushuai28@huawei.com, wulike1@huawei.com
X-In-Reply-To: <e6517f439af43958005e92eac1422d9872aa6a3e.1796348433.git.gongfan1@huawei.com>
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