Skip to content

Commit 9599e03

Browse files
Vasundhara Volamdavem330
authored andcommitted
bnxt_en: Add support for devlink info command
Display the following information via devlink info command: - Driver name - Board id - Broad revision - Board Serial number - Board FW version - FW parameter set version - FW App version - FW management version - FW RoCE version Standard output example: $ devlink dev info pci/0000:3b:00.0 pci/0000:3b:00.0: driver bnxt_en serial_number 00-10-18-FF-FE-AD-05-00 versions: fixed: asic.id D802 asic.rev 1 running: fw 216.1.124.0 fw.psid 0.0.0 fw.app 216.1.122.0 fw.mgmt 864.0.32.0 fw.roce 216.1.15.0 [ This version has incorporated changes suggested by Jakub Kicinski to use generic devlink version tags. ] v2: Use fw.psid Cc: Jiri Pirko <[email protected]> Cc: Jakub Kicinski <[email protected]> Signed-off-by: Vasundhara Volam <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 41c0d91 commit 9599e03

File tree

2 files changed

+138
-0
lines changed

2 files changed

+138
-0
lines changed

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

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,15 @@ void bnxt_dl_health_recovery_done(struct bnxt *bp)
284284
devlink_health_reporter_recovery_done(hlth->fw_reset_reporter);
285285
}
286286

287+
static int bnxt_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
288+
struct netlink_ext_ack *extack);
289+
287290
static const struct devlink_ops bnxt_dl_ops = {
288291
#ifdef CONFIG_BNXT_SRIOV
289292
.eswitch_mode_set = bnxt_dl_eswitch_mode_set,
290293
.eswitch_mode_get = bnxt_dl_eswitch_mode_get,
291294
#endif /* CONFIG_BNXT_SRIOV */
295+
.info_get = bnxt_dl_info_get,
292296
.flash_update = bnxt_dl_flash_update,
293297
};
294298

@@ -355,6 +359,136 @@ static void bnxt_copy_from_nvm_data(union devlink_param_value *dst,
355359
dst->vu8 = (u8)val32;
356360
}
357361

