Skip to contentSkip to conversation

mlx5 misc fixes 2024-07-30

PATCH Applied Tariq Toukan 3 participants 18 messages Jul 30, 2024 – Aug 1, 2024

Subsystems (5)
lore
Share & tools
lore

Tariq Toukan

author maintainer
#0 lore raw

cover mlx5 misc fixes 2024-07-30

Hi,

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

Series generated against:
commit 301927d2d2eb ("Merge tag 'for-net-2024-07-26' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth")

Thanks,
Tariq.

Chris Mi (1):
net/mlx5e: Fix CT entry update leaks of modify header context

Mark Bloch (1):
net/mlx5: Lag, don't use the hardcoded value of the first port

Moshe Shemesh (1):
net/mlx5: Fix missing lock on sync reset reload

Rahul Rameshbabu (1):
net/mlx5e: Require mlx5 tc classifier action support for IPsec prio
capability

Shahar Shitrit (1):
net/mlx5e: Add a check for the return value from
mlx5_port_set_eth_ptys

Shay Drory (2):
net/mlx5: Always drain health in shutdown callback net/mlx5: Fix error handling in irq_pool_request_irq

Yevgeny Kliteynik (1):
net/mlx5: DR, Fix 'stack guard page was hit' error in dr_rule

 drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c     |  1 +
 .../mellanox/mlx5/core/en_accel/ipsec_offload.c        |  7 ++++---
 drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c   |  7 ++++++-
 drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c     |  5 ++++-
 drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c | 10 +++++++---
 drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c      |  2 +-
 drivers/net/ethernet/mellanox/mlx5/core/main.c         |  2 +-
 .../net/ethernet/mellanox/mlx5/core/sf/dev/driver.c    |  1 +
 .../net/ethernet/mellanox/mlx5/core/steering/dr_rule.c |  2 +-
 9 files changed, 26 insertions(+), 11 deletions(-)
Signature · 1 line
2.44.0
author maintainer
#1 lore raw

PATCH 1/8 net/mlx5: Always drain health in shutdown callback

From: Shay Drory <[email protected]>

There is no point in recovery during device shutdown. if health work started need to wait for it to avoid races and NULL pointer access.

Hence, drain health WQ on shutdown callback.

Fixes 1958fc2f0712 ("net/mlx5: SF, Add auxiliary device driver")
Fixes d2aa060d40fa ("net/mlx5: Cancel health poll before sending panic teardown command")
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c          | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +1 -1
index 527da58c7953..5b7e6f4b5c7e 100644
@@ -2142,7 +2142,6 @@ static int mlx5_try_fast_unload(struct mlx5_core_dev *dev)
 	/* Panic tear down fw command will stop the PCI bus communication
 	 * with the HCA, so the health poll is no longer needed.
 	 */
-	mlx5_drain_health_wq(dev);
 	mlx5_stop_health_poll(dev, false);
 
 	ret = mlx5_cmd_fast_teardown_hca(dev);
@@ -2177,6 +2176,7 @@ static void shutdown(struct pci_dev *pdev)
 
 	mlx5_core_info(dev, "Shutdown was called\n");
 	set_bit(MLX5_BREAK_FW_WAIT, &dev->intf_state);
+	mlx5_drain_health_wq(dev);
 	err = mlx5_try_fast_unload(dev);
 	if (err)
 		mlx5_unload_one(dev, false);
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c +1 -0
index b2986175d9af..b706f1486504 100644
@@ -112,6 +112,7 @@ static void mlx5_sf_dev_shutdown(struct auxiliary_device *adev)
 	struct mlx5_core_dev *mdev = sf_dev->mdev;
 
 	set_bit(MLX5_BREAK_FW_WAIT, &mdev->intf_state);
+	mlx5_drain_health_wq(mdev);
 	mlx5_unload_one(mdev, false);
 }
 
Signature · 1 line
2.44.0
Reviewed-by on v1 1/8
#2 lore raw

Re: [PATCH net 1/8] net/mlx5: Always drain health in shutdown callback

Quoted 6 lines · Tariq Toukan

From: Shay Drory <[email protected]>

There is no point in recovery during device shutdown. if health work started need to wait for it to avoid races and NULL pointer access.

Quoted 8 lines

Hence, drain health WQ on shutdown callback.

