eth: fbnic: add devlink health support for FW crashes and OTP mem corruptions
Subsystems (4)
Jakub Kicinski
maintainerv3 cover eth: fbnic: add devlink health support for FW crashes and OTP mem corruptions
Add support for FW crash detection and a corresponding devlink health reporter. Add a reporter for checking OTP memory health.
The output is not particularly exciting:
# devlink health show
pci/0000:01:00.0:
reporter fw
state healthy error 0 recover 0 auto_dump true
reporter otp
state healthy error 0 recover 0 auto_dump true
# devlink health diagnose pci/0000:01:00.0 reporter fw
FW uptime: 0
# devlink health dump show pci/0000:01:00.0 reporter fw
FW coredump:
5a 45 01 00 04 00 06 00 00 00 00 00 4d 01 00 d0
.. lots of hex follows ..
# devlink health dump show pci/0000:01:00.0 reporter otp
OTP:
Status: 0 Data: 0 ECC: 0v3:
- [patch 2] add parsing policies
- [patch 7] use extack
- [patch 8] split time in diagnose callback into sec and msec
- [patch 8] don't report when netdevice is down
v2: https://lore.kernel.org/[email protected]
- [patch 2] fix attr ID
- [patch 2] comment and commit msg adjustments
v1: https://lore.kernel.org/[email protected]
Jakub Kicinski (9):
eth: fbnic: make fbnic_fw_log_write() parameter const
eth: fbnic: use fw uptime to detect fw crashes
eth: fbnic: factor out clearing the action TCAM
eth: fbnic: reprogram TCAMs after FW crash
eth: fbnic: support allocating FW completions with extra space
eth: fbnic: support FW communication for core dump
eth: fbnic: add FW health reporter
eth: fbnic: report FW uptime in health diagnose
eth: fbnic: add OTP health reporter
.../device_drivers/ethernet/meta/fbnic.rst | 19 ++ drivers/net/ethernet/meta/fbnic/fbnic.h | 13 + drivers/net/ethernet/meta/fbnic/fbnic_csr.h | 18 ++ drivers/net/ethernet/meta/fbnic/fbnic_fw.h | 47 ++++ .../net/ethernet/meta/fbnic/fbnic_fw_log.h | 2 +- .../net/ethernet/meta/fbnic/fbnic_devlink.c | 249 ++++++++++++++++++ drivers/net/ethernet/meta/fbnic/fbnic_fw.c | 241 ++++++++++++++++- .../net/ethernet/meta/fbnic/fbnic_fw_log.c | 2 +- drivers/net/ethernet/meta/fbnic/fbnic_pci.c | 39 ++- drivers/net/ethernet/meta/fbnic/fbnic_rpc.c | 57 ++-- 10 files changed, 659 insertions(+), 28 deletions(-)
Signature · 1 line
2.51.0
Jakub Kicinski
maintainerPATCH v3 1/9 eth: fbnic: make fbnic_fw_log_write() parameter const
Make the log message parameter const, it's not modified and this lets us pass in strings which are const for the caller.
--- drivers/net/ethernet/meta/fbnic/fbnic_fw_log.h | 2 +- drivers/net/ethernet/meta/fbnic/fbnic_fw_log.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_fw_log.h +1 -1
@@ -41,5 +41,5 @@ void fbnic_fw_log_disable(struct fbnic_dev *fbd);int fbnic_fw_log_init (struct fbnic_dev *fbd);void fbnic_fw_log_free (struct fbnic_dev *fbd);int fbnic_fw_log_write (struct fbnic_dev *fbd,u64 index,u32 timestamp, -char *msg); +const char *msg);#endif /* _FBNIC_FW_LOG_H_ */
drivers/net/ethernet/meta/fbnic/fbnic_fw_log.c +1 -1
@@ -72,7 +72,7 @@ void fbnic_fw_log_free(struct fbnic_dev *fbd) }int fbnic_fw_log_write (struct fbnic_dev *fbd,u64 index,u32 timestamp, -char *msg) +const char *msg) {struct fbnic_fw_log_entry *entry, *head, *tail, *next;struct fbnic_fw_log *log = &fbd->fw_log;
Signature · 1 line
2.51.0
Jakub Kicinski
maintainerPATCH v3 2/9 eth: fbnic: use fw uptime to detect fw crashes
In reply to Jakub KicinskiCurrently we only detect FW crashes when it stops responding to heartbeat messages. FW has a watchdog which will reset it in case of crashes. Use FW uptime sent in the ownership and heartbeat messages to detect that the watchdog has fired (uptime went down).
---
v3:
- include TIME attrs in parsing policies
v2:
- update commit msg
- use uptime the entry from OWNERSHIP enum in ownership rsp parsing
- update comment about heartbeat rsp
v1: https://lore.kernel.org/[email protected]
--- drivers/net/ethernet/meta/fbnic/fbnic.h | 4 ++++ drivers/net/ethernet/meta/fbnic/fbnic_fw.h | 7 +++++++ drivers/net/ethernet/meta/fbnic/fbnic_fw.c | 17 ++++++++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-)
drivers/net/ethernet/meta/fbnic/fbnic.h +4 -0
@@ -84,6 +84,10 @@ struct fbnic_dev {/* Local copy of hardware statistics */ struct fbnic_hw_stats hw_stats; +/* Firmware time since boot in milliseconds */ +u64 firmware_time; +u64 prev_firmware_time; +struct fbnic_fw_log fw_log; };
drivers/net/ethernet/meta/fbnic/fbnic_fw.h +7 -0
@@ -198,9 +198,16 @@ enum {enum {FBNIC_FW_OWNERSHIP_FLAG =0x0 , +FBNIC_FW_OWNERSHIP_TIME =0x1 ,FBNIC_FW_OWNERSHIP_MSG_MAX }; +enum { +FBNIC_FW_HEARTBEAT_UPTIME =0x0 , +FBNIC_FW_HEARTBEAT_NUMBER_OF_MESSAGES =0x1 , +FBNIC_FW_HEARTBEAT_MSG_MAX +}; +enum {FBNIC_FW_START_UPGRADE_ERROR =0x0 ,FBNIC_FW_START_UPGRADE_SECTION =0x1 ,
drivers/net/ethernet/meta/fbnic/fbnic_fw.c +16 -1
@@ -495,6 +495,11 @@ int fbnic_fw_xmit_ownership_msg(struct fbnic_dev *fbd, bool take_ownership) fbd->last_heartbeat_request = req_time; +/* Set prev_firmware_time to 0 to avoid triggering firmware crash +* detection until we receive the second uptime in a heartbeat resp. +*/ + fbd->prev_firmware_time =0 ; +/* Set heartbeat detection based on if we are taking ownership */ fbd->fw_heartbeat_enabled = take_ownership;
@@ -660,6 +665,7 @@ static int fbnic_fw_parse_cap_resp(void *opaque, struct fbnic_tlv_msg **results) }static const struct fbnic_tlv_index fbnic_ownership_resp_index[] = { +FBNIC_TLV_ATTR_U64 (FBNIC_FW_OWNERSHIP_TIME ),FBNIC_TLV_ATTR_LAST };
@@ -671,10 +677,14 @@ static int fbnic_fw_parse_ownership_resp(void *opaque,/* Count the ownership response as a heartbeat reply */ fbd->last_heartbeat_response = jiffies; +/* Capture firmware time for logging and firmware crash check */ + fbd->firmware_time =fta_get_uint (results,FBNIC_FW_OWNERSHIP_TIME ); +return 0 ; }static const struct fbnic_tlv_index fbnic_heartbeat_resp_index[] = { +FBNIC_TLV_ATTR_U64 (FBNIC_FW_HEARTBEAT_UPTIME ),FBNIC_TLV_ATTR_LAST };
@@ -685,6 +695,9 @@ static int fbnic_fw_parse_heartbeat_resp(void *opaque, fbd->last_heartbeat_response = jiffies; +/* Capture firmware time for logging and firmware crash check */ + fbd->firmware_time =fta_get_uint (results,FBNIC_FW_HEARTBEAT_UPTIME ); +return 0 ; }
@@ -706,6 +719,7 @@ static int fbnic_fw_xmit_heartbeat_message(struct fbnic_dev *fbd) goto free_message; fbd->last_heartbeat_request = req_time; + fbd->prev_firmware_time = fbd->firmware_time;return err;
@@ -766,7 +780,8 @@ void fbnic_fw_check_heartbeat(struct fbnic_dev *fbd)return ;/* Was the last heartbeat response long time ago? */ -if (!fbnic_fw_heartbeat_current (fbd)) { +if (!fbnic_fw_heartbeat_current (fbd) || + fbd->firmware_time < fbd->prev_firmware_time) {dev_warn (fbd->dev,"Firmware did not respond to heartbeat message\n" ); fbd->fw_heartbeat_enabled = false;
Signature · 1 line
2.51.0
Jakub Kicinski
maintainerPATCH v3 3/9 eth: fbnic: factor out clearing the action TCAM
In reply to Jakub KicinskiWe'll want to wipe the driver TCAM state after FW crash, to force a re-programming. Factor out the clearing logic. Remove the micro- -optimization to skip clearing the BMC entry twice, it doesn't hurt.
--- drivers/net/ethernet/meta/fbnic/fbnic_rpc.c | 36 ++++++++++++--------- 1 file changed, 21 insertions(+), 15 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_rpc.c +21 -15
@@ -1124,13 +1124,25 @@ void fbnic_write_ip_addr(struct fbnic_dev *fbd) } } -void fbnic_clear_rules (struct fbnic_dev *fbd) +static void fbnic_clear_valid_act_tcam (struct fbnic_dev *fbd) { -u32 dest =FIELD_PREP (FBNIC_RPC_ACT_TBL0_DEST_MASK , -FBNIC_RPC_ACT_TBL0_DEST_BMC );int i =FBNIC_RPC_TCAM_ACT_NUM_ENTRIES -1 ;struct fbnic_act_tcam *act_tcam; +/* Work from the bottom up deleting all other rules from hardware */ +do { + act_tcam = &fbd->act_tcam[i]; + +if (act_tcam->state !=FBNIC_TCAM_S_VALID ) +continue ; + +fbnic_clear_act_tcam (fbd, i); + act_tcam->state =FBNIC_TCAM_S_UPDATE ; + }while (i--); +} + +void fbnic_clear_rules (struct fbnic_dev *fbd) +{/* Clear MAC rules */ fbnic_clear_macda (fbd);
@@ -1145,6 +1157,11 @@ void fbnic_clear_rules(struct fbnic_dev *fbd)* the interface back up. */ if (fbnic_bmc_present (fbd)) { +u32 dest =FIELD_PREP (FBNIC_RPC_ACT_TBL0_DEST_MASK , +FBNIC_RPC_ACT_TBL0_DEST_BMC ); +int i =FBNIC_RPC_TCAM_ACT_NUM_ENTRIES -1 ; +struct fbnic_act_tcam *act_tcam; + act_tcam = &fbd->act_tcam[i]; if (act_tcam->state == FBNIC_TCAM_S_VALID &&
@@ -1153,21 +1170,10 @@ void fbnic_clear_rules(struct fbnic_dev *fbd)wr32 (fbd,FBNIC_RPC_ACT_TBL1 (i),0 ); act_tcam->state =FBNIC_TCAM_S_UPDATE ; - - i--; } } -/* Work from the bottom up deleting all other rules from hardware */ -do { - act_tcam = &fbd->act_tcam[i]; - -if (act_tcam->state !=FBNIC_TCAM_S_VALID ) -continue ; - -fbnic_clear_act_tcam (fbd, i); - act_tcam->state =FBNIC_TCAM_S_UPDATE ; - }while (i--); +fbnic_clear_valid_act_tcam (fbd); }static void fbnic_delete_act_tcam (struct fbnic_dev *fbd,unsigned int idx)
Signature · 1 line
2.51.0
Jakub Kicinski
maintainerPATCH v3 4/9 eth: fbnic: reprogram TCAMs after FW crash
In reply to Jakub KicinskiFW may mess with the TCAM after it boots, to try to restore the traffic flow to the BMC (it may not be aware that the host is already up). Make sure that we reprogram the TCAMs after detecting a crash.
--- drivers/net/ethernet/meta/fbnic/fbnic.h | 2 ++ drivers/net/ethernet/meta/fbnic/fbnic_pci.c | 23 ++++++++++++++------- drivers/net/ethernet/meta/fbnic/fbnic_rpc.c | 21 +++++++++++++++++++ 3 files changed, 39 insertions(+), 7 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic.h +2 -0
@@ -191,6 +191,8 @@ void fbnic_dbg_fbd_exit(struct fbnic_dev *fbd);void fbnic_dbg_init (void );void fbnic_dbg_exit (void ); +void fbnic_rpc_reset_valid_entries (struct fbnic_dev *fbd); +void fbnic_csr_get_regs (struct fbnic_dev *fbd,u32 *data,u32 *regs_version);int fbnic_csr_regs_len (struct fbnic_dev *fbd);
drivers/net/ethernet/meta/fbnic/fbnic_pci.c +16 -7
@@ -167,6 +167,20 @@ void fbnic_down(struct fbnic_net *fbn)fbnic_flush (fbn); } +static int fbnic_fw_config_after_crash (struct fbnic_dev *fbd) +{ +if (fbnic_fw_xmit_ownership_msg (fbd, true)) { +dev_err (fbd->dev,"NIC failed to take ownership\n" ); + +return -1 ; + } + +fbnic_rpc_reset_valid_entries (fbd); +__fbnic_set_rx_mode (fbd); + +return 0 ; +} +static void fbnic_health_check (struct fbnic_dev *fbd) {struct fbnic_fw_mbx *tx_mbx = &fbd->mbx[FBNIC_IPC_MBX_TX_IDX ];
@@ -182,13 +196,8 @@ static void fbnic_health_check(struct fbnic_dev *fbd)if (tx_mbx->head != tx_mbx->tail)return ; -/* TBD: Need to add a more thorough recovery here. -* Specifically I need to verify what all the firmware will have -* changed since we had setup and it rebooted. May just need to -* perform a down/up. For now we will just reclaim ownership so -* the heartbeat can catch the next fault. -*/ -fbnic_fw_xmit_ownership_msg (fbd, true); +if (fbnic_fw_config_after_crash (fbd)) +dev_err (fbd->dev,"Firmware recovery failed after crash\n" ); }static void fbnic_service_task (struct work_struct *work)
drivers/net/ethernet/meta/fbnic/fbnic_rpc.c +21 -0
@@ -596,6 +596,21 @@ static void fbnic_clear_macda(struct fbnic_dev *fbd) } } +static void fbnic_clear_valid_macda (struct fbnic_dev *fbd) +{ +int idx; + +for (idx =ARRAY_SIZE (fbd->mac_addr); idx--;) { +struct fbnic_mac_addr *mac_addr = &fbd->mac_addr[idx]; + +if (mac_addr->state ==FBNIC_TCAM_S_VALID ) { +fbnic_clear_macda_entry (fbd, idx); + + mac_addr->state =FBNIC_TCAM_S_UPDATE ; + } + } +} +static void fbnic_write_macda_entry (struct fbnic_dev *fbd,unsigned int idx,struct fbnic_mac_addr *mac_addr) {
@@ -1223,3 +1238,9 @@ void fbnic_write_rules(struct fbnic_dev *fbd)fbnic_update_act_tcam (fbd, i); } } + +void fbnic_rpc_reset_valid_entries (struct fbnic_dev *fbd) +{ +fbnic_clear_valid_act_tcam (fbd); +fbnic_clear_valid_macda (fbd); +}
Signature · 1 line
2.51.0
Jakub Kicinski
maintainerPATCH v3 5/9 eth: fbnic: support allocating FW completions with extra space
In reply to Jakub KicinskiSupport allocating extra space after the FW completion. This makes it easy to pass extra variable size buffer space to FW response handlers without worrying about synchronization (completion itself is already refcounted).
--- drivers/net/ethernet/meta/fbnic/fbnic_fw.h | 2 ++ drivers/net/ethernet/meta/fbnic/fbnic_fw.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/net/ethernet/meta/fbnic/fbnic_fw.h +2 -0
@@ -100,6 +100,8 @@ int fbnic_fw_xmit_tsene_read_msg(struct fbnic_dev *fbd,int fbnic_fw_xmit_send_logs (struct fbnic_dev *fbd,bool enable,bool send_log_history);int fbnic_fw_xmit_rpc_macda_sync (struct fbnic_dev *fbd); +struct fbnic_fw_completion *__fbnic_fw_alloc_cmpl (u32 msg_type, +size_t priv_size);struct fbnic_fw_completion *fbnic_fw_alloc_cmpl (u32 msg_type);void fbnic_fw_put_cmpl (struct fbnic_fw_completion *cmpl_data);
drivers/net/ethernet/meta/fbnic/fbnic_fw.c +8 -2
@@ -1544,11 +1544,12 @@ void fbnic_get_fw_ver_commit_str(struct fbnic_dev *fbd, char *fw_version, fw_version, str_sz); } -struct fbnic_fw_completion *fbnic_fw_alloc_cmpl (u32 msg_type) +struct fbnic_fw_completion *__fbnic_fw_alloc_cmpl (u32 msg_type, +size_t priv_size) {struct fbnic_fw_completion *cmpl; - cmpl =kzalloc (sizeof (*cmpl),GFP_KERNEL ); + cmpl =kzalloc (sizeof (*cmpl) + priv_size,GFP_KERNEL );if (!cmpl)return NULL ;
@@ -1559,6 +1560,11 @@ struct fbnic_fw_completion *fbnic_fw_alloc_cmpl(u32 msg_type)return cmpl; } +struct fbnic_fw_completion *fbnic_fw_alloc_cmpl (u32 msg_type) +{ +return __fbnic_fw_alloc_cmpl (msg_type,0 ); +} +void fbnic_fw_put_cmpl (struct fbnic_fw_completion *fw_cmpl) {kref_put (&fw_cmpl->ref_count, fbnic_fw_release_cmpl_data);
Signature · 1 line
2.51.0
Jakub Kicinski
maintainerPATCH v3 6/9 eth: fbnic: support FW communication for core dump
In reply to Jakub KicinskiTo read FW core dump we need to issue two commands to FW:
- first get the FW core dump info
- second read the dump chunk by chunk
Implement these two FW commands. Subsequent commits will use them to expose FW dump via devlink heath.
--- drivers/net/ethernet/meta/fbnic/fbnic_fw.h | 38 ++++ drivers/net/ethernet/meta/fbnic/fbnic_fw.c | 214 +++++++++++++++++++++ 2 files changed, 252 insertions(+)
drivers/net/ethernet/meta/fbnic/fbnic_fw.h +38 -0
@@ -66,6 +66,14 @@ struct fbnic_fw_completion {struct kref ref_count;int result;union { +struct { +u32 size; + } coredump_info; +struct { +u32 size; +u16 stride; +u8 *data[]; + } coredump;struct {u32 offset;u32 length;
@@ -89,6 +97,12 @@ void fbnic_mbx_flush_tx(struct fbnic_dev *fbd);int fbnic_fw_xmit_ownership_msg (struct fbnic_dev *fbd,bool take_ownership);int fbnic_fw_init_heartbeat (struct fbnic_dev *fbd,bool poll);void fbnic_fw_check_heartbeat (struct fbnic_dev *fbd); +int fbnic_fw_xmit_coredump_info_msg (struct fbnic_dev *fbd, +struct fbnic_fw_completion *cmpl_data, +bool force); +int fbnic_fw_xmit_coredump_read_msg (struct fbnic_dev *fbd, +struct fbnic_fw_completion *cmpl_data, +u32 offset,u32 length);int fbnic_fw_xmit_fw_start_upgrade (struct fbnic_dev *fbd,struct fbnic_fw_completion *cmpl_data,unsigned int id,unsigned int len);
@@ -137,6 +151,10 @@ enum {FBNIC_TLV_MSG_ID_OWNERSHIP_RESP =0x13 ,FBNIC_TLV_MSG_ID_HEARTBEAT_REQ =0x14 ,FBNIC_TLV_MSG_ID_HEARTBEAT_RESP =0x15 , +FBNIC_TLV_MSG_ID_COREDUMP_GET_INFO_REQ =0x18 , +FBNIC_TLV_MSG_ID_COREDUMP_GET_INFO_RESP =0x19 , +FBNIC_TLV_MSG_ID_COREDUMP_READ_REQ =0x20 , +FBNIC_TLV_MSG_ID_COREDUMP_READ_RESP =0x21 ,FBNIC_TLV_MSG_ID_FW_START_UPGRADE_REQ =0x22 ,FBNIC_TLV_MSG_ID_FW_START_UPGRADE_RESP =0x23 , FBNIC_TLV_MSG_ID_FW_WRITE_CHUNK_REQ = 0x24,
@@ -210,6 +228,26 @@ enum {FBNIC_FW_HEARTBEAT_MSG_MAX }; +enum { +FBNIC_FW_COREDUMP_REQ_INFO_CREATE =0x0 , +FBNIC_FW_COREDUMP_REQ_INFO_MSG_MAX +}; + +enum { +FBNIC_FW_COREDUMP_INFO_AVAILABLE =0x0 , +FBNIC_FW_COREDUMP_INFO_SIZE =0x1 , +FBNIC_FW_COREDUMP_INFO_ERROR =0x2 , +FBNIC_FW_COREDUMP_INFO_MSG_MAX +}; + +enum { +FBNIC_FW_COREDUMP_READ_OFFSET =0x0 , +FBNIC_FW_COREDUMP_READ_LENGTH =0x1 , +FBNIC_FW_COREDUMP_READ_DATA =0x2 , +FBNIC_FW_COREDUMP_READ_ERROR =0x3 , +FBNIC_FW_COREDUMP_READ_MSG_MAX +}; +enum {FBNIC_FW_START_UPGRADE_ERROR =0x0 ,FBNIC_FW_START_UPGRADE_SECTION =0x1 ,
drivers/net/ethernet/meta/fbnic/fbnic_fw.c +214 -0
226 lines not on this page · raw message
Signature · 1 line
2.51.0
Jakub Kicinski
maintainerPATCH v3 7/9 eth: fbnic: add FW health reporter
In reply to Jakub KicinskiAdd a health reporter to catch FW crashes. Dumping the reporter if FW has not crashed will create a snapshot of FW memory.
---
v3:
- use extack rather than dev_err()
--- .../device_drivers/ethernet/meta/fbnic.rst | 10 ++ drivers/net/ethernet/meta/fbnic/fbnic.h | 5 + .../net/ethernet/meta/fbnic/fbnic_devlink.c | 155 ++++++++++++++++++ drivers/net/ethernet/meta/fbnic/fbnic_pci.c | 11 +- 4 files changed, 180 insertions(+), 1 deletion(-)
Documentation/networking/device_drivers/ethernet/meta/fbnic.rst +10 -0
@@ -69,6 +69,16 @@ On host boot the latest UEFI driver is always used, no explicit activation is required. Firmware activation is required to run new control firmware. cmrt firmware can only be activated by power cycling the NIC. +Health reporters +---------------- + +fw reporter +~~~~~~~~~~~ + +The ``fw`` health reporter tracks FW crashes. Dumping the reporter will +show the core dump of the most recent FW crash, and if no FW crash has +happened since power cycle - a snapshot of the FW memory. + Statistics ----------
drivers/net/ethernet/meta/fbnic/fbnic.h +5 -0
@@ -27,6 +27,7 @@ struct fbnic_dev {struct net_device *netdev;struct dentry *dbg_fbd;struct device *hwmon; +struct devlink_health_reporter *fw_reporter;u32 __iomem *uc_addr0;u32 __iomem *uc_addr4;
@@ -159,8 +160,12 @@ extern char fbnic_driver_name[];void fbnic_devlink_free (struct fbnic_dev *fbd);struct fbnic_dev *fbnic_devlink_alloc (struct pci_dev *pdev); +int fbnic_devlink_health_create (struct fbnic_dev *fbd); +void fbnic_devlink_health_destroy (struct fbnic_dev *fbd);void fbnic_devlink_register (struct fbnic_dev *fbd);void fbnic_devlink_unregister (struct fbnic_dev *fbd); +void __printf(2, 3) +fbnic_devlink_fw_report(struct fbnic_dev *fbd, const char *format, ...); int fbnic_fw_request_mbx(struct fbnic_dev *fbd); void fbnic_fw_free_mbx(struct fbnic_dev *fbd);
drivers/net/ethernet/meta/fbnic/fbnic_devlink.c +155 -0
167 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_pci.c +10 -1
@@ -196,6 +196,8 @@ static void fbnic_health_check(struct fbnic_dev *fbd)if (tx_mbx->head != tx_mbx->tail)return ; +fbnic_devlink_fw_report (fbd,"Firmware crashed detected!" ); +if (fbnic_fw_config_after_crash (fbd))dev_err (fbd->dev,"Firmware recovery failed after crash\n" ); }
@@ -279,6 +281,10 @@ static int fbnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)return -ENOMEM ; } + err =fbnic_devlink_health_create (fbd); +if (err) + goto free_fbd; +/* Populate driver with hardware-specific info and handlers */ fbd->max_num_queues = info->max_num_queues;
@@ -289,7 +295,7 @@ static int fbnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err =fbnic_alloc_irqs (fbd);if (err) - goto free_fbd; + goto err_destroy_health; err =fbnic_mac_init (fbd);if (err) {
@@ -358,6 +364,8 @@ static int fbnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)return 0 ; free_irqs:fbnic_free_irqs (fbd); +err_destroy_health: +fbnic_devlink_health_destroy (fbd); free_fbd:fbnic_devlink_free (fbd);
@@ -392,6 +400,7 @@ static void fbnic_remove(struct pci_dev *pdev)fbnic_fw_free_mbx (fbd);fbnic_free_irqs (fbd); +fbnic_devlink_health_destroy (fbd);fbnic_devlink_free (fbd); }
Signature · 1 line
2.51.0
Jakub Kicinski
maintainerPATCH v3 8/9 eth: fbnic: report FW uptime in health diagnose
In reply to Jakub KicinskiFW crashes are detected based on uptime going back, expose the uptime via devlink health diagnose.
$ devlink -j health diagnose pci/0000:01:00.0 reporter fw
{"last_heartbeat":{"fw_uptime":{"sec":201,"msec":76}}}
$ devlink -j health diagnose pci/0000:01:00.0 reporter fw
last_heartbeat:
fw_uptime:
sec: 201 msec: 76---
v3:
- split time into sec and msec
- don't report when admin down, the time will not be refreshing
--- .../device_drivers/ethernet/meta/fbnic.rst | 4 ++- .../net/ethernet/meta/fbnic/fbnic_devlink.c | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-)
Documentation/networking/device_drivers/ethernet/meta/fbnic.rst +3 -1
@@ -77,7 +77,9 @@ fw reporter The ``fw`` health reporter tracks FW crashes. Dumping the reporter will show the core dump of the most recent FW crash, and if no FW crash has -happened since power cycle - a snapshot of the FW memory. +happened since power cycle - a snapshot of the FW memory. Diagnose callback +shows FW uptime based on the most recently received heartbeat message +(the crashes are detected by checking if uptime goes down). Statistics ----------
drivers/net/ethernet/meta/fbnic/fbnic_devlink.c +29 -0
@@ -485,6 +485,34 @@ static int fbnic_fw_reporter_dump(struct devlink_health_reporter *reporter,return err; } +static int +fbnic_fw_reporter_diagnose (struct devlink_health_reporter *reporter, +struct devlink_fmsg *fmsg, +struct netlink_ext_ack *extack) +{ +struct fbnic_dev *fbd =devlink_health_reporter_priv (reporter); +u32 sec, msec; + +/* Device is most likely down, we're not exchanging heartbeats */ +if (!fbd->prev_firmware_time) +return 0 ; + + sec =div_u64_rem (fbd->firmware_time,MSEC_PER_SEC , &msec); + +devlink_fmsg_pair_nest_start (fmsg,"last_heartbeat" ); +devlink_fmsg_obj_nest_start (fmsg); +devlink_fmsg_pair_nest_start (fmsg,"fw_uptime" ); +devlink_fmsg_obj_nest_start (fmsg); +devlink_fmsg_u32_pair_put (fmsg,"sec" , sec); +devlink_fmsg_u32_pair_put (fmsg,"msec" , msec); +devlink_fmsg_obj_nest_end (fmsg); +devlink_fmsg_pair_nest_end (fmsg); +devlink_fmsg_obj_nest_end (fmsg); +devlink_fmsg_pair_nest_end (fmsg); + +return 0 ; +} + void __printf(2, 3) fbnic_devlink_fw_report(struct fbnic_dev *fbd, const char *format, ...) {
@@ -503,6 +531,7 @@ fbnic_devlink_fw_report(struct fbnic_dev *fbd, const char *format, ...)static const struct devlink_health_reporter_ops fbnic_fw_ops = { .name ="fw" , .dump = fbnic_fw_reporter_dump, + .diagnose = fbnic_fw_reporter_diagnose, };int fbnic_devlink_health_create (struct fbnic_dev *fbd)
Signature · 1 line
2.51.0
Re: [PATCH net-next v3 8/9] eth: fbnic: report FW uptime in health diagnose
Quoted 10 lines · Jakub Kicinski
FW crashes are detected based on uptime going back, expose the uptime via devlink health diagnose.
$ devlink -j health diagnose pci/0000:01:00.0 reporter fw {"last_heartbeat":{"fw_uptime":{"sec":201,"msec":76}}} $ devlink -j health diagnose pci/0000:01:00.0 reporter fw last_heartbeat: fw_uptime: sec: 201 msec: 76
Quoted 2 lines
Reviewed-by Lee Trager <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>
Jakub Kicinski
maintainerPATCH v3 9/9 eth: fbnic: add OTP health reporter
In reply to Jakub KicinskiOTP memory ("fuses") are used for secure boot and anti-rollback protection. The OTP memory is ECC protected. Check for its health periodically to notice when the chip is starting to go bad.
--- .../device_drivers/ethernet/meta/fbnic.rst | 7 ++ drivers/net/ethernet/meta/fbnic/fbnic.h | 2 + drivers/net/ethernet/meta/fbnic/fbnic_csr.h | 18 +++++ .../net/ethernet/meta/fbnic/fbnic_devlink.c | 65 +++++++++++++++++++ drivers/net/ethernet/meta/fbnic/fbnic_pci.c | 5 ++ 5 files changed, 97 insertions(+)
Documentation/networking/device_drivers/ethernet/meta/fbnic.rst +7 -0
@@ -81,6 +81,13 @@ happened since power cycle - a snapshot of the FW memory. Diagnose callback shows FW uptime based on the most recently received heartbeat message (the crashes are detected by checking if uptime goes down). +otp reporter +~~~~~~~~~~~~ + +OTP memory ("fuses") are used for secure boot and anti-rollback +protection. The OTP memory is ECC protected, ECC errors indicate +either manufacturing defect or part deteriorating with age. + Statistics ----------
drivers/net/ethernet/meta/fbnic/fbnic.h +2 -0
@@ -28,6 +28,7 @@ struct fbnic_dev {struct dentry *dbg_fbd;struct device *hwmon;struct devlink_health_reporter *fw_reporter; +struct devlink_health_reporter *otp_reporter;u32 __iomem *uc_addr0;u32 __iomem *uc_addr4;
@@ -166,6 +167,7 @@ void fbnic_devlink_register(struct fbnic_dev *fbd);void fbnic_devlink_unregister (struct fbnic_dev *fbd); void __printf(2, 3) fbnic_devlink_fw_report(struct fbnic_dev *fbd, const char *format, ...); +void fbnic_devlink_otp_check(struct fbnic_dev *fbd, const char *msg); int fbnic_fw_request_mbx(struct fbnic_dev *fbd); void fbnic_fw_free_mbx(struct fbnic_dev *fbd);
drivers/net/ethernet/meta/fbnic/fbnic_csr.h +18 -0
@@ -1178,4 +1178,22 @@ enum {#define FBNIC_IPC_MBX_DESC_FW_CMPL DESC_BIT(1)#define FBNIC_IPC_MBX_DESC_HOST_CMPL DESC_BIT(0) +/* OTP Registers +* These registers are accessible via bar4 offset and are written by CMRT +* on boot. For the write status, the register is broken up in half with OTP +* Write Data Status occupying the top 16 bits and the ECC status occupying the +* bottom 16 bits. +*/ +#define FBNIC_NS_OTP_STATUS 0x0021d +#define FBNIC_NS_OTP_WRITE_STATUS 0x0021e + +#define FBNIC_NS_OTP_WRITE_DATA_STATUS_MASK CSR_GENMASK(31, 16) +#define FBNIC_NS_OTP_WRITE_ECC_STATUS_MASK CSR_GENMASK(15, 0) + +#define FBNIC_REGS_VERSION CSR_GENMASK(31, 16) +#define FBNIC_REGS_HW_TYPE CSR_GENMASK(15, 8) +enum { +FBNIC_CSR_VERSION_V1_0_ASIC =1 , +}; +#endif /* _FBNIC_CSR_H_ */
drivers/net/ethernet/meta/fbnic/fbnic_devlink.c +65 -0
82 lines not on this page · raw message
drivers/net/ethernet/meta/fbnic/fbnic_pci.c +5 -0
@@ -197,6 +197,7 @@ static void fbnic_health_check(struct fbnic_dev *fbd)return ;fbnic_devlink_fw_report (fbd,"Firmware crashed detected!" ); +fbnic_devlink_otp_check (fbd,"error detected after firmware recovery" );if (fbnic_fw_config_after_crash (fbd))dev_err (fbd->dev,"Firmware recovery failed after crash\n" );
@@ -322,6 +323,7 @@ static int fbnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err);fbnic_devlink_register (fbd); +fbnic_devlink_otp_check (fbd,"error detected during probe" );fbnic_dbg_fbd_init (fbd);/* Capture snapshot of hardware stats so netdev can calculate delta */
@@ -475,6 +477,9 @@ static int __fbnic_pm_resume(struct device *dev)*/ fbnic_fw_log_enable (fbd,list_empty (&fbd->fw_log.entries)); +/* Since the FW should be up, check if it reported OTP errors */ +fbnic_devlink_otp_check (fbd,"error detected after PM resume" ); +/* No netdev means there isn't a network interface to bring up */ if (fbnic_init_failure (fbd))return 0 ;
Signature · 1 line
2.51.0
Re: [PATCH net-next v3 9/9] eth: fbnic: add OTP health reporter
Quoted 5 lines · Jakub Kicinski
OTP memory ("fuses") are used for secure boot and anti-rollback protection. The OTP memory is ECC protected. Check for its health periodically to notice when the chip is starting to go bad.
Signed-off-by Jakub Kicinski <[email protected]>
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 21 lines · On Tue, 16 Sep 2025 16:14:11 -0700 you wrote:
Add support for FW crash detection and a corresponding devlink health reporter. Add a reporter for checking OTP memory health.
The output is not particularly exciting:
# devlink health show pci/0000:01:00.0: reporter fw state healthy error 0 recover 0 auto_dump true reporter otp state healthy error 0 recover 0 auto_dump true # devlink health diagnose pci/0000:01:00.0 reporter fw FW uptime: 0 # devlink health dump show pci/0000:01:00.0 reporter fw FW coredump: 5a 45 01 00 04 00 06 00 00 00 00 00 4d 01 00 d0 .. lots of hex follows .. # devlink health dump show pci/0000:01:00.0 reporter otp OTP: Status: 0 Data: 0 ECC: 0
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,v3,1/9] eth: fbnic: make fbnic_fw_log_write() parameter const
https://git.kernel.org/netdev/net-next/c/e6c8ab0a1129 - [net-next,v3,2/9] eth: fbnic: use fw uptime to detect fw crashes https://git.kernel.org/netdev/net-next/c/7fd1f7bac2b8 - [net-next,v3,3/9] eth: fbnic: factor out clearing the action TCAM https://git.kernel.org/netdev/net-next/c/504f8b7119eb - [net-next,v3,4/9] eth: fbnic: reprogram TCAMs after FW crash https://git.kernel.org/netdev/net-next/c/6ae7da8e9e06 - [net-next,v3,5/9] eth: fbnic: support allocating FW completions with extra space https://git.kernel.org/netdev/net-next/c/a8896d14fc0c - [net-next,v3,6/9] eth: fbnic: support FW communication for core dump https://git.kernel.org/netdev/net-next/c/5df1d0a08483 - [net-next,v3,7/9] eth: fbnic: add FW health reporter https://git.kernel.org/netdev/net-next/c/005a54722e9d - [net-next,v3,8/9] eth: fbnic: report FW uptime in health diagnose https://git.kernel.org/netdev/net-next/c/6da8344f92df - [net-next,v3,9/9] eth: fbnic: add OTP health reporter https://git.kernel.org/netdev/net-next/c/e6afcd60c26f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html