aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pci.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/pci.h')
-rw-r--r--include/linux/pci.h62
1 files changed, 58 insertions, 4 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 7bd624bfdcfd..a7fe4bbd7ff1 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -52,6 +52,7 @@
52#include <asm/atomic.h> 52#include <asm/atomic.h>
53#include <linux/device.h> 53#include <linux/device.h>
54#include <linux/io.h> 54#include <linux/io.h>
55#include <linux/irqreturn.h>
55 56
56/* Include the ID list */ 57/* Include the ID list */
57#include <linux/pci_ids.h> 58#include <linux/pci_ids.h>
@@ -93,6 +94,12 @@ enum {
93 /* #6: expansion ROM resource */ 94 /* #6: expansion ROM resource */
94 PCI_ROM_RESOURCE, 95 PCI_ROM_RESOURCE,
95 96
97 /* device specific resources */
98#ifdef CONFIG_PCI_IOV
99 PCI_IOV_RESOURCES,
100 PCI_IOV_RESOURCE_END = PCI_IOV_RESOURCES + PCI_SRIOV_NUM_BARS - 1,
101#endif
102
96 /* resources assigned to buses behind the bridge */ 103 /* resources assigned to buses behind the bridge */
97#define PCI_BRIDGE_RESOURCE_NUM 4 104#define PCI_BRIDGE_RESOURCE_NUM 4
98 105
@@ -180,6 +187,7 @@ struct pci_cap_saved_state {
180 187
181struct pcie_link_state; 188struct pcie_link_state;
182struct pci_vpd; 189struct pci_vpd;
190struct pci_sriov;
183 191
184/* 192/*
185 * The pci_dev structure is used to describe PCI devices. 193 * The pci_dev structure is used to describe PCI devices.
@@ -257,6 +265,8 @@ struct pci_dev {
257 unsigned int is_managed:1; 265 unsigned int is_managed:1;
258 unsigned int is_pcie:1; 266 unsigned int is_pcie:1;
259 unsigned int state_saved:1; 267 unsigned int state_saved:1;
268 unsigned int is_physfn:1;
269 unsigned int is_virtfn:1;
260 pci_dev_flags_t dev_flags; 270 pci_dev_flags_t dev_flags;
261 atomic_t enable_cnt; /* pci_enable_device has been called */ 271 atomic_t enable_cnt; /* pci_enable_device has been called */
262 272
@@ -270,6 +280,12 @@ struct pci_dev {
270 struct list_head msi_list; 280 struct list_head msi_list;
271#endif 281#endif
272 struct pci_vpd *vpd; 282 struct pci_vpd *vpd;
283#ifdef CONFIG_PCI_IOV
284 union {
285 struct pci_sriov *sriov; /* SR-IOV capability related */
286 struct pci_dev *physfn; /* the PF this VF is associated with */
287 };
288#endif
273}; 289};
274 290
275extern struct pci_dev *alloc_pci_dev(void); 291extern struct pci_dev *alloc_pci_dev(void);
@@ -341,6 +357,15 @@ struct pci_bus {
341#define pci_bus_b(n) list_entry(n, struct pci_bus, node) 357#define pci_bus_b(n) list_entry(n, struct pci_bus, node)
342#define to_pci_bus(n) container_of(n, struct pci_bus, dev) 358#define to_pci_bus(n) container_of(n, struct pci_bus, dev)
343 359
360/*
361 * Returns true if the pci bus is root (behind host-pci bridge),
362 * false otherwise
363 */
364static inline bool pci_is_root_bus(struct pci_bus *pbus)
365{
366 return !(pbus->parent);
367}
368
344#ifdef CONFIG_PCI_MSI 369#ifdef CONFIG_PCI_MSI
345static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) 370static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev)
346{ 371{
@@ -528,7 +553,7 @@ void pcibios_update_irq(struct pci_dev *, int irq);
528/* Generic PCI functions used internally */ 553/* Generic PCI functions used internally */
529 554
530extern struct pci_bus *pci_find_bus(int domain, int busnr); 555extern struct pci_bus *pci_find_bus(int domain, int busnr);
531void pci_bus_add_devices(struct pci_bus *bus); 556void pci_bus_add_devices(const struct pci_bus *bus);
532struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, 557struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
533 struct pci_ops *ops, void *sysdata); 558 struct pci_ops *ops, void *sysdata);
534static inline struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops, 559static inline struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops,
@@ -689,6 +714,7 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size);
689/* Power management related routines */ 714/* Power management related routines */
690int pci_save_state(struct pci_dev *dev); 715int pci_save_state(struct pci_dev *dev);
691int pci_restore_state(struct pci_dev *dev); 716int pci_restore_state(struct pci_dev *dev);
717int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state);
692int pci_set_power_state(struct pci_dev *dev, pci_power_t state); 718int pci_set_power_state(struct pci_dev *dev, pci_power_t state);
693pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); 719pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state);
694bool pci_pme_capable(struct pci_dev *dev, pci_power_t state); 720bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
@@ -701,6 +727,9 @@ int pci_back_from_sleep(struct pci_dev *dev);
701 727
702/* Functions for PCI Hotplug drivers to use */ 728/* Functions for PCI Hotplug drivers to use */
703int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); 729int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap);
730#ifdef CONFIG_HOTPLUG
731unsigned int pci_rescan_bus(struct pci_bus *bus);
732#endif
704 733
705/* Vital product data routines */ 734/* Vital product data routines */
706ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf); 735ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf);
@@ -708,7 +737,7 @@ ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void
708int pci_vpd_truncate(struct pci_dev *dev, size_t size); 737int pci_vpd_truncate(struct pci_dev *dev, size_t size);
709 738
710/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ 739/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
711void pci_bus_assign_resources(struct pci_bus *bus); 740void pci_bus_assign_resources(const struct pci_bus *bus);
712void pci_bus_size_bridges(struct pci_bus *bus); 741void pci_bus_size_bridges(struct pci_bus *bus);
713int pci_claim_resource(struct pci_dev *, int); 742int pci_claim_resource(struct pci_dev *, int);
714void pci_assign_unassigned_resources(void); 743void pci_assign_unassigned_resources(void);
@@ -789,7 +818,7 @@ struct msix_entry {
789 818
790 819
791#ifndef CONFIG_PCI_MSI 820#ifndef CONFIG_PCI_MSI
792static inline int pci_enable_msi(struct pci_dev *dev) 821static inline int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec)
793{ 822{
794 return -1; 823 return -1;
795} 824}
@@ -799,6 +828,10 @@ static inline void pci_msi_shutdown(struct pci_dev *dev)
799static inline void pci_disable_msi(struct pci_dev *dev) 828static inline void pci_disable_msi(struct pci_dev *dev)
800{ } 829{ }
801 830
831static inline int pci_msix_table_size(struct pci_dev *dev)
832{
833 return 0;
834}
802static inline int pci_enable_msix(struct pci_dev *dev, 835static inline int pci_enable_msix(struct pci_dev *dev,
803 struct msix_entry *entries, int nvec) 836 struct msix_entry *entries, int nvec)
804{ 837{
@@ -820,9 +853,10 @@ static inline int pci_msi_enabled(void)
820 return 0; 853 return 0;
821} 854}
822#else 855#else
823extern int pci_enable_msi(struct pci_dev *dev); 856extern int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec);
824extern void pci_msi_shutdown(struct pci_dev *dev); 857extern void pci_msi_shutdown(struct pci_dev *dev);
825extern void pci_disable_msi(struct pci_dev *dev); 858extern void pci_disable_msi(struct pci_dev *dev);
859extern int pci_msix_table_size(struct pci_dev *dev);
826extern int pci_enable_msix(struct pci_dev *dev, 860extern int pci_enable_msix(struct pci_dev *dev,
827 struct msix_entry *entries, int nvec); 861 struct msix_entry *entries, int nvec);
828extern void pci_msix_shutdown(struct pci_dev *dev); 862extern void pci_msix_shutdown(struct pci_dev *dev);
@@ -841,6 +875,8 @@ static inline int pcie_aspm_enabled(void)
841extern int pcie_aspm_enabled(void); 875extern int pcie_aspm_enabled(void);
842#endif 876#endif
843 877
878#define pci_enable_msi(pdev) pci_enable_msi_block(pdev, 1)
879
844#ifdef CONFIG_HT_IRQ 880#ifdef CONFIG_HT_IRQ
845/* The functions a driver should call */ 881/* The functions a driver should call */
846int ht_create_irq(struct pci_dev *dev, int idx); 882int ht_create_irq(struct pci_dev *dev, int idx);
@@ -1194,5 +1230,23 @@ int pci_ext_cfg_avail(struct pci_dev *dev);
1194 1230
1195void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); 1231void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
1196 1232
1233#ifdef CONFIG_PCI_IOV
1234extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
1235extern void pci_disable_sriov(struct pci_dev *dev);
1236extern irqreturn_t pci_sriov_migration(struct pci_dev *dev);
1237#else
1238static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
1239{
1240 return -ENODEV;
1241}
1242static inline void pci_disable_sriov(struct pci_dev *dev)
1243{
1244}
1245static inline irqreturn_t pci_sriov_migration(struct pci_dev *dev)
1246{
1247 return IRQ_NONE;
1248}
1249#endif
1250
1197#endif /* __KERNEL__ */ 1251#endif /* __KERNEL__ */
1198#endif /* LINUX_PCI_H */ 1252#endif /* LINUX_PCI_H */