Define constants to make clear what a device is doing.
Noticing that one identify mode was never used, so adding an option.
Signed-off-by: Keith Busch <keith.busch@intel.com>
.\" Title: nvme-id-ns
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
-.\" Date: 02/26/2016
+.\" Date: 03/18/2016
.\" Manual: NVMe Manual
.\" Source: NVMe
.\" Language: English
.\"
-.TH "NVME\-ID\-NS" "1" "02/26/2016" "NVMe" "NVMe Manual"
+.TH "NVME\-ID\-NS" "1" "03/18/2016" "NVMe" "NVMe Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.sp
.nf
\fInvme id\-ns\fR <device> [\-v | \-\-vendor\-specific] [\-b | \-\-raw\-binary]
- [\-\-namespace\-id=<nsid> | \-n <nsid>]
+ [\-\-namespace\-id=<nsid> | \-n <nsid>] [\-f | \-\-force]
.fi
.SH "DESCRIPTION"
.sp
Retrieve the identify namespace structure for the given nsid\&. This is required for the character devices, or overrides the block nsid if given\&.
.RE
.PP
+\-f, \-\-force
+.RS 4
+Request controller return the indentify namespace structure even if the namespace is not attached to the controller\&. This is valid only for controllers at or newer than revision 1\&.2\&. Controllers at revision lower than this may interpret the command incorrectly\&.
+.RE
+.PP
\-b, \-\-raw\-binary
.RS 4
Print the raw buffer to stdout\&. Structure is not parsed by program\&. This overrides the vendor specific and human readable options\&.
p.table {\r
margin-top: 0;\r
}\r
-/* Because the table frame attribute is overridden by CSS in most browsers. */\r
+/* Because the table frame attribute is overriden by CSS in most browsers. */\r
div.tableblock > table[frame="void"] {\r
border-style: none;\r
}\r
<div class="sectionbody">\r
<div class="verseblock">\r
<pre class="content"><em>nvme id-ns</em> <device> [-v | --vendor-specific] [-b | --raw-binary]\r
- [--namespace-id=<nsid> | -n <nsid>]</pre>\r
+ [--namespace-id=<nsid> | -n <nsid>] [-f | --force]</pre>\r
<div class="attribution">\r
</div></div>\r
</div>\r
</p>\r
</dd>\r
<dt class="hdlist1">\r
+-f\r
+</dt>\r
+<dt class="hdlist1">\r
+--force\r
+</dt>\r
+<dd>\r
+<p>\r
+ Request controller return the indentify namespace structure even\r
+ if the namespace is not attached to the controller. This is valid\r
+ only for controllers at or newer than revision 1.2. Controllers\r
+ at revision lower than this may interpret the command incorrectly.\r
+</p>\r
+</dd>\r
+<dt class="hdlist1">\r
-b\r
</dt>\r
<dt class="hdlist1">\r
<div id="footnotes"><hr /></div>\r
<div id="footer">\r
<div id="footer-text">\r
-Last updated 2016-02-26 08:27:57 MST\r
+Last updated 2016-03-18 11:56:04 MDT\r
</div>\r
</div>\r
</body>\r
--------
[verse]
'nvme id-ns' <device> [-v | --vendor-specific] [-b | --raw-binary]
- [--namespace-id=<nsid> | -n <nsid>]
+ [--namespace-id=<nsid> | -n <nsid>] [-f | --force]
DESCRIPTION
-----------
is required for the character devices, or overrides the block nsid
if given.
+-f::
+--force::
+ Request controller return the indentify namespace structure even
+ if the namespace is not attached to the controller. This is valid
+ only for controllers at or newer than revision 1.2. Controllers
+ at revision lower than this may interpret the command incorrectly.
+
-b::
--raw-binary::
Print the raw buffer to stdout. Structure is not parsed by
NVME_CTRL_VWC_PRESENT = 1 << 0,
};
+enum {
+ NVME_ID_CNS_NS = 0x00,
+ NVME_ID_CNS_CTRL = 0x01,
+ NVME_ID_CNS_NS_ACTIVE_LIST = 0x02,
+ NVME_ID_CNS_NS_PRESENT_LIST = 0x10,
+ NVME_ID_CNS_NS_PRESENT = 0x11,
+ NVME_ID_CNS_CTRL_NS_LIST = 0x12,
+ NVME_ID_CNS_CTRL_LIST = 0x13,
+};
+
struct nvme_lbaf {
__le16 ms;
__u8 ds;
int nvme_identify_ns(int fd, __u32 nsid, bool present, void *data)
{
- return nvme_identify(fd, nsid, present ? 0x11 : 0, data);
+ int cns = present ? NVME_ID_CNS_NS_PRESENT : NVME_ID_CNS_NS;
+
+ return nvme_identify(fd, nsid, cns, data);
}
int nvme_identify_ns_list(int fd, __u32 nsid, bool all, void *data)
{
- return nvme_identify(fd, nsid, all ? 0x10 : 0x2, data);
+ int cns = all ? NVME_ID_CNS_NS_ACTIVE_LIST : NVME_ID_CNS_NS_PRESENT_LIST;
+
+ return nvme_identify(fd, nsid, cns, data);
}
int nvme_identify_ctrl_list(int fd, __u32 nsid, __u16 cntid, void *data)
{
- return nvme_identify(fd, nsid, (cntid << 16) | (nsid ? 0x13 : 0x12), data);
+ int cns = nsid ? NVME_ID_CNS_CTRL_NS_LIST : NVME_ID_CNS_CTRL_LIST;
+
+ return nvme_identify(fd, nsid, (cntid << 16) | cns, data);
}
int nvme_get_log(int fd, __u32 nsid, __u32 cdw10, __u32 data_len, void *data)
int nvme_fw_log(int fd, struct nvme_firmware_log_page *fw_log)
{
- return nvme_log(fd, 0xffffffff, 3, sizeof(*fw_log), fw_log);
+ return nvme_log(fd, 0xffffffff, NVME_LOG_FW_SLOT, sizeof(*fw_log), fw_log);
}
int nvme_error_log(int fd, __u32 nsid, int entries,
struct nvme_error_log_page *err_log)
{
- return nvme_log(fd, nsid, 1, entries * sizeof(*err_log), err_log);
+ return nvme_log(fd, nsid, NVME_LOG_ERROR, entries * sizeof(*err_log), err_log);
}
int nvme_smart_log(int fd, __u32 nsid, struct nvme_smart_log *smart_log)
{
- return nvme_log(fd, nsid, 2, sizeof(*smart_log), smart_log);
+ return nvme_log(fd, nsid, NVME_LOG_SMART, sizeof(*smart_log), smart_log);
}
int nvme_intel_smart_log(int fd, __u32 nsid,
"given device, returns properties of the specified namespace "\
"in either human-readable or binary format. Can also return "\
"binary vendor-specific namespace attributes.";
+ const char *force = "Return this namespace, even if not attaced (1.2 devices only)";
const char *vendor_specific = "dump binary vendor infos";
const char *raw_binary = "show infos in binary format";
const char *human_readable = "show infos in readable format";
__u8 vendor_specific;
__u8 raw_binary;
__u8 human_readable;
+ __u8 force;
};
struct config cfg = {
const struct argconfig_commandline_options command_line_options[] = {
{"namespace-id", 'n', "NUM", CFG_POSITIVE, &cfg.namespace_id, required_argument, namespace_id},
+ {"force", 'f', "FLAG", CFG_NONE, &cfg.force, no_argument, force},
{"vendor-specific", 'v', "FLAG", CFG_NONE, &cfg.vendor_specific, no_argument, vendor_specific},
{"raw-binary", 'b', "FLAG", CFG_NONE, &cfg.raw_binary, no_argument, raw_binary},
{"human-readable", 'H', "FLAG", CFG_NONE, &cfg.human_readable, no_argument, human_readable},
if (cfg.human_readable)
flags |= HUMAN;
-
if (!cfg.namespace_id) {
cfg.namespace_id = nvme_get_nsid(fd);
if (cfg.namespace_id <= 0) {
exit(errno);
}
}
- err = nvme_identify_ns(fd, cfg.namespace_id, 0, &ns);
+
+ err = nvme_identify_ns(fd, cfg.namespace_id, cfg.force, &ns);
if (!err) {
if (cfg.raw_binary)
d_raw((unsigned char *)&ns, sizeof(ns));