Fixes 1958fc2f0712 ("net/mlx5: SF, Add auxiliary device driver")
Fixes d2aa060d40fa ("net/mlx5: Cancel health poll before sending panic teardown command")

---

Quoted 36 lines
 drivers/net/ethernet/mellanox/mlx5/core/main.c          | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +1 -1
index 527da58c7953..5b7e6f4b5c7e 100644
@@ -2142,7 +2142,6 @@ static int mlx5_try_fast_unload(struct mlx5_core_dev *dev)
 	/* Panic tear down fw command will stop the PCI bus communication
 	 * with the HCA, so the health poll is no longer needed.
 	 */
-	mlx5_drain_health_wq(dev);
 	mlx5_stop_health_poll(dev, false);
 
 	ret = mlx5_cmd_fast_teardown_hca(dev);
@@ -2177,6 +2176,7 @@ static void shutdown(struct pci_dev *pdev)
 
 	mlx5_core_info(dev, "Shutdown was called\n");
 	set_bit(MLX5_BREAK_FW_WAIT, &dev->intf_state);
+	mlx5_drain_health_wq(dev);
 	err = mlx5_try_fast_unload(dev);
 	if (err)
 		mlx5_unload_one(dev, false);
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/driver.c +1 -0
index b2986175d9af..b706f1486504 100644
@@ -112,6 +112,7 @@ static void mlx5_sf_dev_shutdown(struct auxiliary_device *adev)
 	struct mlx5_core_dev *mdev = sf_dev->mdev;
 
 	set_bit(MLX5_BREAK_FW_WAIT, &mdev->intf_state);
+	mlx5_drain_health_wq(mdev);
 	mlx5_unload_one(mdev, false);
 }
 
author maintainer
#3 lore raw

PATCH 2/8 net/mlx5: Fix error handling in irq_pool_request_irq

In reply to Tariq Toukan

From: Shay Drory <[email protected]>

In case mlx5_irq_alloc fails, the previously allocated index remains in the XArray, which could lead to inconsistencies.

Fix it by adding error handling that erases the allocated index from the XArray if mlx5_irq_alloc returns an error.

Fixes c36326d38d93 ("net/mlx5: Round-Robin EQs over IRQs")
---
 drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c +7 -3
index f7b01b3f0cba..1477db7f5307 100644
@@ -48,6 +48,7 @@ static struct mlx5_irq *
 irq_pool_request_irq(struct mlx5_irq_pool *pool, struct irq_affinity_desc *af_desc)
 {
 	struct irq_affinity_desc auto_desc = {};
+	struct mlx5_irq *irq;
 	u32 irq_index;
 	int err;
 
@@ -64,9 +65,12 @@ irq_pool_request_irq(struct mlx5_irq_pool *pool, struct irq_affinity_desc *af_de
 		else
 			cpu_get(pool, cpumask_first(&af_desc->mask));
 	}
-	return mlx5_irq_alloc(pool, irq_index,
-			      cpumask_empty(&auto_desc.mask) ? af_desc : &auto_desc,
-			      NULL);
+	irq = mlx5_irq_alloc(pool, irq_index,
+			     cpumask_empty(&auto_desc.mask) ? af_desc : &auto_desc,
+			     NULL);
+	if (IS_ERR(irq))
+		xa_erase(&pool->irqs, irq_index);
+	return irq;
 }
 
 /* Looking for the IRQ with the smallest refcount that fits req_mask.
Signature · 1 line
2.44.0
Reviewed-by on v1 2/8
#4 lore raw

Re: [PATCH net 2/8] net/mlx5: Fix error handling in irq_pool_request_irq

Quoted 5 lines · Tariq Toukan

From: Shay Drory <[email protected]>

In case mlx5_irq_alloc fails, the previously allocated index remains in the XArray, which could lead to inconsistencies.

Quoted 8 lines

Fix it by adding error handling that erases the allocated index from the XArray if mlx5_irq_alloc returns an error.

Fixes c36326d38d93 ("net/mlx5: Round-Robin EQs over IRQs")

---

Quoted 31 lines
 drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/irq_affinity.c +7 -3
index f7b01b3f0cba..1477db7f5307 100644
@@ -48,6 +48,7 @@ static struct mlx5_irq *
 irq_pool_request_irq(struct mlx5_irq_pool *pool, struct irq_affinity_desc *af_desc)
 {
 	struct irq_affinity_desc auto_desc = {};
+	struct mlx5_irq *irq;
 	u32 irq_index;
 	int err;
 
@@ -64,9 +65,12 @@ irq_pool_request_irq(struct mlx5_irq_pool *pool, struct irq_affinity_desc *af_de
 		else
 			cpu_get(pool, cpumask_first(&af_desc->mask));
 	}
-	return mlx5_irq_alloc(pool, irq_index,
-			      cpumask_empty(&auto_desc.mask) ? af_desc : &auto_desc,
-			      NULL);
+	irq = mlx5_irq_alloc(pool, irq_index,
+			     cpumask_empty(&auto_desc.mask) ? af_desc : &auto_desc,
+			     NULL);
+	if (IS_ERR(irq))
+		xa_erase(&pool->irqs, irq_index);
+	return irq;
 }
 
 /* Looking for the IRQ with the smallest refcount that fits req_mask.
author maintainer
#5 lore raw

PATCH 3/8 net/mlx5: DR, Fix 'stack guard page was hit' error in dr_rule

In reply to Tariq Toukan

From: Yevgeny Kliteynik <[email protected]>

This patch reduces the size of hw_ste_arr_optimized array that is allocated on stack from 640 bytes (5 match STEs + 5 action STES) to 448 bytes (2 match STEs + 5 action STES).
This fixes the 'stack guard page was hit' issue, while still fitting majority of the usecases (up to 2 match STEs).

---
 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c +1 -1
index 042ca0349124..d1db04baa1fa 100644
@@ -7,7 +7,7 @@
 /* don't try to optimize STE allocation if the stack is too constaraining */
 #define DR_RULE_MAX_STES_OPTIMIZED 0
 #else
