mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
RDMA: Globally allocate and release QP memory
Convert QP object to follow IB/core general allocation scheme. That change allows us to make sure that restrack properly kref the memory. Link: https://lore.kernel.org/r/48e767124758aeecc433360ddd85eaa6325b34d9.1627040189.git.leonro@nvidia.com Reviewed-by: Gal Pressman <galpress@amazon.com> #efa Tested-by: Gal Pressman <galpress@amazon.com> Reviewed-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com> #rdma and core Tested-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Tested-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
committed by
Jason Gunthorpe
parent
44da3730e0
commit
514aee660d
@@ -322,13 +322,14 @@ _ib_create_qp(struct ib_device *dev, struct ib_pd *pd,
|
||||
struct ib_uqp_object *uobj, const char *caller)
|
||||
{
|
||||
struct ib_qp *qp;
|
||||
int ret;
|
||||
|
||||
if (!dev->ops.create_qp)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
|
||||
qp = dev->ops.create_qp(pd, attr, udata);
|
||||
if (IS_ERR(qp))
|
||||
return qp;
|
||||
qp = rdma_zalloc_drv_obj_numa(dev, ib_qp);
|
||||
if (!qp)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
qp->device = dev;
|
||||
qp->pd = pd;
|
||||
@@ -337,14 +338,10 @@ _ib_create_qp(struct ib_device *dev, struct ib_pd *pd,
|
||||
|
||||
qp->qp_type = attr->qp_type;
|
||||
qp->rwq_ind_tbl = attr->rwq_ind_tbl;
|
||||
qp->send_cq = attr->send_cq;
|
||||
qp->recv_cq = attr->recv_cq;
|
||||
qp->srq = attr->srq;
|
||||
qp->rwq_ind_tbl = attr->rwq_ind_tbl;
|
||||
qp->event_handler = attr->event_handler;
|
||||
qp->port = attr->port_num;
|
||||
|
||||
atomic_set(&qp->usecnt, 0);
|
||||
spin_lock_init(&qp->mr_lock);
|
||||
INIT_LIST_HEAD(&qp->rdma_mrs);
|
||||
INIT_LIST_HEAD(&qp->sig_mrs);
|
||||
@@ -352,8 +349,25 @@ _ib_create_qp(struct ib_device *dev, struct ib_pd *pd,
|
||||
rdma_restrack_new(&qp->res, RDMA_RESTRACK_QP);
|
||||
WARN_ONCE(!udata && !caller, "Missing kernel QP owner");
|
||||
rdma_restrack_set_name(&qp->res, udata ? NULL : caller);
|
||||
ret = dev->ops.create_qp(qp, attr, udata);
|
||||
if (ret)
|
||||
goto err_create;
|
||||
|
||||
/*
|
||||
* TODO: The mlx4 internally overwrites send_cq and recv_cq.
|
||||
* Unfortunately, it is not an easy task to fix that driver.
|
||||
*/
|
||||
qp->send_cq = attr->send_cq;
|
||||
qp->recv_cq = attr->recv_cq;
|
||||
|
||||
rdma_restrack_add(&qp->res);
|
||||
return qp;
|
||||
|
||||
err_create:
|
||||
rdma_restrack_put(&qp->res);
|
||||
kfree(qp);
|
||||
return ERR_PTR(ret);
|
||||
|
||||
}
|
||||
|
||||
struct rdma_dev_addr;
|
||||
|
||||
@@ -2654,6 +2654,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
|
||||
SET_DEVICE_OP(dev_ops, get_hw_stats);
|
||||
SET_DEVICE_OP(dev_ops, get_link_layer);
|
||||
SET_DEVICE_OP(dev_ops, get_netdev);
|
||||
SET_DEVICE_OP(dev_ops, get_numa_node);
|
||||
SET_DEVICE_OP(dev_ops, get_port_immutable);
|
||||
SET_DEVICE_OP(dev_ops, get_vector_affinity);
|
||||
SET_DEVICE_OP(dev_ops, get_vf_config);
|
||||
@@ -2710,6 +2711,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
|
||||
SET_OBJ_SIZE(dev_ops, ib_cq);
|
||||
SET_OBJ_SIZE(dev_ops, ib_mw);
|
||||
SET_OBJ_SIZE(dev_ops, ib_pd);
|
||||
SET_OBJ_SIZE(dev_ops, ib_qp);
|
||||
SET_OBJ_SIZE(dev_ops, ib_rwq_ind_table);
|
||||
SET_OBJ_SIZE(dev_ops, ib_srq);
|
||||
SET_OBJ_SIZE(dev_ops, ib_ucontext);
|
||||
|
||||
@@ -343,7 +343,7 @@ void rdma_restrack_del(struct rdma_restrack_entry *res)
|
||||
rt = &dev->res[res->type];
|
||||
|
||||
old = xa_erase(&rt->xa, res->id);
|
||||
if (res->type == RDMA_RESTRACK_MR || res->type == RDMA_RESTRACK_QP)
|
||||
if (res->type == RDMA_RESTRACK_MR)
|
||||
return;
|
||||
WARN_ON(old != res);
|
||||
|
||||
|
||||
@@ -1963,30 +1963,32 @@ int ib_destroy_qp_user(struct ib_qp *qp, struct ib_udata *udata)
|
||||
rdma_rw_cleanup_mrs(qp);
|
||||
|
||||
rdma_counter_unbind_qp(qp, true);
|
||||
rdma_restrack_del(&qp->res);
|
||||
ret = qp->device->ops.destroy_qp(qp, udata);
|
||||
if (!ret) {
|
||||
if (alt_path_sgid_attr)
|
||||
rdma_put_gid_attr(alt_path_sgid_attr);
|
||||
if (av_sgid_attr)
|
||||
rdma_put_gid_attr(av_sgid_attr);
|
||||
if (pd)
|
||||
atomic_dec(&pd->usecnt);
|
||||
if (scq)
|
||||
atomic_dec(&scq->usecnt);
|
||||
if (rcq)
|
||||
atomic_dec(&rcq->usecnt);
|
||||
if (srq)
|
||||
atomic_dec(&srq->usecnt);
|
||||
if (ind_tbl)
|
||||
atomic_dec(&ind_tbl->usecnt);
|
||||
if (sec)
|
||||
ib_destroy_qp_security_end(sec);
|
||||
} else {
|
||||
if (ret) {
|
||||
if (sec)
|
||||
ib_destroy_qp_security_abort(sec);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (alt_path_sgid_attr)
|
||||
rdma_put_gid_attr(alt_path_sgid_attr);
|
||||
if (av_sgid_attr)
|
||||
rdma_put_gid_attr(av_sgid_attr);
|
||||
if (pd)
|
||||
atomic_dec(&pd->usecnt);
|
||||
if (scq)
|
||||
atomic_dec(&scq->usecnt);
|
||||
if (rcq)
|
||||
atomic_dec(&rcq->usecnt);
|
||||
if (srq)
|
||||
atomic_dec(&srq->usecnt);
|
||||
if (ind_tbl)
|
||||
atomic_dec(&ind_tbl->usecnt);
|
||||
if (sec)
|
||||
ib_destroy_qp_security_end(sec);
|
||||
|
||||
rdma_restrack_del(&qp->res);
|
||||
kfree(qp);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(ib_destroy_qp_user);
|
||||
|
||||
@@ -815,7 +815,7 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)
|
||||
if (ib_qp->qp_type == IB_QPT_GSI && rdev->gsi_ctx.gsi_sqp) {
|
||||
rc = bnxt_re_destroy_gsi_sqp(qp);
|
||||
if (rc)
|
||||
goto sh_fail;
|
||||
return rc;
|
||||
}
|
||||
|
||||
mutex_lock(&rdev->qp_lock);
|
||||
@@ -826,10 +826,7 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)
|
||||
ib_umem_release(qp->rumem);
|
||||
ib_umem_release(qp->sumem);
|
||||
|
||||
kfree(qp);
|
||||
return 0;
|
||||
sh_fail:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static u8 __from_ib_qp_type(enum ib_qp_type type)
|
||||
@@ -1402,27 +1399,22 @@ static bool bnxt_re_test_qp_limits(struct bnxt_re_dev *rdev,
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct ib_qp *bnxt_re_create_qp(struct ib_pd *ib_pd,
|
||||
struct ib_qp_init_attr *qp_init_attr,
|
||||
struct ib_udata *udata)
|
||||
int bnxt_re_create_qp(struct ib_qp *ib_qp, struct ib_qp_init_attr *qp_init_attr,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct ib_pd *ib_pd = ib_qp->pd;
|
||||
struct bnxt_re_pd *pd = container_of(ib_pd, struct bnxt_re_pd, ib_pd);
|
||||
struct bnxt_re_dev *rdev = pd->rdev;
|
||||
struct bnxt_qplib_dev_attr *dev_attr = &rdev->dev_attr;
|
||||
struct bnxt_re_qp *qp;
|
||||
struct bnxt_re_qp *qp = container_of(ib_qp, struct bnxt_re_qp, ib_qp);
|
||||
int rc;
|
||||
|
||||
rc = bnxt_re_test_qp_limits(rdev, qp_init_attr, dev_attr);
|
||||
if (!rc) {
|
||||
rc = -EINVAL;
|
||||
goto exit;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
qp = kzalloc(sizeof(*qp), GFP_KERNEL);
|
||||
if (!qp) {
|
||||
rc = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
qp->rdev = rdev;
|
||||
rc = bnxt_re_init_qp_attr(qp, pd, qp_init_attr, udata);
|
||||
if (rc)
|
||||
@@ -1465,16 +1457,14 @@ struct ib_qp *bnxt_re_create_qp(struct ib_pd *ib_pd,
|
||||
mutex_unlock(&rdev->qp_lock);
|
||||
atomic_inc(&rdev->qp_count);
|
||||
|
||||
return &qp->ib_qp;
|
||||
return 0;
|
||||
qp_destroy:
|
||||
bnxt_qplib_destroy_qp(&rdev->qplib_res, &qp->qplib_qp);
|
||||
free_umem:
|
||||
ib_umem_release(qp->rumem);
|
||||
ib_umem_release(qp->sumem);
|
||||
fail:
|
||||
kfree(qp);
|
||||
exit:
|
||||
return ERR_PTR(rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static u8 __from_ib_qp_state(enum ib_qp_state state)
|
||||
|
||||
@@ -78,9 +78,9 @@ struct bnxt_re_srq {
|
||||
};
|
||||
|
||||
struct bnxt_re_qp {
|
||||
struct ib_qp ib_qp;
|
||||
struct list_head list;
|
||||
struct bnxt_re_dev *rdev;
|
||||
struct ib_qp ib_qp;
|
||||
spinlock_t sq_lock; /* protect sq */
|
||||
spinlock_t rq_lock; /* protect rq */
|
||||
struct bnxt_qplib_qp qplib_qp;
|
||||
@@ -179,9 +179,8 @@ int bnxt_re_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
|
||||
int bnxt_re_destroy_srq(struct ib_srq *srq, struct ib_udata *udata);
|
||||
int bnxt_re_post_srq_recv(struct ib_srq *srq, const struct ib_recv_wr *recv_wr,
|
||||
const struct ib_recv_wr **bad_recv_wr);
|
||||
struct ib_qp *bnxt_re_create_qp(struct ib_pd *pd,
|
||||
struct ib_qp_init_attr *qp_init_attr,
|
||||
struct ib_udata *udata);
|
||||
int bnxt_re_create_qp(struct ib_qp *qp, struct ib_qp_init_attr *qp_init_attr,
|
||||
struct ib_udata *udata);
|
||||
int bnxt_re_modify_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
|
||||
int qp_attr_mask, struct ib_udata *udata);
|
||||
int bnxt_re_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
|
||||
|
||||
@@ -709,6 +709,7 @@ static const struct ib_device_ops bnxt_re_dev_ops = {
|
||||
INIT_RDMA_OBJ_SIZE(ib_ah, bnxt_re_ah, ib_ah),
|
||||
INIT_RDMA_OBJ_SIZE(ib_cq, bnxt_re_cq, ib_cq),
|
||||
INIT_RDMA_OBJ_SIZE(ib_pd, bnxt_re_pd, ib_pd),
|
||||
INIT_RDMA_OBJ_SIZE(ib_qp, bnxt_re_qp, ib_qp),
|
||||
INIT_RDMA_OBJ_SIZE(ib_srq, bnxt_re_srq, ib_srq),
|
||||
INIT_RDMA_OBJ_SIZE(ib_ucontext, bnxt_re_ucontext, ib_uctx),
|
||||
};
|
||||
|
||||
@@ -989,9 +989,8 @@ int c4iw_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata);
|
||||
int c4iw_create_srq(struct ib_srq *srq, struct ib_srq_init_attr *attrs,
|
||||
struct ib_udata *udata);
|
||||
int c4iw_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata);
|
||||
struct ib_qp *c4iw_create_qp(struct ib_pd *pd,
|
||||
struct ib_qp_init_attr *attrs,
|
||||
struct ib_udata *udata);
|
||||
int c4iw_create_qp(struct ib_qp *qp, struct ib_qp_init_attr *attrs,
|
||||
struct ib_udata *udata);
|
||||
int c4iw_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
|
||||
int attr_mask, struct ib_udata *udata);
|
||||
int c4iw_ib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
|
||||
|
||||
@@ -499,6 +499,7 @@ static const struct ib_device_ops c4iw_dev_ops = {
|
||||
INIT_RDMA_OBJ_SIZE(ib_cq, c4iw_cq, ibcq),
|
||||
INIT_RDMA_OBJ_SIZE(ib_mw, c4iw_mw, ibmw),
|
||||
INIT_RDMA_OBJ_SIZE(ib_pd, c4iw_pd, ibpd),
|
||||
INIT_RDMA_OBJ_SIZE(ib_qp, c4iw_qp, ibqp),
|
||||
INIT_RDMA_OBJ_SIZE(ib_srq, c4iw_srq, ibsrq),
|
||||
INIT_RDMA_OBJ_SIZE(ib_ucontext, c4iw_ucontext, ibucontext),
|
||||
};
|
||||
|
||||
@@ -2103,16 +2103,15 @@ int c4iw_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)
|
||||
ucontext ? &ucontext->uctx : &rhp->rdev.uctx, !qhp->srq);
|
||||
|
||||
c4iw_put_wr_wait(qhp->wr_waitp);
|
||||
|
||||
kfree(qhp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct ib_qp *c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attrs,
|
||||
struct ib_udata *udata)
|
||||
int c4iw_create_qp(struct ib_qp *qp, struct ib_qp_init_attr *attrs,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct ib_pd *pd = qp->pd;
|
||||
struct c4iw_dev *rhp;
|
||||
struct c4iw_qp *qhp;
|
||||
struct c4iw_qp *qhp = to_c4iw_qp(qp);
|
||||
struct c4iw_pd *php;
|
||||
struct c4iw_cq *schp;
|
||||
struct c4iw_cq *rchp;
|
||||
@@ -2124,44 +2123,36 @@ struct ib_qp *c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attrs,
|
||||
struct c4iw_mm_entry *sq_key_mm, *rq_key_mm = NULL, *sq_db_key_mm;
|
||||
struct c4iw_mm_entry *rq_db_key_mm = NULL, *ma_sync_key_mm = NULL;
|
||||
|
||||
pr_debug("ib_pd %p\n", pd);
|
||||
|
||||
if (attrs->qp_type != IB_QPT_RC || attrs->create_flags)
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
php = to_c4iw_pd(pd);
|
||||
rhp = php->rhp;
|
||||
schp = get_chp(rhp, ((struct c4iw_cq *)attrs->send_cq)->cq.cqid);
|
||||
rchp = get_chp(rhp, ((struct c4iw_cq *)attrs->recv_cq)->cq.cqid);
|
||||
if (!schp || !rchp)
|
||||
return ERR_PTR(-EINVAL);
|
||||
return -EINVAL;
|
||||
|
||||
if (attrs->cap.max_inline_data > T4_MAX_SEND_INLINE)
|
||||
return ERR_PTR(-EINVAL);
|
||||
return -EINVAL;
|
||||
|
||||
if (!attrs->srq) {
|
||||
if (attrs->cap.max_recv_wr > rhp->rdev.hw_queue.t4_max_rq_size)
|
||||
return ERR_PTR(-E2BIG);
|
||||
return -E2BIG;
|
||||
rqsize = attrs->cap.max_recv_wr + 1;
|
||||
if (rqsize < 8)
|
||||
rqsize = 8;
|
||||
}
|
||||
|
||||
if (attrs->cap.max_send_wr > rhp->rdev.hw_queue.t4_max_sq_size)
|
||||
return ERR_PTR(-E2BIG);
|
||||
return -E2BIG;
|
||||
sqsize = attrs->cap.max_send_wr + 1;
|
||||
if (sqsize < 8)
|
||||
sqsize = 8;
|
||||
|
||||
qhp = kzalloc(sizeof(*qhp), GFP_KERNEL);
|
||||
if (!qhp)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
qhp->wr_waitp = c4iw_alloc_wr_wait(GFP_KERNEL);
|
||||
if (!qhp->wr_waitp) {
|
||||
ret = -ENOMEM;
|
||||
goto err_free_qhp;
|
||||
}
|
||||
if (!qhp->wr_waitp)
|
||||
return -ENOMEM;
|
||||
|
||||
qhp->wq.sq.size = sqsize;
|
||||
qhp->wq.sq.memsize =
|
||||
@@ -2339,7 +2330,7 @@ struct ib_qp *c4iw_create_qp(struct ib_pd *pd, struct ib_qp_init_attr *attrs,
|
||||
qhp->wq.sq.qid, qhp->wq.sq.size, qhp->wq.sq.memsize,
|
||||
attrs->cap.max_send_wr, qhp->wq.rq.qid, qhp->wq.rq.size,
|
||||
qhp->wq.rq.memsize, attrs->cap.max_recv_wr);
|
||||
return &qhp->ibqp;
|
||||
return 0;
|
||||
err_free_ma_sync_key:
|
||||
kfree(ma_sync_key_mm);
|
||||
err_free_rq_db_key:
|
||||
@@ -2359,9 +2350,7 @@ err_destroy_qp:
|
||||
ucontext ? &ucontext->uctx : &rhp->rdev.uctx, !attrs->srq);
|
||||
err_free_wr_wait:
|
||||
c4iw_put_wr_wait(qhp->wr_waitp);
|
||||
err_free_qhp:
|
||||
kfree(qhp);
|
||||
return ERR_PTR(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int c4iw_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
|
||||
|
||||
@@ -132,9 +132,8 @@ int efa_query_pkey(struct ib_device *ibdev, u32 port, u16 index,
|
||||
int efa_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata);
|
||||
int efa_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata);
|
||||
int efa_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata);
|
||||
struct ib_qp *efa_create_qp(struct ib_pd *ibpd,
|
||||
struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata);
|
||||
int efa_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata);
|
||||
int efa_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata);
|
||||
int efa_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
|
||||
struct ib_udata *udata);
|
||||
|
||||
@@ -271,6 +271,7 @@ static const struct ib_device_ops efa_dev_ops = {
|
||||
INIT_RDMA_OBJ_SIZE(ib_ah, efa_ah, ibah),
|
||||
INIT_RDMA_OBJ_SIZE(ib_cq, efa_cq, ibcq),
|
||||
INIT_RDMA_OBJ_SIZE(ib_pd, efa_pd, ibpd),
|
||||
INIT_RDMA_OBJ_SIZE(ib_qp, efa_qp, ibqp),
|
||||
INIT_RDMA_OBJ_SIZE(ib_ucontext, efa_ucontext, ibucontext),
|
||||
};
|
||||
|
||||
|
||||
@@ -450,7 +450,6 @@ int efa_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
|
||||
qp->rq_size, DMA_TO_DEVICE);
|
||||
}
|
||||
|
||||
kfree(qp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -609,17 +608,16 @@ static int efa_qp_validate_attr(struct efa_dev *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct ib_qp *efa_create_qp(struct ib_pd *ibpd,
|
||||
struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata)
|
||||
int efa_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct efa_com_create_qp_params create_qp_params = {};
|
||||
struct efa_com_create_qp_result create_qp_resp;
|
||||
struct efa_dev *dev = to_edev(ibpd->device);
|
||||
struct efa_dev *dev = to_edev(ibqp->device);
|
||||
struct efa_ibv_create_qp_resp resp = {};
|
||||
struct efa_ibv_create_qp cmd = {};
|
||||
struct efa_qp *qp = to_eqp(ibqp);
|
||||
struct efa_ucontext *ucontext;
|
||||
struct efa_qp *qp;
|
||||
int err;
|
||||
|
||||
ucontext = rdma_udata_to_drv_context(udata, struct efa_ucontext,
|
||||
@@ -664,14 +662,8 @@ struct ib_qp *efa_create_qp(struct ib_pd *ibpd,
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
qp = kzalloc(sizeof(*qp), GFP_KERNEL);
|
||||
if (!qp) {
|
||||
err = -ENOMEM;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
create_qp_params.uarn = ucontext->uarn;
|
||||
create_qp_params.pd = to_epd(ibpd)->pdn;
|
||||
create_qp_params.pd = to_epd(ibqp->pd)->pdn;
|
||||
|
||||
if (init_attr->qp_type == IB_QPT_UD) {
|
||||
create_qp_params.qp_type = EFA_ADMIN_QP_TYPE_UD;
|
||||
@@ -682,7 +674,7 @@ struct ib_qp *efa_create_qp(struct ib_pd *ibpd,
|
||||
"Unsupported qp type %d driver qp type %d\n",
|
||||
init_attr->qp_type, cmd.driver_qp_type);
|
||||
err = -EOPNOTSUPP;
|
||||
goto err_free_qp;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
ibdev_dbg(&dev->ibdev, "Create QP: qp type %d driver qp type %#x\n",
|
||||
@@ -700,7 +692,7 @@ struct ib_qp *efa_create_qp(struct ib_pd *ibpd,
|
||||
qp->rq_size, DMA_TO_DEVICE);
|
||||
if (!qp->rq_cpu_addr) {
|
||||
err = -ENOMEM;
|
||||
goto err_free_qp;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
ibdev_dbg(&dev->ibdev,
|
||||
@@ -746,7 +738,7 @@ struct ib_qp *efa_create_qp(struct ib_pd *ibpd,
|
||||
|
||||
ibdev_dbg(&dev->ibdev, "Created qp[%d]\n", qp->ibqp.qp_num);
|
||||
|
||||
return &qp->ibqp;
|
||||
return 0;
|
||||
|
||||
err_remove_mmap_entries:
|
||||
efa_qp_user_mmap_entries_remove(qp);
|
||||
@@ -756,11 +748,9 @@ err_free_mapped:
|
||||
if (qp->rq_size)
|
||||
efa_free_mapped(dev, qp->rq_cpu_addr, qp->rq_dma_addr,
|
||||
qp->rq_size, DMA_TO_DEVICE);
|
||||
err_free_qp:
|
||||
kfree(qp);
|
||||
err_out:
|
||||
atomic64_inc(&dev->stats.create_qp_err);
|
||||
return ERR_PTR(err);
|
||||
return err;
|
||||
}
|
||||
|
||||
static const struct {
|
||||
|
||||
@@ -1216,9 +1216,8 @@ int hns_roce_destroy_srq(struct ib_srq *ibsrq, struct ib_udata *udata);
|
||||
int hns_roce_alloc_xrcd(struct ib_xrcd *ib_xrcd, struct ib_udata *udata);
|
||||
int hns_roce_dealloc_xrcd(struct ib_xrcd *ib_xrcd, struct ib_udata *udata);
|
||||
|
||||
struct ib_qp *hns_roce_create_qp(struct ib_pd *ib_pd,
|
||||
struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata);
|
||||
int hns_roce_create_qp(struct ib_qp *ib_qp, struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata);
|
||||
int hns_roce_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
|
||||
int attr_mask, struct ib_udata *udata);
|
||||
void init_flush_work(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp);
|
||||
|
||||
@@ -454,6 +454,7 @@ static const struct ib_device_ops hns_roce_dev_ops = {
|
||||
INIT_RDMA_OBJ_SIZE(ib_ah, hns_roce_ah, ibah),
|
||||
INIT_RDMA_OBJ_SIZE(ib_cq, hns_roce_cq, ib_cq),
|
||||
INIT_RDMA_OBJ_SIZE(ib_pd, hns_roce_pd, ibpd),
|
||||
INIT_RDMA_OBJ_SIZE(ib_qp, hns_roce_qp, ibqp),
|
||||
INIT_RDMA_OBJ_SIZE(ib_ucontext, hns_roce_ucontext, ibucontext),
|
||||
};
|
||||
|
||||
|
||||
@@ -959,8 +959,6 @@ static int set_qp_param(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
|
||||
struct ib_device *ibdev = &hr_dev->ib_dev;
|
||||
int ret;
|
||||
|
||||
hr_qp->ibqp.qp_type = init_attr->qp_type;
|
||||
|
||||
if (init_attr->cap.max_inline_data > hr_dev->caps.max_sq_inline)
|
||||
init_attr->cap.max_inline_data = hr_dev->caps.max_sq_inline;
|
||||
|
||||
@@ -1121,8 +1119,6 @@ void hns_roce_qp_destroy(struct hns_roce_dev *hr_dev, struct hns_roce_qp *hr_qp,
|
||||
free_qp_buf(hr_dev, hr_qp);
|
||||
free_kernel_wrid(hr_qp);
|
||||
free_qp_db(hr_dev, hr_qp, udata);
|
||||
|
||||
kfree(hr_qp);
|
||||
}
|
||||
|
||||
static int check_qp_type(struct hns_roce_dev *hr_dev, enum ib_qp_type type,
|
||||
@@ -1154,22 +1150,18 @@ out:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
struct ib_qp *hns_roce_create_qp(struct ib_pd *pd,
|
||||
struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata)
|
||||
int hns_roce_create_qp(struct ib_qp *qp, struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct ib_device *ibdev = pd ? pd->device : init_attr->xrcd->device;
|
||||
struct ib_device *ibdev = qp->device;
|
||||
struct hns_roce_dev *hr_dev = to_hr_dev(ibdev);
|
||||
struct hns_roce_qp *hr_qp;
|
||||
struct hns_roce_qp *hr_qp = to_hr_qp(qp);
|
||||
struct ib_pd *pd = qp->pd;
|
||||
int ret;
|
||||
|
||||
ret = check_qp_type(hr_dev, init_attr->qp_type, !!udata);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
hr_qp = kzalloc(sizeof(*hr_qp), GFP_KERNEL);
|
||||
if (!hr_qp)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
return ret;
|
||||
|
||||
if (init_attr->qp_type == IB_QPT_XRC_TGT)
|
||||
hr_qp->xrcdn = to_hr_xrcd(init_attr->xrcd)->xrcdn;
|
||||
@@ -1180,15 +1172,11 @@ struct ib_qp *hns_roce_create_qp(struct ib_pd *pd,
|
||||
}
|
||||
|
||||
ret = hns_roce_create_qp_common(hr_dev, pd, init_attr, udata, hr_qp);
|
||||
if (ret) {
|
||||
if (ret)
|
||||
ibdev_err(ibdev, "Create QP type 0x%x failed(%d)\n",
|
||||
init_attr->qp_type, ret);
|
||||
|
||||
kfree(hr_qp);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
return &hr_qp->ibqp;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int to_hr_qp_type(int qp_type)
|
||||
|
||||
@@ -1141,10 +1141,7 @@ void irdma_free_qp_rsrc(struct irdma_qp *iwqp)
|
||||
iwqp->kqp.dma_mem.va, iwqp->kqp.dma_mem.pa);
|
||||
iwqp->kqp.dma_mem.va = NULL;
|
||||
kfree(iwqp->kqp.sq_wrid_mem);
|
||||
iwqp->kqp.sq_wrid_mem = NULL;
|
||||
kfree(iwqp->kqp.rq_wrid_mem);
|
||||
iwqp->kqp.rq_wrid_mem = NULL;
|
||||
kfree(iwqp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -792,18 +792,19 @@ static int irdma_validate_qp_attrs(struct ib_qp_init_attr *init_attr,
|
||||
|
||||
/**
|
||||
* irdma_create_qp - create qp
|
||||
* @ibpd: ptr of pd
|
||||
* @ibqp: ptr of qp
|
||||
* @init_attr: attributes for qp
|
||||
* @udata: user data for create qp
|
||||
*/
|
||||
static struct ib_qp *irdma_create_qp(struct ib_pd *ibpd,
|
||||
struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata)
|
||||
static int irdma_create_qp(struct ib_qp *ibqp,
|
||||
struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata)
|
||||
{
|
||||
struct ib_pd *ibpd = ibqp->pd;
|
||||
struct irdma_pd *iwpd = to_iwpd(ibpd);
|
||||
struct irdma_device *iwdev = to_iwdev(ibpd->device);
|
||||
struct irdma_pci_f *rf = iwdev->rf;
|
||||
struct irdma_qp *iwqp;
|
||||
struct irdma_qp *iwqp = to_iwqp(ibqp);
|
||||
struct irdma_create_qp_req req;
|
||||
struct irdma_create_qp_resp uresp = {};
|
||||
u32 qp_num = 0;
|
||||
@@ -820,7 +821,7 @@ static struct ib_qp *irdma_create_qp(struct ib_pd *ibpd,
|
||||
|
||||
err_code = irdma_validate_qp_attrs(init_attr, iwdev);
|
||||
if (err_code)
|
||||
return ERR_PTR(err_code);
|
||||
return err_code;
|
||||
|
||||
sq_size = init_attr->cap.max_send_wr;
|
||||
rq_size = init_attr->cap.max_recv_wr;
|
||||
@@ -833,10 +834,6 @@ static struct ib_qp *irdma_create_qp(struct ib_pd *ibpd,
|
||||
init_info.qp_uk_init_info.max_rq_frag_cnt = init_attr->cap.max_recv_sge;
|
||||
init_info.qp_uk_init_info.max_inline_data = init_attr->cap.max_inline_data;
|
||||
|
||||
iwqp = kzalloc(sizeof(*iwqp), GFP_KERNEL);
|
||||
if (!iwqp)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
qp = &iwqp->sc_qp;
|
||||
qp->qp_uk.back_qp = iwqp;
|
||||
qp->qp_uk.lock = &iwqp->lock;
|
||||
@@ -849,10 +846,8 @@ static struct ib_qp *irdma_create_qp(struct ib_pd *ibpd,
|
||||
iwqp->q2_ctx_mem.size,
|
||||
&iwqp->q2_ctx_mem.pa,
|
||||
GFP_KERNEL);
|
||||
if (!iwqp->q2_ctx_mem.va) {
|
||||
err_code = -ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
if (!iwqp->q2_ctx_mem.va)
|
||||
return -ENOMEM;
|
||||
|
||||
init_info.q2 = iwqp->q2_ctx_mem.va;
|
||||
init_info.q2_pa = iwqp->q2_ctx_mem.pa;
|
||||
@@ -1001,17 +996,16 @@ static struct ib_qp *irdma_create_qp(struct ib_pd *ibpd,
|
||||
if (err_code) {
|
||||
ibdev_dbg(&iwdev->ibdev, "VERBS: copy_to_udata failed\n");
|
||||
irdma_destroy_qp(&iwqp->ibqp, udata);
|
||||
return ERR_PTR(err_code);
|
||||
return err_code;
|
||||
}
|
||||
}
|
||||
|
||||
init_completion(&iwqp->free_qp);
|
||||
return &iwqp->ibqp;
|
||||
return 0;
|
||||
|
||||
error:
|
||||
irdma_free_qp_rsrc(iwqp);
|
||||
|
||||
return ERR_PTR(err_code);
|
||||
return err_code;
|
||||
}
|
||||
|
||||
static int irdma_get_ib_acc_flags(struct irdma_qp *iwqp)
|
||||
@@ -4406,6 +4400,7 @@ static const struct ib_device_ops irdma_dev_ops = {
|
||||
INIT_RDMA_OBJ_SIZE(ib_ah, irdma_ah, ibah),
|
||||
INIT_RDMA_OBJ_SIZE(ib_cq, irdma_cq, ibcq),
|
||||
INIT_RDMA_OBJ_SIZE(ib_mw, irdma_mr, ibmw),
|
||||
INIT_RDMA_OBJ_SIZE(ib_qp, irdma_qp, ibqp),
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -2577,6 +2577,7 @@ static const struct ib_device_ops mlx4_ib_dev_ops = {
|
||||
INIT_RDMA_OBJ_SIZE(ib_ah, mlx4_ib_ah, ibah),
|
||||
INIT_RDMA_OBJ_SIZE(ib_cq, mlx4_ib_cq, ibcq),
|
||||
INIT_RDMA_OBJ_SIZE(ib_pd, mlx4_ib_pd, ibpd),
|
||||
INIT_RDMA_OBJ_SIZE(ib_qp, mlx4_ib_qp, ibqp),
|
||||
INIT_RDMA_OBJ_SIZE(ib_srq, mlx4_ib_srq, ibsrq),
|
||||
INIT_RDMA_OBJ_SIZE(ib_ucontext, mlx4_ib_ucontext, ibucontext),
|
||||
};
|
||||
|
||||
@@ -792,9 +792,8 @@ void mlx4_ib_free_srq_wqe(struct mlx4_ib_srq *srq, int wqe_index);
|
||||
int mlx4_ib_post_srq_recv(struct ib_srq *ibsrq, const struct ib_recv_wr *wr,
|
||||
const struct ib_recv_wr **bad_wr);
|
||||
|
||||
struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
|
||||
struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata);
|
||||
int mlx4_ib_create_qp(struct ib_qp *qp, struct ib_qp_init_attr *init_attr,
|
||||
struct ib_udata *udata);
|
||||
int mlx4_ib_destroy_qp(struct ib_qp *qp, struct ib_udata *udata);
|
||||
void mlx4_ib_drain_sq(struct ib_qp *qp);
|
||||
void mlx4_ib_drain_rq(struct ib_qp *qp);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user