From a403128a46b70f2f06809618d4acb8a45ad0a293 Mon Sep 17 00:00:00 2001 From: dongshen Date: Wed, 6 Mar 2019 15:24:17 -0800 Subject: [PATCH] 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 Acked-by: Eddie Dong --- hypervisor/dm/vpci/partition_mode.c | 7 ------ hypervisor/dm/vpci/pci_priv.h | 3 --- hypervisor/dm/vpci/sharing_mode.c | 7 ------ hypervisor/dm/vpci/vpci.c | 33 +++++++++++++++++------------ hypervisor/include/dm/vpci.h | 10 --------- 5 files changed, 19 insertions(+), 41 deletions(-) diff --git a/hypervisor/dm/vpci/partition_mode.c b/hypervisor/dm/vpci/partition_mode.c index 6b9f1aae2..b85b2009d 100644 --- a/hypervisor/dm/vpci/partition_mode.c +++ b/hypervisor/dm/vpci/partition_mode.c @@ -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, -}; diff --git a/hypervisor/dm/vpci/pci_priv.h b/hypervisor/dm/vpci/pci_priv.h index d06a207db..27d130c8d 100644 --- a/hypervisor/dm/vpci/pci_priv.h +++ b/hypervisor/dm/vpci/pci_priv.h @@ -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); diff --git a/hypervisor/dm/vpci/sharing_mode.c b/hypervisor/dm/vpci/sharing_mode.c index 4e8b99c99..46d4f27a3 100644 --- a/hypervisor/dm/vpci/sharing_mode.c +++ b/hypervisor/dm/vpci/sharing_mode.c @@ -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; diff --git a/hypervisor/dm/vpci/vpci.c b/hypervisor/dm/vpci/vpci.c index d53df312f..bb0024cb6 100644 --- a/hypervisor/dm/vpci/vpci.c +++ b/hypervisor/dm/vpci/vpci.c @@ -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 } diff --git a/hypervisor/include/dm/vpci.h b/hypervisor/include/dm/vpci.h index e68e86b56..7aa187a2d 100644 --- a/hypervisor/include/dm/vpci.h +++ b/hypervisor/include/dm/vpci.h @@ -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]; };