diff --git a/plugins/ocp/ocp-telemetry-decode.c b/plugins/ocp/ocp-telemetry-decode.c index 80a27183c6..4bf70ad364 100644 --- a/plugins/ocp/ocp-telemetry-decode.c +++ b/plugins/ocp/ocp-telemetry-decode.c @@ -1027,17 +1027,22 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start, if (pevent_descriptor->debug_event_class_type == RESERVED_CLASS_TYPE) break; - if (pevent_descriptor != NULL && pevent_descriptor->event_data_size >= 0) { + __u8 *pevent_specific_data = NULL; + __u16 event_id = 0; + char description_str[256] = ""; + unsigned int data_size = 0; + + if (pevent_descriptor != NULL && + pevent_descriptor->event_data_size >= 0 && + pevent_descriptor->debug_event_class_type != + STATISTIC_SNAPSHOT_CLASS_TYPE) { + event_des_size = sizeof(struct nvme_ocp_telemetry_event_descriptor); /* Data is present in the form of DWORDS, * So multiplying with sizeof(DWORD) */ - unsigned int data_size = pevent_descriptor->event_data_size * + data_size = pevent_descriptor->event_data_size * SIZE_OF_DWORD; - __u8 *pevent_specific_data = NULL; - __u16 event_id = 0; - char description_str[256] = ""; - if (pevent_descriptor != NULL && pevent_descriptor->event_data_size > 0) pevent_specific_data = (__u8 *)pevent_descriptor + event_des_size; @@ -1128,18 +1133,6 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start, pevent_fifos_object, fp); break; - case STATISTIC_SNAPSHOT_CLASS_TYPE: { - struct nvme_ocp_statistic_snapshot_evt_class_format - *pStaticSnapshotEvent = - (struct nvme_ocp_statistic_snapshot_evt_class_format *) - pevent_specific_data; - struct nvme_ocp_telemetry_statistic_descriptor *pstatistic_entry = - (struct nvme_ocp_telemetry_statistic_descriptor *) - (&pStaticSnapshotEvent->statisticDescriptorData); - - parse_statistic(pstatistic_entry, pevent_descriptor_obj, fp); - break; - } case RESERVED_CLASS_TYPE: default: break; @@ -1154,11 +1147,67 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start, else printf(STR_LINE2); } - } else + } else if ((pevent_descriptor != NULL) && + (pevent_descriptor->debug_event_class_type == + STATISTIC_SNAPSHOT_CLASS_TYPE)) { + parse_ocp_telemetry_string_log(0, event_id, + pevent_descriptor->debug_event_class_type, EVENT_STRING, + description_str); + + struct json_object *pevent_descriptor_obj = + ((pevent_fifos_object != NULL) ? json_create_object() : NULL); + + if (pevent_descriptor_obj != NULL) { + json_add_formatted_u32_str(pevent_descriptor_obj, + STR_DBG_EVENT_CLASS_TYPE, + pevent_descriptor->debug_event_class_type); + json_object_add_value_string(pevent_descriptor_obj, + STR_EVENT_STRING, description_str); + } else { + if (fp) { + fprintf(fp, "%s: 0x%x\n", STR_DBG_EVENT_CLASS_TYPE, + pevent_descriptor->debug_event_class_type); + fprintf(fp, "%s: %s\n", STR_EVENT_STRING, description_str); + } else { + printf("%s: 0x%x\n", STR_DBG_EVENT_CLASS_TYPE, + pevent_descriptor->debug_event_class_type); + printf("%s: %s\n", STR_EVENT_STRING, description_str); + } + } + + struct nvme_ocp_statistic_snapshot_evt_class_format + *pStaticSnapshotEvent = + (struct nvme_ocp_statistic_snapshot_evt_class_format *) + pevent_descriptor; + + event_des_size = + sizeof(struct nvme_ocp_statistic_snapshot_evt_class_format); + data_size = + (le16_to_cpu((unsigned int)pStaticSnapshotEvent->stat_data_size) * + SIZE_OF_DWORD); + + if (pStaticSnapshotEvent != NULL && + pStaticSnapshotEvent->stat_data_size > 0) { + __u8 *pstatistic_entry = + (__u8 *)pStaticSnapshotEvent + + sizeof(struct nvme_ocp_telemetry_event_descriptor); + + parse_statistic( + (struct nvme_ocp_telemetry_statistic_descriptor *) + pstatistic_entry, + pevent_descriptor_obj, + fp); + } + } else { + if (fp) + fprintf(fp, "Unknown or null event class %p\n", pevent_descriptor); + else + printf("Unknown or null event class %p\n", pevent_descriptor); + break; + } - offset_to_move += (pevent_descriptor->event_data_size * SIZE_OF_DWORD + - event_des_size); + offset_to_move += (data_size + event_des_size); } if (pevent_fifos_object != NULL && pevent_fifo_array != NULL) @@ -1243,11 +1292,10 @@ int parse_statistic(struct nvme_ocp_telemetry_statistic_descriptor *pstatistic_e return -1; } - if (pstatistic_entry->statistic_id == STATISTICS_RESERVED_ID) + if (le16_to_cpu(pstatistic_entry->statistic_id) == STATISTICS_RESERVED_ID) /* End of statistics entries, return -1 to stop processing the buffer */ return -1; - unsigned int data_size = pstatistic_entry->statistic_data_size * SIZE_OF_DWORD; __u8 *pdata = (__u8 *)pstatistic_entry + sizeof(struct nvme_ocp_telemetry_statistic_descriptor); diff --git a/plugins/ocp/ocp-telemetry-decode.h b/plugins/ocp/ocp-telemetry-decode.h index 21c5b038e9..e48095cda7 100644 --- a/plugins/ocp/ocp-telemetry-decode.h +++ b/plugins/ocp/ocp-telemetry-decode.h @@ -1102,7 +1102,13 @@ struct __packed nvme_ocp_common_dbg_evt_class_vu_data struct __packed nvme_ocp_statistic_snapshot_evt_class_format { - struct nvme_ocp_telemetry_statistic_descriptor statisticDescriptorData; // Bytes 11:10 + __u8 debug_event_class_type; // Byte 0 + __u8 reserved1[3]; // Bytes 3:1 + __le16 stat_id; // Bytes 5:4 + __u8 stat_info; // Byte 6 + __u8 namespace_info; // Byte 7 + __le16 stat_data_size; // Bytes 9:8 + __le16 nsid; // Bytes 11:10 }; struct __packed nvme_ocp_statistics_identifier_string_table