🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #20638

Re: [PATCH net-next v2 6/9] eth: mlx5e: drop the now-dead HW-GRO and LRO vs XDP handling

#20638
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 01:33
225 lines
16199 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

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

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).

- [High] The patch removes mlx5e's own HW-GRO/LRO vs XDP handling.
- [Medium] The patch keys the whole NETDEV_XDP_ACT_XSK set
  (BASIC|REDIRECT|XSK_ZEROCOPY, plus RX_SG) in mlx5e_set_xdp_feature()…
- [Medium] mlx5e_set_xdp_feature() now dereferences
  priv->netdev->cfg_pending->hds_config.

--

eth: mlx5e: drop the now-dead HW-GRO and LRO vs XDP handling

This patch removes the mlx5e driver-side refusal of an XDP attach while
HW-GRO or LRO is on. It also removes the XDP clause in mlx5e_fix_features()
and relies on the core to clear those features and keep them off while a
program is attached. XDP features are now advertised based on
tcp-data-split rather than packet merge, and mlx5e_set_ringparam()
refreshes them when hds changes.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index 06a8a4be4be7c..08568137d044d 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> @@ -4487,12 +4487,14 @@ static int mlx5e_handle_feature(struct net_device *netdev,
>  
>  void mlx5e_set_xdp_feature(struct mlx5e_priv *priv)
>  {
> +	struct netdev_config *cfg = priv->netdev->cfg_pending;

[Severity: Medium]
Is it safe to dereference netdev->cfg_pending here without the netdev
instance lock?

Two callers run mlx5e_set_xdp_feature() on a registered netdev with only
rtnl_lock held: mlx5e_nic_init() and mlx5e_build_rep_params(). Both follow
this pattern:

	if (take_rtnl)
		rtnl_lock();

	/* update XDP supported features */
	mlx5e_set_xdp_feature(priv);

	if (take_rtnl)
		rtnl_unlock();

Both callers are reachable from mlx5e_netdev_change_profile() during
eswitch mode changes.

ethnl_default_set_doit() allocates, swaps and frees cfg_pending while
holding only the instance lock. It does this for the commands mlx5e does
not opt in to rtnl, such as COALESCE_SET, PAUSE_SET, RSS_SET and
LINKMODES_SET:

	ret = netdev_reconfig_start(dev);
	...
out_free_cfg:
	__netdev_free_config(dev->cfg_pending);
	dev->cfg_pending = dev->cfg;

Could the following interleaving read freed memory?

CPU1 (COALESCE_SET, instance lock)
    dev->cfg_pending = P;               /* fresh copy */

CPU0 (profile change, rtnl only)
    cfg = netdev->cfg_pending;          /* P */

CPU1
    __netdev_free_config(P);
    dev->cfg_pending = dev->cfg;

CPU0
    cfg->hds_config                     /* reads freed P */

Reading dev->cfg instead doesn't look safe either. On a successful SET,
the old dev->cfg is swapped into the pending slot and then freed.

Would taking netdev_lock() after rtnl_lock() around these calls work here?
That is the same order mlx5e_nic_enable() uses.

>  	struct mlx5e_params *params = &priv->channels.params;
>  	struct net_device *netdev = priv->netdev;
>  	xdp_features_t val = 0;
>  
> +	/* XDP can't run with HW-GRO, and tcp-data-split keeps HW-GRO on */
>  	if (netdev->netdev_ops->ndo_bpf &&
> -	    params->packet_merge.type == MLX5E_PACKET_MERGE_NONE)
> +	    cfg->hds_config != ETHTOOL_TCP_DATA_SPLIT_ENABLED)
>  		val = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
>  		      NETDEV_XDP_ACT_XSK_ZEROCOPY |
>  		      NETDEV_XDP_ACT_RX_SG;

[Severity: Medium]
Does keying these bits off hds_config also change how AF_XDP zero-copy
bind behaves?

Together, BASIC, REDIRECT and XSK_ZEROCOPY make up NETDEV_XDP_ACT_XSK, and
xp_assign_dev() checks that set before it allows a zero-copy bind:

net/xdp/xsk_buff_pool.c:xp_assign_dev() {
	...
	if ((netdev->xdp_features & NETDEV_XDP_ACT_XSK) != NETDEV_XDP_ACT_XSK) {
		err = -EOPNOTSUPP;
		goto err_unreg_pool;
	}
	...
}

Before this patch, a zero-copy bind on mlx5e with LRO or HW-GRO on was
refused, or fell back to copy mode. Now it reaches this path:

ndo_bpf(XDP_SETUP_XSK_POOL)
  mlx5e_xsk_setup_pool()
    mlx5e_xsk_enable_locked()

mlx5e_xsk_enable_locked() registers the pool and bumps priv->xsk.refcnt
without checking packet_merge.

Nothing on that path calls netdev_update_features(), and
dev_xdp_clear_rx_agg() only runs for XDP_SETUP_PROG. So the commit message
says "The AF_XDP check stays", but the priv->xsk.refcnt clause in
mlx5e_fix_features() is not applied at bind time. LRO or HW-GRO stays on
while an XSK pool is bound.

This also seems to open a sequence that was unreachable before:

1. Bind a zero-copy XSK with HW-GRO on and tcp-data-split=auto.
2. Set tcp-data-split=enabled. mlx5e_ethtool_set_tcp_data_split() accepts
   it because GRO_HW is still in dev->features.
3. mlx5e_fix_features() clears GRO_HW in the XSK clause, then the HDS
   clause forces it back on.
4. mlx5e_set_ringparam() calls mlx5e_set_xdp_feature(), which withdraws
   XSK_ZEROCOPY while a zero-copy pool is still bound.

The commit message only describes the XDP attach change ("used to fail
with -EINVAL and now succeeds"). Should the AF_XDP zero-copy bind change
be handled here, or at least described?

[ ... ]

> @@ -4604,17 +4606,6 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev,
>  		}
>  	}
>  
> -	if (params->xdp_prog) {
> -		if (features & NETIF_F_LRO) {
> -			netdev_warn(netdev, "LRO is incompatible with XDP\n");
> -			features &= ~NETIF_F_LRO;
> -		}
> -		if (features & NETIF_F_GRO_HW) {
> -			netdev_warn(netdev, "HW GRO is incompatible with XDP\n");
> -			features &= ~NETIF_F_GRO_HW;
> -		}
> -	}
> -

