1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2021 Collabora, Ltd. 3bf215546Sopenharmony_ci * Author: Antonio Caggiano <antonio.caggiano@collabora.com> 4bf215546Sopenharmony_ci * 5bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy 6bf215546Sopenharmony_ci * of this software and associated documentation files (the "Software"), to deal 7bf215546Sopenharmony_ci * in the Software without restriction, including without limitation the rights 8bf215546Sopenharmony_ci * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9bf215546Sopenharmony_ci * copies of the Software, and to permit persons to whom the Software is 10bf215546Sopenharmony_ci * furnished to do so, subject to the following conditions: 11bf215546Sopenharmony_ci * 12bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 13bf215546Sopenharmony_ci * all copies or substantial portions of the Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18bf215546Sopenharmony_ci * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21bf215546Sopenharmony_ci * THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#ifndef PAN_PERF_H 25bf215546Sopenharmony_ci#define PAN_PERF_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include <stdint.h> 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#if defined(__cplusplus) 30bf215546Sopenharmony_ciextern "C" { 31bf215546Sopenharmony_ci#endif 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_ci#define PAN_PERF_MAX_CATEGORIES 4 34bf215546Sopenharmony_ci#define PAN_PERF_MAX_COUNTERS 64 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_cistruct panfrost_device; 37bf215546Sopenharmony_cistruct panfrost_perf_category; 38bf215546Sopenharmony_cistruct panfrost_perf; 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_cienum panfrost_perf_counter_units { 41bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_CYCLES, 42bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_JOBS, 43bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_TASKS, 44bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_PRIMITIVES, 45bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_BEATS, 46bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_REQUESTS, 47bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_WARPS, 48bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_QUADS, 49bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_TILES, 50bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_INSTRUCTIONS, 51bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_TRANSACTIONS, 52bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_THREADS, 53bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_BYTES, 54bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_PIXELS, 55bf215546Sopenharmony_ci PAN_PERF_COUNTER_UNITS_ISSUES, 56bf215546Sopenharmony_ci}; 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_cistruct panfrost_perf_counter { 59bf215546Sopenharmony_ci const char *name; 60bf215546Sopenharmony_ci const char *desc; 61bf215546Sopenharmony_ci const char *symbol_name; 62bf215546Sopenharmony_ci enum panfrost_perf_counter_units units; 63bf215546Sopenharmony_ci // Offset of this counter's value within the category 64bf215546Sopenharmony_ci uint32_t offset; 65bf215546Sopenharmony_ci unsigned category_index; 66bf215546Sopenharmony_ci}; 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_cistruct panfrost_perf_category { 69bf215546Sopenharmony_ci const char *name; 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci struct panfrost_perf_counter counters[PAN_PERF_MAX_COUNTERS]; 72bf215546Sopenharmony_ci uint32_t n_counters; 73bf215546Sopenharmony_ci 74bf215546Sopenharmony_ci /* Offset of this category within the counters memory block */ 75bf215546Sopenharmony_ci unsigned offset; 76bf215546Sopenharmony_ci}; 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_cistruct panfrost_perf_config { 79bf215546Sopenharmony_ci const char *name; 80bf215546Sopenharmony_ci 81bf215546Sopenharmony_ci struct panfrost_perf_category categories[PAN_PERF_MAX_CATEGORIES]; 82bf215546Sopenharmony_ci uint32_t n_categories; 83bf215546Sopenharmony_ci}; 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_cistruct panfrost_perf { 86bf215546Sopenharmony_ci struct panfrost_device *dev; 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_ci const struct panfrost_perf_config* cfg; 89bf215546Sopenharmony_ci 90bf215546Sopenharmony_ci // Memory where to dump counter values 91bf215546Sopenharmony_ci uint32_t *counter_values; 92bf215546Sopenharmony_ci uint32_t n_counter_values; 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_ci /* Offsets of categories */ 95bf215546Sopenharmony_ci unsigned category_offset[PAN_PERF_MAX_CATEGORIES]; 96bf215546Sopenharmony_ci}; 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_ciuint32_t 99bf215546Sopenharmony_cipanfrost_perf_counter_read(const struct panfrost_perf_counter *counter, 100bf215546Sopenharmony_ci const struct panfrost_perf *perf); 101bf215546Sopenharmony_ci 102bf215546Sopenharmony_civoid 103bf215546Sopenharmony_cipanfrost_perf_init(struct panfrost_perf *perf, struct panfrost_device *dev); 104bf215546Sopenharmony_ci 105bf215546Sopenharmony_ciint 106bf215546Sopenharmony_cipanfrost_perf_enable(struct panfrost_perf *perf); 107bf215546Sopenharmony_ci 108bf215546Sopenharmony_ciint 109bf215546Sopenharmony_cipanfrost_perf_disable(struct panfrost_perf *perf); 110bf215546Sopenharmony_ci 111bf215546Sopenharmony_ciint 112bf215546Sopenharmony_cipanfrost_perf_dump(struct panfrost_perf *perf); 113bf215546Sopenharmony_ci 114bf215546Sopenharmony_ci#if defined(__cplusplus) 115bf215546Sopenharmony_ci} // extern "C" 116bf215546Sopenharmony_ci#endif 117bf215546Sopenharmony_ci 118bf215546Sopenharmony_ci#endif // PAN_PERF_H 119