]> www.infradead.org Git - users/hch/misc.git/commitdiff
eth: fbnic: report FW uptime in health diagnose
authorJakub Kicinski <kuba@kernel.org>
Tue, 16 Sep 2025 23:14:19 +0000 (16:14 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 18 Sep 2025 09:37:23 +0000 (11:37 +0200)
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>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250916231420.1693955-9-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Documentation/networking/device_drivers/ethernet/meta/fbnic.rst
drivers/net/ethernet/meta/fbnic/fbnic_devlink.c

index 62693566ff1f2ce02b96f3ae99aa5ddd9e4f35f9..8b7ae9975bf7bf7c51d8d80b5c6ad0a8e70b4290 100644 (file)
@@ -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
 ----------
index 195245fb1a9689796a39c8d1668f2b8e5b5bcb34..fd7df44ae7a4697f82561c23c028563331bc2e82 100644 (file)
@@ -485,6 +485,34 @@ cmpl_free:
        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)