From: Keith Busch Date: Fri, 27 Oct 2017 16:09:52 +0000 (-0600) Subject: Add command effects log page X-Git-Tag: v1.5~39 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=b2d99e4d306779e4bcf2648b8fb9204c69a586c1;p=users%2Fhch%2Fnvme-cli.git Add command effects log page This prints out the nvme command effects log page for all commands the log reports to be supported. Signed-off-by: Keith Busch --- diff --git a/Documentation/nvme-effects-log.1 b/Documentation/nvme-effects-log.1 new file mode 100644 index 0000000..9934a08 --- /dev/null +++ b/Documentation/nvme-effects-log.1 @@ -0,0 +1,73 @@ +'\" t +.\" Title: nvme-effects-log +.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 10/27/2017 +.\" Manual: NVMe Manual +.\" Source: NVMe +.\" Language: English +.\" +.TH "NVME\-EFFECTS\-LOG" "1" "10/27/2017" "NVMe" "NVMe Manual" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +nvme-effects-log \- Send NVMe Command Effects log page request, returns result and log +.SH "SYNOPSIS" +.sp +.nf +\fInvme effects\-log\fR +.fi +.SH "DESCRIPTION" +.sp +Retrieves the NVMe Command Effects log page from an NVMe device and provides the retuned structure\&. +.sp +The parameter is mandatory and should be the NVMe character device (ex: /dev/nvme0)\&. +.sp +On success, the returned command effects log structure will be printed for each command that is supported\&. +.SH "OPTIONS" +.sp +No options\&. +.SH "EXAMPLES" +.sp +.RS 4 +.ie n \{\ +\h'-04'\(bu\h'+03'\c +.\} +.el \{\ +.sp -1 +.IP \(bu 2.3 +.\} +Print the effects log page in a human readable format: +.sp +.if n \{\ +.RS 4 +.\} +.nf +# nvme effects\-log /dev/nvme0 +.fi +.if n \{\ +.RE +.\} +.sp +Not much to it\&. +.RE +.SH "NVME" +.sp +Part of the nvme\-user suite diff --git a/Documentation/nvme-effects-log.html b/Documentation/nvme-effects-log.html new file mode 100644 index 0000000..8650318 --- /dev/null +++ b/Documentation/nvme-effects-log.html @@ -0,0 +1,802 @@ + + + + + +nvme-effects-log(1) + + + + + +
+
+

SYNOPSIS

+
+
+
nvme effects-log <device>
+
+
+
+
+
+

DESCRIPTION

+
+

Retrieves the NVMe Command Effects log page from an NVMe device and provides +the retuned structure.

+

The <device> parameter is mandatory and should be the NVMe character +device (ex: /dev/nvme0).

+

On success, the returned command effects log structure will be printed +for each command that is supported.

+
+
+
+

OPTIONS

+
+

No options.

+
+
+
+

EXAMPLES

+
+
    +
  • +

    +Print the effects log page in a human readable format: +

    +
    +
    +
    # nvme effects-log /dev/nvme0
    +
    +

    Not much to it.

    +
  • +
+
+
+
+

NVME

+
+

Part of the nvme-user suite

+
+
+
+

