1
0
Fork 0

Merging upstream version 2.14.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-22 13:00:36 +02:00
parent 0d9181726f
commit f268303a51
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
572 changed files with 4636 additions and 1730 deletions

View file

@ -75,6 +75,81 @@ close_dev:
return err;
}
int get_ocp_error_counters(int argc, char **argv, struct command *cmd,
struct plugin *plugin)
{
const char *desc = "Define Issue Get Feature cmd (FID: 0xC3) Clear PCIe Corr Err Counters";
const char *sel = "[0-3]: current/default/saved/supported/";
const char *nsid = "Byte[04-07]: Namespace Identifier Valid/Invalid/Inactive";
const char *no_uuid = "Do not try to automatically detect UUID index";
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
__u32 result;
int err;
bool uuid;
__u8 uuid_index = 0;
struct config {
__u8 sel;
__u32 nsid;
};
struct config cfg = {
.sel = 0,
.nsid = 0,
};
OPT_ARGS(opts) = {
OPT_BYTE("sel", 's', &cfg.sel, sel),
OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid),
OPT_FLAG("no-uuid", 'u', NULL, no_uuid),
OPT_END()
};
err = parse_and_open(&dev, argc, argv, desc, opts);
if (err)
return err;
uuid = !argconfig_parse_seen(opts, "no-uuid");
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_get_features_args args = {
.args_size = sizeof(args),
.fd = dev_fd(dev),
.fid = OCP_FID_CPCIE,
.nsid = cfg.nsid,
.sel = cfg.sel,
.cdw11 = 0,
.uuidx = uuid_index,
.data_len = 0,
.data = NULL,
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
.result = &result,
};
err = nvme_get_features(&args);
if (!err) {
printf("get-feature:0xC3 %s value: %#08x\n",
nvme_select_to_string(cfg.sel), result);
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
nvme_show_select_result(0xC3, result);
} else {
nvme_show_error("Could not get feature: 0xC3");
}
return err;
}
int ocp_clear_fw_update_history(int argc, char **argv, struct command *cmd, struct plugin *plugin)
{
const char *desc = "OCP Clear Firmware Update History";

View file

@ -10,3 +10,6 @@ int ocp_clear_fw_update_history(int argc, char **argv, struct command *cmd, stru
int ocp_clear_pcie_correctable_errors(int argc, char **argv, struct command *cmd,
struct plugin *plugin);
int get_ocp_error_counters(int argc, char **argv, struct command *cmd,
struct plugin *plugin);

View file

@ -7,7 +7,7 @@
#include "common.h"
#include "util/types.h"
#include "util/logging.h"
#include "logging.h"
#include "nvme-print.h"
#include "ocp-hardware-component-log.h"
#include "ocp-print.h"

View file

@ -22,7 +22,7 @@
#include "plugin.h"
#include "linux/types.h"
#include "util/types.h"
#include "util/logging.h"
#include "logging.h"
#include "nvme-print.h"
#include "nvme-wrap.h"
@ -423,6 +423,80 @@ int ocp_set_latency_monitor_feature(int argc, char **argv, struct command *cmd,
return err;
}
static int ocp_get_latency_monitor_feature(int argc, char **argv, struct command *cmd,
struct plugin *plugin)
{
const char *desc = "Define Issue Get Feature command (FID: 0xC5) Latency Monitor";
const char *sel = "[0-3]: current/default/saved/supported/";
const char *nsid = "Byte[04-07]: Namespace Identifier Valid/Invalid/Inactive";
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
__u32 result;
int err;
bool uuid;
__u8 uuid_index = 0;
struct config {
__u8 sel;
__u32 nsid;
};
struct config cfg = {
.sel = 0,
.nsid = 0,
};
OPT_ARGS(opts) = {
OPT_BYTE("sel", 's', &cfg.sel, sel),
OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid),
OPT_FLAG("no-uuid", 'u', NULL, no_uuid),
OPT_END()
};
err = parse_and_open(&dev, argc, argv, desc, opts);
if (err)
return err;
uuid = !argconfig_parse_seen(opts, "no-uuid");
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_get_features_args args = {
.args_size = sizeof(args),
.fd = dev_fd(dev),
.fid = OCP_FID_LM,
.nsid = cfg.nsid,
.sel = cfg.sel,
.cdw11 = 0,
.uuidx = uuid_index,
.data_len = 0,
.data = NULL,
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
.result = &result,
};
err = nvme_get_features(&args);
if (!err) {
printf("get-feature:0xC5 %s value: %#08x\n",
nvme_select_to_string(cfg.sel), result);
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
nvme_show_select_result(0xC5, result);
} else {
nvme_show_error("Could not get feature: 0xC5");
}
return err;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
@ -1948,6 +2022,85 @@ static int ocp_set_telemetry_profile_feature(int argc, char **argv, struct comma
return err;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// DSSD Power State (Feature Identifier C8h) Get Feature
static int ocp_get_telemetry_profile_feature(int argc, char **argv, struct command *cmd,
struct plugin *plugin)
{
const char *desc = "Define Issue Get Feature command (FID: 0xC8) Latency Monitor";
const char *sel = "[0-3]: current/default/saved/supported/";
const char *nsid = "Byte[04-07]: Namespace Identifier Valid/Invalid/Inactive";
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
__u32 result;
int err;
bool uuid;
__u8 uuid_index = 0;
struct config {
__u8 sel;
__u32 nsid;
};
struct config cfg = {
.sel = 0,
.nsid = 0,
};
OPT_ARGS(opts) = {
OPT_BYTE("sel", 's', &cfg.sel, sel),
OPT_UINT("namespace-id", 'n', &cfg.nsid, nsid),
OPT_FLAG("no-uuid", 'u', NULL, no_uuid),
OPT_END()
};
err = parse_and_open(&dev, argc, argv, desc, opts);
if (err)
return err;
uuid = !argconfig_parse_seen(opts, "no-uuid");
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_get_features_args args = {
.args_size = sizeof(args),
.fd = dev_fd(dev),
.fid = OCP_FID_TEL_CFG,
.nsid = cfg.nsid,
.sel = cfg.sel,
.cdw11 = 0,
.uuidx = uuid_index,
.data_len = 0,
.data = NULL,
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
.result = &result,
};
err = nvme_get_features(&args);
if (!err) {
printf("get-feature:0xC8 %s value: %#08x\n",
nvme_select_to_string(cfg.sel), result);
if (cfg.sel == NVME_GET_FEATURES_SEL_SUPPORTED)
nvme_show_select_result(0xC8, result);
} else {
nvme_show_error("Could not get feature: 0xC8");
}
return err;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
@ -2612,6 +2765,12 @@ static int clear_pcie_correctable_error_counters(int argc, char **argv, struct c
return ocp_clear_pcie_correctable_errors(argc, argv, cmd, plugin);
}
static int get_clear_pcie_correctable_error_counters(int argc, char **argv, struct command *cmd,
struct plugin *plugin)
{
return get_ocp_error_counters(argc, argv, cmd, plugin);
}
static int fw_activation_history_log(int argc, char **argv, struct command *cmd,
struct plugin *plugin)
{

View file

@ -42,6 +42,12 @@ PLUGIN(NAME("ocp", "OCP cloud SSD extensions", OCP_PLUGIN_VERSION),
get_enable_ieee1667_silo)
ENTRY("set-enable-ieee1667-silo", "enable IEEE1667 silo", set_enable_ieee1667_silo)
ENTRY("hardware-component-log", "retrieve hardware component log", hwcomp_log)
ENTRY("get-latency-monitor", "Get Latency Monitor Feature",
ocp_get_latency_monitor_feature)
ENTRY("get-clear-pcie-correctable-errors", "Clear PCIe correctable error counters",
get_clear_pcie_correctable_error_counters)
ENTRY("get-telemetry-profile", "Get Telemetry Profile Feature",
ocp_get_telemetry_profile_feature)
)
);

View file

@ -321,7 +321,7 @@ static void stdout_c3_log(struct nvme_dev *dev, struct ssd_latency_monitor_log *
printf(" Log Page GUID %s\n", guid);
printf("\n");
printf("%64s%92s%119s\n", "Read", "Write", "Deallocate/Trim");
printf("%64s %27s %27s\n", "Read", "Write", "Deallocate/Trim");
for (i = 0; i < C3_BUCKET_NUM; i++) {
printf(" Active Bucket Counter: Bucket %d %27d %27d %27d\n",
i,

View file

@ -1027,17 +1027,22 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start,
if (pevent_descriptor->debug_event_class_type == RESERVED_CLASS_TYPE)
break;
if (pevent_descriptor != NULL && pevent_descriptor->event_data_size >= 0) {
__u8 *pevent_specific_data = NULL;
__u16 event_id = 0;
char description_str[256] = "";
unsigned int data_size = 0;
if (pevent_descriptor != NULL &&
pevent_descriptor->event_data_size >= 0 &&
pevent_descriptor->debug_event_class_type !=
STATISTIC_SNAPSHOT_CLASS_TYPE) {
event_des_size = sizeof(struct nvme_ocp_telemetry_event_descriptor);
/* Data is present in the form of DWORDS,
* So multiplying with sizeof(DWORD)
*/
unsigned int data_size = pevent_descriptor->event_data_size *
data_size = pevent_descriptor->event_data_size *
SIZE_OF_DWORD;
__u8 *pevent_specific_data = NULL;
__u16 event_id = 0;
char description_str[256] = "";
if (pevent_descriptor != NULL && pevent_descriptor->event_data_size > 0)
pevent_specific_data = (__u8 *)pevent_descriptor + event_des_size;
@ -1128,18 +1133,6 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start,
pevent_fifos_object,
fp);
break;
case STATISTIC_SNAPSHOT_CLASS_TYPE: {
struct nvme_ocp_statistic_snapshot_evt_class_format
*pStaticSnapshotEvent =
(struct nvme_ocp_statistic_snapshot_evt_class_format *)
pevent_specific_data;
struct nvme_ocp_telemetry_statistic_descriptor *pstatistic_entry =
(struct nvme_ocp_telemetry_statistic_descriptor *)
(&pStaticSnapshotEvent->statisticDescriptorData);
parse_statistic(pstatistic_entry, pevent_descriptor_obj, fp);
break;
}
case RESERVED_CLASS_TYPE:
default:
break;
@ -1154,11 +1147,67 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start,
else
printf(STR_LINE2);
}
} else
break;
} else if ((pevent_descriptor != NULL) &&
(pevent_descriptor->debug_event_class_type ==
STATISTIC_SNAPSHOT_CLASS_TYPE)) {
parse_ocp_telemetry_string_log(0, event_id,
pevent_descriptor->debug_event_class_type, EVENT_STRING,
description_str);
offset_to_move += (pevent_descriptor->event_data_size * SIZE_OF_DWORD +
event_des_size);
struct json_object *pevent_descriptor_obj =
((pevent_fifos_object != NULL) ? json_create_object() : NULL);
if (pevent_descriptor_obj != NULL) {
json_add_formatted_u32_str(pevent_descriptor_obj,
STR_DBG_EVENT_CLASS_TYPE,
pevent_descriptor->debug_event_class_type);
json_object_add_value_string(pevent_descriptor_obj,
STR_EVENT_STRING, description_str);
} else {
if (fp) {
fprintf(fp, "%s: 0x%x\n", STR_DBG_EVENT_CLASS_TYPE,
pevent_descriptor->debug_event_class_type);
fprintf(fp, "%s: %s\n", STR_EVENT_STRING, description_str);
} else {
printf("%s: 0x%x\n", STR_DBG_EVENT_CLASS_TYPE,
pevent_descriptor->debug_event_class_type);
printf("%s: %s\n", STR_EVENT_STRING, description_str);
}
}
struct nvme_ocp_statistic_snapshot_evt_class_format
*pStaticSnapshotEvent =
(struct nvme_ocp_statistic_snapshot_evt_class_format *)
pevent_descriptor;
event_des_size =
sizeof(struct nvme_ocp_statistic_snapshot_evt_class_format);
data_size =
(le16_to_cpu((unsigned int)pStaticSnapshotEvent->stat_data_size) *
SIZE_OF_DWORD);
if (pStaticSnapshotEvent != NULL &&
pStaticSnapshotEvent->stat_data_size > 0) {
__u8 *pstatistic_entry =
(__u8 *)pStaticSnapshotEvent +
sizeof(struct nvme_ocp_telemetry_event_descriptor);
parse_statistic(
(struct nvme_ocp_telemetry_statistic_descriptor *)
pstatistic_entry,
pevent_descriptor_obj,
fp);
}
} else {
if (fp)
fprintf(fp, "Unknown or null event class %p\n", pevent_descriptor);
else
printf("Unknown or null event class %p\n", pevent_descriptor);
break;
}
offset_to_move += (data_size + event_des_size);
}
if (pevent_fifos_object != NULL && pevent_fifo_array != NULL)
@ -1243,11 +1292,10 @@ int parse_statistic(struct nvme_ocp_telemetry_statistic_descriptor *pstatistic_e
return -1;
}
if (pstatistic_entry->statistic_id == STATISTICS_RESERVED_ID)
if (le16_to_cpu(pstatistic_entry->statistic_id) == STATISTICS_RESERVED_ID)
/* End of statistics entries, return -1 to stop processing the buffer */
return -1;
unsigned int data_size = pstatistic_entry->statistic_data_size * SIZE_OF_DWORD;
__u8 *pdata = (__u8 *)pstatistic_entry +
sizeof(struct nvme_ocp_telemetry_statistic_descriptor);

View file

@ -1102,7 +1102,13 @@ struct __packed nvme_ocp_common_dbg_evt_class_vu_data
struct __packed nvme_ocp_statistic_snapshot_evt_class_format
{
struct nvme_ocp_telemetry_statistic_descriptor statisticDescriptorData; // Bytes 11:10
__u8 debug_event_class_type; // Byte 0
__u8 reserved1[3]; // Bytes 3:1
__le16 stat_id; // Bytes 5:4
__u8 stat_info; // Byte 6
__u8 namespace_info; // Byte 7
__le16 stat_data_size; // Bytes 9:8
__le16 nsid; // Bytes 11:10
};
struct __packed nvme_ocp_statistics_identifier_string_table