[nvmewin] Handling NVMe Passthrough IOCTLs

Jeff Glass akyros000 at gmail.com
Fri Mar 21 09:09:13 PDT 2014


You said "Note: I am getting proper handle from CreateFile for my NVMe
Device."  Did you open \\.\PhysicalDriveXxxx or \\.\ScsiXxxx?

You need to open a handle to the adapter (i.e. Scsi) and not the disk
(i.e. PhysicalDrive) for IOCTL_SCSI_MINIPORT.  That's the most common
mistake I've seen that causes this error.


On 3/21/201 8:57 AM, Saikrishna Ravikanti wrote:
> Hi Team,
>
> By referring PT_IOCTL.Doc and WDK SPTI Sample, I am developing an
> application to send IOCTLs
> using _NVME_PASS_THROUGH_IOCTL structure.
>
> I am facing some problem.
> DeviceIoControl routine returning Error code 1 (Incorrect Function).
>
> Code shown below :
>
> PNVME_PASS_THROUGH_IOCTL pInBuffer = NULL;
> PNVME_PASS_THROUGH_IOCTL pOutBuffer = NULL;
> ULONG   ByteSizeTX =4096;
>
> /* Allocate input buffer to accommodate size of NVME_PASS_THRUGH_IOCTL
> only */
> InputBufLen = sizeof(NVME_PASS_THROUGH_IOCTL);
> pInBuffer = (PNVME_PASS_THROUGH_IOCTL) malloc(InputBufLen); 
> /* Allocate output buffer to accommodate size of
> NVME_PASS_THRUGH_IOCTL and data */
> OutputBufLen = sizeof(NVME_PASS_THROUGH_IOCTL)+ ByteSizeTX - 1;
> pOutBuffer = (PNVME_PASS_THROUGH_IOCTL) malloc(OutputBufLen); 
> if (pInBuffer == NULL || pOutBuffer == NULL)
> return;
> /* Zero out the buffers */
> memset(pInBuffer, 0, InputBufLen);
> memset(pOutBuffer, 0, OutputBufLen);
>
> pInBuffer->SrbIoCtrl.HeaderLength = sizeof(SRB_IO_CONTROL);
> memcpy((UCHAR*)(&pInBuffer->SrbIoCtrl.Signature[0]), NVME_SIG_STR,
> NVME_SIG_STR_LEN);
> pInBuffer->SrbIoCtrl.Timeout = NVME_PT_TIMEOUT;
> pInBuffer->SrbIoCtrl.ControlCode = (ULONG)NVME_PASS_THROUGH_SRB_IO_CODE;
> pInBuffer->SrbIoCtrl.Length = InputBufLen - sizeof(SRB_IO_CONTROL);
>
> pInBuffer->NVMeCmd[0]=ADMIN_IDENTIFY;
> pInBuffer->NVMeCmd[1]=0;
> pInBuffer->NVMeCmd[10]= 1; //Return corresponding controller data
> structure
>
> pInBuffer->DataBufferLen = 0;
> pInBuffer->ReturnBufferLen = sizeof(NVME_PASS_THROUGH_IOCTL) +
> ByteSizeTX - 1;
>
> status = DeviceIoControl(
>                           fileHandle,                           /*
> Handle to \\.\scsi device via CreateFile */
>                           IOCTL_SCSI_MINIPORT,   /* IO control
> function to a miniport driver */
>                           pInBuffer       ,                      /*
> Input buffer with data sent to driver */
>                           InputBufLen,                       /* Length
> of data sent to driver (in bytes) */
>                           pOutBuffer,                  /* Output
> buffer with data received from driver */
>                           OutputBufLen,                       /*
> Length of data received from driver */
>                           &Count,                                  /*
> Bytes placed in DataBuffer */
>                           NULL);                 
>  
> Kindly let me know your valuable inputs about this behavior.
>
> Note: I am getting proper handle from CreateFile for my NVMe Device.
>
> Regards,
> Sai
>
>
> _______________________________________________
> nvmewin mailing list
> nvmewin at lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/nvmewin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/nvmewin/attachments/20140321/2f057056/attachment.html>


More information about the nvmewin mailing list