<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">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.<br>
      <br>
      <br>
      <br>
      On 3/21/2014 1:11 PM, Robles, Raymond C wrote:<br>
    </div>
    <blockquote
cite="mid:49158E750348AA499168FD41D88983606269B8A2@FMSMSX105.amr.corp.intel.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Times New Roman","serif";
        color:#44546A;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span
            style="font-size:10.0pt;color:#44546A">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.
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
            style="font-size:10.0pt;color:#44546A"><o:p> </o:p></span></p>
        <div>
          <div style="border:none;border-top:solid #E1E1E1
            1.0pt;padding:3.0pt 0in 0in 0in">
            <p class="MsoNormal"><b><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:windowtext">From:</span></b><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:windowtext">
                <a class="moz-txt-link-abbreviated" href="mailto:nvmewin-bounces@lists.openfabrics.org">nvmewin-bounces@lists.openfabrics.org</a>
                [<a class="moz-txt-link-freetext" href="mailto:nvmewin-bounces@lists.openfabrics.org">mailto:nvmewin-bounces@lists.openfabrics.org</a>]
                <b>On Behalf Of </b>Jeff Glass<br>
                <b>Sent:</b> Friday, March 21, 2014 9:09 AM<br>
                <b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:nvmewin@lists.openfabrics.org">nvmewin@lists.openfabrics.org</a><br>
                <b>Subject:</b> Re: [nvmewin] Handling NVMe Passthrough
                IOCTLs<o:p></o:p></span></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div>
          <p class="MsoNormal">You said "Note: I am getting proper
            handle from CreateFile for my NVMe Device."  Did you open
            <a moz-do-not-send="true"
              href="file:///%5C%5C.%5CPhysicalDriveXxxx">\\.\PhysicalDriveXxxx</a>
            or <a moz-do-not-send="true"
              href="file:///%5C%5C.%5CScsiXxxx">
              \\.\ScsiXxxx</a>?<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:<o:p></o:p></p>
        </div>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">Hi
                  Team,<o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"><o:p> </o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">By
                  referring PT_IOCTL.Doc and WDK SPTI Sample, I am
                  developing an application to send IOCTLs<o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">using
                  _NVME_PASS_THROUGH_IOCTL structure.<o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"><o:p> </o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">I
                  am facing some problem.<o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">DeviceIoControl
                  routine returning Error code 1 (Incorrect Function).<o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"><o:p> </o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">Code
                  shown below :<o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"><o:p> </o:p></span></p>
            </div>
            <div>
              <div>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">PNVME_PASS_THROUGH_IOCTL
                    pInBuffer = NULL;</span><o:p></o:p></p>
              </div>
              <div>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">PNVME_PASS_THROUGH_IOCTL
                    pOutBuffer = NULL;</span><o:p></o:p></p>
              </div>
              <div>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">ULONG
                      ByteSizeTX =4096;</span><o:p></o:p></p>
              </div>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"><o:p> </o:p></span></p>
            </div>
            <div>
              <div>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">/*
                    Allocate input buffer to accommodate size of
                    NVME_PASS_THRUGH_IOCTL only */</span><o:p></o:p></p>
              </div>
              <div>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">InputBufLen
                    = sizeof(NVME_PASS_THROUGH_IOCTL);</span><o:p></o:p></p>
              </div>
              <div>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">pInBuffer
                    = (PNVME_PASS_THROUGH_IOCTL) malloc(InputBufLen); </span><o:p></o:p></p>
              </div>
              <div>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">/*
                    Allocate output buffer to accommodate size of
                    NVME_PASS_THRUGH_IOCTL and data */</span><o:p></o:p></p>
              </div>
              <div>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">OutputBufLen
                    = sizeof(NVME_PASS_THROUGH_IOCTL)+ ByteSizeTX - 1;</span><o:p></o:p></p>
              </div>
              <div>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">pOutBuffer
                    = (PNVME_PASS_THROUGH_IOCTL) malloc(OutputBufLen); </span><o:p></o:p></p>
              </div>
            </div>
            <div>
              <div>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">if
                    (pInBuffer == NULL || pOutBuffer == NULL)</span><o:p></o:p></p>
              </div>
              <div>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">return;</span><o:p></o:p></p>
              </div>
              <div>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"><o:p> </o:p></span></p>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">           
                    /* Zero out the buffers */</span><o:p></o:p></p>
              </div>
              <div>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">memset(pInBuffer,
                    0, InputBufLen);</span><o:p></o:p></p>
              </div>
              <div>
                <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">memset(pOutBuffer,
                    0, OutputBufLen);</span><o:p></o:p></p>
              </div>
              <div>
                <p class="MsoNormal"><o:p> </o:p></p>
              </div>
              <div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">pInBuffer->SrbIoCtrl.HeaderLength
                      = sizeof(SRB_IO_CONTROL);<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">memcpy((UCHAR*)(&pInBuffer->SrbIoCtrl.Signature[0]),
                      NVME_SIG_STR, NVME_SIG_STR_LEN);<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">pInBuffer->SrbIoCtrl.Timeout
                      = NVME_PT_TIMEOUT;<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">pInBuffer->SrbIoCtrl.ControlCode
                      = (ULONG)NVME_PASS_THROUGH_SRB_IO_CODE;<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">pInBuffer->SrbIoCtrl.Length
                      = InputBufLen - sizeof(SRB_IO_CONTROL);<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"><o:p> </o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">pInBuffer->NVMeCmd[0]=ADMIN_IDENTIFY;<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">pInBuffer->NVMeCmd[1]=0;<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">pInBuffer->NVMeCmd[10]=
                      1; //Return corresponding controller data
                      structure<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"><o:p> </o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">pInBuffer->DataBufferLen
                      = 0;<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">pInBuffer->ReturnBufferLen
                      = sizeof(NVME_PASS_THROUGH_IOCTL) + ByteSizeTX -
                      1;<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"><o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"><o:p> </o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"><o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"> status
                      = DeviceIoControl(<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"> 
                                              fileHandle,              
                                  /* Handle to
                      <a moz-do-not-send="true"
                        href="file:///%5C%5C.%5Cscsi">\\.\scsi</a>
                      device via CreateFile */<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"> 
                                              IOCTL_SCSI_MINIPORT,   /*
                      IO control function to a miniport driver */<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"> 
                                              pInBuffer       ,        
                                   /* Input buffer with data sent to
                      driver */<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"> 
                                              InputBufLen,              
                              /* Length of data sent to driver (in
                      bytes) */<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"> 
                                              pOutBuffer,              
                         /* Output buffer with data received from driver
                      */<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"> 
                                              OutputBufLen,            
                                /* Length of data received from driver
                      */<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"> 
                                              &Count,              
                                         /* Bytes placed in DataBuffer
                      */<o:p></o:p></span></p>
                </div>
                <div>
                  <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"> 
                                              NULL);                 <o:p></o:p></span></p>
                </div>
              </div>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"> <o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">Kindly
                  let me know your valuable inputs about this behavior.<o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"><o:p> </o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">Note:
                  I am getting proper handle from CreateFile for my NVMe
                  Device.<o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066"><o:p> </o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">Regards,<o:p></o:p></span></p>
            </div>
            <div>
              <p class="MsoNormal"><span
style="font-family:"Tahoma","sans-serif";color:#000066">Sai<o:p></o:p></span></p>
            </div>
          </div>
          <p class="MsoNormal"><br>
            <br>
            <br>
            <o:p></o:p></p>
          <pre>_______________________________________________<o:p></o:p></pre>
          <pre>nvmewin mailing list<o:p></o:p></pre>
          <pre><a moz-do-not-send="true" href="mailto:nvmewin@lists.openfabrics.org">nvmewin@lists.openfabrics.org</a><o:p></o:p></pre>
          <pre><a moz-do-not-send="true" href="http://lists.openfabrics.org/cgi-bin/mailman/listinfo/nvmewin">http://lists.openfabrics.org/cgi-bin/mailman/listinfo/nvmewin</a><o:p></o:p></pre>
        </blockquote>
        <p class="MsoNormal"><o:p> </o:p></p>
      </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>