xref: /openbmc/libcper/include/libcper/sections/cper-section-cxl-protocol.h (revision c97c041e571841f0ce67292208e083f6d858cf5c)
1 #ifndef CPER_SECTION_CXL_PROTOCOL_H
2 #define CPER_SECTION_CXL_PROTOCOL_H
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include <stdio.h>
9 #include <json.h>
10 #include <libcper/Cper.h>
11 
12 #define CXL_PROTOCOL_ERROR_VALID_BITFIELD_NAMES                                \
13 	(const char *[]){ "cxlAgentTypeValid",                                 \
14 			  "cxlAgentAddressValid",                              \
15 			  "deviceIDValid",                                     \
16 			  "deviceSerialValid",                                 \
17 			  "capabilityStructureValid",                          \
18 			  "cxlDVSECValid",                                     \
19 			  "cxlErrorLogValid" }
20 #define CXL_PROTOCOL_ERROR_AGENT_TYPES_KEYS (int[]){ 0, 1 }
21 #define CXL_PROTOCOL_ERROR_AGENT_TYPES_VALUES                                  \
22 	(const char *[]){ "CXL 1.1 Device", "CXL 1.1 Host Downstream Port" }
23 #define CXL_PROTOCOL_ERROR_DEVICE_AGENT		      0
24 #define CXL_PROTOCOL_ERROR_HOST_DOWNSTREAM_PORT_AGENT 1
25 
26 ///
27 /// CXL Protocol Error Section
28 ///
29 typedef struct {
30 	UINT64 VendorId : 16;
31 	UINT64 DeviceId : 16;
32 	UINT64 SubsystemVendorId : 16;
33 	UINT64 SubsystemDeviceId : 16;
34 	UINT64 ClassCode : 16;
35 	UINT64 Reserved1 : 3;
36 	UINT64 SlotNumber : 13;
37 	UINT64 Reserved2 : 32;
38 } EFI_CXL_DEVICE_ID;
39 
40 typedef struct {
41 	UINT64 FunctionNumber : 8;
42 	UINT64 DeviceNumber : 8;
43 	UINT64 BusNumber : 8;
44 	UINT64 SegmentNumber : 16;
45 	UINT64 Reserved : 24;
46 } EFI_CXL_DEVICE_AGENT_ADDRESS;
47 
48 typedef union {
49 	EFI_CXL_DEVICE_AGENT_ADDRESS
50 	DeviceAddress; //Active when the agent is a CXL1.1 device in CxlAgentType.
51 	UINT64 PortRcrbBaseAddress; //Active when the agent is a CXL1.1 host downstream port in CxlAgentType.
52 } EFI_CXL_AGENT_ADDRESS;
53 
54 typedef struct {
55 	UINT64 ValidBits;
56 	UINT64 CxlAgentType;
57 	EFI_CXL_AGENT_ADDRESS CxlAgentAddress;
58 	EFI_CXL_DEVICE_ID DeviceId;
59 	UINT64 DeviceSerial;
60 	EFI_PCIE_ERROR_DATA_CAPABILITY CapabilityStructure;
61 	UINT16 CxlDvsecLength;
62 	UINT16 CxlErrorLogLength;
63 	UINT32 Reserved;
64 } __attribute__((packed, aligned(1))) EFI_CXL_PROTOCOL_ERROR_DATA;
65 
66 json_object *cper_section_cxl_protocol_to_ir(void *section);
67 void ir_section_cxl_protocol_to_cper(json_object *section, FILE *out);
68 
69 #ifdef __cplusplus
70 }
71 #endif
72 
73 #endif
74