HV: add generic vdev functions to vdev.c
Add vdev functions so they can be reused by both partition mode and sharing mode code: pci_find_vdev_by_vbdf: search for vdev by virtual bdf pci_find_vdev_by_pbdf: search for vdev by physical bdf 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:
parent
731b0444b1
commit
be3fbaa461
|
@ -81,4 +81,8 @@ void populate_msi_struct(struct pci_vdev *vdev);
|
||||||
|
|
||||||
void add_vdev_handler(struct pci_vdev *vdev, const struct pci_vdev_ops *ops);
|
void add_vdev_handler(struct pci_vdev *vdev, const struct pci_vdev_ops *ops);
|
||||||
|
|
||||||
|
struct pci_vdev *pci_find_vdev_by_vbdf(const struct acrn_vpci *vpci, union pci_bdf vbdf);
|
||||||
|
|
||||||
|
struct pci_vdev *pci_find_vdev_by_pbdf(const struct acrn_vpci *vpci, union pci_bdf pbdf);
|
||||||
|
|
||||||
#endif /* PCI_PRIV_H_ */
|
#endif /* PCI_PRIV_H_ */
|
||||||
|
|
|
@ -63,3 +63,45 @@ void pci_vdev_write_cfg(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pre tmp != NULL
|
||||||
|
*/
|
||||||
|
struct pci_vdev *pci_find_vdev_by_vbdf(const struct acrn_vpci *vpci, union pci_bdf vbdf)
|
||||||
|
{
|
||||||
|
struct pci_vdev *vdev, *tmp;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
vdev = NULL;
|
||||||
|
for (i = 0U; i < vpci->pci_vdev_cnt; i++) {
|
||||||
|
tmp = (struct pci_vdev *)&(vpci->pci_vdevs[i]);
|
||||||
|
|
||||||
|
if (bdf_is_equal(&(tmp->vbdf), &vbdf)) {
|
||||||
|
vdev = tmp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return vdev;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @pre tmp != NULL
|
||||||
|
*/
|
||||||
|
struct pci_vdev *pci_find_vdev_by_pbdf(const struct acrn_vpci *vpci, union pci_bdf pbdf)
|
||||||
|
{
|
||||||
|
struct pci_vdev *vdev, *tmp;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
vdev = NULL;
|
||||||
|
for (i = 0U; i < vpci->pci_vdev_cnt; i++) {
|
||||||
|
tmp = (struct pci_vdev *)&(vpci->pci_vdevs[i]);
|
||||||
|
|
||||||
|
if ((tmp->pdev != NULL) && bdf_is_equal((union pci_bdf *)&(tmp->pdev->bdf), &pbdf)) {
|
||||||
|
vdev = tmp;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return vdev;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue