[nvmewin] Handling NVMe Passthrough IOCTLs

Saikrishna Ravikanti saikrishna.ravikanti at gmail.com
Fri Mar 21 08:57:46 PDT 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/nvmewin/attachments/20140321/ae98bc22/attachment.html>


More information about the nvmewin mailing list