xref: /optee_os/lib/libutee/include/pta_stats.h (revision 9f34db38245c9b3a4e6e7e63eb78a75e23ab2da3)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (C) 2023, STMicroelectronics
4  * Copyright (C) 2022, Microchip
5  */
6 #ifndef __PTA_STATS_H
7 #define __PTA_STATS_H
8 
9 #include <stdint.h>
10 #include <tee_api_types.h>
11 
12 #define STATS_UUID \
13 		{ 0xd96a5b40, 0xe2c7, 0xb1af, \
14 			{ 0x87, 0x94, 0x10, 0x02, 0xa5, 0xd5, 0xc6, 0x1b } }
15 
16 /*
17  * STATS_CMD_PAGER_STATS - Get statistics on pager
18  *
19  * [out]    value[0].a        Number of unlocked pages
20  * [out]    value[0].b        Page pool size
21  * [out]    value[1].a        R/O faults since last stats dump
22  * [out]    value[1].b        R/W faults since last stats dump
23  * [out]    value[2].a        Hidden faults since last stats dump
24  * [out]    value[2].b        Zi pages released since last stats dump
25  */
26 #define STATS_CMD_PAGER_STATS		0
27 
28 /*
29  * STATS_CMD_ALLOC_STATS - Get statistics on core heap allocations
30  *
31  * [in]     value[0].a       ID of allocator(s) to get stats from (ALLOC_ID_*)
32  * [out]    memref[0]        Array of struct pta_stats_alloc instances
33  */
34 #define STATS_CMD_ALLOC_STATS		1
35 
36 #define ALLOC_ID_ALL		0	/* All allocators */
37 #define ALLOC_ID_HEAP		1	/* Core heap allocator */
38 #define ALLOC_ID_PUBLIC_DDR	2	/* Public DDR allocator (deprecated) */
39 #define ALLOC_ID_TA_RAM		3	/* TA_RAM allocator */
40 #define ALLOC_ID_NEXUS_HEAP	4	/* Nexus heap allocator */
41 #define STATS_NB_POOLS		5
42 
43 #define TEE_ALLOCATOR_DESC_LENGTH 32
44 
45 struct pta_stats_alloc {
46 	char desc[TEE_ALLOCATOR_DESC_LENGTH];
47 	uint32_t allocated;               /* Bytes currently allocated */
48 	uint32_t max_allocated;           /* Tracks max value of allocated */
49 	uint32_t size;                    /* Total size for this allocator */
50 	uint32_t num_alloc_fail;          /* Number of failed alloc requests */
51 	uint32_t biggest_alloc_fail;      /* Size of biggest failed alloc */
52 	uint32_t biggest_alloc_fail_used; /* Alloc bytes when above occurred */
53 };
54 
55 /*
56  * STATS_CMD_MEMLEAK_STATS - Print memory leakage info to console
57  */
58 #define STATS_CMD_MEMLEAK_STATS		2
59 
60 /*
61  * STATS_CMD_TA_STATS - Get information on TA instances
62  *
63  * [out]    memref[0]        Array of struct pta_stats_ta per loaded TA
64  */
65 #define STATS_CMD_TA_STATS		3
66 
67 struct pta_stats_ta {
68 	TEE_UUID uuid;
69 	uint32_t panicked;	/* True if TA has panicked */
70 	uint32_t sess_num;	/* Number of opened session */
71 	struct pta_stats_alloc heap;
72 };
73 
74 /*
75  * STATS_CMD_GET_TIME - Get both REE time and TEE time
76  *
77  * [out]    value[0].a        REE time as seen by OP-TEE in seconds
78  * [out]    value[0].b        REE time as seen by OP-TEE, milliseconds part
79  * [out]    value[1].a        TEE system time in seconds
80  * [out]    value[1].b        TEE system time, milliseconds part
81  */
82 #define STATS_CMD_GET_TIME		4
83 
84 /*
85  * STATS_CMD_PRINT_DRIVER_INFO - Print device drivers information to console
86  *
87  * [in]    value[0].a        Target driver, one of STATS_DRIVER_TYPE_*
88  */
89 #define STATS_CMD_PRINT_DRIVER_INFO	5
90 
91 #define STATS_DRIVER_TYPE_CLOCK		0
92 #define STATS_DRIVER_TYPE_REGULATOR	1
93 
94 #endif /*__PTA_STATS_H*/
95