Saturday, January 21, 2012

Checking WWPN for a Linux host


Here we have a dual port HBA:
root@anneke:~ # lspci | grep -i fibre
06:00.0 Fibre Channel: Emulex Corporation Zephyr-X LightPulse Fibre Channel Host Adapter (rev 02)
06:00.1 Fibre Channel: Emulex Corporation Zephyr-X LightPulse Fibre Channel Host Adapter (rev 02)

Verifying the WWPN from the HBA:
root@anneke:~ # cat /sys/class/scsi_host/host0/device/fc_host\:host0/port_name
0x10000000c99f46b4
root@anneke:~ # cat /sys/class/scsi_host/host1/device/fc_host\:host1/port_name
0x10000000c99f46b5

The WWPN show above is:
10:00:00:00:c9:9f:46:b4
10:00:00:00:c9:9f:46:b5

You can also check both HBA WWPN using the following:
cat /sys/class/scsi_host/host*/device/fc_host\:host*/port_name

Or you can use systool instead of messing with /proc:
root@anneke:~ # systool -av -c fc_host
Class = “fc_host”

Class Device = “host0?
Class Device path = “/sys/class/fc_host/host0?
active_fc4s = “0×00 0×00 0×01 0×00 0×00 0×00 0×00 0×01 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 “
fabric_name = “0x100000051ef61a00?
issue_lip =
maxframe_size = “2048 bytes”
node_name = “0x20000000c99f46b4?
port_id = “0x648acd”
port_name = “0x10000000c99f46b4?
port_state = “Online”
port_type = “NPort (fabric via point-to-point)”
speed = “4 Gbit”
supported_classes = “Class 3?
supported_fc4s = “0×00 0×00 0×01 0×00 0×00 0×00 0×00 0×01 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 “
supported_speeds = “1 Gbit, 2 Gbit, 4 Gbit”
tgtid_bind_type = “wwpn (World Wide Port Name)”
uevent =

Device = “host0?
Device path = “/sys/devices/pci0000:00/0000:00:07.0/0000:06:00.0/host0?
uevent =

Class Device = “host1?
Class Device path = “/sys/class/fc_host/host1?
active_fc4s = “0×00 0×00 0×01 0×00 0×00 0×00 0×00 0×01 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 “
fabric_name = “0x1000000533021c00?
issue_lip =
maxframe_size = “2048 bytes”
node_name = “0x20000000c99f46b5?
port_id = “0xc88ac5?
port_name = “0x10000000c99f46b5?
port_state = “Online”
port_type = “NPort (fabric via point-to-point)”
speed = “4 Gbit”
supported_classes = “Class 3?
supported_fc4s = “0×00 0×00 0×01 0×00 0×00 0×00 0×00 0×01 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 0×00 “
supported_speeds = “1 Gbit, 2 Gbit, 4 Gbit”
tgtid_bind_type = “wwpn (World Wide Port Name)”
uevent =

Device = “host1?
Device path = “/sys/devices/pci0000:00/0000:00:07.0/0000:06:00.1/host1?
uevent =

If the output below is looking so mess and you just need the wwpn, you can simplify the systool like this:
root@anneke:~ # systool -c fc_host -v | grep -i port_name
    port_name           = "0x10000000c99f46b4"
    port_name           = "0x10000000c99f46b5"
root@anneke:~ #

And also, here is another way that you can use, with a "better" output:

root@anneke:~ # echo "" && systool -c fc_host -v|egrep -i 'class device =|port_name'|sed 's/0x//'|sed 's/"//g'|sed 's/port_name/WWPN/'|sed 's/  Class Device = //'|sed 's/WWPN           =/WWPN =/' 

host0
    WWPN = 5001438000c38afc
host1
    WWPN = 5001438000c38aba


Hope it helps!

Special thanks to Emerson Takahashi!!!