From patchwork Thu Mar 7 18:02:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Gurtovoy X-Patchwork-Id: 10843625 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A04E517E9 for ; Thu, 7 Mar 2019 18:02:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89EF32F572 for ; Thu, 7 Mar 2019 18:02:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DE502F619; Thu, 7 Mar 2019 18:02:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E54F72F580 for ; Thu, 7 Mar 2019 18:02:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726463AbfCGSCy (ORCPT ); Thu, 7 Mar 2019 13:02:54 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53307 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726539AbfCGSCv (ORCPT ); Thu, 7 Mar 2019 13:02:51 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from maxg@mellanox.com) with ESMTPS (AES256-SHA encrypted); 7 Mar 2019 20:02:45 +0200 Received: from r-vnc08.mtr.labs.mlnx (r-vnc08.mtr.labs.mlnx [10.208.0.121]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x27I2idf016737; Thu, 7 Mar 2019 20:02:45 +0200 From: Max Gurtovoy To: hch@lst.de, linux-rdma@vger.kernel.org, leon@kernel.org, sagi@grimberg.me, jgg@mellanox.com, dledford@redhat.com, bvanassche@acm.org Cc: maxg@mellanox.com, israelr@mellanox.com, idanb@mellanox.com, vladimirk@mellanox.com, shlomin@mellanox.com, oren@mellanox.com Subject: [PATCH 05/18] IB/iser: Embed ib_scatterlist into iser_data_buf Date: Thu, 7 Mar 2019 20:02:31 +0200 Message-Id: <1551981764-26557-6-git-send-email-maxg@mellanox.com> X-Mailer: git-send-email 1.7.8.2 In-Reply-To: <1551981764-26557-1-git-send-email-maxg@mellanox.com> References: <1551981764-26557-1-git-send-email-maxg@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Israel Rukshin Use it to save the needed details for RDMA operation description. Signed-off-by: Israel Rukshin Reviewed-by: Max Gurtovoy --- drivers/infiniband/ulp/iser/iscsi_iser.h | 14 +++++------- drivers/infiniband/ulp/iser/iser_initiator.c | 6 +++-- drivers/infiniband/ulp/iser/iser_memory.c | 33 +++++++++++----------------- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h index a7aeaa0c6fbc..2fc79ea897a3 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.h +++ b/drivers/infiniband/ulp/iser/iscsi_iser.h @@ -188,16 +188,14 @@ enum iser_data_dir { /** * struct iser_data_buf - iSER data buffer * - * @sg: pointer to the sg list - * @size: num entries of this sg - * @data_len: total beffer byte len - * @dma_nents: returned by dma_map_sg + * @ib_sg: ib scatterlist + * @size: num entries of the unmaped sg list + * @data_len: total buffer byte len */ struct iser_data_buf { - struct scatterlist *sg; - int size; - unsigned long data_len; - int dma_nents; + struct ib_scatterlist ib_sg; + int size; + unsigned long data_len; }; /* fwd declarations */ diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c index 96af06cfe0af..9556ec55dec2 100644 --- a/drivers/infiniband/ulp/iser/iser_initiator.c +++ b/drivers/infiniband/ulp/iser/iser_initiator.c @@ -388,16 +388,18 @@ int iser_send_command(struct iscsi_conn *conn, } if (scsi_sg_count(sc)) { /* using a scatter list */ - data_buf->sg = scsi_sglist(sc); + data_buf->ib_sg.sg = scsi_sglist(sc); data_buf->size = scsi_sg_count(sc); } data_buf->data_len = scsi_bufflen(sc); + data_buf->ib_sg.offset = 0; if (scsi_prot_sg_count(sc)) { - prot_buf->sg = scsi_prot_sglist(sc); + prot_buf->ib_sg.sg = scsi_prot_sglist(sc); prot_buf->size = scsi_prot_sg_count(sc); prot_buf->data_len = (data_buf->data_len >> ilog2(sc->device->sector_size)) * 8; + prot_buf->ib_sg.offset = 0; } if (hdr->flags & ISCSI_FLAG_CMD_READ) { diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c index da3f6f7cbc72..8fd3df94ec4b 100644 --- a/drivers/infiniband/ulp/iser/iser_memory.c +++ b/drivers/infiniband/ulp/iser/iser_memory.c @@ -142,7 +142,7 @@ static void iser_data_buf_dump(struct iser_data_buf *data, struct scatterlist *sg; int i; - for_each_sg(data->sg, sg, data->dma_nents, i) + for_each_sg(data->ib_sg.sg, sg, data->ib_sg.dma_nents, i) iser_dbg("sg[%d] dma_addr:0x%lX page:0x%p " "off:0x%x sz:0x%x dma_len:0x%x\n", i, (unsigned long)ib_sg_dma_address(ibdev, sg), @@ -170,8 +170,9 @@ int iser_dma_map_task_data(struct iscsi_iser_task *iser_task, iser_task->dir[iser_dir] = 1; dev = iser_task->iser_conn->ib_conn.device->ib_device; - data->dma_nents = ib_dma_map_sg(dev, data->sg, data->size, dma_dir); - if (data->dma_nents == 0) { + data->ib_sg.dma_nents = ib_dma_map_sg(dev, data->ib_sg.sg, data->size, + dma_dir); + if (data->ib_sg.dma_nents == 0) { iser_err("dma_map_sg failed!!!\n"); return -EINVAL; } @@ -185,14 +186,14 @@ void iser_dma_unmap_task_data(struct iscsi_iser_task *iser_task, struct ib_device *dev; dev = iser_task->iser_conn->ib_conn.device->ib_device; - ib_dma_unmap_sg(dev, data->sg, data->size, dir); + ib_dma_unmap_sg(dev, data->ib_sg.sg, data->size, dir); } static int iser_reg_dma(struct iser_device *device, struct iser_data_buf *mem, struct iser_mem_reg *reg) { - struct scatterlist *sg = mem->sg; + struct scatterlist *sg = mem->ib_sg.sg; reg->sge.lkey = device->pd->local_dma_lkey; /* @@ -235,16 +236,12 @@ int iser_fast_reg_fmr(struct iscsi_iser_task *iser_task, struct iser_page_vec *page_vec = rsc->page_vec; struct ib_fmr_pool *fmr_pool = rsc->fmr_pool; struct ib_pool_fmr *fmr; - struct ib_scatterlist ib_sg; int ret, plen; page_vec->npages = 0; page_vec->fake_mr.page_size = SIZE_4K; - ib_sg.sg = mem->sg; - ib_sg.dma_nents = mem->dma_nents; - ib_sg.offset = 0; - plen = ib_sg_to_pages(&page_vec->fake_mr, &ib_sg, iser_set_page); - if (unlikely(plen < mem->dma_nents)) { + plen = ib_sg_to_pages(&page_vec->fake_mr, &mem->ib_sg, iser_set_page); + if (unlikely(plen < mem->ib_sg.dma_nents)) { iser_err("page vec too short to hold this SG\n"); iser_data_buf_dump(mem, device->ib_device); iser_dump_page_vec(page_vec); @@ -444,7 +441,6 @@ static int iser_fast_reg_mr(struct iscsi_iser_task *iser_task, struct ib_cqe *cqe = &iser_task->iser_conn->ib_conn.reg_cqe; struct ib_mr *mr = rsc->mr; struct ib_reg_wr *wr; - struct ib_scatterlist ib_sg; int n; if (rsc->mr_valid) @@ -452,13 +448,9 @@ static int iser_fast_reg_mr(struct iscsi_iser_task *iser_task, ib_update_fast_reg_key(mr, ib_inc_rkey(mr->rkey)); - ib_sg.sg = mem->sg; - ib_sg.dma_nents = mem->dma_nents; - ib_sg.offset = 0; - n = ib_map_mr_sg(mr, &ib_sg, SIZE_4K); - if (unlikely(n != mem->dma_nents)) { - iser_err("failed to map sg (%d/%d)\n", - n, mem->dma_nents); + n = ib_map_mr_sg(mr, &mem->ib_sg, SIZE_4K); + if (unlikely(n != mem->ib_sg.dma_nents)) { + iser_err("failed to map sg (%d/%d)\n", n, mem->ib_sg.dma_nents); return n < 0 ? n : -EINVAL; } @@ -529,7 +521,8 @@ int iser_reg_rdma_mem(struct iscsi_iser_task *task, bool use_dma_key; int err; - use_dma_key = mem->dma_nents == 1 && (all_imm || !iser_always_reg) && + use_dma_key = mem->ib_sg.dma_nents == 1 && + (all_imm || !iser_always_reg) && scsi_get_prot_op(task->sc) == SCSI_PROT_NORMAL; if (!use_dma_key) {