From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E6F16A09F6; Thu, 17 Dec 2020 18:36:07 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1B133CAA3; Thu, 17 Dec 2020 18:33:26 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 415BCCA3E for ; Thu, 17 Dec 2020 18:33:10 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from talshn@nvidia.com) with SMTP; 17 Dec 2020 19:33:05 +0200 Received: from nvidia.com (l-wincomp04-vm.mtl.labs.mlnx [10.237.1.5]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0BHHX45Z021771; Thu, 17 Dec 2020 19:33:05 +0200 From: Tal Shnaiderman To: dev@dpdk.org Cc: thomas@monjalon.net, matan@nvidia.com, rasland@nvidia.com, ophirmu@nvidia.com Date: Thu, 17 Dec 2020 19:30:16 +0200 Message-Id: <20201217173037.11396-15-talshn@nvidia.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20201217173037.11396-1-talshn@nvidia.com> References: <20201217173037.11396-1-talshn@nvidia.com> Subject: [dpdk-dev] [PATCH 14/35] net/mlx5/windows: support device removed query X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Acked-by: Matan Azrad --- 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 --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; +} -- 2.16.1.windows.4