]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
Add intel vendor specific id-ctrl decoding
authorKeith Busch <keith.busch@intel.com>
Tue, 7 Jun 2016 18:13:22 +0000 (12:13 -0600)
committerKeith Busch <keith.busch@intel.com>
Wed, 8 Jun 2016 23:26:09 +0000 (17:26 -0600)
Signed-off-by: Keith Busch <keith.busch@intel.com>
intel-nvme.c
intel-nvme.h
nvme.c
nvme.h

index 12f6b06cf0df27cac86a68bd6066e7510db3cc61..541f3b1153b1be6744c7479ad3e9d4570359c1b5 100644 (file)
@@ -24,6 +24,27 @@ static void init()
        register_extension(&intel_nvme);
 }
 
+static void intel_id_ctrl(__u8 *vs)
+{
+       char bl[9];
+        char health[21];
+
+       memcpy(bl, &vs[28], sizeof(bl));
+       memcpy(health, &vs[4], sizeof(health));
+
+        bl[sizeof(bl) - 1] = '\0';
+        health[sizeof(health) - 1] = '\0';
+
+       printf("ss      : %d\n", vs[3]);
+       printf("health  : %s\n", health[0] ? health : "healthy");
+       printf("bl      : %s\n", bl);
+}
+
+static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin)
+{
+       return __id_ctrl(argc, argv, cmd, plugin, intel_id_ctrl);
+}
+
 static int get_additional_smart_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
 {
        struct nvme_additional_smart_log smart_log;
index 68b6e19e847db08e039cc823dc4c03d4c9ef593c..5c17df7136b288b78a767f3c8417faaa28178dd5 100644 (file)
@@ -7,6 +7,7 @@
 #include "cmd.h"
 
 COMMAND_LIST(
+       ENTRY("id-ctrl", "Send NVMe Identify Controller", id_ctrl)
        ENTRY("smart-log-add", "Retrieve Intel SMART Log, show it", get_additional_smart_log)
 );
 
diff --git a/nvme.c b/nvme.c
index f5ba87a1573c6bb1d9e14dc3508f1e1978ba6385..5313755f331e9292210d8c70a71728dc4c98f058 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -849,7 +849,7 @@ static int list(int argc, char **argv, struct command *cmd, struct plugin *plugi
 }
 #endif
 
-static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin)
+int __id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin, void (*vs)(__u8 *vs))
 {
        const char *desc = "Send an Identify Controller command to "\
                "the given device and report information about the specified "\
@@ -903,7 +903,7 @@ static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *pl
                        json_nvme_id_ctrl(&ctrl, flags);
                else {
                        printf("NVME Identify Controller:\n");
-                       show_nvme_id_ctrl(&ctrl, flags);
+                       __show_nvme_id_ctrl(&ctrl, flags, vs);
                }
        }
        else if (err > 0)
@@ -913,6 +913,11 @@ static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *pl
        return err;
 }
 
+static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin)
+{
+       return __id_ctrl(argc, argv, cmd, plugin, NULL);
+}
+
 static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plugin)
 {
        const char *desc = "Send an Identify Namespace command to the "\
diff --git a/nvme.h b/nvme.h
index bbf664c29c0005b855570e9d77ba01ee567cb183..d0ad49b8ac1b2b4b30c5fda71634dedcb71c1736 100644 (file)
--- a/nvme.h
+++ b/nvme.h
@@ -598,4 +598,6 @@ int parse_and_open(int argc, char **argv, const char *desc,
 
 extern const char *devicename;
 
+int __id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin, void (*vs)(__u8 *vs));
+
 #endif /* _NVME_H */