Skip to contentSkip to conversation

RDMA/rxe: Do some cleanup

PATCH Applied Xiao Yang 2 participants 6 messages Sep 30, 2021 – Oct 6, 2021

Subsystems (2)
lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

v4 cover RDMA/rxe: Do some cleanup

V3->V4:
1) Rebase on the latest for-next branch.
2) Remove [PATCH v3 1/5].
3) Update [PATCH v3 2/5] to remove the is_user members of struct rxe_sq/rxe_rq/rxe_srq.

Xiao Yang (4):
RDMA/rxe: Remove the is_user members of struct rxe_sq/rxe_rq/rxe_srq RDMA/rxe: Change the is_user member of struct rxe_cq to bool RDMA/rxe: Set partial attributes when completion status !=
IBV_WC_SUCCESS
RDMA/rxe: Remove duplicate settings

 drivers/infiniband/sw/rxe/rxe_comp.c  | 45 +++++++++++++++------------
 drivers/infiniband/sw/rxe/rxe_cq.c    |  3 +-
 drivers/infiniband/sw/rxe/rxe_qp.c    |  2 --
 drivers/infiniband/sw/rxe/rxe_resp.c  |  4 ---
 drivers/infiniband/sw/rxe/rxe_srq.c   |  1 -
 drivers/infiniband/sw/rxe/rxe_verbs.c |  3 --
 drivers/infiniband/sw/rxe/rxe_verbs.h |  5 +--
 7 files changed, 27 insertions(+), 36 deletions(-)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v4 1/4 RDMA/rxe: Remove the is_user members of struct rxe_sq/rxe_rq/rxe_srq

The is_user members of struct rxe_sq/rxe_rq/rxe_srq are unsed since commit ae6e843fe08d ("RDMA/rxe: Add memory barriers to kernel queues"). In this case, it is fine to remove them directly.

---
 drivers/infiniband/sw/rxe/rxe_qp.c    | 2 --
 drivers/infiniband/sw/rxe/rxe_srq.c   | 1 -
 drivers/infiniband/sw/rxe/rxe_verbs.c | 3 ---
 drivers/infiniband/sw/rxe/rxe_verbs.h | 3 ---
 4 files changed, 9 deletions(-)
