qdio.h 8.5 KB

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