Commit d17f98bf authored by Przemek Kitszel's avatar Przemek Kitszel Committed by David S. Miller

net/mlx5: devlink health: use retained error fmsg API

Drop unneeded error checking.

devlink_fmsg_*() family of functions is now retaining errors,
so there is no need to check for them after each call.
Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1d434b48
...@@ -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; VNIC_ENV_GET(&vnic, async_eq_overrun));
err = devlink_fmsg_u32_pair_put(fmsg, "async_eq_overrun",
VNIC_ENV_GET(&vnic, async_eq_overrun));
if (err)
return err;
}
if (MLX5_CAP_GEN(dev, vnic_env_cq_overrun)) {
err = devlink_fmsg_u32_pair_put(fmsg, "cq_overrun",
VNIC_ENV_GET(&vnic, cq_overrun));
if (err)
return err;
}
if (MLX5_CAP_GEN(dev, invalid_command_count)) {
err = devlink_fmsg_u32_pair_put(fmsg, "invalid_command",
VNIC_ENV_GET(&vnic, invalid_command));
if (err)
return err;
}
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));
if (err)
return err;
} }
if (MLX5_CAP_GEN(dev, vnic_env_cq_overrun))
if (MLX5_CAP_GEN(dev, nic_receive_steering_discard)) { devlink_fmsg_u32_pair_put(fmsg, "cq_overrun",
err = devlink_fmsg_u64_pair_put(fmsg, "nic_receive_steering_discard", VNIC_ENV_GET(&vnic, cq_overrun));
VNIC_ENV_GET64(&vnic, if (MLX5_CAP_GEN(dev, invalid_command_count))
nic_receive_steering_discard)); devlink_fmsg_u32_pair_put(fmsg, "invalid_command",
if (err) VNIC_ENV_GET(&vnic, invalid_command));
return err; if (MLX5_CAP_GEN(dev, quota_exceeded_count))
} devlink_fmsg_u32_pair_put(fmsg, "quota_exceeded_command",
VNIC_ENV_GET(&vnic, quota_exceeded_command));
if (MLX5_CAP_GEN(dev, nic_receive_steering_discard))
devlink_fmsg_u64_pair_put(fmsg, "nic_receive_steering_discard",
VNIC_ENV_GET64(&vnic, nic_receive_steering_discard));
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) VNIC_ENV_GET64(&vnic, handled_pkt_steering_fail));
return err;
err = devlink_fmsg_u64_pair_put(fmsg, "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,8 +9,8 @@ ...@@ -9,8 +9,8 @@
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);
#endif /* __MLX5_REPORTER_VNIC_H */ #endif /* __MLX5_REPORTER_VNIC_H */
...@@ -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
...@@ -199,78 +199,38 @@ static int mlx5e_rx_reporter_recover(struct devlink_health_reporter *reporter, ...@@ -199,78 +199,38 @@ static int mlx5e_rx_reporter_recover(struct devlink_health_reporter *reporter,
mlx5e_health_recover_channels(priv); mlx5e_health_recover_channels(priv);
} }
static int mlx5e_reporter_icosq_diagnose(struct mlx5e_icosq *icosq, u8 hw_state, static void mlx5e_reporter_icosq_diagnose(struct mlx5e_icosq *icosq, u8 hw_state,
struct devlink_fmsg *fmsg) struct devlink_fmsg *fmsg)
{ {
int err; mlx5e_health_fmsg_named_obj_nest_start(fmsg, "ICOSQ");
devlink_fmsg_u32_pair_put(fmsg, "sqn", icosq->sqn);
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "ICOSQ"); devlink_fmsg_u8_pair_put(fmsg, "HW state", hw_state);
if (err) devlink_fmsg_u32_pair_put(fmsg, "cc", icosq->cc);
return err; devlink_fmsg_u32_pair_put(fmsg, "pc", icosq->pc);
devlink_fmsg_u32_pair_put(fmsg, "WQE size", mlx5_wq_cyc_get_size(&icosq->wq));
err = devlink_fmsg_u32_pair_put(fmsg, "sqn", icosq->sqn);
if (err) mlx5e_health_fmsg_named_obj_nest_start(fmsg, "CQ");
return err; devlink_fmsg_u32_pair_put(fmsg, "cqn", icosq->cq.mcq.cqn);
devlink_fmsg_u32_pair_put(fmsg, "cc", icosq->cq.wq.cc);
err = devlink_fmsg_u8_pair_put(fmsg, "HW state", hw_state); devlink_fmsg_u32_pair_put(fmsg, "size", mlx5_cqwq_get_size(&icosq->cq.wq));
if (err) mlx5e_health_fmsg_named_obj_nest_end(fmsg);
return err;
mlx5e_health_fmsg_named_obj_nest_end(fmsg);
err = devlink_fmsg_u32_pair_put(fmsg, "cc", icosq->cc);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "pc", icosq->pc);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "WQE size",
mlx5_wq_cyc_get_size(&icosq->wq));
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "CQ");
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "cqn", icosq->cq.mcq.cqn);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "cc", icosq->cq.wq.cc);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "size", mlx5_cqwq_get_size(&icosq->cq.wq));
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
return mlx5e_health_fmsg_named_obj_nest_end(fmsg);
} }
static int mlx5e_health_rq_put_sw_state(struct devlink_fmsg *fmsg, struct mlx5e_rq *rq) static void mlx5e_health_rq_put_sw_state(struct devlink_fmsg *fmsg, struct mlx5e_rq *rq)
{ {
int err;
int i; int i;
BUILD_BUG_ON_MSG(ARRAY_SIZE(rq_sw_state_type_name) != MLX5E_NUM_RQ_STATES, BUILD_BUG_ON_MSG(ARRAY_SIZE(rq_sw_state_type_name) != MLX5E_NUM_RQ_STATES,
"rq_sw_state_type_name string array must be consistent with MLX5E_RQ_STATE_* enum in en.h"); "rq_sw_state_type_name string array must be consistent with MLX5E_RQ_STATE_* enum in en.h");
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SW State"); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SW State");
if (err)
return err;
for (i = 0; i < ARRAY_SIZE(rq_sw_state_type_name); ++i) { for (i = 0; i < ARRAY_SIZE(rq_sw_state_type_name); ++i)
err = devlink_fmsg_u32_pair_put(fmsg, rq_sw_state_type_name[i], devlink_fmsg_u32_pair_put(fmsg, rq_sw_state_type_name[i],
test_bit(i, &rq->state)); test_bit(i, &rq->state));
if (err)
return err;
}
return mlx5e_health_fmsg_named_obj_nest_end(fmsg); mlx5e_health_fmsg_named_obj_nest_end(fmsg);
} }
static int static int
...@@ -291,184 +251,89 @@ mlx5e_rx_reporter_build_diagnose_output_rq_common(struct mlx5e_rq *rq, ...@@ -291,184 +251,89 @@ mlx5e_rx_reporter_build_diagnose_output_rq_common(struct mlx5e_rq *rq,
wq_head = mlx5e_rqwq_get_head(rq); wq_head = mlx5e_rqwq_get_head(rq);
wqe_counter = mlx5e_rqwq_get_wqe_counter(rq); wqe_counter = mlx5e_rqwq_get_wqe_counter(rq);
err = devlink_fmsg_u32_pair_put(fmsg, "rqn", rq->rqn); devlink_fmsg_u32_pair_put(fmsg, "rqn", rq->rqn);
if (err) devlink_fmsg_u8_pair_put(fmsg, "HW state", hw_state);
return err; devlink_fmsg_u32_pair_put(fmsg, "WQE counter", wqe_counter);
devlink_fmsg_u32_pair_put(fmsg, "posted WQEs", wqes_sz);
err = devlink_fmsg_u8_pair_put(fmsg, "HW state", hw_state); devlink_fmsg_u32_pair_put(fmsg, "cc", wq_head);
if (err) mlx5e_health_rq_put_sw_state(fmsg, rq);
return err; mlx5e_health_cq_diag_fmsg(&rq->cq, fmsg);
mlx5e_health_eq_diag_fmsg(rq->cq.mcq.eq, fmsg);
err = devlink_fmsg_u32_pair_put(fmsg, "WQE counter", wqe_counter);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "posted WQEs", wqes_sz);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "cc", wq_head);
if (err)
return err;
err = mlx5e_health_rq_put_sw_state(fmsg, rq);
if (err)
return err;
err = mlx5e_health_cq_diag_fmsg(&rq->cq, fmsg);
if (err)
return err;
err = mlx5e_health_eq_diag_fmsg(rq->cq.mcq.eq, fmsg);
if (err)
return err;
if (rq->icosq) { if (rq->icosq) {
struct mlx5e_icosq *icosq = rq->icosq; struct mlx5e_icosq *icosq = rq->icosq;
u8 icosq_hw_state; u8 icosq_hw_state;
err = mlx5_core_query_sq_state(rq->mdev, icosq->sqn, &icosq_hw_state); mlx5_core_query_sq_state(rq->mdev, icosq->sqn, &icosq_hw_state);
if (err) mlx5e_reporter_icosq_diagnose(icosq, icosq_hw_state, fmsg);
return err;
err = mlx5e_reporter_icosq_diagnose(icosq, icosq_hw_state, fmsg);
if (err)
return err;
} }
return 0; return 0;
} }
static int mlx5e_rx_reporter_build_diagnose_output(struct mlx5e_rq *rq, static void mlx5e_rx_reporter_build_diagnose_output(struct mlx5e_rq *rq,
struct devlink_fmsg *fmsg) struct devlink_fmsg *fmsg)
{ {
int err; devlink_fmsg_obj_nest_start(fmsg);
devlink_fmsg_u32_pair_put(fmsg, "channel ix", rq->ix);
err = devlink_fmsg_obj_nest_start(fmsg); mlx5e_rx_reporter_build_diagnose_output_rq_common(rq, fmsg);
if (err) devlink_fmsg_obj_nest_end(fmsg);
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "channel ix", rq->ix);
if (err)
return err;
err = mlx5e_rx_reporter_build_diagnose_output_rq_common(rq, fmsg);
if (err)
return err;
return devlink_fmsg_obj_nest_end(fmsg);
} }
static int mlx5e_rx_reporter_diagnose_generic_rq(struct mlx5e_rq *rq, static void mlx5e_rx_reporter_diagnose_generic_rq(struct mlx5e_rq *rq,
struct devlink_fmsg *fmsg) struct devlink_fmsg *fmsg)
{ {
struct mlx5e_priv *priv = rq->priv; struct mlx5e_priv *priv = rq->priv;
struct mlx5e_params *params; struct mlx5e_params *params;
u32 rq_stride, rq_sz; u32 rq_stride, rq_sz;
bool real_time; bool real_time;
int err;
params = &priv->channels.params; params = &priv->channels.params;
rq_sz = mlx5e_rqwq_get_size(rq); rq_sz = mlx5e_rqwq_get_size(rq);
real_time = mlx5_is_real_time_rq(priv->mdev); real_time = mlx5_is_real_time_rq(priv->mdev);
rq_stride = BIT(mlx5e_mpwqe_get_log_stride_size(priv->mdev, params, NULL)); rq_stride = BIT(mlx5e_mpwqe_get_log_stride_size(priv->mdev, params, NULL));
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RQ"); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RQ");
if (err) devlink_fmsg_u8_pair_put(fmsg, "type", params->rq_wq_type);
return err; devlink_fmsg_u64_pair_put(fmsg, "stride size", rq_stride);
devlink_fmsg_u32_pair_put(fmsg, "size", rq_sz);
err = devlink_fmsg_u8_pair_put(fmsg, "type", params->rq_wq_type); devlink_fmsg_string_pair_put(fmsg, "ts_format", real_time ? "RT" : "FRC");
if (err) mlx5e_health_cq_common_diag_fmsg(&rq->cq, fmsg);
return err; mlx5e_health_fmsg_named_obj_nest_end(fmsg);
err = devlink_fmsg_u64_pair_put(fmsg, "stride size", rq_stride);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "size", rq_sz);
if (err)
return err;
err = devlink_fmsg_string_pair_put(fmsg, "ts_format", real_time ? "RT" : "FRC");
if (err)
return err;
err = mlx5e_health_cq_common_diag_fmsg(&rq->cq, fmsg);
if (err)
return err;
return mlx5e_health_fmsg_named_obj_nest_end(fmsg);
} }
static int static void
mlx5e_rx_reporter_diagnose_common_ptp_config(struct mlx5e_priv *priv, struct mlx5e_ptp *ptp_ch, mlx5e_rx_reporter_diagnose_common_ptp_config(struct mlx5e_priv *priv, struct mlx5e_ptp *ptp_ch,
struct devlink_fmsg *fmsg) struct devlink_fmsg *fmsg)
{ {
int err; mlx5e_health_fmsg_named_obj_nest_start(fmsg, "PTP");
devlink_fmsg_u32_pair_put(fmsg, "filter_type", priv->tstamp.rx_filter);
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "PTP"); mlx5e_rx_reporter_diagnose_generic_rq(&ptp_ch->rq, fmsg);
if (err) mlx5e_health_fmsg_named_obj_nest_end(fmsg);
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "filter_type", priv->tstamp.rx_filter);
if (err)
return err;
err = mlx5e_rx_reporter_diagnose_generic_rq(&ptp_ch->rq, fmsg);
if (err)
return err;
return mlx5e_health_fmsg_named_obj_nest_end(fmsg);
} }
static int static void
mlx5e_rx_reporter_diagnose_common_config(struct devlink_health_reporter *reporter, mlx5e_rx_reporter_diagnose_common_config(struct devlink_health_reporter *reporter,
struct devlink_fmsg *fmsg) struct devlink_fmsg *fmsg)
{ {
struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter); struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter);
struct mlx5e_rq *generic_rq = &priv->channels.c[0]->rq; struct mlx5e_rq *generic_rq = &priv->channels.c[0]->rq;
struct mlx5e_ptp *ptp_ch = priv->channels.ptp; struct mlx5e_ptp *ptp_ch = priv->channels.ptp;
int err;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "Common config");
if (err)
return err;
err = mlx5e_rx_reporter_diagnose_generic_rq(generic_rq, fmsg);
if (err)
return err;
if (ptp_ch && test_bit(MLX5E_PTP_STATE_RX, ptp_ch->state)) {
err = mlx5e_rx_reporter_diagnose_common_ptp_config(priv, ptp_ch, fmsg);
if (err)
return err;
}
return mlx5e_health_fmsg_named_obj_nest_end(fmsg); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "Common config");
mlx5e_rx_reporter_diagnose_generic_rq(generic_rq, fmsg);
if (ptp_ch && test_bit(MLX5E_PTP_STATE_RX, ptp_ch->state))
mlx5e_rx_reporter_diagnose_common_ptp_config(priv, ptp_ch, fmsg);
mlx5e_health_fmsg_named_obj_nest_end(fmsg);
} }
static int mlx5e_rx_reporter_build_diagnose_output_ptp_rq(struct mlx5e_rq *rq, static void mlx5e_rx_reporter_build_diagnose_output_ptp_rq(struct mlx5e_rq *rq,
struct devlink_fmsg *fmsg) struct devlink_fmsg *fmsg)
{ {
int err; devlink_fmsg_obj_nest_start(fmsg);
devlink_fmsg_string_pair_put(fmsg, "channel", "ptp");
err = devlink_fmsg_obj_nest_start(fmsg); mlx5e_rx_reporter_build_diagnose_output_rq_common(rq, fmsg);
if (err) devlink_fmsg_obj_nest_end(fmsg);
return err;
err = devlink_fmsg_string_pair_put(fmsg, "channel", "ptp");
if (err)
return err;
err = mlx5e_rx_reporter_build_diagnose_output_rq_common(rq, fmsg);
if (err)
return err;
err = devlink_fmsg_obj_nest_end(fmsg);
if (err)
return err;
return 0;
} }
static int mlx5e_rx_reporter_diagnose(struct devlink_health_reporter *reporter, static int mlx5e_rx_reporter_diagnose(struct devlink_health_reporter *reporter,
...@@ -477,20 +342,15 @@ static int mlx5e_rx_reporter_diagnose(struct devlink_health_reporter *reporter, ...@@ -477,20 +342,15 @@ static int mlx5e_rx_reporter_diagnose(struct devlink_health_reporter *reporter,
{ {
struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter); struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter);
struct mlx5e_ptp *ptp_ch = priv->channels.ptp; struct mlx5e_ptp *ptp_ch = priv->channels.ptp;
int i, err = 0; int i;
mutex_lock(&priv->state_lock); mutex_lock(&priv->state_lock);
if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
goto unlock; goto unlock;
err = mlx5e_rx_reporter_diagnose_common_config(reporter, fmsg); mlx5e_rx_reporter_diagnose_common_config(reporter, fmsg);
if (err) devlink_fmsg_arr_pair_nest_start(fmsg, "RQs");
goto unlock;
err = devlink_fmsg_arr_pair_nest_start(fmsg, "RQs");
if (err)
goto unlock;
for (i = 0; i < priv->channels.num; i++) { for (i = 0; i < priv->channels.num; i++) {
struct mlx5e_channel *c = priv->channels.c[i]; struct mlx5e_channel *c = priv->channels.c[i];
...@@ -499,19 +359,14 @@ static int mlx5e_rx_reporter_diagnose(struct devlink_health_reporter *reporter, ...@@ -499,19 +359,14 @@ static int mlx5e_rx_reporter_diagnose(struct devlink_health_reporter *reporter,
rq = test_bit(MLX5E_CHANNEL_STATE_XSK, c->state) ? rq = test_bit(MLX5E_CHANNEL_STATE_XSK, c->state) ?
&c->xskrq : &c->rq; &c->xskrq : &c->rq;
err = mlx5e_rx_reporter_build_diagnose_output(rq, fmsg); mlx5e_rx_reporter_build_diagnose_output(rq, fmsg);
if (err)
goto unlock;
}
if (ptp_ch && test_bit(MLX5E_PTP_STATE_RX, ptp_ch->state)) {
err = mlx5e_rx_reporter_build_diagnose_output_ptp_rq(&ptp_ch->rq, fmsg);
if (err)
goto unlock;
} }
err = devlink_fmsg_arr_pair_nest_end(fmsg); if (ptp_ch && test_bit(MLX5E_PTP_STATE_RX, ptp_ch->state))
mlx5e_rx_reporter_build_diagnose_output_ptp_rq(&ptp_ch->rq, fmsg);
devlink_fmsg_arr_pair_nest_end(fmsg);
unlock: unlock:
mutex_unlock(&priv->state_lock); mutex_unlock(&priv->state_lock);
return err; return 0;
} }
static int mlx5e_rx_reporter_dump_icosq(struct mlx5e_priv *priv, struct devlink_fmsg *fmsg, static int mlx5e_rx_reporter_dump_icosq(struct mlx5e_priv *priv, struct devlink_fmsg *fmsg,
...@@ -519,61 +374,34 @@ static int mlx5e_rx_reporter_dump_icosq(struct mlx5e_priv *priv, struct devlink_ ...@@ -519,61 +374,34 @@ static int mlx5e_rx_reporter_dump_icosq(struct mlx5e_priv *priv, struct devlink_
{ {
struct mlx5e_txqsq *icosq = ctx; struct mlx5e_txqsq *icosq = ctx;
struct mlx5_rsc_key key = {}; struct mlx5_rsc_key key = {};
int err;
if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
return 0; return 0;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SX Slice"); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SX Slice");
if (err)
return err;
key.size = PAGE_SIZE; key.size = PAGE_SIZE;
key.rsc = MLX5_SGMT_TYPE_SX_SLICE_ALL; key.rsc = MLX5_SGMT_TYPE_SX_SLICE_ALL;
err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg); mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
if (err) mlx5e_health_fmsg_named_obj_nest_end(fmsg);
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "ICOSQ");
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "ICOSQ");
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "QPC");
if (err)
return err;
mlx5e_health_fmsg_named_obj_nest_start(fmsg, "QPC");
key.rsc = MLX5_SGMT_TYPE_FULL_QPC; key.rsc = MLX5_SGMT_TYPE_FULL_QPC;
key.index1 = icosq->sqn; key.index1 = icosq->sqn;
key.num_of_obj1 = 1; key.num_of_obj1 = 1;
mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
mlx5e_health_fmsg_named_obj_nest_end(fmsg);
err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "send_buff");
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "send_buff");
if (err)
return err;
key.rsc = MLX5_SGMT_TYPE_SND_BUFF; key.rsc = MLX5_SGMT_TYPE_SND_BUFF;
key.num_of_obj2 = MLX5_RSC_DUMP_ALL; key.num_of_obj2 = MLX5_RSC_DUMP_ALL;
mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
mlx5e_health_fmsg_named_obj_nest_end(fmsg);
err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg); mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
return mlx5e_health_fmsg_named_obj_nest_end(fmsg); return 0;
} }
static int mlx5e_rx_reporter_dump_rq(struct mlx5e_priv *priv, struct devlink_fmsg *fmsg, static int mlx5e_rx_reporter_dump_rq(struct mlx5e_priv *priv, struct devlink_fmsg *fmsg,
...@@ -581,60 +409,34 @@ static int mlx5e_rx_reporter_dump_rq(struct mlx5e_priv *priv, struct devlink_fms ...@@ -581,60 +409,34 @@ static int mlx5e_rx_reporter_dump_rq(struct mlx5e_priv *priv, struct devlink_fms
{ {
struct mlx5_rsc_key key = {}; struct mlx5_rsc_key key = {};
struct mlx5e_rq *rq = ctx; struct mlx5e_rq *rq = ctx;
int err;
if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
return 0; return 0;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RX Slice"); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RX Slice");
if (err)
return err;
key.size = PAGE_SIZE; key.size = PAGE_SIZE;
key.rsc = MLX5_SGMT_TYPE_RX_SLICE_ALL; key.rsc = MLX5_SGMT_TYPE_RX_SLICE_ALL;
err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg); mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
if (err) mlx5e_health_fmsg_named_obj_nest_end(fmsg);
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RQ");
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RQ");
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "QPC");
if (err)
return err;
mlx5e_health_fmsg_named_obj_nest_start(fmsg, "QPC");
key.rsc = MLX5_SGMT_TYPE_FULL_QPC; key.rsc = MLX5_SGMT_TYPE_FULL_QPC;
key.index1 = rq->rqn; key.index1 = rq->rqn;
key.num_of_obj1 = 1; key.num_of_obj1 = 1;
mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
mlx5e_health_fmsg_named_obj_nest_end(fmsg);
err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "receive_buff");
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "receive_buff");
if (err)
return err;
key.rsc = MLX5_SGMT_TYPE_RCV_BUFF; key.rsc = MLX5_SGMT_TYPE_RCV_BUFF;
key.num_of_obj2 = MLX5_RSC_DUMP_ALL; key.num_of_obj2 = MLX5_RSC_DUMP_ALL;
err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg); mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
if (err) mlx5e_health_fmsg_named_obj_nest_end(fmsg);
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg); mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
return mlx5e_health_fmsg_named_obj_nest_end(fmsg); return 0;
} }
static int mlx5e_rx_reporter_dump_all_rqs(struct mlx5e_priv *priv, static int mlx5e_rx_reporter_dump_all_rqs(struct mlx5e_priv *priv,
...@@ -642,44 +444,28 @@ static int mlx5e_rx_reporter_dump_all_rqs(struct mlx5e_priv *priv, ...@@ -642,44 +444,28 @@ static int mlx5e_rx_reporter_dump_all_rqs(struct mlx5e_priv *priv,
{ {
struct mlx5e_ptp *ptp_ch = priv->channels.ptp; struct mlx5e_ptp *ptp_ch = priv->channels.ptp;
struct mlx5_rsc_key key = {}; struct mlx5_rsc_key key = {};
int i, err;
if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
return 0; return 0;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RX Slice"); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "RX Slice");
if (err)
return err;
key.size = PAGE_SIZE; key.size = PAGE_SIZE;
key.rsc = MLX5_SGMT_TYPE_RX_SLICE_ALL; key.rsc = MLX5_SGMT_TYPE_RX_SLICE_ALL;
err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg); mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
if (err) mlx5e_health_fmsg_named_obj_nest_end(fmsg);
return err; devlink_fmsg_arr_pair_nest_start(fmsg, "RQs");
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
err = devlink_fmsg_arr_pair_nest_start(fmsg, "RQs"); for (int i = 0; i < priv->channels.num; i++) {
if (err)
return err;
for (i = 0; i < priv->channels.num; i++) {
struct mlx5e_rq *rq = &priv->channels.c[i]->rq; struct mlx5e_rq *rq = &priv->channels.c[i]->rq;
err = mlx5e_health_queue_dump(priv, fmsg, rq->rqn, "RQ"); mlx5e_health_queue_dump(priv, fmsg, rq->rqn, "RQ");
if (err)
return err;
} }
if (ptp_ch && test_bit(MLX5E_PTP_STATE_RX, ptp_ch->state)) { if (ptp_ch && test_bit(MLX5E_PTP_STATE_RX, ptp_ch->state))
err = mlx5e_health_queue_dump(priv, fmsg, ptp_ch->rq.rqn, "PTP RQ"); mlx5e_health_queue_dump(priv, fmsg, ptp_ch->rq.rqn, "PTP RQ");
if (err)
return err;
}
return devlink_fmsg_arr_pair_nest_end(fmsg); devlink_fmsg_arr_pair_nest_end(fmsg);
return 0;
} }
static int mlx5e_rx_reporter_dump_from_ctx(struct mlx5e_priv *priv, static int mlx5e_rx_reporter_dump_from_ctx(struct mlx5e_priv *priv,
......
...@@ -50,25 +50,19 @@ static void mlx5e_reset_txqsq_cc_pc(struct mlx5e_txqsq *sq) ...@@ -50,25 +50,19 @@ static void mlx5e_reset_txqsq_cc_pc(struct mlx5e_txqsq *sq)
sq->pc = 0; sq->pc = 0;
} }
static int mlx5e_health_sq_put_sw_state(struct devlink_fmsg *fmsg, struct mlx5e_txqsq *sq) static void mlx5e_health_sq_put_sw_state(struct devlink_fmsg *fmsg, struct mlx5e_txqsq *sq)
{ {
int err;
int i; int i;
BUILD_BUG_ON_MSG(ARRAY_SIZE(sq_sw_state_type_name) != MLX5E_NUM_SQ_STATES, BUILD_BUG_ON_MSG(ARRAY_SIZE(sq_sw_state_type_name) != MLX5E_NUM_SQ_STATES,
"sq_sw_state_type_name string array must be consistent with MLX5E_SQ_STATE_* enum in en.h"); "sq_sw_state_type_name string array must be consistent with MLX5E_SQ_STATE_* enum in en.h");
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SW State"); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SW State");
if (err)
return err;
for (i = 0; i < ARRAY_SIZE(sq_sw_state_type_name); ++i) { for (i = 0; i < ARRAY_SIZE(sq_sw_state_type_name); ++i)
err = devlink_fmsg_u32_pair_put(fmsg, sq_sw_state_type_name[i], devlink_fmsg_u32_pair_put(fmsg, sq_sw_state_type_name[i],
test_bit(i, &sq->state)); test_bit(i, &sq->state));
if (err)
return err;
}
return mlx5e_health_fmsg_named_obj_nest_end(fmsg); mlx5e_health_fmsg_named_obj_nest_end(fmsg);
} }
static int mlx5e_tx_reporter_err_cqe_recover(void *ctx) static int mlx5e_tx_reporter_err_cqe_recover(void *ctx)
...@@ -220,173 +214,76 @@ static int mlx5e_tx_reporter_recover(struct devlink_health_reporter *reporter, ...@@ -220,173 +214,76 @@ static int mlx5e_tx_reporter_recover(struct devlink_health_reporter *reporter,
mlx5e_health_recover_channels(priv); mlx5e_health_recover_channels(priv);
} }
static int static void
mlx5e_tx_reporter_build_diagnose_output_sq_common(struct devlink_fmsg *fmsg, mlx5e_tx_reporter_build_diagnose_output_sq_common(struct devlink_fmsg *fmsg,
struct mlx5e_txqsq *sq, int tc) struct mlx5e_txqsq *sq, int tc)
{ {
bool stopped = netif_xmit_stopped(sq->txq); bool stopped = netif_xmit_stopped(sq->txq);
struct mlx5e_priv *priv = sq->priv; struct mlx5e_priv *priv = sq->priv;
u8 state; u8 state;
int err;
err = mlx5_core_query_sq_state(priv->mdev, sq->sqn, &state);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "tc", tc);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "txq ix", sq->txq_ix); mlx5_core_query_sq_state(priv->mdev, sq->sqn, &state);
if (err) devlink_fmsg_u32_pair_put(fmsg, "tc", tc);
return err; devlink_fmsg_u32_pair_put(fmsg, "txq ix", sq->txq_ix);
devlink_fmsg_u32_pair_put(fmsg, "sqn", sq->sqn);
err = devlink_fmsg_u32_pair_put(fmsg, "sqn", sq->sqn); devlink_fmsg_u8_pair_put(fmsg, "HW state", state);
if (err) devlink_fmsg_bool_pair_put(fmsg, "stopped", stopped);
return err; devlink_fmsg_u32_pair_put(fmsg, "cc", sq->cc);
devlink_fmsg_u32_pair_put(fmsg, "pc", sq->pc);
err = devlink_fmsg_u8_pair_put(fmsg, "HW state", state); mlx5e_health_sq_put_sw_state(fmsg, sq);
if (err) mlx5e_health_cq_diag_fmsg(&sq->cq, fmsg);
return err; mlx5e_health_eq_diag_fmsg(sq->cq.mcq.eq, fmsg);
err = devlink_fmsg_bool_pair_put(fmsg, "stopped", stopped);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "cc", sq->cc);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "pc", sq->pc);
if (err)
return err;
err = mlx5e_health_sq_put_sw_state(fmsg, sq);
if (err)
return err;
err = mlx5e_health_cq_diag_fmsg(&sq->cq, fmsg);
if (err)
return err;
return mlx5e_health_eq_diag_fmsg(sq->cq.mcq.eq, fmsg);
} }
static int static void
mlx5e_tx_reporter_build_diagnose_output(struct devlink_fmsg *fmsg, mlx5e_tx_reporter_build_diagnose_output(struct devlink_fmsg *fmsg,
struct mlx5e_txqsq *sq, int tc) struct mlx5e_txqsq *sq, int tc)
{ {
int err; devlink_fmsg_obj_nest_start(fmsg);
devlink_fmsg_u32_pair_put(fmsg, "channel ix", sq->ch_ix);
err = devlink_fmsg_obj_nest_start(fmsg); mlx5e_tx_reporter_build_diagnose_output_sq_common(fmsg, sq, tc);
if (err) devlink_fmsg_obj_nest_end(fmsg);
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "channel ix", sq->ch_ix);
if (err)
return err;
err = mlx5e_tx_reporter_build_diagnose_output_sq_common(fmsg, sq, tc);
if (err)
return err;
err = devlink_fmsg_obj_nest_end(fmsg);
if (err)
return err;
return 0;
} }
static int static void
mlx5e_tx_reporter_build_diagnose_output_ptpsq(struct devlink_fmsg *fmsg, mlx5e_tx_reporter_build_diagnose_output_ptpsq(struct devlink_fmsg *fmsg,
struct mlx5e_ptpsq *ptpsq, int tc) struct mlx5e_ptpsq *ptpsq, int tc)
{ {
int err; devlink_fmsg_obj_nest_start(fmsg);
devlink_fmsg_string_pair_put(fmsg, "channel", "ptp");
err = devlink_fmsg_obj_nest_start(fmsg); mlx5e_tx_reporter_build_diagnose_output_sq_common(fmsg, &ptpsq->txqsq, tc);
if (err) mlx5e_health_fmsg_named_obj_nest_start(fmsg, "Port TS");
return err; mlx5e_health_cq_diag_fmsg(&ptpsq->ts_cq, fmsg);
mlx5e_health_fmsg_named_obj_nest_end(fmsg);
err = devlink_fmsg_string_pair_put(fmsg, "channel", "ptp"); devlink_fmsg_obj_nest_end(fmsg);
if (err)
return err;
err = mlx5e_tx_reporter_build_diagnose_output_sq_common(fmsg, &ptpsq->txqsq, tc);
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "Port TS");
if (err)
return err;
err = mlx5e_health_cq_diag_fmsg(&ptpsq->ts_cq, fmsg);
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
err = devlink_fmsg_obj_nest_end(fmsg);
if (err)
return err;
return 0;
} }
static int static void
mlx5e_tx_reporter_diagnose_generic_txqsq(struct devlink_fmsg *fmsg, mlx5e_tx_reporter_diagnose_generic_txqsq(struct devlink_fmsg *fmsg,
struct mlx5e_txqsq *txqsq) struct mlx5e_txqsq *txqsq)
{ {
u32 sq_stride, sq_sz; bool real_time = mlx5_is_real_time_sq(txqsq->mdev);
bool real_time; u32 sq_sz = mlx5_wq_cyc_get_size(&txqsq->wq);
int err; u32 sq_stride = MLX5_SEND_WQE_BB;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SQ"); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SQ");
if (err) devlink_fmsg_u64_pair_put(fmsg, "stride size", sq_stride);
return err; devlink_fmsg_u32_pair_put(fmsg, "size", sq_sz);
devlink_fmsg_string_pair_put(fmsg, "ts_format", real_time ? "RT" : "FRC");
real_time = mlx5_is_real_time_sq(txqsq->mdev); mlx5e_health_cq_common_diag_fmsg(&txqsq->cq, fmsg);
sq_sz = mlx5_wq_cyc_get_size(&txqsq->wq); mlx5e_health_fmsg_named_obj_nest_end(fmsg);
sq_stride = MLX5_SEND_WQE_BB;
err = devlink_fmsg_u64_pair_put(fmsg, "stride size", sq_stride);
if (err)
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "size", sq_sz);
if (err)
return err;
err = devlink_fmsg_string_pair_put(fmsg, "ts_format", real_time ? "RT" : "FRC");
if (err)
return err;
err = mlx5e_health_cq_common_diag_fmsg(&txqsq->cq, fmsg);
if (err)
return err;
return mlx5e_health_fmsg_named_obj_nest_end(fmsg);
} }
static int static void
mlx5e_tx_reporter_diagnose_generic_tx_port_ts(struct devlink_fmsg *fmsg, mlx5e_tx_reporter_diagnose_generic_tx_port_ts(struct devlink_fmsg *fmsg,
struct mlx5e_ptpsq *ptpsq) struct mlx5e_ptpsq *ptpsq)
{ {
int err; mlx5e_health_fmsg_named_obj_nest_start(fmsg, "Port TS");
mlx5e_health_cq_common_diag_fmsg(&ptpsq->ts_cq, fmsg);
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "Port TS"); mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
err = mlx5e_health_cq_common_diag_fmsg(&ptpsq->ts_cq, fmsg);
if (err)
return err;
return mlx5e_health_fmsg_named_obj_nest_end(fmsg);
} }
static int static void
mlx5e_tx_reporter_diagnose_common_config(struct devlink_health_reporter *reporter, mlx5e_tx_reporter_diagnose_common_config(struct devlink_health_reporter *reporter,
struct devlink_fmsg *fmsg) struct devlink_fmsg *fmsg)
{ {
...@@ -394,39 +291,20 @@ mlx5e_tx_reporter_diagnose_common_config(struct devlink_health_reporter *reporte ...@@ -394,39 +291,20 @@ mlx5e_tx_reporter_diagnose_common_config(struct devlink_health_reporter *reporte
struct mlx5e_txqsq *generic_sq = priv->txq2sq[0]; struct mlx5e_txqsq *generic_sq = priv->txq2sq[0];
struct mlx5e_ptp *ptp_ch = priv->channels.ptp; struct mlx5e_ptp *ptp_ch = priv->channels.ptp;
struct mlx5e_ptpsq *generic_ptpsq; struct mlx5e_ptpsq *generic_ptpsq;
int err;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "Common Config"); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "Common Config");
if (err) mlx5e_tx_reporter_diagnose_generic_txqsq(fmsg, generic_sq);
return err;
err = mlx5e_tx_reporter_diagnose_generic_txqsq(fmsg, generic_sq);
if (err)
return err;
if (!ptp_ch || !test_bit(MLX5E_PTP_STATE_TX, ptp_ch->state)) if (!ptp_ch || !test_bit(MLX5E_PTP_STATE_TX, ptp_ch->state))
goto out; goto out;
generic_ptpsq = &ptp_ch->ptpsq[0]; generic_ptpsq = &ptp_ch->ptpsq[0];
mlx5e_health_fmsg_named_obj_nest_start(fmsg, "PTP");
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "PTP"); mlx5e_tx_reporter_diagnose_generic_txqsq(fmsg, &generic_ptpsq->txqsq);
if (err) mlx5e_tx_reporter_diagnose_generic_tx_port_ts(fmsg, generic_ptpsq);
return err; mlx5e_health_fmsg_named_obj_nest_end(fmsg);
err = mlx5e_tx_reporter_diagnose_generic_txqsq(fmsg, &generic_ptpsq->txqsq);
if (err)
return err;
err = mlx5e_tx_reporter_diagnose_generic_tx_port_ts(fmsg, generic_ptpsq);
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
out: out:
return mlx5e_health_fmsg_named_obj_nest_end(fmsg); mlx5e_health_fmsg_named_obj_nest_end(fmsg);
} }
static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter, static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter,
...@@ -436,20 +314,15 @@ static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter, ...@@ -436,20 +314,15 @@ static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter,
struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter); struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter);
struct mlx5e_ptp *ptp_ch = priv->channels.ptp; struct mlx5e_ptp *ptp_ch = priv->channels.ptp;
int i, tc, err = 0; int i, tc;
mutex_lock(&priv->state_lock); mutex_lock(&priv->state_lock);
if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
goto unlock; goto unlock;
err = mlx5e_tx_reporter_diagnose_common_config(reporter, fmsg); mlx5e_tx_reporter_diagnose_common_config(reporter, fmsg);
if (err) devlink_fmsg_arr_pair_nest_start(fmsg, "SQs");
goto unlock;
err = devlink_fmsg_arr_pair_nest_start(fmsg, "SQs");
if (err)
goto unlock;
for (i = 0; i < priv->channels.num; i++) { for (i = 0; i < priv->channels.num; i++) {
struct mlx5e_channel *c = priv->channels.c[i]; struct mlx5e_channel *c = priv->channels.c[i];
...@@ -457,31 +330,23 @@ static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter, ...@@ -457,31 +330,23 @@ static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter,
for (tc = 0; tc < mlx5e_get_dcb_num_tc(&priv->channels.params); tc++) { for (tc = 0; tc < mlx5e_get_dcb_num_tc(&priv->channels.params); tc++) {
struct mlx5e_txqsq *sq = &c->sq[tc]; struct mlx5e_txqsq *sq = &c->sq[tc];
err = mlx5e_tx_reporter_build_diagnose_output(fmsg, sq, tc); mlx5e_tx_reporter_build_diagnose_output(fmsg, sq, tc);
if (err)
goto unlock;
} }
} }
if (!ptp_ch || !test_bit(MLX5E_PTP_STATE_TX, ptp_ch->state)) if (!ptp_ch || !test_bit(MLX5E_PTP_STATE_TX, ptp_ch->state))
goto close_sqs_nest; goto close_sqs_nest;
for (tc = 0; tc < mlx5e_get_dcb_num_tc(&priv->channels.params); tc++) { for (tc = 0; tc < mlx5e_get_dcb_num_tc(&priv->channels.params); tc++)
err = mlx5e_tx_reporter_build_diagnose_output_ptpsq(fmsg, mlx5e_tx_reporter_build_diagnose_output_ptpsq(fmsg,
&ptp_ch->ptpsq[tc], &ptp_ch->ptpsq[tc],
tc); tc);
if (err)
goto unlock;
}
close_sqs_nest: close_sqs_nest:
err = devlink_fmsg_arr_pair_nest_end(fmsg); devlink_fmsg_arr_pair_nest_end(fmsg);
if (err)
goto unlock;
unlock: unlock:
mutex_unlock(&priv->state_lock); mutex_unlock(&priv->state_lock);
return err; return 0;
} }
static int mlx5e_tx_reporter_dump_sq(struct mlx5e_priv *priv, struct devlink_fmsg *fmsg, static int mlx5e_tx_reporter_dump_sq(struct mlx5e_priv *priv, struct devlink_fmsg *fmsg,
...@@ -489,60 +354,33 @@ static int mlx5e_tx_reporter_dump_sq(struct mlx5e_priv *priv, struct devlink_fms ...@@ -489,60 +354,33 @@ static int mlx5e_tx_reporter_dump_sq(struct mlx5e_priv *priv, struct devlink_fms
{ {
struct mlx5_rsc_key key = {}; struct mlx5_rsc_key key = {};
struct mlx5e_txqsq *sq = ctx; struct mlx5e_txqsq *sq = ctx;
int err;
if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
return 0; return 0;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SX Slice"); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SX Slice");
if (err)
return err;
key.size = PAGE_SIZE; key.size = PAGE_SIZE;
key.rsc = MLX5_SGMT_TYPE_SX_SLICE_ALL; key.rsc = MLX5_SGMT_TYPE_SX_SLICE_ALL;
err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg); mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
if (err) mlx5e_health_fmsg_named_obj_nest_end(fmsg);
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SQ");
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "QPC");
if (err)
return err;
mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SQ");
mlx5e_health_fmsg_named_obj_nest_start(fmsg, "QPC");
key.rsc = MLX5_SGMT_TYPE_FULL_QPC; key.rsc = MLX5_SGMT_TYPE_FULL_QPC;
key.index1 = sq->sqn; key.index1 = sq->sqn;
key.num_of_obj1 = 1; key.num_of_obj1 = 1;
mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
mlx5e_health_fmsg_named_obj_nest_end(fmsg);
err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "send_buff");
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "send_buff");
if (err)
return err;
key.rsc = MLX5_SGMT_TYPE_SND_BUFF; key.rsc = MLX5_SGMT_TYPE_SND_BUFF;
key.num_of_obj2 = MLX5_RSC_DUMP_ALL; key.num_of_obj2 = MLX5_RSC_DUMP_ALL;
err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg); mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
if (err) mlx5e_health_fmsg_named_obj_nest_end(fmsg);
return err;
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg); mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
return mlx5e_health_fmsg_named_obj_nest_end(fmsg); return 0;
} }
static int mlx5e_tx_reporter_timeout_dump(struct mlx5e_priv *priv, struct devlink_fmsg *fmsg, static int mlx5e_tx_reporter_timeout_dump(struct mlx5e_priv *priv, struct devlink_fmsg *fmsg,
...@@ -567,28 +405,17 @@ static int mlx5e_tx_reporter_dump_all_sqs(struct mlx5e_priv *priv, ...@@ -567,28 +405,17 @@ static int mlx5e_tx_reporter_dump_all_sqs(struct mlx5e_priv *priv,
{ {
struct mlx5e_ptp *ptp_ch = priv->channels.ptp; struct mlx5e_ptp *ptp_ch = priv->channels.ptp;
struct mlx5_rsc_key key = {}; struct mlx5_rsc_key key = {};
int i, tc, err; int i, tc;
if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
return 0; return 0;
err = mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SX Slice"); mlx5e_health_fmsg_named_obj_nest_start(fmsg, "SX Slice");
if (err)
return err;
key.size = PAGE_SIZE; key.size = PAGE_SIZE;
key.rsc = MLX5_SGMT_TYPE_SX_SLICE_ALL; key.rsc = MLX5_SGMT_TYPE_SX_SLICE_ALL;
err = mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg); mlx5e_health_rsc_fmsg_dump(priv, &key, fmsg);
if (err) mlx5e_health_fmsg_named_obj_nest_end(fmsg);
return err; devlink_fmsg_arr_pair_nest_start(fmsg, "SQs");
err = mlx5e_health_fmsg_named_obj_nest_end(fmsg);
if (err)
return err;
err = devlink_fmsg_arr_pair_nest_start(fmsg, "SQs");
if (err)
return err;
for (i = 0; i < priv->channels.num; i++) { for (i = 0; i < priv->channels.num; i++) {
struct mlx5e_channel *c = priv->channels.c[i]; struct mlx5e_channel *c = priv->channels.c[i];
...@@ -596,9 +423,7 @@ static int mlx5e_tx_reporter_dump_all_sqs(struct mlx5e_priv *priv, ...@@ -596,9 +423,7 @@ static int mlx5e_tx_reporter_dump_all_sqs(struct mlx5e_priv *priv,
for (tc = 0; tc < mlx5e_get_dcb_num_tc(&priv->channels.params); tc++) { for (tc = 0; tc < mlx5e_get_dcb_num_tc(&priv->channels.params); tc++) {
struct mlx5e_txqsq *sq = &c->sq[tc]; struct mlx5e_txqsq *sq = &c->sq[tc];
err = mlx5e_health_queue_dump(priv, fmsg, sq->sqn, "SQ"); mlx5e_health_queue_dump(priv, fmsg, sq->sqn, "SQ");
if (err)
return err;
} }
} }
...@@ -606,13 +431,12 @@ static int mlx5e_tx_reporter_dump_all_sqs(struct mlx5e_priv *priv, ...@@ -606,13 +431,12 @@ static int mlx5e_tx_reporter_dump_all_sqs(struct mlx5e_priv *priv,
for (tc = 0; tc < mlx5e_get_dcb_num_tc(&priv->channels.params); tc++) { for (tc = 0; tc < mlx5e_get_dcb_num_tc(&priv->channels.params); tc++) {
struct mlx5e_txqsq *sq = &ptp_ch->ptpsq[tc].txqsq; struct mlx5e_txqsq *sq = &ptp_ch->ptpsq[tc].txqsq;
err = mlx5e_health_queue_dump(priv, fmsg, sq->sqn, "PTP SQ"); mlx5e_health_queue_dump(priv, fmsg, sq->sqn, "PTP SQ");
if (err)
return err;
} }
} }
return devlink_fmsg_arr_pair_nest_end(fmsg); devlink_fmsg_arr_pair_nest_end(fmsg);
return 0;
} }
static int mlx5e_tx_reporter_dump_from_ctx(struct mlx5e_priv *priv, static int mlx5e_tx_reporter_dump_from_ctx(struct mlx5e_priv *priv,
......
...@@ -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; ioread32be(&h->assert_exit_ptr));
err = devlink_fmsg_u32_pair_put(fmsg, "assert_exit_ptr", devlink_fmsg_u32_pair_put(fmsg, "assert_callra",
ioread32be(&h->assert_exit_ptr)); 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, "assert_callra",
ioread32be(&h->assert_callra));
if (err)
return err;
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);
......
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