Sound Open Firmware
Loading...
Searching...
No Matches
performance_monitor.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2024 Intel Corporation. All rights reserved.
4 *
5 * Author: Tobiasz Dryjanski <tobiaszx.dryjanski@intel.com>
6 */
7
14#ifndef __SOF_PERFORMANCE_MONITOR_H__
15#define __SOF_PERFORMANCE_MONITOR_H__
16
17#include <ipc4/base_fw.h>
18
20#define WIN3_MBASE DT_REG_ADDR(DT_PHANDLE(DT_NODELABEL(mem_window3), memory))
22#define ADSP_PMW ((volatile uint32_t *) \
23 (sys_cache_uncached_ptr_get((__sparse_force void __sparse_cache *) \
24 (WIN3_MBASE + WIN3_OFFSET))))
25
26#if IS_ENABLED(CONFIG_SOF_TELEMETRY_PERFORMANCE_MEASUREMENTS) || defined(__DOXYGEN__)
34void perf_data_item_comp_init(struct perf_data_item_comp *perf, uint32_t resource_id,
35 uint32_t power_mode);
36
43
51
58
65
73
80int get_extended_performance_data(struct extended_global_perf_data * const ext_global_perf_data);
81
88
95
101
102#else
103
104static inline
105void perf_data_item_comp_init(struct perf_data_item_comp *perf, uint32_t resource_id,
106 uint32_t power_mode)
107{}
108
109static inline struct perf_data_item_comp *perf_data_getnext(void)
110{
111 return NULL;
112}
113
114static inline
116{
117 return 0;
118}
119
120static inline void perf_meas_set_state(enum ipc4_perf_measurements_state_set state) {}
121
123{
125}
126
127static inline int get_performance_data(struct global_perf_data * const global_perf_data)
128{
129 return 0;
130}
131
132static inline
133int get_extended_performance_data(struct extended_global_perf_data * const ext_global_perf_data)
134{
135 return 0;
136}
137
138static inline int reset_performance_counters(void)
139{
140 return 0;
141}
142
143static inline int enable_performance_counters(void)
144{
145 return 0;
146}
147
148static inline void disable_performance_counters(void) {}
149
150#endif
151
152#ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS
153
154struct io_perf_data_item {
155 /* ID of interface */
156 uint32_t id : 8;
157 /* Instance of interface / bus */
158 uint32_t instance : 8;
159 /* I/O direction from ACE perspective: 0 - Input, 1 - Output */
160 uint32_t direction : 1;
161 /* I/O state: 0 - powered down / disabled, 1 - powered up / enabled */
162 uint32_t state : 1;
163 /* Power Mode: 0 - D0, 1 - D0ix (clock gating enabled), */
164 uint32_t power_mode : 2;
165 uint32_t rsvd : 11;
166 /* The component still exists (0) or has been already deleted (1) */
167 uint32_t is_removed : 1;
168 /* Performance data */
169 /*
170 * I/O (id) - ID - Units - Description
171 *
172 * Host IPC - 0 - Count - Counter of Host IPC messages incoming and outcoming
173 * IDC - 1 - Count - Counter of IDC messages incoming and outcoming per DSP core
174 * DMIC - 2 - Bytes - Counter of bytes transferred over DMIC interface
175 * I2S - 3 - Bytes - Counter of bytes transferred over I2S interface
176 * SoundWire - 4 - Bytes - Counter of bytes transferred over SoundWire interface
177 * HD/A - 5 - Bytes - Counter of bytes transferred over HD/A interface
178 * USB - 6 - Bytes - Counter of bytes transferred over USB interface
179 * GPIO - 7 - Count - Counter of GPIO interrupts or triggers
180 * I2C - 8 - Bytes - Counter of bytes transferred over I2C interface
181 * I3C - 9 - Bytes - Counter of bytes transferred over I3C interface
182 * I3C interrupt - 10 - Bytes - Counter of I3C interrupts
183 * UART - 11 - Bytes - Counter of bytes transferred over UART interface
184 * SPI - 12 - Bytes - Counter of bytes transferred over SPI interface
185 * CSI-2 - 13 - Bytes - Counter of bytes transferred over CSI-2 interface
186 * DTF - 14 - Bytes - Counter of bytes transferred over DTF interface
187 */
188 uint64_t data;
189} __packed;
190
191/* those below are used for bits in io_perf_data_item, it just uses 32bit vars specifically */
192enum io_perf_data_item_dir {
193 IO_PERF_INPUT_DIRECTION = 0,
194 IO_PERF_OUTPUT_DIRECTION = 1,
195};
196
197enum io_perf_data_item_state {
198 IO_PERF_POWERED_DOWN_DISABLED = 0,
199 IO_PERF_POWERED_UP_ENABLED = 1,
200};
201
202enum io_perf_data_item_power_mode {
203 IO_PERF_D0_POWER_MODE = 0,
204 IO_PERF_D0IX_POWER_MODE = 1,
205};
206
207enum io_perf_data_item_id {
208 IO_PERF_IPC_ID = 0,
209 IO_PERF_IDC_ID = 1,
210 IO_PERF_DMIC_ID = 2,
211 IO_PERF_I2S_ID = 3,
212 IO_PERF_SOUND_WIRE_ID = 4,
213 IO_PERF_HDA_ID = 5,
214 IO_PERF_USB_ID = 6,
215 IO_PERF_GPIO_ID = 7,
216 IO_PERF_I2C_ID = 8,
217 IO_PERF_I3C_ID = 9,
218 IO_PERF_I3C_INTERRUPT_ID = 10,
219 IO_PERF_UART_ID = 11,
220 IO_PERF_SPI_ID = 12,
221 IO_PERF_CSI_2_ID = 13,
222 IO_PERF_DTF_ID = 14,
223 IO_PERF_INVALID_ID = 0xFF
224};
225
226struct io_global_perf_data {
227 /* Number of statistics */
228 uint32_t perf_item_count;
229 /* Performance statistics per I/O */
230 struct io_perf_data_item perf_items[0];
231};
232
233/* I/O Performance Monitor initialization. */
234/*
235 * @return ErrorCode
236 */
237int io_perf_monitor_init(void);
238
239/* Release slot */
240/*
241 * @param [in] slot_id pointer to io_perf_data_item
242 * @return ErrorCode
243 */
244int io_perf_monitor_release_slot(struct io_perf_data_item *slot_id);
245
246/* Get I/O performance data */
247/*
248 * @param [in] io_global_perf_data point to io_global_perf_data
249 * @return ErrorCode
250 */
251int
252io_perf_monitor_get_performance_data(struct io_global_perf_data *io_global_perf_data);
253
254/* Set control state of I/o performance measurements process */
255/*
256 * @param [in] state a state to set
257 * @return ErrorCode
258 */
259int
260io_perf_monitor_set_state(enum ipc4_perf_measurements_state_set state);
261
262/* Get control state of I/o performance measurements process */
263/*
264 * @return ipc4_perf_measurements_state_set
265 */
266enum ipc4_perf_measurements_state_set io_perf_monitor_get_state(void);
267
268/* Initialization of I/O performance data */
269/*
270 * @param [out] slot_id pointer to io_perf_data_item
271 * @param [in] init_data pointer to init data
272 */
273int io_perf_monitor_init_data(struct io_perf_data_item **slot_id,
274 struct io_perf_data_item *init_data);
275
276/* Update of I/O performance data */
277/*
278 * @param [in] slot_id pointer to io_perf_data_item
279 * @param [in] increment
280 * @note IMPORTANT: this function assumes each perf slot has only one user
281 * (use this only once per slot)
282 */
283void io_perf_monitor_update_data(struct io_perf_data_item *slot_id,
284 uint32_t increment);
285
286/* Update of I/0 state */
287/*
288 * @param [in] slot_id pointer to io_perf_data_item
289 * @param [in] power_up 0 - powered down / disabled, 1 - powered up / enabled
290 */
291void io_perf_monitor_update_io_state(struct io_perf_data_item *slot_id,
292 bool const power_up);
293
294/* Update of I/0 power mode */
295/*
296 * @param [in] slot_id pointer to io_perf_data_item
297 * @param [in] power_mode 0 - D0, 1 - D0ix (clock gating enabled)
298 */
299void io_perf_monitor_update_power_mode(struct io_perf_data_item *slot_id,
300 bool const power_mode);
301
302#endif //SUPPORTED(IO_PERFORMANCE_MEASUREMENTS)
303
304#endif
IPC4 Base Firmware parameters, memory configuration, and status definitions.
ipc4_perf_measurements_state_set
Performance measurement process states.
Definition base_fw.h:447
@ IPC4_PERF_MEASUREMENTS_DISABLED
Performance measurements disabled.
Definition base_fw.h:448
struct perf_data_item_comp * perf_data_getnext(void)
Allocate next free performance data slot from Memory Window 3.
int free_performance_data(struct perf_data_item_comp *item)
Release an allocated performance data slot in Memory Window 3.
void disable_performance_counters(void)
Disable performance counters and unregister records marked for removal.
int get_extended_performance_data(struct extended_global_perf_data *const ext_global_perf_data)
Retrieve extended global performance telemetry data with per-core breakdown.
int reset_performance_counters(void)
Reset all performance measurement counters across all components.
int get_performance_data(struct global_perf_data *const global_perf_data)
Retrieve global aggregated performance telemetry data.
enum ipc4_perf_measurements_state_set perf_meas_get_state(void)
Query current global performance measurement state.
void perf_data_item_comp_init(struct perf_data_item_comp *perf, uint32_t resource_id, uint32_t power_mode)
Initializer for component performance data record.
void perf_meas_set_state(enum ipc4_perf_measurements_state_set state)
Set global performance measurement state machine.
int enable_performance_counters(void)
Reinitialize and activate performance counters for all created components.
uint16_t id
Unique identifier of the control.
Definition header.h:0
uint8_t data[0]
Binary byte payload for raw controls.
Definition header.h:5
Extended global performance data report (IPC4_EXTENDED_GLOBAL_PERF_DATA).
Definition base_fw.h:745
Global DSP performance summary.
Definition base_fw.h:767
Component performance data with wall clock cycle metrics.
Definition base_fw.h:754
struct perf_data_item item
Base performance item header.
Definition base_fw.h:755