🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
2 messages
2 total messages Started by Jakub Kicinski Wed, 18 Nov 2026 23:23
[PATCH net-next 5/8] eth: mlx5e: drop the now-dead HW-GRO and LRO vs XDP handling
#18803
Author: Jakub Kicinski
Date: Wed, 18 Nov 2026 23:23
77 lines
10597 bytes
The core clears HW-GRO and LRO before ndo_bpf runs and keeps them off
for as long as a program is attached. mlx5e_fix_features() never sees
either with params->xdp_prog set, and packet merge is always off by the
time mlx5e_xdp_set() gets called, packet_merge.type only follows the two
feature handlers. If tcp-data-split keeps HW-GRO on, the core refuses
the attach with -EBUSY before calling the driver.

The AF_XDP check stays, the core doesn't know about XSK pools.

This does change user visible behavior: attaching XDP with HW-GRO or LRO
on used to fail with -EINVAL and now succeeds with them turned off.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 .../net/ethernet/mellanox/mlx5/core/en_main.c | 32 ++-----------------
 1 file changed, 3 insertions(+), 29 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index d8563f863844..e462dfc725ae 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -4585,17 +4585,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;
-		}
-	}
-
 	if (priv->xsk.refcnt) {
 		if (features & NETIF_F_LRO) {
 			netdev_warn(netdev, "LRO is incompatible with AF_XDP (%u XSKs are active)\n",
@@ -5177,20 +5166,6 @@ static void mlx5e_tx_timeout(struct net_device *dev, unsigned int txqueue)
 	queue_work(priv->wq, &priv->tx_timeout_work);
 }
 
-static int mlx5e_xdp_allowed(struct net_device *netdev, struct mlx5_core_dev *mdev,
-			     struct mlx5e_params *params)
-{
-	if (params->packet_merge.type != MLX5E_PACKET_MERGE_NONE) {
-		netdev_warn(netdev, "can't set XDP while HW-GRO/LRO is on, disable them first\n");
-		return -EINVAL;
-	}
-
-	if (!mlx5e_params_validate_xdp(netdev, mdev, params))
-		return -EINVAL;
-
-	return 0;
-}
-
 static void mlx5e_rq_replace_xdp_prog(struct mlx5e_rq *rq, struct bpf_prog *prog)
 {
 	struct bpf_prog *old_prog;
@@ -5215,10 +5190,9 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
 	new_params = priv->channels.params;
 	new_params.xdp_prog = prog;
 
-	if (prog) {
-		err = mlx5e_xdp_allowed(netdev, priv->mdev, &new_params);
-		if (err)
-			goto unlock;
+	if (prog && !mlx5e_params_validate_xdp(netdev, priv->mdev, &new_params)) {
+		err = -EINVAL;
+		goto unlock;
 	}
 
 	/* no need for full reset when exchanging programs */
-- 
2.56.1
Re: [PATCH net-next 5/8] eth: mlx5e: drop the now-dead HW-GRO and LRO vs XDP handling
#20478
Author: netdev-bot+sashiko
Date: Sun, 22 Nov 2026 17:03
164 lines
14307 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

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

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] mlx5e_set_xdp_feature() in
  drivers/net/ethernet/mellanox/mlx5/core/en_main.c still sets…
- [Low] The commit message calls the removed code 'now-dead' and then
  says 'This does change user visible behavior: attaching XDP with HW-…
- [Low] mlx5e_xdp_set() still ends with '/* Need to fix some features.

--

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

The core now clears HW-GRO and LRO before ndo_bpf and keeps them off
while an XDP program is attached. This patch removes the xdp_prog clause
from mlx5e_fix_features() and the packet_merge refusal in
mlx5e_xdp_allowed(), and calls mlx5e_params_validate_xdp() directly from
mlx5e_xdp_set().

> This does change user visible behavior: attaching XDP with HW-GRO or LRO
> on used to fail with -EINVAL and now succeeds with them turned off.

[Severity: Low]
Is this attribution accurate? The subject calls the removed code
"now-dead". At the parent commit, the -EINVAL in mlx5e_xdp_allowed()
already looks unreachable:

dev_xdp_attach()
    dev->xdp_pending = 1;
    dev_xdp_clear_rx_agg()
        netdev_update_features()
            __netdev_update_features()
                strips NETIF_F_XDP_DISABLES (xdp_pending is counted
                by dev_xdp_prog_count())
                mlx5e_set_features()
                    set_feature_lro() / set_feature_hw_gro()
                        packet_merge.type = MLX5E_PACKET_MERGE_NONE
    ndo_bpf -> mlx5e_xdp_set()

netif_xdp_propagate() follows the same sequence. When HW-GRO is pinned,
the core returns -EBUSY before ndo_bpf is called.

So the change from -EINVAL to success seems to come from the earlier core
commits ("net: state the "XDP excludes HW-GRO" rule in the core" and
"net: state the "XDP excludes LRO" rule in the core"), not from this
patch.

Could the message say that, and also mention the dependency in the other
direction? This patch removes both mlx5e guards: the xdp_prog clause in
mlx5e_fix_features() and the packet_merge refusal. If it is applied or
backported without the core commits, XDP could run on LRO/HW-GRO
coalesced frames.

> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index d8563f8638447..e462dfc725ae4 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c

[ ... ]

> @@ -5177,20 +5166,6 @@ static void mlx5e_tx_timeout(struct net_device *dev, unsigned int txqueue)
>  	queue_work(priv->wq, &priv->tx_timeout_work);
>  }
>  
> -static int mlx5e_xdp_allowed(struct net_device *netdev, struct mlx5_core_dev *mdev,
> -			     struct mlx5e_params *params)
> -{
> -	if (params->packet_merge.type != MLX5E_PACKET_MERGE_NONE) {
> -		netdev_warn(netdev, "can't set XDP while HW-GRO/LRO is on, disable them first\n");
> -		return -EINVAL;
> -	}

[Severity: Medium]
With this refusal gone, does mlx5e_set_xdp_feature() also need an
update? It still advertises native XDP only when packet merge is off:

drivers/net/ethernet/mellanox/mlx5/core/en_main.c:mlx5e_set_xdp_feature() {
    ...
	if (netdev->netdev_ops->ndo_bpf &&
	    params->packet_merge.type == MLX5E_PACKET_MERGE_NONE)
		val = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
		      NETDEV_XDP_ACT_XSK_ZEROCOPY |
		      NETDEV_XDP_ACT_RX_SG;
    ...
}

With LRO or HW-GRO on and no program attached, the netdev netlink
xdp-features attribute reports no BASIC, REDIRECT or RX_SG. A native
attach in that state now succeeds anyway:
dev_xdp_attach()->dev_xdp_clear_rx_agg() turns the offloads off before
ndo_bpf, and xdp_features is never checked.

Userspace would then see no XDP support on a device where attaching an
XDP program works. The same goes for bond_xdp_set_features(), which
intersects the slave xdp_features. After detach, the core turns
LRO/HW-GRO back on and the advertised mask is empty again.

The empty mask only looks correct when tcp-data-split pins HW-GRO, since
the core returns -EBUSY there. Would it match the new behavior better to
key this gate off the HDS state instead of packet_merge in general?

> -
> -	if (!mlx5e_params_validate_xdp(netdev, mdev, params))
> -		return -EINVAL;
> -
> -	return 0;
> -}
> -
>  static void mlx5e_rq_replace_xdp_prog(struct mlx5e_rq *rq, struct bpf_prog *prog)
>  {
>  	struct bpf_prog *old_prog;
> @@ -5215,10 +5190,9 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
>  	new_params = priv->channels.params;
>  	new_params.xdp_prog = prog;
>  
> -	if (prog) {
> -		err = mlx5e_xdp_allowed(netdev, priv->mdev, &new_params);
> -		if (err)
> -			goto unlock;
> +	if (prog && !mlx5e_params_validate_xdp(netdev, priv->mdev, &new_params)) {
> +		err = -EINVAL;
> +		goto unlock;
>  	}
>  
>  	/* no need for full reset when exchanging programs */

[Severity: Low]
This isn't a bug, but should the tail of mlx5e_xdp_set() be removed as
well?

unlock:
	mutex_unlock(&priv->state_lock);

	/* Need to fix some features. */
	if (!err)
		netdev_update_features(netdev);

Commit f6279f113ad5 ("net/mlx5e: Update netdev features after changing
XDP state") added this call so mlx5e_fix_features() could apply or
release the params->xdp_prog LRO/HW-GRO clause. This patch removes that
clause.

On attach, the core has already called netdev_update_features() via
dev_xdp_clear_rx_agg().

On detach, this call runs while dev_xdp_prog_count() is still non-zero,
because dev_xdp_set_prog() only runs after dev_xdp_install() returns. So
it cannot restore LRO/HW-GRO. That happens in the core's own
netdev_update_features() call in dev_xdp_attach(), after the program is
cleared.

The comment also suggests a dependency that no longer exists.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118232315.3593731-1-kuba%40kernel.org
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads