bnxt_en: Add bnxt_hwrm_nvm_get_dev_info() to query NVM info.
authorVasundhara Volam <vasundhara-v.volam@broadcom.com>
Mon, 12 Oct 2020 09:10:52 +0000 (05:10 -0400)
committerJakub Kicinski <kuba@kernel.org>
Mon, 12 Oct 2020 21:27:03 +0000 (14:27 -0700)
Add a new bnxt_hwrm_nvm_get_dev_info() to query firmware version
information via NVM_GET_DEV_INFO firmware command.  Use it to
get the running version of the NVM configuration information.

This new function will also be used in subsequent patches to get the
stored firmware versions.

Reviewed-by: Andy Gospodarek <gospo@broadcom.com>
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Link: https://lore.kernel.org/r/1602493854-29283-8-git-send-email-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.h

index 78bf636e623b1ac5587b6d0fa72021fdf0ba6d29..fa147865e33f4a1927c0dd439d0ab4b9bd6f150d 100644 (file)
@@ -7562,6 +7562,16 @@ static int bnxt_hwrm_func_reset(struct bnxt *bp)
        return hwrm_send_message(bp, &req, sizeof(req), HWRM_RESET_TIMEOUT);
 }
 
+static void bnxt_nvm_cfg_ver_get(struct bnxt *bp)
+{
+       struct hwrm_nvm_get_dev_info_output nvm_info;
+
+       if (!bnxt_hwrm_nvm_get_dev_info(bp, &nvm_info))
+               snprintf(bp->nvm_cfg_ver, FW_VER_STR_LEN, "%d.%d.%d",
+                        nvm_info.nvm_cfg_ver_maj, nvm_info.nvm_cfg_ver_min,
+                        nvm_info.nvm_cfg_ver_upd);
+}
+
 static int bnxt_hwrm_queue_qportcfg(struct bnxt *bp)
 {
        int rc = 0;
@@ -11223,6 +11233,8 @@ static int bnxt_fw_init_one_p1(struct bnxt *bp)
                if (rc)
                        return rc;
        }
+       bnxt_nvm_cfg_ver_get(bp);
+
        rc = bnxt_hwrm_func_reset(bp);
        if (rc)
                return -ENODEV;
index b208ff7c5d14967e8e8a2a8f2fad60d5d3472ddc..21ef1c21f602acdd444437a33b91bcf0be5ff14d 100644 (file)
@@ -1856,6 +1856,7 @@ struct bnxt {
 #define PHY_VER_STR_LEN         (FW_VER_STR_LEN - BC_HWRM_STR_LEN)
        char                    fw_ver_str[FW_VER_STR_LEN];
        char                    hwrm_ver_supp[FW_VER_STR_LEN];
+       char                    nvm_cfg_ver[FW_VER_STR_LEN];
        u64                     fw_ver_code;
 #define BNXT_FW_VER_CODE(maj, min, bld, rsv)                   \
        ((u64)(maj) << 48 | (u64)(min) << 32 | (u64)(bld) << 16 | (rsv))
index dcbb7b70d60a3400ec63ede38445102a1366ae38..53687bc7fcf5dce4ef9301389106231d1c11f062 100644 (file)
@@ -2072,6 +2072,22 @@ static u32 bnxt_get_link(struct net_device *dev)
        return bp->link_info.link_up;
 }
 
+int bnxt_hwrm_nvm_get_dev_info(struct bnxt *bp,
+                              struct hwrm_nvm_get_dev_info_output *nvm_dev_info)
+{
+       struct hwrm_nvm_get_dev_info_output *resp = bp->hwrm_cmd_resp_addr;
+       struct hwrm_nvm_get_dev_info_input req = {0};
+       int rc;
+
+       bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_NVM_GET_DEV_INFO, -1, -1);
+       mutex_lock(&bp->hwrm_cmd_lock);
+       rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
+       if (!rc)
+               memcpy(nvm_dev_info, resp, sizeof(*resp));
+       mutex_unlock(&bp->hwrm_cmd_lock);
+       return rc;
+}
+
 static void bnxt_print_admin_err(struct bnxt *bp)
 {
        netdev_info(bp->dev, "PF does not have admin privileges to flash or reset the device\n");
index 34f44ddfad7906891a4be47b1b01cd8d08dcaa38..fa6fbde52bea14ef697c24071acf60154dece7cc 100644 (file)
@@ -92,6 +92,8 @@ u32 bnxt_get_rxfh_indir_size(struct net_device *dev);
 u32 _bnxt_fw_to_ethtool_adv_spds(u16, u8);
 u32 bnxt_fw_to_ethtool_speed(u16);
 u16 bnxt_get_fw_auto_link_speeds(u32);
+int bnxt_hwrm_nvm_get_dev_info(struct bnxt *bp,
+                              struct hwrm_nvm_get_dev_info_output *nvm_dev_info);
 int bnxt_flash_package_from_file(struct net_device *dev, const char *filename,
                                 u32 install_type);
 void bnxt_ethtool_init(struct bnxt *bp);