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 DE19FA04B5; Sun, 13 Dec 2020 11:30:16 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AFE72CAA7; Sun, 13 Dec 2020 11:22:27 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id EE90DC9B8 for ; Sun, 13 Dec 2020 11:21:48 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from talshn@nvidia.com) with SMTP; 13 Dec 2020 12:21:43 +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 0BDALe1q018562; Sun, 13 Dec 2020 12:21:43 +0200 From: Tal Shnaiderman To: dev@dpdk.org Cc: thomas@monjalon.net, matan@nvidia.com, rasland@nvidia.com, ophirmu@nvidia.com Date: Sun, 13 Dec 2020 12:20:50 +0200 Message-Id: <20201213102056.11380-27-talshn@nvidia.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20201213102056.11380-1-talshn@nvidia.com> References: <20201210150648.8784-2-talshn@nvidia.com> <20201213102056.11380-1-talshn@nvidia.com> Subject: [dpdk-dev] [PATCH v3 26/32] common/mlx5/windows: add OS umem reg/dereg API 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_umem_reg() and mlx5_os_umem_dereg(). They are equivalent to the Linux implementation. Signed-off-by: Tal Shnaiderman --- drivers/common/mlx5/rte_common_mlx5_exports.def | 2 + drivers/common/mlx5/windows/mlx5_common_os.c | 60 +++++++++++++++++++++++++ drivers/common/mlx5/windows/mlx5_common_os.h | 2 + 3 files changed, 64 insertions(+) diff --git a/drivers/common/mlx5/rte_common_mlx5_exports.def b/drivers/common/mlx5/rte_common_mlx5_exports.def index 5db1eaa48c..1eabe29a58 100644 --- a/drivers/common/mlx5/rte_common_mlx5_exports.def +++ b/drivers/common/mlx5/rte_common_mlx5_exports.def @@ -63,3 +63,5 @@ EXPORTS mlx5_free mlx5_os_alloc_pd mlx5_os_dealloc_pd + mlx5_os_umem_reg + mlx5_os_umem_dereg diff --git a/drivers/common/mlx5/windows/mlx5_common_os.c b/drivers/common/mlx5/windows/mlx5_common_os.c index 85537b6739..cbb09906bd 100644 --- a/drivers/common/mlx5/windows/mlx5_common_os.c +++ b/drivers/common/mlx5/windows/mlx5_common_os.c @@ -70,3 +70,63 @@ mlx5_os_dealloc_pd(void *pd) mlx5_free(pd); return 0; } + +/** + * Register umem. + * + * @param[in] ctx + * Pointer to context. + * @param[in] addr + * Pointer to memory start address. + * @param[in] size + * Size of the memory to register. + * @param[out] access + * UMEM access type + * + * @return + * umem on successful registration, NULL and errno otherwise + */ +void * +mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access) +{ + struct mlx5_devx_umem *umem; + + umem = mlx5_malloc(MLX5_MEM_ZERO, + (sizeof(*umem)), 0, SOCKET_ID_ANY); + if (!umem) { + errno = ENOMEM; + return NULL; + } + umem->umem_hdl = mlx5_glue->devx_umem_reg(ctx, addr, size, access, + &umem->umem_id); + if (!umem->umem_hdl) { + mlx5_free(umem); + return NULL; + } + umem->addr = addr; + return umem; +} + +/** + * Deregister umem. + * + * @param[in] pumem + * Pointer to umem. + * + * @return + * 0 on successful release, negative number otherwise + */ +int +mlx5_os_umem_dereg(void *pumem) +{ + struct mlx5_devx_umem *umem; + int err = 0; + + if (!pumem) + return err; + umem = pumem; + if (umem->umem_hdl) + err = mlx5_glue->devx_umem_dereg(umem->umem_hdl); + mlx5_free(umem); + return err; +} diff --git a/drivers/common/mlx5/windows/mlx5_common_os.h b/drivers/common/mlx5/windows/mlx5_common_os.h index f47351ec41..decb5acd45 100644 --- a/drivers/common/mlx5/windows/mlx5_common_os.h +++ b/drivers/common/mlx5/windows/mlx5_common_os.h @@ -142,4 +142,6 @@ mlx5_os_get_umem_id(void *umem) void *mlx5_os_alloc_pd(void *ctx); int mlx5_os_dealloc_pd(void *pd); +void *mlx5_os_umem_reg(void *ctx, void *addr, size_t size, uint32_t access); +int mlx5_os_umem_dereg(void *pumem); #endif /* RTE_PMD_MLX5_COMMON_OS_H_ */ -- 2.16.1.windows.4