-#define DR_RULE_MAX_STES_OPTIMIZED 5
+#define DR_RULE_MAX_STES_OPTIMIZED 2
 #endif
 #define DR_RULE_MAX_STE_CHAIN_OPTIMIZED (DR_RULE_MAX_STES_OPTIMIZED + DR_ACTION_MAX_STES)
 
Signature · 1 line
2.44.0
Reviewed-by on v1 3/8
#6 lore raw

Re: [PATCH net 3/8] net/mlx5: DR, Fix 'stack guard page was hit' error in dr_rule

Quoted 8 lines · Tariq Toukan

From: Yevgeny Kliteynik <[email protected]>

This patch reduces the size of hw_ste_arr_optimized array that is allocated on stack from 640 bytes (5 match STEs + 5 action STES) to 448 bytes (2 match STEs + 5 action STES).
This fixes the 'stack guard page was hit' issue, while still fitting majority of the usecases (up to 2 match STEs).

Quoted 4 lines

---

Quoted 16 lines
 drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c +1 -1
index 042ca0349124..d1db04baa1fa 100644
@@ -7,7 +7,7 @@
 /* don't try to optimize STE allocation if the stack is too constaraining */
 #define DR_RULE_MAX_STES_OPTIMIZED 0
 #else
-#define DR_RULE_MAX_STES_OPTIMIZED 5
+#define DR_RULE_MAX_STES_OPTIMIZED 2
 #endif
 #define DR_RULE_MAX_STE_CHAIN_OPTIMIZED (DR_RULE_MAX_STES_OPTIMIZED + DR_ACTION_MAX_STES)
 
author maintainer
#7 lore raw

PATCH 4/8 net/mlx5: Lag, don't use the hardcoded value of the first port

In reply to Tariq Toukan

From: Mark Bloch <[email protected]>

The cited commit didn't change the body of the loop as it should. It shouldn't be using MLX5_LAG_P1.

Fixes 7e978e7714d6 ("net/mlx5: Lag, use actual number of lag ports")
---
 drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +1 -1
