From: "Tina Chen" <tina.chen@intel.com>
To: devel@edk2.groups.io
Cc: Tina Chen <tina.chen@intel.com>,
Xiao X Chen <xiao.x.chen@intel.com>,
Arthur Chen <arthur.g.chen@intel.com>, Ray Ni <ray.ni@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>
Subject: [edk2-devel] [PATCH v2] MdePkg:Add NVME Sanitize command support to Nvme.h
Date: Tue, 7 Nov 2023 11:37:20 +0800 [thread overview]
Message-ID: <20231107033721.1546-1-tina.chen@intel.com> (raw)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4591
1. Refer NVME spec 2.0c chapter 5.24, add Sanitize Command related definition.
2. Refer NVME spec 2.0c chapter 5.16, add Get Log Page Command related definition for Sanitize status support.
Cc: Xiao X Chen <xiao.x.chen@intel.com>
Cc: Arthur Chen <arthur.g.chen@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Tina Chen <tina.chen@intel.com>
---
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c | 1 +
MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.c | 1 +
MdePkg/Include/IndustryStandard/Nvme.h | 109 ++++++++++++++++++--
3 files changed, 100 insertions(+), 11 deletions(-)
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c
index b90c48731c..2ecaa2bbbe 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c
@@ -908,6 +908,7 @@ NvmeControllerInit (
DEBUG ((DEBUG_INFO, " RAB : 0x%x\n", Private->ControllerData->Rab));
DEBUG ((DEBUG_INFO, " IEEE : 0x%x\n", *(UINT32 *)Private->ControllerData->Ieee_oui));
DEBUG ((DEBUG_INFO, " AERL : 0x%x\n", Private->ControllerData->Aerl));
+ DEBUG ((DEBUG_INFO, " Sanicap : 0x%x\n", Private->ControllerData->Sanicap));
DEBUG ((DEBUG_INFO, " SQES : 0x%x\n", Private->ControllerData->Sqes));
DEBUG ((DEBUG_INFO, " CQES : 0x%x\n", Private->ControllerData->Cqes));
DEBUG ((DEBUG_INFO, " NN : 0x%x\n", Private->ControllerData->Nn));
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.c b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.c
index fc7b684940..61ef06e42f 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.c
@@ -436,6 +436,7 @@ NvmeDumpControllerData (
DEBUG ((DEBUG_INFO, " RAB : 0x%x\n", ControllerData->Rab));
DEBUG ((DEBUG_INFO, " IEEE : 0x%x\n", *(UINT32 *)ControllerData->Ieee_oui));
DEBUG ((DEBUG_INFO, " AERL : 0x%x\n", ControllerData->Aerl));
+ DEBUG ((DEBUG_INFO, " Sanicap : 0x%x\n", ControllerData->Sanicap));
DEBUG ((DEBUG_INFO, " SQES : 0x%x\n", ControllerData->Sqes));
DEBUG ((DEBUG_INFO, " CQES : 0x%x\n", ControllerData->Cqes));
DEBUG ((DEBUG_INFO, " NN : 0x%x\n", ControllerData->Nn));
diff --git a/MdePkg/Include/IndustryStandard/Nvme.h b/MdePkg/Include/IndustryStandard/Nvme.h
index 8b8a1bb7f3..32a2b4515d 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.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2017 - 2023, Intel Corporation. All rights reserved.<BR>
@@ -9,6 +9,7 @@
NVMe Specification 1.1
NVMe Specification 1.4
NVMe Specification 2.0
+ NVMe Specification 2.c
**/
@@ -403,7 +404,15 @@ 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 Temperature */
+ UINT16 Mxtmt; /* Maximum Thermal Management Temperature */
+ UINT32 Sanicap; /* Sanitize Capabilities */
+ #define SANITIZE_OVERWRITE_ERASE_SUPPORTED BIT2
+ #define SANITIZE_BLOCK_ERASE_SUPPORTED BIT1
+ #define SANITIZE_CRYPTO_ERASE_SUPPORTED BIT0
+ UINT8 Rsvd2[180]; /* Reserved as of Nvm Express 1.4 Spec */
//
// NVM Command Set Attributes
//
@@ -687,10 +696,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 +718,25 @@ typedef struct {
UINT32 Sv : 1; /* Save */
} NVME_ADMIN_SET_FEATURES;
+//
+// 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;
+
//
// NvmExpress Admin Format NVM Command
//
@@ -770,6 +799,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;
typedef struct {
@@ -872,6 +902,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
#define NVME_IO_FLUSH_OPC 0
#define NVME_IO_WRITE_OPC 1
@@ -894,7 +925,8 @@ typedef enum {
NamespaceAttachmentOpcode = NVME_ADMIN_NAMESACE_ATTACHMENT_CMD,
FormatNvmOpcode = NVME_ADMIN_FORMAT_NVM_CMD,
SecuritySendOpcode = NVME_ADMIN_SECURITY_SEND_CMD,
- SecurityReceiveOpcode = NVME_ADMIN_SECURITY_RECEIVE_CMD
+ SecurityReceiveOpcode = NVME_ADMIN_SECURITY_RECEIVE_CMD,
+ SanitizeOpcode = NVME_ADMIN_SANITIZE_CMD
} NVME_ADMIN_COMMAND_OPCODE;
//
@@ -934,12 +966,14 @@ typedef enum {
//
// Get Log Page ? Log Page Identifiers
-// (ref. spec. v1.1 Figure 73).
+// (ref. spec. v2.0 Figure 202).
//
typedef enum {
- ErrorInfoLogID = LID_ERROR_INFO,
- SmartHealthInfoLogID = LID_SMART_INFO,
- FirmwareSlotInfoLogID = LID_FW_SLOT_INFO
+ ErrorInfoLogID = LID_ERROR_INFO,
+ SmartHealthInfoLogID = LID_SMART_INFO,
+ FirmwareSlotInfoLogID = LID_FW_SLOT_INFO,
+ BootPartitionInfoLogID = LID_BP_INFO,
+ SanitizeStatusInfoLogID = LID_SANITIZE_STATUS_INFO
} NVME_LOG_ID;
//
@@ -1062,6 +1096,59 @@ typedef struct {
UINT8 Reserved2[296];
} NVME_SMART_HEALTH_INFO_LOG;
+//
+// Sanitize Status (Log Identifier 81h)
+// (ref. spec. v2.0 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 operation. (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 command that started the sanitize operation whose status is reported in the SSTAT field. (SCDW10)
+ //
+ UINT32 SanitizeCmdDw10Info;
+ //
+ // Indicates the number of seconds required to complete an Overwrite sanitize operation with 16 passes in the background when the No-Deallocate Modifies Media After Sanitize field is not set to 10b.
+ //
+ UINT32 OverwriteEstimatedTime;
+ //
+ // Indicates the number of seconds required to complete a Block Erase sanitize operation in the background when the No-Deallocate Modifies Media After Sanitize field is not set to 10b.
+ //
+ UINT32 BlockEraseEstimatedTime;
+ //
+ // Indicates the number of seconds required to complete a Crypto Erase sanitize operation in the background when the No-Deallocate Modifies Media After Sanitize field is not set to 10b.
+ //
+ UINT32 CryptoEraseEstimatedTime;
+ //
+ // Indicates the number of seconds required to complete an Overwrite sanitize operation and the associated additional media modification after the Overwrite sanitize operation in the background.
+ // The No-Deallocate After Sanitize bit was set to ‘1’ in 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 sanitize 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 ‘1’ in 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 the Crypto Erase sanitize operation in the background.
+ // The No-Deallocate After Sanitize bit was set to ‘1’ in 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()
#endif
--
2.42.0.windows.2
--
Tina Chen
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110796): https://edk2.groups.io/g/devel/message/110796
Mute This Topic: https://groups.io/mt/102436769/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
reply other threads:[~2023-11-07 3:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231107033721.1546-1-tina.chen@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox