qdio.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. /*
  2. * linux/include/asm-s390/qdio.h
  3. *
  4. * Linux for S/390 QDIO base support, Hipersocket base support
  5. * version 2
  6. *
  7. * Copyright 2000,2002 IBM Corporation
  8. * Author(s): Utz Bacher <utz.bacher@de.ibm.com>
  9. *
  10. */
  11. #ifndef __QDIO_H__
  12. #define __QDIO_H__
  13. /* note, that most of the typedef's are from ingo. */
  14. #include <linux/interrupt.h>
  15. #include <asm/cio.h>
  16. #include <asm/ccwdev.h>
  17. #define QDIO_NAME "qdio "
  18. #ifndef __s390x__
  19. #define QDIO_32_BIT
  20. #endif /* __s390x__ */
  21. /**** CONSTANTS, that are relied on without using these symbols *****/
  22. #define QDIO_MAX_QUEUES_PER_IRQ 32 /* used in width of unsigned int */
  23. /************************ END of CONSTANTS **************************/
  24. #define QDIO_MAX_BUFFERS_PER_Q 128 /* must be a power of 2 (%x=&(x-1)*/
  25. #define QDIO_BUF_ORDER 7 /* 2**this == number of pages used for sbals in 1 q */
  26. #define QDIO_MAX_ELEMENTS_PER_BUFFER 16
  27. #define SBAL_SIZE 256
  28. #define QDIO_QETH_QFMT 0
  29. #define QDIO_ZFCP_QFMT 1
  30. #define QDIO_IQDIO_QFMT 2
  31. #define QDIO_IQDIO_QFMT_ASYNCH 3
  32. struct qdio_buffer_element{
  33. unsigned int flags;
  34. unsigned int length;
  35. #ifdef QDIO_32_BIT
  36. void *reserved;
  37. #endif /* QDIO_32_BIT */
  38. void *addr;
  39. } __attribute__ ((packed,aligned(16)));
  40. struct qdio_buffer{
  41. volatile struct qdio_buffer_element element[16];
  42. } __attribute__ ((packed,aligned(256)));
  43. /* params are: ccw_device, status, qdio_error, siga_error,
  44. queue_number, first element processed, number of elements processed,
  45. int_parm */
  46. typedef void qdio_handler_t(struct ccw_device *,unsigned int,unsigned int,
  47. unsigned int,unsigned int,int,int,unsigned long);
  48. #define QDIO_STATUS_INBOUND_INT 0x01
  49. #define QDIO_STATUS_OUTBOUND_INT 0x02
  50. #define QDIO_STATUS_LOOK_FOR_ERROR 0x04
  51. #define QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR 0x08
  52. #define QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR 0x10
  53. #define QDIO_STATUS_ACTIVATE_CHECK_CONDITION 0x20
  54. #define QDIO_SIGA_ERROR_ACCESS_EXCEPTION 0x10
  55. #define QDIO_SIGA_ERROR_B_BIT_SET 0x20
  56. /* for qdio_initialize */
  57. #define QDIO_INBOUND_0COPY_SBALS 0x01
  58. #define QDIO_OUTBOUND_0COPY_SBALS 0x02
  59. #define QDIO_USE_OUTBOUND_PCIS 0x04
  60. /* for qdio_cleanup */
  61. #define QDIO_FLAG_CLEANUP_USING_CLEAR 0x01
  62. #define QDIO_FLAG_CLEANUP_USING_HALT 0x02
  63. struct qdio_initialize {
  64. struct ccw_device *cdev;
  65. unsigned char q_format;
  66. unsigned char adapter_name[8];
  67. unsigned int qib_param_field_format; /*adapter dependent*/
  68. /* pointer to 128 bytes or NULL, if no param field */
  69. unsigned char *qib_param_field; /* adapter dependent */
  70. /* pointer to no_queues*128 words of data or NULL */
  71. unsigned long *input_slib_elements;
  72. unsigned long *output_slib_elements;
  73. unsigned int min_input_threshold;
  74. unsigned int max_input_threshold;
  75. unsigned int min_output_threshold;
  76. unsigned int max_output_threshold;
  77. unsigned int no_input_qs;
  78. unsigned int no_output_qs;
  79. qdio_handler_t *input_handler;
  80. qdio_handler_t *output_handler;
  81. unsigned long int_parm;
  82. unsigned long flags;
  83. void **input_sbal_addr_array; /* addr of n*128 void ptrs */
  84. void **output_sbal_addr_array; /* addr of n*128 void ptrs */
  85. };
  86. extern int qdio_initialize(struct qdio_initialize *init_data);
  87. extern int qdio_allocate(struct qdio_initialize *init_data);
  88. extern int qdio_establish(struct qdio_initialize *init_data);
  89. extern int qdio_activate(struct ccw_device *,int flags);
  90. #define QDIO_STATE_MUST_USE_OUTB_PCI 0x00000001
  91. #define QDIO_STATE_INACTIVE 0x00000002 /* after qdio_cleanup */
  92. #define QDIO_STATE_ESTABLISHED 0x00000004 /* after qdio_initialize */
  93. #define QDIO_STATE_ACTIVE 0x00000008 /* after qdio_activate */
  94. #define QDIO_STATE_STOPPED 0x00000010 /* after queues went down */
  95. extern unsigned long qdio_get_status(int irq);
  96. #define QDIO_FLAG_SYNC_INPUT 0x01
  97. #define QDIO_FLAG_SYNC_OUTPUT 0x02
  98. #define QDIO_FLAG_UNDER_INTERRUPT 0x04
  99. #define QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT 0x08 /* no effect on
  100. adapter interrupts */
  101. #define QDIO_FLAG_DONT_SIGA 0x10
  102. #define QDIO_FLAG_PCI_OUT 0x20
  103. extern int do_QDIO(struct ccw_device*, unsigned int flags,
  104. unsigned int queue_number,
  105. unsigned int qidx,unsigned int count,
  106. struct qdio_buffer *buffers);
  107. extern int qdio_synchronize(struct ccw_device*, unsigned int flags,
  108. unsigned int queue_number);
  109. extern int qdio_cleanup(struct ccw_device*, int how);
  110. extern int qdio_shutdown(struct ccw_device*, int how);
  111. extern int qdio_free(struct ccw_device*);
  112. unsigned char qdio_get_slsb_state(struct ccw_device*, unsigned int flag,
  113. unsigned int queue_number,
  114. unsigned int qidx);
  115. extern void qdio_init_scrubber(void);
  116. struct qdesfmt0 {
  117. #ifdef QDIO_32_BIT
  118. unsigned long res1; /* reserved */
  119. #endif /* QDIO_32_BIT */
  120. unsigned long sliba; /* storage-list-information-block
  121. address */
  122. #ifdef QDIO_32_BIT
  123. unsigned long res2; /* reserved */
  124. #endif /* QDIO_32_BIT */
  125. unsigned long sla; /* storage-list address */
  126. #ifdef QDIO_32_BIT
  127. unsigned long res3; /* reserved */
  128. #endif /* QDIO_32_BIT */
  129. unsigned long slsba; /* storage-list-state-block address */
  130. unsigned int res4; /* reserved */
  131. unsigned int akey : 4; /* access key for DLIB */
  132. unsigned int bkey : 4; /* access key for SL */
  133. unsigned int ckey : 4; /* access key for SBALs */
  134. unsigned int dkey : 4; /* access key for SLSB */
  135. unsigned int res5 : 16; /* reserved */
  136. } __attribute__ ((packed));
  137. /*
  138. * Queue-Description record (QDR)
  139. */
  140. struct qdr {
  141. unsigned int qfmt : 8; /* queue format */
  142. unsigned int pfmt : 8; /* impl. dep. parameter format */
  143. unsigned int res1 : 8; /* reserved */
  144. unsigned int ac : 8; /* adapter characteristics */
  145. unsigned int res2 : 8; /* reserved */
  146. unsigned int iqdcnt : 8; /* input-queue-descriptor count */
  147. unsigned int res3 : 8; /* reserved */
  148. unsigned int oqdcnt : 8; /* output-queue-descriptor count */
  149. unsigned int res4 : 8; /* reserved */
  150. unsigned int iqdsz : 8; /* input-queue-descriptor size */
  151. unsigned int res5 : 8; /* reserved */
  152. unsigned int oqdsz : 8; /* output-queue-descriptor size */
  153. unsigned int res6[9]; /* reserved */
  154. #ifdef QDIO_32_BIT
  155. unsigned long res7; /* reserved */
  156. #endif /* QDIO_32_BIT */
  157. unsigned long qiba; /* queue-information-block address */
  158. unsigned int res8; /* reserved */
  159. unsigned int qkey : 4; /* queue-informatio-block key */
  160. unsigned int res9 : 28; /* reserved */
  161. /* union _qd {*/ /* why this? */
  162. struct qdesfmt0 qdf0[126];
  163. /* } qd;*/
  164. } __attribute__ ((packed,aligned(4096)));
  165. /*
  166. * queue information block (QIB)
  167. */
  168. #define QIB_AC_INBOUND_PCI_SUPPORTED 0x80
  169. #define QIB_AC_OUTBOUND_PCI_SUPPORTED 0x40
  170. #define QIB_RFLAGS_ENABLE_QEBSM 0x80
  171. struct qib {
  172. unsigned int qfmt : 8; /* queue format */
  173. unsigned int pfmt : 8; /* impl. dep. parameter format */
  174. unsigned int rflags : 8; /* QEBSM */
  175. unsigned int ac : 8; /* adapter characteristics */
  176. unsigned int res2; /* reserved */
  177. #ifdef QDIO_32_BIT
  178. unsigned long res3; /* reserved */
  179. #endif /* QDIO_32_BIT */
  180. unsigned long isliba; /* absolute address of 1st
  181. input SLIB */
  182. #ifdef QDIO_32_BIT
  183. unsigned long res4; /* reserved */
  184. #endif /* QDIO_32_BIT */
  185. unsigned long osliba; /* absolute address of 1st
  186. output SLIB */
  187. unsigned int res5; /* reserved */
  188. unsigned int res6; /* reserved */
  189. unsigned char ebcnam[8]; /* adapter identifier in EBCDIC */
  190. unsigned char res7[88]; /* reserved */
  191. unsigned char parm[QDIO_MAX_BUFFERS_PER_Q];
  192. /* implementation dependent
  193. parameters */
  194. } __attribute__ ((packed,aligned(256)));
  195. /*
  196. * storage-list-information block element (SLIBE)
  197. */
  198. struct slibe {
  199. #ifdef QDIO_32_BIT
  200. unsigned long res; /* reserved */
  201. #endif /* QDIO_32_BIT */
  202. unsigned long parms; /* implementation dependent
  203. parameters */
  204. };
  205. /*
  206. * storage-list-information block (SLIB)
  207. */
  208. struct slib {
  209. #ifdef QDIO_32_BIT
  210. unsigned long res1; /* reserved */
  211. #endif /* QDIO_32_BIT */
  212. unsigned long nsliba; /* next SLIB address (if any) */
  213. #ifdef QDIO_32_BIT
  214. unsigned long res2; /* reserved */
  215. #endif /* QDIO_32_BIT */
  216. unsigned long sla; /* SL address */
  217. #ifdef QDIO_32_BIT
  218. unsigned long res3; /* reserved */
  219. #endif /* QDIO_32_BIT */
  220. unsigned long slsba; /* SLSB address */
  221. unsigned char res4[1000]; /* reserved */
  222. struct slibe slibe[QDIO_MAX_BUFFERS_PER_Q]; /* SLIB elements */
  223. } __attribute__ ((packed,aligned(2048)));
  224. struct sbal_flags {
  225. unsigned char res1 : 1; /* reserved */
  226. unsigned char last : 1; /* last entry */
  227. unsigned char cont : 1; /* contiguous storage */
  228. unsigned char res2 : 1; /* reserved */
  229. unsigned char frag : 2; /* fragmentation (s.below) */
  230. unsigned char res3 : 2; /* reserved */
  231. } __attribute__ ((packed));
  232. #define SBAL_FLAGS_FIRST_FRAG 0x04000000UL
  233. #define SBAL_FLAGS_MIDDLE_FRAG 0x08000000UL
  234. #define SBAL_FLAGS_LAST_FRAG 0x0c000000UL
  235. #define SBAL_FLAGS_LAST_ENTRY 0x40000000UL
  236. #define SBAL_FLAGS_CONTIGUOUS 0x20000000UL
  237. #define SBAL_FLAGS0_DATA_CONTINUATION 0x20UL
  238. /* Awesome OpenFCP extensions */
  239. #define SBAL_FLAGS0_TYPE_STATUS 0x00UL
  240. #define SBAL_FLAGS0_TYPE_WRITE 0x08UL
  241. #define SBAL_FLAGS0_TYPE_READ 0x10UL
  242. #define SBAL_FLAGS0_TYPE_WRITE_READ 0x18UL
  243. #define SBAL_FLAGS0_MORE_SBALS 0x04UL
  244. #define SBAL_FLAGS0_COMMAND 0x02UL
  245. #define SBAL_FLAGS0_LAST_SBAL 0x00UL
  246. #define SBAL_FLAGS0_ONLY_SBAL SBAL_FLAGS0_COMMAND
  247. #define SBAL_FLAGS0_MIDDLE_SBAL SBAL_FLAGS0_MORE_SBALS
  248. #define SBAL_FLAGS0_FIRST_SBAL SBAL_FLAGS0_MORE_SBALS | SBAL_FLAGS0_COMMAND
  249. /* Naught of interest beyond this point */
  250. #define SBAL_FLAGS0_PCI 0x40
  251. struct sbal_sbalf_0 {
  252. unsigned char res1 : 1; /* reserved */
  253. unsigned char pci : 1; /* PCI indicator */
  254. unsigned char cont : 1; /* data continuation */
  255. unsigned char sbtype: 2; /* storage-block type (OpenFCP) */
  256. unsigned char res2 : 3; /* reserved */
  257. } __attribute__ ((packed));
  258. struct sbal_sbalf_1 {
  259. unsigned char res1 : 4; /* reserved */
  260. unsigned char key : 4; /* storage key */
  261. } __attribute__ ((packed));
  262. struct sbal_sbalf_14 {
  263. unsigned char res1 : 4; /* reserved */
  264. unsigned char erridx : 4; /* error index */
  265. } __attribute__ ((packed));
  266. struct sbal_sbalf_15 {
  267. unsigned char reason; /* reserved */
  268. } __attribute__ ((packed));
  269. union sbal_sbalf {
  270. struct sbal_sbalf_0 i0;
  271. struct sbal_sbalf_1 i1;
  272. struct sbal_sbalf_14 i14;
  273. struct sbal_sbalf_15 i15;
  274. unsigned char value;
  275. };
  276. struct sbal_element {
  277. union {
  278. struct sbal_flags bits; /* flags */
  279. unsigned char value;
  280. } flags;
  281. unsigned int res1 : 16; /* reserved */
  282. union sbal_sbalf sbalf; /* SBAL flags */
  283. unsigned int res2 : 16; /* reserved */
  284. unsigned int count : 16; /* data count */
  285. #ifdef QDIO_32_BIT
  286. unsigned long res3; /* reserved */
  287. #endif /* QDIO_32_BIT */
  288. unsigned long addr; /* absolute data address */
  289. } __attribute__ ((packed,aligned(16)));
  290. /*
  291. * strorage-block access-list (SBAL)
  292. */
  293. struct sbal {
  294. struct sbal_element element[QDIO_MAX_ELEMENTS_PER_BUFFER];
  295. } __attribute__ ((packed,aligned(256)));
  296. /*
  297. * storage-list (SL)
  298. */
  299. struct sl_element {
  300. #ifdef QDIO_32_BIT
  301. unsigned long res; /* reserved */
  302. #endif /* QDIO_32_BIT */
  303. unsigned long sbal; /* absolute SBAL address */
  304. } __attribute__ ((packed));
  305. struct sl {
  306. struct sl_element element[QDIO_MAX_BUFFERS_PER_Q];
  307. } __attribute__ ((packed,aligned(1024)));
  308. /*
  309. * storage-list-state block (SLSB)
  310. */
  311. struct slsb_flags {
  312. unsigned char owner : 2; /* SBAL owner */
  313. unsigned char type : 1; /* buffer type */
  314. unsigned char state : 5; /* processing state */
  315. } __attribute__ ((packed));
  316. struct slsb {
  317. union {
  318. unsigned char val[QDIO_MAX_BUFFERS_PER_Q];
  319. struct slsb_flags flags[QDIO_MAX_BUFFERS_PER_Q];
  320. } acc;
  321. } __attribute__ ((packed,aligned(256)));
  322. /*
  323. * SLSB values
  324. */
  325. #define SLSB_OWNER_PROG 1
  326. #define SLSB_OWNER_CU 2
  327. #define SLSB_TYPE_INPUT 0
  328. #define SLSB_TYPE_OUTPUT 1
  329. #define SLSB_STATE_NOT_INIT 0
  330. #define SLSB_STATE_EMPTY 1
  331. #define SLSB_STATE_PRIMED 2
  332. #define SLSB_STATE_HALTED 0xe
  333. #define SLSB_STATE_ERROR 0xf
  334. #define SLSB_P_INPUT_NOT_INIT 0x80
  335. #define SLSB_P_INPUT_PROCESSING 0x81
  336. #define SLSB_CU_INPUT_EMPTY 0x41
  337. #define SLSB_P_INPUT_PRIMED 0x82
  338. #define SLSB_P_INPUT_HALTED 0x8E
  339. #define SLSB_P_INPUT_ERROR 0x8F
  340. #define SLSB_P_OUTPUT_NOT_INIT 0xA0
  341. #define SLSB_P_OUTPUT_EMPTY 0xA1
  342. #define SLSB_CU_OUTPUT_PRIMED 0x62
  343. #define SLSB_P_OUTPUT_HALTED 0xAE
  344. #define SLSB_P_OUTPUT_ERROR 0xAF
  345. #define SLSB_ERROR_DURING_LOOKUP 0xFF
  346. #endif /* __QDIO_H__ */