diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c
index e444e1f91523..27be1a946d62 100644
--- a/drivers/infiniband/sw/rxe/rxe_req.c
+++ b/drivers/infiniband/sw/rxe/rxe_req.c
@@ -496,14 +496,32 @@ static int rxe_init_payload(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
 	return err;
 }
 
-static struct sk_buff *init_req_packet(struct rxe_qp *qp,
-				       struct rxe_av *av,
-				       struct rxe_send_wqe *wqe,
-				       int opcode, u32 payload,
-				       struct rxe_pkt_info *pkt)
+static struct sk_buff *rxe_init_req_packet(struct rxe_qp *qp,
+					   struct rxe_send_wqe *wqe,
+					   int opcode, u32 payload,
+					   struct rxe_pkt_info *pkt)
 {
 	struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
-	struct sk_buff *skb;
+	struct sk_buff *skb = NULL;
+	struct rxe_av *av;
+	struct rxe_ah *ah = NULL;
+	u8 *pad_addr;
+	int err;
+
+	pkt->rxe = rxe;
+	pkt->opcode = opcode;
+	pkt->qp = qp;
+	pkt->psn = qp->req.psn;
+	pkt->mask = rxe_opcode[opcode].mask;
+	pkt->wqe = wqe;
+	pkt->port_num = 1;
+
+	/* get address vector and address handle for UD qps only */
+	av = rxe_get_av(pkt, &ah);
+	if (unlikely(!av)) {
+		err = -EINVAL;
+		goto err_out;
+	}
 
 	/* length from start of bth to end of icrc */
 	pkt->pad = (-payload) & 0x3;
@@ -512,31 +530,19 @@ static struct sk_buff *init_req_packet(struct rxe_qp *qp,
 
 	/* init skb */
 	skb = rxe_init_packet(rxe, av, pkt);
-	if (unlikely(!skb))
-		return NULL;
+	if (unlikely(!skb)) {
+		err = -ENOMEM;
+		goto err_out;
+	}
 
+	/* init roce headers */
 	rxe_init_roce_hdrs(qp, wqe, pkt);
 
-	return skb;
-}
-
-static int finish_packet(struct rxe_qp *qp, struct rxe_av *av,
-			 struct rxe_send_wqe *wqe, struct rxe_pkt_info *pkt,
-			 struct sk_buff *skb, u32 payload)
-{
-	u8 *pad_addr;
-	int err;
-
-	err = rxe_prepare(av, pkt, skb);
-	if (err)
-		return err;
-
+	/* init payload if any */
 	if (pkt->mask & RXE_WRITE_OR_SEND_MASK) {
 		err = rxe_init_payload(qp, wqe, pkt, payload);
-		if (pkt->pad) {
-			pad_addr = payload_addr(pkt) + payload;
-			memset(pad_addr, 0, pkt->pad);
-		}
+		if (unlikely(err))
+			goto err_out;
 	} else if (pkt->mask & RXE_FLUSH_MASK) {
 		/* oA19-2: shall have no payload. */
 		wqe->dma.resid = 0;
@@ -547,7 +553,32 @@ static int finish_packet(struct rxe_qp *qp, struct rxe_av *av,
 		wqe->dma.resid -= payload;
 	}
 
-	return 0;
+	/* init pad and icrc */
+	if (pkt->pad) {
+		pad_addr = payload_addr(pkt) + payload;
+		memset(pad_addr, 0, pkt->pad);
+	}
+
+	/* init IP and UDP network headers */
+	err = rxe_prepare(av, pkt, skb);
+	if (unlikely(err))
+		goto err_out;
+
+	if (ah)
+		rxe_put(ah);
+
+	return skb;
+
+err_out:
+	if (err == -EFAULT)
+		wqe->status = IB_WC_LOC_PROT_ERR;
+	else
+		wqe->status = IB_WC_LOC_QP_OP_ERR;
+	if (skb)
+		kfree_skb(skb);
+	if (ah)
+		rxe_put(ah);
+	return NULL;
 }
 
 static void update_wqe_state(struct rxe_qp *qp,
@@ -678,7 +709,6 @@ static int rxe_do_local_ops(struct rxe_qp *qp, struct rxe_send_wqe *wqe)
 
 int rxe_requester(struct rxe_qp *qp)
 {
-	struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
 	struct rxe_pkt_info pkt;
 	struct sk_buff *skb;
 	struct rxe_send_wqe *wqe;
@@ -691,8 +721,6 @@ int rxe_requester(struct rxe_qp *qp)
 	struct rxe_send_wqe rollback_wqe;
 	u32 rollback_psn;
 	struct rxe_queue *q = qp->sq.queue;
-	struct rxe_ah *ah;
-	struct rxe_av *av;
 	unsigned long flags;
 
 	spin_lock_irqsave(&qp->state_lock, flags);
@@ -804,47 +832,12 @@ int rxe_requester(struct rxe_qp *qp)
 		payload = mtu;
 	}
 
-	pkt.rxe = rxe;
-	pkt.opcode = opcode;
-	pkt.qp = qp;
-	pkt.psn = qp->req.psn;
-	pkt.mask = rxe_opcode[opcode].mask;
-	pkt.wqe = wqe;
-
 	/* save wqe state before we build and send packet */
 	save_state(wqe, qp, &rollback_wqe, &rollback_psn);
 
-	av = rxe_get_av(&pkt, &ah);
-	if (unlikely(!av)) {
-		rxe_dbg_qp(qp, "Failed no address vector\n");
-		wqe->status = IB_WC_LOC_QP_OP_ERR;
-		goto err;
-	}
-
-	skb = init_req_packet(qp, av, wqe, opcode, payload, &pkt);
-	if (unlikely(!skb)) {
-		rxe_dbg_qp(qp, "Failed allocating skb\n");
-		wqe->status = IB_WC_LOC_QP_OP_ERR;
-		if (ah)
-			rxe_put(ah);
-		goto err;
-	}
-
-	err = finish_packet(qp, av, wqe, &pkt, skb, payload);
-	if (unlikely(err)) {
-		rxe_dbg_qp(qp, "Error during finish packet\n");
-		if (err == -EFAULT)
-			wqe->status = IB_WC_LOC_PROT_ERR;
-		else
-			wqe->status = IB_WC_LOC_QP_OP_ERR;
-		kfree_skb(skb);
-		if (ah)
-			rxe_put(ah);
+	skb = rxe_init_req_packet(qp, wqe, opcode, payload, &pkt);
+	if (!skb)
 		goto err;
-	}
-
-	if (ah)
-		rxe_put(ah);
 
 	/* update wqe state as though we had sent it */
 	update_wqe_state(qp, wqe, &pkt);