+ + + diff --git a/Documentation/nvme-effects-log.txt b/Documentation/nvme-effects-log.txt new file mode 100644 index 0000000..90d2cf2 --- /dev/null +++ b/Documentation/nvme-effects-log.txt @@ -0,0 +1,42 @@ +nvme-effects-log(1) +=================== + +NAME +---- +nvme-effects-log - Send NVMe Command Effects log page request, returns result and log + +SYNOPSIS +-------- +[verse] +'nvme effects-log' + +DESCRIPTION +----------- +Retrieves the NVMe Command Effects log page from an NVMe device and provides +the retuned structure. + +The parameter is mandatory and should be the NVMe character +device (ex: /dev/nvme0). + +On success, the returned command effects log structure will be printed +for each command that is supported. + +OPTIONS +------- + +No options. + +EXAMPLES +-------- +* Print the effects log page in a human readable format: ++ +------------ +# nvme effects-log /dev/nvme0 +------------ ++ + +Not much to it. + +NVME +---- +Part of the nvme-user suite diff --git a/nvme-builtin.h b/nvme-builtin.h index a96d42e..1a5ab36 100644 --- a/nvme-builtin.h +++ b/nvme-builtin.h @@ -22,6 +22,7 @@ COMMAND_LIST( ENTRY("fw-log", "Retrieve FW Log, show it", get_fw_log) ENTRY("smart-log", "Retrieve SMART Log, show it", get_smart_log) ENTRY("error-log", "Retrieve Error Log, show it", get_error_log) + ENTRY("effects-log", "Retrieve Command Effects Log, show it", get_effects_log) ENTRY("get-feature", "Get feature and show the resulting value", get_feature) ENTRY("set-feature", "Set a feature and show the resulting value", set_feature) ENTRY("format", "Format namespace with new block format", format) diff --git a/nvme-print.c b/nvme-print.c index c3c468e..9f524cd 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -1006,6 +1006,23 @@ void show_fw_log(struct nvme_firmware_log_page *fw_log, const char *devname) fw_to_string(fw_log->frs[i])); } +void show_effects_log(struct nvme_effects_log_page *effects) +{ + int i; + __u32 effect; + + for (i = 0; i < 256; i++) { + effect = le32_to_cpu(effects->acs[i]); + if (effect & 1) + printf("ACS%-4d: %08x\n", i, effects->acs[i]); + } + for (i = 0; i < 256; i++) { + effect = le32_to_cpu(effects->acs[i]); + if (effect & 1) + printf("IOCS%-3d: %08x\n", i, effects->iocs[i]); + } +} + uint64_t int48_to_long(__u8 *data) { int i; diff --git a/nvme-print.h b/nvme-print.h index 4cdcb95..d110b98 100644 --- a/nvme-print.h +++ b/nvme-print.h @@ -25,6 +25,7 @@ void show_lba_range(struct nvme_lba_range_type *lbrt, int nr_ranges); void show_error_log(struct nvme_error_log_page *err_log, int entries, const char *devname); void show_smart_log(struct nvme_smart_log *smart, unsigned int nsid, const char *devname); void show_fw_log(struct nvme_firmware_log_page *fw_log, const char *devname); +void show_effects_log(struct nvme_effects_log_page *effects); void show_ctrl_registers(void *bar, unsigned int mode); void show_nvme_id_ns_descs(void *data); diff --git a/nvme.c b/nvme.c index 07bd5cb..57eeb18 100644 --- a/nvme.c +++ b/nvme.c @@ -223,6 +223,38 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug return err; } +static int get_effects_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) +{ + const char *desc = "Retrieve command effects log page and print the table."; + struct nvme_effects_log_page effects; + + int err, fd; + + struct config { + }; + + struct config cfg = { + }; + + const struct argconfig_commandline_options command_line_options[] = { + {NULL} + }; + + fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg)); + if (fd < 0) + return fd; + + err = nvme_get_log(fd, 0xffffffff, 5, 4096, &effects); + if (!err) + show_effects_log(&effects); + else if (err > 0) + fprintf(stderr, "NVMe Status:%s(%x)\n", + nvme_status_to_string(err), err); + else + perror("effects log page"); + return err; +} + static int get_error_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { const char *desc = "Retrieve specified number of "\ diff --git a/nvme.h b/nvme.h index 5530f90..ec68f17 100644 --- a/nvme.h +++ b/nvme.h @@ -33,6 +33,12 @@ typedef struct { #include "linux/nvme.h" +struct nvme_effects_log_page { + __le32 acs[256]; + __le32 iocs[256]; + __u8 resv[2048]; +}; + struct nvme_error_log_page { __u64 error_count; __u16 sqid;