From patchwork Sat Feb 6 03:36:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12071863 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 E9ED9C433E0 for ; Sat, 6 Feb 2021 03:38:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5FB4264F9D for ; Sat, 6 Feb 2021 03:38:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5FB4264F9D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8EQk-0007ec-FE for qemu-devel@archiver.kernel.org; Fri, 05 Feb 2021 22:38:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8EOs-0005nw-13; Fri, 05 Feb 2021 22:36:46 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:33804) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8EOq-0003go-4v; Fri, 05 Feb 2021 22:36:45 -0500 Received: by mail-pl1-x631.google.com with SMTP id u15so4565613plf.1; Fri, 05 Feb 2021 19:36:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=S9rN2Kzxfipm4/AIkXB8mqZYbmUbYQoOU2bvhW0ijBI=; b=dYFZGp62N++FUxPLyRqXcSF2ZYiOUh3l9oXiwrJiQL/x63VpPYIZJNgO47l/BXooGw eZWm3KQllVBjojhjVhp+bt39dnHMXTl+k2udaZ4f2eanCi6DNU9vA6+75K96mhE6OLxt dVYB+1D9eLPq+QS1CCp3lVAtsUr6rkb8gOELStHx2ZOT+zlLxyq6BulQ5+YMJokC4kPI rbCTaGJm5BDfGcV4Ym58j73EBLrdpUc5fWKzSCaEinzrZQ0ruXWMUAPvWwvOCbO7sJiu EiVJ1XL4SslvTVNMgkOBdjo8O6tEtf3Nf7+JTLgUwraKUb9kM7Luw5ZhA688l7HtiUPz c7DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=S9rN2Kzxfipm4/AIkXB8mqZYbmUbYQoOU2bvhW0ijBI=; b=jOyO3pCpFsRiQwIV4g4uegIa0Z/Mk5Kh2KlKMkk/fjnZiaLalxq3PY9mKpN1sfFkMc 1Dtc0BigsnCYH8LXZ9+Vkl5MxrKtHxwy415WVfsqhYVK2xrRe4E1xekHymGmTL1vACGA vcrV0z2FSFPM6vZQMv+kG4Ma3x2RisvsLUM+UZdI8d175oO/awOVodZrNpkytj606uDn 6Hy+d9mvBysHKDT3KbZIYn7avBmFHrvMzO9I8sirlFKCq1Qb4x6idSQB+89xVKWoRpt0 SMviitByKzkV+nSCDkqScs2f+TikxIDfdeq/WT1mFSstFCBFe/dFTP7uvPob/gaz9ETS vUgg== X-Gm-Message-State: AOAM533JmklOFtEgCFtr5MnRYMlYjPEJ16nhlGVJh0MUdJt5DIDidTS7 AvB10/raa8txB/PT+oTTqRQGoWyFCFWVDQ== X-Google-Smtp-Source: ABdhPJzRzjFbp+CGhAMVBjpenjF6OKXCsFl8Sv1oB0SU01uekv5bTWwKVmHwM4Gtwucc63na+lhaaQ== X-Received: by 2002:a17:90a:9414:: with SMTP id r20mr7092917pjo.158.1612582601101; Fri, 05 Feb 2021 19:36:41 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id j17sm10862375pfh.183.2021.02.05.19.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 19:36:40 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [PATCH 1/6] hw/block/nvme: support namespace detach Date: Sat, 6 Feb 2021 12:36:24 +0900 Message-Id: <20210206033629.4278-2-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210206033629.4278-1-minwoo.im.dev@gmail.com> References: <20210206033629.4278-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Given that now we have nvme-subsys device supported, we can manage namespace allocated, but not attached: detached. This patch introduced a parameter for nvme-ns device named 'detached'. This parameter indicates whether the given namespace device is detached from a entire NVMe subsystem('subsys' given case, shared namespace) or a controller('bus' given case, private namespace). - Allocated namespace 1) Shared ns in the subsystem 'subsys0': -device nvme-ns,id=ns1,drive=blknvme0,nsid=1,subsys=subsys0,detached=true 2) Private ns for the controller 'nvme0' of the subsystem 'subsys0': -device nvme-subsys,id=subsys0 -device nvme,serial=foo,id=nvme0,subsys=subsys0 -device nvme-ns,id=ns1,drive=blknvme0,nsid=1,bus=nvme0,detached=true 3) (Invalid case) Controller 'nvme0' has no subsystem to manage ns: -device nvme,serial=foo,id=nvme0 -device nvme-ns,id=ns1,drive=blknvme0,nsid=1,bus=nvme0,detached=true Signed-off-by: Minwoo Im --- hw/block/nvme-ns.c | 1 + hw/block/nvme-ns.h | 1 + hw/block/nvme-subsys.h | 1 + hw/block/nvme.c | 41 +++++++++++++++++++++++++++++++++++++++-- hw/block/nvme.h | 22 ++++++++++++++++++++++ 5 files changed, 64 insertions(+), 2 deletions(-) diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c index c3b513b0fc78..cdcb81319fb5 100644 --- a/hw/block/nvme-ns.c +++ b/hw/block/nvme-ns.c @@ -393,6 +393,7 @@ static Property nvme_ns_props[] = { DEFINE_BLOCK_PROPERTIES(NvmeNamespace, blkconf), DEFINE_PROP_LINK("subsys", NvmeNamespace, subsys, TYPE_NVME_SUBSYS, NvmeSubsystem *), + DEFINE_PROP_BOOL("detached", NvmeNamespace, params.detached, false), DEFINE_PROP_UINT32("nsid", NvmeNamespace, params.nsid, 0), DEFINE_PROP_UUID("uuid", NvmeNamespace, params.uuid), DEFINE_PROP_UINT16("mssrl", NvmeNamespace, params.mssrl, 128), diff --git a/hw/block/nvme-ns.h b/hw/block/nvme-ns.h index 7af6884862b5..b0c00e115d81 100644 --- a/hw/block/nvme-ns.h +++ b/hw/block/nvme-ns.h @@ -26,6 +26,7 @@ typedef struct NvmeZone { } NvmeZone; typedef struct NvmeNamespaceParams { + bool detached; uint32_t nsid; QemuUUID uuid; diff --git a/hw/block/nvme-subsys.h b/hw/block/nvme-subsys.h index ccf6a71398d3..890d118117dc 100644 --- a/hw/block/nvme-subsys.h +++ b/hw/block/nvme-subsys.h @@ -23,6 +23,7 @@ typedef struct NvmeSubsystem { uint8_t subnqn[256]; NvmeCtrl *ctrls[NVME_SUBSYS_MAX_CTRLS]; + /* Allocated namespaces for this subsystem */ NvmeNamespace *namespaces[NVME_SUBSYS_MAX_NAMESPACES]; } NvmeSubsystem; diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 6b84e34843f5..a1e930f7c8e4 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -23,7 +23,7 @@ * max_ioqpairs=, \ * aerl=, aer_max_queued=, \ * mdts=,zoned.append_size_limit=, \ - * subsys= \ + * subsys=,detached= * -device nvme-ns,drive=,bus=,nsid=,\ * zoned=, \ * subsys= @@ -78,6 +78,13 @@ * controllers in the subsystem. Otherwise, `bus` must be given to attach * this namespace to a specified single controller as a non-shared namespace. * + * - `detached` + * Not to attach the namespace device to controllers in the NVMe subsystem + * during boot-up. If not given, namespaces are all attahced to all + * controllers in the subsystem by default. + * It's mutual exclusive with 'bus' parameter. It's only valid in case + * `subsys` is provided. + * * Setting `zoned` to true selects Zoned Command Set at the namespace. * In this case, the following namespace properties are available to configure * zoned operation: @@ -4521,6 +4528,20 @@ static void nvme_init_state(NvmeCtrl *n) n->aer_reqs = g_new0(NvmeRequest *, n->params.aerl + 1); } +static int nvme_attach_namespace(NvmeCtrl *n, NvmeNamespace *ns, Error **errp) +{ + if (nvme_ns_is_attached(n, ns)) { + error_setg(errp, + "namespace %d is already attached to controller %d", + nvme_nsid(ns), n->cntlid); + return -1; + } + + nvme_ns_attach(n, ns); + + return 0; +} + int nvme_register_namespace(NvmeCtrl *n, NvmeNamespace *ns, Error **errp) { uint32_t nsid = nvme_nsid(ns); @@ -4552,7 +4573,23 @@ int nvme_register_namespace(NvmeCtrl *n, NvmeNamespace *ns, Error **errp) trace_pci_nvme_register_namespace(nsid); - n->namespaces[nsid - 1] = ns; + /* + * If subsys is not given, namespae is always attached to the controller + * because there's no subsystem to manage namespace allocation. + */ + if (!n->subsys) { + if (ns->params.detached) { + error_setg(errp, + "detached needs nvme-subsys specified nvme or nvme-ns"); + return -1; + } + + return nvme_attach_namespace(n, ns, errp); + } else { + if (!ns->params.detached) { + return nvme_attach_namespace(n, ns, errp); + } + } return 0; } diff --git a/hw/block/nvme.h b/hw/block/nvme.h index cb2b5175f1a1..bde0ed7c2679 100644 --- a/hw/block/nvme.h +++ b/hw/block/nvme.h @@ -176,6 +176,10 @@ typedef struct NvmeCtrl { NvmeSubsystem *subsys; NvmeNamespace namespace; + /* + * Attached namespaces to this controller. If subsys is not given, all + * namespaces in this list will always be attached. + */ NvmeNamespace *namespaces[NVME_MAX_NAMESPACES]; NvmeSQueue **sq; NvmeCQueue **cq; @@ -194,6 +198,24 @@ static inline NvmeNamespace *nvme_ns(NvmeCtrl *n, uint32_t nsid) return n->namespaces[nsid - 1]; } +static inline bool nvme_ns_is_attached(NvmeCtrl *n, NvmeNamespace *ns) +{ + int nsid; + + for (nsid = 1; nsid <= n->num_namespaces; nsid++) { + if (nvme_ns(n, nsid) == ns) { + return true; + } + } + + return false; +} + +static inline void nvme_ns_attach(NvmeCtrl *n, NvmeNamespace *ns) +{ + n->namespaces[nvme_nsid(ns) - 1] = ns; +} + static inline NvmeCQueue *nvme_cq(NvmeRequest *req) { NvmeSQueue *sq = req->sq; From patchwork Sat Feb 6 03:36:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12071861 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 2A105C433DB for ; Sat, 6 Feb 2021 03:38:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A8F7964DFA for ; Sat, 6 Feb 2021 03:38:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A8F7964DFA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8EQg-0007as-Ax for qemu-devel@archiver.kernel.org; Fri, 05 Feb 2021 22:38:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8EOt-0005qO-Ik; Fri, 05 Feb 2021 22:36:47 -0500 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:52258) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8EOr-0003ha-8R; Fri, 05 Feb 2021 22:36:47 -0500 Received: by mail-pj1-x102a.google.com with SMTP id q72so4667327pjq.2; Fri, 05 Feb 2021 19:36:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Tba0cycsltwUC73PsTkrnovi7914K2kfDYRvppj6aFo=; b=XPlsnorcMY8zpRVO5amxQIQ7usNTwiTabNgXr6YXkAmd4xZZwP9hihFseqg11VylCQ l6V0HqTGKNqS4vOXtJgHUijNBwqVxsMcet6V6+gzCdJzAybkcv3/jhywpAjZ0OqUyv3Y MVGgrmm8smadRpnM9E2XwYxjV7EwJPSqlllRCzHURZPPUqSW1mdsIIdBeSjE+THj+hX2 G44kJKwVlv6lEySxc6JRxuMIEIHGYaS6hdzovGxKEXcwPugdKlt3cxgYTWIfgtMSbf+T roxB7dPZJO16Y/g+nul9K5mJwYnqzG3Hb+YEI7wdjD8gCOTkej3aCV4t6Ri9ZGCR6MTq PzOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Tba0cycsltwUC73PsTkrnovi7914K2kfDYRvppj6aFo=; b=T2HMG637obRpGJsHu//9sQtzN+gfA7pJnCaUgWyPP2EksYmaXnN+uzO3Sc9TiD65YW CyxAJFgPoHyQez5g2Tu+geyy8vOZDnB6v97hVCHShZ6XQmEbi4/i/tZ6C9h5JYHnOSfR 9ei745Yk85HkElQ9FnpC3sX7kfAxW+8E0AQc7iCkF1Sy4iS12YjkrAUgPpkgklCxiZPZ Z8YF6/8zZydnprdWa63AbOYPPzm194kUqbxgGoxsRKeL8f4f+KOZcXebL8gSVXQ3kop9 Ig6zMhBwaqXd9k2rZ0/2HGlgbUjm8M4F535rDL13twAtZxX0s4YhxcgwTj9fPrfCiOyG /ehw== X-Gm-Message-State: AOAM531q4m9h9b4SoMR6AgGO8DuHVaUJVFuB/QNw28E7Tl/BBwEjzZl5 rR4tE3q530T4zCBVHM7WnBDat1t4U5uqKg== X-Google-Smtp-Source: ABdhPJyAUvFqCTusu6uEQNoAADYvptL2FfzD837Gji0pkkKaN2kpN0ag8wlqGt0T4PWl+6peY5SLow== X-Received: by 2002:a17:90a:4a0e:: with SMTP id e14mr7119834pjh.200.1612582603441; Fri, 05 Feb 2021 19:36:43 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id j17sm10862375pfh.183.2021.02.05.19.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 19:36:43 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [PATCH 2/6] hw/block/nvme: fix namespaces array to 1-based Date: Sat, 6 Feb 2021 12:36:25 +0900 Message-Id: <20210206033629.4278-3-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210206033629.4278-1-minwoo.im.dev@gmail.com> References: <20210206033629.4278-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" subsys->namespaces array used to be sized to NVME_SUBSYS_MAX_NAMESPACES. But subsys->namespaces are being accessed with 1-based namespace id which means the very first array entry will always be empty(NULL). Signed-off-by: Minwoo Im --- hw/block/nvme-subsys.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/block/nvme-subsys.h b/hw/block/nvme-subsys.h index 890d118117dc..574774390c4c 100644 --- a/hw/block/nvme-subsys.h +++ b/hw/block/nvme-subsys.h @@ -24,7 +24,7 @@ typedef struct NvmeSubsystem { NvmeCtrl *ctrls[NVME_SUBSYS_MAX_CTRLS]; /* Allocated namespaces for this subsystem */ - NvmeNamespace *namespaces[NVME_SUBSYS_MAX_NAMESPACES]; + NvmeNamespace *namespaces[NVME_SUBSYS_MAX_NAMESPACES + 1]; } NvmeSubsystem; int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp); From patchwork Sat Feb 6 03:36:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12071865 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 28EF4C433DB for ; Sat, 6 Feb 2021 03:38:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD18D64DFA for ; Sat, 6 Feb 2021 03:38:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD18D64DFA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8EQo-0007r5-Ta for qemu-devel@archiver.kernel.org; Fri, 05 Feb 2021 22:38:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8EOv-0005u6-8K; Fri, 05 Feb 2021 22:36:49 -0500 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:40864) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8EOt-0003i3-Pa; Fri, 05 Feb 2021 22:36:48 -0500 Received: by mail-pf1-x42d.google.com with SMTP id i63so5612303pfg.7; Fri, 05 Feb 2021 19:36:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Abv+wakfYHnDIu4Rl391RohO9DmRG+0B+bBge9capEA=; b=fggVsCVzwKn8lIOoMJNsX4LJ652swjZcP/FeHWVk9I3cjdmIfQxnCO9AzlHJ/GKOiZ +fJpZ/iAmAqRHmmlCrTTXzP1FgUJnHBFy32H3Nfptrwrk+G3JKjHAFU3fbqdg3+hLigO KKxa6dZ/4VDwrB8QPdACfgAHsKrGJv3pTgYAyU3tK5qEl44nRm6NU4sw5Vg4z0Z3zg+R mJLdPxrMEFmK5NZ/OBAUJDNBwDE0nTCPd2Z2RixtipTryyVE31a5r6fqcmzsn1N1jCEz vjCEqobD26oMwptt6jOTtkxsBBC4Q+uK9/LhkyQhRMwfuKKc9ujoTPSS3KSRWos9r0Hj FvEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Abv+wakfYHnDIu4Rl391RohO9DmRG+0B+bBge9capEA=; b=lTv67Cf5NrhvlVf3y2Vyt7YgW28p3XDeXGqw5p6VvDAG5uAWnkLiAKG7ToES7PsOxh pkPGTQLSalscMuA98QdXotHYmb+eXl7hhxW5TH6JDvKbedJz/VK7ViPB62hWaCagghJr V7fKTYQyaV+eO3IwmErDmyG69AYJhkOWC51CnMeHVvGBtUNFjymAx2wY1puvhT6Q+cIs UeC0b/wcfirCZU6pQQl43YuqzEFIJ5os5YrboXZu3V4N7rHaut8drTlpAFjhvrKcy2zd 4dQZYINm84di6NKkJjrjJ2iQBeP1/Ei5RzbjGBswMCtvNCdBqZvT1j3V+y6gmudEMIGf 3g9Q== X-Gm-Message-State: AOAM530bfRt3JjIwRH0+aRfH90aFQf0hVSI2LkedlThUJwPPHG2oS0mn STGHioDts/7+4iTuqUm2YiB27e1AKH5JUg== X-Google-Smtp-Source: ABdhPJx6R1t17JZzCdGOCV6jctuJpLuDtVb971M8v/HimEQrRqpLokEGhwbR5qi0/pxCVzuT1KvT8Q== X-Received: by 2002:a63:c205:: with SMTP id b5mr7422154pgd.281.1612582605807; Fri, 05 Feb 2021 19:36:45 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id j17sm10862375pfh.183.2021.02.05.19.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 19:36:45 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [PATCH 3/6] hw/block/nvme: fix allocated namespace list to 256 Date: Sat, 6 Feb 2021 12:36:26 +0900 Message-Id: <20210206033629.4278-4-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210206033629.4278-1-minwoo.im.dev@gmail.com> References: <20210206033629.4278-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Expand allocated namespace list (subsys->namespaces) to have 256 entries which is a value lager than at least NVME_MAX_NAMESPACES which is for attached namespace list in a controller. Allocated namespace list should at least larger than attached namespace list. n->num_namespaces = NVME_MAX_NAMESPACES; The above line will set the NN field by id->nn so that the subsystem should also prepare at least this number of namespace list entries. Signed-off-by: Minwoo Im --- hw/block/nvme-subsys.h | 2 +- hw/block/nvme.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/block/nvme-subsys.h b/hw/block/nvme-subsys.h index 574774390c4c..8a0732b22316 100644 --- a/hw/block/nvme-subsys.h +++ b/hw/block/nvme-subsys.h @@ -14,7 +14,7 @@ OBJECT_CHECK(NvmeSubsystem, (obj), TYPE_NVME_SUBSYS) #define NVME_SUBSYS_MAX_CTRLS 32 -#define NVME_SUBSYS_MAX_NAMESPACES 32 +#define NVME_SUBSYS_MAX_NAMESPACES 256 typedef struct NvmeCtrl NvmeCtrl; typedef struct NvmeNamespace NvmeNamespace; diff --git a/hw/block/nvme.h b/hw/block/nvme.h index bde0ed7c2679..1c7796b20996 100644 --- a/hw/block/nvme.h +++ b/hw/block/nvme.h @@ -10,6 +10,12 @@ #define NVME_DEFAULT_ZONE_SIZE (128 * MiB) #define NVME_DEFAULT_MAX_ZA_SIZE (128 * KiB) +/* + * Subsystem namespace list for allocated namespaces should be larger than + * attached namespace list in a controller. + */ +QEMU_BUILD_BUG_ON(NVME_MAX_NAMESPACES > NVME_SUBSYS_MAX_NAMESPACES); + typedef struct NvmeParams { char *serial; uint32_t num_queues; /* deprecated since 5.1 */ From patchwork Sat Feb 6 03:36:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12071867 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 26D5FC433E0 for ; Sat, 6 Feb 2021 03:40:08 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CEA5364FA8 for ; Sat, 6 Feb 2021 03:40:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CEA5364FA8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8ES7-00025R-0d for qemu-devel@archiver.kernel.org; Fri, 05 Feb 2021 22:40:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8EOy-00061A-1n; Fri, 05 Feb 2021 22:36:52 -0500 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:50496) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8EOw-0003iy-3i; Fri, 05 Feb 2021 22:36:51 -0500 Received: by mail-pj1-x1035.google.com with SMTP id cl8so4671152pjb.0; Fri, 05 Feb 2021 19:36:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XmjP9NNuBar/smLFXQK8etvVLNaY3fMCsBYhqWhRS34=; b=CxZ8OAgXTmgVGlecdFlML+/t7AixH8l/2hXYD13wjg3MTuQZ0pMyFKSD4jhIBAcauC i5EguzkPUOPPBgYT86kflII+xNvsYkcv2SjQ7MTW3+PHd0sWf43ESlIAfTbBY0tQjudO OBWyAugs85IVEOZ+5/xPoK7QZo+AoGaihPSY4fswueqkEblWTQmiBH0Ybn7rJcKAOOEw Yd7uqQIzTQqfDEHURhOo4ufSg0n9JdhIPtlyQhBfWHfHbmCXeKLRDtt9aGmti6yuHW4v coInH649REYng/ESeg2NsEXhAIitkhI05NZ31zv1AAI2k10jz+fPrHjUQ9CAuUj4a8B6 tdlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XmjP9NNuBar/smLFXQK8etvVLNaY3fMCsBYhqWhRS34=; b=oJZnpzlGjMchISLiMzG/ZDdeQXaq4kDirgcoDLL+T15AuxABtUDIbVTA+Cy7vU2wd/ emx0BSAIzDqyG/8SUub3VsMmojdyStuzlKParbCnzlWh8d+m0//vPa3ZGDZhEe4MNGQx nwFOF+JVetonEEPBBnV1V/1L11eFu8M/yCU2dkkR9KG5/X49oke6VTBl3WbC095GYoE4 /vuKRujSLlPGeI/J8km/IlrVY2I7rnhmXyOIhbO1wWucl83G1tIXCncVM+gAeToVyyMH cAEC/3tc8zliJTrdj8SsOW1joXEMZUSAYIkzCHu+KIex/fyeaNUjKR8DlKDMso7XBu/u owaw== X-Gm-Message-State: AOAM531KJlWwSzSU0HbCUI1px832jfa1svaYUyAw/IVWU6wQRVVPhWmH dCckATSuv2+MC7KpibmqghdSs4taavuGQg== X-Google-Smtp-Source: ABdhPJwnXrNF1FRA63L3j+zMoj3X3pqVviI97nCHojk+cGlqb7j9HyligkACRLoBMWjKf/QrpHuRVQ== X-Received: by 2002:a17:902:c684:b029:df:fab3:63de with SMTP id r4-20020a170902c684b02900dffab363demr6876232plx.81.1612582608239; Fri, 05 Feb 2021 19:36:48 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id j17sm10862375pfh.183.2021.02.05.19.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 19:36:47 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [PATCH 4/6] hw/block/nvme: support allocated namespace type Date: Sat, 6 Feb 2021 12:36:27 +0900 Message-Id: <20210206033629.4278-5-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210206033629.4278-1-minwoo.im.dev@gmail.com> References: <20210206033629.4278-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pj1-x1035.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From NVMe spec 1.4b "6.1.5. NSID and Namespace Relationships" defines valid namespace types: - Unallocated: Not exists in the NVMe subsystem - Allocated: Exists in the NVMe subsystem - Inactive: Not attached to the controller - Active: Attached to the controller This patch added support for allocated, but not attached namespace type: !nvme_ns(n, nsid) && nvme_subsys_ns(n->subsys, nsid) nvme_ns() returns attached namespace instance of the given controller and nvme_subsys_ns() returns allocated namespace instance in the subsystem. Signed-off-by: Minwoo Im --- hw/block/nvme-subsys.h | 13 +++++++++ hw/block/nvme.c | 63 +++++++++++++++++++++++++++++++----------- 2 files changed, 60 insertions(+), 16 deletions(-) diff --git a/hw/block/nvme-subsys.h b/hw/block/nvme-subsys.h index 8a0732b22316..14627f9ccb41 100644 --- a/hw/block/nvme-subsys.h +++ b/hw/block/nvme-subsys.h @@ -30,4 +30,17 @@ typedef struct NvmeSubsystem { int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp); int nvme_subsys_register_ns(NvmeNamespace *ns, Error **errp); +/* + * Return allocated namespace of the specified nsid in the subsystem. + */ +static inline NvmeNamespace *nvme_subsys_ns(NvmeSubsystem *subsys, + uint32_t nsid) +{ + if (!subsys) { + return NULL; + } + + return subsys->namespaces[nsid]; +} + #endif /* NVME_SUBSYS_H */ diff --git a/hw/block/nvme.c b/hw/block/nvme.c index a1e930f7c8e4..d1761a82731f 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -3124,7 +3124,7 @@ static uint16_t nvme_identify_ctrl_csi(NvmeCtrl *n, NvmeRequest *req) return NVME_INVALID_FIELD | NVME_DNR; } -static uint16_t nvme_identify_ns(NvmeCtrl *n, NvmeRequest *req) +static uint16_t nvme_identify_ns(NvmeCtrl *n, NvmeRequest *req, bool active) { NvmeNamespace *ns; NvmeIdentify *c = (NvmeIdentify *)&req->cmd; @@ -3138,7 +3138,14 @@ static uint16_t nvme_identify_ns(NvmeCtrl *n, NvmeRequest *req) ns = nvme_ns(n, nsid); if (unlikely(!ns)) { - return nvme_rpt_empty_id_struct(n, req); + if (!active) { + ns = nvme_subsys_ns(n->subsys, nsid); + if (!ns) { + return nvme_rpt_empty_id_struct(n, req); + } + } else { + return nvme_rpt_empty_id_struct(n, req); + } } if (c->csi == NVME_CSI_NVM && nvme_csi_has_nvm_support(ns)) { @@ -3149,7 +3156,8 @@ static uint16_t nvme_identify_ns(NvmeCtrl *n, NvmeRequest *req) return NVME_INVALID_CMD_SET | NVME_DNR; } -static uint16_t nvme_identify_ns_csi(NvmeCtrl *n, NvmeRequest *req) +static uint16_t nvme_identify_ns_csi(NvmeCtrl *n, NvmeRequest *req, + bool active) { NvmeNamespace *ns; NvmeIdentify *c = (NvmeIdentify *)&req->cmd; @@ -3163,7 +3171,14 @@ static uint16_t nvme_identify_ns_csi(NvmeCtrl *n, NvmeRequest *req) ns = nvme_ns(n, nsid); if (unlikely(!ns)) { - return nvme_rpt_empty_id_struct(n, req); + if (!active) { + ns = nvme_subsys_ns(n->subsys, nsid); + if (!ns) { + return nvme_rpt_empty_id_struct(n, req); + } + } else { + return nvme_rpt_empty_id_struct(n, req); + } } if (c->csi == NVME_CSI_NVM && nvme_csi_has_nvm_support(ns)) { @@ -3176,7 +3191,8 @@ static uint16_t nvme_identify_ns_csi(NvmeCtrl *n, NvmeRequest *req) return NVME_INVALID_FIELD | NVME_DNR; } -static uint16_t nvme_identify_nslist(NvmeCtrl *n, NvmeRequest *req) +static uint16_t nvme_identify_nslist(NvmeCtrl *n, NvmeRequest *req, + bool active) { NvmeNamespace *ns; NvmeIdentify *c = (NvmeIdentify *)&req->cmd; @@ -3201,7 +3217,14 @@ static uint16_t nvme_identify_nslist(NvmeCtrl *n, NvmeRequest *req) for (i = 1; i <= n->num_namespaces; i++) { ns = nvme_ns(n, i); if (!ns) { - continue; + if (!active) { + ns = nvme_subsys_ns(n->subsys, i); + if (!ns) { + continue; + } + } else { + continue; + } } if (ns->params.nsid <= min_nsid) { continue; @@ -3215,7 +3238,8 @@ static uint16_t nvme_identify_nslist(NvmeCtrl *n, NvmeRequest *req) return nvme_dma(n, list, data_len, DMA_DIRECTION_FROM_DEVICE, req); } -static uint16_t nvme_identify_nslist_csi(NvmeCtrl *n, NvmeRequest *req) +static uint16_t nvme_identify_nslist_csi(NvmeCtrl *n, NvmeRequest *req, + bool active) { NvmeNamespace *ns; NvmeIdentify *c = (NvmeIdentify *)&req->cmd; @@ -3241,7 +3265,14 @@ static uint16_t nvme_identify_nslist_csi(NvmeCtrl *n, NvmeRequest *req) for (i = 1; i <= n->num_namespaces; i++) { ns = nvme_ns(n, i); if (!ns) { - continue; + if (!active) { + ns = nvme_subsys_ns(n->subsys, i); + if (!ns) { + continue; + } + } else { + continue; + } } if (ns->params.nsid <= min_nsid || c->csi != ns->csi) { continue; @@ -3321,25 +3352,25 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeRequest *req) switch (le32_to_cpu(c->cns)) { case NVME_ID_CNS_NS: - /* fall through */ + return nvme_identify_ns(n, req, true); case NVME_ID_CNS_NS_PRESENT: - return nvme_identify_ns(n, req); + return nvme_identify_ns(n, req, false); case NVME_ID_CNS_CS_NS: - /* fall through */ + return nvme_identify_ns_csi(n, req, true); case NVME_ID_CNS_CS_NS_PRESENT: - return nvme_identify_ns_csi(n, req); + return nvme_identify_ns_csi(n, req, false); case NVME_ID_CNS_CTRL: return nvme_identify_ctrl(n, req); case NVME_ID_CNS_CS_CTRL: return nvme_identify_ctrl_csi(n, req); case NVME_ID_CNS_NS_ACTIVE_LIST: - /* fall through */ + return nvme_identify_nslist(n, req, true); case NVME_ID_CNS_NS_PRESENT_LIST: - return nvme_identify_nslist(n, req); + return nvme_identify_nslist(n, req, false); case NVME_ID_CNS_CS_NS_ACTIVE_LIST: - /* fall through */ + return nvme_identify_nslist_csi(n, req, true); case NVME_ID_CNS_CS_NS_PRESENT_LIST: - return nvme_identify_nslist_csi(n, req); + return nvme_identify_nslist_csi(n, req, false); case NVME_ID_CNS_NS_DESCR_LIST: return nvme_identify_ns_descr_list(n, req); case NVME_ID_CNS_IO_COMMAND_SET: From patchwork Sat Feb 6 03:36:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12071869 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 C9045C433DB for ; Sat, 6 Feb 2021 03:40:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4151664DFA for ; Sat, 6 Feb 2021 03:40:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4151664DFA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8ESE-0002GN-Bh for qemu-devel@archiver.kernel.org; Fri, 05 Feb 2021 22:40:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8EOz-00066D-Ro; Fri, 05 Feb 2021 22:36:53 -0500 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:36108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8EOy-0003kz-DN; Fri, 05 Feb 2021 22:36:53 -0500 Received: by mail-pg1-x52c.google.com with SMTP id c132so5907926pga.3; Fri, 05 Feb 2021 19:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dFWs89OqpA2FHpdtCvYIxkSfqPquW2C/ITVpO+zm4M0=; b=VKfFNN6KO1uKcS0fVQC+N6CKHh6SUFtzNV9TKkTP+CdyKal4NI6eEEgNEfuwULYnVX LyjND5Yc+cOTJWjm5p21F1v4r24rOqen5k2sN/BtRDGnjQyqGMkELbhmY7fa9enXprpq rO9kDx2bu7zrtcx4Js6V3O7jYJCzzWyc7L4bhQmocv/FtFfEzJewNmz36cQ/817tk3mW S7LDaHDL2yXKuAZpWIiS3Zu2UALFu7F/AcDRuTjoZRJcbvuNIyuD8zMRKRq0QKo+vwqr 4JczbGIbySMptPxEa77A4nBpjhakT1ROuYxNf+SGIoF3fML/JD8SM/Y3ncInflruBNB5 7EKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dFWs89OqpA2FHpdtCvYIxkSfqPquW2C/ITVpO+zm4M0=; b=oTBwD5C+tq6zcxj1xk74ehIIAuDqT4hE27+qkjj0fKdXzLgNkrCXbBXZ8ebLRfhRWT LbWWMrt/Q02XU6IYNdAhf3Y2kisVrLIajNjnS2/6vvzcelfHZ0CCHX1OlJL6jXZpqDRT t2bMXSFFGc2Cs8oC1tTLSxVCuqwmF8GkjmMsm7tXtbjgHH0Ml4AOkPd+hVThIAb1bIMH TsMvD5ObJYKLhw4bve/jA0058TCPyWCsu/SJo1hpeMFcSnCbgx9ek8EqjzQ2xQpLMKkz Ve9WqlTDana3MroGZZpVlW8rs027r/yFq4Zjsu81bGK+e+1SwJBG3mcprBfaT2ya2eXX k/Mw== X-Gm-Message-State: AOAM531wj/htLtmX/zYRGT9+lVz3WVZA7TwDXlspq2z5jHPr118gzIZh ERHEiGFJM8iYPfIKwkr4PFvQDQQ+HqiElw== X-Google-Smtp-Source: ABdhPJwzjXWHR/i2cMRWRrT2VH1V/hU4u+gFhWeZfhFAZ19CNwBGCqWigkYn4SJXZvdQqHHK01HLZQ== X-Received: by 2002:a62:cd02:0:b029:1bc:9fe2:b00c with SMTP id o2-20020a62cd020000b02901bc9fe2b00cmr7504201pfg.23.1612582610672; Fri, 05 Feb 2021 19:36:50 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id j17sm10862375pfh.183.2021.02.05.19.36.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 19:36:50 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [PATCH 5/6] hw/block/nvme: refactor nvme_select_ns_iocs Date: Sat, 6 Feb 2021 12:36:28 +0900 Message-Id: <20210206033629.4278-6-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210206033629.4278-1-minwoo.im.dev@gmail.com> References: <20210206033629.4278-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pg1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This patch has no functional changes. This patch just refactored nvme_select_ns_iocs() to iterate the attached namespaces of the controlller and make it invoke __nvme_select_ns_iocs(). Signed-off-by: Minwoo Im --- hw/block/nvme.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index d1761a82731f..697368a6ae0c 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -3896,6 +3896,25 @@ static void nvme_ctrl_shutdown(NvmeCtrl *n) } } +static void __nvme_select_ns_iocs(NvmeCtrl *n, NvmeNamespace *ns) +{ + ns->iocs = nvme_cse_iocs_none; + switch (ns->csi) { + case NVME_CSI_NVM: + if (NVME_CC_CSS(n->bar.cc) != NVME_CC_CSS_ADMIN_ONLY) { + ns->iocs = nvme_cse_iocs_nvm; + } + break; + case NVME_CSI_ZONED: + if (NVME_CC_CSS(n->bar.cc) == NVME_CC_CSS_CSI) { + ns->iocs = nvme_cse_iocs_zoned; + } else if (NVME_CC_CSS(n->bar.cc) == NVME_CC_CSS_NVM) { + ns->iocs = nvme_cse_iocs_nvm; + } + break; + } +} + static void nvme_select_ns_iocs(NvmeCtrl *n) { NvmeNamespace *ns; @@ -3906,21 +3925,8 @@ static void nvme_select_ns_iocs(NvmeCtrl *n) if (!ns) { continue; } - ns->iocs = nvme_cse_iocs_none; - switch (ns->csi) { - case NVME_CSI_NVM: - if (NVME_CC_CSS(n->bar.cc) != NVME_CC_CSS_ADMIN_ONLY) { - ns->iocs = nvme_cse_iocs_nvm; - } - break; - case NVME_CSI_ZONED: - if (NVME_CC_CSS(n->bar.cc) == NVME_CC_CSS_CSI) { - ns->iocs = nvme_cse_iocs_zoned; - } else if (NVME_CC_CSS(n->bar.cc) == NVME_CC_CSS_NVM) { - ns->iocs = nvme_cse_iocs_nvm; - } - break; - } + + __nvme_select_ns_iocs(n, ns); } } From patchwork Sat Feb 6 03:36:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minwoo Im X-Patchwork-Id: 12071877 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 8270DC433E0 for ; Sat, 6 Feb 2021 03:42:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 407CA64FA0 for ; Sat, 6 Feb 2021 03:42:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 407CA64FA0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8EU1-0003iJ-Do for qemu-devel@archiver.kernel.org; Fri, 05 Feb 2021 22:42:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8EP4-0006DL-14; Fri, 05 Feb 2021 22:36:59 -0500 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]:43241) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8EP0-0003lS-Un; Fri, 05 Feb 2021 22:36:57 -0500 Received: by mail-pg1-x530.google.com with SMTP id n10so5889837pgl.10; Fri, 05 Feb 2021 19:36:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V1gjdZ2JRPOoWQInDj1RVCMU7YB1iohDQS4AqWqM1pY=; b=f9dWd636azPSWg2i+rwG3oj2PdZK7z+EfryZQAjeJvinloNR80/2oRvhTE2It30vcX 4lUJfca9O1JyJIWJ4UggxyLzR1VDKKpoW3zzPSvL4w9SZfybrvgpSYXomcYLNS8E6Ov6 QMMfnjdK7fswfQTuHn7UOE8rbWHePOj8qRB2V7HBstjqd86fSsLRX+/TmUQZkO7PoYn4 ti2jaoFgS/gKD/A88IBuZqWo3zzT3az+Lg5QaO6+JFqUp7Uuk1frUIYQ3WDpX3ljEy9r ErCaP8aFw6cJ/rZQCbRmu1lD2EFoXU0HzHQI8lcHnzUpzLHqSL6cYoPMXjnrwWQ9+HFB RF9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V1gjdZ2JRPOoWQInDj1RVCMU7YB1iohDQS4AqWqM1pY=; b=PuIcZxSMCn9SCW4OpcxIdWEi+aV7ob28hgvbts3N5KT2mmBBlfvLI/IehxUuY0q+Kr pBm21OGmgC/CrXp+1Bu5z/Mw5J+wSTa7YQu5cEM2dCCB+j0BgNDr8eJ4HGGchhoSCwFn 48dWIA4JwQMgIKZNiKJkkeMZpjLakzBIg1gMcOGmo83801MesW5Qh0weikUSrFpaEiw8 YN4zI/S/90+Pm+F/V48ngYW7iFJJex0UpDZ18YDKksMF+QurgyXGrCVApRADPeskBNWq Q3MBGkdh2RMlD0BAxrCPzj/rZlyBTH3nvNyJy+I4FGnvMkGa3K/RrhJXzYVs5CRiZSqq GD/g== X-Gm-Message-State: AOAM531QDjwy8zl2cjgDZo5KPlUlvKAZwgnkpIgaisTC5PnpFYhCJVSQ Y83ihdekzu2X8HYhVj5D1jAg2bzJXdgArA== X-Google-Smtp-Source: ABdhPJwwMMA+qa9fgCgtdNRYbnKN1Gqvbkw5f/3enOnpwqDbJYULsNSFTwVbPa1E1+FywqwYDQwpew== X-Received: by 2002:aa7:8426:0:b029:1be:ed6b:9e27 with SMTP id q6-20020aa784260000b02901beed6b9e27mr7440224pfn.13.1612582613064; Fri, 05 Feb 2021 19:36:53 -0800 (PST) Received: from localhost.localdomain ([211.108.35.36]) by smtp.gmail.com with ESMTPSA id j17sm10862375pfh.183.2021.02.05.19.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 19:36:52 -0800 (PST) From: Minwoo Im To: qemu-devel@nongnu.org, qemu-block@nongnu.org Subject: [PATCH 6/6] hw/block/nvme: support namespace attachment command Date: Sat, 6 Feb 2021 12:36:29 +0900 Message-Id: <20210206033629.4278-7-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210206033629.4278-1-minwoo.im.dev@gmail.com> References: <20210206033629.4278-1-minwoo.im.dev@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=minwoo.im.dev@gmail.com; helo=mail-pg1-x530.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Klaus Jensen , Minwoo Im , Kevin Wolf , Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This patch supports Namespace Attachment command for the pre-defined nvme-ns device nodes. Of course, attach/detach namespace should only be supported in case 'subsys' is given. This is because if we detach a namespace from a controller, somebody needs to manage the detached, but allocated namespace in the NVMe subsystem. Signed-off-by: Minwoo Im --- hw/block/nvme-subsys.h | 10 +++++++ hw/block/nvme.c | 59 ++++++++++++++++++++++++++++++++++++++++++ hw/block/nvme.h | 5 ++++ hw/block/trace-events | 2 ++ include/block/nvme.h | 5 ++++ 5 files changed, 81 insertions(+) diff --git a/hw/block/nvme-subsys.h b/hw/block/nvme-subsys.h index 14627f9ccb41..ef4bec928eae 100644 --- a/hw/block/nvme-subsys.h +++ b/hw/block/nvme-subsys.h @@ -30,6 +30,16 @@ typedef struct NvmeSubsystem { int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp); int nvme_subsys_register_ns(NvmeNamespace *ns, Error **errp); +static inline NvmeCtrl *nvme_subsys_ctrl(NvmeSubsystem *subsys, + uint32_t cntlid) +{ + if (!subsys) { + return NULL; + } + + return subsys->ctrls[cntlid]; +} + /* * Return allocated namespace of the specified nsid in the subsystem. */ diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 697368a6ae0c..769436722c7e 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -183,6 +183,7 @@ static const uint32_t nvme_cse_acs[256] = { [NVME_ADM_CMD_SET_FEATURES] = NVME_CMD_EFF_CSUPP, [NVME_ADM_CMD_GET_FEATURES] = NVME_CMD_EFF_CSUPP, [NVME_ADM_CMD_ASYNC_EV_REQ] = NVME_CMD_EFF_CSUPP, + [NVME_ADM_CMD_NS_ATTACHMENT] = NVME_CMD_EFF_CSUPP, }; static const uint32_t nvme_cse_iocs_none[256]; @@ -3766,6 +3767,62 @@ static uint16_t nvme_aer(NvmeCtrl *n, NvmeRequest *req) return NVME_NO_COMPLETE; } +static void __nvme_select_ns_iocs(NvmeCtrl *n, NvmeNamespace *ns); +static uint16_t nvme_ns_attachment(NvmeCtrl *n, NvmeRequest *req) +{ + NvmeNamespace *ns; + NvmeCtrl *ctrl; + uint16_t list[NVME_CONTROLLER_LIST_SIZE] = {}; + uint32_t nsid = le32_to_cpu(req->cmd.nsid); + uint32_t dw10 = le32_to_cpu(req->cmd.cdw10); + bool attach = !(dw10 & 0xf); + uint16_t *nr_ids = &list[0]; + uint16_t *ids = &list[1]; + uint16_t ret; + int i; + + trace_pci_nvme_ns_attachment(nvme_cid(req), dw10 & 0xf); + + ns = nvme_subsys_ns(n->subsys, nsid); + if (!ns) { + return NVME_INVALID_FIELD | NVME_DNR; + } + + ret = nvme_dma(n, (uint8_t *)list, 4096, + DMA_DIRECTION_TO_DEVICE, req); + if (ret) { + return ret; + } + + if (!*nr_ids) { + return NVME_NS_CTRL_LIST_INVALID | NVME_DNR; + } + + for (i = 0; i < *nr_ids; i++) { + ctrl = nvme_subsys_ctrl(n->subsys, ids[i]); + if (!ctrl) { + return NVME_NS_CTRL_LIST_INVALID | NVME_DNR; + } + + if (attach) { + if (nvme_ns_is_attached(ctrl, ns)) { + return NVME_NS_ALREADY_ATTACHED | NVME_DNR; + } + + nvme_ns_attach(n, ns); + __nvme_select_ns_iocs(n, ns); + } else { + if (!nvme_ns_is_attached(ctrl, ns)) { + return NVME_NS_NOT_ATTACHED | NVME_DNR; + } + + nvme_ns_detach(n, ns); + } + } + + return NVME_SUCCESS; +} + static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest *req) { trace_pci_nvme_admin_cmd(nvme_cid(req), nvme_sqid(req), req->cmd.opcode, @@ -3797,6 +3854,8 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest *req) return nvme_get_feature(n, req); case NVME_ADM_CMD_ASYNC_EV_REQ: return nvme_aer(n, req); + case NVME_ADM_CMD_NS_ATTACHMENT: + return nvme_ns_attachment(n, req); default: assert(false); } diff --git a/hw/block/nvme.h b/hw/block/nvme.h index 1c7796b20996..5a1ab857d166 100644 --- a/hw/block/nvme.h +++ b/hw/block/nvme.h @@ -222,6 +222,11 @@ static inline void nvme_ns_attach(NvmeCtrl *n, NvmeNamespace *ns) n->namespaces[nvme_nsid(ns) - 1] = ns; } +static inline void nvme_ns_detach(NvmeCtrl *n, NvmeNamespace *ns) +{ + n->namespaces[nvme_nsid(ns) - 1] = NULL; +} + static inline NvmeCQueue *nvme_cq(NvmeRequest *req) { NvmeSQueue *sq = req->sq; diff --git a/hw/block/trace-events b/hw/block/trace-events index b6e972d733a6..bf67fe7873d2 100644 --- a/hw/block/trace-events +++ b/hw/block/trace-events @@ -80,6 +80,8 @@ pci_nvme_aer(uint16_t cid) "cid %"PRIu16"" pci_nvme_aer_aerl_exceeded(void) "aerl exceeded" pci_nvme_aer_masked(uint8_t type, uint8_t mask) "type 0x%"PRIx8" mask 0x%"PRIx8"" pci_nvme_aer_post_cqe(uint8_t typ, uint8_t info, uint8_t log_page) "type 0x%"PRIx8" info 0x%"PRIx8" lid 0x%"PRIx8"" +pci_nvme_ns_attachment(uint16_t cid, uint8_t sel) "cid %"PRIu16", sel=0x%"PRIx8"" +pci_nvme_ns_attachment_attach(uint16_t cntlid, uint32_t nsid) "cntlid=0x%"PRIx16", nsid=0x%"PRIx32"" pci_nvme_enqueue_event(uint8_t typ, uint8_t info, uint8_t log_page) "type 0x%"PRIx8" info 0x%"PRIx8" lid 0x%"PRIx8"" pci_nvme_enqueue_event_noqueue(int queued) "queued %d" pci_nvme_enqueue_event_masked(uint8_t typ) "type 0x%"PRIx8"" diff --git a/include/block/nvme.h b/include/block/nvme.h index f82b5ffc2c1d..4b016f954fee 100644 --- a/include/block/nvme.h +++ b/include/block/nvme.h @@ -566,6 +566,7 @@ enum NvmeAdminCommands { NVME_ADM_CMD_ASYNC_EV_REQ = 0x0c, NVME_ADM_CMD_ACTIVATE_FW = 0x10, NVME_ADM_CMD_DOWNLOAD_FW = 0x11, + NVME_ADM_CMD_NS_ATTACHMENT = 0x15, NVME_ADM_CMD_FORMAT_NVM = 0x80, NVME_ADM_CMD_SECURITY_SEND = 0x81, NVME_ADM_CMD_SECURITY_RECV = 0x82, @@ -836,6 +837,9 @@ enum NvmeStatusCodes { NVME_FEAT_NOT_CHANGEABLE = 0x010e, NVME_FEAT_NOT_NS_SPEC = 0x010f, NVME_FW_REQ_SUSYSTEM_RESET = 0x0110, + NVME_NS_ALREADY_ATTACHED = 0x0118, + NVME_NS_NOT_ATTACHED = 0x011A, + NVME_NS_CTRL_LIST_INVALID = 0x011C, NVME_CONFLICTING_ATTRS = 0x0180, NVME_INVALID_PROT_INFO = 0x0181, NVME_WRITE_TO_RO = 0x0182, @@ -951,6 +955,7 @@ typedef struct QEMU_PACKED NvmePSD { uint8_t resv[16]; } NvmePSD; +#define NVME_CONTROLLER_LIST_SIZE 2048 #define NVME_IDENTIFY_DATA_SIZE 4096 enum NvmeIdCns {