@@ -1027,17 +1027,22 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start,
10271027 if (pevent_descriptor -> debug_event_class_type == RESERVED_CLASS_TYPE )
10281028 break ;
10291029
1030- if (pevent_descriptor != NULL && pevent_descriptor -> event_data_size >= 0 ) {
1030+ __u8 * pevent_specific_data = NULL ;
1031+ __u16 event_id = 0 ;
1032+ char description_str [256 ] = "" ;
1033+ unsigned int data_size = 0 ;
1034+
1035+ if (pevent_descriptor != NULL &&
1036+ pevent_descriptor -> event_data_size >= 0 &&
1037+ pevent_descriptor -> debug_event_class_type !=
1038+ STATISTIC_SNAPSHOT_CLASS_TYPE ) {
1039+ event_des_size = sizeof (struct nvme_ocp_telemetry_event_descriptor );
10311040 /* Data is present in the form of DWORDS,
10321041 * So multiplying with sizeof(DWORD)
10331042 */
1034- unsigned int data_size = pevent_descriptor -> event_data_size *
1043+ data_size = pevent_descriptor -> event_data_size *
10351044 SIZE_OF_DWORD ;
10361045
1037- __u8 * pevent_specific_data = NULL ;
1038- __u16 event_id = 0 ;
1039- char description_str [256 ] = "" ;
1040-
10411046 if (pevent_descriptor != NULL && pevent_descriptor -> event_data_size > 0 )
10421047 pevent_specific_data = (__u8 * )pevent_descriptor + event_des_size ;
10431048
@@ -1128,18 +1133,6 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start,
11281133 pevent_fifos_object ,
11291134 fp );
11301135 break ;
1131- case STATISTIC_SNAPSHOT_CLASS_TYPE : {
1132- struct nvme_ocp_statistic_snapshot_evt_class_format
1133- * pStaticSnapshotEvent =
1134- (struct nvme_ocp_statistic_snapshot_evt_class_format * )
1135- pevent_specific_data ;
1136- struct nvme_ocp_telemetry_statistic_descriptor * pstatistic_entry =
1137- (struct nvme_ocp_telemetry_statistic_descriptor * )
1138- (& pStaticSnapshotEvent -> statisticDescriptorData );
1139-
1140- parse_statistic (pstatistic_entry , pevent_descriptor_obj , fp );
1141- break ;
1142- }
11431136 case RESERVED_CLASS_TYPE :
11441137 default :
11451138 break ;
@@ -1154,11 +1147,67 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start,
11541147 else
11551148 printf (STR_LINE2 );
11561149 }
1157- } else
1150+ } else if ((pevent_descriptor != NULL ) &&
1151+ (pevent_descriptor -> debug_event_class_type ==
1152+ STATISTIC_SNAPSHOT_CLASS_TYPE )) {
1153+ parse_ocp_telemetry_string_log (0 , event_id ,
1154+ pevent_descriptor -> debug_event_class_type , EVENT_STRING ,
1155+ description_str );
1156+
1157+ struct json_object * pevent_descriptor_obj =
1158+ ((pevent_fifos_object != NULL ) ? json_create_object () : NULL );
1159+
1160+ if (pevent_descriptor_obj != NULL ) {
1161+ json_add_formatted_u32_str (pevent_descriptor_obj ,
1162+ STR_DBG_EVENT_CLASS_TYPE ,
1163+ pevent_descriptor -> debug_event_class_type );
1164+ json_object_add_value_string (pevent_descriptor_obj ,
1165+ STR_EVENT_STRING , description_str );
1166+ } else {
1167+ if (fp ) {
1168+ fprintf (fp , "%s: 0x%x\n" , STR_DBG_EVENT_CLASS_TYPE ,
1169+ pevent_descriptor -> debug_event_class_type );
1170+ fprintf (fp , "%s: %s\n" , STR_EVENT_STRING , description_str );
1171+ } else {
1172+ printf ("%s: 0x%x\n" , STR_DBG_EVENT_CLASS_TYPE ,
1173+ pevent_descriptor -> debug_event_class_type );
1174+ printf ("%s: %s\n" , STR_EVENT_STRING , description_str );
1175+ }
1176+ }
1177+
1178+ struct nvme_ocp_statistic_snapshot_evt_class_format
1179+ * pStaticSnapshotEvent =
1180+ (struct nvme_ocp_statistic_snapshot_evt_class_format * )
1181+ pevent_descriptor ;
1182+
1183+ event_des_size =
1184+ sizeof (struct nvme_ocp_statistic_snapshot_evt_class_format );
1185+ data_size =
1186+ (le16_to_cpu ((unsigned int )pStaticSnapshotEvent -> stat_data_size ) *
1187+ SIZE_OF_DWORD );
1188+
1189+ if (pStaticSnapshotEvent != NULL &&
1190+ pStaticSnapshotEvent -> stat_data_size > 0 ) {
1191+ __u8 * pstatistic_entry =
1192+ (__u8 * )pStaticSnapshotEvent +
1193+ sizeof (struct nvme_ocp_telemetry_event_descriptor );
1194+
1195+ parse_statistic (
1196+ (struct nvme_ocp_telemetry_statistic_descriptor * )
1197+ pstatistic_entry ,
1198+ pevent_descriptor_obj ,
1199+ fp );
1200+ }
1201+ } else {
1202+ if (fp )
1203+ fprintf (fp , "Unknown or null event class %p\n" , pevent_descriptor );
1204+ else
1205+ printf ("Unknown or null event class %p\n" , pevent_descriptor );
1206+
11581207 break ;
1208+ }
11591209
1160- offset_to_move += (pevent_descriptor -> event_data_size * SIZE_OF_DWORD +
1161- event_des_size );
1210+ offset_to_move += (data_size + event_des_size );
11621211 }
11631212
11641213 if (pevent_fifos_object != NULL && pevent_fifo_array != NULL )
@@ -1243,11 +1292,10 @@ int parse_statistic(struct nvme_ocp_telemetry_statistic_descriptor *pstatistic_e
12431292 return -1 ;
12441293 }
12451294
1246- if (pstatistic_entry -> statistic_id == STATISTICS_RESERVED_ID )
1295+ if (le16_to_cpu ( pstatistic_entry -> statistic_id ) == STATISTICS_RESERVED_ID )
12471296 /* End of statistics entries, return -1 to stop processing the buffer */
12481297 return -1 ;
12491298
1250-
12511299 unsigned int data_size = pstatistic_entry -> statistic_data_size * SIZE_OF_DWORD ;
12521300 __u8 * pdata = (__u8 * )pstatistic_entry +
12531301 sizeof (struct nvme_ocp_telemetry_statistic_descriptor );
0 commit comments