[nvmewin] 答复: send ADMIN_FIRMWARE_IMAGE_DOWNLOAD command fail

Cheng Peng cheng.peng at memblaze.com
Mon Jun 22 20:05:42 PDT 2015


Hi Ray

Thanks for your reply.

I have referenced the PT IOCTL document on the nvmewin repo

I find a related thread: https://www.osronline.com/showthread.cfm?link=249023

The code is following:

int nvme_fwdownload(int argc, char **argv)
{
    int c, option_index = 0, fw_image = 0;
    int error, slot_used = 0, total_slots = 0, slot;
    int activate = 1, device_index = 0;
    HANDLE fd, mapobj, ssd;
    void *mapped_file_addr;
    unsigned long size, len;
    PNVME_PASS_THROUGH_IOCTL ioctl_buffer = NULL;
    PNVMe_COMMAND nvme_cmd = NULL;
    PADMIN_FIRMWARE_IMAGE_DOWNLOAD_COMMAND_DW10 cdw10;

    /*
    * firmware transfer works in units of Dwords,
    * so we do check here to find the special case.
    */
    if (size % 4) {
        printf("Fwdownload: size of the image file %llu bytes\n", size);
        exit(1);
    }

    mapobj = CreateFileMapping(fd,
                        NULL,
                        PAGE_READONLY,
                        0,
                        0,
                        NULL);
    if (mapobj == NULL) {
        error = GetLastError();
        printf("Fwdownload: CreateFileMapping fail, error %d\n", error);
        exit(1);
    }
    mapped_file_addr = MapViewOfFile(mapobj,
                        FILE_MAP_READ,
                        0,
                        0,
                        size);
    if (mapped_file_addr == NULL) {
        error = GetLastError();
        printf("Fwdownload: MapViewofFile fail, error %d\n", error);
        exit(1);
    }

    len = sizeof(NVME_PASS_THROUGH_IOCTL) + size - 1;
    ioctl_buffer = (PNVME_PASS_THROUGH_IOCTL)malloc(len);
    memset(ioctl_buffer, 0, len);

    memcpy(ioctl_buffer->DataBuffer, mapped_file_addr, size);
    /*
    * unmap it immediately after copying the fw to databuffer.
    * In case there is somewhere modify the fw.
    */
    UnmapViewOfFile(mapped_file_addr);
    mapped_file_addr = NULL;
    CloseHandle(mapobj);
    CloseHandle(fd);

    ioctl_buffer->SrbIoCtrl.HeaderLength   = sizeof(SRB_IO_CONTROL);
    memcpy(ioctl_buffer->SrbIoCtrl.Signature, NVME_SIG_STR, sizeof(NVME_SIG_STR));
    ioctl_buffer->SrbIoCtrl.Timeout= 30;
    ioctl_buffer->SrbIoCtrl.ControlCode = (ULONG)NVME_PASS_THROUGH_SRB_IO_CODE;
    ioctl_buffer->SrbIoCtrl.Length = len - sizeof(SRB_IO_CONTROL);

    nvme_cmd = (PNVMe_COMMAND)ioctl_buffer->NVMeCmd;
    nvme_cmd->CDW0.OPC = ADMIN_FIRMWARE_IMAGE_DOWNLOAD;
    nvme_cmd->NSID = 0;
    cdw10 = (PADMIN_FIRMWARE_IMAGE_DOWNLOAD_COMMAND_DW10)&nvme_cmd->CDW10;
    cdw10->NUMD = size / 4 - 1;

    ioctl_buffer->QueueId = 0; /* Admin queue */
    ioctl_buffer->DataBufferLen = size;
    ioctl_buffer->Direction = NVME_FROM_HOST_TO_DEV;
    ioctl_buffer->ReturnBufferLen = len;

    printf("firmware image size %llu\n", size);
    if(nvme_ioctl(ssd, ioctl_buffer, len, 0))
        exit(1);

    if (activate) {
        printf("auto-activate this firmware...\n");

        nvme_get_current_slot(&slot_used, &ssd);
        printf("slot used: %d total_slots: %d\n", slot_used, total_slots);
        slot = (slot_used + 1 > total_slots ? 2 : ++slot_used);

        activate_slot_action(&ssd, slot, 1);
    }

    if (ioctl_buffer) {
        free(ioctl_buffer);
        ioctl_buffer = NULL;
    }

    nvme_close_device(&ssd);
    ssd = NULL;

    return 0;
}

发件人: Robles, Raymond C [mailto:raymond.c.robles at intel.com]
发送时间: Tuesday, June 23, 2015 5:33 AM
收件人: Cheng Peng; nvmewin at lists.openfabrics.org
主题: RE: send ADMIN_FIRMWARE_IMAGE_DOWNLOAD command fail

Hi Cheng,

Could you please provide contents of the pass through IOCTL structure you create? Also, any of the sample user space code you use to create the IOCTL would be helpful.

In addition, have you referenced the PT IOCTL document on the nvmewin repo? This document has sample code on how to construct pass through IOCTL’s.

Thanks,
Ray

From: nvmewin-bounces at lists.openfabrics.org<mailto:nvmewin-bounces at lists.openfabrics.org> [mailto:nvmewin-bounces at lists.openfabrics.org] On Behalf Of Cheng Peng
Sent: Thursday, June 18, 2015 2:13 AM
To: nvmewin at lists.openfabrics.org<mailto:nvmewin at lists.openfabrics.org>
Subject: [nvmewin] send ADMIN_FIRMWARE_IMAGE_DOWNLOAD command fail

Hi all

When I send ADMIN_FIRMWARE_IMAGE_DOWNLOAD command to driver by DeviceIoControl,  I get error code 1450 (ERROR_NO_SYSTEM_RESOURCES)

I find the driver don’t receive the ioctl command.

It is as if the size of firmware image is larger than pPCI->MaximumTransferLength.

How to resolve the problem?

Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/nvmewin/attachments/20150623/834b9312/attachment.html>


More information about the nvmewin mailing list