]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Support for controller list namespace modes
authorKeith Busch <keith.busch@intel.com>
Mon, 8 Jun 2015 23:00:11 +0000 (17:00 -0600)
committerKeith Busch <keith.busch@intel.com>
Mon, 8 Jun 2015 23:00:11 +0000 (17:00 -0600)
Signed-off-by: Keith Busch <keith.busch@intel.com>
Documentation/nvme-list-ctrl.1
Documentation/nvme-list-ctrl.html
Documentation/nvme-list-ctrl.txt
nvme.c

index 811eefda372dcaa8c4c9fb9b172a721fa70f76dd..d086bf397f26c006a4bbaf0e370cd4f75b9a5c52 100644 (file)
@@ -33,20 +33,35 @@ nvme-list-ctrl \- Send NVMe Identify List Controllers, return result and structu
 .sp
 .nf
 \fInvme list\-ctrl\fR <device> [\-\-cntid=<cntid> | \-c <cntid>]
+                        [\-\-namespace\-id=<nsid> | \-n <nsid>]
+DESCRIPTION
 .fi
-.SH "DESCRIPTION"
 .sp
-For the NVMe device given, sends an identify command for controller list and provides the result and returned structure\&.
-.sp
-The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. The starting controller in the list always begins with 0 unless the \*(Aq\-\-cntid\*(Aq option is given to override\&.
-.sp
-On success, the controller array is printed for each index and controller identifier\&.
-.SH "OPTIONS"
+.nf
+For the NVMe device given, sends an identify command for controller list
+and provides the result and returned structure\&. This uses either mode
+12h or 13h depending on the requested namespace identifer\&.
+
+The <device> parameter is mandatory and may be either the NVMe character
+device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&.
+The starting controller in the list always begins with 0 unless the
+`\*(Aq\-\-cntid\*(Aq` option is given to override\&.
+
+On success, the controller array is printed for each index and controller
+identifier\&.
+
+OPTIONS
+.fi
 .PP
 \-c <cntid>, \-\-cntid=<cntid>
 .RS 4
 Retrieve the identify list structure starting with the given controller id\&.
 .RE
+.PP
+\-n <nsid>, \-\-namespace\-id=<nsid>
+.RS 4
+If provided, will request the controllers attached to the specified namespace\&. If no namespace is given, or set to 0, the command requests the controller list for the entire subsystem, whether or not they are attached to namesapce(s)\&.
+.RE
 .SH "EXAMPLES"
 .sp
 No examples yet\&.
index f39d7528effd0a10bc14c7d76ce6b7193cedbb83..966e81773621ca6c6b01f8de1831ebcc44f79a17 100644 (file)
@@ -752,27 +752,27 @@ nvme-id-ns(1) Manual Page
 <h2 id="_synopsis">SYNOPSIS</h2>\r
 <div class="sectionbody">\r
 <div class="verseblock">\r
-<pre class="content"><em>nvme list-ctrl</em> &lt;device&gt; [--cntid=&lt;cntid&gt; | -c &lt;cntid&gt;]</pre>\r
+<pre class="content"><em>nvme list-ctrl</em> &lt;device&gt; [--cntid=&lt;cntid&gt; | -c &lt;cntid&gt;]\r
+                        [--namespace-id=&lt;nsid&gt; | -n &lt;nsid&gt;]\r
+DESCRIPTION</pre>\r
 <div class="attribution">\r
 </div></div>\r
-</div>\r
-</div>\r
-<div class="sect1">\r
-<h2 id="_description">DESCRIPTION</h2>\r
-<div class="sectionbody">\r
-<div class="paragraph"><p>For the NVMe device given, sends an identify command for controller list\r
-and provides the result and returned structure.</p></div>\r
-<div class="paragraph"><p>The &lt;device&gt; parameter is mandatory and may be either the NVMe character\r
+<div class="listingblock">\r
+<div class="content">\r
+<pre><tt>For the NVMe device given, sends an identify command for controller list\r
+and provides the result and returned structure. This uses either mode\r
+12h or 13h depending on the requested namespace identifer.\r
+\r
+The &lt;device&gt; parameter is mandatory and may be either the NVMe character\r
 device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).\r
 The starting controller in the list always begins with 0 unless the\r
-<tt>'--cntid'</tt> option is given to override.</p></div>\r
-<div class="paragraph"><p>On success, the controller array is printed for each index and controller\r
-identifier.</p></div>\r
-</div>\r
-</div>\r
-<div class="sect1">\r
-<h2 id="_options">OPTIONS</h2>\r
-<div class="sectionbody">\r
+`'--cntid'` option is given to override.\r
+\r
+On success, the controller array is printed for each index and controller\r
+identifier.\r
+\r
+OPTIONS</tt></pre>\r
+</div></div>\r
 <div class="dlist"><dl>\r
 <dt class="hdlist1">\r
 -c &lt;cntid&gt;\r
@@ -785,6 +785,20 @@ identifier.</p></div>
         Retrieve the identify list structure starting with the given controller id.\r
 </p>\r
 </dd>\r
+<dt class="hdlist1">\r
+-n &lt;nsid&gt;\r
+</dt>\r
+<dt class="hdlist1">\r
+--namespace-id=&lt;nsid&gt;\r
+</dt>\r
+<dd>\r
+<p>\r
+        If provided, will request the controllers attached to the\r
+        specified namespace. If no namespace is given, or set to 0, the\r
+        command requests the controller list for the entire subsystem,\r
+        whether or not they are attached to namesapce(s).\r
+</p>\r
+</dd>\r
 </dl></div>\r
 </div>\r
 </div>\r
@@ -804,7 +818,7 @@ identifier.</p></div>
 <div id="footnotes"><hr /></div>\r
 <div id="footer">\r
 <div id="footer-text">\r
-Last updated 2015-06-08 11:09:39 MDT\r
+Last updated 2015-06-08 16:59:37 MDT\r
 </div>\r
 </div>\r
 </body>\r
index 44e645acf711308782ce359e7460330eadf14e74..640092e482391bcd43c4ed283a507b075adeafc8 100644 (file)
@@ -9,11 +9,12 @@ SYNOPSIS
 --------
 [verse]
 'nvme list-ctrl' <device> [--cntid=<cntid> | -c <cntid>]
-
+                       [--namespace-id=<nsid> | -n <nsid>]
 DESCRIPTION
 -----------
 For the NVMe device given, sends an identify command for controller list
-and provides the result and returned structure.
+and provides the result and returned structure. This uses either mode
+12h or 13h depending on the requested namespace identifer.
 
 The <device> parameter is mandatory and may be either the NVMe character
 device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).
