]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-cli: Adds readable firmware level in persistent
authorWen Xiong <wenxiong@linux.ibm.com>
Wed, 1 Dec 2021 22:28:44 +0000 (17:28 -0500)
committerDaniel Wagner <dwagner@suse.de>
Fri, 10 Dec 2021 15:12:21 +0000 (16:12 +0100)
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@linux.ibm.com
nvme-print.c

index 85403c631bf4e1dc23d6a3976e982432d8f6b32c..fadd064c893e0fafa8b6c694fa276aa2e1172b10 100644 (file)
@@ -1133,6 +1133,7 @@ static void json_persistent_event_log(void *pevent_log_info, __u32 size)
        __u32 offset, por_info_len, por_info_list;
        __u64 *fw_rev;
        char key[128];
+       char fw_str[50];
 
        struct nvme_smart_log *smart_event;
        struct nvme_fw_commit_event *fw_commit_event;
@@ -1306,10 +1307,14 @@ static 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",
@@ -1337,8 +1342,10 @@ static 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);
@@ -1568,10 +1575,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);
@@ -1598,7 +1607,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++) {