qdio.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. /*
  2. * linux/include/asm-s390/qdio.h
  3. *
  4. * Copyright 2000,2008 IBM Corp.
  5. * Author(s): Utz Bacher <utz.bacher@de.ibm.com>
  6. * Jan Glauber <jang@linux.vnet.ibm.com>
  7. *
  8. */
  9. #ifndef __QDIO_H__
  10. #define __QDIO_H__
  11. #include <linux/interrupt.h>
  12. #include <asm/cio.h>
  13. #include <asm/ccwdev.h>
  14. /* only use 4 queues to save some cachelines */
  15. #define QDIO_MAX_QUEUES_PER_IRQ 4
  16. #define QDIO_MAX_BUFFERS_PER_Q 128
  17. #define QDIO_MAX_BUFFERS_MASK (QDIO_MAX_BUFFERS_PER_Q - 1)
  18. #define QDIO_MAX_ELEMENTS_PER_BUFFER 16
  19. #define QDIO_SBAL_SIZE 256
  20. #define QDIO_QETH_QFMT 0
  21. #define QDIO_ZFCP_QFMT 1
  22. #define QDIO_IQDIO_QFMT 2
  23. /**
  24. * struct qdesfmt0 - queue descriptor, format 0
  25. * @sliba: storage list information block address
  26. * @sla: storage list address
  27. * @slsba: storage list state block address
  28. * @akey: access key for DLIB
  29. * @bkey: access key for SL
  30. * @ckey: access key for SBALs
  31. * @dkey: access key for SLSB
  32. */
  33. struct qdesfmt0 {
  34. u64 sliba;
  35. u64 sla;
  36. u64 slsba;
  37. u32 : 32;
  38. u32 akey : 4;
  39. u32 bkey : 4;
  40. u32 ckey : 4;
  41. u32 dkey : 4;
  42. u32 : 16;
  43. } __attribute__ ((packed));
  44. /**
  45. * struct qdr - queue description record (QDR)
  46. * @qfmt: queue format
  47. * @pfmt: implementation dependent parameter format
  48. * @ac: adapter characteristics
  49. * @iqdcnt: input queue descriptor count
  50. * @oqdcnt: output queue descriptor count
  51. * @iqdsz: inpout queue descriptor size
  52. * @oqdsz: output queue descriptor size
  53. * @qiba: queue information block address
  54. * @qkey: queue information block key
  55. * @qdf0: queue descriptions
  56. */
  57. struct qdr {
  58. u32 qfmt : 8;
  59. u32 pfmt : 8;
  60. u32 : 8;
  61. u32 ac : 8;
  62. u32 : 8;
  63. u32 iqdcnt : 8;
  64. u32 : 8;
  65. u32 oqdcnt : 8;
  66. u32 : 8;
  67. u32 iqdsz : 8;
  68. u32 : 8;
  69. u32 oqdsz : 8;
  70. /* private: */
  71. u32 res[9];
  72. /* public: */
  73. u64 qiba;
  74. u32 : 32;
  75. u32 qkey : 4;
  76. u32 : 28;
  77. struct qdesfmt0 qdf0[126];
  78. } __attribute__ ((packed, aligned(4096)));
  79. #define QIB_AC_OUTBOUND_PCI_SUPPORTED 0x40
  80. #define QIB_RFLAGS_ENABLE_QEBSM 0x80
  81. #define QIB_RFLAGS_ENABLE_DATA_DIV 0x02
  82. /**
  83. * struct qib - queue information block (QIB)
  84. * @qfmt: queue format
  85. * @pfmt: implementation dependent parameter format
  86. * @rflags: QEBSM
  87. * @ac: adapter characteristics
  88. * @isliba: absolute address of first input SLIB
  89. * @osliba: absolute address of first output SLIB
  90. * @ebcnam: adapter identifier in EBCDIC
  91. * @parm: implementation dependent parameters
  92. */
  93. struct qib {
  94. u32 qfmt : 8;
  95. u32 pfmt : 8;
  96. u32 rflags : 8;
  97. u32 ac : 8;
  98. u32 : 32;
  99. u64 isliba;
  100. u64 osliba;
  101. u32 : 32;
  102. u32 : 32;
  103. u8 ebcnam[8];
  104. /* private: */
  105. u8 res[88];
  106. /* public: */
  107. u8 parm[QDIO_MAX_BUFFERS_PER_Q];
  108. } __attribute__ ((packed, aligned(256)));
  109. /**
  110. * struct slibe - storage list information block element (SLIBE)
  111. * @parms: implementation dependent parameters
  112. */
  113. struct slibe {
  114. u64 parms;
  115. };
  116. /**
  117. * struct slib - storage list information block (SLIB)
  118. * @nsliba: next SLIB address (if any)
  119. * @sla: SL address
  120. * @slsba: SLSB address
  121. * @slibe: SLIB elements
  122. */
  123. struct slib {
  124. u64 nsliba;
  125. u64 sla;
  126. u64 slsba;
  127. /* private: */
  128. u8 res[1000];
  129. /* public: */
  130. struct slibe slibe[QDIO_MAX_BUFFERS_PER_Q];
  131. } __attribute__ ((packed, aligned(2048)));
  132. #define SBAL_EFLAGS_LAST_ENTRY 0x40
  133. #define SBAL_EFLAGS_CONTIGUOUS 0x20
  134. #define SBAL_EFLAGS_FIRST_FRAG 0x04
  135. #define SBAL_EFLAGS_MIDDLE_FRAG 0x08
  136. #define SBAL_EFLAGS_LAST_FRAG 0x0c
  137. #define SBAL_EFLAGS_MASK 0x6f
  138. #define SBAL_SFLAGS0_PCI_REQ 0x40
  139. #define SBAL_SFLAGS0_DATA_CONTINUATION 0x20
  140. /* Awesome OpenFCP extensions */
  141. #define SBAL_SFLAGS0_TYPE_STATUS 0x00
  142. #define SBAL_SFLAGS0_TYPE_WRITE 0x08
  143. #define SBAL_SFLAGS0_TYPE_READ 0x10
  144. #define SBAL_SFLAGS0_TYPE_WRITE_READ 0x18
  145. #define SBAL_SFLAGS0_MORE_SBALS 0x04
  146. #define SBAL_SFLAGS0_COMMAND 0x02
  147. #define SBAL_SFLAGS0_LAST_SBAL 0x00
  148. #define SBAL_SFLAGS0_ONLY_SBAL SBAL_SFLAGS0_COMMAND
  149. #define SBAL_SFLAGS0_MIDDLE_SBAL SBAL_SFLAGS0_MORE_SBALS
  150. #define SBAL_SFLAGS0_FIRST_SBAL (SBAL_SFLAGS0_MORE_SBALS | SBAL_SFLAGS0_COMMAND)
  151. /**
  152. * struct qdio_buffer_element - SBAL entry
  153. * @eflags: SBAL entry flags
  154. * @scount: SBAL count
  155. * @sflags: whole SBAL flags
  156. * @length: length
  157. * @addr: address
  158. */
  159. struct qdio_buffer_element {
  160. u8 eflags;
  161. /* private: */
  162. u8 res1;
  163. /* public: */
  164. u8 scount;
  165. u8 sflags;
  166. u32 length;
  167. #ifdef CONFIG_32BIT
  168. /* private: */
  169. void *res2;
  170. /* public: */
  171. #endif
  172. void *addr;
  173. } __attribute__ ((packed, aligned(16)));
  174. /**
  175. * struct qdio_buffer - storage block address list (SBAL)
  176. * @element: SBAL entries
  177. */
  178. struct qdio_buffer {
  179. struct qdio_buffer_element element[QDIO_MAX_ELEMENTS_PER_BUFFER];
  180. } __attribute__ ((packed, aligned(256)));
  181. /**
  182. * struct sl_element - storage list entry
  183. * @sbal: absolute SBAL address
  184. */
  185. struct sl_element {
  186. #ifdef CONFIG_32BIT
  187. /* private: */
  188. unsigned long reserved;
  189. /* public: */
  190. #endif
  191. unsigned long sbal;
  192. } __attribute__ ((packed));
  193. /**
  194. * struct sl - storage list (SL)
  195. * @element: SL entries
  196. */
  197. struct sl {
  198. struct sl_element element[QDIO_MAX_BUFFERS_PER_Q];
  199. } __attribute__ ((packed, aligned(1024)));
  200. /**
  201. * struct slsb - storage list state block (SLSB)
  202. * @val: state per buffer
  203. */
  204. struct slsb {
  205. u8 val[QDIO_MAX_BUFFERS_PER_Q];
  206. } __attribute__ ((packed, aligned(256)));
  207. #define CHSC_AC2_DATA_DIV_AVAILABLE 0x0010
  208. #define CHSC_AC2_DATA_DIV_ENABLED 0x0002
  209. struct qdio_ssqd_desc {
  210. u8 flags;
  211. u8:8;
  212. u16 sch;
  213. u8 qfmt;
  214. u8 parm;
  215. u8 qdioac1;
  216. u8 sch_class;
  217. u8 pcnt;
  218. u8 icnt;
  219. u8:8;
  220. u8 ocnt;
  221. u8:8;
  222. u8 mbccnt;
  223. u16 qdioac2;
  224. u64 sch_token;
  225. u8 mro;
  226. u8 mri;
  227. u8:8;
  228. u8 sbalic;
  229. u16:16;
  230. u8:8;
  231. u8 mmwc;
  232. } __attribute__ ((packed));
  233. /* params are: ccw_device, qdio_error, queue_number,
  234. first element processed, number of elements processed, int_parm */
  235. typedef void qdio_handler_t(struct ccw_device *, unsigned int, int,
  236. int, int, unsigned long);
  237. /* qdio errors reported to the upper-layer program */
  238. #define QDIO_ERROR_SIGA_TARGET 0x02
  239. #define QDIO_ERROR_SIGA_ACCESS_EXCEPTION 0x10
  240. #define QDIO_ERROR_SIGA_BUSY 0x20
  241. #define QDIO_ERROR_ACTIVATE_CHECK_CONDITION 0x40
  242. #define QDIO_ERROR_SLSB_STATE 0x80
  243. /* for qdio_cleanup */
  244. #define QDIO_FLAG_CLEANUP_USING_CLEAR 0x01
  245. #define QDIO_FLAG_CLEANUP_USING_HALT 0x02
  246. /**
  247. * struct qdio_initialize - qdio initalization data
  248. * @cdev: associated ccw device
  249. * @q_format: queue format
  250. * @adapter_name: name for the adapter
  251. * @qib_param_field_format: format for qib_parm_field
  252. * @qib_param_field: pointer to 128 bytes or NULL, if no param field
  253. * @qib_rflags: rflags to set
  254. * @input_slib_elements: pointer to no_input_qs * 128 words of data or NULL
  255. * @output_slib_elements: pointer to no_output_qs * 128 words of data or NULL
  256. * @no_input_qs: number of input queues
  257. * @no_output_qs: number of output queues
  258. * @input_handler: handler to be called for input queues
  259. * @output_handler: handler to be called for output queues
  260. * @int_parm: interruption parameter
  261. * @input_sbal_addr_array: address of no_input_qs * 128 pointers
  262. * @output_sbal_addr_array: address of no_output_qs * 128 pointers
  263. */
  264. struct qdio_initialize {
  265. struct ccw_device *cdev;
  266. unsigned char q_format;
  267. unsigned char adapter_name[8];
  268. unsigned int qib_param_field_format;
  269. unsigned char *qib_param_field;
  270. unsigned char qib_rflags;
  271. unsigned long *input_slib_elements;
  272. unsigned long *output_slib_elements;
  273. unsigned int no_input_qs;
  274. unsigned int no_output_qs;
  275. qdio_handler_t *input_handler;
  276. qdio_handler_t *output_handler;
  277. void (*queue_start_poll) (struct ccw_device *, int, unsigned long);
  278. int scan_threshold;
  279. unsigned long int_parm;
  280. void **input_sbal_addr_array;
  281. void **output_sbal_addr_array;
  282. };
  283. #define QDIO_STATE_INACTIVE 0x00000002 /* after qdio_cleanup */
  284. #define QDIO_STATE_ESTABLISHED 0x00000004 /* after qdio_establish */
  285. #define QDIO_STATE_ACTIVE 0x00000008 /* after qdio_activate */
  286. #define QDIO_STATE_STOPPED 0x00000010 /* after queues went down */
  287. #define QDIO_FLAG_SYNC_INPUT 0x01
  288. #define QDIO_FLAG_SYNC_OUTPUT 0x02
  289. #define QDIO_FLAG_PCI_OUT 0x10
  290. extern int qdio_allocate(struct qdio_initialize *);
  291. extern int qdio_establish(struct qdio_initialize *);
  292. extern int qdio_activate(struct ccw_device *);
  293. extern int do_QDIO(struct ccw_device *, unsigned int, int, unsigned int,
  294. unsigned int);
  295. extern int qdio_start_irq(struct ccw_device *, int);
  296. extern int qdio_stop_irq(struct ccw_device *, int);
  297. extern int qdio_get_next_buffers(struct ccw_device *, int, int *, int *);
  298. extern int qdio_shutdown(struct ccw_device *, int);
  299. extern int qdio_free(struct ccw_device *);
  300. extern int qdio_get_ssqd_desc(struct ccw_device *, struct qdio_ssqd_desc *);
  301. #endif /* __QDIO_H__ */