From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id CA1C87803E7 for ; Thu, 9 Nov 2023 07:51:23 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=dj3+vm1iTGIX6B3+TIHarui9QvZVqZu1DKKnhpVPAuQ=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1699516282; v=1; b=RZG7NTOEslVlCUEXkFHEuejVLMmvaI2YStwKkkLZot7+A5ISvJYN4JgVauXf3Fw8HMq5JHE7 WkAloSqqWk+YzxHXYstJgDl65Ez/7IbuR9ihJyRxeb/BhXVFHW+k+YUT/QN5fRDu+tKjwwz2CRE 87YPTP/gJoPFj4JmofWyfphY= X-Received: by 127.0.0.2 with SMTP id 6mATYY7687511xg3lEqSH2Wd; Wed, 08 Nov 2023 23:51:22 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web10.116525.1699516281816005467 for ; Wed, 08 Nov 2023 23:51:21 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10888"; a="454238047" X-IronPort-AV: E=Sophos;i="6.03,288,1694761200"; d="scan'208";a="454238047" X-Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2023 23:51:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,288,1694761200"; d="scan'208";a="4459069" X-Received: from chentina-desk.gar.corp.intel.com ([10.5.215.16]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2023 23:51:19 -0800 From: "Tina Chen" To: devel@edk2.groups.io Cc: Tina Chen , Ray Ni , Xiao X Chen , Arthur Chen , Liming Gao , Zhiguang Liu , Sean Brogan , Michael D Kinney Subject: [edk2-devel] [PATCH v4 1/1] MdePkg:Add NVME Sanitize command support to Nvme.h Date: Thu, 9 Nov 2023 15:51:10 +0800 Message-ID: <20231109075112.549-1-tina.chen@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,tina.chen@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Pq8ATNZiZmX3YqSJVKzD2HpMx7686176AA= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=RZG7NTOE; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4591 1. Refer NVME spec 2.0c chapter 5.24, add Sanitize Command related definiti= on. 2. Refer NVME spec 2.0c chapter 5.16, add Get Log Page Command related defi= nition for Sanitize status support. Cc: Ray Ni Cc: Xiao X Chen Cc: Arthur Chen Cc: Liming Gao Cc: Zhiguang Liu Cc: Sean Brogan Cc: Michael D Kinney Signed-off-by: Tina Chen --- MdePkg/Include/IndustryStandard/Nvme.h | 121 ++++++++++++++++++-- 1 file changed, 110 insertions(+), 11 deletions(-) diff --git a/MdePkg/Include/IndustryStandard/Nvme.h b/MdePkg/Include/Indust= ryStandard/Nvme.h index 8b8a1bb7f3..67f2196bc7 100644 --- a/MdePkg/Include/IndustryStandard/Nvme.h +++ b/MdePkg/Include/IndustryStandard/Nvme.h @@ -1,5 +1,5 @@ /** @file - Definitions based on NVMe spec. version 1.1. + Definitions based on NVMe spec. version 2.0c. =20 (C) Copyright 2016 Hewlett Packard Enterprise Development LP
Copyright (c) 2017 - 2023, Intel Corporation. All rights reserved.
@@ -9,6 +9,7 @@ NVMe Specification 1.1 NVMe Specification 1.4 NVMe Specification 2.0 + NVMe Specification 2.0c =20 **/ =20 @@ -354,6 +355,15 @@ typedef struct { UINT8 Rsvd7[16]; /* Reserved as of Nvm Express 1.1 Spec */ } NVME_PSDESCRIPTOR; =20 +typedef struct { + UINT32 Ces : 1; /* Crypto Erase Supported */ + UINT32 Bes : 1; /* Block Erase Supported */ + UINT32 Ows : 1; /* Overwrite Supported */ + UINT32 Rsvd1 : 26; /* Reserved as of NVM Express 2.0c Spec */ + UINT32 Ndi : 1; /* No-Deallocate Inhibited */ + UINT32 Nodmmas : 2; /* No-Deallocate Modifies Media After Sanitize= */ +} NVME_SANICAP; + // // Identify Controller Data // @@ -403,7 +413,12 @@ typedef struct { UINT16 Edstt; /* Extended Device Self-test Time */ UINT8 Dsto; /* Device Self-test Options */ UINT8 Fwug; /* Firmware Update Granularity */ - UINT8 Rsvd2[192]; /* Reserved as of Nvm Express 1.4 Spec= */ + UINT16 Kas; /* Keep Alive Support */ + UINT16 Hctma; /* Host Controlled Thermal Management = Attributes */ + UINT16 Mntmt; /* Minimum Thermal Management Temperat= ure */ + UINT16 Mxtmt; /* Maximum Thermal Management Temperat= ure */ + NVME_SANICAP Sanicap; /* Sanitize Capabilities */ + UINT8 Rsvd2[180]; /* Reserved as of Nvm Express 1.4 Spec= */ // // NVM Command Set Attributes // @@ -687,10 +702,11 @@ typedef struct { // CDW 10 // UINT32 Lid : 8; /* Log Page Identifier */ - #define LID_ERROR_INFO 0x1 - #define LID_SMART_INFO 0x2 - #define LID_FW_SLOT_INFO 0x3 - #define LID_BP_INFO 0x15 + #define LID_ERROR_INFO 0x1 + #define LID_SMART_INFO 0x2 + #define LID_FW_SLOT_INFO 0x3 + #define LID_BP_INFO 0x15 + #define LID_SANITIZE_STATUS_INFO 0x81 UINT32 Rsvd1 : 8; UINT32 Numd : 12; /* Number of Dwords */ UINT32 Rsvd2 : 4; /* Reserved as of Nvm Express 1.1 Spec */ @@ -708,6 +724,31 @@ typedef struct { UINT32 Sv : 1; /* Save */ } NVME_ADMIN_SET_FEATURES; =20 +// +// NvmExpress Admin Sanitize Command +// +typedef struct { + // + // CDW 10 + // + UINT32 Sanact : 3; /* Sanitize Action */ + UINT32 Ause : 1; /* Allow Unrestricted Sanitize Exit */ + UINT32 Owpass : 4; /* Overwrite Pass Count */ + UINT32 Oipbp : 1; /* Overwrite Invert Pattern Between Passes *= / + UINT32 Nodas : 1; /* No-Deallocate After Sanitize */ + UINT32 Rsvd1 : 22; + // + // CDW 11 + // + UINT32 Ovrpat; /* Overwrite Pattern */ +} NVME_ADMIN_SANITIZE; + +#define SANITIZE_ACTION_NO_ACTION 0x0 +#define SANITIZE_ACTION_EXIT_FAILURE_MODE 0x1 +#define SANITIZE_ACTION_BLOCK_ERASE 0x2 +#define SANITIZE_ACTION_OVERWRITE 0x3 +#define SANITIZE_ACTION_CRYPTO_ERASE 0x4 + // // NvmExpress Admin Format NVM Command // @@ -770,6 +811,7 @@ typedef union { NVME_ADMIN_FORMAT_NVM FormatNvm; NVME_ADMIN_SECURITY_RECEIVE SecurityReceive; NVME_ADMIN_SECURITY_SEND SecuritySend; + NVME_ADMIN_SANITIZE Sanitize; } NVME_ADMIN_CMD; =20 typedef struct { @@ -872,6 +914,7 @@ typedef struct { #define NVME_ADMIN_FORMAT_NVM_CMD 0x80 #define NVME_ADMIN_SECURITY_SEND_CMD 0x81 #define NVME_ADMIN_SECURITY_RECEIVE_CMD 0x82 +#define NVME_ADMIN_SANITIZE_CMD 0x84 =20 #define NVME_IO_FLUSH_OPC 0 #define NVME_IO_WRITE_OPC 1 @@ -894,7 +937,8 @@ typedef enum { NamespaceAttachmentOpcode =3D NVME_ADMIN_NAMESACE_ATTACHMENT_CMD, FormatNvmOpcode =3D NVME_ADMIN_FORMAT_NVM_CMD, SecuritySendOpcode =3D NVME_ADMIN_SECURITY_SEND_CMD, - SecurityReceiveOpcode =3D NVME_ADMIN_SECURITY_RECEIVE_CMD + SecurityReceiveOpcode =3D NVME_ADMIN_SECURITY_RECEIVE_CMD, + SanitizeOpcode =3D NVME_ADMIN_SANITIZE_CMD } NVME_ADMIN_COMMAND_OPCODE; =20 // @@ -934,12 +978,14 @@ typedef enum { =20 // // Get Log Page ? Log Page Identifiers -// (ref. spec. v1.1 Figure 73). +// (ref. spec. v2.0c Figure 202). // typedef enum { - ErrorInfoLogID =3D LID_ERROR_INFO, - SmartHealthInfoLogID =3D LID_SMART_INFO, - FirmwareSlotInfoLogID =3D LID_FW_SLOT_INFO + ErrorInfoLogID =3D LID_ERROR_INFO, + SmartHealthInfoLogID =3D LID_SMART_INFO, + FirmwareSlotInfoLogID =3D LID_FW_SLOT_INFO, + BootPartitionInfoLogID =3D LID_BP_INFO, + SanitizeStatusInfoLogID =3D LID_SANITIZE_STATUS_INFO } NVME_LOG_ID; =20 // @@ -1062,6 +1108,59 @@ typedef struct { UINT8 Reserved2[296]; } NVME_SMART_HEALTH_INFO_LOG; =20 +// +// Sanitize Status (Log Identifier 81h) +// (ref. spec. v2.0c 5.16.1.25). +// +typedef struct { + // + // Indicates the fraction complete of the sanitize operation. (SPROG) + // + UINT16 SanitizeProgress; + // + // Indicates the status associated with the most recent sanitize operati= on. (SSTAT) + // + UINT16 SanitizeStatus : 3; + UINT16 OverwriteSanitizeCompletedNumber : 5; + UINT16 GlobalDataErased : 1; + UINT16 SanitizeStatusRsvd : 7; + // + // Contains the value of the Command Dword 10 field of the Sanitize comm= and that started the sanitize operation whose status is reported in the SST= AT field. (SCDW10) + // + UINT32 SanitizeCmdDw10Info; + // + // Indicates the number of seconds required to complete an Overwrite san= itize operation with 16 passes in the background when the No-Deallocate Mod= ifies Media After Sanitize field is not set to 10b. + // + UINT32 OverwriteEstimatedTime; + // + // Indicates the number of seconds required to complete a Block Erase sa= nitize operation in the background when the No-Deallocate Modifies Media Af= ter Sanitize field is not set to 10b. + // + UINT32 BlockEraseEstimatedTime; + // + // Indicates the number of seconds required to complete a Crypto Erase s= anitize operation in the background when the No-Deallocate Modifies Media A= fter Sanitize field is not set to 10b. + // + UINT32 CryptoEraseEstimatedTime; + // + // Indicates the number of seconds required to complete an Overwrite san= itize operation and the associated additional media modification after the = Overwrite sanitize operation in the background. + // The No-Deallocate After Sanitize bit was set to =E2=80=981=E2=80=99 i= n the Sanitize command that requested the Overwrite sanitize operation. + // The No-Deallocate Modifies Media After Sanitize field is set to 10b. + // + UINT32 OverwriteEstimatedTimeWithNodmm; + // + // Indicates the number of seconds required to complete a Block Erase sa= nitize operation and the associated additional media modification after the= Block Erase sanitize operation in the background. + // The No-Deallocate After Sanitize bit was set to =E2=80=981=E2=80=99 i= n the Sanitize command that requested the Block Erase sanitize operation. + // The No-Deallocate Modifies Media After Sanitize field is set to 10b. + // + UINT32 BlockEraseEstimatedTimeWithNodmm; + // + // Indicates the number of seconds required to complete a Crypto Erase = sanitize operation and the associated additional media modification after t= he Crypto Erase sanitize operation in the background. + // The No-Deallocate After Sanitize bit was set to =E2=80=981=E2=80=99 i= n the Sanitize command that requested the Crypto Erase sanitize operation. + // The No-Deallocate Modifies Media After Sanitize field is set to 10b. + // + UINT32 CryptoEraseEstimatedTimeWithNodmm; + UINT8 Reserved[480]; +} NVME_SANITIZE_STATUS_INFO_LOG; + #pragma pack() =20 #endif --=20 2.42.0.windows.2 --=20 Tina Chen -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110952): https://edk2.groups.io/g/devel/message/110952 Mute This Topic: https://groups.io/mt/102481639/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-