From e76b610467f3f9f2878c85a9a6677e0a58e9aec9 Mon Sep 17 00:00:00 2001 From: Paul Wood Date: Mon, 23 Dec 2024 11:57:11 -0800 Subject: [PATCH] ocp-telemetry-decode: fix ascii string lookup Lookup ascii string in VU Event Identifier String Table for vendor unique event classes. Fix typo. Signed-off-by: Paul Wood --- plugins/ocp/ocp-telemetry-decode.c | 23 ++++++++++++----------- plugins/ocp/ocp-telemetry-decode.h | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/plugins/ocp/ocp-telemetry-decode.c b/plugins/ocp/ocp-telemetry-decode.c index 0f902368ab..d6a0b6301e 100644 --- a/plugins/ocp/ocp-telemetry-decode.c +++ b/plugins/ocp/ocp-telemetry-decode.c @@ -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; diff --git a/plugins/ocp/ocp-telemetry-decode.h b/plugins/ocp/ocp-telemetry-decode.h index 29d7b23484..2f926ab71a 100644 --- a/plugins/ocp/ocp-telemetry-decode.h +++ b/plugins/ocp/ocp-telemetry-decode.h @@ -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