diff mbox series

[for-next,v3,6/8] RDMA/rxe: Put fake udp send code in a subroutine

Message ID 20230727192831.65495-7-rpearsonhpe@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Jason Gunthorpe
Headers show
Series RDMA/rxe: Misc cleanups | expand

Commit Message

Bob Pearson July 27, 2023, 7:28 p.m. UTC
Isolate the code that handles the case of an overlong to a
subroutine named fake_udp_send().

Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
---
 drivers/infiniband/sw/rxe/rxe_req.c | 37 ++++++++++++++++-------------
 1 file changed, 20 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c
index 27be1a946d62..8423d259f26a 100644
--- a/drivers/infiniband/sw/rxe/rxe_req.c
+++ b/drivers/infiniband/sw/rxe/rxe_req.c
@@ -707,6 +707,24 @@  static int rxe_do_local_ops(struct rxe_qp *qp, struct rxe_send_wqe *wqe)
 	return 0;
 }
 
+/* C10-93.1.1: If the total sum of all the buffer lengths specified for a
+ * UD message exceeds the MTU of the port as returned by QueryHCA, the CI
+ * shall not emit any packets for this message. Further, the CI shall not
+ * generate an error due to this condition.
+ */
+static void fake_udp_send(struct rxe_qp *qp, struct rxe_send_wqe *wqe)
+{
+	wqe->first_psn = qp->req.psn;
+	wqe->last_psn = qp->req.psn;
+	qp->req.psn = (qp->req.psn + 1) & BTH_PSN_MASK;
+	qp->req.opcode = IB_OPCODE_UD_SEND_ONLY;
+	qp->req.wqe_index = queue_next_index(qp->sq.queue,
+				       qp->req.wqe_index);
+	wqe->state = wqe_state_done;
+	wqe->status = IB_WC_SUCCESS;
+	rxe_run_task(&qp->comp.task);
+}
+
 int rxe_requester(struct rxe_qp *qp)
 {
 	struct rxe_pkt_info pkt;
@@ -810,23 +828,8 @@  int rxe_requester(struct rxe_qp *qp)
 	payload = (mask & (RXE_WRITE_OR_SEND_MASK | RXE_ATOMIC_WRITE_MASK)) ?
 			wqe->dma.resid : 0;
 	if (payload > mtu) {
-		if (qp_type(qp) == IB_QPT_UD) {
-			/* C10-93.1.1: If the total sum of all the buffer lengths specified for a
-			 * UD message exceeds the MTU of the port as returned by QueryHCA, the CI
-			 * shall not emit any packets for this message. Further, the CI shall not
-			 * generate an error due to this condition.
-			 */
-
-			/* fake a successful UD send */
-			wqe->first_psn = qp->req.psn;
-			wqe->last_psn = qp->req.psn;
-			qp->req.psn = (qp->req.psn + 1) & BTH_PSN_MASK;
-			qp->req.opcode = IB_OPCODE_UD_SEND_ONLY;
-			qp->req.wqe_index = queue_next_index(qp->sq.queue,
-						       qp->req.wqe_index);
-			wqe->state = wqe_state_done;
-			wqe->status = IB_WC_SUCCESS;
-			rxe_sched_task(&qp->comp.task);
+		if (unlikely(qp_type(qp) == IB_QPT_UD)) {
+			fake_udp_send(qp, wqe);
 			goto done;
 		}
 		payload = mtu;