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 17A6AA09FF; Mon, 28 Dec 2020 11:04:30 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1D123CC54; Mon, 28 Dec 2020 10:55:47 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id E62CCCA45 for ; Mon, 28 Dec 2020 10:54:51 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from talshn@nvidia.com) with SMTP; 28 Dec 2020 11:54:46 +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 0BS9shDq012171; Mon, 28 Dec 2020 11:54:45 +0200 From: Tal Shnaiderman To: dev@dpdk.org Cc: thomas@monjalon.net, matan@nvidia.com, rasland@nvidia.com, ophirmu@nvidia.com Date: Mon, 28 Dec 2020 11:54:29 +0200 Message-Id: <20201228095436.14996-26-talshn@nvidia.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20201228095436.14996-1-talshn@nvidia.com> References: <20201213205005.7300-2-talshn@nvidia.com> <20201228095436.14996-1-talshn@nvidia.com> Subject: [dpdk-dev] [PATCH v5 25/32] common/mlx5/windows: add OS alloc/dealloc pd 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" Implement Windows API mlx5_os_alloc_pd() and mlx5_os_dealloc_pd(). They are equivalent to the Linux implementation in [1]. [1] ("net/mlx5: wrap glue alloc/dealloc PD with OS calls") Signed-off-by: Tal Shnaiderman Acked-by: Matan Azrad --- drivers/common/mlx5/rte_common_mlx5_exports.def | 3 +- drivers/common/mlx5/windows/mlx5_common_os.c | 48 +++++++++++++++++++++++++ drivers/common/mlx5/windows/mlx5_common_os.h | 3 ++ drivers/common/mlx5/windows/mlx5_win_ext.h | 6 ++++ 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/drivers/common/mlx5/rte_common_mlx5_exports.def b/drivers/common/mlx5/rte_common_mlx5_exports.def index 2f6aab133b..5db1eaa48c 100644 --- a/drivers/common/mlx5/rte_common_mlx5_exports.def +++ b/drivers/common/mlx5/rte_common_mlx5_exports.def @@ -61,4 +61,5 @@ EXPORTS mlx5_malloc mlx5_realloc mlx5_free - + mlx5_os_alloc_pd + mlx5_os_dealloc_pd diff --git a/drivers/common/mlx5/windows/mlx5_common_os.c b/drivers/common/mlx5/windows/mlx5_common_os.c index 5707fb60c3..85537b6739 100644 --- a/drivers/common/mlx5/windows/mlx5_common_os.c +++ b/drivers/common/mlx5/windows/mlx5_common_os.c @@ -22,3 +22,51 @@ void mlx5_glue_constructor(void) { } + +/** + * Allocate PD. Given a devx context object + * return an mlx5-pd object. + * + * @param[in] ctx + * Pointer to context. + * + * @return + * The mlx5_pd if pd is valid, NULL and errno otherwise. + */ +void * +mlx5_os_alloc_pd(void *ctx) +{ + struct mlx5_pd *ppd = mlx5_malloc(MLX5_MEM_ZERO, + sizeof(struct mlx5_pd), 0, SOCKET_ID_ANY); + if (!ppd) + return NULL; + + struct mlx5_devx_obj *obj = mlx5_devx_cmd_alloc_pd(ctx); + if (!obj) { + mlx5_free(ppd); + return NULL; + } + ppd->obj = obj; + ppd->pdn = obj->id; + ppd->devx_ctx = ctx; + return ppd; +} + +/** + * Release PD. Releases a given mlx5_pd object + * + * @param[in] pd + * Pointer to mlx5_pd. + * + * @return + * Zero if pd is released successfully, negative number otherwise. + */ +int +mlx5_os_dealloc_pd(void *pd) +{ + if (!pd) + return -EINVAL; + mlx5_devx_cmd_destroy(((struct mlx5_pd *)pd)->obj); + mlx5_free(pd); + return 0; +} diff --git a/drivers/common/mlx5/windows/mlx5_common_os.h b/drivers/common/mlx5/windows/mlx5_common_os.h index 2abdb2c3ae..f47351ec41 100644 --- a/drivers/common/mlx5/windows/mlx5_common_os.h +++ b/drivers/common/mlx5/windows/mlx5_common_os.h @@ -139,4 +139,7 @@ mlx5_os_get_umem_id(void *umem) return 0; return ((struct mlx5_devx_umem *)umem)->umem_id; } + +void *mlx5_os_alloc_pd(void *ctx); +int mlx5_os_dealloc_pd(void *pd); #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */ diff --git a/drivers/common/mlx5/windows/mlx5_win_ext.h b/drivers/common/mlx5/windows/mlx5_win_ext.h index 0e74910e9d..8e697b30c1 100644 --- a/drivers/common/mlx5/windows/mlx5_win_ext.h +++ b/drivers/common/mlx5/windows/mlx5_win_ext.h @@ -28,6 +28,12 @@ struct mlx5_devx_umem { uint32_t umem_id; }; +struct mlx5_pd { + void *obj; + uint32_t pdn; + devx_device_ctx *devx_ctx; +}; + #define GET_DEVX_CTX(ctx) (((mlx5_context_st *)ctx)->devx_ctx) #define GET_OBJ_CTX(obj) (((mlx5_devx_obj_st *)obj)->devx_ctx) -- 2.16.1.windows.4