Skip to contentSkip to conversation

mlx5 misc fixes 2024-12-03

PATCH Applied Tariq Toukan 2 participants 8 messages Dec 3, 2024 – Dec 5, 2024

Subsystems (4)
lore
Share & tools
lore

Tariq Toukan

author maintainer
#0 lore raw

cover mlx5 misc fixes 2024-12-03

Hi,

This patchset provides misc bug fixes from the team to the mlx5 core and Eth drivers.

Series generated against:
commit af8edaeddbc5 ("net: hsr: must allocate more bytes for RedBox support")

Thanks,
Tariq.

Cosmin Ratiu (2):
net/mlx5: HWS: Fix memory leak in mlx5hws_definer_calc_layout net/mlx5: HWS: Properly set bwc queue locks lock classes

Jianbo Liu (1):
net/mlx5e: Remove workaround to avoid syndrome for internal port

Patrisious Haddad (2):
net/mlx5: E-Switch, Fix switching to switchdev mode with IB device
disabled
net/mlx5: E-Switch, Fix switching to switchdev mode in MPV

Tariq Toukan (1):
net/mlx5e: SD, Use correct mdev to build channel param

 .../mellanox/mlx5/core/en/tc_tun_encap.c      | 13 ++++++--
 .../net/ethernet/mellanox/mlx5/core/en_main.c | 32 ++++++++++---------
 .../mellanox/mlx5/core/eswitch_offloads.c     |  5 +--
 .../mlx5/core/steering/hws/bwc_complex.c      |  2 ++
 .../mellanox/mlx5/core/steering/hws/send.c    |  1 +
 5 files changed, 34 insertions(+), 19 deletions(-)
Signature · 1 line
2.44.0
author maintainer
#1 lore raw

PATCH 1/6 net/mlx5: HWS: Fix memory leak in mlx5hws_definer_calc_layout

From: Cosmin Ratiu <[email protected]>

It allocates a match template, which creates a compressed definer fc struct, but that is not deallocated.

This commit fixes that.

Fixes 74a778b4a63f ("net/mlx5: HWS, added definers handling")
---
 .../net/ethernet/mellanox/mlx5/core/steering/hws/bwc_complex.c  | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc_complex.c +2 -0
index c00010ca86bd..9fb059a6511f 100644
@@ -39,6 +39,8 @@ bool mlx5hws_bwc_match_params_is_complex(struct mlx5hws_context *ctx,
 		} else {
 			mlx5hws_err(ctx, "Failed to calculate matcher definer layout\n");
 		}
+	} else {
+		kfree(mt->fc);
 	}
 
 	mlx5hws_match_template_destroy(mt);
Signature · 1 line
2.44.0
author maintainer
#2 lore raw

PATCH 2/6 net/mlx5: HWS: Properly set bwc queue locks lock classes

In reply to Tariq Toukan

From: Cosmin Ratiu <[email protected]>

The mentioned "Fixes" patch forgot to do that.

Fixes 9addffa34359 ("net/mlx5: HWS, use lock classes for bwc locks")
---
 drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/send.c +1 -0
index 424797b6d802..883b4ed30892 100644
@@ -990,6 +990,7 @@ static int hws_bwc_send_queues_init(struct mlx5hws_context *ctx)
 	for (i = 0; i < bwc_queues; i++) {
 		mutex_init(&ctx->bwc_send_queue_locks[i]);
 		lockdep_register_key(ctx->bwc_lock_class_keys + i);
+		lockdep_set_class(ctx->bwc_send_queue_locks + i, ctx->bwc_lock_class_keys + i);
 	}
 
 	return 0;
Signature · 1 line
2.44.0
author maintainer
#3 lore raw

PATCH 3/6 net/mlx5: E-Switch, Fix switching to switchdev mode with IB device disabled

In reply to Tariq Toukan

From: Patrisious Haddad <[email protected]>

In case that IB device is already disabled when moving to switchdev mode, which can happen when working with LAG, need to do rescan_drivers() before leaving in order to add ethernet representor auxiliary device.

Fixes ab85ebf43723 ("net/mlx5: E-switch, refactor eswitch mode change")
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +1 -0
index d6ff2dc4c19e..5213d5b2cad5 100644
@@ -2338,6 +2338,7 @@ static void esw_mode_change(struct mlx5_eswitch *esw, u16 mode)
 
 	if (esw->dev->priv.flags & MLX5_PRIV_FLAGS_DISABLE_IB_ADEV) {
 		esw->mode = mode;
+		mlx5_rescan_drivers_locked(esw->dev);
 		mlx5_devcom_comp_unlock(esw->dev->priv.hca_devcom_comp);
 		return;
 	}
Signature · 1 line
2.44.0
author maintainer
#4 lore raw

PATCH 4/6 net/mlx5: E-Switch, Fix switching to switchdev mode in MPV

In reply to Tariq Toukan

From: Patrisious Haddad <[email protected]>

