blob: 6dc54e5fcb8a1d8fb5ff4f6b5d57c104f7e5bec5 [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2005
8*
9* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
10* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
11* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
12* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
13* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
15* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
16* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
17* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
18* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
19* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
20* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
21*
22* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
23* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
24* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
25* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
26* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
27*
28* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
29* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
30* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
31* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
32* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
33*
34*****************************************************************************/
35
36/*****************************************************************************
37 *
38 * Filename:
39 * ---------
40 * sysconf_statistics.h
41 *
42 * Project:
43 * --------
44 * Maui_Software
45 *
46 * Description:
47 * ------------
48 * This file provides the stack statistics definition
49 *
50 * Author:
51 * -------
52 * -------
53 *
54 *============================================================================
55 * HISTORY
56 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
57 *------------------------------------------------------------------------------
58 * removed!
59 * removed!
60 * removed!
61 *
62 * removed!
63 * removed!
64 * removed!
65 * removed!
66 *
67 * removed!
68 * removed!
69 * removed!
70 *
71 * removed!
72 * removed!
73 * removed!
74 *
75 * removed!
76 * removed!
77 * removed!
78 *
79 * removed!
80 * removed!
81 * removed!
82 *
83 * removed!
84 * removed!
85 * removed!
86 *
87 * removed!
88 * removed!
89 * removed!
90 *
91 * removed!
92 * removed!
93 * removed!
94 *
95 * removed!
96 * removed!
97 * removed!
98 *
99 * removed!
100 * removed!
101 * removed!
102 *
103 * removed!
104 * removed!
105 * removed!
106 *
107 * removed!
108 * removed!
109 * removed!
110 *
111 * removed!
112 * removed!
113 * removed!
114 *
115 * removed!
116 * removed!
117 * removed!
118 *
119 * removed!
120 * removed!
121 * removed!
122 *
123 * removed!
124 * removed!
125 * removed!
126 *
127 * removed!
128 * removed!
129 * removed!
130 *
131 * removed!
132 * removed!
133 * removed!
134 *
135 * removed!
136 * removed!
137 * removed!
138 *
139 * removed!
140 * removed!
141 * removed!
142 *
143 * removed!
144 * removed!
145 * removed!
146 *
147 * removed!
148 * removed!
149 * removed!
150 *
151 * removed!
152 * removed!
153 * removed!
154 *
155 * removed!
156 * removed!
157 * removed!
158 *
159 * removed!
160 * removed!
161 * removed!
162 *
163 * removed!
164 * removed!
165 * removed!
166 * removed!
167 * removed!
168 * removed!
169 * removed!
170 * removed!
171 * removed!
172 * removed!
173 * removed!
174 *
175 * removed!
176 * removed!
177 * removed!
178 *
179 * removed!
180 * removed!
181 * removed!
182 *
183 * removed!
184 * removed!
185 * removed!
186 *
187 * removed!
188 * removed!
189 * removed!
190 *
191 * removed!
192 * removed!
193 * removed!
194 *
195 * removed!
196 * removed!
197 * removed!
198 *
199 * removed!
200 * removed!
201 * removed!
202 *
203 * removed!
204 * removed!
205 * removed!
206 *
207 * removed!
208 * removed!
209 * removed!
210 *
211 * removed!
212 * removed!
213 * removed!
214 *
215 * removed!
216 * removed!
217 * removed!
218 *
219 * removed!
220 * removed!
221 * removed!
222 *
223 * removed!
224 * removed!
225 * removed!
226 *
227 * removed!
228 * removed!
229 * removed!
230 *
231 * removed!
232 * removed!
233 * removed!
234 *
235 * removed!
236 * removed!
237 * removed!
238 *
239 * removed!
240 * removed!
241 * removed!
242 * removed!
243 * removed!
244 * removed!
245 * removed!
246 * removed!
247 * removed!
248 * removed!
249 * removed!
250 * removed!
251 * removed!
252 * removed!
253 * removed!
254 * removed!
255 * removed!
256 * removed!
257 *------------------------------------------------------------------------------
258 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
259 *============================================================================
260 ****************************************************************************/
261
262#ifndef _SYSCONF_STATISTICS_H
263#define _SYSCONF_STATISTICS_H
264
265#define DSPSYS_STAT_DATA_LEN 512
266/*RHR*/
267#include "kal_general_types.h"
268#include "stack_config.h"
269#include "ctrl_buff_pool.h"
270#if defined(__KAL_CROSS_CORE_SUPPORT__) && defined(__MTK_TARGET__)
271#include "kalcc_ctrl_buff_pool.h"
272#endif
273
274#if defined(DEBUG_KAL) && (defined(__UMTS_RAT__) || defined(__LTE_RAT__))
275/* sizeof(stack_statistics_struct) is over 4K, so using compile option to control it */
276/* in case of 2G, no 8k control buffer no further statistic info */
277#define FURTHER_STATISTIC
278#endif
279#define KAL_ADM_PROFILE_AMOUNT (10)
280#define KAL_ADM_PROFILE_AMOUNT_KICKED_OUT (3)
281#define KAL_AFM_PROFILE
282#if defined(KAL_AFM_PROFILE)
283#define KAL_AFM_PROFILE_AMOUNT (10)
284#define KAL_AFM_POOL_PROFILE_AMOUNT (10)
285#endif
286
287#if defined(FURTHER_STATISTIC)
288#define HRTQbitProfileSize 32
289#endif
290
291/*************************************************************************
292 * System Statistics
293 *************************************************************************/
294enum {
295 STACK_STATS_NONE,
296 STACK_STATS_UPDATE,
297 STACK_STATS_END,
298};
299
300enum {
301 STACK_STATS_HISR_NAME = 0,
302 STACK_STATS_HISR_MAX_NAME = 8,
303};
304
305typedef struct clib_heap_statistics_t {
306 kal_uint32 curr_alloc_mem;
307 kal_uint32 max_alloc_mem;
308 kal_uint32 alloc_count;
309 kal_uint32 alloc_fail_count;
310 kal_uint32 config_size;
311} clib_heap_statistics_struct;
312
313
314#define KAL_TIMER_COUNT_STAT 10
315
316struct kal_mod_res_cnt {
317 module_type owner_module;
318 kal_uint16 count;
319};
320
321typedef struct {
322 kal_uint32 *adm_cb; /* ADM_CB * */
323 kal_uint32 adm_cb_size;
324 kal_uint32 max_mbsize_of_mini_left_size;
325 kal_uint32 mini_left_size; /* minimum mini_left_size during each allocation */
326 kal_uint32 creator_caller;
327} ADM_PROFILE;
328
329#if defined(KAL_AFM_PROFILE)
330typedef struct {
331 kal_uint32 buff_size;
332 kal_uint16 buff_nr;
333 kal_uint16 left_buff_nr;
334 kal_uint16 min_left_buff_nr;
335} AFM_POOL_PROFILE;
336
337typedef struct {
338 kal_uint32 * afm_cb; /* AFM_CB * */
339 kal_uint32 afm_cb_size;
340 kal_uint16 afm_subpool_nr;
341 kal_uint16 afm_option;
342 kal_uint32 afm_total_left_mem_sz;
343 kal_uint32 mini_left_size; /* minimum mini_left_size during each allocation */
344 kal_uint32 creator_caller;
345 AFM_POOL_PROFILE afm_subpool[KAL_AFM_POOL_PROFILE_AMOUNT];
346} AFM_PROFILE;
347#endif
348
349typedef struct runtime_sysmem_size {
350 kal_uint16 mutex;
351 kal_uint16 semaphore;
352 kal_uint16 enh_mutex;
353 kal_uint16 event_group;
354 kal_uint16 kal_timer;
355 kal_uint16 event_scheduler;
356 kal_uint16 spinlock;
357 kal_uint16 protect;
358} runtime_sysmem_size_s;
359
360typedef struct runtime_max_amount_sys {
361 kal_uint16 mutex;
362 kal_uint16 semaphore;
363 kal_uint16 enh_mutex;
364 kal_uint16 event_group;
365 kal_uint16 kal_timer;
366 kal_uint16 event_scheduler;
367 kal_uint16 spinlock;
368 kal_uint16 protect;
369} runtime_max_amount_sys_s;
370
371/* It's better to make this 4 bytes alignment, for dump parser */
372typedef struct runtime_max_amount_task {
373 kal_uint32 name;
374 kal_uint32 schedule_count;
375 kal_uint16 stack;
376 kal_uint8 ext_queue;
377 kal_uint8 int_queue;
378 kal_uint8 mutex;
379 kal_uint8 semaphore;
380 kal_uint8 event_group;
381 kal_uint8 kal_timer;
382 kal_uint8 event_scheduler;
383 kal_uint8 enh_mutex;
384 kal_uint8 spinlock;
385 kal_uint8 protect;
386} runtime_max_amount_task_s;
387
388typedef struct runtime_max_amount_hisr {
389 kal_uint32 name;
390 kal_uint32 schedule_count;
391 kal_uint16 stack;
392} runtime_max_amount_hisr_s;
393
394typedef struct memory_pool {
395 kal_uint32 max_sys_mem_used; /* Maximum system dynamic memory used */
396#ifdef DEBUG_KAL
397 kal_uint32 max_sysdebug_mem_used; /* Maximum system debug dynamic memory used */
398 kal_uint32 max_event_number_used;
399#endif
400} memory_pool_s;
401
402typedef struct stack_statistics_t {
403 kal_uint16 stack_stats_status;
404 kal_uint32 total_save_count;
405 kal_uint32 effective_accum_ustime_low;
406 kal_uint32 effective_accum_ustime_high;
407
408 memory_pool_s memory_pool;
409
410
411 runtime_max_amount_sys_s runtime_max_amount_total;
412 runtime_max_amount_sys_s runtime_max_amount_system;
413 runtime_max_amount_task_s runtime_max_amount_task[KAL_MAX_NUM_TASKS];
414 runtime_max_amount_hisr_s runtime_max_amount_hisr[KAL_MAX_NUM_HISRS];
415 runtime_sysmem_size_s primitive_size;
416
417#if defined(DEBUG_BUF1) || defined(DEBUG_BUF2)
418 /* Maximum number control buffers allocated */
419 kal_uint16 max_ctrl_buff_num_allocated[RPS_CREATED_CTRL_BUFF_POOLS];
420#endif /* DEBUG_BUF1 || DEBUG_BUF2 */
421
422#if defined(DEBUG_BUF_MOD_USAGE) && !defined(__MTK_TARGET__)
423 kal_uint16 mod_ctrlBuf_peak_count[RPS_CREATED_CTRL_BUFF_POOLS][MOD_ID_CODE_END];
424#endif /* end of DEBUG_BUF_MOD_USAGE && !__MTK_TARGET__ */
425
426
427#if defined(FURTHER_STATISTIC)
428 ADM_PROFILE top_adm_profile[KAL_ADM_PROFILE_AMOUNT];
429 ADM_PROFILE top_adm_user_profile[KAL_ADM_PROFILE_AMOUNT];
430 kal_uint32 kicked_out_smallest_adm_user_size[KAL_ADM_PROFILE_AMOUNT_KICKED_OUT];
431 kal_uint32 kicked_out_adm_user_number;
432
433 AFM_PROFILE top_afm_profile[KAL_AFM_PROFILE_AMOUNT];
434 AFM_PROFILE top_afm_user_profile[KAL_AFM_PROFILE_AMOUNT];
435
436 kal_uint32 NVRAM_HRTQbitFailLog_VPE0_Dur[HRTQbitProfileSize];
437 kal_uint32 NVRAM_HRTQbitFailLog_VPE0_Addr[HRTQbitProfileSize];
438
439 kal_uint32 NVRAM_HRTQbitFailLog_VPE1_Dur[HRTQbitProfileSize];
440 kal_uint32 NVRAM_HRTQbitFailLog_VPE1_Addr[HRTQbitProfileSize];
441
442 kal_uint32 NVRAM_HRTQbitFailLog_VPE2_Dur[HRTQbitProfileSize];
443 kal_uint32 NVRAM_HRTQbitFailLog_VPE2_Addr[HRTQbitProfileSize];
444
445 kal_uint32 NVRAM_HRTQbitFailLog_VPE3_Dur[HRTQbitProfileSize];
446 kal_uint32 NVRAM_HRTQbitFailLog_VPE3_Addr[HRTQbitProfileSize];
447#endif
448
449
450} stack_statistics_struct;
451
452
453/*************************************************************************
454 * Define function prototype.
455 *************************************************************************/
456
457extern kal_int32 stack_get_stats_info(kal_uint32 stats, void *buff,
458 kal_uint32 buff_size);
459extern void clib_get_heap_statistics(clib_heap_statistics_struct *pstat);
460extern kal_bool stack_update_sys_statistics(stack_statistics_struct *prev_stats);
461
462#endif /* _SYSCONF_STATISTICS_H */