1 #ifndef CPER_SECTION_CXL_PROTOCOL_H
2 #define CPER_SECTION_CXL_PROTOCOL_H
3 
4 #include "json.h"
5 #include "../edk/Cper.h"
6 
7 #define CXL_PROTOCOL_ERROR_VALID_BITFIELD_NAMES (const char*[]) {"cxlAgentTypeValid", "cxlAgentAddressValid", \
8     "deviceIDValid", "deviceSerialValid", "capabilityStructureValid", "cxlDVSECValid", "cxlErrorLogValid"}
9 #define CXL_PROTOCOL_ERROR_AGENT_TYPES_KEYS (int []){0, 1}
10 #define CXL_PROTOCOL_ERROR_AGENT_TYPES_VALUES (const char*[]){"CXL 1.1 Device", "CXL 1.1 Host Downstream Port"}
11 #define CXL_PROTOCOL_ERROR_DEVICE_AGENT 0
12 #define CXL_PROTOCOL_ERROR_HOST_DOWNSTREAM_PORT_AGENT 1
13 
14 ///
15 /// CXL Protocol Error Section
16 ///
17 typedef struct {
18     UINT64 VendorId : 16;
19     UINT64 DeviceId : 16;
20     UINT64 SubsystemVendorId : 16;
21     UINT64 SubsystemDeviceId : 16;
22     UINT64 ClassCode : 16;
23     UINT64 Reserved1 : 3;
24     UINT64 SlotNumber : 13;
25     UINT64 Reserved2 : 32;
26 } EFI_CXL_DEVICE_ID;
27 
28 typedef struct {
29     UINT64 FunctionNumber : 8;
30     UINT64 DeviceNumber : 8;
31     UINT64 BusNumber : 8;
32     UINT64 SegmentNumber : 16;
33     UINT64 Reserved : 24;
34 } EFI_CXL_DEVICE_AGENT_ADDRESS;
35 
36 typedef union {
37     EFI_CXL_DEVICE_AGENT_ADDRESS DeviceAddress; //Active when the agent is a CXL1.1 device in CxlAgentType.
38     UINT64 PortRcrbBaseAddress; //Active when the agent is a CXL1.1 host downstream port in CxlAgentType.
39 } EFI_CXL_AGENT_ADDRESS;
40 
41 typedef struct {
42     UINT64 ValidBits;
43     UINT64 CxlAgentType;
44     EFI_CXL_AGENT_ADDRESS CxlAgentAddress;
45     EFI_CXL_DEVICE_ID DeviceId;
46     UINT64 DeviceSerial;
47     EFI_PCIE_ERROR_DATA_CAPABILITY CapabilityStructure;
48     UINT16 CxlDvsecLength;
49     UINT16 CxlErrorLogLength;
50     UINT32 Reserved;
51 } EFI_CXL_PROTOCOL_ERROR_DATA;
52 
53 json_object* cper_section_cxl_protocol_to_ir(void* section, EFI_ERROR_SECTION_DESCRIPTOR* descriptor);
54 
55 #endif