qdio.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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. /**
  133. * struct sbal_flags - storage block address list flags
  134. * @last: last entry
  135. * @cont: contiguous storage
  136. * @frag: fragmentation
  137. */
  138. struct sbal_flags {
  139. u8 : 1;
  140. u8 last : 1;
  141. u8 cont : 1;
  142. u8 : 1;
  143. u8 frag : 2;
  144. u8 : 2;
  145. } __attribute__ ((packed));
  146. #define SBAL_FLAGS_FIRST_FRAG 0x04000000UL
  147. #define SBAL_FLAGS_MIDDLE_FRAG 0x08000000UL
  148. #define SBAL_FLAGS_LAST_FRAG 0x0c000000UL
  149. #define SBAL_FLAGS_LAST_ENTRY 0x40000000UL
  150. #define SBAL_FLAGS_CONTIGUOUS 0x20000000UL
  151. #define SBAL_FLAGS0_DATA_CONTINUATION 0x20UL
  152. /* Awesome OpenFCP extensions */
  153. #define SBAL_FLAGS0_TYPE_STATUS 0x00UL
  154. #define SBAL_FLAGS0_TYPE_WRITE 0x08UL
  155. #define SBAL_FLAGS0_TYPE_READ 0x10UL
  156. #define SBAL_FLAGS0_TYPE_WRITE_READ 0x18UL
  157. #define SBAL_FLAGS0_MORE_SBALS 0x04UL
  158. #define SBAL_FLAGS0_COMMAND 0x02UL
  159. #define SBAL_FLAGS0_LAST_SBAL 0x00UL
  160. #define SBAL_FLAGS0_ONLY_SBAL SBAL_FLAGS0_COMMAND
  161. #define SBAL_FLAGS0_MIDDLE_SBAL SBAL_FLAGS0_MORE_SBALS
  162. #define SBAL_FLAGS0_FIRST_SBAL SBAL_FLAGS0_MORE_SBALS | SBAL_FLAGS0_COMMAND
  163. #define SBAL_FLAGS0_PCI 0x40
  164. /**
  165. * struct sbal_sbalf_0 - sbal flags for sbale 0
  166. * @pci: PCI indicator
  167. * @cont: data continuation
  168. * @sbtype: storage-block type (FCP)
  169. */
  170. struct sbal_sbalf_0 {
  171. u8 : 1;
  172. u8 pci : 1;
  173. u8 cont : 1;
  174. u8 sbtype : 2;
  175. u8 : 3;
  176. } __attribute__ ((packed));
  177. /**
  178. * struct sbal_sbalf_1 - sbal flags for sbale 1
  179. * @key: storage key
  180. */
  181. struct sbal_sbalf_1 {
  182. u8 : 4;
  183. u8 key : 4;
  184. } __attribute__ ((packed));
  185. /**
  186. * struct sbal_sbalf_14 - sbal flags for sbale 14
  187. * @erridx: error index
  188. */
  189. struct sbal_sbalf_14 {
  190. u8 : 4;
  191. u8 erridx : 4;
  192. } __attribute__ ((packed));
  193. /**
  194. * struct sbal_sbalf_15 - sbal flags for sbale 15
  195. * @reason: reason for error state
  196. */
  197. struct sbal_sbalf_15 {
  198. u8 reason;
  199. } __attribute__ ((packed));
  200. /**
  201. * union sbal_sbalf - storage block address list flags
  202. * @i0: sbalf0
  203. * @i1: sbalf1
  204. * @i14: sbalf14
  205. * @i15: sblaf15
  206. * @value: raw value
  207. */
  208. union sbal_sbalf {
  209. struct sbal_sbalf_0 i0;
  210. struct sbal_sbalf_1 i1;
  211. struct sbal_sbalf_14 i14;
  212. struct sbal_sbalf_15 i15;
  213. u8 value;
  214. };
  215. /**
  216. * struct qdio_buffer_element - SBAL entry
  217. * @flags: flags
  218. * @length: length
  219. * @addr: address
  220. */
  221. struct qdio_buffer_element {
  222. u32 flags;
  223. u32 length;
  224. #ifdef CONFIG_32BIT
  225. /* private: */
  226. void *reserved;
  227. /* public: */
  228. #endif
  229. void *addr;
  230. } __attribute__ ((packed, aligned(16)));
  231. /**
  232. * struct qdio_buffer - storage block address list (SBAL)
  233. * @element: SBAL entries
  234. */
  235. struct qdio_buffer {
  236. struct qdio_buffer_element element[QDIO_MAX_ELEMENTS_PER_BUFFER];
  237. } __attribute__ ((packed, aligned(256)));
  238. /**
  239. * struct sl_element - storage list entry
  240. * @sbal: absolute SBAL address
  241. */
  242. struct sl_element {
  243. #ifdef CONFIG_32BIT
  244. /* private: */
  245. unsigned long reserved;
  246. /* public: */
  247. #endif
  248. unsigned long sbal;
  249. } __attribute__ ((packed));
  250. /**
  251. * struct sl - storage list (SL)
  252. * @element: SL entries
  253. */
  254. struct sl {
  255. struct sl_element element[QDIO_MAX_BUFFERS_PER_Q];
  256. } __attribute__ ((packed, aligned(1024)));
  257. /**
  258. * struct slsb - storage list state block (SLSB)
  259. * @val: state per buffer
  260. */
  261. struct slsb {
  262. u8 val[QDIO_MAX_BUFFERS_PER_Q];
  263. } __attribute__ ((packed, aligned(256)));
  264. #define CHSC_AC2_DATA_DIV_AVAILABLE 0x0010
  265. #define CHSC_AC2_DATA_DIV_ENABLED 0x0002
  266. struct qdio_ssqd_desc {
  267. u8 flags;
  268. u8:8;
  269. u16 sch;
  270. u8 qfmt;
  271. u8 parm;
  272. u8 qdioac1;
  273. u8 sch_class;
  274. u8 pcnt;
  275. u8 icnt;
  276. u8:8;
  277. u8 ocnt;
  278. u8:8;
  279. u8 mbccnt;
  280. u16 qdioac2;
  281. u64 sch_token;
  282. u8 mro;
  283. u8 mri;
  284. u8:8;
  285. u8 sbalic;
  286. u16:16;
  287. u8:8;
  288. u8 mmwc;
  289. } __attribute__ ((packed));
  290. /* params are: ccw_device, qdio_error, queue_number,
  291. first element processed, number of elements processed, int_parm */
  292. typedef void qdio_handler_t(struct ccw_device *, unsigned int, int,
  293. int, int, unsigned long);
  294. /* qdio errors reported to the upper-layer program */
  295. #define QDIO_ERROR_SIGA_TARGET 0x02
  296. #define QDIO_ERROR_SIGA_ACCESS_EXCEPTION 0x10
  297. #define QDIO_ERROR_SIGA_BUSY 0x20
  298. #define QDIO_ERROR_ACTIVATE_CHECK_CONDITION 0x40
  299. #define QDIO_ERROR_SLSB_STATE 0x80
  300. /* for qdio_cleanup */
  301. #define QDIO_FLAG_CLEANUP_USING_CLEAR 0x01
  302. #define QDIO_FLAG_CLEANUP_USING_HALT 0x02
  303. /**
  304. * struct qdio_initialize - qdio initalization data
  305. * @cdev: associated ccw device
  306. * @q_format: queue format
  307. * @adapter_name: name for the adapter
  308. * @qib_param_field_format: format for qib_parm_field
  309. * @qib_param_field: pointer to 128 bytes or NULL, if no param field
  310. * @qib_rflags: rflags to set
  311. * @input_slib_elements: pointer to no_input_qs * 128 words of data or NULL
  312. * @output_slib_elements: pointer to no_output_qs * 128 words of data or NULL
  313. * @no_input_qs: number of input queues
  314. * @no_output_qs: number of output queues
  315. * @input_handler: handler to be called for input queues
  316. * @output_handler: handler to be called for output queues
  317. * @int_parm: interruption parameter
  318. * @input_sbal_addr_array: address of no_input_qs * 128 pointers
  319. * @output_sbal_addr_array: address of no_output_qs * 128 pointers
  320. */
  321. struct qdio_initialize {
  322. struct ccw_device *cdev;
  323. unsigned char q_format;
  324. unsigned char adapter_name[8];
  325. unsigned int qib_param_field_format;
  326. unsigned char *qib_param_field;
  327. unsigned char qib_rflags;
  328. unsigned long *input_slib_elements;
  329. unsigned long *output_slib_elements;
  330. unsigned int no_input_qs;
  331. unsigned int no_output_qs;
  332. qdio_handler_t *input_handler;
  333. qdio_handler_t *output_handler;
  334. void (*queue_start_poll) (struct ccw_device *, int, unsigned long);
  335. int scan_threshold;
  336. unsigned long int_parm;
  337. void **input_sbal_addr_array;
  338. void **output_sbal_addr_array;
  339. };
  340. #define QDIO_STATE_INACTIVE 0x00000002 /* after qdio_cleanup */
  341. #define QDIO_STATE_ESTABLISHED 0x00000004 /* after qdio_establish */
  342. #define QDIO_STATE_ACTIVE 0x00000008 /* after qdio_activate */
  343. #define QDIO_STATE_STOPPED 0x00000010 /* after queues went down */
  344. #define QDIO_FLAG_SYNC_INPUT 0x01
  345. #define QDIO_FLAG_SYNC_OUTPUT 0x02
  346. #define QDIO_FLAG_PCI_OUT 0x10
  347. extern int qdio_allocate(struct qdio_initialize *);
  348. extern int qdio_establish(struct qdio_initialize *);
  349. extern int qdio_activate(struct ccw_device *);
  350. extern int do_QDIO(struct ccw_device *, unsigned int, int, unsigned int,
  351. unsigned int);
  352. extern int qdio_start_irq(struct ccw_device *, int);
  353. extern int qdio_stop_irq(struct ccw_device *, int);
  354. extern int qdio_get_next_buffers(struct ccw_device *, int, int *, int *);
  355. extern int qdio_shutdown(struct ccw_device *, int);
  356. extern int qdio_free(struct ccw_device *);
  357. extern int qdio_get_ssqd_desc(struct ccw_device *, struct qdio_ssqd_desc *);
  358. #endif /* __QDIO_H__ */