linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] Providers/rxe: Add dma-buf support
@ 2021-09-08  6:20 Shunsuke Mie
  0 siblings, 0 replies; only message in thread
From: Shunsuke Mie @ 2021-09-08  6:20 UTC (permalink / raw)
  To: Zhu Yanjun
  Cc: Christian König, Alex Deucher, Daniel Vetter, Doug Ledford,
	Jason Gunthorpe, Jianxin Xiong, Leon Romanovsky, linux-kernel,
	linux-rdma, Shunsuke Mie, dhobsong, taki, etom

This is the user space counter-part of the kernel patch set to add
dma-buf support to the RXE driver.

Implement a new provider method for dma-buf base memory registration.

Pull request at GitHub: https://github.com/linux-rdma/rdma-core/pull/1055

Signed-off-by: Shunsuke Mie <mie@igel.co.jp>
---
 providers/rxe/rxe.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/providers/rxe/rxe.c b/providers/rxe/rxe.c
index 3c3ea8bb..0e6b1ecd 100644
--- a/providers/rxe/rxe.c
+++ b/providers/rxe/rxe.c
@@ -239,6 +239,25 @@ static struct ibv_mr *rxe_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
 	return &vmr->ibv_mr;
 }
 
+static struct ibv_mr* rxe_reg_dmabuf_mr(struct ibv_pd *pd, uint64_t offset, size_t length,
+        uint64_t iova, int fd, int access)
+{
+	struct verbs_mr *vmr;
+    int ret;
+
+    vmr = malloc(sizeof (*vmr));
+    if (!vmr)
+        return NULL;
+
+    ret = ibv_cmd_reg_dmabuf_mr(pd, offset, length, iova, fd, access, vmr);
+    if (ret) {
+        free(vmr);
+        return NULL;
+    }
+
+    return &vmr->ibv_mr;
+}
+
 static int rxe_dereg_mr(struct verbs_mr *vmr)
 {
 	int ret;
@@ -1706,6 +1725,7 @@ static const struct verbs_context_ops rxe_ctx_ops = {
 	.alloc_pd = rxe_alloc_pd,
 	.dealloc_pd = rxe_dealloc_pd,
 	.reg_mr = rxe_reg_mr,
+	.reg_dmabuf_mr = rxe_reg_dmabuf_mr,
 	.dereg_mr = rxe_dereg_mr,
 	.alloc_mw = rxe_alloc_mw,
 	.dealloc_mw = rxe_dealloc_mw,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-08  6:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-08  6:20 [RFC PATCH] Providers/rxe: Add dma-buf support Shunsuke Mie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).