drivers/infiniband/sw/rxe/rxe_qp.c +0 -2
index c8f4790083d2..975321812c87 100644
@@ -307,8 +307,6 @@ static int rxe_qp_init_resp(struct rxe_dev *rxe, struct rxe_qp *qp,
 	spin_lock_init(&qp->rq.producer_lock);
 	spin_lock_init(&qp->rq.consumer_lock);
 
-	qp->rq.is_user = qp->is_user;
-
 	skb_queue_head_init(&qp->resp_pkts);
 
 	rxe_init_task(rxe, &qp->resp.task, qp,
drivers/infiniband/sw/rxe/rxe_srq.c +0 -1
index a9e7817e2732..eb1c4c3b3a78 100644
@@ -86,7 +86,6 @@ int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq,
 	srq->srq_num		= srq->pelem.index;
 	srq->rq.max_wr		= init->attr.max_wr;
 	srq->rq.max_sge		= init->attr.max_sge;
-	srq->rq.is_user		= srq->is_user;
 
 	srq_wqe_size		= rcv_wqe_size(srq->rq.max_sge);
 
drivers/infiniband/sw/rxe/rxe_verbs.c +0 -3
index 9d0bb9aa7514..c49ba0381964 100644
@@ -267,9 +267,6 @@ static int rxe_create_srq(struct ib_srq *ibsrq, struct ib_srq_init_attr *init,
 		if (udata->outlen < sizeof(*uresp))
 			return -EINVAL;
 		uresp = udata->outbuf;
-		srq->is_user = true;
-	} else {
-		srq->is_user = false;
 	}
 
 	err = rxe_srq_chk_attr(rxe, NULL, &init->attr, IB_SRQ_INIT_MASK);
drivers/infiniband/sw/rxe/rxe_verbs.h +0 -3
index c807639435eb..962bb2481a28 100644
@@ -77,7 +77,6 @@ enum wqe_state {
 };
 
 struct rxe_sq {
-	bool			is_user;
 	int			max_wr;
 	int			max_sge;
 	int			max_inline;
@@ -86,7 +85,6 @@ struct rxe_sq {
 };
 
 struct rxe_rq {
-	bool			is_user;
 	int			max_wr;
 	int			max_sge;
 	spinlock_t		producer_lock; /* guard queue producer */
@@ -100,7 +98,6 @@ struct rxe_srq {
 	struct rxe_pd		*pd;
 	struct rxe_rq		rq;
 	u32			srq_num;
-	bool			is_user;
 
 	int			limit;
 	int			error;
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH v4 2/4 RDMA/rxe: Change the is_user member of struct rxe_cq to bool

In reply to Xiao Yang

Make the is_user members of struct rxe_qp/rxe_cq has the same type.

---
 drivers/infiniband/sw/rxe/rxe_cq.c    | 3 +--
 drivers/infiniband/sw/rxe/rxe_verbs.h | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/infiniband/sw/rxe/rxe_cq.c +1 -2
index 4eedaa0244b3..6848426c074f 100644
@@ -77,8 +77,7 @@ int rxe_cq_from_init(struct rxe_dev *rxe, struct rxe_cq *cq, int cqe,
 		return err;
 	}
 
-	if (uresp)
-		cq->is_user = 1;
+	cq->is_user = uresp;
 
 	cq->is_dying = false;
 
drivers/infiniband/sw/rxe/rxe_verbs.h +1 -1
index 962bb2481a28..098fde693dbd 100644
@@ -64,7 +64,7 @@ struct rxe_cq {
 	spinlock_t		cq_lock;
 	u8			notify;
 	bool			is_dying;
-	int			is_user;
+	bool			is_user;
 	struct tasklet_struct	comp_task;
 };
 
Signature · 1 line
2.25.1
author
#3 lore raw

PATCH v4 3/4 RDMA/rxe: Set partial attributes when completion status != IBV_WC_SUCCESS

In reply to Xiao Yang

As ibv_poll_cq()'s manual said, only partial attributes are valid when completion status != IBV_WC_SUCCESS.

---
 drivers/infiniband/sw/rxe/rxe_comp.c | 45 +++++++++++++++-------------
 1 file changed, 25 insertions(+), 20 deletions(-)
drivers/infiniband/sw/rxe/rxe_comp.c +25 -20
index 48a3864ada29..d771ba8449a1 100644
@@ -380,30 +380,35 @@ static inline enum comp_state do_atomic(struct rxe_qp *qp,
 static void make_send_cqe(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
 			  struct rxe_cqe *cqe)
 {
+	struct ib_wc *wc = &cqe->ibwc;
+	struct ib_uverbs_wc *uwc = &cqe->uibwc;
+
 	memset(cqe, 0, sizeof(*cqe));
 
 	if (!qp->is_user) {
-		struct ib_wc		*wc	= &cqe->ibwc;
-
-		wc->wr_id		= wqe->wr.wr_id;
-		wc->status		= wqe->status;
-		wc->opcode		= wr_to_wc_opcode(wqe->wr.opcode);
-		if (wqe->wr.opcode == IB_WR_RDMA_WRITE_WITH_IMM ||
-		    wqe->wr.opcode == IB_WR_SEND_WITH_IMM)
-			wc->wc_flags = IB_WC_WITH_IMM;
-		wc->byte_len		= wqe->dma.length;
-		wc->qp			= &qp->ibqp;
+		wc->wr_id = wqe->wr.wr_id;
+		wc->status = wqe->status;
+		wc->qp = &qp->ibqp;
 	} else {
-		struct ib_uverbs_wc	*uwc	= &cqe->uibwc;
-
-		uwc->wr_id		= wqe->wr.wr_id;
-		uwc->status		= wqe->status;
-		uwc->opcode		= wr_to_wc_opcode(wqe->wr.opcode);
-		if (wqe->wr.opcode == IB_WR_RDMA_WRITE_WITH_IMM ||
-		    wqe->wr.opcode == IB_WR_SEND_WITH_IMM)
-			uwc->wc_flags = IB_WC_WITH_IMM;
-		uwc->byte_len		= wqe->dma.length;
-		uwc->qp_num		= qp->ibqp.qp_num;
+		uwc->wr_id = wqe->wr.wr_id;
+		uwc->status = wqe->status;
+		uwc->qp_num = qp->ibqp.qp_num;
+	}
+
+	if (wqe->status == IB_WC_SUCCESS) {
+		if (!qp->is_user) {
+			wc->opcode = wr_to_wc_opcode(wqe->wr.opcode);
+			if (wqe->wr.opcode == IB_WR_RDMA_WRITE_WITH_IMM ||
+			    wqe->wr.opcode == IB_WR_SEND_WITH_IMM)
+				wc->wc_flags = IB_WC_WITH_IMM;
+			wc->byte_len = wqe->dma.length;
+		} else {
+			uwc->opcode = wr_to_wc_opcode(wqe->wr.opcode);
+			if (wqe->wr.opcode == IB_WR_RDMA_WRITE_WITH_IMM ||
+			    wqe->wr.opcode == IB_WR_SEND_WITH_IMM)
+				uwc->wc_flags = IB_WC_WITH_IMM;
+			uwc->byte_len = wqe->dma.length;
+		}
 	}
 }
 
Signature · 1 line
2.25.1
author
#4 lore raw

PATCH v4 4/4 RDMA/rxe: Remove duplicate settings

In reply to Xiao Yang

Remove duplicate settings for vendor_err and qp_num.

---
 drivers/infiniband/sw/rxe/rxe_resp.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/infiniband/sw/rxe/rxe_resp.c +0 -4
index 4af0dc95784a..e8f435fa6e4d 100644
@@ -860,7 +860,6 @@ static enum resp_states do_complete(struct rxe_qp *qp,
 		wc->opcode = (pkt->mask & RXE_IMMDT_MASK &&
 				pkt->mask & RXE_WRITE_MASK) ?
 					IB_WC_RECV_RDMA_WITH_IMM : IB_WC_RECV;
-		wc->vendor_err = 0;
 		wc->byte_len = (pkt->mask & RXE_IMMDT_MASK &&
 				pkt->mask & RXE_WRITE_MASK) ?
 					qp->resp.length : wqe->dma.length - wqe->dma.resid;
@@ -881,8 +880,6 @@ static enum resp_states do_complete(struct rxe_qp *qp,
 				uwc->ex.invalidate_rkey = ieth_rkey(pkt);
 			}
 
-			uwc->qp_num		= qp->ibqp.qp_num;
-
 			if (pkt->mask & RXE_DETH_MASK)
 				uwc->src_qp = deth_sqp(pkt);
 
@@ -914,7 +911,6 @@ static enum resp_states do_complete(struct rxe_qp *qp,
 			if (pkt->mask & RXE_DETH_MASK)
 				wc->src_qp = deth_sqp(pkt);
 
-			wc->qp			= &qp->ibqp;
 			wc->port_num		= qp->attr.port_num;
 		}
 	}
Signature · 1 line
2.25.1
maintainer Applied
#5 lore raw
In reply to Xiao Yang
Quoted 6 lines · Xiao Yang

V3->V4:
1) Rebase on the latest for-next branch.
2) Remove [PATCH v3 1/5].
3) Update [PATCH v3 2/5] to remove the is_user members of struct rxe_sq/rxe_rq/rxe_srq.

Quoted 6 lines

Xiao Yang (4):
RDMA/rxe: Remove the is_user members of struct rxe_sq/rxe_rq/rxe_srq RDMA/rxe: Change the is_user member of struct rxe_cq to bool RDMA/rxe: Set partial attributes when completion status !=
IBV_WC_SUCCESS
RDMA/rxe: Remove duplicate settings

Applied to for-next, thanks

Jason