[dpdk-stable] patch 'net/mlx5: close tools socket with last device' has been queued to stable release 20.11.4
Xueming Li
xuemingl at nvidia.com
Wed Nov 10 07:31:00 CET 2021
Hi,
FYI, your patch has been queued to stable release 20.11.4
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/12/21. 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/steevenlee/dpdk
This queued commit can be viewed at:
https://github.com/steevenlee/dpdk/commit/315ca5d5358aa3089510df129d0c7f144714c4ba
Thanks.
Xueming Li <xuemingl at nvidia.com>
---
>From 315ca5d5358aa3089510df129d0c7f144714c4ba Mon Sep 17 00:00:00 2001
From: Dmitry Kozlyuk <dkozlyuk at nvidia.com>
Date: Thu, 14 Oct 2021 11:55:28 +0300
Subject: [PATCH] net/mlx5: close tools socket with last device
Cc: Xueming Li <xuemingl at nvidia.com>
[ upstream commit ea823b2c511d6e4a4e51fa5e4aabc30e5a30cdb7 ]
MLX5 PMD exposes a socket for external tools to dump port state.
Socket events are listened using an interrupt source of EXT type.
The socket was closed and the interrupt callback was unregistered
at program exit, which is incorrect because DPDK could be already
shut down at this point. Move actions performed at program exit
to the moment the last MLX5 port is closed. The socket will be opened
again if later a new MLX5 device is plugged in and probed.
Also fix comments that were decisively talking
about secondary processes instead of external tools.
Fixes: e6cdc54cc0ef ("net/mlx5: add socket server for external tools")
Reported-by: Harman Kalra <hkalra at marvell.com>
Signed-off-by: Dmitry Kozlyuk <dkozlyuk at nvidia.com>
Acked-by: Thomas Monjalon <thomas at monjalon.net>
---
drivers/net/mlx5/linux/mlx5_os.c | 9 +++++++++
drivers/net/mlx5/linux/mlx5_socket.c | 12 +++---------
drivers/net/mlx5/mlx5.c | 4 ++++
drivers/net/mlx5/mlx5.h | 2 ++
4 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index cc4fa3dd97..e4bb26bc2b 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -2463,6 +2463,15 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn,
return err;
}
+/**
+ * Cleanup resources when the last device is closed.
+ */
+void
+mlx5_os_net_cleanup(void)
+{
+ mlx5_pmd_socket_uninit();
+}
+
/**
* Install shared asynchronous device events handler.
* This function is implemented to support event sharing
diff --git a/drivers/net/mlx5/linux/mlx5_socket.c b/drivers/net/mlx5/linux/mlx5_socket.c
index b1f41bc102..e60d1ec212 100644
--- a/drivers/net/mlx5/linux/mlx5_socket.c
+++ b/drivers/net/mlx5/linux/mlx5_socket.c
@@ -140,10 +140,7 @@ mlx5_pmd_interrupt_handler_uninstall(void)
}
/**
- * Initialise the socket to communicate with the secondary process
- *
- * @param[in] dev
- * Pointer to Ethernet device.
+ * Initialise the socket to communicate with external tools.
*
* @return
* 0 on success, a negative value otherwise.
@@ -160,10 +157,6 @@ mlx5_pmd_socket_init(void)
MLX5_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
if (server_socket)
return 0;
- /*
- * Initialize the socket to communicate with the secondary
- * process.
- */
ret = socket(AF_UNIX, SOCK_STREAM, 0);
if (ret < 0) {
DRV_LOG(WARNING, "Failed to open mlx5 socket: %s",
@@ -210,7 +203,8 @@ error:
/**
* Un-Initialize the pmd socket
*/
-RTE_FINI(mlx5_pmd_socket_uninit)
+void
+mlx5_pmd_socket_uninit(void)
{
if (!server_socket)
return;
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 48588d4cd5..ef1308ffc1 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1079,6 +1079,10 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
mlx5_mr_release_cache(&sh->share_cache);
/* Remove context from the global device list. */
LIST_REMOVE(sh, next);
+ /* Release resources on the last device removal. */
+ if (LIST_EMPTY(&mlx5_dev_ctx_list)) {
+ mlx5_os_net_cleanup();
+ }
pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
/*
* Ensure there is no async event handler installed.
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 3d6d5bb923..7e984f8438 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1261,6 +1261,7 @@ int mlx5_mp_os_req_queue_control(struct rte_eth_dev *dev, uint16_t queue_id,
/* mlx5_socket.c */
int mlx5_pmd_socket_init(void);
+void mlx5_pmd_socket_uninit(void);
/* mlx5_flow_meter.c */
@@ -1298,6 +1299,7 @@ int mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable);
int mlx5_os_set_allmulti(struct rte_eth_dev *dev, int enable);
int mlx5_os_set_nonblock_channel_fd(int fd);
void mlx5_os_mac_addr_flush(struct rte_eth_dev *dev);
+void mlx5_os_net_cleanup(void);
/* mlx5_txpp.c */
--
2.33.0
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2021-11-10 14:17:09.746918599 +0800
+++ 0176-net-mlx5-close-tools-socket-with-last-device.patch 2021-11-10 14:17:01.987411803 +0800
@@ -1 +1 @@
-From ea823b2c511d6e4a4e51fa5e4aabc30e5a30cdb7 Mon Sep 17 00:00:00 2001
+From 315ca5d5358aa3089510df129d0c7f144714c4ba Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit ea823b2c511d6e4a4e51fa5e4aabc30e5a30cdb7 ]
@@ -17 +19,0 @@
-Cc: stable at dpdk.org
@@ -25 +27 @@
- drivers/net/mlx5/mlx5.c | 6 ++++--
+ drivers/net/mlx5/mlx5.c | 4 ++++
@@ -27,2 +29 @@
- drivers/net/mlx5/windows/mlx5_os.c | 8 ++++++++
- 5 files changed, 26 insertions(+), 11 deletions(-)
+ 4 files changed, 18 insertions(+), 9 deletions(-)
@@ -31 +32 @@
-index 7de60ac3d7..0eff7930b4 100644
+index cc4fa3dd97..e4bb26bc2b 100644
@@ -34,2 +35,2 @@
-@@ -2666,6 +2666,15 @@ mlx5_os_net_probe(struct mlx5_common_device *cdev)
- return mlx5_os_auxiliary_probe(cdev);
+@@ -2463,6 +2463,15 @@ mlx5_os_open_device(const struct mlx5_dev_spawn_data *spawn,
+ return err;
@@ -51 +52 @@
-index 6356b66dc4..902b8ec934 100644
+index b1f41bc102..e60d1ec212 100644
@@ -54 +55 @@
-@@ -167,10 +167,7 @@ mlx5_pmd_interrupt_handler_uninstall(void)
+@@ -140,10 +140,7 @@ mlx5_pmd_interrupt_handler_uninstall(void)
@@ -66 +67 @@
-@@ -187,10 +184,6 @@ mlx5_pmd_socket_init(void)
+@@ -160,10 +157,6 @@ mlx5_pmd_socket_init(void)
@@ -77 +78 @@
-@@ -237,7 +230,8 @@ error:
+@@ -210,7 +203,8 @@ error:
@@ -88 +89 @@
-index 4a1b85b927..f827318fd0 100644
+index 48588d4cd5..ef1308ffc1 100644
@@ -91,2 +92,2 @@
-@@ -1363,9 +1363,11 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
- }
+@@ -1079,6 +1079,10 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
+ mlx5_mr_release_cache(&sh->share_cache);
@@ -95,2 +95,0 @@
-- /* Release flow workspaces objects on the last device. */
-- if (LIST_EMPTY(&mlx5_dev_ctx_list))
@@ -100 +98,0 @@
- mlx5_flow_os_release_workspace();
@@ -106 +104 @@
-index adef86d3ae..d8694d7a6b 100644
+index 3d6d5bb923..7e984f8438 100644
@@ -109 +107 @@
-@@ -1706,6 +1706,7 @@ int mlx5_mp_os_req_queue_control(struct rte_eth_dev *dev, uint16_t queue_id,
+@@ -1261,6 +1261,7 @@ int mlx5_mp_os_req_queue_control(struct rte_eth_dev *dev, uint16_t queue_id,
@@ -117 +115 @@
-@@ -1749,6 +1750,7 @@ int mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable);
+@@ -1298,6 +1299,7 @@ int mlx5_os_set_promisc(struct rte_eth_dev *dev, int enable);
@@ -125,17 +122,0 @@
-diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
-index 685babe0ae..fdf3b957c7 100644
---- a/drivers/net/mlx5/windows/mlx5_os.c
-+++ b/drivers/net/mlx5/windows/mlx5_os.c
-@@ -949,4 +949,12 @@ mlx5_os_net_probe(struct mlx5_common_device *cdev)
- return 0;
- }
-
-+/**
-+ * Cleanup resources when the last device is closed.
-+ */
-+void
-+mlx5_os_net_cleanup(void)
-+{
-+}
-+
- const struct mlx5_flow_driver_ops mlx5_flow_verbs_drv_ops = {0};
More information about the stable
mailing list