Add new routine to print out general adapter information (various version
numbers, adapter name, part number, serial number, etc.) and remove
redundant information dumped in the Port Information.

Signed-off-by: Hariprasad Shenai <haripra...@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h      |  4 ++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 78 ++++++++++++++++++++++---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c      | 14 +++++
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.h      |  7 +++
 4 files changed, 95 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 326d4009525e..459775884cad 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -324,7 +324,9 @@ struct adapter_params {
        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 */
        u8 api_vers[7];
 
        unsigned short mtus[NMTUS];
@@ -731,6 +733,7 @@ struct adapter {
        u32 t4_bar0;
        struct pci_dev *pdev;
        struct device *pdev_dev;
+       const char *name;
        unsigned int mbox;
        unsigned int pf;
        unsigned int flags;
@@ -1306,6 +1309,7 @@ int t4_fl_pkt_align(struct adapter *adap);
 unsigned int t4_flash_cfg_addr(struct adapter *adapter);
 int t4_check_fw_version(struct adapter *adap);
 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_prep_fw(struct adapter *adap, struct fw_info *fw_info,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index a1e329ec24cd..b8dc7921b258 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3738,7 +3738,10 @@ static int adap_init0(struct adapter *adap)
         * 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);
+
        ret = t4_check_fw_version(adap);
        /* If firmware is too old (not supported by driver) force an update. */
        if (ret)
@@ -4652,6 +4655,68 @@ static void cxgb4_check_pcie_caps(struct adapter *adap)
                         "suggested for optimal performance.\n");
 }
 
+/* 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));
+
+       /* Software/Hardware configuration */
+       dev_info(adapter->pdev_dev, "Configuration: %sNIC %s, %s capable\n",
+                is_offload(adapter) ? "R" : "",
+                ((adapter->flags & USING_MSIX) ? "MSI-X" :
+                 (adapter->flags & USING_MSI) ? "MSI" : ""),
+                is_offload(adapter) ? "Offload" : "non-Offload");
+}
+
 static void print_port_info(const struct net_device *dev)
 {
        char buf[80];
@@ -4679,14 +4744,8 @@ static void print_port_info(const struct net_device *dev)
                --bufp;
        sprintf(bufp, "BASE-%s", t4_get_port_type_description(pi->port_type));
 
-       netdev_info(dev, "Chelsio %s rev %d %s %sNIC %s\n",
-                   adap->params.vpd.id,
-                   CHELSIO_CHIP_RELEASE(adap->params.chip), buf,
-                   is_offload(adap) ? "R" : "",
-                   (adap->flags & USING_MSIX) ? " MSI-X" :
-                   (adap->flags & USING_MSI) ? " MSI" : "");
-       netdev_info(dev, "S/N: %s, P/N: %s\n",
-                   adap->params.vpd.sn, adap->params.vpd.pn);
+       netdev_info(dev, "%s: Chelsio %s (%s) %s\n",
+                   dev->name, adap->params.vpd.id, adap->name, buf);
 }
 
 static void enable_pcie_relaxed_ordering(struct pci_dev *dev)
@@ -4844,6 +4903,7 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
        adapter->regs = regs;
        adapter->pdev = pdev;
        adapter->pdev_dev = &pdev->dev;
+       adapter->name = pci_name(pdev);
        adapter->mbox = func;
        adapter->pf = func;
        adapter->msg_enable = dflt_msg_enable;
@@ -5074,6 +5134,8 @@ static int init_one(struct pci_dev *pdev, const struct 
pci_device_id *ent)
        if (is_offload(adapter))
                attach_ulds(adapter);
 
+       print_adapter_info(adapter);
+
 sriov:
 #ifdef CONFIG_PCI_IOV
        if (func < ARRAY_SIZE(num_vf) && num_vf[func] > 0)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 71586a3e0f61..2ced24fc569d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -2937,6 +2937,20 @@ int t4_get_fw_version(struct adapter *adapter, u32 *vers)
 }
 
 /**
+ *     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.
+ */
+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
  *     @vers: where to place the version
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.h
index 2fc60e83a7a1..7f59ca458431 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.h
@@ -220,6 +220,13 @@ 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),
+
        /*
         * iSCSI persistent/crash information.
         */
-- 
2.3.4

Reply via email to