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. #define VERSION_QDIO_H "$Revision: 1.57 $"
  14. /* note, that most of the typedef's are from ingo. */
  15. #include <linux/interrupt.h>
  16. #include <asm/cio.h>
  17. #include <asm/ccwdev.h>
  18. #define QDIO_NAME "qdio "
  19. #ifndef __s390x__
  20. #define QDIO_32_BIT
  21. #endif /* __s390x__ */
  22. /**** CONSTANTS, that are relied on without using these symbols *****/
  23. #define QDIO_MAX_QUEUES_PER_IRQ 32 /* used in width of unsigned int */
  24. /************************ END of CONSTANTS **************************/
  25. #define QDIO_MAX_BUFFERS_PER_Q 128 /* must be a power of 2 (%x=&(x-1)*/
  26. #define QDIO_BUF_ORDER 7 /* 2**this == number of pages used for sbals in 1 q */
  27. #define QDIO_MAX_ELEMENTS_PER_BUFFER 16
  28. #define SBAL_SIZE 256
  29. #define QDIO_QETH_QFMT 0
  30. #define QDIO_ZFCP_QFMT 1
  31. #define QDIO_IQDIO_QFMT 2
  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. extern int do_QDIO(struct ccw_device*, unsigned int flags,
  103. unsigned int queue_number,
  104. unsigned int qidx,unsigned int count,
  105. struct qdio_buffer *buffers);
  106. extern int qdio_synchronize(struct ccw_device*, unsigned int flags,
  107. unsigned int queue_number);
  108. extern int qdio_cleanup(struct ccw_device*, int how);
  109. extern int qdio_shutdown(struct ccw_device*, int how);
  110. extern int qdio_free(struct ccw_device*);
  111. unsigned char qdio_get_slsb_state(struct ccw_device*, unsigned int flag,
  112. unsigned int queue_number,
  113. unsigned int qidx);
  114. extern void qdio_init_scrubber(void);
  115. struct qdesfmt0 {
  116. #ifdef QDIO_32_BIT
  117. unsigned long res1; /* reserved */
  118. #endif /* QDIO_32_BIT */
  119. unsigned long sliba; /* storage-list-information-block
  120. address */
  121. #ifdef QDIO_32_BIT
  122. unsigned long res2; /* reserved */
  123. #endif /* QDIO_32_BIT */
  124. unsigned long sla; /* storage-list address */
  125. #ifdef QDIO_32_BIT
  126. unsigned long res3; /* reserved */
  127. #endif /* QDIO_32_BIT */
  128. unsigned long slsba; /* storage-list-state-block address */
  129. unsigned int res4; /* reserved */
  130. unsigned int akey : 4; /* access key for DLIB */
  131. unsigned int bkey : 4; /* access key for SL */
  132. unsigned int ckey : 4; /* access key for SBALs */
  133. unsigned int dkey : 4; /* access key for SLSB */
  134. unsigned int res5 : 16; /* reserved */
  135. } __attribute__ ((packed));
  136. /*
  137. * Queue-Description record (QDR)
  138. */
  139. struct qdr {
  140. unsigned int qfmt : 8; /* queue format */
  141. unsigned int pfmt : 8; /* impl. dep. parameter format */
  142. unsigned int res1 : 8; /* reserved */
  143. unsigned int ac : 8; /* adapter characteristics */
  144. unsigned int res2 : 8; /* reserved */
  145. unsigned int iqdcnt : 8; /* input-queue-descriptor count */
  146. unsigned int res3 : 8; /* reserved */
  147. unsigned int oqdcnt : 8; /* output-queue-descriptor count */
  148. unsigned int res4 : 8; /* reserved */
  149. unsigned int iqdsz : 8; /* input-queue-descriptor size */
  150. unsigned int res5 : 8; /* reserved */
  151. unsigned int oqdsz : 8; /* output-queue-descriptor size */
  152. unsigned int res6[9]; /* reserved */
  153. #ifdef QDIO_32_BIT
  154. unsigned long res7; /* reserved */
  155. #endif /* QDIO_32_BIT */
  156. unsigned long qiba; /* queue-information-block address */
  157. unsigned int res8; /* reserved */
  158. unsigned int qkey : 4; /* queue-informatio-block key */
  159. unsigned int res9 : 28; /* reserved */
  160. /* union _qd {*/ /* why this? */
  161. struct qdesfmt0 qdf0[126];
  162. /* } qd;*/
  163. } __attribute__ ((packed,aligned(4096)));
  164. /*
  165. * queue information block (QIB)
  166. */
  167. #define QIB_AC_INBOUND_PCI_SUPPORTED 0x80
  168. #define QIB_AC_OUTBOUND_PCI_SUPPORTED 0x40
  169. struct qib {
  170. unsigned int qfmt : 8; /* queue format */
  171. unsigned int pfmt : 8; /* impl. dep. parameter format */
  172. unsigned int res1 : 8; /* reserved */
  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__ */