[PATCH] IB/ipath: support more models of InfiniPath hardware
authorBryan O'Sullivan <bos@pathscale.com>
Sat, 1 Jul 2006 11:36:13 +0000 (04:36 -0700)
committerLinus Torvalds <torvalds@g5.osdl.org>
Sat, 1 Jul 2006 16:56:01 +0000 (09:56 -0700)
We do a few more explicit checks for specific models, and now also support the
old PathScale serial number style, or new QLogic style.

This is backwards compatible with previous versions of software and hardware.
That is, older software will see a plausible serial number and correct GUID
when used with a new board, while newer software will correctly handle an
older board.

Signed-off-by: Mike Albaugh <mike.albaugh@qlogic.com>
Signed-off-by: Dave Olson <dave.olson@qlogic.com>
Signed-off-by: Bryan O'Sullivan <bryan.osullivan@qlogic.com>
Cc: "Michael S. Tsirkin" <mst@mellanox.co.il>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/infiniband/hw/ipath/ipath_common.h
drivers/infiniband/hw/ipath/ipath_eeprom.c
drivers/infiniband/hw/ipath/ipath_kernel.h
drivers/infiniband/hw/ipath/ipath_pe800.c

index 106f8f49cbb19c203039c80781f49cbbd8b8734a..3130a7ed254b757b690fa7fba812e275ada420a7 100644 (file)
@@ -476,7 +476,7 @@ struct ipath_sma_pkt
  * Data layout in I2C flash (for GUID, etc.)
  * All fields are little-endian binary unless otherwise stated
  */
-#define IPATH_FLASH_VERSION 1
+#define IPATH_FLASH_VERSION 2
 struct ipath_flash {
        /* flash layout version (IPATH_FLASH_VERSION) */
        __u8 if_fversion;
@@ -484,14 +484,14 @@ struct ipath_flash {
        __u8 if_csum;
        /*
         * valid length (in use, protected by if_csum), including
-        * if_fversion and if_sum themselves)
+        * if_fversion and if_csum themselves)
         */
        __u8 if_length;
        /* the GUID, in network order */
        __u8 if_guid[8];
        /* number of GUIDs to use, starting from if_guid */
        __u8 if_numguid;
-       /* the board serial number, in ASCII */
+       /* the (last 10 characters of) board serial number, in ASCII */
        char if_serial[12];
        /* board mfg date (YYYYMMDD ASCII) */
        char if_mfgdate[8];
@@ -503,8 +503,10 @@ struct ipath_flash {
        __u8 if_powerhour[2];
        /* ASCII free-form comment field */
        char if_comment[32];
-       /* 78 bytes used, min flash size is 128 bytes */
-       __u8 if_future[50];
+       /* Backwards compatible prefix for longer QLogic Serial Numbers */
+       char if_sprefix[4];
+       /* 82 bytes used, min flash size is 128 bytes */
+       __u8 if_future[46];
 };
 
 /*
index f086e33604598b34318698095f1892b26ab0232c..3313356ab93aa13d1c6b3fe4bb60d543f21402fc 100644 (file)
@@ -601,8 +601,31 @@ void ipath_get_eeprom_info(struct ipath_devdata *dd)
                guid = *(__be64 *) ifp->if_guid;
        dd->ipath_guid = guid;
        dd->ipath_nguid = ifp->if_numguid;
-       memcpy(dd->ipath_serial, ifp->if_serial,
-              sizeof(ifp->if_serial));
+       /*
+        * Things are slightly complicated by the desire to transparently
+        * support both the Pathscale 10-digit serial number and the QLogic
+        * 13-character version.
+        */
+       if ((ifp->if_fversion > 1) && ifp->if_sprefix[0]
+               && ((u8 *)ifp->if_sprefix)[0] != 0xFF) {
+               /* This board has a Serial-prefix, which is stored
+                * elsewhere for backward-compatibility.
+                */
+               char *snp = dd->ipath_serial;
+               int len;
+               memcpy(snp, ifp->if_sprefix, sizeof ifp->if_sprefix);
+               snp[sizeof ifp->if_sprefix] = '\0';
+               len = strlen(snp);
+               snp += len;
+               len = (sizeof dd->ipath_serial) - len;
+               if (len > sizeof ifp->if_serial) {
+                       len = sizeof ifp->if_serial;
+               }
+               memcpy(snp, ifp->if_serial, len);
+       } else
+               memcpy(dd->ipath_serial, ifp->if_serial,
+                      sizeof ifp->if_serial);
+
        ipath_cdbg(VERBOSE, "Initted GUID to %llx from eeprom\n",
                   (unsigned long long) be64_to_cpu(dd->ipath_guid));
 
index fe3c862e23b52e943e49d39c1d57a0f007ed7e1b..00a6bbdbe95715605b0e1da0f7bf4d6945f1df83 100644 (file)
@@ -491,8 +491,11 @@ struct ipath_devdata {
        u16 ipath_lid;
        /* list of pkeys programmed; 0 if not set */
        u16 ipath_pkeys[4];
-       /* ASCII serial number, from flash */
-       u8 ipath_serial[12];
+       /*
+        * ASCII serial number, from flash, large enough for original
+        * all digit strings, and longer QLogic serial number format
+        */
+       u8 ipath_serial[16];
        /* human readable board version */
        u8 ipath_boardversion[80];
        /* chip major rev, from ipath_revision */
index 98fd5d37dfff4554a13a912c503e57becdd4e10c..b83f66d8262cfb0830ea61e424ec68822123ce89 100644 (file)
@@ -533,7 +533,7 @@ static int ipath_pe_boardname(struct ipath_devdata *dd, char *name,
        if (n)
                snprintf(name, namelen, "%s", n);
 
-       if (dd->ipath_majrev != 4 || dd->ipath_minrev != 1) {
+       if (dd->ipath_majrev != 4 || !dd->ipath_minrev || dd->ipath_minrev>2) {
                ipath_dev_err(dd, "Unsupported PE-800 revision %u.%u!\n",
                              dd->ipath_majrev, dd->ipath_minrev);
                ret = 1;