Skip to content

Commit 657a33c

Browse files
Vasundhara Volamdavem330
authored andcommitted
bnxt_en: Add devlink health reset reporter.
Add devlink health reporter for the firmware reset event. Once we get the notification from firmware about the impending reset, the driver will report this to devlink and the call to bnxt_fw_reset() will be initiated to complete the reset sequence. 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 230d1f0 commit 657a33c

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10167,6 +10167,9 @@ static void bnxt_sp_task(struct work_struct *work)
1016710167
if (test_and_clear_bit(BNXT_RESET_TASK_SILENT_SP_EVENT, &bp->sp_event))
1016810168
bnxt_reset(bp, true);
1016910169

10170+
if (test_and_clear_bit(BNXT_FW_RESET_NOTIFY_SP_EVENT, &bp->sp_event))
10171+
bnxt_devlink_health_report(bp, BNXT_FW_RESET_NOTIFY_SP_EVENT);
10172+
1017010173
smp_mb__before_atomic();
1017110174
clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state);
1017210175
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,11 @@ struct bnxt_fw_health {
13711371
u32 fw_reset_seq_vals[16];
13721372
u32 fw_reset_seq_delay_msec[16];
13731373
struct devlink_health_reporter *fw_reporter;
1374+
struct devlink_health_reporter *fw_reset_reporter;
1375+
};
1376+
1377+
struct bnxt_fw_reporter_ctx {
1378+
unsigned long sp_event;
13741379
};
13751380

13761381
#define BNXT_FW_HEALTH_REG_TYPE_MASK 3

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,24 @@ static const struct devlink_health_reporter_ops bnxt_dl_fw_reporter_ops = {
6565
.diagnose = bnxt_fw_reporter_diagnose,
6666
};
6767

68+
static int bnxt_fw_reset_recover(struct devlink_health_reporter *reporter,
69+
void *priv_ctx)
70+
{
71+
struct bnxt *bp = devlink_health_reporter_priv(reporter);
72+
73+
if (!priv_ctx)
74+
return -EOPNOTSUPP;
75+
76+
bnxt_fw_reset(bp);
77+
return 0;
78+
}
79+
80+
static const
81+
struct devlink_health_reporter_ops bnxt_dl_fw_reset_reporter_ops = {
82+
.name = "fw_reset",
83+
.recover = bnxt_fw_reset_recover,
84+
};
85+
6886
static void bnxt_dl_fw_reporters_create(struct bnxt *bp)
6987
{
7088
struct bnxt_fw_health *health = bp->fw_health;
@@ -80,6 +98,16 @@ static void bnxt_dl_fw_reporters_create(struct bnxt *bp)
8098
PTR_ERR(health->fw_reporter));
8199
health->fw_reporter = NULL;
82100
}
101+
102+
health->fw_reset_reporter =
103+
devlink_health_reporter_create(bp->dl,
104+
&bnxt_dl_fw_reset_reporter_ops,
105+
0, true, bp);
106+
if (IS_ERR(health->fw_reset_reporter)) {
107+
netdev_warn(bp->dev, "Failed to create FW fatal health reporter, rc = %ld\n",
108+
PTR_ERR(health->fw_reset_reporter));
109+
health->fw_reset_reporter = NULL;
110+
}
83111
}
84112

85113
static void bnxt_dl_fw_reporters_destroy(struct bnxt *bp)
@@ -91,6 +119,30 @@ static void bnxt_dl_fw_reporters_destroy(struct bnxt *bp)
91119

92120
if (health->fw_reporter)
93121
devlink_health_reporter_destroy(health->fw_reporter);
122+
123+
if (health->fw_reset_reporter)
124+
devlink_health_reporter_destroy(health->fw_reset_reporter);
125+
}
126+
127+
void bnxt_devlink_health_report(struct bnxt *bp, unsigned long event)
128+
{
129+
struct bnxt_fw_health *fw_health = bp->fw_health;
130+
struct bnxt_fw_reporter_ctx fw_reporter_ctx;
131+
132+
if (!fw_health)
133+
return;
134+
135+
fw_reporter_ctx.sp_event = event;
136+
switch (event) {
137+
case BNXT_FW_RESET_NOTIFY_SP_EVENT:
138+
if (!fw_health->fw_reset_reporter)
139+
return;
140+
141+
devlink_health_report(fw_health->fw_reset_reporter,
142+
"FW non-fatal reset event received",
143+
&fw_reporter_ctx);
144+
return;
145+
}
94146
}
95147

96148
static const struct devlink_ops bnxt_dl_ops = {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct bnxt_dl_nvm_param {
5555
u16 num_bits;
5656
};
5757

58+
void bnxt_devlink_health_report(struct bnxt *bp, unsigned long event);
5859
int bnxt_dl_register(struct bnxt *bp);
5960
void bnxt_dl_unregister(struct bnxt *bp);
6061

0 commit comments

Comments
 (0)