logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

isst_if.h (15281B)


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