From patchwork Thu Feb 7 17:33:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Gurtovoy X-Patchwork-Id: 10801641 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 8727114E1 for ; Thu, 7 Feb 2019 17:33:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 728002E34D for ; Thu, 7 Feb 2019 17:33:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66B2E2E38D; Thu, 7 Feb 2019 17:33:49 +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 84ACB2E34D for ; Thu, 7 Feb 2019 17:33:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726747AbfBGRdk (ORCPT ); Thu, 7 Feb 2019 12:33:40 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:49094 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726832AbfBGRdi (ORCPT ); Thu, 7 Feb 2019 12:33:38 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from maxg@mellanox.com) with ESMTPS (AES256-SHA encrypted); 7 Feb 2019 19:33:32 +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 x17HXVKZ025778; Thu, 7 Feb 2019 19:33:32 +0200 From: Max Gurtovoy To: linux-rdma@vger.kernel.org, sagi@grimberg.me, hch@lst.de, leon@kernel.org, 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 06/17] IB/srp: Embed ib_scatterlist into srp_map_state struct Date: Thu, 7 Feb 2019 19:33:20 +0200 Message-Id: <1549560811-8655-7-git-send-email-maxg@mellanox.com> X-Mailer: git-send-email 1.7.8.2 In-Reply-To: <1549560811-8655-1-git-send-email-maxg@mellanox.com> References: <1549560811-8655-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 to save the needed details for RDMA operation description. Signed-off-by: Israel Rukshin Reviewed-by: Max Gurtovoy --- drivers/infiniband/ulp/srp/ib_srp.c | 39 ++++++++++++++++--------------------- drivers/infiniband/ulp/srp/ib_srp.h | 2 +- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 1ce1619990d5..9c7092daaa2d 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -1511,20 +1511,20 @@ static void srp_reg_mr_err_done(struct ib_cq *cq, struct ib_wc *wc) } /* - * Map up to ib_sg->dma_nents elements of state->sg where ib_sg->offset - * is the offset where to start in the first element. - * ib_sg->offset is updated to the offset in state->sg[retval] of the first - * byte that has not yet been mapped. + * Map up to state->ib_sg.dma_nents elements of state->ib_sg.sg where + * state->ib_sg.offset is the offset where to start in the first element. + * state->ib_sg.offset is updated to the offset in state->ib_sg.sg[retval] of + * the first byte that has not yet been mapped. */ static int srp_map_finish_fr(struct srp_map_state *state, struct srp_request *req, - struct srp_rdma_ch *ch, - struct ib_scatterlist *ib_sg) + struct srp_rdma_ch *ch) { struct srp_target_port *target = ch->target; struct srp_device *dev = target->srp_host->srp_dev; struct ib_reg_wr wr; struct srp_fr_desc *desc; + struct ib_scatterlist *ib_sg = &state->ib_sg; u32 rkey; int n, err; @@ -1538,8 +1538,8 @@ static int srp_map_finish_fr(struct srp_map_state *state, WARN_ON_ONCE(!dev->use_fast_reg); if (ib_sg->dma_nents == 1 && target->global_rkey) { - srp_map_desc(state, sg_dma_address(state->sg) + ib_sg->offset, - sg_dma_len(state->sg) - ib_sg->offset, + srp_map_desc(state, sg_dma_address(ib_sg->sg) + ib_sg->offset, + sg_dma_len(ib_sg->sg) - ib_sg->offset, target->global_rkey); ib_sg->offset = 0; return 1; @@ -1664,12 +1664,10 @@ static int srp_map_sg_fr(struct srp_map_state *state, struct srp_rdma_ch *ch, struct srp_request *req, struct scatterlist *scat, int count) { - struct ib_scatterlist ib_sg; - - ib_sg.offset = 0; state->fr.next = req->fr_list; state->fr.end = req->fr_list + ch->target->mr_per_cmd; - state->sg = scat; + state->ib_sg.sg = scat; + state->ib_sg.offset = 0; if (count == 0) return 0; @@ -1677,15 +1675,14 @@ static int srp_map_sg_fr(struct srp_map_state *state, struct srp_rdma_ch *ch, while (count) { int i, n; - ib_sg.sg = state->sg; - ib_sg.dma_nents = count; - n = srp_map_finish_fr(state, req, ch, &ib_sg); + state->ib_sg.dma_nents = count; + n = srp_map_finish_fr(state, req, ch); if (unlikely(n < 0)) return n; count -= n; for (i = 0; i < n; i++) - state->sg = sg_next(state->sg); + state->ib_sg.sg = sg_next(state->ib_sg.sg); } return 0; @@ -1726,7 +1723,6 @@ static int srp_map_idb(struct srp_rdma_ch *ch, struct srp_request *req, struct srp_direct_buf idb_desc; u64 idb_pages[1]; struct scatterlist idb_sg[1]; - struct ib_scatterlist ib_sg; int ret; memset(&state, 0, sizeof(state)); @@ -1738,16 +1734,15 @@ static int srp_map_idb(struct srp_rdma_ch *ch, struct srp_request *req, state.dma_len = idb_len; if (dev->use_fast_reg) { - state.sg = idb_sg; + state.ib_sg.sg = idb_sg; sg_init_one(idb_sg, req->indirect_desc, idb_len); idb_sg->dma_address = req->indirect_dma_addr; /* hack! */ #ifdef CONFIG_NEED_SG_DMA_LENGTH idb_sg->dma_length = idb_sg->length; /* hack^2 */ #endif - ib_sg.sg = state.sg; - ib_sg.dma_nents = 1; - ib_sg.offset = 0; - ret = srp_map_finish_fr(&state, req, ch, &ib_sg); + state.ib_sg.dma_nents = 1; + state.ib_sg.offset = 0; + ret = srp_map_finish_fr(&state, req, ch); if (ret < 0) return ret; WARN_ON_ONCE(ret < 1); diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h index b2861cd2087a..30f6174dc23e 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.h +++ b/drivers/infiniband/ulp/srp/ib_srp.h @@ -340,7 +340,7 @@ struct srp_map_state { struct srp_direct_buf *desc; union { u64 *pages; - struct scatterlist *sg; + struct ib_scatterlist ib_sg; }; dma_addr_t base_dma_addr; u32 dma_len;