1761fc6ecSEtienne Carriere /* SPDX-License-Identifier: BSD-2-Clause */ 2761fc6ecSEtienne Carriere /* 3761fc6ecSEtienne Carriere * Copyright (C) 2023, STMicroelectronics 4761fc6ecSEtienne Carriere * Copyright (C) 2022, Microchip 5761fc6ecSEtienne Carriere */ 6761fc6ecSEtienne Carriere #ifndef __PTA_STATS_H 7761fc6ecSEtienne Carriere #define __PTA_STATS_H 8761fc6ecSEtienne Carriere 9*a05577eaSEtienne Carriere #include <stdint.h> 10*a05577eaSEtienne Carriere #include <tee_api_types.h> 11*a05577eaSEtienne Carriere 12761fc6ecSEtienne Carriere #define STATS_UUID \ 13761fc6ecSEtienne Carriere { 0xd96a5b40, 0xe2c7, 0xb1af, \ 14761fc6ecSEtienne Carriere { 0x87, 0x94, 0x10, 0x02, 0xa5, 0xd5, 0xc6, 0x1b } } 15761fc6ecSEtienne Carriere 16761fc6ecSEtienne Carriere /* 17*a05577eaSEtienne Carriere * STATS_CMD_PAGER_STATS - Get statistics on pager 18761fc6ecSEtienne Carriere * 19*a05577eaSEtienne Carriere * [out] value[0].a Number of unlocked pages 20*a05577eaSEtienne Carriere * [out] value[0].b Page pool size 21*a05577eaSEtienne Carriere * [out] value[1].a R/O faults since last stats dump 22*a05577eaSEtienne Carriere * [out] value[1].b R/W faults since last stats dump 23*a05577eaSEtienne Carriere * [out] value[2].a Hidden faults since last stats dump 24*a05577eaSEtienne Carriere * [out] value[2].b Zi pages released since last stats dump 25*a05577eaSEtienne Carriere */ 26*a05577eaSEtienne Carriere #define STATS_CMD_PAGER_STATS 0 27*a05577eaSEtienne Carriere 28*a05577eaSEtienne Carriere /* 29*a05577eaSEtienne Carriere * STATS_CMD_ALLOC_STATS - Get statistics on core heap allocations 30*a05577eaSEtienne Carriere * 31*a05577eaSEtienne Carriere * [in] value[0].a ID of allocator(s) to get stats from (ALLOC_ID_*) 32*a05577eaSEtienne Carriere * [out] memref[0] Array of struct pta_stats_alloc instances 33*a05577eaSEtienne Carriere */ 34*a05577eaSEtienne Carriere #define STATS_CMD_ALLOC_STATS 1 35*a05577eaSEtienne Carriere 36*a05577eaSEtienne Carriere #define ALLOC_ID_ALL 0 /* All allocators */ 37*a05577eaSEtienne Carriere #define ALLOC_ID_HEAP 1 /* Core heap allocator */ 38*a05577eaSEtienne Carriere #define ALLOC_ID_PUBLIC_DDR 2 /* Public DDR allocator (deprecated) */ 39*a05577eaSEtienne Carriere #define ALLOC_ID_TA_RAM 3 /* TA_RAM allocator */ 40*a05577eaSEtienne Carriere #define ALLOC_ID_NEXUS_HEAP 4 /* Nexus heap allocator */ 41*a05577eaSEtienne Carriere #define STATS_NB_POOLS 5 42*a05577eaSEtienne Carriere 43*a05577eaSEtienne Carriere #define TEE_ALLOCATOR_DESC_LENGTH 32 44*a05577eaSEtienne Carriere 45*a05577eaSEtienne Carriere struct pta_stats_alloc { 46*a05577eaSEtienne Carriere char desc[TEE_ALLOCATOR_DESC_LENGTH]; 47*a05577eaSEtienne Carriere uint32_t allocated; /* Bytes currently allocated */ 48*a05577eaSEtienne Carriere uint32_t max_allocated; /* Tracks max value of allocated */ 49*a05577eaSEtienne Carriere uint32_t size; /* Total size for this allocator */ 50*a05577eaSEtienne Carriere uint32_t num_alloc_fail; /* Number of failed alloc requests */ 51*a05577eaSEtienne Carriere uint32_t biggest_alloc_fail; /* Size of biggest failed alloc */ 52*a05577eaSEtienne Carriere uint32_t biggest_alloc_fail_used; /* Alloc bytes when above occurred */ 53*a05577eaSEtienne Carriere }; 54*a05577eaSEtienne Carriere 55*a05577eaSEtienne Carriere /* 56*a05577eaSEtienne Carriere * STATS_CMD_MEMLEAK_STATS - Print memory leakage info to console 57*a05577eaSEtienne Carriere */ 58*a05577eaSEtienne Carriere #define STATS_CMD_MEMLEAK_STATS 2 59*a05577eaSEtienne Carriere 60*a05577eaSEtienne Carriere /* 61*a05577eaSEtienne Carriere * STATS_CMD_TA_STATS - Get information on TA instances 62*a05577eaSEtienne Carriere * 63*a05577eaSEtienne Carriere * [out] memref[0] Array of struct pta_stats_ta per loaded TA 64761fc6ecSEtienne Carriere */ 65761fc6ecSEtienne Carriere #define STATS_CMD_TA_STATS 3 66761fc6ecSEtienne Carriere 67*a05577eaSEtienne Carriere struct pta_stats_ta { 68*a05577eaSEtienne Carriere TEE_UUID uuid; 69*a05577eaSEtienne Carriere uint32_t panicked; /* True if TA has panicked */ 70*a05577eaSEtienne Carriere uint32_t sess_num; /* Number of opened session */ 71*a05577eaSEtienne Carriere struct pta_stats_alloc heap; 72*a05577eaSEtienne Carriere }; 73*a05577eaSEtienne Carriere 74761fc6ecSEtienne Carriere /* 75761fc6ecSEtienne Carriere * STATS_CMD_GET_TIME - Get both REE time and TEE time 76761fc6ecSEtienne Carriere * 77761fc6ecSEtienne Carriere * [out] value[0].a REE time as seen by OP-TEE in seconds 78761fc6ecSEtienne Carriere * [out] value[0].b REE time as seen by OP-TEE, milliseconds part 79761fc6ecSEtienne Carriere * [out] value[1].a TEE system time in seconds 80761fc6ecSEtienne Carriere * [out] value[1].b TEE system time, milliseconds part 81761fc6ecSEtienne Carriere */ 82761fc6ecSEtienne Carriere #define STATS_CMD_GET_TIME 4 83761fc6ecSEtienne Carriere 84761fc6ecSEtienne Carriere #endif /*__PTA_STATS_H*/ 85