From patchwork Fri Nov 6 23:42:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Fomichev X-Patchwork-Id: 11888461 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 105EB14B4 for ; Fri, 6 Nov 2020 23:48:22 +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 B5D8220704 for ; Fri, 6 Nov 2020 23:48:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="KlURHEdM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5D8220704 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:42842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kbBSu-0003s2-QQ for patchwork-qemu-devel@patchwork.kernel.org; Fri, 06 Nov 2020 18:48:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kbBO6-0005HH-6p; Fri, 06 Nov 2020 18:43:22 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:57357) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kbBO3-0003TB-AT; Fri, 06 Nov 2020 18:43:21 -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=1604706200; x=1636242200; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jR2w/WGNNbVyESF4tPkSNOFiXsfAZlFecXFYaBR3/5E=; b=KlURHEdMC7vBfblCU9HaZkaBfoMETetXuHkxFBpwhTCrSo5FFMPigeHp qe8OekMbWLBBHa6Oszp7EdG7mAVh8DU+iNHBYm69KAUFmPct+BvZPx+L2 QlDvMVa1SqgPsY3ks5cWSXXL5vU7tyXLEiRuuKAJ3UCrEmOJApccDOcCx mhNJzOpYwtYyPzf+hkP6V+OxvgcUgA6SMLO3pPgeoYRRqGNWPybch8/G3 /kWUdoTjb7Ks24RUp7tU2kw5KTbDE1ZjcDoBwLiQXXe7igqvQvxn30lKF hYQRtFuml7sqp9DSicm19FniNVOtDS3OFGdD57dCGAKa7fretIIcVap8R Q==; IronPort-SDR: WvTBEgGIDuYW5b3DJrcLCw+WBjK0iIsDVxZFt7oXh5G6tEbTSw2Xf7ZSHuJxz47WPud/f0miTG vqUbOo5frkCeunxh6qIWIeB7PUsZUxNtwU+sGAUD1qZgKstsGVGcdYX+Z9sg7DHXBv2rSpjJVU gmsnxOTf7ep1YAcWTu7P7YjhUhhjOjHfrlDph/GuRHWAuJq9eMHbzE2HmLKHqkTaflBYsLSVbC oDp846OnXgJmhsOejhjBODnwleJI6VxPexjcF4tjcwa8AMP8Gq6p5eE91HPf9oJo1sMfEQVBG7 bdk= X-IronPort-AV: E=Sophos;i="5.77,457,1596470400"; d="scan'208";a="153267057" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 07 Nov 2020 07:43:18 +0800 IronPort-SDR: nRuJr+I4+9aeoG1VnOAAhMIucvwtvXZzpkmlc2Okau80BJQU1j2v3+mIg7QsZASgDMXAMYb09R AQFnavTkOQZa16SogeSiq3namsJNlKc+FgcYpiFtxH1GgFXIpZbjka6SSW5wU8boClHGIIzMi0 OQkSVXMFWWE7bgFzsRnXN+uo/plFTa1wQbExWHOxAJv6m4zJa8S8O3aPt8vDNoYxu33ZaPL8PP ZAZBEbWxkXb5/TaKkDukZOA2K3eoBH7BzucGM6np+ZjqXln5rEtl1JWFliWgLGO8oWcSFHdcCF 860Jz7EbQEPpHJiDzWqyWB1N Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2020 15:28:09 -0800 IronPort-SDR: 7uhjf2g0mRW9Z3k5x5yEi5T1QU1+sTugr0zBuh6pRMwz3kaM9TJe6MTex6EVwqohUpiKRUtFYX DvZQRvDZghRSSW4blsZL02pLpk4b9CtLaIKjaoTXU0GQf/wQiwcuJCn72D+vPwFa5VbHurg41P 3tEAw1ODB8hORoKY2Va9ql1JMTo/77gLNRNBg4qyN6q6MEHkza1kB7mNupxdceNvGv7N2oixfI AbgXC/3uAQKCIOc7CPNKlP/jAfNA+kLcACkSGgzlGroEH1NkHFMw1ihvY1NnARw7zJafTzJip4 pvw= WDCIronportException: Internal Received: from unknown (HELO redsun50.ssa.fujisawa.hgst.com) ([10.149.66.24]) by uls-op-cesaip01.wdc.com with ESMTP; 06 Nov 2020 15:43:15 -0800 From: Dmitry Fomichev To: Keith Busch , Klaus Jensen , Kevin Wolf , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Max Reitz , Maxim Levitsky , Fam Zheng Subject: [PATCH v10 02/12] hw/block/nvme: Generate namespace UUIDs Date: Sat, 7 Nov 2020 08:42:55 +0900 Message-Id: <20201106234305.21339-3-dmitry.fomichev@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20201106234305.21339-1-dmitry.fomichev@wdc.com> References: <20201106234305.21339-1-dmitry.fomichev@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=572b21b8d=dmitry.fomichev@wdc.com; helo=esa6.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/06 18:43:12 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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: Niklas Cassel , Damien Le Moal , qemu-block@nongnu.org, Dmitry Fomichev , qemu-devel@nongnu.org, Alistair Francis , Matias Bjorling Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" In NVMe 1.4, a namespace must report an ID descriptor of UUID type if it doesn't support EUI64 or NGUID. Add a new namespace property, "uuid", that provides the user the option to either specify the UUID explicitly or have a UUID generated automatically every time a namespace is initialized. Suggested-by: Klaus Jensen Signed-off-by: Dmitry Fomichev Reviewed-by: Klaus Jensen Reviewed-by: Keith Busch Reviewed-by: Niklas Cassel --- hw/block/nvme-ns.h | 1 + hw/block/nvme-ns.c | 1 + hw/block/nvme.c | 9 +++++---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/block/nvme-ns.h b/hw/block/nvme-ns.h index ea8c2f785d..a38071884a 100644 --- a/hw/block/nvme-ns.h +++ b/hw/block/nvme-ns.h @@ -21,6 +21,7 @@ typedef struct NvmeNamespaceParams { uint32_t nsid; + QemuUUID uuid; } NvmeNamespaceParams; typedef struct NvmeNamespace { diff --git a/hw/block/nvme-ns.c b/hw/block/nvme-ns.c index b69cdaf27e..de735eb9f3 100644 --- a/hw/block/nvme-ns.c +++ b/hw/block/nvme-ns.c @@ -129,6 +129,7 @@ static void nvme_ns_realize(DeviceState *dev, Error **errp) static Property nvme_ns_props[] = { DEFINE_BLOCK_PROPERTIES(NvmeNamespace, blkconf), DEFINE_PROP_UINT32("nsid", NvmeNamespace, params.nsid, 0), + DEFINE_PROP_UUID("uuid", NvmeNamespace, params.uuid), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 702f7cc2e3..ed3f38f01d 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1564,6 +1564,7 @@ static uint16_t nvme_identify_nslist(NvmeCtrl *n, NvmeRequest *req) static uint16_t nvme_identify_ns_descr_list(NvmeCtrl *n, NvmeRequest *req) { + NvmeNamespace *ns; NvmeIdentify *c = (NvmeIdentify *)&req->cmd; uint32_t nsid = le32_to_cpu(c->nsid); uint8_t list[NVME_IDENTIFY_DATA_SIZE]; @@ -1583,7 +1584,8 @@ static uint16_t nvme_identify_ns_descr_list(NvmeCtrl *n, NvmeRequest *req) return NVME_INVALID_NSID | NVME_DNR; } - if (unlikely(!nvme_ns(n, nsid))) { + ns = nvme_ns(n, nsid); + if (unlikely(!ns)) { return NVME_INVALID_FIELD | NVME_DNR; } @@ -1592,12 +1594,11 @@ 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 = 0x3) must be reported in the - * Namespace Identification Descriptor. Add a very basic Namespace UUID - * here. + * Namespace Identification Descriptor. Add the namespace UUID here. */ ns_descrs->uuid.hdr.nidt = NVME_NIDT_UUID; ns_descrs->uuid.hdr.nidl = NVME_NIDT_UUID_LEN; - stl_be_p(&ns_descrs->uuid.v, nsid); + memcpy(&ns_descrs->uuid.v, ns->params.uuid.data, NVME_NIDT_UUID_LEN); return nvme_dma(n, list, NVME_IDENTIFY_DATA_SIZE, DMA_DIRECTION_FROM_DEVICE, req);