bnxt_en: Get firmware package version one time.
authorMichael Chan <michael.chan@broadcom.com>
Thu, 26 Oct 2017 15:51:23 +0000 (11:51 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 27 Oct 2017 15:02:44 +0000 (00:02 +0900)
The current code retrieves the firmware package version from firmware
everytime ethtool -i is run.  There is no reason to do that as the
firmware will not change while the driver is loaded.  Get the version
once at init time.

Also, display the full 4-part firmware version string and remove the
less useful interface spec version.

Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

index d2403f47e102ff5161be315e59b704684c769c4f..ffc6c494f6eaf5b568e7484e7add6aa4ac6310aa 100644 (file)
@@ -4892,9 +4892,9 @@ static int bnxt_hwrm_ver_get(struct bnxt *bp)
                            resp->hwrm_intf_upd);
                netdev_warn(bp->dev, "Please update firmware with HWRM interface 1.0.0 or newer.\n");
        }
-       snprintf(bp->fw_ver_str, BC_HWRM_STR_LEN, "%d.%d.%d/%d.%d.%d",
+       snprintf(bp->fw_ver_str, BC_HWRM_STR_LEN, "%d.%d.%d.%d",
                 resp->hwrm_fw_maj, resp->hwrm_fw_min, resp->hwrm_fw_bld,
-                resp->hwrm_intf_maj, resp->hwrm_intf_min, resp->hwrm_intf_upd);
+                resp->hwrm_fw_rsvd);
 
        bp->hwrm_cmd_timeout = le16_to_cpu(resp->def_req_timeout);
        if (!bp->hwrm_cmd_timeout)
index 85be1cb41f1a854e3ecb38e57d29d5729389d73d..fe93625e0539e0226323b6d15ac1b91b38d0a498 100644 (file)
@@ -26,8 +26,6 @@
 #define FLASH_PACKAGE_TIMEOUT  ((HWRM_CMD_TIMEOUT) * 200)
 #define INSTALL_PACKAGE_TIMEOUT        ((HWRM_CMD_TIMEOUT) * 200)
 
-static char *bnxt_get_pkgver(struct net_device *dev, char *buf, size_t buflen);
-
 static u32 bnxt_get_msglevel(struct net_device *dev)
 {
        struct bnxt *bp = netdev_priv(dev);
@@ -822,20 +820,10 @@ static void bnxt_get_drvinfo(struct net_device *dev,
                             struct ethtool_drvinfo *info)
 {
        struct bnxt *bp = netdev_priv(dev);
-       char *pkglog;
-       char *pkgver = NULL;
 
-       pkglog = kmalloc(BNX_PKG_LOG_MAX_LENGTH, GFP_KERNEL);
-       if (pkglog)
-               pkgver = bnxt_get_pkgver(dev, pkglog, BNX_PKG_LOG_MAX_LENGTH);
        strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver));
        strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version));
-       if (pkgver && *pkgver != 0 && isdigit(*pkgver))
-               snprintf(info->fw_version, sizeof(info->fw_version) - 1,
-                        "%s pkg %s", bp->fw_ver_str, pkgver);
-       else
-               strlcpy(info->fw_version, bp->fw_ver_str,
-                       sizeof(info->fw_version));
+       strlcpy(info->fw_version, bp->fw_ver_str, sizeof(info->fw_version));
        strlcpy(info->bus_info, pci_name(bp->pdev), sizeof(info->bus_info));
        info->n_stats = bnxt_get_num_stats(bp);
        info->testinfo_len = bp->num_tests;
@@ -843,7 +831,6 @@ static void bnxt_get_drvinfo(struct net_device *dev,
        info->eedump_len = 0;
        /* TODO CHIMP FW: reg dump details */
        info->regdump_len = 0;
-       kfree(pkglog);
 }
 
 static void bnxt_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
@@ -2503,8 +2490,23 @@ void bnxt_ethtool_init(struct bnxt *bp)
        struct hwrm_selftest_qlist_output *resp = bp->hwrm_cmd_resp_addr;
        struct hwrm_selftest_qlist_input req = {0};
        struct bnxt_test_info *test_info;
+       struct net_device *dev = bp->dev;
+       char *pkglog;
        int i, rc;
 
+       pkglog = kzalloc(BNX_PKG_LOG_MAX_LENGTH, GFP_KERNEL);
+       if (pkglog) {
+               char *pkgver;
+               int len;
+
+               pkgver = bnxt_get_pkgver(dev, pkglog, BNX_PKG_LOG_MAX_LENGTH);
+               if (pkgver && *pkgver != 0 && isdigit(*pkgver)) {
+                       len = strlen(bp->fw_ver_str);
+                       snprintf(bp->fw_ver_str + len, FW_VER_STR_LEN - len - 1,
+                                "/pkg %s", pkgver);
+               }
+               kfree(pkglog);
+       }
        if (bp->hwrm_spec_code < 0x10704 || !BNXT_SINGLE_PF(bp))
                return;