Skip to content

Commit 1e34f3e

Browse files
Moshe ShemeshSaeed Mahameed
authored andcommitted
net/mlx5: Create FW devlink_health_reporter
Create mlx5_devlink_health_reporter for FW reporter. The FW reporter implements devlink_health_reporter diagnose callback. The fw reporter diagnose command can be triggered any time by the user to check current fw status. In healthy status, it will return clear syndrome. Otherwise it will return the syndrome and description of the error type. Command example and output on healthy status: $ devlink health diagnose pci/0000:82:00.0 reporter fw Syndrome: 0 Command example and output on non healthy status: $ devlink health diagnose pci/0000:82:00.0 reporter fw Syndrome: 8 Description: unrecoverable hardware error Signed-off-by: Moshe Shemesh <[email protected]> Signed-off-by: Eran Ben Elisha <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 3e5b72a commit 1e34f3e

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

drivers/net/ethernet/mellanox/mlx5/core/health.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,51 @@ static void print_health_info(struct mlx5_core_dev *dev)
388388
mlx5_core_err(dev, "raw fw_ver 0x%08x\n", fw);
389389
}
390390

391+
static int
392+
mlx5_fw_reporter_diagnose(struct devlink_health_reporter *reporter,
393+
struct devlink_fmsg *fmsg)
394+
{
395+
struct mlx5_core_dev *dev = devlink_health_reporter_priv(reporter);
396+
struct mlx5_core_health *health = &dev->priv.health;
397+
struct health_buffer __iomem *h = health->health;
398+
u8 synd;
399+
int err;
400+
401+
synd = ioread8(&h->synd);
402+
err = devlink_fmsg_u8_pair_put(fmsg, "Syndrome", synd);
403+
if (err || !synd)
404+
return err;
405+
return devlink_fmsg_string_pair_put(fmsg, "Description", hsynd_str(synd));
406+
}
407+
408+
static const struct devlink_health_reporter_ops mlx5_fw_reporter_ops = {
409+
.name = "fw",
410+
.diagnose = mlx5_fw_reporter_diagnose,
411+
};
412+
413+
static void mlx5_fw_reporter_create(struct mlx5_core_dev *dev)
414+
{
415+
struct mlx5_core_health *health = &dev->priv.health;
416+
struct devlink *devlink = priv_to_devlink(dev);
417+
418+
health->fw_reporter =
419+
devlink_health_reporter_create(devlink, &mlx5_fw_reporter_ops,
420+
0, false, dev);
421+
if (IS_ERR(health->fw_reporter))
422+
mlx5_core_warn(dev, "Failed to create fw reporter, err = %ld\n",
423+
PTR_ERR(health->fw_reporter));
424+
}
425+
426+
static void mlx5_fw_reporter_destroy(struct mlx5_core_dev *dev)
427+
{
428+
struct mlx5_core_health *health = &dev->priv.health;
429+
430+
if (IS_ERR_OR_NULL(health->fw_reporter))
431+
return;
432+
433+
devlink_health_reporter_destroy(health->fw_reporter);
434+
}
435+
391436
static unsigned long get_next_poll_jiffies(void)
392437
{
393438
unsigned long next;
@@ -498,6 +543,7 @@ void mlx5_health_cleanup(struct mlx5_core_dev *dev)
498543
struct mlx5_core_health *health = &dev->priv.health;
499544

500545
destroy_workqueue(health->wq);
546+
mlx5_fw_reporter_destroy(dev);
501547
}
502548

503549
int mlx5_health_init(struct mlx5_core_dev *dev)
@@ -519,5 +565,7 @@ int mlx5_health_init(struct mlx5_core_dev *dev)
519565
spin_lock_init(&health->wq_lock);
520566
INIT_WORK(&health->work, health_care);
521567

568+
mlx5_fw_reporter_create(dev);
569+
522570
return 0;
523571
}

include/linux/mlx5/driver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include <linux/mlx5/eq.h>
5454
#include <linux/timecounter.h>
5555
#include <linux/ptp_clock_kernel.h>
56+
#include <net/devlink.h>
5657

5758
enum {
5859
MLX5_BOARD_ID_LEN = 64,
@@ -443,6 +444,7 @@ struct mlx5_core_health {
443444
unsigned long flags;
444445
struct work_struct work;
445446
struct delayed_work recover_work;
447+
struct devlink_health_reporter *fw_reporter;
446448
};
447449

448450
struct mlx5_qp_table {

0 commit comments

Comments
 (0)