net/mlx5: support device removed query on Windows
authorTal Shnaiderman <talshn@nvidia.com>
Mon, 28 Dec 2020 12:32:41 +0000 (14:32 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 8 Jan 2021 15:03:08 +0000 (16:03 +0100)
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
drivers/common/mlx5/windows/mlx5_glue.h
drivers/common/mlx5/windows/mlx5_win_ext.h
drivers/net/mlx5/windows/mlx5_ethdev_os.c

index 1675318..aef6d3b 100644 (file)
@@ -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,
 };
index bfaaa2a..420bfb2 100644 (file)
@@ -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;
index a14a6cc..111af2e 100644 (file)
@@ -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 {
index f0355ac..f4ec855 100644 (file)
@@ -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;
+}