]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
NVMe: Add support for get feature's SEL field.
authorKeith Busch <keith.busch@intel.com>
Mon, 1 Dec 2014 21:47:27 +0000 (14:47 -0700)
committerKeith Busch <keith.busch@intel.com>
Mon, 1 Dec 2014 21:47:27 +0000 (14:47 -0700)
Added in the 1.1 specification.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Documentation/nvme-get-feature.txt
nvme.c

index 5ca09364513d3d617f406e391a0d2d9a0fb248db..459f38c7ba1251b8043128c1e20378b4afdfbe84 100644 (file)
@@ -11,6 +11,7 @@ SYNOPSIS
 'nvme get-feature' <device> [--namespace-id=<nsid> | -n <nsid>]
                          [--feature-id=<fid> | -f <fid>] [--cdw11=<cdw11>]
                          [--data-len=<data-len> | -l <data-len>]
+                         [--sel=<select> | -s <select>]
                          [--raw-binary | -b]
 
 DESCRIPTION
@@ -40,6 +41,21 @@ OPTIONS
        The feature id to send with the command. Value provided should
        be in hex.
 
+-s <select>::
+--sel=<select>::
+       Select (SEL): This field specifies which value of the attributes
+       to return in the provided data:
++
+[]
+|==================
+|Select|Description
+|0|Current 
+|1|Default 
+|2|Saved
+|3|Supported capabilities
+|4–7|Reserved
+|==================
+
 -l <data-len>::
 --data-len=<data-len>::
        The data length for the buffer returned for this feature. Most
diff --git a/nvme.c b/nvme.c
index 8d53fd02053ae5ad8815e1f3b7bb4a3d353b62a9..941df724fa65cbc46bd4320108034129a3dedce0 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -864,18 +864,20 @@ static int nvme_feature(int opcode, void *buf, int data_len, __u32 fid,
 static int get_feature(int argc, char **argv)
 {
        int opt, err, long_index = 0;
-       unsigned int f, result, raw = 0, cdw11 = 0, nsid = 0, data_len = 0;
+       unsigned int f, result, raw = 0, cdw10, cdw11 = 0, nsid = 0, data_len = 0;
+       unsigned char sel = 0;
        void *buf = NULL;
        static struct option opts[] = {
                {"namespace-id", required_argument, 0, 'n'},
                {"feature-id", required_argument, 0, 'f'},
+               {"sel", required_argument, 0, 's'},
                {"cdw11", required_argument, 0, 0},
                {"data-len", required_argument, 0, 'l'},
                {"raw-binary", no_argument, 0, 'b'},
                {0, 0, 0, 0 }
        };
 
-       while ((opt = getopt_long(argc, (char **)argv, "n:f:l:b", opts,
+       while ((opt = getopt_long(argc, (char **)argv, "n:f:l:s:b", opts,
                                                        &long_index)) != -1) {
                switch (opt) {
                case 0:
@@ -890,6 +892,9 @@ static int get_feature(int argc, char **argv)
                case 'l':
                        get_int(optarg, &data_len);
                        break;
+               case 's':
+                       get_byte(optarg, &sel);
+                       break;
                case 'b':
                        raw = 1;
                        break;
@@ -898,6 +903,10 @@ static int get_feature(int argc, char **argv)
                }
        }
        get_dev(optind, argc, argv);
+       if (sel > 7) {
+               fprintf(stderr, "invalid 'select' param:%d\n", sel);
+               return EINVAL;
+       }
        if (!f) {
                fprintf(stderr, "feature-id required param\n");
                return EINVAL;
@@ -907,7 +916,8 @@ static int get_feature(int argc, char **argv)
        if (data_len)
                buf = malloc(data_len);
 
-       err = nvme_feature(nvme_admin_get_features, buf, data_len, f, nsid,
+       cdw10 = sel << 8 | f;
+       err = nvme_feature(nvme_admin_get_features, buf, data_len, cdw10, nsid,
                                                        cdw11, &result);
        if (!err) {
                printf("get-feature:%d(%s), value:%#08x\n", f,