* [PATCH net-next V2 1/2] net/mlx5e: Update XDP features in switch channels
2025-11-30 10:13 [PATCH net-next V2 0/2] net/mlx5e: Disable egress xdp-redirect in default Tariq Toukan
@ 2025-11-30 10:13 ` Tariq Toukan
2025-11-30 10:13 ` [PATCH net-next V2 2/2] net/mlx5e: Support XDP target xmit with dummy program Tariq Toukan
2025-12-02 14:30 ` [PATCH net-next V2 0/2] net/mlx5e: Disable egress xdp-redirect in default patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Tariq Toukan @ 2025-11-30 10:13 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
John Fastabend, netdev, linux-rdma, linux-kernel, bpf,
Gal Pressman, Moshe Shemesh, Dragos Tatulea, William Tu, toke
The XDP features state might depend of the state of other features, like
HW-LRO / HW-GRO.
In general, move the re-evaluation announcement of the XDP features
(xdp_set_features_flag_locked) into the flow where configuration gets
changed. There's no point in updating them elsewhere.
This is a more appropriate place, as this modifies the announced
features while channels are inactive, which avoids the small interval
between channel activation and the proper setting of the XDP features.
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: William Tu <witu@nvidia.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 +-
.../net/ethernet/mellanox/mlx5/core/en_ethtool.c | 10 +---------
drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 13 ++++++-------
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 2 +-
4 files changed, 9 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 3ada7c16adfb..811178d8976c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -1249,7 +1249,7 @@ void mlx5e_netdev_attach_nic_profile(struct mlx5e_priv *priv);
void mlx5e_set_netdev_mtu_boundaries(struct mlx5e_priv *priv);
void mlx5e_build_nic_params(struct mlx5e_priv *priv, struct mlx5e_xsk *xsk, u16 mtu);
-void mlx5e_set_xdp_feature(struct net_device *netdev);
+void mlx5e_set_xdp_feature(struct mlx5e_priv *priv);
netdev_features_t mlx5e_features_check(struct sk_buff *skb,
struct net_device *netdev,
netdev_features_t features);
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
index fe67c73849f9..d3fef1e7e2f7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -2294,7 +2294,6 @@ static int set_pflag_rx_striding_rq(struct net_device *netdev, bool enable)
struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5_core_dev *mdev = priv->mdev;
struct mlx5e_params new_params;
- int err;
if (enable) {
/* Checking the regular RQ here; mlx5e_validate_xsk_param called
@@ -2315,14 +2314,7 @@ static int set_pflag_rx_striding_rq(struct net_device *netdev, bool enable)
MLX5E_SET_PFLAG(&new_params, MLX5E_PFLAG_RX_STRIDING_RQ, enable);
mlx5e_set_rq_type(mdev, &new_params);
- err = mlx5e_safe_switch_params(priv, &new_params, NULL, NULL, true);
- if (err)
- return err;
-
- /* update XDP supported features */
- mlx5e_set_xdp_feature(netdev);
-
- return 0;
+ return mlx5e_safe_switch_params(priv, &new_params, NULL, NULL, true);
}
static int set_pflag_rx_no_csum_complete(struct net_device *netdev, bool enable)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index e537df670758..f0f2bc7f317d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -3365,6 +3365,7 @@ static int mlx5e_switch_priv_params(struct mlx5e_priv *priv,
}
}
+ mlx5e_set_xdp_feature(priv);
return 0;
}
@@ -3396,6 +3397,7 @@ static int mlx5e_switch_priv_channels(struct mlx5e_priv *priv,
}
}
+ mlx5e_set_xdp_feature(priv);
if (!MLX5_CAP_GEN(priv->mdev, tis_tir_td_order))
mlx5e_close_channels(old_chs);
priv->profile->update_rx(priv);
@@ -4409,10 +4411,10 @@ static int mlx5e_handle_feature(struct net_device *netdev,
return 0;
}
-void mlx5e_set_xdp_feature(struct net_device *netdev)
+void mlx5e_set_xdp_feature(struct mlx5e_priv *priv)
{
- struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5e_params *params = &priv->channels.params;
+ struct net_device *netdev = priv->netdev;
xdp_features_t val;
if (!netdev->netdev_ops->ndo_bpf ||
@@ -4461,9 +4463,6 @@ int mlx5e_set_features(struct net_device *netdev, netdev_features_t features)
return -EINVAL;
}
- /* update XDP supported features */
- mlx5e_set_xdp_feature(netdev);
-
return 0;
}
@@ -5859,7 +5858,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
netdev->netmem_tx = true;
netif_set_tso_max_size(netdev, GSO_MAX_SIZE);
- mlx5e_set_xdp_feature(netdev);
+ mlx5e_set_xdp_feature(priv);
mlx5e_set_netdev_dev_addr(netdev);
mlx5e_macsec_build_netdev(priv);
mlx5e_ipsec_build_netdev(priv);
@@ -5957,7 +5956,7 @@ static int mlx5e_nic_init(struct mlx5_core_dev *mdev,
mlx5e_psp_register(priv);
/* update XDP supported features */
- mlx5e_set_xdp_feature(netdev);
+ mlx5e_set_xdp_feature(priv);
if (take_rtnl)
rtnl_unlock();
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
index 0335ca8277ef..ee9595109649 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -867,7 +867,7 @@ static void mlx5e_build_rep_params(struct net_device *netdev)
if (take_rtnl)
rtnl_lock();
/* update XDP supported features */
- mlx5e_set_xdp_feature(netdev);
+ mlx5e_set_xdp_feature(priv);
if (take_rtnl)
rtnl_unlock();
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH net-next V2 2/2] net/mlx5e: Support XDP target xmit with dummy program
2025-11-30 10:13 [PATCH net-next V2 0/2] net/mlx5e: Disable egress xdp-redirect in default Tariq Toukan
2025-11-30 10:13 ` [PATCH net-next V2 1/2] net/mlx5e: Update XDP features in switch channels Tariq Toukan
@ 2025-11-30 10:13 ` Tariq Toukan
2025-12-02 14:30 ` [PATCH net-next V2 0/2] net/mlx5e: Disable egress xdp-redirect in default patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Tariq Toukan @ 2025-11-30 10:13 UTC (permalink / raw)
To: Eric Dumazet, Jakub Kicinski, Paolo Abeni, Andrew Lunn,
David S. Miller
Cc: Saeed Mahameed, Leon Romanovsky, Tariq Toukan, Mark Bloch,
Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
John Fastabend, netdev, linux-rdma, linux-kernel, bpf,
Gal Pressman, Moshe Shemesh, Dragos Tatulea, William Tu, toke
Save per-channel resources in default, in device and host memory.
As no better API exist, make the XDP-redirect-target SQ available by
loading a dummy XDP program.
This improves the latency of interface up/down operations when feature
is disabled.
Perf numbers:
NIC: Connect-X7.
Setup: 248 channels, default mtu and rx/tx ring sizes.
Interface up + down:
Before: 2.246 secs
After: 1.798 secs (-0.448 sec)
Saves ~1.8 msec per channel.
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: William Tu <witu@nvidia.com>
---
.../net/ethernet/mellanox/mlx5/core/en_main.c | 23 +++++++++----------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index f0f2bc7f317d..6168f0814414 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2612,7 +2612,7 @@ static int mlx5e_open_queues(struct mlx5e_channel *c,
if (err)
goto err_close_icosq_cq;
- if (netdev_ops->ndo_xdp_xmit) {
+ if (netdev_ops->ndo_xdp_xmit && c->xdp) {
c->xdpsq = mlx5e_open_xdpredirect_sq(c, params, cparam, &ccp);
if (IS_ERR(c->xdpsq)) {
err = PTR_ERR(c->xdpsq);
@@ -4415,19 +4415,18 @@ void mlx5e_set_xdp_feature(struct mlx5e_priv *priv)
{
struct mlx5e_params *params = &priv->channels.params;
struct net_device *netdev = priv->netdev;
- xdp_features_t val;
+ xdp_features_t val = 0;
- if (!netdev->netdev_ops->ndo_bpf ||
- params->packet_merge.type != MLX5E_PACKET_MERGE_NONE) {
- xdp_set_features_flag_locked(netdev, 0);
- return;
- }
+ 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;
+
+ if (netdev->netdev_ops->ndo_xdp_xmit && params->xdp_prog)
+ val |= NETDEV_XDP_ACT_NDO_XMIT |
+ NETDEV_XDP_ACT_NDO_XMIT_SG;
- val = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
- NETDEV_XDP_ACT_XSK_ZEROCOPY |
- NETDEV_XDP_ACT_RX_SG |
- NETDEV_XDP_ACT_NDO_XMIT |
- NETDEV_XDP_ACT_NDO_XMIT_SG;
xdp_set_features_flag_locked(netdev, val);
}
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net-next V2 0/2] net/mlx5e: Disable egress xdp-redirect in default
2025-11-30 10:13 [PATCH net-next V2 0/2] net/mlx5e: Disable egress xdp-redirect in default Tariq Toukan
2025-11-30 10:13 ` [PATCH net-next V2 1/2] net/mlx5e: Update XDP features in switch channels Tariq Toukan
2025-11-30 10:13 ` [PATCH net-next V2 2/2] net/mlx5e: Support XDP target xmit with dummy program Tariq Toukan
@ 2025-12-02 14:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-12-02 14:30 UTC (permalink / raw)
To: Tariq Toukan
Cc: edumazet, kuba, pabeni, andrew+netdev, davem, saeedm, leon,
mbloch, ast, daniel, hawk, john.fastabend, netdev, linux-rdma,
linux-kernel, bpf, gal, moshe, dtatulea, witu, toke
Hello:
This series was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Sun, 30 Nov 2025 12:13:35 +0200 you wrote:
> Hi,
>
> This small series disables the egress xdp-redirect feature in default.
> It can still be enabled by loading a dummy XDP program.
>
> Patches were previously submitted as part of [1].
>
> [...]
Here is the summary with links:
- [net-next,V2,1/2] net/mlx5e: Update XDP features in switch channels
https://git.kernel.org/netdev/net-next/c/96a839506135
- [net-next,V2,2/2] net/mlx5e: Support XDP target xmit with dummy program
https://git.kernel.org/netdev/net-next/c/d4aa0cc9bd31
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread