@@ -86,6 +86,7 @@ static const struct verbs_context_ops mlx4_ctx_ops = {
.query_port = mlx4_query_port,
.alloc_pd = mlx4_alloc_pd,
.dealloc_pd = mlx4_free_pd,
+ .import_mr = mlx4_import_mr,
.import_pd = mlx4_import_pd,
.reg_mr = mlx4_reg_mr,
.rereg_mr = mlx4_rereg_mr,
@@ -316,6 +316,8 @@ int mlx4_query_rt_values(struct ibv_context *context,
struct ibv_values_ex *values);
struct ibv_pd *mlx4_alloc_pd(struct ibv_context *context);
int mlx4_free_pd(struct ibv_pd *pd);
+struct ibv_mr *mlx4_import_mr(struct ibv_context *context, uint32_t fd,
+ uint32_t handle);
struct ibv_pd *mlx4_import_pd(struct ibv_context *context, uint32_t fd,
uint32_t handle);
struct ibv_xrcd *mlx4_open_xrcd(struct ibv_context *context,
@@ -239,6 +239,32 @@ int mlx4_free_pd(struct ibv_pd *pd)
return 0;
}
+struct ibv_mr *mlx4_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;
+}
+
struct ibv_pd *mlx4_import_pd(struct ibv_context *context, uint32_t fd,
uint32_t handle)
{