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(-)
@@ -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,
};
@@ -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;
@@ -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 {
@@ -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;
+}