mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-20 09:07:11 +00:00
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:
parent
ff54fa2325
commit
4c8e60f1d0
@ -7,6 +7,7 @@
|
|||||||
#include <vm_config.h>
|
#include <vm_config.h>
|
||||||
#include <pci.h>
|
#include <pci.h>
|
||||||
#include <pci_dev.h>
|
#include <pci_dev.h>
|
||||||
|
#include <vpci.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In theory, emulated PCI device doesn't need to bind to physical PCI device.
|
* In theory, emulated PCI device doesn't need to bind to physical PCI device.
|
||||||
@ -19,6 +20,7 @@ struct acrn_vm_pci_dev_config sos_pci_devs[CONFIG_MAX_PCI_DEV_NUM] = {
|
|||||||
.emu_type = PCI_DEV_TYPE_HVEMUL,
|
.emu_type = PCI_DEV_TYPE_HVEMUL,
|
||||||
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||||
.pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
.pbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||||
|
.vdev_ops = &vhostbridge_ops,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -122,14 +122,9 @@ static int32_t vhostbridge_write_cfg(struct pci_vdev *vdev, uint32_t offset,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pci_vdev_ops vhostbridge_ops = {
|
const struct pci_vdev_ops vhostbridge_ops = {
|
||||||
.init_vdev = init_vhostbridge,
|
.init_vdev = init_vhostbridge,
|
||||||
.deinit_vdev = deinit_vhostbridge,
|
.deinit_vdev = deinit_vhostbridge,
|
||||||
.write_vdev_cfg = vhostbridge_write_cfg,
|
.write_vdev_cfg = vhostbridge_write_cfg,
|
||||||
.read_vdev_cfg = vhostbridge_read_cfg,
|
.read_vdev_cfg = vhostbridge_read_cfg,
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct pci_vdev_ops *get_vhostbridge_ops(void)
|
|
||||||
{
|
|
||||||
return &vhostbridge_ops;
|
|
||||||
}
|
|
||||||
|
@ -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->pdev = dev_config->pdev;
|
||||||
vdev->pci_dev_config = dev_config;
|
vdev->pci_dev_config = dev_config;
|
||||||
|
|
||||||
if (dev_config->emu_type == PCI_DEV_TYPE_PTDEV) {
|
if (dev_config->vdev_ops != NULL) {
|
||||||
vdev->vdev_ops = &pci_pt_dev_ops;
|
vdev->vdev_ops = dev_config->vdev_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);
|
|
||||||
} else {
|
} 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);
|
vdev->vdev_ops->init_vdev(vdev);
|
||||||
|
@ -88,6 +88,7 @@ struct acrn_vm_pci_dev_config {
|
|||||||
union pci_bdf pbdf; /* physical BDF of PCI device */
|
union pci_bdf pbdf; /* physical BDF of PCI device */
|
||||||
uint64_t vbar_base[PCI_BAR_COUNT]; /* vbar base address of PCI device */
|
uint64_t vbar_base[PCI_BAR_COUNT]; /* vbar base address of PCI device */
|
||||||
struct pci_pdev *pdev; /* the physical PCI device if it's a PT device */
|
struct pci_pdev *pdev; /* the physical PCI device if it's a PT device */
|
||||||
|
const struct pci_vdev_ops *vdev_ops; /* operations for PCI CFG read/write */
|
||||||
} __aligned(8);
|
} __aligned(8);
|
||||||
|
|
||||||
struct acrn_vm_config {
|
struct acrn_vm_config {
|
||||||
|
@ -111,11 +111,10 @@ struct acrn_vpci {
|
|||||||
struct pci_vdev pci_vdevs[CONFIG_MAX_PCI_DEV_NUM];
|
struct pci_vdev pci_vdevs[CONFIG_MAX_PCI_DEV_NUM];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern const struct pci_vdev_ops vhostbridge_ops;
|
||||||
void vpci_init(struct acrn_vm *vm);
|
void vpci_init(struct acrn_vm *vm);
|
||||||
void vpci_cleanup(const 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);
|
void vpci_set_ptdev_intr_info(const struct acrn_vm *target_vm, uint16_t vbdf, uint16_t pbdf);
|
||||||
void vpci_reset_ptdev_intr_info(const struct acrn_vm *target_vm, uint16_t vbdf, uint16_t pbdf);
|
void vpci_reset_ptdev_intr_info(const struct acrn_vm *target_vm, uint16_t vbdf, uint16_t pbdf);
|
||||||
|
|
||||||
const struct pci_vdev_ops *get_vhostbridge_ops(void);
|
|
||||||
|
|
||||||
#endif /* VPCI_H_ */
|
#endif /* VPCI_H_ */
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <vm_config.h>
|
#include <vm_config.h>
|
||||||
#include <pci_devices.h>
|
#include <pci_devices.h>
|
||||||
|
#include <vpci.h>
|
||||||
|
|
||||||
/* The vbar_base info of pt devices is included in device MACROs which defined in
|
/* The vbar_base info of pt devices is included in device MACROs which defined in
|
||||||
* arch/x86/configs/$(CONFIG_BOARD)/pci_devices.h.
|
* arch/x86/configs/$(CONFIG_BOARD)/pci_devices.h.
|
||||||
@ -16,6 +17,7 @@ struct acrn_vm_pci_dev_config vm0_pci_devs[VM0_CONFIG_PCI_DEV_NUM] = {
|
|||||||
{
|
{
|
||||||
.emu_type = PCI_DEV_TYPE_HVEMUL,
|
.emu_type = PCI_DEV_TYPE_HVEMUL,
|
||||||
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||||
|
.vdev_ops = &vhostbridge_ops,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.emu_type = PCI_DEV_TYPE_PTDEV,
|
.emu_type = PCI_DEV_TYPE_PTDEV,
|
||||||
@ -33,6 +35,7 @@ struct acrn_vm_pci_dev_config vm1_pci_devs[VM1_CONFIG_PCI_DEV_NUM] = {
|
|||||||
{
|
{
|
||||||
.emu_type = PCI_DEV_TYPE_HVEMUL,
|
.emu_type = PCI_DEV_TYPE_HVEMUL,
|
||||||
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},
|
||||||
|
.vdev_ops = &vhostbridge_ops,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.emu_type = PCI_DEV_TYPE_PTDEV,
|
.emu_type = PCI_DEV_TYPE_PTDEV,
|
||||||
|
Loading…
Reference in New Issue
Block a user