From: Keith Busch Date: Tue, 7 Jun 2016 18:13:22 +0000 (-0600) Subject: Add intel vendor specific id-ctrl decoding X-Git-Tag: v0.8~17 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=7ca24e33f59c0db7c24a41d06d81c802a39f34c8;p=users%2Fhch%2Fnvme-cli.git Add intel vendor specific id-ctrl decoding Signed-off-by: Keith Busch --- diff --git a/intel-nvme.c b/intel-nvme.c index 12f6b06..541f3b1 100644 --- a/intel-nvme.c +++ b/intel-nvme.c @@ -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; diff --git a/intel-nvme.h b/intel-nvme.h index 68b6e19..5c17df7 100644 --- a/intel-nvme.h +++ b/intel-nvme.h @@ -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 f5ba87a..5313755 100644 --- 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 bbf664c..d0ad49b 100644 --- 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 */