diff --git a/plugins/solidigm/solidigm-internal-logs.c b/plugins/solidigm/solidigm-internal-logs.c index 47304438c6..236652a784 100644 --- a/plugins/solidigm/solidigm-internal-logs.c +++ b/plugins/solidigm/solidigm-internal-logs.c @@ -19,6 +19,7 @@ #include "libnvme.h" #include "plugin.h" #include "nvme-print.h" +#include "solidigm-util.h" #define DWORD_SIZE 4 @@ -427,7 +428,8 @@ static int dump_telemetry(struct nvme_dev *dev, struct config cfg, enum telemetr int err = 0, output; __u8 *buffer = NULL; size_t bytes_remaining = 0; - int data_area = NVME_TELEMETRY_DA_3; + enum nvme_telemetry_da da; + size_t max_data_tx; char file_path[PATH_MAX]; char *log_name; @@ -444,6 +446,12 @@ static int dump_telemetry(struct nvme_dev *dev, struct config cfg, enum telemetr default: return -EINVAL; } + err = nvme_get_telemetry_max(dev_fd(dev), &da, &max_data_tx); + if (err) + return err; + + if (max_data_tx > DRIVER_MAX_TX_256K) + max_data_tx = DRIVER_MAX_TX_256K; sprintf(file_path, "%s_%s.bin", cfg.file_prefix, log_name); output = open(file_path, O_WRONLY | O_CREAT | O_TRUNC, 0644); @@ -452,16 +460,16 @@ static int dump_telemetry(struct nvme_dev *dev, struct config cfg, enum telemetr switch (ttype) { case HOSTGENNEW: - err = nvme_get_new_host_telemetry(dev_fd(dev), &log, - data_area, &log_size); + err = nvme_get_telemetry_log(dev_fd(dev), true, false, false, max_data_tx, da, + &log, &log_size); break; case HOSTGENOLD: - err = nvme_get_host_telemetry(dev_fd(dev), &log, - data_area, &log_size); + err = nvme_get_telemetry_log(dev_fd(dev), false, false, false, max_data_tx, da, + &log, &log_size); break; case CONTROLLER: - err = nvme_get_ctrl_telemetry(dev_fd(dev), true, &log, - data_area, &log_size); + err = nvme_get_telemetry_log(dev_fd(dev), false, true, true, max_data_tx, da, &log, + &log_size); break; } @@ -546,42 +554,42 @@ int solidigm_get_internal_log(int argc, char **argv, struct command *command, if (err == 0) log_count++; else if (err < 0) - perror("Assert log"); + perror("Error retrieving Assert log"); } if (all || !strcmp(cfg.type, "EVENT")) { err = dump_event_logs(dev, cfg); if (err == 0) log_count++; else if (err < 0) - perror("Eventt log"); + perror("Error retrieving Event log"); } if (all || !strcmp(cfg.type, "NLOG")) { err = dump_nlogs(dev, cfg, -1); if (err == 0) log_count++; else if (err < 0) - perror("Nlog"); + perror("Error retrieving Nlog"); } if (all || !strcmp(cfg.type, "CONTROLLERINITTELEMETRY")) { err = dump_telemetry(dev, cfg, CONTROLLER); if (err == 0) log_count++; else if (err < 0) - perror("Telemetry Controller Initated"); + perror("Error retrieving Telemetry Controller Initiated"); } if (all || !strcmp(cfg.type, "HOSTINITTELEMETRYNOGEN")) { err = dump_telemetry(dev, cfg, HOSTGENOLD); if (err == 0) log_count++; else if (err < 0) - perror("Previously existing Telemetry Host Initated"); + perror("Error retrieving previously existing Telemetry Host Initiated"); } if (all || !strcmp(cfg.type, "HOSTINITTELEMETRY")) { err = dump_telemetry(dev, cfg, HOSTGENNEW); if (err == 0) log_count++; else if (err < 0) - perror("Telemetry Host Initated"); + perror("Error retrieving Telemetry Host Initiated"); } if (log_count == 0) { diff --git a/plugins/solidigm/solidigm-nvme.h b/plugins/solidigm/solidigm-nvme.h index d6b0cbe4c6..bc4a20170e 100644 --- a/plugins/solidigm/solidigm-nvme.h +++ b/plugins/solidigm/solidigm-nvme.h @@ -13,7 +13,7 @@ #include "cmd.h" -#define SOLIDIGM_PLUGIN_VERSION "0.15" +#define SOLIDIGM_PLUGIN_VERSION "0.16" PLUGIN(NAME("solidigm", "Solidigm vendor specific extensions", SOLIDIGM_PLUGIN_VERSION), COMMAND_LIST( diff --git a/plugins/solidigm/solidigm-telemetry.c b/plugins/solidigm/solidigm-telemetry.c index 472284a1b4..2bebcccab9 100644 --- a/plugins/solidigm/solidigm-telemetry.c +++ b/plugins/solidigm/solidigm-telemetry.c @@ -22,6 +22,7 @@ #include "solidigm-telemetry/header.h" #include "solidigm-telemetry/config.h" #include "solidigm-telemetry/data-area.h" +#include "solidigm-util.h" static int read_file2buffer(char *file_name, char **buffer, size_t *length) { @@ -71,7 +72,7 @@ int solidigm_get_telemetry_log(int argc, char **argv, struct command *cmd, struc struct config cfg = { .host_gen = 1, .ctrl_init = false, - .data_area = 3, + .data_area = -1, .cfg_file = NULL, .is_input_file = false, }; @@ -90,6 +91,10 @@ int solidigm_get_telemetry_log(int argc, char **argv, struct command *cmd, struc if (err) goto ret; + /* When not selected on the command line, get minimum data area required */ + if (cfg.data_area == -1) + cfg.data_area = cfg.cfg_file ? 3 : 1; + if (cfg.is_input_file) { if (optind >= argc) { err = errno = EINVAL; @@ -138,19 +143,23 @@ int solidigm_get_telemetry_log(int argc, char **argv, struct command *cmd, struc } if (!cfg.is_input_file) { - if (cfg.ctrl_init) - err = nvme_get_ctrl_telemetry(dev_fd(dev), true, - &tl.log, cfg.data_area, - &tl.log_size); - else if (cfg.host_gen) - err = nvme_get_new_host_telemetry(dev_fd(dev), &tl.log, - cfg.data_area, - &tl.log_size); - else - err = nvme_get_host_telemetry(dev_fd(dev), &tl.log, - cfg.data_area, - &tl.log_size); + size_t max_data_tx; + + err = nvme_get_telemetry_max(dev_fd(dev), NULL, &max_data_tx); + if (err < 0) { + SOLIDIGM_LOG_WARNING("identify_ctrl: %s", + nvme_strerror(errno)); + goto close_fd; + } else if (err > 0) { + nvme_show_status(err); + SOLIDIGM_LOG_WARNING("Failed to acquire identify ctrl %d!", err); + goto close_fd; + } + if (max_data_tx > DRIVER_MAX_TX_256K) + max_data_tx = DRIVER_MAX_TX_256K; + err = nvme_get_telemetry_log(dev_fd(dev), cfg.host_gen, cfg.ctrl_init, true, + max_data_tx, cfg.data_area, &tl.log, &tl.log_size); if (err < 0) { SOLIDIGM_LOG_WARNING("get-telemetry-log: %s", nvme_strerror(errno)); diff --git a/plugins/solidigm/solidigm-util.h b/plugins/solidigm/solidigm-util.h index 3a18501f31..fa5032fe20 100644 --- a/plugins/solidigm/solidigm-util.h +++ b/plugins/solidigm/solidigm-util.h @@ -7,4 +7,6 @@ #include "nvme.h" +#define DRIVER_MAX_TX_256K (256 * 1024) + __u8 solidigm_get_vu_uuid_index(struct nvme_dev *dev);