Blob Blame History Raw
From 6c916ee527e14bf4c4640ffeef8efdd891ba9ef4 Mon Sep 17 00:00:00 2001
From: Maurizio Lombardi <mlombard@redhat.com>
Date: Thu, 30 Jun 2022 16:17:44 +0200
Subject: [PATCH 4/7] nvme-cli: Adds event number in persistent event entries

Persistent Event Entries:
Event Number: 0
Event Type: SMART/Health Log Snapshot Event(0x1)
Event Type Revision: 1
Event Header Length: 21
Controller Identifier: 66
Event Timestamp: 44392

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
---
 nvme-print.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/nvme-print.c b/nvme-print.c
index 21524a50..3b82b174 100755
--- a/nvme-print.c
+++ b/nvme-print.c
@@ -1174,8 +1174,9 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size)
 			break;
 		valid_attrs = json_create_object();
 
-		json_object_add_value_uint(valid_attrs, "event_type",
-			pevent_entry_head->etype);
+		json_object_add_value_uint(valid_attrs, "event_number", i);
+		json_object_add_value_string(valid_attrs, "event_type",
+				nvme_pel_event_to_string(pevent_entry_head->etype));
 		json_object_add_value_uint(valid_attrs, "event_type_rev",
 			pevent_entry_head->etype_rev);
 		json_object_add_value_uint(valid_attrs, "event_header_len",
@@ -1505,7 +1506,8 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
 			le16_to_cpu(pevent_entry_head->el)) >= size)
 			break;
 
-		printf("Event Type: %u\n", pevent_entry_head->etype);
+		printf("Event Number: %u\n", i);
+		printf("Event Type: %s\n", nvme_pel_event_to_string(pevent_entry_head->etype));
 		printf("Event Type Revision: %u\n", pevent_entry_head->etype_rev);
 		printf("Event Header Length: %u\n", pevent_entry_head->ehl);
 		printf("Controller Identifier: %u\n",
@@ -1521,12 +1523,12 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
 		switch (pevent_entry_head->etype) {
 		case NVME_SMART_HEALTH_EVENT:
 			smart_event = pevent_log_info + offset;
-			printf("Smart Health Event: \n");
+			printf("Smart Health Event Entry: \n");
 			nvme_show_smart_log(smart_event, NVME_NSID_ALL, devname, flags);
 			break;
 		case NVME_FW_COMMIT_EVENT:
 			fw_commit_event = pevent_log_info + offset;
-			printf("FW Commit Event: \n");
+			printf("FW Commit Event Entry: \n");
 			printf("Old Firmware Revision: %"PRIu64"\n",
 				le64_to_cpu(fw_commit_event->old_fw_rev));
 			printf("New Firmware Revision: %"PRIu64"\n",
@@ -1543,7 +1545,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
 			break;
 		case NVME_TIMESTAMP_EVENT:
 			ts_change_event = pevent_log_info + offset;
-			printf("Time Stamp Change Event: \n");
+			printf("Time Stamp Change Event Entry: \n");
 			printf("Previous Timestamp: %"PRIu64"\n",
 				le64_to_cpu(ts_change_event->previous_timestamp));
 			printf("Milliseconds Since Reset: %"PRIu64"\n",
@@ -1555,7 +1557,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
 
 			por_info_list = por_info_len / sizeof(*por_event);
 
-			printf("Power On Reset Event: \n");
+			printf("Power On Reset Event Entry: \n");
 			fw_rev = pevent_log_info + offset;
 			printf("Firmware Revision: %"PRIu64"\n", le64_to_cpu(*fw_rev));
 			printf("Reset Information List: \n");
@@ -1578,13 +1580,13 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
 			break;
 		case NVME_NSS_HW_ERROR_EVENT:
 			nss_hw_err_event = pevent_log_info + offset;
-			printf("NVM Subsystem Hardware Error Event Code: %u, %s\n",
+			printf("NVM Subsystem Hardware Error Event Code Entry: %u, %s\n",
 				le16_to_cpu(nss_hw_err_event->nss_hw_err_event_code),
 				nvme_show_nss_hw_error(nss_hw_err_event->nss_hw_err_event_code));
 			break;
 		case NVME_CHANGE_NS_EVENT:
 			ns_event = pevent_log_info + offset;
-			printf("Change Namespace Event: \n");
+			printf("Change Namespace Event Entry: \n");
 			printf("Namespace Management CDW10: %u\n",
 				le32_to_cpu(ns_event->nsmgt_cdw10));
 			printf("Namespace Size: %"PRIu64"\n",
@@ -1603,7 +1605,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
 			break;
 		case NVME_FORMAT_START_EVENT:
 			format_start_event = pevent_log_info + offset;
-			printf("Format NVM Start Event: \n");
+			printf("Format NVM Start Event Entry: \n");
 			printf("Namespace Identifier: %u\n",
 				le32_to_cpu(format_start_event->nsid));
 			printf("Format NVM Attributes: %u\n",
@@ -1613,7 +1615,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
 			break;
 		case NVME_FORMAT_COMPLETION_EVENT:
 			format_cmpln_event = pevent_log_info + offset;
-			printf("Format NVM Completion Event: \n");
+			printf("Format NVM Completion Event Entry: \n");
 			printf("Namespace Identifier: %u\n",
 				le32_to_cpu(format_cmpln_event->nsid));
 			printf("Smallest Format Progress Indicator: %u\n",
@@ -1627,7 +1629,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
 			break;
 		case NVME_SANITIZE_START_EVENT:
 			sanitize_start_event = pevent_log_info + offset;
-			printf("Sanitize Start Event: \n");
+			printf("Sanitize Start Event Entry: \n");
 			printf("SANICAP: %u\n", sanitize_start_event->sani_cap);
 			printf("Sanitize CDW10: %u\n",
 				le32_to_cpu(sanitize_start_event->sani_cdw10));
@@ -1636,7 +1638,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
 			break;
 		case NVME_SANITIZE_COMPLETION_EVENT:
 			sanitize_cmpln_event = pevent_log_info + offset;
-			printf("Sanitize Completion Event: \n");
+			printf("Sanitize Completion Event Entry: \n");
 			printf("Sanitize Progress: %u\n",
 				le16_to_cpu(sanitize_cmpln_event->sani_prog));
 			printf("Sanitize Status: %u\n",
@@ -1646,7 +1648,7 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
 			break;
 		case NVME_THERMAL_EXCURSION_EVENT:
 			thermal_exc_event = pevent_log_info + offset;
-			printf("Thermal Excursion Event: \n");
+			printf("Thermal Excursion Event Entry: \n");
 			printf("Over Temperature: %u\n", thermal_exc_event->over_temp);
 			printf("Threshold: %u\n", thermal_exc_event->threshold);
 			break;
-- 
2.31.1