blob: 6bd34a139249b2505b95b20684614ff2a77e0bbc [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 */
229#define PECI_PKG_ID_PLATFORM_ID 0x0001 /* Platform ID */
230#define PECI_PKG_ID_UNCORE_ID 0x0002 /* Uncore Device ID */
231#define PECI_PKG_ID_MAX_THREAD_ID 0x0003 /* Max Thread ID */
232#define PECI_PKG_ID_MICROCODE_REV 0x0004 /* CPU Microcode Update Revision */
233#define PECI_PKG_ID_MACHINE_CHECK_STATUS 0x0005 /* Machine Check Status */
234#define PECI_PKG_ID_PKG_ENERGY_STATUS 0x00ff /* Average Energy */
235
236 __u8 rx_len;
237 __u8 cc;
238 __u8 padding[2];
239 __u8 pkg_config[4];
240} __attribute__((__packed__));
241
242/**
243 * struct peci_wr_pkg_cfg_msg - WrPkgConfig command
244 * @addr: address of the client
245 * @index: encoding index for the requested service
246 * @param: specific data being requested
247 * @tx_len: number of data to be written in bytes
248 * @cc: completion code
249 * @value: package config data to be written
250 *
251 * The WrPkgConfig() command provides write access to the Package Configuration
252 * Space (PCS) within the processor, including various power and thermal
253 * management functions. Typical PCS write services supported by the processor
254 * may include power limiting, thermal averaging constant programming and so
255 * on.
256 */
257struct peci_wr_pkg_cfg_msg {
258#define PECI_WRPKGCFG_WRITE_LEN_BASE 6
259#define PECI_WRPKGCFG_READ_LEN 1
260#define PECI_WRPKGCFG_CMD 0xa5
261
262 __u8 addr;
263 __u8 index;
264#define PECI_MBX_INDEX_DIMM_AMBIENT 19
265#define PECI_MBX_INDEX_DIMM_TEMP 24
266
267 __u16 param;
268 __u8 tx_len;
269 __u8 cc;
270 __u8 padding[2];
271 __u32 value;
272} __attribute__((__packed__));
273
274/**
275 * struct peci_rd_ia_msr_msg - RdIAMSR command
276 * @addr: address of the client
277 * @thread_id: ID of the specific logical processor
278 * @address: address of MSR to read from
279 * @cc: completion code
280 * @value: data to be read
281 *
282 * The RdIAMSR() PECI command provides read access to Model Specific Registers
283 * (MSRs) defined in the processor's Intel Architecture (IA).
284 */
285struct peci_rd_ia_msr_msg {
286#define PECI_RDIAMSR_WRITE_LEN 5
287#define PECI_RDIAMSR_READ_LEN 9
288#define PECI_RDIAMSR_CMD 0xb1
289
290 __u8 addr;
291 __u8 thread_id;
292 __u16 address;
293 __u8 cc;
294 __u8 padding[3];
295 __u64 value;
296} __attribute__((__packed__));
297
298/**
299 * struct peci_wr_ia_msr_msg - WrIAMSR command
300 * @addr: address of the client
301 * @thread_id: ID of the specific logical processor
302 * @address: address of MSR to write to
303 * @tx_len: number of data to be written in bytes
304 * @cc: completion code
305 * @value: data to be written
306 *
307 * The WrIAMSR() PECI command provides write access to Model Specific Registers
308 * (MSRs) defined in the processor's Intel Architecture (IA).
309 */
310struct peci_wr_ia_msr_msg {
311#define PECI_WRIAMSR_CMD 0xb5
312
313 __u8 addr;
314 __u8 thread_id;
315 __u16 address;
316 __u8 tx_len;
317 __u8 cc;
318 __u8 padding[2];
319 __u64 value;
320} __attribute__((__packed__));
321
322/**
323 * struct peci_rd_ia_msrex_msg - RdIAMSREX command
324 * @addr: address of the client
325 * @thread_id: ID of the specific logical processor
326 * @address: address of MSR to read from
327 * @cc: completion code
328 * @value: data to be read
329 *
330 * The RdIAMSREX() PECI command provides read access to Model Specific
331 * Registers (MSRs) defined in the processor's Intel Architecture (IA).
332 * The differences between RdIAMSREX() and RdIAMSR() are that:
333 * (1)RdIAMSR() can only read MC registers, RdIAMSREX() can read all MSRs
334 * (2)thread_id of RdIAMSR() is u8, thread_id of RdIAMSREX() is u16
335 */
336struct peci_rd_ia_msrex_msg {
337#define PECI_RDIAMSREX_WRITE_LEN 6
338#define PECI_RDIAMSREX_READ_LEN 9
339#define PECI_RDIAMSREX_CMD 0xd1
340
341 __u8 addr;
342 __u8 padding0;
343 __u16 thread_id;
344 __u16 address;
345 __u8 cc;
346 __u8 padding1;
347 __u64 value;
348} __attribute__((__packed__));
349
350/**
351 * struct peci_rd_pci_cfg_msg - RdPCIConfig command
352 * @addr: address of the client
353 * @bus: PCI bus number
354 * @device: PCI device number
355 * @function: specific function to read from
356 * @reg: specific register to read from
357 * @cc: completion code
358 * @pci_config: config data to be read
359 *
360 * The RdPCIConfig() command provides sideband read access to the PCI
361 * configuration space maintained in downstream devices external to the
362 * processor.
363 */
364struct peci_rd_pci_cfg_msg {
365#define PECI_RDPCICFG_WRITE_LEN 6
366#define PECI_RDPCICFG_READ_LEN 5
367#define PECI_RDPCICFG_READ_LEN_MAX 24
368#define PECI_RDPCICFG_CMD 0x61
369
370 __u8 addr;
371 __u8 bus;
372#define PECI_PCI_BUS0_CPU0 0x00
373#define PECI_PCI_BUS0_CPU1 0x80
374#define PECI_PCI_CPUBUSNO_BUS 0x00
375#define PECI_PCI_CPUBUSNO_DEV 0x08
376#define PECI_PCI_CPUBUSNO_FUNC 0x02
377#define PECI_PCI_CPUBUSNO 0xcc
378#define PECI_PCI_CPUBUSNO_1 0xd0
379#define PECI_PCI_CPUBUSNO_VALID 0xd4
380
381 __u8 device;
382 __u8 function;
383 __u16 reg;
384 __u8 cc;
385 __u8 padding[1];
386 __u8 pci_config[4];
387} __attribute__((__packed__));
388
389/**
390 * struct peci_wr_pci_cfg_msg - WrPCIConfig command
391 * @addr: address of the client
392 * @bus: PCI bus number
393 * @device: PCI device number
394 * @function: specific function to write to
395 * @reg: specific register to write to
396 * @tx_len: number of data to be written in bytes
397 * @cc: completion code
398 * @pci_config: config data to be written
399 *
400 * The RdPCIConfig() command provides sideband write access to the PCI
401 * configuration space maintained in downstream devices external to the
402 * processor.
403 */
404struct peci_wr_pci_cfg_msg {
405#define PECI_WRPCICFG_CMD 0x65
406
407 __u8 addr;
408 __u8 bus;
409 __u8 device;
410 __u8 function;
411 __u16 reg;
412 __u8 tx_len;
413 __u8 cc;
414 __u8 pci_config[4];
415} __attribute__((__packed__));
416
417/**
418 * struct peci_rd_pci_cfg_local_msg - RdPCIConfigLocal command
419 * @addr: address of the client
420 * @bus: PCI bus number
421 * @device: PCI device number
422 * @function: specific function to read from
423 * @reg: specific register to read from
424 * @rx_len: number of data to be read in bytes
425 * @cc: completion code
426 * @pci_config: config data to be read
427 *
428 * The RdPCIConfigLocal() command provides sideband read access to the PCI
429 * configuration space that resides within the processor. This includes all
430 * processor IIO and uncore registers within the PCI configuration space.
431 */
432struct peci_rd_pci_cfg_local_msg {
433#define PECI_RDPCICFGLOCAL_WRITE_LEN 5
434#define PECI_RDPCICFGLOCAL_READ_LEN_BASE 1
435#define PECI_RDPCICFGLOCAL_CMD 0xe1
436
437 __u8 addr;
438 __u8 bus;
439 __u8 device;
440 __u8 function;
441 __u16 reg;
442 __u8 rx_len;
443 __u8 cc;
444 __u8 pci_config[4];
445} __attribute__((__packed__));
446
447/**
448 * struct peci_wr_pci_cfg_local_msg - WrPCIConfigLocal command
449 * @addr: address of the client
450 * @bus: PCI bus number
451 * @device: PCI device number
452 * @function: specific function to read from
453 * @reg: specific register to read from
454 * @tx_len: number of data to be written in bytes
455 * @cc: completion code
456 * @value: config data to be written
457 *
458 * The WrPCIConfigLocal() command provides sideband write access to the PCI
459 * configuration space that resides within the processor. PECI originators can
460 * access this space even before BIOS enumeration of the system buses.
461 */
462struct peci_wr_pci_cfg_local_msg {
463#define PECI_WRPCICFGLOCAL_WRITE_LEN_BASE 6
464#define PECI_WRPCICFGLOCAL_READ_LEN 1
465#define PECI_WRPCICFGLOCAL_CMD 0xe5
466
467 __u8 addr;
468 __u8 bus;
469 __u8 device;
470 __u8 function;
471 __u16 reg;
472 __u8 tx_len;
473 __u8 cc;
474 __u32 value;
475} __attribute__((__packed__));
476
477struct peci_rd_end_pt_cfg_msg {
478#define PECI_RDENDPTCFG_PCI_WRITE_LEN 12
479#define PECI_RDENDPTCFG_MMIO_D_WRITE_LEN 14
480#define PECI_RDENDPTCFG_MMIO_Q_WRITE_LEN 18
481#define PECI_RDENDPTCFG_READ_LEN_BASE 1
482#define PECI_RDENDPTCFG_CMD 0xc1
483
484 __u8 addr;
485 __u8 msg_type;
486#define PECI_ENDPTCFG_TYPE_LOCAL_PCI 0x03
487#define PECI_ENDPTCFG_TYPE_PCI 0x04
488#define PECI_ENDPTCFG_TYPE_MMIO 0x05
489
490 union {
491 struct {
492 __u8 seg;
493 __u8 bus;
494 __u8 device;
495 __u8 function;
496 __u16 reg;
497 } pci_cfg;
498 struct {
499 __u8 seg;
500 __u8 bus;
501 __u8 device;
502 __u8 function;
503 __u8 bar;
504 __u8 addr_type;
505#define PECI_ENDPTCFG_ADDR_TYPE_PCI 0x04
506#define PECI_ENDPTCFG_ADDR_TYPE_MMIO_D 0x05
507#define PECI_ENDPTCFG_ADDR_TYPE_MMIO_Q 0x06
508
509 __u64 offset;
510 } mmio;
511 } params;
512 __u8 rx_len;
513 __u8 cc;
514 __u8 padding[2];
515 __u8 data[8];
516} __attribute__((__packed__));
517
518struct peci_wr_end_pt_cfg_msg {
519#define PECI_WRENDPTCFG_PCI_WRITE_LEN_BASE 13
520#define PECI_WRENDPTCFG_MMIO_D_WRITE_LEN_BASE 15
521#define PECI_WRENDPTCFG_MMIO_Q_WRITE_LEN_BASE 19
522#define PECI_WRENDPTCFG_READ_LEN 1
523#define PECI_WRENDPTCFG_CMD 0xc5
524
525 __u8 addr;
526 __u8 msg_type;
527 /* See msg_type in struct peci_rd_end_pt_cfg_msg */
528
529 union {
530 struct {
531 __u8 seg;
532 __u8 bus;
533 __u8 device;
534 __u8 function;
535 __u16 reg;
536 } pci_cfg;
537 struct {
538 __u8 seg;
539 __u8 bus;
540 __u8 device;
541 __u8 function;
542 __u8 bar;
543 __u8 addr_type;
544 /* See addr_type in struct peci_rd_end_pt_cfg_msg */
545
546 __u64 offset;
547 } mmio;
548 } params;
549 __u8 tx_len;
550 __u8 cc;
551 __u8 padding[2];
552 __u64 value;
553} __attribute__((__packed__));
554
555/* Crashdump Agent */
556#define PECI_CRASHDUMP_CORE 0x00
557#define PECI_CRASHDUMP_TOR 0x01
558
559/* Crashdump Agent Param */
560#define PECI_CRASHDUMP_PAYLOAD_SIZE 0x00
561
562/* Crashdump Agent Data Param */
563#define PECI_CRASHDUMP_AGENT_ID 0x00
564#define PECI_CRASHDUMP_AGENT_PARAM 0x01
565
566struct peci_crashdump_disc_msg {
567 __u8 addr;
568 __u8 subopcode;
569#define PECI_CRASHDUMP_ENABLED 0x00
570#define PECI_CRASHDUMP_NUM_AGENTS 0x01
571#define PECI_CRASHDUMP_AGENT_DATA 0x02
572
573 __u8 cc;
574 __u8 param0;
575 __u16 param1;
576 __u8 param2;
577 __u8 rx_len;
578 __u8 data[8];
579} __attribute__((__packed__));
580
581struct peci_crashdump_get_frame_msg {
582#define PECI_CRASHDUMP_DISC_WRITE_LEN 9
583#define PECI_CRASHDUMP_DISC_READ_LEN_BASE 1
584#define PECI_CRASHDUMP_DISC_VERSION 0
585#define PECI_CRASHDUMP_DISC_OPCODE 1
586#define PECI_CRASHDUMP_GET_FRAME_WRITE_LEN 10
587#define PECI_CRASHDUMP_GET_FRAME_READ_LEN_BASE 1
588#define PECI_CRASHDUMP_GET_FRAME_VERSION 0
589#define PECI_CRASHDUMP_GET_FRAME_OPCODE 3
590#define PECI_CRASHDUMP_CMD 0x71
591
592 __u8 addr;
593 __u8 padding0;
594 __u16 param0;
595 __u16 param1;
596 __u16 param2;
597 __u8 rx_len;
598 __u8 cc;
599 __u8 padding1[2];
600 __u8 data[16];
601} __attribute__((__packed__));
602
Jae Hyun Yooadf056a2021-02-25 12:44:08 -0800603#define PECI_IOC_BASE 0xb8
Jason M. Bills62cbc712020-05-07 14:07:49 -0700604
605#define PECI_IOC_XFER \
606 _IOWR(PECI_IOC_BASE, PECI_CMD_XFER, struct peci_xfer_msg)
607
608#define PECI_IOC_PING \
609 _IOWR(PECI_IOC_BASE, PECI_CMD_PING, struct peci_ping_msg)
610
611#define PECI_IOC_GET_DIB \
612 _IOWR(PECI_IOC_BASE, PECI_CMD_GET_DIB, struct peci_get_dib_msg)
613
614#define PECI_IOC_GET_TEMP \
615 _IOWR(PECI_IOC_BASE, PECI_CMD_GET_TEMP, struct peci_get_temp_msg)
616
617#define PECI_IOC_RD_PKG_CFG \
618 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PKG_CFG, struct peci_rd_pkg_cfg_msg)
619
620#define PECI_IOC_WR_PKG_CFG \
621 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_PKG_CFG, struct peci_wr_pkg_cfg_msg)
622
623#define PECI_IOC_RD_IA_MSR \
624 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_IA_MSR, struct peci_rd_ia_msr_msg)
625
626#define PECI_IOC_WR_IA_MSR \
627 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_IA_MSR, struct peci_wr_ia_msr_msg)
628
629#define PECI_IOC_RD_IA_MSREX \
630 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_IA_MSREX, struct peci_rd_ia_msrex_msg)
631
632#define PECI_IOC_RD_PCI_CFG \
633 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PCI_CFG, struct peci_rd_pci_cfg_msg)
634
635#define PECI_IOC_WR_PCI_CFG \
636 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_PCI_CFG, struct peci_wr_pci_cfg_msg)
637
638#define PECI_IOC_RD_PCI_CFG_LOCAL \
639 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_PCI_CFG_LOCAL, \
640 struct peci_rd_pci_cfg_local_msg)
641
642#define PECI_IOC_WR_PCI_CFG_LOCAL \
643 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_PCI_CFG_LOCAL, \
644 struct peci_wr_pci_cfg_local_msg)
645
646#define PECI_IOC_RD_END_PT_CFG \
647 _IOWR(PECI_IOC_BASE, PECI_CMD_RD_END_PT_CFG, \
648 struct peci_rd_end_pt_cfg_msg)
649
650#define PECI_IOC_WR_END_PT_CFG \
651 _IOWR(PECI_IOC_BASE, PECI_CMD_WR_END_PT_CFG, \
652 struct peci_wr_end_pt_cfg_msg)
653
654#define PECI_IOC_CRASHDUMP_DISC \
655 _IOWR(PECI_IOC_BASE, PECI_CMD_CRASHDUMP_DISC, \
656 struct peci_crashdump_disc_msg)
657
658#define PECI_IOC_CRASHDUMP_GET_FRAME \
659 _IOWR(PECI_IOC_BASE, PECI_CMD_CRASHDUMP_GET_FRAME, \
660 struct peci_crashdump_get_frame_msg)
661
662#endif /* __PECI_IOCTL_H */