Skip to contentSkip to conversation

mlx5 fixes 2023-03-21

GIT PULL Applied Saeed Mahameed 2 participants 9 messages Mar 21, 2023 – Mar 23, 2023

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

From: Saeed Mahameed <[email protected]>

This series provides bug fixes to mlx5 driver. Please pull and let me know if there is any problem.

Conflict notice:
when merged into net-next, this series will cause a conflict in file:
drivers/net/ethernet/mellanox/mlx5/core/en_tc.

to resolve just to DON'T take any changes to the missing function mlx5e_hairpin_params_init() inside that file, that function doesn't exist there anymore, we will submit a separate patch to fix net-next.

Thanks,
Saeed.

The following changes since commit f038f3917baf04835ba2b7bcf2a04ac93fbf8a9c:

octeontx2-vf: Add missing free for alloc_percpu (2023-03-20 22:00:19 -0700)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2023-03-21

for you to fetch changes up to 640fcdbcf27fc62de9223f958ceb4e897a00e791:

net/mlx5: E-Switch, Fix an Oops in error handling code (2023-03-21 14:06:32 -0700)

----------------------------------------------------------------
mlx5-fixes-2023-03-21

----------------------------------------------------------------
Dan Carpenter (1):
net/mlx5: E-Switch, Fix an Oops in error handling code

Emeel Hakim (1):
net/mlx5e: Overcome slow response for first macsec ASO WQE

Gavin Li (2):
net/mlx5e: Set uplink rep as NETNS_LOCAL
net/mlx5e: Block entering switchdev mode with ns inconsistency

Lama Kayal (1):
net/mlx5: Fix steering rules cleanup

Maher Sanalla (1):
net/mlx5: Read the TC mapping of all priorities on ETS query

Roy Novich (1):
net/mlx5e: Initialize link speed to zero

 .../net/ethernet/mellanox/mlx5/core/en_accel/macsec.c |  9 ++++++++-
 drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c    |  6 ++++--
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c     |  6 +++++-
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c       |  2 +-
 .../mellanox/mlx5/core/esw/acl/ingress_ofld.c         |  3 +--
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c     |  1 +
 .../ethernet/mellanox/mlx5/core/eswitch_offloads.c    | 19 +++++++++++++++++++
 7 files changed, 39 insertions(+), 7 deletions(-)
#6 lore raw

PATCH 5/7 net/mlx5e: Overcome slow response for first macsec ASO WQE

From: Emeel Hakim <[email protected]>

First ASO WQE poll causes a cache miss in hardware hence the resut is delayed. It causes to the situation where such WQE is polled earlier than it is needed.

Add logic to retry ASO CQ polling operation.

Fixes 739cfa34518e ("net/mlx5: Make ASO poll CQ usable in atomic context")
---
 .../net/ethernet/mellanox/mlx5/core/en_accel/macsec.c    | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c +8 -1