[Severity: High]
On mlx5e, does the core really keep HW-GRO off for as long as a program is
attached?

__netdev_update_features() strips NETIF_F_XDP_DISABLES only before it calls
ndo_fix_features, and doesn't check again afterwards:

net/core/dev.c:__netdev_update_features() {
	...
	if ((features & NETIF_F_XDP_DISABLES) && dev_xdp_prog_count(dev)) {
		netdev_dbg(dev, "Dropping HW-GRO and LRO features since XDP is attached.\n");
		features &= ~NETIF_F_XDP_DISABLES;
	}

	if (dev->netdev_ops->ndo_fix_features)
		features = dev->netdev_ops->ndo_fix_features(dev, features);
	...
}

Later, mlx5e_fix_features() adds GRO_HW back unconditionally for HDS:

	if (cfg && cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
	    !(features & NETIF_F_GRO_HW)) {
		...
		features |= NETIF_F_GRO_HW;
	}

Can this sequence leave SHAMPO active with an XDP program attached?

1. Enable HW-GRO and tcp-data-split.
2. Run ethtool -K <dev> rx-fcs on (or rx off). netdev_fix_features() drops
   GRO_HW after the driver hook, and set_feature_hw_gro(false) sets
   packet_merge to NONE. hds_config stays ENABLED.
3. Attach a multi-buffer native XDP program. dev_xdp_install() only
   refuses hds for !xdp_has_frags, and dev_xdp_clear_rx_agg() sees no
   GRO_HW or LRO. mlx5e_xdp_set() now only calls
   mlx5e_params_validate_xdp().
