Skip to content

Commit

Permalink
plugins/solidigm: internal-logs Telemetry auto detect last data area.
Browse files Browse the repository at this point in the history
Faster telemetry retrieval using large buffers.

Signed-off-by: leonardo.da.cunha <[email protected]>
  • Loading branch information
lgdacunh authored and igaw committed Oct 13, 2023
1 parent 9fee876 commit a00a035
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 27 deletions.
34 changes: 21 additions & 13 deletions plugins/solidigm/solidigm-internal-logs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "libnvme.h"
#include "plugin.h"
#include "nvme-print.h"
#include "solidigm-util.h"

#define DWORD_SIZE 4

Expand Down Expand Up @@ -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;

Expand All @@ -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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/solidigm/solidigm-nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
35 changes: 22 additions & 13 deletions plugins/solidigm/solidigm-telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
};
Expand All @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 2 additions & 0 deletions plugins/solidigm/solidigm-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@

#include "nvme.h"

#define DRIVER_MAX_TX_256K (256 * 1024)

__u8 solidigm_get_vu_uuid_index(struct nvme_dev *dev);

0 comments on commit a00a035

Please sign in to comment.