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 <talshn@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
This commit is contained in:
Tal Shnaiderman 2020-12-28 11:54:30 +02:00 committed by Ferruh Yigit
parent 1552fb2871
commit 1969ee4244
3 changed files with 64 additions and 0 deletions

View File

@ -64,3 +64,5 @@ EXPORTS
mlx5_os_alloc_pd
mlx5_os_dealloc_pd
mlx5_os_umem_reg
mlx5_os_umem_dereg

View File

@ -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;
}

View File

@ -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_ */