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::229; helo=mail-qt0-x229.google.com; envelope-from=rafaelrodrigues.machado@gmail.com; receiver=edk2-devel@lists.01.org Received: from mail-qt0-x229.google.com (mail-qt0-x229.google.com [IPv6:2607:f8b0:400d:c0d::229]) (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 1E2F522106DCD for ; Wed, 28 Mar 2018 06:25:40 -0700 (PDT) Received: by mail-qt0-x229.google.com with SMTP id s2so2529062qti.2 for ; Wed, 28 Mar 2018 06:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=KSVqdLuTngy+glyv8Nri4Zd+aI9y67vIi8F5+D+hIk0=; b=mCodfDedtzXOjP+L1n2z+NLNS0VpsuAbWK0Hl67j0s4ic5oJESSqb9OiATvFv4IE2f AltLpYDnFql3G0lCBuBqLR9O5PHjUAOzBnRSmgXwz/rnZvWI4z0HjSLsFuaRiBlDBSZS oLoF9cF9RP7Q+jyn/LzeJ0zyS6wPIhnFGuetxegYhzo1YTbmtsTsHb9AySomkb/AO2FU v6XC/QkGX/4jcwmA+pd0janFY3ZdjviT8qRgwqyY+fIV+ox9OEHrlahx6yJoWo24Lv9N NzyueHozb6tHtIfr5SX/WNLq6K6R7dQmKCEDGWBHHIe3IpzZdi7zkn8akHANXoUajPaW D6zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=KSVqdLuTngy+glyv8Nri4Zd+aI9y67vIi8F5+D+hIk0=; b=GvWpcWXcVRG6vDU1/xLhtkiu19wuwmwgME7c8D8hEQuQylW5jtASRG4NWl9OFsu4oL G/9BBXQ925ROMREg++XgzwgqcdZ5inkyzBddlZsvrXvvh0Oz65l2P5xmG+hMTJX4LlPM n25IHcEu6t/3pl/k3vH+D5VxYw3Zaw4rv7GwHyYBvkC/xRQFR7nHqaSVg06szEjDIkYR oyHIDwybyhCe5tBOlSGh4BIkNy2N9rl0sN3cQCkn4bAB4DYAcE9DSu3CrOxfCoyFe+6Y T1PHZ+1Q7mmay7txuhAiIBEoUm9LqU2hP64r/Acn4HA3MRi4uuujJ53T/Kpb/vSB55GD EIYw== X-Gm-Message-State: ALQs6tC4jlYbp76CrB5x0enzaBynT2xuAEn1UGBZ3fTrPqICTeh9KWar wk73Spi+4pDN8ZvdxX4l5UqRoEF83CNGUnCc/cE= X-Google-Smtp-Source: AIpwx48ul9ifPJ/7mcT4Jr7+YbvKmKmbWWFM2CdYqpPV1dnmfQVxnkT4UPQYBGdbWk3xhJs5NMfBgDbUJvRbJ38G2xY= X-Received: by 10.237.57.5 with SMTP id l5mr5027379qte.200.1522243938060; Wed, 28 Mar 2018 06:32:18 -0700 (PDT) MIME-Version: 1.0 From: Rafael Machado Date: Wed, 28 Mar 2018 13:32:07 +0000 Message-ID: To: "edk2-devel@lists.01.org" X-Content-Filtered-By: Mailman/MimeDel 2.1.26 Subject: 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: Wed, 28 Mar 2018 13:25:41 -0000 Content-Type: text/plain; charset="UTF-8" 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