cxgb4: display serial config and vpd versions
authorGanesh Goudar <ganeshgr@chelsio.com>
Thu, 20 Jul 2017 12:58:48 +0000 (18:28 +0530)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Jul 2017 22:29:29 +0000 (15:29 -0700)
print the versions of vpd and serial configuration file,
flashed to adapter, and cleanup the relevant code.

Signed-off-by: Casey Leedom <leedom@chelsio.com>
Signed-off-by: Ganesh Goudar <ganeshgr@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h

index ef4be781fd054696edac7c494cf713f0dd5f3d4e..1978abbc6ceb157dfb5b6887058772266f56c302 100644 (file)
@@ -338,10 +338,12 @@ struct adapter_params {
        unsigned int sf_nsec;             /* # of flash sectors */
        unsigned int sf_fw_start;         /* start of FW image in flash */
 
-       unsigned int fw_vers;
-       unsigned int bs_vers;           /* bootstrap version */
-       unsigned int tp_vers;
-       unsigned int er_vers;           /* expansion ROM version */
+       unsigned int fw_vers;             /* firmware version */
+       unsigned int bs_vers;             /* bootstrap version */
+       unsigned int tp_vers;             /* TP microcode version */
+       unsigned int er_vers;             /* expansion ROM version */
+       unsigned int scfg_vers;           /* Serial Configuration version */
+       unsigned int vpd_vers;            /* VPD Version */
        u8 api_vers[7];
 
        unsigned short mtus[NMTUS];
@@ -1407,6 +1409,10 @@ int t4_get_fw_version(struct adapter *adapter, u32 *vers);
 int t4_get_bs_version(struct adapter *adapter, u32 *vers);
 int t4_get_tp_version(struct adapter *adapter, u32 *vers);
 int t4_get_exprom_version(struct adapter *adapter, u32 *vers);
+int t4_get_scfg_version(struct adapter *adapter, u32 *vers);
+int t4_get_vpd_version(struct adapter *adapter, u32 *vers);
+int t4_get_version_info(struct adapter *adapter);
+void t4_dump_version_info(struct adapter *adapter);
 int t4_prep_fw(struct adapter *adap, struct fw_info *fw_info,
               const u8 *fw_data, unsigned int fw_size,
               struct fw_hdr *card_fw, enum dev_state state, int *reset);
index e403fa18f1b15e570748b2136ae1bf8b54d14afb..fdf220aa08d6013f28a34494dcd373e0547fa3f3 100644 (file)
@@ -3610,11 +3610,8 @@ static int adap_init0(struct adapter *adap)
         * later reporting and B. to warn if the currently loaded firmware
         * is excessively mismatched relative to the driver.)
         */
-       t4_get_fw_version(adap, &adap->params.fw_vers);
-       t4_get_bs_version(adap, &adap->params.bs_vers);
-       t4_get_tp_version(adap, &adap->params.tp_vers);
-       t4_get_exprom_version(adap, &adap->params.er_vers);
 
+       t4_get_version_info(adap);
        ret = t4_check_fw_version(adap);
        /* If firmware is too old (not supported by driver) force an update. */
        if (ret)
