From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 53786224DD136 for ; Wed, 28 Mar 2018 18:23:55 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2018 18:30:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,374,1517904000"; d="scan'208";a="32298620" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga002.fm.intel.com with ESMTP; 28 Mar 2018 18:30:34 -0700 Received: from fmsmsx125.amr.corp.intel.com (10.18.125.40) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 28 Mar 2018 18:30:33 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX125.amr.corp.intel.com (10.18.125.40) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 28 Mar 2018 18:30:33 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.226]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.129]) with mapi id 14.03.0319.002; Thu, 29 Mar 2018 09:30:31 +0800 From: "Wu, Hao A" To: Rafael Machado , "edk2-devel@lists.01.org" Thread-Topic: [edk2] NVMe Smart Data Buffer Size Thread-Index: AQHTxpk84EX9DiiD7UegRnLMjsy78qPmahWw Date: Thu, 29 Mar 2018 01:30:30 +0000 Message-ID: References: In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: NVMe Smart Data Buffer Size X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Mar 2018 01:23:56 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, Some comments below: > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Rafael Machado > Sent: Wednesday, March 28, 2018 9:32 PM > To: edk2-devel@lists.01.org > Subject: [edk2] NVMe Smart Data Buffer Size >=20 > Hi everyone >=20 > I'am working on a development related to retrieving the SMART data > information from a NVMe device. > After some research I got to a code that works correctly, but I would lik= e > to have a 100% understanding of why it works. >=20 > To retrieve the SMART data I send the command > (EFI_NVM_EXPRESS_COMMAND) as > follows: >=20 > //************************************************************ > //Fill the EFI_NVM_EXPRESS_COMMAND struct > Command->Cdw0.Opcode =3D NVME_ADMIN_GET_LOG_PAGE_CMD; //This is > the command > 0x02 > Command->Nsid =3D NVME_ALL_VALID_NSID; //The NSID used in this case is > the 0xFFFFFFFF to retrieve the global information > Command->Cdw10 =3D (4096 << 16) | 2; // page 2 is the Smart/Health log p= age > Command->Cdw11 =3D 0x0; > Command->Cdw12 =3D 0x0; > Command->Cdw13 =3D 0x0; > Command->Flags =3D CDW10_VALID > | CDW11_VALID > | CDW12_VALID > | CDW13_VALID; >=20 > // Fill the EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET struct > This->Nsid =3D NVME_ALL_VALID_NSID; //This is the NSID used by > the NVME_PROTOCOL, that is also 0xFFFFFFFF > CommandPacket->NvmeCmd =3D Command; > CommandPacket->NvmeCompletion =3D Completion; > CommandPacket->TransferBuffer =3D (VOID*) SmartData; > CommandPacket->TransferLength =3D 4096; > CommandPacket->CommandTimeout =3D 0; > CommandPacket->QueueType =3D NVME_ADMIN_QUEUE; > CommandPacket->MetadataBuffer =3D NULL; > CommandPacket->MetadataLength =3D 0; > //************************************************************ >=20 > The question I have, is about the size of the buffer to be used as the > transfer buffer at the EFI_NVM_EXPRESS_COMMAND and at the > EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET. At the Nvme spec we > see that the > SmartData information is 512 bytes long. >=20 > So the question is. > Why, even having just 512 bytes to be retrieved by the GetLogCommand page > 0x02, do I need to create a 4096 bytes buffer to retrieve the SMART data = ? I have a check on the NVMe v1.1 spec for the Get Log Page command: For Command Dword 10: 27:16 Number of Dwords (NUMD): This field specifies the number of Dwords to return. If host software specifies a size larger than the log page requested, the results are undefined. This is a 0's based value. Per my understanding, since the field requires a 0's based Dword value, for getting the SMART / Health Information (which is 512 bytes in length), the Cdw10 should be: Command->Cdw10 =3D (127 << 16) | 2; // 128 Dword, 0's based And for the PassThru command packet: CommandPacket->TransferLength =3D 512; Please help to verify if this works properly for you. Thanks in advance. >=20 > Command->Cdw10 =3D (4096 << 16) | 2; > CommandPacket->TransferBuffer =3D (VOID*) SmartData; (allocated previousl= y) > CommandPacket->TransferLength =3D 4096; >=20 > Just for reference. When I create a 512 bytes buffer I get a DeviceError > status after the PassThru. With the sample code below: >=20 > Command->Cdw10 =3D (512 << 16) | 2; > CommandPacket->TransferBuffer =3D (VOID*) SmartData; (allocated previousl= y) > CommandPacket->TransferLength =3D 512; >=20 >=20 > Another question I have is: > We have two places that we need to set the Nsid. >=20 > EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET. Nsid > EFI_NVM_EXPRESS_COMMAND.Nsid >=20 > Since I am not a NVme expert, my question is if both represent the same > information. > Should I use 0xFFFFFFFF in both? Yes, you are right. These two values: NamespaceId param for EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.PassThru() and Nsid field of EFI_NVM_EXPRESS_COMMAND should be set to the same value. Best Regards, Hao Wu >=20 > Thanks and Regards > Rafael R. Machado > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel