[PATCH rdma-core 02/11] libbnxtre: Add support for user memory regions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds code to allow user applications to register and
unregister memory buffers with the HCA. Following functions are
now supported:
 - ibv_reg_mr()
 - ibv_dereg_mr()

Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@xxxxxxxxxxxx>
Signed-off-by: Somnath Kotur <somnath.kotur@xxxxxxxxxxxx>
Signed-off-by: Selvin Xavier <selvin.xavier@xxxxxxxxxxxx>
Signed-off-by: Devesh Sharma <devesh.sharma@xxxxxxxxxxxx>
---
 providers/bnxtre/abi.h   |  4 ++++
 providers/bnxtre/verbs.c | 26 ++++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/providers/bnxtre/abi.h b/providers/bnxtre/abi.h
index 653ac71..0568d67 100644
--- a/providers/bnxtre/abi.h
+++ b/providers/bnxtre/abi.h
@@ -56,4 +56,8 @@ struct bnxt_re_pd_resp {
 	__u64 dbr;
 };
 
+struct bnxt_re_mr_resp {
+	struct ibv_reg_mr_resp resp;
+};
+
 #endif
diff --git a/providers/bnxtre/verbs.c b/providers/bnxtre/verbs.c
index ab1a453..9813db8 100644
--- a/providers/bnxtre/verbs.c
+++ b/providers/bnxtre/verbs.c
@@ -134,12 +134,34 @@ int bnxt_re_free_pd(struct ibv_pd *ibvpd)
 struct ibv_mr *bnxt_re_reg_mr(struct ibv_pd *ibvpd, void *sva, size_t len,
 			      int access)
 {
-	return NULL;
+	struct bnxt_re_mr *mr;
+	struct ibv_reg_mr cmd;
+	struct bnxt_re_mr_resp resp;
+
+	mr = calloc(1, sizeof(*mr));
+	if (!mr)
+		return NULL;
+
+	if (ibv_cmd_reg_mr(ibvpd, sva, len, (uint64_t)sva, access, &mr->ibvmr,
+			   &cmd, sizeof(cmd), &resp.resp, sizeof(resp))) {
+		free(mr);
+		return NULL;
+	}
+
+	return &mr->ibvmr;
 }
 
 int bnxt_re_dereg_mr(struct ibv_mr *ibvmr)
 {
-	return -ENOSYS;
+	struct bnxt_re_mr *mr = (struct bnxt_re_mr *)ibvmr;
+	int status;
+
+	status = ibv_cmd_dereg_mr(ibvmr);
+	if (status)
+		return status;
+	free(mr);
+
+	return 0;
 }
 
 struct ibv_cq *bnxt_re_create_cq(struct ibv_context *ibvctx, int ncqe,
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux