pci.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. #ifndef __ASM_S390_PCI_H
  2. #define __ASM_S390_PCI_H
  3. /* must be set before including asm-generic/pci.h */
  4. #define PCI_DMA_BUS_IS_PHYS (0)
  5. /* must be set before including pci_clp.h */
  6. #define PCI_BAR_COUNT 6
  7. #include <linux/pci.h>
  8. #include <linux/mutex.h>
  9. #include <asm-generic/pci.h>
  10. #include <asm-generic/pci-dma-compat.h>
  11. #include <asm/pci_clp.h>
  12. #include <asm/pci_debug.h>
  13. #define PCIBIOS_MIN_IO 0x1000
  14. #define PCIBIOS_MIN_MEM 0x10000000
  15. #define pcibios_assign_all_busses() (0)
  16. void __iomem *pci_iomap(struct pci_dev *, int, unsigned long);
  17. void pci_iounmap(struct pci_dev *, void __iomem *);
  18. int pci_domain_nr(struct pci_bus *);
  19. int pci_proc_domain(struct pci_bus *);
  20. #define ZPCI_BUS_NR 0 /* default bus number */
  21. #define ZPCI_DEVFN 0 /* default device number */
  22. /* PCI Function Controls */
  23. #define ZPCI_FC_FN_ENABLED 0x80
  24. #define ZPCI_FC_ERROR 0x40
  25. #define ZPCI_FC_BLOCKED 0x20
  26. #define ZPCI_FC_DMA_ENABLED 0x10
  27. struct zpci_fmb {
  28. u32 format : 8;
  29. u32 dma_valid : 1;
  30. u32 : 23;
  31. u32 samples;
  32. u64 last_update;
  33. /* hardware counters */
  34. u64 ld_ops;
  35. u64 st_ops;
  36. u64 stb_ops;
  37. u64 rpcit_ops;
  38. u64 dma_rbytes;
  39. u64 dma_wbytes;
  40. } __packed __aligned(16);
  41. enum zpci_state {
  42. ZPCI_FN_STATE_RESERVED,
  43. ZPCI_FN_STATE_STANDBY,
  44. ZPCI_FN_STATE_CONFIGURED,
  45. ZPCI_FN_STATE_ONLINE,
  46. NR_ZPCI_FN_STATES,
  47. };
  48. struct zpci_bar_struct {
  49. struct resource *res; /* bus resource */
  50. u32 val; /* bar start & 3 flag bits */
  51. u16 map_idx; /* index into bar mapping array */
  52. u8 size; /* order 2 exponent */
  53. };
  54. struct s390_domain;
  55. /* Private data per function */
  56. struct zpci_dev {
  57. struct pci_dev *pdev;
  58. struct pci_bus *bus;
  59. struct list_head entry; /* list of all zpci_devices, needed for hotplug, etc. */
  60. enum zpci_state state;
  61. u32 fid; /* function ID, used by sclp */
  62. u32 fh; /* function handle, used by insn's */
  63. u16 vfn; /* virtual function number */
  64. u16 pchid; /* physical channel ID */
  65. u8 pfgid; /* function group ID */
  66. u8 pft; /* pci function type */
  67. u16 domain;
  68. struct mutex lock;
  69. u8 pfip[CLP_PFIP_NR_SEGMENTS]; /* pci function internal path */
  70. u32 uid; /* user defined id */
  71. u8 util_str[CLP_UTIL_STR_LEN]; /* utility string */
  72. /* IRQ stuff */
  73. u64 msi_addr; /* MSI address */
  74. unsigned int max_msi; /* maximum number of MSI's */
  75. struct airq_iv *aibv; /* adapter interrupt bit vector */
  76. unsigned int aisb; /* number of the summary bit */
  77. /* DMA stuff */
  78. unsigned long *dma_table;
  79. spinlock_t dma_table_lock;
  80. int tlb_refresh;
  81. spinlock_t iommu_bitmap_lock;
  82. unsigned long *iommu_bitmap;
  83. unsigned long iommu_size;
  84. unsigned long iommu_pages;
  85. unsigned int next_bit;
  86. char res_name[16];
  87. struct zpci_bar_struct bars[PCI_BAR_COUNT];
  88. u64 start_dma; /* Start of available DMA addresses */
  89. u64 end_dma; /* End of available DMA addresses */
  90. u64 dma_mask; /* DMA address space mask */
  91. /* Function measurement block */
  92. struct zpci_fmb *fmb;
  93. u16 fmb_update; /* update interval */
  94. /* software counters */
  95. atomic64_t allocated_pages;
  96. atomic64_t mapped_pages;
  97. atomic64_t unmapped_pages;
  98. enum pci_bus_speed max_bus_speed;
  99. struct dentry *debugfs_dev;
  100. struct dentry *debugfs_perf;
  101. struct s390_domain *s390_domain; /* s390 IOMMU domain data */
  102. };
  103. static inline bool zdev_enabled(struct zpci_dev *zdev)
  104. {
  105. return (zdev->fh & (1UL << 31)) ? true : false;
  106. }
  107. extern const struct attribute_group *zpci_attr_groups[];
  108. /* -----------------------------------------------------------------------------
  109. Prototypes
  110. ----------------------------------------------------------------------------- */
  111. /* Base stuff */
  112. int zpci_create_device(struct zpci_dev *);
  113. int zpci_enable_device(struct zpci_dev *);
  114. int zpci_disable_device(struct zpci_dev *);
  115. void zpci_stop_device(struct zpci_dev *);
  116. int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64);
  117. int zpci_unregister_ioat(struct zpci_dev *, u8);
  118. /* CLP */
  119. int clp_scan_pci_devices(void);
  120. int clp_rescan_pci_devices(void);
  121. int clp_rescan_pci_devices_simple(void);
  122. int clp_add_pci_device(u32, u32, int);
  123. int clp_enable_fh(struct zpci_dev *, u8);
  124. int clp_disable_fh(struct zpci_dev *);
  125. #ifdef CONFIG_PCI
  126. /* Error handling and recovery */
  127. void zpci_event_error(void *);
  128. void zpci_event_availability(void *);
  129. void zpci_rescan(void);
  130. bool zpci_is_enabled(void);
  131. #else /* CONFIG_PCI */
  132. static inline void zpci_event_error(void *e) {}
  133. static inline void zpci_event_availability(void *e) {}
  134. static inline void zpci_rescan(void) {}
  135. #endif /* CONFIG_PCI */
  136. #ifdef CONFIG_HOTPLUG_PCI_S390
  137. int zpci_init_slot(struct zpci_dev *);
  138. void zpci_exit_slot(struct zpci_dev *);
  139. #else /* CONFIG_HOTPLUG_PCI_S390 */
  140. static inline int zpci_init_slot(struct zpci_dev *zdev)
  141. {
  142. return 0;
  143. }
  144. static inline void zpci_exit_slot(struct zpci_dev *zdev) {}
  145. #endif /* CONFIG_HOTPLUG_PCI_S390 */
  146. /* Helpers */
  147. static inline struct zpci_dev *to_zpci(struct pci_dev *pdev)
  148. {
  149. return pdev->sysdata;
  150. }
  151. struct zpci_dev *get_zdev_by_fid(u32);
  152. /* DMA */
  153. int zpci_dma_init(void);
  154. void zpci_dma_exit(void);
  155. /* FMB */
  156. int zpci_fmb_enable_device(struct zpci_dev *);
  157. int zpci_fmb_disable_device(struct zpci_dev *);
  158. /* Debug */
  159. int zpci_debug_init(void);
  160. void zpci_debug_exit(void);
  161. void zpci_debug_init_device(struct zpci_dev *);
  162. void zpci_debug_exit_device(struct zpci_dev *);
  163. void zpci_debug_info(struct zpci_dev *, struct seq_file *);
  164. #ifdef CONFIG_NUMA
  165. /* Returns the node based on PCI bus */
  166. static inline int __pcibus_to_node(const struct pci_bus *bus)
  167. {
  168. return NUMA_NO_NODE;
  169. }
  170. static inline const struct cpumask *
  171. cpumask_of_pcibus(const struct pci_bus *bus)
  172. {
  173. return cpu_online_mask;
  174. }
  175. #endif /* CONFIG_NUMA */
  176. #endif