From nobody Thu May 16 17:58:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+110796+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110796+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1699328249; cv=none; d=zohomail.com; s=zohoarc; b=no0cUxu9lvMLs/q/vl5Z+B7yjpiZkyzmWFIEfQZVXFxOM9cDerzN23/egkOmW9Wuir5DbpWDUtYIS5rDoHDV4KmI8t2DINalWBQkBh15lN+a+iI/NkmUs2YUL2otFGSv3iDRHh6dhZChd/nsX2q93HAKMxrajFfLt9gJmFZ1d7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699328249; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=wH/7ENqGp0Nr4Y/+qrTPtckKKtUeVoiTlwch4CuUBmA=; b=Vg4KXAFhvVYzIv5RW2TBPw9VDq09ThLaljDwD9cSUyB5cO8d0mfDgLKJyacJi91TOvDsjyQhBlRBAf8s5biW17rsMPsZtBQtxOZiFuFbkVK6aynk9jEfj4tAT2KiEp4PdQJGFmvkmNM5vnXCZQW2SLDCmK/GODGv8GFY1Yd3P8k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+110796+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1699328249162491.85498042910854; Mon, 6 Nov 2023 19:37:29 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=cm/vTLZCZyJJjCIE01G6/gQtu43Uesivi+3lV+zCoZ8=; 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=1699328248; v=1; b=vvr6SvkTi41ZyV5fURuX2YJWdZTQqv31XfU7PrVsuVy2B9HwoWgn+chdYdmqLHNsZdydqd1m EtucMCeSivNrPXzPkEkSGRs9DbPL6cZsEeV5ij90qXvU6bkeL+QzjFiqulXjOqutBbnqqO8uA4I kJA1ZfzZhYYhsZi/JUddoCLo= X-Received: by 127.0.0.2 with SMTP id HfHXYY1788612xDA0DNZgfAH; Mon, 06 Nov 2023 19:37:28 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web11.2852.1699328248230637747 for ; Mon, 06 Nov 2023 19:37:28 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10886"; a="386594985" X-IronPort-AV: E=Sophos;i="6.03,282,1694761200"; d="scan'208";a="386594985" X-Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 19:37:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,282,1694761200"; d="scan'208";a="10272578" X-Received: from chentina-desk.gar.corp.intel.com ([10.5.215.16]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 19:37:26 -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 v2] MdePkg:Add NVME Sanitize command support to Nvme.h Date: Tue, 7 Nov 2023 11:37:20 +0800 Message-ID: <20231107033721.1546-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: iWecZDpgVBcuSAfRRwqoCiSIx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1699328250304100001 Content-Type: text/plain; charset="utf-8" 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 | 109 ++++++++++++++= ++++-- 3 files changed, 100 insertions(+), 11 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..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. =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.c =20 **/ =20 @@ -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 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 +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; =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 +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; =20 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 =20 #define NVME_IO_FLUSH_OPC 0 #define NVME_IO_WRITE_OPC 1 @@ -894,7 +925,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 +966,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 +1096,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.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 (#110796): https://edk2.groups.io/g/devel/message/110796 Mute This Topic: https://groups.io/mt/102436769/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-