From nobody Tue May 14 18:39:07 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+110751+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+110751+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1699285135; cv=none; d=zohomail.com; s=zohoarc; b=PKTyQmjJLC14fS4GNXCG6bt2WpL1kFmxL5BqMDMT3JDYfyIfwhZPfaAlkXwKpZ2+HCSJMZaouSuq7pMTuRK5/6PtA21a2nmOe5UPcEm0z8EQmsmRDvAonrL7Mec7DQON2kI6z9SSDBwvKasQJ9IvEWpmC/wFTNaUJImALV42zF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699285135; 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=WAp7ASdRX9x5HhHcog3FxAkzsyvRRX13ujLhpvVaC34=; b=DuA2y858ZQ9eFH/hAq/bkN9z8DqmbEkAomCOSxZQyFsEUKQ2GYRDBFbsycyObjERFvBDQBnUnExpYMDKKlvDOn+NMKz+jA4PNQv4UpknDaP2947A5LZkP+DpR1VNgrC5G5M9ZQZfMOWPNJ5aJVnhA4jnlK1DTutTIZ9RdtruWpA= 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+110751+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 1699285135149321.5476629155745; Mon, 6 Nov 2023 07:38:55 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=MIlnG/TPrqVFCySq5qy55QrEfbfgF6UTovBKcTHKgSE=; 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=X9+YIZiUyjcyRvy/m+y67F5Ml2vzG0EzWljrxWL0U/5dBoMx0Hi7B6DLnBAo2l2wRcgmpZSG kilzQuC6/+y8tqvxwfEC1zGnWdl7cdFXRIBpecIO2K7vXQtvNLf9XATPcODWdrcaRG5llxf6bLp NHhRfJ6dK66bjEYIh0JcEglM= X-Received: by 127.0.0.2 with SMTP id zDLnYY1788612xESTViwhRPL; 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: 1v8211hJfMR6V7oFL4DfvLl1x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1699285136098100001 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 | 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/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-