2020-01-27 17:45:06 +03:00
|
|
|
/*
|
|
|
|
* QEMU PowerPC PowerNV (POWER8) PHB3 model
|
|
|
|
*
|
|
|
|
* Copyright (c) 2014-2020, IBM Corporation.
|
|
|
|
*
|
|
|
|
* This code is licensed under the GPL version 2 or later. See the
|
|
|
|
* COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PCI_HOST_PNV_PHB3_H
|
|
|
|
#define PCI_HOST_PNV_PHB3_H
|
|
|
|
|
|
|
|
#include "hw/ppc/xics.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2022-06-24 11:49:12 +03:00
|
|
|
#include "hw/pci-host/pnv_phb.h"
|
2020-01-27 17:45:06 +03:00
|
|
|
|
|
|
|
typedef struct PnvPHB3 PnvPHB3;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PHB3 XICS Source for MSIs
|
|
|
|
*/
|
|
|
|
#define TYPE_PHB3_MSI "phb3-msi"
|
2020-09-03 23:43:22 +03:00
|
|
|
typedef struct Phb3MsiState Phb3MsiState;
|
2020-09-01 00:07:33 +03:00
|
|
|
DECLARE_INSTANCE_CHECKER(Phb3MsiState, PHB3_MSI,
|
|
|
|
TYPE_PHB3_MSI)
|
2020-01-27 17:45:06 +03:00
|
|
|
|
|
|
|
#define PHB3_MAX_MSI 2048
|
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct Phb3MsiState {
|
2020-01-27 17:45:06 +03:00
|
|
|
ICSState ics;
|
|
|
|
qemu_irq *qirqs;
|
|
|
|
|
|
|
|
PnvPHB3 *phb;
|
|
|
|
uint64_t rba[PHB3_MAX_MSI / 64];
|
|
|
|
uint32_t rba_sum;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2020-01-27 17:45:06 +03:00
|
|
|
|
|
|
|
void pnv_phb3_msi_update_config(Phb3MsiState *msis, uint32_t base,
|
|
|
|
uint32_t count);
|
|
|
|
void pnv_phb3_msi_send(Phb3MsiState *msis, uint64_t addr, uint16_t data,
|
|
|
|
int32_t dev_pe);
|
|
|
|
void pnv_phb3_msi_ffi(Phb3MsiState *msis, uint64_t val);
|
2024-06-07 14:21:53 +03:00
|
|
|
void pnv_phb3_msi_pic_print_info(Phb3MsiState *msis, GString *buf);
|
2020-01-27 17:45:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We have one such address space wrapper per possible device under
|
|
|
|
* the PHB since they need to be assigned statically at qemu device
|
|
|
|
* creation time. The relationship to a PE is done later dynamically.
|
|
|
|
* This means we can potentially create a lot of these guys. Q35
|
|
|
|
* stores them as some kind of radix tree but we never really need to
|
|
|
|
* do fast lookups so instead we simply keep a QLIST of them for now,
|
|
|
|
* we can add the radix if needed later on.
|
|
|
|
*
|
|
|
|
* We do cache the PE number to speed things up a bit though.
|
|
|
|
*/
|
|
|
|
typedef struct PnvPhb3DMASpace {
|
|
|
|
PCIBus *bus;
|
|
|
|
uint8_t devfn;
|
|
|
|
int pe_num; /* Cached PE number */
|
|
|
|
#define PHB_INVALID_PE (-1)
|
|
|
|
PnvPHB3 *phb;
|
|
|
|
AddressSpace dma_as;
|
|
|
|
IOMMUMemoryRegion dma_mr;
|
|
|
|
MemoryRegion msi32_mr;
|
|
|
|
MemoryRegion msi64_mr;
|
|
|
|
QLIST_ENTRY(PnvPhb3DMASpace) list;
|
|
|
|
} PnvPhb3DMASpace;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PHB3 Power Bus Common Queue
|
|
|
|
*/
|
|
|
|
#define TYPE_PNV_PBCQ "pnv-pbcq"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(PnvPBCQState, PNV_PBCQ)
|
2020-01-27 17:45:06 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct PnvPBCQState {
|
2020-01-27 17:45:06 +03:00
|
|
|
DeviceState parent;
|
|
|
|
|
|
|
|
uint32_t nest_xbase;
|
|
|
|
uint32_t spci_xbase;
|
|
|
|
uint32_t pci_xbase;
|
|
|
|
#define PBCQ_NEST_REGS_COUNT 0x46
|
|
|
|
#define PBCQ_PCI_REGS_COUNT 0x15
|
|
|
|
#define PBCQ_SPCI_REGS_COUNT 0x5
|
|
|
|
|
|
|
|
uint64_t nest_regs[PBCQ_NEST_REGS_COUNT];
|
|
|
|
uint64_t spci_regs[PBCQ_SPCI_REGS_COUNT];
|
|
|
|
uint64_t pci_regs[PBCQ_PCI_REGS_COUNT];
|
|
|
|
MemoryRegion mmbar0;
|
|
|
|
MemoryRegion mmbar1;
|
|
|
|
MemoryRegion phbbar;
|
|
|
|
uint64_t mmio0_base;
|
|
|
|
uint64_t mmio0_size;
|
|
|
|
uint64_t mmio1_base;
|
|
|
|
uint64_t mmio1_size;
|
|
|
|
PnvPHB3 *phb;
|
|
|
|
|
|
|
|
MemoryRegion xscom_nest_regs;
|
|
|
|
MemoryRegion xscom_pci_regs;
|
|
|
|
MemoryRegion xscom_spci_regs;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2020-01-27 17:45:06 +03:00
|
|
|
|
|
|
|
/*
|
2022-08-11 19:39:40 +03:00
|
|
|
* PHB3 PCIe Root Bus
|
2020-01-27 17:45:06 +03:00
|
|
|
*/
|
2022-01-12 13:28:27 +03:00
|
|
|
#define TYPE_PNV_PHB3_ROOT_BUS "pnv-phb3-root"
|
2022-08-11 19:39:40 +03:00
|
|
|
struct PnvPHB3RootBus {
|
|
|
|
PCIBus parent;
|
|
|
|
|
|
|
|
uint32_t chip_id;
|
|
|
|
uint32_t phb_id;
|
|
|
|
};
|
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB3RootBus, PNV_PHB3_ROOT_BUS)
|
2020-01-27 17:45:06 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* PHB3 PCIe Host Bridge for PowerNV machines (POWER8)
|
|
|
|
*/
|
|
|
|
#define TYPE_PNV_PHB3 "pnv-phb3"
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB3, PNV_PHB3)
|
2020-01-27 17:45:06 +03:00
|
|
|
|
|
|
|
#define PNV_PHB3_NUM_M64 16
|
|
|
|
#define PNV_PHB3_NUM_REGS (0x1000 >> 3)
|
|
|
|
#define PNV_PHB3_NUM_LSI 8
|
|
|
|
#define PNV_PHB3_NUM_PE 256
|
|
|
|
|
|
|
|
#define PCI_MMIO_TOTAL_SIZE (0x1ull << 60)
|
|
|
|
|
|
|
|
struct PnvPHB3 {
|
2022-06-24 11:49:12 +03:00
|
|
|
DeviceState parent;
|
|
|
|
|
|
|
|
PnvPHB *phb_base;
|
2020-01-27 17:45:06 +03:00
|
|
|
|
|
|
|
uint32_t chip_id;
|
|
|
|
uint32_t phb_id;
|
|
|
|
char bus_path[8];
|
|
|
|
|
|
|
|
uint64_t regs[PNV_PHB3_NUM_REGS];
|
|
|
|
MemoryRegion mr_regs;
|
|
|
|
|
|
|
|
MemoryRegion mr_m32;
|
|
|
|
MemoryRegion mr_m64[PNV_PHB3_NUM_M64];
|
|
|
|
MemoryRegion pci_mmio;
|
|
|
|
MemoryRegion pci_io;
|
|
|
|
|
|
|
|
uint64_t ioda_LIST[8];
|
|
|
|
uint64_t ioda_LXIVT[8];
|
|
|
|
uint64_t ioda_TVT[512];
|
|
|
|
uint64_t ioda_M64BT[16];
|
|
|
|
uint64_t ioda_MDT[256];
|
|
|
|
uint64_t ioda_PEEV[4];
|
|
|
|
|
|
|
|
uint32_t total_irq;
|
|
|
|
ICSState lsis;
|
|
|
|
qemu_irq *qirqs;
|
|
|
|
Phb3MsiState msis;
|
|
|
|
|
|
|
|
PnvPBCQState pbcq;
|
|
|
|
|
|
|
|
QLIST_HEAD(, PnvPhb3DMASpace) dma_spaces;
|
2021-12-17 19:57:19 +03:00
|
|
|
|
|
|
|
PnvChip *chip;
|
2020-01-27 17:45:06 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
uint64_t pnv_phb3_reg_read(void *opaque, hwaddr off, unsigned size);
|
|
|
|
void pnv_phb3_reg_write(void *opaque, hwaddr off, uint64_t val, unsigned size);
|
|
|
|
void pnv_phb3_update_regions(PnvPHB3 *phb);
|
|
|
|
void pnv_phb3_remap_irqs(PnvPHB3 *phb);
|
2022-06-24 11:49:10 +03:00
|
|
|
void pnv_phb3_bus_init(DeviceState *dev, PnvPHB3 *phb);
|
2020-01-27 17:45:06 +03:00
|
|
|
|
|
|
|
#endif /* PCI_HOST_PNV_PHB3_H */
|