HV: remove vpci ops

Do not call vpci ops, call the corresponding sharing mode/partition functions
directly instead.

Remove struct vpci_ops from vpci.h

Tracked-On: #2534
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
dongshen 2019-03-06 15:24:17 -08:00 committed by Eddie Dong
parent aa1ee9424c
commit a403128a46
5 changed files with 19 additions and 41 deletions

View File

@ -172,10 +172,3 @@ void partition_mode_cfgwrite(struct acrn_vpci *vpci, union pci_bdf vbdf,
}
}
}
const struct vpci_ops partition_mode_vpci_ops = {
.init = partition_mode_vpci_init,
.deinit = partition_mode_vpci_deinit,
.cfgread = partition_mode_cfgread,
.cfgwrite = partition_mode_cfgwrite,
};

View File

@ -68,7 +68,6 @@ static inline void pci_vdev_write_cfg_u32(struct pci_vdev *vdev, uint32_t offset
}
#ifdef CONFIG_PARTITION_MODE
extern const struct vpci_ops partition_mode_vpci_ops;
void vdev_hostbridge_init(struct pci_vdev *vdev);
int32_t vdev_hostbridge_cfgread(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val);
int32_t vdev_hostbridge_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val);
@ -80,8 +79,6 @@ int32_t vdev_pt_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes,
void vdev_pt_deinit(const struct pci_vdev *vdev);
#else
extern const struct vpci_ops sharing_mode_vpci_ops;
void vmsi_init(struct pci_vdev *vdev);
int32_t vmsi_cfgread(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val);
int32_t vmsi_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val);

View File

@ -142,13 +142,6 @@ void sharing_mode_vpci_deinit(const struct acrn_vm *vm)
}
}
const struct vpci_ops sharing_mode_vpci_ops = {
.init = sharing_mode_vpci_init,
.deinit = sharing_mode_vpci_deinit,
.cfgread = sharing_mode_cfgread,
.cfgwrite = sharing_mode_cfgwrite,
};
void vpci_set_ptdev_intr_info(const struct acrn_vm *target_vm, uint16_t vbdf, uint16_t pbdf)
{
struct pci_vdev *vdev;

View File

@ -75,9 +75,11 @@ static uint32_t pci_cfgdata_io_read(struct acrn_vm *vm, uint16_t addr, size_t by
uint32_t val = ~0U;
if (pi->cached_enable) {
if ((vpci->ops != NULL) && (vpci->ops->cfgread != NULL)) {
vpci->ops->cfgread(vpci, pi->cached_bdf, pi->cached_reg + offset, bytes, &val);
}
#ifdef CONFIG_PARTITION_MODE
partition_mode_cfgread(vpci, pi->cached_bdf, pi->cached_reg + offset, bytes, &val);
#else
sharing_mode_cfgread(vpci, pi->cached_bdf, pi->cached_reg + offset, bytes, &val);
#endif
pci_cfg_clear_cache(pi);
}
@ -91,9 +93,11 @@ static void pci_cfgdata_io_write(struct acrn_vm *vm, uint16_t addr, size_t bytes
uint16_t offset = addr - PCI_CONFIG_DATA;
if (pi->cached_enable) {
if ((vpci->ops != NULL) && (vpci->ops->cfgwrite != NULL)) {
vpci->ops->cfgwrite(vpci, pi->cached_bdf, pi->cached_reg + offset, bytes, val);
}
#ifdef CONFIG_PARTITION_MODE
partition_mode_cfgwrite(vpci, pi->cached_bdf, pi->cached_reg + offset, bytes, val);
#else
sharing_mode_cfgwrite(vpci, pi->cached_bdf, pi->cached_reg + offset, bytes, val);
#endif
pci_cfg_clear_cache(pi);
}
}
@ -101,6 +105,7 @@ static void pci_cfgdata_io_write(struct acrn_vm *vm, uint16_t addr, size_t bytes
void vpci_init(struct acrn_vm *vm)
{
struct acrn_vpci *vpci = &vm->vpci;
int32_t ret;
struct vm_io_range pci_cfgaddr_range = {
.flags = IO_ATTR_RW,
@ -117,12 +122,12 @@ void vpci_init(struct acrn_vm *vm)
vpci->vm = vm;
#ifdef CONFIG_PARTITION_MODE
vpci->ops = &partition_mode_vpci_ops;
ret = partition_mode_vpci_init(vm);
#else
vpci->ops = &sharing_mode_vpci_ops;
ret = sharing_mode_vpci_init(vm);
#endif
if ((vpci->ops->init != NULL) && (vpci->ops->init(vm) == 0)) {
if (ret == 0) {
/*
* SOS: intercept port CF8 only.
* UOS or partition mode: register handler for CF8 only and I/O requests to CF9/CFA/CFB are
@ -139,9 +144,9 @@ void vpci_init(struct acrn_vm *vm)
void vpci_cleanup(const struct acrn_vm *vm)
{
const struct acrn_vpci *vpci = &vm->vpci;
if ((vpci->ops != NULL) && (vpci->ops->deinit != NULL)) {
vpci->ops->deinit(vm);
}
#ifdef CONFIG_PARTITION_MODE
partition_mode_vpci_deinit(vm);
#else
sharing_mode_vpci_deinit(vm);
#endif
}

View File

@ -88,19 +88,9 @@ struct pci_addr_info {
bool cached_enable;
};
struct vpci_ops {
int32_t (*init)(const struct acrn_vm *vm);
void (*deinit)(const struct acrn_vm *vm);
void (*cfgread)(struct acrn_vpci *vpci, union pci_bdf vbdf, uint32_t offset,
uint32_t bytes, uint32_t *val);
void (*cfgwrite)(struct acrn_vpci *vpci, union pci_bdf vbdf, uint32_t offset,
uint32_t bytes, uint32_t val);
};
struct acrn_vpci {
struct acrn_vm *vm;
struct pci_addr_info addr_info;
const struct vpci_ops *ops;
uint32_t pci_vdev_cnt;
struct pci_vdev pci_vdevs[CONFIG_MAX_PCI_DEV_NUM];
};