qdio.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. #ifndef _CIO_QDIO_H
  2. #define _CIO_QDIO_H
  3. #include <asm/page.h>
  4. #define VERSION_CIO_QDIO_H "$Revision: 1.33 $"
  5. #ifdef CONFIG_QDIO_DEBUG
  6. #define QDIO_VERBOSE_LEVEL 9
  7. #else /* CONFIG_QDIO_DEBUG */
  8. #define QDIO_VERBOSE_LEVEL 5
  9. #endif /* CONFIG_QDIO_DEBUG */
  10. #define QDIO_USE_PROCESSING_STATE
  11. #ifdef CONFIG_QDIO_PERF_STATS
  12. #define QDIO_PERFORMANCE_STATS
  13. #endif /* CONFIG_QDIO_PERF_STATS */
  14. #define QDIO_MINIMAL_BH_RELIEF_TIME 16
  15. #define QDIO_TIMER_POLL_VALUE 1
  16. #define IQDIO_TIMER_POLL_VALUE 1
  17. /*
  18. * unfortunately this can't be (QDIO_MAX_BUFFERS_PER_Q*4/3) or so -- as
  19. * we never know, whether we'll get initiative again, e.g. to give the
  20. * transmit skb's back to the stack, however the stack may be waiting for
  21. * them... therefore we define 4 as threshold to start polling (which
  22. * will stop as soon as the asynchronous queue catches up)
  23. * btw, this only applies to the asynchronous HiperSockets queue
  24. */
  25. #define IQDIO_FILL_LEVEL_TO_POLL 4
  26. #define TIQDIO_THININT_ISC 3
  27. #define TIQDIO_DELAY_TARGET 0
  28. #define QDIO_BUSY_BIT_PATIENCE 100 /* in microsecs */
  29. #define QDIO_BUSY_BIT_GIVE_UP 10000000 /* 10 seconds */
  30. #define IQDIO_GLOBAL_LAPS 2 /* GLOBAL_LAPS are not used as we */
  31. #define IQDIO_GLOBAL_LAPS_INT 1 /* don't global summary */
  32. #define IQDIO_LOCAL_LAPS 4
  33. #define IQDIO_LOCAL_LAPS_INT 1
  34. #define IQDIO_GLOBAL_SUMMARY_CC_MASK 2
  35. /*#define IQDIO_IQDC_INT_PARM 0x1234*/
  36. #define QDIO_Q_LAPS 5
  37. #define QDIO_STORAGE_KEY PAGE_DEFAULT_KEY
  38. #define L2_CACHELINE_SIZE 256
  39. #define INDICATORS_PER_CACHELINE (L2_CACHELINE_SIZE/sizeof(__u32))
  40. #define QDIO_PERF "qdio_perf"
  41. /* must be a power of 2 */
  42. /*#define QDIO_STATS_NUMBER 4
  43. #define QDIO_STATS_CLASSES 2
  44. #define QDIO_STATS_COUNT_NEEDED 2*/
  45. #define QDIO_NO_USE_COUNT_TIMEOUT (1*HZ) /* wait for 1 sec on each q before
  46. exiting without having use_count
  47. of the queue to 0 */
  48. #define QDIO_ESTABLISH_TIMEOUT (1*HZ)
  49. #define QDIO_ACTIVATE_TIMEOUT ((5*HZ)>>10)
  50. #define QDIO_CLEANUP_CLEAR_TIMEOUT (20*HZ)
  51. #define QDIO_CLEANUP_HALT_TIMEOUT (10*HZ)
  52. enum qdio_irq_states {
  53. QDIO_IRQ_STATE_INACTIVE,
  54. QDIO_IRQ_STATE_ESTABLISHED,
  55. QDIO_IRQ_STATE_ACTIVE,
  56. QDIO_IRQ_STATE_STOPPED,
  57. QDIO_IRQ_STATE_CLEANUP,
  58. QDIO_IRQ_STATE_ERR,
  59. NR_QDIO_IRQ_STATES,
  60. };
  61. /* used as intparm in do_IO: */
  62. #define QDIO_DOING_SENSEID 0
  63. #define QDIO_DOING_ESTABLISH 1
  64. #define QDIO_DOING_ACTIVATE 2
  65. #define QDIO_DOING_CLEANUP 3
  66. /************************* DEBUG FACILITY STUFF *********************/
  67. #define QDIO_DBF_HEX(ex,name,level,addr,len) \
  68. do { \
  69. if (ex) \
  70. debug_exception(qdio_dbf_##name,level,(void*)(addr),len); \
  71. else \
  72. debug_event(qdio_dbf_##name,level,(void*)(addr),len); \
  73. } while (0)
  74. #define QDIO_DBF_TEXT(ex,name,level,text) \
  75. do { \
  76. if (ex) \
  77. debug_text_exception(qdio_dbf_##name,level,text); \
  78. else \
  79. debug_text_event(qdio_dbf_##name,level,text); \
  80. } while (0)
  81. #define QDIO_DBF_HEX0(ex,name,addr,len) QDIO_DBF_HEX(ex,name,0,addr,len)
  82. #define QDIO_DBF_HEX1(ex,name,addr,len) QDIO_DBF_HEX(ex,name,1,addr,len)
  83. #define QDIO_DBF_HEX2(ex,name,addr,len) QDIO_DBF_HEX(ex,name,2,addr,len)
  84. #ifdef CONFIG_QDIO_DEBUG
  85. #define QDIO_DBF_HEX3(ex,name,addr,len) QDIO_DBF_HEX(ex,name,3,addr,len)
  86. #define QDIO_DBF_HEX4(ex,name,addr,len) QDIO_DBF_HEX(ex,name,4,addr,len)
  87. #define QDIO_DBF_HEX5(ex,name,addr,len) QDIO_DBF_HEX(ex,name,5,addr,len)
  88. #define QDIO_DBF_HEX6(ex,name,addr,len) QDIO_DBF_HEX(ex,name,6,addr,len)
  89. #else /* CONFIG_QDIO_DEBUG */
  90. #define QDIO_DBF_HEX3(ex,name,addr,len) do {} while (0)
  91. #define QDIO_DBF_HEX4(ex,name,addr,len) do {} while (0)
  92. #define QDIO_DBF_HEX5(ex,name,addr,len) do {} while (0)
  93. #define QDIO_DBF_HEX6(ex,name,addr,len) do {} while (0)
  94. #endif /* CONFIG_QDIO_DEBUG */
  95. #define QDIO_DBF_TEXT0(ex,name,text) QDIO_DBF_TEXT(ex,name,0,text)
  96. #define QDIO_DBF_TEXT1(ex,name,text) QDIO_DBF_TEXT(ex,name,1,text)
  97. #define QDIO_DBF_TEXT2(ex,name,text) QDIO_DBF_TEXT(ex,name,2,text)
  98. #ifdef CONFIG_QDIO_DEBUG
  99. #define QDIO_DBF_TEXT3(ex,name,text) QDIO_DBF_TEXT(ex,name,3,text)
  100. #define QDIO_DBF_TEXT4(ex,name,text) QDIO_DBF_TEXT(ex,name,4,text)
  101. #define QDIO_DBF_TEXT5(ex,name,text) QDIO_DBF_TEXT(ex,name,5,text)
  102. #define QDIO_DBF_TEXT6(ex,name,text) QDIO_DBF_TEXT(ex,name,6,text)
  103. #else /* CONFIG_QDIO_DEBUG */
  104. #define QDIO_DBF_TEXT3(ex,name,text) do {} while (0)
  105. #define QDIO_DBF_TEXT4(ex,name,text) do {} while (0)
  106. #define QDIO_DBF_TEXT5(ex,name,text) do {} while (0)
  107. #define QDIO_DBF_TEXT6(ex,name,text) do {} while (0)
  108. #endif /* CONFIG_QDIO_DEBUG */
  109. #define QDIO_DBF_SETUP_NAME "qdio_setup"
  110. #define QDIO_DBF_SETUP_LEN 8
  111. #define QDIO_DBF_SETUP_PAGES 4
  112. #define QDIO_DBF_SETUP_NR_AREAS 1
  113. #ifdef CONFIG_QDIO_DEBUG
  114. #define QDIO_DBF_SETUP_LEVEL 6
  115. #else /* CONFIG_QDIO_DEBUG */
  116. #define QDIO_DBF_SETUP_LEVEL 2
  117. #endif /* CONFIG_QDIO_DEBUG */
  118. #define QDIO_DBF_SBAL_NAME "qdio_labs" /* sbal */
  119. #define QDIO_DBF_SBAL_LEN 256
  120. #define QDIO_DBF_SBAL_PAGES 4
  121. #define QDIO_DBF_SBAL_NR_AREAS 2
  122. #ifdef CONFIG_QDIO_DEBUG
  123. #define QDIO_DBF_SBAL_LEVEL 6
  124. #else /* CONFIG_QDIO_DEBUG */
  125. #define QDIO_DBF_SBAL_LEVEL 2
  126. #endif /* CONFIG_QDIO_DEBUG */
  127. #define QDIO_DBF_TRACE_NAME "qdio_trace"
  128. #define QDIO_DBF_TRACE_LEN 8
  129. #define QDIO_DBF_TRACE_NR_AREAS 2
  130. #ifdef CONFIG_QDIO_DEBUG
  131. #define QDIO_DBF_TRACE_PAGES 16
  132. #define QDIO_DBF_TRACE_LEVEL 4 /* -------- could be even more verbose here */
  133. #else /* CONFIG_QDIO_DEBUG */
  134. #define QDIO_DBF_TRACE_PAGES 4
  135. #define QDIO_DBF_TRACE_LEVEL 2
  136. #endif /* CONFIG_QDIO_DEBUG */
  137. #define QDIO_DBF_SENSE_NAME "qdio_sense"
  138. #define QDIO_DBF_SENSE_LEN 64
  139. #define QDIO_DBF_SENSE_PAGES 2
  140. #define QDIO_DBF_SENSE_NR_AREAS 1
  141. #ifdef CONFIG_QDIO_DEBUG
  142. #define QDIO_DBF_SENSE_LEVEL 6
  143. #else /* CONFIG_QDIO_DEBUG */
  144. #define QDIO_DBF_SENSE_LEVEL 2
  145. #endif /* CONFIG_QDIO_DEBUG */
  146. #ifdef CONFIG_QDIO_DEBUG
  147. #define QDIO_TRACE_QTYPE QDIO_ZFCP_QFMT
  148. #define QDIO_DBF_SLSB_OUT_NAME "qdio_slsb_out"
  149. #define QDIO_DBF_SLSB_OUT_LEN QDIO_MAX_BUFFERS_PER_Q
  150. #define QDIO_DBF_SLSB_OUT_PAGES 256
  151. #define QDIO_DBF_SLSB_OUT_NR_AREAS 1
  152. #define QDIO_DBF_SLSB_OUT_LEVEL 6
  153. #define QDIO_DBF_SLSB_IN_NAME "qdio_slsb_in"
  154. #define QDIO_DBF_SLSB_IN_LEN QDIO_MAX_BUFFERS_PER_Q
  155. #define QDIO_DBF_SLSB_IN_PAGES 256
  156. #define QDIO_DBF_SLSB_IN_NR_AREAS 1
  157. #define QDIO_DBF_SLSB_IN_LEVEL 6
  158. #endif /* CONFIG_QDIO_DEBUG */
  159. #define QDIO_PRINTK_HEADER QDIO_NAME ": "
  160. #if QDIO_VERBOSE_LEVEL>8
  161. #define QDIO_PRINT_STUPID(x...) printk( KERN_DEBUG QDIO_PRINTK_HEADER x)
  162. #else
  163. #define QDIO_PRINT_STUPID(x...)
  164. #endif
  165. #if QDIO_VERBOSE_LEVEL>7
  166. #define QDIO_PRINT_ALL(x...) printk( QDIO_PRINTK_HEADER x)
  167. #else
  168. #define QDIO_PRINT_ALL(x...)
  169. #endif
  170. #if QDIO_VERBOSE_LEVEL>6
  171. #define QDIO_PRINT_INFO(x...) printk( QDIO_PRINTK_HEADER x)
  172. #else
  173. #define QDIO_PRINT_INFO(x...)
  174. #endif
  175. #if QDIO_VERBOSE_LEVEL>5
  176. #define QDIO_PRINT_WARN(x...) printk( QDIO_PRINTK_HEADER x)
  177. #else
  178. #define QDIO_PRINT_WARN(x...)
  179. #endif
  180. #if QDIO_VERBOSE_LEVEL>4
  181. #define QDIO_PRINT_ERR(x...) printk( QDIO_PRINTK_HEADER x)
  182. #else
  183. #define QDIO_PRINT_ERR(x...)
  184. #endif
  185. #if QDIO_VERBOSE_LEVEL>3
  186. #define QDIO_PRINT_CRIT(x...) printk( QDIO_PRINTK_HEADER x)
  187. #else
  188. #define QDIO_PRINT_CRIT(x...)
  189. #endif
  190. #if QDIO_VERBOSE_LEVEL>2
  191. #define QDIO_PRINT_ALERT(x...) printk( QDIO_PRINTK_HEADER x)
  192. #else
  193. #define QDIO_PRINT_ALERT(x...)
  194. #endif
  195. #if QDIO_VERBOSE_LEVEL>1
  196. #define QDIO_PRINT_EMERG(x...) printk( QDIO_PRINTK_HEADER x)
  197. #else
  198. #define QDIO_PRINT_EMERG(x...)
  199. #endif
  200. #define HEXDUMP16(importance,header,ptr) \
  201. QDIO_PRINT_##importance(header "%02x %02x %02x %02x " \
  202. "%02x %02x %02x %02x %02x %02x %02x %02x " \
  203. "%02x %02x %02x %02x\n",*(((char*)ptr)), \
  204. *(((char*)ptr)+1),*(((char*)ptr)+2), \
  205. *(((char*)ptr)+3),*(((char*)ptr)+4), \
  206. *(((char*)ptr)+5),*(((char*)ptr)+6), \
  207. *(((char*)ptr)+7),*(((char*)ptr)+8), \
  208. *(((char*)ptr)+9),*(((char*)ptr)+10), \
  209. *(((char*)ptr)+11),*(((char*)ptr)+12), \
  210. *(((char*)ptr)+13),*(((char*)ptr)+14), \
  211. *(((char*)ptr)+15)); \
  212. QDIO_PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
  213. "%02x %02x %02x %02x %02x %02x %02x %02x\n", \
  214. *(((char*)ptr)+16),*(((char*)ptr)+17), \
  215. *(((char*)ptr)+18),*(((char*)ptr)+19), \
  216. *(((char*)ptr)+20),*(((char*)ptr)+21), \
  217. *(((char*)ptr)+22),*(((char*)ptr)+23), \
  218. *(((char*)ptr)+24),*(((char*)ptr)+25), \
  219. *(((char*)ptr)+26),*(((char*)ptr)+27), \
  220. *(((char*)ptr)+28),*(((char*)ptr)+29), \
  221. *(((char*)ptr)+30),*(((char*)ptr)+31));
  222. /****************** END OF DEBUG FACILITY STUFF *********************/
  223. /*
  224. * Some instructions as assembly
  225. */
  226. extern __inline__ int
  227. do_siga_sync(unsigned int irq, unsigned int mask1, unsigned int mask2)
  228. {
  229. int cc;
  230. #ifndef CONFIG_ARCH_S390X
  231. asm volatile (
  232. "lhi 0,2 \n\t"
  233. "lr 1,%1 \n\t"
  234. "lr 2,%2 \n\t"
  235. "lr 3,%3 \n\t"
  236. "siga 0 \n\t"
  237. "ipm %0 \n\t"
  238. "srl %0,28 \n\t"
  239. : "=d" (cc)
  240. : "d" (0x10000|irq), "d" (mask1), "d" (mask2)
  241. : "cc", "0", "1", "2", "3"
  242. );
  243. #else /* CONFIG_ARCH_S390X */
  244. asm volatile (
  245. "lghi 0,2 \n\t"
  246. "llgfr 1,%1 \n\t"
  247. "llgfr 2,%2 \n\t"
  248. "llgfr 3,%3 \n\t"
  249. "siga 0 \n\t"
  250. "ipm %0 \n\t"
  251. "srl %0,28 \n\t"
  252. : "=d" (cc)
  253. : "d" (0x10000|irq), "d" (mask1), "d" (mask2)
  254. : "cc", "0", "1", "2", "3"
  255. );
  256. #endif /* CONFIG_ARCH_S390X */
  257. return cc;
  258. }
  259. extern __inline__ int
  260. do_siga_input(unsigned int irq, unsigned int mask)
  261. {
  262. int cc;
  263. #ifndef CONFIG_ARCH_S390X
  264. asm volatile (
  265. "lhi 0,1 \n\t"
  266. "lr 1,%1 \n\t"
  267. "lr 2,%2 \n\t"
  268. "siga 0 \n\t"
  269. "ipm %0 \n\t"
  270. "srl %0,28 \n\t"
  271. : "=d" (cc)
  272. : "d" (0x10000|irq), "d" (mask)
  273. : "cc", "0", "1", "2", "memory"
  274. );
  275. #else /* CONFIG_ARCH_S390X */
  276. asm volatile (
  277. "lghi 0,1 \n\t"
  278. "llgfr 1,%1 \n\t"
  279. "llgfr 2,%2 \n\t"
  280. "siga 0 \n\t"
  281. "ipm %0 \n\t"
  282. "srl %0,28 \n\t"
  283. : "=d" (cc)
  284. : "d" (0x10000|irq), "d" (mask)
  285. : "cc", "0", "1", "2", "memory"
  286. );
  287. #endif /* CONFIG_ARCH_S390X */
  288. return cc;
  289. }
  290. extern __inline__ int
  291. do_siga_output(unsigned long irq, unsigned long mask, __u32 *bb)
  292. {
  293. int cc;
  294. __u32 busy_bit;
  295. #ifndef CONFIG_ARCH_S390X
  296. asm volatile (
  297. "lhi 0,0 \n\t"
  298. "lr 1,%2 \n\t"
  299. "lr 2,%3 \n\t"
  300. "siga 0 \n\t"
  301. "0:"
  302. "ipm %0 \n\t"
  303. "srl %0,28 \n\t"
  304. "srl 0,31 \n\t"
  305. "lr %1,0 \n\t"
  306. "1: \n\t"
  307. ".section .fixup,\"ax\"\n\t"
  308. "2: \n\t"
  309. "lhi %0,%4 \n\t"
  310. "bras 1,3f \n\t"
  311. ".long 1b \n\t"
  312. "3: \n\t"
  313. "l 1,0(1) \n\t"
  314. "br 1 \n\t"
  315. ".previous \n\t"
  316. ".section __ex_table,\"a\"\n\t"
  317. ".align 4 \n\t"
  318. ".long 0b,2b \n\t"
  319. ".previous \n\t"
  320. : "=d" (cc), "=d" (busy_bit)
  321. : "d" (0x10000|irq), "d" (mask),
  322. "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION)
  323. : "cc", "0", "1", "2", "memory"
  324. );
  325. #else /* CONFIG_ARCH_S390X */
  326. asm volatile (
  327. "lghi 0,0 \n\t"
  328. "llgfr 1,%2 \n\t"
  329. "llgfr 2,%3 \n\t"
  330. "siga 0 \n\t"
  331. "0:"
  332. "ipm %0 \n\t"
  333. "srl %0,28 \n\t"
  334. "srl 0,31 \n\t"
  335. "llgfr %1,0 \n\t"
  336. "1: \n\t"
  337. ".section .fixup,\"ax\"\n\t"
  338. "lghi %0,%4 \n\t"
  339. "jg 1b \n\t"
  340. ".previous\n\t"
  341. ".section __ex_table,\"a\"\n\t"
  342. ".align 8 \n\t"
  343. ".quad 0b,1b \n\t"
  344. ".previous \n\t"
  345. : "=d" (cc), "=d" (busy_bit)
  346. : "d" (0x10000|irq), "d" (mask),
  347. "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION)
  348. : "cc", "0", "1", "2", "memory"
  349. );
  350. #endif /* CONFIG_ARCH_S390X */
  351. (*bb) = busy_bit;
  352. return cc;
  353. }
  354. extern __inline__ unsigned long
  355. do_clear_global_summary(void)
  356. {
  357. unsigned long time;
  358. #ifndef CONFIG_ARCH_S390X
  359. asm volatile (
  360. "lhi 1,3 \n\t"
  361. ".insn rre,0xb2650000,2,0 \n\t"
  362. "lr %0,3 \n\t"
  363. : "=d" (time) : : "cc", "1", "2", "3"
  364. );
  365. #else /* CONFIG_ARCH_S390X */
  366. asm volatile (
  367. "lghi 1,3 \n\t"
  368. ".insn rre,0xb2650000,2,0 \n\t"
  369. "lgr %0,3 \n\t"
  370. : "=d" (time) : : "cc", "1", "2", "3"
  371. );
  372. #endif /* CONFIG_ARCH_S390X */
  373. return time;
  374. }
  375. /*
  376. * QDIO device commands returned by extended Sense-ID
  377. */
  378. #define DEFAULT_ESTABLISH_QS_CMD 0x1b
  379. #define DEFAULT_ESTABLISH_QS_COUNT 0x1000
  380. #define DEFAULT_ACTIVATE_QS_CMD 0x1f
  381. #define DEFAULT_ACTIVATE_QS_COUNT 0
  382. /*
  383. * additional CIWs returned by extended Sense-ID
  384. */
  385. #define CIW_TYPE_EQUEUE 0x3 /* establish QDIO queues */
  386. #define CIW_TYPE_AQUEUE 0x4 /* activate QDIO queues */
  387. #define QDIO_CHSC_RESPONSE_CODE_OK 1
  388. /* flags for st qdio sch data */
  389. #define CHSC_FLAG_QDIO_CAPABILITY 0x80
  390. #define CHSC_FLAG_VALIDITY 0x40
  391. #define CHSC_FLAG_SIGA_INPUT_NECESSARY 0x40
  392. #define CHSC_FLAG_SIGA_OUTPUT_NECESSARY 0x20
  393. #define CHSC_FLAG_SIGA_SYNC_NECESSARY 0x10
  394. #define CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS 0x08
  395. #define CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS 0x04
  396. #ifdef QDIO_PERFORMANCE_STATS
  397. struct qdio_perf_stats {
  398. unsigned int tl_runs;
  399. unsigned int siga_outs;
  400. unsigned int siga_ins;
  401. unsigned int siga_syncs;
  402. unsigned int pcis;
  403. unsigned int thinints;
  404. unsigned int fast_reqs;
  405. __u64 start_time_outbound;
  406. unsigned int outbound_cnt;
  407. unsigned int outbound_time;
  408. __u64 start_time_inbound;
  409. unsigned int inbound_cnt;
  410. unsigned int inbound_time;
  411. };
  412. #endif /* QDIO_PERFORMANCE_STATS */
  413. #define atomic_swap(a,b) xchg((int*)a.counter,b)
  414. /* unlikely as the later the better */
  415. #define SYNC_MEMORY if (unlikely(q->siga_sync)) qdio_siga_sync_q(q)
  416. #define SYNC_MEMORY_ALL if (unlikely(q->siga_sync)) \
  417. qdio_siga_sync(q,~0U,~0U)
  418. #define SYNC_MEMORY_ALL_OUTB if (unlikely(q->siga_sync)) \
  419. qdio_siga_sync(q,~0U,0)
  420. #define NOW qdio_get_micros()
  421. #define SAVE_TIMESTAMP(q) q->timing.last_transfer_time=NOW
  422. #define GET_SAVED_TIMESTAMP(q) (q->timing.last_transfer_time)
  423. #define SAVE_FRONTIER(q,val) q->last_move_ftc=val
  424. #define GET_SAVED_FRONTIER(q) (q->last_move_ftc)
  425. #define MY_MODULE_STRING(x) #x
  426. #ifdef CONFIG_ARCH_S390X
  427. #define QDIO_GET_ADDR(x) ((__u32)(unsigned long)x)
  428. #else /* CONFIG_ARCH_S390X */
  429. #define QDIO_GET_ADDR(x) ((__u32)(long)x)
  430. #endif /* CONFIG_ARCH_S390X */
  431. #ifdef CONFIG_QDIO_DEBUG
  432. #define set_slsb(x,y) \
  433. if(q->queue_type==QDIO_TRACE_QTYPE) { \
  434. if(q->is_input_q) { \
  435. QDIO_DBF_HEX2(0,slsb_in,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \
  436. } else { \
  437. QDIO_DBF_HEX2(0,slsb_out,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \
  438. } \
  439. } \
  440. qdio_set_slsb(x,y); \
  441. if(q->queue_type==QDIO_TRACE_QTYPE) { \
  442. if(q->is_input_q) { \
  443. QDIO_DBF_HEX2(0,slsb_in,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \
  444. } else { \
  445. QDIO_DBF_HEX2(0,slsb_out,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \
  446. } \
  447. }
  448. #else /* CONFIG_QDIO_DEBUG */
  449. #define set_slsb(x,y) qdio_set_slsb(x,y)
  450. #endif /* CONFIG_QDIO_DEBUG */
  451. struct qdio_q {
  452. volatile struct slsb slsb;
  453. char unused[QDIO_MAX_BUFFERS_PER_Q];
  454. __u32 * volatile dev_st_chg_ind;
  455. int is_input_q;
  456. int irq;
  457. struct ccw_device *cdev;
  458. unsigned int is_iqdio_q;
  459. unsigned int is_thinint_q;
  460. /* bit 0 means queue 0, bit 1 means queue 1, ... */
  461. unsigned int mask;
  462. unsigned int q_no;
  463. qdio_handler_t (*handler);
  464. /* points to the next buffer to be checked for having
  465. * been processed by the card (outbound)
  466. * or to the next buffer the program should check for (inbound) */
  467. volatile int first_to_check;
  468. /* and the last time it was: */
  469. volatile int last_move_ftc;
  470. atomic_t number_of_buffers_used;
  471. atomic_t polling;
  472. unsigned int siga_in;
  473. unsigned int siga_out;
  474. unsigned int siga_sync;
  475. unsigned int siga_sync_done_on_thinints;
  476. unsigned int siga_sync_done_on_outb_tis;
  477. unsigned int hydra_gives_outbound_pcis;
  478. /* used to save beginning position when calling dd_handlers */
  479. int first_element_to_kick;
  480. atomic_t use_count;
  481. atomic_t is_in_shutdown;
  482. void *irq_ptr;
  483. #ifdef QDIO_USE_TIMERS_FOR_POLLING
  484. struct timer_list timer;
  485. atomic_t timer_already_set;
  486. spinlock_t timer_lock;
  487. #else /* QDIO_USE_TIMERS_FOR_POLLING */
  488. struct tasklet_struct tasklet;
  489. #endif /* QDIO_USE_TIMERS_FOR_POLLING */
  490. enum qdio_irq_states state;
  491. /* used to store the error condition during a data transfer */
  492. unsigned int qdio_error;
  493. unsigned int siga_error;
  494. unsigned int error_status_flags;
  495. /* list of interesting queues */
  496. volatile struct qdio_q *list_next;
  497. volatile struct qdio_q *list_prev;
  498. struct sl *sl;
  499. volatile struct sbal *sbal[QDIO_MAX_BUFFERS_PER_Q];
  500. struct qdio_buffer *qdio_buffers[QDIO_MAX_BUFFERS_PER_Q];
  501. unsigned long int_parm;
  502. /*struct {
  503. int in_bh_check_limit;
  504. int threshold;
  505. } threshold_classes[QDIO_STATS_CLASSES];*/
  506. struct {
  507. /* inbound: the time to stop polling
  508. outbound: the time to kick peer */
  509. int threshold; /* the real value */
  510. /* outbound: last time of do_QDIO
  511. inbound: last time of noticing incoming data */
  512. /*__u64 last_transfer_times[QDIO_STATS_NUMBER];
  513. int last_transfer_index; */
  514. __u64 last_transfer_time;
  515. __u64 busy_start;
  516. } timing;
  517. atomic_t busy_siga_counter;
  518. unsigned int queue_type;
  519. /* leave this member at the end. won't be cleared in qdio_fill_qs */
  520. struct slib *slib; /* a page is allocated under this pointer,
  521. sl points into this page, offset PAGE_SIZE/2
  522. (after slib) */
  523. } __attribute__ ((aligned(256)));
  524. struct qdio_irq {
  525. __u32 * volatile dev_st_chg_ind;
  526. unsigned long int_parm;
  527. int irq;
  528. unsigned int is_iqdio_irq;
  529. unsigned int is_thinint_irq;
  530. unsigned int hydra_gives_outbound_pcis;
  531. unsigned int sync_done_on_outb_pcis;
  532. enum qdio_irq_states state;
  533. unsigned int no_input_qs;
  534. unsigned int no_output_qs;
  535. unsigned char qdioac;
  536. struct ccw1 ccw;
  537. struct ciw equeue;
  538. struct ciw aqueue;
  539. struct qib qib;
  540. void (*original_int_handler) (struct ccw_device *,
  541. unsigned long, struct irb *);
  542. /* leave these four members together at the end. won't be cleared in qdio_fill_irq */
  543. struct qdr *qdr;
  544. struct qdio_q *input_qs[QDIO_MAX_QUEUES_PER_IRQ];
  545. struct qdio_q *output_qs[QDIO_MAX_QUEUES_PER_IRQ];
  546. struct semaphore setting_up_sema;
  547. };
  548. #endif