2 * QEMU CXL PCI interfaces
4 * Copyright (c) 2020 Intel
6 * This work is licensed under the terms of the GNU GPL, version 2. See the
7 * COPYING file in the top-level directory.
14 #define CXL_VENDOR_ID 0x1e98
16 #define PCIE_DVSEC_HEADER1_OFFSET 0x4 /* Offset from start of extend cap */
17 #define PCIE_DVSEC_ID_OFFSET 0x8
19 #define PCIE_CXL_DEVICE_DVSEC_LENGTH 0x3C
20 #define PCIE_CXL31_DEVICE_DVSEC_REVID 3
22 #define EXTENSIONS_PORT_DVSEC_LENGTH 0x28
23 #define EXTENSIONS_PORT_DVSEC_REVID 0
25 #define GPF_PORT_DVSEC_LENGTH 0x10
26 #define GPF_PORT_DVSEC_REVID 0
28 #define GPF_DEVICE_DVSEC_LENGTH 0x10
29 #define GPF_DEVICE_DVSEC_REVID 0
31 #define PCIE_CXL3_FLEXBUS_PORT_DVSEC_LENGTH 0x20
32 #define PCIE_CXL3_FLEXBUS_PORT_DVSEC_REVID 2
34 #define REG_LOC_DVSEC_LENGTH 0x24
35 #define REG_LOC_DVSEC_REVID 0
38 PCIE_CXL_DEVICE_DVSEC
= 0,
39 NON_CXL_FUNCTION_MAP_DVSEC
= 2,
40 EXTENSIONS_PORT_DVSEC
= 3,
43 PCIE_FLEXBUS_PORT_DVSEC
= 7,
49 typedef struct DVSECHeader
{
53 } QEMU_PACKED DVSECHeader
;
54 QEMU_BUILD_BUG_ON(sizeof(DVSECHeader
) != 10);
57 * CXL r3.1 Table 8-2: CXL DVSEC ID Assignment
58 * Devices must implement certain DVSEC IDs, and can [optionally]
60 * (x) - IDs in Table 8-2.
62 * CXL RCD (D1): 0, [2], [5], 7, [8], A - Not emulated yet
63 * CXL RCD USP (UP1): 7, [8] - Not emulated yet
64 * CXL RCH DSP (DP1): 7, [8]
65 * CXL SLD (D2): 0, [2], 5, 7, 8, [A]
66 * CXL LD (LD): 0, [2], 5, 7, 8
67 * CXL RP (R): 3, 4, 7, 8
68 * CXL Switch USP (USP): [2], 7, 8
69 * CXL Switch DSP (DSP): 3, 4, 7, 8
70 * FM-Owned LD (FMLD): 0, [2], 7, 8, 9
74 * CXL r3.1 Section 8.1.3: PCIe DVSEC for Devices
75 * DVSEC ID: 0, Revision: 3
77 typedef struct CXLDVSECDevice
{
86 uint32_t range1_size_hi
;
87 uint32_t range1_size_lo
;
88 uint32_t range1_base_hi
;
89 uint32_t range1_base_lo
;
90 uint32_t range2_size_hi
;
91 uint32_t range2_size_lo
;
92 uint32_t range2_base_hi
;
93 uint32_t range2_base_lo
;
96 } QEMU_PACKED CXLDVSECDevice
;
97 QEMU_BUILD_BUG_ON(sizeof(CXLDVSECDevice
) != PCIE_CXL_DEVICE_DVSEC_LENGTH
);
100 * CXL r3.1 Section 8.1.5: CXL Extensions DVSEC for Ports
101 * DVSEC ID: 3, Revision: 0
103 typedef struct CXLDVSECPortExt
{
107 uint8_t alt_bus_base
;
108 uint8_t alt_bus_limit
;
109 uint16_t alt_memory_base
;
110 uint16_t alt_memory_limit
;
111 uint16_t alt_prefetch_base
;
112 uint16_t alt_prefetch_limit
;
113 uint32_t alt_prefetch_base_high
;
114 uint32_t alt_prefetch_limit_high
;
116 uint32_t rcrb_base_high
;
118 QEMU_BUILD_BUG_ON(sizeof(CXLDVSECPortExt
) != 0x28);
120 #define PORT_CONTROL_OFFSET 0xc
121 #define PORT_CONTROL_UNMASK_SBR 1
122 #define PORT_CONTROL_ALT_MEMID_EN 4
125 * CXL r3.1 Section 8.1.6: GPF DVSEC for CXL Port
126 * DVSEC ID: 4, Revision: 0
128 typedef struct CXLDVSECPortGPF
{
131 uint16_t phase1_ctrl
;
132 uint16_t phase2_ctrl
;
134 QEMU_BUILD_BUG_ON(sizeof(CXLDVSECPortGPF
) != 0x10);
137 * CXL r3.1 Section 8.1.7: GPF DVSEC for CXL Device
138 * DVSEC ID: 5, Revision 0
140 typedef struct CXLDVSECDeviceGPF
{
142 uint16_t phase2_duration
;
143 uint32_t phase2_power
;
145 QEMU_BUILD_BUG_ON(sizeof(CXLDVSECDeviceGPF
) != 0x10);
148 * CXL r3.1 Section 8.1.8: PCIe DVSEC for Flex Bus Port
149 * CXL r3.1 Section 8.2.1.3: Flex Bus Port DVSEC
150 * DVSEC ID: 7, Revision 2
152 typedef struct CXLDVSECPortFlexBus
{
157 uint32_t rcvd_mod_ts_data_phase1
;
161 } CXLDVSECPortFlexBus
;
162 QEMU_BUILD_BUG_ON(sizeof(CXLDVSECPortFlexBus
) != 0x20);
165 * CXL r3.1 Section 8.1.9: Register Locator DVSEC
166 * DVSEC ID: 8, Revision 0
168 typedef struct CXLDVSECRegisterLocator
{
171 uint32_t reg0_base_lo
;
172 uint32_t reg0_base_hi
;
173 uint32_t reg1_base_lo
;
174 uint32_t reg1_base_hi
;
175 uint32_t reg2_base_lo
;
176 uint32_t reg2_base_hi
;
177 } CXLDVSECRegisterLocator
;
178 QEMU_BUILD_BUG_ON(sizeof(CXLDVSECRegisterLocator
) != 0x24);
180 /* BAR Equivalence Indicator */
181 #define BEI_BAR_10H 0
182 #define BEI_BAR_14H 1
183 #define BEI_BAR_18H 2
184 #define BEI_BAR_1cH 3
185 #define BEI_BAR_20H 4
186 #define BEI_BAR_24H 5
188 /* Register Block Identifier */
190 #define RBI_COMPONENT_REG (1 << 8)
191 #define RBI_BAR_VIRT_ACL (2 << 8)
192 #define RBI_CXL_DEVICE_REG (3 << 8)