public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Mustafa Ismail <mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	e1000-rdma-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [RDMA PATCH 16/16] i40iw: Adding queue drain functions
Date: Thu,  7 Apr 2016 11:31:04 -0500	[thread overview]
Message-ID: <1460046664-552-17-git-send-email-mustafa.ismail@intel.com> (raw)
In-Reply-To: <1460046664-552-1-git-send-email-mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

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: Mustafa Ismail <mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Faisal Latif <faisal.latif-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
 drivers/infiniband/hw/i40iw/i40iw_verbs.c | 38 +++++++++++++++++++++++++++++++
 drivers/infiniband/hw/i40iw/i40iw_verbs.h |  2 ++
 2 files changed, 40 insertions(+)

diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.c b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
index 9da5361..fc0bace 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_verbs.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.c
@@ -789,6 +789,8 @@ static struct ib_qp *i40iw_create_qp(struct ib_pd *ibpd,
 			return ERR_PTR(err_code);
 		}
 	}
+	init_completion(&iwqp->sq_drained);
+	init_completion(&iwqp->rq_drained);
 
 	return &iwqp->ibqp;
 error:
@@ -1582,6 +1584,32 @@ static int i40iw_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_ne
 }
 
 /**
+ * i40iw_drain_sq - drain the send queue
+ * @ibqp: ib qp pointer
+ */
+static void i40iw_drain_sq(struct ib_qp *ibqp)
+{
+	struct i40iw_qp *iwqp = to_iwqp(ibqp);
+	struct i40iw_sc_qp *qp = &iwqp->sc_qp;
+
+	if (I40IW_RING_MORE_WORK(qp->qp_uk.sq_ring))
+		wait_for_completion(&iwqp->sq_drained);
+}
+
+/**
+ * i40iw_drain_rq - drain the receive queue
+ * @ibqp: ib qp pointer
+ */
+static void i40iw_drain_rq(struct ib_qp *ibqp)
+{
+	struct i40iw_qp *iwqp = to_iwqp(ibqp);
+	struct i40iw_sc_qp *qp = &iwqp->sc_qp;
+
+	if (I40IW_RING_MORE_WORK(qp->qp_uk.rq_ring))
+		wait_for_completion(&iwqp->rq_drained);
+}
+
+/**
  * i40iw_hwreg_mr - send cqp command for memory registration
  * @iwdev: iwarp device
  * @iwmr: iwarp mr pointer
@@ -2216,6 +2244,7 @@ static int i40iw_poll_cq(struct ib_cq *ibcq,
 	enum i40iw_status_code ret;
 	struct i40iw_cq_uk *ukcq;
 	struct i40iw_sc_qp *qp;
+	struct i40iw_qp *iwqp;
 	unsigned long flags;
 
 	iwcq = (struct i40iw_cq *)ibcq;
@@ -2266,6 +2295,13 @@ static int i40iw_poll_cq(struct ib_cq *ibcq,
 		qp = (struct i40iw_sc_qp *)cq_poll_info.qp_handle;
 		entry->qp = (struct ib_qp *)qp->back_qp;
 		entry->src_qp = cq_poll_info.qp_id;
+		iwqp = (struct i40iw_qp *)qp->back_qp;
+		if (iwqp->iwarp_state > I40IW_QP_STATE_RTS) {
+			if (!I40IW_RING_MORE_WORK(qp->qp_uk.sq_ring))
+				complete(&iwqp->sq_drained);
+			if (!I40IW_RING_MORE_WORK(qp->qp_uk.rq_ring))
+				complete(&iwqp->rq_drained);
+		}
 		entry->byte_len = cq_poll_info.bytes_xfered;
 		entry++;
 		cqe_count++;
@@ -2512,6 +2548,8 @@ static struct i40iw_ib_device *i40iw_init_rdma_device(struct i40iw_device *iwdev
 	iwibdev->ibdev.query_device = i40iw_query_device;
 	iwibdev->ibdev.create_ah = i40iw_create_ah;
 	iwibdev->ibdev.destroy_ah = i40iw_destroy_ah;
+	iwibdev->ibdev.drain_sq = i40iw_drain_sq;
+	iwibdev->ibdev.drain_rq = i40iw_drain_rq;
 	iwibdev->ibdev.alloc_mr = i40iw_alloc_mr;
 	iwibdev->ibdev.map_mr_sg = i40iw_map_mr_sg;
 	iwibdev->ibdev.iwcm = kzalloc(sizeof(*iwibdev->ibdev.iwcm), GFP_KERNEL);
diff --git a/drivers/infiniband/hw/i40iw/i40iw_verbs.h b/drivers/infiniband/hw/i40iw/i40iw_verbs.h
index 0acb6c8..0069be8 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_verbs.h
+++ b/drivers/infiniband/hw/i40iw/i40iw_verbs.h
@@ -170,5 +170,7 @@ struct i40iw_qp {
 	struct i40iw_pbl *iwpbl;
 	struct i40iw_dma_mem q2_ctx_mem;
 	struct i40iw_dma_mem ietf_mem;
+	struct completion sq_drained;
+	struct completion rq_drained;
 };
 #endif
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-04-07 16:31 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-07 16:30 [RDMA PATCH 00/16] Intel X722 iWARP driver update Mustafa Ismail
     [not found] ` <1460046664-552-1-git-send-email-mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-04-07 16:30   ` [RDMA PATCH 01/16] i40iw: Fix overflow of region length Mustafa Ismail
     [not found]     ` <1460046664-552-2-git-send-email-mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-04-11  9:23       ` Leon Romanovsky
     [not found]         ` <20160411092324.GG20252-2ukJVAZIZ/Y@public.gmane.org>
2016-04-12 18:09           ` Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 02/16] i40iw: Correct QP size calculation Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 03/16] i40iw: Fix refused connections Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 04/16] i40iw: Correct max message size in query port Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 05/16] i40iw: Do not set self-referencing pointer to NULL after free Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 06/16] i40iw: Add qp table lock around AE processing Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 07/16] i40iw: Set vendor_err only if there is an actual error Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 08/16] i40iw: Populate vendor_id and vendor_part_id fields Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 09/16] i40iw: Remove unused code and fix warning Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 10/16] i40iw: Add virtual channel message queue Mustafa Ismail
2016-04-07 16:30   ` [RDMA PATCH 11/16] i40iw: Correct return code check in add_pble_pool Mustafa Ismail
2016-04-07 16:31   ` [RDMA PATCH 12/16] i40iw: Initialize max enabled vfs variable Mustafa Ismail
2016-04-07 16:31   ` [RDMA PATCH 13/16] i40iw: Add base memory management extensions Mustafa Ismail
     [not found]     ` <1460046664-552-14-git-send-email-mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-04-12 14:07       ` Christoph Hellwig
     [not found]         ` <20160412140739.GA23302-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2016-04-12 18:13           ` Mustafa Ismail
2016-04-07 16:31   ` [RDMA PATCH 14/16] i40iw: Fix endian issues and warnings Mustafa Ismail
2016-04-07 16:31   ` [RDMA PATCH 15/16] i40iw: Fix SD calculation for initial HMC creation Mustafa Ismail
2016-04-07 16:31   ` Mustafa Ismail [this message]
     [not found]     ` <1460046664-552-17-git-send-email-mustafa.ismail-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-04-08  0:46       ` [RDMA PATCH 16/16] i40iw: Adding queue drain functions Leon Romanovsky
     [not found]         ` <20160408004638.GD20252-2ukJVAZIZ/Y@public.gmane.org>
2016-04-08 18:44           ` Mustafa Ismail
2016-04-08 22:15             ` Steve Wise
2016-04-10 19:26               ` Sagi Grimberg
     [not found]                 ` <570AA8D0.2060404-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2016-04-11  4:50                   ` 'Leon Romanovsky'
2016-04-12 10:27   ` [RDMA PATCH 00/16] Intel X722 iWARP driver update Or Gerlitz
     [not found] ` <CALq1K=L4fdgLxL+-2vNfX0SUvrS9ShTgS=vDOpZyJDyK8EHB=Q@mail.gmail.com>
2016-04-12  4:33   ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460046664-552-17-git-send-email-mustafa.ismail@intel.com \
    --to=mustafa.ismail-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=e1000-rdma-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox