4 * Copyright (C) 2021 Avery Design Systems, Inc.
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
13 #include "hw/cxl/cxl_pci.h"
14 #include "hw/pci/pcie_doe.h"
18 * Coherent Device Attribute Table (CDAT) Specification, Rev. 1.03, July. 2022
19 * Compute Express Link (CXL) Specification, Rev. 3.0, Aug. 2022
21 /* Table Access DOE - CXL r3.0 8.1.11 */
22 #define CXL_DOE_TABLE_ACCESS 2
23 #define CXL_DOE_PROTOCOL_CDAT ((CXL_DOE_TABLE_ACCESS << 16) | CXL_VENDOR_ID)
25 /* Read Entry - CXL r3.0 8.1.11.1 */
26 #define CXL_DOE_TAB_TYPE_CDAT 0
27 #define CXL_DOE_TAB_ENT_MAX 0xFFFF
29 /* Read Entry Request - CXL r3.0 8.1.11.1 Table 8-13 */
30 #define CXL_DOE_TAB_REQ 0
31 typedef struct CDATReq
{
35 uint16_t entry_handle
;
36 } QEMU_PACKED CDATReq
;
38 /* Read Entry Response - CXL r3.0 8.1.11.1 Table 8-14 */
39 #define CXL_DOE_TAB_RSP 0
40 typedef struct CDATRsp
{
44 uint16_t entry_handle
;
45 } QEMU_PACKED CDATRsp
;
47 /* CDAT Table Format - CDAT Table 1 */
48 #define CXL_CDAT_REV 2
49 typedef struct CDATTableHeader
{
55 } QEMU_PACKED CDATTableHeader
;
57 /* CDAT Structure Types - CDAT Table 2 */
61 CDAT_TYPE_DSMSCIS
= 2,
67 typedef struct CDATSubHeader
{
73 /* Device Scoped Memory Affinity Structure - CDAT Table 3 */
74 typedef struct CDATDsmas
{
78 #define CDAT_DSMAS_FLAG_NV (1 << 2)
79 #define CDAT_DSMAS_FLAG_SHAREABLE (1 << 3)
80 #define CDAT_DSMAS_FLAG_HW_COHERENT (1 << 4)
81 #define CDAT_DSMAS_FLAG_DYNAMIC_CAP (1 << 5)
85 } QEMU_PACKED CDATDsmas
;
87 /* Device Scoped Latency and Bandwidth Information Structure - CDAT Table 5 */
88 typedef struct CDATDslbis
{
91 /* Definitions of these fields refer directly to HMAT fields */
95 uint64_t entry_base_unit
;
98 } QEMU_PACKED CDATDslbis
;
100 /* Device Scoped Memory Side Cache Information Structure - CDAT Table 6 */
101 typedef struct CDATDsmscis
{
102 CDATSubHeader header
;
103 uint8_t DSMAS_handle
;
105 uint64_t memory_side_cache_size
;
106 uint32_t cache_attributes
;
107 } QEMU_PACKED CDATDsmscis
;
109 /* Device Scoped Initiator Structure - CDAT Table 7 */
110 typedef struct CDATDsis
{
111 CDATSubHeader header
;
115 } QEMU_PACKED CDATDsis
;
117 /* Device Scoped EFI Memory Type Structure - CDAT Table 8 */
118 typedef struct CDATDsemts
{
119 CDATSubHeader header
;
120 uint8_t DSMAS_handle
;
121 uint8_t EFI_memory_type_attr
;
125 } QEMU_PACKED CDATDsemts
;
127 /* Switch Scoped Latency and Bandwidth Information Structure - CDAT Table 9 */
128 typedef struct CDATSslbisHeader
{
129 CDATSubHeader header
;
132 uint64_t entry_base_unit
;
133 } QEMU_PACKED CDATSslbisHeader
;
135 #define CDAT_PORT_ID_USP 0x100
136 /* Switch Scoped Latency and Bandwidth Entry - CDAT Table 10 */
137 typedef struct CDATSslbe
{
140 uint16_t latency_bandwidth
;
142 } QEMU_PACKED CDATSslbe
;
144 typedef struct CDATSslbis
{
145 CDATSslbisHeader sslbis_header
;
147 } QEMU_PACKED CDATSslbis
;
149 typedef struct CDATEntry
{
154 typedef struct CDATObject
{
158 int (*build_cdat_table
)(CDATSubHeader
***cdat_table
, void *priv
);
159 void (*free_cdat_table
)(CDATSubHeader
**cdat_table
, int num
, void *priv
);
164 struct CDATSubHeader
**built_buf
;
167 #endif /* CXL_CDAT_H */