147 lines
5.4 KiB
Diff
147 lines
5.4 KiB
Diff
From a0db61992c14b34fcf6787b957d5d5d0e77c6f33 Mon Sep 17 00:00:00 2001
|
|
From: Maurizio Lombardi <mlombard@redhat.com>
|
|
Date: Wed, 29 Jun 2022 18:00:44 +0200
|
|
Subject: [PATCH 3/7] nvme-cli: Decode "Supported Events Bitmap" in PEL header
|
|
|
|
"Supported Events Bitmap" in PEL header shows what events
|
|
are supported in current nvme devices.
|
|
|
|
Persistent Event Log for device: nvme0n1
|
|
Action for Persistent Event Log: 0
|
|
..
|
|
..
|
|
..
|
|
Supported Events Bitmap:
|
|
Support SMART/Health Log Snapshot Event(0x1)
|
|
Support Firmware Commit Event(0x2)
|
|
Support Timestamp Change Event(0x3)
|
|
Support Power-on or Reset Event(0x4)
|
|
Support NVM Subsystem Hardware Error Event(0x5)
|
|
Support Change Namespace Event(0x6)
|
|
Support Format NVM Start Event(0x7)
|
|
Support Format NVM Completion Event(0x8)
|
|
Support Sanitize Start Event(0x9)
|
|
Support Sanitize Completion Event(0xa)
|
|
Support Set Feature Event(0xb)
|
|
Support Set Telemetry CRT Event(0xc)
|
|
Support Thermal Excursion Event(0xd)
|
|
|
|
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
|
|
---
|
|
nvme-print.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++------
|
|
nvme.c | 4 ++--
|
|
2 files changed, 48 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/nvme-print.c b/nvme-print.c
|
|
index f631b347..21524a50 100755
|
|
--- a/nvme-print.c
|
|
+++ b/nvme-print.c
|
|
@@ -1015,6 +1015,26 @@ void nvme_show_predictable_latency_event_agg_log(
|
|
}
|
|
}
|
|
|
|
+const char *nvme_pel_event_to_string(int type)
|
|
+{
|
|
+ switch (type) {
|
|
+ case NVME_SMART_HEALTH_EVENT: return "SMART/Health Log Snapshot Event(0x1)";
|
|
+ case NVME_FW_COMMIT_EVENT: return "Firmware Commit Event(0x2)";
|
|
+ case NVME_TIMESTAMP_EVENT: return "Timestamp Change Event(0x3)";
|
|
+ case NVME_POWER_ON_RESET_EVENT: return "Power-on or Reset Event(0x4)";
|
|
+ case NVME_NSS_HW_ERROR_EVENT: return "NVM Subsystem Hardware Error Event(0x5)";
|
|
+ case NVME_CHANGE_NS_EVENT: return "Change Namespace Event(0x6)";
|
|
+ case NVME_FORMAT_START_EVENT: return "Format NVM Start Event(0x7)";
|
|
+ case NVME_FORMAT_COMPLETION_EVENT: return "Format NVM Completion Event(0x8)";
|
|
+ case NVME_SANITIZE_START_EVENT: return "Sanitize Start Event(0x9)";
|
|
+ case NVME_SANITIZE_COMPLETION_EVENT: return "Sanitize Completion Event(0xa)";
|
|
+ case NVME_SET_FEATURE_EVENT: return "Set Feature Event(0xb)";
|
|
+ case NVME_TELEMETRY_CRT: return "Set Telemetry CRT Event(0xc)";
|
|
+ case NVME_THERMAL_EXCURSION_EVENT: return "Thermal Excursion Event(0xd)";
|
|
+ default: return NULL;
|
|
+ }
|
|
+}
|
|
+
|
|
static const char *nvme_show_nss_hw_error(__u16 error_code)
|
|
{
|
|
switch (error_code) {
|
|
@@ -1043,6 +1063,29 @@ static const char *nvme_show_nss_hw_error(__u16 error_code)
|
|
}
|
|
}
|
|
|
|
+static void add_bitmap(int i, __u8 seb, struct json_object *root, int json_flag)
|
|
+{
|
|
+ char evt_str[50];
|
|
+ char key[128];
|
|
+
|
|
+ for (int bit = 0; bit < 8; bit++) {
|
|
+ if (nvme_pel_event_to_string(bit + i * 8)) {
|
|
+ if (json_flag == 1) {
|
|
+ sprintf(key, "bitmap_%x", (bit + i * 8));
|
|
+ if ((seb >> bit) & 0x1)
|
|
+ snprintf(evt_str, sizeof(evt_str), "Support %s",
|
|
+ nvme_pel_event_to_string(bit + i * 8));
|
|
+ json_object_add_value_string(root, key, evt_str);
|
|
+ } else {
|
|
+ if (nvme_pel_event_to_string(bit + i * 8))
|
|
+ if ((seb >> bit) & 0x1)
|
|
+ printf(" Support %s\n",
|
|
+ nvme_pel_event_to_string(bit + i * 8));
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+}
|
|
+
|
|
void json_persistent_event_log(void *pevent_log_info, __u32 size)
|
|
{
|
|
struct json_object *root;
|
|
@@ -1112,9 +1155,7 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size)
|
|
for (int i = 0; i < 32; i++) {
|
|
if (pevent_log_head->supp_event_bm[i] == 0)
|
|
continue;
|
|
- sprintf(key, "bitmap_%d", i);
|
|
- json_object_add_value_uint(root, key,
|
|
- pevent_log_head->supp_event_bm[i]);
|
|
+ add_bitmap(i, pevent_log_head->supp_event_bm[i], root, 1);
|
|
}
|
|
} else {
|
|
printf("No log data can be shown with this log len at least " \
|
|
@@ -1440,12 +1481,11 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
|
|
le32_to_cpu(pevent_log_head->rci));
|
|
if(human)
|
|
nvme_show_persistent_event_log_rci(pevent_log_head->rci);
|
|
- printf("Supported Events Bitmap: ");
|
|
+ printf("Supported Events Bitmap: \n");
|
|
for (int i = 0; i < 32; i++) {
|
|
if (pevent_log_head->supp_event_bm[i] == 0)
|
|
continue;
|
|
- printf("BitMap[%d] is 0x%x\n", i,
|
|
- pevent_log_head->supp_event_bm[i]);
|
|
+ add_bitmap(i, pevent_log_head->supp_event_bm[i], NULL, 0);
|
|
}
|
|
} else {
|
|
printf("No log data can be shown with this log len at least " \
|
|
diff --git a/nvme.c b/nvme.c
|
|
index 0535ed2b..44c53e6b 100644
|
|
--- a/nvme.c
|
|
+++ b/nvme.c
|
|
@@ -4808,7 +4808,7 @@ static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin
|
|
|
|
nc = argconfig_parse_comma_sep_array(cfg.ctx_attrs, ctx_attrs, ARRAY_SIZE(ctx_attrs));
|
|
nb = argconfig_parse_comma_sep_array(cfg.blocks, nlbs, ARRAY_SIZE(nlbs));
|
|
- ns = argconfig_parse_comma_sep_array_long(cfg.slbas, slbas, ARRAY_SIZE(slbas));
|
|
+ ns = argconfig_parse_comma_sep_array_long(cfg.slbas, (long long unsigned int *)slbas, ARRAY_SIZE(slbas));
|
|
nr = max(nc, max(nb, ns));
|
|
if (!nr || nr > 256) {
|
|
fprintf(stderr, "No range definition provided\n");
|
|
@@ -4963,7 +4963,7 @@ static int copy(int argc, char **argv, struct command *cmd, struct plugin *plugi
|
|
}
|
|
}
|
|
|
|
- copy = nvme_setup_copy_range(nlbs, slbas, eilbrts, elbatms, elbats, nr);
|
|
+ copy = nvme_setup_copy_range(nlbs, (__u64 *)slbas, eilbrts, elbatms, elbats, nr);
|
|
if (!copy) {
|
|
fprintf(stderr, "failed to allocate payload\n");
|
|
errno = ENOMEM;
|
|
--
|
|
2.31.1
|
|
|