blob: 77a116ddf032d65d12dd42daf961a44898aa9b68 [file] [log] [blame]
Jason M. Bills62cbc712020-05-07 14:07:49 -07001/* 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)
36#define PECI_DEV_RETRY_INTERVAL_MIN_MSEC 1
37#define PECI_DEV_RETRY_INTERVAL_MAX_MSEC 128
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 */
62enum 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 */
93struct 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 */
110struct 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 */
125struct 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 */
146struct 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
164 *
165 * The RdPkgConfig() command provides read access to the Package Configuration
166 * Space (PCS) within the processor, including various power and thermal
167 * management functions. Typical PCS read services supported by the processor
168 * may include access to temperature data, energy status, run time information,
169 * DIMM temperatures and so on.
170 */
171struct peci_rd_pkg_cfg_msg {
172#define PECI_RDPKGCFG_WRITE_LEN 5
173#define PECI_RDPKGCFG_READ_LEN_BASE 1
174#define PECI_RDPKGCFG_CMD 0xa1
175
176 __u8 addr;
177 __u8 index;
178#define PECI_MBX_INDEX_CPU_ID 0 /* Package Identifier Read */
179#define PECI_MBX_INDEX_VR_DEBUG 1 /* VR Debug */
180#define PECI_MBX_INDEX_PKG_TEMP_READ 2 /* Package Temperature Read */
181#define PECI_MBX_INDEX_ENERGY_COUNTER 3 /* Energy counter */
182#define PECI_MBX_INDEX_ENERGY_STATUS 4 /* DDR Energy Status */
183#define PECI_MBX_INDEX_WAKE_MODE_BIT 5 /* "Wake on PECI" Mode bit */
184#define PECI_MBX_INDEX_EPI 6 /* Efficient Performance Indication */
185#define PECI_MBX_INDEX_PKG_RAPL_PERF 8 /* Pkg RAPL Performance Status Read */
186#define PECI_MBX_INDEX_PER_CORE_DTS_TEMP 9 /* Per Core DTS Temperature Read */
187#define PECI_MBX_INDEX_DTS_MARGIN 10 /* DTS thermal margin */
188#define PECI_MBX_INDEX_SKT_PWR_THRTL_DUR 11 /* Socket Power Throttled Duration */
189#define PECI_MBX_INDEX_CFG_TDP_CONTROL 12 /* TDP Config Control */
190#define PECI_MBX_INDEX_CFG_TDP_LEVELS 13 /* TDP Config Levels */
191#define PECI_MBX_INDEX_DDR_DIMM_TEMP 14 /* DDR DIMM Temperature */
192#define PECI_MBX_INDEX_CFG_ICCMAX 15 /* Configurable ICCMAX */
193#define PECI_MBX_INDEX_TEMP_TARGET 16 /* Temperature Target Read */
194#define PECI_MBX_INDEX_CURR_CFG_LIMIT 17 /* Current Config Limit */
195#define PECI_MBX_INDEX_DIMM_TEMP_READ 20 /* Package Thermal Status Read */
196#define PECI_MBX_INDEX_DRAM_IMC_TMP_READ 22 /* DRAM IMC Temperature Read */
197#define PECI_MBX_INDEX_DDR_CH_THERM_STAT 23 /* DDR Channel Thermal Status */
198#define PECI_MBX_INDEX_PKG_POWER_LIMIT1 26 /* Package Power Limit1 */
199#define PECI_MBX_INDEX_PKG_POWER_LIMIT2 27 /* Package Power Limit2 */
200#define PECI_MBX_INDEX_TDP 28 /* Thermal design power minimum */
201#define PECI_MBX_INDEX_TDP_HIGH 29 /* Thermal design power maximum */
202#define PECI_MBX_INDEX_TDP_UNITS 30 /* Units for power/energy registers */
203#define PECI_MBX_INDEX_RUN_TIME 31 /* Accumulated Run Time */
204#define PECI_MBX_INDEX_CONSTRAINED_TIME 32 /* Thermally Constrained Time Read */
205#define PECI_MBX_INDEX_TURBO_RATIO 33 /* Turbo Activation Ratio */
206#define PECI_MBX_INDEX_DDR_RAPL_PL1 34 /* DDR RAPL PL1 */
207#define PECI_MBX_INDEX_DDR_PWR_INFO_HIGH 35 /* DRAM Power Info Read (high) */
208#define PECI_MBX_INDEX_DDR_PWR_INFO_LOW 36 /* DRAM Power Info Read (low) */
209#define PECI_MBX_INDEX_DDR_RAPL_PL2 37 /* DDR RAPL PL2 */
210#define PECI_MBX_INDEX_DDR_RAPL_STATUS 38 /* DDR RAPL Performance Status */
211#define PECI_MBX_INDEX_DDR_HOT_ABSOLUTE 43 /* DDR Hottest Dimm Absolute Temp */
212#define PECI_MBX_INDEX_DDR_HOT_RELATIVE 44 /* DDR Hottest Dimm Relative Temp */
213#define PECI_MBX_INDEX_DDR_THROTTLE_TIME 45 /* DDR Throttle Time */
214#define PECI_MBX_INDEX_DDR_THERM_STATUS 46 /* DDR Thermal Status */
215#define PECI_MBX_INDEX_TIME_AVG_TEMP 47 /* Package time-averaged temperature */
216#define PECI_MBX_INDEX_TURBO_RATIO_LIMIT 49 /* Turbo Ratio Limit Read */
217#define PECI_MBX_INDEX_HWP_AUTO_OOB 53 /* HWP Autonomous Out-of-band */
218#define PECI_MBX_INDEX_DDR_WARM_BUDGET 55 /* DDR Warm Power Budget */
219#define PECI_MBX_INDEX_DDR_HOT_BUDGET 56 /* DDR Hot Power Budget */
220#define PECI_MBX_INDEX_PKG_PSYS_PWR_LIM3 57 /* Package/Psys Power Limit3 */
221#define PECI_MBX_INDEX_PKG_PSYS_PWR_LIM1 58 /* Package/Psys Power Limit1 */
222#define PECI_MBX_INDEX_PKG_PSYS_PWR_LIM2 59 /* Package/Psys Power Limit2 */
223#define PECI_MBX_INDEX_PKG_PSYS_PWR_LIM4 60 /* Package/Psys Power Limit4 */
224#define PECI_MBX_INDEX_PERF_LIMIT_REASON 65 /* Performance Limit Reasons */
225
226 __u16 param;
227/* When index is PECI_MBX_INDEX_CPU_ID */
228#define PECI_PKG_ID_CPU_ID 0x0000 /* CPUID Info */
Jason M. Bills8fc53d72021-02-25 14:53:22 -0800229#define PECI_PKG_POWER_SKU_UNIT 0x0000 /* Time, Energy, Power units */
Jason M. Bills62cbc712020-05-07 14:07:49 -0700230#define PECI_PKG_ID_PLATFORM_ID 0x0001 /* Platform ID */
231#define PECI_PKG_ID_UNCORE_ID 0x0002 /* Uncore Device ID */
232#define PECI_PKG_ID_MAX_THREAD_ID 0x0003 /* Max Thread ID */
233#define PECI_PKG_ID_MICROCODE_REV 0x0004 /* CPU Microcode Update Revision */
234#define PECI_PKG_ID_MACHINE_CHECK_STATUS 0x0005 /* Machine Check Status */
Jason M. Bills8fc53d72021-02-25 14:53:22 -0800235#define PECI_PKG_ID_CPU_PACKAGE 0x00ff /* CPU package ID*/
236#define PECI_PKG_ID_DIMM 0x00ff /* DIMM ID*/
237#define PECI_PKG_ID_PLATFORM 0x00fe /* Entire platform ID */
Jason M. Bills62cbc712020-05-07 14:07:49 -0700238
239 __u8 rx_len;
240 __u8 cc;
241 __u8 padding[2];
242 __u8 pkg_config[4];
243} __attribute__((__packed__));
244
245/**
246 * struct peci_wr_pkg_cfg_msg - WrPkgConfig command
247 * @addr: address of the client
248 * @index: encoding index for the requested service
249 * @param: specific data being requested
250 * @tx_len: number of data to be written in bytes
251 * @cc: completion code
252 * @value: package config data to be written
253 *
254 * The WrPkgConfig() command provides write access to the Package Configuration
255 * Space (PCS) within the processor, including various power and thermal
256 * management functions. Typical PCS write services supported by the processor
257 * may include power limiting, thermal averaging constant programming and so
258 * on.
259 */
260struct peci_wr_pkg_cfg_msg {
261#define PECI_WRPKGCFG_WRITE_LEN_BASE 6
262#define PECI_WRPKGCFG_READ_LEN 1
263#define PECI_WRPKGCFG_CMD 0xa5
264
265 __u8 addr;
266 __u8 index;
267#define PECI_MBX_INDEX_DIMM_AMBIENT 19
268#define PECI_MBX_INDEX_DIMM_TEMP 24
269
270 __u16 param;
271 __u8 tx_len;
272 __u8 cc;
273 __u8 padding[2];
274 __u32 value;
275} __attribute__((__packed__));
276
277/**
278 * struct peci_rd_ia_msr_msg - RdIAMSR command
279 * @addr: address of the client
280 * @thread_id: ID of the specific logical processor
281 * @address: address of MSR to read from
282 * @cc: completion code
283 * @value: data to be read
284 *
285 * The RdIAMSR() PECI command provides read access to Model Specific Registers
286 * (MSRs) defined in the processor's Intel Architecture (IA).
287 */
288struct peci_rd_ia_msr_msg {
289#define PECI_RDIAMSR_WRITE_LEN 5
290#define PECI_RDIAMSR_READ_LEN 9
291#define PECI_RDIAMSR_CMD 0xb1
292
293 __u8 addr;
294 __u8 thread_id;
295 __u16 address;
296 __u8 cc;
297 __u8 padding[3];
298 __u64 value;
299} __attribute__((__packed__));
300
301/**
302 * struct peci_wr_ia_msr_msg - WrIAMSR command
303 * @addr: address of the client
304 * @thread_id: ID of the specific logical processor
305 * @address: address of MSR to write to
306 * @tx_len: number of data to be written in bytes
307 * @cc: completion code
308 * @value: data to be written
309 *
310 * The WrIAMSR() PECI command provides write access to Model Specific Registers
311 * (MSRs) defined in the processor's Intel Architecture (IA).
312 */
313struct peci_wr_ia_msr_msg {
314#define PECI_WRIAMSR_CMD 0xb5
315
316 __u8 addr;
317 __u8 thread_id;
318 __u16 address;
319 __u8 tx_len;
320 __u8 cc;
321 __u8 padding[2];
322 __u64 value;
323} __attribute__((__packed__));
324
325/**
326 * struct peci_rd_ia_msrex_msg - RdIAMSREX command
327 * @addr: address of the client
328 * @thread_id: ID of the specific logical processor
329 * @address: address of MSR to read from
330 * @cc: completion code
331 * @value: data to be read
332 *
333 * The RdIAMSREX() PECI command provides read access to Model Specific
334 * Registers (MSRs) defined in the processor's Intel Architecture (IA).
335 * The differences between RdIAMSREX() and RdIAMSR() are that:
336 * (1)RdIAMSR() can only read MC registers, RdIAMSREX() can read all MSRs
337 * (2)thread_id of RdIAMSR() is u8, thread_id of RdIAMSREX() is u16
338 */
339struct peci_rd_ia_msrex_msg {
340#define PECI_RDIAMSREX_WRITE_LEN 6
341#define PECI_RDIAMSREX_READ_LEN 9
342#define PECI_RDIAMSREX_CMD 0xd1
343
344 __u8 addr;
345 __u8 padding0;
346 __u16 thread_id;
347 __u16 address;
348 __u8 cc;
349 __u8 padding1;
350 __u64 value;
351} __attribute__((__packed__));
352
353/**
354 * struct peci_rd_pci_cfg_msg - RdPCIConfig command
355 * @addr: address of the client
356 * @bus: PCI bus number
357 * @device: PCI device number
358 * @function: specific function to read from
359 * @reg: specific register to read from
360 * @cc: completion code
361 * @pci_config: config data to be read
362 *
363 * The RdPCIConfig() command provides sideband read access to the PCI
364 * configuration space maintained in downstream devices external to the
365 * processor.
366 */
367struct peci_rd_pci_cfg_msg {
368#define PECI_RDPCICFG_WRITE_LEN 6
369#define PECI_RDPCICFG_READ_LEN 5
370#define PECI_RDPCICFG_READ_LEN_MAX 24
371#define PECI_RDPCICFG_CMD 0x61
372
373 __u8 addr;
374 __u8 bus;
375#define PECI_PCI_BUS0_CPU0 0x00
376#define PECI_PCI_BUS0_CPU1 0x80
377#define PECI_PCI_CPUBUSNO_BUS 0x00
378#define PECI_PCI_CPUBUSNO_DEV 0x08
379#define PECI_PCI_CPUBUSNO_FUNC 0x02
380#define PECI_PCI_CPUBUSNO 0xcc
381#define PECI_PCI_CPUBUSNO_1 0xd0
382#define PECI_PCI_CPUBUSNO_VALID 0xd4
383
384 __u8 device;
385 __u8 function;
386 __u16 reg;
387 __u8 cc;
388 __u8 padding[1];
389 __u8 pci_config[4];
390} __attribute__((__packed__));
391
392/**
393 * struct peci_wr_pci_cfg_msg - WrPCIConfig command
394 * @addr: address of the client
395 * @bus: PCI bus number
396 * @device: PCI device number
397 * @function: specific function to write to
398 * @reg: specific register to write to
399 * @tx_len: number of data to be written in bytes
400 * @cc: completion code
401 * @pci_config: config data to be written
402 *
403 * The RdPCIConfig() command provides sideband write access to the PCI
404 * configuration space maintained in downstream devices external to the
405 * processor.
406 */
407struct peci_wr_pci_cfg_msg {
408#define PECI_WRPCICFG_CMD 0x65
409
410 __u8 addr;
411 __u8 bus;
412 __u8 device;
413 __u8 function;
414 __u16 reg;
415 __u8 tx_len;
416 __u8 cc;
417 __u8 pci_config[4];
418} __attribute__((__packed__));
419
420/**
421 * struct peci_rd_pci_cfg_local_msg - RdPCIConfigLocal command
422 * @addr: address of the client
423 * @bus: PCI bus number
424 * @device: PCI device number
425 * @function: specific function to read from
426 * @reg: specific register to read from
427 * @rx_len: number of data to be read in bytes
428 * @cc: completion code
429 * @pci_config: config data to be read
430 *
431 * The RdPCIConfigLocal() command provides sideband read access to the PCI
432 * configuration space that resides within the processor. This includes all
433 * processor IIO and uncore registers within the PCI configuration space.
434 */
435struct peci_rd_pci_cfg_local_msg {
436#define PECI_RDPCICFGLOCAL_WRITE_LEN 5
437#define PECI_RDPCICFGLOCAL_READ_LEN_BASE 1
438#define PECI_RDPCICFGLOCAL_CMD 0xe1
439
440 __u8 addr;
441 __u8 bus;
442 __u8 device;
443 __u8 function;
444 __u16 reg;
445 __u8 rx_len;
446 __u8 cc;
447 __u8 pci_config[4];
448} __attribute__((__packed__));
449
450/**
451 * struct peci_wr_pci_cfg_local_msg - WrPCIConfigLocal command
452 * @addr: address of the client
453 * @bus: PCI bus number
454 * @device: PCI device number
455 * @function: specific function to read from
456 * @reg: specific register to read from
457 * @tx_len: number of data to be written in bytes
458 * @cc: completion code
459 * @value: config data to be written
460 *
461 * The WrPCIConfigLocal() command provides sideband write access to the PCI
462 * configuration space that resides within the processor. PECI originators can
463 * access this space even before BIOS enumeration of the system buses.
464 */
465struct peci_wr_pci_cfg_local_msg {
466#define PECI_WRPCICFGLOCAL_WRITE_LEN_BASE 6
467#define PECI_WRPCICFGLOCAL_READ_LEN 1
468#define PECI_WRPCICFGLOCAL_CMD 0xe5
469
470 __u8 addr;
471 __u8 bus;
472 __u8 device;
473 __u8 function;
474 __u16 reg;
475 __u8 tx_len;
476 __u8 cc;
477 __u32 value;
478} __attribute__((__packed__));
479
480struct peci_rd_end_pt_cfg_msg {
481#define PECI_RDENDPTCFG_PCI_WRITE_LEN 12
482#define PECI_RDENDPTCFG_MMIO_D_WRITE_LEN 14
483#define PECI_RDENDPTCFG_MMIO_Q_WRITE_LEN 18
484#define PECI_RDENDPTCFG_READ_LEN_BASE 1
485#define PECI_RDENDPTCFG_CMD 0xc1
486
487 __u8 addr;
488 __u8 msg_type;
489#define PECI_ENDPTCFG_TYPE_LOCAL_PCI 0x03
490#define PECI_ENDPTCFG_TYPE_PCI 0x04
491#define PECI_ENDPTCFG_TYPE_MMIO 0x05
492
493 union {
494 struct {
495 __u8 seg;
496 __u8 bus;
497 __u8 device;
498 __u8 function;
499 __u16 reg;
500 } pci_cfg;
501 struct {
502 __u8 seg;
503 __u8 bus;
504 __u8 device;
505 __u8 function;
506 __u8 bar;
507 __u8 addr_type;
508#define PECI_ENDPTCFG_ADDR_TYPE_PCI 0x04
509#define PECI_ENDPTCFG_ADDR_TYPE_MMIO_D 0x05
510#define PECI_ENDPTCFG_ADDR_TYPE_MMIO_Q 0x06
511
512 __u64 offset;
513 } mmio;
514 } params;
515 __u8 rx_len;
516 __u8 cc;
517 __u8 padding[2];
518 __u8 data[8];
519} __attribute__((__packed__));
520
521struct peci_wr_end_pt_cfg_msg {
522#define PECI_WRENDPTCFG_PCI_WRITE_LEN_BASE 13
523#define PECI_WRENDPTCFG_MMIO_D_WRITE_LEN_BASE 15
524#define PECI_WRENDPTCFG_MMIO_Q_WRITE_LEN_BASE 19
525#define PECI_WRENDPTCFG_READ_LEN 1
526#define PECI_WRENDPTCFG_CMD 0xc5
527
528 __u8 addr;
529 __u8 msg_type;
530 /* See msg_type in struct peci_rd_end_pt_cfg_msg */
531
532 union {
533 struct {
534 __u8 seg;
535 __u8 bus;
536 __u8 device;
537 __u8 function;
538 __u16 reg;
539 } pci_cfg;
540 struct {
541 __u8 seg;
542 __u8 bus;
543 __u8 device;
544 __u8 function;
545 __u8 bar;
546 __u8 addr_type;
547 /* See addr_type in struct peci_rd_end_pt_cfg_msg */
548
549 __u64 offset;
550 } mmio;
551 } params;
552 __u8 tx_len;
553 __u8 cc;
554 __u8 padding[2];
555 __u64 value;
556} __attribute__((__packed__));
557
558/* Crashdump Agent */
559#define PECI_CRASHDUMP_CORE 0x00
560#define PECI_CRASHDUMP_TOR 0x01
561
562/* Crashdump Agent Param */
563#define PECI_CRASHDUMP_PAYLOAD_SIZE 0x00
564
565/* Crashdump Agent Data Param */
566#define PECI_CRASHDUMP_AGENT_ID 0x00
567#define PECI_CRASHDUMP_AGENT_PARAM 0x01
568
569struct peci_crashdump_disc_msg {
570 __u8 addr;
571 __u8 subopcode;
572#define PECI_CRASHDUMP_ENABLED 0x00
573#define PECI_CRASHDUMP_NUM_AGENTS 0x01
574#define PECI_CRASHDUMP_AGENT_DATA 0x02
575
576 __u8 cc;
577 __u8 param0;
578 __u16 param1;
579 __u8 param2;
580 __u8 rx_len;
581 __u8 data[8];
582} __attribute__((__packed__));
583
584struct peci_crashdump_get_frame_msg {
585#define PECI_CRASHDUMP_DISC_WRITE_LEN 9
586#define PECI_CRASHDUMP_DISC_READ_LEN_BASE 1
587#define PECI_CRASHDUMP_DISC_VERSION 0
588#define PECI_CRASHDUMP_DISC_OPCODE 1
589#define PECI_CRASHDUMP_GET_FRAME_WRITE_LEN 10
590#define PECI_CRASHDUMP_GET_FRAME_READ_LEN_BASE 1
591#define PECI_CRASHDUMP_GET_FRAME_VERSION 0
592#define PECI_CRASHDUMP_GET_FRAME_OPCODE 3
593#define PECI_CRASHDUMP_CMD 0x71
594
595 __u8 addr;
596 __u8 padding0;
597 __u16 param0;
598 __u16 param1;
599 __u16 param2;
600 __u8 rx_len;
601 __u8 cc;
602 __u8 padding1[2];
603 __u8 data[16];
604} __attribute__((__packed__));
605
Jae Hyun Yooadf056a2021-02-25 12:44:08 -0800606#define PECI_IOC_BASE 0xb8
Jason M. Bills62cbc712020-05-07 14:07:49 -0700607
608#define PECI_IOC_XFER \
609 _IOWR(PECI_IOC_BASE, PECI_CMD_XFER, struct peci_xfer_msg)
610
611#define PECI_IOC_PING \
612 _IOWR(PECI_IOC_BASE, PECI_CMD_PING, struct peci_ping_msg)
613
614#define PECI_IOC_GET_DIB \
615 _IOWR(PECI_IOC_BASE, PECI_CMD_GET_DIB, struct peci_get_dib_msg)
616
617#define PECI_IOC_GET_TEMP \
618 _IOWR(PECI_IOC_BASE, PECI_CMD_GET_TEMP, struct peci_get_temp_msg)
619
620#define PECI_IOC_RD_PKG_CFG \
621 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PKG_CFG, struct peci_rd_pkg_cfg_msg)
622
623#define PECI_IOC_WR_PKG_CFG \
624 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_PKG_CFG, struct peci_wr_pkg_cfg_msg)
625
626#define PECI_IOC_RD_IA_MSR \
627 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_IA_MSR, struct peci_rd_ia_msr_msg)
628
629#define PECI_IOC_WR_IA_MSR \
630 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_IA_MSR, struct peci_wr_ia_msr_msg)
631
632#define PECI_IOC_RD_IA_MSREX \
633 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_IA_MSREX, struct peci_rd_ia_msrex_msg)
634
635#define PECI_IOC_RD_PCI_CFG \
636 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PCI_CFG, struct peci_rd_pci_cfg_msg)
637
638#define PECI_IOC_WR_PCI_CFG \
639 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_PCI_CFG, struct peci_wr_pci_cfg_msg)
640
641#define PECI_IOC_RD_PCI_CFG_LOCAL \
642 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PCI_CFG_LOCAL, \
643 struct peci_rd_pci_cfg_local_msg)
644
645#define PECI_IOC_WR_PCI_CFG_LOCAL \
646 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_PCI_CFG_LOCAL, \
647 struct peci_wr_pci_cfg_local_msg)
648
649#define PECI_IOC_RD_END_PT_CFG \
650 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_END_PT_CFG, \
651 struct peci_rd_end_pt_cfg_msg)
652
653#define PECI_IOC_WR_END_PT_CFG \
654 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_END_PT_CFG, \
655 struct peci_wr_end_pt_cfg_msg)
656
657#define PECI_IOC_CRASHDUMP_DISC \
658 _IOWR(PECI_IOC_BASE, PECI_CMD_CRASHDUMP_DISC, \
659 struct peci_crashdump_disc_msg)
660
661#define PECI_IOC_CRASHDUMP_GET_FRAME \
662 _IOWR(PECI_IOC_BASE, PECI_CMD_CRASHDUMP_GET_FRAME, \
663 struct peci_crashdump_get_frame_msg)
664
665#endif /* __PECI_IOCTL_H */