| 1 |
/* |
| 2 |
* Copyright © 2021 Collabora, Ltd. |
| 3 |
* SPDX-License-Identifier: MIT |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef PAN_PERF_H |
| 7 |
#define PAN_PERF_H |
| 8 |
|
| 9 |
#include <stdint.h> |
| 10 |
|
| 11 |
#if defined(__cplusplus) |
| 12 |
extern "C" { |
| 13 |
#endif |
| 14 |
|
| 15 |
#define PAN_PERF_MAX_CATEGORIES 4 |
| 16 |
#define PAN_PERF_MAX_COUNTERS 64 |
| 17 |
|
| 18 |
struct pan_kmod_dev; |
| 19 |
struct pan_kmod_dev_props; |
| 20 |
struct pan_model; |
| 21 |
struct pan_perf_category; |
| 22 |
struct pan_perf; |
| 23 |
|
| 24 |
enum pan_perf_counter_units { |
| 25 |
PAN_PERF_COUNTER_UNITS_CYCLES, |
| 26 |
PAN_PERF_COUNTER_UNITS_JOBS, |
| 27 |
PAN_PERF_COUNTER_UNITS_TASKS, |
| 28 |
PAN_PERF_COUNTER_UNITS_PRIMITIVES, |
| 29 |
PAN_PERF_COUNTER_UNITS_BEATS, |
| 30 |
PAN_PERF_COUNTER_UNITS_REQUESTS, |
| 31 |
PAN_PERF_COUNTER_UNITS_WARPS, |
| 32 |
PAN_PERF_COUNTER_UNITS_QUADS, |
| 33 |
PAN_PERF_COUNTER_UNITS_TILES, |
| 34 |
PAN_PERF_COUNTER_UNITS_INSTRUCTIONS, |
| 35 |
PAN_PERF_COUNTER_UNITS_TRANSACTIONS, |
| 36 |
PAN_PERF_COUNTER_UNITS_THREADS, |
| 37 |
PAN_PERF_COUNTER_UNITS_BYTES, |
| 38 |
PAN_PERF_COUNTER_UNITS_PIXELS, |
| 39 |
PAN_PERF_COUNTER_UNITS_ISSUES, |
| 40 |
}; |
| 41 |
|
| 42 |
struct pan_perf_counter { |
| 43 |
const char *name; |
| 44 |
const char *desc; |
| 45 |
const char *symbol_name; |
| 46 |
enum pan_perf_counter_units units; |
| 47 |
// Offset of this counter's value within the category |
| 48 |
uint32_t offset; |
| 49 |
unsigned category_index; |
| 50 |
}; |
| 51 |
|
| 52 |
struct pan_perf_category { |
| 53 |
const char *name; |
| 54 |
|
| 55 |
struct pan_perf_counter counters[PAN_PERF_MAX_COUNTERS]; |
| 56 |
uint32_t n_counters; |
| 57 |
|
| 58 |
/* Offset of this category within the counters memory block */ |
| 59 |
unsigned offset; |
| 60 |
}; |
| 61 |
|
| 62 |
struct pan_perf_config { |
| 63 |
const char *name; |
| 64 |
|
| 65 |
struct pan_perf_category categories[PAN_PERF_MAX_CATEGORIES]; |
| 66 |
uint32_t n_categories; |
| 67 |
}; |
| 68 |
|
| 69 |
struct pan_perf { |
| 70 |
struct pan_kmod_dev *dev; |
| 71 |
unsigned core_id_range; |
| 72 |
const struct pan_perf_config *cfg; |
| 73 |
|
| 74 |
// Memory where to dump counter values |
| 75 |
uint32_t *counter_values; |
| 76 |
uint32_t n_counter_values; |
| 77 |
|
| 78 |
/* Offsets of categories */ |
| 79 |
unsigned category_offset[PAN_PERF_MAX_CATEGORIES]; |
| 80 |
}; |
| 81 |
|
| 82 |
uint32_t pan_perf_counter_read(const struct pan_perf_counter *counter, |
| 83 |
const struct pan_perf *perf); |
| 84 |
|
| 85 |
void pan_perf_init(struct pan_perf *perf, int fd); |
| 86 |
|
| 87 |
int pan_perf_enable(struct pan_perf *perf); |
| 88 |
|
| 89 |
int pan_perf_disable(struct pan_perf *perf); |
| 90 |
|
| 91 |
int pan_perf_dump(struct pan_perf *perf); |
| 92 |
|
| 93 |
#if defined(__cplusplus) |
| 94 |
} // extern "C" |
| 95 |
#endif |
| 96 |
|
| 97 |
#endif // PAN_PERF_H |