Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
| 2 | /* Copyright (c) 2018-2020 Intel Corporation */ |
| 3 | |
| 4 | #ifndef __PECI_IOCTL_H |
| 5 | #define __PECI_IOCTL_H |
| 6 | |
| 7 | #include <linux/ioctl.h> |
| 8 | #include <linux/types.h> |
| 9 | |
| 10 | /* The PECI client's default address of 0x30 */ |
| 11 | #define PECI_BASE_ADDR 0x30 |
| 12 | |
| 13 | /* Max number of CPU clients */ |
| 14 | #define PECI_OFFSET_MAX 8 |
| 15 | |
| 16 | /* PECI read/write data buffer size max */ |
| 17 | #define PECI_BUFFER_SIZE 255 |
| 18 | |
| 19 | /* Device Specific Completion Code (CC) Definition */ |
| 20 | #define PECI_DEV_CC_SUCCESS 0x40 |
| 21 | #define PECI_DEV_CC_NEED_RETRY 0x80 |
| 22 | #define PECI_DEV_CC_OUT_OF_RESOURCE 0x81 |
| 23 | #define PECI_DEV_CC_UNAVAIL_RESOURCE 0x82 |
| 24 | #define PECI_DEV_CC_INVALID_REQ 0x90 |
| 25 | #define PECI_DEV_CC_MCA_ERROR 0x91 |
| 26 | #define PECI_DEV_CC_CATASTROPHIC_MCA_ERROR 0x93 |
| 27 | #define PECI_DEV_CC_FATAL_MCA_DETECTED 0x94 |
| 28 | #define PECI_DEV_CC_PARITY_ERROR_ON_GPSB_OR_PMSB 0x98 |
| 29 | #define PECI_DEV_CC_PARITY_ERROR_ON_GPSB_OR_PMSB_IERR 0x9B |
| 30 | #define PECI_DEV_CC_PARITY_ERROR_ON_GPSB_OR_PMSB_MCA 0x9C |
| 31 | |
| 32 | /* Completion Code mask to check retry needs */ |
| 33 | #define PECI_DEV_CC_RETRY_CHECK_MASK 0xf0 |
| 34 | |
| 35 | #define PECI_DEV_RETRY_TIMEOUT msecs_to_jiffies(700) |
Jason M. Bills | 6a5c2ea | 2022-03-01 14:58:00 -0800 | [diff] [blame] | 36 | #define PECI_DEV_RETRY_INTERVAL_MIN_USEC 100 |
| 37 | #define PECI_DEV_RETRY_INTERVAL_MAX_USEC (128 * 1000) |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 38 | #define PECI_DEV_RETRY_BIT 0x01 |
| 39 | |
| 40 | /** |
| 41 | * enum peci_cmd - PECI client commands |
| 42 | * @PECI_CMD_XFER: raw PECI transfer |
| 43 | * @PECI_CMD_PING: ping, a required message for all PECI devices |
| 44 | * @PECI_CMD_GET_DIB: get DIB (Device Info Byte) |
| 45 | * @PECI_CMD_GET_TEMP: get maximum die temperature |
| 46 | * @PECI_CMD_RD_PKG_CFG: read access to the PCS (Package Configuration Space) |
| 47 | * @PECI_CMD_WR_PKG_CFG: write access to the PCS (Package Configuration Space) |
| 48 | * @PECI_CMD_RD_IA_MSR: read access to MSRs (Model Specific Registers) |
| 49 | * @PECI_CMD_WR_IA_MSR: write access to MSRs (Model Specific Registers) |
| 50 | * @PECI_CMD_RD_IA_MSREX: read access to MSRs (Model Specific Registers) |
| 51 | * @PECI_CMD_RD_PCI_CFG: sideband read access to the PCI configuration space |
| 52 | * maintained in downstream devices external to the processor |
| 53 | * @PECI_CMD_WR_PCI_CFG: sideband write access to the PCI configuration space |
| 54 | * maintained in downstream devices external to the processor |
| 55 | * @PECI_CMD_RD_PCI_CFG_LOCAL: sideband read access to the PCI configuration |
| 56 | * space that resides within the processor |
| 57 | * @PECI_CMD_WR_PCI_CFG_LOCAL: sideband write access to the PCI configuration |
| 58 | * space that resides within the processor |
| 59 | * |
| 60 | * Available commands depend on client's PECI revision. |
| 61 | */ |
| 62 | enum peci_cmd { |
| 63 | PECI_CMD_XFER = 0, |
| 64 | PECI_CMD_PING, |
| 65 | PECI_CMD_GET_DIB, |
| 66 | PECI_CMD_GET_TEMP, |
| 67 | PECI_CMD_RD_PKG_CFG, |
| 68 | PECI_CMD_WR_PKG_CFG, |
| 69 | PECI_CMD_RD_IA_MSR, |
| 70 | PECI_CMD_WR_IA_MSR, |
| 71 | PECI_CMD_RD_IA_MSREX, |
| 72 | PECI_CMD_RD_PCI_CFG, |
| 73 | PECI_CMD_WR_PCI_CFG, |
| 74 | PECI_CMD_RD_PCI_CFG_LOCAL, |
| 75 | PECI_CMD_WR_PCI_CFG_LOCAL, |
| 76 | PECI_CMD_RD_END_PT_CFG, |
| 77 | PECI_CMD_WR_END_PT_CFG, |
| 78 | PECI_CMD_CRASHDUMP_DISC, |
| 79 | PECI_CMD_CRASHDUMP_GET_FRAME, |
| 80 | PECI_CMD_MAX |
| 81 | }; |
| 82 | |
| 83 | /** |
| 84 | * struct peci_xfer_msg - raw PECI transfer command |
| 85 | * @addr; address of the client |
| 86 | * @tx_len: number of data to be written in bytes |
| 87 | * @rx_len: number of data to be read in bytes |
| 88 | * @tx_buf: data to be written, or NULL |
| 89 | * @rx_buf: data to be read, or NULL |
| 90 | * |
| 91 | * raw PECI transfer |
| 92 | */ |
| 93 | struct peci_xfer_msg { |
| 94 | __u8 addr; |
| 95 | __u8 tx_len; |
| 96 | __u8 rx_len; |
| 97 | __u8 padding; |
| 98 | __u8 *tx_buf; |
| 99 | __u8 *rx_buf; |
| 100 | } __attribute__((__packed__)); |
| 101 | |
| 102 | /** |
| 103 | * struct peci_ping_msg - ping command |
| 104 | * @addr: address of the client |
| 105 | * |
| 106 | * Ping() is a required message for all PECI devices. This message is used to |
| 107 | * enumerate devices or determine if a device has been removed, been |
| 108 | * powered-off, etc. |
| 109 | */ |
| 110 | struct peci_ping_msg { |
| 111 | __u8 addr; |
| 112 | __u8 padding[3]; |
| 113 | } __attribute__((__packed__)); |
| 114 | |
| 115 | /** |
| 116 | * struct peci_get_dib_msg - GetDIB command |
| 117 | * @addr: address of the client |
| 118 | * @dib: DIB data to be read |
| 119 | * |
| 120 | * The processor PECI client implementation of GetDIB() includes an 8-byte |
| 121 | * response and provides information regarding client revision number and the |
| 122 | * number of supported domains. All processor PECI clients support the GetDIB() |
| 123 | * command. |
| 124 | */ |
| 125 | struct peci_get_dib_msg { |
| 126 | #define PECI_GET_DIB_WR_LEN 1 |
| 127 | #define PECI_GET_DIB_RD_LEN 8 |
| 128 | #define PECI_GET_DIB_CMD 0xf7 |
| 129 | |
| 130 | __u8 addr; |
| 131 | __u8 padding[3]; |
| 132 | __u64 dib; |
| 133 | } __attribute__((__packed__)); |
| 134 | |
| 135 | /** |
| 136 | * struct peci_get_temp_msg - GetTemp command |
| 137 | * @addr: address of the client |
| 138 | * @temp_raw: raw temperature data to be read |
| 139 | * |
| 140 | * The GetTemp() command is used to retrieve the maximum die temperature from a |
| 141 | * target PECI address. The temperature is used by the external thermal |
| 142 | * management system to regulate the temperature on the die. The data is |
| 143 | * returned as a negative value representing the number of degrees centigrade |
| 144 | * below the maximum processor junction temperature. |
| 145 | */ |
| 146 | struct peci_get_temp_msg { |
| 147 | #define PECI_GET_TEMP_WR_LEN 1 |
| 148 | #define PECI_GET_TEMP_RD_LEN 2 |
| 149 | #define PECI_GET_TEMP_CMD 0x01 |
| 150 | |
| 151 | __u8 addr; |
| 152 | __u8 padding; |
| 153 | __s16 temp_raw; |
| 154 | } __attribute__((__packed__)); |
| 155 | |
| 156 | /** |
| 157 | * struct peci_rd_pkg_cfg_msg - RdPkgConfig command |
| 158 | * @addr: address of the client |
| 159 | * @index: encoding index for the requested service |
| 160 | * @param: specific data being requested |
| 161 | * @rx_len: number of data to be read in bytes |
| 162 | * @cc: completion code |
| 163 | * @pkg_config: package config data to be read |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 164 | * @domain_id: domain ID of the client |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 165 | * |
| 166 | * The RdPkgConfig() command provides read access to the Package Configuration |
| 167 | * Space (PCS) within the processor, including various power and thermal |
| 168 | * management functions. Typical PCS read services supported by the processor |
| 169 | * may include access to temperature data, energy status, run time information, |
| 170 | * DIMM temperatures and so on. |
| 171 | */ |
| 172 | struct peci_rd_pkg_cfg_msg { |
| 173 | #define PECI_RDPKGCFG_WRITE_LEN 5 |
| 174 | #define PECI_RDPKGCFG_READ_LEN_BASE 1 |
| 175 | #define PECI_RDPKGCFG_CMD 0xa1 |
| 176 | |
| 177 | __u8 addr; |
| 178 | __u8 index; |
| 179 | #define PECI_MBX_INDEX_CPU_ID 0 /* Package Identifier Read */ |
| 180 | #define PECI_MBX_INDEX_VR_DEBUG 1 /* VR Debug */ |
| 181 | #define PECI_MBX_INDEX_PKG_TEMP_READ 2 /* Package Temperature Read */ |
| 182 | #define PECI_MBX_INDEX_ENERGY_COUNTER 3 /* Energy counter */ |
| 183 | #define PECI_MBX_INDEX_ENERGY_STATUS 4 /* DDR Energy Status */ |
| 184 | #define PECI_MBX_INDEX_WAKE_MODE_BIT 5 /* "Wake on PECI" Mode bit */ |
| 185 | #define PECI_MBX_INDEX_EPI 6 /* Efficient Performance Indication */ |
| 186 | #define PECI_MBX_INDEX_PKG_RAPL_PERF 8 /* Pkg RAPL Performance Status Read */ |
Jason M. Bills | 6a5c2ea | 2022-03-01 14:58:00 -0800 | [diff] [blame] | 187 | #define PECI_MBX_INDEX_MODULE_TEMP 9 /* Module Temperature Read */ |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 188 | #define PECI_MBX_INDEX_DTS_MARGIN 10 /* DTS thermal margin */ |
| 189 | #define PECI_MBX_INDEX_SKT_PWR_THRTL_DUR 11 /* Socket Power Throttled Duration */ |
| 190 | #define PECI_MBX_INDEX_CFG_TDP_CONTROL 12 /* TDP Config Control */ |
| 191 | #define PECI_MBX_INDEX_CFG_TDP_LEVELS 13 /* TDP Config Levels */ |
| 192 | #define PECI_MBX_INDEX_DDR_DIMM_TEMP 14 /* DDR DIMM Temperature */ |
| 193 | #define PECI_MBX_INDEX_CFG_ICCMAX 15 /* Configurable ICCMAX */ |
| 194 | #define PECI_MBX_INDEX_TEMP_TARGET 16 /* Temperature Target Read */ |
| 195 | #define PECI_MBX_INDEX_CURR_CFG_LIMIT 17 /* Current Config Limit */ |
| 196 | #define PECI_MBX_INDEX_DIMM_TEMP_READ 20 /* Package Thermal Status Read */ |
| 197 | #define PECI_MBX_INDEX_DRAM_IMC_TMP_READ 22 /* DRAM IMC Temperature Read */ |
| 198 | #define PECI_MBX_INDEX_DDR_CH_THERM_STAT 23 /* DDR Channel Thermal Status */ |
| 199 | #define PECI_MBX_INDEX_PKG_POWER_LIMIT1 26 /* Package Power Limit1 */ |
| 200 | #define PECI_MBX_INDEX_PKG_POWER_LIMIT2 27 /* Package Power Limit2 */ |
| 201 | #define PECI_MBX_INDEX_TDP 28 /* Thermal design power minimum */ |
| 202 | #define PECI_MBX_INDEX_TDP_HIGH 29 /* Thermal design power maximum */ |
| 203 | #define PECI_MBX_INDEX_TDP_UNITS 30 /* Units for power/energy registers */ |
| 204 | #define PECI_MBX_INDEX_RUN_TIME 31 /* Accumulated Run Time */ |
| 205 | #define PECI_MBX_INDEX_CONSTRAINED_TIME 32 /* Thermally Constrained Time Read */ |
| 206 | #define PECI_MBX_INDEX_TURBO_RATIO 33 /* Turbo Activation Ratio */ |
| 207 | #define PECI_MBX_INDEX_DDR_RAPL_PL1 34 /* DDR RAPL PL1 */ |
| 208 | #define PECI_MBX_INDEX_DDR_PWR_INFO_HIGH 35 /* DRAM Power Info Read (high) */ |
| 209 | #define PECI_MBX_INDEX_DDR_PWR_INFO_LOW 36 /* DRAM Power Info Read (low) */ |
| 210 | #define PECI_MBX_INDEX_DDR_RAPL_PL2 37 /* DDR RAPL PL2 */ |
| 211 | #define PECI_MBX_INDEX_DDR_RAPL_STATUS 38 /* DDR RAPL Performance Status */ |
| 212 | #define PECI_MBX_INDEX_DDR_HOT_ABSOLUTE 43 /* DDR Hottest Dimm Absolute Temp */ |
| 213 | #define PECI_MBX_INDEX_DDR_HOT_RELATIVE 44 /* DDR Hottest Dimm Relative Temp */ |
| 214 | #define PECI_MBX_INDEX_DDR_THROTTLE_TIME 45 /* DDR Throttle Time */ |
| 215 | #define PECI_MBX_INDEX_DDR_THERM_STATUS 46 /* DDR Thermal Status */ |
| 216 | #define PECI_MBX_INDEX_TIME_AVG_TEMP 47 /* Package time-averaged temperature */ |
| 217 | #define PECI_MBX_INDEX_TURBO_RATIO_LIMIT 49 /* Turbo Ratio Limit Read */ |
| 218 | #define PECI_MBX_INDEX_HWP_AUTO_OOB 53 /* HWP Autonomous Out-of-band */ |
| 219 | #define PECI_MBX_INDEX_DDR_WARM_BUDGET 55 /* DDR Warm Power Budget */ |
| 220 | #define PECI_MBX_INDEX_DDR_HOT_BUDGET 56 /* DDR Hot Power Budget */ |
| 221 | #define PECI_MBX_INDEX_PKG_PSYS_PWR_LIM3 57 /* Package/Psys Power Limit3 */ |
| 222 | #define PECI_MBX_INDEX_PKG_PSYS_PWR_LIM1 58 /* Package/Psys Power Limit1 */ |
| 223 | #define PECI_MBX_INDEX_PKG_PSYS_PWR_LIM2 59 /* Package/Psys Power Limit2 */ |
| 224 | #define PECI_MBX_INDEX_PKG_PSYS_PWR_LIM4 60 /* Package/Psys Power Limit4 */ |
| 225 | #define PECI_MBX_INDEX_PERF_LIMIT_REASON 65 /* Performance Limit Reasons */ |
| 226 | |
| 227 | __u16 param; |
| 228 | /* When index is PECI_MBX_INDEX_CPU_ID */ |
| 229 | #define PECI_PKG_ID_CPU_ID 0x0000 /* CPUID Info */ |
Jason M. Bills | 8fc53d7 | 2021-02-25 14:53:22 -0800 | [diff] [blame] | 230 | #define PECI_PKG_POWER_SKU_UNIT 0x0000 /* Time, Energy, Power units */ |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 231 | #define PECI_PKG_ID_PLATFORM_ID 0x0001 /* Platform ID */ |
| 232 | #define PECI_PKG_ID_UNCORE_ID 0x0002 /* Uncore Device ID */ |
| 233 | #define PECI_PKG_ID_MAX_THREAD_ID 0x0003 /* Max Thread ID */ |
| 234 | #define PECI_PKG_ID_MICROCODE_REV 0x0004 /* CPU Microcode Update Revision */ |
| 235 | #define PECI_PKG_ID_MACHINE_CHECK_STATUS 0x0005 /* Machine Check Status */ |
Jason M. Bills | 8fc53d7 | 2021-02-25 14:53:22 -0800 | [diff] [blame] | 236 | #define PECI_PKG_ID_CPU_PACKAGE 0x00ff /* CPU package ID*/ |
| 237 | #define PECI_PKG_ID_DIMM 0x00ff /* DIMM ID*/ |
| 238 | #define PECI_PKG_ID_PLATFORM 0x00fe /* Entire platform ID */ |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 239 | |
| 240 | __u8 rx_len; |
| 241 | __u8 cc; |
| 242 | __u8 padding[2]; |
| 243 | __u8 pkg_config[4]; |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 244 | __u8 domain_id; |
| 245 | __u8 padding1[3]; |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 246 | } __attribute__((__packed__)); |
| 247 | |
| 248 | /** |
| 249 | * struct peci_wr_pkg_cfg_msg - WrPkgConfig command |
| 250 | * @addr: address of the client |
| 251 | * @index: encoding index for the requested service |
| 252 | * @param: specific data being requested |
| 253 | * @tx_len: number of data to be written in bytes |
| 254 | * @cc: completion code |
| 255 | * @value: package config data to be written |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 256 | * @domain_id: domain ID of the client |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 257 | * |
| 258 | * The WrPkgConfig() command provides write access to the Package Configuration |
| 259 | * Space (PCS) within the processor, including various power and thermal |
| 260 | * management functions. Typical PCS write services supported by the processor |
| 261 | * may include power limiting, thermal averaging constant programming and so |
| 262 | * on. |
| 263 | */ |
| 264 | struct peci_wr_pkg_cfg_msg { |
| 265 | #define PECI_WRPKGCFG_WRITE_LEN_BASE 6 |
| 266 | #define PECI_WRPKGCFG_READ_LEN 1 |
| 267 | #define PECI_WRPKGCFG_CMD 0xa5 |
| 268 | |
| 269 | __u8 addr; |
| 270 | __u8 index; |
| 271 | #define PECI_MBX_INDEX_DIMM_AMBIENT 19 |
| 272 | #define PECI_MBX_INDEX_DIMM_TEMP 24 |
| 273 | |
| 274 | __u16 param; |
| 275 | __u8 tx_len; |
| 276 | __u8 cc; |
| 277 | __u8 padding[2]; |
| 278 | __u32 value; |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 279 | __u8 domain_id; |
| 280 | __u8 padding1[3]; |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 281 | } __attribute__((__packed__)); |
| 282 | |
| 283 | /** |
| 284 | * struct peci_rd_ia_msr_msg - RdIAMSR command |
| 285 | * @addr: address of the client |
| 286 | * @thread_id: ID of the specific logical processor |
| 287 | * @address: address of MSR to read from |
| 288 | * @cc: completion code |
| 289 | * @value: data to be read |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 290 | * @domain_id: domain ID of the client |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 291 | * |
| 292 | * The RdIAMSR() PECI command provides read access to Model Specific Registers |
| 293 | * (MSRs) defined in the processor's Intel Architecture (IA). |
| 294 | */ |
| 295 | struct peci_rd_ia_msr_msg { |
| 296 | #define PECI_RDIAMSR_WRITE_LEN 5 |
| 297 | #define PECI_RDIAMSR_READ_LEN 9 |
| 298 | #define PECI_RDIAMSR_CMD 0xb1 |
| 299 | |
| 300 | __u8 addr; |
| 301 | __u8 thread_id; |
| 302 | __u16 address; |
| 303 | __u8 cc; |
| 304 | __u8 padding[3]; |
| 305 | __u64 value; |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 306 | __u8 domain_id; |
| 307 | __u8 padding1[3]; |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 308 | } __attribute__((__packed__)); |
| 309 | |
| 310 | /** |
| 311 | * struct peci_wr_ia_msr_msg - WrIAMSR command |
| 312 | * @addr: address of the client |
| 313 | * @thread_id: ID of the specific logical processor |
| 314 | * @address: address of MSR to write to |
| 315 | * @tx_len: number of data to be written in bytes |
| 316 | * @cc: completion code |
| 317 | * @value: data to be written |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 318 | * @domain_id: domain ID of the client |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 319 | * |
| 320 | * The WrIAMSR() PECI command provides write access to Model Specific Registers |
| 321 | * (MSRs) defined in the processor's Intel Architecture (IA). |
| 322 | */ |
| 323 | struct peci_wr_ia_msr_msg { |
| 324 | #define PECI_WRIAMSR_CMD 0xb5 |
| 325 | |
| 326 | __u8 addr; |
| 327 | __u8 thread_id; |
| 328 | __u16 address; |
| 329 | __u8 tx_len; |
| 330 | __u8 cc; |
| 331 | __u8 padding[2]; |
| 332 | __u64 value; |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 333 | __u8 domain_id; |
| 334 | __u8 padding1[3]; |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 335 | } __attribute__((__packed__)); |
| 336 | |
| 337 | /** |
| 338 | * struct peci_rd_ia_msrex_msg - RdIAMSREX command |
| 339 | * @addr: address of the client |
| 340 | * @thread_id: ID of the specific logical processor |
| 341 | * @address: address of MSR to read from |
| 342 | * @cc: completion code |
| 343 | * @value: data to be read |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 344 | * @domain_id: domain ID of the client |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 345 | * |
| 346 | * The RdIAMSREX() PECI command provides read access to Model Specific |
| 347 | * Registers (MSRs) defined in the processor's Intel Architecture (IA). |
| 348 | * The differences between RdIAMSREX() and RdIAMSR() are that: |
| 349 | * (1)RdIAMSR() can only read MC registers, RdIAMSREX() can read all MSRs |
| 350 | * (2)thread_id of RdIAMSR() is u8, thread_id of RdIAMSREX() is u16 |
| 351 | */ |
| 352 | struct peci_rd_ia_msrex_msg { |
| 353 | #define PECI_RDIAMSREX_WRITE_LEN 6 |
| 354 | #define PECI_RDIAMSREX_READ_LEN 9 |
| 355 | #define PECI_RDIAMSREX_CMD 0xd1 |
| 356 | |
| 357 | __u8 addr; |
| 358 | __u8 padding0; |
| 359 | __u16 thread_id; |
| 360 | __u16 address; |
| 361 | __u8 cc; |
| 362 | __u8 padding1; |
| 363 | __u64 value; |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 364 | __u8 domain_id; |
| 365 | __u8 padding2[3]; |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 366 | } __attribute__((__packed__)); |
| 367 | |
| 368 | /** |
| 369 | * struct peci_rd_pci_cfg_msg - RdPCIConfig command |
| 370 | * @addr: address of the client |
| 371 | * @bus: PCI bus number |
| 372 | * @device: PCI device number |
| 373 | * @function: specific function to read from |
| 374 | * @reg: specific register to read from |
| 375 | * @cc: completion code |
| 376 | * @pci_config: config data to be read |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 377 | * @domain_id: domain ID of the client |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 378 | * |
| 379 | * The RdPCIConfig() command provides sideband read access to the PCI |
| 380 | * configuration space maintained in downstream devices external to the |
| 381 | * processor. |
| 382 | */ |
| 383 | struct peci_rd_pci_cfg_msg { |
| 384 | #define PECI_RDPCICFG_WRITE_LEN 6 |
| 385 | #define PECI_RDPCICFG_READ_LEN 5 |
| 386 | #define PECI_RDPCICFG_READ_LEN_MAX 24 |
| 387 | #define PECI_RDPCICFG_CMD 0x61 |
| 388 | |
| 389 | __u8 addr; |
| 390 | __u8 bus; |
| 391 | #define PECI_PCI_BUS0_CPU0 0x00 |
| 392 | #define PECI_PCI_BUS0_CPU1 0x80 |
| 393 | #define PECI_PCI_CPUBUSNO_BUS 0x00 |
| 394 | #define PECI_PCI_CPUBUSNO_DEV 0x08 |
| 395 | #define PECI_PCI_CPUBUSNO_FUNC 0x02 |
| 396 | #define PECI_PCI_CPUBUSNO 0xcc |
| 397 | #define PECI_PCI_CPUBUSNO_1 0xd0 |
| 398 | #define PECI_PCI_CPUBUSNO_VALID 0xd4 |
| 399 | |
| 400 | __u8 device; |
| 401 | __u8 function; |
| 402 | __u16 reg; |
| 403 | __u8 cc; |
| 404 | __u8 padding[1]; |
| 405 | __u8 pci_config[4]; |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 406 | __u8 domain_id; |
| 407 | __u8 padding1[3]; |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 408 | } __attribute__((__packed__)); |
| 409 | |
| 410 | /** |
| 411 | * struct peci_wr_pci_cfg_msg - WrPCIConfig command |
| 412 | * @addr: address of the client |
| 413 | * @bus: PCI bus number |
| 414 | * @device: PCI device number |
| 415 | * @function: specific function to write to |
| 416 | * @reg: specific register to write to |
| 417 | * @tx_len: number of data to be written in bytes |
| 418 | * @cc: completion code |
| 419 | * @pci_config: config data to be written |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 420 | * @domain_id: domain ID of the client |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 421 | * |
| 422 | * The RdPCIConfig() command provides sideband write access to the PCI |
| 423 | * configuration space maintained in downstream devices external to the |
| 424 | * processor. |
| 425 | */ |
| 426 | struct peci_wr_pci_cfg_msg { |
| 427 | #define PECI_WRPCICFG_CMD 0x65 |
| 428 | |
| 429 | __u8 addr; |
| 430 | __u8 bus; |
| 431 | __u8 device; |
| 432 | __u8 function; |
| 433 | __u16 reg; |
| 434 | __u8 tx_len; |
| 435 | __u8 cc; |
| 436 | __u8 pci_config[4]; |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 437 | __u8 domain_id; |
| 438 | __u8 padding[3]; |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 439 | } __attribute__((__packed__)); |
| 440 | |
| 441 | /** |
| 442 | * struct peci_rd_pci_cfg_local_msg - RdPCIConfigLocal command |
| 443 | * @addr: address of the client |
| 444 | * @bus: PCI bus number |
| 445 | * @device: PCI device number |
| 446 | * @function: specific function to read from |
| 447 | * @reg: specific register to read from |
| 448 | * @rx_len: number of data to be read in bytes |
| 449 | * @cc: completion code |
| 450 | * @pci_config: config data to be read |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 451 | * @domain_id: domain ID of the client |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 452 | * |
| 453 | * The RdPCIConfigLocal() command provides sideband read access to the PCI |
| 454 | * configuration space that resides within the processor. This includes all |
| 455 | * processor IIO and uncore registers within the PCI configuration space. |
| 456 | */ |
| 457 | struct peci_rd_pci_cfg_local_msg { |
| 458 | #define PECI_RDPCICFGLOCAL_WRITE_LEN 5 |
| 459 | #define PECI_RDPCICFGLOCAL_READ_LEN_BASE 1 |
| 460 | #define PECI_RDPCICFGLOCAL_CMD 0xe1 |
| 461 | |
| 462 | __u8 addr; |
| 463 | __u8 bus; |
| 464 | __u8 device; |
| 465 | __u8 function; |
| 466 | __u16 reg; |
| 467 | __u8 rx_len; |
| 468 | __u8 cc; |
| 469 | __u8 pci_config[4]; |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 470 | __u8 domain_id; |
| 471 | __u8 padding[3]; |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 472 | } __attribute__((__packed__)); |
| 473 | |
| 474 | /** |
| 475 | * struct peci_wr_pci_cfg_local_msg - WrPCIConfigLocal command |
| 476 | * @addr: address of the client |
| 477 | * @bus: PCI bus number |
| 478 | * @device: PCI device number |
| 479 | * @function: specific function to read from |
| 480 | * @reg: specific register to read from |
| 481 | * @tx_len: number of data to be written in bytes |
| 482 | * @cc: completion code |
| 483 | * @value: config data to be written |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 484 | * @domain_id: domain ID of the client |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 485 | * |
| 486 | * The WrPCIConfigLocal() command provides sideband write access to the PCI |
| 487 | * configuration space that resides within the processor. PECI originators can |
| 488 | * access this space even before BIOS enumeration of the system buses. |
| 489 | */ |
| 490 | struct peci_wr_pci_cfg_local_msg { |
| 491 | #define PECI_WRPCICFGLOCAL_WRITE_LEN_BASE 6 |
| 492 | #define PECI_WRPCICFGLOCAL_READ_LEN 1 |
| 493 | #define PECI_WRPCICFGLOCAL_CMD 0xe5 |
| 494 | |
| 495 | __u8 addr; |
| 496 | __u8 bus; |
| 497 | __u8 device; |
| 498 | __u8 function; |
| 499 | __u16 reg; |
| 500 | __u8 tx_len; |
| 501 | __u8 cc; |
| 502 | __u32 value; |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 503 | __u8 domain_id; |
| 504 | __u8 padding[3]; |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 505 | } __attribute__((__packed__)); |
| 506 | |
| 507 | struct peci_rd_end_pt_cfg_msg { |
| 508 | #define PECI_RDENDPTCFG_PCI_WRITE_LEN 12 |
| 509 | #define PECI_RDENDPTCFG_MMIO_D_WRITE_LEN 14 |
| 510 | #define PECI_RDENDPTCFG_MMIO_Q_WRITE_LEN 18 |
| 511 | #define PECI_RDENDPTCFG_READ_LEN_BASE 1 |
| 512 | #define PECI_RDENDPTCFG_CMD 0xc1 |
| 513 | |
| 514 | __u8 addr; |
| 515 | __u8 msg_type; |
| 516 | #define PECI_ENDPTCFG_TYPE_LOCAL_PCI 0x03 |
| 517 | #define PECI_ENDPTCFG_TYPE_PCI 0x04 |
| 518 | #define PECI_ENDPTCFG_TYPE_MMIO 0x05 |
| 519 | |
| 520 | union { |
| 521 | struct { |
| 522 | __u8 seg; |
| 523 | __u8 bus; |
| 524 | __u8 device; |
| 525 | __u8 function; |
| 526 | __u16 reg; |
| 527 | } pci_cfg; |
| 528 | struct { |
| 529 | __u8 seg; |
| 530 | __u8 bus; |
| 531 | __u8 device; |
| 532 | __u8 function; |
| 533 | __u8 bar; |
| 534 | __u8 addr_type; |
| 535 | #define PECI_ENDPTCFG_ADDR_TYPE_PCI 0x04 |
| 536 | #define PECI_ENDPTCFG_ADDR_TYPE_MMIO_D 0x05 |
| 537 | #define PECI_ENDPTCFG_ADDR_TYPE_MMIO_Q 0x06 |
| 538 | |
| 539 | __u64 offset; |
| 540 | } mmio; |
| 541 | } params; |
| 542 | __u8 rx_len; |
| 543 | __u8 cc; |
| 544 | __u8 padding[2]; |
| 545 | __u8 data[8]; |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 546 | __u8 domain_id; |
| 547 | __u8 padding1[3]; |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 548 | } __attribute__((__packed__)); |
| 549 | |
| 550 | struct peci_wr_end_pt_cfg_msg { |
| 551 | #define PECI_WRENDPTCFG_PCI_WRITE_LEN_BASE 13 |
| 552 | #define PECI_WRENDPTCFG_MMIO_D_WRITE_LEN_BASE 15 |
| 553 | #define PECI_WRENDPTCFG_MMIO_Q_WRITE_LEN_BASE 19 |
| 554 | #define PECI_WRENDPTCFG_READ_LEN 1 |
| 555 | #define PECI_WRENDPTCFG_CMD 0xc5 |
| 556 | |
| 557 | __u8 addr; |
| 558 | __u8 msg_type; |
| 559 | /* See msg_type in struct peci_rd_end_pt_cfg_msg */ |
| 560 | |
| 561 | union { |
| 562 | struct { |
| 563 | __u8 seg; |
| 564 | __u8 bus; |
| 565 | __u8 device; |
| 566 | __u8 function; |
| 567 | __u16 reg; |
| 568 | } pci_cfg; |
| 569 | struct { |
| 570 | __u8 seg; |
| 571 | __u8 bus; |
| 572 | __u8 device; |
| 573 | __u8 function; |
| 574 | __u8 bar; |
| 575 | __u8 addr_type; |
| 576 | /* See addr_type in struct peci_rd_end_pt_cfg_msg */ |
| 577 | |
| 578 | __u64 offset; |
| 579 | } mmio; |
| 580 | } params; |
| 581 | __u8 tx_len; |
| 582 | __u8 cc; |
| 583 | __u8 padding[2]; |
| 584 | __u64 value; |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 585 | __u8 domain_id; |
| 586 | __u8 padding1[3]; |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 587 | } __attribute__((__packed__)); |
| 588 | |
| 589 | /* Crashdump Agent */ |
| 590 | #define PECI_CRASHDUMP_CORE 0x00 |
| 591 | #define PECI_CRASHDUMP_TOR 0x01 |
| 592 | |
| 593 | /* Crashdump Agent Param */ |
| 594 | #define PECI_CRASHDUMP_PAYLOAD_SIZE 0x00 |
| 595 | |
| 596 | /* Crashdump Agent Data Param */ |
| 597 | #define PECI_CRASHDUMP_AGENT_ID 0x00 |
| 598 | #define PECI_CRASHDUMP_AGENT_PARAM 0x01 |
| 599 | |
| 600 | struct peci_crashdump_disc_msg { |
| 601 | __u8 addr; |
| 602 | __u8 subopcode; |
| 603 | #define PECI_CRASHDUMP_ENABLED 0x00 |
| 604 | #define PECI_CRASHDUMP_NUM_AGENTS 0x01 |
| 605 | #define PECI_CRASHDUMP_AGENT_DATA 0x02 |
| 606 | |
| 607 | __u8 cc; |
| 608 | __u8 param0; |
| 609 | __u16 param1; |
| 610 | __u8 param2; |
| 611 | __u8 rx_len; |
| 612 | __u8 data[8]; |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 613 | __u8 domain_id; |
| 614 | __u8 padding[3]; |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 615 | } __attribute__((__packed__)); |
| 616 | |
| 617 | struct peci_crashdump_get_frame_msg { |
| 618 | #define PECI_CRASHDUMP_DISC_WRITE_LEN 9 |
| 619 | #define PECI_CRASHDUMP_DISC_READ_LEN_BASE 1 |
| 620 | #define PECI_CRASHDUMP_DISC_VERSION 0 |
| 621 | #define PECI_CRASHDUMP_DISC_OPCODE 1 |
| 622 | #define PECI_CRASHDUMP_GET_FRAME_WRITE_LEN 10 |
| 623 | #define PECI_CRASHDUMP_GET_FRAME_READ_LEN_BASE 1 |
| 624 | #define PECI_CRASHDUMP_GET_FRAME_VERSION 0 |
| 625 | #define PECI_CRASHDUMP_GET_FRAME_OPCODE 3 |
| 626 | #define PECI_CRASHDUMP_CMD 0x71 |
| 627 | |
| 628 | __u8 addr; |
| 629 | __u8 padding0; |
| 630 | __u16 param0; |
| 631 | __u16 param1; |
| 632 | __u16 param2; |
| 633 | __u8 rx_len; |
| 634 | __u8 cc; |
| 635 | __u8 padding1[2]; |
| 636 | __u8 data[16]; |
Jason M. Bills | 8bb8f37 | 2022-03-01 16:04:44 -0800 | [diff] [blame] | 637 | __u8 domain_id; |
| 638 | __u8 padding2[3]; |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 639 | } __attribute__((__packed__)); |
| 640 | |
Jae Hyun Yoo | adf056a | 2021-02-25 12:44:08 -0800 | [diff] [blame] | 641 | #define PECI_IOC_BASE 0xb8 |
Jason M. Bills | 62cbc71 | 2020-05-07 14:07:49 -0700 | [diff] [blame] | 642 | |
| 643 | #define PECI_IOC_XFER \ |
| 644 | _IOWR(PECI_IOC_BASE, PECI_CMD_XFER, struct peci_xfer_msg) |
| 645 | |
| 646 | #define PECI_IOC_PING \ |
| 647 | _IOWR(PECI_IOC_BASE, PECI_CMD_PING, struct peci_ping_msg) |
| 648 | |
| 649 | #define PECI_IOC_GET_DIB \ |
| 650 | _IOWR(PECI_IOC_BASE, PECI_CMD_GET_DIB, struct peci_get_dib_msg) |
| 651 | |
| 652 | #define PECI_IOC_GET_TEMP \ |
| 653 | _IOWR(PECI_IOC_BASE, PECI_CMD_GET_TEMP, struct peci_get_temp_msg) |
| 654 | |
| 655 | #define PECI_IOC_RD_PKG_CFG \ |
| 656 | _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PKG_CFG, struct peci_rd_pkg_cfg_msg) |
| 657 | |
| 658 | #define PECI_IOC_WR_PKG_CFG \ |
| 659 | _IOWR(PECI_IOC_BASE, PECI_CMD_WR_PKG_CFG, struct peci_wr_pkg_cfg_msg) |
| 660 | |
| 661 | #define PECI_IOC_RD_IA_MSR \ |
| 662 | _IOWR(PECI_IOC_BASE, PECI_CMD_RD_IA_MSR, struct peci_rd_ia_msr_msg) |
| 663 | |
| 664 | #define PECI_IOC_WR_IA_MSR \ |
| 665 | _IOWR(PECI_IOC_BASE, PECI_CMD_WR_IA_MSR, struct peci_wr_ia_msr_msg) |
| 666 | |
| 667 | #define PECI_IOC_RD_IA_MSREX \ |
| 668 | _IOWR(PECI_IOC_BASE, PECI_CMD_RD_IA_MSREX, struct peci_rd_ia_msrex_msg) |
| 669 | |
| 670 | #define PECI_IOC_RD_PCI_CFG \ |
| 671 | _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PCI_CFG, struct peci_rd_pci_cfg_msg) |
| 672 | |
| 673 | #define PECI_IOC_WR_PCI_CFG \ |
| 674 | _IOWR(PECI_IOC_BASE, PECI_CMD_WR_PCI_CFG, struct peci_wr_pci_cfg_msg) |
| 675 | |
| 676 | #define PECI_IOC_RD_PCI_CFG_LOCAL \ |
| 677 | _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PCI_CFG_LOCAL, \ |
| 678 | struct peci_rd_pci_cfg_local_msg) |
| 679 | |
| 680 | #define PECI_IOC_WR_PCI_CFG_LOCAL \ |
| 681 | _IOWR(PECI_IOC_BASE, PECI_CMD_WR_PCI_CFG_LOCAL, \ |
| 682 | struct peci_wr_pci_cfg_local_msg) |
| 683 | |
| 684 | #define PECI_IOC_RD_END_PT_CFG \ |
| 685 | _IOWR(PECI_IOC_BASE, PECI_CMD_RD_END_PT_CFG, \ |
| 686 | struct peci_rd_end_pt_cfg_msg) |
| 687 | |
| 688 | #define PECI_IOC_WR_END_PT_CFG \ |
| 689 | _IOWR(PECI_IOC_BASE, PECI_CMD_WR_END_PT_CFG, \ |
| 690 | struct peci_wr_end_pt_cfg_msg) |
| 691 | |
| 692 | #define PECI_IOC_CRASHDUMP_DISC \ |
| 693 | _IOWR(PECI_IOC_BASE, PECI_CMD_CRASHDUMP_DISC, \ |
| 694 | struct peci_crashdump_disc_msg) |
| 695 | |
| 696 | #define PECI_IOC_CRASHDUMP_GET_FRAME \ |
| 697 | _IOWR(PECI_IOC_BASE, PECI_CMD_CRASHDUMP_GET_FRAME, \ |
| 698 | struct peci_crashdump_get_frame_msg) |
| 699 | |
| 700 | #endif /* __PECI_IOCTL_H */ |