@@ -4,6 +4,7 @@
obj-$(CONFIG_PDS_CORE) := pds_core.o
pds_core-y := main.o \
+ devlink.o \
dev.o \
core.o
@@ -45,6 +45,8 @@ static void pdsc_fw_down(struct pdsc *pdsc)
return;
}
+ devlink_health_report(pdsc->fw_reporter, "FW down reported", pdsc);
+
pdsc_teardown(pdsc, PDSC_TEARDOWN_RECOVERY);
mutex_unlock(&pdsc->config_lock);
@@ -68,6 +70,10 @@ static void pdsc_fw_up(struct pdsc *pdsc)
mutex_unlock(&pdsc->config_lock);
+ pdsc->fw_recoveries++;
+ devlink_health_reporter_state_update(pdsc->fw_reporter,
+ DEVLINK_HEALTH_REPORTER_STATE_HEALTHY);
+
return;
err_out:
@@ -68,6 +68,8 @@ struct pdsc {
struct timer_list wdtimer;
unsigned int wdtimer_period;
struct work_struct health_work;
+ struct devlink_health_reporter *fw_reporter;
+ u32 fw_recoveries;
struct pdsc_devinfo dev_info;
struct pds_core_dev_identity dev_ident;
@@ -89,6 +91,9 @@ struct pdsc {
};
void pdsc_queue_health_check(struct pdsc *pdsc);
+int pdsc_fw_reporter_diagnose(struct devlink_health_reporter *reporter,
+ struct devlink_fmsg *fmsg,
+ struct netlink_ext_ack *extack);
#ifdef CONFIG_DEBUG_FS
void pdsc_debugfs_create(void);
new file mode 100644
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright(c) 2023 Advanced Micro Devices, Inc */
+
+#include "core.h"
+
+int pdsc_fw_reporter_diagnose(struct devlink_health_reporter *reporter,
+ struct devlink_fmsg *fmsg,
+ struct netlink_ext_ack *extack)
+{
+ struct pdsc *pdsc = devlink_health_reporter_priv(reporter);
+ int err = 0;
+
+ if (test_bit(PDSC_S_FW_DEAD, &pdsc->state))
+ err = devlink_fmsg_string_pair_put(fmsg, "Status", "dead");
+ else if (!pdsc_is_fw_good(pdsc))
+ err = devlink_fmsg_string_pair_put(fmsg, "Status", "unhealthy");
+ else
+ err = devlink_fmsg_string_pair_put(fmsg, "Status", "healthy");
+ if (err)
+ return err;
+
+ err = devlink_fmsg_u32_pair_put(fmsg, "State",
+ pdsc->fw_status &
+ ~PDS_CORE_FW_STS_F_GENERATION);
+ if (err)
+ return err;
+ err = devlink_fmsg_u32_pair_put(fmsg, "Generation",
+ pdsc->fw_generation >> 4);
+ if (err)
+ return err;
+ err = devlink_fmsg_u32_pair_put(fmsg, "Recoveries",
+ pdsc->fw_recoveries);
+ if (err)
+ return err;
+
+ return 0;
+}
@@ -162,10 +162,16 @@ static int pdsc_init_vf(struct pdsc *vf)
return -1;
}
+static const struct devlink_health_reporter_ops pdsc_fw_reporter_ops = {
+ .name = "fw",
+ .diagnose = pdsc_fw_reporter_diagnose,
+};
+
#define PDSC_WQ_NAME_LEN 24
static int pdsc_init_pf(struct pdsc *pdsc)
{
+ struct devlink_health_reporter *hr;
char wq_name[PDSC_WQ_NAME_LEN];
struct devlink *dl;
int err;
@@ -204,6 +210,16 @@ static int pdsc_init_pf(struct pdsc *pdsc)
dl = priv_to_devlink(pdsc);
devl_lock(dl);
+
+ hr = devl_health_reporter_create(dl, &pdsc_fw_reporter_ops, 0, pdsc);
+ if (IS_ERR(hr)) {
+ dev_warn(pdsc->dev, "Failed to create fw reporter: %pe\n", hr);
+ err = PTR_ERR(hr);
+ devl_unlock(dl);
+ goto err_out_teardown;
+ }
+ pdsc->fw_reporter = hr;
+
devl_register(dl);
devl_unlock(dl);
@@ -212,6 +228,8 @@ static int pdsc_init_pf(struct pdsc *pdsc)
return 0;
+err_out_teardown:
+ pdsc_teardown(pdsc, PDSC_TEARDOWN_REMOVING);
err_out_unmap_bars:
mutex_unlock(&pdsc->config_lock);
del_timer_sync(&pdsc->wdtimer);
@@ -318,6 +336,10 @@ static void pdsc_remove(struct pci_dev *pdev)
dl = priv_to_devlink(pdsc);
devl_lock(dl);
devl_unregister(dl);
+ if (pdsc->fw_reporter) {
+ devl_health_reporter_destroy(pdsc->fw_reporter);
+ pdsc->fw_reporter = NULL;
+ }
devl_unlock(dl);
if (!pdev->is_virtfn) {
Add devlink health reporting on top of our fw watchdog. Example: # devlink health show pci/0000:2b:00.0 reporter fw pci/0000:2b:00.0: reporter fw state healthy error 0 recover 0 Signed-off-by: Shannon Nelson <shannon.nelson@amd.com> --- drivers/net/ethernet/amd/pds_core/Makefile | 1 + drivers/net/ethernet/amd/pds_core/core.c | 6 ++++ drivers/net/ethernet/amd/pds_core/core.h | 5 +++ drivers/net/ethernet/amd/pds_core/devlink.c | 37 +++++++++++++++++++++ drivers/net/ethernet/amd/pds_core/main.c | 22 ++++++++++++ 5 files changed, 71 insertions(+) create mode 100644 drivers/net/ethernet/amd/pds_core/devlink.c