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

cxgb3: Convert qpidr to XArray

Signed-off-by: default avatarMatthew Wilcox <willy@infradead.org>
Acked-by: default avatarSteve Wise <swise@opengridcomputing.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent a2f40971
...@@ -62,37 +62,30 @@ struct cxgb3_client t3c_client = { ...@@ -62,37 +62,30 @@ struct cxgb3_client t3c_client = {
static LIST_HEAD(dev_list); static LIST_HEAD(dev_list);
static DEFINE_MUTEX(dev_mutex); static DEFINE_MUTEX(dev_mutex);
static int disable_qp_db(int id, void *p, void *data)
{
struct iwch_qp *qhp = p;
cxio_disable_wq_db(&qhp->wq);
return 0;
}
static int enable_qp_db(int id, void *p, void *data)
{
struct iwch_qp *qhp = p;
if (data)
ring_doorbell(qhp->rhp->rdev.ctrl_qp.doorbell, qhp->wq.qpid);
cxio_enable_wq_db(&qhp->wq);
return 0;
}
static void disable_dbs(struct iwch_dev *rnicp) static void disable_dbs(struct iwch_dev *rnicp)
{ {
spin_lock_irq(&rnicp->lock); unsigned long index;
idr_for_each(&rnicp->qpidr, disable_qp_db, NULL); struct iwch_qp *qhp;
spin_unlock_irq(&rnicp->lock);
xa_lock_irq(&rnicp->qps);
xa_for_each(&rnicp->qps, index, qhp)
cxio_disable_wq_db(&qhp->wq);
xa_unlock_irq(&rnicp->qps);
} }
static void enable_dbs(struct iwch_dev *rnicp, int ring_db) static void enable_dbs(struct iwch_dev *rnicp, int ring_db)
{ {
spin_lock_irq(&rnicp->lock); unsigned long index;
idr_for_each(&rnicp->qpidr, enable_qp_db, struct iwch_qp *qhp;
(void *)(unsigned long)ring_db);
spin_unlock_irq(&rnicp->lock); xa_lock_irq(&rnicp->qps);
xa_for_each(&rnicp->qps, index, qhp) {
if (ring_db)
ring_doorbell(qhp->rhp->rdev.ctrl_qp.doorbell,
qhp->wq.qpid);
cxio_enable_wq_db(&qhp->wq);
}
xa_unlock_irq(&rnicp->qps);
} }
static void iwch_db_drop_task(struct work_struct *work) static void iwch_db_drop_task(struct work_struct *work)
...@@ -106,7 +99,7 @@ static void rnic_init(struct iwch_dev *rnicp) ...@@ -106,7 +99,7 @@ static void rnic_init(struct iwch_dev *rnicp)
{ {
pr_debug("%s iwch_dev %p\n", __func__, rnicp); pr_debug("%s iwch_dev %p\n", __func__, rnicp);
xa_init_flags(&rnicp->cqs, XA_FLAGS_LOCK_IRQ); xa_init_flags(&rnicp->cqs, XA_FLAGS_LOCK_IRQ);
idr_init(&rnicp->qpidr); xa_init_flags(&rnicp->qps, XA_FLAGS_LOCK_IRQ);
idr_init(&rnicp->mmidr); idr_init(&rnicp->mmidr);
spin_lock_init(&rnicp->lock); spin_lock_init(&rnicp->lock);
INIT_DELAYED_WORK(&rnicp->db_drop_task, iwch_db_drop_task); INIT_DELAYED_WORK(&rnicp->db_drop_task, iwch_db_drop_task);
...@@ -191,7 +184,7 @@ static void close_rnic_dev(struct t3cdev *tdev) ...@@ -191,7 +184,7 @@ static void close_rnic_dev(struct t3cdev *tdev)
iwch_unregister_device(dev); iwch_unregister_device(dev);
cxio_rdev_close(&dev->rdev); cxio_rdev_close(&dev->rdev);
WARN_ON(!xa_empty(&dev->cqs)); WARN_ON(!xa_empty(&dev->cqs));
idr_destroy(&dev->qpidr); WARN_ON(!xa_empty(&dev->qps));
idr_destroy(&dev->mmidr); idr_destroy(&dev->mmidr);
ib_dealloc_device(&dev->ibdev); ib_dealloc_device(&dev->ibdev);
break; break;
......
...@@ -107,7 +107,7 @@ struct iwch_dev { ...@@ -107,7 +107,7 @@ struct iwch_dev {
u32 device_cap_flags; u32 device_cap_flags;
struct iwch_rnic_attributes attr; struct iwch_rnic_attributes attr;
struct xarray cqs; struct xarray cqs;
struct idr qpidr; struct xarray qps;
struct idr mmidr; struct idr mmidr;
spinlock_t lock; spinlock_t lock;
struct list_head entry; struct list_head entry;
...@@ -141,7 +141,7 @@ static inline struct iwch_cq *get_chp(struct iwch_dev *rhp, u32 cqid) ...@@ -141,7 +141,7 @@ static inline struct iwch_cq *get_chp(struct iwch_dev *rhp, u32 cqid)
static inline struct iwch_qp *get_qhp(struct iwch_dev *rhp, u32 qpid) static inline struct iwch_qp *get_qhp(struct iwch_dev *rhp, u32 qpid)
{ {
return idr_find(&rhp->qpidr, qpid); return xa_load(&rhp->qps, qpid);
} }
static inline struct iwch_mr *get_mhp(struct iwch_dev *rhp, u32 mmid) static inline struct iwch_mr *get_mhp(struct iwch_dev *rhp, u32 mmid)
......
...@@ -48,14 +48,14 @@ static void post_qp_event(struct iwch_dev *rnicp, struct iwch_cq *chp, ...@@ -48,14 +48,14 @@ static void post_qp_event(struct iwch_dev *rnicp, struct iwch_cq *chp,
struct iwch_qp *qhp; struct iwch_qp *qhp;
unsigned long flag; unsigned long flag;
spin_lock(&rnicp->lock); xa_lock(&rnicp->qps);
qhp = get_qhp(rnicp, CQE_QPID(rsp_msg->cqe)); qhp = xa_load(&rnicp->qps, CQE_QPID(rsp_msg->cqe));
if (!qhp) { if (!qhp) {
pr_err("%s unaffiliated error 0x%x qpid 0x%x\n", pr_err("%s unaffiliated error 0x%x qpid 0x%x\n",
__func__, CQE_STATUS(rsp_msg->cqe), __func__, CQE_STATUS(rsp_msg->cqe),
CQE_QPID(rsp_msg->cqe)); CQE_QPID(rsp_msg->cqe));
spin_unlock(&rnicp->lock); xa_unlock(&rnicp->qps);
return; return;
} }
...@@ -65,7 +65,7 @@ static void post_qp_event(struct iwch_dev *rnicp, struct iwch_cq *chp, ...@@ -65,7 +65,7 @@ static void post_qp_event(struct iwch_dev *rnicp, struct iwch_cq *chp,
__func__, __func__,
qhp->attr.state, qhp->wq.qpid, qhp->attr.state, qhp->wq.qpid,
CQE_STATUS(rsp_msg->cqe)); CQE_STATUS(rsp_msg->cqe));
spin_unlock(&rnicp->lock); xa_unlock(&rnicp->qps);
return; return;
} }
...@@ -76,7 +76,7 @@ static void post_qp_event(struct iwch_dev *rnicp, struct iwch_cq *chp, ...@@ -76,7 +76,7 @@ static void post_qp_event(struct iwch_dev *rnicp, struct iwch_cq *chp,
CQE_WRID_HI(rsp_msg->cqe), CQE_WRID_LOW(rsp_msg->cqe)); CQE_WRID_HI(rsp_msg->cqe), CQE_WRID_LOW(rsp_msg->cqe));
atomic_inc(&qhp->refcnt); atomic_inc(&qhp->refcnt);
spin_unlock(&rnicp->lock); xa_unlock(&rnicp->qps);
if (qhp->attr.state == IWCH_QP_STATE_RTS) { if (qhp->attr.state == IWCH_QP_STATE_RTS) {
attrs.next_state = IWCH_QP_STATE_TERMINATE; attrs.next_state = IWCH_QP_STATE_TERMINATE;
...@@ -114,21 +114,21 @@ void iwch_ev_dispatch(struct cxio_rdev *rdev_p, struct sk_buff *skb) ...@@ -114,21 +114,21 @@ void iwch_ev_dispatch(struct cxio_rdev *rdev_p, struct sk_buff *skb)
unsigned long flag; unsigned long flag;
rnicp = (struct iwch_dev *) rdev_p->ulp; rnicp = (struct iwch_dev *) rdev_p->ulp;
spin_lock(&rnicp->lock); xa_lock(&rnicp->qps);
chp = get_chp(rnicp, cqid); chp = get_chp(rnicp, cqid);
qhp = get_qhp(rnicp, CQE_QPID(rsp_msg->cqe)); qhp = xa_load(&rnicp->qps, CQE_QPID(rsp_msg->cqe));
if (!chp || !qhp) { if (!chp || !qhp) {
pr_err("BAD AE cqid 0x%x qpid 0x%x opcode %d status 0x%x type %d wrid.hi 0x%x wrid.lo 0x%x\n", pr_err("BAD AE cqid 0x%x qpid 0x%x opcode %d status 0x%x type %d wrid.hi 0x%x wrid.lo 0x%x\n",
cqid, CQE_QPID(rsp_msg->cqe), cqid, CQE_QPID(rsp_msg->cqe),
CQE_OPCODE(rsp_msg->cqe), CQE_STATUS(rsp_msg->cqe), CQE_OPCODE(rsp_msg->cqe), CQE_STATUS(rsp_msg->cqe),
CQE_TYPE(rsp_msg->cqe), CQE_WRID_HI(rsp_msg->cqe), CQE_TYPE(rsp_msg->cqe), CQE_WRID_HI(rsp_msg->cqe),
CQE_WRID_LOW(rsp_msg->cqe)); CQE_WRID_LOW(rsp_msg->cqe));
spin_unlock(&rnicp->lock); xa_unlock(&rnicp->qps);
goto out; goto out;
} }
iwch_qp_add_ref(&qhp->ibqp); iwch_qp_add_ref(&qhp->ibqp);
atomic_inc(&chp->refcnt); atomic_inc(&chp->refcnt);
spin_unlock(&rnicp->lock); xa_unlock(&rnicp->qps);
/* /*
* 1) completion of our sending a TERMINATE. * 1) completion of our sending a TERMINATE.
......
...@@ -756,7 +756,7 @@ static int iwch_destroy_qp(struct ib_qp *ib_qp) ...@@ -756,7 +756,7 @@ static int iwch_destroy_qp(struct ib_qp *ib_qp)
iwch_modify_qp(rhp, qhp, IWCH_QP_ATTR_NEXT_STATE, &attrs, 0); iwch_modify_qp(rhp, qhp, IWCH_QP_ATTR_NEXT_STATE, &attrs, 0);
wait_event(qhp->wait, !qhp->ep); wait_event(qhp->wait, !qhp->ep);
remove_handle(rhp, &rhp->qpidr, qhp->wq.qpid); xa_erase_irq(&rhp->qps, qhp->wq.qpid);
atomic_dec(&qhp->refcnt); atomic_dec(&qhp->refcnt);
wait_event(qhp->wait, !atomic_read(&qhp->refcnt)); wait_event(qhp->wait, !atomic_read(&qhp->refcnt));
...@@ -872,7 +872,7 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd, ...@@ -872,7 +872,7 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd,
init_waitqueue_head(&qhp->wait); init_waitqueue_head(&qhp->wait);
atomic_set(&qhp->refcnt, 1); atomic_set(&qhp->refcnt, 1);
if (insert_handle(rhp, &rhp->qpidr, qhp, qhp->wq.qpid)) { if (xa_store_irq(&rhp->qps, qhp->wq.qpid, qhp, GFP_KERNEL)) {
cxio_destroy_qp(&rhp->rdev, &qhp->wq, cxio_destroy_qp(&rhp->rdev, &qhp->wq,
ucontext ? &ucontext->uctx : &rhp->rdev.uctx); ucontext ? &ucontext->uctx : &rhp->rdev.uctx);
kfree(qhp); kfree(qhp);
......
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