qdio.h 13 KB

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