4. Run ethtool -K <dev> rx-fcs off. The core strips GRO_HW, then
   mlx5e_fix_features() forces it back for HDS, and netdev_fix_features()
   no longer drops it. mlx5e_set_features()->set_feature_hw_gro(true)
   then switches packet_merge to SHAMPO with params.xdp_prog set.

With SHAMPO, the RQs use mlx5e_handle_rx_cqe_mpwrq_shampo(). Header-split
packets go through mlx5e_skb_from_cqe_shampo(), which never runs
rq->xdp_prog, so that traffic would skip the attached program.

The removed xdp clause had the same ordering problem, because it ran
before the HDS clause. However, this patch removes the driver-side
handling on the basis of the core guarantee, and the gap still seems to
be there at the end of the series.

Is anything on this path meant to reject SHAMPO while an XDP program is
attached?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122010112.1471146-1-kuba%40kernel.org
Technical Details
Message-ID: <179539763134.3135.16178645255065325636@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368940-linux-kernel-netdev=dewy.ru
References: <20261122010112.1471146-7-kuba@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368940-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 6/9] eth: mlx5e: drop the now-dead HW-GRO and
 LRO vs XDP handling
Date: Mon, 23 Nov 2026 01:33:51 +0000
Organization: Usenet Network
Message-ID: <179539763134.3135.16178645255065325636@kernel.org>
References: <20261122010112.1471146-7-kuba@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3763919"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:dSPmmlXp4+zKA+cZ36MlceVYEnE= sha256:kUNOh6thFdIAvT16j12jVXAraKVMru6T4XvGqAXxJzs=
	sha1:qbpG0SIzuP5eBO73shfpT8r3Q2Q= sha256:6O07iAyjCat7QJggindABSu+X46pb7PJadPwMpBQ7mM=
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 63FD3125D8C; Mon, 23 Nov 2026 04:34:19 +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 j9USYGRsNNxz;
	Mon, 23 Nov 2026 04:34:15 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-368940-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 8F9CA125D8E; Mon, 23 Nov 2026 04:34:02 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 24DDB23631; Mon, 23 Nov 2026 01:33:58 +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=1795397634;
	b=mkpWhsSo32eCwJAc72YzMF0l/oV+8wSXkPqn0H3kNkYou+FdBCupFVnUrcCYtUuiZAr6
	 22bgG8+H1x7G6s/EHflCikbE6j4oY88PtT33wzwS4zQOyBWCUwBYAACgndeU5jZ4DZRCG
	 c666VMy3lDlKHVf4TMtKAo36T2LAOJf9bGQY9er8ZsJOPVR+NgoEwcLejxouK5EmJnn8U
	 eKvC8TFBUjvxf4UTH071+nMUNCZ+22MJqtLfcCahjAx+ey49Mu17aexfnxva9hLjf9W0c
	 rTf3IR+u6Zj+UL379b14IuoFusdeQCAzCfHdGJqg2jwJnRNbF6CEoKZQY8P2PzG5E2Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795397634;
	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=hSrhjQ/TWRX4InbKWtKHtYXAh19fxrq/c8z+nCcpNxE=;
	b=2evu2LY/6wdj/2Be+e/sZMINybb7Y2VrI/gBOAhqpOzYCIgatJmuBM5fPoxCQ26ZM17U
	 buPWLEPp81cl5bDVp+Lse3D+X9DgiEYp7E/CN1Xm0tap6iF5HMA6GdSyZakQo53lyDiy3
	 mtC+7KofUhpZCWiyU4CTPFgPsWgwMER54Qn/umyXJbPX/Dg00EIfnqQgmia7KhJfvckC+
	 DTbj8vbaNZh0IcmpZC2yP8fCQN38BuQsP6c/h1apC41MwprLSwCFSw1fmgW4YYHsEH0FA
	 1k5UUH44gOr7UiMCavJomHh6hZ3sTJ2dO7osrz+OhNLvNRwa8gLzPTvOwes8mNTgIeQ==
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=DjfRabsX;
	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 E9940606A32A;
	Mon, 23 Nov 2026 01:33:53 +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=DjfRabsX
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=1795397633;
	b=OvgJfiht9uc9Yrmb0SGU1H4+3f3efpESjuppT0Gdvl9eW3E9sSNCMv9BeYpM7KWzhKti
	 O6E5ZAAhnCdCB455xDWsPzPe0HMrrQXEFnE/Ku7HdX66iSJa6nO33/ZxQMHY6mjJldZCo
	 riCeLlCeOgOmXd6vql5Dc7f9AgW8Xvz9W3tRNyQwUDkGS3Nhg+dSkPJ3Lc2r98vNjLAFk
	 JaoIopXEiut3M9d611kiPFuXCQ1Jf3NGePEFCJ9/2AZ4lxes6ESN2UP4YzxwaogXfucel
	 lf3pA1XBF9UbyWRfwBUAb9Ly8R8VAhYc5QVJ0B5uDim6NWIKyIElw7veCwOhU0nWRWw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795397633;
	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=hSrhjQ/TWRX4InbKWtKHtYXAh19fxrq/c8z+nCcpNxE=;
	b=LBfVTM0zenoO+1AWPcqbKsbv06ujyEDPURURkLEsBaRFcLJtyxVK8mFznfDEuKElBgUP
	 bC7Ri+/r3UXL606zvcnq2kzEFznFNEgn9a/qCFYhvBltQefD2vU/o6/FVoVpQwxlyGCYW
	 iCk2Y7qV8RGqLRt63dLuDmCCSnL2DN7iRr4bCHKvkHv1Rieu/A928QMC5qBnreb+6AXBE
	 VxO5TiYDkTviGU7YDFuZBoH1fM0zIc7EavA6vGc3fE74z03Hn9Fq72Z9p1mVVXrtb9ZhR
	 MOPy9k0XBk/D7JuWS87Exifsxc9YrKHfXNukl5JTprBmjwHPpHbPHtWOHSLA1WxwQvQ==
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=DjfRabsX;
	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 1592B606A683;
	Mon, 23 Nov 2026 01:33:52 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9FA41F000C4;
	Mon, 23 Nov 2026 01:33:51 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795397632;
	bh=hSrhjQ/TWRX4InbKWtKHtYXAh19fxrq/c8z+nCcpNxE=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=DjfRabsXEcvkrNBAKFQ6l8gc8rtUoMV6pzUvAvkSWF6vBkeWa0CCGIdn8vGD0MAzQ
	 dU8RX+SIZgDjjegpfTvzYlr/eDJUcA0nO63sZEvQ0wNP6J9dIjSRjo7eqJaTxTiNRD
	 MyNcMp+WrUUi9EBNIG1IhiLFQ319Zlmx3rKM+dE4QisAZsyNwe6AgJdfAWi7tlSfr3
	 WevaCinA8TObY6N8+e0Ott6V0Y+z7fkvI2H/YyMGy1yP7Om2ybyxdwG1lqFHQDSnAQ
	 Dgb2r4YuyNw5I8YNm/uEtKk26dmWfCcYiUftR59L1UjlmC1jM1s1gtg6o/1z19sp0C
	 6CmYL3IQNOn5g==
X-Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
 pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org,
 michael.chan@broadcom.com, manishc@marvell.com, joshwash@google.com,
 hramamurthy@google.com, tariqt@nvidia.com, saeedm@nvidia.com,
 daniel@iogearbox.net, hawk@kernel.org, sdf@fomichev.me, willemb@google.com,
 przemyslaw.kitszel@intel.com, bpf@vger.kernel.org, nktgrg@google.com
X-In-Reply-To: <20261122010112.1471146-7-kuba@kernel.org>
X-sashiko-severity: High
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