From patchwork Tue Dec 15 06:03:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11974067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DB38C4361B for ; Tue, 15 Dec 2020 06:04:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E79EE20791 for ; Tue, 15 Dec 2020 06:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725926AbgLOGEz (ORCPT ); Tue, 15 Dec 2020 01:04:55 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:36375 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726147AbgLOGEu (ORCPT ); Tue, 15 Dec 2020 01:04:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1608012289; x=1639548289; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mQ0mk9gOb3GueQDoqDxI+x/4JSzU9z3SWA8da78K+fM=; b=WU8J55hokfed88f438gpdo42kO3j6xkH1nF2uQ/lGeIP2/0iooH9AoUn NwnRwDpFbxG2bcJwpxgyAXlqycHXBofAv6yqehGlZe5fdtAs6GK+Ymmo6 9Khsn2HU5kEbIXWqdOLsPQqe2Gd4pbFnM8Z086GNlNmx/p5DHTJTRX8jO PE/MOpFYc9AtBz6Rnc36AI1WrKaF3llXYlCr/ld/dXguLLPIizFGsGBOH Xj2wKGHbzM5+VVcRYXPP+Pd3NKCR7yQTBvrmggyJ6l+oCCb4Axp9wiQlv kBKZq/B9ASnNogCcpKJx4GMNgHUX5X79LcE/8oADUg5c42nCmsGecZbO3 w==; IronPort-SDR: AQTFYUTPXurAGYWtZtVZ5qqprvCerwYBrAw9jwrXpcK38Kf0hIyzGadf1b9KVGAOhm5P67gku4 Zbnb0kMQzkSDAEA8KefIwpbcSxm9zU1+yhpXTDD6nlpV7ZMsYOTShvK1424r4ENSqYB6TEz1Av B5ze2Xmfd09rbuDQ6K6gFhnaF51PgImme4xYRvs6FUjQYrXkSpPsSVfEVAvXw0PBIEDWKkeNpo +mGgXNtM39akfXs2Jr38KcKDS/XwksyluTRIy0gLNX+PfifKa3j1hFVubuW0y/AKhDG4XIjVck ews= X-IronPort-AV: E=Sophos;i="5.78,420,1599494400"; d="scan'208";a="155197994" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 15 Dec 2020 14:03:40 +0800 IronPort-SDR: spqTAyjhowsz35j9+axYLxe/wMFThOOEAZyRDljUXoZvjbv+wDNVorLnFWYuTKskAj2d0ChO85 NPnCHt76SO2EVFEykb8r6R4BvP7PN0zIYX7D4V4zs0jne80DmvMJy6wMsMLViuYBLqfiU/Bns6 WKkhgN8pgOea0WkCHvRNCx/VGl5Lnfhv/qwhkBfZV7Yq3sboUMzEJCku76+BLeQ5dBIMDH+UKy XUwG/qTbTdamdDu5/9Ofx7V5zMquTVfYAa00U48a7Qcf5oWo3zmXXqIk1gZg4XUHD9HkGp3HoA kspOaa/mmzz+G8O0uB3i7RZ8 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2020 21:49:00 -0800 IronPort-SDR: wamrKfPWR01aYsCEvUChlhXQ38kBLloCi3TywL6gkp2uCy1laa+Yz+CrxmZxbBkD/mCbWkGvhJ B3o72mRtzgl6nx2/R07pRcbxNMiRtTClh5GhgZ3QXnVio9HRRw0ujfD9asAm0JwuZn0oyeN7J6 W7CYQiTkdDyBe57p1DGw8hWue6plmUD7zgt2aBUqnF+dlIXmqnz4IkHQFb6023oPSYkLflIHMK MKvs15RpgoCJdrgZDhqQYtrADKbBJ1skIsKSgSVA58YcHuH+6yb4CiUexkGMcptkySD7keybiZ EN4= WDCIronportException: Internal Received: from vm.labspan.wdc.com (HELO vm.sc.wdc.com) ([10.6.137.102]) by uls-op-cesaip02.wdc.com with ESMTP; 14 Dec 2020 22:03:41 -0800 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: sagi@grimberg.me, hch@lst.de, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V7 3/6] nvmet: add NVM command set identifier support Date: Mon, 14 Dec 2020 22:03:02 -0800 Message-Id: <20201215060305.28141-4-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20201215060305.28141-1-chaitanya.kulkarni@wdc.com> References: <20201215060305.28141-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org NVMe TP 4056 allows controller to support different command sets. NVMeoF target currently only supports namespaces that contain traditional logical blocks that may be randomly read and written. In some applications there is value in exposing namespaces that contain logical blocks that have special access rules (e.g. sequentially write required namespace such as Zoned Namespace (ZNS)). In order to support the Zoned Block Devices (ZBD) backend, controller needs to have support for ZNS Command Set Identifier (CSI). In this preparation patch we adjust the code such that it can now support different command sets. We update the namespace data structure to store the CSI value which defaults to NVME_CSI_NVM which represents traditional logical blocks namespace type. The CSI support is required to implement the ZBD backend over NVMe ZNS interface, since ZNS commands belongs to different command set than the default one. Signed-off-by: Chaitanya Kulkarni --- drivers/nvme/target/admin-cmd.c | 33 ++++++++++++++++++++------------- drivers/nvme/target/core.c | 13 ++++++++++++- drivers/nvme/target/nvmet.h | 1 + 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index 74620240ac47..f4c0f3aca485 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -176,19 +176,26 @@ static void nvmet_execute_get_log_cmd_effects_ns(struct nvmet_req *req) if (!log) goto out; - log->acs[nvme_admin_get_log_page] = cpu_to_le32(1 << 0); - log->acs[nvme_admin_identify] = cpu_to_le32(1 << 0); - log->acs[nvme_admin_abort_cmd] = cpu_to_le32(1 << 0); - log->acs[nvme_admin_set_features] = cpu_to_le32(1 << 0); - log->acs[nvme_admin_get_features] = cpu_to_le32(1 << 0); - log->acs[nvme_admin_async_event] = cpu_to_le32(1 << 0); - log->acs[nvme_admin_keep_alive] = cpu_to_le32(1 << 0); - - log->iocs[nvme_cmd_read] = cpu_to_le32(1 << 0); - log->iocs[nvme_cmd_write] = cpu_to_le32(1 << 0); - log->iocs[nvme_cmd_flush] = cpu_to_le32(1 << 0); - log->iocs[nvme_cmd_dsm] = cpu_to_le32(1 << 0); - log->iocs[nvme_cmd_write_zeroes] = cpu_to_le32(1 << 0); + switch (req->cmd->get_log_page.csi) { + case NVME_CSI_NVM: + log->acs[nvme_admin_get_log_page] = cpu_to_le32(1 << 0); + log->acs[nvme_admin_identify] = cpu_to_le32(1 << 0); + log->acs[nvme_admin_abort_cmd] = cpu_to_le32(1 << 0); + log->acs[nvme_admin_set_features] = cpu_to_le32(1 << 0); + log->acs[nvme_admin_get_features] = cpu_to_le32(1 << 0); + log->acs[nvme_admin_async_event] = cpu_to_le32(1 << 0); + log->acs[nvme_admin_keep_alive] = cpu_to_le32(1 << 0); + + log->iocs[nvme_cmd_read] = cpu_to_le32(1 << 0); + log->iocs[nvme_cmd_write] = cpu_to_le32(1 << 0); + log->iocs[nvme_cmd_flush] = cpu_to_le32(1 << 0); + log->iocs[nvme_cmd_dsm] = cpu_to_le32(1 << 0); + log->iocs[nvme_cmd_write_zeroes] = cpu_to_le32(1 << 0); + break; + default: + status = NVME_SC_INVALID_LOG_PAGE; + break; + } status = nvmet_copy_to_sgl(req, 0, log, sizeof(*log)); diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index 8ce4d59cc9e7..672e4009f8d6 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -681,6 +681,7 @@ struct nvmet_ns *nvmet_ns_alloc(struct nvmet_subsys *subsys, u32 nsid) uuid_gen(&ns->uuid); ns->buffered_io = false; + ns->csi = NVME_CSI_NVM; return ns; } @@ -1103,6 +1104,16 @@ static inline u8 nvmet_cc_iocqes(u32 cc) return (cc >> NVME_CC_IOCQES_SHIFT) & 0xf; } +static inline bool nvmet_cc_css_check(u8 cc_css) +{ + switch (cc_css <<= NVME_CC_CSS_SHIFT) { + case NVME_CC_CSS_NVM: + return true; + default: + return false; + } +} + static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl) { lockdep_assert_held(&ctrl->lock); @@ -1111,7 +1122,7 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl) nvmet_cc_iocqes(ctrl->cc) != NVME_NVM_IOCQES || nvmet_cc_mps(ctrl->cc) != 0 || nvmet_cc_ams(ctrl->cc) != 0 || - nvmet_cc_css(ctrl->cc) != 0) { + !nvmet_cc_css_check(nvmet_cc_css(ctrl->cc))) { ctrl->csts = NVME_CSTS_CFS; return; } diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h index 8776dd1a0490..476b3cd91c65 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -81,6 +81,7 @@ struct nvmet_ns { struct pci_dev *p2p_dev; int pi_type; int metadata_size; + u8 csi; }; static inline struct nvmet_ns *to_nvmet_ns(struct config_item *item)