Skip to content

Commit 26a1a86

Browse files
weiny2djbw
authored andcommitted
cxl/events: Promote CXL event structures to a core header
UEFI code can process CXL events through CPER records. Those records use almost the same format as the CXL events. Lift the CXL event structures to a core header to be shared in later patches. [jic123: drop "CXL rev 3.0" mention] Signed-off-by: Ira Weiny <ira.weiny@intel.com> Link: https://lore.kernel.org/r/20231220-cxl-cper-v5-2-1bb8a4ca2c7a@intel.com [djbw: add F: entry to maintainers for include/linux/cxl-event.h] Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 6d0fc41 commit 26a1a86

3 files changed

Lines changed: 97 additions & 89 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5245,6 +5245,7 @@ M: Dan Williams <dan.j.williams@intel.com>
52455245
L: linux-cxl@vger.kernel.org
52465246
S: Maintained
52475247
F: drivers/cxl/
5248+
F: include/linux/cxl-event.h
52485249
F: include/uapi/linux/cxl_mem.h
52495250
F: tools/testing/cxl/
52505251

drivers/cxl/cxlmem.h

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/cdev.h>
77
#include <linux/uuid.h>
88
#include <linux/rcuwait.h>
9+
#include <linux/cxl-event.h>
910
#include "cxl.h"
1011

1112
/* CXL 2.0 8.2.8.5.1.1 Memory Device Status Register */
@@ -579,27 +580,6 @@ struct cxl_mbox_identify {
579580
u8 qos_telemetry_caps;
580581
} __packed;
581582

582-
/*
583-
* Common Event Record Format
584-
* CXL rev 3.0 section 8.2.9.2.1; Table 8-42
585-
*/
586-
struct cxl_event_record_hdr {
587-
uuid_t id;
588-
u8 length;
589-
u8 flags[3];
590-
__le16 handle;
591-
__le16 related_handle;
592-
__le64 timestamp;
593-
u8 maint_op_class;
594-
u8 reserved[15];
595-
} __packed;
596-
597-
#define CXL_EVENT_RECORD_DATA_LENGTH 0x50
598-
struct cxl_event_record_raw {
599-
struct cxl_event_record_hdr hdr;
600-
u8 data[CXL_EVENT_RECORD_DATA_LENGTH];
601-
} __packed;
602-
603583
/*
604584
* Get Event Records output payload
605585
* CXL rev 3.0 section 8.2.9.2.2; Table 8-50
@@ -641,74 +621,6 @@ struct cxl_mbox_clear_event_payload {
641621
} __packed;
642622
#define CXL_CLEAR_EVENT_MAX_HANDLES U8_MAX
643623

644-
/*
645-
* General Media Event Record
646-
* CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43
647-
*/
648-
#define CXL_EVENT_GEN_MED_COMP_ID_SIZE 0x10
649-
struct cxl_event_gen_media {
650-
struct cxl_event_record_hdr hdr;
651-
__le64 phys_addr;
652-
u8 descriptor;
653-
u8 type;
654-
u8 transaction_type;
655-
u8 validity_flags[2];
656-
u8 channel;
657-
u8 rank;
658-
u8 device[3];
659-
u8 component_id[CXL_EVENT_GEN_MED_COMP_ID_SIZE];
660-
u8 reserved[46];
661-
} __packed;
662-
663-
/*
664-
* DRAM Event Record - DER
665-
* CXL rev 3.0 section 8.2.9.2.1.2; Table 3-44
666-
*/
667-
#define CXL_EVENT_DER_CORRECTION_MASK_SIZE 0x20
668-
struct cxl_event_dram {
669-
struct cxl_event_record_hdr hdr;
670-
__le64 phys_addr;
671-
u8 descriptor;
672-
u8 type;
673-
u8 transaction_type;
674-
u8 validity_flags[2];
675-
u8 channel;
676-
u8 rank;
677-
u8 nibble_mask[3];
678-
u8 bank_group;
679-
u8 bank;
680-
u8 row[3];
681-
u8 column[2];
682-
u8 correction_mask[CXL_EVENT_DER_CORRECTION_MASK_SIZE];
683-
u8 reserved[0x17];
684-
} __packed;
685-
686-
/*
687-
* Get Health Info Record
688-
* CXL rev 3.0 section 8.2.9.8.3.1; Table 8-100
689-
*/
690-
struct cxl_get_health_info {
691-
u8 health_status;
692-
u8 media_status;
693-
u8 add_status;
694-
u8 life_used;
695-
u8 device_temp[2];
696-
u8 dirty_shutdown_cnt[4];
697-
u8 cor_vol_err_cnt[4];
698-
u8 cor_per_err_cnt[4];
699-
} __packed;
700-
701-
/*
702-
* Memory Module Event Record
703-
* CXL rev 3.0 section 8.2.9.2.1.3; Table 8-45
704-
*/
705-
struct cxl_event_mem_module {
706-
struct cxl_event_record_hdr hdr;
707-
u8 event_type;
708-
struct cxl_get_health_info info;
709-
u8 reserved[0x3d];
710-
} __packed;
711-
712624
struct cxl_mbox_get_partition_info {
713625
__le64 active_volatile_cap;
714626
__le64 active_persistent_cap;

include/linux/cxl-event.h

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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
5+
6+
/*
7+
* Common Event Record Format
8+
* CXL rev 3.0 section 8.2.9.2.1; Table 8-42
9+
*/
10+
struct cxl_event_record_hdr {
11+
uuid_t id;
12+
u8 length;
13+
u8 flags[3];
14+
__le16 handle;
15+
__le16 related_handle;
16+
__le64 timestamp;
17+
u8 maint_op_class;
18+
u8 reserved[15];
19+
} __packed;
20+
21+
#define CXL_EVENT_RECORD_DATA_LENGTH 0x50
22+
struct cxl_event_record_raw {
23+
struct cxl_event_record_hdr hdr;
24+
u8 data[CXL_EVENT_RECORD_DATA_LENGTH];
25+
} __packed;
26+
27+
/*
28+
* General Media Event Record
29+
* CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43
30+
*/
31+
#define CXL_EVENT_GEN_MED_COMP_ID_SIZE 0x10
32+
struct cxl_event_gen_media {
33+
struct cxl_event_record_hdr hdr;
34+
__le64 phys_addr;
35+
u8 descriptor;
36+
u8 type;
37+
u8 transaction_type;
38+
u8 validity_flags[2];
39+
u8 channel;
40+
u8 rank;
41+
u8 device[3];
42+
u8 component_id[CXL_EVENT_GEN_MED_COMP_ID_SIZE];
43+
u8 reserved[46];
44+
} __packed;
45+
46+
/*
47+
* DRAM Event Record - DER
48+
* CXL rev 3.0 section 8.2.9.2.1.2; Table 3-44
49+
*/
50+
#define CXL_EVENT_DER_CORRECTION_MASK_SIZE 0x20
51+
struct cxl_event_dram {
52+
struct cxl_event_record_hdr hdr;
53+
__le64 phys_addr;
54+
u8 descriptor;
55+
u8 type;
56+
u8 transaction_type;
57+
u8 validity_flags[2];
58+
u8 channel;
59+
u8 rank;
60+
u8 nibble_mask[3];
61+
u8 bank_group;
62+
u8 bank;
63+
u8 row[3];
64+
u8 column[2];
65+
u8 correction_mask[CXL_EVENT_DER_CORRECTION_MASK_SIZE];
66+
u8 reserved[0x17];
67+
} __packed;
68+
69+
/*
70+
* Get Health Info Record
71+
* CXL rev 3.0 section 8.2.9.8.3.1; Table 8-100
72+
*/
73+
struct cxl_get_health_info {
74+
u8 health_status;
75+
u8 media_status;
76+
u8 add_status;
77+
u8 life_used;
78+
u8 device_temp[2];
79+
u8 dirty_shutdown_cnt[4];
80+
u8 cor_vol_err_cnt[4];
81+
u8 cor_per_err_cnt[4];
82+
} __packed;
83+
84+
/*
85+
* Memory Module Event Record
86+
* CXL rev 3.0 section 8.2.9.2.1.3; Table 8-45
87+
*/
88+
struct cxl_event_mem_module {
89+
struct cxl_event_record_hdr hdr;
90+
u8 event_type;
91+
struct cxl_get_health_info info;
92+
u8 reserved[0x3d];
93+
} __packed;
94+
95+
#endif /* _LINUX_CXL_EVENT_H */

0 commit comments

Comments
 (0)