From patchwork Tue Aug 15 09:52:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 9901529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2495160244 for ; Tue, 15 Aug 2017 09:52:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 159DD28815 for ; Tue, 15 Aug 2017 09:52:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0AADA28822; Tue, 15 Aug 2017 09:52: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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 3F3DC28815 for ; Tue, 15 Aug 2017 09:52:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753477AbdHOJwr (ORCPT ); Tue, 15 Aug 2017 05:52:47 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:43628 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753473AbdHOJwr (ORCPT ); Tue, 15 Aug 2017 05:52:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=arEhMIGxkKdsZSBK0hlSNWBKrR2lBrsFAqZvkybbiqE=; b=Lrxg83i5A1+vg6VRPKYDQ+MV1 ju02f1txVQU3zflKhz4s7wqRcUKSdq6V1XW5VllSCXX8NKrB6NRu4TILrUaQur8bmBVzKygmIAbmo kBslaQ0KkXtxsDa7Nn4DoyLbKlFg9whsEaBi+zw/GAzGB6u3W+clQ2DnoG8gcGUHP/HN0ao7tGS+8 7JcmERTtRHQwlgInT3idgh20GmI/kY9qovJ/3U3wOIw3hI8Ky858dIST8e2GmozyKn35k1jzTZbrE rWBbz0VyjusbiWphpUXmCJdwwZyj65hKUg22Xe5ti8d8BRsDRTHo/huW5gQfRrtNXAZhl710000x5 pW1YtEoWQ==; Received: from bzq-82-81-101-184.red.bezeqint.net ([82.81.101.184] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dhYWh-0007Bp-KS; Tue, 15 Aug 2017 09:52:44 +0000 From: Sagi Grimberg To: linux-nvme@lists.infradead.org, Christoph Hellwig , Keith Busch Cc: linux-block@vger.kernel.org Subject: [PATCH 08/12] nvme: add some ctrl ops for centralizing control plane logic. Date: Tue, 15 Aug 2017 12:52:21 +0300 Message-Id: <1502790745-12569-9-git-send-email-sagi@grimberg.me> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502790745-12569-1-git-send-email-sagi@grimberg.me> References: <1502790745-12569-1-git-send-email-sagi@grimberg.me> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The goal is to move a larger portion of the logic to nvme core, thus add admin/io queue and tagset callouts. 1. for queues we start with admin/io queues: ->alloc ->free ->start ->stop we separate admin and IO mostly to allow pci driver to free the queue in batches rather than one by one (to speed up the process). 2. for tagset we have: ->alloc_tagset ->free_tagset which accepts admin boolean. 3. we also has some misc ops: ->post_configure ->nr_hw_queues And I think we'll have more as we go. Signed-off-by: Sagi Grimberg --- drivers/nvme/host/nvme.h | 13 +++++++++ drivers/nvme/host/rdma.c | 76 ++++++++++++++++++++++++++++-------------------- 2 files changed, 57 insertions(+), 32 deletions(-) diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index c52ba1405788..7b8e57b3e634 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -235,6 +235,19 @@ struct nvme_ctrl_ops { void (*submit_async_event)(struct nvme_ctrl *ctrl, int aer_idx); int (*delete_ctrl)(struct nvme_ctrl *ctrl); int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size); + int (*alloc_admin_queue)(struct nvme_ctrl *ctrl); + void (*free_admin_queue)(struct nvme_ctrl *ctrl); + int (*start_admin_queue)(struct nvme_ctrl *ctrl); + void (*stop_admin_queue)(struct nvme_ctrl *ctrl); + int (*alloc_io_queues)(struct nvme_ctrl *ctrl); + void (*free_io_queues)(struct nvme_ctrl *ctrl); + int (*start_io_queues)(struct nvme_ctrl *ctrl); + void (*stop_io_queues)(struct nvme_ctrl *ctrl); + struct blk_mq_tag_set *(*alloc_tagset)(struct nvme_ctrl *ctrl, + bool admin); + void (*free_tagset)(struct nvme_ctrl *ctrl, bool admin); + int (*post_configure)(struct nvme_ctrl *ctrl); + unsigned int (*nr_hw_queues)(struct nvme_ctrl *ctrl); }; static inline bool nvme_ctrl_ready(struct nvme_ctrl *ctrl) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index b03c4a2a1172..cf4e4371c2db 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -757,12 +757,12 @@ static struct blk_mq_tag_set *nvme_rdma_alloc_tagset(struct nvme_ctrl *nctrl, static void nvme_rdma_destroy_admin_queue(struct nvme_ctrl *ctrl, bool remove) { - nvme_rdma_stop_admin_queue(ctrl); + ctrl->ops->stop_admin_queue(ctrl); if (remove) { blk_cleanup_queue(ctrl->admin_q); - nvme_rdma_free_tagset(ctrl, true); + ctrl->ops->free_tagset(ctrl, true); } - nvme_rdma_free_admin_queue(ctrl); + ctrl->ops->free_admin_queue(ctrl); } static int nvme_rdma_alloc_admin_queue(struct nvme_ctrl *nctrl) @@ -798,12 +798,12 @@ static int nvme_rdma_configure_admin_queue(struct nvme_ctrl *ctrl, { int error; - error = nvme_rdma_alloc_admin_queue(ctrl); + error = ctrl->ops->alloc_admin_queue(ctrl); if (error) return error; if (new) { - ctrl->admin_tagset = nvme_rdma_alloc_tagset(ctrl, true); + ctrl->admin_tagset = ctrl->ops->alloc_tagset(ctrl, true); if (IS_ERR(ctrl->admin_tagset)) goto out_free_queue; @@ -818,7 +818,7 @@ static int nvme_rdma_configure_admin_queue(struct nvme_ctrl *ctrl, goto out_free_queue; } - error = nvme_rdma_start_admin_queue(ctrl); + error = ctrl->ops->start_admin_queue(ctrl); if (error) goto out_cleanup_queue; @@ -846,21 +846,21 @@ static int nvme_rdma_configure_admin_queue(struct nvme_ctrl *ctrl, blk_cleanup_queue(ctrl->admin_q); out_free_tagset: if (new) - nvme_rdma_free_tagset(ctrl, true); + ctrl->ops->free_tagset(ctrl, true); out_free_queue: - nvme_rdma_free_admin_queue(ctrl); + ctrl->ops->free_admin_queue(ctrl); return error; } static void nvme_rdma_destroy_io_queues(struct nvme_ctrl *ctrl, bool remove) { - nvme_rdma_stop_io_queues(ctrl); + ctrl->ops->stop_io_queues(ctrl); if (remove) { blk_cleanup_queue(ctrl->connect_q); - nvme_rdma_free_tagset(ctrl, false); + ctrl->ops->free_tagset(ctrl, false); } - nvme_rdma_free_io_queues(ctrl); + ctrl->ops->free_io_queues(ctrl); } static int nvme_rdma_configure_io_queues(struct nvme_ctrl *ctrl, bool new) @@ -868,7 +868,7 @@ static int nvme_rdma_configure_io_queues(struct nvme_ctrl *ctrl, bool new) unsigned int nr_io_queues; int ret; - nr_io_queues = nvme_rdma_nr_io_queues(ctrl); + nr_io_queues = ctrl->ops->nr_hw_queues(ctrl); ret = nvme_set_queue_count(ctrl, &nr_io_queues); if (ret) return ret; @@ -880,12 +880,12 @@ static int nvme_rdma_configure_io_queues(struct nvme_ctrl *ctrl, bool new) dev_info(ctrl->device, "creating %d I/O queues.\n", nr_io_queues); - ret = nvme_rdma_alloc_io_queues(ctrl); + ret = ctrl->ops->alloc_io_queues(ctrl); if (ret) return ret; if (new) { - ctrl->tagset = nvme_rdma_alloc_tagset(ctrl, false); + ctrl->tagset = ctrl->ops->alloc_tagset(ctrl, false); if (IS_ERR(ctrl->tagset)) goto out_free_io_queues; @@ -914,9 +914,9 @@ static int nvme_rdma_configure_io_queues(struct nvme_ctrl *ctrl, bool new) blk_cleanup_queue(ctrl->connect_q); out_free_tag_set: if (new) - nvme_rdma_free_tagset(ctrl, false); + ctrl->ops->free_tagset(ctrl, false); out_free_io_queues: - nvme_rdma_free_io_queues(ctrl); + ctrl->ops->free_io_queues(ctrl); return ret; } @@ -1005,10 +1005,10 @@ static void nvme_rdma_error_recovery_work(struct work_struct *work) if (ctrl->queue_count > 1) { nvme_stop_queues(ctrl); - nvme_rdma_stop_io_queues(ctrl); + ctrl->ops->stop_io_queues(ctrl); } blk_mq_quiesce_queue(ctrl->admin_q); - nvme_rdma_stop_admin_queue(ctrl); + ctrl->ops->stop_admin_queue(ctrl); /* We must take care of fastfail/requeue all our inflight requests */ if (ctrl->queue_count > 1) @@ -1862,19 +1862,6 @@ static void nvme_rdma_reset_ctrl_work(struct work_struct *work) nvme_rdma_remove_ctrl(ctrl); } -static const struct nvme_ctrl_ops nvme_rdma_ctrl_ops = { - .name = "rdma", - .module = THIS_MODULE, - .flags = NVME_F_FABRICS, - .reg_read32 = nvmf_reg_read32, - .reg_read64 = nvmf_reg_read64, - .reg_write32 = nvmf_reg_write32, - .free_ctrl = nvme_rdma_free_ctrl, - .submit_async_event = nvme_rdma_submit_async_event, - .delete_ctrl = nvme_rdma_del_ctrl, - .get_address = nvmf_get_address, -}; - static int nvme_rdma_post_configure(struct nvme_ctrl *ctrl) { /* sanity check icdoff */ @@ -1908,6 +1895,31 @@ static int nvme_rdma_post_configure(struct nvme_ctrl *ctrl) return 0; } +static const struct nvme_ctrl_ops nvme_rdma_ctrl_ops = { + .name = "rdma", + .module = THIS_MODULE, + .flags = NVME_F_FABRICS, + .reg_read32 = nvmf_reg_read32, + .reg_read64 = nvmf_reg_read64, + .reg_write32 = nvmf_reg_write32, + .free_ctrl = nvme_rdma_free_ctrl, + .submit_async_event = nvme_rdma_submit_async_event, + .delete_ctrl = nvme_rdma_del_ctrl, + .get_address = nvmf_get_address, + .alloc_admin_queue = nvme_rdma_alloc_admin_queue, + .free_admin_queue = nvme_rdma_free_admin_queue, + .start_admin_queue = nvme_rdma_start_admin_queue, + .stop_admin_queue = nvme_rdma_stop_admin_queue, + .alloc_io_queues = nvme_rdma_alloc_io_queues, + .free_io_queues = nvme_rdma_free_io_queues, + .start_io_queues = nvme_rdma_start_io_queues, + .stop_io_queues = nvme_rdma_stop_io_queues, + .alloc_tagset = nvme_rdma_alloc_tagset, + .free_tagset = nvme_rdma_free_tagset, + .post_configure = nvme_rdma_post_configure, + .nr_hw_queues = nvme_rdma_nr_io_queues, +}; + static int nvme_rdma_probe_ctrl(struct nvme_ctrl *ctrl, struct device *dev, const struct nvme_ctrl_ops *ops, unsigned long quirks) { @@ -1925,7 +1937,7 @@ static int nvme_rdma_probe_ctrl(struct nvme_ctrl *ctrl, struct device *dev, if (ret) goto out_uninit_ctrl; - ret = nvme_rdma_post_configure(ctrl); + ret = ctrl->ops->post_configure(ctrl); if (ret) goto out_remove_admin_queue;