xref: /openbmc/qemu/include/hw/cxl/cxl.h (revision 118d4ed0)
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_bridge.h"
17 #include "hw/pci/pci_host.h"
18 #include "cxl_pci.h"
19 #include "cxl_component.h"
20 #include "cxl_device.h"
21 
22 #define CXL_COMPONENT_REG_BAR_IDX 0
23 #define CXL_DEVICE_REG_BAR_IDX 2
24 
25 #define CXL_WINDOW_MAX 10
26 
27 typedef struct CXLFixedWindow {
28     uint64_t size;
29     char **targets;
30     struct PXBDev *target_hbs[8];
31     uint8_t num_targets;
32     uint8_t enc_int_ways;
33     uint8_t enc_int_gran;
34     /* Todo: XOR based interleaving */
35     MemoryRegion mr;
36     hwaddr base;
37 } CXLFixedWindow;
38 
39 typedef struct CXLState {
40     bool is_enabled;
41     MemoryRegion host_mr;
42     unsigned int next_mr_idx;
43     GList *fixed_windows;
44     CXLFixedMemoryWindowOptionsList *cfmw_list;
45 } CXLState;
46 
47 struct CXLHost {
48     PCIHostState parent_obj;
49 
50     CXLComponentState cxl_cstate;
51 };
52 
53 #define TYPE_PXB_CXL_HOST "pxb-cxl-host"
54 OBJECT_DECLARE_SIMPLE_TYPE(CXLHost, PXB_CXL_HOST)
55 
56 #define TYPE_CXL_USP "cxl-upstream"
57 
58 typedef struct CXLUpstreamPort CXLUpstreamPort;
59 DECLARE_INSTANCE_CHECKER(CXLUpstreamPort, CXL_USP, TYPE_CXL_USP)
60 CXLComponentState *cxl_usp_to_cstate(CXLUpstreamPort *usp);
61 #endif
62