From: netdev-bot+sashiko@kernel.org
To: kuba@kernel.org
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
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 [thread overview]
Message-ID: <179539763134.3135.16178645255065325636@kernel.org> (raw)
In-Reply-To: <20261122010112.1471146-7-kuba@kernel.org>
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
next prev parent reply other threads:[~2026-11-23 1:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 1:01 [PATCH net-next v2 0/9] net: make core auto-disable HW-GRO and LRO when XDP gets attached Jakub Kicinski
2026-11-22 1:01 ` [PATCH net-next v2 1/9] net: stop making HW-GRO depend on SW GRO Jakub Kicinski
2026-11-22 1:01 ` [PATCH net-next v2 2/9] selftests: drv-net: gro_stats: use the shared set_ethtool_feat() Jakub Kicinski
2026-11-22 1:01 ` [PATCH net-next v2 3/9] selftests: drv-net: drop the generic XDP hack from the HW GRO setup Jakub Kicinski
2026-11-22 1:01 ` [PATCH net-next v2 4/9] net: state the "XDP excludes HW-GRO" rule in the core Jakub Kicinski
2026-11-23 1:33 ` netdev-bot+sashiko
2026-11-22 1:01 ` [PATCH net-next v2 5/9] net: state the "XDP excludes LRO" " Jakub Kicinski
2026-11-23 1:33 ` netdev-bot+sashiko
2026-11-22 1:01 ` [PATCH net-next v2 6/9] eth: mlx5e: drop the now-dead HW-GRO and LRO vs XDP handling Jakub Kicinski
2026-11-23 1:33 ` netdev-bot+sashiko [this message]
2026-11-22 1:01 ` [PATCH net-next v2 7/9] eth: bnxt_en: don't clear HW-GRO and LRO for XDP in ndo_fix_features Jakub Kicinski
2026-11-22 1:01 ` [PATCH net-next v2 8/9] eth: qede: drop the now-dead HW-GRO vs XDP handling Jakub Kicinski
2026-11-22 1:01 ` [PATCH net-next v2 9/9] eth: gve: drop the now-dead HW-GRO vs XDP interlock Jakub Kicinski
2026-11-23 1:33 ` 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=179539763134.3135.16178645255065325636@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=hramamurthy@google.com \
--cc=joshwash@google.com \
--cc=kuba@kernel.org \
--cc=manishc@marvell.com \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=nktgrg@google.com \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=saeedm@nvidia.com \
--cc=sdf@fomichev.me \
--cc=tariqt@nvidia.com \
--cc=willemb@google.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