diff mbox series

[for-rc,5/6] RDMA/efa: Use rdma block iterator in chunk list creation

Message ID 20190528124618.77918-6-galpress@amazon.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series EFA updates 2019-05-28 | expand

Commit Message

Gal Pressman May 28, 2019, 12:46 p.m. UTC
When creating the chunks list the rdma_for_each_block() iterator is used
in order to iterate over the payload in EFA_CHUNK_PAYLOAD_SIZE (device
defined) strides.

Cc: Shiraz Saleem <shiraz.saleem@intel.com>
Reviewed-by: Firas JahJah <firasj@amazon.com>
Reviewed-by: Yossi Leybovich <sleybo@amazon.com>
Signed-off-by: Gal Pressman <galpress@amazon.com>
---
 drivers/infiniband/hw/efa/efa_verbs.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

Comments

Shiraz Saleem May 29, 2019, 5:03 p.m. UTC | #1
> Subject: [PATCH for-rc 5/6] RDMA/efa: Use rdma block iterator in chunk list
> creation
> 
> When creating the chunks list the rdma_for_each_block() iterator is used in order
> to iterate over the payload in EFA_CHUNK_PAYLOAD_SIZE (device
> defined) strides.
> 
> Cc: Shiraz Saleem <shiraz.saleem@intel.com>
> Reviewed-by: Firas JahJah <firasj@amazon.com>
> Reviewed-by: Yossi Leybovich <sleybo@amazon.com>
> Signed-off-by: Gal Pressman <galpress@amazon.com>
> ---

Looks ok.

Reviewed-by: Shiraz Saleem <shiraz.saleem@intel.com>
Gal Pressman May 29, 2019, 7:11 p.m. UTC | #2
On 29/05/2019 20:03, Saleem, Shiraz wrote:
>> Subject: [PATCH for-rc 5/6] RDMA/efa: Use rdma block iterator in chunk list
>> creation
>>
>> When creating the chunks list the rdma_for_each_block() iterator is used in order
>> to iterate over the payload in EFA_CHUNK_PAYLOAD_SIZE (device
>> defined) strides.
>>
>> Cc: Shiraz Saleem <shiraz.saleem@intel.com>
>> Reviewed-by: Firas JahJah <firasj@amazon.com>
>> Reviewed-by: Yossi Leybovich <sleybo@amazon.com>
>> Signed-off-by: Gal Pressman <galpress@amazon.com>
>> ---
> 
> Looks ok.
> 
> Reviewed-by: Shiraz Saleem <shiraz.saleem@intel.com>

Thanks Shiraz
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/efa/efa_verbs.c b/drivers/infiniband/hw/efa/efa_verbs.c
index c1246c39f234..6d4c3f2280df 100644
--- a/drivers/infiniband/hw/efa/efa_verbs.c
+++ b/drivers/infiniband/hw/efa/efa_verbs.c
@@ -1097,14 +1097,14 @@  static struct scatterlist *efa_vmalloc_buf_to_sg(u64 *buf, int page_cnt)
  */
 static int pbl_chunk_list_create(struct efa_dev *dev, struct pbl_context *pbl)
 {
-	unsigned int entry, payloads_in_sg, chunk_list_size, chunk_idx, payload_idx;
 	struct pbl_chunk_list *chunk_list = &pbl->phys.indirect.chunk_list;
 	int page_cnt = pbl->phys.indirect.pbl_buf_size_in_pages;
 	struct scatterlist *pages_sgl = pbl->phys.indirect.sgl;
+	unsigned int chunk_list_size, chunk_idx, payload_idx;
 	int sg_dma_cnt = pbl->phys.indirect.sg_dma_cnt;
 	struct efa_com_ctrl_buff_info *ctrl_buf;
 	u64 *cur_chunk_buf, *prev_chunk_buf;
-	struct scatterlist *sg;
+	struct ib_block_iter biter;
 	dma_addr_t dma_addr;
 	int i;
 
@@ -1138,18 +1138,15 @@  static int pbl_chunk_list_create(struct efa_dev *dev, struct pbl_context *pbl)
 	chunk_idx = 0;
 	payload_idx = 0;
 	cur_chunk_buf = chunk_list->chunks[0].buf;
-	for_each_sg(pages_sgl, sg, sg_dma_cnt, entry) {
-		payloads_in_sg = sg_dma_len(sg) >> EFA_CHUNK_PAYLOAD_SHIFT;
-		for (i = 0; i < payloads_in_sg; i++) {
-			cur_chunk_buf[payload_idx++] =
-				(sg_dma_address(sg) & ~(EFA_CHUNK_PAYLOAD_SIZE - 1)) +
-				(EFA_CHUNK_PAYLOAD_SIZE * i);
+	rdma_for_each_block(pages_sgl, &biter, sg_dma_cnt,
+			    EFA_CHUNK_PAYLOAD_SIZE) {
+		cur_chunk_buf[payload_idx++] =
+			rdma_block_iter_dma_address(&biter);
 
-			if (payload_idx == EFA_PTRS_PER_CHUNK) {
-				chunk_idx++;
-				cur_chunk_buf = chunk_list->chunks[chunk_idx].buf;
-				payload_idx = 0;
-			}
+		if (payload_idx == EFA_PTRS_PER_CHUNK) {
+			chunk_idx++;
+			cur_chunk_buf = chunk_list->chunks[chunk_idx].buf;
+			payload_idx = 0;
 		}
 	}