]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
ocp-telemetry-decode: fix ascii string lookup
authorPaul Wood <p.wood@samsung.com>
Mon, 23 Dec 2024 19:57:11 +0000 (11:57 -0800)
committerDaniel Wagner <wagi@monom.org>
Mon, 27 Jan 2025 08:47:23 +0000 (09:47 +0100)
Lookup ascii string in VU Event Identifier String Table for vendor
unique event classes. Fix typo.

Signed-off-by: Paul Wood <p.wood@samsung.com>
plugins/ocp/ocp-telemetry-decode.c
plugins/ocp/ocp-telemetry-decode.h

index 0f902368ab41fc537033fa661d8121b240bb8cd7..d6a0b6301ee00672276953b000b7415b15df4510 100644 (file)
@@ -489,9 +489,9 @@ int get_telemetry_das_offset_and_size(
        return 0;
 }
 
-int get_static_id_ascii_string(int identifier, char *description)
+int get_statistic_id_ascii_string(int identifier, char *description)
 {
-       if (pstring_buffer == NULL)
+       if (!pstring_buffer || !description)
                return -1;
 
        struct nvme_ocp_telemetry_string_header *pocp_ts_header =
@@ -522,16 +522,17 @@ int get_static_id_ascii_string(int identifier, char *description)
                        memcpy(description, pdescription,
                               peach_statistic_entry->ascii_id_length + 1);
 
-                       // If ASCII string isn't found, see in our internal Map
-                       // for 2.5 Spec defined strings (id < 0x1D).
-                       if ((description == NULL) && (identifier < 0x1D))
-                               memcpy(description,
-                                      statistic_identifiers_map[identifier].description,
-                                      peach_statistic_entry->ascii_id_length + 1);
                        return 0;
                }
        }
 
+       // If ASCII string isn't found, see in our internal Map
+       // for 2.5 Spec defined strings
+       if (identifier <= 0x1D) {
+               strcpy(description, statistic_identifiers_map[identifier].description);
+               return 0;
+       }
+
        return -1;
 }
 
@@ -629,10 +630,10 @@ int parse_ocp_telemetry_string_log(int event_fifo_num, int identifier, int debug
        }
 
        if (string_table == STATISTICS_IDENTIFIER_STRING)
-               get_static_id_ascii_string(identifier, description);
-       else if (string_table == EVENT_STRING)
+               get_statistic_id_ascii_string(identifier, description);
+       else if (string_table == EVENT_STRING && debug_event_class < 0x80)
                get_event_id_ascii_string(identifier, debug_event_class, description);
-       else if (string_table == VU_EVENT_STRING)
+       else if (string_table == VU_EVENT_STRING || debug_event_class >= 0x80)
                get_vu_event_id_ascii_string(identifier, debug_event_class, description);
 
        return 0;
index 29d7b234845058acd0f14f3d0c61fd7cf1e86323..2f926ab71a9a6953ce033ddc06a8023a1f0708a2 100644 (file)
@@ -1174,7 +1174,7 @@ int print_ocp_telemetry_json(struct ocp_telemetry_parse_options *options);
  *
  * @return 0 success
  */
-int get_static_id_ascii_string(int identifier, char *description);
+int get_statistic_id_ascii_string(int identifier, char *description);
 
 /**
  * @brief gets event id ascii string