1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2023 Intel Corporation. */
3 #ifndef _LINUX_CXL_EVENT_H
4 #define _LINUX_CXL_EVENT_H
6 #include <linux/types.h>
7 #include <linux/uuid.h>
8 #include <linux/workqueue_types.h>
11 * Common Event Record Format
12 * CXL rev 3.0 section 8.2.9.2.1; Table 8-42
14 struct cxl_event_record_hdr
{
18 __le16 related_handle
;
24 struct cxl_event_media_hdr
{
25 struct cxl_event_record_hdr hdr
;
31 * The meaning of Validity Flags from bit 2 is
32 * different across DRAM and General Media records
39 #define CXL_EVENT_RECORD_DATA_LENGTH 0x50
40 struct cxl_event_generic
{
41 struct cxl_event_record_hdr hdr
;
42 u8 data
[CXL_EVENT_RECORD_DATA_LENGTH
];
46 * General Media Event Record
47 * CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43
49 #define CXL_EVENT_GEN_MED_COMP_ID_SIZE 0x10
50 struct cxl_event_gen_media
{
51 struct cxl_event_media_hdr media_hdr
;
53 u8 component_id
[CXL_EVENT_GEN_MED_COMP_ID_SIZE
];
58 * DRAM Event Record - DER
59 * CXL rev 3.0 section 8.2.9.2.1.2; Table 3-44
61 #define CXL_EVENT_DER_CORRECTION_MASK_SIZE 0x20
62 struct cxl_event_dram
{
63 struct cxl_event_media_hdr media_hdr
;
69 u8 correction_mask
[CXL_EVENT_DER_CORRECTION_MASK_SIZE
];
74 * Get Health Info Record
75 * CXL rev 3.0 section 8.2.9.8.3.1; Table 8-100
77 struct cxl_get_health_info
{
83 u8 dirty_shutdown_cnt
[4];
84 u8 cor_vol_err_cnt
[4];
85 u8 cor_per_err_cnt
[4];
89 * Memory Module Event Record
90 * CXL rev 3.0 section 8.2.9.2.1.3; Table 8-45
92 struct cxl_event_mem_module
{
93 struct cxl_event_record_hdr hdr
;
95 struct cxl_get_health_info info
;
100 struct cxl_event_generic generic
;
101 struct cxl_event_gen_media gen_media
;
102 struct cxl_event_dram dram
;
103 struct cxl_event_mem_module mem_module
;
104 /* dram & gen_media event header */
105 struct cxl_event_media_hdr media_hdr
;
109 * Common Event Record Format; in event logs
110 * CXL rev 3.0 section 8.2.9.2.1; Table 8-42
112 struct cxl_event_record_raw
{
114 union cxl_event event
;
117 enum cxl_event_type
{
118 CXL_CPER_EVENT_GENERIC
,
119 CXL_CPER_EVENT_GEN_MEDIA
,
121 CXL_CPER_EVENT_MEM_MODULE
,
124 #define CPER_CXL_DEVICE_ID_VALID BIT(0)
125 #define CPER_CXL_DEVICE_SN_VALID BIT(1)
126 #define CPER_CXL_COMP_EVENT_LOG_VALID BIT(2)
127 struct cxl_cper_event_rec
{
131 struct cper_cxl_event_devid
{
138 u16 slot_num
; /* bits 2:0 reserved */
140 } __packed device_id
;
141 struct cper_cxl_event_sn
{
144 } __packed dev_serial_num
;
147 union cxl_event event
;
150 struct cxl_cper_work_data
{
151 enum cxl_event_type event_type
;
152 struct cxl_cper_event_rec rec
;
155 #ifdef CONFIG_ACPI_APEI_GHES
156 int cxl_cper_register_work(struct work_struct
*work
);
157 int cxl_cper_unregister_work(struct work_struct
*work
);
158 int cxl_cper_kfifo_get(struct cxl_cper_work_data
*wd
);
160 static inline int cxl_cper_register_work(struct work_struct
*work
)
165 static inline int cxl_cper_unregister_work(struct work_struct
*work
)
169 static inline int cxl_cper_kfifo_get(struct cxl_cper_work_data
*wd
)
175 #endif /* _LINUX_CXL_EVENT_H */