Skip to content

Commit d0ad2ea

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Store the running firmware version code.
We currently only store the firmware version as a string for ethtool and devlink info. Store it also as a version code. The next 2 patches will need to check the firmware major version to determine some workarounds. We also use the 16-bit firmware version fields if the firmware is newer and provides the 16-bit fields. Reviewed-by: Edwin Peer <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a83024b commit d0ad2ea

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7240,8 +7240,9 @@ static int __bnxt_hwrm_ver_get(struct bnxt *bp, bool silent)
72407240
static int bnxt_hwrm_ver_get(struct bnxt *bp)
72417241
{
72427242
struct hwrm_ver_get_output *resp = bp->hwrm_cmd_resp_addr;
7243+
u16 fw_maj, fw_min, fw_bld, fw_rsv;
72437244
u32 dev_caps_cfg, hwrm_ver;
7244-
int rc;
7245+
int rc, len;
72457246

72467247
bp->hwrm_max_req_len = HWRM_MAX_REQ_LEN;
72477248
mutex_lock(&bp->hwrm_cmd_lock);
@@ -7273,9 +7274,22 @@ static int bnxt_hwrm_ver_get(struct bnxt *bp)
72737274
resp->hwrm_intf_maj_8b, resp->hwrm_intf_min_8b,
72747275
resp->hwrm_intf_upd_8b);
72757276

7276-
snprintf(bp->fw_ver_str, BC_HWRM_STR_LEN, "%d.%d.%d.%d",
7277-
resp->hwrm_fw_maj_8b, resp->hwrm_fw_min_8b,
7278-
resp->hwrm_fw_bld_8b, resp->hwrm_fw_rsvd_8b);
7277+
fw_maj = le16_to_cpu(resp->hwrm_fw_major);
7278+
if (bp->hwrm_spec_code > 0x10803 && fw_maj) {
7279+
fw_min = le16_to_cpu(resp->hwrm_fw_minor);
7280+
fw_bld = le16_to_cpu(resp->hwrm_fw_build);
7281+
fw_rsv = le16_to_cpu(resp->hwrm_fw_patch);
7282+
len = FW_VER_STR_LEN;
7283+
} else {
7284+
fw_maj = resp->hwrm_fw_maj_8b;
7285+
fw_min = resp->hwrm_fw_min_8b;
7286+
fw_bld = resp->hwrm_fw_bld_8b;
7287+
fw_rsv = resp->hwrm_fw_rsvd_8b;
7288+
len = BC_HWRM_STR_LEN;
7289+
}
7290+
bp->fw_ver_code = BNXT_FW_VER_CODE(fw_maj, fw_min, fw_bld, fw_rsv);
7291+
snprintf(bp->fw_ver_str, len, "%d.%d.%d.%d", fw_maj, fw_min, fw_bld,
7292+
fw_rsv);
72797293

72807294
if (strlen(resp->active_pkg_name)) {
72817295
int fw_ver_len = strlen(bp->fw_ver_str);

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,10 @@ struct bnxt {
17461746
#define PHY_VER_STR_LEN (FW_VER_STR_LEN - BC_HWRM_STR_LEN)
17471747
char fw_ver_str[FW_VER_STR_LEN];
17481748
char hwrm_ver_supp[FW_VER_STR_LEN];
1749+
u64 fw_ver_code;
1750+
#define BNXT_FW_VER_CODE(maj, min, bld, rsv) \
1751+
((u64)(maj) << 48 | (u64)(min) << 32 | (u64)(bld) << 16 | (rsv))
1752+
17491753
__be16 vxlan_port;
17501754
u8 vxlan_port_cnt;
17511755
__le16 vxlan_fw_dst_port_id;

0 commit comments

Comments
 (0)