2015-01-09 11:04:38 +03:00
|
|
|
/*
|
|
|
|
* s390 PCI BUS definitions
|
|
|
|
*
|
|
|
|
* Copyright 2014 IBM Corp.
|
|
|
|
* Author(s): Frank Blaschka <frank.blaschka@de.ibm.com>
|
|
|
|
* Hong Bo Li <lihbbj@cn.ibm.com>
|
|
|
|
* Yi Min Zhao <zyimin@cn.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or (at
|
|
|
|
* your option) any later version. See the COPYING file in the top-level
|
|
|
|
* directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HW_S390_PCI_BUS_H
|
|
|
|
#define HW_S390_PCI_BUS_H
|
|
|
|
|
2016-06-22 20:11:19 +03:00
|
|
|
#include "hw/pci/pci.h"
|
|
|
|
#include "hw/pci/pci_host.h"
|
2015-01-09 11:04:38 +03:00
|
|
|
#include "hw/s390x/sclp.h"
|
|
|
|
#include "hw/s390x/s390_flic.h"
|
|
|
|
#include "hw/s390x/css.h"
|
2020-10-26 18:34:36 +03:00
|
|
|
#include "hw/s390x/s390-pci-clp.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.h"
|
2015-01-09 11:04:38 +03:00
|
|
|
|
|
|
|
#define TYPE_S390_PCI_HOST_BRIDGE "s390-pcihost"
|
2016-04-14 14:02:39 +03:00
|
|
|
#define TYPE_S390_PCI_BUS "s390-pcibus"
|
2016-05-11 10:10:06 +03:00
|
|
|
#define TYPE_S390_PCI_DEVICE "zpci"
|
2016-12-08 08:02:24 +03:00
|
|
|
#define TYPE_S390_PCI_IOMMU "s390-pci-iommu"
|
2017-07-11 06:56:20 +03:00
|
|
|
#define TYPE_S390_IOMMU_MEMORY_REGION "s390-iommu-memory-region"
|
2016-05-13 11:16:30 +03:00
|
|
|
#define FH_MASK_ENABLE 0x80000000
|
|
|
|
#define FH_MASK_INSTANCE 0x7f000000
|
|
|
|
#define FH_MASK_SHM 0x00ff0000
|
2016-11-15 10:51:38 +03:00
|
|
|
#define FH_MASK_INDEX 0x0000ffff
|
2016-05-13 11:16:30 +03:00
|
|
|
#define FH_SHM_VFIO 0x00010000
|
|
|
|
#define FH_SHM_EMUL 0x00020000
|
2016-05-11 10:10:06 +03:00
|
|
|
#define ZPCI_MAX_FID 0xffffffff
|
|
|
|
#define ZPCI_MAX_UID 0xffff
|
|
|
|
#define UID_UNDEFINED 0
|
2016-05-11 10:22:42 +03:00
|
|
|
#define UID_CHECKING_ENABLED 0x01
|
2021-12-03 17:27:06 +03:00
|
|
|
#define ZPCI_DTSM 0x40
|
2015-01-09 11:04:38 +03:00
|
|
|
|
2022-12-09 22:57:00 +03:00
|
|
|
/* zPCI Function Types */
|
|
|
|
#define ZPCI_PFT_ISM 5
|
|
|
|
|
2020-09-16 21:25:19 +03:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(S390pciState, S390_PCI_HOST_BRIDGE)
|
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(S390PCIBus, S390_PCI_BUS)
|
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(S390PCIBusDevice, S390_PCI_DEVICE)
|
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(S390PCIIOMMU, S390_PCI_IOMMU)
|
2015-01-09 11:04:38 +03:00
|
|
|
|
|
|
|
#define HP_EVENT_TO_CONFIGURED 0x0301
|
|
|
|
#define HP_EVENT_RESERVED_TO_STANDBY 0x0302
|
2016-04-27 12:44:17 +03:00
|
|
|
#define HP_EVENT_DECONFIGURE_REQUEST 0x0303
|
2015-01-09 11:04:38 +03:00
|
|
|
#define HP_EVENT_CONFIGURED_TO_STBRES 0x0304
|
|
|
|
#define HP_EVENT_STANDBY_TO_RESERVED 0x0308
|
|
|
|
|
|
|
|
#define ERR_EVENT_INVALAS 0x1
|
|
|
|
#define ERR_EVENT_OORANGE 0x2
|
|
|
|
#define ERR_EVENT_INVALTF 0x3
|
|
|
|
#define ERR_EVENT_TPROTE 0x4
|
|
|
|
#define ERR_EVENT_APROTE 0x5
|
|
|
|
#define ERR_EVENT_KEYE 0x6
|
|
|
|
#define ERR_EVENT_INVALTE 0x7
|
|
|
|
#define ERR_EVENT_INVALTL 0x8
|
|
|
|
#define ERR_EVENT_TT 0x9
|
|
|
|
#define ERR_EVENT_INVALMS 0xa
|
|
|
|
#define ERR_EVENT_SERR 0xb
|
|
|
|
#define ERR_EVENT_NOMSI 0x10
|
|
|
|
#define ERR_EVENT_INVALBV 0x11
|
|
|
|
#define ERR_EVENT_AIBV 0x12
|
|
|
|
#define ERR_EVENT_AIRERR 0x13
|
|
|
|
#define ERR_EVENT_FMBA 0x2a
|
|
|
|
#define ERR_EVENT_FMBUP 0x2b
|
|
|
|
#define ERR_EVENT_FMBPRO 0x2c
|
|
|
|
#define ERR_EVENT_CCONF 0x30
|
|
|
|
#define ERR_EVENT_SERVAC 0x3a
|
|
|
|
#define ERR_EVENT_PERMERR 0x3b
|
|
|
|
|
|
|
|
#define ERR_EVENT_Q_BIT 0x2
|
|
|
|
#define ERR_EVENT_MVN_OFFSET 16
|
|
|
|
|
|
|
|
#define ZPCI_MSI_VEC_BITS 11
|
|
|
|
#define ZPCI_MSI_VEC_MASK 0x7ff
|
|
|
|
|
|
|
|
#define ZPCI_MSI_ADDR 0xfe00000000000000ULL
|
|
|
|
#define ZPCI_SDMA_ADDR 0x100000000ULL
|
|
|
|
#define ZPCI_EDMA_ADDR 0x1ffffffffffffffULL
|
|
|
|
|
|
|
|
#define PAGE_DEFAULT_ACC 0
|
|
|
|
#define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4)
|
|
|
|
|
|
|
|
/* I/O Translation Anchor (IOTA) */
|
|
|
|
enum ZpciIoatDtype {
|
|
|
|
ZPCI_IOTA_STO = 0,
|
|
|
|
ZPCI_IOTA_RTTO = 1,
|
|
|
|
ZPCI_IOTA_RSTO = 2,
|
|
|
|
ZPCI_IOTA_RFTO = 3,
|
|
|
|
ZPCI_IOTA_PFAA = 4,
|
|
|
|
ZPCI_IOTA_IOPFAA = 5,
|
|
|
|
ZPCI_IOTA_IOPTO = 7
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ZPCI_IOTA_IOT_ENABLED 0x800ULL
|
|
|
|
#define ZPCI_IOTA_DT_ST (ZPCI_IOTA_STO << 2)
|
|
|
|
#define ZPCI_IOTA_DT_RT (ZPCI_IOTA_RTTO << 2)
|
|
|
|
#define ZPCI_IOTA_DT_RS (ZPCI_IOTA_RSTO << 2)
|
|
|
|
#define ZPCI_IOTA_DT_RF (ZPCI_IOTA_RFTO << 2)
|
|
|
|
#define ZPCI_IOTA_DT_PF (ZPCI_IOTA_PFAA << 2)
|
|
|
|
#define ZPCI_IOTA_FS_4K 0
|
|
|
|
#define ZPCI_IOTA_FS_1M 1
|
|
|
|
#define ZPCI_IOTA_FS_2G 2
|
|
|
|
#define ZPCI_KEY (PAGE_DEFAULT_KEY << 5)
|
|
|
|
|
|
|
|
#define ZPCI_IOTA_STO_FLAG (ZPCI_IOTA_IOT_ENABLED | ZPCI_KEY | ZPCI_IOTA_DT_ST)
|
|
|
|
#define ZPCI_IOTA_RTTO_FLAG (ZPCI_IOTA_IOT_ENABLED | ZPCI_KEY | ZPCI_IOTA_DT_RT)
|
|
|
|
#define ZPCI_IOTA_RSTO_FLAG (ZPCI_IOTA_IOT_ENABLED | ZPCI_KEY | ZPCI_IOTA_DT_RS)
|
|
|
|
#define ZPCI_IOTA_RFTO_FLAG (ZPCI_IOTA_IOT_ENABLED | ZPCI_KEY | ZPCI_IOTA_DT_RF)
|
|
|
|
#define ZPCI_IOTA_RFAA_FLAG (ZPCI_IOTA_IOT_ENABLED | ZPCI_KEY |\
|
|
|
|
ZPCI_IOTA_DT_PF | ZPCI_IOTA_FS_2G)
|
|
|
|
|
|
|
|
/* I/O Region and segment tables */
|
|
|
|
#define ZPCI_INDEX_MASK 0x7ffULL
|
|
|
|
|
|
|
|
#define ZPCI_TABLE_TYPE_MASK 0xc
|
|
|
|
#define ZPCI_TABLE_TYPE_RFX 0xc
|
|
|
|
#define ZPCI_TABLE_TYPE_RSX 0x8
|
|
|
|
#define ZPCI_TABLE_TYPE_RTX 0x4
|
|
|
|
#define ZPCI_TABLE_TYPE_SX 0x0
|
|
|
|
|
|
|
|
#define ZPCI_TABLE_LEN_RFX 0x3
|
|
|
|
#define ZPCI_TABLE_LEN_RSX 0x3
|
|
|
|
#define ZPCI_TABLE_LEN_RTX 0x3
|
|
|
|
|
|
|
|
#define ZPCI_TABLE_OFFSET_MASK 0xc0
|
|
|
|
#define ZPCI_TABLE_SIZE 0x4000
|
|
|
|
#define ZPCI_TABLE_ALIGN ZPCI_TABLE_SIZE
|
|
|
|
#define ZPCI_TABLE_ENTRY_SIZE (sizeof(unsigned long))
|
|
|
|
#define ZPCI_TABLE_ENTRIES (ZPCI_TABLE_SIZE / ZPCI_TABLE_ENTRY_SIZE)
|
|
|
|
|
|
|
|
#define ZPCI_TABLE_BITS 11
|
|
|
|
#define ZPCI_PT_BITS 8
|
2021-09-01 15:58:00 +03:00
|
|
|
#define ZPCI_ST_SHIFT (ZPCI_PT_BITS + TARGET_PAGE_BITS)
|
2015-01-09 11:04:38 +03:00
|
|
|
#define ZPCI_RT_SHIFT (ZPCI_ST_SHIFT + ZPCI_TABLE_BITS)
|
|
|
|
|
|
|
|
#define ZPCI_RTE_FLAG_MASK 0x3fffULL
|
|
|
|
#define ZPCI_RTE_ADDR_MASK (~ZPCI_RTE_FLAG_MASK)
|
|
|
|
#define ZPCI_STE_FLAG_MASK 0x7ffULL
|
|
|
|
#define ZPCI_STE_ADDR_MASK (~ZPCI_STE_FLAG_MASK)
|
|
|
|
|
2018-02-05 10:22:56 +03:00
|
|
|
#define ZPCI_SFAA_MASK (~((1ULL << 20) - 1))
|
|
|
|
|
2015-01-09 11:04:38 +03:00
|
|
|
/* I/O Page tables */
|
|
|
|
#define ZPCI_PTE_VALID_MASK 0x400
|
|
|
|
#define ZPCI_PTE_INVALID 0x400
|
|
|
|
#define ZPCI_PTE_VALID 0x000
|
|
|
|
#define ZPCI_PT_SIZE 0x800
|
|
|
|
#define ZPCI_PT_ALIGN ZPCI_PT_SIZE
|
|
|
|
#define ZPCI_PT_ENTRIES (ZPCI_PT_SIZE / ZPCI_TABLE_ENTRY_SIZE)
|
|
|
|
#define ZPCI_PT_MASK (ZPCI_PT_ENTRIES - 1)
|
|
|
|
|
|
|
|
#define ZPCI_PTE_FLAG_MASK 0xfffULL
|
|
|
|
#define ZPCI_PTE_ADDR_MASK (~ZPCI_PTE_FLAG_MASK)
|
|
|
|
|
|
|
|
/* Shared bits */
|
|
|
|
#define ZPCI_TABLE_VALID 0x00
|
|
|
|
#define ZPCI_TABLE_INVALID 0x20
|
|
|
|
#define ZPCI_TABLE_PROTECTED 0x200
|
|
|
|
#define ZPCI_TABLE_UNPROTECTED 0x000
|
2018-02-05 10:22:56 +03:00
|
|
|
#define ZPCI_TABLE_FC 0x400
|
2015-01-09 11:04:38 +03:00
|
|
|
|
|
|
|
#define ZPCI_TABLE_VALID_MASK 0x20
|
|
|
|
#define ZPCI_TABLE_PROT_MASK 0x200
|
|
|
|
|
2018-02-05 10:22:56 +03:00
|
|
|
#define ZPCI_ETT_RT 1
|
|
|
|
#define ZPCI_ETT_ST 0
|
|
|
|
#define ZPCI_ETT_PT -1
|
|
|
|
|
2016-04-19 10:03:13 +03:00
|
|
|
/* PCI Function States
|
|
|
|
*
|
|
|
|
* reserved: default; device has just been plugged or is in progress of being
|
|
|
|
* unplugged
|
|
|
|
* standby: device is present but not configured; transition from any
|
|
|
|
* configured state/to this state via sclp configure/deconfigure
|
|
|
|
*
|
|
|
|
* The following states make up the "configured" meta-state:
|
|
|
|
* disabled: device is configured but not enabled; transition between this
|
|
|
|
* state and enabled via clp enable/disable
|
|
|
|
* enbaled: device is ready for use; transition to disabled via clp disable;
|
|
|
|
* may enter an error state
|
|
|
|
* blocked: ignore all DMA and interrupts; transition back to enabled or from
|
|
|
|
* error state via mpcifc
|
2016-11-19 22:29:26 +03:00
|
|
|
* error: an error occurred; transition back to enabled via mpcifc
|
|
|
|
* permanent error: an unrecoverable error occurred; transition to standby via
|
2016-04-19 10:03:13 +03:00
|
|
|
* sclp deconfigure
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
ZPCI_FS_RESERVED,
|
|
|
|
ZPCI_FS_STANDBY,
|
|
|
|
ZPCI_FS_DISABLED,
|
|
|
|
ZPCI_FS_ENABLED,
|
|
|
|
ZPCI_FS_BLOCKED,
|
|
|
|
ZPCI_FS_ERROR,
|
|
|
|
ZPCI_FS_PERMANENT_ERROR,
|
|
|
|
} ZpciState;
|
|
|
|
|
2015-01-09 11:04:38 +03:00
|
|
|
typedef struct SeiContainer {
|
|
|
|
QTAILQ_ENTRY(SeiContainer) link;
|
|
|
|
uint32_t fid;
|
|
|
|
uint32_t fh;
|
|
|
|
uint8_t cc;
|
|
|
|
uint16_t pec;
|
|
|
|
uint64_t faddr;
|
|
|
|
uint32_t e;
|
|
|
|
} SeiContainer;
|
|
|
|
|
|
|
|
typedef struct PciCcdfErr {
|
|
|
|
uint32_t reserved1;
|
|
|
|
uint32_t fh;
|
|
|
|
uint32_t fid;
|
|
|
|
uint32_t e;
|
|
|
|
uint64_t faddr;
|
|
|
|
uint32_t reserved3;
|
|
|
|
uint16_t reserved4;
|
|
|
|
uint16_t pec;
|
|
|
|
} QEMU_PACKED PciCcdfErr;
|
|
|
|
|
|
|
|
typedef struct PciCcdfAvail {
|
|
|
|
uint32_t reserved1;
|
|
|
|
uint32_t fh;
|
|
|
|
uint32_t fid;
|
|
|
|
uint32_t reserved2;
|
|
|
|
uint32_t reserved3;
|
|
|
|
uint32_t reserved4;
|
|
|
|
uint32_t reserved5;
|
|
|
|
uint16_t reserved6;
|
|
|
|
uint16_t pec;
|
|
|
|
} QEMU_PACKED PciCcdfAvail;
|
|
|
|
|
|
|
|
typedef struct ChscSeiNt2Res {
|
|
|
|
uint16_t length;
|
|
|
|
uint16_t code;
|
|
|
|
uint16_t reserved1;
|
|
|
|
uint8_t reserved2;
|
|
|
|
uint8_t nt;
|
|
|
|
uint8_t flags;
|
|
|
|
uint8_t reserved3;
|
|
|
|
uint8_t reserved4;
|
|
|
|
uint8_t cc;
|
|
|
|
uint32_t reserved5[13];
|
|
|
|
uint8_t ccdf[4016];
|
|
|
|
} QEMU_PACKED ChscSeiNt2Res;
|
|
|
|
|
|
|
|
typedef struct S390MsixInfo {
|
|
|
|
uint8_t table_bar;
|
|
|
|
uint8_t pba_bar;
|
|
|
|
uint16_t entries;
|
|
|
|
uint32_t table_offset;
|
|
|
|
uint32_t pba_offset;
|
|
|
|
} S390MsixInfo;
|
|
|
|
|
2018-02-05 10:22:56 +03:00
|
|
|
typedef struct S390IOTLBEntry {
|
|
|
|
uint64_t iova;
|
|
|
|
uint64_t translated_addr;
|
|
|
|
uint64_t len;
|
|
|
|
uint64_t perm;
|
|
|
|
} S390IOTLBEntry;
|
|
|
|
|
2020-10-26 18:34:35 +03:00
|
|
|
typedef struct S390PCIDMACount {
|
|
|
|
int id;
|
|
|
|
int users;
|
|
|
|
uint32_t avail;
|
|
|
|
QTAILQ_ENTRY(S390PCIDMACount) link;
|
|
|
|
} S390PCIDMACount;
|
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct S390PCIIOMMU {
|
2016-12-08 08:02:24 +03:00
|
|
|
Object parent_obj;
|
|
|
|
S390PCIBusDevice *pbdev;
|
2016-05-11 10:10:36 +03:00
|
|
|
AddressSpace as;
|
|
|
|
MemoryRegion mr;
|
2017-07-11 06:56:19 +03:00
|
|
|
IOMMUMemoryRegion iommu_mr;
|
2016-12-08 08:02:24 +03:00
|
|
|
bool enabled;
|
|
|
|
uint64_t g_iota;
|
|
|
|
uint64_t pba;
|
|
|
|
uint64_t pal;
|
2022-10-28 22:47:58 +03:00
|
|
|
uint64_t max_dma_limit;
|
2018-02-05 10:22:57 +03:00
|
|
|
GHashTable *iotlb;
|
2020-10-26 18:34:35 +03:00
|
|
|
S390PCIDMACount *dma_limit;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2016-05-11 10:10:36 +03:00
|
|
|
|
2016-12-08 08:03:18 +03:00
|
|
|
typedef struct S390PCIIOMMUTable {
|
|
|
|
uint64_t key;
|
|
|
|
S390PCIIOMMU *iommu[PCI_SLOT_MAX];
|
|
|
|
} S390PCIIOMMUTable;
|
|
|
|
|
2019-01-08 20:37:30 +03:00
|
|
|
/* Function Measurement Block */
|
|
|
|
#define DEFAULT_MUI 4000
|
|
|
|
#define UPDATE_U_BIT 0x1ULL
|
|
|
|
#define FMBK_MASK 0xfULL
|
|
|
|
|
|
|
|
typedef struct ZpciFmbFmt0 {
|
|
|
|
uint64_t dma_rbytes;
|
|
|
|
uint64_t dma_wbytes;
|
|
|
|
} ZpciFmbFmt0;
|
|
|
|
|
|
|
|
#define ZPCI_FMB_CNT_LD 0
|
|
|
|
#define ZPCI_FMB_CNT_ST 1
|
|
|
|
#define ZPCI_FMB_CNT_STB 2
|
|
|
|
#define ZPCI_FMB_CNT_RPCIT 3
|
|
|
|
#define ZPCI_FMB_CNT_MAX 4
|
|
|
|
|
|
|
|
#define ZPCI_FMB_FORMAT 0
|
|
|
|
|
|
|
|
typedef struct ZpciFmb {
|
|
|
|
uint32_t format;
|
|
|
|
uint32_t sample;
|
|
|
|
uint64_t last_update;
|
|
|
|
uint64_t counter[ZPCI_FMB_CNT_MAX];
|
|
|
|
ZpciFmbFmt0 fmt0;
|
|
|
|
} ZpciFmb;
|
|
|
|
QEMU_BUILD_BUG_MSG(offsetof(ZpciFmb, fmt0) != 48, "padding in ZpciFmb");
|
|
|
|
|
2021-12-03 17:27:03 +03:00
|
|
|
#define ZPCI_DEFAULT_FN_GRP 0xFF
|
2022-09-02 20:27:35 +03:00
|
|
|
#define ZPCI_SIM_GRP_START 0xF0
|
2020-10-26 18:34:37 +03:00
|
|
|
typedef struct S390PCIGroup {
|
|
|
|
ClpRspQueryPciGrp zpci_group;
|
|
|
|
int id;
|
2022-09-02 20:27:35 +03:00
|
|
|
int host_id;
|
2020-10-26 18:34:37 +03:00
|
|
|
QTAILQ_ENTRY(S390PCIGroup) link;
|
|
|
|
} S390PCIGroup;
|
2022-09-02 20:27:35 +03:00
|
|
|
S390PCIGroup *s390_group_create(int id, int host_id);
|
2020-10-26 18:34:37 +03:00
|
|
|
S390PCIGroup *s390_group_find(int id);
|
2022-09-02 20:27:35 +03:00
|
|
|
S390PCIGroup *s390_group_find_host_sim(int host_id);
|
2020-10-26 18:34:37 +03:00
|
|
|
|
2017-01-27 16:20:52 +03:00
|
|
|
struct S390PCIBusDevice {
|
2016-05-11 10:10:06 +03:00
|
|
|
DeviceState qdev;
|
2015-01-09 11:04:38 +03:00
|
|
|
PCIDevice *pdev;
|
2016-04-19 10:03:13 +03:00
|
|
|
ZpciState state;
|
2016-05-11 10:10:06 +03:00
|
|
|
char *target;
|
|
|
|
uint16_t uid;
|
2016-11-15 10:51:38 +03:00
|
|
|
uint32_t idx;
|
2015-01-09 11:04:38 +03:00
|
|
|
uint32_t fh;
|
|
|
|
uint32_t fid;
|
2016-05-11 10:10:06 +03:00
|
|
|
bool fid_defined;
|
2015-01-09 11:04:38 +03:00
|
|
|
uint64_t fmb_addr;
|
2019-01-08 20:37:30 +03:00
|
|
|
ZpciFmb fmb;
|
|
|
|
QEMUTimer *fmb_timer;
|
2015-01-09 11:04:38 +03:00
|
|
|
uint8_t isc;
|
|
|
|
uint16_t noi;
|
2017-11-30 15:55:27 +03:00
|
|
|
uint16_t maxstbl;
|
2015-01-09 11:04:38 +03:00
|
|
|
uint8_t sum;
|
2022-12-09 22:57:00 +03:00
|
|
|
uint8_t pft;
|
2020-10-26 18:34:37 +03:00
|
|
|
S390PCIGroup *pci_group;
|
2020-10-26 18:34:39 +03:00
|
|
|
ClpRspQueryPci zpci_fn;
|
2015-01-09 11:04:38 +03:00
|
|
|
S390MsixInfo msix;
|
|
|
|
AdapterRoutes routes;
|
2016-05-11 10:10:36 +03:00
|
|
|
S390PCIIOMMU *iommu;
|
2016-09-06 09:00:44 +03:00
|
|
|
MemoryRegion msix_notify_mr;
|
2016-01-28 08:26:43 +03:00
|
|
|
IndAddr *summary_ind;
|
|
|
|
IndAddr *indicator;
|
2022-12-09 22:57:00 +03:00
|
|
|
Notifier shutdown_notifier;
|
s390x/pci: Introduce unplug requests and split unplug handler
PCI on s390x is really weird and how it was modeled in QEMU might not have
been the right choice. Anyhow, right now it is the case that:
- Hotplugging a PCI device will silently create a zPCI device
(if none is provided)
- Hotunplugging a zPCI device will unplug the PCI device (if any)
- Hotunplugging a PCI device will unplug also the zPCI device
As far as I can see, we can no longer change this behavior. But we
should fix it.
Both device types are handled via a single hotplug handler call. This
is problematic for various reasons:
1. Unplugging via the zPCI device allows to unplug devices that are not
hot removable. (check performed in qdev_unplug()) - bad.
2. Hotplug handler chains are not possible for the unplug case. In the
future, the machine might want to override hotplug handlers, to
process device specific stuff and to then branch off to the actual
hotplug handler. We need separate hotplug handler calls for both the
PCI and zPCI device to make this work reliably. All other PCI
implementations are already prepared to handle this correctly, only
s390x is missing.
Therefore, introduce the unplug_request handler and properly perform
unplug checks by redirecting to the separate unplug_request handlers.
When finally unplugging, perform two separate hotplug_handler_unplug()
calls, first for the PCI device, followed by the zPCI device. This now
nicely splits unplugging paths for both devices.
The redirect part is a little hairy, as the user is allowed to trigger
unplug either via the PCI or the zPCI device. So redirect always to the
PCI unplug request handler first and remember if that check has been
performed in the zPCI device. Redirect then to the zPCI device unplug
request handler to perform the magic. Remembering that we already
checked the PCI device breaks the redirect loop.
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20190130155733.32742-5-david@redhat.com>
Reviewed-by: Collin Walling <walling@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
2019-01-30 18:57:31 +03:00
|
|
|
bool pci_unplug_request_processed;
|
2019-01-30 18:57:32 +03:00
|
|
|
bool unplug_requested;
|
2022-09-02 20:27:32 +03:00
|
|
|
bool interp;
|
2022-09-02 20:27:34 +03:00
|
|
|
bool forwarding_assist;
|
2016-11-15 10:51:38 +03:00
|
|
|
QTAILQ_ENTRY(S390PCIBusDevice) link;
|
2017-01-27 16:20:52 +03:00
|
|
|
};
|
2015-01-09 11:04:38 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct S390PCIBus {
|
2016-04-14 14:02:39 +03:00
|
|
|
BusState qbus;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2016-04-14 14:02:39 +03:00
|
|
|
|
2020-09-03 23:43:22 +03:00
|
|
|
struct S390pciState {
|
2015-01-09 11:04:38 +03:00
|
|
|
PCIHostState parent_obj;
|
2016-11-15 10:51:38 +03:00
|
|
|
uint32_t next_idx;
|
2016-11-23 09:26:34 +03:00
|
|
|
int bus_no;
|
2016-04-14 14:02:39 +03:00
|
|
|
S390PCIBus *bus;
|
2016-12-08 08:03:18 +03:00
|
|
|
GHashTable *iommu_table;
|
2016-11-09 16:30:50 +03:00
|
|
|
GHashTable *zpci_table;
|
2015-01-09 11:04:38 +03:00
|
|
|
QTAILQ_HEAD(, SeiContainer) pending_sei;
|
2016-11-15 10:51:38 +03:00
|
|
|
QTAILQ_HEAD(, S390PCIBusDevice) zpci_devs;
|
2020-10-26 18:34:35 +03:00
|
|
|
QTAILQ_HEAD(, S390PCIDMACount) zpci_dma_limit;
|
2020-10-26 18:34:37 +03:00
|
|
|
QTAILQ_HEAD(, S390PCIGroup) zpci_groups;
|
2022-09-02 20:27:35 +03:00
|
|
|
uint8_t next_sim_grp;
|
2020-09-03 23:43:22 +03:00
|
|
|
};
|
2015-01-09 11:04:38 +03:00
|
|
|
|
2016-11-23 06:08:29 +03:00
|
|
|
S390pciState *s390_get_phb(void);
|
2017-07-06 17:40:21 +03:00
|
|
|
int pci_chsc_sei_nt2_get_event(void *res);
|
|
|
|
int pci_chsc_sei_nt2_have_event(void);
|
2016-04-28 07:33:53 +03:00
|
|
|
void s390_pci_sclp_configure(SCCB *sccb);
|
|
|
|
void s390_pci_sclp_deconfigure(SCCB *sccb);
|
2016-12-08 08:02:24 +03:00
|
|
|
void s390_pci_iommu_enable(S390PCIIOMMU *iommu);
|
|
|
|
void s390_pci_iommu_disable(S390PCIIOMMU *iommu);
|
2016-04-19 10:03:13 +03:00
|
|
|
void s390_pci_generate_error_event(uint16_t pec, uint32_t fh, uint32_t fid,
|
|
|
|
uint64_t faddr, uint32_t e);
|
2018-02-05 10:22:56 +03:00
|
|
|
uint16_t s390_guest_io_table_walk(uint64_t g_iota, hwaddr addr,
|
|
|
|
S390IOTLBEntry *entry);
|
2016-11-23 06:08:29 +03:00
|
|
|
S390PCIBusDevice *s390_pci_find_dev_by_idx(S390pciState *s, uint32_t idx);
|
|
|
|
S390PCIBusDevice *s390_pci_find_dev_by_fh(S390pciState *s, uint32_t fh);
|
|
|
|
S390PCIBusDevice *s390_pci_find_dev_by_fid(S390pciState *s, uint32_t fid);
|
2017-09-05 13:12:58 +03:00
|
|
|
S390PCIBusDevice *s390_pci_find_dev_by_target(S390pciState *s,
|
|
|
|
const char *target);
|
2016-11-23 06:08:29 +03:00
|
|
|
S390PCIBusDevice *s390_pci_find_next_avail_dev(S390pciState *s,
|
|
|
|
S390PCIBusDevice *pbdev);
|
2015-01-09 11:04:38 +03:00
|
|
|
|
|
|
|
#endif
|