2 * linux/include/asm/qdio.h
4 * Linux for S/390 QDIO base support, Hipersocket base support
7 * Copyright 2000,2002 IBM Corporation
8 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>
14 #define VERSION_QDIO_H "$Revision: 1.57.4.4 $"
16 /* note, that most of the typedef's are from ingo. */
18 #include <linux/interrupt.h>
21 //#define QDIO_DBF_LIKE_HELL
23 #define QDIO_NAME "qdio "
25 #define QDIO_VERBOSE_LEVEL 9
27 #ifndef CONFIG_ARCH_S390X
29 #endif /* CONFIG_ARCH_S390X */
31 #define QDIO_USE_PROCESSING_STATE
33 #ifdef CONFIG_QDIO_PERF_STATS
34 #define QDIO_PERFORMANCE_STATS
35 #endif /* CONFIG_QDIO_PERF_STATS */
37 /**** CONSTANTS, that are relied on without using these symbols *****/
38 #define QDIO_MAX_QUEUES_PER_IRQ 32 /* used in width of unsigned int */
39 /************************ END of CONSTANTS **************************/
40 #define QDIO_MAX_BUFFERS_PER_Q 128 /* must be a power of 2 (%x=&(x-1)*/
41 #define QDIO_BUF_ORDER 7 /* 2**this == number of pages used for sbals in 1 q */
42 #define QDIO_MAX_ELEMENTS_PER_BUFFER 16
45 /* unfortunately this can't be (QDIO_MAX_BUFFERS_PER_Q*4/3) or so -- as
46 * we never know, whether we'll get initiative again, e.g. to give the
47 * transmit skb's back to the stack, however the stack may be waiting for
48 * them... therefore we define 4 as threshold to start polling (which
49 * will stop as soon as the asynchronous queue catches up)
50 * btw, this only applies to the asynchronous HiperSockets queue */
51 #define IQDIO_FILL_LEVEL_TO_POLL 4
53 #define TIQDIO_THININT_ISC 3
54 #define TIQDIO_DELAY_TARGET 0
55 #define QDIO_BUSY_BIT_PATIENCE 100 /* in microsecs */
56 #define QDIO_BUSY_BIT_GIVE_UP 10000000 /* 10 seconds */
57 #define IQDIO_GLOBAL_LAPS 2 /* GLOBAL_LAPS are not used as we */
58 #define IQDIO_GLOBAL_LAPS_INT 1 /* dont global summary */
59 #define IQDIO_LOCAL_LAPS 4
60 #define IQDIO_LOCAL_LAPS_INT 1
61 #define IQDIO_GLOBAL_SUMMARY_CC_MASK 2
62 /*#define IQDIO_IQDC_INT_PARM 0x1234*/
66 #define QDIO_STORAGE_ACC_KEY 0
68 #define L2_CACHELINE_SIZE 256
69 #define INDICATORS_PER_CACHELINE (L2_CACHELINE_SIZE/sizeof(__u32))
71 #define QDIO_PERF "qdio_perf"
73 /* must be a power of 2 */
74 /*#define QDIO_STATS_NUMBER 4
76 #define QDIO_STATS_CLASSES 2
77 #define QDIO_STATS_COUNT_NEEDED 2*/
79 #define QDIO_ACTIVATE_DELAY 5 /* according to brenton belmar and paul
80 gioquindo it can take up to 5ms before
81 queues are really active */
83 #define QDIO_NO_USE_COUNT_TIME 10
84 #define QDIO_NO_USE_COUNT_TIMEOUT 1000 /* wait for 1 sec on each q before
85 exiting without having use_count
88 #define QDIO_ESTABLISH_TIMEOUT 1000
89 #define QDIO_ACTIVATE_TIMEOUT 100
90 #define QDIO_CLEANUP_CLEAR_TIMEOUT 20000
91 #define QDIO_CLEANUP_HALT_TIMEOUT 10000
93 #define QDIO_BH AURORA_BH
95 #define QDIO_IRQ_BUCKETS 256 /* heavy..., but does only use a few bytes, but
96 be rather faster in cases of collisions
97 (if there really is a collision, it is
98 on every (traditional) interrupt and every
99 do_QDIO, so we rather are generous */
100 #define QDIO_QETH_QFMT 0
101 #define QDIO_ZFCP_QFMT 1
102 #define QDIO_IQDIO_QFMT 2
104 #define QDIO_IRQ_STATE_FRESH 0 /* must be 0 -> memset has set it to 0 */
105 #define QDIO_IRQ_STATE_INACTIVE 1
106 #define QDIO_IRQ_STATE_ESTABLISHED 2
107 #define QDIO_IRQ_STATE_ACTIVE 3
108 #define QDIO_IRQ_STATE_STOPPED 4
110 /* used as intparm in do_IO: */
111 #define QDIO_DOING_SENSEID 0
112 #define QDIO_DOING_ESTABLISH 1
113 #define QDIO_DOING_ACTIVATE 2
114 #define QDIO_DOING_CLEANUP 3
116 /************************* DEBUG FACILITY STUFF *********************/
117 /* #define QDIO_DBF_LIKE_HELL */
119 #define QDIO_DBF_HEX(ex,name,level,addr,len) \
122 debug_exception(qdio_dbf_##name,level,(void*)(addr),len); \
124 debug_event(qdio_dbf_##name,level,(void*)(addr),len); \
126 #define QDIO_DBF_TEXT(ex,name,level,text) \
129 debug_text_exception(qdio_dbf_##name,level,text); \
131 debug_text_event(qdio_dbf_##name,level,text); \
134 #define QDIO_DBF_HEX0(ex,name,addr,len) QDIO_DBF_HEX(ex,name,0,addr,len)
135 #define QDIO_DBF_HEX1(ex,name,addr,len) QDIO_DBF_HEX(ex,name,1,addr,len)
136 #define QDIO_DBF_HEX2(ex,name,addr,len) QDIO_DBF_HEX(ex,name,2,addr,len)
137 #define QDIO_DBF_HEX3(ex,name,addr,len) QDIO_DBF_HEX(ex,name,3,addr,len)
138 #define QDIO_DBF_HEX4(ex,name,addr,len) QDIO_DBF_HEX(ex,name,4,addr,len)
139 #define QDIO_DBF_HEX5(ex,name,addr,len) QDIO_DBF_HEX(ex,name,5,addr,len)
140 #define QDIO_DBF_HEX6(ex,name,addr,len) QDIO_DBF_HEX(ex,name,6,addr,len)
141 #ifdef QDIO_DBF_LIKE_HELL
142 #endif /* QDIO_DBF_LIKE_HELL */
144 #define QDIO_DBF_HEX0(ex,name,addr,len) do {} while (0)
145 #define QDIO_DBF_HEX1(ex,name,addr,len) do {} while (0)
146 #define QDIO_DBF_HEX2(ex,name,addr,len) do {} while (0)
147 #ifndef QDIO_DBF_LIKE_HELL
148 #define QDIO_DBF_HEX3(ex,name,addr,len) do {} while (0)
149 #define QDIO_DBF_HEX4(ex,name,addr,len) do {} while (0)
150 #define QDIO_DBF_HEX5(ex,name,addr,len) do {} while (0)
151 #define QDIO_DBF_HEX6(ex,name,addr,len) do {} while (0)
152 #endif /* QDIO_DBF_LIKE_HELL */
155 #define QDIO_DBF_TEXT0(ex,name,text) QDIO_DBF_TEXT(ex,name,0,text)
156 #define QDIO_DBF_TEXT1(ex,name,text) QDIO_DBF_TEXT(ex,name,1,text)
157 #define QDIO_DBF_TEXT2(ex,name,text) QDIO_DBF_TEXT(ex,name,2,text)
158 #define QDIO_DBF_TEXT3(ex,name,text) QDIO_DBF_TEXT(ex,name,3,text)
159 #define QDIO_DBF_TEXT4(ex,name,text) QDIO_DBF_TEXT(ex,name,4,text)
160 #define QDIO_DBF_TEXT5(ex,name,text) QDIO_DBF_TEXT(ex,name,5,text)
161 #define QDIO_DBF_TEXT6(ex,name,text) QDIO_DBF_TEXT(ex,name,6,text)
162 #ifdef QDIO_DBF_LIKE_HELL
163 #endif /* QDIO_DBF_LIKE_HELL */
165 #define QDIO_DBF_TEXT0(ex,name,text) do {} while (0)
166 #define QDIO_DBF_TEXT1(ex,name,text) do {} while (0)
167 #define QDIO_DBF_TEXT2(ex,name,text) do {} while (0)
168 #ifndef QDIO_DBF_LIKE_HELL
169 #define QDIO_DBF_TEXT3(ex,name,text) do {} while (0)
170 #define QDIO_DBF_TEXT4(ex,name,text) do {} while (0)
171 #define QDIO_DBF_TEXT5(ex,name,text) do {} while (0)
172 #define QDIO_DBF_TEXT6(ex,name,text) do {} while (0)
173 #endif /* QDIO_DBF_LIKE_HELL */
176 #define QDIO_DBF_SETUP_NAME "qdio_setup"
177 #define QDIO_DBF_SETUP_LEN 8
178 #define QDIO_DBF_SETUP_INDEX 2
179 #define QDIO_DBF_SETUP_NR_AREAS 1
180 #ifdef QDIO_DBF_LIKE_HELL
181 #define QDIO_DBF_SETUP_LEVEL 6
182 #else /* QDIO_DBF_LIKE_HELL */
183 #define QDIO_DBF_SETUP_LEVEL 2
184 #endif /* QDIO_DBF_LIKE_HELL */
186 #define QDIO_DBF_SBAL_NAME "qdio_labs" /* sbal */
187 #define QDIO_DBF_SBAL_LEN 256
188 #define QDIO_DBF_SBAL_INDEX 2
189 #define QDIO_DBF_SBAL_NR_AREAS 2
190 #ifdef QDIO_DBF_LIKE_HELL
191 #define QDIO_DBF_SBAL_LEVEL 6
192 #else /* QDIO_DBF_LIKE_HELL */
193 #define QDIO_DBF_SBAL_LEVEL 2
194 #endif /* QDIO_DBF_LIKE_HELL */
196 #define QDIO_DBF_TRACE_NAME "qdio_trace"
197 #define QDIO_DBF_TRACE_LEN 8
198 #define QDIO_DBF_TRACE_NR_AREAS 2
199 #ifdef QDIO_DBF_LIKE_HELL
200 #define QDIO_DBF_TRACE_INDEX 4
201 #define QDIO_DBF_TRACE_LEVEL 4 /* -------- could be even more verbose here */
202 #else /* QDIO_DBF_LIKE_HELL */
203 #define QDIO_DBF_TRACE_INDEX 2
204 #define QDIO_DBF_TRACE_LEVEL 2
205 #endif /* QDIO_DBF_LIKE_HELL */
207 #define QDIO_DBF_SENSE_NAME "qdio_sense"
208 #define QDIO_DBF_SENSE_LEN 64
209 #define QDIO_DBF_SENSE_INDEX 1
210 #define QDIO_DBF_SENSE_NR_AREAS 1
211 #ifdef QDIO_DBF_LIKE_HELL
212 #define QDIO_DBF_SENSE_LEVEL 6
213 #else /* QDIO_DBF_LIKE_HELL */
214 #define QDIO_DBF_SENSE_LEVEL 2
215 #endif /* QDIO_DBF_LIKE_HELL */
217 #ifdef QDIO_DBF_LIKE_HELL
218 #define QDIO_TRACE_QTYPE QDIO_ZFCP_QFMT
220 #define QDIO_DBF_SLSB_OUT_NAME "qdio_slsb_out"
221 #define QDIO_DBF_SLSB_OUT_LEN QDIO_MAX_BUFFERS_PER_Q
222 #define QDIO_DBF_SLSB_OUT_INDEX 8
223 #define QDIO_DBF_SLSB_OUT_NR_AREAS 1
224 #define QDIO_DBF_SLSB_OUT_LEVEL 6
226 #define QDIO_DBF_SLSB_IN_NAME "qdio_slsb_in"
227 #define QDIO_DBF_SLSB_IN_LEN QDIO_MAX_BUFFERS_PER_Q
228 #define QDIO_DBF_SLSB_IN_INDEX 8
229 #define QDIO_DBF_SLSB_IN_NR_AREAS 1
230 #define QDIO_DBF_SLSB_IN_LEVEL 6
231 #endif /* QDIO_DBF_LIKE_HELL */
233 /****************** END OF DEBUG FACILITY STUFF *********************/
235 typedef struct qdio_buffer_element_t {
240 #endif /* QDIO_32_BIT */
242 } __attribute__ ((packed,aligned(16))) qdio_buffer_element_t;
244 typedef struct qdio_buffer_t {
245 volatile qdio_buffer_element_t element[16];
246 } __attribute__ ((packed,aligned(256))) qdio_buffer_t;
249 /* params are: irq, status, qdio_error, siga_error,
250 queue_number, first element processed, number of elements processed,
252 typedef void qdio_handler_t(int,unsigned int,unsigned int,unsigned int,
253 unsigned int,int,int,unsigned long);
256 #define QDIO_STATUS_INBOUND_INT 0x01
257 #define QDIO_STATUS_OUTBOUND_INT 0x02
258 #define QDIO_STATUS_LOOK_FOR_ERROR 0x04
259 #define QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR 0x08
260 #define QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR 0x10
261 #define QDIO_STATUS_ACTIVATE_CHECK_CONDITION 0x20
263 #define QDIO_SIGA_ERROR_ACCESS_EXCEPTION 0x10
264 #define QDIO_SIGA_ERROR_B_BIT_SET 0x20
266 /* for qdio_initialize */
267 #define QDIO_INBOUND_0COPY_SBALS 0x01
268 #define QDIO_OUTBOUND_0COPY_SBALS 0x02
269 #define QDIO_USE_OUTBOUND_PCIS 0x04
270 #define QDIO_PFIX 0x08
272 /* for qdio_cleanup */
273 #define QDIO_FLAG_CLEANUP_USING_CLEAR 0x01
274 #define QDIO_FLAG_CLEANUP_USING_HALT 0x02
276 typedef struct qdio_initialize_t {
278 unsigned char q_format;
279 unsigned char adapter_name[8];
280 unsigned int qib_param_field_format; /*adapter dependent*/
281 /* pointer to 128 bytes or NULL, if no param field */
282 unsigned char *qib_param_field; /* adapter dependent */
283 /* pointer to no_queues*128 words of data or NULL */
284 unsigned long *input_slib_elements;
285 unsigned long *output_slib_elements;
286 unsigned int min_input_threshold;
287 unsigned int max_input_threshold;
288 unsigned int min_output_threshold;
289 unsigned int max_output_threshold;
290 unsigned int no_input_qs;
291 unsigned int no_output_qs;
292 qdio_handler_t *input_handler;
293 qdio_handler_t *output_handler;
294 unsigned long int_parm;
296 void **input_sbal_addr_array; /* addr of n*128 void ptrs */
297 void **output_sbal_addr_array; /* addr of n*128 void ptrs */
299 extern int qdio_initialize(qdio_initialize_t *init_data);
301 extern int qdio_activate(int irq,int flags);
303 #define QDIO_STATE_MUST_USE_OUTB_PCI 0x00000001
304 #define QDIO_STATE_INACTIVE 0x00000002 /* after qdio_cleanup */
305 #define QDIO_STATE_ESTABLISHED 0x00000004 /* after qdio_initialize */
306 #define QDIO_STATE_ACTIVE 0x00000008 /* after qdio_activate */
307 #define QDIO_STATE_STOPPED 0x00000010 /* after queues went down */
308 extern unsigned long qdio_get_status(int irq);
311 #define QDIO_FLAG_SYNC_INPUT 0x01
312 #define QDIO_FLAG_SYNC_OUTPUT 0x02
313 #define QDIO_FLAG_UNDER_INTERRUPT 0x04
314 #define QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT 0x08 /* no effect on
315 adapter interrupts */
316 #define QDIO_FLAG_DONT_SIGA 0x10
318 extern int do_QDIO(int irq,unsigned int flags, unsigned int queue_number,
319 unsigned int qidx,unsigned int count,
320 qdio_buffer_t *buffers);
322 extern int qdio_synchronize(int irq,unsigned int flags,
323 unsigned int queue_number);
325 extern int qdio_cleanup(int irq,int how);
327 extern unsigned char qdio_get_slsb_state(int irq,unsigned int flag,
328 unsigned int queue_number,
332 * QDIO device commands returned by extended Sense-ID
334 #define DEFAULT_ESTABLISH_QS_CMD 0x1b
335 #define DEFAULT_ESTABLISH_QS_COUNT 0x1000
336 #define DEFAULT_ACTIVATE_QS_CMD 0x1f
337 #define DEFAULT_ACTIVATE_QS_COUNT 0
338 typedef struct _qdio_cmds {
339 unsigned char rcd; /* read configuration data */
340 unsigned short count_rcd;
341 unsigned char sii; /* set interface identifier */
342 unsigned short count_sii;
343 unsigned char rni; /* read node identifier */
344 unsigned short count_rni;
345 unsigned char eq; /* establish QDIO queues */
346 unsigned short count_eq;
347 unsigned char aq; /* activate QDIO queues */
348 unsigned short count_aq;
352 * additional CIWs returned by extended Sense-ID
354 #define CIW_TYPE_EQUEUE 0x3 /* establish QDIO queues */
355 #define CIW_TYPE_AQUEUE 0x4 /* activate QDIO queues */
357 typedef struct _qdesfmt0 {
359 unsigned long res1; /* reserved */
360 #endif /* QDIO_32_BIT */
361 unsigned long sliba; /* storage-list-information-block
364 unsigned long res2; /* reserved */
365 #endif /* QDIO_32_BIT */
366 unsigned long sla; /* storage-list address */
368 unsigned long res3; /* reserved */
369 #endif /* QDIO_32_BIT */
370 unsigned long slsba; /* storage-list-state-block address */
371 unsigned int res4; /* reserved */
372 unsigned int akey : 4; /* access key for DLIB */
373 unsigned int bkey : 4; /* access key for SL */
374 unsigned int ckey : 4; /* access key for SBALs */
375 unsigned int dkey : 4; /* access key for SLSB */
376 unsigned int res5 : 16; /* reserved */
377 } __attribute__ ((packed)) qdesfmt0_t;
380 * Queue-Description record (QDR)
382 typedef struct _qdr {
383 unsigned int qfmt : 8; /* queue format */
384 unsigned int pfmt : 8; /* impl. dep. parameter format */
385 unsigned int res1 : 8; /* reserved */
386 unsigned int ac : 8; /* adapter characteristics */
387 unsigned int res2 : 8; /* reserved */
388 unsigned int iqdcnt : 8; /* input-queue-descriptor count */
389 unsigned int res3 : 8; /* reserved */
390 unsigned int oqdcnt : 8; /* output-queue-descriptor count */
391 unsigned int res4 : 8; /* reserved */
392 unsigned int iqdsz : 8; /* input-queue-descriptor size */
393 unsigned int res5 : 8; /* reserved */
394 unsigned int oqdsz : 8; /* output-queue-descriptor size */
395 unsigned int res6[9]; /* reserved */
397 unsigned long res7; /* reserved */
398 #endif /* QDIO_32_BIT */
399 unsigned long qiba; /* queue-information-block address */
400 unsigned int res8; /* reserved */
401 unsigned int qkey : 4; /* queue-informatio-block key */
402 unsigned int res9 : 28; /* reserved */
403 /* union _qd {*/ /* why this? */
404 qdesfmt0_t qdf0[126];
406 } __attribute__ ((packed,aligned(4096))) qdr_t;
410 * queue information block (QIB)
412 #define QIB_AC_INBOUND_PCI_SUPPORTED 0x80
413 #define QIB_AC_OUTBOUND_PCI_SUPPORTED 0x40
414 typedef struct _qib {
415 unsigned int qfmt : 8; /* queue format */
416 unsigned int pfmt : 8; /* impl. dep. parameter format */
417 unsigned int res1 : 8; /* reserved */
418 unsigned int ac : 8; /* adapter characteristics */
419 unsigned int res2; /* reserved */
421 unsigned long res3; /* reserved */
422 #endif /* QDIO_32_BIT */
423 unsigned long isliba; /* absolute address of 1st
426 unsigned long res4; /* reserved */
427 #endif /* QDIO_32_BIT */
428 unsigned long osliba; /* absolute address of 1st
430 unsigned int res5; /* reserved */
431 unsigned int res6; /* reserved */
432 unsigned char ebcnam[8]; /* adapter identifier in EBCDIC */
433 unsigned char res7[88]; /* reserved */
434 unsigned char parm[QDIO_MAX_BUFFERS_PER_Q];
435 /* implementation dependent
437 } __attribute__ ((packed,aligned(256))) qib_t;
441 * storage-list-information block element (SLIBE)
443 typedef struct _slibe {
445 unsigned long res; /* reserved */
446 #endif /* QDIO_32_BIT */
447 unsigned long parms; /* implementation dependent
452 * storage-list-information block (SLIB)
454 typedef struct _slib {
456 unsigned long res1; /* reserved */
457 #endif /* QDIO_32_BIT */
458 unsigned long nsliba; /* next SLIB address (if any) */
460 unsigned long res2; /* reserved */
461 #endif /* QDIO_32_BIT */
462 unsigned long sla; /* SL address */
464 unsigned long res3; /* reserved */
465 #endif /* QDIO_32_BIT */
466 unsigned long slsba; /* SLSB address */
467 unsigned char res4[1000]; /* reserved */
468 slibe_t slibe[QDIO_MAX_BUFFERS_PER_Q]; /* SLIB elements */
469 } __attribute__ ((packed,aligned(2048))) slib_t;
471 typedef struct _sbal_flags {
472 unsigned char res1 : 1; /* reserved */
473 unsigned char last : 1; /* last entry */
474 unsigned char cont : 1; /* contiguous storage */
475 unsigned char res2 : 1; /* reserved */
476 unsigned char frag : 2; /* fragmentation (s.below) */
477 unsigned char res3 : 2; /* reserved */
478 } __attribute__ ((packed)) sbal_flags_t;
480 #define SBAL_FLAGS_FIRST_FRAG 0x04000000UL
481 #define SBAL_FLAGS_MIDDLE_FRAG 0x08000000UL
482 #define SBAL_FLAGS_LAST_FRAG 0x0c000000UL
483 #define SBAL_FLAGS_LAST_ENTRY 0x40000000UL
484 #define SBAL_FLAGS_CONTIGUOUS 0x20000000UL
486 #define SBAL_FLAGS0_DATA_CONTINUATION 0x20UL
488 /* Awesome FCP extensions */
489 #define SBAL_FLAGS0_TYPE_STATUS 0x00UL
490 #define SBAL_FLAGS0_TYPE_WRITE 0x08UL
491 #define SBAL_FLAGS0_TYPE_READ 0x10UL
492 #define SBAL_FLAGS0_TYPE_WRITE_READ 0x18UL
493 #define SBAL_FLAGS0_MORE_SBALS 0x04UL
494 #define SBAL_FLAGS0_COMMAND 0x02UL
495 #define SBAL_FLAGS0_LAST_SBAL 0x00UL
496 #define SBAL_FLAGS0_ONLY_SBAL SBAL_FLAGS0_COMMAND
497 #define SBAL_FLAGS0_MIDDLE_SBAL SBAL_FLAGS0_MORE_SBALS
498 #define SBAL_FLAGS0_FIRST_SBAL SBAL_FLAGS0_MORE_SBALS | SBAL_FLAGS0_COMMAND
499 /* Naught of interest beyond this point */
501 #define SBAL_FLAGS0_PCI 0x40
502 typedef struct _sbal_sbalf_0 {
503 unsigned char res1 : 1; /* reserved */
504 unsigned char pci : 1; /* PCI indicator */
505 unsigned char cont : 1; /* data continuation */
506 unsigned char sbtype: 2; /* storage-block type (FCP) */
507 unsigned char res2 : 3; /* reserved */
508 } __attribute__ ((packed)) sbal_sbalf_0_t;
510 typedef struct _sbal_sbalf_1 {
511 unsigned char res1 : 4; /* reserved */
512 unsigned char key : 4; /* storage key */
513 } __attribute__ ((packed)) sbal_sbalf_1_t;
515 typedef struct _sbal_sbalf_14 {
516 unsigned char res1 : 4; /* reserved */
517 unsigned char erridx : 4; /* error index */
518 } __attribute__ ((packed)) sbal_sbalf_14_t;
520 typedef struct _sbal_sbalf_15 {
521 unsigned char reason; /* reserved */
522 } __attribute__ ((packed)) sbal_sbalf_15_t;
524 typedef union _sbal_sbalf {
532 typedef struct _sbale {
534 sbal_flags_t bits; /* flags */
537 unsigned int res1 : 16; /* reserved */
538 sbal_sbalf_t sbalf; /* SBAL flags */
539 unsigned int res2 : 16; /* reserved */
540 unsigned int count : 16; /* data count */
542 unsigned long res3; /* reserved */
543 #endif /* QDIO_32_BIT */
544 unsigned long addr; /* absolute data address */
545 } __attribute__ ((packed,aligned(16))) sbal_element_t;
548 * strorage-block access-list (SBAL)
550 typedef struct _sbal {
551 sbal_element_t element[QDIO_MAX_ELEMENTS_PER_BUFFER];
552 } __attribute__ ((packed,aligned(256))) sbal_t;
557 typedef struct _sl_element {
559 unsigned long res; /* reserved */
560 #endif /* QDIO_32_BIT */
561 unsigned long sbal; /* absolute SBAL address */
562 } __attribute__ ((packed)) sl_element_t;
565 sl_element_t element[QDIO_MAX_BUFFERS_PER_Q];
566 } __attribute__ ((packed,aligned(1024))) sl_t;
569 * storage-list-state block (SLSB)
571 /*typedef struct _slsb_val {*/
572 /* unsigned char value; */ /* SLSB entry as a single byte value */
573 /*} __attribute__ ((packed)) slsb_val_t;*/
575 typedef struct _slsb_flags {
576 unsigned char owner : 2; /* SBAL owner */
577 unsigned char type : 1; /* buffer type */
578 unsigned char state : 5; /* processing state */
579 } __attribute__ ((packed)) slsb_flags_t;
582 typedef struct _slsb {
584 unsigned char val[QDIO_MAX_BUFFERS_PER_Q];
585 slsb_flags_t flags[QDIO_MAX_BUFFERS_PER_Q];
587 } __attribute__ ((packed,aligned(256))) slsb_t;
592 #define SLSB_OWNER_PROG 1
593 #define SLSB_OWNER_CU 2
595 #define SLSB_TYPE_INPUT 0
596 #define SLSB_TYPE_OUTPUT 1
598 #define SLSB_STATE_NOT_INIT 0
599 #define SLSB_STATE_EMPTY 1
600 #define SLSB_STATE_PRIMED 2
601 #define SLSB_STATE_HALTED 0xe
602 #define SLSB_STATE_ERROR 0xf
604 #define SLSB_P_INPUT_NOT_INIT 0x80
605 #define SLSB_P_INPUT_PROCESSING 0x81
606 #define SLSB_CU_INPUT_EMPTY 0x41
607 #define SLSB_P_INPUT_PRIMED 0x82
608 #define SLSB_P_INPUT_HALTED 0x8E
609 #define SLSB_P_INPUT_ERROR 0x8F
611 #define SLSB_P_OUTPUT_NOT_INIT 0xA0
612 #define SLSB_P_OUTPUT_EMPTY 0xA1
613 #define SLSB_CU_OUTPUT_PRIMED 0x62
614 #define SLSB_P_OUTPUT_HALTED 0xAE
615 #define SLSB_P_OUTPUT_ERROR 0xAF
617 #define SLSB_ERROR_DURING_LOOKUP 0xFF
619 typedef struct qdio_q_t {
620 volatile slsb_t slsb;
622 char unused[QDIO_MAX_BUFFERS_PER_Q];
624 __u32 * volatile dev_st_chg_ind;
627 int is_0copy_sbals_q;
629 unsigned int is_iqdio_q;
630 unsigned int is_thinint_q;
632 /* bit 0 means queue 0, bit 1 means queue 1, ... */
636 qdio_handler_t (*handler);
638 /* points to the next buffer to be checked for having
639 * been processed by the card (outbound)
640 * or to the next buffer the program should check for (inbound) */
641 volatile int first_to_check;
642 /* and the last time it was: */
643 volatile int last_move_ftc;
645 atomic_t number_of_buffers_used;
648 unsigned int siga_in;
649 unsigned int siga_out;
650 unsigned int siga_sync;
651 unsigned int siga_sync_done_on_thinints;
652 unsigned int siga_sync_done_on_outb_tis;
653 unsigned int hydra_gives_outbound_pcis;
655 /* used to save beginning position when calling dd_handlers */
656 int first_element_to_kick;
659 atomic_t is_in_shutdown;
664 #ifdef QDIO_USE_TIMERS_FOR_POLLING
665 struct timer_list timer;
666 atomic_t timer_already_set;
667 spinlock_t timer_lock;
668 #else /* QDIO_USE_TIMERS_FOR_POLLING */
669 struct tasklet_struct tasklet;
670 #endif /* QDIO_USE_TIMERS_FOR_POLLING */
674 /* used to store the error condition during a data transfer */
675 unsigned int qdio_error;
676 unsigned int siga_error;
677 unsigned int error_status_flags;
679 /* list of interesting queues */
680 volatile struct qdio_q_t *list_next;
681 volatile struct qdio_q_t *list_prev;
683 slib_t *slib; /* a page is allocated under this pointer,
684 sl points into this page, offset PAGE_SIZE/2
687 volatile sbal_t *sbal[QDIO_MAX_BUFFERS_PER_Q];
689 qdio_buffer_t *qdio_buffers[QDIO_MAX_BUFFERS_PER_Q];
691 unsigned long int_parm;
694 int in_bh_check_limit;
696 } threshold_classes[QDIO_STATS_CLASSES];*/
699 /* inbound: the time to stop polling
700 outbound: the time to kick peer */
701 int threshold; /* the real value */
703 /* outbound: last time of do_QDIO
704 inbound: last time of noticing incoming data */
705 /*__u64 last_transfer_times[QDIO_STATS_NUMBER];
706 int last_transfer_index; */
708 __u64 last_transfer_time;
711 atomic_t busy_siga_counter;
712 unsigned int queue_type;
713 } __attribute__ ((aligned(256))) qdio_q_t;
715 typedef struct qdio_irq_t {
716 __u32 * volatile dev_st_chg_ind;
718 unsigned long int_parm;
721 unsigned int is_iqdio_irq;
722 unsigned int is_thinint_irq;
723 unsigned int hydra_gives_outbound_pcis;
724 unsigned int sync_done_on_outb_pcis;
727 struct semaphore setting_up_lock;
729 unsigned int no_input_qs;
730 unsigned int no_output_qs;
732 unsigned char qdioac;
734 qdio_q_t *input_qs[QDIO_MAX_QUEUES_PER_IRQ];
735 qdio_q_t *output_qs[QDIO_MAX_QUEUES_PER_IRQ];
741 atomic_t interrupt_has_arrived;
742 atomic_t interrupt_has_been_cleaned;
743 wait_queue_head_t wait_q;
747 qdio_cmds_t commands;
751 io_handler_func_t original_int_handler;
753 unsigned long other_flags; /* e.g. QDIO_PFIX */
755 struct qdio_irq_t *next;
758 #define QDIO_CHSC_RESPONSE_CODE_OK 1
759 /* flags for st qdio sch data */
760 #define CHSC_FLAG_QDIO_CAPABILITY 0x80
761 #define CHSC_FLAG_VALIDITY 0x40
763 #define CHSC_FLAG_SIGA_INPUT_NECESSARY 0x40
764 #define CHSC_FLAG_SIGA_OUTPUT_NECESSARY 0x20
765 #define CHSC_FLAG_SIGA_SYNC_NECESSARY 0x10
766 #define CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS 0x08
767 #define CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS 0x04
769 typedef struct qdio_chsc_area_t {
775 __u16 operation_code;
788 __u64 summary_indicator_addr;
790 __u64 subchannel_indicator_addr;
801 __u32 reserved3[1004];
802 } __attribute__ ((packed,aligned(4))) set_chsc;
809 __u32 reserved4[1009];
810 } __attribute__ ((packed,aligned(4))) set_chsc_fast;
817 /* words 2 to 9 for st sch qdio data */
829 /* plus 5 words of reserved fields */
830 } __attribute__ ((packed,aligned(8)))
831 store_qdio_data_response;
832 } operation_data_area;
833 } __attribute__ ((packed,aligned(8))) request_block;
840 } __attribute__ ((packed,aligned(8))) response_block;
841 } __attribute__ ((packed,aligned(PAGE_SIZE))) qdio_chsc_area_t;
844 #define QDIO_PRINTK_HEADER QDIO_NAME ": "
846 #if QDIO_VERBOSE_LEVEL>8
847 #define QDIO_PRINT_STUPID(x...) printk( KERN_DEBUG QDIO_PRINTK_HEADER x)
849 #define QDIO_PRINT_STUPID(x...)
852 #if QDIO_VERBOSE_LEVEL>7
853 #define QDIO_PRINT_ALL(x...) printk( QDIO_PRINTK_HEADER x)
855 #define QDIO_PRINT_ALL(x...)
858 #if QDIO_VERBOSE_LEVEL>6
859 #define QDIO_PRINT_INFO(x...) printk( QDIO_PRINTK_HEADER x)
861 #define QDIO_PRINT_INFO(x...)
864 #if QDIO_VERBOSE_LEVEL>5
865 #define QDIO_PRINT_WARN(x...) printk( QDIO_PRINTK_HEADER x)
867 #define QDIO_PRINT_WARN(x...)
870 #if QDIO_VERBOSE_LEVEL>4
871 #define QDIO_PRINT_ERR(x...) printk( QDIO_PRINTK_HEADER x)
873 #define QDIO_PRINT_ERR(x...)
876 #if QDIO_VERBOSE_LEVEL>3
877 #define QDIO_PRINT_CRIT(x...) printk( QDIO_PRINTK_HEADER x)
879 #define QDIO_PRINT_CRIT(x...)
882 #if QDIO_VERBOSE_LEVEL>2
883 #define QDIO_PRINT_ALERT(x...) printk( QDIO_PRINTK_HEADER x)
885 #define QDIO_PRINT_ALERT(x...)
888 #if QDIO_VERBOSE_LEVEL>1
889 #define QDIO_PRINT_EMERG(x...) printk( QDIO_PRINTK_HEADER x)
891 #define QDIO_PRINT_EMERG(x...)
894 #endif /* __QDIO_H__ */