When does Storport enumerates targets and its LUNs

Hi all,

I’m writing physical storport miniport driver for FC HBA for Windows
Server 2003 & above OSes.
I like to understand, how Storport enumerates targets & LUNs and works
under the hood. To be elaborate,

  1. What happens once HwStorInitialize is done? Does Storport
    immedietely starts scanning SCSI targets?
    Or will it start only after the StorPortNotification
    (NotificationType = BusChangeDetected)?

  2. How windows enumerates targets & its LUNs? Does it issue
    Report-LUNs to LUN0 for all possible targets? Or issues inquiry to all
    possible B-T-L?s?

Thanks & Regards,
T.V.Gokul.

  1. It immediately starts scanning for SCSI targets.
  2. Report LUNs is sent to LUN 0. Then Inquiry commands are issued to
    LUNs 0-7 plus any other LUNs in the 8-255 range reported by the Report
    LUNs command.
  3. If the Report LUNs fails with a SCSI error Command Not Supported,
    Inquiry commands are sent to LUNs 0-7.
  4. If the Report LUNs fails with SRB_STATUS_SELECTION_TIMEOUT, the scan
    proceeds to the next tartet.
  5. I’m not sure what happens with other error codes on Report LUNs.

Not sure if this is still true, but to get Windows to use Report LUNs and
to support more than 8 LUNs per target, you had to have a registry value
LargeLuns set to 1 in Parameters\Device under your service key.

Gokul TV
Sent by: xxxxx@lists.osr.com
06/19/2009 01:47 AM
Please respond to
“Windows System Software Devs Interest List”

To
“Windows System Software Devs Interest List”
cc

Subject
[ntdev] When does Storport enumerates targets and its LUNs

Hi all,

I’m writing physical storport miniport driver for FC HBA for Windows
Server 2003 & above OSes.
I like to understand, how Storport enumerates targets & LUNs and works
under the hood. To be elaborate,

1. What happens once HwStorInitialize is done? Does Storport
immedietely starts scanning SCSI targets?
Or will it start only after the StorPortNotification
(NotificationType = BusChangeDetected)?

2. How windows enumerates targets & its LUNs? Does it issue
Report-LUNs to LUN0 for all possible targets? Or issues inquiry to all
possible B-T-L?s?

Thanks & Regards,
T.V.Gokul.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

I’ll just add to Jerry’s response a little. Please keep in mind that I’m responding based on current OS builds (Windows 7), though I don’t recall any differences from Windows Vista / Server 2008. Server 2003 is back beyond my immediate memory, so I can’t confirm if this all applies to that OS.

First, it’s important to realize the Storport’s bus scans are triggered by the Plug and Play manager of Windows. Specifically, any time that PnP is asked to generate a new list of “children” for a given adapter, it tells Storport to re-enumerate, which causes Storport to issue a bus scan. This can happen for a variety of reasons:

  1. Device Manager (or some other app) requests for a rescan to be done.
  2. The miniport sends Storport a “BusChangeDetected” notification, causing Storport to tell PnP to invalidate its current device list.
  3. Upon initial creation of the device object for the adapter, PnP needs to know if it has children. (This is the first time a bus scan is done.)

During a bus scan, Storport attempts to build a “LUN list” for every possible target (as reported by the miniport). Specifically, for every possible path and target combination, Storport will send a REPORT LUNS request to LUN 0. If that succeeds, the reported LUNs will be added to the LUN list.

If the REPORT LUNS request fails for any reason, the Storport will send an INQUIRY to LUN 0. If the inquiry succeeds, LUN 0 is added to the LUN list, and Storport will likewise send inquiries to LUNS 1-7, adding them to the list of they respond. If the INQUIRY to LUN 0 fails, however, Storport simply moves on to the next target.

In addition to LUNs found up to this point, Storport will also send INQUIRYs to the LUNs that it found on the previous bus scan. If any of those respond, they’ll be added to the list as well.

Once the list is constructed, it is compared to the list from the previous bus scan to determine which devices have arrived and which ones have vanished. In some cases, a device may “change” between bus scans. That is, one device is removed and another is added at that same SCSI address. For this reason, Storport compares the INQUIRY data between the two bus scans to determine if a “change” has taken place for a given LUN. If it has, a new device object is created, causing PnP to request the removal of the old device object and initialization of the new device object.

No registry keys are needed to enable this behavior. But as I said, I can’t speak to Windows Server 2003.

– Keith

Thanks a lot Keith & Jmasker for the detailed explanation. :slight_smile:

Regards,
T.V.Gokul.

Hi All,

Thanks a lot for your detailed information.
As it is very much helpful for me for designing my Vminiport.

Thanks and Regards,
Bharat.

On Mon, Jun 22, 2009 at 10:04 AM, Gokul TV wrote:
> Thanks a lot Keith & Jmasker for the detailed explanation. :slight_smile:
>
> Regards,
> T.V.Gokul.
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
>