pci_expander_bridge.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. /*
  2. * PCI Expander Bridge Device Emulation
  3. *
  4. * Copyright (C) 2015 Red Hat Inc
  5. *
  6. * Authors:
  7. * Marcel Apfelbaum <marcel@redhat.com>
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  10. * See the COPYING file in the top-level directory.
  11. */
  12. #include "qemu/osdep.h"
  13. #include "qapi/error.h"
  14. #include "hw/pci/pci.h"
  15. #include "hw/pci/pci_bus.h"
  16. #include "hw/pci/pci_host.h"
  17. #include "hw/pci/pcie_port.h"
  18. #include "hw/qdev-properties.h"
  19. #include "hw/pci/pci_bridge.h"
  20. #include "hw/pci-bridge/pci_expander_bridge.h"
  21. #include "hw/cxl/cxl.h"
  22. #include "qemu/range.h"
  23. #include "qemu/error-report.h"
  24. #include "qemu/module.h"
  25. #include "sysemu/numa.h"
  26. #include "hw/boards.h"
  27. #include "qom/object.h"
  28. enum BusType { PCI, PCIE, CXL };
  29. #define TYPE_PXB_BUS "pxb-bus"
  30. typedef struct PXBBus PXBBus;
  31. DECLARE_INSTANCE_CHECKER(PXBBus, PXB_BUS,
  32. TYPE_PXB_BUS)
  33. #define TYPE_PXB_PCIE_BUS "pxb-pcie-bus"
  34. DECLARE_INSTANCE_CHECKER(PXBBus, PXB_PCIE_BUS,
  35. TYPE_PXB_PCIE_BUS)
  36. #define TYPE_PXB_CXL_BUS "pxb-cxl-bus"
  37. DECLARE_INSTANCE_CHECKER(PXBBus, PXB_CXL_BUS,
  38. TYPE_PXB_CXL_BUS)
  39. struct PXBBus {
  40. /*< private >*/
  41. PCIBus parent_obj;
  42. /*< public >*/
  43. char bus_path[8];
  44. };
  45. #define TYPE_PXB_DEVICE "pxb"
  46. DECLARE_INSTANCE_CHECKER(PXBDev, PXB_DEV,
  47. TYPE_PXB_DEVICE)
  48. #define TYPE_PXB_PCIE_DEVICE "pxb-pcie"
  49. DECLARE_INSTANCE_CHECKER(PXBDev, PXB_PCIE_DEV,
  50. TYPE_PXB_PCIE_DEVICE)
  51. static PXBDev *convert_to_pxb(PCIDevice *dev)
  52. {
  53. /* A CXL PXB's parent bus is PCIe, so the normal check won't work */
  54. if (object_dynamic_cast(OBJECT(dev), TYPE_PXB_CXL_DEVICE)) {
  55. return PXB_CXL_DEV(dev);
  56. }
  57. return pci_bus_is_express(pci_get_bus(dev))
  58. ? PXB_PCIE_DEV(dev) : PXB_DEV(dev);
  59. }
  60. static GList *pxb_dev_list;
  61. #define TYPE_PXB_HOST "pxb-host"
  62. CXLComponentState *cxl_get_hb_cstate(PCIHostState *hb)
  63. {
  64. CXLHost *host = PXB_CXL_HOST(hb);
  65. return &host->cxl_cstate;
  66. }
  67. bool cxl_get_hb_passthrough(PCIHostState *hb)
  68. {
  69. CXLHost *host = PXB_CXL_HOST(hb);
  70. return host->passthrough;
  71. }
  72. static int pxb_bus_num(PCIBus *bus)
  73. {
  74. PXBDev *pxb = convert_to_pxb(bus->parent_dev);
  75. return pxb->bus_nr;
  76. }
  77. static uint16_t pxb_bus_numa_node(PCIBus *bus)
  78. {
  79. PXBDev *pxb = convert_to_pxb(bus->parent_dev);
  80. return pxb->numa_node;
  81. }
  82. static void pxb_bus_class_init(ObjectClass *class, void *data)
  83. {
  84. PCIBusClass *pbc = PCI_BUS_CLASS(class);
  85. pbc->bus_num = pxb_bus_num;
  86. pbc->numa_node = pxb_bus_numa_node;
  87. }
  88. static const TypeInfo pxb_bus_info = {
  89. .name = TYPE_PXB_BUS,
  90. .parent = TYPE_PCI_BUS,
  91. .instance_size = sizeof(PXBBus),
  92. .class_init = pxb_bus_class_init,
  93. };
  94. static const TypeInfo pxb_pcie_bus_info = {
  95. .name = TYPE_PXB_PCIE_BUS,
  96. .parent = TYPE_PCIE_BUS,
  97. .instance_size = sizeof(PXBBus),
  98. .class_init = pxb_bus_class_init,
  99. };
  100. static const TypeInfo pxb_cxl_bus_info = {
  101. .name = TYPE_PXB_CXL_BUS,
  102. .parent = TYPE_CXL_BUS,
  103. .instance_size = sizeof(PXBBus),
  104. .class_init = pxb_bus_class_init,
  105. };
  106. static const char *pxb_host_root_bus_path(PCIHostState *host_bridge,
  107. PCIBus *rootbus)
  108. {
  109. PXBBus *bus = pci_bus_is_cxl(rootbus) ?
  110. PXB_CXL_BUS(rootbus) :
  111. pci_bus_is_express(rootbus) ? PXB_PCIE_BUS(rootbus) :
  112. PXB_BUS(rootbus);
  113. snprintf(bus->bus_path, 8, "0000:%02x", pxb_bus_num(rootbus));
  114. return bus->bus_path;
  115. }
  116. static char *pxb_host_ofw_unit_address(const SysBusDevice *dev)
  117. {
  118. const PCIHostState *pxb_host;
  119. const PCIBus *pxb_bus;
  120. const PXBDev *pxb_dev;
  121. int position;
  122. const DeviceState *pxb_dev_base;
  123. const PCIHostState *main_host;
  124. const SysBusDevice *main_host_sbd;
  125. pxb_host = PCI_HOST_BRIDGE(dev);
  126. pxb_bus = pxb_host->bus;
  127. pxb_dev = convert_to_pxb(pxb_bus->parent_dev);
  128. position = g_list_index(pxb_dev_list, pxb_dev);
  129. assert(position >= 0);
  130. pxb_dev_base = DEVICE(pxb_dev);
  131. main_host = PCI_HOST_BRIDGE(pxb_dev_base->parent_bus->parent);
  132. main_host_sbd = SYS_BUS_DEVICE(main_host);
  133. if (main_host_sbd->num_mmio > 0) {
  134. return g_strdup_printf(HWADDR_FMT_plx ",%x",
  135. main_host_sbd->mmio[0].addr, position + 1);
  136. }
  137. if (main_host_sbd->num_pio > 0) {
  138. return g_strdup_printf("i%04x,%x",
  139. main_host_sbd->pio[0], position + 1);
  140. }
  141. return NULL;
  142. }
  143. static void pxb_host_class_init(ObjectClass *class, void *data)
  144. {
  145. DeviceClass *dc = DEVICE_CLASS(class);
  146. SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(class);
  147. PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(class);
  148. dc->fw_name = "pci";
  149. /* Reason: Internal part of the pxb/pxb-pcie device, not usable by itself */
  150. dc->user_creatable = false;
  151. sbc->explicit_ofw_unit_address = pxb_host_ofw_unit_address;
  152. hc->root_bus_path = pxb_host_root_bus_path;
  153. }
  154. static const TypeInfo pxb_host_info = {
  155. .name = TYPE_PXB_HOST,
  156. .parent = TYPE_PCI_HOST_BRIDGE,
  157. .class_init = pxb_host_class_init,
  158. };
  159. static void pxb_cxl_realize(DeviceState *dev, Error **errp)
  160. {
  161. SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
  162. CXLHost *cxl = PXB_CXL_HOST(dev);
  163. CXLComponentState *cxl_cstate = &cxl->cxl_cstate;
  164. struct MemoryRegion *mr = &cxl_cstate->crb.component_registers;
  165. cxl_component_register_block_init(OBJECT(dev), cxl_cstate,
  166. TYPE_PXB_CXL_HOST);
  167. sysbus_init_mmio(sbd, mr);
  168. }
  169. /*
  170. * Host bridge realization has no means of knowning state associated
  171. * with a particular machine. As such, it is nececssary to delay
  172. * final setup of the host bridge register space until later in the
  173. * machine bring up.
  174. */
  175. void pxb_cxl_hook_up_registers(CXLState *cxl_state, PCIBus *bus, Error **errp)
  176. {
  177. PXBDev *pxb = PXB_CXL_DEV(pci_bridge_get_device(bus));
  178. CXLHost *cxl = pxb->cxl.cxl_host_bridge;
  179. CXLComponentState *cxl_cstate = &cxl->cxl_cstate;
  180. struct MemoryRegion *mr = &cxl_cstate->crb.component_registers;
  181. hwaddr offset;
  182. offset = memory_region_size(mr) * cxl_state->next_mr_idx;
  183. if (offset > memory_region_size(&cxl_state->host_mr)) {
  184. error_setg(errp, "Insufficient space for pxb cxl host register space");
  185. return;
  186. }
  187. memory_region_add_subregion(&cxl_state->host_mr, offset, mr);
  188. cxl_state->next_mr_idx++;
  189. }
  190. static void pxb_cxl_host_class_init(ObjectClass *class, void *data)
  191. {
  192. DeviceClass *dc = DEVICE_CLASS(class);
  193. PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(class);
  194. hc->root_bus_path = pxb_host_root_bus_path;
  195. dc->fw_name = "cxl";
  196. dc->realize = pxb_cxl_realize;
  197. /* Reason: Internal part of the pxb/pxb-pcie device, not usable by itself */
  198. dc->user_creatable = false;
  199. }
  200. /*
  201. * This is a device to handle the MMIO for a CXL host bridge. It does nothing
  202. * else.
  203. */
  204. static const TypeInfo cxl_host_info = {
  205. .name = TYPE_PXB_CXL_HOST,
  206. .parent = TYPE_PCI_HOST_BRIDGE,
  207. .instance_size = sizeof(CXLHost),
  208. .class_init = pxb_cxl_host_class_init,
  209. };
  210. /*
  211. * Registers the PXB bus as a child of pci host root bus.
  212. */
  213. static void pxb_register_bus(PCIDevice *dev, PCIBus *pxb_bus, Error **errp)
  214. {
  215. PCIBus *bus = pci_get_bus(dev);
  216. int pxb_bus_num = pci_bus_num(pxb_bus);
  217. if (bus->parent_dev) {
  218. error_setg(errp, "PXB devices can be attached only to root bus");
  219. return;
  220. }
  221. QLIST_FOREACH(bus, &bus->child, sibling) {
  222. if (pci_bus_num(bus) == pxb_bus_num) {
  223. error_setg(errp, "Bus %d is already in use", pxb_bus_num);
  224. return;
  225. }
  226. }
  227. QLIST_INSERT_HEAD(&pci_get_bus(dev)->child, pxb_bus, sibling);
  228. }
  229. static int pxb_map_irq_fn(PCIDevice *pci_dev, int pin)
  230. {
  231. PCIDevice *pxb = pci_get_bus(pci_dev)->parent_dev;
  232. /*
  233. * First carry out normal swizzle to handle
  234. * multple root ports on a pxb instance.
  235. */
  236. pin = pci_swizzle_map_irq_fn(pci_dev, pin);
  237. /*
  238. * The bios does not index the pxb slot number when
  239. * it computes the IRQ because it resides on bus 0
  240. * and not on the current bus.
  241. * However QEMU routes the irq through bus 0 and adds
  242. * the pxb slot to the IRQ computation of the PXB
  243. * device.
  244. *
  245. * Synchronize between bios and QEMU by canceling
  246. * pxb's effect.
  247. */
  248. return pin - PCI_SLOT(pxb->devfn);
  249. }
  250. static void pxb_cxl_dev_reset(DeviceState *dev)
  251. {
  252. CXLHost *cxl = PXB_CXL_DEV(dev)->cxl.cxl_host_bridge;
  253. CXLComponentState *cxl_cstate = &cxl->cxl_cstate;
  254. PCIHostState *hb = PCI_HOST_BRIDGE(cxl);
  255. uint32_t *reg_state = cxl_cstate->crb.cache_mem_registers;
  256. uint32_t *write_msk = cxl_cstate->crb.cache_mem_regs_write_mask;
  257. int dsp_count = 0;
  258. cxl_component_register_init_common(reg_state, write_msk, CXL2_ROOT_PORT);
  259. /*
  260. * The CXL specification allows for host bridges with no HDM decoders
  261. * if they only have a single root port.
  262. */
  263. if (!PXB_DEV(dev)->hdm_for_passthrough) {
  264. dsp_count = pcie_count_ds_ports(hb->bus);
  265. }
  266. /* Initial reset will have 0 dsp so wait until > 0 */
  267. if (dsp_count == 1) {
  268. cxl->passthrough = true;
  269. /* Set Capability ID in header to NONE */
  270. ARRAY_FIELD_DP32(reg_state, CXL_HDM_CAPABILITY_HEADER, ID, 0);
  271. } else {
  272. ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, TARGET_COUNT,
  273. 8);
  274. }
  275. }
  276. static gint pxb_compare(gconstpointer a, gconstpointer b)
  277. {
  278. const PXBDev *pxb_a = a, *pxb_b = b;
  279. return pxb_a->bus_nr < pxb_b->bus_nr ? -1 :
  280. pxb_a->bus_nr > pxb_b->bus_nr ? 1 :
  281. 0;
  282. }
  283. static void pxb_dev_realize_common(PCIDevice *dev, enum BusType type,
  284. Error **errp)
  285. {
  286. PXBDev *pxb = convert_to_pxb(dev);
  287. DeviceState *ds, *bds = NULL;
  288. PCIBus *bus;
  289. const char *dev_name = NULL;
  290. Error *local_err = NULL;
  291. MachineState *ms = MACHINE(qdev_get_machine());
  292. if (ms->numa_state == NULL) {
  293. error_setg(errp, "NUMA is not supported by this machine-type");
  294. return;
  295. }
  296. if (pxb->numa_node != NUMA_NODE_UNASSIGNED &&
  297. pxb->numa_node >= ms->numa_state->num_nodes) {
  298. error_setg(errp, "Illegal numa node %d", pxb->numa_node);
  299. return;
  300. }
  301. if (dev->qdev.id && *dev->qdev.id) {
  302. dev_name = dev->qdev.id;
  303. }
  304. ds = qdev_new(type == CXL ? TYPE_PXB_CXL_HOST : TYPE_PXB_HOST);
  305. if (type == PCIE) {
  306. bus = pci_root_bus_new(ds, dev_name, NULL, NULL, 0, TYPE_PXB_PCIE_BUS);
  307. } else if (type == CXL) {
  308. bus = pci_root_bus_new(ds, dev_name, NULL, NULL, 0, TYPE_PXB_CXL_BUS);
  309. bus->flags |= PCI_BUS_CXL;
  310. PXB_CXL_DEV(dev)->cxl.cxl_host_bridge = PXB_CXL_HOST(ds);
  311. } else {
  312. bus = pci_root_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_PXB_BUS);
  313. bds = qdev_new("pci-bridge");
  314. bds->id = g_strdup(dev_name);
  315. qdev_prop_set_uint8(bds, PCI_BRIDGE_DEV_PROP_CHASSIS_NR, pxb->bus_nr);
  316. qdev_prop_set_bit(bds, PCI_BRIDGE_DEV_PROP_SHPC, false);
  317. }
  318. bus->parent_dev = dev;
  319. bus->address_space_mem = pci_get_bus(dev)->address_space_mem;
  320. bus->address_space_io = pci_get_bus(dev)->address_space_io;
  321. bus->map_irq = pxb_map_irq_fn;
  322. PCI_HOST_BRIDGE(ds)->bus = bus;
  323. PCI_HOST_BRIDGE(ds)->bypass_iommu = pxb->bypass_iommu;
  324. pxb_register_bus(dev, bus, &local_err);
  325. if (local_err) {
  326. error_propagate(errp, local_err);
  327. goto err_register_bus;
  328. }
  329. sysbus_realize_and_unref(SYS_BUS_DEVICE(ds), &error_fatal);
  330. if (bds) {
  331. qdev_realize_and_unref(bds, &bus->qbus, &error_fatal);
  332. }
  333. pci_word_test_and_set_mask(dev->config + PCI_STATUS,
  334. PCI_STATUS_66MHZ | PCI_STATUS_FAST_BACK);
  335. pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_HOST);
  336. pxb_dev_list = g_list_insert_sorted(pxb_dev_list, pxb, pxb_compare);
  337. return;
  338. err_register_bus:
  339. object_unref(OBJECT(bds));
  340. object_unparent(OBJECT(bus));
  341. object_unref(OBJECT(ds));
  342. }
  343. static void pxb_dev_realize(PCIDevice *dev, Error **errp)
  344. {
  345. if (pci_bus_is_express(pci_get_bus(dev))) {
  346. error_setg(errp, "pxb devices cannot reside on a PCIe bus");
  347. return;
  348. }
  349. pxb_dev_realize_common(dev, PCI, errp);
  350. }
  351. static void pxb_dev_exitfn(PCIDevice *pci_dev)
  352. {
  353. PXBDev *pxb = convert_to_pxb(pci_dev);
  354. pxb_dev_list = g_list_remove(pxb_dev_list, pxb);
  355. }
  356. static Property pxb_dev_properties[] = {
  357. /* Note: 0 is not a legal PXB bus number. */
  358. DEFINE_PROP_UINT8("bus_nr", PXBDev, bus_nr, 0),
  359. DEFINE_PROP_UINT16("numa_node", PXBDev, numa_node, NUMA_NODE_UNASSIGNED),
  360. DEFINE_PROP_BOOL("bypass_iommu", PXBDev, bypass_iommu, false),
  361. DEFINE_PROP_END_OF_LIST(),
  362. };
  363. static void pxb_dev_class_init(ObjectClass *klass, void *data)
  364. {
  365. DeviceClass *dc = DEVICE_CLASS(klass);
  366. PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
  367. k->realize = pxb_dev_realize;
  368. k->exit = pxb_dev_exitfn;
  369. k->vendor_id = PCI_VENDOR_ID_REDHAT;
  370. k->device_id = PCI_DEVICE_ID_REDHAT_PXB;
  371. k->class_id = PCI_CLASS_BRIDGE_HOST;
  372. dc->desc = "PCI Expander Bridge";
  373. device_class_set_props(dc, pxb_dev_properties);
  374. dc->hotpluggable = false;
  375. set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
  376. }
  377. static const TypeInfo pxb_dev_info = {
  378. .name = TYPE_PXB_DEVICE,
  379. .parent = TYPE_PCI_DEVICE,
  380. .instance_size = sizeof(PXBDev),
  381. .class_init = pxb_dev_class_init,
  382. .interfaces = (InterfaceInfo[]) {
  383. { INTERFACE_CONVENTIONAL_PCI_DEVICE },
  384. { },
  385. },
  386. };
  387. static void pxb_pcie_dev_realize(PCIDevice *dev, Error **errp)
  388. {
  389. if (!pci_bus_is_express(pci_get_bus(dev))) {
  390. error_setg(errp, "pxb-pcie devices cannot reside on a PCI bus");
  391. return;
  392. }
  393. pxb_dev_realize_common(dev, PCIE, errp);
  394. }
  395. static void pxb_pcie_dev_class_init(ObjectClass *klass, void *data)
  396. {
  397. DeviceClass *dc = DEVICE_CLASS(klass);
  398. PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
  399. k->realize = pxb_pcie_dev_realize;
  400. k->exit = pxb_dev_exitfn;
  401. k->vendor_id = PCI_VENDOR_ID_REDHAT;
  402. k->device_id = PCI_DEVICE_ID_REDHAT_PXB_PCIE;
  403. k->class_id = PCI_CLASS_BRIDGE_HOST;
  404. dc->desc = "PCI Express Expander Bridge";
  405. device_class_set_props(dc, pxb_dev_properties);
  406. dc->hotpluggable = false;
  407. set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
  408. }
  409. static const TypeInfo pxb_pcie_dev_info = {
  410. .name = TYPE_PXB_PCIE_DEVICE,
  411. .parent = TYPE_PCI_DEVICE,
  412. .instance_size = sizeof(PXBDev),
  413. .class_init = pxb_pcie_dev_class_init,
  414. .interfaces = (InterfaceInfo[]) {
  415. { INTERFACE_CONVENTIONAL_PCI_DEVICE },
  416. { },
  417. },
  418. };
  419. static void pxb_cxl_dev_realize(PCIDevice *dev, Error **errp)
  420. {
  421. /* A CXL PXB's parent bus is still PCIe */
  422. if (!pci_bus_is_express(pci_get_bus(dev))) {
  423. error_setg(errp, "pxb-cxl devices cannot reside on a PCI bus");
  424. return;
  425. }
  426. pxb_dev_realize_common(dev, CXL, errp);
  427. pxb_cxl_dev_reset(DEVICE(dev));
  428. }
  429. static Property pxb_cxl_dev_properties[] = {
  430. /* Note: 0 is not a legal PXB bus number. */
  431. DEFINE_PROP_UINT8("bus_nr", PXBDev, bus_nr, 0),
  432. DEFINE_PROP_UINT16("numa_node", PXBDev, numa_node, NUMA_NODE_UNASSIGNED),
  433. DEFINE_PROP_BOOL("bypass_iommu", PXBDev, bypass_iommu, false),
  434. DEFINE_PROP_BOOL("hdm_for_passthrough", PXBDev, hdm_for_passthrough, false),
  435. DEFINE_PROP_END_OF_LIST(),
  436. };
  437. static void pxb_cxl_dev_class_init(ObjectClass *klass, void *data)
  438. {
  439. DeviceClass *dc = DEVICE_CLASS(klass);
  440. PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
  441. k->realize = pxb_cxl_dev_realize;
  442. k->exit = pxb_dev_exitfn;
  443. /*
  444. * XXX: These types of bridges don't actually show up in the hierarchy so
  445. * vendor, device, class, etc. ids are intentionally left out.
  446. */
  447. dc->desc = "CXL Host Bridge";
  448. device_class_set_props(dc, pxb_cxl_dev_properties);
  449. set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
  450. /* Host bridges aren't hotpluggable. FIXME: spec reference */
  451. dc->hotpluggable = false;
  452. dc->reset = pxb_cxl_dev_reset;
  453. }
  454. static const TypeInfo pxb_cxl_dev_info = {
  455. .name = TYPE_PXB_CXL_DEVICE,
  456. .parent = TYPE_PCI_DEVICE,
  457. .instance_size = sizeof(PXBDev),
  458. .class_init = pxb_cxl_dev_class_init,
  459. .interfaces =
  460. (InterfaceInfo[]){
  461. { INTERFACE_CONVENTIONAL_PCI_DEVICE },
  462. {},
  463. },
  464. };
  465. static void pxb_register_types(void)
  466. {
  467. type_register_static(&pxb_bus_info);
  468. type_register_static(&pxb_pcie_bus_info);
  469. type_register_static(&pxb_cxl_bus_info);
  470. type_register_static(&pxb_host_info);
  471. type_register_static(&cxl_host_info);
  472. type_register_static(&pxb_dev_info);
  473. type_register_static(&pxb_pcie_dev_info);
  474. type_register_static(&pxb_cxl_dev_info);
  475. }
  476. type_init(pxb_register_types)