'\" t
.\" Title: nvme-id-iocs
-.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
-.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
-.\" Date: 10/20/2020
+.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
+.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
+.\" Date: 05/28/2021
.\" Manual: NVMe Manual
.\" Source: NVMe
.\" Language: English
.\"
-.TH "NVME\-ID\-IOCS" "1" "10/20/2020" "NVMe" "NVMe Manual"
+.TH "NVME\-ID\-IOCS" "1" "05/28/2021" "NVMe" "NVMe Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.sp
.nf
\fInvme id\-iocs\fR <device> [\-\-controller\-id=<cntid> | \-c <cntid>]
+ [\-o <fmt> | \-\-output\-format=<fmt>]
.fi
.SH "DESCRIPTION"
.sp
.RS 4
Retrieve the identify I/O Command set data structure for the given cntid\&. If this value is not given, cntid will be 0xffff\&.
.RE
+.PP
+\-H, \-\-human\-readable
+.RS 4
+This option will parse and format many of the bit fields into human\-readable formats\&.
+.RE
+.PP
+\-o <format>, \-\-output\-format=<format>
+.RS 4
+Set the reporting format to
+\fInormal\fR,
+\fIjson\fR, or
+\fIbinary\fR\&. Only one output format can be used at a time\&.
+.RE
.SH "EXAMPLES"
.sp
.RS 4
.RE
.\}
.RE
+.sp
+.RS 4
+.ie n \{\
+\h'-04'\(bu\h'+03'\c
+.\}
+.el \{\
+.sp -1
+.IP \(bu 2.3
+.\}
+show the fields in human readable format
+.sp
+.if n \{\
+.RS 4
+.\}
+.nf
+# nvme id\-iocs /dev/nvme0 \-H
+.fi
+.if n \{\
+.RE
+.\}
+.RE
.SH "NVME"
.sp
Part of the nvme\-user suite
<h2 id="_synopsis">SYNOPSIS</h2>\r
<div class="sectionbody">\r
<div class="verseblock">\r
-<pre class="content"><em>nvme id-iocs</em> <device> [--controller-id=<cntid> | -c <cntid>]</pre>\r
+<pre class="content"><em>nvme id-iocs</em> <device> [--controller-id=<cntid> | -c <cntid>]\r
+ [-o <fmt> | --output-format=<fmt>]</pre>\r
<div class="attribution">\r
</div></div>\r
</div>\r
cntid. If this value is not given, cntid will be 0xffff.\r
</p>\r
</dd>\r
+<dt class="hdlist1">\r
+-H\r
+</dt>\r
+<dt class="hdlist1">\r
+--human-readable\r
+</dt>\r
+<dd>\r
+<p>\r
+ This option will parse and format many of the bit fields\r
+ into human-readable formats.\r
+</p>\r
+</dd>\r
+<dt class="hdlist1">\r
+-o <format>\r
+</dt>\r
+<dt class="hdlist1">\r
+--output-format=<format>\r
+</dt>\r
+<dd>\r
+<p>\r
+ Set the reporting format to <em>normal</em>, <em>json</em>, or\r
+ <em>binary</em>. Only one output format can be used at a time.\r
+</p>\r
+</dd>\r
</dl></div>\r
</div>\r
</div>\r
<pre><code># nvme id-iocs /dev/nvme0</code></pre>\r
</div></div>\r
</li>\r
+<li>\r
+<p>\r
+show the fields in human readable format\r
+</p>\r
+<div class="listingblock">\r
+<div class="content">\r
+<pre><code># nvme id-iocs /dev/nvme0 -H</code></pre>\r
+</div></div>\r
+</li>\r
</ul></div>\r
</div>\r
</div>\r
<div id="footer">\r
<div id="footer-text">\r
Last updated\r
- 2020-05-06 10:39:59 CEST\r
+ 2021-05-28 23:15:06 IST\r
</div>\r
</div>\r
</body>\r
--------
[verse]
'nvme id-iocs' <device> [--controller-id=<cntid> | -c <cntid>]
+ [-o <fmt> | --output-format=<fmt>]
DESCRIPTION
-----------
--controller-id=<cntid>::
Retrieve the identify I/O Command set data structure for the given
cntid. If this value is not given, cntid will be 0xffff.
+-H::
+--human-readable::
+ This option will parse and format many of the bit fields
+ into human-readable formats.
+
+-o <format>::
+--output-format=<format>::
+ Set the reporting format to 'normal', 'json', or
+ 'binary'. Only one output format can be used at a time.
EXAMPLES
--------
------------
# nvme id-iocs /dev/nvme0
------------
-
++
+* show the fields in human readable format
++
+------------
+# nvme id-iocs /dev/nvme0 -H
+------------
NVME
----
Part of the nvme-user suite
NVME_IOCS_ZONED = 0x02,
};
+#define NVME_NUM_IOCS_COMBINATIONS 512
+
#define NVME_AQ_DEPTH 32
#define NVME_NR_AEN_COMMANDS 1
#define NVME_AQ_BLK_MQ_DEPTH (NVME_AQ_DEPTH - NVME_NR_AEN_COMMANDS)
};
struct nvme_id_iocs {
- __le64 iocs[512];
+ __le64 iocs[NVME_NUM_IOCS_COMBINATIONS];
};
enum {
}
}
-void nvme_show_id_iocs(struct nvme_id_iocs *iocs)
+static void nvme_show_iocs_vector(__u64 iocs_vec)
+{
+ __u64 rsvd3 = iocs_vec >> 3;
+ __u8 zns_cmd_set = (iocs_vec >> 2) & 0x1;
+ __u8 kv_cmd_set = (iocs_vec >> 1) & 0x1;
+ __u8 nvm_cmd_set = iocs_vec & 0x1;
+
+ if (rsvd3)
+ printf(" [63:3] : %"PRIx64"\tReserved3\n", le64_to_cpu(rsvd3));
+ printf(" [2:2] : %#x\tZNS Command Set %sSelected\n",
+ zns_cmd_set, zns_cmd_set ? "" : "not ");
+ printf(" [1:1] : %#x\tKV Command Set %sSelected\n",
+ kv_cmd_set, kv_cmd_set ? "" : "not ");
+ printf(" [0:0] : %#x\tNVM Command Set %sSelected\n",
+ nvm_cmd_set, nvm_cmd_set ? "" : "not ");
+ printf("\n");
+}
+
+static void json_id_iocs(struct nvme_id_iocs *iocs)
+{
+ struct json_object *root;
+ struct json_object *entries;
+ int i;
+
+ root = json_create_object();
+ entries = json_create_array();
+
+ for (i = 0; i < NVME_NUM_IOCS_COMBINATIONS; i++) {
+ if (iocs->iocs[i]) {
+ struct json_object *entry = json_create_object();
+ json_object_add_value_uint(entry, "iocs",
+ le64_to_cpu(iocs->iocs[i]));
+ json_array_add_value_object(entries, entry);
+ }
+ }
+
+ json_object_add_value_array(root, "iocs_list", entries);
+ json_print_object(root, NULL);
+ printf("\n");
+ json_free_object(root);
+
+}
+
+void nvme_show_id_iocs(struct nvme_id_iocs *iocs, enum nvme_print_flags flags)
{
- __u16 i;
+ if (flags & BINARY)
+ return d_raw((unsigned char *)iocs, sizeof(*iocs));
+ else if (flags & JSON)
+ return json_id_iocs(iocs);
+
+ bool human = flags & VERBOSE;
+ int i;
- for (i = 0; i < 512; i++)
- if (iocs->iocs[i])
- printf("I/O Command Set Combination[%u]:%"PRIx64"\n", i,
+ for (i = 0; i < NVME_NUM_IOCS_COMBINATIONS; i++) {
+ if (iocs->iocs[i]) {
+ printf("I/O Command Set Combination[%u]: %"PRIx64"\n", i,
(uint64_t)le64_to_cpu(iocs->iocs[i]));
+ if (human)
+ nvme_show_iocs_vector(le64_to_cpu(iocs->iocs[i]));
+ }
+ }
}
static const char *nvme_trtype_to_string(__u8 trtype)
enum nvme_print_flags flags);
void nvme_show_id_uuid_list(const struct nvme_id_uuid_list *uuid_list,
enum nvme_print_flags flags);
-void nvme_show_id_iocs(struct nvme_id_iocs *iocs);
+void nvme_show_id_iocs(struct nvme_id_iocs *iocs, enum nvme_print_flags flags);
void nvme_show_list_ctrl(struct nvme_controller_list *ctrl_list,
enum nvme_print_flags flags);
void nvme_show_list_ns(__u32 *ns_list, enum nvme_print_flags flags);
"given device, returns properties of the specified controller "\
"in either human-readable or binary format.";
const char *controller_id = "identifier of desired controller";
+ const char *human_readable = "show info in human readable format";
struct nvme_id_iocs iocs;
+ enum nvme_print_flags flags;
int err, fd;
struct config {
__u16 cntid;
+ char *output_format;
+ int human_readable;
};
struct config cfg = {
.cntid = 0xffff,
+ .output_format = "normal",
};
OPT_ARGS(opts) = {
- OPT_SHRT("controller-id", 'c', &cfg.cntid, controller_id),
+ OPT_SHRT("controller-id", 'c', &cfg.cntid, controller_id),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable),
OPT_END()
};
goto ret;
}
+ err = flags = validate_output_format(cfg.output_format);
+ if (flags < 0)
+ goto close_fd;
+ if (cfg.human_readable)
+ flags |= VERBOSE;
+
err = nvme_identify_iocs(fd, cfg.cntid, &iocs);
if (!err) {
printf("NVMe Identify I/O Command Set:\n");
- nvme_show_id_iocs(&iocs);
+ nvme_show_id_iocs(&iocs, flags);
} else if (err > 0)
nvme_show_status(err);
else
perror("NVMe Identify I/O Command Set");
+close_fd:
close(fd);
ret:
return nvme_status_to_errno(err, false);