i40iw: Add support to make destroy QP synchronous
[linux-2.6-block.git] / drivers / infiniband / hw / i40iw / i40iw_utils.c
index 4ab8e0dcfd4caf99660965ed6f5800c5b6e5fd9f..644f8c641aa0ce58127b312ac733a3ef68e354f9 100644 (file)
@@ -477,25 +477,6 @@ void i40iw_cleanup_pending_cqp_op(struct i40iw_device *iwdev)
        }
 }
 
-/**
- * i40iw_free_qp - callback after destroy cqp completes
- * @cqp_request: cqp request for destroy qp
- * @num: not used
- */
-static void i40iw_free_qp(struct i40iw_cqp_request *cqp_request, u32 num)
-{
-       struct i40iw_sc_qp *qp = (struct i40iw_sc_qp *)cqp_request->param;
-       struct i40iw_qp *iwqp = (struct i40iw_qp *)qp->back_qp;
-       struct i40iw_device *iwdev;
-       u32 qp_num = iwqp->ibqp.qp_num;
-
-       iwdev = iwqp->iwdev;
-
-       i40iw_rem_pdusecount(iwqp->iwpd, iwdev);
-       i40iw_free_qp_resources(iwdev, iwqp, qp_num);
-       i40iw_rem_devusecount(iwdev);
-}
-
 /**
  * i40iw_wait_event - wait for completion
  * @iwdev: iwarp device
@@ -616,26 +597,23 @@ void i40iw_rem_pdusecount(struct i40iw_pd *iwpd, struct i40iw_device *iwdev)
 }
 
 /**
- * i40iw_add_ref - add refcount for qp
+ * i40iw_qp_add_ref - add refcount for qp
  * @ibqp: iqarp qp
  */
-void i40iw_add_ref(struct ib_qp *ibqp)
+void i40iw_qp_add_ref(struct ib_qp *ibqp)
 {
        struct i40iw_qp *iwqp = (struct i40iw_qp *)ibqp;
 
-       atomic_inc(&iwqp->refcount);
+       refcount_inc(&iwqp->refcount);
 }
 
 /**
- * i40iw_rem_ref - rem refcount for qp and free if 0
+ * i40iw_qp_rem_ref - rem refcount for qp and free if 0
  * @ibqp: iqarp qp
  */
-void i40iw_rem_ref(struct ib_qp *ibqp)
+void i40iw_qp_rem_ref(struct ib_qp *ibqp)
 {
        struct i40iw_qp *iwqp;
-       enum i40iw_status_code status;
-       struct i40iw_cqp_request *cqp_request;
-       struct cqp_commands_info *cqp_info;
        struct i40iw_device *iwdev;
        u32 qp_num;
        unsigned long flags;
@@ -643,7 +621,7 @@ void i40iw_rem_ref(struct ib_qp *ibqp)
        iwqp = to_iwqp(ibqp);
        iwdev = iwqp->iwdev;
        spin_lock_irqsave(&iwdev->qptable_lock, flags);
-       if (!atomic_dec_and_test(&iwqp->refcount)) {
+       if (!refcount_dec_and_test(&iwqp->refcount)) {
                spin_unlock_irqrestore(&iwdev->qptable_lock, flags);
                return;
        }
@@ -651,25 +629,8 @@ void i40iw_rem_ref(struct ib_qp *ibqp)
        qp_num = iwqp->ibqp.qp_num;
        iwdev->qp_table[qp_num] = NULL;
        spin_unlock_irqrestore(&iwdev->qptable_lock, flags);
-       cqp_request = i40iw_get_cqp_request(&iwdev->cqp, false);
-       if (!cqp_request)
-               return;
-
-       cqp_request->callback_fcn = i40iw_free_qp;
-       cqp_request->param = (void *)&iwqp->sc_qp;
-       cqp_info = &cqp_request->info;
-       cqp_info->cqp_cmd = OP_QP_DESTROY;
-       cqp_info->post_sq = 1;
-       cqp_info->in.u.qp_destroy.qp = &iwqp->sc_qp;
-       cqp_info->in.u.qp_destroy.scratch = (uintptr_t)cqp_request;
-       cqp_info->in.u.qp_destroy.remove_hash_idx = true;
-       status = i40iw_handle_cqp_op(iwdev, cqp_request);
-       if (!status)
-               return;
+       complete(&iwqp->free_qp);
 
-       i40iw_rem_pdusecount(iwqp->iwpd, iwdev);
-       i40iw_free_qp_resources(iwdev, iwqp, qp_num);
-       i40iw_rem_devusecount(iwdev);
 }
 
 /**
@@ -936,7 +897,7 @@ static void i40iw_terminate_timeout(struct timer_list *t)
        struct i40iw_sc_qp *qp = (struct i40iw_sc_qp *)&iwqp->sc_qp;
 
        i40iw_terminate_done(qp, 1);
-       i40iw_rem_ref(&iwqp->ibqp);
+       i40iw_qp_rem_ref(&iwqp->ibqp);
 }
 
 /**
@@ -948,7 +909,7 @@ void i40iw_terminate_start_timer(struct i40iw_sc_qp *qp)
        struct i40iw_qp *iwqp;
 
        iwqp = (struct i40iw_qp *)qp->back_qp;
-       i40iw_add_ref(&iwqp->ibqp);
+       i40iw_qp_add_ref(&iwqp->ibqp);
        timer_setup(&iwqp->terminate_timer, i40iw_terminate_timeout, 0);
        iwqp->terminate_timer.expires = jiffies + HZ;
        add_timer(&iwqp->terminate_timer);
@@ -964,7 +925,7 @@ void i40iw_terminate_del_timer(struct i40iw_sc_qp *qp)
 
        iwqp = (struct i40iw_qp *)qp->back_qp;
        if (del_timer(&iwqp->terminate_timer))
-               i40iw_rem_ref(&iwqp->ibqp);
+               i40iw_qp_rem_ref(&iwqp->ibqp);
 }
 
 /**