hv: refine init_pdev function

Due to SRIOV VF physical device needs to be initialized when
VF_ENABLE is set and a SRIOV VF physical device initialization
is same with standard PCIe physical device, so expose the
init_pdev for SRIOV VF physical device initialization.

Tracked-On: #4433

Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Yuan Liu 2020-02-27 19:06:31 +08:00 committed by wenlingz
parent abbdef4f5d
commit 87e7d79112
2 changed files with 16 additions and 4 deletions

View File

@ -49,8 +49,6 @@ static uint32_t num_pci_pdev;
static struct pci_pdev pci_pdev_array[CONFIG_MAX_PCI_DEV_NUM];
static uint64_t pci_mmcfg_base = DEFAULT_PCI_MMCFG_BASE;
static void init_pdev(uint16_t pbdf, uint32_t drhd_index);
#ifdef CONFIG_ACPI_PARSE_ENABLED
void set_mmcfg_base(uint64_t mmcfg_base)
{
@ -607,11 +605,22 @@ static void pci_read_cap(struct pci_pdev *pdev)
}
}
static void init_pdev(uint16_t pbdf, uint32_t drhd_index)
/*
* @brief Initialize a pdev data structure.
*
* Initialize a pdev data structure with a physical device BDF(pbdf) and DRHD index(drhd_index).
* The caller of the function init_pdev should guarantee execution atomically.
*
* @param pbdf Physical device BDF
* @param drhd_index DRHD index
*
* @return If there's a successfully initialized pdev return it, otherwise return NULL;
*/
struct pci_pdev *init_pdev(uint16_t pbdf, uint32_t drhd_index)
{
uint8_t hdr_type;
union pci_bdf bdf;
struct pci_pdev *pdev;
struct pci_pdev *pdev = NULL;
if (num_pci_pdev < CONFIG_MAX_PCI_DEV_NUM) {
bdf.value = pbdf;
@ -640,4 +649,6 @@ static void init_pdev(uint16_t pbdf, uint32_t drhd_index)
} else {
pr_err("%s, failed to alloc pci_pdev!\n", __func__);
}
return pdev;
}

View File

@ -301,6 +301,7 @@ void set_mmcfg_base(uint64_t mmcfg_base);
#endif
uint64_t get_mmcfg_base(void);
struct pci_pdev *init_pdev(uint16_t pbdf, uint32_t drhd_index);
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 enable_disable_pci_intx(union pci_bdf bdf, bool enable);