index d0871c46b8c5..cf8045b92689 100644
@@ -1538,7 +1538,7 @@ u8 mlx5_lag_get_slave_port(struct mlx5_core_dev *dev,
 		goto unlock;
 
 	for (i = 0; i < ldev->ports; i++) {
-		if (ldev->pf[MLX5_LAG_P1].netdev == slave) {
+		if (ldev->pf[i].netdev == slave) {
 			port = i;
 			break;
 		}
Signature · 1 line
2.44.0
Reviewed-by on v1 4/8
#8 lore raw

Re: [PATCH net 4/8] net/mlx5: Lag, don't use the hardcoded value of the first port

Quoted 9 lines · Tariq Toukan

From: Mark Bloch <[email protected]>

The cited commit didn't change the body of the loop as it should. It shouldn't be using MLX5_LAG_P1.

Fixes 7e978e7714d6 ("net/mlx5: Lag, use actual number of lag ports")

---

Quoted 16 lines
 drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +1 -1
index d0871c46b8c5..cf8045b92689 100644
@@ -1538,7 +1538,7 @@ u8 mlx5_lag_get_slave_port(struct mlx5_core_dev *dev,
 		goto unlock;
 
 	for (i = 0; i < ldev->ports; i++) {
-		if (ldev->pf[MLX5_LAG_P1].netdev == slave) {
+		if (ldev->pf[i].netdev == slave) {
 			port = i;
 			break;
 		}
author maintainer
#9 lore raw

PATCH 5/8 net/mlx5: Fix missing lock on sync reset reload

In reply to Tariq Toukan

From: Moshe Shemesh <[email protected]>

On sync reset reload work, when remote host updates devlink on reload actions performed on that host, it misses taking devlink lock before calling devlink_remote_reload_actions_performed() which results in triggering lock assert like the following:

WARNING: CPU: 4 PID: 1164 at net/devlink/core.c:261 devl_assert_locked+0x3e/0x50
…
 CPU: 4 PID: 1164 Comm: kworker/u96:6 Tainted: G S      W          6.10.0-rc2+ #116
 Hardware name: Supermicro SYS-2028TP-DECTR/X10DRT-PT, BIOS 2.0 12/18/2015
 Workqueue: mlx5_fw_reset_events mlx5_sync_reset_reload_work [mlx5_core]
 RIP: 0010:devl_assert_locked+0x3e/0x50
…
 Call Trace:
  <TASK>
  ? __warn+0xa4/0x210
  ? devl_assert_locked+0x3e/0x50
  ? report_bug+0x160/0x280
  ? handle_bug+0x3f/0x80
  ? exc_invalid_op+0x17/0x40
  ? asm_exc_invalid_op+0x1a/0x20
  ? devl_assert_locked+0x3e/0x50
  devlink_notify+0x88/0x2b0
  ? mlx5_attach_device+0x20c/0x230 [mlx5_core]
  ? __pfx_devlink_notify+0x10/0x10
  ? process_one_work+0x4b6/0xbb0
  process_one_work+0x4b6/0xbb0

[…]

Fixes 84a433a40d0e ("net/mlx5: Lock mlx5 devlink reload callbacks")
---
 drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +4 -1
index 979c49ae6b5c..b43ca0b762c3 100644
@@ -207,6 +207,7 @@ int mlx5_fw_reset_set_live_patch(struct mlx5_core_dev *dev)
 static void mlx5_fw_reset_complete_reload(struct mlx5_core_dev *dev, bool unloaded)
 {
 	struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset;
+	struct devlink *devlink = priv_to_devlink(dev);
 
 	/* if this is the driver that initiated the fw reset, devlink completed the reload */
 	if (test_bit(MLX5_FW_RESET_FLAGS_PENDING_COMP, &fw_reset->reset_flags)) {
@@ -218,9 +219,11 @@ static void mlx5_fw_reset_complete_reload(struct mlx5_core_dev *dev, bool unload
 			mlx5_core_err(dev, "reset reload flow aborted, PCI reads still not working\n");
 		else
 			mlx5_load_one(dev, true);
-		devlink_remote_reload_actions_performed(priv_to_devlink(dev), 0,
+		devl_lock(devlink);
+		devlink_remote_reload_actions_performed(devlink, 0,
 							BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT) |
 							BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE));
+		devl_unlock(devlink);
 	}
 }
 
Signature · 1 line
2.44.0
Reviewed-by on v1 5/8
#10 lore raw

Re: [PATCH net 5/8] net/mlx5: Fix missing lock on sync reset reload

Quoted 28 lines · Tariq Toukan

From: Moshe Shemesh <[email protected]>

On sync reset reload work, when remote host updates devlink on reload actions performed on that host, it misses taking devlink lock before calling devlink_remote_reload_actions_performed() which results in triggering lock assert like the following:

WARNING: CPU: 4 PID: 1164 at net/devlink/core.c:261 devl_assert_locked+0x3e/0x50
…
 CPU: 4 PID: 1164 Comm: kworker/u96:6 Tainted: G S      W          6.10.0-rc2+ #116
 Hardware name: Supermicro SYS-2028TP-DECTR/X10DRT-PT, BIOS 2.0 12/18/2015
 Workqueue: mlx5_fw_reset_events mlx5_sync_reset_reload_work [mlx5_core]
 RIP: 0010:devl_assert_locked+0x3e/0x50
…
 Call Trace:
  <TASK>
  ? __warn+0xa4/0x210
  ? devl_assert_locked+0x3e/0x50
  ? report_bug+0x160/0x280
  ? handle_bug+0x3f/0x80
  ? exc_invalid_op+0x17/0x40
  ? asm_exc_invalid_op+0x1a/0x20
  ? devl_assert_locked+0x3e/0x50
  devlink_notify+0x88/0x2b0
  ? mlx5_attach_device+0x20c/0x230 [mlx5_core]
  ? __pfx_devlink_notify+0x10/0x10
  ? process_one_work+0x4b6/0xbb0
  process_one_work+0x4b6/0xbb0
Quoted 7 lines

[…]

Fixes 84a433a40d0e ("net/mlx5: Lock mlx5 devlink reload callbacks")

---

Quoted 28 lines
 drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c +4 -1
index 979c49ae6b5c..b43ca0b762c3 100644
@@ -207,6 +207,7 @@ int mlx5_fw_reset_set_live_patch(struct mlx5_core_dev *dev)
 static void mlx5_fw_reset_complete_reload(struct mlx5_core_dev *dev, bool unloaded)
 {
 	struct mlx5_fw_reset *fw_reset = dev->priv.fw_reset;
+	struct devlink *devlink = priv_to_devlink(dev);
 
 	/* if this is the driver that initiated the fw reset, devlink completed the reload */
 	if (test_bit(MLX5_FW_RESET_FLAGS_PENDING_COMP, &fw_reset->reset_flags)) {
@@ -218,9 +219,11 @@ static void mlx5_fw_reset_complete_reload(struct mlx5_core_dev *dev, bool unload
 			mlx5_core_err(dev, "reset reload flow aborted, PCI reads still not working\n");
 		else
 			mlx5_load_one(dev, true);
-		devlink_remote_reload_actions_performed(priv_to_devlink(dev), 0,
+		devl_lock(devlink);
+		devlink_remote_reload_actions_performed(devlink, 0,
 							BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT) |
 							BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE));
+		devl_unlock(devlink);
 	}
 }
 
author maintainer
#11 lore raw

PATCH 6/8 net/mlx5e: Require mlx5 tc classifier action support for IPsec prio capability

In reply to Tariq Toukan

From: Rahul Rameshbabu <[email protected]>

Require mlx5 classifier action support when creating IPSec chains in offload path. MLX5_IPSEC_CAP_PRIO should only be set if CONFIG_MLX5_CLS_ACT is enabled. If CONFIG_MLX5_CLS_ACT=n and MLX5_IPSEC_CAP_PRIO is set, configuring IPsec offload will fail due to the mlxx5 ipsec chain rules failing to be created due to lack of classifier action support.

Fixes fa5aa2f89073 ("net/mlx5e: Use chains for IPsec policy priority offload")
---
 .../ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c   | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c +4 -3
index 6e00afe4671b..797db853de36 100644
@@ -51,9 +51,10 @@ u32 mlx5_ipsec_device_caps(struct mlx5_core_dev *mdev)
 		    MLX5_CAP_FLOWTABLE_NIC_RX(mdev, decap))
 			caps |= MLX5_IPSEC_CAP_PACKET_OFFLOAD;
 
-		if ((MLX5_CAP_FLOWTABLE_NIC_TX(mdev, ignore_flow_level) &&
-		     MLX5_CAP_FLOWTABLE_NIC_RX(mdev, ignore_flow_level)) ||
-		    MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, ignore_flow_level))
+		if (IS_ENABLED(CONFIG_MLX5_CLS_ACT) &&
+		    ((MLX5_CAP_FLOWTABLE_NIC_TX(mdev, ignore_flow_level) &&
+		      MLX5_CAP_FLOWTABLE_NIC_RX(mdev, ignore_flow_level)) ||
+		     MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, ignore_flow_level)))
 			caps |= MLX5_IPSEC_CAP_PRIO;
 
 		if (MLX5_CAP_FLOWTABLE_NIC_TX(mdev,
Signature · 1 line
2.44.0
Reviewed-by on v1 6/8
#12 lore raw

Re: [PATCH net 6/8] net/mlx5e: Require mlx5 tc classifier action support for IPsec prio capability

Quoted 8 lines · Tariq Toukan

From: Rahul Rameshbabu <[email protected]>

Require mlx5 classifier action support when creating IPSec chains in offload path. MLX5_IPSEC_CAP_PRIO should only be set if CONFIG_MLX5_CLS_ACT is enabled. If CONFIG_MLX5_CLS_ACT=n and MLX5_IPSEC_CAP_PRIO is set, configuring IPsec offload will fail due to the mlxx5 ipsec chain rules failing to be created due to lack of classifier action support.

Quoted 5 lines
Fixes fa5aa2f89073 ("net/mlx5e: Use chains for IPsec policy priority offload")

---

Quoted 21 lines
 .../ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c   | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c +4 -3
index 6e00afe4671b..797db853de36 100644
@@ -51,9 +51,10 @@ u32 mlx5_ipsec_device_caps(struct mlx5_core_dev *mdev)
 		    MLX5_CAP_FLOWTABLE_NIC_RX(mdev, decap))
 			caps |= MLX5_IPSEC_CAP_PACKET_OFFLOAD;
 
-		if ((MLX5_CAP_FLOWTABLE_NIC_TX(mdev, ignore_flow_level) &&
-		     MLX5_CAP_FLOWTABLE_NIC_RX(mdev, ignore_flow_level)) ||
-		    MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, ignore_flow_level))
+		if (IS_ENABLED(CONFIG_MLX5_CLS_ACT) &&
+		    ((MLX5_CAP_FLOWTABLE_NIC_TX(mdev, ignore_flow_level) &&
+		      MLX5_CAP_FLOWTABLE_NIC_RX(mdev, ignore_flow_level)) ||
+		     MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, ignore_flow_level)))
 			caps |= MLX5_IPSEC_CAP_PRIO;
 
 		if (MLX5_CAP_FLOWTABLE_NIC_TX(mdev,
author maintainer
#13 lore raw

PATCH 7/8 net/mlx5e: Fix CT entry update leaks of modify header context

In reply to Tariq Toukan

From: Chris Mi <[email protected]>

The cited commit allocates a new modify header to replace the old one when updating CT entry. But if failed to allocate a new one, eg. exceed the max number firmware can support, modify header will be an error pointer that will trigger a panic when deallocating it. And the old modify header point is copied to old attr. When the old attr is freed, the old modify header is lost.

Fix it by restoring the old attr to attr when failed to allocate a new modify header context. So when the CT entry is freed, the right modify header context will be freed. And the panic of accessing error pointer is also fixed.

Fixes 94ceffb48eac ("net/mlx5e: Implement CT entry update")
---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +1 -0
index 8cf8ba2622f2..71a168746ebe 100644
@@ -932,6 +932,7 @@ mlx5_tc_ct_entry_replace_rule(struct mlx5_tc_ct_priv *ct_priv,
 	mlx5_tc_ct_entry_destroy_mod_hdr(ct_priv, zone_rule->attr, mh);
 	mlx5_put_label_mapping(ct_priv, attr->ct_attr.ct_labels_id);
 err_mod_hdr:
+	*attr = *old_attr;
 	kfree(old_attr);
 err_attr:
 	kvfree(spec);
Signature · 1 line
2.44.0
Reviewed-by on v1 7/8
#14 lore raw

Re: [PATCH net 7/8] net/mlx5e: Fix CT entry update leaks of modify header context

Quoted 14 lines · Tariq Toukan

From: Chris Mi <[email protected]>

The cited commit allocates a new modify header to replace the old one when updating CT entry. But if failed to allocate a new one, eg. exceed the max number firmware can support, modify header will be an error pointer that will trigger a panic when deallocating it. And the old modify header point is copied to old attr. When the old attr is freed, the old modify header is lost.

Fix it by restoring the old attr to attr when failed to allocate a new modify header context. So when the CT entry is freed, the right modify header context will be freed. And the panic of accessing error pointer is also fixed.

Quoted 4 lines
Fixes 94ceffb48eac ("net/mlx5e: Implement CT entry update")

---

Quoted 15 lines
 drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +1 -0
index 8cf8ba2622f2..71a168746ebe 100644
@@ -932,6 +932,7 @@ mlx5_tc_ct_entry_replace_rule(struct mlx5_tc_ct_priv *ct_priv,
 	mlx5_tc_ct_entry_destroy_mod_hdr(ct_priv, zone_rule->attr, mh);
 	mlx5_put_label_mapping(ct_priv, attr->ct_attr.ct_labels_id);
 err_mod_hdr:
+	*attr = *old_attr;
 	kfree(old_attr);
 err_attr:
 	kvfree(spec);
author maintainer
#15 lore raw

PATCH 8/8 net/mlx5e: Add a check for the return value from mlx5_port_set_eth_ptys

In reply to Tariq Toukan

From: Shahar Shitrit <[email protected]>

Since the documentation for mlx5_toggle_port_link states that it should only be used after setting the port register, we add a check for the return value from mlx5_port_set_eth_ptys to ensure the register was successfully set before calling it.

Fixes 667daedaecd1 ("net/mlx5e: Toggle link only after modifying port parameters")
---
 drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +6 -1
index 00d5661dc62e..36845872ae94 100644
@@ -1409,7 +1409,12 @@ static int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv,
 	if (!an_changes && link_modes == eproto.admin)
 		goto out;
 
-	mlx5_port_set_eth_ptys(mdev, an_disable, link_modes, ext);
+	err = mlx5_port_set_eth_ptys(mdev, an_disable, link_modes, ext);
+	if (err) {
+		netdev_err(priv->netdev, "%s: failed to set ptys reg: %d\n", __func__, err);
+		goto out;
+	}
+
 	mlx5_toggle_port_link(mdev);
 
 out:
Signature · 1 line
2.44.0
Reviewed-by on v1 8/8
#16 lore raw

Re: [PATCH net 8/8] net/mlx5e: Add a check for the return value from mlx5_port_set_eth_ptys

Quoted 7 lines · Tariq Toukan

From: Shahar Shitrit <[email protected]>

Since the documentation for mlx5_toggle_port_link states that it should only be used after setting the port register, we add a check for the return value from mlx5_port_set_eth_ptys to ensure the register was successfully set before calling it.

Quoted 5 lines
Fixes 667daedaecd1 ("net/mlx5e: Toggle link only after modifying port parameters")

---

Quoted 21 lines
 drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +6 -1
index 00d5661dc62e..36845872ae94 100644
@@ -1409,7 +1409,12 @@ static int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv,
 	if (!an_changes && link_modes == eproto.admin)
 		goto out;
 
-	mlx5_port_set_eth_ptys(mdev, an_disable, link_modes, ext);
+	err = mlx5_port_set_eth_ptys(mdev, an_disable, link_modes, ext);
+	if (err) {
+		netdev_err(priv->netdev, "%s: failed to set ptys reg: %d\n", __func__, err);
+		goto out;
+	}
+
 	mlx5_toggle_port_link(mdev);
 
 out:
#17 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, 30 Jul 2024 09:16:29 +0300 you wrote:

Hi,

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

Series generated against:
commit 301927d2d2eb ("Merge tag 'for-net-2024-07-26' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth")

[...]

Here is the summary with links:
- [net,1/8] net/mlx5: Always drain health in shutdown callback

    https://git.kernel.org/netdev/net/c/1b75da22ed1e
  - [net,2/8] net/mlx5: Fix error handling in irq_pool_request_irq
    https://git.kernel.org/netdev/net/c/a4557b0b57c4
  - [net,3/8] net/mlx5: DR, Fix 'stack guard page was hit' error in dr_rule
    https://git.kernel.org/netdev/net/c/94a3ad6c0813
  - [net,4/8] net/mlx5: Lag, don't use the hardcoded value of the first port
    https://git.kernel.org/netdev/net/c/3fda84dc0903
  - [net,5/8] net/mlx5: Fix missing lock on sync reset reload
    https://git.kernel.org/netdev/net/c/572f9caa9e72
  - [net,6/8] net/mlx5e: Require mlx5 tc classifier action support for IPsec prio capability
    https://git.kernel.org/netdev/net/c/06827e27fdcd
  - [net,7/8] net/mlx5e: Fix CT entry update leaks of modify header context
    https://git.kernel.org/netdev/net/c/025f2b85a5e5
  - [net,8/8] net/mlx5e: Add a check for the return value from mlx5_port_set_eth_ptys
    https://git.kernel.org/netdev/net/c/3f8e82a020a5

You are awesome, thank you!

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