🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19589

Re: [PATCH net-next v2 08/10] net/mlx5e: TC, offload RX queue mapping in NIC flows

#19589
From: netdev-bot+sashiko
Date: Fri, 20 Nov 2026 03:30
135 lines
13137 bytes
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
Technical Details
Message-ID: <179514544232.3136.10984795533608621568@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367606-linux-kernel-netdev=dewy.ru
References: <20261117092915.255194-9-acassen@corp.free.fr>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367606-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179514544232.3136.10984795533608621568@kernel.org>
References: <20261117092915.255194-9-acassen@corp.free.fr>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3050549"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ShXrk4ZFC1mdYKIpCd0es890U+Y= sha256:Yvhl2ExlAQxVfzys8A3QeVEm9mrKq63j+tUbo2TCZvI=
	sha1:jeYGaIcdoIVaxKxuW1nQQrl6o88= sha256:m0zpheAYc8iyeQt/tsEJVq5qo2dlSBk7k72M/QlynRs=
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 0A1B011588F; Fri, 20 Nov 2026 06:31:08 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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, URIBL_BLOCKED=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 7IOy0ktVh8hc;
	Fri, 20 Nov 2026 06:31:04 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-367606-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 E197F115858; Fri, 20 Nov 2026 06:30:55 +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 E460D83592; Fri, 20 Nov 2026 03:30:45 +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=1795145445;
	b=hRKcPyODv/E/aDGhxmHzELw7oujgSBzroz42U6U2c/C9xq4McF64VJCZph7QfcV6fB2d
	 hBTCQ2Fo/9iuZYi97nFDwLonpzDWQ2i5TLpRNMRepvQHjyiV7/O5ocj6W2wKlBX//KqRl
	 8ztwNAZYCSfOOrE7Uj+lXsj/O/zWFDRv6dnx5bR6jf0TY7tsFToCuic6ISnZ0u8isi5V1
	 QdLl1E59w/Vgb3AzyhsWUmdR8WpMs0e2T98eiepoFOBENbkPNSZ5+IkxzZyIcU+ttsbqZ
	 uzLMmSscgtgSjk04ptBBBTjhXpxshFzwof6ed0DY/PWLrLmUWURIAC0FSl+pLTMdRlA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795145445;
	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=JEbsS3L/h/hHVQUZ7EK4zXodUkr5QxYRn1luefQLwmg=;
	b=qnryV1xPqf159HS72xr6P9XnLK0vKezFfwqEYpDWFTIP43E3MWgSov1zdIjNCkpzP2Lf
	 6ktgKIf76QwQbhgRXzVOfPLSw06BrAelGCM1T4q9UgUHIFAZwa2gHnVlUk5zdy+BWHfCg
	 7AJ+t4EWfz2SAbQX3di4zSHWmxX4GdtXw/vQx2nseCPtJiIAusyVUi+bhoYq0qdX7cTbV
	 Wb0vINmdy8JKYYzWEy5bAV6CjIJl7R/2cUWxRJPhbJxoLm3isCl5qY+J899WDof0wzyTN
	 BbVE20bNETxpZtq/rT5+aibJ9/aEi3pgd8z8Dr0y7BGD6LZfXzDosl/8mV3qAgk+Aog==
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=jx3xeSU5;
	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 596D9606A33D;
	Fri, 20 Nov 2026 03:30:45 +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=jx3xeSU5
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=1795145444;
	b=QIbOKwRmlyB8zhmuO+1Hhdmj8pYQO2n6vzF0FI3O0wsz4CU3k8JnqnG6uHcAwXOw9J15
	 grx8RqJZSWbyca53ffBXdPCmpsYwSiCXDm0WVb6P6QKoTQWAMPdRCMoSlWWvFO2tGrvBL
	 ruBxzjuvwnYIimHr/E0jQg6A9N1cRn+41rn/mqk+9PbfdXnaVlP4M2nb40cEDB5SozSO6
	 mYwhI7osZv5Dhl5Nrte5+fndoQibBgUJK8GYPeQFPFMafoz2Ss8PvzhJPwT2AvC5lE2Pl
	 kGfHE/ruMO1OhgZkbubMslno/xa9zJ3Hv/q1Qst7/MP0OMRIayAO3eaW39Q/TjXr6UA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795145444;
	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=JEbsS3L/h/hHVQUZ7EK4zXodUkr5QxYRn1luefQLwmg=;
	b=rG+jzZ9TjA+U8HRxohWLL2ugK5hMso8yzKR6qyN7UOg/uOBzxOf/EwBs+iUOXtozlr7S
	 sdFCCSEL2Kq5swfiUdx4pUk9we2ZmcEBHYWWp86Gy3LZ2BkP8DHnHCMQjyt4Ao7m/LppU
	 Q1Gy3XbijitbKAhlfJgX878JKCk4LLEJJSWWuahBIMibhXi+N5o5qL1tzWEAGiQewxaAF
	 EX2lKUIV1rNIHZ5WLIo97m/LIFLFUy9yeLJcnys0WzRKcpF1r+1ucRNqc/Qgwi9sOsDiK
	 z+xcECgWyr3UyJqxB3ZHTgvs1uYH9X8N4BMOX8//6K8Az8wgzdgNQntmd6cO8nmHhIQ==
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=jx3xeSU5;
	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 74D10606A333;
	Fri, 20 Nov 2026 03:30:44 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B55791F000C4;
	Fri, 20 Nov 2026 03:30:42 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795145444;
	bh=JEbsS3L/h/hHVQUZ7EK4zXodUkr5QxYRn1luefQLwmg=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=jx3xeSU59jyKOaAlGzeSDm71p9gj7Az9FVVDrXrm2MJX+NlhKqPzjESpPLEL+Kt3z
	 kHW191e+JLfpXatl/5wyG+GLrYn5Xum0afORLWn37zFS7h1Z06glVmBAhKjOXfc+b8
	 5uyzUEWVZYmNWFRqz8TtYFsYvkx0Jgo+TlGroPNRkVUxlKnxJy6iLPxfSeZANNIMbS
	 gPNFADV/UAzJaGK47M5AVuN6CHC0d3Bxh7l/CGG3cVRPt+mc68rFcxRia83qKyYPzu
	 UspIWMjCNXuv6w0NSvaZ7MKmO4KjHthVehFDS3MioUJ2NApFRcG978XnuV7VVbw5X8
	 +9ulhGBrZaRIw==
X-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
X-In-Reply-To: <20261117092915.255194-9-acassen@corp.free.fr>
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