hv: vpci: add each vdev_ops for each emulated PCI device

Add a field (vdev_ops) in struct acrn_vm_pci_dev_config to configure a PCI CFG
operation for an emulated PCI device. Use pci_pt_dev_ops for PCI_DEV_TYPE_PTDEV
by default if there's no such configure.

Tracked-On: #3475
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Li, Fei1
2019-08-07 23:29:18 +08:00
committed by ACRN System Integration
parent ff54fa2325
commit 4c8e60f1d0
6 changed files with 14 additions and 14 deletions

View File

@@ -122,14 +122,9 @@ static int32_t vhostbridge_write_cfg(struct pci_vdev *vdev, uint32_t offset,
return 0;
}
static const struct pci_vdev_ops vhostbridge_ops = {
const struct pci_vdev_ops vhostbridge_ops = {
.init_vdev = init_vhostbridge,
.deinit_vdev = deinit_vhostbridge,
.write_vdev_cfg = vhostbridge_write_cfg,
.read_vdev_cfg = vhostbridge_read_cfg,
};
const struct pci_vdev_ops *get_vhostbridge_ops(void)
{
return &vhostbridge_ops;
}

View File

@@ -427,13 +427,13 @@ static void vpci_init_vdev(struct acrn_vpci *vpci, struct acrn_vm_pci_dev_config
vdev->pdev = dev_config->pdev;
vdev->pci_dev_config = dev_config;
if (dev_config->emu_type == PCI_DEV_TYPE_PTDEV) {
vdev->vdev_ops = &pci_pt_dev_ops;
ASSERT(dev_config->pdev != NULL,
"PCI PTDev %x:%x.%x is not present in the platform!",
dev_config->pbdf.b, dev_config->pbdf.d, dev_config->pbdf.f);
if (dev_config->vdev_ops != NULL) {
vdev->vdev_ops = dev_config->vdev_ops;
} else {
vdev->vdev_ops = get_vhostbridge_ops();
vdev->vdev_ops = &pci_pt_dev_ops;
ASSERT(dev_config->emu_type == PCI_DEV_TYPE_PTDEV,
"Only PCI_DEV_TYPE_PTDEV could not configure vdev_ops");
ASSERT(dev_config->pdev != NULL, "PCI PTDev is not present on platform!");
}
vdev->vdev_ops->init_vdev(vdev);