RE: [PATCH v2 rdma-next 1/3] qedr: Add wrapping generic structure for qpidr and adjust idr routines.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Sent: Monday, July 9, 2018 8:01 PM
> To: Bason, Yuval <Yuval.Bason@xxxxxxxxxx>
> On Sun, Jul 08, 2018 at 04:59:49PM +0300, Yuval Bason wrote:
> > Today, we are using idr mechanism for QP's only.
> > This patch prepares the qedr_idr stuctures and the idr routines for
> > both QP's and SRQ's.
> >
> > Signed-off-by: Michal Kalderon <michal.kalderon@xxxxxxxxxx>
> > Signed-off-by: Yuval Bason <yuval.bason@xxxxxxxxxx>
> >  drivers/infiniband/hw/qedr/main.c       |  4 ++--
> >  drivers/infiniband/hw/qedr/qedr.h       |  8 ++++++--
> >  drivers/infiniband/hw/qedr/qedr_iw_cm.c | 12 +++++------
> >  drivers/infiniband/hw/qedr/verbs.c      | 36 ++++++++++++++++------------
> -----
> >  4 files changed, 31 insertions(+), 29 deletions(-)
> >
> > diff --git a/drivers/infiniband/hw/qedr/main.c
> > b/drivers/infiniband/hw/qedr/main.c
> > index ad22b32..912a0ca 100644
> > +++ b/drivers/infiniband/hw/qedr/main.c
> > @@ -325,8 +325,8 @@ static int qedr_alloc_resources(struct qedr_dev
> *dev)
> >       spin_lock_init(&dev->sgid_lock);
> >
> >       if (IS_IWARP(dev)) {
> > -             spin_lock_init(&dev->idr_lock);
> > -             idr_init(&dev->qpidr);
> > +             spin_lock_init(&dev->qpidr.idr_lock);
> > +             idr_init(&dev->qpidr.idr);
> >               dev->iwarp_wq =
> create_singlethread_workqueue("qedr_iwarpq");
> >       }
> >
> > diff --git a/drivers/infiniband/hw/qedr/qedr.h
> > b/drivers/infiniband/hw/qedr/qedr.h
> > index 86d4511..5d0b75e 100644
> > +++ b/drivers/infiniband/hw/qedr/qedr.h
> > @@ -122,6 +122,11 @@ struct qedr_device_attr {
> >
> >  #define QEDR_ENET_STATE_BIT  (0)
> >
> > +struct qedr_idr {
> > +     spinlock_t idr_lock; /* Protect idr data-structure */
> > +     struct idr idr;
> > +};
> > +
> >  struct qedr_dev {
> >       struct ib_device        ibdev;
> >       struct qed_dev          *cdev;
> > @@ -165,8 +170,7 @@ struct qedr_dev {
> >       struct qedr_cq          *gsi_rqcq;
> >       struct qedr_qp          *gsi_qp;
> >       enum qed_rdma_type      rdma_type;
> > -     spinlock_t              idr_lock; /* Protect qpidr data-structure */
> > -     struct idr              qpidr;
> > +     struct qedr_idr         qpidr;
> >       struct workqueue_struct *iwarp_wq;
> >       u16                     iwarp_max_mtu;
> >
> > diff --git a/drivers/infiniband/hw/qedr/qedr_iw_cm.c
> > b/drivers/infiniband/hw/qedr/qedr_iw_cm.c
> > index 26dc374..505fa36 100644
> > +++ b/drivers/infiniband/hw/qedr/qedr_iw_cm.c
> > @@ -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 i;
> >
> > -     qp = idr_find(&dev->qpidr, conn_param->qpn);
> > +     qp = idr_find(&dev->qpidr.idr, conn_param->qpn);
> >
> >       laddr = (struct sockaddr_in *)&cm_id->m_local_addr;
> >       raddr = (struct sockaddr_in *)&cm_id->m_remote_addr; @@ -679,7
> > +679,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);
> >
> > -     qp = idr_find(&dev->qpidr, conn_param->qpn);
> > +     qp = idr_find(&dev->qpidr.idr, conn_param->qpn);
> >       if (!qp) {
> >               DP_ERR(dev, "Invalid QP number %d\n", conn_param->qpn);
> >               return -EINVAL;
> > @@ -737,9 +737,9 @@ void qedr_iw_qp_rem_ref(struct ib_qp *ibqp)
> >       struct qedr_qp *qp = get_qedr_qp(ibqp);
> >
> >       if (atomic_dec_and_test(&qp->refcnt)) {
> > -             spin_lock_irq(&qp->dev->idr_lock);
> > -             idr_remove(&qp->dev->qpidr, qp->qp_id);
> > -             spin_unlock_irq(&qp->dev->idr_lock);
> > +             spin_lock_irq(&qp->dev->qpidr.idr_lock);
> > +             idr_remove(&qp->dev->qpidr.idr, qp->qp_id);
> > +             spin_unlock_irq(&qp->dev->qpidr.idr_lock);
> >               kfree(qp);
> >       }
> >  }
> > @@ -748,5 +748,5 @@ struct ib_qp *qedr_iw_get_qp(struct ib_device
> > *ibdev, int qpn)  {
> >       struct qedr_dev *dev = get_qedr_dev(ibdev);
> >
> > -     return idr_find(&dev->qpidr, qpn);
> > +     return idr_find(&dev->qpidr.idr, qpn);
> >  }
> > diff --git a/drivers/infiniband/hw/qedr/verbs.c
> > b/drivers/infiniband/hw/qedr/verbs.c
> > index 0c41d54..d5c31f4 100644
> > +++ b/drivers/infiniband/hw/qedr/verbs.c
> > @@ -1311,32 +1311,27 @@ static inline void qedr_qp_user_print(struct
> qedr_dev *dev, struct qedr_qp *qp)
> >                qp->usq.buf_len, qp->urq.buf_addr, qp->urq.buf_len);  }
> >
> > -static int qedr_idr_add(struct qedr_dev *dev, void *ptr, u32 id)
> > +static int qedr_idr_add(struct qedr_dev *dev, struct qedr_idr *qidr,
> > +                     void *ptr, u32 id)
> >  {
> >       int rc;
> >
> > -     if (!rdma_protocol_iwarp(&dev->ibdev, 1))
> > -             return 0;
> > -
> >       idr_preload(GFP_KERNEL);
> > -     spin_lock_irq(&dev->idr_lock);
> > +     spin_lock_irq(&qidr->idr_lock);
> >
> > -     rc = idr_alloc(&dev->qpidr, ptr, id, id + 1, GFP_ATOMIC);
> > +     rc = idr_alloc(&qidr->idr, ptr, id, id + 1, GFP_ATOMIC);
> >
> > -     spin_unlock_irq(&dev->idr_lock);
> > +     spin_unlock_irq(&qidr->idr_lock);
> >       idr_preload_end();
> >
> >       return rc < 0 ? rc : 0;
> >  }
> >
> > -static void qedr_idr_remove(struct qedr_dev *dev, u32 id)
> > +static void qedr_idr_remove(struct qedr_dev *dev, struct qedr_idr
> > +*qidr, u32 id)
> >  {
> > -     if (!rdma_protocol_iwarp(&dev->ibdev, 1))
> > -             return;
> > -
> > -     spin_lock_irq(&dev->idr_lock);
> > -     idr_remove(&dev->qpidr, id);
> > -     spin_unlock_irq(&dev->idr_lock);
> > +     spin_lock_irq(&qidr->idr_lock);
> > +     idr_remove(&qidr->idr, id);
> > +     spin_unlock_irq(&qidr->idr_lock);
> >  }
> >
> >  static inline void
> > @@ -1708,9 +1703,11 @@ struct ib_qp *qedr_create_qp(struct ib_pd
> > *ibpd,
> >
> >       qp->ibqp.qp_num = qp->qp_id;
> >
> > -     rc = qedr_idr_add(dev, qp, qp->qp_id);
> > -     if (rc)
> > -             goto err;
> > +     if (rdma_protocol_iwarp(&dev->ibdev, 1)) {
> > +             rc = qedr_idr_add(dev, &dev->qpidr, qp, qp->qp_id);
> > +             if (rc)
> > +                     goto err;
> > +     }
> >
> >       return &qp->ibqp;
> >
> > @@ -2279,8 +2276,9 @@ int qedr_destroy_qp(struct ib_qp *ibqp)
> >
> >       qedr_free_qp_resources(dev, qp);
> >
> > -     if (atomic_dec_and_test(&qp->refcnt)) {
> > -             qedr_idr_remove(dev, qp->qp_id);
> > +     if (atomic_dec_and_test(&qp->refcnt) &&
> > +         rdma_protocol_iwarp(&dev->ibdev, 1)) {
> 
> Please send a cleanup patch to use refcount_t for this stuff?
Do you mean as part of this patch series?
> 
> Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux