Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: acassen@corp.free.fr
Cc: saeedm@nvidia.com, leon@kernel.org, tariqt@nvidia.com,
	mbloch@nvidia.com, jhs@mojatatu.com, jiri@resnulli.us,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	michael.chan@broadcom.com, pavan.chebbi@broadcom.com,
	bharat@chelsio.com, donald.hunter@gmail.com, corbet@lwn.net,
	skhan@linuxfoundation.org, rdunlap@infradead.org,
	dsahern@kernel.org, idosch@nvidia.com, shuah@kernel.org,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
	oss-drivers@corigine.com
Subject: Re: [PATCH net-next v3 08/11] net/mlx5e: TC, offload RX queue mapping in NIC flows
Date: Mon, 23 Nov 2026 21:34:30 +0000	[thread overview]
Message-ID: <179546967077.3135.3838730458941932181@kernel.org> (raw)
In-Reply-To: <20261122213200.3207385-9-acassen@corp.free.fr>

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

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

- [Medium] TC skbedit rx_queue rules are not protected when the channel
  count is reduced, so their traffic is dropped without any warning.
- [Low] tc_act_can_offload_rx_queue() reads
  flow->priv->channels.params.num_channels without a lock and without…

--

net/mlx5e: TC, offload RX queue mapping in NIC flows

This adds offload of TC skbedit queue_mapping to mlx5e NIC flows. The
rule's destination is set to the channel's direct TIR, the same way
ethtool steering rules work. The action must be the last one and cannot
follow a terminating action.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/rx_queue.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/rx_queue.c
> new file mode 100644
> index 0000000000000..32598a2163009
> --- /dev/null
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/rx_queue.c
> @@ -0,0 +1,67 @@

[ ... ]

