From patchwork Mon Jun 8 13:15:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 6564971 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 879B99F2F4 for ; Mon, 8 Jun 2015 13:16:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7089420531 for ; Mon, 8 Jun 2015 13:16:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5C6A120527 for ; Mon, 8 Jun 2015 13:16:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752679AbbFHNQH (ORCPT ); Mon, 8 Jun 2015 09:16:07 -0400 Received: from [193.47.165.129] ([193.47.165.129]:48144 "EHLO mellanox.co.il" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752683AbbFHNQG (ORCPT ); Mon, 8 Jun 2015 09:16:06 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from sagig@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Jun 2015 16:15: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 t58DFRXD013889; Mon, 8 Jun 2015 16:15:27 +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 t58DFR8A000866; Mon, 8 Jun 2015 16:15:27 +0300 Received: (from sagig@localhost) by r-vnc05.mtr.labs.mlnx (8.14.4/8.14.4/Submit) id t58DFR6L000865; Mon, 8 Jun 2015 16:15:27 +0300 From: Sagi Grimberg To: Doug Ledford Cc: linux-rdma@vger.kernel.org, Or Gerlitz , Oren Duer , Sagi Grimberg Subject: [PATCH 10/11] IB/iser: Make reg_desc_get a per device routine Date: Mon, 8 Jun 2015 16:15:22 +0300 Message-Id: <1433769323-790-11-git-send-email-sagig@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1433769323-790-1-git-send-email-sagig@mellanox.com> References: <1433769323-790-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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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). 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 9383360..758e56b 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.h +++ b/drivers/infiniband/ulp/iser/iscsi_iser.h @@ -331,6 +331,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, @@ -340,6 +342,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); }; /** @@ -655,8 +660,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 300e23c..7ee7f44 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; }