<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">You said "Note: I am getting proper
      handle from CreateFile for my NVMe Device."  Did you open
      \\.\PhysicalDriveXxxx or \\.\ScsiXxxx?<br>
      <br>
      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.<br>
      <br>
      <br>
      On 3/21/201 8:57 AM, Saikrishna Ravikanti wrote:<br>
    </div>
    <blockquote
cite="mid:CABWxpwBivtg1e+G5aG2-uD1v-RSPsj-08YPwcSAWUr0sRQKc7A@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)">Hi
          Team,</div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)">
          <br>
        </div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)">By
          referring PT_IOCTL.Doc and WDK SPTI Sample, I am developing an
          application to send IOCTLs</div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)">
          using _NVME_PASS_THROUGH_IOCTL structure.</div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)"><br>
        </div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)">
          I am facing some problem.</div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)">DeviceIoControl
          routine returning Error code 1 (Incorrect Function).</div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)">
          <br>
        </div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)">Code
          shown below :</div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)">
          <br>
        </div>
        <div class="gmail_default">
          <div class="gmail_default"><font color="#000066" face="tahoma,
              sans-serif">PNVME_PASS_THROUGH_IOCTL pInBuffer = NULL;</font></div>
          <div class="gmail_default"><font color="#000066" face="tahoma,
              sans-serif">PNVME_PASS_THROUGH_IOCTL pOutBuffer = NULL;</font></div>
          <div class="gmail_default"><font color="#000066" face="tahoma,
              sans-serif">ULONG   ByteSizeTX =4096;<br>
            </font></div>
        </div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)">
          <br>
        </div>
        <div class="gmail_default">
          <div class="gmail_default"><font color="#000066" face="tahoma,
              sans-serif">/* Allocate input buffer to accommodate size
              of NVME_PASS_THRUGH_IOCTL only */</font></div>
          <div class="gmail_default">
            <font color="#000066" face="tahoma, sans-serif"><span
                class="" style="white-space:pre"> </span>InputBufLen =
              sizeof(NVME_PASS_THROUGH_IOCTL);</font></div>
          <div class="gmail_default"><font color="#000066" face="tahoma,
              sans-serif"><span class="" style="white-space:pre"> </span>pInBuffer
              = (PNVME_PASS_THROUGH_IOCTL) malloc(InputBufLen); </font></div>
          <div class="gmail_default"><span
              style="color:rgb(0,0,102);font-family:tahoma,sans-serif">/*
              Allocate output buffer to accommodate size of
              NVME_PASS_THRUGH_IOCTL and data */</span><br>
          </div>
          <div class="gmail_default"><font color="#000066" face="tahoma,
              sans-serif"><span class="" style="white-space:pre"> </span>OutputBufLen
              = sizeof(NVME_PASS_THROUGH_IOCTL)+ ByteSizeTX - 1;</font></div>
          <div class="gmail_default"><font color="#000066" face="tahoma,
              sans-serif"><span class="" style="white-space:pre"> </span>pOutBuffer
              = (PNVME_PASS_THROUGH_IOCTL) malloc(OutputBufLen); </font></div>
        </div>
        <div class="gmail_default">
          <div class="gmail_default"><font color="#000066" face="tahoma,
              sans-serif">if (pInBuffer == NULL || pOutBuffer == NULL)</font></div>
          <div class="gmail_default"><font color="#000066" face="tahoma,
              sans-serif"><span class="" style="white-space:pre"> </span>return;</font></div>
          <div class="gmail_default"><span class=""
              style="color:rgb(0,0,102);font-family:tahoma,sans-serif;white-space:pre">
            </span><span
              style="color:rgb(0,0,102);font-family:tahoma,sans-serif">/*
              Zero out the buffers */</span><br>
          </div>
          <div class="gmail_default"><font color="#000066" face="tahoma,
              sans-serif"><span class="" style="white-space:pre"> </span>memset(pInBuffer,
              0, InputBufLen);</font></div>
          <div class="gmail_default"><font color="#000066" face="tahoma,
              sans-serif"><span class="" style="white-space:pre"> </span>memset(pOutBuffer,
              0, OutputBufLen);</font></div>
          <div class="gmail_default"><font color="#000066" face="tahoma,
              sans-serif"><br>
            </font></div>
          <div class="gmail_default"><font color="#000066" face="tahoma,
              sans-serif">
              <div class="gmail_default">pInBuffer->SrbIoCtrl.HeaderLength
                = sizeof(SRB_IO_CONTROL);</div>
              <div class="gmail_default">memcpy((UCHAR*)(&pInBuffer->SrbIoCtrl.Signature[0]),
                NVME_SIG_STR, NVME_SIG_STR_LEN);</div>
              <div class="gmail_default">pInBuffer->SrbIoCtrl.Timeout
                = NVME_PT_TIMEOUT;</div>
              <div class="gmail_default">
                pInBuffer->SrbIoCtrl.ControlCode =
                (ULONG)NVME_PASS_THROUGH_SRB_IO_CODE;</div>
              <div class="gmail_default">pInBuffer->SrbIoCtrl.Length
                = InputBufLen - sizeof(SRB_IO_CONTROL);</div>
              <div class="gmail_default"><br>
              </div>
              <div class="gmail_default">pInBuffer->NVMeCmd[0]=ADMIN_IDENTIFY;</div>
              <div class="gmail_default">pInBuffer->NVMeCmd[1]=0;</div>
              <div class="gmail_default">pInBuffer->NVMeCmd[10]= 1;
                //Return corresponding controller data structure</div>
              <div class="gmail_default"><br>
              </div>
              <div class="gmail_default">pInBuffer->DataBufferLen =
                0;</div>
              <div class="gmail_default">pInBuffer->ReturnBufferLen =
                sizeof(NVME_PASS_THROUGH_IOCTL) + ByteSizeTX - 1;</div>
              <div class="gmail_default">
                <span class="" style="white-space:pre"> </span></div>
              <div class="gmail_default"><br>
              </div>
              <div class="gmail_default"><span class=""
                  style="white-space:pre"> </span></div>
              <div class="gmail_default"><span class=""
                  style="white-space:pre"> </span>status =
                DeviceIoControl(</div>
              <div class="gmail_default"><span class=""
                  style="white-space:pre"> </span>                    
                      fileHandle,                           /* Handle to
                \\.\scsi device via CreateFile */</div>
              <div class="gmail_default"><span class=""
                  style="white-space:pre"> </span>                    
                      IOCTL_SCSI_MINIPORT,   /* IO control function to a
                miniport driver */</div>
              <div class="gmail_default"><span class=""
                  style="white-space:pre"> </span>                    
                      pInBuffer       ,                      /* Input
                buffer with data sent to driver */</div>
              <div class="gmail_default"><span class=""
                  style="white-space:pre"> </span>                    
                      InputBufLen,                       /* Length of
                data sent to driver (in bytes) */</div>
              <div class="gmail_default"><span class=""
                  style="white-space:pre"> </span>                    
                      pOutBuffer,                  /* Output buffer with
                data received from driver */</div>
              <div class="gmail_default"><span class=""
                  style="white-space:pre"> </span>                    
                      OutputBufLen,                       /* Length of
                data received from driver */</div>
              <div class="gmail_default"><span class=""
                  style="white-space:pre"> </span>                    
                      &Count,                                  /*
                Bytes placed in DataBuffer */</div>
              <div class="gmail_default"><span class=""
                  style="white-space:pre"> </span>                    
                      NULL);                 </div>
            </font></div>
        </div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)"> </div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)">
          Kindly let me know your valuable inputs about this behavior.</div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)"><br>
        </div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)">
          Note: I am getting proper handle from CreateFile for my NVMe
          Device.</div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)"><br>
        </div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)">
          Regards,</div>
        <div class="gmail_default"
          style="font-family:tahoma,sans-serif;font-size:small;color:rgb(0,0,102)">Sai</div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
nvmewin mailing list
<a class="moz-txt-link-abbreviated" href="mailto:nvmewin@lists.openfabrics.org">nvmewin@lists.openfabrics.org</a>
<a class="moz-txt-link-freetext" href="http://lists.openfabrics.org/cgi-bin/mailman/listinfo/nvmewin">http://lists.openfabrics.org/cgi-bin/mailman/listinfo/nvmewin</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>