public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Bob Pearson <rpearsonhpe@gmail.com>
To: jgg@nvidia.com, leon@kernel.org, zyjzyj2000@gmail.com,
	jhack@hpe.com, linux-rdma@vger.kernel.org
Cc: Bob Pearson <rpearsonhpe@gmail.com>
Subject: [PATCH for-next 14/17] RDMA/rxe: Extend response packets for frags
Date: Thu, 27 Oct 2022 13:55:08 -0500	[thread overview]
Message-ID: <20221027185510.33808-15-rpearsonhpe@gmail.com> (raw)
In-Reply-To: <20221027185510.33808-1-rpearsonhpe@gmail.com>

Extend prepare_ack_packet(), read_reply() and send_common_ack() in
rxe_resp.c to support fragmented skbs.  Adjust calls to these routines
for the changed API.

This is in preparation for using fragmented skbs.

Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
---
 drivers/infiniband/sw/rxe/rxe_resp.c | 89 +++++++++++++++++-----------
 1 file changed, 54 insertions(+), 35 deletions(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c
index 8868415b71b6..79dcd0f37140 100644
--- a/drivers/infiniband/sw/rxe/rxe_resp.c
+++ b/drivers/infiniband/sw/rxe/rxe_resp.c
@@ -660,10 +660,8 @@ static enum resp_states atomic_reply(struct rxe_qp *qp,
 
 static struct sk_buff *prepare_ack_packet(struct rxe_qp *qp,
 					  struct rxe_pkt_info *ack,
-					  int opcode,
-					  int payload,
-					  u32 psn,
-					  u8 syndrome)
+					  int opcode, int payload, u32 psn,
+					  u8 syndrome, bool *fragp)
 {
 	struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
 	struct sk_buff *skb;
@@ -682,7 +680,7 @@ static struct sk_buff *prepare_ack_packet(struct rxe_qp *qp,
 	ack->psn = psn;
 	ack->port_num = 1;
 
-	skb = rxe_init_packet(qp, &qp->pri_av, ack, NULL);
+	skb = rxe_init_packet(qp, &qp->pri_av, ack, fragp);
 	if (!skb)
 		return NULL;
 
@@ -698,12 +696,14 @@ static struct sk_buff *prepare_ack_packet(struct rxe_qp *qp,
 		atmack_set_orig(ack, qp->resp.res->atomic.orig_val);
 
 	err = rxe_prepare(&qp->pri_av, ack, skb);
-	if (err) {
-		kfree_skb(skb);
-		return NULL;
-	}
+	if (err)
+		goto err_free_skb;
 
 	return skb;
+
+err_free_skb:
+	kfree_skb(skb);
+	return NULL;
 }
 
 /**
@@ -775,6 +775,8 @@ static enum resp_states read_reply(struct rxe_qp *qp,
 	struct resp_res *res = qp->resp.res;
 	struct rxe_mr *mr;
 	int skb_offset = 0;
+	bool frag;
+	enum rxe_mr_copy_op op;
 
 	if (!res) {
 		res = rxe_prepare_res(qp, req_pkt, RXE_READ_MASK);
@@ -787,8 +789,10 @@ static enum resp_states read_reply(struct rxe_qp *qp,
 			qp->resp.mr = NULL;
 		} else {
 			mr = rxe_recheck_mr(qp, res->read.rkey);
-			if (!mr)
-				return RESPST_ERR_RKEY_VIOLATION;
+			if (!mr) {
+				state = RESPST_ERR_RKEY_VIOLATION;
+				goto err_out;
+			}
 		}
 
 		if (res->read.resid <= mtu)
@@ -797,8 +801,10 @@ static enum resp_states read_reply(struct rxe_qp *qp,
 			opcode = IB_OPCODE_RC_RDMA_READ_RESPONSE_FIRST;
 	} else {
 		mr = rxe_recheck_mr(qp, res->read.rkey);
-		if (!mr)
-			return RESPST_ERR_RKEY_VIOLATION;
+		if (!mr) {
+			state = RESPST_ERR_RKEY_VIOLATION;
+			goto err_out;
+		}
 
 		if (res->read.resid > mtu)
 			opcode = IB_OPCODE_RC_RDMA_READ_RESPONSE_MIDDLE;
@@ -806,35 +812,33 @@ static enum resp_states read_reply(struct rxe_qp *qp,
 			opcode = IB_OPCODE_RC_RDMA_READ_RESPONSE_LAST;
 	}
 
-	res->state = rdatm_res_state_next;
-
 	payload = min_t(int, res->read.resid, mtu);
 
 	skb = prepare_ack_packet(qp, &ack_pkt, opcode, payload,
-				 res->cur_psn, AETH_ACK_UNLIMITED);
-	if (!skb)
-		return RESPST_ERR_RNR;
+				 res->cur_psn, AETH_ACK_UNLIMITED, &frag);
+	if (!skb) {
+		state = RESPST_ERR_RNR;
+		goto err_put_mr;
+	}
 
+	op = frag ? RXE_FRAG_FROM_MR : RXE_COPY_FROM_MR;
 	err = rxe_copy_mr_data(skb, mr, res->read.va, payload_addr(&ack_pkt),
-			       skb_offset, payload, RXE_COPY_FROM_MR);
+			       skb_offset, payload, op);
 	if (err) {
-		kfree_skb(skb);
-		rxe_put(mr);
-		return RESPST_ERR_RKEY_VIOLATION;
+		state = RESPST_ERR_RKEY_VIOLATION;
+		goto err_free_skb;
 	}
 
-	if (mr)
-		rxe_put(mr);
-
-	if (bth_pad(&ack_pkt)) {
-		u8 *pad = payload_addr(&ack_pkt) + payload;
-
-		memset(pad, 0, bth_pad(&ack_pkt));
-	}
+	err = rxe_prepare_pad_icrc(&ack_pkt, skb, payload, frag);
+	if (err)
+		goto err_free_skb;
 
 	err = rxe_xmit_packet(qp, &ack_pkt, skb);
-	if (err)
-		return RESPST_ERR_RNR;
+	if (err) {
+		/* rxe_xmit_packet will consume the packet */
+		state = RESPST_ERR_RNR;
+		goto err_put_mr;
+	}
 
 	res->read.va += payload;
 	res->read.resid -= payload;
@@ -851,6 +855,16 @@ static enum resp_states read_reply(struct rxe_qp *qp,
 		state = RESPST_CLEANUP;
 	}
 
+	/* keep these after all error exits */
+	res->state = rdatm_res_state_next;
+	rxe_put(mr);
+	return state;
+
+err_free_skb:
+	kfree_skb(skb);
+err_put_mr:
+	rxe_put(mr);
+err_out:
 	return state;
 }
 
@@ -1041,14 +1055,19 @@ static int send_common_ack(struct rxe_qp *qp, u8 syndrome, u32 psn,
 				  int opcode, const char *msg)
 {
 	int err;
-	struct rxe_pkt_info ack_pkt;
+	struct rxe_pkt_info ack;
 	struct sk_buff *skb;
+	int payload = 0;
 
-	skb = prepare_ack_packet(qp, &ack_pkt, opcode, 0, psn, syndrome);
+	skb = prepare_ack_packet(qp, &ack, opcode, payload,
+				 psn, syndrome, NULL);
 	if (!skb)
 		return -ENOMEM;
 
-	err = rxe_xmit_packet(qp, &ack_pkt, skb);
+	/* doesn't fail if frag == false */
+	(void)rxe_prepare_pad_icrc(&ack, skb, payload, false);
+
+	err = rxe_xmit_packet(qp, &ack, skb);
 	if (err)
 		pr_err_ratelimited("Failed sending %s\n", msg);
 
-- 
2.34.1


  parent reply	other threads:[~2022-10-27 18:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27 18:54 [PATCH for-next 00/17] RDMA/rxe: Enable scatter/gather support for skbs Bob Pearson
2022-10-27 18:54 ` [PATCH for-next 01/17] RDMA/rxe: Isolate code to fill request roce headers Bob Pearson
2022-10-27 18:54 ` [PATCH for-next 02/17] RDMA/rxe: Isolate request payload code in a subroutine Bob Pearson
2022-10-27 18:54 ` [PATCH for-next 03/17] RDMA/rxe: Isolate code to build request packet Bob Pearson
2022-10-30 18:52   ` kernel test robot
2022-10-27 18:54 ` [PATCH for-next 04/17] RDMA/rxe: Add sg fragment ops Bob Pearson
2022-10-27 18:54 ` [PATCH for-next 05/17] RDMA/rxe: Add rxe_add_frag() to rxe_mr.c Bob Pearson
2022-10-27 18:55 ` [PATCH for-next 06/17] RDMA/rxe: Add routine to compute the number of frags Bob Pearson
2022-10-27 18:55 ` [PATCH for-next 07/17] RDMA/rxe: Extend rxe_mr_copy to support skb frags Bob Pearson
2022-10-27 18:55 ` [PATCH for-next 08/17] RDMA/rxe: Add routine to compute number of frags for dma Bob Pearson
2022-10-27 18:55 ` [PATCH for-next 09/17] RDMA/rxe: Extend copy_data to support skb frags Bob Pearson
2022-10-27 18:55 ` [PATCH for-next 10/17] RDMA/rxe: Replace rxe by qp as a parameter Bob Pearson
2022-10-27 18:55 ` [PATCH for-next 11/17] RDMA/rxe: Extend rxe_init_packet() to support frags Bob Pearson
2022-10-27 18:55 ` [PATCH for-next 12/17] RDMA/rxe: Extend rxe_icrc.c " Bob Pearson
2022-10-27 20:29   ` kernel test robot
2022-10-30 19:33   ` kernel test robot
2022-10-27 18:55 ` [PATCH for-next 13/17] RDMA/rxe: Extend rxe_init_req_packet() for frags Bob Pearson
2022-10-27 18:55 ` Bob Pearson [this message]
2022-10-30 20:13   ` [PATCH for-next 14/17] RDMA/rxe: Extend response packets " kernel test robot
2022-10-27 18:55 ` [PATCH for-next 15/17] RDMA/rxe: Extend send/write_data_in() " Bob Pearson
2022-10-27 18:55 ` [PATCH for-next 16/17] RDMA/rxe: Extend do_read() in rxe_comp,c " Bob Pearson
2022-10-27 18:55 ` [PATCH for-next 17/17] RDMA/rxe: Enable sg code in rxe Bob Pearson

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=20221027185510.33808-15-rpearsonhpe@gmail.com \
    --to=rpearsonhpe@gmail.com \
    --cc=jgg@nvidia.com \
    --cc=jhack@hpe.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=zyjzyj2000@gmail.com \
    /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