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.h67
1 files changed, 63 insertions, 4 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 7bd624bfdcfd..72698d89e767 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,
@@ -649,6 +674,11 @@ int __must_check pci_reenable_device(struct pci_dev *);
649int __must_check pcim_enable_device(struct pci_dev *pdev); 674int __must_check pcim_enable_device(struct pci_dev *pdev);
650void pcim_pin_device(struct pci_dev *pdev); 675void pcim_pin_device(struct pci_dev *pdev);
651 676
677static inline int pci_is_enabled(struct pci_dev *pdev)
678{
679 return (atomic_read(&pdev->enable_cnt) > 0);
680}
681
652static inline int pci_is_managed(struct pci_dev *pdev) 682static inline int pci_is_managed(struct pci_dev *pdev)
653{ 683{
654 return pdev->is_managed; 684 return pdev->is_managed;
@@ -689,6 +719,7 @@ size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size);
689/* Power management related routines */ 719/* Power management related routines */
690int pci_save_state(struct pci_dev *dev); 720int pci_save_state(struct pci_dev *dev);
691int pci_restore_state(struct pci_dev *dev); 721int pci_restore_state(struct pci_dev *dev);
722int __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); 723int 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); 724pci_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); 725bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
@@ -701,6 +732,9 @@ int pci_back_from_sleep(struct pci_dev *dev);
701 732
702/* Functions for PCI Hotplug drivers to use */ 733/* Functions for PCI Hotplug drivers to use */
703int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap); 734int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap);
735#ifdef CONFIG_HOTPLUG
736unsigned int pci_rescan_bus(struct pci_bus *bus);
737#endif
704 738
705/* Vital product data routines */ 739/* Vital product data routines */
706ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf); 740ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf);
@@ -708,7 +742,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); 742int pci_vpd_truncate(struct pci_dev *dev, size_t size);
709 743
710/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ 744/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
711void pci_bus_assign_resources(struct pci_bus *bus); 745void pci_bus_assign_resources(const struct pci_bus *bus);
712void pci_bus_size_bridges(struct pci_bus *bus); 746void pci_bus_size_bridges(struct pci_bus *bus);
713int pci_claim_resource(struct pci_dev *, int); 747int pci_claim_resource(struct pci_dev *, int);
714void pci_assign_unassigned_resources(void); 748void pci_assign_unassigned_resources(void);
@@ -789,7 +823,7 @@ struct msix_entry {
789 823
790 824
791#ifndef CONFIG_PCI_MSI 825#ifndef CONFIG_PCI_MSI
792static inline int pci_enable_msi(struct pci_dev *dev) 826static inline int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec)
793{ 827{
794 return -1; 828 return -1;
795} 829}
@@ -799,6 +833,10 @@ static inline void pci_msi_shutdown(struct pci_dev *dev)
799static inline void pci_disable_msi(struct pci_dev *dev) 833static inline void pci_disable_msi(struct pci_dev *dev)
800{ } 834{ }
801 835
836static inline int pci_msix_table_size(struct pci_dev *dev)
837{
838 return 0;
839}
802static inline int pci_enable_msix(struct pci_dev *dev, 840static inline int pci_enable_msix(struct pci_dev *dev,
803 struct msix_entry *entries, int nvec) 841 struct msix_entry *entries, int nvec)
804{ 842{
@@ -820,9 +858,10 @@ static inline int pci_msi_enabled(void)
820 return 0; 858 return 0;
821} 859}
822#else 860#else
823extern int pci_enable_msi(struct pci_dev *dev); 861extern int pci_enable_msi_block(struct pci_dev *dev, unsigned int nvec);
824extern void pci_msi_shutdown(struct pci_dev *dev); 862extern void pci_msi_shutdown(struct pci_dev *dev);
825extern void pci_disable_msi(struct pci_dev *dev); 863extern void pci_disable_msi(struct pci_dev *dev);
864extern int pci_msix_table_size(struct pci_dev *dev);
826extern int pci_enable_msix(struct pci_dev *dev, 865extern int pci_enable_msix(struct pci_dev *dev,
827 struct msix_entry *entries, int nvec); 866 struct msix_entry *entries, int nvec);
828extern void pci_msix_shutdown(struct pci_dev *dev); 867extern void pci_msix_shutdown(struct pci_dev *dev);
@@ -841,6 +880,8 @@ static inline int pcie_aspm_enabled(void)
841extern int pcie_aspm_enabled(void); 880extern int pcie_aspm_enabled(void);
842#endif 881#endif
843 882
883#define pci_enable_msi(pdev) pci_enable_msi_block(pdev, 1)
884
844#ifdef CONFIG_HT_IRQ 885#ifdef CONFIG_HT_IRQ
845/* The functions a driver should call */ 886/* The functions a driver should call */
846int ht_create_irq(struct pci_dev *dev, int idx); 887int ht_create_irq(struct pci_dev *dev, int idx);
@@ -1194,5 +1235,23 @@ int pci_ext_cfg_avail(struct pci_dev *dev);
1194 1235
1195void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); 1236void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
1196 1237
1238#ifdef CONFIG_PCI_IOV
1239extern int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
1240extern void pci_disable_sriov(struct pci_dev *dev);
1241extern irqreturn_t pci_sriov_migration(struct pci_dev *dev);
1242#else
1243static inline int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
1244{
1245 return -ENODEV;
1246}
1247static inline void pci_disable_sriov(struct pci_dev *dev)
1248{
1249}
1250static inline irqreturn_t pci_sriov_migration(struct pci_dev *dev)
1251{
1252 return IRQ_NONE;
1253}
1254#endif
1255
1197#endif /* __KERNEL__ */ 1256#endif /* __KERNEL__ */
1198#endif /* LINUX_PCI_H */ 1257#endif /* LINUX_PCI_H */