summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/intel/intel-nvme.c6
-rw-r--r--plugins/micron/micron-nvme.c4
-rw-r--r--plugins/ocp/ocp-nvme.c97
-rw-r--r--plugins/ocp/ocp-nvme.h3
-rw-r--r--plugins/scaleflux/sfx-nvme.c8
-rw-r--r--plugins/solidigm/solidigm-telemetry/nlog.c5
-rw-r--r--plugins/wdc/wdc-nvme.c34
-rw-r--r--plugins/zns/zns.c24
8 files changed, 147 insertions, 34 deletions
diff --git a/plugins/intel/intel-nvme.c b/plugins/intel/intel-nvme.c
index e62c85d..3b2f973 100644
--- a/plugins/intel/intel-nvme.c
+++ b/plugins/intel/intel-nvme.c
@@ -1065,7 +1065,7 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct
media_version[1] = (data[3] << 8) | data[2];
if (err)
- goto close_fd;
+ goto close_dev;
if (media_version[0] == 1000) {
__u32 thresholds[OPTANE_V1000_BUCKET_LEN] = {0};
@@ -1088,7 +1088,7 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct
if (err) {
fprintf(stderr, "Quering thresholds failed. ");
nvme_show_status(err);
- goto close_fd;
+ goto close_dev;
}
/* Update bucket thresholds to be printed */
@@ -1124,7 +1124,7 @@ static int get_lat_stats_log(int argc, char **argv, struct command *cmd, struct
sizeof(stats));
}
-close_fd:
+close_dev:
dev_close(dev);
return err;
}
diff --git a/plugins/micron/micron-nvme.c b/plugins/micron/micron-nvme.c
index d6fb601..195c971 100644
--- a/plugins/micron/micron-nvme.c
+++ b/plugins/micron/micron-nvme.c
@@ -1799,7 +1799,7 @@ static void GetGenericLogs(int fd, const char *dir)
}
log_len = le64_to_cpu(pevent_log.tll);
- pevent_log_info = nvme_alloc(log_len, &huge);
+ pevent_log_info = nvme_alloc_huge(log_len, &huge);
if (!pevent_log_info) {
perror("could not alloc buffer for persistent event log page (ignored)!\n");
return;
@@ -1809,7 +1809,7 @@ static void GetGenericLogs(int fd, const char *dir)
if (!err)
WriteData((__u8 *)pevent_log_info, log_len, dir,
"persistent_event_log.bin", "persistent event log");
- nvme_free(pevent_log_info, huge);
+ nvme_free_huge(pevent_log_info, huge);
}
static void GetNSIDDInfo(int fd, const char *dir, int nsid)
diff --git a/plugins/ocp/ocp-nvme.c b/plugins/ocp/ocp-nvme.c
index edf75fc..fdb6b50 100644
--- a/plugins/ocp/ocp-nvme.c
+++ b/plugins/ocp/ocp-nvme.c
@@ -1867,6 +1867,103 @@ static int ocp_device_capabilities_log(int argc, char **argv, struct command *cm
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
+/// DSSD Power State (Feature Identifier C7h) Set Feature
+
+static int set_dssd_power_state(struct nvme_dev *dev, const __u32 nsid,
+ const __u8 fid, __u8 power_state, bool save,
+ bool uuid)
+{
+ __u32 result;
+ int err;
+ int uuid_index = 0;
+
+ if (uuid) {
+ /* OCP 2.0 requires UUID index support */
+ err = ocp_get_uuid_index(dev, &uuid_index);
+ if (err || !uuid_index) {
+ nvme_show_error("ERROR: No OCP UUID index found");
+ return err;
+ }
+ }
+
+ struct nvme_set_features_args args = {
+ .args_size = sizeof(args),
+ .fd = dev_fd(dev),
+ .fid = fid,
+ .nsid = nsid,
+ .cdw11 = power_state,
+ .cdw12 = 0,
+ .save = save,
+ .uuidx = uuid_index,
+ .cdw15 = 0,
+ .data_len = 0,
+ .data = NULL,
+ .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
+ .result = &result,
+ };
+
+ err = nvme_set_features(&args);
+ if (err > 0) {
+ nvme_show_status(err);
+ } else if (err < 0) {
+ nvme_show_perror("Define DSSD Power State");
+ fprintf(stderr, "Command failed while parsing.\n");
+ } else {
+ printf("Successfully set DSSD Power State (feature: 0xC7) to below values\n");
+ printf("DSSD Power State: 0x%x\n", power_state);
+ printf("Save bit Value: 0x%x\n", save);
+ }
+
+ return err;
+}
+
+static int set_dssd_power_state_feature(int argc, char **argv, struct command *cmd,
+ struct plugin *plugin)
+{
+ const char *desc = "Define DSSD Power State (Feature Identifier C7h) Set Feature.";
+ const char *power_state = "DSSD Power State to set in watts";
+ const char *save = "Specifies that the controller shall save the attribute";
+ const __u32 nsid = 0;
+ const __u8 fid = 0xC7;
+ struct nvme_dev *dev;
+ int err;
+
+ struct config {
+ __u8 power_state;
+ bool save;
+ };
+
+ struct config cfg = {
+ .power_state = 0,
+ .save = false,
+ };
+
+ OPT_ARGS(opts) = {
+ OPT_BYTE("power-state", 'p', &cfg.power_state, power_state),
+ OPT_FLAG("save", 's', &cfg.save, save),
+ OPT_FLAG("no-uuid", 'n', NULL,
+ "Skip UUID index search (UUID index not required for OCP 1.0)"),
+ OPT_END()
+ };
+
+ err = parse_and_open(&dev, argc, argv, desc, opts);
+ if (err)
+ return err;
+
+ if (argconfig_parse_seen(opts, "power state"))
+ err = set_dssd_power_state(dev, nsid, fid, cfg.power_state,
+ cfg.save,
+ !argconfig_parse_seen(opts, "no-uuid"));
+
+ dev_close(dev);
+
+ return err;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
/// Misc
static const __u8 OCP_FID_CLEAR_PCIE_CORRECTABLE_ERROR_COUNTERS = 0xC3;
diff --git a/plugins/ocp/ocp-nvme.h b/plugins/ocp/ocp-nvme.h
index 74dd0ef..dda4ffe 100644
--- a/plugins/ocp/ocp-nvme.h
+++ b/plugins/ocp/ocp-nvme.h
@@ -22,10 +22,11 @@ PLUGIN(NAME("ocp", "OCP cloud SSD extensions", NVME_VERSION),
ENTRY("clear-fw-activate-history", "Clear firmware update history log", clear_fw_update_history)
ENTRY("eol-plp-failure-mode", "Define EOL or PLP circuitry failure mode.", eol_plp_failure_mode)
ENTRY("clear-pcie-correctable-error-counters", "Clear PCIe correctable error counters", clear_pcie_corectable_error_counters)
- ENTRY("vs-fw-activate-history", "Get firmware activation history log", fw_activation_history_log)
+ ENTRY("fw-activate-history", "Get firmware activation history log", fw_activation_history_log)
ENTRY("unsupported-reqs-log", "Get Unsupported Requirements Log Page", ocp_unsupported_requirements_log)
ENTRY("error-recovery-log", "Retrieve Error Recovery Log Page", ocp_error_recovery_log)
ENTRY("device-capability-log", "Get Device capabilities Requirements Log Page", ocp_device_capabilities_log)
+ ENTRY("set-dssd-power-state-feature", "Get Device capabilities Requirements Log Page", set_dssd_power_state_feature)
)
);
diff --git a/plugins/scaleflux/sfx-nvme.c b/plugins/scaleflux/sfx-nvme.c
index 01867c7..e7f3b99 100644
--- a/plugins/scaleflux/sfx-nvme.c
+++ b/plugins/scaleflux/sfx-nvme.c
@@ -1410,7 +1410,7 @@ static int nvme_dump_evtlog(struct nvme_dev *dev, __u32 namespace_id, __u32 stor
if (log_len % 4)
log_len = (log_len / 4 + 1) * 4;
- pevent_log_info = nvme_alloc(single_len, &huge);
+ pevent_log_info = nvme_alloc_huge(single_len, &huge);
if (!pevent_log_info) {
err = -ENOMEM;
goto free_pevent;
@@ -1453,8 +1453,8 @@ static int nvme_dump_evtlog(struct nvme_dev *dev, __u32 namespace_id, __u32 stor
printf("\nDump-evtlog: Success\n");
if (parse) {
- nvme_free(pevent_log_info, huge);
- pevent_log_info = nvme_alloc(log_len, &huge);
+ nvme_free_huge(pevent_log_info, huge);
+ pevent_log_info = nvme_alloc_huge(log_len, &huge);
if (!pevent_log_info) {
fprintf(stderr, "Failed to alloc enough memory 0x%x to parse evtlog\n", log_len);
err = -ENOMEM;
@@ -1479,7 +1479,7 @@ static int nvme_dump_evtlog(struct nvme_dev *dev, __u32 namespace_id, __u32 stor
close_fd:
fclose(fd);
free:
- nvme_free(pevent_log_info, huge);
+ nvme_free_huge(pevent_log_info, huge);
free_pevent:
free(pevent);
ret:
diff --git a/plugins/solidigm/solidigm-telemetry/nlog.c b/plugins/solidigm/solidigm-telemetry/nlog.c
index 43b8918..926772b 100644
--- a/plugins/solidigm/solidigm-telemetry/nlog.c
+++ b/plugins/solidigm/solidigm-telemetry/nlog.c
@@ -8,15 +8,16 @@
#include "nlog.h"
#include "config.h"
#include <string.h>
-#include <math.h>
#include <stdio.h>
+#include "ccan/ilog/ilog.h"
+
#define LOG_ENTRY_HEADER_SIZE 1
#define LOG_ENTRY_TIMESTAMP_SIZE 2
#define LOG_ENTRY_NUM_ARGS_MAX 8
#define LOG_ENTRY_MAX_SIZE (LOG_ENTRY_HEADER_SIZE + LOG_ENTRY_TIMESTAMP_SIZE + \
LOG_ENTRY_NUM_ARGS_MAX)
-#define NUM_ARGS_MASK ((1 << ((int)log2(LOG_ENTRY_NUM_ARGS_MAX)+1)) - 1)
+#define NUM_ARGS_MASK ((1 << ((int)STATIC_ILOG_32(LOG_ENTRY_NUM_ARGS_MAX))) - 1)
#define MAX_HEADER_MISMATCH_TRACK 10
static int formats_find(struct json_object *formats, uint32_t val, struct json_object **format)
diff --git a/plugins/wdc/wdc-nvme.c b/plugins/wdc/wdc-nvme.c
index ec3f2b0..ae57e85 100644
--- a/plugins/wdc/wdc-nvme.c
+++ b/plugins/wdc/wdc-nvme.c
@@ -80,12 +80,13 @@
#define WDC_NVME_SN655_DEV_ID 0x2722
#define WDC_NVME_SN860_DEV_ID 0x2730
#define WDC_NVME_SN660_DEV_ID 0x2704
-
-/* This id's are no longer supported, delete ?? */
-#define WDC_NVME_SN550_DEV_ID 0x2708
#define WDC_NVME_SN560_DEV_ID_1 0x2712
#define WDC_NVME_SN560_DEV_ID_2 0x2713
#define WDC_NVME_SN560_DEV_ID_3 0x2714
+#define WDC_NVME_SN861_DEV_ID 0x2750
+
+/* This id's are no longer supported, delete ?? */
+#define WDC_NVME_SN550_DEV_ID 0x2708
#define WDC_NVME_SXSLCL_DEV_ID 0x2001
#define WDC_NVME_SN520_DEV_ID 0x5003
@@ -1666,6 +1667,17 @@ static __u64 wdc_get_drive_capabilities(nvme_root_t r, struct nvme_dev *dev)
WDC_DRIVE_CAP_CLEAR_PCIE);
break;
+ case WDC_NVME_SN861_DEV_ID:
+ capabilities |= (WDC_DRIVE_CAP_C0_LOG_PAGE | WDC_DRIVE_CAP_OCP_C1_LOG_PAGE |
+ WDC_DRIVE_CAP_C3_LOG_PAGE | WDC_DRIVE_CAP_OCP_C4_LOG_PAGE |
+ WDC_DRIVE_CAP_OCP_C5_LOG_PAGE);
+
+ capabilities |= (WDC_DRIVE_CAP_CAP_DIAG | WDC_DRIVE_CAP_INTERNAL_LOG |
+ WDC_DRIVE_CAP_DRIVE_STATUS | WDC_DRIVE_CAP_CLEAR_ASSERT |
+ WDC_DRIVE_CAP_RESIZE | WDC_DRIVE_CAP_FW_ACTIVATE_HISTORY |
+ WDC_DRVIE_CAP_DISABLE_CTLR_TELE_LOG |
+ WDC_DRIVE_CAP_REASON_ID);
+
default:
capabilities = 0;
}
@@ -6514,6 +6526,8 @@ static int wdc_get_c0_log_page(nvme_root_t r, struct nvme_dev *dev, char *format
case WDC_NVME_SN560_DEV_ID_3:
fallthrough;
case WDC_NVME_SN550_DEV_ID:
+ fallthrough;
+ case WDC_NVME_SN861_DEV_ID:
ret = wdc_get_c0_log_page_sn(r, dev, uuid_index, format, namespace_id, fmt);
break;
case WDC_NVME_ZN350_DEV_ID:
@@ -9437,7 +9451,7 @@ static int wdc_reason_identifier(int argc, char **argv,
cfg.log_id != NVME_LOG_LID_TELEMETRY_CTRL) {
fprintf(stderr, "ERROR: WDC: Invalid Log ID. It must be 7 (Host) or 8 (Controller)\n");
ret = -1;
- goto close_fd;
+ goto close_dev;
}
if (cfg.file) {
@@ -9448,7 +9462,7 @@ static int wdc_reason_identifier(int argc, char **argv,
if (verify_file < 0) {
fprintf(stderr, "ERROR: WDC: open: %s\n", strerror(errno));
ret = -1;
- goto close_fd;
+ goto close_dev;
}
close(verify_file);
strncpy(f, cfg.file, PATH_MAX - 1);
@@ -9466,12 +9480,12 @@ static int wdc_reason_identifier(int argc, char **argv,
if (wdc_get_serial_name(dev, f, PATH_MAX, fileSuffix) == -1) {
fprintf(stderr, "ERROR: WDC: failed to generate file name\n");
ret = -1;
- goto close_fd;
+ goto close_dev;
}
if (strlen(f) > PATH_MAX - 5) {
fprintf(stderr, "ERROR: WDC: file name overflow\n");
ret = -1;
- goto close_fd;
+ goto close_dev;
}
strcat(f, ".bin");
}
@@ -9488,7 +9502,7 @@ static int wdc_reason_identifier(int argc, char **argv,
nvme_show_status(ret);
-close_fd:
+close_dev:
dev_close(dev);
nvme_free_tree(r);
return ret;
@@ -10372,7 +10386,7 @@ static int wdc_vs_pcie_stats(int argc, char **argv, struct command *command,
goto out;
}
- pcieStatsPtr = nvme_alloc(pcie_stats_size, &huge);
+ pcieStatsPtr = nvme_alloc_huge(pcie_stats_size, &huge);
if (!pcieStatsPtr) {
fprintf(stderr, "ERROR: WDC: PCIE Stats alloc: %s\n", strerror(errno));
ret = -1;
@@ -10403,7 +10417,7 @@ static int wdc_vs_pcie_stats(int argc, char **argv, struct command *command,
}
}
- nvme_free(pcieStatsPtr, huge);
+ nvme_free_huge(pcieStatsPtr, huge);
out:
nvme_free_tree(r);
diff --git a/plugins/zns/zns.c b/plugins/zns/zns.c
index 5b9d013..7b1b191 100644
--- a/plugins/zns/zns.c
+++ b/plugins/zns/zns.c
@@ -137,7 +137,7 @@ static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *pl
err = flags = validate_output_format(cfg.output_format);
if (flags < 0)
- goto close_fd;
+ goto close_dev;
err = nvme_zns_identify_ctrl(dev_fd(dev), &ctrl);
if (!err)
@@ -146,7 +146,7 @@ static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *pl
nvme_show_status(err);
else
perror("zns identify controller");
-close_fd:
+close_dev:
dev_close(dev);
return err;
}
@@ -190,7 +190,7 @@ static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plug
flags = validate_output_format(cfg.output_format);
if (flags < 0)
- goto close_fd;
+ goto close_dev;
if (cfg.vendor_specific)
flags |= VS;
if (cfg.human_readable)
@@ -200,14 +200,14 @@ static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plug
err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id);
if (err < 0) {
perror("get-namespace-id");
- goto close_fd;
+ goto close_dev;
}
}
err = nvme_identify_ns(dev_fd(dev), cfg.namespace_id, &id_ns);
if (err) {
nvme_show_status(err);
- goto close_fd;
+ goto close_dev;
}
err = nvme_zns_identify_ns(dev_fd(dev), cfg.namespace_id, &ns);
@@ -217,7 +217,7 @@ static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plug
nvme_show_status(err);
else
perror("zns identify namespace");
-close_fd:
+close_dev:
dev_close(dev);
return err;
}
@@ -839,8 +839,8 @@ static int report_zones(int argc, char **argv, struct command *cmd, struct plugi
unsigned int nr_zones_chunks = 1024, /* 1024 entries * 64 bytes per entry = 64k byte transfer */
nr_zones_retrieved = 0,
nr_zones,
- offset,
log_len;
+ __u64 offset;
int total_nr_zones = 0;
struct nvme_zns_id_ns id_zns;
struct nvme_id_ns id_ns;
@@ -949,7 +949,7 @@ static int report_zones(int argc, char **argv, struct command *cmd, struct plugi
log_len = sizeof(struct nvme_zone_report) + ((sizeof(struct nvme_zns_desc) * nr_zones_chunks) + (nr_zones_chunks * zdes));
report_size = log_len;
- report = nvme_alloc(report_size, &huge);
+ report = nvme_alloc_huge(report_size, &huge);
if (!report) {
perror("alloc");
err = -ENOMEM;
@@ -997,7 +997,7 @@ static int report_zones(int argc, char **argv, struct command *cmd, struct plugi
ops->zns_finish_zone_list(total_nr_zones, zone_list);
}
- nvme_free(report, huge);
+ nvme_free_huge(report, huge);
free_buff:
free(buff);
@@ -1258,13 +1258,13 @@ static int changed_zone_list(int argc, char **argv, struct command *cmd, struct
flags = validate_output_format(cfg.output_format);
if (flags < 0)
- goto close_fd;
+ goto close_dev;
if (!cfg.namespace_id) {
err = nvme_get_nsid(dev_fd(dev), &cfg.namespace_id);
if (err < 0) {
perror("get-namespace-id");
- goto close_fd;
+ goto close_dev;
}
}
@@ -1277,7 +1277,7 @@ static int changed_zone_list(int argc, char **argv, struct command *cmd, struct
else
perror("zns changed-zone-list");
-close_fd:
+close_dev:
dev_close(dev);
return err;
}