patch 'net/mlx5: fix device removal event handling' has been queued to stable release 20.11.9

luca.boccassi at gmail.com luca.boccassi at gmail.com
Wed Jun 28 16:10:45 CEST 2023


Hi,

FYI, your patch has been queued to stable release 20.11.9

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 06/30/23. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/92f3908f23339ab540c5a461a79f7d033bd2ce0f

Thanks.

Luca Boccassi

---
>From 92f3908f23339ab540c5a461a79f7d033bd2ce0f Mon Sep 17 00:00:00 2001
From: Viacheslav Ovsiienko <viacheslavo at nvidia.com>
Date: Tue, 30 May 2023 18:13:28 +0300
Subject: [PATCH] net/mlx5: fix device removal event handling

[ upstream commit 22dc56cfbd39692eb74fad93ff5ecc3df5fd0633 ]

On the device removal kernel notifies user space application
with queueing the IBV_DEVICE_FATAL_EVENT and triggering appropriate
file descriptor. Mellanox kernel driver stack emits this event
twice from different layers (mlx5 and uverbs). The IB port index
is not applicable in the event structure and should be ignored
for IBV_DEVICE_FATAL_EVENT events.

Also, on the older kernels (at least from OFED 4.9) there might be
race conditions causing the event queue close before application
fetches the IBV_DEVICE_FATAL_EVENT message with ibv_get_async_event()
API.

To provide the reliable device removal event detection the patch:

  - ignores the IB port index for the IBV_DEVICE_FATAL_EVENT
  - introduces the flag to notify PMD about removal only once
  - acks event with ibv_ack_async_event after actual handling
  - checks for EIO error, making sure queue is not closed yet

Fixes: 40d9f906f4e2 ("net/mlx5: fix device removal handler for multiport")

Signed-off-by: Viacheslav Ovsiienko <viacheslavo at nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_ethdev_os.c | 40 +++++++++++++++++--------
 drivers/net/mlx5/mlx5.h                 |  1 +
 2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
index 92320616b5..473dad3851 100644
--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
@@ -715,6 +715,7 @@ mlx5_dev_interrupt_device_fatal(struct mlx5_dev_ctx_shared *sh)
 
 	for (i = 0; i < sh->max_port; ++i) {
 		struct rte_eth_dev *dev;
+		struct mlx5_priv *priv;
 
 		if (sh->port[i].ih_port_id >= RTE_MAX_ETHPORTS) {
 			/*
@@ -725,9 +726,14 @@ mlx5_dev_interrupt_device_fatal(struct mlx5_dev_ctx_shared *sh)
 		}
 		dev = &rte_eth_devices[sh->port[i].ih_port_id];
 		MLX5_ASSERT(dev);
-		if (dev->data->dev_conf.intr_conf.rmv)
+		priv = dev->data->dev_private;
+		MLX5_ASSERT(priv);
+		if (!priv->rmv_notified && dev->data->dev_conf.intr_conf.rmv) {
+			/* Notify driver about removal only once. */
+			priv->rmv_notified = 1;
 			rte_eth_dev_callback_process
 				(dev, RTE_ETH_EVENT_INTR_RMV, NULL);
+		}
 	}
 }
 
@@ -800,21 +806,29 @@ mlx5_dev_interrupt_handler(void *cb_arg)
 		struct rte_eth_dev *dev;
 		uint32_t tmp;
 
-		if (mlx5_glue->get_async_event(sh->ctx, &event))
+		if (mlx5_glue->get_async_event(sh->ctx, &event)) {
+			if (errno == EIO) {
+				DRV_LOG(DEBUG,
+					"IBV async event queue closed on: %s",
+					sh->ibdev_name);
+				mlx5_dev_interrupt_device_fatal(sh);
+			}
 			break;
+		}
+		if (event.event_type == IBV_EVENT_DEVICE_FATAL) {
+			/*
+			 * The DEVICE_FATAL event can be called by kernel
+			 * twice - from mlx5 and uverbs layers, and port
+			 * index is not applicable. We should notify all
+			 * existing ports.
+			 */
+			mlx5_dev_interrupt_device_fatal(sh);
+			mlx5_glue->ack_async_event(&event);
+			continue;
+		}
 		/* Retrieve and check IB port index. */
 		tmp = (uint32_t)event.element.port_num;
