From 09a6bd4d46b29cd8379f9f4f03002269a3e87086 Mon Sep 17 00:00:00 2001 From: Shunsuke Mie Date: Fri, 16 Jul 2021 18:41:26 +0900 Subject: [PATCH] Providers/rxe: Add dma-buf support Implement a new provider method for dma-buf base memory registration. Signed-off-by: Shunsuke Mie --- providers/rxe/rxe.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/providers/rxe/rxe.c b/providers/rxe/rxe.c index 3c3ea8bbb..84e00e602 100644 --- a/providers/rxe/rxe.c +++ b/providers/rxe/rxe.c @@ -239,6 +239,26 @@ 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 +1726,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,