net/mlx5: close tools socket with last device

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: e6cdc54cc0 ("net/mlx5: add socket server for external tools")
Cc: stable@dpdk.org

Reported-by: Harman Kalra <hkalra@marvell.com>
Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
This commit is contained in:
Dmitry Kozlyuk 2021-10-14 11:55:28 +03:00 committed by Raslan Darawsheh
parent 9ec1ceab76
commit ea823b2c51
5 changed files with 26 additions and 11 deletions

View File

@ -2666,6 +2666,15 @@ mlx5_os_net_probe(struct mlx5_common_device *cdev)
return mlx5_os_auxiliary_probe(cdev);
}
/**
* 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

View File

@ -167,10 +167,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.
@ -187,10 +184,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",
@ -237,7 +230,8 @@ mlx5_pmd_socket_init(void)
/**
* Un-Initialize the pmd socket
*/
RTE_FINI(mlx5_pmd_socket_uninit)
void
mlx5_pmd_socket_uninit(void)
{
if (!server_socket)
return;

View File

@ -1363,9 +1363,11 @@ mlx5_free_shared_dev_ctx(struct mlx5_dev_ctx_shared *sh)
}
/* Remove context from the global device list. */
LIST_REMOVE(sh, next);
/* Release flow workspaces objects on the last device. */
if (LIST_EMPTY(&mlx5_dev_ctx_list))
/* Release resources on the last device removal. */
if (LIST_EMPTY(&mlx5_dev_ctx_list)) {
mlx5_os_net_cleanup();
mlx5_flow_os_release_workspace();
}
pthread_mutex_unlock(&mlx5_dev_ctx_list_mutex);
/*
* Ensure there is no async event handler installed.

View File

@ -1706,6 +1706,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 */
@ -1749,6 +1750,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 */

View File

@ -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};