qdio.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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 qaob - queue asynchronous operation block
  119. * @res0: reserved parameters
  120. * @res1: reserved parameter
  121. * @res2: reserved parameter
  122. * @res3: reserved parameter
  123. * @aorc: asynchronous operation return code
  124. * @flags: internal flags
  125. * @cbtbs: control block type
  126. * @sb_count: number of storage blocks
  127. * @sba: storage block element addresses
  128. * @dcount: size of storage block elements
  129. * @user0: user defineable value
  130. * @res4: reserved paramater
  131. * @user1: user defineable value
  132. * @user2: user defineable value
  133. */
  134. struct qaob {
  135. u64 res0[6];
  136. u8 res1;
  137. u8 res2;
  138. u8 res3;
  139. u8 aorc;
  140. u8 flags;
  141. u16 cbtbs;
  142. u8 sb_count;
  143. u64 sba[QDIO_MAX_ELEMENTS_PER_BUFFER];
  144. u16 dcount[QDIO_MAX_ELEMENTS_PER_BUFFER];
  145. u64 user0;
  146. u64 res4[2];
  147. u64 user1;
  148. u64 user2;
  149. } __attribute__ ((packed, aligned(256)));
  150. /**
  151. * struct slib - storage list information block (SLIB)
  152. * @nsliba: next SLIB address (if any)
  153. * @sla: SL address
  154. * @slsba: SLSB address
  155. * @slibe: SLIB elements
  156. */
  157. struct slib {
  158. u64 nsliba;
  159. u64 sla;
  160. u64 slsba;
  161. /* private: */
  162. u8 res[1000];
  163. /* public: */
  164. struct slibe slibe[QDIO_MAX_BUFFERS_PER_Q];
  165. } __attribute__ ((packed, aligned(2048)));
  166. #define SBAL_EFLAGS_LAST_ENTRY 0x40
  167. #define SBAL_EFLAGS_CONTIGUOUS 0x20
  168. #define SBAL_EFLAGS_FIRST_FRAG 0x04
  169. #define SBAL_EFLAGS_MIDDLE_FRAG 0x08
  170. #define SBAL_EFLAGS_LAST_FRAG 0x0c
  171. #define SBAL_EFLAGS_MASK 0x6f
  172. #define SBAL_SFLAGS0_PCI_REQ 0x40
  173. #define SBAL_SFLAGS0_DATA_CONTINUATION 0x20
  174. /* Awesome OpenFCP extensions */
  175. #define SBAL_SFLAGS0_TYPE_STATUS 0x00
  176. #define SBAL_SFLAGS0_TYPE_WRITE 0x08
  177. #define SBAL_SFLAGS0_TYPE_READ 0x10
  178. #define SBAL_SFLAGS0_TYPE_WRITE_READ 0x18
  179. #define SBAL_SFLAGS0_MORE_SBALS 0x04
  180. #define SBAL_SFLAGS0_COMMAND 0x02
  181. #define SBAL_SFLAGS0_LAST_SBAL 0x00
  182. #define SBAL_SFLAGS0_ONLY_SBAL SBAL_SFLAGS0_COMMAND
  183. #define SBAL_SFLAGS0_MIDDLE_SBAL SBAL_SFLAGS0_MORE_SBALS
  184. #define SBAL_SFLAGS0_FIRST_SBAL (SBAL_SFLAGS0_MORE_SBALS | SBAL_SFLAGS0_COMMAND)
  185. /**
  186. * struct qdio_buffer_element - SBAL entry
  187. * @eflags: SBAL entry flags
  188. * @scount: SBAL count
  189. * @sflags: whole SBAL flags
  190. * @length: length
  191. * @addr: address
  192. */
  193. struct qdio_buffer_element {
  194. u8 eflags;
  195. /* private: */
  196. u8 res1;
  197. /* public: */
  198. u8 scount;
  199. u8 sflags;
  200. u32 length;
  201. #ifdef CONFIG_32BIT
  202. /* private: */
  203. void *res2;
  204. /* public: */
  205. #endif
  206. void *addr;
  207. } __attribute__ ((packed, aligned(16)));
  208. /**
  209. * struct qdio_buffer - storage block address list (SBAL)
  210. * @element: SBAL entries
  211. */
  212. struct qdio_buffer {
  213. struct qdio_buffer_element element[QDIO_MAX_ELEMENTS_PER_BUFFER];
  214. } __attribute__ ((packed, aligned(256)));
  215. /**
  216. * struct sl_element - storage list entry
  217. * @sbal: absolute SBAL address
  218. */
  219. struct sl_element {
  220. #ifdef CONFIG_32BIT
  221. /* private: */
  222. unsigned long reserved;
  223. /* public: */
  224. #endif
  225. unsigned long sbal;
  226. } __attribute__ ((packed));
  227. /**
  228. * struct sl - storage list (SL)
  229. * @element: SL entries
  230. */
  231. struct sl {
  232. struct sl_element element[QDIO_MAX_BUFFERS_PER_Q];
  233. } __attribute__ ((packed, aligned(1024)));
  234. /**
  235. * struct slsb - storage list state block (SLSB)
  236. * @val: state per buffer
  237. */
  238. struct slsb {
  239. u8 val[QDIO_MAX_BUFFERS_PER_Q];
  240. } __attribute__ ((packed, aligned(256)));
  241. #define CHSC_AC2_MULTI_BUFFER_AVAILABLE 0x0080
  242. #define CHSC_AC2_MULTI_BUFFER_ENABLED 0x0040
  243. #define CHSC_AC2_DATA_DIV_AVAILABLE 0x0010
  244. #define CHSC_AC2_DATA_DIV_ENABLED 0x0002
  245. /**
  246. * struct qdio_outbuf_state - SBAL related asynchronous operation information
  247. * (for communication with upper layer programs)
  248. * (only required for use with completion queues)
  249. * @flags: flags indicating state of buffer
  250. * @aob: pointer to QAOB used for the particular SBAL
  251. * @user: pointer to upper layer program's state information related to SBAL
  252. * (stored in user1 data of QAOB)
  253. */
  254. struct qdio_outbuf_state {
  255. u8 flags;
  256. struct qaob *aob;
  257. void *user;
  258. };
  259. #define QDIO_OUTBUF_STATE_FLAG_NONE 0x00
  260. #define QDIO_OUTBUF_STATE_FLAG_PENDING 0x01
  261. #define CHSC_AC1_INITIATE_INPUTQ 0x80
  262. /* qdio adapter-characteristics-1 flag */
  263. #define AC1_SIGA_INPUT_NEEDED 0x40 /* process input queues */
  264. #define AC1_SIGA_OUTPUT_NEEDED 0x20 /* process output queues */
  265. #define AC1_SIGA_SYNC_NEEDED 0x10 /* ask hypervisor to sync */
  266. #define AC1_AUTOMATIC_SYNC_ON_THININT 0x08 /* set by hypervisor */
  267. #define AC1_AUTOMATIC_SYNC_ON_OUT_PCI 0x04 /* set by hypervisor */
  268. #define AC1_SC_QEBSM_AVAILABLE 0x02 /* available for subchannel */
  269. #define AC1_SC_QEBSM_ENABLED 0x01 /* enabled for subchannel */
  270. #define CHSC_AC2_DATA_DIV_AVAILABLE 0x0010
  271. #define CHSC_AC2_DATA_DIV_ENABLED 0x0002
  272. #define CHSC_AC3_FORMAT2_CQ_AVAILABLE 0x8000
  273. struct qdio_ssqd_desc {
  274. u8 flags;
  275. u8:8;
  276. u16 sch;
  277. u8 qfmt;
  278. u8 parm;
  279. u8 qdioac1;
  280. u8 sch_class;
  281. u8 pcnt;
  282. u8 icnt;
  283. u8:8;
  284. u8 ocnt;
  285. u8:8;
  286. u8 mbccnt;
  287. u16 qdioac2;
  288. u64 sch_token;
  289. u8 mro;
  290. u8 mri;
  291. u16 qdioac3;
  292. u16:16;
  293. u8:8;
  294. u8 mmwc;
  295. } __attribute__ ((packed));
  296. /* params are: ccw_device, qdio_error, queue_number,
  297. first element processed, number of elements processed, int_parm */
  298. typedef void qdio_handler_t(struct ccw_device *, unsigned int, int,
  299. int, int, unsigned long);
  300. /* qdio errors reported to the upper-layer program */
  301. #define QDIO_ERROR_SIGA_TARGET 0x02
  302. #define QDIO_ERROR_SIGA_ACCESS_EXCEPTION 0x10
  303. #define QDIO_ERROR_SIGA_BUSY 0x20
  304. #define QDIO_ERROR_ACTIVATE_CHECK_CONDITION 0x40
  305. #define QDIO_ERROR_SLSB_STATE 0x80
  306. /* for qdio_cleanup */
  307. #define QDIO_FLAG_CLEANUP_USING_CLEAR 0x01
  308. #define QDIO_FLAG_CLEANUP_USING_HALT 0x02
  309. /**
  310. * struct qdio_initialize - qdio initalization data
  311. * @cdev: associated ccw device
  312. * @q_format: queue format
  313. * @adapter_name: name for the adapter
  314. * @qib_param_field_format: format for qib_parm_field
  315. * @qib_param_field: pointer to 128 bytes or NULL, if no param field
  316. * @qib_rflags: rflags to set
  317. * @input_slib_elements: pointer to no_input_qs * 128 words of data or NULL
  318. * @output_slib_elements: pointer to no_output_qs * 128 words of data or NULL
  319. * @no_input_qs: number of input queues
  320. * @no_output_qs: number of output queues
  321. * @input_handler: handler to be called for input queues
  322. * @output_handler: handler to be called for output queues
  323. * @queue_start_poll_array: polling handlers (one per input queue or NULL)
  324. * @int_parm: interruption parameter
  325. * @input_sbal_addr_array: address of no_input_qs * 128 pointers
  326. * @output_sbal_addr_array: address of no_output_qs * 128 pointers
  327. * @output_sbal_state_array: no_output_qs * 128 state info (for CQ or NULL)
  328. */
  329. struct qdio_initialize {
  330. struct ccw_device *cdev;
  331. unsigned char q_format;
  332. unsigned char qdr_ac;
  333. unsigned char adapter_name[8];
  334. unsigned int qib_param_field_format;
  335. unsigned char *qib_param_field;
  336. unsigned char qib_rflags;
  337. unsigned long *input_slib_elements;
  338. unsigned long *output_slib_elements;
  339. unsigned int no_input_qs;
  340. unsigned int no_output_qs;
  341. qdio_handler_t *input_handler;
  342. qdio_handler_t *output_handler;
  343. void (**queue_start_poll_array) (struct ccw_device *, int,
  344. unsigned long);
  345. int scan_threshold;
  346. unsigned long int_parm;
  347. void **input_sbal_addr_array;
  348. void **output_sbal_addr_array;
  349. struct qdio_outbuf_state *output_sbal_state_array;
  350. };
  351. #define QDIO_STATE_INACTIVE 0x00000002 /* after qdio_cleanup */
  352. #define QDIO_STATE_ESTABLISHED 0x00000004 /* after qdio_establish */
  353. #define QDIO_STATE_ACTIVE 0x00000008 /* after qdio_activate */
  354. #define QDIO_STATE_STOPPED 0x00000010 /* after queues went down */
  355. #define QDIO_FLAG_SYNC_INPUT 0x01
  356. #define QDIO_FLAG_SYNC_OUTPUT 0x02
  357. #define QDIO_FLAG_PCI_OUT 0x10
  358. extern int qdio_allocate(struct qdio_initialize *);
  359. extern int qdio_establish(struct qdio_initialize *);
  360. extern int qdio_activate(struct ccw_device *);
  361. extern void qdio_release_aob(struct qaob *);
  362. extern int do_QDIO(struct ccw_device *, unsigned int, int, unsigned int,
  363. unsigned int);
  364. extern int qdio_start_irq(struct ccw_device *, int);
  365. extern int qdio_stop_irq(struct ccw_device *, int);
  366. extern int qdio_get_next_buffers(struct ccw_device *, int, int *, int *);
  367. extern int qdio_shutdown(struct ccw_device *, int);
  368. extern int qdio_free(struct ccw_device *);
  369. extern int qdio_get_ssqd_desc(struct ccw_device *, struct qdio_ssqd_desc *);
  370. #endif /* __QDIO_H__ */