[PATCH 3/5] nvme-cli: Adds readable firmware level in persistent
wenxiong at linux.ibm.com
wenxiong at linux.ibm.com
Wed Nov 17 08:04:46 PST 2021
From: Wen Xiong <wenxiong at linux.ibm.com>
For example, In Firmware Commit Event:
Old Firmware Revision: 3617604718875264338
New Firmware Revision: 3833777500989048146
changes to
Old Firmware Revision: 3617604718875264338 (REV.SP42)
New Firmware Revision: 3833777500989048146 (REV.SP45)
Signed-off-by: Wen Xiong <wenxiong at linux.ibm.com>
---
nvme-print.c | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/nvme-print.c b/nvme-print.c
index dcb0e7c..3f2bb66 100644
--- a/nvme-print.c
+++ b/nvme-print.c
@@ -1110,6 +1110,7 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size)
__u64 *fw_rev;
char key[128];
char evt_str[50];
+ char fw_str[50];
struct nvme_smart_log *smart_event;
struct nvme_fw_commit_event *fw_commit_event;
@@ -1292,10 +1293,14 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size)
break;
case NVME_PEL_FW_COMMIT_EVENT:
fw_commit_event = pevent_log_info + offset;
- json_object_add_value_uint64(valid_attrs, "old_fw_rev",
- le64_to_cpu(fw_commit_event->old_fw_rev));
- json_object_add_value_uint64(valid_attrs, "new_fw_rev",
- le64_to_cpu(fw_commit_event->new_fw_rev));
+ snprintf(fw_str, sizeof(fw_str), "%"PRIu64" (%s)",
+ le64_to_cpu(fw_commit_event->old_fw_rev),
+ fw_to_string((char *)&fw_commit_event->old_fw_rev));
+ json_object_add_value_string(valid_attrs, "old_fw_rev", fw_str);
+ snprintf(fw_str, sizeof(fw_str), "%"PRIu64" (%s)",
+ le64_to_cpu(fw_commit_event->new_fw_rev),
+ fw_to_string((char *)&fw_commit_event->new_fw_rev));
+ json_object_add_value_string(valid_attrs, "new_fw_rev", fw_str);
json_object_add_value_uint(valid_attrs, "fw_commit_action",
fw_commit_event->fw_commit_action);
json_object_add_value_uint(valid_attrs, "fw_slot",
@@ -1323,8 +1328,10 @@ void json_persistent_event_log(void *pevent_log_info, __u32 size)
por_info_list = por_info_len / sizeof(*por_event);
fw_rev = pevent_log_info + offset;
- json_object_add_value_uint64(valid_attrs, "fw_rev",
- le64_to_cpu(*fw_rev));
+ snprintf(fw_str, sizeof(fw_str), "%"PRIu64" (%s)",
+ le64_to_cpu(*fw_rev),
+ fw_to_string((char *)fw_rev));
+ json_object_add_value_string(valid_attrs, "fw_rev", fw_str);
for (int i = 0; i < por_info_list; i++) {
por_event = pevent_log_info + offset +
sizeof(*fw_rev) + i * sizeof(*por_event);
@@ -1559,10 +1566,12 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
case NVME_PEL_FW_COMMIT_EVENT:
fw_commit_event = pevent_log_info + offset;
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",
- le64_to_cpu(fw_commit_event->new_fw_rev));
+ printf("Old Firmware Revision: %"PRIu64" (%s)\n",
+ le64_to_cpu(fw_commit_event->old_fw_rev),
+ fw_to_string((char *)&fw_commit_event->old_fw_rev));
+ printf("New Firmware Revision: %"PRIu64" (%s)\n",
+ le64_to_cpu(fw_commit_event->new_fw_rev),
+ fw_to_string((char *)&fw_commit_event->new_fw_rev));
printf("FW Commit Action: %u\n",
fw_commit_event->fw_commit_action);
printf("FW Slot: %u\n", fw_commit_event->fw_slot);
@@ -1589,7 +1598,8 @@ void nvme_show_persistent_event_log(void *pevent_log_info,
printf("Power On Reset Event Entry: \n");
fw_rev = pevent_log_info + offset;
- printf("Firmware Revision: %"PRIu64"\n", le64_to_cpu(*fw_rev));
+ printf("Firmware Revision: %"PRIu64" (%s)\n", le64_to_cpu(*fw_rev),
+ fw_to_string((char *)fw_rev));
printf("Reset Information List: \n");
for (int i = 0; i < por_info_list; i++) {
--
2.27.0
More information about the Linux-nvme
mailing list