Linux Documentation
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: gongfan1@huawei.com
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
Subject: Re: [PATCH net-next v19 4/4] hinic3: Add ethtool pause param ops
Date: Sat, 05 Dec 2026 04:17:58 +0000	[thread overview]
Message-ID: <179644427846.3146.11969061479529550723@kernel.org> (raw)
In-Reply-To: <e6517f439af43958005e92eac1422d9872aa6a3e.1796348433.git.gongfan1@huawei.com>

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

      reply	other threads:[~2026-12-05  4:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  4:08 [PATCH net-next v19 0/4] net: hinic3: Support ethtool ops Fan Gong
2026-12-04  4:08 ` [PATCH net-next v19 1/4] hinic3: Add ethtool statistic ops part(1/2) Fan Gong
2026-12-05  4:17   ` netdev-bot+sashiko
2026-12-04  4:08 ` [PATCH net-next v19 2/4] hinic3: Add ethtool statistic ops part(2/2) Fan Gong
2026-12-05  4:17   ` netdev-bot+sashiko
2026-12-04  4:08 ` [PATCH net-next v19 3/4] hinic3: Add per-queue netdev-genl stats Fan Gong
2026-12-05  4:17   ` netdev-bot+sashiko
2026-12-04  4:08 ` [PATCH net-next v19 4/4] hinic3: Add ethtool pause param ops Fan Gong
2026-12-05  4:17   ` 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=179644427846.3146.11969061479529550723@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dimitri.daskalakis1@gmail.com \
    --cc=edumazet@google.com \
    --cc=gongfan1@huawei.com \
    --cc=horms@kernel.org \
    --cc=hramamurthy@google.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=kuba@kernel.org \
    --cc=larysa.zaremba@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mohsin.bashr@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tengpeisen@huawei.com \
    --cc=vadim.fedorenko@linux.dev \
    --cc=wudi234@huawei.com \
    --cc=wulike1@huawei.com \
    --cc=zhoushuai28@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