diff options
author | Williams, Mitch A <mitch.a.williams@intel.com> | 2010-02-09 20:43:04 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-12 19:56:07 -0500 |
commit | fb8a0d9d1bfd1e4355f307e86a6da7209eefd5f3 (patch) | |
tree | 99f23a4bc7c51343619f63970e5d017d75b5a66f | |
parent | 81d54ec8479a2c695760da81f05b5a9fb2dbe40a (diff) |
pci: Add SR-IOV convenience functions and macros
Add and export pci_num_vf to allow other subsystems to determine how many
virtual function devices are associated with an SR-IOV physical function
device.
Add macros dev_is_pci, dev_is_ps, and dev_num_vf to make it easier for
non-PCI specific code to determine SR-IOV capabilities.
Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/pci/iov.c | 15 | ||||
-rw-r--r-- | include/linux/pci.h | 11 |
2 files changed, 26 insertions, 0 deletions
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index b2a448e19fe6..3e5ab2bf6a5c 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c | |||
@@ -706,6 +706,21 @@ irqreturn_t pci_sriov_migration(struct pci_dev *dev) | |||
706 | } | 706 | } |
707 | EXPORT_SYMBOL_GPL(pci_sriov_migration); | 707 | EXPORT_SYMBOL_GPL(pci_sriov_migration); |
708 | 708 | ||
709 | /** | ||
710 | * pci_num_vf - return number of VFs associated with a PF device_release_driver | ||
711 | * @dev: the PCI device | ||
712 | * | ||
713 | * Returns number of VFs, or 0 if SR-IOV is not enabled. | ||
714 | */ | ||
715 | int pci_num_vf(struct pci_dev *dev) | ||
716 | { | ||
717 | if (!dev || !dev->is_physfn) | ||
718 | return 0; | ||
719 | else | ||
720 | return dev->sriov->nr_virtfn; | ||
721 | } | ||
722 | EXPORT_SYMBOL_GPL(pci_num_vf); | ||
723 | |||
709 | static int ats_alloc_one(struct pci_dev *dev, int ps) | 724 | static int ats_alloc_one(struct pci_dev *dev, int ps) |
710 | { | 725 | { |
711 | int pos; | 726 | int pos; |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 174e5392e51e..59a98e2ee2c6 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -612,6 +612,9 @@ extern void pci_remove_bus_device(struct pci_dev *dev); | |||
612 | extern void pci_stop_bus_device(struct pci_dev *dev); | 612 | extern void pci_stop_bus_device(struct pci_dev *dev); |
613 | void pci_setup_cardbus(struct pci_bus *bus); | 613 | void pci_setup_cardbus(struct pci_bus *bus); |
614 | extern void pci_sort_breadthfirst(void); | 614 | extern void pci_sort_breadthfirst(void); |
615 | #define dev_is_pci(d) ((d)->bus == &pci_bus_type) | ||
616 | #define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false)) | ||
617 | #define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0)) | ||
615 | 618 | ||
616 | /* Generic PCI functions exported to card drivers */ | 619 | /* Generic PCI functions exported to card drivers */ |
617 | 620 | ||
@@ -1129,6 +1132,9 @@ static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus, | |||
1129 | unsigned int devfn) | 1132 | unsigned int devfn) |
1130 | { return NULL; } | 1133 | { return NULL; } |
1131 | 1134 | ||
1135 | #define dev_is_pci(d) (false) | ||
1136 | #define dev_is_pf(d) (false) | ||
1137 | #define dev_num_vf(d) (0) | ||
1132 | #endif /* CONFIG_PCI */ | 1138 | #endif /* CONFIG_PCI */ |
1133 | 1139 | ||
1134 | /* Include architecture-dependent settings and functions */ | 1140 | /* Include architecture-dependent settings and functions */ |
@@ -1286,6 +1292,7 @@ void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); | |||
1286 | extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); | 1292 | extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); |
1287 | extern void pci_disable_sriov(struct pci_dev *dev); | 1293 | extern void pci_disable_sriov(struct pci_dev *dev); |
1288 | extern irqreturn_t pci_sriov_migration(struct pci_dev *dev); | 1294 | extern irqreturn_t pci_sriov_migration(struct pci_dev *dev); |
1295 | extern int pci_num_vf(struct pci_dev *dev); | ||
1289 | #else | 1296 | #else |
1290 | static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) | 1297 | static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn) |
1291 | { | 1298 | { |
@@ -1298,6 +1305,10 @@ static inline irqreturn_t pci_sriov_migration(struct pci_dev *dev) | |||
1298 | { | 1305 | { |
1299 | return IRQ_NONE; | 1306 | return IRQ_NONE; |
1300 | } | 1307 | } |
1308 | static inline int pci_num_vf(struct pci_dev *dev) | ||
1309 | { | ||
1310 | return 0; | ||
1311 | } | ||
1301 | #endif | 1312 | #endif |
1302 | 1313 | ||
1303 | #if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE) | 1314 | #if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE) |