> +static bool
> +tc_act_can_offload_rx_queue(struct mlx5e_tc_act_parse_state *parse_state,
> +			    const struct flow_action_entry *act,
> +			    int act_index,
> +			    struct mlx5_flow_attr *attr)
> +{

[ ... ]

> +	if (act->rx_queue >= flow->priv->channels.params.num_channels) {

[Severity: Low]

Is this read of priv->channels.params.num_channels safe against a
concurrent channel change?

The NIC flower offload path runs without RTNL, because mlx5e_setup_tc()
sets:

	f->unlocked_driver_cb = true;

and mlx5e_configure_flower()->parse_tc_actions() does not take
priv->state_lock either.

Meanwhile, ethtool set_channels rewrites the whole struct in
mlx5e_switch_priv_channels() while holding state_lock and RTNL:

	priv->channels = *new_chs;

So a "tc filter add" that races with "ethtool -L" is a plain data race
on num_channels, which KCSAN would report.

The commit message says:

  "Direct TIRs exist up to the maximum channel count. The rule always
  points to a valid one."

That claim depends on this unannotated read always returning a value
<= max_nch. This check is the only bound applied before
tc_act_parse_rx_queue() indexes res->channels[] through
mlx5e_rx_res_get_tirn_direct().

Would it make sense to use READ_ONCE() here, or to also check
act->rx_queue against mlx5e_rx_res_get_max_nch(priv->rx_res)?

> +		NL_SET_ERR_MSG_MOD(extack, "RX queue index out of range");
> +		return false;
> +	}
> +
> +	return true;
> +}
> +
> +static int
> +tc_act_parse_rx_queue(struct mlx5e_tc_act_parse_state *parse_state,
> +		      const struct flow_action_entry *act,
> +		      struct mlx5e_priv *priv,
> +		      struct mlx5_flow_attr *attr)
> +{
> +	attr->nic_attr->rx_tirn = mlx5e_rx_res_get_tirn_direct(priv->rx_res,
> +							       act->rx_queue);

[Severity: Medium]

The rx_queue range check in tc_act_can_offload_rx_queue() runs only when
the rule is added. Nothing looks at the TIR number stored here again.

What happens to this rule if the channel count is later reduced, for
example with "ethtool -L <dev> combined N" where N <= rx_queue?

mlx5e_add_offloaded_nic_rule() installs nic_attr->rx_tirn as the FTE
destination. When the channel becomes inactive, the RQT behind that TIR
is redirected to the drop RQ in
mlx5e_rx_res_channel_deactivate_direct():

	err = mlx5e_rqt_redirect_direct(&res->channels[ix].direct_rqt, res->drop_rqn, NULL);

The hardware rule keeps matching, so all matching traffic is dropped.
The rule is not rejected and the user is not told.

ethtool ntuple rules use the same direct TIRs, and the ethtool core
protects them: it refuses the reduction through
ethtool_get_max_rxnfc_channel() in net/ethtool/common.c.
mlx5e_ethtool_set_channels() has no equivalent check for TC rules.

The commit message notes this:

  "ethtool refuses such a change for its own rules but nothing tracks
  the queues of TC rules."

Could the driver track the highest rx_queue used by TC rules and refuse
a channel reduction below it in mlx5e_ethtool_set_channels(), the same
way ethtool rules are handled?

> +	attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
> +
> +	return 0;
> +}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122213200.3207385-1-acassen%40corp.free.fr

  reply	other threads:[~2026-11-23 21:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22 21:31 [PATCH net-next v3 00/11] tc flower: tunnel key partitioning for RX queue steering Alexandre Cassen
2026-11-22 21:31 ` [PATCH net-next v3 01/11] bnxt_en: require an exact tunnel id in TC flows Alexandre Cassen
2026-11-22 21:31 ` [PATCH net-next v3 02/11] cxgb4: flower: refuse a tunnel key wider than the VNI Alexandre Cassen
2026-11-22 21:31 ` [PATCH net-next v3 03/11] nfp: " Alexandre Cassen
2026-11-22 21:31 ` [PATCH net-next v3 04/11] net/mlx5e: TC, " Alexandre Cassen
2026-11-22 21:31 ` [PATCH net-next v3 05/11] net/mlx5e: TC, reject a partial tunnel key with tunnel mapping Alexandre Cassen
2026-11-23 21:34   ` netdev-bot+sashiko
2026-11-22 21:31 ` [PATCH net-next v3 06/11] net/sched: cls_flower: add enc_key_id mask Alexandre Cassen
2026-11-22 21:31 ` [PATCH net-next v3 07/11] selftests: forwarding: tc_flower: test the " Alexandre Cassen
2026-11-23 21:34   ` netdev-bot+sashiko
2026-11-22 21:31 ` [PATCH net-next v3 08/11] net/mlx5e: TC, offload RX queue mapping in NIC flows Alexandre Cassen
2026-11-23 21:34   ` netdev-bot+sashiko [this message]
2026-11-22 21:31 ` [PATCH net-next v3 09/11] net/mlx5e: TC, reject tunnel keys without a tunnel device Alexandre Cassen
2026-11-23 21:34   ` netdev-bot+sashiko
2026-11-22 21:31 ` [PATCH net-next v3 10/11] net/mlx5e: TC, match the tunnel key " Alexandre Cassen
2026-11-22 21:31 ` [PATCH net-next v3 11/11] docs: networking: describe tunnel key partitioning in TC queue filtering Alexandre Cassen
2026-11-23 21:34   ` netdev-bot+sashiko
2026-11-22 21:45 ` [PATCH net-next v3 00/11] tc flower: tunnel key partitioning for RX queue steering sashiko-bot

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=179546967077.3135.3838730458941932181@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=acassen@corp.free.fr \
    --cc=andrew+netdev@lunn.ch \
    --cc=bharat@chelsio.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@corigine.com \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.com \
    --cc=rdunlap@infradead.org \
    --cc=saeedm@nvidia.com \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=tariqt@nvidia.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