xref: /qemu/include/hw/cxl/cxl.h (revision 674b0a5784a5c0fc5d954b9f42fc1eb1a9648bf0)
1 /*
2  * QEMU CXL Support
3  *
4  * Copyright (c) 2020 Intel
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2. See the
7  * COPYING file in the top-level directory.
8  */
9 
10 #ifndef CXL_H
11 #define CXL_H
12 
13 
14 #include "qapi/qapi-types-machine.h"
15 #include "qapi/qapi-visit-machine.h"
16 #include "hw/pci/pci_host.h"
17 #include "cxl_pci.h"
18 #include "cxl_component.h"
19 #include "cxl_device.h"
20 
21 #define CXL_COMPONENT_REG_BAR_IDX 0
22 #define CXL_DEVICE_REG_BAR_IDX 2
23 
24 #define CXL_WINDOW_MAX 10
25 
26 typedef struct CXLFixedWindow {
27     uint64_t size;
28     char **targets;
29     struct PXBDev *target_hbs[8];
30     uint8_t num_targets;
31     uint8_t enc_int_ways;
32     uint8_t enc_int_gran;
33     /* Todo: XOR based interleaving */
34     MemoryRegion mr;
35     hwaddr base;
36 } CXLFixedWindow;
37 
38 typedef struct CXLState {
39     bool is_enabled;
40     MemoryRegion host_mr;
41     unsigned int next_mr_idx;
42     GList *fixed_windows;
43     CXLFixedMemoryWindowOptionsList *cfmw_list;
44 } CXLState;
45 
46 struct CXLHost {
47     PCIHostState parent_obj;
48 
49     CXLComponentState cxl_cstate;
50 };
51 
52 #define TYPE_PXB_CXL_HOST "pxb-cxl-host"
53 OBJECT_DECLARE_SIMPLE_TYPE(CXLHost, PXB_CXL_HOST)
54 
55 #define TYPE_CXL_USP "cxl-upstream"
56 
57 typedef struct CXLUpstreamPort CXLUpstreamPort;
58 DECLARE_INSTANCE_CHECKER(CXLUpstreamPort, CXL_USP, TYPE_CXL_USP)
59 CXLComponentState *cxl_usp_to_cstate(CXLUpstreamPort *usp);
60 #endif
61