aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/ulp
diff options
context:
space:
mode:
authorSagi Grimberg <sagig@mellanox.com>2015-04-14 11:08:26 -0400
committerDoug Ledford <dledford@redhat.com>2015-04-15 16:07:13 -0400
commitad1e5672429eadd5a7f9613bf2e59546a2eeef13 (patch)
treecf83172af5bb1b2cecfb3178c8f1657a09ed6cdb /drivers/infiniband/ulp
parent6ef8bb837dd7e60f078084d4842a43fd163fb4a2 (diff)
IB/iser: Remove code duplication for a single DMA entry
In singleton scatterlists, DMA memory registration code is taken both for Fastreg and FMR code paths. Move it to a function. This patch does not change any functionality. Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Adir Lev <adirl@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/ulp')
-rw-r--r--drivers/infiniband/ulp/iser/iser_memory.c48
1 files changed, 21 insertions, 27 deletions
diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c
index 0575052d9f8f..abc979e62ae1 100644
--- a/drivers/infiniband/ulp/iser/iser_memory.c
+++ b/drivers/infiniband/ulp/iser/iser_memory.c
@@ -334,6 +334,24 @@ void iser_dma_unmap_task_data(struct iscsi_iser_task *iser_task,
334 ib_dma_unmap_sg(dev, data->sg, data->size, dir); 334 ib_dma_unmap_sg(dev, data->sg, data->size, dir);
335} 335}
336 336
337static int
338iser_reg_dma(struct iser_device *device, struct iser_data_buf *mem,
339 struct iser_mem_reg *reg)
340{
341 struct scatterlist *sg = mem->sg;
342
343 reg->sge.lkey = device->mr->lkey;
344 reg->rkey = device->mr->rkey;
345 reg->sge.addr = ib_sg_dma_address(device->ib_device, &sg[0]);
346 reg->sge.length = ib_sg_dma_len(device->ib_device, &sg[0]);
347
348 iser_dbg("Single DMA entry: lkey=0x%x, rkey=0x%x, addr=0x%llx,"
349 " length=0x%x\n", reg->sge.lkey, reg->rkey,
350 reg->sge.addr, reg->sge.length);
351
352 return 0;
353}
354
337static int fall_to_bounce_buf(struct iscsi_iser_task *iser_task, 355static int fall_to_bounce_buf(struct iscsi_iser_task *iser_task,
338 struct iser_data_buf *mem, 356 struct iser_data_buf *mem,
339 enum iser_data_dir cmd_dir, 357 enum iser_data_dir cmd_dir,
@@ -461,7 +479,6 @@ int iser_reg_rdma_mem_fmr(struct iscsi_iser_task *iser_task,
461 int aligned_len; 479 int aligned_len;
462 int err; 480 int err;
463 int i; 481 int i;
464 struct scatterlist *sg;
465 482
466 mem_reg = &iser_task->rdma_reg[cmd_dir]; 483 mem_reg = &iser_task->rdma_reg[cmd_dir];
467 484
@@ -477,19 +494,7 @@ int iser_reg_rdma_mem_fmr(struct iscsi_iser_task *iser_task,
477 494
478 /* if there a single dma entry, FMR is not needed */ 495 /* if there a single dma entry, FMR is not needed */
479 if (mem->dma_nents == 1) { 496 if (mem->dma_nents == 1) {
480 sg = mem->sg; 497 return iser_reg_dma(device, mem, mem_reg);
481
482 mem_reg->sge.lkey = device->mr->lkey;
483 mem_reg->rkey = device->mr->rkey;
484 mem_reg->sge.length = ib_sg_dma_len(ibdev, &sg[0]);
485 mem_reg->sge.addr = ib_sg_dma_address(ibdev, &sg[0]);
486
487 iser_dbg("PHYSICAL Mem.register: lkey: 0x%08X rkey: 0x%08X "
488 "va: 0x%08lX sz: %ld]\n",
489 (unsigned int)mem_reg->sge.lkey,
490 (unsigned int)mem_reg->rkey,
491 (unsigned long)mem_reg->sge.addr,
492 (unsigned long)mem_reg->sge.length);
493 } else { /* use FMR for multiple dma entries */ 498 } else { /* use FMR for multiple dma entries */
494 err = iser_reg_page_vec(iser_task, mem, ib_conn->fmr.page_vec, 499 err = iser_reg_page_vec(iser_task, mem, ib_conn->fmr.page_vec,
495 mem_reg); 500 mem_reg);
@@ -659,7 +664,6 @@ static int iser_fast_reg_mr(struct iscsi_iser_task *iser_task,
659{ 664{
660 struct ib_conn *ib_conn = &iser_task->iser_conn->ib_conn; 665 struct ib_conn *ib_conn = &iser_task->iser_conn->ib_conn;
661 struct iser_device *device = ib_conn->device; 666 struct iser_device *device = ib_conn->device;
662 struct ib_device *ibdev = device->ib_device;
663 struct ib_mr *mr; 667 struct ib_mr *mr;
664 struct ib_fast_reg_page_list *frpl; 668 struct ib_fast_reg_page_list *frpl;
665 struct ib_send_wr fastreg_wr, inv_wr; 669 struct ib_send_wr fastreg_wr, inv_wr;
@@ -667,18 +671,8 @@ static int iser_fast_reg_mr(struct iscsi_iser_task *iser_task,
667 int ret, offset, size, plen; 671 int ret, offset, size, plen;
668 672
669 /* if there a single dma entry, dma mr suffices */ 673 /* if there a single dma entry, dma mr suffices */
670 if (mem->dma_nents == 1) { 674 if (mem->dma_nents == 1)
671 struct scatterlist *sg = mem->sg; 675 return iser_reg_dma(device, mem, reg);
672
673 reg->sge.lkey = device->mr->lkey;
674 reg->rkey = device->mr->rkey;
675 reg->sge.addr = ib_sg_dma_address(ibdev, &sg[0]);
676 reg->sge.length = ib_sg_dma_len(ibdev, &sg[0]);
677
678 iser_dbg("Single DMA entry: lkey=0x%x, addr=0x%llx, length=0x%x\n",
679 reg->sge.lkey, reg->sge.addr, reg->sge.length);
680 return 0;
681 }
682 676
683 if (ind == ISER_DATA_KEY_VALID) { 677 if (ind == ISER_DATA_KEY_VALID) {
684 mr = desc->data_mr; 678 mr = desc->data_mr;