From patchwork Mon Jun 14 20:19:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 12319745 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_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,URIBL_BLOCKED,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 9AC83C2B9F4 for ; Mon, 14 Jun 2021 20:21:09 +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 2F3B661246 for ; Mon, 14 Jun 2021 20:21:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F3B661246 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lst51-0002tr-W6 for qemu-devel@archiver.kernel.org; Mon, 14 Jun 2021 16:21:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lst3S-0000Zc-N9; Mon, 14 Jun 2021 16:19:30 -0400 Received: from mout.gmx.net ([212.227.17.20]:56111) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lst3Q-0008Pr-Gn; Mon, 14 Jun 2021 16:19:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1623701954; bh=HjhYv27Yc1iGJfdXqReonBAeugYYlc1E5JsgqVHcBwc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=gQGT6/WJk9O9oERxgPkRVLu7Kk7yjO8CKdE32xrWanegTsEN75HiQU0Pf0wRGzGFg pLoybkmqwG01+5ukUPybdqR8mY8qZaSlWSkYU7JdddmCQgEtGfaXvJeZW880n9r8Lo MjycxYxDtYGKgD17z8gLHTTaCWabPSkHalVZZ0Dg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([62.143.247.63]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1N0XD2-1l5J8o1Q1s-00wVco; Mon, 14 Jun 2021 22:19:14 +0200 From: Heinrich Schuchardt To: Keith Busch , Klaus Jensen Subject: [PATCH v3 1/2] hw/nvme: namespace parameter for EUI-64 Date: Mon, 14 Jun 2021 22:19:00 +0200 Message-Id: <20210614201901.17871-2-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210614201901.17871-1-xypron.glpk@gmx.de> References: <20210614201901.17871-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:u+/i30LAmUcN6WXx1XRa/xvaYhB3es61zcXPLLsDjgP2oPrLTAs wNlS/+QM6YRjuikW0laDh2ePhuIafvNGjwEuXpX+oPy8zPd64kSO6dsI8uuGgZL+PHTNZpf 93YgACopBPXPogYDMXCIRqS+gu6fzYrTU78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oWkd/D69syNS60IazF/HhXh0SXqH9YFgQHVqv0L5ZdlE1Pmq7rhSH422HB/YboOvM 8jz0uwEggpAYBx0V48oHcnt4W8j3Jhq2sx4HIGLDMPhic9Dk8EI0vkblQDO+YP9BCMORtsjsZ 649vth/iwqhfYY3WJxkVdU/CLSBxKhKGuVY Received-SPF: pass client-ip=212.227.17.20; envelope-from=xypron.glpk@gmx.de; helo=mout.gmx.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Eduardo Habkost , qemu-block@nongnu.org, Heinrich Schuchardt , qemu-devel@nongnu.org, Klaus Jensen Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The EUI-64 field is the only identifier for NVMe namespaces in UEFI device paths. Add a new namespace property "eui64", that provides the user the option to specify the EUI-64. Signed-off-by: Heinrich Schuchardt Acked-by: Klaus Jensen --- v3: no change v2: fix typo %s/EUI64/EUI-64/ --- docs/system/nvme.rst | 4 +++ hw/nvme/ctrl.c | 58 ++++++++++++++++++++++++++------------------ hw/nvme/ns.c | 2 ++ hw/nvme/nvme.h | 1 + 4 files changed, 42 insertions(+), 23 deletions(-) -- 2.30.2 diff --git a/docs/system/nvme.rst b/docs/system/nvme.rst index f7f63d6bf6..b5f8288d7c 100644 --- a/docs/system/nvme.rst +++ b/docs/system/nvme.rst @@ -81,6 +81,10 @@ There are a number of parameters available: Set the UUID of the namespace. This will be reported as a "Namespace UUID" descriptor in the Namespace Identification Descriptor List. +``eui64`` + Set the EUI-64 of the namespace. This will be reported as a "IEEE Extended + Unique Identifier" descriptor in the Namespace Identification Descriptor List. + ``bus`` If there are more ``nvme`` devices defined, this parameter may be used to attach the namespace to a specific ``nvme`` device (identified by an ``id`` diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 8dd9cb2ccb..f37c4fd635 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -4436,19 +4436,19 @@ static uint16_t nvme_identify_ns_descr_list(NvmeCtrl *n, NvmeRequest *req) NvmeIdentify *c = (NvmeIdentify *)&req->cmd; uint32_t nsid = le32_to_cpu(c->nsid); uint8_t list[NVME_IDENTIFY_DATA_SIZE] = {}; - - struct data { - struct { - NvmeIdNsDescr hdr; - uint8_t v[NVME_NIDL_UUID]; - } uuid; - struct { - NvmeIdNsDescr hdr; - uint8_t v; - } csi; - }; - - struct data *ns_descrs = (struct data *)list; + uint8_t *pos = list; + struct { + NvmeIdNsDescr hdr; + uint8_t v[NVME_NIDL_UUID]; + } QEMU_PACKED uuid; + struct { + NvmeIdNsDescr hdr; + uint64_t v; + } QEMU_PACKED eui64; + struct { + NvmeIdNsDescr hdr; + uint8_t v; + } QEMU_PACKED csi; trace_pci_nvme_identify_ns_descr_list(nsid); @@ -4462,17 +4462,29 @@ static uint16_t nvme_identify_ns_descr_list(NvmeCtrl *n, NvmeRequest *req) } /* - * Because the NGUID and EUI64 fields are 0 in the Identify Namespace data - * structure, a Namespace UUID (nidt = 3h) must be reported in the - * Namespace Identification Descriptor. Add the namespace UUID here. + * If the EUI-64 field is 0 and the NGUID field is 0, the namespace must + * provide a valid Namespace UUID in the Namespace Identification Descriptor + * data structure. QEMU does not yet support setting NGUID. */ - ns_descrs->uuid.hdr.nidt = NVME_NIDT_UUID; - ns_descrs->uuid.hdr.nidl = NVME_NIDL_UUID; - memcpy(&ns_descrs->uuid.v, ns->params.uuid.data, NVME_NIDL_UUID); - - ns_descrs->csi.hdr.nidt = NVME_NIDT_CSI; - ns_descrs->csi.hdr.nidl = NVME_NIDL_CSI; - ns_descrs->csi.v = ns->csi; + uuid.hdr.nidt = NVME_NIDT_UUID; + uuid.hdr.nidl = NVME_NIDL_UUID; + memcpy(uuid.v, ns->params.uuid.data, NVME_NIDL_UUID); + memcpy(pos, &uuid, sizeof(uuid)); + pos += sizeof(uuid); + + if (ns->params.eui64) { + eui64.hdr.nidt = NVME_NIDT_EUI64; + eui64.hdr.nidl = NVME_NIDL_EUI64; + eui64.v = cpu_to_be64(ns->params.eui64); + memcpy(pos, &eui64, sizeof(eui64)); + pos += sizeof(eui64); + } + + csi.hdr.nidt = NVME_NIDT_CSI; + csi.hdr.nidl = NVME_NIDL_CSI; + csi.v = ns->csi; + memcpy(pos, &csi, sizeof(csi)); + pos += sizeof(csi); return nvme_c2h(n, list, sizeof(list), req); } diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index 3fec9c6273..45e457de6a 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -77,6 +77,7 @@ static int nvme_ns_init(NvmeNamespace *ns, Error **errp) id_ns->mssrl = cpu_to_le16(ns->params.mssrl); id_ns->mcl = cpu_to_le32(ns->params.mcl); id_ns->msrc = ns->params.msrc; + id_ns->eui64 = cpu_to_be64(ns->params.eui64); ds = 31 - clz32(ns->blkconf.logical_block_size); ms = ns->params.ms; @@ -511,6 +512,7 @@ static Property nvme_ns_props[] = { DEFINE_PROP_BOOL("shared", NvmeNamespace, params.shared, false), DEFINE_PROP_UINT32("nsid", NvmeNamespace, params.nsid, 0), DEFINE_PROP_UUID("uuid", NvmeNamespace, params.uuid), + DEFINE_PROP_UINT64("eui64", NvmeNamespace, params.eui64, 0), DEFINE_PROP_UINT16("ms", NvmeNamespace, params.ms, 0), DEFINE_PROP_UINT8("mset", NvmeNamespace, params.mset, 0), DEFINE_PROP_UINT8("pi", NvmeNamespace, params.pi, 0), diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index 93a7e0e538..ac90e13d7b 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -83,6 +83,7 @@ typedef struct NvmeNamespaceParams { bool shared; uint32_t nsid; QemuUUID uuid; + uint64_t eui64; uint16_t ms; uint8_t mset; From patchwork Mon Jun 14 20:19:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 12319743 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_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,URIBL_BLOCKED,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 56461C48BE6 for ; Mon, 14 Jun 2021 20:21:05 +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 2144961246 for ; Mon, 14 Jun 2021 20:21:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2144961246 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lst4y-0002ir-9G for qemu-devel@archiver.kernel.org; Mon, 14 Jun 2021 16:21:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lst3S-0000Ya-36; Mon, 14 Jun 2021 16:19:30 -0400 Received: from mout.gmx.net ([212.227.17.22]:54135) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lst3K-0008Ml-A2; Mon, 14 Jun 2021 16:19:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1623701954; bh=cFuk5QEea/OM1ma3BUUW7V5tDNdgOzxk3DozvdLmZDA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=AwWet850kzdkjydRs2Gsjxr+cXWFel2bXHTrE1XmDJvz/TGoEt2iSkJ+bGv7EC5kj KeK07uqgtjyu0yuqSffIPin4NHFBBd43yLJ4z+5RlT0fzbK2cgihf2PT+iMhpMaD5P sVH5flSYP13v2eLl8iJ7HPhAvD42+wGpI1nGp6l4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([62.143.247.63]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1M9Wyy-1lwAqM2gpY-005VUw; Mon, 14 Jun 2021 22:19:14 +0200 From: Heinrich Schuchardt To: Keith Busch , Klaus Jensen Subject: [PATCH v3 2/2] hw/nvme: default for namespace EUI-64 Date: Mon, 14 Jun 2021 22:19:01 +0200 Message-Id: <20210614201901.17871-3-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210614201901.17871-1-xypron.glpk@gmx.de> References: <20210614201901.17871-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:VEJhc2VqTkuU52FJ0Zpiv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pOzNV5vyBD7g2NEMcsyTgdsc6TpoZjizVRLR24El5XjBNzSJs9FWd9X9Zr1A3sZz 3oK6UD2lPPFxy6POjcCgBTUNmiGa8H4QTnZY2WbeYHTwUqi1e6sZyg22gzrBB8A5wxyXsM82l 8caurdKaK2Aa4xWsqRiF2caH+c5gYvriqNFv4VKOwzQ5zWzQQaMenL2w2v+2nlYrcNkRAHcle mKOZXBTKMPe1uAaryCVAIaLxzEQxeYDejuxGyC0eKDmsCkTuCRFpvHIY3TrUyR06qwgv03H9w zqdrnFwHWKUVfEYTsR/BKZmIYp/lAqH8qeP Received-SPF: pass client-ip=212.227.17.22; envelope-from=xypron.glpk@gmx.de; helo=mout.gmx.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Heinrich Schuchardt , qemu-block@nongnu.org, Eduardo Habkost , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On machines with version > 6.0 replace a missing EUI-64 by a generated value. Signed-off-by: Heinrich Schuchardt --- v3: use 52-54-00-00-00-00-00-00 as starting values for generating EUI-64s v2: new patch --- docs/system/nvme.rst | 2 ++ hw/core/machine.c | 1 + hw/nvme/ns.c | 9 +++++++++ hw/nvme/nvme.h | 2 ++ 4 files changed, 14 insertions(+) -- 2.30.2 diff --git a/docs/system/nvme.rst b/docs/system/nvme.rst index b5f8288d7c..33a15c7dbc 100644 --- a/docs/system/nvme.rst +++ b/docs/system/nvme.rst @@ -84,6 +84,8 @@ There are a number of parameters available: ``eui64`` Set the EUI-64 of the namespace. This will be reported as a "IEEE Extended Unique Identifier" descriptor in the Namespace Identification Descriptor List. + Since machine type 6.1 a non-zero default value is used if the parameter + is not provided. For earlier machine types the field defaults to 0. ``bus`` If there are more ``nvme`` devices defined, this parameter may be used to diff --git a/hw/core/machine.c b/hw/core/machine.c index 55b9bc7817..d0e9348888 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -39,6 +39,7 @@ GlobalProperty hw_compat_6_0[] = { { "gpex-pcihost", "allow-unmapped-accesses", "false" }, { "i8042", "extended-state", "false"}, + { "nvme-ns", "eui64-default", "off"}, }; const size_t hw_compat_6_0_len = G_N_ELEMENTS(hw_compat_6_0); diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index 45e457de6a..4275c3db63 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -56,6 +56,7 @@ void nvme_ns_init_format(NvmeNamespace *ns) static int nvme_ns_init(NvmeNamespace *ns, Error **errp) { + static uint64_t ns_count; NvmeIdNs *id_ns = &ns->id_ns; uint8_t ds; uint16_t ms; @@ -73,6 +74,12 @@ static int nvme_ns_init(NvmeNamespace *ns, Error **errp) id_ns->nmic |= NVME_NMIC_NS_SHARED; } + /* Substitute a missing EUI-64 by an autogenerated one */ + ++ns_count; + if (!ns->params.eui64 && ns->params.eui64_default) { + ns->params.eui64 = ns_count + NVME_EUI64_DEFAULT; + } + /* simple copy */ id_ns->mssrl = cpu_to_le16(ns->params.mssrl); id_ns->mcl = cpu_to_le32(ns->params.mcl); @@ -533,6 +540,8 @@ static Property nvme_ns_props[] = { params.max_open_zones, 0), DEFINE_PROP_UINT32("zoned.descr_ext_size", NvmeNamespace, params.zd_extension_size, 0), + DEFINE_PROP_BOOL("eui64-default", NvmeNamespace, params.eui64_default, + true), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index ac90e13d7b..371ac9bfd8 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -26,6 +26,7 @@ #define NVME_MAX_CONTROLLERS 32 #define NVME_MAX_NAMESPACES 256 +#define NVME_EUI64_DEFAULT ((uint64_t)0x5254000000000000) typedef struct NvmeCtrl NvmeCtrl; typedef struct NvmeNamespace NvmeNamespace; @@ -84,6 +85,7 @@ typedef struct NvmeNamespaceParams { uint32_t nsid; QemuUUID uuid; uint64_t eui64; + bool eui64_default; uint16_t ms; uint8_t mset;