Programmatically getting a FC drive's WWNN, WWPN and PortID

Trent Nelson trent at snakebite.org
Thu May 3 05:51:18 UTC 2012


    How can I programmatically get the WWNN, WWPN and PortID of a drive?  The
    info is available via dmesg when the drive is detected:

        % dmesg | grep da31
        da31 at isp1 bus 0 scbus6 target 13 lun 0
        da31: <SEAGATE ST336605FC 0005> Fixed Direct Access SCSI-3 device 
        da31: 200.000MB/s transfers WWNN 0x20000004cf83a4b2 WWPN 0x21000004cf83a4b2 PortID 0xcd
        da31: Command Queueing enabled
        da31: 35003MB (71687371 512 byte sectors: 255H 63S/T 4462C)

    I figured `camcontrol inquiry` would be my best shot, but no dice:

        % camcontrol inquiry da31
        pass32: <SEAGATE ST336605FC 0005> Fixed Direct Access SCSI-3 device 
        pass32: Serial Number 3FP1G51L00007240R1BS
        pass32: 200.000MB/s transfers, Command Queueing Enabled

    It would be ace if camcontrol inquiry could be taught about WWNNs, WWPNs
    and PortIDs.  In the mean time, is there any `camcontrol cmd`-type magic
    I could use to get at the values?

    Use case: some Python code I'm working on that basically does this:
        <1. knowledge of which disks are in which JBOD arrays> +
        <2. knowledge of JBOD ports->SAN switch ports> +
        <3. knowledge of localhost HBA->SAN switch port> +
        <4. knowledge of localhost HBA->accessible disks by WWPN> +
        <5. knowledge of port bandwidth limits> +
        <6. knowledge of other systems' 'claimed' disks+paths>

          = Automatic optimal gmultipath/zpool configuration
            
    Step 4 needs to be able to get at disk WWNN/WWPN/PortIDs for a given HBA
    in a programatic/reliable fashion (`dmesg | grep da33` isn't reliable).

    If there isn't some sort of magic `camcontrol cmd` I can send in the
    interim, I'm all ears for what I'd need to hack in order to implement
    this functionality :-)

    Regards,

        Trent.



More information about the freebsd-scsi mailing list