From: Guoqing Jiang <guoqing.jiang@linux.dev>
To: bmt@zurich.ibm.com, jgg@ziepe.ca, leon@kernel.org
Cc: linux-rdma@vger.kernel.org
Subject: [PATCH 08/19] RDMA/siw: Factor out siw_generic_rx helper
Date: Mon, 9 Oct 2023 15:17:50 +0800 [thread overview]
Message-ID: <20231009071801.10210-9-guoqing.jiang@linux.dev> (raw)
In-Reply-To: <20231009071801.10210-1-guoqing.jiang@linux.dev>
Remove the redundant code given they share the same logic.
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
---
drivers/infiniband/sw/siw/siw_qp_rx.c | 53 ++++++++++-----------------
1 file changed, 20 insertions(+), 33 deletions(-)
diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c b/drivers/infiniband/sw/siw/siw_qp_rx.c
index aa7b680452fb..4931c0c57df0 100644
--- a/drivers/infiniband/sw/siw/siw_qp_rx.c
+++ b/drivers/infiniband/sw/siw/siw_qp_rx.c
@@ -405,6 +405,20 @@ static struct siw_wqe *siw_rqe_get(struct siw_qp *qp)
return wqe;
}
+static int siw_generic_rx(struct siw_mem *mem_p, struct siw_rx_stream *srx,
+ unsigned int *pbl_idx, u64 addr, int bytes)
+{
+ int rv;
+
+ if (mem_p->mem_obj == NULL)
+ rv = siw_rx_kva(srx, ib_virt_dma_to_ptr(addr), bytes);
+ else if (!mem_p->is_pbl)
+ rv = siw_rx_umem(srx, mem_p->umem, addr, bytes);
+ else
+ rv = siw_rx_pbl(srx, pbl_idx, mem_p, addr, bytes);
+ return rv;
+}
+
/*
* siw_proc_send:
*
@@ -485,17 +499,8 @@ int siw_proc_send(struct siw_qp *qp)
break;
}
mem_p = *mem;
- if (mem_p->mem_obj == NULL)
- rv = siw_rx_kva(srx,
- ib_virt_dma_to_ptr(sge->laddr + frx->sge_off),
- sge_bytes);
- else if (!mem_p->is_pbl)
- rv = siw_rx_umem(srx, mem_p->umem,
- sge->laddr + frx->sge_off, sge_bytes);
- else
- rv = siw_rx_pbl(srx, &frx->pbl_idx, mem_p,
- sge->laddr + frx->sge_off, sge_bytes);
-
+ rv = siw_generic_rx(mem_p, srx, &frx->pbl_idx,
+ sge->laddr + frx->sge_off, sge_bytes);
if (unlikely(rv != sge_bytes)) {
wqe->processed += rcvd_bytes;
@@ -598,17 +603,8 @@ int siw_proc_write(struct siw_qp *qp)
return -EINVAL;
}
- if (mem->mem_obj == NULL)
- rv = siw_rx_kva(srx,
- (void *)(uintptr_t)(srx->ddp_to + srx->fpdu_part_rcvd),
- bytes);
- else if (!mem->is_pbl)
- rv = siw_rx_umem(srx, mem->umem,
- srx->ddp_to + srx->fpdu_part_rcvd, bytes);
- else
- rv = siw_rx_pbl(srx, &frx->pbl_idx, mem,
- srx->ddp_to + srx->fpdu_part_rcvd, bytes);
-
+ rv = siw_generic_rx(mem, srx, &frx->pbl_idx,
+ srx->ddp_to + srx->fpdu_part_rcvd, bytes);
if (unlikely(rv != bytes)) {
siw_init_terminate(qp, TERM_ERROR_LAYER_DDP,
DDP_ETYPE_CATASTROPHIC,
@@ -849,17 +845,8 @@ int siw_proc_rresp(struct siw_qp *qp)
mem_p = *mem;
bytes = min(srx->fpdu_part_rem, srx->skb_new);
-
- if (mem_p->mem_obj == NULL)
- rv = siw_rx_kva(srx,
- ib_virt_dma_to_ptr(sge->laddr + wqe->processed),
- bytes);
- else if (!mem_p->is_pbl)
- rv = siw_rx_umem(srx, mem_p->umem, sge->laddr + wqe->processed,
- bytes);
- else
- rv = siw_rx_pbl(srx, &frx->pbl_idx, mem_p,
- sge->laddr + wqe->processed, bytes);
+ rv = siw_generic_rx(mem_p, srx, &frx->pbl_idx,
+ sge->laddr + wqe->processed, bytes);
if (rv != bytes) {
wqe->wc_status = SIW_WC_GENERAL_ERR;
rv = -EINVAL;
--
2.35.3
next prev parent reply other threads:[~2023-10-09 7:25 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 7:17 [PATCH 00/19] Cleanup for siw Guoqing Jiang
2023-10-09 7:17 ` [PATCH 01/19] RDMA/siw: Introduce siw_get_page Guoqing Jiang
2023-10-09 7:17 ` [PATCH 02/19] RDMA/siw: Introduce siw_srx_update_skb Guoqing Jiang
2023-10-25 12:33 ` Bernard Metzler
2023-10-26 6:37 ` Guoqing Jiang
2023-10-09 7:17 ` [PATCH 03/19] RDMA/siw: Use iov.iov_len in kernel_sendmsg Guoqing Jiang
2023-10-25 12:36 ` Bernard Metzler
2023-10-09 7:17 ` [PATCH 04/19] RDMA/siw: Remove goto lable in siw_mmap Guoqing Jiang
2023-10-25 12:38 ` Bernard Metzler
2023-10-26 6:38 ` Guoqing Jiang
2023-10-09 7:17 ` [PATCH 05/19] RDMA/siw: Remove rcu from siw_qp Guoqing Jiang
2023-10-25 12:39 ` Bernard Metzler
2023-10-09 7:17 ` [PATCH 06/19] RDMA/siw: No need to check term_info.valid before call siw_send_terminate Guoqing Jiang
2023-10-25 12:39 ` Bernard Metzler
2023-10-09 7:17 ` [PATCH 07/19] RDMA/siw: Also goto out_sem_up if pin_user_pages returns 0 Guoqing Jiang
2023-10-25 12:51 ` Bernard Metzler
2023-10-09 7:17 ` Guoqing Jiang [this message]
2023-10-09 7:17 ` [PATCH 09/19] RDMA/siw: Introduce SIW_STAG_MAX_INDEX Guoqing Jiang
2023-10-25 12:52 ` Bernard Metzler
2023-10-09 7:17 ` [PATCH 10/19] RDMA/siw: Add one parameter to siw_destroy_cpulist Guoqing Jiang
2023-10-09 7:17 ` [PATCH 11/19] RDMA/siw: Introduce siw_cep_set_free_and_put Guoqing Jiang
2023-10-25 12:57 ` Bernard Metzler
2023-10-09 7:17 ` [PATCH 12/19] RDMA/siw: Introduce siw_free_cm_id Guoqing Jiang
2023-10-09 9:02 ` kernel test robot
2023-10-09 14:39 ` kernel test robot
2023-10-25 13:02 ` Bernard Metzler
2023-10-26 6:41 ` Guoqing Jiang
2023-10-09 7:17 ` [PATCH 13/19] RDMA/siw: Simplify siw_qp_id2obj Guoqing Jiang
2023-10-25 13:04 ` Bernard Metzler
2023-10-26 6:42 ` Guoqing Jiang
2023-10-26 13:23 ` Bernard Metzler
2023-10-09 7:17 ` [PATCH 14/19] RDMA/siw: Simplify siw_mem_id2obj Guoqing Jiang
2023-10-25 13:04 ` Bernard Metzler
2023-10-09 7:17 ` [PATCH 15/19] RDMA/siw: Cleanup siw_accept Guoqing Jiang
2023-10-09 7:17 ` [PATCH 16/19] RDMA/siw: Remove siw_sk_assign_cm_upcalls Guoqing Jiang
2023-10-25 13:19 ` Bernard Metzler
2023-10-26 6:45 ` Guoqing Jiang
2023-10-26 13:52 ` Bernard Metzler
2023-10-09 7:17 ` [PATCH 17/19] RDMA/siw: Fix typo Guoqing Jiang
2023-10-09 7:18 ` [PATCH 18/19] RDMA/siw: Only check attrs->cap.max_send_wr in siw_create_qp Guoqing Jiang
2023-10-09 7:18 ` [PATCH 19/19] RDMA/siw: Introduce siw_destroy_cep_sock Guoqing Jiang
2023-10-09 9:54 ` kernel test robot
2023-10-09 13:30 ` Guoqing Jiang
2023-10-13 15:45 ` [PATCH 00/19] Cleanup for siw Bernard Metzler
2023-10-16 2:22 ` Guoqing Jiang
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=20231009071801.10210-9-guoqing.jiang@linux.dev \
--to=guoqing.jiang@linux.dev \
--cc=bmt@zurich.ibm.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).