diff mbox series

[14/35] net/mlx5/windows: support device removed query

Message ID 20201217173037.11396-15-talshn@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers show
Series mlx5 Windows support - part #6 | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tal Shnaiderman Dec. 17, 2020, 5:30 p.m. UTC
This commit implements mlx5_is_removed() API. A new glue call
'init_shutdown_event' is added to support the new API.

Signed-off-by: Tal Shnaiderman <talshn@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/common/mlx5/windows/mlx5_glue.c    | 21 +++++++++++++++++++++
 drivers/common/mlx5/windows/mlx5_glue.h    |  1 +
 drivers/common/mlx5/windows/mlx5_win_ext.h |  2 +-
 drivers/net/mlx5/windows/mlx5_ethdev_os.c  | 20 ++++++++++++++++++++
 4 files changed, 43 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/common/mlx5/windows/mlx5_glue.c b/drivers/common/mlx5/windows/mlx5_glue.c
index 167531823b..aef6d3b5f4 100644
--- a/drivers/common/mlx5/windows/mlx5_glue.c
+++ b/drivers/common/mlx5/windows/mlx5_glue.c
@@ -308,6 +308,26 @@  mlx5_glue_query_rt_values(void *ctx, void *devx_clock)
 	return 0;
 }
 
+static int
+mlx5_glue_devx_init_showdown_event(void *ctx)
+{
+	struct mlx5_context *mlx5_ctx;
+	int err;
+
+	if (!ctx) {
+		errno = EINVAL;
+		return errno;
+	}
+	mlx5_ctx = (struct mlx5_context *)ctx;
+	err = devx_query_shutdown_event(mlx5_ctx->devx_ctx,
+			&mlx5_ctx->shutdown_event_obj);
+	if (err) {
+		errno = err;
+		return errno;
+	}
+	return 0;
+}
+
 alignas(RTE_CACHE_LINE_SIZE)
 const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
 	.version = MLX5_GLUE_VERSION,
@@ -330,4 +350,5 @@  const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
 	.devx_fs_rule_del = mlx5_glue_devx_fs_rule_del,
 	.devx_query_eqn = mlx5_glue_devx_query_eqn,
 	.query_rt_values = mlx5_glue_query_rt_values,
+	.devx_init_showdown_event = mlx5_glue_devx_init_showdown_event,
 };
diff --git a/drivers/common/mlx5/windows/mlx5_glue.h b/drivers/common/mlx5/windows/mlx5_glue.h
index bfaaa2a493..420bfb27ef 100644
--- a/drivers/common/mlx5/windows/mlx5_glue.h
+++ b/drivers/common/mlx5/windows/mlx5_glue.h
@@ -52,6 +52,7 @@  struct mlx5_glue {
 	int (*devx_fs_rule_del)(void *flow);
 	int (*devx_query_eqn)(void *context, uint32_t cpus, uint32_t *eqn);
 	int (*query_rt_values)(void *ctx, void *devx_clock);
+	int (*devx_init_showdown_event)(void *ctx);
 };
 
 extern const struct mlx5_glue *mlx5_glue;
diff --git a/drivers/common/mlx5/windows/mlx5_win_ext.h b/drivers/common/mlx5/windows/mlx5_win_ext.h
index a14a6ccc3d..111af2e8da 100644
--- a/drivers/common/mlx5/windows/mlx5_win_ext.h
+++ b/drivers/common/mlx5/windows/mlx5_win_ext.h
@@ -14,7 +14,7 @@  extern "C" {
 typedef struct mlx5_context {
 	devx_device_ctx        *devx_ctx;
 	struct devx_device mlx5_dev;
-
+	struct devx_shutdown_event shutdown_event_obj;
 } mlx5_context_st;
 
 typedef struct {
diff --git a/drivers/net/mlx5/windows/mlx5_ethdev_os.c b/drivers/net/mlx5/windows/mlx5_ethdev_os.c
index f0355ac671..f4ec855302 100644
--- a/drivers/net/mlx5/windows/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/windows/mlx5_ethdev_os.c
@@ -369,3 +369,23 @@  mlx5_read_clock(struct rte_eth_dev *dev, uint64_t *clock)
 	*clock = *(uint64_t volatile *)mlx5_clock.p_iseg_internal_timer;
 	return 0;
 }
+
+/**
+ * Check if mlx5 device was removed.
+ *
+ * @param dev
+ *   Pointer to Ethernet device structure.
+ *
+ * @return
+ *   1 when device is removed, otherwise 0.
+ */
+int
+mlx5_is_removed(struct rte_eth_dev *dev)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	mlx5_context_st *context_obj = (mlx5_context_st *)priv->sh->ctx;
+
+	if (*context_obj->shutdown_event_obj.p_flag)
+		return 1;
+	return 0;
+}