[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1547737521-29888-20-git-send-email-eranbe@mellanox.com>
Date: Thu, 17 Jan 2019 17:05:13 +0200
From: Eran Ben Elisha <eranbe@...lanox.com>
To: netdev@...r.kernel.org, Jiri Pirko <jiri@...lanox.com>,
"David S. Miller" <davem@...emloft.net>,
Ariel Almog <ariela@...lanox.com>,
Aya Levin <ayal@...lanox.com>,
Eran Ben Elisha <eranbe@...lanox.com>,
Moshe Shemesh <moshe@...lanox.com>
Subject: [PATCH net-next 19/27] net/mlx5: Refactor print health info
From: Moshe Shemesh <moshe@...lanox.com>
Refactor print health info code, split to two functions:
1. mlx5_get_health_info() - writes the health info into a buffer.
2. mlx5_print_health_info() - prints the health info to kernel log.
This refactoring is done to enable using the health info data by devlink
health reporter diagnose() in the downstream patch.
Signed-off-by: Moshe Shemesh <moshe@...lanox.com>
Reviewed-by: Saeed Mahameed <saeedm@...lanox.com>
---
.../net/ethernet/mellanox/mlx5/core/health.c | 44 +++++++++++++------
.../ethernet/mellanox/mlx5/core/mlx5_core.h | 7 +++
include/linux/mlx5/device.h | 1 +
include/linux/mlx5/mlx5_ifc.h | 4 +-
4 files changed, 42 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c
index 87c327751941..20576a525421 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/health.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c
@@ -390,7 +390,8 @@ static const char *hsynd_str(u8 synd)
}
}
-static void print_health_info(struct mlx5_core_dev *dev)
+void mlx5_get_health_info(struct mlx5_core_dev *dev, u8 *synd,
+ char (*lines_buf)[HEALTH_INFO_MAX_LINE])
{
struct mlx5_core_health *health = &dev->priv.health;
struct health_buffer __iomem *h = health->health;
@@ -398,23 +399,40 @@ static void print_health_info(struct mlx5_core_dev *dev)
u32 fw;
int i;
+ *synd = ioread8(&h->synd);
/* If the syndrome is 0, the device is OK and no need to print buffer */
- if (!ioread8(&h->synd))
+ if (!synd)
return;
for (i = 0; i < ARRAY_SIZE(h->assert_var); i++)
- dev_err(&dev->pdev->dev, "assert_var[%d] 0x%08x\n", i, ioread32be(h->assert_var + i));
+ sprintf(lines_buf[i], "assert_var[%d] 0x%08x\n", i, ioread32be(h->assert_var + i));
- dev_err(&dev->pdev->dev, "assert_exit_ptr 0x%08x\n", ioread32be(&h->assert_exit_ptr));
- dev_err(&dev->pdev->dev, "assert_callra 0x%08x\n", ioread32be(&h->assert_callra));
+ sprintf(lines_buf[i++], "assert_exit_ptr 0x%08x\n", ioread32be(&h->assert_exit_ptr));
+ sprintf(lines_buf[i++], "assert_callra 0x%08x\n", ioread32be(&h->assert_callra));
sprintf(fw_str, "%d.%d.%d", fw_rev_maj(dev), fw_rev_min(dev), fw_rev_sub(dev));
- dev_err(&dev->pdev->dev, "fw_ver %s\n", fw_str);
- dev_err(&dev->pdev->dev, "hw_id 0x%08x\n", ioread32be(&h->hw_id));
- dev_err(&dev->pdev->dev, "irisc_index %d\n", ioread8(&h->irisc_index));
- dev_err(&dev->pdev->dev, "synd 0x%x: %s\n", ioread8(&h->synd), hsynd_str(ioread8(&h->synd)));
- dev_err(&dev->pdev->dev, "ext_synd 0x%04x\n", ioread16be(&h->ext_synd));
+ sprintf(lines_buf[i++], "fw_ver %s\n", fw_str);
+ sprintf(lines_buf[i++], "hw_id 0x%08x\n", ioread32be(&h->hw_id));
+ sprintf(lines_buf[i++], "irisc_index %d\n", ioread8(&h->irisc_index));
+ sprintf(lines_buf[i++], "synd 0x%x: %s\n", ioread8(&h->synd), hsynd_str(ioread8(&h->synd)));
+ snprintf(lines_buf[i++], HEALTH_INFO_MAX_LINE, "ext_synd 0x%04x\n", ioread16be(&h->ext_synd));
fw = ioread32be(&h->fw_ver);
- dev_err(&dev->pdev->dev, "raw fw_ver 0x%08x\n", fw);
+ sprintf(lines_buf[i], "raw fw_ver 0x%08x\n", fw);
+}
+
+static void mlx5_print_health_info(struct mlx5_core_dev *dev)
+{
+ char lines_buf[HEALTH_INFO_LINES][HEALTH_INFO_MAX_LINE] = {};
+ u8 synd;
+ int i;
+
+ mlx5_get_health_info(dev, &synd, lines_buf);
+
+ if (!synd)
+ return;
+
+ for (i = 0; i < HEALTH_INFO_LINES; i++)
+ dev_err(&dev->pdev->dev, lines_buf[i]);
+
}
static unsigned long get_next_poll_jiffies(void)
@@ -461,7 +479,7 @@ static void poll_health(struct timer_list *t)
health->prev = count;
if (health->miss_counter == MAX_MISSES) {
dev_err(&dev->pdev->dev, "device's health compromised - reached miss count\n");
- print_health_info(dev);
+ mlx5_print_health_info(dev);
}
fatal_error = check_fatal_sensors(dev);
@@ -469,7 +487,7 @@ static void poll_health(struct timer_list *t)
if (fatal_error && !health->fatal_error) {
mlx5_core_err(dev, "Fatal error %u detected\n", fatal_error);
dev->priv.health.fatal_error = fatal_error;
- print_health_info(dev);
+ mlx5_print_health_info(dev);
mlx5_trigger_health_work(dev);
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
index bf118e85aefe..af5cf19cc019 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h
@@ -204,4 +204,11 @@ enum {
u8 mlx5_get_nic_state(struct mlx5_core_dev *dev);
void mlx5_set_nic_state(struct mlx5_core_dev *dev, u8 state);
+
+#define HEALTH_INFO_MAX_LINE 64
+#define HEALTH_INFO_LINES (MLX5_FLD_SZ_DW(health_buffer, assert_var) + 8)
+#define HEALTH_INFO_MAX_BUFF (HEALTH_INFO_MAX_LINE * HEALTH_INFO_LINES)
+void mlx5_get_health_info(struct mlx5_core_dev *dev, u8 *synd,
+ char (*lines_buf)[HEALTH_INFO_MAX_LINE]);
+
#endif /* __MLX5_CORE_H__ */
diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h
index cac801609d76..9125289d1f46 100644
--- a/include/linux/mlx5/device.h
+++ b/include/linux/mlx5/device.h
@@ -61,6 +61,7 @@
#define __mlx5_st_sz_bits(typ) sizeof(struct mlx5_ifc_##typ##_bits)
#define MLX5_FLD_SZ_BYTES(typ, fld) (__mlx5_bit_sz(typ, fld) / 8)
+#define MLX5_FLD_SZ_DW(typ, fld) (__mlx5_bit_sz(typ, fld) / 32)
#define MLX5_ST_SZ_BYTES(typ) (sizeof(struct mlx5_ifc_##typ##_bits) / 8)
#define MLX5_ST_SZ_DW(typ) (sizeof(struct mlx5_ifc_##typ##_bits) / 32)
#define MLX5_ST_SZ_QW(typ) (sizeof(struct mlx5_ifc_##typ##_bits) / 64)
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h
index 35fe5217b244..203f937e9efb 100644
--- a/include/linux/mlx5/mlx5_ifc.h
+++ b/include/linux/mlx5/mlx5_ifc.h
@@ -3371,7 +3371,9 @@ union mlx5_ifc_event_auto_bits {
};
struct mlx5_ifc_health_buffer_bits {
- u8 reserved_at_0[0x100];
+ u8 assert_var[0xa0];
+
+ u8 reserved_at_a0[0x60];
u8 assert_existptr[0x20];
--
2.17.1
Powered by blists - more mailing lists