From patchwork Fri Mar 27 17:15:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Gurtovoy X-Patchwork-Id: 11462755 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4002117EA for ; Fri, 27 Mar 2020 17:15:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 298D82072F for ; Fri, 27 Mar 2020 17:15:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727702AbgC0RPx (ORCPT ); Fri, 27 Mar 2020 13:15:53 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:44748 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727242AbgC0RPw (ORCPT ); Fri, 27 Mar 2020 13:15:52 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from maxg@mellanox.com) with ESMTPS (AES256-SHA encrypted); 27 Mar 2020 20:15:46 +0300 Received: from mtr-vdi-031.wap.labs.mlnx. (mtr-vdi-031.wap.labs.mlnx [10.209.102.136]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 02RHFjj8004869; Fri, 27 Mar 2020 20:15:46 +0300 From: Max Gurtovoy To: linux-nvme@lists.infradead.org, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, martin.petersen@oracle.com, jsmart2021@gmail.com, linux-rdma@vger.kernel.org Cc: idanb@mellanox.com, axboe@kernel.dk, maxg@mellanox.com, vladimirk@mellanox.com, oren@mellanox.com, shlomin@mellanox.com, israelr@mellanox.com, jgg@mellanox.com Subject: [PATCH 05/17] nvme-fabrics: Allow user enabling metadata/T10-PI support Date: Fri, 27 Mar 2020 20:15:33 +0300 Message-Id: <20200327171545.98970-7-maxg@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200327171545.98970-1-maxg@mellanox.com> References: <20200327171545.98970-1-maxg@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Israel Rukshin Preparation for adding metadata (T10-PI) over fabric support. This will allow end-to-end protection information passthrough and validation for NVMe over Fabric. Signed-off-by: Israel Rukshin Reviewed-by: Max Gurtovoy --- drivers/nvme/host/core.c | 3 ++- drivers/nvme/host/fabrics.c | 11 +++++++++++ drivers/nvme/host/fabrics.h | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 2feb7fb..0b4d847 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1900,7 +1900,8 @@ static int __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id) * controller. */ if (ns->ctrl->ops->flags & NVME_F_METADATA_SUPPORTED) { - if (ns->ctrl->ops->flags & NVME_F_FABRICS || + if ((ns->ctrl->ops->flags & NVME_F_FABRICS && + ns->ctrl->opts->pi_enable) || !(ns->features & NVME_NS_EXT_LBAS)) ns->features |= NVME_NS_MD_HOST_SUPPORTED; } diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index 2a6c819..38f4213 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c @@ -612,6 +612,7 @@ bool __nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq, { NVMF_OPT_NR_WRITE_QUEUES, "nr_write_queues=%d" }, { NVMF_OPT_NR_POLL_QUEUES, "nr_poll_queues=%d" }, { NVMF_OPT_TOS, "tos=%d" }, + { NVMF_OPT_PI_ENABLE, "pi_enable" }, { NVMF_OPT_ERR, NULL } }; @@ -634,6 +635,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, opts->hdr_digest = false; opts->data_digest = false; opts->tos = -1; /* < 0 == use transport default */ + opts->pi_enable = false; options = o = kstrdup(buf, GFP_KERNEL); if (!options) @@ -867,6 +869,15 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, } opts->tos = token; break; +#ifdef CONFIG_BLK_DEV_INTEGRITY + case NVMF_OPT_PI_ENABLE: + if (opts->discovery_nqn) { + pr_debug("Ignoring pi_enable value for discovery controller\n"); + break; + } + opts->pi_enable = true; + break; +#endif default: pr_warn("unknown parameter or missing value '%s' in ctrl creation request\n", p); diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h index a0ec40a..773f748 100644 --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h @@ -56,6 +56,7 @@ enum { NVMF_OPT_NR_WRITE_QUEUES = 1 << 17, NVMF_OPT_NR_POLL_QUEUES = 1 << 18, NVMF_OPT_TOS = 1 << 19, + NVMF_OPT_PI_ENABLE = 1 << 20, }; /** @@ -89,6 +90,7 @@ enum { * @nr_write_queues: number of queues for write I/O * @nr_poll_queues: number of queues for polling I/O * @tos: type of service + * @pi_enable: Enable metadata (T10-PI) support */ struct nvmf_ctrl_options { unsigned mask; @@ -111,6 +113,7 @@ struct nvmf_ctrl_options { unsigned int nr_write_queues; unsigned int nr_poll_queues; int tos; + bool pi_enable; }; /*