@@ -1027,17 +1027,21 @@ 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 != STATISTIC_SNAPSHOT_CLASS_TYPE ) {
1038+ event_des_size = sizeof (struct nvme_ocp_telemetry_event_descriptor );
10311039 /* Data is present in the form of DWORDS,
10321040 * So multiplying with sizeof(DWORD)
10331041 */
1034- unsigned int data_size = pevent_descriptor -> event_data_size *
1042+ data_size = pevent_descriptor -> event_data_size *
10351043 SIZE_OF_DWORD ;
10361044
1037- __u8 * pevent_specific_data = NULL ;
1038- __u16 event_id = 0 ;
1039- char description_str [256 ] = "" ;
1040-
10411045 if (pevent_descriptor != NULL && pevent_descriptor -> event_data_size > 0 )
10421046 pevent_specific_data = (__u8 * )pevent_descriptor + event_des_size ;
10431047
@@ -1128,18 +1132,6 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start,
11281132 pevent_fifos_object ,
11291133 fp );
11301134 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- }
11431135 case RESERVED_CLASS_TYPE :
11441136 default :
11451137 break ;
@@ -1154,11 +1146,61 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start,
11541146 else
11551147 printf (STR_LINE2 );
11561148 }
1157- } else
1149+ } else if ((pevent_descriptor != NULL ) &&
1150+ (pevent_descriptor -> debug_event_class_type ==
1151+ STATISTIC_SNAPSHOT_CLASS_TYPE )) {
1152+ parse_ocp_telemetry_string_log (0 , event_id ,
1153+ pevent_descriptor -> debug_event_class_type , EVENT_STRING ,
1154+ description_str );
1155+
1156+ struct json_object * pevent_descriptor_obj =
1157+ ((pevent_fifos_object != NULL )?json_create_object ():NULL );
1158+
1159+ if (pevent_descriptor_obj != NULL ) {
1160+ json_add_formatted_u32_str (pevent_descriptor_obj ,
1161+ STR_DBG_EVENT_CLASS_TYPE ,
1162+ pevent_descriptor -> debug_event_class_type );
1163+ json_object_add_value_string (pevent_descriptor_obj ,
1164+ STR_EVENT_STRING , description_str );
1165+ } else {
1166+ if (fp ) {
1167+ fprintf (fp , "%s: 0x%x\n" , STR_DBG_EVENT_CLASS_TYPE ,
1168+ pevent_descriptor -> debug_event_class_type );
1169+ fprintf (fp , "%s: %s\n" , STR_EVENT_STRING , description_str );
1170+ } else {
1171+ printf ("%s: 0x%x\n" , STR_DBG_EVENT_CLASS_TYPE ,
1172+ pevent_descriptor -> debug_event_class_type );
1173+ printf ("%s: %s\n" , STR_EVENT_STRING , description_str );
1174+ }
1175+ }
1176+
1177+ struct nvme_ocp_statistic_snapshot_evt_class_format
1178+ * pStaticSnapshotEvent =
1179+ (struct nvme_ocp_statistic_snapshot_evt_class_format * )
1180+ pevent_descriptor ;
1181+
1182+ event_des_size = sizeof (struct nvme_ocp_statistic_snapshot_evt_class_format );
1183+ data_size = (le16_to_cpu ((unsigned int )pStaticSnapshotEvent -> stat_data_size ) *
1184+ SIZE_OF_DWORD );
1185+
1186+ if (pStaticSnapshotEvent != NULL &&
1187+ pStaticSnapshotEvent -> stat_data_size > 0 ) {
1188+ __u8 * pstatistic_entry =
1189+ (__u8 * )pStaticSnapshotEvent +
1190+ sizeof (struct nvme_ocp_telemetry_event_descriptor );
1191+
1192+ parse_statistic ((struct nvme_ocp_telemetry_statistic_descriptor * )pstatistic_entry , pevent_descriptor_obj , fp );
1193+ }
1194+ } else {
1195+ if (fp ) {
1196+ fprintf (fp , "Unknown or null event class %p\n" , pevent_descriptor );
1197+ } else {
1198+ printf ("Unknown or null event class %p\n" , pevent_descriptor );
1199+ }
11581200 break ;
1201+ }
11591202
1160- offset_to_move += (pevent_descriptor -> event_data_size * SIZE_OF_DWORD +
1161- event_des_size );
1203+ offset_to_move += (data_size + event_des_size );
11621204 }
11631205
11641206 if (pevent_fifos_object != NULL && pevent_fifo_array != NULL )
@@ -1243,11 +1285,10 @@ int parse_statistic(struct nvme_ocp_telemetry_statistic_descriptor *pstatistic_e
12431285 return -1 ;
12441286 }
12451287
1246- if (pstatistic_entry -> statistic_id == STATISTICS_RESERVED_ID )
1288+ if (le16_to_cpu ( pstatistic_entry -> statistic_id ) == STATISTICS_RESERVED_ID )
12471289 /* End of statistics entries, return -1 to stop processing the buffer */
12481290 return -1 ;
12491291
1250-
12511292 unsigned int data_size = pstatistic_entry -> statistic_data_size * SIZE_OF_DWORD ;
12521293 __u8 * pdata = (__u8 * )pstatistic_entry +
12531294 sizeof (struct nvme_ocp_telemetry_statistic_descriptor );
0 commit comments