IB/rdmavt: Add functions to get and release QP references
authorMike Marciniszyn <mike.marciniszyn@intel.com>
Tue, 6 Sep 2016 11:34:21 +0000 (04:34 -0700)
committerDoug Ledford <dledford@redhat.com>
Fri, 16 Sep 2016 18:35:27 +0000 (14:35 -0400)
This centralizes the function and improves code readability.

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
include/rdma/rdmavt_qp.h

index bd34d0b56bf770feea3c7d4822cf8e3de8ec0fd3..2c5183ef0243e9d57f9ad2e446ddc2c2aaf072b3 100644 (file)
@@ -465,6 +465,25 @@ static inline struct rvt_rwqe *rvt_get_rwqe_ptr(struct rvt_rq *rq, unsigned n)
                  rq->max_sge * sizeof(struct ib_sge)) * n);
 }
 
+/**
+ * rvt_get_qp - get a QP reference
+ * @qp - the QP to hold
+ */
+static inline void rvt_get_qp(struct rvt_qp *qp)
+{
+       atomic_inc(&qp->refcount);
+}
+
+/**
+ * rvt_put_qp - release a QP reference
+ * @qp - the QP to release
+ */
+static inline void rvt_put_qp(struct rvt_qp *qp)
+{
+       if (qp && atomic_dec_and_test(&qp->refcount))
+               wake_up(&qp->wait);
+}
+
 /**
  * rvt_qp_wqe_reserve - reserve operation
  * @qp - the rvt qp