]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-print: Add PEL RCI port identifier type printf function
authorTokunori Ikegami <ikegami.t@gmail.com>
Mon, 26 Feb 2024 15:52:02 +0000 (00:52 +0900)
committerDaniel Wagner <wagi@monom.org>
Tue, 5 Mar 2024 08:58:49 +0000 (09:58 +0100)
Change to use NVME_PEL_RCI_RCPIT definitions.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
nvme-print-stdout.c
nvme-print.c
nvme-print.h

index e984fe562e7c334ad54538b095e22eb53339c78f..37e019dba9efab993129617861c3e425f49f8135 100644 (file)
@@ -224,14 +224,11 @@ static void stdout_persistent_event_log_rci(__le32 pel_header_rci)
        __u8 rcpit = NVME_PEL_RCI_RCPIT(rci);
        __u16 rcpid = NVME_PEL_RCI_RCPID(rci);
 
-       if(rsvd19)
+       if (rsvd19)
                printf("  [31:19] : %#x\tReserved\n", rsvd19);
-       printf("\tReporting Context Exists (RCE): %s(%u)\n",
-               rce ? "true" : "false", rce);
+       printf("\tReporting Context Exists (RCE): %s(%u)\n", rce ? "true" : "false", rce);
        printf("\tReporting Context Port Identifier Type (RCPIT): %u(%s)\n", rcpit,
-               (rcpit == 0x00) ? "Does not already exist" :
-               (rcpit == 0x01) ? "NVM subsystem port" :
-               (rcpit == 0x02) ? "NVMe-MI port" : "Reserved");
+              nvme_pel_rci_rcpit_to_string(rcpit));
        printf("\tReporting Context Port Identifier (RCPID): %#x\n\n", rcpid);
 }
 
index 1086aad2a9bae40726533a3831585c92a9304f5c..1e9ae844a24e1eb0641aee265e47901792760f73 100644 (file)
@@ -950,6 +950,21 @@ const char *nvme_host_metadata_type_to_string(enum nvme_features_id fid,
        }
 }
 
+const char *nvme_pel_rci_rcpit_to_string(enum nvme_pel_rci_rcpit rcpit)
+{
+       switch (rcpit) {
+       case NVME_PEL_RCI_RCPIT_NOT_EXIST:
+               return "Does not already exist";
+       case NVME_PEL_RCI_RCPIT_EST_PORT:
+               return "NVM subsystem port";
+       case NVME_PEL_RCI_RCPIT_EST_ME:
+               return "NVMe-MI port";
+       default:
+               break;
+       }
+       return "Reserved";
+}
+
 void nvme_feature_show(enum nvme_features_id fid, int sel, unsigned int result)
 {
        nvme_print(show_feature, NORMAL, fid, sel, result);
index 4533474eb304b03d0f21245bc518a50e99ac0a80..5ded3b6becaa6fa132388a6bdbef64af1e863562 100644 (file)
@@ -302,6 +302,7 @@ const char *nvme_zone_state_to_string(__u8 state);
 const char *nvme_zone_type_to_string(__u8 cond);
 const char *nvme_plm_window_to_string(__u32 plm);
 const char *nvme_ns_wp_cfg_to_string(enum nvme_ns_write_protect_cfg state);
+const char *nvme_pel_rci_rcpit_to_string(enum nvme_pel_rci_rcpit rcpit);
 
 void nvme_dev_full_path(nvme_ns_t n, char *path, size_t len);
 void nvme_generic_full_path(nvme_ns_t n, char *path, size_t len);