From: Keith Busch Date: Mon, 8 Jun 2015 23:00:11 +0000 (-0600) Subject: Support for controller list namespace modes X-Git-Tag: v0.1~30 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=efb703586685f8203def4561cc2b7d8e4e527aa5;p=users%2Fsagi%2Fnvme-cli.git Support for controller list namespace modes Signed-off-by: Keith Busch --- diff --git a/Documentation/nvme-list-ctrl.1 b/Documentation/nvme-list-ctrl.1 index 811eefda..d086bf39 100644 --- a/Documentation/nvme-list-ctrl.1 +++ b/Documentation/nvme-list-ctrl.1 @@ -33,20 +33,35 @@ nvme-list-ctrl \- Send NVMe Identify List Controllers, return result and structu .sp .nf \fInvme list\-ctrl\fR [\-\-cntid= | \-c ] + [\-\-namespace\-id= | \-n ] +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 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 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= .RS 4 Retrieve the identify list structure starting with the given controller id\&. .RE +.PP +\-n , \-\-namespace\-id= +.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\&. diff --git a/Documentation/nvme-list-ctrl.html b/Documentation/nvme-list-ctrl.html index f39d7528..966e8177 100644 --- a/Documentation/nvme-list-ctrl.html +++ b/Documentation/nvme-list-ctrl.html @@ -752,27 +752,27 @@ nvme-id-ns(1) Manual Page

SYNOPSIS

-
nvme list-ctrl <device> [--cntid=<cntid> | -c <cntid>]
+
nvme list-ctrl <device> [--cntid=<cntid> | -c <cntid>]
+                        [--namespace-id=<nsid> | -n <nsid>]
+DESCRIPTION
-
- -
-

DESCRIPTION

-
-

For the NVMe device given, sends an identify command for controller list -and provides the result and returned structure.

-

The <device> parameter is mandatory and may be either the NVMe character +

+
+
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
-'--cntid' option is given to override.

-

On success, the controller array is printed for each index and controller -identifier.

-
-
-
-

OPTIONS

-
+`'--cntid'` option is given to override. + +On success, the controller array is printed for each index and controller +identifier. + +OPTIONS +
-c <cntid> @@ -785,6 +785,20 @@ identifier.

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). +

+
@@ -804,7 +818,7 @@ identifier.


diff --git a/Documentation/nvme-list-ctrl.txt b/Documentation/nvme-list-ctrl.txt index 44e645ac..640092e4 100644 --- a/Documentation/nvme-list-ctrl.txt +++ b/Documentation/nvme-list-ctrl.txt @@ -9,11 +9,12 @@ SYNOPSIS -------- [verse] 'nvme list-ctrl' [--cntid= | -c ] - + [--namespace-id= | -n ] 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 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=:: Retrieve the identify list structure starting with the given controller id. +-n :: +--namespace-id=:: + 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 da878775..3ce1dade 100644 --- 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]);