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