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"
17 * Coherent Device Attribute Table (CDAT) Specification, Rev. 1.03, July. 2022
18 * Compute Express Link (CXL) Specification, Rev. 3.0, Aug. 2022
20 /* Table Access DOE - CXL r3.0 8.1.11 */
21 #define CXL_DOE_TABLE_ACCESS 2
22 #define CXL_DOE_PROTOCOL_CDAT ((CXL_DOE_TABLE_ACCESS << 16) | CXL_VENDOR_ID)
24 /* Read Entry - CXL r3.0 8.1.11.1 */
25 #define CXL_DOE_TAB_TYPE_CDAT 0
26 #define CXL_DOE_TAB_ENT_MAX 0xFFFF
28 /* Read Entry Request - CXL r3.0 8.1.11.1 Table 8-13 */
29 #define CXL_DOE_TAB_REQ 0
30 typedef struct CDATReq
{
34 uint16_t entry_handle
;
35 } QEMU_PACKED CDATReq
;
37 /* Read Entry Response - CXL r3.0 8.1.11.1 Table 8-14 */
38 #define CXL_DOE_TAB_RSP 0
39 typedef struct CDATRsp
{
43 uint16_t entry_handle
;
44 } QEMU_PACKED CDATRsp
;
46 /* CDAT Table Format - CDAT Table 1 */
47 #define CXL_CDAT_REV 2
48 typedef struct CDATTableHeader
{
54 } QEMU_PACKED CDATTableHeader
;
56 /* CDAT Structure Types - CDAT Table 2 */
60 CDAT_TYPE_DSMSCIS
= 2,
66 typedef struct CDATSubHeader
{
72 /* Device Scoped Memory Affinity Structure - CDAT Table 3 */
73 typedef struct CDATDsmas
{
77 #define CDAT_DSMAS_FLAG_NV (1 << 2)
78 #define CDAT_DSMAS_FLAG_SHAREABLE (1 << 3)
79 #define CDAT_DSMAS_FLAG_HW_COHERENT (1 << 4)
80 #define CDAT_DSMAS_FLAG_DYNAMIC_CAP (1 << 5)
84 } QEMU_PACKED CDATDsmas
;
86 /* Device Scoped Latency and Bandwidth Information Structure - CDAT Table 5 */
87 typedef struct CDATDslbis
{
90 /* Definitions of these fields refer directly to HMAT fields */
94 uint64_t entry_base_unit
;
97 } QEMU_PACKED CDATDslbis
;
99 /* Device Scoped Memory Side Cache Information Structure - CDAT Table 6 */
100 typedef struct CDATDsmscis
{
101 CDATSubHeader header
;
102 uint8_t DSMAS_handle
;
104 uint64_t memory_side_cache_size
;
105 uint32_t cache_attributes
;
106 } QEMU_PACKED CDATDsmscis
;
108 /* Device Scoped Initiator Structure - CDAT Table 7 */
109 typedef struct CDATDsis
{
110 CDATSubHeader header
;
114 } QEMU_PACKED CDATDsis
;
116 /* Device Scoped EFI Memory Type Structure - CDAT Table 8 */
117 typedef struct CDATDsemts
{
118 CDATSubHeader header
;
119 uint8_t DSMAS_handle
;
120 uint8_t EFI_memory_type_attr
;
124 } QEMU_PACKED CDATDsemts
;
126 /* Switch Scoped Latency and Bandwidth Information Structure - CDAT Table 9 */
127 typedef struct CDATSslbisHeader
{
128 CDATSubHeader header
;
131 uint64_t entry_base_unit
;
132 } QEMU_PACKED CDATSslbisHeader
;
134 /* Switch Scoped Latency and Bandwidth Entry - CDAT Table 10 */
135 typedef struct CDATSslbe
{
138 uint16_t latency_bandwidth
;
140 } QEMU_PACKED CDATSslbe
;
142 typedef struct CDATSslbis
{
143 CDATSslbisHeader sslbis_header
;
145 } QEMU_PACKED CDATSslbis
;
147 typedef struct CDATEntry
{
152 typedef struct CDATObject
{
156 int (*build_cdat_table
)(CDATSubHeader
***cdat_table
, void *priv
);
157 void (*free_cdat_table
)(CDATSubHeader
**cdat_table
, int num
, void *priv
);
162 struct CDATSubHeader
**built_buf
;
165 #endif /* CXL_CDAT_H */