diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index ce6a366..f15aa2a 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -722,6 +722,18 @@ int pci_num_vf(struct pci_dev *dev) } EXPORT_SYMBOL_GPL(pci_num_vf); +/** + * pci_get_vf_dev - return the PCI device of a specific VF + * @dev: the PCI device + */ +struct pci_dev *pci_get_vf_dev(struct pci_dev *dev, int id) +{ + return pci_get_bus_and_slot( + virtfn_bus(dev, id), + virtfn_devfn(dev, id)); +} +EXPORT_SYMBOL_GPL(pci_get_vf_dev); + static int ats_alloc_one(struct pci_dev *dev, int ps) { int pos; diff --git a/include/linux/pci.h b/include/linux/pci.h index a327322..fb6010b 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1374,6 +1374,7 @@ extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); extern void pci_disable_sriov(struct pci_dev *dev); extern irqreturn_t pci_sriov_migration(struct pci_dev *dev); extern int pci_num_vf(struct pci_dev *dev); +extern struct pci_dev *pci_get_vf_dev(struct pci_dev *dev, int id); #else static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) { @@ -1390,6 +1391,10 @@ static inline int pci_num_vf(struct pci_dev *dev) { return 0; } +static inline struct pci_dev *pci_get_vf_dev(struct pci_dev *dev, int id) +{ + return NULL; +} #endif #if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE)