Commit a10f9bfe authored by David S. Miller's avatar David S. Miller

Merge branch 'devlink-errors-fmsg'

Przemek Kitszel says:

====================
devlink: retain error in struct devlink_fmsg

Extend devlink fmsg to retain error (patch 1),
so drivers could omit error checks after devlink_fmsg_*() (patches 2-10),
and finally enforce future uses to follow this practice by change to
return void (patch 11)

Note that it was compile tested only.

bloat-o-meter for whole series:
add/remove: 8/18 grow/shrink: 23/40 up/down: 2017/-5833 (-3816)
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 7ce69360 0050629c
...@@ -154,33 +154,20 @@ int pdsc_fw_reporter_diagnose(struct devlink_health_reporter *reporter, ...@@ -154,33 +154,20 @@ int pdsc_fw_reporter_diagnose(struct devlink_health_reporter *reporter,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct pdsc *pdsc = devlink_health_reporter_priv(reporter); struct pdsc *pdsc = devlink_health_reporter_priv(reporter);
int err;
mutex_lock(&pdsc->config_lock); mutex_lock(&pdsc->config_lock);
if (test_bit(PDSC_S_FW_DEAD, &pdsc->state)) if (test_bit(PDSC_S_FW_DEAD, &pdsc->state))
err = devlink_fmsg_string_pair_put(fmsg, "Status", "dead"); devlink_fmsg_string_pair_put(fmsg, "Status", "dead");
else if (!pdsc_is_fw_good(pdsc)) else if (!pdsc_is_fw_good(pdsc))
err = devlink_fmsg_string_pair_put(fmsg, "Status", "unhealthy"); devlink_fmsg_string_pair_put(fmsg, "Status", "unhealthy");
else else
err = devlink_fmsg_string_pair_put(fmsg, "Status", "healthy"); devlink_fmsg_string_pair_put(fmsg, "Status", "healthy");
mutex_unlock(&pdsc->config_lock); mutex_unlock(&pdsc->config_lock);
if (err) devlink_fmsg_u32_pair_put(fmsg, "State",
return err; pdsc->fw_status & ~PDS_CORE_FW_STS_F_GENERATION);
devlink_fmsg_u32_pair_put(fmsg, "Generation", pdsc->fw_generation >> 4);
err = devlink_fmsg_u32_pair_put(fmsg, "State", devlink_fmsg_u32_pair_put(fmsg, "Recoveries", pdsc->fw_recoveries);
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;
return devlink_fmsg_u32_pair_put(fmsg, "Recoveries", return 0;
pdsc->fw_recoveries);
} }
...@@ -104,20 +104,21 @@ static int bnxt_fw_diagnose(struct devlink_health_reporter *reporter, ...@@ -104,20 +104,21 @@ static int bnxt_fw_diagnose(struct devlink_health_reporter *reporter,
struct bnxt *bp = devlink_health_reporter_priv(reporter); struct bnxt *bp = devlink_health_reporter_priv(reporter);
struct bnxt_fw_health *h = bp->fw_health; struct bnxt_fw_health *h = bp->fw_health;
u32 fw_status, fw_resets; u32 fw_status, fw_resets;
int rc;
if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) {
return devlink_fmsg_string_pair_put(fmsg, "Status", "recovering"); devlink_fmsg_string_pair_put(fmsg, "Status", "recovering");
return 0;
}
if (!h->status_reliable) if (!h->status_reliable) {
return devlink_fmsg_string_pair_put(fmsg, "Status", "unknown"); devlink_fmsg_string_pair_put(fmsg, "Status", "unknown");
return 0;
}
mutex_lock(&h->lock); mutex_lock(&h->lock);
fw_status = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG); fw_status = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG);
if (BNXT_FW_IS_BOOTING(fw_status)) { if (BNXT_FW_IS_BOOTING(fw_status)) {
rc = devlink_fmsg_string_pair_put(fmsg, "Status", "initializing"); devlink_fmsg_string_pair_put(fmsg, "Status", "initializing");
if (rc)
goto unlock;
} else if (h->severity || fw_status != BNXT_FW_STATUS_HEALTHY) { } else if (h->severity || fw_status != BNXT_FW_STATUS_HEALTHY) {
if (!h->severity) { if (!h->severity) {
h->severity = SEVERITY_FATAL; h->severity = SEVERITY_FATAL;
...@@ -126,58 +127,35 @@ static int bnxt_fw_diagnose(struct devlink_health_reporter *reporter, ...@@ -126,58 +127,35 @@ static int bnxt_fw_diagnose(struct devlink_health_reporter *reporter,
devlink_health_report(h->fw_reporter, devlink_health_report(h->fw_reporter,
"FW error diagnosed", h); "FW error diagnosed", h);
} }
rc = devlink_fmsg_string_pair_put(fmsg, "Status", "error"); devlink_fmsg_string_pair_put(fmsg, "Status", "error");
if (rc) devlink_fmsg_u32_pair_put(fmsg, "Syndrome", fw_status);
goto unlock;
rc = devlink_fmsg_u32_pair_put(fmsg, "Syndrome", fw_status);
if (rc)
goto unlock;
} else { } else {
rc = devlink_fmsg_string_pair_put(fmsg, "Status", "healthy"); devlink_fmsg_string_pair_put(fmsg, "Status", "healthy");
if (rc)
goto unlock;
} }
rc = devlink_fmsg_string_pair_put(fmsg, "Severity", devlink_fmsg_string_pair_put(fmsg, "Severity",
bnxt_health_severity_str(h->severity)); bnxt_health_severity_str(h->severity));
if (rc)
goto unlock;
if (h->severity) { if (h->severity) {
rc = devlink_fmsg_string_pair_put(fmsg, "Remedy", devlink_fmsg_string_pair_put(fmsg, "Remedy",
bnxt_health_remedy_str(h->remedy)); bnxt_health_remedy_str(h->remedy));
if (rc) if (h->remedy == REMEDY_DEVLINK_RECOVER)
goto unlock; devlink_fmsg_string_pair_put(fmsg, "Impact",
if (h->remedy == REMEDY_DEVLINK_RECOVER) {
rc = devlink_fmsg_string_pair_put(fmsg, "Impact",
"traffic+ntuple_cfg"); "traffic+ntuple_cfg");
if (rc)
goto unlock;
}
} }
unlock:
mutex_unlock(&h->lock); mutex_unlock(&h->lock);
if (rc || !h->resets_reliable) if (!h->resets_reliable)
return rc; return 0;
fw_resets = bnxt_fw_health_readl(bp, BNXT_FW_RESET_CNT_REG); fw_resets = bnxt_fw_health_readl(bp, BNXT_FW_RESET_CNT_REG);
rc = devlink_fmsg_u32_pair_put(fmsg, "Resets", fw_resets); devlink_fmsg_u32_pair_put(fmsg, "Resets", fw_resets);
if (rc) devlink_fmsg_u32_pair_put(fmsg, "Arrests", h->arrests);
return rc; devlink_fmsg_u32_pair_put(fmsg, "Survivals", h->survivals);
rc = devlink_fmsg_u32_pair_put(fmsg, "Arrests", h->arrests); devlink_fmsg_u32_pair_put(fmsg, "Discoveries", h->discoveries);
if (rc) devlink_fmsg_u32_pair_put(fmsg, "Fatalities", h->fatalities);
return rc; devlink_fmsg_u32_pair_put(fmsg, "Diagnoses", h->diagnoses);
rc = devlink_fmsg_u32_pair_put(fmsg, "Survivals", h->survivals); return 0;
if (rc)
return rc;
rc = devlink_fmsg_u32_pair_put(fmsg, "Discoveries", h->discoveries);
if (rc)
return rc;
rc = devlink_fmsg_u32_pair_put(fmsg, "Fatalities", h->fatalities);
if (rc)
return rc;
return devlink_fmsg_u32_pair_put(fmsg, "Diagnoses", h->diagnoses);
} }
static int bnxt_fw_dump(struct devlink_health_reporter *reporter, static int bnxt_fw_dump(struct devlink_health_reporter *reporter,
...@@ -203,19 +181,12 @@ static int bnxt_fw_dump(struct devlink_health_reporter *reporter, ...@@ -203,19 +181,12 @@ static int bnxt_fw_dump(struct devlink_health_reporter *reporter,
rc = bnxt_get_coredump(bp, BNXT_DUMP_LIVE, data, &dump_len); rc = bnxt_get_coredump(bp, BNXT_DUMP_LIVE, data, &dump_len);
if (!rc) { if (!rc) {
rc = devlink_fmsg_pair_nest_start(fmsg, "core"); devlink_fmsg_pair_nest_start(fmsg, "core");
if (rc) devlink_fmsg_binary_pair_put(fmsg, "data", data, dump_len);
goto exit; devlink_fmsg_u32_pair_put(fmsg, "size", dump_len);
rc = devlink_fmsg_binary_pair_put(fmsg, "data", data, dump_len); devlink_fmsg_pair_nest_end(fmsg);
if (rc)
goto exit;
rc = devlink_fmsg_u32_pair_put(fmsg, "size", dump_len);
if (rc)
goto exit;
rc = devlink_fmsg_pair_nest_end(fmsg);
} }
exit:
vfree(data); vfree(data);
return rc; return rc;
} }
......
...@@ -315,136 +315,76 @@ void hinic_devlink_unregister(struct hinic_devlink_priv *priv) ...@@ -315,136 +315,76 @@ void hinic_devlink_unregister(struct hinic_devlink_priv *priv)
devlink_unregister(devlink); devlink_unregister(devlink);
} }
static int chip_fault_show(struct devlink_fmsg *fmsg, static void chip_fault_show(struct devlink_fmsg *fmsg,
struct hinic_fault_event *event) struct hinic_fault_event *event)
{ {
const char * const level_str[FAULT_LEVEL_MAX + 1] = { const char * const level_str[FAULT_LEVEL_MAX + 1] = {
"fatal", "reset", "flr", "general", "suggestion", "Unknown"}; "fatal", "reset", "flr", "general", "suggestion", "Unknown"};
u8 fault_level; u8 fault_level;
int err;
fault_level = (event->event.chip.err_level < FAULT_LEVEL_MAX) ? fault_level = (event->event.chip.err_level < FAULT_LEVEL_MAX) ?
event->event.chip.err_level : FAULT_LEVEL_MAX; event->event.chip.err_level : FAULT_LEVEL_MAX;
if (fault_level == FAULT_LEVEL_SERIOUS_FLR) { if (fault_level == FAULT_LEVEL_SERIOUS_FLR)
err = devlink_fmsg_u32_pair_put(fmsg, "Function level err func_id", devlink_fmsg_u32_pair_put(fmsg, "Function level err func_id",
(u32)event->event.chip.func_id); (u32)event->event.chip.func_id);
if (err) devlink_fmsg_u8_pair_put(fmsg, "module_id", event->event.chip.node_id);
return err; devlink_fmsg_u32_pair_put(fmsg, "err_type", (u32)event->event.chip.err_type);
} devlink_fmsg_string_pair_put(fmsg, "err_level", level_str[fault_level]);
devlink_fmsg_u32_pair_put(fmsg, "err_csr_addr",
err = devlink_fmsg_u8_pair_put(fmsg, "module_id", event->event.chip.node_id);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "err_type", (u32)event->event.chip.err_type);
if (err)
return err;
err = devlink_fmsg_string_pair_put(fmsg, "err_level", level_str[fault_level]);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "err_csr_addr",
event->event.chip.err_csr_addr); event->event.chip.err_csr_addr);
if (err) devlink_fmsg_u32_pair_put(fmsg, "err_csr_value",
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "err_csr_value",
event->event.chip.err_csr_value); event->event.chip.err_csr_value);
if (err)
return err;
return 0;
} }
static int fault_report_show(struct devlink_fmsg *fmsg, static void fault_report_show(struct devlink_fmsg *fmsg,
struct hinic_fault_event *event) struct hinic_fault_event *event)
{ {
const char * const type_str[FAULT_TYPE_MAX + 1] = { const char * const type_str[FAULT_TYPE_MAX + 1] = {
"chip", "ucode", "mem rd timeout", "mem wr timeout", "chip", "ucode", "mem rd timeout", "mem wr timeout",
"reg rd timeout", "reg wr timeout", "phy fault", "Unknown"}; "reg rd timeout", "reg wr timeout", "phy fault", "Unknown"};
u8 fault_type; u8 fault_type;
int err;
fault_type = (event->type < FAULT_TYPE_MAX) ? event->type : FAULT_TYPE_MAX; fault_type = (event->type < FAULT_TYPE_MAX) ? event->type : FAULT_TYPE_MAX;
err = devlink_fmsg_string_pair_put(fmsg, "Fault type", type_str[fault_type]); devlink_fmsg_string_pair_put(fmsg, "Fault type", type_str[fault_type]);
if (err) devlink_fmsg_binary_pair_put(fmsg, "Fault raw data", event->event.val,
return err; sizeof(event->event.val));
err = devlink_fmsg_binary_pair_put(fmsg, "Fault raw data",
event->event.val, sizeof(event->event.val));
if (err)
return err;
switch (event->type) { switch (event->type) {
case FAULT_TYPE_CHIP: case FAULT_TYPE_CHIP:
err = chip_fault_show(fmsg, event); chip_fault_show(fmsg, event);
if (err)
return err;
break; break;
case FAULT_TYPE_UCODE: case FAULT_TYPE_UCODE:
err = devlink_fmsg_u8_pair_put(fmsg, "Cause_id", event->event.ucode.cause_id); devlink_fmsg_u8_pair_put(fmsg, "Cause_id", event->event.ucode.cause_id);
if (err) devlink_fmsg_u8_pair_put(fmsg, "core_id", event->event.ucode.core_id);
return err; devlink_fmsg_u8_pair_put(fmsg, "c_id", event->event.ucode.c_id);
err = devlink_fmsg_u8_pair_put(fmsg, "core_id", event->event.ucode.core_id); devlink_fmsg_u8_pair_put(fmsg, "epc", event->event.ucode.epc);
if (err)
return err;
err = devlink_fmsg_u8_pair_put(fmsg, "c_id", event->event.ucode.c_id);
if (err)
return err;
err = devlink_fmsg_u8_pair_put(fmsg, "epc", event->event.ucode.epc);
if (err)
return err;
break; break;
case FAULT_TYPE_MEM_RD_TIMEOUT: case FAULT_TYPE_MEM_RD_TIMEOUT:
case FAULT_TYPE_MEM_WR_TIMEOUT: case FAULT_TYPE_MEM_WR_TIMEOUT:
err = devlink_fmsg_u32_pair_put(fmsg, "Err_csr_ctrl", devlink_fmsg_u32_pair_put(fmsg, "Err_csr_ctrl",
event->event.mem_timeout.err_csr_ctrl); event->event.mem_timeout.err_csr_ctrl);
if (err) devlink_fmsg_u32_pair_put(fmsg, "err_csr_data",
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "err_csr_data",
event->event.mem_timeout.err_csr_data); event->event.mem_timeout.err_csr_data);
if (err) devlink_fmsg_u32_pair_put(fmsg, "ctrl_tab",
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "ctrl_tab",
event->event.mem_timeout.ctrl_tab); event->event.mem_timeout.ctrl_tab);
if (err) devlink_fmsg_u32_pair_put(fmsg, "mem_index",
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "mem_index",
event->event.mem_timeout.mem_index); event->event.mem_timeout.mem_index);
if (err)
return err;
break; break;
case FAULT_TYPE_REG_RD_TIMEOUT: case FAULT_TYPE_REG_RD_TIMEOUT:
case FAULT_TYPE_REG_WR_TIMEOUT: case FAULT_TYPE_REG_WR_TIMEOUT:
err = devlink_fmsg_u32_pair_put(fmsg, "Err_csr", event->event.reg_timeout.err_csr); devlink_fmsg_u32_pair_put(fmsg, "Err_csr", event->event.reg_timeout.err_csr);
if (err)
return err;
break; break;
case FAULT_TYPE_PHY_FAULT: case FAULT_TYPE_PHY_FAULT:
err = devlink_fmsg_u8_pair_put(fmsg, "Op_type", event->event.phy_fault.op_type); devlink_fmsg_u8_pair_put(fmsg, "Op_type", event->event.phy_fault.op_type);
if (err) devlink_fmsg_u8_pair_put(fmsg, "port_id", event->event.phy_fault.port_id);
return err; devlink_fmsg_u8_pair_put(fmsg, "dev_ad", event->event.phy_fault.dev_ad);
err = devlink_fmsg_u8_pair_put(fmsg, "port_id", event->event.phy_fault.port_id); devlink_fmsg_u32_pair_put(fmsg, "csr_addr", event->event.phy_fault.csr_addr);
if (err) devlink_fmsg_u32_pair_put(fmsg, "op_data", event->event.phy_fault.op_data);
return err;
err = devlink_fmsg_u8_pair_put(fmsg, "dev_ad", event->event.phy_fault.dev_ad);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "csr_addr", event->event.phy_fault.csr_addr);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "op_data", event->event.phy_fault.op_data);
if (err)
return err;
break; break;
default: default:
break; break;
} }
return 0;
} }
static int hinic_hw_reporter_dump(struct devlink_health_reporter *reporter, static int hinic_hw_reporter_dump(struct devlink_health_reporter *reporter,
...@@ -452,75 +392,30 @@ static int hinic_hw_reporter_dump(struct devlink_health_reporter *reporter, ...@@ -452,75 +392,30 @@ static int hinic_hw_reporter_dump(struct devlink_health_reporter *reporter,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
if (priv_ctx) if (priv_ctx)
return fault_report_show(fmsg, priv_ctx); fault_report_show(fmsg, priv_ctx);
return 0; return 0;
} }
static int mgmt_watchdog_report_show(struct devlink_fmsg *fmsg, static void mgmt_watchdog_report_show(struct devlink_fmsg *fmsg,
struct hinic_mgmt_watchdog_info *watchdog_info) struct hinic_mgmt_watchdog_info *winfo)
{ {
int err; devlink_fmsg_u32_pair_put(fmsg, "Mgmt deadloop time_h", winfo->curr_time_h);
devlink_fmsg_u32_pair_put(fmsg, "time_l", winfo->curr_time_l);
err = devlink_fmsg_u32_pair_put(fmsg, "Mgmt deadloop time_h", watchdog_info->curr_time_h); devlink_fmsg_u32_pair_put(fmsg, "task_id", winfo->task_id);
if (err) devlink_fmsg_u32_pair_put(fmsg, "sp", winfo->sp);
return err; devlink_fmsg_u32_pair_put(fmsg, "stack_current_used", winfo->curr_used);
devlink_fmsg_u32_pair_put(fmsg, "peak_used", winfo->peak_used);
err = devlink_fmsg_u32_pair_put(fmsg, "time_l", watchdog_info->curr_time_l); devlink_fmsg_u32_pair_put(fmsg, "\n Overflow_flag", winfo->is_overflow);
if (err) devlink_fmsg_u32_pair_put(fmsg, "stack_top", winfo->stack_top);
return err; devlink_fmsg_u32_pair_put(fmsg, "stack_bottom", winfo->stack_bottom);
devlink_fmsg_u32_pair_put(fmsg, "mgmt_pc", winfo->pc);
err = devlink_fmsg_u32_pair_put(fmsg, "task_id", watchdog_info->task_id); devlink_fmsg_u32_pair_put(fmsg, "lr", winfo->lr);
if (err) devlink_fmsg_u32_pair_put(fmsg, "cpsr", winfo->cpsr);
return err; devlink_fmsg_binary_pair_put(fmsg, "Mgmt register info", winfo->reg,
sizeof(winfo->reg));
err = devlink_fmsg_u32_pair_put(fmsg, "sp", watchdog_info->sp); devlink_fmsg_binary_pair_put(fmsg, "Mgmt dump stack(start from sp)",
if (err) winfo->data, sizeof(winfo->data));
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "stack_current_used", watchdog_info->curr_used);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "peak_used", watchdog_info->peak_used);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "\n Overflow_flag", watchdog_info->is_overflow);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "stack_top", watchdog_info->stack_top);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "stack_bottom", watchdog_info->stack_bottom);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "mgmt_pc", watchdog_info->pc);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "lr", watchdog_info->lr);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "cpsr", watchdog_info->cpsr);
if (err)
return err;
err = devlink_fmsg_binary_pair_put(fmsg, "Mgmt register info",
watchdog_info->reg, sizeof(watchdog_info->reg));
if (err)
return err;
err = devlink_fmsg_binary_pair_put(fmsg, "Mgmt dump stack(start from sp)",
watchdog_info->data, sizeof(watchdog_info->data));
if (err)
return err;
return 0;
} }
static int hinic_fw_reporter_dump(struct devlink_health_reporter *reporter, static int hinic_fw_reporter_dump(struct devlink_health_reporter *reporter,
...@@ -528,7 +423,7 @@ static int hinic_fw_reporter_dump(struct devlink_health_reporter *reporter, ...@@ -528,7 +423,7 @@ static int hinic_fw_reporter_dump(struct devlink_health_reporter *reporter,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
if (priv_ctx) if (priv_ctx)
return mgmt_watchdog_report_show(fmsg, priv_ctx); mgmt_watchdog_report_show(fmsg, priv_ctx);
return 0; return 0;
} }
......
...@@ -889,36 +889,16 @@ int mlx5_fw_tracer_trigger_core_dump_general(struct mlx5_core_dev *dev) ...@@ -889,36 +889,16 @@ int mlx5_fw_tracer_trigger_core_dump_general(struct mlx5_core_dev *dev)
return 0; return 0;
} }
static int static void
mlx5_devlink_fmsg_fill_trace(struct devlink_fmsg *fmsg, mlx5_devlink_fmsg_fill_trace(struct devlink_fmsg *fmsg,
struct mlx5_fw_trace_data *trace_data) struct mlx5_fw_trace_data *trace_data)
{ {
int err; devlink_fmsg_obj_nest_start(fmsg);
devlink_fmsg_u64_pair_put(fmsg, "timestamp", trace_data->timestamp);
err = devlink_fmsg_obj_nest_start(fmsg); devlink_fmsg_bool_pair_put(fmsg, "lost", trace_data->lost);
if (err) devlink_fmsg_u8_pair_put(fmsg, "event_id", trace_data->event_id);
return err; devlink_fmsg_string_pair_put(fmsg, "msg", trace_data->msg);
devlink_fmsg_obj_nest_end(fmsg);
err = devlink_fmsg_u64_pair_put(fmsg, "timestamp", trace_data->timestamp);
if (err)
return err;
err = devlink_fmsg_bool_pair_put(fmsg, "lost", trace_data->lost);
if (err)
return err;
err = devlink_fmsg_u8_pair_put(fmsg, "event_id", trace_data->event_id);
if (err)
return err;
err = devlink_fmsg_string_pair_put(fmsg, "msg", trace_data->msg);
if (err)
return err;
err = devlink_fmsg_obj_nest_end(fmsg);
if (err)
return err;
return 0;
} }
int mlx5_fw_tracer_get_saved_traces_objects(struct mlx5_fw_tracer *tracer, int mlx5_fw_tracer_get_saved_traces_objects(struct mlx5_fw_tracer *tracer,
...@@ -927,7 +907,6 @@ int mlx5_fw_tracer_get_saved_traces_objects(struct mlx5_fw_tracer *tracer, ...@@ -927,7 +907,6 @@ int mlx5_fw_tracer_get_saved_traces_objects(struct mlx5_fw_tracer *tracer,
struct mlx5_fw_trace_data *straces = tracer->st_arr.straces; struct mlx5_fw_trace_data *straces = tracer->st_arr.straces;
u32 index, start_index, end_index; u32 index, start_index, end_index;
u32 saved_traces_index; u32 saved_traces_index;
int err;
if (!straces[0].timestamp) if (!straces[0].timestamp)
return -ENOMSG; return -ENOMSG;
...@@ -940,22 +919,18 @@ int mlx5_fw_tracer_get_saved_traces_objects(struct mlx5_fw_tracer *tracer, ...@@ -940,22 +919,18 @@ int mlx5_fw_tracer_get_saved_traces_objects(struct mlx5_fw_tracer *tracer,
start_index = 0; start_index = 0;
end_index = (saved_traces_index - 1) & (SAVED_TRACES_NUM - 1); end_index = (saved_traces_index - 1) & (SAVED_TRACES_NUM - 1);
err = devlink_fmsg_arr_pair_nest_start(fmsg, "dump fw traces"); devlink_fmsg_arr_pair_nest_start(fmsg, "dump fw traces");
if (err)
goto unlock;
index = start_index; index = start_index;
while (index != end_index) { while (index != end_index) {
err = mlx5_devlink_fmsg_fill_trace(fmsg, &straces[index]); mlx5_devlink_fmsg_fill_trace(fmsg, &straces[index]);
if (err)
goto unlock;
index = (index + 1) & (SAVED_TRACES_NUM - 1); index = (index + 1) & (SAVED_TRACES_NUM - 1);
} }
err = devlink_fmsg_arr_pair_nest_end(fmsg); devlink_fmsg_arr_pair_nest_end(fmsg);
unlock:
mutex_unlock(&tracer->st_arr.lock); mutex_unlock(&tracer->st_arr.lock);
return err;
return 0;
} }
static void mlx5_fw_tracer_update_db(struct work_struct *work) static void mlx5_fw_tracer_update_db(struct work_struct *work)
......
...@@ -13,106 +13,55 @@ struct mlx5_vnic_diag_stats { ...@@ -13,106 +13,55 @@ struct mlx5_vnic_diag_stats {
__be64 query_vnic_env_out[MLX5_ST_SZ_QW(query_vnic_env_out)]; __be64 query_vnic_env_out[MLX5_ST_SZ_QW(query_vnic_env_out)];
}; };
int mlx5_reporter_vnic_diagnose_counters(struct mlx5_core_dev *dev, void mlx5_reporter_vnic_diagnose_counters(struct mlx5_core_dev *dev,
struct devlink_fmsg *fmsg, struct devlink_fmsg *fmsg,
u16 vport_num, bool other_vport) u16 vport_num, bool other_vport)
{ {
u32 in[MLX5_ST_SZ_DW(query_vnic_env_in)] = {}; u32 in[MLX5_ST_SZ_DW(query_vnic_env_in)] = {};
struct mlx5_vnic_diag_stats vnic; struct mlx5_vnic_diag_stats vnic;
int err;
MLX5_SET(query_vnic_env_in, in, opcode, MLX5_CMD_OP_QUERY_VNIC_ENV); MLX5_SET(query_vnic_env_in, in, opcode, MLX5_CMD_OP_QUERY_VNIC_ENV);
MLX5_SET(query_vnic_env_in, in, vport_number, vport_num); MLX5_SET(query_vnic_env_in, in, vport_number, vport_num);
MLX5_SET(query_vnic_env_in, in, other_vport, !!other_vport); MLX5_SET(query_vnic_env_in, in, other_vport, !!other_vport);
err = mlx5_cmd_exec_inout(dev, query_vnic_env, in, &vnic.query_vnic_env_out); mlx5_cmd_exec_inout(dev, query_vnic_env, in, &vnic.query_vnic_env_out);
if (err)
return err;
err = devlink_fmsg_pair_nest_start(fmsg, "vNIC env counters"); devlink_fmsg_pair_nest_start(fmsg, "vNIC env counters");
if (err) devlink_fmsg_obj_nest_start(fmsg);
return err;
err = devlink_fmsg_obj_nest_start(fmsg);
if (err)
return err;
if (MLX5_CAP_GEN(dev, vnic_env_queue_counters)) { if (MLX5_CAP_GEN(dev, vnic_env_queue_counters)) {
err = devlink_fmsg_u32_pair_put(fmsg, "total_error_queues", devlink_fmsg_u32_pair_put(fmsg, "total_error_queues",
VNIC_ENV_GET(&vnic, total_error_queues)); VNIC_ENV_GET(&vnic, total_error_queues));
if (err) devlink_fmsg_u32_pair_put(fmsg, "send_queue_priority_update_flow",
return err; VNIC_ENV_GET(&vnic, send_queue_priority_update_flow));
err = devlink_fmsg_u32_pair_put(fmsg, "send_queue_priority_update_flow",
VNIC_ENV_GET(&vnic,
send_queue_priority_update_flow));
if (err)
return err;
} }
if (MLX5_CAP_GEN(dev, eq_overrun_count)) { if (MLX5_CAP_GEN(dev, eq_overrun_count)) {
err = devlink_fmsg_u32_pair_put(fmsg, "comp_eq_overrun", devlink_fmsg_u32_pair_put(fmsg, "comp_eq_overrun",
VNIC_ENV_GET(&vnic, comp_eq_overrun)); VNIC_ENV_GET(&vnic, comp_eq_overrun));
if (err) devlink_fmsg_u32_pair_put(fmsg, "async_eq_overrun",
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "async_eq_overrun",
VNIC_ENV_GET(&vnic, async_eq_overrun)); VNIC_ENV_GET(&vnic, async_eq_overrun));
if (err)
return err;
} }
if (MLX5_CAP_GEN(dev, vnic_env_cq_overrun))
if (MLX5_CAP_GEN(dev, vnic_env_cq_overrun)) { devlink_fmsg_u32_pair_put(fmsg, "cq_overrun",
err = devlink_fmsg_u32_pair_put(fmsg, "cq_overrun",
VNIC_ENV_GET(&vnic, cq_overrun)); VNIC_ENV_GET(&vnic, cq_overrun));
if (err) if (MLX5_CAP_GEN(dev, invalid_command_count))
return err; devlink_fmsg_u32_pair_put(fmsg, "invalid_command",
}
if (MLX5_CAP_GEN(dev, invalid_command_count)) {
err = devlink_fmsg_u32_pair_put(fmsg, "invalid_command",
VNIC_ENV_GET(&vnic, invalid_command)); VNIC_ENV_GET(&vnic, invalid_command));
if (err) if (MLX5_CAP_GEN(dev, quota_exceeded_count))
return err; devlink_fmsg_u32_pair_put(fmsg, "quota_exceeded_command",
}
if (MLX5_CAP_GEN(dev, quota_exceeded_count)) {
err = devlink_fmsg_u32_pair_put(fmsg, "quota_exceeded_command",
VNIC_ENV_GET(&vnic, quota_exceeded_command)); VNIC_ENV_GET(&vnic, quota_exceeded_command));
if (err) if (MLX5_CAP_GEN(dev, nic_receive_steering_discard))
return err; devlink_fmsg_u64_pair_put(fmsg, "nic_receive_steering_discard",
} VNIC_ENV_GET64(&vnic, nic_receive_steering_discard));
if (MLX5_CAP_GEN(dev, nic_receive_steering_discard)) {
err = devlink_fmsg_u64_pair_put(fmsg, "nic_receive_steering_discard",
VNIC_ENV_GET64(&vnic,
nic_receive_steering_discard));
if (err)
return err;
}
if (MLX5_CAP_GEN(dev, vnic_env_cnt_steering_fail)) { if (MLX5_CAP_GEN(dev, vnic_env_cnt_steering_fail)) {
err = devlink_fmsg_u64_pair_put(fmsg, "generated_pkt_steering_fail", devlink_fmsg_u64_pair_put(fmsg, "generated_pkt_steering_fail",
VNIC_ENV_GET64(&vnic, VNIC_ENV_GET64(&vnic, generated_pkt_steering_fail));
generated_pkt_steering_fail)); devlink_fmsg_u64_pair_put(fmsg, "handled_pkt_steering_fail",
if (err)
return err;
err = devlink_fmsg_u64_pair_put(fmsg, "handled_pkt_steering_fail",
VNIC_ENV_GET64(&vnic, handled_pkt_steering_fail)); VNIC_ENV_GET64(&vnic, handled_pkt_steering_fail));
if (err)
return err;
} }
err = devlink_fmsg_obj_nest_end(fmsg); devlink_fmsg_obj_nest_end(fmsg);
if (err) devlink_fmsg_pair_nest_end(fmsg);
return err;
err = devlink_fmsg_pair_nest_end(fmsg);
if (err)
return err;
return 0;
} }
static int mlx5_reporter_vnic_diagnose(struct devlink_health_reporter *reporter, static int mlx5_reporter_vnic_diagnose(struct devlink_health_reporter *reporter,
...@@ -121,7 +70,8 @@ static int mlx5_reporter_vnic_diagnose(struct devlink_health_reporter *reporter, ...@@ -121,7 +70,8 @@ static int mlx5_reporter_vnic_diagnose(struct devlink_health_reporter *reporter,
{ {
struct mlx5_core_dev *dev = devlink_health_reporter_priv(reporter); struct mlx5_core_dev *dev = devlink_health_reporter_priv(reporter);
return mlx5_reporter_vnic_diagnose_counters(dev, fmsg, 0, false); mlx5_reporter_vnic_diagnose_counters(dev, fmsg, 0, false);
return 0;
} }
static const struct devlink_health_reporter_ops mlx5_reporter_vnic_ops = { static const struct devlink_health_reporter_ops mlx5_reporter_vnic_ops = {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
void mlx5_reporter_vnic_create(struct mlx5_core_dev *dev); void mlx5_reporter_vnic_create(struct mlx5_core_dev *dev);
void mlx5_reporter_vnic_destroy(struct mlx5_core_dev *dev); void mlx5_reporter_vnic_destroy(struct mlx5_core_dev *dev);
int mlx5_reporter_vnic_diagnose_counters(struct mlx5_core_dev *dev, void mlx5_reporter_vnic_diagnose_counters(struct mlx5_core_dev *dev,
struct devlink_fmsg *fmsg, struct devlink_fmsg *fmsg,
u16 vport_num, bool other_vport); u16 vport_num, bool other_vport);
......
...@@ -5,134 +5,59 @@ ...@@ -5,134 +5,59 @@
#include "lib/eq.h" #include "lib/eq.h"
#include "lib/mlx5.h" #include "lib/mlx5.h"
int mlx5e_health_fmsg_named_obj_nest_start(struct devlink_fmsg *fmsg, char *name) void mlx5e_health_fmsg_named_obj_nest_start(struct devlink_fmsg *fmsg, char *name)
{ {
int err; devlink_fmsg_pair_nest_start(fmsg, name);
devlink_fmsg_obj_nest_start(fmsg);
err = devlink_fmsg_pair_nest_start(fmsg, name);
if (err)
return err;
err = devlink_fmsg_obj_nest_start(fmsg);
if (err)
return err;
return 0;
} }
int mlx5e_health_fmsg_named_obj_nest_end(struct devlink_fmsg *fmsg) void mlx5e_health_fmsg_named_obj_nest_end(struct devlink_fmsg *fmsg)
{ {
int err; devlink_fmsg_obj_nest_end(fmsg);
devlink_fmsg_pair_nest_end(fmsg);
err = devlink_fmsg_obj_nest_end(fmsg);
if (err)
return err;
err = devlink_fmsg_pair_nest_end(fmsg);
if (err)
return err;
return 0;
} }
int mlx5e_health_cq_diag_fmsg(struct mlx5e_cq *cq, struct devlink_fmsg *fmsg) void mlx5e_health_cq_diag_fmsg(struct mlx5e_cq *cq, struct devlink_fmsg *fmsg)
{ {
u32 out[MLX5_ST_SZ_DW(query_cq_out)] = {}; u32 out[MLX5_ST_SZ_DW(query_cq_out)] = {};
u8 hw_status; u8 hw_status;
void *cqc; void *cqc;
int err;
err = mlx5_core_query_cq(cq->mdev, &cq->mcq, out);
if (err)
return err;
mlx5_core_query_cq(cq->mdev, &cq->mcq, out);
cqc = MLX5_ADDR_OF(query_cq_out, out, cq_context); cqc = MLX5_ADDR_OF(query_cq_out, out, cq_context);
hw_status = MLX5_GET(cqc, cqc, status); hw_status = MLX5_GET(cqc, cqc, status);
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "CQ"); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "CQ");
if (err) devlink_fmsg_u32_pair_put(fmsg, "cqn", cq->mcq.cqn);
return err; devlink_fmsg_u8_pair_put(fmsg, "HW status", hw_status);
devlink_fmsg_u32_pair_put(fmsg, "ci", mlx5_cqwq_get_ci(&cq->wq));
err = devlink_fmsg_u32_pair_put(fmsg, "cqn", cq->mcq.cqn); devlink_fmsg_u32_pair_put(fmsg, "size", mlx5_cqwq_get_size(&cq->wq));
if (err) mlx5e_health_fmsg_named_obj_nest_end(fmsg);
return err;
err = devlink_fmsg_u8_pair_put(fmsg, "HW status", hw_status);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "ci", mlx5_cqwq_get_ci(&cq->wq));
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "size", mlx5_cqwq_get_size(&cq->wq));
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
return 0;
} }
int mlx5e_health_cq_common_diag_fmsg(struct mlx5e_cq *cq, struct devlink_fmsg *fmsg) void mlx5e_health_cq_common_diag_fmsg(struct mlx5e_cq *cq, struct devlink_fmsg *fmsg)
{ {
u8 cq_log_stride; u8 cq_log_stride;
u32 cq_sz; u32 cq_sz;
int err;
cq_sz = mlx5_cqwq_get_size(&cq->wq); cq_sz = mlx5_cqwq_get_size(&cq->wq);
cq_log_stride = mlx5_cqwq_get_log_stride_size(&cq->wq); cq_log_stride = mlx5_cqwq_get_log_stride_size(&cq->wq);
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "CQ"); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "CQ");
if (err) devlink_fmsg_u64_pair_put(fmsg, "stride size", BIT(cq_log_stride));
return err; devlink_fmsg_u32_pair_put(fmsg, "size", cq_sz);
mlx5e_health_fmsg_named_obj_nest_end(fmsg);
err = devlink_fmsg_u64_pair_put(fmsg, "stride size", BIT(cq_log_stride));
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "size", cq_sz);
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
return 0;
} }
int mlx5e_health_eq_diag_fmsg(struct mlx5_eq_comp *eq, struct devlink_fmsg *fmsg) void mlx5e_health_eq_diag_fmsg(struct mlx5_eq_comp *eq, struct devlink_fmsg *fmsg)
{ {
int err; mlx5e_health_fmsg_named_obj_nest_start(fmsg, "EQ");
devlink_fmsg_u8_pair_put(fmsg, "eqn", eq->core.eqn);
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "EQ"); devlink_fmsg_u32_pair_put(fmsg, "irqn", eq->core.irqn);
if (err) devlink_fmsg_u32_pair_put(fmsg, "vecidx", eq->core.vecidx);
return err; devlink_fmsg_u32_pair_put(fmsg, "ci", eq->core.cons_index);
devlink_fmsg_u32_pair_put(fmsg, "size", eq_get_size(&eq->core));
err = devlink_fmsg_u8_pair_put(fmsg, "eqn", eq->core.eqn); mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "irqn", eq->core.irqn);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "vecidx", eq->core.vecidx);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "ci", eq->core.cons_index);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "size", eq_get_size(&eq->core));
if (err)
return err;
return mlx5e_health_fmsg_named_obj_nest_end(fmsg);
} }
void mlx5e_health_create_reporters(struct mlx5e_priv *priv) void mlx5e_health_create_reporters(struct mlx5e_priv *priv)
...@@ -235,23 +160,19 @@ int mlx5e_health_report(struct mlx5e_priv *priv, ...@@ -235,23 +160,19 @@ int mlx5e_health_report(struct mlx5e_priv *priv,
} }
#define MLX5_HEALTH_DEVLINK_MAX_SIZE 1024 #define MLX5_HEALTH_DEVLINK_MAX_SIZE 1024
static int mlx5e_health_rsc_fmsg_binary(struct devlink_fmsg *fmsg, static void mlx5e_health_rsc_fmsg_binary(struct devlink_fmsg *fmsg,
const void *value, u32 value_len) const void *value, u32 value_len)
{ {
u32 data_size; u32 data_size;
int err = 0;
u32 offset; u32 offset;
for (offset = 0; offset < value_len; offset += data_size) { for (offset = 0; offset < value_len; offset += data_size) {
data_size = value_len - offset; data_size = value_len - offset;
if (data_size > MLX5_HEALTH_DEVLINK_MAX_SIZE) if (data_size > MLX5_HEALTH_DEVLINK_MAX_SIZE)
data_size = MLX5_HEALTH_DEVLINK_MAX_SIZE; data_size = MLX5_HEALTH_DEVLINK_MAX_SIZE;
err = devlink_fmsg_binary_put(fmsg, value + offset, data_size); devlink_fmsg_binary_put(fmsg, value + offset, data_size);
if (err)
break;
} }
return err;
} }
int mlx5e_health_rsc_fmsg_dump(struct mlx5e_priv *priv, struct mlx5_rsc_key *key, int mlx5e_health_rsc_fmsg_dump(struct mlx5e_priv *priv, struct mlx5_rsc_key *key,
...@@ -259,9 +180,8 @@ int mlx5e_health_rsc_fmsg_dump(struct mlx5e_priv *priv, struct mlx5_rsc_key *key ...@@ -259,9 +180,8 @@ int mlx5e_health_rsc_fmsg_dump(struct mlx5e_priv *priv, struct mlx5_rsc_key *key
{ {
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
struct mlx5_rsc_dump_cmd *cmd; struct mlx5_rsc_dump_cmd *cmd;
int cmd_err, err = 0;
struct page *page; struct page *page;
int cmd_err, err;
int end_err;
int size; int size;
if (IS_ERR_OR_NULL(mdev->rsc_dump)) if (IS_ERR_OR_NULL(mdev->rsc_dump))
...@@ -271,9 +191,7 @@ int mlx5e_health_rsc_fmsg_dump(struct mlx5e_priv *priv, struct mlx5_rsc_key *key ...@@ -271,9 +191,7 @@ int mlx5e_health_rsc_fmsg_dump(struct mlx5e_priv *priv, struct mlx5_rsc_key *key
if (!page) if (!page)
return -ENOMEM; return -ENOMEM;
err = devlink_fmsg_binary_pair_nest_start(fmsg, "data"); devlink_fmsg_binary_pair_nest_start(fmsg, "data");
if (err)
goto free_page;
cmd = mlx5_rsc_dump_cmd_create(mdev, key); cmd = mlx5_rsc_dump_cmd_create(mdev, key);
if (IS_ERR(cmd)) { if (IS_ERR(cmd)) {
...@@ -288,52 +206,31 @@ int mlx5e_health_rsc_fmsg_dump(struct mlx5e_priv *priv, struct mlx5_rsc_key *key ...@@ -288,52 +206,31 @@ int mlx5e_health_rsc_fmsg_dump(struct mlx5e_priv *priv, struct mlx5_rsc_key *key
goto destroy_cmd; goto destroy_cmd;
} }
err = mlx5e_health_rsc_fmsg_binary(fmsg, page_address(page), size); mlx5e_health_rsc_fmsg_binary(fmsg, page_address(page), size);
if (err)
goto destroy_cmd;
} while (cmd_err > 0); } while (cmd_err > 0);
destroy_cmd: destroy_cmd:
mlx5_rsc_dump_cmd_destroy(cmd); mlx5_rsc_dump_cmd_destroy(cmd);
end_err = devlink_fmsg_binary_pair_nest_end(fmsg); devlink_fmsg_binary_pair_nest_end(fmsg);
if (end_err)
err = end_err;
free_page: free_page:
__free_page(page); __free_page(page);
return err; return err;
} }
int mlx5e_health_queue_dump(struct mlx5e_priv *priv, struct devlink_fmsg *fmsg, void mlx5e_health_queue_dump(struct mlx5e_priv *priv, struct devlink_fmsg *fmsg,
int queue_idx, char *lbl) int queue_idx, char *lbl)
{ {
struct mlx5_rsc_key key = {}; struct mlx5_rsc_key key = {};
int err;
key.rsc = MLX5_SGMT_TYPE_FULL_QPC; key.rsc = MLX5_SGMT_TYPE_FULL_QPC;
key.index1 = queue_idx; key.index1 = queue_idx;
key.size = PAGE_SIZE; key.size = PAGE_SIZE;
key.num_of_obj1 = 1; key.num_of_obj1 = 1;
err = devlink_fmsg_obj_nest_start(fmsg); devlink_fmsg_obj_nest_start(fmsg);
if (err) mlx5e_health_fmsg_named_obj_nest_start(fmsg, lbl);
return err; devlink_fmsg_u32_pair_put(fmsg, "index", queue_idx);
mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, lbl); mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err) devlink_fmsg_obj_nest_end(fmsg);
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "index", queue_idx);
if (err)
return err;
err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
return devlink_fmsg_obj_nest_end(fmsg);
} }
...@@ -20,11 +20,11 @@ void mlx5e_reporter_tx_err_cqe(struct mlx5e_txqsq *sq); ...@@ -20,11 +20,11 @@ void mlx5e_reporter_tx_err_cqe(struct mlx5e_txqsq *sq);
int mlx5e_reporter_tx_timeout(struct mlx5e_txqsq *sq); int mlx5e_reporter_tx_timeout(struct mlx5e_txqsq *sq);
void mlx5e_reporter_tx_ptpsq_unhealthy(struct mlx5e_ptpsq *ptpsq); void mlx5e_reporter_tx_ptpsq_unhealthy(struct mlx5e_ptpsq *ptpsq);
int mlx5e_health_cq_diag_fmsg(struct mlx5e_cq *cq, struct devlink_fmsg *fmsg); void mlx5e_health_cq_diag_fmsg(struct mlx5e_cq *cq, struct devlink_fmsg *fmsg);
int mlx5e_health_cq_common_diag_fmsg(struct mlx5e_cq *cq, struct devlink_fmsg *fmsg); void mlx5e_health_cq_common_diag_fmsg(struct mlx5e_cq *cq, struct devlink_fmsg *fmsg);
int mlx5e_health_eq_diag_fmsg(struct mlx5_eq_comp *eq, struct devlink_fmsg *fmsg); void mlx5e_health_eq_diag_fmsg(struct mlx5_eq_comp *eq, struct devlink_fmsg *fmsg);
int mlx5e_health_fmsg_named_obj_nest_start(struct devlink_fmsg *fmsg, char *name); void mlx5e_health_fmsg_named_obj_nest_start(struct devlink_fmsg *fmsg, char *name);
int mlx5e_health_fmsg_named_obj_nest_end(struct devlink_fmsg *fmsg); void mlx5e_health_fmsg_named_obj_nest_end(struct devlink_fmsg *fmsg);
void mlx5e_reporter_rx_create(struct mlx5e_priv *priv); void mlx5e_reporter_rx_create(struct mlx5e_priv *priv);
void mlx5e_reporter_rx_destroy(struct mlx5e_priv *priv); void mlx5e_reporter_rx_destroy(struct mlx5e_priv *priv);
...@@ -54,6 +54,6 @@ void mlx5e_health_destroy_reporters(struct mlx5e_priv *priv); ...@@ -54,6 +54,6 @@ void mlx5e_health_destroy_reporters(struct mlx5e_priv *priv);
void mlx5e_health_channels_update(struct mlx5e_priv *priv); void mlx5e_health_channels_update(struct mlx5e_priv *priv);
int mlx5e_health_rsc_fmsg_dump(struct mlx5e_priv *priv, struct mlx5_rsc_key *key, int mlx5e_health_rsc_fmsg_dump(struct mlx5e_priv *priv, struct mlx5_rsc_key *key,
struct devlink_fmsg *fmsg); struct devlink_fmsg *fmsg);
int mlx5e_health_queue_dump(struct mlx5e_priv *priv, struct devlink_fmsg *fmsg, void mlx5e_health_queue_dump(struct mlx5e_priv *priv, struct devlink_fmsg *fmsg,
int queue_idx, char *lbl); int queue_idx, char *lbl);
#endif #endif
...@@ -1356,8 +1356,9 @@ mlx5e_rep_vnic_reporter_diagnose(struct devlink_health_reporter *reporter, ...@@ -1356,8 +1356,9 @@ mlx5e_rep_vnic_reporter_diagnose(struct devlink_health_reporter *reporter,
struct mlx5e_rep_priv *rpriv = devlink_health_reporter_priv(reporter); struct mlx5e_rep_priv *rpriv = devlink_health_reporter_priv(reporter);
struct mlx5_eswitch_rep *rep = rpriv->rep; struct mlx5_eswitch_rep *rep = rpriv->rep;
return mlx5_reporter_vnic_diagnose_counters(rep->esw->dev, fmsg, mlx5_reporter_vnic_diagnose_counters(rep->esw->dev, fmsg, rep->vport,
rep->vport, true); true);
return 0;
} }
static const struct devlink_health_reporter_ops mlx5_rep_vnic_reporter_ops = { static const struct devlink_health_reporter_ops mlx5_rep_vnic_reporter_ops = {
......
...@@ -450,14 +450,15 @@ mlx5_fw_reporter_diagnose(struct devlink_health_reporter *reporter, ...@@ -450,14 +450,15 @@ mlx5_fw_reporter_diagnose(struct devlink_health_reporter *reporter,
struct mlx5_core_dev *dev = devlink_health_reporter_priv(reporter); struct mlx5_core_dev *dev = devlink_health_reporter_priv(reporter);
struct mlx5_core_health *health = &dev->priv.health; struct mlx5_core_health *health = &dev->priv.health;
struct health_buffer __iomem *h = health->health; struct health_buffer __iomem *h = health->health;
u8 synd; u8 synd = ioread8(&h->synd);
int err;
synd = ioread8(&h->synd); if (!synd)
err = devlink_fmsg_u8_pair_put(fmsg, "Syndrome", synd); return 0;
if (err || !synd)
return err; devlink_fmsg_u8_pair_put(fmsg, "Syndrome", synd);
return devlink_fmsg_string_pair_put(fmsg, "Description", hsynd_str(synd)); devlink_fmsg_string_pair_put(fmsg, "Description", hsynd_str(synd));
return 0;
} }
struct mlx5_fw_reporter_ctx { struct mlx5_fw_reporter_ctx {
...@@ -465,94 +466,47 @@ struct mlx5_fw_reporter_ctx { ...@@ -465,94 +466,47 @@ struct mlx5_fw_reporter_ctx {
int miss_counter; int miss_counter;
}; };
static int static void
mlx5_fw_reporter_ctx_pairs_put(struct devlink_fmsg *fmsg, mlx5_fw_reporter_ctx_pairs_put(struct devlink_fmsg *fmsg,
struct mlx5_fw_reporter_ctx *fw_reporter_ctx) struct mlx5_fw_reporter_ctx *fw_reporter_ctx)
{ {
int err; devlink_fmsg_u8_pair_put(fmsg, "syndrome", fw_reporter_ctx->err_synd);
devlink_fmsg_u32_pair_put(fmsg, "fw_miss_counter", fw_reporter_ctx->miss_counter);
err = devlink_fmsg_u8_pair_put(fmsg, "syndrome",
fw_reporter_ctx->err_synd);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "fw_miss_counter",
fw_reporter_ctx->miss_counter);
if (err)
return err;
return 0;
} }
static int static void
mlx5_fw_reporter_heath_buffer_data_put(struct mlx5_core_dev *dev, mlx5_fw_reporter_heath_buffer_data_put(struct mlx5_core_dev *dev,
struct devlink_fmsg *fmsg) struct devlink_fmsg *fmsg)
{ {
struct mlx5_core_health *health = &dev->priv.health; struct mlx5_core_health *health = &dev->priv.health;
struct health_buffer __iomem *h = health->health; struct health_buffer __iomem *h = health->health;
u8 rfr_severity; u8 rfr_severity;
int err;
int i; int i;
if (!ioread8(&h->synd)) if (!ioread8(&h->synd))
return 0; return;
err = devlink_fmsg_pair_nest_start(fmsg, "health buffer");
if (err)
return err;
err = devlink_fmsg_obj_nest_start(fmsg);
if (err)
return err;
err = devlink_fmsg_arr_pair_nest_start(fmsg, "assert_var");
if (err)
return err;
for (i = 0; i < ARRAY_SIZE(h->assert_var); i++) { devlink_fmsg_pair_nest_start(fmsg, "health buffer");
err = devlink_fmsg_u32_put(fmsg, ioread32be(h->assert_var + i)); devlink_fmsg_obj_nest_start(fmsg);
if (err) devlink_fmsg_arr_pair_nest_start(fmsg, "assert_var");
return err; for (i = 0; i < ARRAY_SIZE(h->assert_var); i++)
} devlink_fmsg_u32_put(fmsg, ioread32be(h->assert_var + i));
err = devlink_fmsg_arr_pair_nest_end(fmsg); devlink_fmsg_arr_pair_nest_end(fmsg);
if (err) devlink_fmsg_u32_pair_put(fmsg, "assert_exit_ptr",
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "assert_exit_ptr",
ioread32be(&h->assert_exit_ptr)); ioread32be(&h->assert_exit_ptr));
if (err) devlink_fmsg_u32_pair_put(fmsg, "assert_callra",
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "assert_callra",
ioread32be(&h->assert_callra)); ioread32be(&h->assert_callra));
if (err) devlink_fmsg_u32_pair_put(fmsg, "time", ioread32be(&h->time));
return err; devlink_fmsg_u32_pair_put(fmsg, "hw_id", ioread32be(&h->hw_id));
err = devlink_fmsg_u32_pair_put(fmsg, "time", ioread32be(&h->time));
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "hw_id", ioread32be(&h->hw_id));
if (err)
return err;
rfr_severity = ioread8(&h->rfr_severity); rfr_severity = ioread8(&h->rfr_severity);
err = devlink_fmsg_u8_pair_put(fmsg, "rfr", mlx5_health_get_rfr(rfr_severity)); devlink_fmsg_u8_pair_put(fmsg, "rfr", mlx5_health_get_rfr(rfr_severity));
if (err) devlink_fmsg_u8_pair_put(fmsg, "severity", mlx5_health_get_severity(rfr_severity));
return err; devlink_fmsg_u8_pair_put(fmsg, "irisc_index", ioread8(&h->irisc_index));
err = devlink_fmsg_u8_pair_put(fmsg, "severity", mlx5_health_get_severity(rfr_severity)); devlink_fmsg_u8_pair_put(fmsg, "synd", ioread8(&h->synd));
if (err) devlink_fmsg_u32_pair_put(fmsg, "ext_synd", ioread16be(&h->ext_synd));
return err; devlink_fmsg_u32_pair_put(fmsg, "raw_fw_ver", ioread32be(&h->fw_ver));
err = devlink_fmsg_u8_pair_put(fmsg, "irisc_index", devlink_fmsg_obj_nest_end(fmsg);
ioread8(&h->irisc_index)); devlink_fmsg_pair_nest_end(fmsg);
if (err)
return err;
err = devlink_fmsg_u8_pair_put(fmsg, "synd", ioread8(&h->synd));
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "ext_synd",
ioread16be(&h->ext_synd));
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "raw_fw_ver",
ioread32be(&h->fw_ver));
if (err)
return err;
err = devlink_fmsg_obj_nest_end(fmsg);
if (err)
return err;
return devlink_fmsg_pair_nest_end(fmsg);
} }
static int static int
...@@ -570,14 +524,11 @@ mlx5_fw_reporter_dump(struct devlink_health_reporter *reporter, ...@@ -570,14 +524,11 @@ mlx5_fw_reporter_dump(struct devlink_health_reporter *reporter,
if (priv_ctx) { if (priv_ctx) {
struct mlx5_fw_reporter_ctx *fw_reporter_ctx = priv_ctx; struct mlx5_fw_reporter_ctx *fw_reporter_ctx = priv_ctx;
err = mlx5_fw_reporter_ctx_pairs_put(fmsg, fw_reporter_ctx); mlx5_fw_reporter_ctx_pairs_put(fmsg, fw_reporter_ctx);
if (err)
return err;
} }
err = mlx5_fw_reporter_heath_buffer_data_put(dev, fmsg); mlx5_fw_reporter_heath_buffer_data_put(dev, fmsg);
if (err)
return err;
return mlx5_fw_tracer_get_saved_traces_objects(dev->tracer, fmsg); return mlx5_fw_tracer_get_saved_traces_objects(dev->tracer, fmsg);
} }
...@@ -643,12 +594,10 @@ mlx5_fw_fatal_reporter_dump(struct devlink_health_reporter *reporter, ...@@ -643,12 +594,10 @@ mlx5_fw_fatal_reporter_dump(struct devlink_health_reporter *reporter,
if (priv_ctx) { if (priv_ctx) {
struct mlx5_fw_reporter_ctx *fw_reporter_ctx = priv_ctx; struct mlx5_fw_reporter_ctx *fw_reporter_ctx = priv_ctx;
err = mlx5_fw_reporter_ctx_pairs_put(fmsg, fw_reporter_ctx); mlx5_fw_reporter_ctx_pairs_put(fmsg, fw_reporter_ctx);
if (err)
goto free_data;
} }
err = devlink_fmsg_binary_pair_put(fmsg, "crdump_data", cr_data, crdump_size); devlink_fmsg_binary_pair_put(fmsg, "crdump_data", cr_data, crdump_size);
free_data: free_data:
kvfree(cr_data); kvfree(cr_data);
......
...@@ -1792,122 +1792,78 @@ static void mlxsw_core_health_listener_func(const struct mlxsw_reg_info *reg, ...@@ -1792,122 +1792,78 @@ static void mlxsw_core_health_listener_func(const struct mlxsw_reg_info *reg,
static const struct mlxsw_listener mlxsw_core_health_listener = static const struct mlxsw_listener mlxsw_core_health_listener =
MLXSW_CORE_EVENTL(mlxsw_core_health_listener_func, MFDE); MLXSW_CORE_EVENTL(mlxsw_core_health_listener_func, MFDE);
static int static void
mlxsw_core_health_fw_fatal_dump_fatal_cause(const char *mfde_pl, mlxsw_core_health_fw_fatal_dump_fatal_cause(const char *mfde_pl,
struct devlink_fmsg *fmsg) struct devlink_fmsg *fmsg)
{ {
u32 val, tile_v; u32 val, tile_v;
int err;
val = mlxsw_reg_mfde_fatal_cause_id_get(mfde_pl); val = mlxsw_reg_mfde_fatal_cause_id_get(mfde_pl);
err = devlink_fmsg_u32_pair_put(fmsg, "cause_id", val); devlink_fmsg_u32_pair_put(fmsg, "cause_id", val);
if (err)
return err;
tile_v = mlxsw_reg_mfde_fatal_cause_tile_v_get(mfde_pl); tile_v = mlxsw_reg_mfde_fatal_cause_tile_v_get(mfde_pl);
if (tile_v) { if (tile_v) {
val = mlxsw_reg_mfde_fatal_cause_tile_index_get(mfde_pl); val = mlxsw_reg_mfde_fatal_cause_tile_index_get(mfde_pl);
err = devlink_fmsg_u8_pair_put(fmsg, "tile_index", val); devlink_fmsg_u8_pair_put(fmsg, "tile_index", val);
if (err)
return err;
} }
return 0;
} }
static int static void
mlxsw_core_health_fw_fatal_dump_fw_assert(const char *mfde_pl, mlxsw_core_health_fw_fatal_dump_fw_assert(const char *mfde_pl,
struct devlink_fmsg *fmsg) struct devlink_fmsg *fmsg)
{ {
u32 val, tile_v; u32 val, tile_v;
int err;
val = mlxsw_reg_mfde_fw_assert_var0_get(mfde_pl); val = mlxsw_reg_mfde_fw_assert_var0_get(mfde_pl);
err = devlink_fmsg_u32_pair_put(fmsg, "var0", val); devlink_fmsg_u32_pair_put(fmsg, "var0", val);
if (err)
return err;
val = mlxsw_reg_mfde_fw_assert_var1_get(mfde_pl); val = mlxsw_reg_mfde_fw_assert_var1_get(mfde_pl);
err = devlink_fmsg_u32_pair_put(fmsg, "var1", val); devlink_fmsg_u32_pair_put(fmsg, "var1", val);
if (err)
return err;
val = mlxsw_reg_mfde_fw_assert_var2_get(mfde_pl); val = mlxsw_reg_mfde_fw_assert_var2_get(mfde_pl);
err = devlink_fmsg_u32_pair_put(fmsg, "var2", val); devlink_fmsg_u32_pair_put(fmsg, "var2", val);
if (err)
return err;
val = mlxsw_reg_mfde_fw_assert_var3_get(mfde_pl); val = mlxsw_reg_mfde_fw_assert_var3_get(mfde_pl);
err = devlink_fmsg_u32_pair_put(fmsg, "var3", val); devlink_fmsg_u32_pair_put(fmsg, "var3", val);
if (err)
return err;
val = mlxsw_reg_mfde_fw_assert_var4_get(mfde_pl); val = mlxsw_reg_mfde_fw_assert_var4_get(mfde_pl);
err = devlink_fmsg_u32_pair_put(fmsg, "var4", val); devlink_fmsg_u32_pair_put(fmsg, "var4", val);
if (err)
return err;
val = mlxsw_reg_mfde_fw_assert_existptr_get(mfde_pl); val = mlxsw_reg_mfde_fw_assert_existptr_get(mfde_pl);
err = devlink_fmsg_u32_pair_put(fmsg, "existptr", val); devlink_fmsg_u32_pair_put(fmsg, "existptr", val);
if (err)
return err;
val = mlxsw_reg_mfde_fw_assert_callra_get(mfde_pl); val = mlxsw_reg_mfde_fw_assert_callra_get(mfde_pl);
err = devlink_fmsg_u32_pair_put(fmsg, "callra", val); devlink_fmsg_u32_pair_put(fmsg, "callra", val);
if (err)
return err;
val = mlxsw_reg_mfde_fw_assert_oe_get(mfde_pl); val = mlxsw_reg_mfde_fw_assert_oe_get(mfde_pl);
err = devlink_fmsg_bool_pair_put(fmsg, "old_event", val); devlink_fmsg_bool_pair_put(fmsg, "old_event", val);
if (err)
return err;
tile_v = mlxsw_reg_mfde_fw_assert_tile_v_get(mfde_pl); tile_v = mlxsw_reg_mfde_fw_assert_tile_v_get(mfde_pl);
if (tile_v) { if (tile_v) {
val = mlxsw_reg_mfde_fw_assert_tile_index_get(mfde_pl); val = mlxsw_reg_mfde_fw_assert_tile_index_get(mfde_pl);
err = devlink_fmsg_u8_pair_put(fmsg, "tile_index", val); devlink_fmsg_u8_pair_put(fmsg, "tile_index", val);
if (err)
return err;
} }
val = mlxsw_reg_mfde_fw_assert_ext_synd_get(mfde_pl); val = mlxsw_reg_mfde_fw_assert_ext_synd_get(mfde_pl);
err = devlink_fmsg_u32_pair_put(fmsg, "ext_synd", val); devlink_fmsg_u32_pair_put(fmsg, "ext_synd", val);
if (err)
return err;
return 0;
} }
static int static void
mlxsw_core_health_fw_fatal_dump_kvd_im_stop(const char *mfde_pl, mlxsw_core_health_fw_fatal_dump_kvd_im_stop(const char *mfde_pl,
struct devlink_fmsg *fmsg) struct devlink_fmsg *fmsg)
{ {
u32 val; u32 val;
int err;
val = mlxsw_reg_mfde_kvd_im_stop_oe_get(mfde_pl); val = mlxsw_reg_mfde_kvd_im_stop_oe_get(mfde_pl);
err = devlink_fmsg_bool_pair_put(fmsg, "old_event", val); devlink_fmsg_bool_pair_put(fmsg, "old_event", val);
if (err)
return err;
val = mlxsw_reg_mfde_kvd_im_stop_pipes_mask_get(mfde_pl); val = mlxsw_reg_mfde_kvd_im_stop_pipes_mask_get(mfde_pl);
return devlink_fmsg_u32_pair_put(fmsg, "pipes_mask", val); devlink_fmsg_u32_pair_put(fmsg, "pipes_mask", val);
} }
static int static void
mlxsw_core_health_fw_fatal_dump_crspace_to(const char *mfde_pl, mlxsw_core_health_fw_fatal_dump_crspace_to(const char *mfde_pl,
struct devlink_fmsg *fmsg) struct devlink_fmsg *fmsg)
{ {
u32 val; u32 val;
int err;
val = mlxsw_reg_mfde_crspace_to_log_address_get(mfde_pl); val = mlxsw_reg_mfde_crspace_to_log_address_get(mfde_pl);
err = devlink_fmsg_u32_pair_put(fmsg, "log_address", val); devlink_fmsg_u32_pair_put(fmsg, "log_address", val);
if (err)
return err;
val = mlxsw_reg_mfde_crspace_to_oe_get(mfde_pl); val = mlxsw_reg_mfde_crspace_to_oe_get(mfde_pl);
err = devlink_fmsg_bool_pair_put(fmsg, "old_event", val); devlink_fmsg_bool_pair_put(fmsg, "old_event", val);
if (err)
return err;
val = mlxsw_reg_mfde_crspace_to_log_id_get(mfde_pl); val = mlxsw_reg_mfde_crspace_to_log_id_get(mfde_pl);
err = devlink_fmsg_u8_pair_put(fmsg, "log_irisc_id", val); devlink_fmsg_u8_pair_put(fmsg, "log_irisc_id", val);
if (err)
return err;
val = mlxsw_reg_mfde_crspace_to_log_ip_get(mfde_pl); val = mlxsw_reg_mfde_crspace_to_log_ip_get(mfde_pl);
err = devlink_fmsg_u64_pair_put(fmsg, "log_ip", val); devlink_fmsg_u64_pair_put(fmsg, "log_ip", val);
if (err)
return err;
return 0;
} }
static int mlxsw_core_health_fw_fatal_dump(struct devlink_health_reporter *reporter, static int mlxsw_core_health_fw_fatal_dump(struct devlink_health_reporter *reporter,
...@@ -1918,24 +1874,17 @@ static int mlxsw_core_health_fw_fatal_dump(struct devlink_health_reporter *repor ...@@ -1918,24 +1874,17 @@ static int mlxsw_core_health_fw_fatal_dump(struct devlink_health_reporter *repor
char *val_str; char *val_str;
u8 event_id; u8 event_id;
u32 val; u32 val;
int err;
if (!priv_ctx) if (!priv_ctx)
/* User-triggered dumps are not possible */ /* User-triggered dumps are not possible */
return -EOPNOTSUPP; return -EOPNOTSUPP;
val = mlxsw_reg_mfde_irisc_id_get(mfde_pl); val = mlxsw_reg_mfde_irisc_id_get(mfde_pl);
err = devlink_fmsg_u8_pair_put(fmsg, "irisc_id", val); devlink_fmsg_u8_pair_put(fmsg, "irisc_id", val);
if (err)
return err;
err = devlink_fmsg_arr_pair_nest_start(fmsg, "event");
if (err)
return err;
devlink_fmsg_arr_pair_nest_start(fmsg, "event");
event_id = mlxsw_reg_mfde_event_id_get(mfde_pl); event_id = mlxsw_reg_mfde_event_id_get(mfde_pl);
err = devlink_fmsg_u32_pair_put(fmsg, "id", event_id); devlink_fmsg_u32_pair_put(fmsg, "id", event_id);
if (err)
return err;
switch (event_id) { switch (event_id) {
case MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO: case MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO:
val_str = "CR space timeout"; val_str = "CR space timeout";
...@@ -1955,24 +1904,13 @@ static int mlxsw_core_health_fw_fatal_dump(struct devlink_health_reporter *repor ...@@ -1955,24 +1904,13 @@ static int mlxsw_core_health_fw_fatal_dump(struct devlink_health_reporter *repor
default: default:
val_str = NULL; val_str = NULL;
} }
if (val_str) { if (val_str)
err = devlink_fmsg_string_pair_put(fmsg, "desc", val_str); devlink_fmsg_string_pair_put(fmsg, "desc", val_str);
if (err) devlink_fmsg_arr_pair_nest_end(fmsg);
return err;
}
err = devlink_fmsg_arr_pair_nest_end(fmsg);
if (err)
return err;
err = devlink_fmsg_arr_pair_nest_start(fmsg, "severity");
if (err)
return err;
devlink_fmsg_arr_pair_nest_start(fmsg, "severity");
val = mlxsw_reg_mfde_severity_get(mfde_pl); val = mlxsw_reg_mfde_severity_get(mfde_pl);
err = devlink_fmsg_u8_pair_put(fmsg, "id", val); devlink_fmsg_u8_pair_put(fmsg, "id", val);
if (err)
return err;
switch (val) { switch (val) {
case MLXSW_REG_MFDE_SEVERITY_FATL: case MLXSW_REG_MFDE_SEVERITY_FATL:
val_str = "Fatal"; val_str = "Fatal";
...@@ -1986,15 +1924,9 @@ static int mlxsw_core_health_fw_fatal_dump(struct devlink_health_reporter *repor ...@@ -1986,15 +1924,9 @@ static int mlxsw_core_health_fw_fatal_dump(struct devlink_health_reporter *repor
default: default:
val_str = NULL; val_str = NULL;
} }
if (val_str) { if (val_str)
err = devlink_fmsg_string_pair_put(fmsg, "desc", val_str); devlink_fmsg_string_pair_put(fmsg, "desc", val_str);
if (err) devlink_fmsg_arr_pair_nest_end(fmsg);
return err;
}
err = devlink_fmsg_arr_pair_nest_end(fmsg);
if (err)
return err;
val = mlxsw_reg_mfde_method_get(mfde_pl); val = mlxsw_reg_mfde_method_get(mfde_pl);
switch (val) { switch (val) {
...@@ -2007,16 +1939,11 @@ static int mlxsw_core_health_fw_fatal_dump(struct devlink_health_reporter *repor ...@@ -2007,16 +1939,11 @@ static int mlxsw_core_health_fw_fatal_dump(struct devlink_health_reporter *repor
default: default:
val_str = NULL; val_str = NULL;
} }
if (val_str) { if (val_str)
err = devlink_fmsg_string_pair_put(fmsg, "method", val_str); devlink_fmsg_string_pair_put(fmsg, "method", val_str);
if (err)
return err;
}
val = mlxsw_reg_mfde_long_process_get(mfde_pl); val = mlxsw_reg_mfde_long_process_get(mfde_pl);
err = devlink_fmsg_bool_pair_put(fmsg, "long_process", val); devlink_fmsg_bool_pair_put(fmsg, "long_process", val);
if (err)
return err;
val = mlxsw_reg_mfde_command_type_get(mfde_pl); val = mlxsw_reg_mfde_command_type_get(mfde_pl);
switch (val) { switch (val) {
...@@ -2032,29 +1959,25 @@ static int mlxsw_core_health_fw_fatal_dump(struct devlink_health_reporter *repor ...@@ -2032,29 +1959,25 @@ static int mlxsw_core_health_fw_fatal_dump(struct devlink_health_reporter *repor
default: default:
val_str = NULL; val_str = NULL;
} }
if (val_str) { if (val_str)
err = devlink_fmsg_string_pair_put(fmsg, "command_type", val_str); devlink_fmsg_string_pair_put(fmsg, "command_type", val_str);
if (err)
return err;
}
val = mlxsw_reg_mfde_reg_attr_id_get(mfde_pl); val = mlxsw_reg_mfde_reg_attr_id_get(mfde_pl);
err = devlink_fmsg_u32_pair_put(fmsg, "reg_attr_id", val); devlink_fmsg_u32_pair_put(fmsg, "reg_attr_id", val);
if (err)
return err;
switch (event_id) { switch (event_id) {
case MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO: case MLXSW_REG_MFDE_EVENT_ID_CRSPACE_TO:
return mlxsw_core_health_fw_fatal_dump_crspace_to(mfde_pl, mlxsw_core_health_fw_fatal_dump_crspace_to(mfde_pl, fmsg);
fmsg); break;
case MLXSW_REG_MFDE_EVENT_ID_KVD_IM_STOP: case MLXSW_REG_MFDE_EVENT_ID_KVD_IM_STOP:
return mlxsw_core_health_fw_fatal_dump_kvd_im_stop(mfde_pl, mlxsw_core_health_fw_fatal_dump_kvd_im_stop(mfde_pl, fmsg);
fmsg); break;
case MLXSW_REG_MFDE_EVENT_ID_FW_ASSERT: case MLXSW_REG_MFDE_EVENT_ID_FW_ASSERT:
return mlxsw_core_health_fw_fatal_dump_fw_assert(mfde_pl, fmsg); mlxsw_core_health_fw_fatal_dump_fw_assert(mfde_pl, fmsg);
break;
case MLXSW_REG_MFDE_EVENT_ID_FATAL_CAUSE: case MLXSW_REG_MFDE_EVENT_ID_FATAL_CAUSE:
return mlxsw_core_health_fw_fatal_dump_fatal_cause(mfde_pl, mlxsw_core_health_fw_fatal_dump_fatal_cause(mfde_pl, fmsg);
fmsg); break;
} }
return 0; return 0;
......
...@@ -66,12 +66,12 @@ qed_fw_fatal_reporter_dump(struct devlink_health_reporter *reporter, ...@@ -66,12 +66,12 @@ qed_fw_fatal_reporter_dump(struct devlink_health_reporter *reporter,
return err; return err;
} }
err = devlink_fmsg_binary_pair_put(fmsg, "dump_data", devlink_fmsg_binary_pair_put(fmsg, "dump_data", p_dbg_data_buf,
p_dbg_data_buf, dbg_data_buf_size); dbg_data_buf_size);
vfree(p_dbg_data_buf); vfree(p_dbg_data_buf);
return err; return 0;
} }
static int static int
......
...@@ -63,91 +63,45 @@ nsim_dev_dummy_reporter_recover(struct devlink_health_reporter *reporter, ...@@ -63,91 +63,45 @@ nsim_dev_dummy_reporter_recover(struct devlink_health_reporter *reporter,
static int nsim_dev_dummy_fmsg_put(struct devlink_fmsg *fmsg, u32 binary_len) static int nsim_dev_dummy_fmsg_put(struct devlink_fmsg *fmsg, u32 binary_len)
{ {
char *binary; char *binary;
int err;
int i; int i;
err = devlink_fmsg_bool_pair_put(fmsg, "test_bool", true); devlink_fmsg_bool_pair_put(fmsg, "test_bool", true);
if (err) devlink_fmsg_u8_pair_put(fmsg, "test_u8", 1);
return err; devlink_fmsg_u32_pair_put(fmsg, "test_u32", 3);
err = devlink_fmsg_u8_pair_put(fmsg, "test_u8", 1); devlink_fmsg_u64_pair_put(fmsg, "test_u64", 4);
if (err) devlink_fmsg_string_pair_put(fmsg, "test_string", "somestring");
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "test_u32", 3);
if (err)
return err;
err = devlink_fmsg_u64_pair_put(fmsg, "test_u64", 4);
if (err)
return err;
err = devlink_fmsg_string_pair_put(fmsg, "test_string", "somestring");
if (err)
return err;
binary = kmalloc(binary_len, GFP_KERNEL | __GFP_NOWARN); binary = kmalloc(binary_len, GFP_KERNEL | __GFP_NOWARN);
if (!binary) if (!binary)
return -ENOMEM; return -ENOMEM;
get_random_bytes(binary, binary_len); get_random_bytes(binary, binary_len);
err = devlink_fmsg_binary_pair_put(fmsg, "test_binary", binary, binary_len); devlink_fmsg_binary_pair_put(fmsg, "test_binary", binary, binary_len);
kfree(binary); kfree(binary);
if (err)
return err;
err = devlink_fmsg_pair_nest_start(fmsg, "test_nest"); devlink_fmsg_pair_nest_start(fmsg, "test_nest");
if (err) devlink_fmsg_obj_nest_start(fmsg);
return err; devlink_fmsg_bool_pair_put(fmsg, "nested_test_bool", false);
err = devlink_fmsg_obj_nest_start(fmsg); devlink_fmsg_u8_pair_put(fmsg, "nested_test_u8", false);
if (err) devlink_fmsg_obj_nest_end(fmsg);
return err; devlink_fmsg_pair_nest_end(fmsg);
err = devlink_fmsg_bool_pair_put(fmsg, "nested_test_bool", false); devlink_fmsg_arr_pair_nest_end(fmsg);
if (err) devlink_fmsg_arr_pair_nest_start(fmsg, "test_u32_array");
return err;
err = devlink_fmsg_u8_pair_put(fmsg, "nested_test_u8", false);
if (err)
return err;
err = devlink_fmsg_obj_nest_end(fmsg);
if (err)
return err;
err = devlink_fmsg_pair_nest_end(fmsg);
if (err)
return err;
err = devlink_fmsg_arr_pair_nest_end(fmsg); for (i = 0; i < 10; i++)
if (err) devlink_fmsg_u32_put(fmsg, i);
return err; devlink_fmsg_arr_pair_nest_end(fmsg);
devlink_fmsg_arr_pair_nest_start(fmsg, "test_array_of_objects");
err = devlink_fmsg_arr_pair_nest_start(fmsg, "test_u32_array");
if (err)
return err;
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
err = devlink_fmsg_u32_put(fmsg, i); devlink_fmsg_obj_nest_start(fmsg);
if (err) devlink_fmsg_bool_pair_put(fmsg, "in_array_nested_test_bool",
return err;
}
err = devlink_fmsg_arr_pair_nest_end(fmsg);
if (err)
return err;
err = devlink_fmsg_arr_pair_nest_start(fmsg, "test_array_of_objects");
if (err)
return err;
for (i = 0; i < 10; i++) {
err = devlink_fmsg_obj_nest_start(fmsg);
if (err)
return err;
err = devlink_fmsg_bool_pair_put(fmsg,
"in_array_nested_test_bool",
false); false);
if (err) devlink_fmsg_u8_pair_put(fmsg, "in_array_nested_test_u8", i);
return err; devlink_fmsg_obj_nest_end(fmsg);
err = devlink_fmsg_u8_pair_put(fmsg,
"in_array_nested_test_u8",
i);
if (err)
return err;
err = devlink_fmsg_obj_nest_end(fmsg);
if (err)
return err;
} }
return devlink_fmsg_arr_pair_nest_end(fmsg); devlink_fmsg_arr_pair_nest_end(fmsg);
return 0;
} }
static int static int
...@@ -157,14 +111,10 @@ nsim_dev_dummy_reporter_dump(struct devlink_health_reporter *reporter, ...@@ -157,14 +111,10 @@ nsim_dev_dummy_reporter_dump(struct devlink_health_reporter *reporter,
{ {
struct nsim_dev_health *health = devlink_health_reporter_priv(reporter); struct nsim_dev_health *health = devlink_health_reporter_priv(reporter);
struct nsim_dev_dummy_reporter_ctx *ctx = priv_ctx; struct nsim_dev_dummy_reporter_ctx *ctx = priv_ctx;
int err;
if (ctx) { if (ctx)
err = devlink_fmsg_string_pair_put(fmsg, "break_message", devlink_fmsg_string_pair_put(fmsg, "break_message", ctx->break_msg);
ctx->break_msg);
if (err)
return err;
}
return nsim_dev_dummy_fmsg_put(fmsg, health->binary_len); return nsim_dev_dummy_fmsg_put(fmsg, health->binary_len);
} }
...@@ -174,15 +124,11 @@ nsim_dev_dummy_reporter_diagnose(struct devlink_health_reporter *reporter, ...@@ -174,15 +124,11 @@ nsim_dev_dummy_reporter_diagnose(struct devlink_health_reporter *reporter,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct nsim_dev_health *health = devlink_health_reporter_priv(reporter); struct nsim_dev_health *health = devlink_health_reporter_priv(reporter);
int err;
if (health->recovered_break_msg) { if (health->recovered_break_msg)
err = devlink_fmsg_string_pair_put(fmsg, devlink_fmsg_string_pair_put(fmsg, "recovered_break_message",
"recovered_break_message",
health->recovered_break_msg); health->recovered_break_msg);
if (err)
return err;
}
return nsim_dev_dummy_fmsg_put(fmsg, health->binary_len); return nsim_dev_dummy_fmsg_put(fmsg, health->binary_len);
} }
......
...@@ -2,51 +2,29 @@ ...@@ -2,51 +2,29 @@
#include "qlge.h" #include "qlge.h"
#include "qlge_devlink.h" #include "qlge_devlink.h"
static int qlge_fill_seg_(struct devlink_fmsg *fmsg, static void qlge_fill_seg_(struct devlink_fmsg *fmsg,
struct mpi_coredump_segment_header *seg_header, struct mpi_coredump_segment_header *seg_header,
u32 *reg_data) u32 *reg_data)
{ {
int regs_num = (seg_header->seg_size int regs_num = (seg_header->seg_size
- sizeof(struct mpi_coredump_segment_header)) / sizeof(u32); - sizeof(struct mpi_coredump_segment_header)) / sizeof(u32);
int err;
int i; int i;
err = devlink_fmsg_pair_nest_start(fmsg, seg_header->description); devlink_fmsg_pair_nest_start(fmsg, seg_header->description);
if (err) devlink_fmsg_obj_nest_start(fmsg);
return err; devlink_fmsg_u32_pair_put(fmsg, "segment", seg_header->seg_num);
err = devlink_fmsg_obj_nest_start(fmsg); devlink_fmsg_arr_pair_nest_start(fmsg, "values");
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "segment", seg_header->seg_num);
if (err)
return err;
err = devlink_fmsg_arr_pair_nest_start(fmsg, "values");
if (err)
return err;
for (i = 0; i < regs_num; i++) { for (i = 0; i < regs_num; i++) {
err = devlink_fmsg_u32_put(fmsg, *reg_data); devlink_fmsg_u32_put(fmsg, *reg_data);
if (err)
return err;
reg_data++; reg_data++;
} }
err = devlink_fmsg_obj_nest_end(fmsg); devlink_fmsg_obj_nest_end(fmsg);
if (err) devlink_fmsg_arr_pair_nest_end(fmsg);
return err; devlink_fmsg_pair_nest_end(fmsg);
err = devlink_fmsg_arr_pair_nest_end(fmsg);
if (err)
return err;
err = devlink_fmsg_pair_nest_end(fmsg);
return err;
} }
#define FILL_SEG(seg_hdr, seg_regs) \ #define FILL_SEG(seg_hdr, seg_regs) \
do { \ qlge_fill_seg_(fmsg, &dump->seg_hdr, dump->seg_regs)
err = qlge_fill_seg_(fmsg, &dump->seg_hdr, dump->seg_regs); \
if (err) { \
kvfree(dump); \
return err; \
} \
} while (0)
static int qlge_reporter_coredump(struct devlink_health_reporter *reporter, static int qlge_reporter_coredump(struct devlink_health_reporter *reporter,
struct devlink_fmsg *fmsg, void *priv_ctx, struct devlink_fmsg *fmsg, void *priv_ctx,
...@@ -114,14 +92,8 @@ static int qlge_reporter_coredump(struct devlink_health_reporter *reporter, ...@@ -114,14 +92,8 @@ static int qlge_reporter_coredump(struct devlink_health_reporter *reporter,
FILL_SEG(xfi_hss_tx_hdr, serdes_xfi_hss_tx); FILL_SEG(xfi_hss_tx_hdr, serdes_xfi_hss_tx);
FILL_SEG(xfi_hss_rx_hdr, serdes_xfi_hss_rx); FILL_SEG(xfi_hss_rx_hdr, serdes_xfi_hss_rx);
FILL_SEG(xfi_hss_pll_hdr, serdes_xfi_hss_pll); FILL_SEG(xfi_hss_pll_hdr, serdes_xfi_hss_pll);
qlge_fill_seg_(fmsg, &dump->misc_nic_seg_hdr,
err = qlge_fill_seg_(fmsg, &dump->misc_nic_seg_hdr,
(u32 *)&dump->misc_nic_info); (u32 *)&dump->misc_nic_info);
if (err) {
kvfree(dump);
return err;
}
FILL_SEG(intr_states_seg_hdr, intr_states); FILL_SEG(intr_states_seg_hdr, intr_states);
FILL_SEG(cam_entries_seg_hdr, cam_entries); FILL_SEG(cam_entries_seg_hdr, cam_entries);
FILL_SEG(nic_routing_words_seg_hdr, nic_routing_words); FILL_SEG(nic_routing_words_seg_hdr, nic_routing_words);
...@@ -140,7 +112,7 @@ static int qlge_reporter_coredump(struct devlink_health_reporter *reporter, ...@@ -140,7 +112,7 @@ static int qlge_reporter_coredump(struct devlink_health_reporter *reporter,
FILL_SEG(sem_regs_seg_hdr, sem_regs); FILL_SEG(sem_regs_seg_hdr, sem_regs);
kvfree(dump); kvfree(dump);
return err; return 0;
} }
static const struct devlink_health_reporter_ops qlge_reporter_ops = { static const struct devlink_health_reporter_ops qlge_reporter_ops = {
......
...@@ -1854,35 +1854,35 @@ int devlink_info_version_running_put_ext(struct devlink_info_req *req, ...@@ -1854,35 +1854,35 @@ int devlink_info_version_running_put_ext(struct devlink_info_req *req,
const char *version_value, const char *version_value,
enum devlink_info_version_type version_type); enum devlink_info_version_type version_type);
int devlink_fmsg_obj_nest_start(struct devlink_fmsg *fmsg); void devlink_fmsg_obj_nest_start(struct devlink_fmsg *fmsg);
int devlink_fmsg_obj_nest_end(struct devlink_fmsg *fmsg); void devlink_fmsg_obj_nest_end(struct devlink_fmsg *fmsg);
int devlink_fmsg_pair_nest_start(struct devlink_fmsg *fmsg, const char *name); void devlink_fmsg_pair_nest_start(struct devlink_fmsg *fmsg, const char *name);
int devlink_fmsg_pair_nest_end(struct devlink_fmsg *fmsg); void devlink_fmsg_pair_nest_end(struct devlink_fmsg *fmsg);
int devlink_fmsg_arr_pair_nest_start(struct devlink_fmsg *fmsg, void devlink_fmsg_arr_pair_nest_start(struct devlink_fmsg *fmsg,
const char *name); const char *name);
int devlink_fmsg_arr_pair_nest_end(struct devlink_fmsg *fmsg); void devlink_fmsg_arr_pair_nest_end(struct devlink_fmsg *fmsg);
int devlink_fmsg_binary_pair_nest_start(struct devlink_fmsg *fmsg, void devlink_fmsg_binary_pair_nest_start(struct devlink_fmsg *fmsg,
const char *name); const char *name);
int devlink_fmsg_binary_pair_nest_end(struct devlink_fmsg *fmsg); void devlink_fmsg_binary_pair_nest_end(struct devlink_fmsg *fmsg);
int devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value); void devlink_fmsg_u32_put(struct devlink_fmsg *fmsg, u32 value);
int devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value); void devlink_fmsg_string_put(struct devlink_fmsg *fmsg, const char *value);
int devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value, void devlink_fmsg_binary_put(struct devlink_fmsg *fmsg, const void *value,
u16 value_len); u16 value_len);
int devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name, void devlink_fmsg_bool_pair_put(struct devlink_fmsg *fmsg, const char *name,
bool value); bool value);
int devlink_fmsg_u8_pair_put(struct devlink_fmsg *fmsg, const char *name, void devlink_fmsg_u8_pair_put(struct devlink_fmsg *fmsg, const char *name,
u8 value); u8 value);
int devlink_fmsg_u32_pair_put(struct devlink_fmsg *fmsg, const char *name, void devlink_fmsg_u32_pair_put(struct devlink_fmsg *fmsg, const char *name,
u32 value); u32 value);
int devlink_fmsg_u64_pair_put(struct devlink_fmsg *fmsg, const char *name, void devlink_fmsg_u64_pair_put(struct devlink_fmsg *fmsg, const char *name,
u64 value); u64 value);
int devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name, void devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name,
const char *value); const char *value);
int devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name, void devlink_fmsg_binary_pair_put(struct devlink_fmsg *fmsg, const char *name,
const void *value, u32 value_len); const void *value, u32 value_len);
struct devlink_health_reporter * struct devlink_health_reporter *
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment