From: Cheng Xu <chengyou@linux.alibaba.com>
To: jgg@ziepe.ca, leon@kernel.org
Cc: linux-rdma@vger.kernel.org, KaiShen@linux.alibaba.com
Subject: [PATCH for-next 2/2] RDMA/erdma: Add drain_sq and drain_rq support
Date: Wed, 24 Aug 2022 17:42:51 +0800 [thread overview]
Message-ID: <20220824094251.23190-3-chengyou@linux.alibaba.com> (raw)
In-Reply-To: <20220824094251.23190-1-chengyou@linux.alibaba.com>
For erdma, hardware won't process any WRs after modifying QP state to
error, so the default __ib_drain_sq and __ib_drain_rq can not work for
erdma device. Here, we introduce custom implementation of drain_sq and
drain_rq interface to fit erdma hardware.
Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com>
---
drivers/infiniband/hw/erdma/erdma_qp.c | 71 +++++++++++++++++++++++
drivers/infiniband/hw/erdma/erdma_verbs.h | 10 ++++
2 files changed, 81 insertions(+)
diff --git a/drivers/infiniband/hw/erdma/erdma_qp.c b/drivers/infiniband/hw/erdma/erdma_qp.c
index abf8b134d076..57fdb946fbfd 100644
--- a/drivers/infiniband/hw/erdma/erdma_qp.c
+++ b/drivers/infiniband/hw/erdma/erdma_qp.c
@@ -599,3 +599,74 @@ int erdma_post_recv_nodrain(struct ib_qp *ibqp,
{
return erdma_post_recv(ibqp, recv_wr, bad_recv_wr, false);
}
+
+static void erdma_drain_qp_done(struct ib_cq *cq, struct ib_wc *wc)
+{
+ struct erdma_drain_cqe *cqe =
+ container_of(wc->wr_cqe, struct erdma_drain_cqe, cqe);
+
+ complete(&cqe->done);
+}
+
+static void erdma_drain_qp_common(struct ib_qp *ibqp, struct completion *comp,
+ struct ib_cq *ibcq)
+{
+ struct ib_qp_attr attr = { .qp_state = IB_QPS_ERR };
+ struct erdma_qp *qp = to_eqp(ibqp);
+ const struct ib_send_wr *bad_swr;
+ const struct ib_recv_wr *bad_rwr;
+ struct ib_rdma_wr swr = {
+ .wr = {
+ .next = NULL,
+ { .wr_cqe = &qp->kern_qp.sdrain.cqe, },
+ .opcode = IB_WR_RDMA_WRITE,
+ .send_flags = IB_SEND_SIGNALED,
+ },
+ };
+ struct ib_recv_wr rwr = {
+ .next = NULL,
+ .wr_cqe = &qp->kern_qp.rdrain.cqe,
+ .num_sge = 0,
+ };
+
+ if (qp->flags & ERDMA_QP_FLAGS_DRAIN_ISSUED)
+ goto wait_for_completion;
+
+ qp->flags |= ERDMA_QP_FLAGS_DRAIN_ISSUED;
+
+ qp->kern_qp.rdrain.cqe.done = erdma_drain_qp_done;
+ init_completion(&qp->kern_qp.rdrain.done);
+
+ qp->kern_qp.sdrain.cqe.done = erdma_drain_qp_done;
+ init_completion(&qp->kern_qp.sdrain.done);
+
+ if (erdma_post_recv(ibqp, &rwr, &bad_rwr, true))
+ return;
+
+ if (erdma_post_send(ibqp, &swr.wr, &bad_swr, true))
+ return;
+
+ if (ib_modify_qp(ibqp, &attr, IB_QP_STATE))
+ return;
+
+wait_for_completion:
+ if (ibcq->poll_ctx == IB_POLL_DIRECT)
+ while (wait_for_completion_timeout(comp, HZ / 10) <= 0)
+ ib_process_cq_direct(ibcq, -1);
+ else
+ wait_for_completion(comp);
+}
+
+void erdma_drain_sq(struct ib_qp *ibqp)
+{
+ struct erdma_qp *qp = to_eqp(ibqp);
+
+ erdma_drain_qp_common(ibqp, &qp->kern_qp.sdrain.done, ibqp->send_cq);
+}
+
+void erdma_drain_rq(struct ib_qp *ibqp)
+{
+ struct erdma_qp *qp = to_eqp(ibqp);
+
+ erdma_drain_qp_common(ibqp, &qp->kern_qp.rdrain.done, ibqp->recv_cq);
+}
diff --git a/drivers/infiniband/hw/erdma/erdma_verbs.h b/drivers/infiniband/hw/erdma/erdma_verbs.h
index f4148fbac878..4cec92c8a737 100644
--- a/drivers/infiniband/hw/erdma/erdma_verbs.h
+++ b/drivers/infiniband/hw/erdma/erdma_verbs.h
@@ -133,6 +133,11 @@ struct erdma_uqp {
u32 rq_offset;
};
+struct erdma_drain_cqe {
+ struct ib_cqe cqe;
+ struct completion done;
+};
+
struct erdma_kqp {
u16 sq_pi;
u16 sq_ci;
@@ -155,6 +160,9 @@ struct erdma_kqp {
void *sq_db_info;
void *rq_db_info;
+ struct erdma_drain_cqe sdrain;
+ struct erdma_drain_cqe rdrain;
+
u8 sig_all;
};
@@ -341,6 +349,8 @@ int erdma_post_send_nodrain(struct ib_qp *ibqp,
int erdma_post_recv_nodrain(struct ib_qp *ibqp,
const struct ib_recv_wr *recv_wr,
const struct ib_recv_wr **bad_recv_wr);
+void erdma_drain_sq(struct ib_qp *ibqp);
+void erdma_drain_rq(struct ib_qp *ibqp);
int erdma_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
struct ib_mr *erdma_ib_alloc_mr(struct ib_pd *ibpd, enum ib_mr_type mr_type,
u32 max_num_sg);
--
2.27.0
next prev parent reply other threads:[~2022-08-24 9:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 9:42 [PATCH for-next 0/2] RDMA/erdma: Introduce custom implementation of drain_sq and drain_rq Cheng Xu
2022-08-24 9:42 ` [PATCH for-next 1/2] RDMA/erdma: Introduce internal post_send/post_recv for qp drain Cheng Xu
2022-08-24 12:10 ` Leon Romanovsky
2022-08-24 9:42 ` Cheng Xu [this message]
2022-08-24 12:10 ` [PATCH for-next 2/2] RDMA/erdma: Add drain_sq and drain_rq support Leon Romanovsky
2022-08-25 1:59 ` Cheng Xu
2022-08-24 14:08 ` [PATCH for-next 0/2] RDMA/erdma: Introduce custom implementation of drain_sq and drain_rq Tom Talpey
2022-08-24 14:56 ` Bernard Metzler
2022-08-25 1:54 ` Cheng Xu
2022-08-25 16:37 ` Tom Talpey
2022-08-26 3:21 ` Cheng Xu
2022-08-26 13:11 ` Tom Talpey
2022-08-26 13:57 ` Jason Gunthorpe
2022-08-29 4:01 ` Cheng Xu
2022-08-30 18:45 ` Tom Talpey
2022-08-31 2:08 ` Cheng Xu
2022-08-31 2:52 ` Cheng Xu
2022-08-29 3:37 ` Cheng Xu
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=20220824094251.23190-3-chengyou@linux.alibaba.com \
--to=chengyou@linux.alibaba.com \
--cc=KaiShen@linux.alibaba.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.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