]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net/mlx5: Print health buffer by log level
authorAya Levin <ayal@nvidia.com>
Mon, 11 Oct 2021 14:19:23 +0000 (17:19 +0300)
committerSaeed Mahameed <saeedm@nvidia.com>
Mon, 25 Oct 2021 20:51:19 +0000 (13:51 -0700)
Add log macro which gets log level as a parameter. Use the severity
read from the health buffer and the new log macro to log the health buffer
with severity as log level.  Prior to this patch, health buffer was
printed in error log level regardless of its severity. Now the user may
filter dmesg (--level) or change kernel log level to focus on different
severity levels of firmware errors.

Signed-off-by: Aya Levin <ayal@nvidia.com>
Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Documentation/networking/device_drivers/ethernet/mellanox/mlx5.rst
drivers/net/ethernet/mellanox/mlx5/core/health.c
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h

index 4b59cf2c599f79a1bb94854e9b154c8cd788aa8e..2ee74a49be9d855e80d38830aa781389cf57598a 100644 (file)
@@ -543,6 +543,8 @@ The CR-space dump uses vsc interface which is valid even if the FW command
 interface is not functional, which is the case in most FW fatal errors.
 The recover function runs recover flow which reloads the driver and triggers fw
 reset if needed.
+On firmware error, the health buffer is dumped into the dmesg. The log
+level is derived from the error's severity (given in health buffer).
 
 User commands examples:
 
index 538ef392f54cd044bb9e07c1a7841e77c08cd466..c35a27255232bdb3abf77e50567c43bfe1b21e1d 100644 (file)
@@ -422,27 +422,26 @@ static void print_health_info(struct mlx5_core_dev *dev)
 
        rfr_severity = ioread8(&h->rfr_severity);
        severity  = mlx5_health_get_severity(rfr_severity);
-       mlx5_core_err(dev, "Health issue observed, %s, severity(%d) %s:\n",
-                     hsynd_str(ioread8(&h->synd)), severity, mlx5_loglevel_str(severity));
+       mlx5_log(dev, severity, "Health issue observed, %s, severity(%d) %s:\n",
+                hsynd_str(ioread8(&h->synd)), severity, mlx5_loglevel_str(severity));
 
        for (i = 0; i < ARRAY_SIZE(h->assert_var); i++)
-               mlx5_core_err(dev, "assert_var[%d] 0x%08x\n", i,
-                             ioread32be(h->assert_var + i));
-
-       mlx5_core_err(dev, "assert_exit_ptr 0x%08x\n",
-                     ioread32be(&h->assert_exit_ptr));
-       mlx5_core_err(dev, "assert_callra 0x%08x\n",
-                     ioread32be(&h->assert_callra));
-       mlx5_core_err(dev, "fw_ver %d.%d.%d", fw_rev_maj(dev), fw_rev_min(dev), fw_rev_sub(dev));
-       mlx5_core_err(dev, "time %u\n", ioread32be(&h->time));
-       mlx5_core_err(dev, "hw_id 0x%08x\n", ioread32be(&h->hw_id));
-       mlx5_core_err(dev, "rfr %d\n", mlx5_health_get_rfr(rfr_severity));
-       mlx5_core_err(dev, "severity %d (%s)\n", severity, mlx5_loglevel_str(severity));
-       mlx5_core_err(dev, "irisc_index %d\n", ioread8(&h->irisc_index));
-       mlx5_core_err(dev, "synd 0x%x: %s\n", ioread8(&h->synd),
-                     hsynd_str(ioread8(&h->synd)));
-       mlx5_core_err(dev, "ext_synd 0x%04x\n", ioread16be(&h->ext_synd));
-       mlx5_core_err(dev, "raw fw_ver 0x%08x\n", ioread32be(&h->fw_ver));
+               mlx5_log(dev, severity, "assert_var[%d] 0x%08x\n", i,
+                        ioread32be(h->assert_var + i));
+
+       mlx5_log(dev, severity, "assert_exit_ptr 0x%08x\n", ioread32be(&h->assert_exit_ptr));
+       mlx5_log(dev, severity, "assert_callra 0x%08x\n", ioread32be(&h->assert_callra));
+       mlx5_log(dev, severity, "fw_ver %d.%d.%d", fw_rev_maj(dev), fw_rev_min(dev),
+                fw_rev_sub(dev));
+       mlx5_log(dev, severity, "time %u\n", ioread32be(&h->time));
+       mlx5_log(dev, severity, "hw_id 0x%08x\n", ioread32be(&h->hw_id));
+       mlx5_log(dev, severity, "rfr %d\n", mlx5_health_get_rfr(rfr_severity));
+       mlx5_log(dev, severity, "severity %d (%s)\n", severity, mlx5_loglevel_str(severity));
+       mlx5_log(dev, severity, "irisc_index %d\n", ioread8(&h->irisc_index));
+       mlx5_log(dev, severity, "synd 0x%x: %s\n", ioread8(&h->synd),
+                hsynd_str(ioread8(&h->synd)));
+       mlx5_log(dev, severity, "ext_synd 0x%04x\n", ioread16be(&h->ext_synd));
+       mlx5_log(dev, severity, "raw fw_ver 0x%08x\n", ioread32be(&h->fw_ver));
 }
 
 static int
index 230eab7e3bc91a1443cd67aa54885e9dd36fe795..bb677329ea08d77824894839543163829ac0b4f5 100644 (file)
@@ -97,6 +97,30 @@ do {                                                         \
                             __func__, __LINE__, current->pid,  \
                             ##__VA_ARGS__)
 
+static inline void mlx5_printk(struct mlx5_core_dev *dev, int level, const char *format, ...)
+{
+       struct device *device = dev->device;
+       struct va_format vaf;
+       va_list args;
+
+       if (WARN_ONCE(level < LOGLEVEL_EMERG || level > LOGLEVEL_DEBUG,
+                     "Level %d is out of range, set to default level\n", level))
+               level = LOGLEVEL_DEFAULT;
+
+       va_start(args, format);
+       vaf.fmt = format;
+       vaf.va = &args;
+
+       dev_printk_emit(level, device, "%s %s: %pV", dev_driver_string(device), dev_name(device),
+                       &vaf);
+       va_end(args);
+}
+
+#define mlx5_log(__dev, level, format, ...)                    \
+       mlx5_printk(__dev, level, "%s:%d:(pid %d): " format,    \
+                   __func__, __LINE__, current->pid,           \
+                   ##__VA_ARGS__)
+
 static inline struct device *mlx5_core_dma_dev(struct mlx5_core_dev *dev)
 {
        return &dev->pdev->dev;