Fix the mentioned commit change for MPV mode, since in MPV mode the IB device is shared between different core devices, so under this change when moving both devices simultaneously to switchdev mode the IB device removal and re-addition can race with itself causing unexpected behavior.

In such case do rescan_drivers() only once in order to add the ethernet representor auxiliary device, and skip adding and removing IB devices.

Fixes ab85ebf43723 ("net/mlx5: E-switch, refactor eswitch mode change")
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -2
index 5213d5b2cad5..d5b42b3a19fd 100644
@@ -2335,8 +2335,8 @@ static int esw_create_restore_table(struct mlx5_eswitch *esw)
 static void esw_mode_change(struct mlx5_eswitch *esw, u16 mode)
 {
 	mlx5_devcom_comp_lock(esw->dev->priv.hca_devcom_comp);
-
-	if (esw->dev->priv.flags & MLX5_PRIV_FLAGS_DISABLE_IB_ADEV) {
+	if (esw->dev->priv.flags & MLX5_PRIV_FLAGS_DISABLE_IB_ADEV ||
+	    mlx5_core_mp_enabled(esw->dev)) {
 		esw->mode = mode;
 		mlx5_rescan_drivers_locked(esw->dev);
 		mlx5_devcom_comp_unlock(esw->dev->priv.hca_devcom_comp);
Signature · 1 line
2.44.0
author maintainer
#5 lore raw

PATCH 5/6 net/mlx5e: SD, Use correct mdev to build channel param

In reply to Tariq Toukan

In a multi-PF netdev, each traffic channel creates its own resources against a specific PF.
In the cited commit, where this support was added, the channel_param logic was mistakenly kept unchanged, so it always used the primary PF which is found at priv->mdev.
In this patch we fix this by moving the logic to be per-channel, and passing the correct mdev instance.

This bug happened to be usually harmless, as the resulting cparam structures would be the same for all channels, due to identical FW logic and decisions.
However, in some use cases, like fwreset, this gets broken.

This could lead to different symptoms. Example:
Error cqe on cqn 0x428, ci 0x0, qn 0x10a9, opcode 0xe, syndrome 0x4, vendor syndrome 0x32

Fixes e4f9686bdee7 ("net/mlx5e: Let channels be SD-aware")
---
 .../net/ethernet/mellanox/mlx5/core/en_main.c | 32 ++++++++++---------
 1 file changed, 17 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +17 -15
index d0b80b520397..dd16d73000c3 100644
@@ -2680,11 +2680,11 @@ void mlx5e_trigger_napi_sched(struct napi_struct *napi)
 
 static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
 			      struct mlx5e_params *params,
-			      struct mlx5e_channel_param *cparam,
 			      struct xsk_buff_pool *xsk_pool,
 			      struct mlx5e_channel **cp)
 {
 	struct net_device *netdev = priv->netdev;
+	struct mlx5e_channel_param *cparam;
 	struct mlx5_core_dev *mdev;
 	struct mlx5e_xsk_param xsk;
 	struct mlx5e_channel *c;
@@ -2706,8 +2706,15 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
 		return err;
 
 	c = kvzalloc_node(sizeof(*c), GFP_KERNEL, cpu_to_node(cpu));
-	if (!c)
-		return -ENOMEM;
+	cparam = kvzalloc(sizeof(*cparam), GFP_KERNEL);
+	if (!c || !cparam) {
+		err = -ENOMEM;
+		goto err_free;
+	}
+
+	err = mlx5e_build_channel_param(mdev, params, cparam);
+	if (err)
+		goto err_free;
 
 	c->priv     = priv;
 	c->mdev     = mdev;
@@ -2741,6 +2748,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
 
 	*cp = c;
 
+	kvfree(cparam);
 	return 0;
 
 err_close_queues:
@@ -2749,6 +2757,8 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
 err_napi_del:
 	netif_napi_del(&c->napi);
 
+err_free:
+	kvfree(cparam);
 	kvfree(c);
 
 	return err;
@@ -2807,20 +2817,14 @@ static void mlx5e_close_channel(struct mlx5e_channel *c)
 int mlx5e_open_channels(struct mlx5e_priv *priv,
 			struct mlx5e_channels *chs)
 {
-	struct mlx5e_channel_param *cparam;
 	int err = -ENOMEM;
 	int i;
 
 	chs->num = chs->params.num_channels;
 
 	chs->c = kcalloc(chs->num, sizeof(struct mlx5e_channel *), GFP_KERNEL);
-	cparam = kvzalloc(sizeof(struct mlx5e_channel_param), GFP_KERNEL);
-	if (!chs->c || !cparam)
-		goto err_free;
-
-	err = mlx5e_build_channel_param(priv->mdev, &chs->params, cparam);
-	if (err)
-		goto err_free;
+	if (!chs->c)
+		goto err_out;
 
 	for (i = 0; i < chs->num; i++) {
 		struct xsk_buff_pool *xsk_pool = NULL;
@@ -2828,7 +2832,7 @@ int mlx5e_open_channels(struct mlx5e_priv *priv,
 		if (chs->params.xdp_prog)
 			xsk_pool = mlx5e_xsk_get_pool(&chs->params, chs->params.xsk, i);
 
-		err = mlx5e_open_channel(priv, i, &chs->params, cparam, xsk_pool, &chs->c[i]);
+		err = mlx5e_open_channel(priv, i, &chs->params, xsk_pool, &chs->c[i]);
 		if (err)
 			goto err_close_channels;
 	}
@@ -2846,7 +2850,6 @@ int mlx5e_open_channels(struct mlx5e_priv *priv,
 	}
 
 	mlx5e_health_channels_update(priv);
-	kvfree(cparam);
 	return 0;
 
 err_close_ptp:
@@ -2857,9 +2860,8 @@ int mlx5e_open_channels(struct mlx5e_priv *priv,
 	for (i--; i >= 0; i--)
 		mlx5e_close_channel(chs->c[i]);
 
-err_free:
 	kfree(chs->c);
-	kvfree(cparam);
+err_out:
 	chs->num = 0;
 	return err;
 }
Signature · 1 line
2.44.0
author maintainer
#6 lore raw

PATCH 6/6 net/mlx5e: Remove workaround to avoid syndrome for internal port

In reply to Tariq Toukan

From: Jianbo Liu <[email protected]>

Previously a workaround was added to avoid syndrome 0xcdb051. It is triggered when offload a rule with tunnel encapsulation, and forwarding to another table, but not matching on the internal port in firmware steering mode. The original workaround skips internal tunnel port logic, which is not correct as not all cases are considered. As an example, if vlan is configured on the uplink port, traffic can't pass because vlan header is not added with this workaround. Besides, there is no such issue for software steering. So, this patch removes that, and returns error directly if trying to offload such rule for firmware steering.

Fixes 06b4eac9c4be ("net/mlx5e: Don't offload internal port if filter device is out device")
---
 .../ethernet/mellanox/mlx5/core/en/tc_tun_encap.c   | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +11 -2
index 878cbdbf5ec8..e7e01f3298ef 100644
@@ -5,6 +5,7 @@
 #include <net/nexthop.h>
 #include <net/ip_tunnels.h>
 #include "tc_tun_encap.h"
+#include "fs_core.h"
 #include "en_tc.h"
 #include "tc_tun.h"
 #include "rep/tc.h"
@@ -24,10 +25,18 @@ static int mlx5e_set_int_port_tunnel(struct mlx5e_priv *priv,
 
 	route_dev = dev_get_by_index(dev_net(e->out_dev), e->route_dev_ifindex);
 
-	if (!route_dev || !netif_is_ovs_master(route_dev) ||
-	    attr->parse_attr->filter_dev == e->out_dev)
+	if (!route_dev || !netif_is_ovs_master(route_dev))
 		goto out;
 
+	if (priv->mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_DMFS &&
+	    mlx5e_eswitch_uplink_rep(attr->parse_attr->filter_dev) &&
+	    (attr->esw_attr->dests[out_index].flags & MLX5_ESW_DEST_ENCAP)) {
+		mlx5_core_warn(priv->mdev,
+			       "Matching on external port with encap + fwd to table actions is not allowed for firmware steering\n");
+		err = -EINVAL;
+		goto out;
+	}
+
 	err = mlx5e_set_fwd_to_int_port_actions(priv, attr, e->route_dev_ifindex,
 						MLX5E_TC_INT_PORT_EGRESS,
 						&attr->action, out_index);
Signature · 1 line
2.44.0
#7 lore raw
In reply to Tariq Toukan
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Tue, 3 Dec 2024 22:49:14 +0200 you wrote:

Hi,

This patchset provides misc bug fixes from the team to the mlx5 core and Eth drivers.

Series generated against:
commit af8edaeddbc5 ("net: hsr: must allocate more bytes for RedBox support")

[...]

Here is the summary with links:
- [net,1/6] net/mlx5: HWS: Fix memory leak in mlx5hws_definer_calc_layout

    https://git.kernel.org/netdev/net/c/530b69a26952
  - [net,2/6] net/mlx5: HWS: Properly set bwc queue locks lock classes
    https://git.kernel.org/netdev/net/c/10e0f0c018d5
  - [net,3/6] net/mlx5: E-Switch, Fix switching to switchdev mode with IB device disabled
    https://git.kernel.org/netdev/net/c/5f9b2bf019b7
  - [net,4/6] net/mlx5: E-Switch, Fix switching to switchdev mode in MPV
    https://git.kernel.org/netdev/net/c/d04c81a3e3ce
  - [net,5/6] net/mlx5e: SD, Use correct mdev to build channel param
    https://git.kernel.org/netdev/net/c/31f114c3d158
  - [net,6/6] net/mlx5e: Remove workaround to avoid syndrome for internal port
    https://git.kernel.org/netdev/net/c/5085f861b414

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html