Blob Blame History Raw
From 81a035c029c2ef108da0f854c5a670aa3f06bb94 Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Wed, 17 Jun 2020 12:10:11 +0200
Subject: [PATCH] devlink: Add health error recovery status monitoring

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1821039
Upstream Status: iproute2.git commit 5023df6a21c73
Conflicts: context change due to missing commit
  - ef12d6dafaeb9 ("devlink: Add devlink trap set and show commands")
  - 4ede9e9d56206 ("devlink: Add devlink trap group set and show commands")
  - a66af5569337b ("devlink: Add devlink trap policer set and show commands")

commit 5023df6a21c73560b514d7fde5381d140373afe9
Author: Moshe Shemesh <moshe@mellanox.com>
Date:   Tue Feb 4 23:37:02 2020 +0200

    devlink: Add health error recovery status monitoring

    Add support for devlink health error recovery status monitoring.
    Update devlink-monitor man page accordingly.

    Signed-off-by: Moshe Shemesh <moshe@mellanox.com>
    Acked-by: Jiri Pirko <jiri@mellanox.com>
    Signed-off-by: David Ahern <dsahern@gmail.com>
---
 devlink/devlink.c          | 17 +++++++++++++++--
 man/man8/devlink-monitor.8 |  3 ++-
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 0293373928f50..f7e859c266394 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -3764,6 +3764,7 @@ static const char *cmd_name(uint8_t cmd)
 	case DEVLINK_CMD_REGION_SET: return "set";
 	case DEVLINK_CMD_REGION_NEW: return "new";
 	case DEVLINK_CMD_REGION_DEL: return "del";
+	case DEVLINK_CMD_HEALTH_REPORTER_RECOVER: return "status";
 	default: return "<unknown cmd>";
 	}
 }
@@ -3792,6 +3793,8 @@ static const char *cmd_obj(uint8_t cmd)
 	case DEVLINK_CMD_REGION_NEW:
 	case DEVLINK_CMD_REGION_DEL:
 		return "region";
+	case DEVLINK_CMD_HEALTH_REPORTER_RECOVER:
+		return "health";
 	default: return "<unknown obj>";
 	}
 }
@@ -3817,6 +3820,7 @@ static bool cmd_filter_check(struct dl *dl, uint8_t cmd)
 }
 
 static void pr_out_region(struct dl *dl, struct nlattr **tb);
+static void pr_out_health(struct dl *dl, struct nlattr **tb_health);
 
 static int cmd_mon_show_cb(const struct nlmsghdr *nlh, void *data)
 {
@@ -3872,6 +3876,14 @@ static int cmd_mon_show_cb(const struct nlmsghdr *nlh, void *data)
 		pr_out_mon_header(genl->cmd);
 		pr_out_region(dl, tb);
 		break;
+	case DEVLINK_CMD_HEALTH_REPORTER_RECOVER:
+		mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
+		if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME] ||
+		    !tb[DEVLINK_ATTR_HEALTH_REPORTER])
+			return MNL_CB_ERROR;
+		pr_out_mon_header(genl->cmd);
+		pr_out_health(dl, tb);
+		break;
 	}
 	return MNL_CB_OK;
 }
@@ -3885,7 +3897,8 @@ static int cmd_mon_show(struct dl *dl)
 	while ((cur_obj = dl_argv_index(dl, index++))) {
 		if (strcmp(cur_obj, "all") != 0 &&
 		    strcmp(cur_obj, "dev") != 0 &&
-		    strcmp(cur_obj, "port") != 0) {
+		    strcmp(cur_obj, "port") != 0 &&
+		    strcmp(cur_obj, "health") != 0) {
 			pr_err("Unknown object \"%s\"\n", cur_obj);
 			return -EINVAL;
 		}
@@ -3902,7 +3915,7 @@ static int cmd_mon_show(struct dl *dl)
 static void cmd_mon_help(void)
 {
 	pr_err("Usage: devlink monitor [ all | OBJECT-LIST ]\n"
-	       "where  OBJECT-LIST := { dev | port }\n");
+	       "where  OBJECT-LIST := { dev | port | health }\n");
 }
 
 static int cmd_mon(struct dl *dl)
diff --git a/man/man8/devlink-monitor.8 b/man/man8/devlink-monitor.8
index 13fe641dc8f54..9bc579673ebf4 100644
--- a/man/man8/devlink-monitor.8
+++ b/man/man8/devlink-monitor.8
@@ -21,7 +21,7 @@ command is the first in the command line and then the object list.
 .I OBJECT-LIST
 is the list of object types that we want to monitor.
 It may contain
-.BR dev ", " port ".
+.BR dev ", " port ", " health ".
 
 .B devlink
 opens Devlink Netlink socket, listens on it and dumps state changes.
@@ -31,6 +31,7 @@ opens Devlink Netlink socket, listens on it and dumps state changes.
 .BR devlink-dev (8),
 .BR devlink-sb (8),
 .BR devlink-port (8),
+.BR devlink-health (8),
 .br
 
 .SH AUTHOR
-- 
2.26.2