From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400d:c0d::22b; helo=mail-qt0-x22b.google.com; envelope-from=rafaelrodrigues.machado@gmail.com; receiver=edk2-devel@lists.01.org Received: from mail-qt0-x22b.google.com (mail-qt0-x22b.google.com [IPv6:2607:f8b0:400d:c0d::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CDB3421F0DB0E for ; Thu, 29 Mar 2018 07:06:45 -0700 (PDT) Received: by mail-qt0-x22b.google.com with SMTP id l18so6370016qtj.1 for ; Thu, 29 Mar 2018 07:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xdkFSgln2v8LsrH4EyfQvam3F5vHkJpKpJHRAlxTX6Y=; b=aIdd7GC3nASxM//mSnXaGCiHPaK+8nRm+twTaCSe6i/H6soKERibFeDjleajSPgeHc ZD2UddGf0MZx6ANxWfV9ZlxByQcoaTATmtFFhekvg92jh6pDeStB+pXR9nId/4XDlrSH scFEVupDTsTg6WOG3oVoBTGe0UpsIQwvnC4T/dcOO0AlNoZ3oEoqutfTxww/Vdo9JRMh /wM0/e8kCijZISIgQ4h73kY0whJJBQcWanqcTz8YW5rNSfAroXqVJDAsYEJWkRktZsfe iJ7DzOM9yqvOCKRrj8Zzuhu1iPWIqYJzAtDa6pXyFqrsRKWezid5OtL5G18J6IwJmtdV AJ+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xdkFSgln2v8LsrH4EyfQvam3F5vHkJpKpJHRAlxTX6Y=; b=X0V5HHsTm7Mgc2HzCgxaVjnwzvnD6NblW4sVj6r82ziweJVFzfWO7Zk1scMceo/XUf H9zfrA7Lvp/ZvvwvFm18g2Lf5MviUq0OpEHaMs9IpAOHegP8gGdiCAQhLF+Uaocn0Ela YudaiEKGKWCjKZWu1f9gOD3BRx8XYrnb+zZeKFFS4ANzbFjV8B+9vnrDWXENeR7lYDJA 7guXbJobJSgv8pqLiylAzYh+Ovsl91ExqAjr3UN7mJnALBsYlWhg/3nomO/O391Hh4QU /P3tLvPRJWXXBH2Q6hyutm5eFgeuNAjSJYVWG8nJqW8El1yS1UcOHfru1vQvZUtugZeU 7FLA== X-Gm-Message-State: AElRT7E8SnUS812owbUhl7gf8w6MSCAaCGWsnA10PGl0zdmzlUmboRgj Rz5RqsiiwexI7WpnxPd+FFxPlYN4nMzeVWHMBBQ= X-Google-Smtp-Source: AIpwx49+HajLodQZvBmzHXgyxsWW+j+tpc+7oTacOMpz0PUOysJtuh/Lcmo8y7dg4Agia73InRHF7reD0kA0iCJNg4U= X-Received: by 10.200.48.247 with SMTP id w52mr11511878qta.226.1522332804232; Thu, 29 Mar 2018 07:13:24 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Rafael Machado Date: Thu, 29 Mar 2018 14:13:13 +0000 Message-ID: To: "Wu, Hao A" Cc: "edk2-devel@lists.01.org" X-Content-Filtered-By: Mailman/MimeDel 2.1.26 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 14:06:46 -0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Hao Wu Thanks for clarifying. The problem was that my code didn't consider the command packet CDw10 as 0's based. Best Regards Rafael R. Machado Em qua, 28 de mar de 2018 =C3=A0s 22:30, Wu, Hao A esc= reveu: > 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 > > > > Hi everyone > > > > 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 > like > > to have a 100% understanding of why it works. > > > > To retrieve the SMART data I send the command > > (EFI_NVM_EXPRESS_COMMAND) as > > follows: > > > > //************************************************************ > > //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 i= s > > the 0xFFFFFFFF to retrieve the global information > > Command->Cdw10 =3D (4096 << 16) | 2; // page 2 is the Smart/Health log > page > > Command->Cdw11 =3D 0x0; > > Command->Cdw12 =3D 0x0; > > Command->Cdw13 =3D 0x0; > > Command->Flags =3D CDW10_VALID > > | CDW11_VALID > > | CDW12_VALID > > | CDW13_VALID; > > > > // 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; > > //************************************************************ > > > > 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. > > > > So the question is. > > Why, even having just 512 bytes to be retrieved by the GetLogCommand pa= ge > > 0x02, do I need to create a 4096 bytes buffer to retrieve the SMART dat= a > ? > > 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. > > > > > Command->Cdw10 =3D (4096 << 16) | 2; > > CommandPacket->TransferBuffer =3D (VOID*) SmartData; (allocated previou= sly) > > CommandPacket->TransferLength =3D 4096; > > > > Just for reference. When I create a 512 bytes buffer I get a DeviceErro= r > > status after the PassThru. With the sample code below: > > > > Command->Cdw10 =3D (512 << 16) | 2; > > CommandPacket->TransferBuffer =3D (VOID*) SmartData; (allocated previou= sly) > > CommandPacket->TransferLength =3D 512; > > > > > > Another question I have is: > > We have two places that we need to set the Nsid. > > > > EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET. Nsid > > EFI_NVM_EXPRESS_COMMAND.Nsid > > > > 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 > > > > > Thanks and Regards > > Rafael R. Machado > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel >