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 #define CXL_EVENT_RECORD_DATA_LENGTH 0x50
25 struct cxl_event_generic {
26 struct cxl_event_record_hdr hdr;
27 u8 data[CXL_EVENT_RECORD_DATA_LENGTH];
31 * General Media Event Record
32 * CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43
34 #define CXL_EVENT_GEN_MED_COMP_ID_SIZE 0x10
35 struct cxl_event_gen_media {
36 struct cxl_event_record_hdr hdr;
45 u8 component_id[CXL_EVENT_GEN_MED_COMP_ID_SIZE];
50 * DRAM Event Record - DER
51 * CXL rev 3.0 section 8.2.9.2.1.2; Table 3-44
53 #define CXL_EVENT_DER_CORRECTION_MASK_SIZE 0x20
54 struct cxl_event_dram {
55 struct cxl_event_record_hdr hdr;
68 u8 correction_mask[CXL_EVENT_DER_CORRECTION_MASK_SIZE];
73 * Get Health Info Record
74 * CXL rev 3.0 section 8.2.9.8.3.1; Table 8-100
76 struct cxl_get_health_info {
82 u8 dirty_shutdown_cnt[4];
83 u8 cor_vol_err_cnt[4];
84 u8 cor_per_err_cnt[4];
88 * Memory Module Event Record
89 * CXL rev 3.0 section 8.2.9.2.1.3; Table 8-45
91 struct cxl_event_mem_module {
92 struct cxl_event_record_hdr hdr;
94 struct cxl_get_health_info info;
99 * General Media or DRAM Event Common Fields
100 * - provides common access to phys_addr
102 struct cxl_event_common {
103 struct cxl_event_record_hdr hdr;
108 struct cxl_event_generic generic;
109 struct cxl_event_gen_media gen_media;
110 struct cxl_event_dram dram;
111 struct cxl_event_mem_module mem_module;
112 struct cxl_event_common common;
116 * Common Event Record Format; in event logs
117 * CXL rev 3.0 section 8.2.9.2.1; Table 8-42
119 struct cxl_event_record_raw {
121 union cxl_event event;
124 enum cxl_event_type {
125 CXL_CPER_EVENT_GENERIC,
126 CXL_CPER_EVENT_GEN_MEDIA,
128 CXL_CPER_EVENT_MEM_MODULE,
131 #define CPER_CXL_DEVICE_ID_VALID BIT(0)
132 #define CPER_CXL_DEVICE_SN_VALID BIT(1)
133 #define CPER_CXL_COMP_EVENT_LOG_VALID BIT(2)
134 struct cxl_cper_event_rec {
138 struct cper_cxl_event_devid {
145 u16 slot_num; /* bits 2:0 reserved */
147 } __packed device_id;
148 struct cper_cxl_event_sn {
151 } __packed dev_serial_num;
154 union cxl_event event;
157 struct cxl_cper_work_data {
158 enum cxl_event_type event_type;
159 struct cxl_cper_event_rec rec;
162 #ifdef CONFIG_ACPI_APEI_GHES
163 int cxl_cper_register_work(struct work_struct *work);
164 int cxl_cper_unregister_work(struct work_struct *work);
165 int cxl_cper_kfifo_get(struct cxl_cper_work_data *wd);
167 static inline int cxl_cper_register_work(struct work_struct *work)
172 static inline int cxl_cper_unregister_work(struct work_struct *work)
176 static inline int cxl_cper_kfifo_get(struct cxl_cper_work_data *wd)
182 #endif /* _LINUX_CXL_EVENT_H */