362+
static int bnxt_hwrm_get_nvm_cfg_ver(struct bnxt *bp,
363+
union devlink_param_value *nvm_cfg_ver)
364+
{
365+
struct hwrm_nvm_get_variable_input req = {0};
366+
union bnxt_nvm_data *data;
367+
dma_addr_t data_dma_addr;
368+
int rc;
369+
370+
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_NVM_GET_VARIABLE, -1, -1);
371+
data = dma_alloc_coherent(&bp->pdev->dev, sizeof(*data),
372+
&data_dma_addr, GFP_KERNEL);
373+
if (!data)
374+
return -ENOMEM;
375+
376+
req.dest_data_addr = cpu_to_le64(data_dma_addr);
377+
req.data_len = cpu_to_le16(BNXT_NVM_CFG_VER_BITS);
378+
req.option_num = cpu_to_le16(NVM_OFF_NVM_CFG_VER);
379+
380+
rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
381+
if (!rc)
382+
bnxt_copy_from_nvm_data(nvm_cfg_ver, data,
383+
BNXT_NVM_CFG_VER_BITS,
384+
BNXT_NVM_CFG_VER_BYTES);
385+
386+
dma_free_coherent(&bp->pdev->dev, sizeof(*data), data, data_dma_addr);
387+
return rc;
388+
}
389+
390+
static int bnxt_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
391+
struct netlink_ext_ack *extack)
392+
{
393+
struct bnxt *bp = bnxt_get_bp_from_dl(dl);
394+
union devlink_param_value nvm_cfg_ver;
395+
struct hwrm_ver_get_output *ver_resp;
396+
char mgmt_ver[FW_VER_STR_LEN];
397+
char roce_ver[FW_VER_STR_LEN];
398+
char fw_ver[FW_VER_STR_LEN];
399+
char buf[32];
400+
int rc;
401+
402+
rc = devlink_info_driver_name_put(req, DRV_MODULE_NAME);
403+
if (rc)
404+
return rc;
405+
406+
sprintf(buf, "%X", bp->chip_num);
407+
rc = devlink_info_version_fixed_put(req,
408+
DEVLINK_INFO_VERSION_GENERIC_ASIC_ID, buf);
409+
if (rc)
410+
return rc;
411+
412+
ver_resp = &bp->ver_resp;
413+
sprintf(buf, "%X", ver_resp->chip_rev);
414+
rc = devlink_info_version_fixed_put(req,
415+
DEVLINK_INFO_VERSION_GENERIC_ASIC_REV, buf);
416+
if (rc)
417+
return rc;
418+
419+
if (BNXT_PF(bp)) {
420+
sprintf(buf, "%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X",
421+
bp->dsn[7], bp->dsn[6], bp->dsn[5], bp->dsn[4],
422+
bp->dsn[3], bp->dsn[2], bp->dsn[1], bp->dsn[0]);
423+
rc = devlink_info_serial_number_put(req, buf);
424+
if (rc)
425+
return rc;
426+
}
427+
428+
if (strlen(ver_resp->active_pkg_name)) {
429+
rc =
430+
devlink_info_version_running_put(req,
431+
DEVLINK_INFO_VERSION_GENERIC_FW,
432+
ver_resp->active_pkg_name);
433+
if (rc)
434+
return rc;
435+
}
436+
437+
if (BNXT_PF(bp) && !bnxt_hwrm_get_nvm_cfg_ver(bp, &nvm_cfg_ver)) {
438+
u32 ver = nvm_cfg_ver.vu32;
439+
440+
sprintf(buf, "%X.%X.%X", (ver >> 16) & 0xF, (ver >> 8) & 0xF,
441+
ver & 0xF);
442+
rc = devlink_info_version_running_put(req,
443+
DEVLINK_INFO_VERSION_GENERIC_FW_PSID, buf);
444+
if (rc)
445+
return rc;
446+
}
447+
448+
if (ver_resp->flags & VER_GET_RESP_FLAGS_EXT_VER_AVAIL) {
449+
snprintf(fw_ver, FW_VER_STR_LEN, "%d.%d.%d.%d",
450+
ver_resp->hwrm_fw_major, ver_resp->hwrm_fw_minor,
451+
ver_resp->hwrm_fw_build, ver_resp->hwrm_fw_patch);
452+
453+
snprintf(mgmt_ver, FW_VER_STR_LEN, "%d.%d.%d.%d",
454+
ver_resp->mgmt_fw_major, ver_resp->mgmt_fw_minor,
455+
ver_resp->mgmt_fw_build, ver_resp->mgmt_fw_patch);
456+
457+
snprintf(roce_ver, FW_VER_STR_LEN, "%d.%d.%d.%d",
458+
ver_resp->roce_fw_major, ver_resp->roce_fw_minor,
459+
ver_resp->roce_fw_build, ver_resp->roce_fw_patch);
460+
} else {
461+
snprintf(fw_ver, FW_VER_STR_LEN, "%d.%d.%d.%d",
462+
ver_resp->hwrm_fw_maj_8b, ver_resp->hwrm_fw_min_8b,
463+
ver_resp->hwrm_fw_bld_8b, ver_resp->hwrm_fw_rsvd_8b);
464+
465+
snprintf(mgmt_ver, FW_VER_STR_LEN, "%d.%d.%d.%d",
466+
ver_resp->mgmt_fw_maj_8b, ver_resp->mgmt_fw_min_8b,
467+
ver_resp->mgmt_fw_bld_8b, ver_resp->mgmt_fw_rsvd_8b);
468+
469+
snprintf(roce_ver, FW_VER_STR_LEN, "%d.%d.%d.%d",
470+
ver_resp->roce_fw_maj_8b, ver_resp->roce_fw_min_8b,
471+
ver_resp->roce_fw_bld_8b, ver_resp->roce_fw_rsvd_8b);
472+
}
473+
rc = devlink_info_version_running_put(req,
474+
DEVLINK_INFO_VERSION_GENERIC_FW_APP, fw_ver);
475+
if (rc)
476+
return rc;
477+
478+
if (!(bp->flags & BNXT_FLAG_CHIP_P5)) {
479+
rc = devlink_info_version_running_put(req,
480+
DEVLINK_INFO_VERSION_GENERIC_FW_MGMT, mgmt_ver);
481+
if (rc)
482+
return rc;
483+
484+
rc = devlink_info_version_running_put(req,
485+
DEVLINK_INFO_VERSION_GENERIC_FW_ROCE, roce_ver);
486+
if (rc)
487+
return rc;
488+
}
489+
return 0;
490+
}
491+
358492
static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,
359493
int msg_len, union devlink_param_value *val)
360494
{

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ static inline void bnxt_link_bp_to_dl(struct bnxt *bp, struct devlink *dl)
3838
#define NVM_OFF_IGNORE_ARI 164
3939
#define NVM_OFF_DIS_GRE_VER_CHECK 171
4040
#define NVM_OFF_ENABLE_SRIOV 401
41+
#define NVM_OFF_NVM_CFG_VER 602
42+
43+
#define BNXT_NVM_CFG_VER_BITS 24
44+
#define BNXT_NVM_CFG_VER_BYTES 4
4145

4246
#define BNXT_MSIX_VEC_MAX 1280
4347
#define BNXT_MSIX_VEC_MIN_MAX 128

0 commit comments

Comments
 (0)