[nvmewin] Handling NVMe Passthrough IOCTLs
Jeff Glass
akyros000 at gmail.com
Fri Mar 21 13:57:54 PDT 2014
If he has a handle to the disk device he should be able to send
IOCTL_SCSI_GET_ADDRESS to determine the ScsiXxx name of the HBA device.
The "PortNumber" field of the returned SCSI_ADDRESS structure is the Xxx
portion of \\.\ScsiXxx.
On 3/21/2014 1:11 PM, Robles, Raymond C wrote:
>
> Agreed with Jeff... but you will also want to make sure you are
> opening the correct ScsiXxx handle. This varies depending on the
> system. Many times it's Scsi1or Scsi2, but essentially, you'll have to
> walk through opening handles and upon opening one successfully, seeing
> the Identify succeed.
>
>
>
> *From:*nvmewin-bounces at lists.openfabrics.org
> [mailto:nvmewin-bounces at lists.openfabrics.org] *On Behalf Of *Jeff Glass
> *Sent:* Friday, March 21, 2014 9:09 AM
> *To:* nvmewin at lists.openfabrics.org
> *Subject:* Re: [nvmewin] Handling NVMe Passthrough IOCTLs
>
>
>
> You said "Note: I am getting proper handle from CreateFile for my NVMe
> Device." Did you open \\.\PhysicalDriveXxxx
> <file:///%5C%5C.%5CPhysicalDriveXxxx> or \\.\ScsiXxxx
> <file:///%5C%5C.%5CScsiXxxx>?
>
> 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 <file:///%5C%5C.%5Cscsi> 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 <mailto:nvmewin at lists.openfabrics.org>
>
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/nvmewin
>
>
>
>
>
> _______________________________________________
> 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/0b50bf06/attachment.html>
More information about the nvmewin
mailing list