[PATCH for-next 02/17] RDMA/rxe: Isolate request payload code in a subroutine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Isolate the code that fills the payload of a request packet into
a subroutine named rxe_init_payload().

Signed-off-by: Bob Pearson <rpearsonhpe@xxxxxxxxx>
---
 drivers/infiniband/sw/rxe/rxe_req.c | 34 +++++++++++++++++------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c
index bcfbc78c0b53..10a75f4e3608 100644
--- a/drivers/infiniband/sw/rxe/rxe_req.c
+++ b/drivers/infiniband/sw/rxe/rxe_req.c
@@ -437,6 +437,25 @@ static void rxe_init_roce_hdrs(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
 	}
 }
 
+static int rxe_init_payload(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
+			    struct rxe_pkt_info *pkt, u32 payload)
+{
+	void *data;
+	int err = 0;
+
+	if (wqe->wr.send_flags & IB_SEND_INLINE) {
+		data = &wqe->dma.inline_data[wqe->dma.sge_offset];
+		memcpy(payload_addr(pkt), data, payload);
+		wqe->dma.resid -= payload;
+		wqe->dma.sge_offset += payload;
+	} else {
+		err = copy_data(qp->pd, 0, &wqe->dma, payload_addr(pkt),
+				payload, RXE_FROM_MR_OBJ);
+	}
+
+	return err;
+}
+
 static struct sk_buff *init_req_packet(struct rxe_qp *qp,
 				       struct rxe_av *av,
 				       struct rxe_send_wqe *wqe,
@@ -473,20 +492,7 @@ static int finish_packet(struct rxe_qp *qp, struct rxe_av *av,
 		return err;
 
 	if (pkt->mask & RXE_WRITE_OR_SEND_MASK) {
-		if (wqe->wr.send_flags & IB_SEND_INLINE) {
-			u8 *tmp = &wqe->dma.inline_data[wqe->dma.sge_offset];
-
-			memcpy(payload_addr(pkt), tmp, payload);
-
-			wqe->dma.resid -= payload;
-			wqe->dma.sge_offset += payload;
-		} else {
-			err = copy_data(qp->pd, 0, &wqe->dma,
-					payload_addr(pkt), payload,
-					RXE_FROM_MR_OBJ);
-			if (err)
-				return err;
-		}
+		err = rxe_init_payload(qp, wqe, pkt, payload);
 		if (bth_pad(pkt)) {
 			u8 *pad = payload_addr(pkt) + payload;
 
-- 
2.34.1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux