]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-print: Add PEL EHAI port identifier type printf function
authorTokunori Ikegami <ikegami.t@gmail.com>
Fri, 15 Mar 2024 14:55:28 +0000 (23:55 +0900)
committerDaniel Wagner <wagi@monom.org>
Tue, 19 Mar 2024 09:23:23 +0000 (10:23 +0100)
Change to use NVME_PEL_EHAI_PIT definitions.

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

index f37668e80f2f0dede58057b56ce61e40546c4bc7..6741bb2ab5d1b3bc06171c6117e18eb75219e102 100644 (file)
@@ -230,15 +230,11 @@ static void stdout_persistent_event_log_rci(__le32 pel_header_rci)
 
 static void stdout_persistent_event_entry_ehai(__u8 ehai)
 {
-       __u8 rsvd1 = (ehai & 0xfc) >> 2;
-       __u8 pit = ehai & 0x03;
+       __u8 rsvd1 = NVME_PEL_EHAI_RSVD(ehai);
+       __u8 pit = NVME_PEL_EHAI_PIT(ehai);
 
        printf("  [7:2] : %#x\tReserved\n", rsvd1);
-       printf("\tPort Identifier Type (PIT): %u(%s)\n", pit,
-               (pit == 0x00) ? "PIT not reported and PELPID does not apply" :
-               (pit == 0x01) ? "NVM subsystem port" :
-               (pit == 0x02) ? "NVMe-MI port" :
-               "Event not associated with any port and PELPID does not apply");
+       printf("\tPort Identifier Type (PIT): %u(%s)\n", pit, nvme_pel_ehai_pit_to_string(pit));
 }
 
 static void stdout_add_bitmap(int i, __u8 seb)
index ba0b4acac702fb3a25472d8ded204efa2c6a0f1c..0a8deb2a8bd9bdc6425931fcfb06a103f80cfd6f 100644 (file)
@@ -964,6 +964,23 @@ const char *nvme_pel_rci_rcpit_to_string(enum nvme_pel_rci_rcpit rcpit)
        return "Reserved";
 }
 
+const char *nvme_pel_ehai_pit_to_string(enum nvme_pel_ehai_pit pit)
+{
+       switch (pit) {
+       case NVME_PEL_EHAI_PIT_NOT_REPORTED:
+               return "PIT not reported and PELPID does not apply";
+       case NVME_PEL_EHAI_PIT_NSS_PORT:
+               return "NVM subsystem port";
+       case NVME_PEL_EHAI_PIT_NMI_PORT:
+               return "NVMe-MI port";
+       case NVME_PEL_EHAI_PIT_NOT_ASSOCIATED:
+               return "Event not associated with any port and PELPID does not apply";
+       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 5ded3b6becaa6fa132388a6bdbef64af1e863562..d2a32f5a0531bd00b2e6c7a024bf0bccc7089fc6 100644 (file)
@@ -303,6 +303,7 @@ 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);
+const char *nvme_pel_ehai_pit_to_string(enum nvme_pel_ehai_pit pit);
 
 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);