476 lines · c
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */2/*3 * Intel Speed Select Interface: OS to hardware Interface4 * 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_H11#define __ISST_IF_H12 13#include <linux/types.h>14 15/**16 * struct isst_if_platform_info - Define platform information17 * @api_version: Version of the firmware document, which this driver18 * can communicate19 * @driver_version: Driver version, which will help user to send right20 * commands. Even if the firmware is capable, driver may21 * not be ready22 * @max_cmds_per_ioctl: Returns the maximum number of commands driver will23 * accept in a single ioctl24 * @mbox_supported: Support of mail box interface25 * @mmio_supported: Support of mmio interface for core-power feature26 *27 * Used to return output of IOCTL ISST_IF_GET_PLATFORM_INFO. This28 * information can be used by the user space, to get the driver, firmware29 * support and also number of commands to send in a single IOCTL request.30 */31struct 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 CPU41 * @logical_cpu: Linux logical CPU number42 * @physical_cpu: PUNIT CPU number43 *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 */47struct 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 IOCTL54 * @cmd_count: Number of CPU mapping command in cpu_map[]55 * @cpu_map[]: Holds one or more CPU map data structure56 *57 * This structure used with ioctl ISST_IF_GET_PHY_ID to send58 * one or more CPU mapping commands. Here IOCTL return value indicates59 * number of commands sent or error number if no commands have been sent.60 */61struct 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 register68 * @read_write: Value 0: Read, 1: Write69 * @logical_cpu: Logical CPU number to get target PCI device.70 * @reg: PUNIT register offset71 * @value: For write operation value to write and for72 * read placeholder read value73 *74 * Structure to specify read/write data to PUNIT registers.75 */76struct 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 commands85 * @cmd_count: Number of io reg commands in io_reg[]86 * @io_reg[]: Holds one or more io_reg command structure87 *88 * This structure used with ioctl ISST_IF_IO_CMD to send89 * one or more read/write commands to PUNIT. Here IOCTL return value90 * indicates number of requests sent or error number if no requests have91 * been sent.92 */93struct 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 command100 * @logical_cpu: Logical CPU number to get target PCI device101 * @parameter: Mailbox parameter value102 * @req_data: Request data for the mailbox103 * @resp_data: Response data for mailbox command response104 * @command: Mailbox command value105 * @sub_command: Mailbox sub command value106 * @reserved: Unused, set to 0107 *108 * Structure to specify mailbox command to be sent to PUNIT.109 */110struct 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 commands122 * @cmd_count: Number of mailbox commands in mbox_cmd[]123 * @mbox_cmd[]: Holds one or more mbox commands124 *125 * This structure used with ioctl ISST_IF_MBOX_COMMAND to send126 * one or more mailbox commands to PUNIT. Here IOCTL return value127 * indicates number of commands sent or error number if no commands have128 * been sent.129 */130struct 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 command137 * @read_write: Value 0: Read, 1: Write138 * @logical_cpu: Logical CPU number139 * @msr: MSR number140 * @data: For write operation, data to write, for read141 * place holder142 *143 * Structure to specify MSR command related to PUNIT.144 */145struct 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 commands154 * @cmd_count: Number of mailbox commands in msr_cmd[]155 * @msr_cmd[]: Holds one or more msr commands156 *157 * This structure used with ioctl ISST_IF_MSR_COMMAND to send158 * one or more MSR commands. IOCTL return value indicates number of159 * commands sent or error number if no commands have been sent.160 */161struct 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 feature168 * @get_set: 0: Get, 1: Set169 * @socket_id: Socket/package id170 * @power_domain: Power Domain id171 * @enable: Feature enable status172 * @priority_type: Priority type for the feature (ordered/proportional)173 *174 * Structure to get/set core_power feature state using IOCTL175 * ISST_IF_CORE_POWER_STATE.176 */177struct 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 praram188 * @get_set: 0: Get, 1: Set189 * @socket_id: Socket/package id190 * @power_domain: Power Domain id191 * clos: Clos ID for the parameters192 * min_freq_mhz: Minimum frequency in MHz193 * max_freq_mhz: Maximum frequency in MHz194 * prop_prio: Proportional priority from 0-15195 *196 * Structure to get/set per clos property using IOCTL197 * ISST_IF_CLOS_PARAM.198 */199struct 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 CPU211 * @socket_id: Socket/package id212 * @power_domain: Power Domain id213 * @logical_cpu: CPU number214 * @clos: Clos ID to assign to the logical CPU215 *216 * Structure to get/set core_power feature.217 */218struct 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 CPUs227 * @cmd_count: Number of cmds (cpus) in this request228 * @get_set: Request is for get or set229 * @punit_cpu_map: Set to 1 if the CPU number is punit numbering not230 * Linux CPU number231 *232 * Structure used to get/set associate CPUs to clos using IOCTL233 * ISST_IF_CLOS_ASSOC.234 */235struct 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 socket244 * @socket_id: Socket/package id245 * @count: Number of instances246 * @valid_mask: Mask of instances as there can be holes247 *248 * Structure used to get TPMI instances information using249 * IOCTL ISST_IF_COUNT_TPMI_INSTANCES.250 */251struct 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 levels259 * @socket_id: Socket/package id260 * @power_domain: Power Domain id261 * @logical_cpu: CPU number262 * @clos: Clos ID to assign to the logical CPU263 * @max_level: Maximum performance level supported by the platform264 * @feature_rev: The feature revision for SST-PP supported by the platform265 * @level_mask: Mask of supported performance levels266 * @current_level: Current performance level267 * @feature_state: SST-BF and SST-TF (enabled/disabled) status at current level268 * @locked: SST-PP performance level change is locked/unlocked269 * @enabled: SST-PP feature is enabled or not270 * @sst-tf_support: SST-TF support status at this level271 * @sst-bf_support: SST-BF support status at this level272 *273 * Structure to get SST-PP details using IOCTL ISST_IF_PERF_LEVELS.274 */275struct 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 level291 * @socket_id: Socket/package id292 * @power_domain: Power Domain id293 * @level: level to set294 *295 * Structure used change SST-PP level using IOCTL ISST_IF_PERF_SET_LEVEL.296 */297struct 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-TF305 * @socket_id: Socket/package id306 * @power_domain: Power Domain id307 * @feature: bit 0 = SST-BF state, bit 1 = SST-TF state308 *309 * Structure used to enable SST-BF/SST-TF using IOCTL ISST_IF_PERF_SET_FEATURE.310 */311struct isst_perf_feature_control {312 __u8 socket_id;313 __u8 power_domain_id;314 __u8 feature;315};316 317#define TRL_MAX_BUCKETS 8318#define TRL_MAX_LEVELS 6319 320/**321 * struct isst_perf_level_data_info - Structure to get SST-PP level details322 * @socket_id: Socket/package id323 * @power_domain: Power Domain id324 * @level: SST-PP level for which caller wants to get information325 * @tdp_ratio: TDP Ratio326 * @base_freq_mhz: Base frequency in MHz327 * @base_freq_avx2_mhz: AVX2 Base frequency in MHz328 * @base_freq_avx512_mhz: AVX512 base frequency in MHz329 * @base_freq_amx_mhz: AMX base frequency in MHz330 * @thermal_design_power_w: Thermal design (TDP) power331 * @tjunction_max_c: Max junction temperature332 * @max_memory_freq_mhz: Max memory frequency in MHz333 * @cooling_type: Type of cooling is used334 * @p0_freq_mhz: core maximum frequency335 * @p1_freq_mhz: Core TDP frequency336 * @pn_freq_mhz: Core maximum efficiency frequency337 * @pm_freq_mhz: Core minimum frequency338 * @p0_fabric_freq_mhz: Fabric (Uncore) maximum frequency339 * @p1_fabric_freq_mhz: Fabric (Uncore) TDP frequency340 * @pn_fabric_freq_mhz: Fabric (Uncore) minimum efficiency frequency341 * @pm_fabric_freq_mhz: Fabric (Uncore) minimum frequency342 * @max_buckets: Maximum trl buckets343 * @max_trl_levels: Maximum trl levels344 * @bucket_core_counts[TRL_MAX_BUCKETS]: Number of cores per bucket345 * @trl_freq_mhz[TRL_MAX_LEVELS][TRL_MAX_BUCKETS]: maximum frequency346 * for a bucket and trl level347 *348 * Structure used to get information on frequencies and TDP for a SST-PP349 * level using ISST_IF_GET_PERF_LEVEL_INFO.350 */351struct 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 mask380 * @socket_id: Socket/package id381 * @power_domain: Power Domain id382 * @level: SST-PP level for which caller wants to get information383 * @punit_cpu_map: Set to 1 if the CPU number is punit numbering not384 * Linux CPU number. If 0 CPU buffer is copied to user space385 * supplied cpu_buffer of size cpu_buffer_size. Punit386 * 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 CPU389 * buffer size.390 * @cpu_buffer: Buffer to copy CPU mask when punit_cpu_map is 0391 *392 * Structure used to get cpumask for a SST-PP level using393 * IOCTL ISST_IF_GET_PERF_LEVEL_CPU_MASK. Also used to get CPU mask for394 * IOCTL ISST_IF_GET_BASE_FREQ_CPU_MASK for SST-BF.395 */396struct 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 frequencies408 * @socket_id: Socket/package id409 * @power_domain: Power Domain id410 * @level: SST-PP level for which caller wants to get information411 * @high_base_freq_mhz: High priority CPU base frequency412 * @low_base_freq_mhz: Low priority CPU base frequency413 * @tjunction_max_c: Max junction temperature414 * @thermal_design_power_w: Thermal design power in watts415 *416 * Structure used to get SST-BF information using417 * IOCTL ISST_IF_GET_BASE_FREQ_INFO.418 */419struct 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 frequencies431 * @socket_id: Socket/package id432 * @power_domain: Power Domain id433 * @level: SST-PP level for which caller wants to get information434 * @max_clip_freqs: Maximum number of low priority core clipping frequencies435 * @lp_clip_freq_mhz: Clip frequencies per trl level436 * @bucket_core_counts: Maximum number of cores for a bucket437 * @trl_freq_mhz: Frequencies per trl level for each bucket438 *439 * Structure used to get SST-TF information using440 * IOCTL ISST_IF_GET_TURBO_FREQ_INFO.441 */442struct 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 0xFE455#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#endif476