xref: /linux/include/uapi/linux/isst_if.h (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  * Intel Speed Select Interface: OS to hardware Interface
4  * Copyright (c) 2019, Intel Corporation.
5  * All rights reserved.
6  *
7  * Author: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
8  */
9 
10 #ifndef __ISST_IF_H
11 #define __ISST_IF_H
12 
13 #include <linux/types.h>
14 
15 /**
16  * struct isst_if_platform_info - Define platform information
17  * @api_version:	Version of the firmware document, which this driver
18  *			can communicate
19  * @driver_version:	Driver version, which will help user to send right
20  *			commands. Even if the firmware is capable, driver may
21  *			not be ready
22  * @max_cmds_per_ioctl:	Returns the maximum number of commands driver will
23  *			accept in a single ioctl
24  * @mbox_supported:	Support of mail box interface
25  * @mmio_supported:	Support of mmio interface for core-power feature
26  *
27  * Used to return output of IOCTL ISST_IF_GET_PLATFORM_INFO. This
28  * information can be used by the user space, to get the driver, firmware
29  * support and also number of commands to send in a single IOCTL request.
30  */
31 struct isst_if_platform_info {
32 	__u16 api_version;
33 	__u16 driver_version;
34 	__u16 max_cmds_per_ioctl;
35 	__u8 mbox_supported;
36 	__u8 mmio_supported;
37 };
38 
39 /**
40  * struct isst_if_cpu_map - CPU mapping between logical and physical CPU
41  * @logical_cpu:	Linux logical CPU number
42  * @physical_cpu:	PUNIT CPU number
43  *
44  * Used to convert from Linux logical CPU to PUNIT CPU numbering scheme.
45  * The PUNIT CPU number is different than APIC ID based CPU numbering.
46  */
47 struct isst_if_cpu_map {
48 	__u32 logical_cpu;
49 	__u32 physical_cpu;
50 };
51 
52 /**
53  * struct isst_if_cpu_maps - structure for CPU map IOCTL
54  * @cmd_count:	Number of CPU mapping command in cpu_map[]
55  * @cpu_map[]:	Holds one or more CPU map data structure
56  *
57  * This structure used with ioctl ISST_IF_GET_PHY_ID to send
58  * one or more CPU mapping commands. Here IOCTL return value indicates
59  * number of commands sent or error number if no commands have been sent.
60  */
61 struct isst_if_cpu_maps {
62 	__u32 cmd_count;
63 	struct isst_if_cpu_map cpu_map[1];
64 };
65 
66 /**
67  * struct isst_if_io_reg - Read write PUNIT IO register
68  * @read_write:		Value 0: Read, 1: Write
69  * @logical_cpu:	Logical CPU number to get target PCI device.
70  * @reg:		PUNIT register offset
71  * @value:		For write operation value to write and for
72  *			read placeholder read value
73  *
74  * Structure to specify read/write data to PUNIT registers.
75  */
76 struct isst_if_io_reg {
77 	__u32 read_write; /* Read:0, Write:1 */
78 	__u32 logical_cpu;
79 	__u32 reg;
80 	__u32 value;
81 };
82 
83 /**
84  * struct isst_if_io_regs - structure for IO register commands
85  * @cmd_count:	Number of io reg commands in io_reg[]
86  * @io_reg[]:	Holds one or more io_reg command structure
87  *
88  * This structure used with ioctl ISST_IF_IO_CMD to send
89  * one or more read/write commands to PUNIT. Here IOCTL return value
90  * indicates number of requests sent or error number if no requests have
91  * been sent.
92  */
93 struct isst_if_io_regs {
94 	__u32 req_count;
95 	struct isst_if_io_reg io_reg[1];
96 };
97 
98 /**
99  * struct isst_if_mbox_cmd - Structure to define mail box command
100  * @logical_cpu:	Logical CPU number to get target PCI device
101  * @parameter:		Mailbox parameter value
102  * @req_data:		Request data for the mailbox
103  * @resp_data:		Response data for mailbox command response
104  * @command:		Mailbox command value
105  * @sub_command:	Mailbox sub command value
106  * @reserved:		Unused, set to 0
107  *
108  * Structure to specify mailbox command to be sent to PUNIT.
109  */
110 struct isst_if_mbox_cmd {
111 	__u32 logical_cpu;
112 	__u32 parameter;
113 	__u32 req_data;
114 	__u32 resp_data;
115 	__u16 command;
116 	__u16 sub_command;
117 	__u32 reserved;
118 };
119 
120 /**
121  * struct isst_if_mbox_cmds - structure for mailbox commands
122  * @cmd_count:	Number of mailbox commands in mbox_cmd[]
123  * @mbox_cmd[]:	Holds one or more mbox commands
124  *
125  * This structure used with ioctl ISST_IF_MBOX_COMMAND to send
126  * one or more mailbox commands to PUNIT. Here IOCTL return value
127  * indicates number of commands sent or error number if no commands have
128  * been sent.
129  */
130 struct isst_if_mbox_cmds {
131 	__u32 cmd_count;
132 	struct isst_if_mbox_cmd mbox_cmd[1];
133 };
134 
135 /**
136  * struct isst_if_msr_cmd - Structure to define msr command
137  * @read_write:		Value 0: Read, 1: Write
138  * @logical_cpu:	Logical CPU number
139  * @msr:		MSR number
140  * @data:		For write operation, data to write, for read
141  *			place holder
142  *
143  * Structure to specify MSR command related to PUNIT.
144  */
145 struct isst_if_msr_cmd {
146 	__u32 read_write; /* Read:0, Write:1 */
147 	__u32 logical_cpu;
148 	__u64 msr;
149 	__u64 data;
150 };
151 
152 /**
153  * struct isst_if_msr_cmds - structure for msr commands
154  * @cmd_count:	Number of mailbox commands in msr_cmd[]
155  * @msr_cmd[]:	Holds one or more msr commands
156  *
157  * This structure used with ioctl ISST_IF_MSR_COMMAND to send
158  * one or more MSR commands. IOCTL return value indicates number of
159  * commands sent or error number if no commands have been sent.
160  */
161 struct isst_if_msr_cmds {
162 	__u32 cmd_count;
163 	struct isst_if_msr_cmd msr_cmd[1];
164 };
165 
166 /**
167  * struct isst_core_power - Structure to get/set core_power feature
168  * @get_set:	0: Get, 1: Set
169  * @socket_id:	Socket/package id
170  * @power_domain: Power Domain id
171  * @enable:	Feature enable status
172  * @priority_type: Priority type for the feature (ordered/proportional)
173  *
174  * Structure to get/set core_power feature state using IOCTL
175  * ISST_IF_CORE_POWER_STATE.
176  */
177 struct isst_core_power {
178 	__u8 get_set;
179 	__u8 socket_id;
180 	__u8 power_domain_id;
181 	__u8 enable;
182 	__u8 supported;
183 	__u8 priority_type;
184 };
185 
186 /**
187  * struct isst_clos_param - Structure to get/set clos praram
188  * @get_set:	0: Get, 1: Set
189  * @socket_id:	Socket/package id
190  * @power_domain:	Power Domain id
191  * clos:	Clos ID for the parameters
192  * min_freq_mhz: Minimum frequency in MHz
193  * max_freq_mhz: Maximum frequency in MHz
194  * prop_prio:	Proportional priority from 0-15
195  *
196  * Structure to get/set per clos property using IOCTL
197  * ISST_IF_CLOS_PARAM.
198  */
199 struct isst_clos_param {
200 	__u8 get_set;
201 	__u8 socket_id;
202 	__u8 power_domain_id;
203 	__u8 clos;
204 	__u16 min_freq_mhz;
205 	__u16 max_freq_mhz;
206 	__u8 prop_prio;
207 };
208 
209 /**
210  * struct isst_if_clos_assoc - Structure to assign clos to a CPU
211  * @socket_id:	Socket/package id
212  * @power_domain:	Power Domain id
213  * @logical_cpu: CPU number
214  * @clos:	Clos ID to assign to the logical CPU
215  *
216  * Structure to get/set core_power feature.
217  */
218 struct isst_if_clos_assoc {
219 	__u8 socket_id;
220 	__u8 power_domain_id;
221 	__u16 logical_cpu;
222 	__u16 clos;
223 };
224 
225 /**
226  * struct isst_if_clos_assoc_cmds - Structure to assign clos to CPUs
227  * @cmd_count:	Number of cmds (cpus) in this request
228  * @get_set:	Request is for get or set
229  * @punit_cpu_map: Set to 1 if the CPU number is punit numbering not
230  *		   Linux CPU number
231  *
232  * Structure used to get/set associate CPUs to clos using IOCTL
233  * ISST_IF_CLOS_ASSOC.
234  */
235 struct isst_if_clos_assoc_cmds {
236 	__u16 cmd_count;
237 	__u16 get_set;
238 	__u16 punit_cpu_map;
239 	struct isst_if_clos_assoc assoc_info[1];
240 };
241 
242 /**
243  * struct isst_tpmi_instance_count - Get number of TPMI instances per socket
244  * @socket_id:	Socket/package id
245  * @count:	Number of instances
246  * @valid_mask: Mask of instances as there can be holes
247  *
248  * Structure used to get TPMI instances information using
249  * IOCTL ISST_IF_COUNT_TPMI_INSTANCES.
250  */
251 struct isst_tpmi_instance_count {
252 	__u8 socket_id;
253 	__u8 count;
254 	__u16 valid_mask;
255 };
256 
257 /**
258  * struct isst_perf_level_info - Structure to get information on SST-PP levels
259  * @socket_id:	Socket/package id
260  * @power_domain:	Power Domain id
261  * @logical_cpu: CPU number
262  * @clos:	Clos ID to assign to the logical CPU
263  * @max_level: Maximum performance level supported by the platform
264  * @feature_rev: The feature revision for SST-PP supported by the platform
265  * @level_mask: Mask of supported performance levels
266  * @current_level: Current performance level
267  * @feature_state: SST-BF and SST-TF (enabled/disabled) status at current level
268  * @locked: SST-PP performance level change is locked/unlocked
269  * @enabled: SST-PP feature is enabled or not
270  * @sst-tf_support: SST-TF support status at this level
271  * @sst-bf_support: SST-BF support status at this level
272  *
273  * Structure to get SST-PP details using IOCTL ISST_IF_PERF_LEVELS.
274  */
275 struct isst_perf_level_info {
276 	__u8 socket_id;
277 	__u8 power_domain_id;
278 	__u8 max_level;
279 	__u8 feature_rev;
280 	__u8 level_mask;
281 	__u8 current_level;
282 	__u8 feature_state;
283 	__u8 locked;
284 	__u8 enabled;
285 	__u8 sst_tf_support;
286 	__u8 sst_bf_support;
287 };
288 
289 /**
290  * struct isst_perf_level_control - Structure to set SST-PP level
291  * @socket_id:	Socket/package id
292  * @power_domain:	Power Domain id
293  * @level:	level to set
294  *
295  * Structure used change SST-PP level using IOCTL ISST_IF_PERF_SET_LEVEL.
296  */
297 struct isst_perf_level_control {
298 	__u8 socket_id;
299 	__u8 power_domain_id;
300 	__u8 level;
301 };
302 
303 /**
304  * struct isst_perf_feature_control - Structure to activate SST-BF/SST-TF
305  * @socket_id:	Socket/package id
306  * @power_domain:	Power Domain id
307  * @feature:	bit 0 = SST-BF state, bit 1 = SST-TF state
308  *
309  * Structure used to enable SST-BF/SST-TF using IOCTL ISST_IF_PERF_SET_FEATURE.
310  */
311 struct isst_perf_feature_control {
312 	__u8 socket_id;
313 	__u8 power_domain_id;
314 	__u8 feature;
315 };
316 
317 #define TRL_MAX_BUCKETS	8
318 #define TRL_MAX_LEVELS		6
319 
320 /**
321  * struct isst_perf_level_data_info - Structure to get SST-PP level details
322  * @socket_id:	Socket/package id
323  * @power_domain:	Power Domain id
324  * @level:	SST-PP level for which caller wants to get information
325  * @tdp_ratio: TDP Ratio
326  * @base_freq_mhz: Base frequency in MHz
327  * @base_freq_avx2_mhz: AVX2 Base frequency in MHz
328  * @base_freq_avx512_mhz: AVX512 base frequency in MHz
329  * @base_freq_amx_mhz: AMX base frequency in MHz
330  * @thermal_design_power_w: Thermal design (TDP) power
331  * @tjunction_max_c: Max junction temperature
332  * @max_memory_freq_mhz: Max memory frequency in MHz
333  * @cooling_type: Type of cooling is used
334  * @p0_freq_mhz: core maximum frequency
335  * @p1_freq_mhz: Core TDP frequency
336  * @pn_freq_mhz: Core maximum efficiency frequency
337  * @pm_freq_mhz: Core minimum frequency
338  * @p0_fabric_freq_mhz: Fabric (Uncore) maximum frequency
339  * @p1_fabric_freq_mhz: Fabric (Uncore) TDP frequency
340  * @pn_fabric_freq_mhz: Fabric (Uncore) minimum efficiency frequency
341  * @pm_fabric_freq_mhz: Fabric (Uncore) minimum frequency
342  * @max_buckets: Maximum trl buckets
343  * @max_trl_levels: Maximum trl levels
344  * @bucket_core_counts[TRL_MAX_BUCKETS]: Number of cores per bucket
345  * @trl_freq_mhz[TRL_MAX_LEVELS][TRL_MAX_BUCKETS]: maximum frequency
346  * for a bucket and trl level
347  *
348  * Structure used to get information on frequencies and TDP for a SST-PP
349  * level using ISST_IF_GET_PERF_LEVEL_INFO.
350  */
351 struct isst_perf_level_data_info {
352 	__u8 socket_id;
353 	__u8 power_domain_id;
354 	__u16 level;
355 	__u16 tdp_ratio;
356 	__u16 base_freq_mhz;
357 	__u16 base_freq_avx2_mhz;
358 	__u16 base_freq_avx512_mhz;
359 	__u16 base_freq_amx_mhz;
360 	__u16 thermal_design_power_w;
361 	__u16 tjunction_max_c;
362 	__u16 max_memory_freq_mhz;
363 	__u16 cooling_type;
364 	__u16 p0_freq_mhz;
365 	__u16 p1_freq_mhz;
366 	__u16 pn_freq_mhz;
367 	__u16 pm_freq_mhz;
368 	__u16 p0_fabric_freq_mhz;
369 	__u16 p1_fabric_freq_mhz;
370 	__u16 pn_fabric_freq_mhz;
371 	__u16 pm_fabric_freq_mhz;
372 	__u16 max_buckets;
373 	__u16 max_trl_levels;
374 	__u16 bucket_core_counts[TRL_MAX_BUCKETS];
375 	__u16 trl_freq_mhz[TRL_MAX_LEVELS][TRL_MAX_BUCKETS];
376 };
377 
378 /**
379  * struct isst_perf_level_cpu_mask - Structure to get SST-PP level CPU mask
380  * @socket_id:	Socket/package id
381  * @power_domain:	Power Domain id
382  * @level:	SST-PP level for which caller wants to get information
383  * @punit_cpu_map: Set to 1 if the CPU number is punit numbering not
384  *		   Linux CPU number. If 0 CPU buffer is copied to user space
385  *		   supplied cpu_buffer of size cpu_buffer_size. Punit
386  *		   cpu mask is copied to "mask" field.
387  * @mask:	cpu mask for this PP level (punit CPU numbering)
388  * @cpu_buffer_size: size of cpu_buffer also used to return the copied CPU
389  *		buffer size.
390  * @cpu_buffer:	Buffer to copy CPU mask when punit_cpu_map is 0
391  *
392  * Structure used to get cpumask for a SST-PP level using
393  * IOCTL ISST_IF_GET_PERF_LEVEL_CPU_MASK. Also used to get CPU mask for
394  * IOCTL ISST_IF_GET_BASE_FREQ_CPU_MASK for SST-BF.
395  */
396 struct isst_perf_level_cpu_mask {
397 	__u8 socket_id;
398 	__u8 power_domain_id;
399 	__u8 level;
400 	__u8 punit_cpu_map;
401 	__u64 mask;
402 	__u16 cpu_buffer_size;
403 	__s8 cpu_buffer[1];
404 };
405 
406 /**
407  * struct isst_base_freq_info - Structure to get SST-BF frequencies
408  * @socket_id:	Socket/package id
409  * @power_domain:	Power Domain id
410  * @level:	SST-PP level for which caller wants to get information
411  * @high_base_freq_mhz: High priority CPU base frequency
412  * @low_base_freq_mhz: Low priority CPU base frequency
413  * @tjunction_max_c: Max junction temperature
414  * @thermal_design_power_w: Thermal design power in watts
415  *
416  * Structure used to get SST-BF information using
417  * IOCTL ISST_IF_GET_BASE_FREQ_INFO.
418  */
419 struct isst_base_freq_info {
420 	__u8 socket_id;
421 	__u8 power_domain_id;
422 	__u16 level;
423 	__u16 high_base_freq_mhz;
424 	__u16 low_base_freq_mhz;
425 	__u16 tjunction_max_c;
426 	__u16 thermal_design_power_w;
427 };
428 
429 /**
430  * struct isst_turbo_freq_info - Structure to get SST-TF frequencies
431  * @socket_id:	Socket/package id
432  * @power_domain:	Power Domain id
433  * @level:	SST-PP level for which caller wants to get information
434  * @max_clip_freqs: Maximum number of low priority core clipping frequencies
435  * @lp_clip_freq_mhz: Clip frequencies per trl level
436  * @bucket_core_counts: Maximum number of cores for a bucket
437  * @trl_freq_mhz: Frequencies per trl level for each bucket
438  *
439  * Structure used to get SST-TF information using
440  * IOCTL ISST_IF_GET_TURBO_FREQ_INFO.
441  */
442 struct isst_turbo_freq_info {
443 	__u8 socket_id;
444 	__u8 power_domain_id;
445 	__u16 level;
446 	__u16 max_clip_freqs;
447 	__u16 max_buckets;
448 	__u16 max_trl_levels;
449 	__u16 lp_clip_freq_mhz[TRL_MAX_LEVELS];
450 	__u16 bucket_core_counts[TRL_MAX_BUCKETS];
451 	__u16 trl_freq_mhz[TRL_MAX_LEVELS][TRL_MAX_BUCKETS];
452 };
453 
454 #define ISST_IF_MAGIC			0xFE
455 #define ISST_IF_GET_PLATFORM_INFO	_IOR(ISST_IF_MAGIC, 0, struct isst_if_platform_info *)
456 #define ISST_IF_GET_PHY_ID		_IOWR(ISST_IF_MAGIC, 1, struct isst_if_cpu_map *)
457 #define ISST_IF_IO_CMD		_IOW(ISST_IF_MAGIC, 2, struct isst_if_io_regs *)
458 #define ISST_IF_MBOX_COMMAND	_IOWR(ISST_IF_MAGIC, 3, struct isst_if_mbox_cmds *)
459 #define ISST_IF_MSR_COMMAND	_IOWR(ISST_IF_MAGIC, 4, struct isst_if_msr_cmds *)
460 
461 #define ISST_IF_COUNT_TPMI_INSTANCES	_IOR(ISST_IF_MAGIC, 5, struct isst_tpmi_instance_count *)
462 #define ISST_IF_CORE_POWER_STATE _IOWR(ISST_IF_MAGIC, 6, struct isst_core_power *)
463 #define ISST_IF_CLOS_PARAM	_IOWR(ISST_IF_MAGIC, 7, struct isst_clos_param *)
464 #define ISST_IF_CLOS_ASSOC	_IOWR(ISST_IF_MAGIC, 8, struct isst_if_clos_assoc_cmds *)
465 
466 #define ISST_IF_PERF_LEVELS	_IOWR(ISST_IF_MAGIC, 9, struct isst_perf_level_info *)
467 #define ISST_IF_PERF_SET_LEVEL	_IOW(ISST_IF_MAGIC, 10, struct isst_perf_level_control *)
468 #define ISST_IF_PERF_SET_FEATURE _IOW(ISST_IF_MAGIC, 11, struct isst_perf_feature_control *)
469 #define ISST_IF_GET_PERF_LEVEL_INFO	_IOR(ISST_IF_MAGIC, 12, struct isst_perf_level_data_info *)
470 #define ISST_IF_GET_PERF_LEVEL_CPU_MASK	_IOR(ISST_IF_MAGIC, 13, struct isst_perf_level_cpu_mask *)
471 #define ISST_IF_GET_BASE_FREQ_INFO	_IOR(ISST_IF_MAGIC, 14, struct isst_base_freq_info *)
472 #define ISST_IF_GET_BASE_FREQ_CPU_MASK	_IOR(ISST_IF_MAGIC, 15, struct isst_perf_level_cpu_mask *)
473 #define ISST_IF_GET_TURBO_FREQ_INFO	_IOR(ISST_IF_MAGIC, 16, struct isst_turbo_freq_info *)
474 
475 #endif
476