[dpdk-dev] [PATCH 1/5] common/mlx5: glue MR registration with IOVA
From: Matan Azrad <hidden>
Date: 2021-11-07 15:30:32
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Michael Baum <redacted>
Add support for rdma-core API to register IOVA MR.
The API gets the process VA, size, and IOVA and returns a memory region
with space pointed by a specific IOVA.
So any access in this MR should come with an address that is relative to
the IOVA specified in the API.
Fixes: cc07a42da250 ("vdpa/mlx5: prepare memory regions")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <redacted>
Signed-off-by: Matan Azrad <redacted>
---
drivers/common/mlx5/linux/meson.build | 2 ++
drivers/common/mlx5/linux/mlx5_glue.c | 18 ++++++++++++++++++
drivers/common/mlx5/linux/mlx5_glue.h | 3 +++
3 files changed, 23 insertions(+)
diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index 2dcd27b778..7909f23e21 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build@@ -200,6 +200,8 @@ has_sym_args = [ 'MLX5DV_DR_ACTION_FLAGS_ASO_CT_DIRECTION_INITIATOR' ], [ 'HAVE_MLX5_DR_ALLOW_DUPLICATE', 'infiniband/mlx5dv.h', 'mlx5dv_dr_domain_allow_duplicate_rules' ], + [ 'HAVE_MLX5_IBV_REG_MR_IOVA', 'infiniband/verbs.h', + 'ibv_reg_mr_iova' ], ] config = configuration_data() foreach arg:has_sym_args
diff --git a/drivers/common/mlx5/linux/mlx5_glue.c b/drivers/common/mlx5/linux/mlx5_glue.c
index 037ca961a0..bc6622053f 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.c
+++ b/drivers/common/mlx5/linux/mlx5_glue.c@@ -224,6 +224,23 @@ mlx5_glue_reg_mr(struct ibv_pd *pd, void *addr, size_t length, int access) return ibv_reg_mr(pd, addr, length, access); } +static struct ibv_mr * +mlx5_glue_reg_mr_iova(struct ibv_pd *pd, void *addr, size_t length, + uint64_t iova, int access) +{ +#ifdef HAVE_MLX5_IBV_REG_MR_IOVA + return ibv_reg_mr_iova(pd, addr, length, iova, access); +#else + (void)pd; + (void)addr; + (void)length; + (void)iova; + (void)access; + errno = ENOTSUP; + return NULL; +#endif +} + static struct ibv_mr * mlx5_glue_alloc_null_mr(struct ibv_pd *pd) {
@@ -1412,6 +1429,7 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) { .destroy_qp = mlx5_glue_destroy_qp, .modify_qp = mlx5_glue_modify_qp, .reg_mr = mlx5_glue_reg_mr, + .reg_mr_iova = mlx5_glue_reg_mr_iova, .alloc_null_mr = mlx5_glue_alloc_null_mr, .dereg_mr = mlx5_glue_dereg_mr, .create_counter_set = mlx5_glue_create_counter_set,
diff --git a/drivers/common/mlx5/linux/mlx5_glue.h b/drivers/common/mlx5/linux/mlx5_glue.h
index f39ef2dac7..4e6d31f263 100644
--- a/drivers/common/mlx5/linux/mlx5_glue.h
+++ b/drivers/common/mlx5/linux/mlx5_glue.h@@ -197,6 +197,9 @@ struct mlx5_glue { int attr_mask); struct ibv_mr *(*reg_mr)(struct ibv_pd *pd, void *addr, size_t length, int access); + struct ibv_mr *(*reg_mr_iova)(struct ibv_pd *pd, void *addr, + size_t length, uint64_t iova, + int access); struct ibv_mr *(*alloc_null_mr)(struct ibv_pd *pd); int (*dereg_mr)(struct ibv_mr *mr); struct ibv_counter_set *(*create_counter_set)
--
2.25.1