mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 05:57:33 +00:00
vhostbridge: update vhostbridge to use vdev_ops
And use vhostbridge for both SOS and pre-launched VM. Tracked-On: #3241 Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
9eba328bef
commit
009a16bd7d
@ -45,9 +45,8 @@
|
||||
* @pre vdev->vpci != NULL
|
||||
* @pre vdev->vpci->vm != NULL
|
||||
*/
|
||||
void init_vhostbridge(struct pci_vdev *vdev)
|
||||
static void init_vhostbridge(struct pci_vdev *vdev)
|
||||
{
|
||||
if (is_hostbridge(vdev) && is_prelaunched_vm(vdev->vpci->vm)) {
|
||||
/* PCI config space */
|
||||
pci_vdev_write_cfg_u16(vdev, PCIR_VENDOR, (uint16_t)0x8086U);
|
||||
pci_vdev_write_cfg_u16(vdev, PCIR_DEVICE, (uint16_t)0x5af0U);
|
||||
@ -89,10 +88,9 @@ void init_vhostbridge(struct pci_vdev *vdev)
|
||||
pci_vdev_write_cfg_u8(vdev, 0xf5U, (uint8_t)0xfU);
|
||||
pci_vdev_write_cfg_u8(vdev, 0xf6U, (uint8_t)0x1cU);
|
||||
pci_vdev_write_cfg_u8(vdev, 0xf7U, (uint8_t)0x1U);
|
||||
}
|
||||
}
|
||||
|
||||
void deinit_vhostbridge(__unused const struct pci_vdev *vdev)
|
||||
static void deinit_vhostbridge(__unused struct pci_vdev *vdev)
|
||||
{
|
||||
}
|
||||
|
||||
@ -102,17 +100,11 @@ void deinit_vhostbridge(__unused const struct pci_vdev *vdev)
|
||||
* @pre vdev->vpci != NULL
|
||||
* @pre vdev->vpci->vm != NULL
|
||||
*/
|
||||
int32_t vhostbridge_read_cfg(const struct pci_vdev *vdev, uint32_t offset,
|
||||
static int32_t vhostbridge_read_cfg(struct pci_vdev *vdev, uint32_t offset,
|
||||
uint32_t bytes, uint32_t *val)
|
||||
{
|
||||
int32_t ret = -ENODEV;
|
||||
|
||||
if (is_hostbridge(vdev) && is_prelaunched_vm(vdev->vpci->vm)) {
|
||||
*val = pci_vdev_read_cfg(vdev, offset, bytes);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -121,18 +113,23 @@ int32_t vhostbridge_read_cfg(const struct pci_vdev *vdev, uint32_t offset,
|
||||
* @pre vdev->vpci != NULL
|
||||
* @pre vdev->vpci->vm != NULL
|
||||
*/
|
||||
int32_t vhostbridge_write_cfg(struct pci_vdev *vdev, uint32_t offset,
|
||||
static int32_t vhostbridge_write_cfg(struct pci_vdev *vdev, uint32_t offset,
|
||||
uint32_t bytes, uint32_t val)
|
||||
{
|
||||
int32_t ret = -ENODEV;
|
||||
|
||||
if (is_hostbridge(vdev) && is_prelaunched_vm(vdev->vpci->vm)) {
|
||||
if (!is_bar_offset(PCI_BAR_COUNT, offset)) {
|
||||
pci_vdev_write_cfg(vdev, offset, bytes, val);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static 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,
|
||||
};
|
||||
|
||||
struct pci_vdev_ops *get_vhostbridge_ops(void)
|
||||
{
|
||||
return &vhostbridge_ops;
|
||||
}
|
||||
|
@ -473,7 +473,12 @@ static void init_vdev_for_pdev(struct pci_pdev *pdev, const struct acrn_vm *vm)
|
||||
vdev->bdf.value = pdev->bdf.value;
|
||||
}
|
||||
|
||||
if (is_hostbridge(vdev)) {
|
||||
vdev->vdev_ops = get_vhostbridge_ops();
|
||||
} else {
|
||||
vdev->vdev_ops = &pci_pt_dev_ops;
|
||||
}
|
||||
|
||||
vdev->vdev_ops->init_vdev(vdev);
|
||||
}
|
||||
}
|
||||
|
@ -133,11 +133,6 @@ static inline bool is_hostbridge(const struct pci_vdev *vdev)
|
||||
return (vdev->bdf.value == 0U);
|
||||
}
|
||||
|
||||
void init_vhostbridge(struct pci_vdev *vdev);
|
||||
int32_t vhostbridge_read_cfg(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val);
|
||||
int32_t vhostbridge_write_cfg(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val);
|
||||
void deinit_vhostbridge(__unused const struct pci_vdev *vdev);
|
||||
|
||||
void init_vdev_pt(struct pci_vdev *vdev);
|
||||
int32_t vdev_pt_read_cfg(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val);
|
||||
int32_t vdev_pt_write_cfg(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val);
|
||||
|
@ -116,4 +116,6 @@ 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_reset_ptdev_intr_info(const struct acrn_vm *target_vm, uint16_t vbdf, uint16_t pbdf);
|
||||
|
||||
struct pci_vdev_ops *get_vhostbridge_ops(void);
|
||||
|
||||
#endif /* VPCI_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user