@@ -390,7 +390,7 @@ int ibv_cmd_close_xrcd(struct verbs_xrcd *xrcd)
int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
uint64_t hca_va, int access,
- struct ibv_mr *mr, struct ibv_reg_mr *cmd,
+ struct verbs_mr *vmr, struct ibv_reg_mr *cmd,
size_t cmd_size,
struct ib_uverbs_reg_mr_resp *resp, size_t resp_size)
{
@@ -408,15 +408,16 @@ int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
(void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size);
- mr->handle = resp->mr_handle;
- mr->lkey = resp->lkey;
- mr->rkey = resp->rkey;
- mr->context = pd->context;
+ vmr->ibv_mr.handle = resp->mr_handle;
+ vmr->ibv_mr.lkey = resp->lkey;
+ vmr->ibv_mr.rkey = resp->rkey;
+ vmr->ibv_mr.context = pd->context;
+ vmr->mr_type = IBV_MR_TYPE_MR;
return 0;
}
-int ibv_cmd_rereg_mr(struct ibv_mr *mr, uint32_t flags, void *addr,
+int ibv_cmd_rereg_mr(struct verbs_mr *vmr, uint32_t flags, void *addr,
size_t length, uint64_t hca_va, int access,
struct ibv_pd *pd, struct ibv_rereg_mr *cmd,
size_t cmd_sz, struct ib_uverbs_rereg_mr_resp *resp,
@@ -424,7 +425,7 @@ int ibv_cmd_rereg_mr(struct ibv_mr *mr, uint32_t flags, void *addr,
{
IBV_INIT_CMD_RESP(cmd, cmd_sz, REREG_MR, resp, resp_sz);
- cmd->mr_handle = mr->handle;
+ cmd->mr_handle = vmr->ibv_mr.handle;
cmd->flags = flags;
cmd->start = (uintptr_t)addr;
cmd->length = length;
@@ -432,27 +433,28 @@ int ibv_cmd_rereg_mr(struct ibv_mr *mr, uint32_t flags, void *addr,
cmd->pd_handle = (flags & IBV_REREG_MR_CHANGE_PD) ? pd->handle : 0;
cmd->access_flags = access;
- if (write(mr->context->cmd_fd, cmd, cmd_sz) != cmd_sz)
+ if (write(vmr->ibv_mr.context->cmd_fd, cmd, cmd_sz) != cmd_sz)
return errno;
(void)VALGRIND_MAKE_MEM_DEFINED(resp, resp_sz);
- mr->lkey = resp->lkey;
- mr->rkey = resp->rkey;
+ vmr->ibv_mr.lkey = resp->lkey;
+ vmr->ibv_mr.rkey = resp->rkey;
if (flags & IBV_REREG_MR_CHANGE_PD)
- mr->context = pd->context;
+ vmr->ibv_mr.context = pd->context;
return 0;
}
-int ibv_cmd_dereg_mr(struct ibv_mr *mr)
+int ibv_cmd_dereg_mr(struct verbs_mr *vmr)
{
struct ibv_dereg_mr cmd;
IBV_INIT_CMD(&cmd, sizeof cmd, DEREG_MR);
- cmd.mr_handle = mr->handle;
+ cmd.mr_handle = vmr->ibv_mr.handle;
- if (write(mr->context->cmd_fd, &cmd, sizeof cmd) != sizeof cmd)
+ if (write(vmr->ibv_mr.context->cmd_fd, &cmd, sizeof(cmd)) !=
+ sizeof(cmd))
return errno;
return 0;
@@ -70,7 +70,7 @@ int ibv_cmd_free_dm(struct verbs_dm *dm)
int ibv_cmd_reg_dm_mr(struct ibv_pd *pd, struct verbs_dm *dm,
uint64_t offset, size_t length,
- unsigned int access, struct ibv_mr *mr,
+ unsigned int access, struct verbs_mr *vmr,
struct ibv_command_buffer *link)
{
DECLARE_COMMAND_BUFFER_LINK(cmdb, UVERBS_OBJECT_MR, UVERBS_METHOD_DM_MR_REG,
@@ -102,13 +102,15 @@ int ibv_cmd_reg_dm_mr(struct ibv_pd *pd, struct verbs_dm *dm,
if (ret)
return errno;
- mr->handle = read_attr_obj(UVERBS_ATTR_REG_DM_MR_HANDLE, handle);
- mr->context = pd->context;
- mr->lkey = lkey;
- mr->rkey = rkey;
- mr->length = length;
- mr->pd = pd;
- mr->addr = NULL;
+ vmr->ibv_mr.handle =
+ read_attr_obj(UVERBS_ATTR_REG_DM_MR_HANDLE, handle);
+ vmr->ibv_mr.context = pd->context;
+ vmr->ibv_mr.lkey = lkey;
+ vmr->ibv_mr.rkey = rkey;
+ vmr->ibv_mr.length = length;
+ vmr->ibv_mr.pd = pd;
+ vmr->ibv_mr.addr = NULL;
+ vmr->mr_type = IBV_MR_TYPE_MR;
return 0;
}
@@ -85,6 +85,20 @@ enum ibv_gid_type {
IBV_GID_TYPE_ROCE_V2,
};
+enum ibv_mr_type {
+ IBV_MR_TYPE_MR,
+};
+
+struct verbs_mr {
+ struct ibv_mr ibv_mr;
+ enum ibv_mr_type mr_type;
+};
+
+static inline struct verbs_mr *verbs_get_mr(struct ibv_mr *mr)
+{
+ return container_of(mr, struct verbs_mr, ibv_mr);
+}
+
struct verbs_qp {
struct ibv_qp qp;
uint32_t comp_mask;
@@ -252,7 +266,7 @@ struct verbs_context_ops {
int (*dealloc_mw)(struct ibv_mw *mw);
int (*dealloc_pd)(struct ibv_pd *pd);
int (*dealloc_td)(struct ibv_td *td);
- int (*dereg_mr)(struct ibv_mr *mr);
+ int (*dereg_mr)(struct verbs_mr *vmr);
int (*destroy_ah)(struct ibv_ah *ah);
int (*destroy_counters)(struct ibv_counters *counters);
int (*destroy_cq)(struct ibv_cq *cq);
@@ -313,7 +327,7 @@ struct verbs_context_ops {
struct ibv_mr *(*reg_mr)(struct ibv_pd *pd, void *addr, size_t length,
int access);
int (*req_notify_cq)(struct ibv_cq *cq, int solicited_only);
- int (*rereg_mr)(struct ibv_mr *mr, int flags, struct ibv_pd *pd,
+ int (*rereg_mr)(struct verbs_mr *vmr, int flags, struct ibv_pd *pd,
void *addr, size_t length, int access);
int (*resize_cq)(struct ibv_cq *cq, int cqe);
};
@@ -406,15 +420,15 @@ int ibv_cmd_open_xrcd(struct ibv_context *context, struct verbs_xrcd *xrcd,
int ibv_cmd_close_xrcd(struct verbs_xrcd *xrcd);
int ibv_cmd_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
uint64_t hca_va, int access,
- struct ibv_mr *mr, struct ibv_reg_mr *cmd,
+ struct verbs_mr *vmr, struct ibv_reg_mr *cmd,
size_t cmd_size,
struct ib_uverbs_reg_mr_resp *resp, size_t resp_size);
-int ibv_cmd_rereg_mr(struct ibv_mr *mr, uint32_t flags, void *addr,
+int ibv_cmd_rereg_mr(struct verbs_mr *vmr, uint32_t flags, void *addr,
size_t length, uint64_t hca_va, int access,
struct ibv_pd *pd, struct ibv_rereg_mr *cmd,
size_t cmd_sz, struct ib_uverbs_rereg_mr_resp *resp,
size_t resp_sz);
-int ibv_cmd_dereg_mr(struct ibv_mr *mr);
+int ibv_cmd_dereg_mr(struct verbs_mr *vmr);
int ibv_cmd_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type,
struct ibv_mw *mw, struct ibv_alloc_mw *cmd,
size_t cmd_size,
@@ -562,7 +576,7 @@ int ibv_cmd_alloc_dm(struct ibv_context *ctx,
int ibv_cmd_free_dm(struct verbs_dm *dm);
int ibv_cmd_reg_dm_mr(struct ibv_pd *pd, struct verbs_dm *dm,
uint64_t offset, size_t length,
- unsigned int access, struct ibv_mr *mr,
+ unsigned int access, struct verbs_mr *vmr,
struct ibv_command_buffer *link);
/*
@@ -200,7 +200,7 @@ static int dealloc_td(struct ibv_td *td)
return ENOSYS;
}
-static int dereg_mr(struct ibv_mr *mr)
+static int dereg_mr(struct verbs_mr *vmr)
{
return ENOSYS;
}
@@ -406,8 +406,8 @@ static int req_notify_cq(struct ibv_cq *cq, int solicited_only)
return ENOSYS;
}
-static int rereg_mr(struct ibv_mr *mr, int flags, struct ibv_pd *pd, void *addr,
- size_t length, int access)
+static int rereg_mr(struct verbs_mr *vmr, int flags, struct ibv_pd *pd,
+ void *addr, size_t length, int access)
{
errno = ENOSYS;
return IBV_REREG_MR_ERR_INPUT;
@@ -278,8 +278,9 @@ LATEST_SYMVER_FUNC(ibv_rereg_mr, 1_1, "IBVERBS_1.1",
old_addr = mr->addr;
old_len = mr->length;
- err = get_ops(mr->context)
- ->rereg_mr(mr, flags, pd, addr, length, access);
+ err = get_ops(mr->context)->rereg_mr(verbs_get_mr(mr),
+ flags, pd, addr,
+ length, access);
if (!err) {
if (flags & IBV_REREG_MR_CHANGE_PD)
mr->pd = pd;
@@ -309,7 +310,7 @@ LATEST_SYMVER_FUNC(ibv_dereg_mr, 1_1, "IBVERBS_1.1",
void *addr = mr->addr;
size_t length = mr->length;
- ret = get_ops(mr->context)->dereg_mr(mr);
+ ret = get_ops(mr->context)->dereg_mr(verbs_get_mr(mr));
if (!ret)
ibv_dofork_range(addr, length);
@@ -126,7 +126,7 @@ struct bnxt_re_qp {
};
struct bnxt_re_mr {
- struct ibv_mr ibvmr;
+ struct verbs_mr vmr;
};
struct bnxt_re_ah {
@@ -145,21 +145,21 @@ struct ibv_mr *bnxt_re_reg_mr(struct ibv_pd *ibvpd, void *sva, size_t len,
if (!mr)
return NULL;
- if (ibv_cmd_reg_mr(ibvpd, sva, len, (uintptr_t)sva, access, &mr->ibvmr,
+ if (ibv_cmd_reg_mr(ibvpd, sva, len, (uintptr_t)sva, access, &mr->vmr,
&cmd, sizeof(cmd), &resp.ibv_resp, sizeof(resp))) {
free(mr);
return NULL;
}
- return &mr->ibvmr;
+ return &mr->vmr.ibv_mr;
}
-int bnxt_re_dereg_mr(struct ibv_mr *ibvmr)
+int bnxt_re_dereg_mr(struct verbs_mr *vmr)
{
- struct bnxt_re_mr *mr = (struct bnxt_re_mr *)ibvmr;
+ struct bnxt_re_mr *mr = (struct bnxt_re_mr *)vmr;
int status;
- status = ibv_cmd_dereg_mr(ibvmr);
+ status = ibv_cmd_dereg_mr(vmr);
if (status)
return status;
free(mr);
@@ -63,7 +63,7 @@ struct ibv_pd *bnxt_re_alloc_pd(struct ibv_context *uctx);
int bnxt_re_free_pd(struct ibv_pd *ibvpd);
struct ibv_mr *bnxt_re_reg_mr(struct ibv_pd *ibvpd, void *buf, size_t len,
int ibv_access_flags);
-int bnxt_re_dereg_mr(struct ibv_mr *ibvmr);
+int bnxt_re_dereg_mr(struct verbs_mr *vmr);
struct ibv_cq *bnxt_re_create_cq(struct ibv_context *uctx, int ncqe,
struct ibv_comp_channel *ch, int vec);
@@ -79,7 +79,7 @@ struct iwch_pd {
};
struct iwch_mr {
- struct ibv_mr ibv_mr;
+ struct verbs_mr vmr;
uint64_t va_fbo;
uint32_t page_size;
uint32_t pbl_addr;
@@ -129,9 +129,9 @@ static inline struct iwch_qp *to_iwch_qp(struct ibv_qp *ibqp)
return to_iwch_xxx(qp, qp);
}
-static inline struct iwch_mr *to_iwch_mr(struct ibv_mr *ibmr)
+static inline struct iwch_mr *to_iwch_mr(struct verbs_mr *vmr)
{
- return to_iwch_xxx(mr, mr);
+ return container_of(vmr, struct iwch_mr, vmr);
}
static inline unsigned long long_log2(unsigned long x)
@@ -152,7 +152,7 @@ extern int iwch_free_pd(struct ibv_pd *pd);
extern struct ibv_mr *iwch_reg_mr(struct ibv_pd *pd, void *addr,
size_t length, int access);
-extern int iwch_dereg_mr(struct ibv_mr *mr);
+extern int iwch_dereg_mr(struct verbs_mr *mr);
struct ibv_cq *iwch_create_cq(struct ibv_context *context, int cqe,
struct ibv_comp_channel *channel,
@@ -117,7 +117,7 @@ static struct ibv_mr *__iwch_reg_mr(struct ibv_pd *pd, void *addr,
return NULL;
if (ibv_cmd_reg_mr(pd, addr, length, hca_va,
- access, &mhp->ibv_mr, &cmd, sizeof cmd,
+ access, &mhp->vmr, &cmd, sizeof(cmd),
&resp.ibv_resp, sizeof resp)) {
free(mhp);
return NULL;
@@ -128,16 +128,16 @@ static struct ibv_mr *__iwch_reg_mr(struct ibv_pd *pd, void *addr,
mhp->pbl_addr = resp.pbl_addr;
mhp->len = length;
- PDBG("%s stag 0x%x va_fbo 0x%" PRIx64
+ PDBG("%s stag 0x%x va_fbo 0x%" PRIx64
" page_size %d pbl_addr 0x%x len %d\n",
- __FUNCTION__, mhp->ibv_mr.rkey, mhp->va_fbo,
+ __func__, mhp->vmr.ibv_mr.rkey, mhp->va_fbo,
mhp->page_size, mhp->pbl_addr, mhp->len);
pthread_spin_lock(&dev->lock);
- dev->mmid2ptr[t3_mmid(mhp->ibv_mr.lkey)] = mhp;
+ dev->mmid2ptr[t3_mmid(mhp->vmr.ibv_mr.lkey)] = mhp;
pthread_spin_unlock(&dev->lock);
- return &mhp->ibv_mr;
+ return &mhp->vmr.ibv_mr;
}
struct ibv_mr *iwch_reg_mr(struct ibv_pd *pd, void *addr,
@@ -147,20 +147,20 @@ struct ibv_mr *iwch_reg_mr(struct ibv_pd *pd, void *addr,
return __iwch_reg_mr(pd, addr, length, (uintptr_t) addr, access);
}
-int iwch_dereg_mr(struct ibv_mr *mr)
+int iwch_dereg_mr(struct verbs_mr *vmr)
{
int ret;
- struct iwch_device *dev = to_iwch_dev(mr->pd->context->device);
+ struct iwch_device *dev = to_iwch_dev(vmr->ibv_mr.pd->context->device);
- ret = ibv_cmd_dereg_mr(mr);
+ ret = ibv_cmd_dereg_mr(vmr);
if (ret)
return ret;
pthread_spin_lock(&dev->lock);
- dev->mmid2ptr[t3_mmid(mr->lkey)] = NULL;
+ dev->mmid2ptr[t3_mmid(vmr->ibv_mr.lkey)] = NULL;
pthread_spin_unlock(&dev->lock);
- free(to_iwch_mr(mr));
+ free(to_iwch_mr(vmr));
return 0;
}
@@ -90,7 +90,7 @@ struct c4iw_pd {
};
struct c4iw_mr {
- struct ibv_mr ibv_mr;
+ struct verbs_mr vmr;
uint64_t va_fbo;
uint32_t len;
};
@@ -147,9 +147,9 @@ static inline struct c4iw_qp *to_c4iw_qp(struct ibv_qp *ibqp)
return to_c4iw_xxx(qp, qp);
}
-static inline struct c4iw_mr *to_c4iw_mr(struct ibv_mr *ibmr)
+static inline struct c4iw_mr *to_c4iw_mr(struct verbs_mr *vmr)
{
- return to_c4iw_xxx(mr, mr);
+ return container_of(vmr, struct c4iw_mr, vmr);
}
static inline struct c4iw_qp *get_qhp(struct c4iw_dev *rhp, u32 qid)
@@ -180,7 +180,7 @@ int c4iw_free_pd(struct ibv_pd *pd);
struct ibv_mr *c4iw_reg_mr(struct ibv_pd *pd, void *addr,
size_t length, int access);
-int c4iw_dereg_mr(struct ibv_mr *mr);
+int c4iw_dereg_mr(struct verbs_mr *vmr);
struct ibv_cq *c4iw_create_cq(struct ibv_context *context, int cqe,
struct ibv_comp_channel *channel,
@@ -121,7 +121,7 @@ static struct ibv_mr *__c4iw_reg_mr(struct ibv_pd *pd, void *addr,
return NULL;
if (ibv_cmd_reg_mr(pd, addr, length, hca_va,
- access, &mhp->ibv_mr, &cmd, sizeof cmd,
+ access, &mhp->vmr, &cmd, sizeof(cmd),
&resp, sizeof resp)) {
free(mhp);
return NULL;
@@ -131,13 +131,13 @@ static struct ibv_mr *__c4iw_reg_mr(struct ibv_pd *pd, void *addr,
mhp->len = length;
PDBG("%s stag 0x%x va_fbo 0x%" PRIx64 " len %d\n",
- __func__, mhp->ibv_mr.rkey, mhp->va_fbo, mhp->len);
+ __func__, mhp->vmr.ibv_mr.rkey, mhp->va_fbo, mhp->len);
pthread_spin_lock(&dev->lock);
- dev->mmid2ptr[c4iw_mmid(mhp->ibv_mr.lkey)] = mhp;
+ dev->mmid2ptr[c4iw_mmid(mhp->vmr.ibv_mr.lkey)] = mhp;
pthread_spin_unlock(&dev->lock);
INC_STAT(mr);
- return &mhp->ibv_mr;
+ return &mhp->vmr.ibv_mr;
}
struct ibv_mr *c4iw_reg_mr(struct ibv_pd *pd, void *addr,
@@ -147,20 +147,20 @@ struct ibv_mr *c4iw_reg_mr(struct ibv_pd *pd, void *addr,
return __c4iw_reg_mr(pd, addr, length, (uintptr_t) addr, access);
}
-int c4iw_dereg_mr(struct ibv_mr *mr)
+int c4iw_dereg_mr(struct verbs_mr *vmr)
{
int ret;
- struct c4iw_dev *dev = to_c4iw_dev(mr->pd->context->device);
+ struct c4iw_dev *dev = to_c4iw_dev(vmr->ibv_mr.pd->context->device);
- ret = ibv_cmd_dereg_mr(mr);
+ ret = ibv_cmd_dereg_mr(vmr);
if (ret)
return ret;
pthread_spin_lock(&dev->lock);
- dev->mmid2ptr[c4iw_mmid(mr->lkey)] = NULL;
+ dev->mmid2ptr[c4iw_mmid(vmr->ibv_mr.lkey)] = NULL;
pthread_spin_unlock(&dev->lock);
- free(to_c4iw_mr(mr));
+ free(to_c4iw_mr(vmr));
return 0;
}
@@ -207,7 +207,7 @@ int hfi1_free_pd(struct ibv_pd *pd);
struct ibv_mr *hfi1_reg_mr(struct ibv_pd *pd, void *addr,
size_t length, int access);
-int hfi1_dereg_mr(struct ibv_mr *mr);
+int hfi1_dereg_mr(struct verbs_mr *vmr);
struct ibv_cq *hfi1_create_cq(struct ibv_context *context, int cqe,
struct ibv_comp_channel *channel,
@@ -132,35 +132,35 @@ int hfi1_free_pd(struct ibv_pd *pd)
struct ibv_mr *hfi1_reg_mr(struct ibv_pd *pd, void *addr,
size_t length, int access)
{
- struct ibv_mr *mr;
+ struct verbs_mr *vmr;
struct ibv_reg_mr cmd;
struct ib_uverbs_reg_mr_resp resp;
int ret;
- mr = malloc(sizeof *mr);
- if (!mr)
+ vmr = malloc(sizeof(*vmr));
+ if (!vmr)
return NULL;
- ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access, mr,
+ ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access, vmr,
&cmd, sizeof cmd, &resp, sizeof resp);
if (ret) {
- free(mr);
+ free(vmr);
return NULL;
}
- return mr;
+ return &vmr->ibv_mr;
}
-int hfi1_dereg_mr(struct ibv_mr *mr)
+int hfi1_dereg_mr(struct verbs_mr *vmr)
{
int ret;
- ret = ibv_cmd_dereg_mr(mr);
+ ret = ibv_cmd_dereg_mr(vmr);
if (ret)
return ret;
- free(mr);
+ free(vmr);
return 0;
}
@@ -270,9 +270,9 @@ int hns_roce_u_free_pd(struct ibv_pd *pd);
struct ibv_mr *hns_roce_u_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
int access);
-int hns_roce_u_rereg_mr(struct ibv_mr *mr, int flags, struct ibv_pd *pd,
+int hns_roce_u_rereg_mr(struct verbs_mr *mr, int flags, struct ibv_pd *pd,
void *addr, size_t length, int access);
-int hns_roce_u_dereg_mr(struct ibv_mr *mr);
+int hns_roce_u_dereg_mr(struct verbs_mr *mr);
struct ibv_cq *hns_roce_u_create_cq(struct ibv_context *context, int cqe,
struct ibv_comp_channel *channel,
@@ -123,7 +123,7 @@ struct ibv_mr *hns_roce_u_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
int access)
{
int ret;
- struct ibv_mr *mr;
+ struct verbs_mr *vmr;
struct ibv_reg_mr cmd;
struct ib_uverbs_reg_mr_resp resp;
@@ -137,40 +137,40 @@ struct ibv_mr *hns_roce_u_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
return NULL;
}
- mr = malloc(sizeof(*mr));
- if (!mr)
+ vmr = malloc(sizeof(*vmr));
+ if (!vmr)
return NULL;
- ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr, access, mr,
+ ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access, vmr,
&cmd, sizeof(cmd), &resp, sizeof(resp));
if (ret) {
- free(mr);
+ free(vmr);
return NULL;
}
- return mr;
+ return &vmr->ibv_mr;
}
-int hns_roce_u_rereg_mr(struct ibv_mr *mr, int flags, struct ibv_pd *pd,
+int hns_roce_u_rereg_mr(struct verbs_mr *vmr, int flags, struct ibv_pd *pd,
void *addr, size_t length, int access)
{
struct ibv_rereg_mr cmd;
struct ib_uverbs_rereg_mr_resp resp;
- return ibv_cmd_rereg_mr(mr, flags, addr, length, (uintptr_t)addr,
+ return ibv_cmd_rereg_mr(vmr, flags, addr, length, (uintptr_t)addr,
access, pd, &cmd, sizeof(cmd), &resp,
sizeof(resp));
}
-int hns_roce_u_dereg_mr(struct ibv_mr *mr)
+int hns_roce_u_dereg_mr(struct verbs_mr *vmr)
{
int ret;
- ret = ibv_cmd_dereg_mr(mr);
+ ret = ibv_cmd_dereg_mr(vmr);
if (ret)
return ret;
- free(mr);
+ free(vmr);
return ret;
}
@@ -96,7 +96,7 @@ struct i40iw_uqp;
struct i40iw_ucq {
struct ibv_cq ibv_cq;
- struct ibv_mr mr;
+ struct verbs_mr vmr;
struct ibv_mr mr_shadow_area;
pthread_spinlock_t lock;
uint8_t is_armed;
@@ -112,7 +112,7 @@ struct i40iw_uqp {
struct ibv_qp ibv_qp;
struct i40iw_ucq *send_cq;
struct i40iw_ucq *recv_cq;
- struct ibv_mr mr;
+ struct verbs_mr vmr;
uint32_t i40iw_drv_opt;
pthread_spinlock_t lock;
u32 *push_db; /* mapped as uncached memory*/
@@ -161,7 +161,7 @@ int i40iw_uquery_port(struct ibv_context *, uint8_t, struct ibv_port_attr *);
struct ibv_pd *i40iw_ualloc_pd(struct ibv_context *);
int i40iw_ufree_pd(struct ibv_pd *);
struct ibv_mr *i40iw_ureg_mr(struct ibv_pd *, void *, size_t, int);
-int i40iw_udereg_mr(struct ibv_mr *);
+int i40iw_udereg_mr(struct verbs_mr *vmr);
struct ibv_cq *i40iw_ucreate_cq(struct ibv_context *, int, struct ibv_comp_channel *, int);
int i40iw_uresize_cq(struct ibv_cq *, int);
int i40iw_udestroy_cq(struct ibv_cq *);
@@ -151,39 +151,39 @@ int i40iw_ufree_pd(struct ibv_pd *pd)
*/
struct ibv_mr *i40iw_ureg_mr(struct ibv_pd *pd, void *addr, size_t length, int access)
{
- struct ibv_mr *mr;
+ struct verbs_mr *vmr;
struct i40iw_ureg_mr cmd;
struct ib_uverbs_reg_mr_resp resp;
- mr = malloc(sizeof(*mr));
- if (!mr)
+ vmr = malloc(sizeof(*vmr));
+ if (!vmr)
return NULL;
cmd.reg_type = IW_MEMREG_TYPE_MEM;
if (ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr,
- access, mr, &cmd.ibv_cmd, sizeof(cmd),
+ access, vmr, &cmd.ibv_cmd, sizeof(cmd),
&resp, sizeof(resp))) {
fprintf(stderr, PFX "%s: Failed to register memory\n", __func__);
- free(mr);
+ free(vmr);
return NULL;
}
- return mr;
+ return &vmr->ibv_mr;
}
/**
* i40iw_udereg_mr - re-register memory region
* @mr: mr that was allocated
*/
-int i40iw_udereg_mr(struct ibv_mr *mr)
+int i40iw_udereg_mr(struct verbs_mr *vmr)
{
int ret;
- ret = ibv_cmd_dereg_mr(mr);
+ ret = ibv_cmd_dereg_mr(vmr);
if (ret)
return ret;
- free(mr);
+ free(vmr);
return 0;
}
@@ -258,10 +258,11 @@ struct ibv_cq *i40iw_ucreate_cq(struct ibv_context *context, int cqe,
reg_mr_cmd.cq_pages = cq_pages;
- ret = ibv_cmd_reg_mr(&iwvctx->iwupd->ibv_pd, (void *)info.cq_base, totalsize,
- (uintptr_t)info.cq_base, IBV_ACCESS_LOCAL_WRITE,
- &iwucq->mr, ®_mr_cmd.ibv_cmd, sizeof(reg_mr_cmd), ®_mr_resp,
- sizeof(reg_mr_resp));
+ ret = ibv_cmd_reg_mr(&iwvctx->iwupd->ibv_pd, (void *)info.cq_base,
+ totalsize, (uintptr_t)info.cq_base,
+ IBV_ACCESS_LOCAL_WRITE, &iwucq->vmr,
+ ®_mr_cmd.ibv_cmd, sizeof(reg_mr_cmd),
+ ®_mr_resp, sizeof(reg_mr_resp));
if (ret) {
fprintf(stderr, PFX "%s: failed to pin memory for CQ\n", __func__);
goto err;
@@ -272,7 +273,7 @@ struct ibv_cq *i40iw_ucreate_cq(struct ibv_context *context, int cqe,
&iwucq->ibv_cq, &cmd.ibv_cmd, sizeof(cmd),
&resp.ibv_resp, sizeof(resp));
if (ret) {
- ibv_cmd_dereg_mr(&iwucq->mr);
+ ibv_cmd_dereg_mr(&iwucq->vmr);
fprintf(stderr, PFX "%s: failed to create CQ\n", __func__);
goto err;
}
@@ -312,7 +313,7 @@ int i40iw_udestroy_cq(struct ibv_cq *cq)
if (ret)
return ret;
- ibv_cmd_dereg_mr(&iwucq->mr);
+ ibv_cmd_dereg_mr(&iwucq->vmr);
free(iwucq->cq.cq_base);
free(iwucq);
@@ -478,7 +479,7 @@ static int i40iw_destroy_vmapped_qp(struct i40iw_uqp *iwuqp,
if (iwuqp->push_wqe)
munmap(iwuqp->push_wqe, I40IW_HW_PAGE_SIZE);
- ibv_cmd_dereg_mr(&iwuqp->mr);
+ ibv_cmd_dereg_mr(&iwuqp->vmr);
free((void *)sq_base);
return 0;
@@ -530,9 +531,11 @@ static int i40iw_vmapped_qp(struct i40iw_uqp *iwuqp, struct ibv_pd *pd,
reg_mr_cmd.sq_pages = sq_pages;
reg_mr_cmd.rq_pages = rq_pages;
- ret = ibv_cmd_reg_mr(pd, (void *)info->sq, totalqpsize, (uintptr_t)info->sq,
- IBV_ACCESS_LOCAL_WRITE, &iwuqp->mr, ®_mr_cmd.ibv_cmd,
- sizeof(reg_mr_cmd), ®_mr_resp, sizeof(reg_mr_resp));
+ ret = ibv_cmd_reg_mr(pd, (void *)info->sq, totalqpsize,
+ (uintptr_t)info->sq, IBV_ACCESS_LOCAL_WRITE,
+ &iwuqp->vmr, ®_mr_cmd.ibv_cmd,
+ sizeof(reg_mr_cmd), ®_mr_resp,
+ sizeof(reg_mr_resp));
if (ret) {
fprintf(stderr, PFX "%s: failed to pin memory for SQ\n", __func__);
free(info->sq);
@@ -545,7 +548,7 @@ static int i40iw_vmapped_qp(struct i40iw_uqp *iwuqp, struct ibv_pd *pd,
&resp->ibv_resp, sizeof(struct i40iw_ucreate_qp_resp));
if (ret) {
fprintf(stderr, PFX "%s: failed to create QP, status %d\n", __func__, ret);
- ibv_cmd_dereg_mr(&iwuqp->mr);
+ ibv_cmd_dereg_mr(&iwuqp->vmr);
free(info->sq);
return 0;
}
@@ -186,7 +186,7 @@ int ipath_free_pd(struct ibv_pd *pd);
struct ibv_mr *ipath_reg_mr(struct ibv_pd *pd, void *addr,
size_t length, int access);
-int ipath_dereg_mr(struct ibv_mr *mr);
+int ipath_dereg_mr(struct verbs_mr *vmr);
struct ibv_cq *ipath_create_cq(struct ibv_context *context, int cqe,
struct ibv_comp_channel *channel,
@@ -112,34 +112,34 @@ int ipath_free_pd(struct ibv_pd *pd)
struct ibv_mr *ipath_reg_mr(struct ibv_pd *pd, void *addr,
size_t length, int access)
{
- struct ibv_mr *mr;
+ struct verbs_mr *vmr;
struct ibv_reg_mr cmd;
struct ib_uverbs_reg_mr_resp resp;
int ret;
- mr = malloc(sizeof *mr);
- if (!mr)
+ vmr = malloc(sizeof(*vmr));
+ if (!vmr)
return NULL;
- ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access, mr,
+ ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access, vmr,
&cmd, sizeof cmd, &resp, sizeof resp);
if (ret) {
- free(mr);
+ free(vmr);
return NULL;
}
- return mr;
+ return &vmr->ibv_mr;
}
-int ipath_dereg_mr(struct ibv_mr *mr)
+int ipath_dereg_mr(struct verbs_mr *vmr)
{
int ret;
- ret = ibv_cmd_dereg_mr(mr);
+ ret = ibv_cmd_dereg_mr(vmr);
if (ret)
return ret;
- free(mr);
+ free(vmr);
return 0;
}
@@ -329,9 +329,9 @@ int mlx4_close_xrcd(struct ibv_xrcd *xrcd);
struct ibv_mr *mlx4_reg_mr(struct ibv_pd *pd, void *addr,
size_t length, int access);
-int mlx4_rereg_mr(struct ibv_mr *mr, int flags, struct ibv_pd *pd,
+int mlx4_rereg_mr(struct verbs_mr *vmr, int flags, struct ibv_pd *pd,
void *addr, size_t length, int access);
-int mlx4_dereg_mr(struct ibv_mr *mr);
+int mlx4_dereg_mr(struct verbs_mr *vmr);
struct ibv_mw *mlx4_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type type);
int mlx4_dealloc_mw(struct ibv_mw *mw);
@@ -273,27 +273,27 @@ int mlx4_close_xrcd(struct ibv_xrcd *ib_xrcd)
struct ibv_mr *mlx4_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
int access)
{
- struct ibv_mr *mr;
+ struct verbs_mr *vmr;
struct ibv_reg_mr cmd;
struct ib_uverbs_reg_mr_resp resp;
int ret;
- mr = malloc(sizeof *mr);
- if (!mr)
+ vmr = malloc(sizeof(*vmr));
+ if (!vmr)
return NULL;
ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr,
- access, mr, &cmd, sizeof cmd,
- &resp, sizeof resp);
+ access, vmr, &cmd, sizeof(cmd),
+ &resp, sizeof(resp));
if (ret) {
- free(mr);
+ free(vmr);
return NULL;
}
- return mr;
+ return &vmr->ibv_mr;
}
-int mlx4_rereg_mr(struct ibv_mr *mr,
+int mlx4_rereg_mr(struct verbs_mr *vmr,
int flags,
struct ibv_pd *pd, void *addr,
size_t length, int access)
@@ -304,22 +304,22 @@ int mlx4_rereg_mr(struct ibv_mr *mr,
if (flags & IBV_REREG_MR_KEEP_VALID)
return ENOTSUP;
- return ibv_cmd_rereg_mr(mr, flags, addr, length,
+ return ibv_cmd_rereg_mr(vmr, flags, addr, length,
(uintptr_t)addr,
access, pd,
&cmd, sizeof(cmd),
&resp, sizeof(resp));
}
-int mlx4_dereg_mr(struct ibv_mr *mr)
+int mlx4_dereg_mr(struct verbs_mr *vmr)
{
int ret;
- ret = ibv_cmd_dereg_mr(mr);
+ ret = ibv_cmd_dereg_mr(vmr);
if (ret && !cleanup_on_fatal(ret))
return ret;
- free(mr);
+ free(vmr);
return 0;
}
@@ -479,7 +479,7 @@ struct mlx5_dm {
};
struct mlx5_mr {
- struct ibv_mr ibv_mr;
+ struct verbs_mr vmr;
struct mlx5_buf buf;
uint32_t alloc_flags;
};
@@ -657,7 +657,7 @@ static inline struct mlx5_dm *to_mdm(struct ibv_dm *ibdm)
static inline struct mlx5_mr *to_mmr(struct ibv_mr *ibmr)
{
- return to_mxxx(mr, mr);
+ return container_of(ibmr, struct mlx5_mr, vmr.ibv_mr);
}
static inline struct mlx5_ah *to_mah(struct ibv_ah *ibah)
@@ -737,9 +737,9 @@ int mlx5_free_pd(struct ibv_pd *pd);
struct ibv_mr *mlx5_reg_mr(struct ibv_pd *pd, void *addr,
size_t length, int access);
-int mlx5_rereg_mr(struct ibv_mr *mr, int flags, struct ibv_pd *pd, void *addr,
+int mlx5_rereg_mr(struct verbs_mr *mr, int flags, struct ibv_pd *pd, void *addr,
size_t length, int access);
-int mlx5_dereg_mr(struct ibv_mr *mr);
+int mlx5_dereg_mr(struct verbs_mr *mr);
struct ibv_mw *mlx5_alloc_mw(struct ibv_pd *pd, enum ibv_mw_type);
int mlx5_dealloc_mw(struct ibv_mw *mw);
int mlx5_bind_mw(struct ibv_qp *qp, struct ibv_mw *mw,
@@ -384,7 +384,7 @@ struct ibv_mr *mlx5_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
return NULL;
ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access,
- &(mr->ibv_mr), &cmd, sizeof(cmd), &resp,
+ &mr->vmr, &cmd, sizeof(cmd), &resp,
sizeof resp);
if (ret) {
mlx5_free_buf(&(mr->buf));
@@ -393,7 +393,7 @@ struct ibv_mr *mlx5_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
}
mr->alloc_flags = acc;
- return &mr->ibv_mr;
+ return &mr->vmr.ibv_mr;
}
enum {
@@ -424,7 +424,7 @@ struct ibv_mr *mlx5_reg_dm_mr(struct ibv_pd *pd, struct ibv_dm *ibdm,
}
ret = ibv_cmd_reg_dm_mr(pd, &dm->verbs_dm, dm_offset, length, acc,
- &mr->ibv_mr, NULL);
+ &mr->vmr, NULL);
if (ret) {
free(mr);
return NULL;
@@ -432,11 +432,11 @@ struct ibv_mr *mlx5_reg_dm_mr(struct ibv_pd *pd, struct ibv_dm *ibdm,
mr->alloc_flags = acc;
- return &mr->ibv_mr;
+ return &mr->vmr.ibv_mr;
}
-int mlx5_rereg_mr(struct ibv_mr *ibmr, int flags, struct ibv_pd *pd, void *addr,
- size_t length, int access)
+int mlx5_rereg_mr(struct verbs_mr *vmr, int flags, struct ibv_pd *pd,
+ void *addr, size_t length, int access)
{
struct ibv_rereg_mr cmd;
struct ib_uverbs_rereg_mr_resp resp;
@@ -444,21 +444,20 @@ int mlx5_rereg_mr(struct ibv_mr *ibmr, int flags, struct ibv_pd *pd, void *addr,
if (flags & IBV_REREG_MR_KEEP_VALID)
return ENOTSUP;
- return ibv_cmd_rereg_mr(ibmr, flags, addr, length, (uintptr_t)addr,
+ return ibv_cmd_rereg_mr(vmr, flags, addr, length, (uintptr_t)addr,
access, pd, &cmd, sizeof(cmd), &resp,
sizeof(resp));
}
-int mlx5_dereg_mr(struct ibv_mr *ibmr)
+int mlx5_dereg_mr(struct verbs_mr *vmr)
{
int ret;
- struct mlx5_mr *mr = to_mmr(ibmr);
- ret = ibv_cmd_dereg_mr(ibmr);
+ ret = ibv_cmd_dereg_mr(vmr);
if (ret)
return ret;
- free(mr);
+ free(vmr);
return 0;
}
@@ -179,7 +179,7 @@ void mthca_free_av(struct mthca_ah *ah)
if (page->next)
page->next->prev = page->prev;
- mthca_dereg_mr(page->mr);
+ mthca_dereg_mr(verbs_get_mr(page->mr));
mthca_free_buf(&page->buf);
free(page);
}
@@ -282,7 +282,7 @@ int mthca_free_pd(struct ibv_pd *pd);
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);
+int mthca_dereg_mr(struct verbs_mr *mr);
struct ibv_cq *mthca_create_cq(struct ibv_context *context, int cqe,
struct ibv_comp_channel *channel,
@@ -117,7 +117,7 @@ static struct ibv_mr *__mthca_reg_mr(struct ibv_pd *pd, void *addr,
int access,
int dma_sync)
{
- struct ibv_mr *mr;
+ struct verbs_mr *vmr;
struct umthca_reg_mr cmd;
struct ib_uverbs_reg_mr_resp resp;
int ret;
@@ -131,18 +131,18 @@ static struct ibv_mr *__mthca_reg_mr(struct ibv_pd *pd, void *addr,
cmd.mr_attrs = dma_sync ? MTHCA_MR_DMASYNC : 0;
cmd.reserved = 0;
- mr = malloc(sizeof *mr);
- if (!mr)
+ vmr = malloc(sizeof(*vmr));
+ if (!vmr)
return NULL;
- ret = ibv_cmd_reg_mr(pd, addr, length, hca_va, access, mr, &cmd.ibv_cmd,
- sizeof cmd, &resp, sizeof resp);
+ ret = ibv_cmd_reg_mr(pd, addr, length, hca_va, access, vmr,
+ &cmd.ibv_cmd, sizeof(cmd), &resp, sizeof(resp));
if (ret) {
- free(mr);
+ free(vmr);
return NULL;
}
- return mr;
+ return &vmr->ibv_mr;
}
struct ibv_mr *mthca_reg_mr(struct ibv_pd *pd, void *addr,
@@ -151,15 +151,15 @@ struct ibv_mr *mthca_reg_mr(struct ibv_pd *pd, void *addr,
return __mthca_reg_mr(pd, addr, length, (uintptr_t) addr, access, 0);
}
-int mthca_dereg_mr(struct ibv_mr *mr)
+int mthca_dereg_mr(struct verbs_mr *vmr)
{
int ret;
- ret = ibv_cmd_dereg_mr(mr);
+ ret = ibv_cmd_dereg_mr(vmr);
if (ret)
return ret;
- free(mr);
+ free(vmr);
return 0;
}
@@ -258,7 +258,7 @@ err_set_db:
cq->set_ci_db_index);
err_unreg:
- mthca_dereg_mr(cq->mr);
+ mthca_dereg_mr(verbs_get_mr(cq->mr));
err_buf:
mthca_free_buf(&cq->buf);
@@ -312,14 +312,14 @@ int mthca_resize_cq(struct ibv_cq *ibcq, int cqe)
ret = ibv_cmd_resize_cq(ibcq, cqe - 1, &cmd.ibv_cmd, sizeof cmd, &resp,
sizeof resp);
if (ret) {
- mthca_dereg_mr(mr);
+ mthca_dereg_mr(verbs_get_mr(mr));
mthca_free_buf(&buf);
goto out;
}
mthca_cq_resize_copy_cqes(cq, buf.buf, old_cqe);
- mthca_dereg_mr(cq->mr);
+ mthca_dereg_mr(verbs_get_mr(cq->mr));
mthca_free_buf(&cq->buf);
cq->buf = buf;
@@ -345,7 +345,7 @@ int mthca_destroy_cq(struct ibv_cq *cq)
to_mcq(cq)->arm_db_index);
}
- mthca_dereg_mr(to_mcq(cq)->mr);
+ mthca_dereg_mr(verbs_get_mr(to_mcq(cq)->mr));
mthca_free_buf(&to_mcq(cq)->buf);
free(to_mcq(cq));
@@ -437,7 +437,7 @@ err_db:
srq->db_index);
err_unreg:
- mthca_dereg_mr(srq->mr);
+ mthca_dereg_mr(verbs_get_mr(srq->mr));
err_free:
free(srq->wrid);
@@ -478,7 +478,7 @@ int mthca_destroy_srq(struct ibv_srq *srq)
mthca_free_db(to_mctx(srq->context)->db_tab, MTHCA_DB_TYPE_SRQ,
to_msrq(srq)->db_index);
- mthca_dereg_mr(to_msrq(srq)->mr);
+ mthca_dereg_mr(verbs_get_mr(to_msrq(srq)->mr));
mthca_free_buf(&to_msrq(srq)->buf);
free(to_msrq(srq)->wrid);
@@ -588,7 +588,7 @@ err_sq_db:
qp->sq.db_index);
err_unreg:
- mthca_dereg_mr(qp->mr);
+ mthca_dereg_mr(verbs_get_mr(qp->mr));
err_free:
free(qp->wrid);
@@ -698,7 +698,7 @@ int mthca_destroy_qp(struct ibv_qp *qp)
to_mqp(qp)->sq.db_index);
}
- mthca_dereg_mr(to_mqp(qp)->mr);
+ mthca_dereg_mr(verbs_get_mr(to_mqp(qp)->mr));
mthca_free_buf(&to_mqp(qp)->buf);
free(to_mqp(qp)->wrid);
free(to_mqp(qp));
@@ -276,7 +276,7 @@ struct nes_uqp;
struct nes_ucq {
struct ibv_cq ibv_cq;
struct nes_hw_cqe volatile *cqes;
- struct ibv_mr mr;
+ struct verbs_mr vmr;
pthread_spinlock_t lock;
uint32_t cq_id;
uint16_t size;
@@ -297,7 +297,7 @@ struct nes_uqp {
uint32_t qp_id;
struct nes_ucq *send_cq;
struct nes_ucq *recv_cq;
- struct ibv_mr mr;
+ struct verbs_mr vmr;
uint32_t nes_drv_opt;
pthread_spinlock_t lock;
uint16_t sq_db_index;
@@ -356,7 +356,7 @@ int nes_uquery_port(struct ibv_context *, uint8_t, struct ibv_port_attr *);
struct ibv_pd *nes_ualloc_pd(struct ibv_context *);
int nes_ufree_pd(struct ibv_pd *);
struct ibv_mr *nes_ureg_mr(struct ibv_pd *, void *, size_t, int);
-int nes_udereg_mr(struct ibv_mr *);
+int nes_udereg_mr(struct verbs_mr *vmr);
struct ibv_cq *nes_ucreate_cq(struct ibv_context *, int, struct ibv_comp_channel *, int);
int nes_uresize_cq(struct ibv_cq *, int);
int nes_udestroy_cq(struct ibv_cq *);
@@ -168,39 +168,39 @@ int nes_ufree_pd(struct ibv_pd *pd)
struct ibv_mr *nes_ureg_mr(struct ibv_pd *pd, void *addr,
size_t length, int access)
{
- struct ibv_mr *mr;
+ struct verbs_mr *vmr;
struct nes_ureg_mr cmd;
struct ib_uverbs_reg_mr_resp resp;
- mr = malloc(sizeof *mr);
- if (!mr)
+ vmr = malloc(sizeof(*vmr));
+ if (!vmr)
return NULL;
cmd.reg_type = IWNES_MEMREG_TYPE_MEM;
if (ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr,
- access, mr, &cmd.ibv_cmd, sizeof cmd,
- &resp, sizeof resp)) {
- free(mr);
+ access, vmr, &cmd.ibv_cmd, sizeof(cmd),
+ &resp, sizeof(resp))) {
+ free(vmr);
return NULL;
}
- return mr;
+ return &vmr->ibv_mr;
}
/**
* nes_udereg_mr
*/
-int nes_udereg_mr(struct ibv_mr *mr)
+int nes_udereg_mr(struct verbs_mr *vmr)
{
int ret;
- ret = ibv_cmd_dereg_mr(mr);
+ ret = ibv_cmd_dereg_mr(vmr);
if (ret)
return ret;
- free(mr);
+ free(vmr);
return 0;
}
@@ -243,9 +243,9 @@ struct ibv_cq *nes_ucreate_cq(struct ibv_context *context, int cqe,
ret = ibv_cmd_reg_mr(&nesvctx->nesupd->ibv_pd, (void *)nesucq->cqes,
(nesucq->size*sizeof(struct nes_hw_cqe)),
- (uintptr_t)nesucq->cqes, IBV_ACCESS_LOCAL_WRITE, &nesucq->mr,
- ®_mr_cmd.ibv_cmd, sizeof reg_mr_cmd,
- ®_mr_resp, sizeof reg_mr_resp);
+ (uintptr_t)nesucq->cqes, IBV_ACCESS_LOCAL_WRITE,
+ &nesucq->vmr, ®_mr_cmd.ibv_cmd, sizeof(reg_mr_cmd),
+ ®_mr_resp, sizeof(reg_mr_resp));
if (ret) {
/* fprintf(stderr, "ibv_cmd_reg_mr failed (ret = %d).\n", ret); */
free((struct nes_hw_cqe *)nesucq->cqes);
@@ -300,7 +300,7 @@ int nes_udestroy_cq(struct ibv_cq *cq)
if (ret)
return ret;
- ret = ibv_cmd_dereg_mr(&nesucq->mr);
+ ret = ibv_cmd_dereg_mr(&nesucq->vmr);
if (ret)
fprintf(stderr, PFX "%s: Failed to deregister CQ Memory Region.\n", __FUNCTION__);
@@ -957,9 +957,10 @@ static int nes_vmapped_qp(struct nes_uqp *nesuqp, struct ibv_pd *pd, struct ibv_
// nesuqp->rq_vbase, nesuqp->sq_vbase, &nesuqp->mr);
ret = ibv_cmd_reg_mr(pd, (void *)nesuqp->sq_vbase,totalqpsize,
- (uintptr_t) nesuqp->sq_vbase, IBV_ACCESS_LOCAL_WRITE,
- &nesuqp->mr, ®_mr_cmd.ibv_cmd, sizeof reg_mr_cmd,
- ®_mr_resp, sizeof reg_mr_resp);
+ (uintptr_t)nesuqp->sq_vbase,
+ IBV_ACCESS_LOCAL_WRITE, &nesuqp->vmr,
+ ®_mr_cmd.ibv_cmd, sizeof(reg_mr_cmd),
+ ®_mr_resp, sizeof(reg_mr_resp));
if (ret) {
// fprintf(stderr, PFX "%s ibv_cmd_reg_mr failed (ret = %d).\n", __FUNCTION__, ret);
free((void *) nesuqp->sq_vbase);
@@ -972,7 +973,7 @@ static int nes_vmapped_qp(struct nes_uqp *nesuqp, struct ibv_pd *pd, struct ibv_
ret = ibv_cmd_create_qp(pd, &nesuqp->ibv_qp, attr, &cmd.ibv_cmd, sizeof cmd,
&resp->ibv_resp, sizeof (struct nes_ucreate_qp_resp) );
if (ret) {
- ibv_cmd_dereg_mr(&nesuqp->mr);
+ ibv_cmd_dereg_mr(&nesuqp->vmr);
free((void *)nesuqp->sq_vbase);
return 0;
}
@@ -1155,7 +1156,7 @@ int nes_udestroy_qp(struct ibv_qp *qp)
// fprintf(stderr, PFX "%s addr&mr= %p \n", __FUNCTION__, &nesuqp->mr );
if (nesuqp->mapping == NES_QP_VMAP) {
- ret = ibv_cmd_dereg_mr(&nesuqp->mr);
+ ret = ibv_cmd_dereg_mr(&nesuqp->vmr);
if (ret)
fprintf(stderr, PFX "%s dereg_mr FAILED\n", __FUNCTION__);
free((void *)nesuqp->sq_vbase);
@@ -82,7 +82,7 @@ struct ocrdma_pd {
};
struct ocrdma_mr {
- struct ibv_mr ibv_mr;
+ struct verbs_mr vmr;
};
struct ocrdma_cq {
@@ -271,7 +271,7 @@ struct ibv_pd *ocrdma_alloc_pd(struct ibv_context *);
int ocrdma_free_pd(struct ibv_pd *);
struct ibv_mr *ocrdma_reg_mr(struct ibv_pd *, void *, size_t,
int ibv_access_flags);
-int ocrdma_dereg_mr(struct ibv_mr *);
+int ocrdma_dereg_mr(struct verbs_mr *vmr);
struct ibv_cq *ocrdma_create_cq(struct ibv_context *, int,
struct ibv_comp_channel *, int);
@@ -200,24 +200,24 @@ struct ibv_mr *ocrdma_reg_mr(struct ibv_pd *pd, void *addr,
bzero(mr, sizeof *mr);
if (ibv_cmd_reg_mr(pd, addr, len, hca_va,
- access, &mr->ibv_mr, &cmd, sizeof cmd,
- &resp.ibv_resp, sizeof resp)) {
+ access, &mr->vmr, &cmd, sizeof(cmd),
+ &resp.ibv_resp, sizeof(resp))) {
free(mr);
return NULL;
}
- return &mr->ibv_mr;
+ return &mr->vmr.ibv_mr;
}
/*
* ocrdma_dereg_mr
*/
-int ocrdma_dereg_mr(struct ibv_mr *mr)
+int ocrdma_dereg_mr(struct verbs_mr *vmr)
{
int status;
- status = ibv_cmd_dereg_mr(mr);
+ status = ibv_cmd_dereg_mr(vmr);
if (status)
return status;
- free(mr);
+ free(vmr);
return 0;
}
@@ -139,7 +139,7 @@ struct qelr_pd {
};
struct qelr_mr {
- struct ibv_mr ibv_mr;
+ struct verbs_mr vmr;
};
union db_prod64 {
@@ -48,7 +48,7 @@ int qelr_dealloc_pd(struct ibv_pd *);
struct ibv_mr *qelr_reg_mr(struct ibv_pd *, void *, size_t,
int ibv_access_flags);
-int qelr_dereg_mr(struct ibv_mr *);
+int qelr_dereg_mr(struct verbs_mr *vmr);
struct ibv_cq *qelr_create_cq(struct ibv_context *, int,
struct ibv_comp_channel *, int);
@@ -175,7 +175,7 @@ struct ibv_mr *qelr_reg_mr(struct ibv_pd *ibpd, void *addr,
bzero(mr, sizeof(*mr));
if (ibv_cmd_reg_mr(ibpd, addr, len, hca_va,
- access, &mr->ibv_mr, &cmd, sizeof(cmd),
+ access, &mr->vmr, &cmd, sizeof(cmd),
&resp.ibv_resp, sizeof(resp))) {
free(mr);
return NULL;
@@ -183,25 +183,25 @@ struct ibv_mr *qelr_reg_mr(struct ibv_pd *ibpd, void *addr,
DP_VERBOSE(cxt->dbg_fp, QELR_MSG_MR,
"MR Register %p completed successfully pd_id=%d addr=%p len=%zu access=%d lkey=%x rkey=%x\n",
- mr, pd->pd_id, addr, len, access, mr->ibv_mr.lkey,
- mr->ibv_mr.rkey);
+ mr, pd->pd_id, addr, len, access, mr->vmr.ibv_mr.lkey,
+ mr->vmr.ibv_mr.rkey);
- return &mr->ibv_mr;
+ return &mr->vmr.ibv_mr;
}
-int qelr_dereg_mr(struct ibv_mr *mr)
+int qelr_dereg_mr(struct verbs_mr *vmr)
{
- struct qelr_devctx *cxt = get_qelr_ctx(mr->context);
+ struct qelr_devctx *cxt = get_qelr_ctx(vmr->ibv_mr.context);
int rc;
- rc = ibv_cmd_dereg_mr(mr);
+ rc = ibv_cmd_dereg_mr(vmr);
if (rc)
return rc;
- free(mr);
+ free(vmr);
DP_VERBOSE(cxt->dbg_fp, QELR_MSG_MR,
- "MR DERegister %p completed successfully\n", mr);
+ "MR DERegister %p completed successfully\n", vmr);
return 0;
}
@@ -50,7 +50,7 @@ int qelr_dealloc_pd(struct ibv_pd *ibpd);
struct ibv_mr *qelr_reg_mr(struct ibv_pd *ibpd, void *addr,
size_t len, int access);
-int qelr_dereg_mr(struct ibv_mr *mr);
+int qelr_dereg_mr(struct verbs_mr *mr);
struct ibv_cq *qelr_create_cq(struct ibv_context *context, int cqe,
struct ibv_comp_channel *channel,
@@ -125,35 +125,34 @@ static int rxe_dealloc_pd(struct ibv_pd *pd)
static struct ibv_mr *rxe_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
int access)
{
- struct ibv_mr *mr;
+ struct verbs_mr *vmr;
struct ibv_reg_mr cmd;
struct ib_uverbs_reg_mr_resp resp;
int ret;
- mr = malloc(sizeof *mr);
- if (!mr) {
+ vmr = malloc(sizeof(*vmr));
+ if (!vmr)
return NULL;
- }
- ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access, mr,
+ ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t)addr, access, vmr,
&cmd, sizeof cmd, &resp, sizeof resp);
if (ret) {
- free(mr);
+ free(vmr);
return NULL;
}
- return mr;
+ return &vmr->ibv_mr;
}
-static int rxe_dereg_mr(struct ibv_mr *mr)
+static int rxe_dereg_mr(struct verbs_mr *vmr)
{
int ret;
- ret = ibv_cmd_dereg_mr(mr);
+ ret = ibv_cmd_dereg_mr(vmr);
if (ret)
return ret;
- free(mr);
+ free(vmr);
return 0;
}
@@ -283,7 +283,7 @@ int pvrdma_free_pd(struct ibv_pd *pd);
struct ibv_mr *pvrdma_reg_mr(struct ibv_pd *pd, void *addr,
size_t length, int access);
-int pvrdma_dereg_mr(struct ibv_mr *mr);
+int pvrdma_dereg_mr(struct verbs_mr *mr);
struct ibv_cq *pvrdma_create_cq(struct ibv_context *context, int cqe,
struct ibv_comp_channel *channel,
@@ -114,35 +114,35 @@ int pvrdma_free_pd(struct ibv_pd *pd)
struct ibv_mr *pvrdma_reg_mr(struct ibv_pd *pd, void *addr, size_t length,
int access)
{
- struct ibv_mr *mr;
+ struct verbs_mr *vmr;
struct ibv_reg_mr cmd;
struct ib_uverbs_reg_mr_resp resp;
int ret;
- mr = malloc(sizeof(*mr));
- if (!mr)
+ vmr = malloc(sizeof(*vmr));
+ if (!vmr)
return NULL;
ret = ibv_cmd_reg_mr(pd, addr, length, (uintptr_t) addr,
- access, mr, &cmd, sizeof(cmd),
+ access, vmr, &cmd, sizeof(cmd),
&resp, sizeof(resp));
if (ret) {
- free(mr);
+ free(vmr);
return NULL;
}
- return mr;
+ return &vmr->ibv_mr;
}
-int pvrdma_dereg_mr(struct ibv_mr *mr)
+int pvrdma_dereg_mr(struct verbs_mr *vmr)
{
int ret;
- ret = ibv_cmd_dereg_mr(mr);
+ ret = ibv_cmd_dereg_mr(vmr);
if (ret)
return ret;
- free(mr);
+ free(vmr);
return 0;
}