Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

providers/mana: Add dma-buf support #1557

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions providers/mana/mana.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,29 @@ int mana_dealloc_pd(struct ibv_pd *ibpd)
return 0;
}

struct ibv_mr *mana_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 = calloc(1, sizeof(*vmr));
if (!vmr)
return NULL;

ret = ibv_cmd_reg_dmabuf_mr(pd, offset, length, iova, fd, access, vmr, NULL);
if (ret) {
verbs_err(verbs_get_ctx(pd->context),
"Failed to register dma-buf MR\n");
errno = ret;
free(vmr);
return NULL;
}

return &vmr->ibv_mr;
}

struct ibv_mr *mana_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
uint64_t hca_va, int access)
{
Expand Down Expand Up @@ -236,6 +259,7 @@ static const struct verbs_context_ops mana_ctx_ops = {
.post_send = mana_post_send,
.query_device_ex = mana_query_device_ex,
.query_port = mana_query_port,
.reg_dmabuf_mr = mana_reg_dmabuf_mr,
.reg_mr = mana_reg_mr,
.req_notify_cq = mana_arm_cq,
};
Expand Down
4 changes: 4 additions & 0 deletions providers/mana/mana.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ mana_alloc_parent_domain(struct ibv_context *context,

int mana_dealloc_pd(struct ibv_pd *pd);

struct ibv_mr *mana_reg_dmabuf_mr(struct ibv_pd *pd, uint64_t offset,
size_t length, uint64_t iova, int fd,
int access);

struct ibv_mr *mana_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
uint64_t hca_va, int access);

Expand Down