qdio.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. #ifndef _CIO_QDIO_H
  2. #define _CIO_QDIO_H
  3. #include <asm/page.h>
  4. #include "schid.h"
  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. static inline int
  227. do_sqbs(unsigned long sch, unsigned char state, int queue,
  228. unsigned int *start, unsigned int *count)
  229. {
  230. #ifdef CONFIG_64BIT
  231. register unsigned long _ccq asm ("0") = *count;
  232. register unsigned long _sch asm ("1") = sch;
  233. unsigned long _queuestart = ((unsigned long)queue << 32) | *start;
  234. asm volatile (
  235. " .insn rsy,0xeb000000008A,%1,0,0(%2)\n\t"
  236. : "+d" (_ccq), "+d" (_queuestart)
  237. : "d" ((unsigned long)state), "d" (_sch)
  238. : "memory", "cc"
  239. );
  240. *count = _ccq & 0xff;
  241. *start = _queuestart & 0xff;
  242. return (_ccq >> 32) & 0xff;
  243. #else
  244. return 0;
  245. #endif
  246. }
  247. static inline int
  248. do_eqbs(unsigned long sch, unsigned char *state, int queue,
  249. unsigned int *start, unsigned int *count)
  250. {
  251. #ifdef CONFIG_64BIT
  252. register unsigned long _ccq asm ("0") = *count;
  253. register unsigned long _sch asm ("1") = sch;
  254. unsigned long _queuestart = ((unsigned long)queue << 32) | *start;
  255. unsigned long _state = 0;
  256. asm volatile (
  257. " .insn rrf,0xB99c0000,%1,%2,0,0 \n\t"
  258. : "+d" (_ccq), "+d" (_queuestart), "+d" (_state)
  259. : "d" (_sch)
  260. : "memory", "cc"
  261. );
  262. *count = _ccq & 0xff;
  263. *start = _queuestart & 0xff;
  264. *state = _state & 0xff;
  265. return (_ccq >> 32) & 0xff;
  266. #else
  267. return 0;
  268. #endif
  269. }
  270. static inline int
  271. do_siga_sync(struct subchannel_id schid, unsigned int mask1, unsigned int mask2)
  272. {
  273. int cc;
  274. #ifndef CONFIG_64BIT
  275. asm volatile (
  276. "lhi 0,2 \n\t"
  277. "lr 1,%1 \n\t"
  278. "lr 2,%2 \n\t"
  279. "lr 3,%3 \n\t"
  280. "siga 0 \n\t"
  281. "ipm %0 \n\t"
  282. "srl %0,28 \n\t"
  283. : "=d" (cc)
  284. : "d" (schid), "d" (mask1), "d" (mask2)
  285. : "cc", "0", "1", "2", "3"
  286. );
  287. #else /* CONFIG_64BIT */
  288. asm volatile (
  289. "lghi 0,2 \n\t"
  290. "llgfr 1,%1 \n\t"
  291. "llgfr 2,%2 \n\t"
  292. "llgfr 3,%3 \n\t"
  293. "siga 0 \n\t"
  294. "ipm %0 \n\t"
  295. "srl %0,28 \n\t"
  296. : "=d" (cc)
  297. : "d" (schid), "d" (mask1), "d" (mask2)
  298. : "cc", "0", "1", "2", "3"
  299. );
  300. #endif /* CONFIG_64BIT */
  301. return cc;
  302. }
  303. static inline int
  304. do_siga_input(struct subchannel_id schid, unsigned int mask)
  305. {
  306. int cc;
  307. #ifndef CONFIG_64BIT
  308. asm volatile (
  309. "lhi 0,1 \n\t"
  310. "lr 1,%1 \n\t"
  311. "lr 2,%2 \n\t"
  312. "siga 0 \n\t"
  313. "ipm %0 \n\t"
  314. "srl %0,28 \n\t"
  315. : "=d" (cc)
  316. : "d" (schid), "d" (mask)
  317. : "cc", "0", "1", "2", "memory"
  318. );
  319. #else /* CONFIG_64BIT */
  320. asm volatile (
  321. "lghi 0,1 \n\t"
  322. "llgfr 1,%1 \n\t"
  323. "llgfr 2,%2 \n\t"
  324. "siga 0 \n\t"
  325. "ipm %0 \n\t"
  326. "srl %0,28 \n\t"
  327. : "=d" (cc)
  328. : "d" (schid), "d" (mask)
  329. : "cc", "0", "1", "2", "memory"
  330. );
  331. #endif /* CONFIG_64BIT */
  332. return cc;
  333. }
  334. static inline int
  335. do_siga_output(unsigned long schid, unsigned long mask, __u32 *bb,
  336. unsigned int fc)
  337. {
  338. int cc;
  339. __u32 busy_bit;
  340. #ifndef CONFIG_64BIT
  341. asm volatile (
  342. "lhi 0,0 \n\t"
  343. "lr 1,%2 \n\t"
  344. "lr 2,%3 \n\t"
  345. "siga 0 \n\t"
  346. "0:"
  347. "ipm %0 \n\t"
  348. "srl %0,28 \n\t"
  349. "srl 0,31 \n\t"
  350. "lr %1,0 \n\t"
  351. "1: \n\t"
  352. ".section .fixup,\"ax\"\n\t"
  353. "2: \n\t"
  354. "lhi %0,%4 \n\t"
  355. "bras 1,3f \n\t"
  356. ".long 1b \n\t"
  357. "3: \n\t"
  358. "l 1,0(1) \n\t"
  359. "br 1 \n\t"
  360. ".previous \n\t"
  361. ".section __ex_table,\"a\"\n\t"
  362. ".align 4 \n\t"
  363. ".long 0b,2b \n\t"
  364. ".previous \n\t"
  365. : "=d" (cc), "=d" (busy_bit)
  366. : "d" (schid), "d" (mask),
  367. "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION)
  368. : "cc", "0", "1", "2", "memory"
  369. );
  370. #else /* CONFIG_64BIT */
  371. asm volatile (
  372. "llgfr 0,%5 \n\t"
  373. "lgr 1,%2 \n\t"
  374. "llgfr 2,%3 \n\t"
  375. "siga 0 \n\t"
  376. "0:"
  377. "ipm %0 \n\t"
  378. "srl %0,28 \n\t"
  379. "srl 0,31 \n\t"
  380. "llgfr %1,0 \n\t"
  381. "1: \n\t"
  382. ".section .fixup,\"ax\"\n\t"
  383. "lghi %0,%4 \n\t"
  384. "jg 1b \n\t"
  385. ".previous\n\t"
  386. ".section __ex_table,\"a\"\n\t"
  387. ".align 8 \n\t"
  388. ".quad 0b,1b \n\t"
  389. ".previous \n\t"
  390. : "=d" (cc), "=d" (busy_bit)
  391. : "d" (schid), "d" (mask),
  392. "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION), "d" (fc)
  393. : "cc", "0", "1", "2", "memory"
  394. );
  395. #endif /* CONFIG_64BIT */
  396. (*bb) = busy_bit;
  397. return cc;
  398. }
  399. static inline unsigned long
  400. do_clear_global_summary(void)
  401. {
  402. unsigned long time;
  403. #ifndef CONFIG_64BIT
  404. asm volatile (
  405. "lhi 1,3 \n\t"
  406. ".insn rre,0xb2650000,2,0 \n\t"
  407. "lr %0,3 \n\t"
  408. : "=d" (time) : : "cc", "1", "2", "3"
  409. );
  410. #else /* CONFIG_64BIT */
  411. asm volatile (
  412. "lghi 1,3 \n\t"
  413. ".insn rre,0xb2650000,2,0 \n\t"
  414. "lgr %0,3 \n\t"
  415. : "=d" (time) : : "cc", "1", "2", "3"
  416. );
  417. #endif /* CONFIG_64BIT */
  418. return time;
  419. }
  420. /*
  421. * QDIO device commands returned by extended Sense-ID
  422. */
  423. #define DEFAULT_ESTABLISH_QS_CMD 0x1b
  424. #define DEFAULT_ESTABLISH_QS_COUNT 0x1000
  425. #define DEFAULT_ACTIVATE_QS_CMD 0x1f
  426. #define DEFAULT_ACTIVATE_QS_COUNT 0
  427. /*
  428. * additional CIWs returned by extended Sense-ID
  429. */
  430. #define CIW_TYPE_EQUEUE 0x3 /* establish QDIO queues */
  431. #define CIW_TYPE_AQUEUE 0x4 /* activate QDIO queues */
  432. #define QDIO_CHSC_RESPONSE_CODE_OK 1
  433. /* flags for st qdio sch data */
  434. #define CHSC_FLAG_QDIO_CAPABILITY 0x80
  435. #define CHSC_FLAG_VALIDITY 0x40
  436. #define CHSC_FLAG_SIGA_INPUT_NECESSARY 0x40
  437. #define CHSC_FLAG_SIGA_OUTPUT_NECESSARY 0x20
  438. #define CHSC_FLAG_SIGA_SYNC_NECESSARY 0x10
  439. #define CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS 0x08
  440. #define CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS 0x04
  441. #ifdef QDIO_PERFORMANCE_STATS
  442. struct qdio_perf_stats {
  443. unsigned int tl_runs;
  444. unsigned int siga_outs;
  445. unsigned int siga_ins;
  446. unsigned int siga_syncs;
  447. unsigned int pcis;
  448. unsigned int thinints;
  449. unsigned int fast_reqs;
  450. __u64 start_time_outbound;
  451. unsigned int outbound_cnt;
  452. unsigned int outbound_time;
  453. __u64 start_time_inbound;
  454. unsigned int inbound_cnt;
  455. unsigned int inbound_time;
  456. };
  457. #endif /* QDIO_PERFORMANCE_STATS */
  458. #define atomic_swap(a,b) xchg((int*)a.counter,b)
  459. /* unlikely as the later the better */
  460. #define SYNC_MEMORY if (unlikely(q->siga_sync)) qdio_siga_sync_q(q)
  461. #define SYNC_MEMORY_ALL if (unlikely(q->siga_sync)) \
  462. qdio_siga_sync(q,~0U,~0U)
  463. #define SYNC_MEMORY_ALL_OUTB if (unlikely(q->siga_sync)) \
  464. qdio_siga_sync(q,~0U,0)
  465. #define NOW qdio_get_micros()
  466. #define SAVE_TIMESTAMP(q) q->timing.last_transfer_time=NOW
  467. #define GET_SAVED_TIMESTAMP(q) (q->timing.last_transfer_time)
  468. #define SAVE_FRONTIER(q,val) q->last_move_ftc=val
  469. #define GET_SAVED_FRONTIER(q) (q->last_move_ftc)
  470. #define MY_MODULE_STRING(x) #x
  471. #ifdef CONFIG_64BIT
  472. #define QDIO_GET_ADDR(x) ((__u32)(unsigned long)x)
  473. #else /* CONFIG_64BIT */
  474. #define QDIO_GET_ADDR(x) ((__u32)(long)x)
  475. #endif /* CONFIG_64BIT */
  476. struct qdio_q {
  477. volatile struct slsb slsb;
  478. char unused[QDIO_MAX_BUFFERS_PER_Q];
  479. __u32 * dev_st_chg_ind;
  480. int is_input_q;
  481. struct subchannel_id schid;
  482. struct ccw_device *cdev;
  483. unsigned int is_iqdio_q;
  484. unsigned int is_thinint_q;
  485. /* bit 0 means queue 0, bit 1 means queue 1, ... */
  486. unsigned int mask;
  487. unsigned int q_no;
  488. qdio_handler_t (*handler);
  489. /* points to the next buffer to be checked for having
  490. * been processed by the card (outbound)
  491. * or to the next buffer the program should check for (inbound) */
  492. volatile int first_to_check;
  493. /* and the last time it was: */
  494. volatile int last_move_ftc;
  495. atomic_t number_of_buffers_used;
  496. atomic_t polling;
  497. unsigned int siga_in;
  498. unsigned int siga_out;
  499. unsigned int siga_sync;
  500. unsigned int siga_sync_done_on_thinints;
  501. unsigned int siga_sync_done_on_outb_tis;
  502. unsigned int hydra_gives_outbound_pcis;
  503. /* used to save beginning position when calling dd_handlers */
  504. int first_element_to_kick;
  505. atomic_t use_count;
  506. atomic_t is_in_shutdown;
  507. void *irq_ptr;
  508. #ifdef QDIO_USE_TIMERS_FOR_POLLING
  509. struct timer_list timer;
  510. atomic_t timer_already_set;
  511. spinlock_t timer_lock;
  512. #else /* QDIO_USE_TIMERS_FOR_POLLING */
  513. struct tasklet_struct tasklet;
  514. #endif /* QDIO_USE_TIMERS_FOR_POLLING */
  515. enum qdio_irq_states state;
  516. /* used to store the error condition during a data transfer */
  517. unsigned int qdio_error;
  518. unsigned int siga_error;
  519. unsigned int error_status_flags;
  520. /* list of interesting queues */
  521. volatile struct qdio_q *list_next;
  522. volatile struct qdio_q *list_prev;
  523. struct sl *sl;
  524. volatile struct sbal *sbal[QDIO_MAX_BUFFERS_PER_Q];
  525. struct qdio_buffer *qdio_buffers[QDIO_MAX_BUFFERS_PER_Q];
  526. unsigned long int_parm;
  527. /*struct {
  528. int in_bh_check_limit;
  529. int threshold;
  530. } threshold_classes[QDIO_STATS_CLASSES];*/
  531. struct {
  532. /* inbound: the time to stop polling
  533. outbound: the time to kick peer */
  534. int threshold; /* the real value */
  535. /* outbound: last time of do_QDIO
  536. inbound: last time of noticing incoming data */
  537. /*__u64 last_transfer_times[QDIO_STATS_NUMBER];
  538. int last_transfer_index; */
  539. __u64 last_transfer_time;
  540. __u64 busy_start;
  541. } timing;
  542. atomic_t busy_siga_counter;
  543. unsigned int queue_type;
  544. /* leave this member at the end. won't be cleared in qdio_fill_qs */
  545. struct slib *slib; /* a page is allocated under this pointer,
  546. sl points into this page, offset PAGE_SIZE/2
  547. (after slib) */
  548. } __attribute__ ((aligned(256)));
  549. struct qdio_irq {
  550. __u32 * volatile dev_st_chg_ind;
  551. unsigned long int_parm;
  552. struct subchannel_id schid;
  553. unsigned int is_iqdio_irq;
  554. unsigned int is_thinint_irq;
  555. unsigned int hydra_gives_outbound_pcis;
  556. unsigned int sync_done_on_outb_pcis;
  557. /* QEBSM facility */
  558. unsigned int is_qebsm;
  559. unsigned long sch_token;
  560. enum qdio_irq_states state;
  561. unsigned int no_input_qs;
  562. unsigned int no_output_qs;
  563. unsigned char qdioac;
  564. struct ccw1 ccw;
  565. struct ciw equeue;
  566. struct ciw aqueue;
  567. struct qib qib;
  568. void (*original_int_handler) (struct ccw_device *,
  569. unsigned long, struct irb *);
  570. /* leave these four members together at the end. won't be cleared in qdio_fill_irq */
  571. struct qdr *qdr;
  572. struct qdio_q *input_qs[QDIO_MAX_QUEUES_PER_IRQ];
  573. struct qdio_q *output_qs[QDIO_MAX_QUEUES_PER_IRQ];
  574. struct semaphore setting_up_sema;
  575. };
  576. #endif