@@ -61,6 +61,10 @@ struct mthca_reg_mr {
__u32 reserved;
};
+struct mthca_reg_io_mr {
+ struct ibv_reg_io_mr ibv_cmd;
+};
+
struct mthca_create_cq {
struct ibv_create_cq ibv_cmd;
__u32 lkey;
@@ -113,6 +113,8 @@ static struct ibv_context_ops mthca_ctx_ops = {
.dealloc_pd = mthca_free_pd,
.reg_mr = mthca_reg_mr,
.dereg_mr = mthca_dereg_mr,
+ .reg_io_mr = mthca_reg_io_mr,
+ .dereg_io_mr = mthca_dereg_io_mr,
.create_cq = mthca_create_cq,
.poll_cq = mthca_poll_cq,
.resize_cq = mthca_resize_cq,
@@ -312,6 +312,10 @@ struct ibv_mr *mthca_reg_mr(struct ibv_pd *pd, void *addr,
size_t length, int access);
int mthca_dereg_mr(struct ibv_mr *mr);
+struct ibv_mr *mthca_reg_io_mr(struct ibv_pd *pd, void *addr,
+ size_t length, enum ibv_access_flags access);
+int mthca_dereg_io_mr(struct ibv_mr *mr);
+
struct ibv_cq *mthca_create_cq(struct ibv_context *context, int cqe,
struct ibv_comp_channel *channel,
int comp_vector);
@@ -174,6 +174,56 @@ int mthca_dereg_mr(struct ibv_mr *mr)
return 0;
}
+
+static struct ibv_mr *__mthca_reg_io_mr(struct ibv_pd *pd, void *addr,
+ size_t length, uint64_t hca_va,
+ enum ibv_access_flags access)
+{
+ struct ibv_mr *mr;
+ struct mthca_reg_io_mr cmd;
+ int ret;
+
+ mr = malloc(sizeof *mr);
+ if (!mr)
+ return NULL;
+
+#ifdef IBV_CMD_REG_MR_HAS_RESP_PARAMS
+ {
+ struct ibv_reg_io_mr_resp resp;
+
+ ret = ibv_cmd_reg_io_mr(pd, addr, length, hca_va, access, mr,
+ &cmd.ibv_cmd, sizeof cmd, &resp, sizeof resp);
+ }
+#else
+ ret = ibv_cmd_reg_io_mr(pd, addr, length, hca_va, access, mr,
+ &cmd.ibv_cmd, sizeof cmd);
+#endif
+ if (ret) {
+ free(mr);
+ return NULL;
+ }
+
+ return mr;
+}
+
+struct ibv_mr *mthca_reg_io_mr(struct ibv_pd *pd, void *addr,
+ size_t length, enum ibv_access_flags access)
+{
+ return __mthca_reg_io_mr(pd, addr, length, (uintptr_t) addr, access);
+}
+
+int mthca_dereg_io_mr(struct ibv_mr *mr)
+{
+ int ret;
+
+ ret = ibv_cmd_dereg_mr(mr);
+ if (ret)
+ return ret;
+
+ free(mr);
+ return 0;
+}
+
static int align_cq_size(int cqe)
{
int nent;