RDMA/nes: Adding queue drain functions
authorTatyana Nikolova <Tatyana.E.Nikolova@intel.com>
Tue, 29 Mar 2016 17:58:37 +0000 (12:58 -0500)
committerDoug Ledford <dledford@redhat.com>
Fri, 13 May 2016 23:39:59 +0000 (19:39 -0400)
Adding sq and rq drain functions, which block until all
previously posted wr-s in the specified queue have completed.
A completion object is signaled to unblock the thread,
when the last cqe for the corresponding queue is processed.

Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
Signed-off-by: Faisal Latif <faisal.latif@intel.com>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/nes/nes_verbs.c
drivers/infiniband/hw/nes/nes_verbs.h

index fba69a39a7eb496cb80ae819c231917e48203c17..7394224e99b2845bf503f881384a5d7d4d904b0d 100644 (file)
@@ -1315,6 +1315,8 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
                        nes_debug(NES_DBG_QP, "Invalid QP type: %d\n", init_attr->qp_type);
                        return ERR_PTR(-EINVAL);
        }
+       init_completion(&nesqp->sq_drained);
+       init_completion(&nesqp->rq_drained);
 
        nesqp->sig_all = (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR);
        init_timer(&nesqp->terminate_timer);
@@ -3452,6 +3454,29 @@ out:
        return err;
 }
 
+/**
+ * nes_drain_sq - drain sq
+ * @ibqp: pointer to ibqp
+ */
+static void nes_drain_sq(struct ib_qp *ibqp)
+{
+       struct nes_qp *nesqp = to_nesqp(ibqp);
+
+       if (nesqp->hwqp.sq_tail != nesqp->hwqp.sq_head)
+               wait_for_completion(&nesqp->sq_drained);
+}
+
+/**
+ * nes_drain_rq - drain rq
+ * @ibqp: pointer to ibqp
+ */
+static void nes_drain_rq(struct ib_qp *ibqp)
+{
+       struct nes_qp *nesqp = to_nesqp(ibqp);
+
+       if (nesqp->hwqp.rq_tail != nesqp->hwqp.rq_head)
+               wait_for_completion(&nesqp->rq_drained);
+}
 
 /**
  * nes_poll_cq
@@ -3582,6 +3607,13 @@ static int nes_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry)
                                }
                        }
 
+                       if (nesqp->iwarp_state > NES_CQP_QP_IWARP_STATE_RTS) {
+                               if (nesqp->hwqp.sq_tail == nesqp->hwqp.sq_head)
+                                       complete(&nesqp->sq_drained);
+                               if (nesqp->hwqp.rq_tail == nesqp->hwqp.rq_head)
+                                       complete(&nesqp->rq_drained);
+                       }
+
                        entry->wr_id = wrid;
                        entry++;
                        cqe_count++;
@@ -3754,6 +3786,8 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev)
        nesibdev->ibdev.req_notify_cq = nes_req_notify_cq;
        nesibdev->ibdev.post_send = nes_post_send;
        nesibdev->ibdev.post_recv = nes_post_recv;
+       nesibdev->ibdev.drain_sq = nes_drain_sq;
+       nesibdev->ibdev.drain_rq = nes_drain_rq;
 
        nesibdev->ibdev.iwcm = kzalloc(sizeof(*nesibdev->ibdev.iwcm), GFP_KERNEL);
        if (nesibdev->ibdev.iwcm == NULL) {
index 70290883d06769f3eee19ed4b36750808c2fa3d8..e02a5662dc209738a640b8793f0f9cafd9d180ce 100644 (file)
@@ -189,6 +189,8 @@ struct nes_qp {
        u8                    pau_pending;
        u8                    pau_state;
        __u64                 nesuqp_addr;
+       struct completion     sq_drained;
+       struct completion     rq_drained;
 };
 
 struct ib_mr *nes_reg_phys_mr(struct ib_pd *ib_pd,