@@ -4560,56 +4557,8 @@ static void cxgb4_check_pcie_caps(struct adapter *adap)
 /* Dump basic information about the adapter */
 static void print_adapter_info(struct adapter *adapter)
 {
-       /* Device information */
-       dev_info(adapter->pdev_dev, "Chelsio %s rev %d\n",
-                adapter->params.vpd.id,
-                CHELSIO_CHIP_RELEASE(adapter->params.chip));
-       dev_info(adapter->pdev_dev, "S/N: %s, P/N: %s\n",
-                adapter->params.vpd.sn, adapter->params.vpd.pn);
-
-       /* Firmware Version */
-       if (!adapter->params.fw_vers)
-               dev_warn(adapter->pdev_dev, "No firmware loaded\n");
-       else
-               dev_info(adapter->pdev_dev, "Firmware version: %u.%u.%u.%u\n",
-                        FW_HDR_FW_VER_MAJOR_G(adapter->params.fw_vers),
-                        FW_HDR_FW_VER_MINOR_G(adapter->params.fw_vers),
-                        FW_HDR_FW_VER_MICRO_G(adapter->params.fw_vers),
-                        FW_HDR_FW_VER_BUILD_G(adapter->params.fw_vers));
-
-       /* Bootstrap Firmware Version. (Some adapters don't have Bootstrap
-        * Firmware, so dev_info() is more appropriate here.)
-        */
-       if (!adapter->params.bs_vers)
-               dev_info(adapter->pdev_dev, "No bootstrap loaded\n");
-       else
-               dev_info(adapter->pdev_dev, "Bootstrap version: %u.%u.%u.%u\n",
-                        FW_HDR_FW_VER_MAJOR_G(adapter->params.bs_vers),
-                        FW_HDR_FW_VER_MINOR_G(adapter->params.bs_vers),
-                        FW_HDR_FW_VER_MICRO_G(adapter->params.bs_vers),
-                        FW_HDR_FW_VER_BUILD_G(adapter->params.bs_vers));
-
-       /* TP Microcode Version */
-       if (!adapter->params.tp_vers)
-               dev_warn(adapter->pdev_dev, "No TP Microcode loaded\n");
-       else
-               dev_info(adapter->pdev_dev,
-                        "TP Microcode version: %u.%u.%u.%u\n",
-                        FW_HDR_FW_VER_MAJOR_G(adapter->params.tp_vers),
-                        FW_HDR_FW_VER_MINOR_G(adapter->params.tp_vers),
-                        FW_HDR_FW_VER_MICRO_G(adapter->params.tp_vers),
-                        FW_HDR_FW_VER_BUILD_G(adapter->params.tp_vers));
-
-       /* Expansion ROM version */
-       if (!adapter->params.er_vers)
-               dev_info(adapter->pdev_dev, "No Expansion ROM loaded\n");
-       else
-               dev_info(adapter->pdev_dev,
-                        "Expansion ROM version: %u.%u.%u.%u\n",
-                        FW_HDR_FW_VER_MAJOR_G(adapter->params.er_vers),
-                        FW_HDR_FW_VER_MINOR_G(adapter->params.er_vers),
-                        FW_HDR_FW_VER_MICRO_G(adapter->params.er_vers),
-                        FW_HDR_FW_VER_BUILD_G(adapter->params.er_vers));
+       /* Hardware/Firmware/etc. Version/Revision IDs */
+       t4_dump_version_info(adapter);
 
        /* Software/Hardware configuration */
        dev_info(adapter->pdev_dev, "Configuration: %sNIC %s, %s capable\n",
index 570c0958a0e1d208a0e4373ba4684a953371a50d..db41b3e99b8170dce02224c167dff605aed3db42 100644 (file)
@@ -3076,6 +3076,179 @@ int t4_get_exprom_version(struct adapter *adap, u32 *vers)
        return 0;
 }
 
+/**
+ *      t4_get_vpd_version - return the VPD version
+ *      @adapter: the adapter
+ *      @vers: where to place the version
+ *
+ *      Reads the VPD via the Firmware interface (thus this can only be called
+ *      once we're ready to issue Firmware commands).  The format of the
+ *      VPD version is adapter specific.  Returns 0 on success, an error on
+ *      failure.
+ *
+ *      Note that early versions of the Firmware didn't include the ability
+ *      to retrieve the VPD version, so we zero-out the return-value parameter
+ *      in that case to avoid leaving it with garbage in it.
+ *
+ *      Also note that the Firmware will return its cached copy of the VPD
+ *      Revision ID, not the actual Revision ID as written in the Serial
+ *      EEPROM.  This is only an issue if a new VPD has been written and the
+ *      Firmware/Chip haven't yet gone through a RESET sequence.  So it's best
+ *      to defer calling this routine till after a FW_RESET_CMD has been issued
+ *      if the Host Driver will be performing a full adapter initialization.
+ */
+int t4_get_vpd_version(struct adapter *adapter, u32 *vers)
+{
+       u32 vpdrev_param;
+       int ret;
+
+       vpdrev_param = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
+                       FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_VPDREV));
+       ret = t4_query_params(adapter, adapter->mbox, adapter->pf, 0,
+                             1, &vpdrev_param, vers);
+       if (ret)
+               *vers = 0;
+       return ret;
+}
+
+/**
+ *      t4_get_scfg_version - return the Serial Configuration version
+ *      @adapter: the adapter
+ *      @vers: where to place the version
+ *
+ *      Reads the Serial Configuration Version via the Firmware interface
+ *      (thus this can only be called once we're ready to issue Firmware
+ *      commands).  The format of the Serial Configuration version is
+ *      adapter specific.  Returns 0 on success, an error on failure.
+ *
+ *      Note that early versions of the Firmware didn't include the ability
+ *      to retrieve the Serial Configuration version, so we zero-out the
+ *      return-value parameter in that case to avoid leaving it with
+ *      garbage in it.
+ *
+ *      Also note that the Firmware will return its cached copy of the Serial
+ *      Initialization Revision ID, not the actual Revision ID as written in
+ *      the Serial EEPROM.  This is only an issue if a new VPD has been written
+ *      and the Firmware/Chip haven't yet gone through a RESET sequence.  So
+ *      it's best to defer calling this routine till after a FW_RESET_CMD has
+ *      been issued if the Host Driver will be performing a full adapter
+ *      initialization.
+ */
+int t4_get_scfg_version(struct adapter *adapter, u32 *vers)
+{
+       u32 scfgrev_param;
+       int ret;
+
+       scfgrev_param = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_DEV) |
+                        FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_DEV_SCFGREV));
+       ret = t4_query_params(adapter, adapter->mbox, adapter->pf, 0,
+                             1, &scfgrev_param, vers);
+       if (ret)
+               *vers = 0;
+       return ret;
+}
+
+/**
+ *      t4_get_version_info - extract various chip/firmware version information
+ *      @adapter: the adapter
+ *
+ *      Reads various chip/firmware version numbers and stores them into the
+ *      adapter Adapter Parameters structure.  If any of the efforts fails
+ *      the first failure will be returned, but all of the version numbers
+ *      will be read.
+ */
+int t4_get_version_info(struct adapter *adapter)
+{
+       int ret = 0;
+
+       #define FIRST_RET(__getvinfo) \
+       do { \
+               int __ret = __getvinfo; \
+               if (__ret && !ret) \
+                       ret = __ret; \
+       } while (0)
+
+       FIRST_RET(t4_get_fw_version(adapter, &adapter->params.fw_vers));
+       FIRST_RET(t4_get_bs_version(adapter, &adapter->params.bs_vers));
+       FIRST_RET(t4_get_tp_version(adapter, &adapter->params.tp_vers));
+       FIRST_RET(t4_get_exprom_version(adapter, &adapter->params.er_vers));
+       FIRST_RET(t4_get_scfg_version(adapter, &adapter->params.scfg_vers));
+       FIRST_RET(t4_get_vpd_version(adapter, &adapter->params.vpd_vers));
+
+       #undef FIRST_RET
+       return ret;
+}
+
+/**
+ *      t4_dump_version_info - dump all of the adapter configuration IDs
+ *      @adapter: the adapter
+ *
+ *      Dumps all of the various bits of adapter configuration version/revision
+ *      IDs information.  This is typically called at some point after
+ *      t4_get_version_info() has been called.
+ */
+void t4_dump_version_info(struct adapter *adapter)
+{
+       /* Device information */
+       dev_info(adapter->pdev_dev, "Chelsio %s rev %d\n",
+                adapter->params.vpd.id,
+                CHELSIO_CHIP_RELEASE(adapter->params.chip));
+       dev_info(adapter->pdev_dev, "S/N: %s, P/N: %s\n",
+                adapter->params.vpd.sn, adapter->params.vpd.pn);
+
+       /* Firmware Version */
+       if (!adapter->params.fw_vers)
+               dev_warn(adapter->pdev_dev, "No firmware loaded\n");
+       else
+               dev_info(adapter->pdev_dev, "Firmware version: %u.%u.%u.%u\n",
+                        FW_HDR_FW_VER_MAJOR_G(adapter->params.fw_vers),
+                        FW_HDR_FW_VER_MINOR_G(adapter->params.fw_vers),
+                        FW_HDR_FW_VER_MICRO_G(adapter->params.fw_vers),
+                        FW_HDR_FW_VER_BUILD_G(adapter->params.fw_vers));
+
+       /* Bootstrap Firmware Version. (Some adapters don't have Bootstrap
+        * Firmware, so dev_info() is more appropriate here.)
+        */
+       if (!adapter->params.bs_vers)
+               dev_info(adapter->pdev_dev, "No bootstrap loaded\n");
+       else
+               dev_info(adapter->pdev_dev, "Bootstrap version: %u.%u.%u.%u\n",
+                        FW_HDR_FW_VER_MAJOR_G(adapter->params.bs_vers),
+                        FW_HDR_FW_VER_MINOR_G(adapter->params.bs_vers),
+                        FW_HDR_FW_VER_MICRO_G(adapter->params.bs_vers),
+                        FW_HDR_FW_VER_BUILD_G(adapter->params.bs_vers));
+
+       /* TP Microcode Version */
+       if (!adapter->params.tp_vers)
+               dev_warn(adapter->pdev_dev, "No TP Microcode loaded\n");
+       else
+               dev_info(adapter->pdev_dev,
+                        "TP Microcode version: %u.%u.%u.%u\n",
+                        FW_HDR_FW_VER_MAJOR_G(adapter->params.tp_vers),
+                        FW_HDR_FW_VER_MINOR_G(adapter->params.tp_vers),
+                        FW_HDR_FW_VER_MICRO_G(adapter->params.tp_vers),
+                        FW_HDR_FW_VER_BUILD_G(adapter->params.tp_vers));
+
+       /* Expansion ROM version */
+       if (!adapter->params.er_vers)
+               dev_info(adapter->pdev_dev, "No Expansion ROM loaded\n");
+       else
+               dev_info(adapter->pdev_dev,
+                        "Expansion ROM version: %u.%u.%u.%u\n",
+                        FW_HDR_FW_VER_MAJOR_G(adapter->params.er_vers),
+                        FW_HDR_FW_VER_MINOR_G(adapter->params.er_vers),
+                        FW_HDR_FW_VER_MICRO_G(adapter->params.er_vers),
+                        FW_HDR_FW_VER_BUILD_G(adapter->params.er_vers));
+
+       /* Serial Configuration version */
+       dev_info(adapter->pdev_dev, "Serial Configuration version: %#x\n",
+                adapter->params.scfg_vers);
+
+       /* VPD Version */
+       dev_info(adapter->pdev_dev, "VPD version: %#x\n",
+                adapter->params.vpd_vers);
+}
+
 /**
  *     t4_check_fw_version - check if the FW is supported with this driver
  *     @adap: the adapter
index 0ebed64d62d3952d5e60ab5534f7274812d2624a..ad825fbc21a5b7efd30470244a93082a3e6df844 100644 (file)
@@ -1124,6 +1124,8 @@ enum fw_params_param_dev {
        FW_PARAMS_PARAM_DEV_MAXIRD_ADAPTER = 0x14, /* max supported adap IRD */
        FW_PARAMS_PARAM_DEV_ULPTX_MEMWRITE_DSGL = 0x17,
        FW_PARAMS_PARAM_DEV_FWCACHE = 0x18,
+       FW_PARAMS_PARAM_DEV_SCFGREV = 0x1A,
+       FW_PARAMS_PARAM_DEV_VPDREV = 0x1B,
        FW_PARAMS_PARAM_DEV_RI_FR_NSMR_TPTE_WR  = 0x1C,
        FW_PARAMS_PARAM_DEV_MPSBGMAP    = 0x1E,
 };