From patchwork Thu Aug 6 15:33:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 6960801 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0761C9F6E2 for ; Thu, 6 Aug 2015 15:34:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EB027206DC for ; Thu, 6 Aug 2015 15:33:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2397820718 for ; Thu, 6 Aug 2015 15:33:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932263AbbHFPdu (ORCPT ); Thu, 6 Aug 2015 11:33:50 -0400 Received: from [193.47.165.129] ([193.47.165.129]:33286 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S932310AbbHFPdt (ORCPT ); Thu, 6 Aug 2015 11:33:49 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from sagig@mellanox.com) with ESMTPS (AES256-SHA encrypted); 6 Aug 2015 18:33:13 +0300 Received: from r-vnc05.mtr.labs.mlnx (r-vnc05.mtr.labs.mlnx [10.208.0.115]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id t76FXDTn006063; Thu, 6 Aug 2015 18:33:13 +0300 Received: from r-vnc05.mtr.labs.mlnx (localhost [127.0.0.1]) by r-vnc05.mtr.labs.mlnx (8.14.4/8.14.4) with ESMTP id t76FXCZ9004418; Thu, 6 Aug 2015 18:33:12 +0300 Received: (from sagig@localhost) by r-vnc05.mtr.labs.mlnx (8.14.4/8.14.4/Submit) id t76FXC3a004417; Thu, 6 Aug 2015 18:33:12 +0300 From: Sagi Grimberg To: Doug Ledford Cc: linux-rdma@vger.kernel.org Subject: [PATCH v1 17/22] IB/iser: Make reg_desc_get a per device routine Date: Thu, 6 Aug 2015 18:33:01 +0300 Message-Id: <1438875186-4310-18-git-send-email-sagig@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1438875186-4310-1-git-send-email-sagig@mellanox.com> References: <1438875186-4310-1-git-send-email-sagig@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As for fmrs we will hold a single registration descriptor as no need for multiple like in the frwr mode (descriptor for each task). This change helps unifying the duplicate registration code paths. Signed-off-by: Sagi Grimberg Signed-off-by: Adir Lev --- drivers/infiniband/ulp/iser/iscsi_iser.h | 16 ++++++++++--- drivers/infiniband/ulp/iser/iser_memory.c | 38 +++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h index a8c8177..611abaa 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.h +++ b/drivers/infiniband/ulp/iser/iscsi_iser.h @@ -333,6 +333,8 @@ struct iser_comp { * @free_reg_res: Free registration resources * @reg_rdma_mem: Register memory buffers * @unreg_rdma_mem: Un-register memory buffers + * @reg_desc_get: Get a registration descriptor for pool + * @reg_desc_put: Get a registration descriptor to pool */ struct iser_reg_ops { int (*alloc_reg_res)(struct ib_conn *ib_conn, @@ -342,6 +344,9 @@ struct iser_reg_ops { enum iser_data_dir cmd_dir); void (*unreg_rdma_mem)(struct iscsi_iser_task *iser_task, enum iser_data_dir cmd_dir); + struct iser_fr_desc * (*reg_desc_get)(struct ib_conn *ib_conn); + void (*reg_desc_put)(struct ib_conn *ib_conn, + struct iser_fr_desc *desc); }; /** @@ -657,8 +662,13 @@ void iser_free_fastreg_pool(struct ib_conn *ib_conn); u8 iser_check_task_pi_status(struct iscsi_iser_task *iser_task, enum iser_data_dir cmd_dir, sector_t *sector); struct iser_fr_desc * -iser_reg_desc_get(struct ib_conn *ib_conn); +iser_reg_desc_get_fr(struct ib_conn *ib_conn); void -iser_reg_desc_put(struct ib_conn *ib_conn, - struct iser_fr_desc *desc); +iser_reg_desc_put_fr(struct ib_conn *ib_conn, + struct iser_fr_desc *desc); +struct iser_fr_desc * +iser_reg_desc_get_fmr(struct ib_conn *ib_conn); +void +iser_reg_desc_put_fmr(struct ib_conn *ib_conn, + struct iser_fr_desc *desc); #endif diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c index 11bba5a..4e687ee 100644 --- a/drivers/infiniband/ulp/iser/iser_memory.c +++ b/drivers/infiniband/ulp/iser/iser_memory.c @@ -44,6 +44,8 @@ static struct iser_reg_ops fastreg_ops = { .free_reg_res = iser_free_fastreg_pool, .reg_rdma_mem = iser_reg_rdma_mem_fastreg, .unreg_rdma_mem = iser_unreg_mem_fastreg, + .reg_desc_get = iser_reg_desc_get_fr, + .reg_desc_put = iser_reg_desc_put_fr, }; static struct iser_reg_ops fmr_ops = { @@ -51,6 +53,8 @@ static struct iser_reg_ops fmr_ops = { .free_reg_res = iser_free_fmr_pool, .reg_rdma_mem = iser_reg_rdma_mem_fmr, .unreg_rdma_mem = iser_unreg_mem_fmr, + .reg_desc_get = iser_reg_desc_get_fmr, + .reg_desc_put = iser_reg_desc_put_fmr, }; int iser_assign_reg_ops(struct iser_device *device) @@ -182,7 +186,7 @@ iser_copy_to_bounce(struct iser_data_buf *data) } struct iser_fr_desc * -iser_reg_desc_get(struct ib_conn *ib_conn) +iser_reg_desc_get_fr(struct ib_conn *ib_conn) { struct iser_fr_pool *fr_pool = &ib_conn->fr_pool; struct iser_fr_desc *desc; @@ -198,8 +202,8 @@ iser_reg_desc_get(struct ib_conn *ib_conn) } void -iser_reg_desc_put(struct ib_conn *ib_conn, - struct iser_fr_desc *desc) +iser_reg_desc_put_fr(struct ib_conn *ib_conn, + struct iser_fr_desc *desc) { struct iser_fr_pool *fr_pool = &ib_conn->fr_pool; unsigned long flags; @@ -209,6 +213,21 @@ iser_reg_desc_put(struct ib_conn *ib_conn, spin_unlock_irqrestore(&fr_pool->lock, flags); } +struct iser_fr_desc * +iser_reg_desc_get_fmr(struct ib_conn *ib_conn) +{ + struct iser_fr_pool *fr_pool = &ib_conn->fr_pool; + + return list_first_entry(&fr_pool->list, + struct iser_fr_desc, list); +} + +void +iser_reg_desc_put_fmr(struct ib_conn *ib_conn, + struct iser_fr_desc *desc) +{ +} + /** * iser_start_rdma_unaligned_sg */ @@ -544,13 +563,14 @@ void iser_unreg_mem_fmr(struct iscsi_iser_task *iser_task, void iser_unreg_mem_fastreg(struct iscsi_iser_task *iser_task, enum iser_data_dir cmd_dir) { + struct iser_device *device = iser_task->iser_conn->ib_conn.device; struct iser_mem_reg *reg = &iser_task->rdma_reg[cmd_dir]; if (!reg->mem_h) return; - iser_reg_desc_put(&iser_task->iser_conn->ib_conn, - reg->mem_h); + device->reg_ops->reg_desc_put(&iser_task->iser_conn->ib_conn, + reg->mem_h); reg->mem_h = NULL; } @@ -564,7 +584,6 @@ int iser_reg_rdma_mem_fmr(struct iscsi_iser_task *iser_task, enum iser_data_dir cmd_dir) { struct ib_conn *ib_conn = &iser_task->iser_conn->ib_conn; - struct iser_fr_pool *fr_pool = &ib_conn->fr_pool; struct iser_device *device = ib_conn->device; struct ib_device *ibdev = device->ib_device; struct iser_data_buf *mem = &iser_task->data[cmd_dir]; @@ -590,8 +609,7 @@ int iser_reg_rdma_mem_fmr(struct iscsi_iser_task *iser_task, } else { /* use FMR for multiple dma entries */ struct iser_fr_desc *desc; - desc = list_first_entry(&fr_pool->list, - struct iser_fr_desc, list); + desc = device->reg_ops->reg_desc_get(ib_conn); err = iser_fast_reg_fmr(iser_task, mem, &desc->rsc, mem_reg); if (err && err != -EAGAIN) { iser_data_buf_dump(mem, ibdev); @@ -844,7 +862,7 @@ int iser_reg_rdma_mem_fastreg(struct iscsi_iser_task *iser_task, if (mem->dma_nents != 1 || scsi_get_prot_op(iser_task->sc) != SCSI_PROT_NORMAL) { - desc = iser_reg_desc_get(ib_conn); + desc = device->reg_ops->reg_desc_get(ib_conn); mem_reg->mem_h = desc; } @@ -887,7 +905,7 @@ int iser_reg_rdma_mem_fastreg(struct iscsi_iser_task *iser_task, return 0; err_reg: if (desc) - iser_reg_desc_put(ib_conn, desc); + device->reg_ops->reg_desc_put(ib_conn, desc); return err; }