qdio.h 18 KB

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