pci.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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 <linux/iommu.h>
  10. #include <asm-generic/pci.h>
  11. #include <asm/pci_clp.h>
  12. #include <asm/pci_debug.h>
  13. #include <asm/sclp.h>
  14. #define PCIBIOS_MIN_IO 0x1000
  15. #define PCIBIOS_MIN_MEM 0x10000000
  16. #define pcibios_assign_all_busses() (0)
  17. void __iomem *pci_iomap(struct pci_dev *, int, unsigned long);
  18. void pci_iounmap(struct pci_dev *, void __iomem *);
  19. int pci_domain_nr(struct pci_bus *);
  20. int pci_proc_domain(struct pci_bus *);
  21. #define ZPCI_BUS_NR 0 /* default bus number */
  22. #define ZPCI_DEVFN 0 /* default device number */
  23. /* PCI Function Controls */
  24. #define ZPCI_FC_FN_ENABLED 0x80
  25. #define ZPCI_FC_ERROR 0x40
  26. #define ZPCI_FC_BLOCKED 0x20
  27. #define ZPCI_FC_DMA_ENABLED 0x10
  28. #define ZPCI_FMB_DMA_COUNTER_VALID (1 << 23)
  29. struct zpci_fmb_fmt0 {
  30. u64 dma_rbytes;
  31. u64 dma_wbytes;
  32. };
  33. struct zpci_fmb_fmt1 {
  34. u64 rx_bytes;
  35. u64 rx_packets;
  36. u64 tx_bytes;
  37. u64 tx_packets;
  38. };
  39. struct zpci_fmb_fmt2 {
  40. u64 consumed_work_units;
  41. u64 max_work_units;
  42. };
  43. struct zpci_fmb {
  44. u32 format : 8;
  45. u32 fmt_ind : 24;
  46. u32 samples;
  47. u64 last_update;
  48. /* common counters */
  49. u64 ld_ops;
  50. u64 st_ops;
  51. u64 stb_ops;
  52. u64 rpcit_ops;
  53. /* format specific counters */
  54. union {
  55. struct zpci_fmb_fmt0 fmt0;
  56. struct zpci_fmb_fmt1 fmt1;
  57. struct zpci_fmb_fmt2 fmt2;
  58. };
  59. } __packed __aligned(128);
  60. enum zpci_state {
  61. ZPCI_FN_STATE_STANDBY = 0,
  62. ZPCI_FN_STATE_CONFIGURED = 1,
  63. ZPCI_FN_STATE_RESERVED = 2,
  64. ZPCI_FN_STATE_ONLINE = 3,
  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 long 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. struct iommu_device iommu_dev; /* IOMMU core handle */
  105. char res_name[16];
  106. struct zpci_bar_struct bars[PCI_BAR_COUNT];
  107. u64 start_dma; /* Start of available DMA addresses */
  108. u64 end_dma; /* End of available DMA addresses */
  109. u64 dma_mask; /* DMA address space mask */
  110. /* Function measurement block */
  111. struct zpci_fmb *fmb;
  112. u16 fmb_update; /* update interval */
  113. u16 fmb_length;
  114. /* software counters */
  115. atomic64_t allocated_pages;
  116. atomic64_t mapped_pages;
  117. atomic64_t unmapped_pages;
  118. enum pci_bus_speed max_bus_speed;
  119. struct dentry *debugfs_dev;
  120. struct dentry *debugfs_perf;
  121. struct s390_domain *s390_domain; /* s390 IOMMU domain data */
  122. };
  123. static inline bool zdev_enabled(struct zpci_dev *zdev)
  124. {
  125. return (zdev->fh & (1UL << 31)) ? true : false;
  126. }
  127. extern const struct attribute_group *zpci_attr_groups[];
  128. /* -----------------------------------------------------------------------------
  129. Prototypes
  130. ----------------------------------------------------------------------------- */
  131. /* Base stuff */
  132. int zpci_create_device(struct zpci_dev *);
  133. void zpci_remove_device(struct zpci_dev *zdev);
  134. int zpci_enable_device(struct zpci_dev *);
  135. int zpci_disable_device(struct zpci_dev *);
  136. int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64);
  137. int zpci_unregister_ioat(struct zpci_dev *, u8);
  138. void zpci_remove_reserved_devices(void);
  139. /* CLP */
  140. int clp_scan_pci_devices(void);
  141. int clp_rescan_pci_devices(void);
  142. int clp_rescan_pci_devices_simple(void);
  143. int clp_add_pci_device(u32, u32, int);
  144. int clp_enable_fh(struct zpci_dev *, u8);
  145. int clp_disable_fh(struct zpci_dev *);
  146. int clp_get_state(u32 fid, enum zpci_state *state);
  147. /* IOMMU Interface */
  148. int zpci_init_iommu(struct zpci_dev *zdev);
  149. void zpci_destroy_iommu(struct zpci_dev *zdev);
  150. #ifdef CONFIG_PCI
  151. /* Error handling and recovery */
  152. void zpci_event_error(void *);
  153. void zpci_event_availability(void *);
  154. void zpci_rescan(void);
  155. bool zpci_is_enabled(void);
  156. #else /* CONFIG_PCI */
  157. static inline void zpci_event_error(void *e) {}
  158. static inline void zpci_event_availability(void *e) {}
  159. static inline void zpci_rescan(void) {}
  160. #endif /* CONFIG_PCI */
  161. #ifdef CONFIG_HOTPLUG_PCI_S390
  162. int zpci_init_slot(struct zpci_dev *);
  163. void zpci_exit_slot(struct zpci_dev *);
  164. #else /* CONFIG_HOTPLUG_PCI_S390 */
  165. static inline int zpci_init_slot(struct zpci_dev *zdev)
  166. {
  167. return 0;
  168. }
  169. static inline void zpci_exit_slot(struct zpci_dev *zdev) {}
  170. #endif /* CONFIG_HOTPLUG_PCI_S390 */
  171. /* Helpers */
  172. static inline struct zpci_dev *to_zpci(struct pci_dev *pdev)
  173. {
  174. return pdev->sysdata;
  175. }
  176. struct zpci_dev *get_zdev_by_fid(u32);
  177. /* DMA */
  178. int zpci_dma_init(void);
  179. void zpci_dma_exit(void);
  180. /* FMB */
  181. int zpci_fmb_enable_device(struct zpci_dev *);
  182. int zpci_fmb_disable_device(struct zpci_dev *);
  183. /* Debug */
  184. int zpci_debug_init(void);
  185. void zpci_debug_exit(void);
  186. void zpci_debug_init_device(struct zpci_dev *, const char *);
  187. void zpci_debug_exit_device(struct zpci_dev *);
  188. void zpci_debug_info(struct zpci_dev *, struct seq_file *);
  189. /* Error reporting */
  190. int zpci_report_error(struct pci_dev *, struct zpci_report_error_header *);
  191. #ifdef CONFIG_NUMA
  192. /* Returns the node based on PCI bus */
  193. static inline int __pcibus_to_node(const struct pci_bus *bus)
  194. {
  195. return NUMA_NO_NODE;
  196. }
  197. static inline const struct cpumask *
  198. cpumask_of_pcibus(const struct pci_bus *bus)
  199. {
  200. return cpu_online_mask;
  201. }
  202. #endif /* CONFIG_NUMA */
  203. #endif