nvme-cli: telemetry-log add controller initiated log gathering
PATCH 1/1 nvme-cli: telemetry-log add controller initiated log gathering
If the controller has a controller initiated log (0x8) available, we can now retrieve it.
Signed-off-by Scott Bauer <scott.bauer at intel.com>
--- linux/nvme.h | 1 + nvme-ioctl.c | 6 +++++- nvme-ioctl.h | 2 +- nvme.c | 8 ++++++-- 4 files changed, 13 insertions(+), 4 deletions(-)
linux/nvme.h +1 -0
@@ -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,
nvme-ioctl.c +5 -1
@@ -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,
nvme-ioctl.h +1 -1
@@ -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);
nvme.c +6 -2
@@ -233,6 +233,7 @@ static int get_telemetry_log(int argc, char **argv, struct command *cmd, structconst 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, structstruct 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",
Signature · 1 line
2.11.0
Keith Busch
AppliedPATCH 1/1 nvme-cli: telemetry-log add controller initiated log gathering
Applied, thanks!