diff mbox series

[v1,rdma-core,09/12] mlx4: Implementation of import MR callback

Message ID 20190821142639.5807-10-yuval.shaia@oracle.com (mailing list archive)
State Changes Requested
Headers show
Series Shared PD and MR | expand

Commit Message

Yuval Shaia Aug. 21, 2019, 2:26 p.m. UTC
The import MR verb take care of importing the generic part of the MR
object and then triggers provider's specific callback to take care of
provider's specific attributes.
Add implementation of mlx4 related MR attributes.

Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
Signed-off-by: Shamir Rabinovitch <srabinov7@gmail.com>
---
 providers/mlx4/mlx4.c  |  1 +
 providers/mlx4/mlx4.h  |  2 ++
 providers/mlx4/verbs.c | 26 ++++++++++++++++++++++++++
 3 files changed, 29 insertions(+)
diff mbox series

Patch

diff --git a/providers/mlx4/mlx4.c b/providers/mlx4/mlx4.c
index 62ea5539..40935ca0 100644
--- a/providers/mlx4/mlx4.c
+++ b/providers/mlx4/mlx4.c
@@ -86,6 +86,7 @@  static const struct verbs_context_ops mlx4_ctx_ops = {
 	.query_port    = mlx4_query_port,
 	.alloc_pd      = mlx4_alloc_pd,
 	.dealloc_pd    = mlx4_free_pd,
+	.import_mr     = mlx4_import_mr,
 	.import_pd     = mlx4_import_pd,
 	.reg_mr	       = mlx4_reg_mr,
 	.rereg_mr      = mlx4_rereg_mr,
diff --git a/providers/mlx4/mlx4.h b/providers/mlx4/mlx4.h
index 9f171d09..d919e30c 100644
--- a/providers/mlx4/mlx4.h
+++ b/providers/mlx4/mlx4.h
@@ -316,6 +316,8 @@  int mlx4_query_rt_values(struct ibv_context *context,
 			 struct ibv_values_ex *values);
 struct ibv_pd *mlx4_alloc_pd(struct ibv_context *context);
 int mlx4_free_pd(struct ibv_pd *pd);
+struct ibv_mr *mlx4_import_mr(struct ibv_context *context, uint32_t fd,
+			      uint32_t handle);
 struct ibv_pd *mlx4_import_pd(struct ibv_context *context, uint32_t fd,
 			      uint32_t handle);
 struct ibv_xrcd *mlx4_open_xrcd(struct ibv_context *context,
diff --git a/providers/mlx4/verbs.c b/providers/mlx4/verbs.c
index 87fbf2e1..13b2799c 100644
--- a/providers/mlx4/verbs.c
+++ b/providers/mlx4/verbs.c
@@ -239,6 +239,32 @@  int mlx4_free_pd(struct ibv_pd *pd)
 	return 0;
 }
 
+struct ibv_mr *mlx4_import_mr(struct ibv_context *context, uint32_t fd,
+			      uint32_t handle)
+{
+	struct ibv_import_mr cmd = {
+		.handle = handle,
+		.type = UVERBS_OBJECT_MR,
+		.fd = fd,
+	};
+	struct ib_uverbs_import_fr_fd_resp resp;
+	struct verbs_mr *vmr;
+	int ret;
+
+	vmr = calloc(1, sizeof(*vmr));
+	if (!vmr)
+		return NULL;
+
+	ret = ibv_cmd_import_mr(context, vmr, &cmd, sizeof(cmd), &resp,
+				sizeof(resp));
+	if (ret) {
+		free(vmr);
+		return NULL;
+	}
+
+	return &vmr->ibv_mr;
+}
+
 struct ibv_pd *mlx4_import_pd(struct ibv_context *context, uint32_t fd,
 			      uint32_t handle)
 {