-		if (!tmp && event.event_type == IBV_EVENT_DEVICE_FATAL) {
-			/*
-			 * The DEVICE_FATAL event is called once for
-			 * entire device without port specifying.
-			 * We should notify all existing ports.
-			 */
-			mlx5_glue->ack_async_event(&event);
-			mlx5_dev_interrupt_device_fatal(sh);
-			continue;
-		}
-		MLX5_ASSERT(tmp && (tmp <= sh->max_port));
+		MLX5_ASSERT(tmp <= sh->max_port);
 		if (!tmp) {
 			/* Unsupported device level event. */
 			mlx5_glue->ack_async_event(&event);
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 1f47c433eb..19cb02ad42 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -945,6 +945,7 @@ struct mlx5_priv {
 	unsigned int mtr_reg_share:1; /* Whether support meter REG_C share. */
 	unsigned int sampler_en:1; /* Whether support sampler. */
 	unsigned int lb_used:1; /* Loopback queue is referred to. */
+	unsigned int rmv_notified:1; /* Notified about removal event */
 	uint32_t mark_enabled:1; /* If mark action is enabled on rxqs. */
 	uint16_t domain_id; /* Switch domain identifier. */
 	uint16_t vport_id; /* Associated VF vport index (if any). */
-- 
2.39.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-06-28 11:40:08.957115256 +0100
+++ 0021-net-mlx5-fix-device-removal-event-handling.patch	2023-06-28 11:40:08.088028165 +0100
@@ -1 +1 @@
-From 22dc56cfbd39692eb74fad93ff5ecc3df5fd0633 Mon Sep 17 00:00:00 2001
+From 92f3908f23339ab540c5a461a79f7d033bd2ce0f Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 22dc56cfbd39692eb74fad93ff5ecc3df5fd0633 ]
+
@@ -26 +27,0 @@
-Cc: stable at dpdk.org
@@ -35 +36 @@
-index 55801534d1..639e629fe4 100644
+index 92320616b5..473dad3851 100644
@@ -38 +39 @@
-@@ -746,6 +746,7 @@ mlx5_dev_interrupt_device_fatal(struct mlx5_dev_ctx_shared *sh)
+@@ -715,6 +715,7 @@ mlx5_dev_interrupt_device_fatal(struct mlx5_dev_ctx_shared *sh)
@@ -46 +47 @@
-@@ -756,9 +757,14 @@ mlx5_dev_interrupt_device_fatal(struct mlx5_dev_ctx_shared *sh)
+@@ -725,9 +726,14 @@ mlx5_dev_interrupt_device_fatal(struct mlx5_dev_ctx_shared *sh)
@@ -62 +63 @@
-@@ -830,21 +836,29 @@ mlx5_dev_interrupt_handler(void *cb_arg)
+@@ -800,21 +806,29 @@ mlx5_dev_interrupt_handler(void *cb_arg)
@@ -66,2 +67,2 @@
--		if (mlx5_glue->get_async_event(sh->cdev->ctx, &event))
-+		if (mlx5_glue->get_async_event(sh->cdev->ctx, &event)) {
+-		if (mlx5_glue->get_async_event(sh->ctx, &event))
++		if (mlx5_glue->get_async_event(sh->ctx, &event)) {
@@ -105 +106 @@
-index fffd3c79f1..10a2f33ea0 100644
+index 1f47c433eb..19cb02ad42 100644
@@ -108,2 +109 @@
-@@ -1744,6 +1744,7 @@ struct mlx5_priv {
- 	unsigned int mtr_en:1; /* Whether support meter. */
+@@ -945,6 +945,7 @@ struct mlx5_priv {
@@ -110,0 +111 @@
+ 	unsigned int sampler_en:1; /* Whether support sampler. */
@@ -114,2 +115,2 @@
- 	uint32_t num_lag_ports:4; /* Number of ports can be bonded. */
- 	uint32_t tunnel_enabled:1; /* If tunnel offloading is enabled on rxqs. */
+ 	uint16_t domain_id; /* Switch domain identifier. */
+ 	uint16_t vport_id; /* Associated VF vport index (if any). */


More information about the stable mailing list