From: Gregory Etelson <[email protected]> Add functions to allocate and free a null Memory Region (MR) using ibverbs on Linux.
There is no implementation for DevX on Windows. Signed-off-by: Gregory Etelson <[email protected]> Signed-off-by: Thomas Monjalon <[email protected]> --- drivers/common/mlx5/linux/mlx5_common_verbs.c | 35 +++++++++++++++++++ drivers/common/mlx5/mlx5_common_mr.h | 9 +++++ drivers/common/mlx5/windows/mlx5_common_os.c | 16 +++++++++ 3 files changed, 60 insertions(+) diff --git a/drivers/common/mlx5/linux/mlx5_common_verbs.c b/drivers/common/mlx5/linux/mlx5_common_verbs.c index 2322d9d033..6d44e1f566 100644 --- a/drivers/common/mlx5/linux/mlx5_common_verbs.c +++ b/drivers/common/mlx5/linux/mlx5_common_verbs.c @@ -161,3 +161,38 @@ mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb, mlx5_dereg_mr_t *dereg_mr_cb) *reg_mr_cb = mlx5_common_verbs_reg_mr; *dereg_mr_cb = mlx5_common_verbs_dereg_mr; } + +RTE_EXPORT_INTERNAL_SYMBOL(mlx5_os_alloc_null_mr) +struct mlx5_pmd_mr * +mlx5_os_alloc_null_mr(struct rte_device *dev, void *pd) +{ + struct ibv_mr *ibv_mr; + struct mlx5_pmd_mr *null_mr; + + null_mr = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*null_mr), 0, dev->numa_node); + if (!null_mr) + return NULL; + ibv_mr = mlx5_glue->alloc_null_mr(pd); + if (!ibv_mr) { + mlx5_free(null_mr); + return NULL; + } + *null_mr = (struct mlx5_pmd_mr) { + .lkey = rte_cpu_to_be_32(ibv_mr->lkey), + .addr = ibv_mr->addr, + .len = ibv_mr->length, + .obj = (void *)ibv_mr, + }; + return null_mr; +} + +RTE_EXPORT_INTERNAL_SYMBOL(mlx5_os_free_null_mr) +void +mlx5_os_free_null_mr(struct mlx5_pmd_mr *null_mr) +{ + if (!null_mr) + return; + if (null_mr->obj) + claim_zero(mlx5_glue->dereg_mr(null_mr->obj)); + mlx5_free(null_mr); +} diff --git a/drivers/common/mlx5/mlx5_common_mr.h b/drivers/common/mlx5/mlx5_common_mr.h index cf7c685e9b..00f3d832c3 100644 --- a/drivers/common/mlx5/mlx5_common_mr.h +++ b/drivers/common/mlx5/mlx5_common_mr.h @@ -21,6 +21,8 @@ #include "mlx5_common_mp.h" #include "mlx5_common_defs.h" +struct rte_device; + /* mlx5 PMD MR struct. */ struct mlx5_pmd_mr { uint32_t lkey; @@ -258,6 +260,13 @@ __rte_internal void mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb, mlx5_dereg_mr_t *dereg_mr_cb); +__rte_internal +struct mlx5_pmd_mr * +mlx5_os_alloc_null_mr(struct rte_device *dev, void *pd); +__rte_internal +void +mlx5_os_free_null_mr(struct mlx5_pmd_mr *null_mr); + __rte_internal int mlx5_mr_mempool_register(struct mlx5_common_device *cdev, diff --git a/drivers/common/mlx5/windows/mlx5_common_os.c b/drivers/common/mlx5/windows/mlx5_common_os.c index 16fcc5f9fc..692517a9bf 100644 --- a/drivers/common/mlx5/windows/mlx5_common_os.c +++ b/drivers/common/mlx5/windows/mlx5_common_os.c @@ -454,6 +454,22 @@ mlx5_os_set_reg_mr_cb(mlx5_reg_mr_t *reg_mr_cb, mlx5_dereg_mr_t *dereg_mr_cb) *dereg_mr_cb = mlx5_os_dereg_mr; } +RTE_EXPORT_INTERNAL_SYMBOL(mlx5_os_alloc_null_mr) +struct mlx5_pmd_mr * +mlx5_os_alloc_null_mr(struct rte_device *dev, void *pd) +{ + RTE_SET_USED(dev); + RTE_SET_USED(pd); + return NULL; +} + +RTE_EXPORT_INTERNAL_SYMBOL(mlx5_os_free_null_mr) +void +mlx5_os_free_null_mr(struct mlx5_pmd_mr *null_mr) +{ + RTE_SET_USED(null_mr); +} + /* * In Windows, no need to wrap the MR, no known issue for it in kernel. * Use the regular function to create direct MR. -- 2.54.0

