The "Adapter", "Port" and "Target" enumerations are based on the
order that the devices are added to the OS. This means that if
interfaces are created or destroyed the enumerations can
change if fcoeadm is re-run.

libHBAAPI/libhbalinux enumerates the HBA/Port pairings by their
fc_host ID. fcoeadm_display.c starts with lowest numbered
HBA/Port and diplays it. It then goes through all other HBA/Ports
to see if there are other ports on the same card (matching on
serial number).

This scenario shows how the problem can occur.

Card Serial Number xx.00
        eth2
        eth3

Card Serial Number xx.01
        eth4
        eth5

fcoeadm -c eth5 (fc_host 0)
fcoeadm -c eth3 (fc_host 1)
fcoeadm -c eth2 (fc_host 2)
fcoeadm -c eth4 (fc_host 3)

fcoeadm -i

Adapter 0
-displays SN xx.01 header
        Port 0
        -displays eth5
        Port 1
        -displays eth4
Adapter 1
-displays SN xx.00 header
        Port 0
        -displays eth3
        Port 1
        -displays eth2

fcoeadm -d eth5
fcoeadm -c eth5 (fc_host 4)

fcoeadm -i

Adapter 0
-displays SN xx.00 header
        Port 0
        -displays eth3
        Port 1
        -displays eth2
Adapter 1
-displays SN xx.01 header
        Port 0
        -displays eth4
        Port 1
        -displays eth5

It's not necessarily a problem that devices are reordered,
but the "Adapter" and "Port" enumerations are misleading.

The fcoeadm format still groups the correct ports under the
correct Serial Number so that each port on a physical device
displays correctly. We just don't need the arbitrary "Adapter"
and "Port" strings.

The target enumeration is also no longer displayed as it was another
enumeration that fcoeadm was making up and wouldn't necessarily
be consistent.

This does not apply to '-l' as the LUN ID is returned from the
target.

Signed-off-by: Robert Love <[email protected]>
---

 fcoeadm_display.c |   24 +++++++-----------------
 1 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/fcoeadm_display.c b/fcoeadm_display.c
index f6ce3f8..4a8eb80 100644
--- a/fcoeadm_display.c
+++ b/fcoeadm_display.c
@@ -249,10 +249,8 @@ static void show_wwn(unsigned char *pWwn)
        sa_dump_wwn(pWwn, 8, 0);
 }
 
-static void
-show_hba_info(int hba_index, HBA_ADAPTERATTRIBUTES *hba_info, int flags)
+static void show_hba_info(HBA_ADAPTERATTRIBUTES *hba_info, int flags)
 {
-       printf("Adapter #%d\n", hba_index);
        printf("    Description:      %s\n", hba_info->ModelDescription);
        printf("    Revision:         %s\n", hba_info->HardwareVersion);
        printf("    Manufacturer:     %s\n", hba_info->Manufacturer);
@@ -263,16 +261,12 @@ show_hba_info(int hba_index, HBA_ADAPTERATTRIBUTES 
*hba_info, int flags)
        printf("\n");
 }
 
-static void
-show_port_info(int hba_index, int lp_index,
-               HBA_ADAPTERATTRIBUTES *hba_info,
-               HBA_PORTATTRIBUTES *lp_info)
+static void show_port_info(HBA_ADAPTERATTRIBUTES *hba_info,
+                          HBA_PORTATTRIBUTES *lp_info)
 {
        char buf[256];
        int len = sizeof(buf);
 
-       printf("    Port #%d\n", lp_index);
-
        printf("        Symbolic Name:     %s\n",
                                        lp_info->PortSymbolicName);
 
@@ -309,8 +303,7 @@ show_port_info(int hba_index, int lp_index,
        /* TODO: Display PortSupportedFc4Types and PortActiveFc4Types */
 }
 
-static void show_target_info(const char *symbolic_name, int hba_index,
-                            int lp_index, int rp_index,
+static void show_target_info(const char *symbolic_name,
                             HBA_ADAPTERATTRIBUTES *hba_info,
                             HBA_PORTATTRIBUTES *rp_info)
 {
@@ -321,9 +314,8 @@ static void show_target_info(const char *symbolic_name, int 
hba_index,
 
        ifname = get_ifname_from_symbolic_name(symbolic_name);
 
-       printf("Target #%d @ %s\n", rp_index, ifname);
-
        rc = sa_sys_read_line(rp_info->OSDeviceName, "roles", buf, sizeof(buf));
+       printf("    Interface:        %s\n", ifname);
        printf("    Roles:            %s\n", buf);
 
        printf("    Node Name:        0x");
@@ -1278,7 +1270,7 @@ enum fcoe_err display_adapter_info(const char *ifname)
                /*
                 * Display the adapter header.
                 */
-               show_hba_info(i, &hba_table[i].hba_attrs, 0);
+               show_hba_info(&hba_table[i].hba_attrs, 0);
 
                /*
                 * Loop through HBAs again to print sub-ports.
@@ -1298,8 +1290,7 @@ enum fcoe_err display_adapter_info(const char *ifname)
                        if (!strncmp(hba_table[i].hba_attrs.SerialNumber,
                                     hba_table[j].hba_attrs.SerialNumber,
                                     
strlen(hba_table[i].hba_attrs.SerialNumber))) {
-                               show_port_info(i, j,
-                                              &hba_table[j].hba_attrs,
+                               show_port_info(&hba_table[j].hba_attrs,
                                               &hba_table[j].port_attrs);
                                hba_table[j].displayed = 1;
                        }
@@ -1374,7 +1365,6 @@ enum fcoe_err display_target_info(const char *ifname,
 
                        show_target_info(
                                hba_table[i].port_attrs.PortSymbolicName,
-                               i, 0, target_index,
                                &hba_table[i].hba_attrs,
                                &rport_attrs);
 

_______________________________________________
devel mailing list
[email protected]
http://www.open-fcoe.org/mailman/listinfo/devel

Reply via email to