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 41318D80F9A for ; Mon, 6 Nov 2023 15:38:56 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=a+ZsKVj7OLQD9sxHBuui+j0CZ6Y6/j45RDf18Vp7c2g=; 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=1699285134; v=1; b=medxdLwL+eWaHBVCcCXL43j/NFQ6uIo9bmCuvgiLT688NlVTUUCUQN/4uY63Mreeu7sdV5A4 PZw3n4uxskauANI0e/n9j+57n6yj5IM91WeP2hM1B8Zvu0T/wQql+Gc43DIAZjXw23Z2rqy7+LZ BSQ059WHvUaIejFOD/LUd4uw= X-Received: by 127.0.0.2 with SMTP id hhCMYY7687511xdJ8SeUh8aA; Mon, 06 Nov 2023 07:38:54 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.55079.1699279281097844038 for ; Mon, 06 Nov 2023 06:01:21 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10886"; a="393173671" X-IronPort-AV: E=Sophos;i="6.03,281,1694761200"; d="scan'208";a="393173671" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 06:01:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10886"; a="906068256" X-IronPort-AV: E=Sophos;i="6.03,281,1694761200"; d="scan'208";a="906068256" X-Received: from chentina-desk.gar.corp.intel.com ([10.5.215.16]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 06:01:18 -0800 From: "Tina Chen" To: devel@edk2.groups.io Cc: Tina Chen , Xiao X Chen , Arthur Chen , Ray Ni , Liming Gao Subject: [edk2-devel] [PATCH V1] MdePkg:Add NVME Sanitize command support to Nvme.h Date: Mon, 6 Nov 2023 22:01:04 +0800 Message-ID: <20231106140105.1678-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: GLHIbpvHdJ5JNRzzoHt5H3ryx7686176AA= 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=medxdLwL; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none) 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: Xiao X Chen Cc: Arthur Chen Cc: Ray Ni Cc: Liming Gao Signed-off-by: Tina Chen --- MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c | 1 + MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.c | 1 + MdePkg/Include/IndustryStandard/Nvme.h | 106 ++++++++++++++= ++++-- 3 files changed, 98 insertions(+), 10 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c b/MdeModule= Pkg/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->R= ab)); DEBUG ((DEBUG_INFO, " IEEE : 0x%x\n", *(UINT32 *)Private->Contro= llerData->Ieee_oui)); DEBUG ((DEBUG_INFO, " AERL : 0x%x\n", Private->ControllerData->A= erl)); + DEBUG ((DEBUG_INFO, " Sanicap : 0x%x\n", Private->ControllerData->S= anicap)); DEBUG ((DEBUG_INFO, " SQES : 0x%x\n", Private->ControllerData->S= qes)); DEBUG ((DEBUG_INFO, " CQES : 0x%x\n", Private->ControllerData->C= qes)); DEBUG ((DEBUG_INFO, " NN : 0x%x\n", Private->ControllerData->N= n)); diff --git a/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiHci.c b/MdeMod= ulePkg/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/Indust= ryStandard/Nvme.h index 8b8a1bb7f3..d158d6c267 100644 --- a/MdePkg/Include/IndustryStandard/Nvme.h +++ b/MdePkg/Include/IndustryStandard/Nvme.h @@ -403,7 +403,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 Temperat= ure */ + UINT16 Mxtmt; /* Maximum Thermal Management Temperat= ure */ + 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 +695,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 +717,25 @@ 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; + // // NvmExpress Admin Format NVM Command // @@ -770,6 +798,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 +901,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 +924,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 +965,14 @@ typedef enum { =20 // // Get Log Page ? Log Page Identifiers -// (ref. spec. v1.1 Figure 73). +// (ref. spec. v2.0 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 +1095,59 @@ typedef struct { UINT8 Reserved2[296]; } NVME_SMART_HEALTH_INFO_LOG; =20 +// +// 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 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.35.2.windows.1 --=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 (#110751): https://edk2.groups.io/g/devel/message/110751 Mute This Topic: https://groups.io/mt/102422560/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-