From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
andrew+netdev@lunn.ch, horms@kernel.org, alexanderduyck@fb.com,
lee@trager.us, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next v3 8/9] eth: fbnic: report FW uptime in health diagnose
Date: Tue, 16 Sep 2025 16:14:19 -0700 [thread overview]
Message-ID: <20250916231420.1693955-9-kuba@kernel.org> (raw)
In-Reply-To: <20250916231420.1693955-1-kuba@kernel.org>
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
Reviewed-by: Lee Trager <lee@trager.us>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
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(-)
diff --git a/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst b/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst
index 62693566ff1f..8b7ae9975bf7 100644
--- a/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst
+++ b/Documentation/networking/device_drivers/ethernet/meta/fbnic.rst
@@ -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
----------
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c b/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c
index 195245fb1a96..fd7df44ae7a4 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c
@@ -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)
--
2.51.0
next prev parent reply other threads:[~2025-09-16 23:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 23:14 [PATCH net-next v3 0/9] eth: fbnic: add devlink health support for FW crashes and OTP mem corruptions Jakub Kicinski
2025-09-16 23:14 ` [PATCH net-next v3 1/9] eth: fbnic: make fbnic_fw_log_write() parameter const Jakub Kicinski
2025-09-16 23:14 ` [PATCH net-next v3 2/9] eth: fbnic: use fw uptime to detect fw crashes Jakub Kicinski
2025-09-16 23:14 ` [PATCH net-next v3 3/9] eth: fbnic: factor out clearing the action TCAM Jakub Kicinski
2025-09-16 23:14 ` [PATCH net-next v3 4/9] eth: fbnic: reprogram TCAMs after FW crash Jakub Kicinski
2025-09-16 23:14 ` [PATCH net-next v3 5/9] eth: fbnic: support allocating FW completions with extra space Jakub Kicinski
2025-09-16 23:14 ` [PATCH net-next v3 6/9] eth: fbnic: support FW communication for core dump Jakub Kicinski
2025-09-16 23:14 ` [PATCH net-next v3 7/9] eth: fbnic: add FW health reporter Jakub Kicinski
2025-09-16 23:14 ` Jakub Kicinski [this message]
2025-09-17 16:08 ` [PATCH net-next v3 8/9] eth: fbnic: report FW uptime in health diagnose Simon Horman
2025-09-16 23:14 ` [PATCH net-next v3 9/9] eth: fbnic: add OTP health reporter Jakub Kicinski
2025-09-17 16:09 ` Simon Horman
2025-09-18 10:20 ` [PATCH net-next v3 0/9] eth: fbnic: add devlink health support for FW crashes and OTP mem corruptions patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250916231420.1693955-9-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=alexanderduyck@fb.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=lee@trager.us \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).