]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
Add AEN decoder helper to get-log
authorKeith Busch <keith.busch@intel.com>
Fri, 20 Oct 2017 21:11:18 +0000 (15:11 -0600)
committerKeith Busch <keith.busch@intel.com>
Fri, 20 Oct 2017 21:11:18 +0000 (15:11 -0600)
This is a convenience helper for retreiving logs from an AEN result.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Documentation/nvme-get-log.txt
nvme.c

index 1a496f7efbd59a35547801a13b688efb0f071943..55ba5afa58b8e9b263e064ed860b42069fe94340 100644 (file)
@@ -10,6 +10,7 @@ SYNOPSIS
 [verse]
 'nvme get-log' <device> [--log-id=<log-id> | -i <log-id>]
                      [--log-len=<log-len> | -l <log-len>]
+                     [--aen=<aen> | -a <aen>]
                      [--namespace-id=<nsid> | -n <nsid>]
                      [--raw-binary | -b]
 
@@ -38,6 +39,12 @@ OPTIONS
 --log-id=<log-id>::
        Sets the commands requested log-id to <log-id>. Defaults to 0.
 
+-a <aen>::
+--aen=<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 <nsid>::
 --namespace-id=<nsid>::
        Sets the command's nsid value to the given nsid. Defaults to
diff --git a/nvme.c b/nvme.c
index 74a4fd0975a45ac2f0ca01dd907058eb632d81e3..07bd5cbbe3c31f782529b06428df7ecd44a41016 100644 (file)
--- 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;