index 8af53178e40d..33b3620ea45c 100644
@@ -1412,6 +1412,7 @@ static int macsec_aso_query(struct mlx5_core_dev *mdev, struct mlx5e_macsec *mac
 	struct mlx5e_macsec_aso *aso;
 	struct mlx5_aso_wqe *aso_wqe;
 	struct mlx5_aso *maso;
+	unsigned long expires;
 	int err;
 
 	aso = &macsec->aso;
@@ -1425,7 +1426,13 @@ static int macsec_aso_query(struct mlx5_core_dev *mdev, struct mlx5e_macsec *mac
 	macsec_aso_build_wqe_ctrl_seg(aso, &aso_wqe->aso_ctrl, NULL);
 
 	mlx5_aso_post_wqe(maso, false, &aso_wqe->ctrl);
-	err = mlx5_aso_poll_cq(maso, false);
+	expires = jiffies + msecs_to_jiffies(10);
+	do {
+		err = mlx5_aso_poll_cq(maso, false);
+		if (err)
+			usleep_range(2, 10);
+	} while (err && time_is_after_jiffies(expires));
+
 	if (err)
 		goto err_out;
 
Signature · 1 line
2.39.2
#7 lore raw

PATCH 6/7 net/mlx5: Read the TC mapping of all priorities on ETS query

In reply to Saeed Mahameed

From: Maher Sanalla <[email protected]>

When ETS configurations are queried by the user to get the mapping assignment between packet priority and traffic class, only priorities up to maximum TCs are queried from QTCT register in FW to retrieve their assigned TC, leaving the rest of the priorities mapped to the default TC #0 which might be misleading.

Fix by querying the TC mapping of all priorities on each ETS query, regardless of the maximum number of TCs configured in FW.

Fixes 820c2c5e773d ("net/mlx5e: Read ETS settings directly from firmware")
---
 drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c +4 -2
index 2449731b7d79..89de92d06483 100644
@@ -117,12 +117,14 @@ static int mlx5e_dcbnl_ieee_getets(struct net_device *netdev,
 	if (!MLX5_CAP_GEN(priv->mdev, ets))
 		return -EOPNOTSUPP;
 
-	ets->ets_cap = mlx5_max_tc(priv->mdev) + 1;
-	for (i = 0; i < ets->ets_cap; i++) {
+	for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
 		err = mlx5_query_port_prio_tc(mdev, i, &ets->prio_tc[i]);
 		if (err)
 			return err;
+	}
 
+	ets->ets_cap = mlx5_max_tc(priv->mdev) + 1;
+	for (i = 0; i < ets->ets_cap; i++) {
 		err = mlx5_query_port_tc_group(mdev, i, &tc_group[i]);
 		if (err)
 			return err;
Signature · 1 line
2.39.2
#3 lore raw

PATCH 2/7 net/mlx5e: Block entering switchdev mode with ns inconsistency

In reply to Saeed Mahameed

From: Gavin Li <[email protected]>

Upon entering switchdev mode, VF/SF representors are spawned in the devlink instance's net namespace, whereas the PF net device transforms into the uplink representor, remaining in the net namespace the PF net device was in. Therefore, if a PF net device's namespace is different from its parent devlink net namespace, entering switchdev mode can create an illegal situation where all representors sharing the same core device are NOT in the same net namespace.

To avoid this issue, block entering switchdev mode for devices whose child netdev net namespace has diverged from the parent devlink's.

Fixes 7768d1971de6 ("net/mlx5: E-Switch, Add control for encapsulation")
---
 .../mellanox/mlx5/core/eswitch_offloads.c     | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +19 -0
index 22075943bb58..25a8076a77bf 100644
@@ -3405,6 +3405,18 @@ static int esw_inline_mode_to_devlink(u8 mlx5_mode, u8 *mode)
 	return 0;
 }
 
+static bool esw_offloads_devlink_ns_eq_netdev_ns(struct devlink *devlink)
+{
+	struct net *devl_net, *netdev_net;
+	struct mlx5_eswitch *esw;
+
+	esw = mlx5_devlink_eswitch_get(devlink);
+	netdev_net = dev_net(esw->dev->mlx5e_res.uplink_netdev);
+	devl_net = devlink_net(devlink);
+
+	return net_eq(devl_net, netdev_net);
+}
+
 int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
 				  struct netlink_ext_ack *extack)
 {
@@ -3419,6 +3431,13 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,
 	if (esw_mode_from_devlink(mode, &mlx5_mode))
 		return -EINVAL;
 
+	if (mode == DEVLINK_ESWITCH_MODE_SWITCHDEV &&
+	    !esw_offloads_devlink_ns_eq_netdev_ns(devlink)) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "Can't change E-Switch mode to switchdev when netdev net namespace has diverged from the devlink's.");
+		return -EPERM;
+	}
+
 	mlx5_lag_disable_change(esw->dev);
 	err = mlx5_esw_try_lock(esw);
 	if (err < 0) {
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/7 net/mlx5e: Set uplink rep as NETNS_LOCAL

In reply to Saeed Mahameed

From: Gavin Li <[email protected]>

Previously, NETNS_LOCAL was not set for uplink representors, inconsistent with VF representors, and allowed the uplink representor to be moved between net namespaces and separated from the VF representors it shares the core device with. Such usage would break the isolation model of namespaces, as devices in different namespaces would have access to shared memory.

To solve this issue, set NETNS_LOCAL for uplink representors if eswitch is in switchdev mode.

Fixes 7a9fb35e8c3a ("net/mlx5e: Do not reload ethernet ports when changing eswitch mode")
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +5 -1
index a7f2ab22cc40..7ca7e9b57607 100644
@@ -4150,8 +4150,12 @@ static netdev_features_t mlx5e_fix_features(struct net_device *netdev,
 		}
 	}
 
-	if (mlx5e_is_uplink_rep(priv))
+	if (mlx5e_is_uplink_rep(priv)) {
 		features = mlx5e_fix_uplink_rep_features(netdev, features);
+		features |= NETIF_F_NETNS_LOCAL;
+	} else {
+		features &= ~NETIF_F_NETNS_LOCAL;
+	}
 
 	mutex_unlock(&priv->state_lock);
 
Signature · 1 line
2.39.2
#4 lore raw

PATCH 3/7 net/mlx5: Fix steering rules cleanup

In reply to Saeed Mahameed

From: Lama Kayal <[email protected]>

vport's mc, uc and multicast rules are not deleted in teardown path when EEH happens. Since the vport's promisc settings(uc, mc and all) in firmware are reset after EEH, mlx5 driver will try to delete the above rules in the initialization path. This cause kernel crash because these software rules are no longer valid.

Fix by nullifying these rules right after delete to avoid accessing any dangling pointers.

Call Trace:
__list_del_entry_valid+0xcc/0x100 (unreliable)
tree_put_node+0xf4/0x1b0 [mlx5_core]
tree_remove_node+0x30/0x70 [mlx5_core]
mlx5_del_flow_rules+0x14c/0x1f0 [mlx5_core]
esw_apply_vport_rx_mode+0x10c/0x200 [mlx5_core]
esw_update_vport_rx_mode+0xb4/0x180 [mlx5_core]
esw_vport_change_handle_locked+0x1ec/0x230 [mlx5_core]
esw_enable_vport+0x130/0x260 [mlx5_core]
mlx5_eswitch_enable_sriov+0x2a0/0x2f0 [mlx5_core]
mlx5_device_enable_sriov+0x74/0x440 [mlx5_core]
mlx5_load_one+0x114c/0x1550 [mlx5_core]
mlx5_pci_resume+0x68/0xf0 [mlx5_core]
eeh_report_resume+0x1a4/0x230
eeh_pe_dev_traverse+0x98/0x170
eeh_handle_normal_event+0x3e4/0x640
eeh_handle_event+0x4c/0x370
eeh_event_handler+0x14c/0x210
kthread+0x168/0x1b0
ret_from_kernel_thread+0x5c/0x84
Fixes a35f71f27a61 ("net/mlx5: E-Switch, Implement promiscuous rx modes vf request handling")
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +1 -0
index 0f052513fefa..8bdf28762f41 100644
@@ -959,6 +959,7 @@ void mlx5_esw_vport_disable(struct mlx5_eswitch *esw, u16 vport_num)
 	 */
 	esw_vport_change_handle_locked(vport);
 	vport->enabled_events = 0;
+	esw_apply_vport_rx_mode(esw, vport, false, false);
 	esw_vport_cleanup(esw, vport);
 	esw->enabled_vports--;
 
Signature · 1 line
2.39.2
#5 lore raw

PATCH 4/7 net/mlx5e: Initialize link speed to zero

In reply to Saeed Mahameed

From: Roy Novich <[email protected]>

mlx5e_port_max_linkspeed does not guarantee value assignment for speed. Avoid cases where link_speed might be used uninitialized. In case mlx5e_port_max_linkspeed fails, a default link speed of 50000 will be used for the calculations.

Fixes 3f6d08d196b2 ("net/mlx5e: Add RSS support for hairpin")
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +1 -1
index 6bfed633343a..87a2850b32d0 100644
@@ -1103,8 +1103,8 @@ static void
 mlx5e_hairpin_params_init(struct mlx5e_hairpin_params *hairpin_params,
 			  struct mlx5_core_dev *mdev)
 {
+	u32 link_speed = 0;
 	u64 link_speed64;
-	u32 link_speed;
 
 	hairpin_params->mdev = mdev;
 	/* set hairpin pair per each 50Gbs share of the link */
Signature · 1 line
2.39.2
#8 lore raw

PATCH 7/7 net/mlx5: E-Switch, Fix an Oops in error handling code

In reply to Saeed Mahameed

From: Dan Carpenter <[email protected]>

The error handling dereferences "vport". There is nothing we can do if it is an error pointer except returning the error code.

Fixes 133dcfc577ea ("net/mlx5: E-Switch, Alloc and free unique metadata for match")
---
 drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_ofld.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_ofld.c +1 -2
index d55775627a47..50d2ea323979 100644
@@ -364,8 +364,7 @@ int mlx5_esw_acl_ingress_vport_metadata_update(struct mlx5_eswitch *esw, u16 vpo
 
 	if (WARN_ON_ONCE(IS_ERR(vport))) {
 		esw_warn(esw->dev, "vport(%d) invalid!\n", vport_num);
-		err = PTR_ERR(vport);
-		goto out;
+		return PTR_ERR(vport);
 	}
 
 	esw_acl_ingress_ofld_rules_destroy(esw, vport);
Signature · 1 line
2.39.2
#2 lore raw

Re: [net 1/7] net/mlx5e: Set uplink rep as NETNS_LOCAL

In reply to Saeed Mahameed
This series was applied to netdev/net.git (main) by Saeed Mahameed <[email protected]>:

Hello:

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

Quoted 10 lines · On Tue, 21 Mar 2023 14:11:29 -0700 you wrote:

From: Gavin Li <[email protected]>

Previously, NETNS_LOCAL was not set for uplink representors, inconsistent with VF representors, and allowed the uplink representor to be moved between net namespaces and separated from the VF representors it shares the core device with. Such usage would break the isolation model of namespaces, as devices in different namespaces would have access to shared memory.

[...]

Here is the summary with links:
- [net,1/7] net/mlx5e: Set uplink rep as NETNS_LOCAL

    https://git.kernel.org/netdev/net/c/c83172b0639c
  - [net,2/7] net/mlx5e: Block entering switchdev mode with ns inconsistency
    https://git.kernel.org/netdev/net/c/662404b24a4c
  - [net,3/7] net/mlx5: Fix steering rules cleanup
    https://git.kernel.org/netdev/net/c/922f56e9a795
  - [net,4/7] net/mlx5e: Initialize link speed to zero
    https://git.kernel.org/netdev/net/c/6e9d51b1a5cb
  - [net,5/7] net/mlx5e: Overcome slow response for first macsec ASO WQE
    https://git.kernel.org/netdev/net/c/7e3fce82d945
  - [net,6/7] net/mlx5: Read the TC mapping of all priorities on ETS query
    https://git.kernel.org/netdev/net/c/44d553188c38
  - [net,7/7] net/mlx5: E-Switch, Fix an Oops in error handling code
    https://git.kernel.org/netdev/net/c/640fcdbcf27f

You are awesome, thank you!

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