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 v2 08/10] net/mlx5e: TC, offload RX queue mapping in NIC flows
Date: Fri, 20 Nov 2026 03:30:42 +0000	[thread overview]
Message-ID: <179514544232.3136.10984795533608621568@kernel.org> (raw)
In-Reply-To: <20261117092915.255194-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] A TC rule that maps a flow to an RX queue keeps a hardware
  destination that turns into a silent blackhole once the channel count…
- [Low] tc_act_can_offload_rx_queue()
  (drivers/net/ethernet/mellanox/mlx5/core/en/tc/act/rx_queue.c:42)…

--

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

This adds offload of the skbedit queue_mapping action to mlx5e NIC TC
flows. The rule's destination becomes the direct TIR of the requested
channel. The action must be the last one and must not 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

[ ... ]

> +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) {
> +		NL_SET_ERR_MSG_MOD(extack, "RX queue index out of range");
> +		return false;
> +	}

[Severity: Medium]
The queue index is only checked against num_channels here, when the rule
is inserted. What happens to the offloaded rule after a later
"ethtool -L combined N" with N <= rx_queue?

tc_act_parse_rx_queue() stores the direct TIR number in nic_attr->rx_tirn.
mlx5e_add_offloaded_nic_rule() then programs it as a TIR destination.

On the channel switch:

mlx5e_switch_priv_channels()
  mlx5e_deactivate_priv_channels()
    mlx5e_rx_res_channels_deactivate()
      mlx5e_rx_res_channel_deactivate_direct()
        mlx5e_rqt_redirect_direct(&res->channels[ix].direct_rqt,
                                  res->drop_rqn, NULL);

mlx5e_rx_res_channels_activate() then re-points the direct RQTs only for
indices below the new channel count. The FTE still points at the direct
TIR for rx_queue, and that TIR's RQT now points at the drop RQ. Hardware
drops the matched flow, but tc still reports the filter as in_hw.

The ethtool core check (ethtool_get_max_rxnfc_channel() and
ethtool_get_max_rxfh_channel() in net/ethtool/common.c) only knows about
ntuple and RSS users. So the reduction is allowed, and nothing
re-validates, reprograms or removes the TC rule.

The drops are counted on priv->drop_rq_q_counter, and
mlx5e_grp_q_update_stats() reports them as rx_if_down_packets even though
the interface is up.

The commit message acknowledges this:

  "Reducing the channel count below the queue of a rule drops its traffic
  until the channel returns."

Could the driver track the queues used by TC rules, so that set_channels
can refuse the change as it does for ethtool's own rules? Alternatively,
could it reprogram the affected rules so they don't keep dropping
traffic?

[Severity: Low]
Is it safe to read priv->channels.params.num_channels here without a lock?

mlx5e_setup_tc() sets f->unlocked_driver_cb = true, so this path can run
without rtnl:

mlx5e_configure_flower()->...->parse_tc_nic_actions()->parse_tc_actions()
  ->tc_act_can_offload_rx_queue()

This path doesn't take priv->state_lock either. Meanwhile,
mlx5e_switch_priv_params() and mlx5e_switch_priv_channels() overwrite the
structures with plain struct copies under state_lock:

    priv->channels.params = *new_params;
    ...
    priv->channels = *new_chs;

The two sides share no lock, so this is an unannotated data race that
KCSAN would likely report.

The check is also check-then-act:

CPU0 (tc filter add)           CPU1 (ethtool -L combined 4)
reads num_channels == 8
accepts rx_queue == 7
                               switches channels, direct RQT 7 now
                               points at the drop RQ
installs FTE to direct TIR 7

The filter add succeeds, but its traffic is silently dropped. Direct TIRs
exist for all max_nch indices, so the rule still references a valid TIR.

The commit message mentions this window too ("A channel change racing
with the range check of a new rule has the same result").

If the channel reduction issue above is fixed by tracking TC queue usage,
would this check also need to run under priv->state_lock?

> +
> +	return true;
> +}

[ ... ]

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

  parent reply	other threads:[~2026-11-20  3:30 UTC|newest]

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

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=179514544232.3136.10984795533608621568@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