HV: remove vdev ops for partition mode

Remove vdev ops for partition mode, change related code to directly call the corresponding
functions instead

Remove struct pci_vdev_ops from vpci.h

Add @pre for pci_find_vdev_by_pbdf and pci_find_vdev_by_vbdf/partition_mode_vpci_init

Change the return value from int32_t to void to comply with misra c and
add ASSERT/panic in the functions (if necessary):
 vdev_hostbridge_init
 vdev_hostbridge_deinit
 vdev_pt_init
 vdev_pt_deinit

Still use pr_err in partition_mode_cfgread and partition_mode_cfgwrite to check if vdev cfgread/cfgwrite
access is aligned on 1/2/4 bytes, which is the only case that vdev cfgread/cfgwrite will return
nonzero, pr_err will be removed in subsequent patch titled "unify the sharing
mode and partition mode coding style for similar functions"

Remove @pre for local variables

Add ASSERT in partition_mode_pdev_init to check if pdev is NULL (user config
error)

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 14:38:42 -08:00
committed by Eddie Dong
parent b1cc18810e
commit a7f528cfd0
6 changed files with 73 additions and 99 deletions

View File

@@ -32,18 +32,6 @@
#include <pci.h>
struct pci_vdev;
struct pci_vdev_ops {
int32_t (*init)(struct pci_vdev *vdev);
int32_t (*deinit)(const struct pci_vdev *vdev);
int32_t (*cfgwrite)(struct pci_vdev *vdev, uint32_t offset,
uint32_t bytes, uint32_t val);
int32_t (*cfgread)(const struct pci_vdev *vdev, uint32_t offset,
uint32_t bytes, uint32_t *val);
};
struct msix_table_entry {
uint64_t addr;
@@ -77,10 +65,6 @@ union pci_cfgdata {
};
struct pci_vdev {
#ifdef CONFIG_PARTITION_MODE
const struct pci_vdev_ops *ops;
#endif
const struct acrn_vpci *vpci;
/* The bus/device/function triple of the virtual PCI device. */
union pci_bdf vbdf;
@@ -121,11 +105,6 @@ struct acrn_vpci {
struct pci_vdev pci_vdevs[CONFIG_MAX_PCI_DEV_NUM];
};
#ifdef CONFIG_PARTITION_MODE
extern const struct pci_vdev_ops pci_ops_vdev_hostbridge;
extern const struct pci_vdev_ops pci_ops_vdev_pt;
#endif
void vpci_init(struct acrn_vm *vm);
void vpci_cleanup(const struct acrn_vm *vm);
void vpci_set_ptdev_intr_info(const struct acrn_vm *target_vm, uint16_t vbdf, uint16_t pbdf);