mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-08 19:48:58 +00:00
HV: define function bdf_is_equal() to compare bdf
Use a function to compare bdf instead and some related code cleanup Tracked-On: #2534 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com> Reviewed-by: Eddie Dong <eddie.dong@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
028663537a
commit
4d11985366
@ -34,17 +34,18 @@
|
|||||||
|
|
||||||
static struct pci_vdev *partition_mode_find_vdev(struct acrn_vpci *vpci, union pci_bdf vbdf)
|
static struct pci_vdev *partition_mode_find_vdev(struct acrn_vpci *vpci, union pci_bdf vbdf)
|
||||||
{
|
{
|
||||||
struct pci_vdev *vdev = NULL;
|
struct pci_vdev *vdev, *tmp;
|
||||||
struct acrn_vm_config *vm_config = get_vm_config(vpci->vm->vm_id);
|
struct acrn_vm_config *vm_config = get_vm_config(vpci->vm->vm_id);
|
||||||
int32_t i;
|
int32_t i;
|
||||||
|
|
||||||
|
vdev = NULL;
|
||||||
for (i = 0; i < vm_config->pci_ptdev_num; i++) {
|
for (i = 0; i < vm_config->pci_ptdev_num; i++) {
|
||||||
vdev = &vpci->vm->pci_vdevs[i];
|
tmp = &vpci->vm->pci_vdevs[i];
|
||||||
|
|
||||||
if (vdev->vbdf.value == vbdf.value) {
|
if (bdf_is_equal(&(tmp->vbdf), &vbdf)) {
|
||||||
|
vdev = tmp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vdev = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return vdev;
|
return vdev;
|
||||||
|
@ -35,13 +35,16 @@ static struct pci_vdev sharing_mode_vdev_array[CONFIG_MAX_PCI_DEV_NUM];
|
|||||||
|
|
||||||
struct pci_vdev *sharing_mode_find_vdev(union pci_bdf pbdf)
|
struct pci_vdev *sharing_mode_find_vdev(union pci_bdf pbdf)
|
||||||
{
|
{
|
||||||
struct pci_vdev *vdev = NULL;
|
struct pci_vdev *vdev, *tmp;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
|
vdev = NULL;
|
||||||
/* SOS_VM uses phys BDF */
|
/* SOS_VM uses phys BDF */
|
||||||
for (i = 0U; i < num_pci_vdev; i++) {
|
for (i = 0U; i < num_pci_vdev; i++) {
|
||||||
if (sharing_mode_vdev_array[i].pdev->bdf.value == pbdf.value) {
|
tmp = &sharing_mode_vdev_array[i];
|
||||||
vdev = &sharing_mode_vdev_array[i];
|
if ((tmp->pdev != NULL) && bdf_is_equal((union pci_bdf*)&(tmp->pdev->bdf), &pbdf)) {
|
||||||
|
vdev = tmp;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,7 +407,7 @@ struct pci_pdev *find_pci_pdev(union pci_bdf pbdf)
|
|||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
for (i = 0U; i < num_pci_pdev; i++) {
|
for (i = 0U; i < num_pci_pdev; i++) {
|
||||||
if (pci_pdev_array[i].bdf.value == pbdf.value) {
|
if (bdf_is_equal(&pci_pdev_array[i].bdf, &pbdf)) {
|
||||||
pdev = &pci_pdev_array[i];
|
pdev = &pci_pdev_array[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -220,6 +220,14 @@ static inline uint8_t pci_devfn(uint16_t bdf)
|
|||||||
return (uint8_t)(bdf & 0xFFU);
|
return (uint8_t)(bdf & 0xFFU);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @pre a != NULL && b != NULL
|
||||||
|
*/
|
||||||
|
static inline bool bdf_is_equal(const union pci_bdf *a, const union pci_bdf *b)
|
||||||
|
{
|
||||||
|
return (a->value == b->value);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t pci_pdev_read_cfg(union pci_bdf bdf, uint32_t offset, uint32_t bytes);
|
uint32_t pci_pdev_read_cfg(union pci_bdf bdf, uint32_t offset, uint32_t bytes);
|
||||||
void pci_pdev_write_cfg(union pci_bdf bdf, uint32_t offset, uint32_t bytes, uint32_t val);
|
void pci_pdev_write_cfg(union pci_bdf bdf, uint32_t offset, uint32_t bytes, uint32_t val);
|
||||||
void enable_disable_pci_intx(union pci_bdf bdf, bool enable);
|
void enable_disable_pci_intx(union pci_bdf bdf, bool enable);
|
||||||
|
Loading…
Reference in New Issue
Block a user