net/cxgbe: update hardware info prints
authorRahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Sat, 27 May 2017 03:46:22 +0000 (09:16 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 12 Jun 2017 09:41:27 +0000 (10:41 +0100)
Update informational prints pertaining to underlying hardware.
Add bootstrap firmware version and expansion ROM version prints.
Move the prints to a single function.

Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Signed-off-by: Kumar Sanghvi <kumaras@chelsio.com>
drivers/net/cxgbe/base/common.h
drivers/net/cxgbe/base/t4_hw.c
drivers/net/cxgbe/base/t4_hw.h
drivers/net/cxgbe/cxgbe_main.c

index 5db4ca8..dd8da0a 100644 (file)
@@ -216,7 +216,9 @@ struct adapter_params {
        unsigned int sf_nsec;             /* # of flash sectors */
 
        unsigned int fw_vers;
+       unsigned int bs_vers;
        unsigned int tp_vers;
+       unsigned int er_vers;
 
        unsigned short mtus[NMTUS];
        unsigned short a_wnd[NCCTRL_WIN];
@@ -390,8 +392,8 @@ void t4_get_port_stats_offset(struct adapter *adap, int idx,
                              struct port_stats *offset);
 void t4_clr_port_stats(struct adapter *adap, int idx);
 void t4_reset_link_config(struct adapter *adap, int idx);
-int t4_get_fw_version(struct adapter *adapter, u32 *vers);
-int t4_get_tp_version(struct adapter *adapter, u32 *vers);
+int t4_get_version_info(struct adapter *adapter);
+void t4_dump_version_info(struct adapter *adapter);
 int t4_get_flash_params(struct adapter *adapter);
 int t4_get_chip_type(struct adapter *adap, int ver);
 int t4_prep_adapter(struct adapter *adapter);
index 053a2cd..787494b 100644 (file)
@@ -2496,6 +2496,43 @@ int t4_read_flash(struct adapter *adapter, unsigned int addr,
        return 0;
 }
 
+/**
+ * t4_get_exprom_version - return the Expansion ROM version (if any)
+ * @adapter: the adapter
+ * @vers: where to place the version
+ *
+ * Reads the Expansion ROM header from FLASH and returns the version
+ * number (if present) through the @vers return value pointer.  We return
+ * this in the Firmware Version Format since it's convenient.  Return
+ * 0 on success, -ENOENT if no Expansion ROM is present.
+ */
+static int t4_get_exprom_version(struct adapter *adapter, u32 *vers)
+{
+       struct exprom_header {
+               unsigned char hdr_arr[16];      /* must start with 0x55aa */
+               unsigned char hdr_ver[4];       /* Expansion ROM version */
+       } *hdr;
+       u32 exprom_header_buf[DIV_ROUND_UP(sizeof(struct exprom_header),
+                                          sizeof(u32))];
+       int ret;
+
+       ret = t4_read_flash(adapter, FLASH_EXP_ROM_START,
+                           ARRAY_SIZE(exprom_header_buf),
+                           exprom_header_buf, 0);
+       if (ret)
+               return ret;
+
+       hdr = (struct exprom_header *)exprom_header_buf;
+       if (hdr->hdr_arr[0] != 0x55 || hdr->hdr_arr[1] != 0xaa)
+               return -ENOENT;
+
+       *vers = (V_FW_HDR_FW_VER_MAJOR(hdr->hdr_ver[0]) |
+                V_FW_HDR_FW_VER_MINOR(hdr->hdr_ver[1]) |
+                V_FW_HDR_FW_VER_MICRO(hdr->hdr_ver[2]) |
+                V_FW_HDR_FW_VER_BUILD(hdr->hdr_ver[3]));
+       return 0;
+}
+
 /**
  * t4_get_fw_version - read the firmware version
  * @adapter: the adapter
@@ -2503,12 +2540,26 @@ int t4_read_flash(struct adapter *adapter, unsigned int addr,
  *
  * Reads the FW version from flash.
  */
-int t4_get_fw_version(struct adapter *adapter, u32 *vers)
+static int t4_get_fw_version(struct adapter *adapter, u32 *vers)
 {
        return t4_read_flash(adapter, FLASH_FW_START +
                             offsetof(struct fw_hdr, fw_ver), 1, vers, 0);
 }
 
+/**
+ *     t4_get_bs_version - read the firmware bootstrap version
+ *     @adapter: the adapter
+ *     @vers: where to place the version
+ *
+ *     Reads the FW Bootstrap version from flash.
+ */
+static int t4_get_bs_version(struct adapter *adapter, u32 *vers)
+{
+       return t4_read_flash(adapter, FLASH_FWBOOTSTRAP_START +
+                            offsetof(struct fw_hdr, fw_ver), 1,
+                            vers, 0);
+}
+
 /**
  * t4_get_tp_version - read the TP microcode version
  * @adapter: the adapter
@@ -2516,13 +2567,108 @@ int t4_get_fw_version(struct adapter *adapter, u32 *vers)
  *
  * Reads the TP microcode version from flash.
  */
-int t4_get_tp_version(struct adapter *adapter, u32 *vers)
+static int t4_get_tp_version(struct adapter *adapter, u32 *vers)
 {
        return t4_read_flash(adapter, FLASH_FW_START +
                             offsetof(struct fw_hdr, tp_microcode_ver),
                             1, vers, 0);
 }
 
+/**
+ * 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));
+
+#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, "Chelsio rev %d\n",
+                CHELSIO_CHIP_RELEASE(adapter->params.chip));
+
+       /**
+        * Firmware Version.
+        */
+       if (!adapter->params.fw_vers)
+               dev_warn(adapter, "No firmware loaded\n");
+       else
+               dev_info(adapter, "Firmware version: %u.%u.%u.%u\n",
+                        G_FW_HDR_FW_VER_MAJOR(adapter->params.fw_vers),
+                        G_FW_HDR_FW_VER_MINOR(adapter->params.fw_vers),
+                        G_FW_HDR_FW_VER_MICRO(adapter->params.fw_vers),
+                        G_FW_HDR_FW_VER_BUILD(adapter->params.fw_vers));
+
+       /**
+        * Bootstrap Firmware Version.
+        */
+       if (!adapter->params.bs_vers)
+               dev_warn(adapter, "No bootstrap loaded\n");
+       else
+               dev_info(adapter, "Bootstrap version: %u.%u.%u.%u\n",
+                        G_FW_HDR_FW_VER_MAJOR(adapter->params.bs_vers),
+                        G_FW_HDR_FW_VER_MINOR(adapter->params.bs_vers),
+                        G_FW_HDR_FW_VER_MICRO(adapter->params.bs_vers),
+                        G_FW_HDR_FW_VER_BUILD(adapter->params.bs_vers));
+
+       /**
+        * TP Microcode Version.
+        */
+       if (!adapter->params.tp_vers)
+               dev_warn(adapter, "No TP Microcode loaded\n");
+       else
+               dev_info(adapter, "TP Microcode version: %u.%u.%u.%u\n",
+                        G_FW_HDR_FW_VER_MAJOR(adapter->params.tp_vers),
+                        G_FW_HDR_FW_VER_MINOR(adapter->params.tp_vers),
+                        G_FW_HDR_FW_VER_MICRO(adapter->params.tp_vers),
+                        G_FW_HDR_FW_VER_BUILD(adapter->params.tp_vers));
+
+       /**
+        * Expansion ROM version.
+        */
+       if (!adapter->params.er_vers)
+               dev_info(adapter, "No Expansion ROM loaded\n");
+       else
+               dev_info(adapter, "Expansion ROM version: %u.%u.%u.%u\n",
+                        G_FW_HDR_FW_VER_MAJOR(adapter->params.er_vers),
+                        G_FW_HDR_FW_VER_MINOR(adapter->params.er_vers),
+                        G_FW_HDR_FW_VER_MICRO(adapter->params.er_vers),
+                        G_FW_HDR_FW_VER_BUILD(adapter->params.er_vers));
+}
+
 #define ADVERT_MASK (V_FW_PORT_CAP_SPEED(M_FW_PORT_CAP_SPEED) | \
                     FW_PORT_CAP_ANEG)
 
