freedreno/a6xx: Fix CP_BIN_SIZE_ADDRESS name
[mesa.git] / src / freedreno / perfcntrs / freedreno_perfcntr.h
1 /*
2 * Copyright (C) 2018 Rob Clark <robclark@freedesktop.org>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 * Authors:
24 * Rob Clark <robclark@freedesktop.org>
25 */
26
27 #ifndef FREEDRENO_PERFCNTR_H_
28 #define FREEDRENO_PERFCNTR_H_
29
30 /*
31 * Mapping very closely to the AMD_performance_monitor extension, adreno has
32 * groups of performance counters where each group has N counters, which can
33 * select from M different countables (things that can be counted), where
34 * generally M > N.
35 */
36
37 /* Describes a single counter: */
38 struct fd_perfcntr_counter {
39 /* offset of the select register to choose what to count: */
40 unsigned select_reg;
41 /* offset of the lo/hi 32b to read current counter value: */
42 unsigned counter_reg_lo;
43 unsigned counter_reg_hi;
44 /* Optional, most counters don't have enable/clear registers: */
45 unsigned enable;
46 unsigned clear;
47 };
48
49
50 enum fd_perfcntr_type {
51 FD_PERFCNTR_TYPE_UINT64,
52 FD_PERFCNTR_TYPE_UINT,
53 FD_PERFCNTR_TYPE_FLOAT,
54 FD_PERFCNTR_TYPE_PERCENTAGE,
55 FD_PERFCNTR_TYPE_BYTES,
56 FD_PERFCNTR_TYPE_MICROSECONDS,
57 FD_PERFCNTR_TYPE_HZ,
58 FD_PERFCNTR_TYPE_DBM,
59 FD_PERFCNTR_TYPE_TEMPERATURE,
60 FD_PERFCNTR_TYPE_VOLTS,
61 FD_PERFCNTR_TYPE_AMPS,
62 FD_PERFCNTR_TYPE_WATTS,
63 };
64
65 /* Whether an average value per frame or a cumulative value should be
66 * displayed.
67 */
68 enum fd_perfcntr_result_type {
69 FD_PERFCNTR_RESULT_TYPE_AVERAGE,
70 FD_PERFCNTR_RESULT_TYPE_CUMULATIVE,
71 };
72
73
74 /* Describes a single countable: */
75 struct fd_perfcntr_countable {
76 const char *name;
77 /* selector register enum value to select this countable: */
78 unsigned selector;
79
80 /* description of the countable: */
81 enum fd_perfcntr_type query_type;
82 enum fd_perfcntr_result_type result_type;
83 };
84
85 /* Describes an entire counter group: */
86 struct fd_perfcntr_group {
87 const char *name;
88 unsigned num_counters;
89 const struct fd_perfcntr_counter *counters;
90 unsigned num_countables;
91 const struct fd_perfcntr_countable *countables;
92 };
93
94 const struct fd_perfcntr_group *fd_perfcntrs(unsigned gpu_id, unsigned *count);
95
96 #define COUNTER(_sel, _lo, _hi) { \
97 .select_reg = REG(_sel), \
98 .counter_reg_lo = REG(_lo), \
99 .counter_reg_hi = REG(_hi), \
100 }
101
102 #define COUNTER2(_sel, _lo, _hi, _en, _clr) { \
103 .select_reg = REG(_sel), \
104 .counter_reg_lo = REG(_lo), \
105 .counter_reg_hi = REG(_hi), \
106 .enable = REG(_en), \
107 .clear = REG(_clr), \
108 }
109
110 #define COUNTABLE(_selector, _query_type, _result_type) { \
111 .name = #_selector, \
112 .selector = _selector, \
113 .query_type = FD_PERFCNTR_TYPE_ ## _query_type, \
114 .result_type = FD_PERFCNTR_RESULT_TYPE_ ## _result_type, \
115 }
116
117 #define GROUP(_name, _counters, _countables) { \
118 .name = _name, \
119 .num_counters = ARRAY_SIZE(_counters), \
120 .counters = _counters, \
121 .num_countables = ARRAY_SIZE(_countables), \
122 .countables = _countables, \
123 }
124
125 #endif /* FREEDRENO_PERFCNTR_H_ */