15
15
#include "bnxt_vfr.h"
16
16
#include "bnxt_devlink.h"
17
17
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
+
18
96
static const struct devlink_ops bnxt_dl_ops = {
19
97
#ifdef CONFIG_BNXT_SRIOV
20
98
.eswitch_mode_set = bnxt_dl_eswitch_mode_set ,
@@ -247,6 +325,8 @@ int bnxt_dl_register(struct bnxt *bp)
247
325
248
326
devlink_params_publish (dl );
249
327
328
+ bnxt_dl_fw_reporters_create (bp );
329
+
250
330
return 0 ;
251
331
252
332
err_dl_port_unreg :
@@ -269,6 +349,7 @@ void bnxt_dl_unregister(struct bnxt *bp)
269
349
if (!dl )
270
350
return ;
271
351
352
+ bnxt_dl_fw_reporters_destroy (bp );
272
353
devlink_port_params_unregister (& bp -> dl_port , bnxt_dl_port_params ,
273
354
ARRAY_SIZE (bnxt_dl_port_params ));
274
355
devlink_port_unregister (& bp -> dl_port );
0 commit comments