index 5e62c41..0749884 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2014-2016 Chelsio Communications.
+ *   Copyright(c) 2014-2017 Chelsio Communications.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -123,6 +123,14 @@ struct rsp_ctrl {
 #define FLASH_MAX_SIZE(nsecs)   ((nsecs) * SF_SEC_SIZE)
 
 enum {
+       /*
+        * Various Expansion-ROM boot images, etc.
+        */
+       FLASH_EXP_ROM_START_SEC = 0,
+       FLASH_EXP_ROM_NSECS = 6,
+       FLASH_EXP_ROM_START = FLASH_START(FLASH_EXP_ROM_START_SEC),
+       FLASH_EXP_ROM_MAX_SIZE = FLASH_MAX_SIZE(FLASH_EXP_ROM_NSECS),
+
        /*
         * Location of firmware image in FLASH.
         */
@@ -131,6 +139,14 @@ enum {
        FLASH_FW_START = FLASH_START(FLASH_FW_START_SEC),
        FLASH_FW_MAX_SIZE = FLASH_MAX_SIZE(FLASH_FW_NSECS),
 
+       /*
+        * Location of bootstrap firmware image in FLASH.
+        */
+       FLASH_FWBOOTSTRAP_START_SEC = 27,
+       FLASH_FWBOOTSTRAP_NSECS = 1,
+       FLASH_FWBOOTSTRAP_START = FLASH_START(FLASH_FWBOOTSTRAP_START_SEC),
+       FLASH_FWBOOTSTRAP_MAX_SIZE = FLASH_MAX_SIZE(FLASH_FWBOOTSTRAP_NSECS),
+
        /*
         * Location of Firmware Configuration File in FLASH.
         */
index 4691505..42238ef 100644 (file)
@@ -366,6 +366,17 @@ static int init_rss(struct adapter *adap)
        return 0;
 }
 
+/**
+ * Dump basic information about the adapter.
+ */
+static void print_adapter_info(struct adapter *adap)
+{
+       /**
+        * Hardware/Firmware/etc. Version/Revision IDs.
+        */
+       t4_dump_version_info(adap);
+}
+
 static void print_port_info(struct adapter *adap)
 {
        int i;
@@ -648,18 +659,7 @@ static int adap_init0(struct adapter *adap)
                state = (enum dev_state)((unsigned)state & ~DEV_STATE_INIT);
        }
 
-       t4_get_fw_version(adap, &adap->params.fw_vers);
-       t4_get_tp_version(adap, &adap->params.tp_vers);
-
-       dev_info(adap, "fw: %u.%u.%u.%u, TP: %u.%u.%u.%u\n",
-                G_FW_HDR_FW_VER_MAJOR(adap->params.fw_vers),
-                G_FW_HDR_FW_VER_MINOR(adap->params.fw_vers),
-                G_FW_HDR_FW_VER_MICRO(adap->params.fw_vers),
-                G_FW_HDR_FW_VER_BUILD(adap->params.fw_vers),
-                G_FW_HDR_FW_VER_MAJOR(adap->params.tp_vers),
-                G_FW_HDR_FW_VER_MINOR(adap->params.tp_vers),
-                G_FW_HDR_FW_VER_MICRO(adap->params.tp_vers),
-                G_FW_HDR_FW_VER_BUILD(adap->params.tp_vers));
+       t4_get_version_info(adap);
 
        ret = t4_get_core_clock(adap, &adap->params.vpd);
        if (ret < 0) {
@@ -1206,6 +1206,7 @@ allocate_mac:
 
        cfg_queues(adapter->eth_dev);
 
+       print_adapter_info(adapter);
        print_port_info(adapter);
 
        err = init_rss(adapter);