@@ -238,6 +238,73 @@ void perf_meas_set_state(enum ipc4_perf_measurements_state_set state)
238238 perf_measurements_state = state ;
239239}
240240
241+ int get_extended_performance_data (struct extended_global_perf_data * const ext_global_perf_data )
242+ {
243+ if (!ext_global_perf_data ) {
244+ tr_err (& ipc_tr , "IPC data is NULL" );
245+ return - EINVAL ;
246+ }
247+
248+ size_t slots_count ;
249+ size_t slot_idx = 0 ;
250+ uint64_t total_dsp_cycles [CONFIG_MAX_CORE_COUNT ];
251+
252+ /* TODO
253+ * Setting temporary values here.
254+ * Replace this with actual total dsp cycles info once it is available.
255+ */
256+ for (size_t core_id = 0 ; core_id < CONFIG_MAX_CORE_COUNT ; ++ core_id )
257+ total_dsp_cycles [core_id ] = 1 ;
258+
259+ /* Fill one performance record per core with total dsp cycles */
260+ for (size_t core_id = 0 ; core_id < CONFIG_MAX_CORE_COUNT ; ++ core_id ) {
261+ if (!(cpu_enabled_cores () & BIT (core_id )))
262+ continue ;
263+
264+ memset (& ext_global_perf_data -> perf_items [slot_idx ], 0 ,
265+ sizeof (struct ext_perf_data_item ));
266+
267+ ext_global_perf_data -> perf_items [slot_idx ].resource_id = core_id ;
268+ ext_global_perf_data -> perf_items [slot_idx ].module_total_dsp_cycles_consumed =
269+ total_dsp_cycles [core_id ];
270+ ++ slot_idx ;
271+ }
272+
273+ slots_count = perf_bitmap_get_occupied (& performance_data_bitmap ) + slot_idx ;
274+ ext_global_perf_data -> perf_item_count = slots_count ;
275+
276+ /* fill the rest of the IPC records with data from
277+ * components registered in MW3 for performance measurement
278+ */
279+ for (size_t idx = 0 ; idx < perf_bitmap_get_size (& performance_data_bitmap ) &&
280+ slot_idx < slots_count ; ++ idx ) {
281+ if (perf_bitmap_is_bit_clear (& performance_data_bitmap , idx ))
282+ continue ;
283+
284+ ext_global_perf_data -> perf_items [slot_idx ].resource_id =
285+ perf_data [idx ].item .resource_id ;
286+ ext_global_perf_data -> perf_items [slot_idx ].power_mode =
287+ perf_data [idx ].item .power_mode ;
288+ ext_global_perf_data -> perf_items [slot_idx ].is_removed =
289+ perf_data [idx ].item .is_removed ;
290+ ext_global_perf_data -> perf_items [slot_idx ].module_total_dsp_iterations =
291+ perf_data [idx ].total_iteration_count ;
292+ ext_global_perf_data -> perf_items [slot_idx ].module_total_dsp_cycles_consumed =
293+ perf_data [idx ].total_cycles_consumed ;
294+ ext_global_perf_data -> perf_items [slot_idx ].module_peak_dsp_cycles =
295+ perf_data [idx ].item .peak_kcps * 1000 ;
296+ ext_global_perf_data -> perf_items [slot_idx ].module_peak_restricted_cycles =
297+ perf_data [idx ].restricted_peak_cycles ;
298+ ext_global_perf_data -> perf_items [slot_idx ].module_total_restricted_cycles_consumed =
299+ perf_data [idx ].restricted_total_cycles ;
300+ ext_global_perf_data -> perf_items [slot_idx ].module_total_restricted_iterations =
301+ perf_data [idx ].restricted_total_iterations ;
302+ ext_global_perf_data -> perf_items [slot_idx ].rsvd = 0 ;
303+ ++ slot_idx ;
304+ }
305+ return 0 ;
306+ }
307+
241308#ifdef CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS
242309static void telemetry_perf_queue_append (struct telemetry_perf_queue * q , size_t element )
243310{
0 commit comments