From: Tal Shnaiderman Date: Mon, 28 Dec 2020 09:54:30 +0000 (+0200) Subject: common/mlx5: add UMEM reg/dereg functions on Windows X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=1969ee424405;p=dpdk.git common/mlx5: add UMEM reg/dereg functions on Windows Implement Windows API mlx5_os_umem_reg() and mlx5_os_umem_dereg(). They are equivalent to the Linux implementation. Signed-off-by: Tal Shnaiderman Acked-by: Matan Azrad --- diff --git a/drivers/common/mlx5/rte_common_mlx5_exports.def b/drivers/common/mlx5/rte_common_mlx5_exports.def index 93203ea034..648d03ac60 100644 --- a/drivers/common/mlx5/rte_common_mlx5_exports.def +++ b/drivers/common/mlx5/rte_common_mlx5_exports.def @@ -64,3 +64,5 @@ EXPORTS 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 9ca850e26b..50617e4bc4 100644 --- a/drivers/common/mlx5/windows/mlx5_common_os.c +++ b/drivers/common/mlx5/windows/mlx5_common_os.c @@ -69,3 +69,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_ */