From: Keith Busch Date: Fri, 20 Oct 2017 21:11:18 +0000 (-0600) Subject: Add AEN decoder helper to get-log X-Git-Tag: v1.5~45 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d95bae38379e3953bfbd691c2181706781018281;p=users%2Fsagi%2Fnvme-cli.git Add AEN decoder helper to get-log This is a convenience helper for retreiving logs from an AEN result. Signed-off-by: Keith Busch --- diff --git a/Documentation/nvme-get-log.txt b/Documentation/nvme-get-log.txt index 1a496f7e..55ba5afa 100644 --- a/Documentation/nvme-get-log.txt +++ b/Documentation/nvme-get-log.txt @@ -10,6 +10,7 @@ SYNOPSIS [verse] 'nvme get-log' [--log-id= | -i ] [--log-len= | -l ] + [--aen= | -a ] [--namespace-id= | -n ] [--raw-binary | -b] @@ -38,6 +39,12 @@ OPTIONS --log-id=:: Sets the commands requested log-id to . Defaults to 0. +-a :: +--aen=:: + Convenience field for extracting log information based on an + asynchronous event notification result. This will override log-id and + log-len, if set. + -n :: --namespace-id=:: Sets the command's nsid value to the given nsid. Defaults to diff --git a/nvme.c b/nvme.c index 74a4fd09..07bd5cbb 100644 --- a/nvme.c +++ b/nvme.c @@ -363,6 +363,7 @@ static int get_log(int argc, char **argv, struct command *cmd, struct plugin *pl const char *namespace_id = "desired namespace"; const char *log_id = "identifier of log to retrieve"; const char *log_len = "how many bytes to retrieve"; + const char *aen = "result of the aen, use to override log id"; const char *raw_binary = "output in raw format"; int err, fd; @@ -370,6 +371,7 @@ static int get_log(int argc, char **argv, struct command *cmd, struct plugin *pl __u32 namespace_id; __u32 log_id; __u32 log_len; + __u32 aen; int raw_binary; }; @@ -383,6 +385,7 @@ static int get_log(int argc, char **argv, struct command *cmd, struct plugin *pl {"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id}, {"log-id", 'i', "NUM", CFG_POSITIVE, &cfg.log_id, required_argument, log_id}, {"log-len", 'l', "NUM", CFG_POSITIVE, &cfg.log_len, required_argument, log_len}, + {"aen", 'a', "NUM", CFG_POSITIVE, &cfg.aen, required_argument, aen}, {"raw-binary", 'b', "", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary}, {NULL} }; @@ -391,6 +394,11 @@ static int get_log(int argc, char **argv, struct command *cmd, struct plugin *pl if (fd < 0) return fd; + if (cfg.aen) { + cfg.log_len = 4096; + cfg.log_id = (cfg.aen >> 16) & 0xff; + } + if (!cfg.log_len) { fprintf(stderr, "non-zero log-len is required param\n"); return EINVAL;