eth: fbnic: add devlink health support for FW crashes and OTP mem corruptions
Subsystems (4)
Jakub Kicinski
maintainerv2 cover eth: fbnic: add devlink health support for FW crashes and OTP mem corruptions
Add support for FW crash detection and a corresponding delink 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: 0v2:
- [patch 2] fix attr ID
- [patch 2] comment and commit msg adjustments
v1: https://lore.kernel.org/all/[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 | 235 +++++++++++++++++ drivers/net/ethernet/meta/fbnic/fbnic_fw.c | 239 +++++++++++++++++- .../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, 643 insertions(+), 28 deletions(-)
Signature · 1 line
2.51.0
Jakub Kicinski
maintainerPATCH v2 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
Re: [PATCH net-next v2 1/9] eth: fbnic: make fbnic_fw_log_write() parameter const
Quoted 4 lines · Jakub Kicinski
Make the log message parameter const, it's not modified and this lets us pass in strings which are const for the caller.
Signed-off-by Jakub Kicinski <[email protected]>
Jakub Kicinski
maintainerPATCH v2 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).
---
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 | 15 ++++++++++++++- 3 files changed, 25 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 +14 -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;
@@ -671,6 +676,9 @@ 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 ; }
@@ -685,6 +693,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 +717,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 +778,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
Re: [PATCH net-next v2 2/9] eth: fbnic: use fw uptime to detect fw crashes
Quoted 6 lines · Jakub Kicinski
Currently 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).
Quoted 7 lines
Signed-off-by Jakub Kicinski <[email protected]>---
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]
Thanks for the updates.
Jakub Kicinski
maintainerPATCH v2 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
Re: [PATCH net-next v2 3/9] eth: fbnic: factor out clearing the action TCAM
Quoted 5 lines · Jakub Kicinski
We'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.
Signed-off-by Jakub Kicinski <[email protected]>
Jakub Kicinski
maintainerPATCH v2 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
Re: [PATCH net-next v2 4/9] eth: fbnic: reprogram TCAMs after FW crash
Quoted 6 lines · Jakub Kicinski
FW 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.
Signed-off-by Jakub Kicinski <[email protected]>
Jakub Kicinski
maintainerPATCH v2 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
@@ -1542,11 +1542,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 ;
@@ -1557,6 +1558,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
Re: [PATCH net-next v2 5/9] eth: fbnic: support allocating FW completions with extra space
Quoted 6 lines · Jakub Kicinski
Support 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).
Signed-off-by Jakub Kicinski <[email protected]>
Jakub Kicinski
maintainerPATCH v2 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
Re: [PATCH net-next v2 6/9] eth: fbnic: support FW communication for core dump
Quoted 8 lines · Jakub Kicinski
To 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 chunkImplement these two FW commands. Subsequent commits will use them to expose FW dump via devlink heath.
Signed-off-by Jakub Kicinski <[email protected]>
Jakub Kicinski
maintainerPATCH v2 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.
--- .../device_drivers/ethernet/meta/fbnic.rst | 10 ++ drivers/net/ethernet/meta/fbnic/fbnic.h | 5 + .../net/ethernet/meta/fbnic/fbnic_devlink.c | 157 ++++++++++++++++++ drivers/net/ethernet/meta/fbnic/fbnic_pci.c | 11 +- 4 files changed, 182 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 +157 -0
169 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
Re: [PATCH net-next v2 7/9] eth: fbnic: add FW health reporter
Quoted 4 lines · Jakub Kicinski
Add a health reporter to catch FW crashes. Dumping the reporter if FW has not crashed will create a snapshot of FW memory.
Signed-off-by Jakub Kicinski <[email protected]>
Jakub Kicinski
maintainerPATCH v2 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.
--- .../device_drivers/ethernet/meta/fbnic.rst | 4 +++- drivers/net/ethernet/meta/fbnic/fbnic_devlink.c | 13 +++++++++++++ 2 files changed, 16 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 current FW uptime (the crashes are detected by checking if uptime +goes down). Statistics ----------
drivers/net/ethernet/meta/fbnic/fbnic_devlink.c +13 -0
@@ -487,6 +487,18 @@ 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); + +devlink_fmsg_u32_pair_put (fmsg,"FW uptime" , fbd->firmware_time); + +return 0 ; +} + void __printf(2, 3) fbnic_devlink_fw_report(struct fbnic_dev *fbd, const char *format, ...) {
@@ -505,6 +517,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 v2 8/9] eth: fbnic: report FW uptime in health diagnose
Quoted 14 lines · Jakub Kicinski
FW crashes are detected based on uptime going back, expose the uptime via devlink health diagnose.
Signed-off-by Jakub Kicinski <[email protected]>--- .../device_drivers/ethernet/meta/fbnic.rst | 4 +++- drivers/net/ethernet/meta/fbnic/fbnic_devlink.c | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)Documentation/networking/device_drivers/ethernet/meta/fbnic.rst +0
-0
Documentation/networking/device_drivers/ethernet/meta/fbnic.rst fw reporter · line 82
Quoted 7 lines
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 current FW uptime (the crashes are detected by checking if uptime +goes down).
I was a little surprised to see this since it didn't go through our normal internal review and validation process.
Quoted 9 lines
Documentation/networking/device_drivers/ethernet/meta/fbnic.rst +0
-0Statistics ----------drivers/net/ethernet/meta/fbnic/fbnic_devlink.c +0
-0@@ -487,6 +487,18 @@ static int fbnic_fw_reporter_dump(struct devlink_health_reporter *reporter,return err;
drivers/net/ethernet/meta/fbnic/fbnic_devlink.c static int fbnic_fw_reporter_dump(struct devlink_health_reporter *reporter, · line 497
Quoted 10 lines
drivers/net/ethernet/meta/fbnic/fbnic_devlink.c +8
-0} +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); + +devlink_fmsg_u32_pair_put (fmsg,"FW uptime" , fbd->firmware_time);
I originally added fbd->firmware_time as part of the implementation for logging support in D51521853. The original idea was to correlate firmware logs to host time. This proved to be difficult. Instead I used firmware time to detect firmware crashes in D52065019. Time is to set 0 when fbnic_fw_log_write() is called in fbnic_devlink_fw_report() because we don't know the actual time firmware crashed. fbd->firmware_time is only updated with the heartbeat is received. When a crash occurs fbd->firmware_time is reset once firmware comes back up. Ignoring the crash case this should be something like fbd->firmware_time + (jiffies - fbd->last_heartbeat_req) * 1000.
Another issue is your using a u32 for fbd->firmware_time which is u64. Firmware returns its time by calling k_uptime_get()[1] which returns an s64 as its the firmware uptime in milliseconds.
We also don't use firmware time in its raw integer form anywhere in the driver or firmware. Its very hard to read FBNIC_FW_LOG_FMT has the format used in the driver which is based on what Zephyr uses[2].
IMO this doesn't really have a use case and I would just drop it.
[1] https://elixir.bootlin.com/zephyr/v3.7.1/source/include/zephyr/kernel.h#L1751
[2] https://github.com/zephyrproject-rtos/zephyr/blob/main/subsys/logging/log_output.c#L263
Jakub Kicinski
maintainerRe: [PATCH net-next v2 8/9] eth: fbnic: report FW uptime in health diagnose
Quoted 10 lines · On Mon, 15 Sep 2025 18:35:40 -0700 Lee Trager wrote:
Quoted 10 lines
Statistics
----------drivers/net/ethernet/meta/fbnic/fbnic_devlink.c +0
-0@@ -487,6 +487,18 @@ static int fbnic_fw_reporter_dump(struct devlink_health_reporter *reporter,return err; }
Quoted 15 lines
drivers/net/ethernet/meta/fbnic/fbnic_devlink.c static int fbnic_fw_reporter_dump(struct devlink_health_reporter *reporter, · line 497
Quoted 8 lines
drivers/net/ethernet/meta/fbnic/fbnic_devlink.c +8
-0+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); + +devlink_fmsg_u32_pair_put (fmsg,"FW uptime" , fbd->firmware_time);I originally added
fbd->firmware_timeas part of the implementation for logging support in D51521853. The original idea was to correlate firmware logs to host time. This proved to be difficult. Instead I used firmware time to detect firmware crashes in D52065019. Time is to set 0 whenfbnic_fw_log_write()is called infbnic_devlink_fw_report()because we don't know the actual time firmware crashed.
I don't see this in my series.
Quoted 5 lines
fbd->firmware_timeis
only updated with the heartbeat is received. When a crash occursfbd->firmware_timeis reset once firmware comes back up. Ignoring the crash case this should be something likefbd->firmware_time+ (jiffies -fbd->last_heartbeat_req) * 1000.
I don't understand what you're getting at, TBH.
Quoted 3 lines
Another issue is your using a u32 for
fbd->firmware_timewhich is u64. Firmware returns its time by calling k_uptime_get()[1] which returns an s64 as its the firmware uptime in milliseconds.
Ah, good point.
Quoted 5 lines
We also don't use firmware time in its raw integer form anywhere in the driver or firmware. Its very hard to read
FBNIC_FW_LOG_FMThas the format used in the driver which is based on what Zephyr uses[2].IMO this doesn't really have a use case and I would just drop it.
Knowing FW uptime is very useful in multi-host systems. NIC get into bad state and digging up when the last NIC power cycle happened from orchestration datasets is a PITA.
Jakub Kicinski
maintainerPATCH v2 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 current FW uptime (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