1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #include "req-gen/_begin.h"
4 
5 /*
6  * Based on the document "getPerfCountInfo v1.07"
7  */
8 
9 /*
10  * #define REQUEST_NAME counter_request_name
11  * #define REQUEST_NUM r_num
12  * #define REQUEST_IDX_KIND starting_index_kind
13  * #include I(REQUEST_BEGIN)
14  * REQUEST(
15  *	__field(...)
16  *	__field(...)
17  *	__array(...)
18  *	__count(...)
19  * )
20  * #include I(REQUEST_END)
21  *
22  * - starting_index_kind is one of the following, depending on the event:
23  *
24  *   hw_chip_id: hardware chip id or -1 for current hw chip
25  *   partition_id
26  *   sibling_part_id,
27  *   phys_processor_idx:
28  *   0xffffffffffffffff: or -1, which means it is irrelavant for the event
29  *
30  * __count(offset, bytes, name):
31  *	a counter that should be exposed via perf
32  * __field(offset, bytes, name)
33  *	a normal field
34  * __array(offset, bytes, name)
35  *	an array of bytes
36  *
37  *
38  *	@bytes for __count, and __field _must_ be a numeral token
39  *	in decimal, not an expression and not in hex.
40  *
41  *
42  * TODO:
43  *	- expose secondary index (if any counter ever uses it, only 0xA0
44  *	  appears to use it right now, and it doesn't have any counters)
45  *	- embed versioning info
46  *	- include counter descriptions
47  */
48 #define REQUEST_NAME dispatch_timebase_by_processor
49 #define REQUEST_NUM 0x10
50 #define REQUEST_IDX_KIND "phys_processor_idx=?"
51 #include I(REQUEST_BEGIN)
52 REQUEST(__count(0,	8,	processor_time_in_timebase_cycles)
53 	__field(0x8,	4,	hw_processor_id)
54 	__field(0xC,	2,	owning_part_id)
55 	__field(0xE,	1,	processor_state)
56 	__field(0xF,	1,	version)
57 	__field(0x10,	4,	hw_chip_id)
58 	__field(0x14,	4,	phys_module_id)
59 	__field(0x18,	4,	primary_affinity_domain_idx)
60 	__field(0x1C,	4,	secondary_affinity_domain_idx)
61 	__field(0x20,	4,	processor_version)
62 	__field(0x24,	2,	logical_processor_idx)
63 	__field(0x26,	2,	reserved)
64 	__field(0x28,	4,	processor_id_register)
65 	__field(0x2C,	4,	phys_processor_idx)
66 )
67 #include I(REQUEST_END)
68 
69 #define REQUEST_NAME entitled_capped_uncapped_donated_idle_timebase_by_partition
70 #define REQUEST_NUM 0x20
71 #define REQUEST_IDX_KIND "sibling_part_id=?"
72 #include I(REQUEST_BEGIN)
73 REQUEST(__field(0,	8,	partition_id)
74 	__count(0x8,	8,	entitled_cycles)
75 	__count(0x10,	8,	consumed_capped_cycles)
76 	__count(0x18,	8,	consumed_uncapped_cycles)
77 	__count(0x20,	8,	cycles_donated)
78 	__count(0x28,	8,	purr_idle_cycles)
79 )
80 #include I(REQUEST_END)
81 
82 /*
83  * Not available for counter_info_version >= 0x8, use
84  * run_instruction_cycles_by_partition(0x100) instead.
85  */
86 #define REQUEST_NAME run_instructions_run_cycles_by_partition
87 #define REQUEST_NUM 0x30
88 #define REQUEST_IDX_KIND "sibling_part_id=?"
89 #include I(REQUEST_BEGIN)
90 REQUEST(__field(0,	8,	partition_id)
91 	__count(0x8,	8,	instructions_completed)
92 	__count(0x10,	8,	cycles)
93 )
94 #include I(REQUEST_END)
95 
96 #define REQUEST_NAME system_performance_capabilities
97 #define REQUEST_NUM 0x40
98 #define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff"
99 #include I(REQUEST_BEGIN)
100 REQUEST(__field(0,	1,	perf_collect_privileged)
101 	__field(0x1,	1,	capability_mask)
102 	__array(0x2,	0xE,	reserved)
103 )
104 #include I(REQUEST_END)
105 
106 #define REQUEST_NAME processor_bus_utilization_abc_links
107 #define REQUEST_NUM 0x50
108 #define REQUEST_IDX_KIND "hw_chip_id=?"
109 #include I(REQUEST_BEGIN)
110 REQUEST(__field(0,	4,	hw_chip_id)
111 	__array(0x4,	0xC,	reserved1)
112 	__count(0x10,	8,	total_link_cycles)
113 	__count(0x18,	8,	idle_cycles_for_a_link)
114 	__count(0x20,	8,	idle_cycles_for_b_link)
115 	__count(0x28,	8,	idle_cycles_for_c_link)
116 	__array(0x30,	0x20,	reserved2)
117 )
118 #include I(REQUEST_END)
119 
120 #define REQUEST_NAME processor_bus_utilization_wxyz_links
121 #define REQUEST_NUM 0x60
122 #define REQUEST_IDX_KIND "hw_chip_id=?"
123 #include I(REQUEST_BEGIN)
124 REQUEST(__field(0,	4,	hw_chip_id)
125 	__array(0x4,	0xC,	reserved1)
126 	__count(0x10,	8,	total_link_cycles)
127 	__count(0x18,	8,	idle_cycles_for_w_link)
128 	__count(0x20,	8,	idle_cycles_for_x_link)
129 	__count(0x28,	8,	idle_cycles_for_y_link)
130 	__count(0x30,	8,	idle_cycles_for_z_link)
131 	__array(0x38,	0x28,	reserved2)
132 )
133 #include I(REQUEST_END)
134 
135 #define REQUEST_NAME processor_bus_utilization_gx_links
136 #define REQUEST_NUM 0x70
137 #define REQUEST_IDX_KIND "hw_chip_id=?"
138 #include I(REQUEST_BEGIN)
139 REQUEST(__field(0,	4,	hw_chip_id)
140 	__array(0x4,	0xC,	reserved1)
141 	__count(0x10,	8,	gx0_in_address_cycles)
142 	__count(0x18,	8,	gx0_in_data_cycles)
143 	__count(0x20,	8,	gx0_in_retries)
144 	__count(0x28,	8,	gx0_in_bus_cycles)
145 	__count(0x30,	8,	gx0_in_cycles_total)
146 	__count(0x38,	8,	gx0_out_address_cycles)
147 	__count(0x40,	8,	gx0_out_data_cycles)
148 	__count(0x48,	8,	gx0_out_retries)
149 	__count(0x50,	8,	gx0_out_bus_cycles)
150 	__count(0x58,	8,	gx0_out_cycles_total)
151 	__count(0x60,	8,	gx1_in_address_cycles)
152 	__count(0x68,	8,	gx1_in_data_cycles)
153 	__count(0x70,	8,	gx1_in_retries)
154 	__count(0x78,	8,	gx1_in_bus_cycles)
155 	__count(0x80,	8,	gx1_in_cycles_total)
156 	__count(0x88,	8,	gx1_out_address_cycles)
157 	__count(0x90,	8,	gx1_out_data_cycles)
158 	__count(0x98,	8,	gx1_out_retries)
159 	__count(0xA0,	8,	gx1_out_bus_cycles)
160 	__count(0xA8,	8,	gx1_out_cycles_total)
161 )
162 #include I(REQUEST_END)
163 
164 #define REQUEST_NAME processor_bus_utilization_mc_links
165 #define REQUEST_NUM 0x80
166 #define REQUEST_IDX_KIND "hw_chip_id=?"
167 #include I(REQUEST_BEGIN)
168 REQUEST(__field(0,	4,	hw_chip_id)
169 	__array(0x4,	0xC,	reserved1)
170 	__count(0x10,	8,	mc0_frames)
171 	__count(0x18,	8,	mc0_reads)
172 	__count(0x20,	8,	mc0_write)
173 	__count(0x28,	8,	mc0_total_cycles)
174 	__count(0x30,	8,	mc1_frames)
175 	__count(0x38,	8,	mc1_reads)
176 	__count(0x40,	8,	mc1_writes)
177 	__count(0x48,	8,	mc1_total_cycles)
178 )
179 #include I(REQUEST_END)
180 
181 /* Processor_config (0x90) skipped, no counters */
182 /* Current_processor_frequency (0x91) skipped, no counters */
183 
184 #define REQUEST_NAME processor_core_utilization
185 #define REQUEST_NUM 0x94
186 #define REQUEST_IDX_KIND "phys_processor_idx=?"
187 #include I(REQUEST_BEGIN)
188 REQUEST(__field(0,	4,	phys_processor_idx)
189 	__field(0x4,	4,	hw_processor_id)
190 	__count(0x8,	8,	cycles_across_any_thread)
191 	__count(0x10,	8,	timebase_at_collection)
192 	__count(0x18,	8,	purr_cycles)
193 	__count(0x20,	8,	sum_of_cycles_across_all_threads)
194 	__count(0x28,	8,	instructions_completed)
195 )
196 #include I(REQUEST_END)
197 
198 /* Processor_core_power_mode (0x95) skipped, no counters */
199 /* Affinity_domain_information_by_virtual_processor (0xA0) skipped,
200  *	no counters */
201 /* Affinity_domain_information_by_domain (0xB0) skipped, no counters */
202 /* Affinity_domain_information_by_partition (0xB1) skipped, no counters */
203 /* Physical_memory_info (0xC0) skipped, no counters */
204 /* Processor_bus_topology (0xD0) skipped, no counters */
205 
206 #define REQUEST_NAME partition_hypervisor_queuing_times
207 #define REQUEST_NUM 0xE0
208 #define REQUEST_IDX_KIND "partition_id=?"
209 #include I(REQUEST_BEGIN)
210 REQUEST(__field(0,	2, partition_id)
211 	__array(0x2,	6, reserved1)
212 	__count(0x8,	8, time_waiting_for_entitlement)
213 	__count(0x10,	8, times_waited_for_entitlement)
214 	__count(0x18,	8, time_waiting_for_phys_processor)
215 	__count(0x20,	8, times_waited_for_phys_processor)
216 	__count(0x28,	8, dispatches_on_home_core)
217 	__count(0x30,	8, dispatches_on_home_primary_affinity_domain)
218 	__count(0x38,	8, dispatches_on_home_secondary_affinity_domain)
219 	__count(0x40,	8, dispatches_off_home_secondary_affinity_domain)
220 	__count(0x48,	8, dispatches_on_dedicated_processor_donating_cycles)
221 )
222 #include I(REQUEST_END)
223 
224 #define REQUEST_NAME system_hypervisor_times
225 #define REQUEST_NUM 0xF0
226 #define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff"
227 #include I(REQUEST_BEGIN)
228 REQUEST(__count(0,	8,	time_spent_to_dispatch_virtual_processors)
229 	__count(0x8,	8,	time_spent_processing_virtual_processor_timers)
230 	__count(0x10,	8,	time_spent_managing_partitions_over_entitlement)
231 	__count(0x18,	8,	time_spent_on_system_management)
232 )
233 #include I(REQUEST_END)
234 
235 #define REQUEST_NAME system_tlbie_count_and_time
236 #define REQUEST_NUM 0xF4
237 #define REQUEST_IDX_KIND "starting_index=0xffffffffffffffff"
238 #include I(REQUEST_BEGIN)
239 REQUEST(__count(0,	8,	tlbie_instructions_issued)
240 	/*
241 	 * FIXME: The spec says the offset here is 0x10, which I suspect
242 	 *	  is wrong.
243 	 */
244 	__count(0x8,	8,	time_spent_issuing_tlbies)
245 )
246 #include I(REQUEST_END)
247 
248 #define REQUEST_NAME partition_instruction_count_and_time
249 #define REQUEST_NUM 0x100
250 #define REQUEST_IDX_KIND "partition_id=?"
251 #include I(REQUEST_BEGIN)
252 REQUEST(__field(0,	2,	partition_id)
253 	__array(0x2,	0x6,	reserved1)
254 	__count(0x8,	8,	instructions_performed)
255 	__count(0x10,	8,	time_collected)
256 )
257 #include I(REQUEST_END)
258 
259 /* set_mmcrh (0x80001000) skipped, no counters */
260 /* retrieve_hpmcx (0x80002000) skipped, no counters */
261 
262 #include "req-gen/_end.h"
263