how to get the port number of the SCSI Host based adapter on my system?

Posted on 2012-09-08
Last Modified: 2012-09-17

I have two SAS host based adapters on my system. i want to fire an IOCTL on the miniport driver for these adapters to find out some hardware specific details.

To be able to fire an IOCTL, i need to create a handle for these scsi adapters using createFile function. While doing this, i need to prepare the file name is \\.\scsiN, where N stands for the  number of the SCSI adapter.

Is there anyway to determine N (the number of the SCSI adapter) directly here instead of starting with 0 iterating until my IOCTL on the minport succeeds?

I have a way to do it when i have some SCSI drives connected to the HBAs. I will fire an IOCTL with the control code IOCTL_SCSI_GET_ADDRESS on to one of the drives connected to the HBA and in return i will get a SCSI_ADDRESS structure for the SCSI disk. This structure contains the port number of the disk, which is same as the controller number.

But i don't want to do this because i want to be able to fire the IOCTL on the miniport even when the disks are not connected.

Please let me know if anybody can help.
Question by:raj_ksrt
    1 Comment
    LVL 46

    Accepted Solution

    I've always actually scanned. If you don't, then you won't be able to detect devices that aren't attached (i.e, have no drive letter associated with them, or they aren't part of a software RAID set; or you haven't run a diskpart rescan yet)

    So 1)  do a loop opening \\.\SCSIn  (I go from 0-15)
    Then 2) use the IOCTL as you described.

    * Don't make the assumption that every attached device is going to be a SCSI device type 0.  

    * Also be aware of SATA disks attached to SAS controllers.  While the standard SCSI pass-through IOCTLS will work, you will get an emulated target and you have to use vendor/product specific code to do even basic things like get the correct make/model/serial number of the target device.  That is because in SCSI world, the Vendor / Product IDs are 8/16 bytes respectively, and the serial number can be on EVPD page 80, or 83, or sometimes somewhere else.

    But on SATA devices, you have a fixed 40-byte MAKE/MODEL field, and I think 20 bytes for serial number.  Something always gets lost in the translation.

    * Unless you have control over the hardware, then also be aware of iSCSI target devices, and hardware RAID devices.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Having issues meeting security compliance criteria because of those pesky USB drives? Then I can help you! This article will explain how to disable USB Mass Storage devices in Windows Server 2008 R2.
    Create your own, high-performance VM backup appliance by installing NAKIVO Backup & Replication directly onto a Synology NAS!
    Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
    In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now