@@ -29,6 +30,13 @@ OPTIONS
 --cntid=<cntid>::
        Retrieve the identify list structure starting with the given controller id.
 
+-n <nsid>::
+--namespace-id=<nsid>::
+       If provided, will request the controllers attached to the
+       specified namespace. If no namespace is given, or set to 0, the
+       command requests the controller list for the entire subsystem,
+       whether or not they are attached to namesapce(s).
+
 EXAMPLES
 --------
 No examples yet.
diff --git a/nvme.c b/nvme.c
index da878775f9159a4d3a4f0e3e3e5ffc0d1f37ffdf..3ce1dadeb865ed3a1934ca5ce1fbee93371799e2 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -1167,6 +1167,7 @@ static int list_ctrl(int argc, char **argv)
 
        struct config {
                __u16 cntid;
+               __u32 namespace_id;
        };
        struct config cfg;
 
@@ -1177,6 +1178,8 @@ static int list_ctrl(int argc, char **argv)
        const struct argconfig_commandline_options command_line_options[] = {
                {"cntid", "NUM",  CFG_POSITIVE, &defaults.cntid, required_argument, NULL},
                {"c",     "NUM",  CFG_POSITIVE, &defaults.cntid, required_argument, NULL},
+               {"namespace-id", "NUM",  CFG_POSITIVE, &defaults.namespace_id, required_argument, NULL},
+               {"n",            "NUM",  CFG_POSITIVE, &defaults.namespace_id, required_argument, NULL},
                {0}
        };
        argconfig_parse(argc, argv, "list_ctrl", command_line_options,
@@ -1186,7 +1189,8 @@ static int list_ctrl(int argc, char **argv)
        if (posix_memalign((void *)&cntlist, getpagesize(), 0x1000))
                return ENOMEM;
 
-       err = identify(0, cntlist, cfg.cntid << 16 | 0x13);
+       err = identify(cfg.namespace_id, cntlist,
+                       cfg.cntid << 16 | cfg.namespace_id ? 0x12 : 0x13);
        if (!err) {
                for (i = 0; i < (min(cntlist->num, 2048)); i++)
                        printf("[%4u]:%#x\n", i, cntlist->identifier[i]);