Commit b6014f9e authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Jason Gunthorpe

qedr: Convert qpidr to XArray

Signed-off-by: default avatarMatthew Wilcox <willy@infradead.org>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 0ee3b915
...@@ -364,8 +364,7 @@ static int qedr_alloc_resources(struct qedr_dev *dev) ...@@ -364,8 +364,7 @@ static int qedr_alloc_resources(struct qedr_dev *dev)
spin_lock_init(&dev->sgid_lock); spin_lock_init(&dev->sgid_lock);
if (IS_IWARP(dev)) { if (IS_IWARP(dev)) {
spin_lock_init(&dev->qpidr.idr_lock); xa_init_flags(&dev->qps, XA_FLAGS_LOCK_IRQ);
idr_init(&dev->qpidr.idr);
dev->iwarp_wq = create_singlethread_workqueue("qedr_iwarpq"); dev->iwarp_wq = create_singlethread_workqueue("qedr_iwarpq");
} }
......
...@@ -171,7 +171,7 @@ struct qedr_dev { ...@@ -171,7 +171,7 @@ struct qedr_dev {
struct qedr_cq *gsi_rqcq; struct qedr_cq *gsi_rqcq;
struct qedr_qp *gsi_qp; struct qedr_qp *gsi_qp;
enum qed_rdma_type rdma_type; enum qed_rdma_type rdma_type;
struct qedr_idr qpidr; struct xarray qps;
struct qedr_idr srqidr; struct qedr_idr srqidr;
struct workqueue_struct *iwarp_wq; struct workqueue_struct *iwarp_wq;
u16 iwarp_max_mtu; u16 iwarp_max_mtu;
......
...@@ -491,7 +491,7 @@ int qedr_iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) ...@@ -491,7 +491,7 @@ int qedr_iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
int rc = 0; int rc = 0;
int i; int i;
qp = idr_find(&dev->qpidr.idr, conn_param->qpn); qp = xa_load(&dev->qps, conn_param->qpn);
if (unlikely(!qp)) if (unlikely(!qp))
return -EINVAL; return -EINVAL;
...@@ -681,7 +681,7 @@ int qedr_iw_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) ...@@ -681,7 +681,7 @@ int qedr_iw_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
DP_DEBUG(dev, QEDR_MSG_IWARP, "Accept on qpid=%d\n", conn_param->qpn); DP_DEBUG(dev, QEDR_MSG_IWARP, "Accept on qpid=%d\n", conn_param->qpn);
qp = idr_find(&dev->qpidr.idr, conn_param->qpn); qp = xa_load(&dev->qps, conn_param->qpn);
if (!qp) { if (!qp) {
DP_ERR(dev, "Invalid QP number %d\n", conn_param->qpn); DP_ERR(dev, "Invalid QP number %d\n", conn_param->qpn);
return -EINVAL; return -EINVAL;
...@@ -739,9 +739,7 @@ void qedr_iw_qp_rem_ref(struct ib_qp *ibqp) ...@@ -739,9 +739,7 @@ void qedr_iw_qp_rem_ref(struct ib_qp *ibqp)
struct qedr_qp *qp = get_qedr_qp(ibqp); struct qedr_qp *qp = get_qedr_qp(ibqp);
if (atomic_dec_and_test(&qp->refcnt)) { if (atomic_dec_and_test(&qp->refcnt)) {
spin_lock_irq(&qp->dev->qpidr.idr_lock); xa_erase_irq(&qp->dev->qps, qp->qp_id);
idr_remove(&qp->dev->qpidr.idr, qp->qp_id);
spin_unlock_irq(&qp->dev->qpidr.idr_lock);
kfree(qp); kfree(qp);
} }
} }
...@@ -750,5 +748,5 @@ struct ib_qp *qedr_iw_get_qp(struct ib_device *ibdev, int qpn) ...@@ -750,5 +748,5 @@ struct ib_qp *qedr_iw_get_qp(struct ib_device *ibdev, int qpn)
{ {
struct qedr_dev *dev = get_qedr_dev(ibdev); struct qedr_dev *dev = get_qedr_dev(ibdev);
return idr_find(&dev->qpidr.idr, qpn); return xa_load(&dev->qps, qpn);
} }
...@@ -1988,7 +1988,7 @@ struct ib_qp *qedr_create_qp(struct ib_pd *ibpd, ...@@ -1988,7 +1988,7 @@ struct ib_qp *qedr_create_qp(struct ib_pd *ibpd,
qp->ibqp.qp_num = qp->qp_id; qp->ibqp.qp_num = qp->qp_id;
if (rdma_protocol_iwarp(&dev->ibdev, 1)) { if (rdma_protocol_iwarp(&dev->ibdev, 1)) {
rc = qedr_idr_add(dev, &dev->qpidr, qp, qp->qp_id); rc = xa_insert_irq(&dev->qps, qp->qp_id, qp, GFP_KERNEL);
if (rc) if (rc)
goto err; goto err;
} }
...@@ -2564,7 +2564,7 @@ int qedr_destroy_qp(struct ib_qp *ibqp) ...@@ -2564,7 +2564,7 @@ int qedr_destroy_qp(struct ib_qp *ibqp)
if (atomic_dec_and_test(&qp->refcnt) && if (atomic_dec_and_test(&qp->refcnt) &&
rdma_protocol_iwarp(&dev->ibdev, 1)) { rdma_protocol_iwarp(&dev->ibdev, 1)) {
qedr_idr_remove(dev, &dev->qpidr, qp->qp_id); xa_erase_irq(&dev->qps, qp->qp_id);
kfree(qp); kfree(qp);
} }
return rc; return rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment