pci.h 5.9 KB

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