IB/rdmavt: Add destroy qp verb
authorDennis Dalessandro <dennis.dalessandro@intel.com>
Fri, 22 Jan 2016 21:00:42 +0000 (13:00 -0800)
committerDoug Ledford <dledford@redhat.com>
Fri, 11 Mar 2016 01:37:25 +0000 (20:37 -0500)
This patch adds in support the qp destroy verb call.

Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/sw/rdmavt/qp.c

index 94421268b84c2e2210ed1a34d1adf154cfe0e09f..cca65a6a21426b414d732bdea38af5f36dbff16c 100644 (file)
@@ -1201,13 +1201,30 @@ inval:
  */
 int rvt_destroy_qp(struct ib_qp *ibqp)
 {
-       /*
-        * VT-DRIVER-API: qp_flush()
-        * Driver provies a mechanism to flush and wait for that flush to
-        * finish.
-        */
+       struct rvt_qp *qp = ibqp_to_rvtqp(ibqp);
+       struct rvt_dev_info *rdi = ib_to_rvt(ibqp->device);
 
-       return -EOPNOTSUPP;
+       spin_lock_irq(&qp->r_lock);
+       spin_lock(&qp->s_lock);
+       rvt_reset_qp(rdi, qp, ibqp->qp_type);
+       spin_unlock(&qp->s_lock);
+       spin_unlock_irq(&qp->r_lock);
+
+       /* qpn is now available for use again */
+       rvt_free_qpn(&rdi->qp_dev->qpn_table, qp->ibqp.qp_num);
+
+       spin_lock(&rdi->n_qps_lock);
+       rdi->n_qps_allocated--;
+       spin_unlock(&rdi->n_qps_lock);
+
+       if (qp->ip)
+               kref_put(&qp->ip->ref, rvt_release_mmap_info);
+       else
+               vfree(qp->r_rq.wq);
+       vfree(qp->s_wq);
+       rdi->driver_f.qp_priv_free(rdi, qp);
+       kfree(qp);
+       return 0;
 }
 
 int rvt_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,