From patchwork Fri Jun 11 23:46:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 12316753 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 304F6C48BE6 for ; Sat, 12 Jun 2021 00:12:35 +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 A6D26613CA for ; Sat, 12 Jun 2021 00:12:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6D26613CA 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]:43350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrrGL-00065D-MY for qemu-devel@archiver.kernel.org; Fri, 11 Jun 2021 20:12:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrqs8-0006Nc-H6; Fri, 11 Jun 2021 19:47:32 -0400 Received: from mout.gmx.net ([212.227.15.15]:36841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrqs6-0006Bw-Bo; Fri, 11 Jun 2021 19:47:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1623455242; bh=rQLqPvBxinQQ7gY8t/jGS2z0+EcN0fbFMhSnOnmLkLc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=P8yrqf64kZXd5FgM39RhJWG8RAiTAmAEWVzqpIFI/xd1nPayy/fPhFvPj2hxvV5OI fqgez+eeAtKbtFMWhv72kRC2I7ftI7OnUOIDwZVVOw/DwS+J2hzX/wEdL0SZG08Xn1 ZDcd8FoObFJA2Vt9HWyHH/IvJ1bE7nRtRNT4XyQ4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([62.143.247.63]) by mail.gmx.net (mrgmx004 [212.227.17.184]) with ESMTPSA (Nemesis) id 1Mo6v3-1lX2zR2HhT-00pg8m; Sat, 12 Jun 2021 01:47:22 +0200 From: Heinrich Schuchardt To: Keith Busch , Klaus Jensen , Peter Maydell Subject: [PATCH v2 3/3] hw/nvme: default for namespace EUI-64 Date: Sat, 12 Jun 2021 01:46:31 +0200 Message-Id: <20210611234631.81314-4-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210611234631.81314-1-xypron.glpk@gmx.de> References: <20210611234631.81314-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:xCmmQqQ4SCV0f4VeAYxd95DoCiP1DKkif+ZljC2UtqfkRENvfAV qDlKMxYv/vQ/9LdZrHBC0IuzqpJqeLlS2SDim1BUbnnRRyijXssSVDB2yrTmHAyvZ2K0sr0 pYlFEPIwGq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q+z3Jp3OSOm/Sto7R/hHBdd 7E8NzgHfWgOZTAT0R9/xOFCl2vo4zOYU2hGQ/vNkQCJpT9lTOgaJZpP2BEFcEhs01pIzRBNjA 2gcnEvHoc6Y09PzLO6eXHaOruJD9rijoOesbzifjtI47ZUIWJy0vjjR6kxS2tamzrLgy5E9WD /G4n2cTCc8bCZjp5BERpCwMR7WczcGHW0tN Received-SPF: pass client-ip=212.227.15.15; 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_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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 , Cornelia Huck , qemu-devel@nongnu.org, qemu-arm@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 --- 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..3fb869731d 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 0x27fed9272381cbd0UL 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;