public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* NVMe Smart Data Buffer Size
@ 2018-03-28 13:32 Rafael Machado
  2018-03-29  1:30 ` Wu, Hao A
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael Machado @ 2018-03-28 13:32 UTC (permalink / raw)
  To: edk2-devel@lists.01.org

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 = NVME_ADMIN_GET_LOG_PAGE_CMD; //This is the command
0x02
Command->Nsid =   NVME_ALL_VALID_NSID; //The NSID used in this case is
the 0xFFFFFFFF to retrieve the global information
Command->Cdw10 =  (4096 << 16) | 2; // page 2 is the Smart/Health log page
Command->Cdw11 =  0x0;
Command->Cdw12 =  0x0;
Command->Cdw13 =  0x0;
Command->Flags =  CDW10_VALID
                                 | CDW11_VALID
                                 | CDW12_VALID
                                 | CDW13_VALID;

// Fill the EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET struct
This->Nsid = NVME_ALL_VALID_NSID;  //This is the NSID used by
the NVME_PROTOCOL, that is also 0xFFFFFFFF
CommandPacket->NvmeCmd        = Command;
CommandPacket->NvmeCompletion = Completion;
CommandPacket->TransferBuffer = (VOID*) SmartData;
CommandPacket->TransferLength = 4096;
CommandPacket->CommandTimeout = 0;
CommandPacket->QueueType      = NVME_ADMIN_QUEUE;
CommandPacket->MetadataBuffer = NULL;
CommandPacket->MetadataLength = 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 page
0x02, do I need to create a 4096 bytes buffer to retrieve the SMART data ?

Command->Cdw10 =  (4096 << 16) | 2;
CommandPacket->TransferBuffer = (VOID*) SmartData; (allocated previously)
CommandPacket->TransferLength = 4096;

Just for reference. When I create a 512 bytes buffer I get a DeviceError
status after the PassThru. With the sample code below:

Command->Cdw10 =  (512 << 16) | 2;
CommandPacket->TransferBuffer = (VOID*) SmartData; (allocated previously)
CommandPacket->TransferLength = 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?

Thanks and Regards
Rafael R. Machado


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-29 14:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-28 13:32 NVMe Smart Data Buffer Size Rafael Machado
2018-03-29  1:30 ` Wu, Hao A
2018-03-29 14:13   ` Rafael Machado

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox