@@ -112,6 +112,32 @@ static struct ibv_pd *rxe_alloc_pd(struct ibv_context *context)
return pd;
}
+static struct ibv_mr *rxe_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;
+}
+
static struct ibv_pd *rxe_import_pd(struct ibv_context *context, uint32_t fd,
uint32_t handle)
{
@@ -862,6 +888,7 @@ static const struct verbs_context_ops rxe_ctx_ops = {
.query_port = rxe_query_port,
.alloc_pd = rxe_alloc_pd,
.dealloc_pd = rxe_dealloc_pd,
+ .import_mr = rxe_import_mr,
.import_pd = rxe_import_pd,
.reg_mr = rxe_reg_mr,
.dereg_mr = rxe_dereg_mr,