From mboxrd@z Thu Jan 1 00:00:00 1970 From: scott.bauer@intel.com (Scott Bauer) Date: Mon, 5 Feb 2018 14:26:23 -0700 Subject: [PATCH] nvme-cli: telemetry-log add controller initiated log gathering Message-ID: <20180205212623.2929-1-scott.bauer@intel.com> If the controller has a controller initiated log (0x8) available, we can now retrieve it. Signed-off-by: Scott Bauer --- linux/nvme.h | 1 + nvme-ioctl.c | 6 +++++- nvme-ioctl.h | 2 +- nvme.c | 8 ++++++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/linux/nvme.h b/linux/nvme.h index 8bacf3a..537217a 100644 --- a/linux/nvme.h +++ b/linux/nvme.h @@ -795,6 +795,7 @@ enum { NVME_LOG_FW_SLOT = 0x03, NVME_LOG_CMD_EFFECTS = 0x05, NVME_LOG_TELEMETRY_HOST = 0x07, + NVME_LOG_TELEMETRY_CTRL = 0x08, NVME_LOG_DISC = 0x70, NVME_LOG_RESERVATION = 0x80, NVME_LOG_SANITIZE = 0x81, diff --git a/nvme-ioctl.c b/nvme-ioctl.c index 6dd7192..a6e1e01 100644 --- a/nvme-ioctl.c +++ b/nvme-ioctl.c @@ -412,8 +412,12 @@ int nvme_get_log(int fd, __u32 nsid, __u8 log_id, __u32 data_len, void *data) } int nvme_get_telemetry_log(int fd, void *lp, int generate_report, - size_t log_page_size, __u64 offset) + int ctrl_init, size_t log_page_size, __u64 offset) { + if (ctrl_init) + return nvme_get_log13(fd, NVME_NSID_ALL, NVME_LOG_TELEMETRY_CTRL, + NVME_NO_LOG_LSP, offset, + log_page_size, lp); if (generate_report) return nvme_get_log13(fd, NVME_NSID_ALL, NVME_LOG_TELEMETRY_HOST, NVME_TELEM_LSP_CREATE, offset, diff --git a/nvme-ioctl.h b/nvme-ioctl.h index 6569665..f5b287b 100644 --- a/nvme-ioctl.h +++ b/nvme-ioctl.h @@ -84,7 +84,7 @@ int nvme_get_log(int fd, __u32 nsid, __u8 log_id, __u32 data_len, void *data); int nvme_get_telemetry_log(int fd, void *lp, int generate_report, - size_t log_page_size, __u64 offset); + int ctrl_gen, size_t log_page_size, __u64 offset); int nvme_fw_log(int fd, struct nvme_firmware_log_page *fw_log); int nvme_error_log(int fd, int entries, struct nvme_error_log_page *err_log); int nvme_smart_log(int fd, __u32 nsid, struct nvme_smart_log *smart_log); diff --git a/nvme.c b/nvme.c index 499beef..8e97cfa 100644 --- a/nvme.c +++ b/nvme.c @@ -233,6 +233,7 @@ static int get_telemetry_log(int argc, char **argv, struct command *cmd, struct const char *desc = "Retrieve telemetry log and write to binary file"; const char *fname = "File name to save raw binary, includes header"; const char *hgen = "Have the host tell the controller to generate the report"; + const char *cgen = "Gather report generated by the controller."; struct nvme_telemetry_log_page_hdr *hdr; void *page_log; size_t full_size, offset, num_blocks; @@ -241,15 +242,18 @@ static int get_telemetry_log(int argc, char **argv, struct command *cmd, struct struct config { char *file_name; __u32 host_gen; + int ctrl_init; }; struct config cfg = { .file_name = NULL, .host_gen = 1, + .ctrl_init = 0, }; const struct argconfig_commandline_options command_line_options[] = { {"output-file", 'o', "FILE", CFG_STRING, &cfg.file_name, required_argument, fname}, {"host-generate", 'h', "NUM", CFG_POSITIVE, &cfg.host_gen, required_argument, hgen}, + {"controller-init", 'c', "", CFG_NONE, &cfg.ctrl_init, no_argument, cgen}, {NULL} }; @@ -277,7 +281,7 @@ static int get_telemetry_log(int argc, char **argv, struct command *cmd, struct hdr = malloc(4096); memset(hdr, 0, 4096); - err = nvme_get_telemetry_log(fd, hdr, cfg.host_gen, 4096, 0); + err = nvme_get_telemetry_log(fd, hdr, cfg.host_gen, cfg.ctrl_init, 4096, 0); if (err) { fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(err), err); @@ -310,7 +314,7 @@ static int get_telemetry_log(int argc, char **argv, struct command *cmd, struct } while (full_size) { - err = nvme_get_telemetry_log(fd, page_log, 0, 4096, offset); + err = nvme_get_telemetry_log(fd, page_log, 0, cfg.ctrl_init, 4096, offset); if (err) { fprintf(stderr, "Failed to aquire full telemetry log!\n"); fprintf(stderr, "NVMe Status:%s(%x)\n", -- 2.11.0