HV: some minor code cleanup for partition mode code
Define is_hostbridge function Rename pdev_ref to pdev 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
82789f44a9
commit
caa291c094
|
@ -33,6 +33,10 @@
|
||||||
#include <logmsg.h>
|
#include <logmsg.h>
|
||||||
#include "pci_priv.h"
|
#include "pci_priv.h"
|
||||||
|
|
||||||
|
static inline bool is_hostbridge(const struct pci_vdev *vdev)
|
||||||
|
{
|
||||||
|
return (vdev->vbdf.value == 0U);
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool is_valid_bar_type(const struct pci_bar *bar)
|
static inline bool is_valid_bar_type(const struct pci_bar *bar)
|
||||||
{
|
{
|
||||||
|
@ -52,13 +56,13 @@ static inline bool is_valid_bar(const struct pci_bar *bar)
|
||||||
|
|
||||||
static void partition_mode_pdev_init(struct pci_vdev *vdev, union pci_bdf pbdf)
|
static void partition_mode_pdev_init(struct pci_vdev *vdev, union pci_bdf pbdf)
|
||||||
{
|
{
|
||||||
struct pci_pdev *pdev_ref;
|
struct pci_pdev *pdev;
|
||||||
uint32_t idx;
|
uint32_t idx;
|
||||||
struct pci_bar *pbar, *vbar;
|
struct pci_bar *pbar, *vbar;
|
||||||
|
|
||||||
pdev_ref = find_pci_pdev(pbdf);
|
pdev = find_pci_pdev(pbdf);
|
||||||
if (pdev_ref != NULL) {
|
if (pdev != NULL) {
|
||||||
vdev->pdev = pdev_ref;
|
vdev->pdev = pdev;
|
||||||
|
|
||||||
/* Sanity checking for vbar */
|
/* Sanity checking for vbar */
|
||||||
for (idx = 0U; idx < (uint32_t)PCI_BAR_COUNT; idx++) {
|
for (idx = 0U; idx < (uint32_t)PCI_BAR_COUNT; idx++) {
|
||||||
|
@ -100,11 +104,11 @@ static int32_t partition_mode_vpci_init(const struct acrn_vm *vm)
|
||||||
ptdev_config = &vm_config->pci_ptdevs[i];
|
ptdev_config = &vm_config->pci_ptdevs[i];
|
||||||
vdev->vbdf.value = ptdev_config->vbdf.value;
|
vdev->vbdf.value = ptdev_config->vbdf.value;
|
||||||
|
|
||||||
if (vdev->vbdf.value != 0U) {
|
if (is_hostbridge(vdev)) {
|
||||||
|
vdev->ops = &pci_ops_vdev_hostbridge;
|
||||||
|
} else {
|
||||||
partition_mode_pdev_init(vdev, ptdev_config->pbdf);
|
partition_mode_pdev_init(vdev, ptdev_config->pbdf);
|
||||||
vdev->ops = &pci_ops_vdev_pt;
|
vdev->ops = &pci_ops_vdev_pt;
|
||||||
} else {
|
|
||||||
vdev->ops = &pci_ops_vdev_hostbridge;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vdev->ops->init != NULL) {
|
if (vdev->ops->init != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue