Skip to content

Commit 6763c77

Browse files
Vasundhara Volamdavem330
authored andcommitted
bnxt_en: Add new FW devlink_health_reporter
Create new FW devlink_health_reporter, to know the current health status of FW. Command example and output: $ devlink health show pci/0000:af:00.0 reporter fw pci/0000:af:00.0: name fw state healthy error 0 recover 0 FW status: Healthy; Reset count: 1 Cc: Jiri Pirko <[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 3bc7d4a commit 6763c77

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,7 @@ struct bnxt_fw_health {
13681368
u32 fw_reset_seq_regs[16];
13691369
u32 fw_reset_seq_vals[16];
13701370
u32 fw_reset_seq_delay_msec[16];
1371+
struct devlink_health_reporter *fw_reporter;
13711372
};
13721373

13731374
#define BNXT_FW_HEALTH_REG_TYPE_MASK 3
@@ -1382,6 +1383,8 @@ struct bnxt_fw_health {
13821383
#define BNXT_FW_HEALTH_WIN_BASE 0x3000
13831384
#define BNXT_FW_HEALTH_WIN_MAP_OFF 8
13841385

1386+
#define BNXT_FW_STATUS_HEALTHY 0x8000
1387+
13851388
struct bnxt {
13861389
void __iomem *bar0;
13871390
void __iomem *bar1;

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

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,84 @@
1515
#include "bnxt_vfr.h"
1616
#include "bnxt_devlink.h"
1717

18+
static int bnxt_fw_reporter_diagnose(struct devlink_health_reporter *reporter,
19+
struct devlink_fmsg *fmsg)
20+
{
21+
struct bnxt *bp = devlink_health_reporter_priv(reporter);
22+
struct bnxt_fw_health *health = bp->fw_health;
23+
u32 val, health_status;
24+
int rc;
25+
26+
if (!health || test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))
27+
return 0;
28+
29+
val = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG);
30+
health_status = val & 0xffff;
31+
32+
if (health_status == BNXT_FW_STATUS_HEALTHY) {
33+
rc = devlink_fmsg_string_pair_put(fmsg, "FW status",
34+
"Healthy;");
35+
if (rc)
36+
return rc;
37+
} else if (health_status < BNXT_FW_STATUS_HEALTHY) {
38+
rc = devlink_fmsg_string_pair_put(fmsg, "FW status",
39+
"Not yet completed initialization;");
40+
if (rc)
41+
return rc;
42+
} else if (health_status > BNXT_FW_STATUS_HEALTHY) {
43+
rc = devlink_fmsg_string_pair_put(fmsg, "FW status",
44+
"Encountered fatal error and cannot recover;");
45+
if (rc)
46+
return rc;
47+
}
48+
49+
if (val >> 16) {
50+
rc = devlink_fmsg_u32_pair_put(fmsg, "Error", val >> 16);
51+
if (rc)
52+
return rc;
53+
}
54+
55+
val = bnxt_fw_health_readl(bp, BNXT_FW_RESET_CNT_REG);
56+
rc = devlink_fmsg_u32_pair_put(fmsg, "Reset count", val);
57+
if (rc)
58+
return rc;
59+
60+
return 0;
61+
}
62+
63+
static const struct devlink_health_reporter_ops bnxt_dl_fw_reporter_ops = {
64+
.name = "fw",
65+
.diagnose = bnxt_fw_reporter_diagnose,
66+
};
67+
68+
static void bnxt_dl_fw_reporters_create(struct bnxt *bp)
69+
{
70+
struct bnxt_fw_health *health = bp->fw_health;
71+
72+
if (!health)
73+
return;
74+
75+
health->fw_reporter =
76+
devlink_health_reporter_create(bp->dl, &bnxt_dl_fw_reporter_ops,
77+
0, false, bp);
78+
if (IS_ERR(health->fw_reporter)) {
79+
netdev_warn(bp->dev, "Failed to create FW health reporter, rc = %ld\n",
80+
PTR_ERR(health->fw_reporter));
81+
health->fw_reporter = NULL;
82+
}
83+
}
84+
85+
static void bnxt_dl_fw_reporters_destroy(struct bnxt *bp)
86+
{
87+
struct bnxt_fw_health *health = bp->fw_health;
88+
89+
if (!health)
90+
return;
91+
92+
if (health->fw_reporter)
93+
devlink_health_reporter_destroy(health->fw_reporter);
94+
}
95+
1896
static const struct devlink_ops bnxt_dl_ops = {
1997
#ifdef CONFIG_BNXT_SRIOV
2098
.eswitch_mode_set = bnxt_dl_eswitch_mode_set,
@@ -247,6 +325,8 @@ int bnxt_dl_register(struct bnxt *bp)
247325

248326
devlink_params_publish(dl);
249327

328+
bnxt_dl_fw_reporters_create(bp);
329+
250330
return 0;
251331

252332
err_dl_port_unreg:
@@ -269,6 +349,7 @@ void bnxt_dl_unregister(struct bnxt *bp)
269349
if (!dl)
270350
return;
271351

352+
bnxt_dl_fw_reporters_destroy(bp);
272353
devlink_port_params_unregister(&bp->dl_port, bnxt_dl_port_params,
273354
ARRAY_SIZE(bnxt_dl_port_params));
274355
devlink_port_unregister(&bp->dl_port);

0 commit comments

Comments
 (0)