6 #define VERSION_CIO_QDIO_H "$Revision: 1.33 $"
8 #ifdef CONFIG_QDIO_DEBUG
9 #define QDIO_VERBOSE_LEVEL 9
10 #else /* CONFIG_QDIO_DEBUG */
11 #define QDIO_VERBOSE_LEVEL 5
12 #endif /* CONFIG_QDIO_DEBUG */
14 #define QDIO_USE_PROCESSING_STATE
16 #ifdef CONFIG_QDIO_PERF_STATS
17 #define QDIO_PERFORMANCE_STATS
18 #endif /* CONFIG_QDIO_PERF_STATS */
20 #define QDIO_MINIMAL_BH_RELIEF_TIME 16
21 #define QDIO_TIMER_POLL_VALUE 1
22 #define IQDIO_TIMER_POLL_VALUE 1
25 * unfortunately this can't be (QDIO_MAX_BUFFERS_PER_Q*4/3) or so -- as
26 * we never know, whether we'll get initiative again, e.g. to give the
27 * transmit skb's back to the stack, however the stack may be waiting for
28 * them... therefore we define 4 as threshold to start polling (which
29 * will stop as soon as the asynchronous queue catches up)
30 * btw, this only applies to the asynchronous HiperSockets queue
32 #define IQDIO_FILL_LEVEL_TO_POLL 4
34 #define TIQDIO_THININT_ISC 3
35 #define TIQDIO_DELAY_TARGET 0
36 #define QDIO_BUSY_BIT_PATIENCE 100 /* in microsecs */
37 #define QDIO_BUSY_BIT_GIVE_UP 10000000 /* 10 seconds */
38 #define IQDIO_GLOBAL_LAPS 2 /* GLOBAL_LAPS are not used as we */
39 #define IQDIO_GLOBAL_LAPS_INT 1 /* don't global summary */
40 #define IQDIO_LOCAL_LAPS 4
41 #define IQDIO_LOCAL_LAPS_INT 1
42 #define IQDIO_GLOBAL_SUMMARY_CC_MASK 2
43 /*#define IQDIO_IQDC_INT_PARM 0x1234*/
47 #define QDIO_STORAGE_KEY PAGE_DEFAULT_KEY
49 #define L2_CACHELINE_SIZE 256
50 #define INDICATORS_PER_CACHELINE (L2_CACHELINE_SIZE/sizeof(__u32))
52 #define QDIO_PERF "qdio_perf"
54 /* must be a power of 2 */
55 /*#define QDIO_STATS_NUMBER 4
57 #define QDIO_STATS_CLASSES 2
58 #define QDIO_STATS_COUNT_NEEDED 2*/
60 #define QDIO_NO_USE_COUNT_TIMEOUT (1*HZ) /* wait for 1 sec on each q before
61 exiting without having use_count
64 #define QDIO_ESTABLISH_TIMEOUT (1*HZ)
65 #define QDIO_ACTIVATE_TIMEOUT ((5*HZ)>>10)
66 #define QDIO_CLEANUP_CLEAR_TIMEOUT (20*HZ)
67 #define QDIO_CLEANUP_HALT_TIMEOUT (10*HZ)
69 enum qdio_irq_states
{
70 QDIO_IRQ_STATE_INACTIVE
,
71 QDIO_IRQ_STATE_ESTABLISHED
,
72 QDIO_IRQ_STATE_ACTIVE
,
73 QDIO_IRQ_STATE_STOPPED
,
74 QDIO_IRQ_STATE_CLEANUP
,
79 /* used as intparm in do_IO: */
80 #define QDIO_DOING_SENSEID 0
81 #define QDIO_DOING_ESTABLISH 1
82 #define QDIO_DOING_ACTIVATE 2
83 #define QDIO_DOING_CLEANUP 3
85 /************************* DEBUG FACILITY STUFF *********************/
87 #define QDIO_DBF_HEX(ex,name,level,addr,len) \
90 debug_exception(qdio_dbf_##name,level,(void*)(addr),len); \
92 debug_event(qdio_dbf_##name,level,(void*)(addr),len); \
94 #define QDIO_DBF_TEXT(ex,name,level,text) \
97 debug_text_exception(qdio_dbf_##name,level,text); \
99 debug_text_event(qdio_dbf_##name,level,text); \
103 #define QDIO_DBF_HEX0(ex,name,addr,len) QDIO_DBF_HEX(ex,name,0,addr,len)
104 #define QDIO_DBF_HEX1(ex,name,addr,len) QDIO_DBF_HEX(ex,name,1,addr,len)
105 #define QDIO_DBF_HEX2(ex,name,addr,len) QDIO_DBF_HEX(ex,name,2,addr,len)
106 #ifdef CONFIG_QDIO_DEBUG
107 #define QDIO_DBF_HEX3(ex,name,addr,len) QDIO_DBF_HEX(ex,name,3,addr,len)
108 #define QDIO_DBF_HEX4(ex,name,addr,len) QDIO_DBF_HEX(ex,name,4,addr,len)
109 #define QDIO_DBF_HEX5(ex,name,addr,len) QDIO_DBF_HEX(ex,name,5,addr,len)
110 #define QDIO_DBF_HEX6(ex,name,addr,len) QDIO_DBF_HEX(ex,name,6,addr,len)
111 #else /* CONFIG_QDIO_DEBUG */
112 #define QDIO_DBF_HEX3(ex,name,addr,len) do {} while (0)
113 #define QDIO_DBF_HEX4(ex,name,addr,len) do {} while (0)
114 #define QDIO_DBF_HEX5(ex,name,addr,len) do {} while (0)
115 #define QDIO_DBF_HEX6(ex,name,addr,len) do {} while (0)
116 #endif /* CONFIG_QDIO_DEBUG */
118 #define QDIO_DBF_TEXT0(ex,name,text) QDIO_DBF_TEXT(ex,name,0,text)
119 #define QDIO_DBF_TEXT1(ex,name,text) QDIO_DBF_TEXT(ex,name,1,text)
120 #define QDIO_DBF_TEXT2(ex,name,text) QDIO_DBF_TEXT(ex,name,2,text)
121 #ifdef CONFIG_QDIO_DEBUG
122 #define QDIO_DBF_TEXT3(ex,name,text) QDIO_DBF_TEXT(ex,name,3,text)
123 #define QDIO_DBF_TEXT4(ex,name,text) QDIO_DBF_TEXT(ex,name,4,text)
124 #define QDIO_DBF_TEXT5(ex,name,text) QDIO_DBF_TEXT(ex,name,5,text)
125 #define QDIO_DBF_TEXT6(ex,name,text) QDIO_DBF_TEXT(ex,name,6,text)
126 #else /* CONFIG_QDIO_DEBUG */
127 #define QDIO_DBF_TEXT3(ex,name,text) do {} while (0)
128 #define QDIO_DBF_TEXT4(ex,name,text) do {} while (0)
129 #define QDIO_DBF_TEXT5(ex,name,text) do {} while (0)
130 #define QDIO_DBF_TEXT6(ex,name,text) do {} while (0)
131 #endif /* CONFIG_QDIO_DEBUG */
133 #define QDIO_DBF_SETUP_NAME "qdio_setup"
134 #define QDIO_DBF_SETUP_LEN 8
135 #define QDIO_DBF_SETUP_PAGES 4
136 #define QDIO_DBF_SETUP_NR_AREAS 1
137 #ifdef CONFIG_QDIO_DEBUG
138 #define QDIO_DBF_SETUP_LEVEL 6
139 #else /* CONFIG_QDIO_DEBUG */
140 #define QDIO_DBF_SETUP_LEVEL 2
141 #endif /* CONFIG_QDIO_DEBUG */
143 #define QDIO_DBF_SBAL_NAME "qdio_labs" /* sbal */
144 #define QDIO_DBF_SBAL_LEN 256
145 #define QDIO_DBF_SBAL_PAGES 4
146 #define QDIO_DBF_SBAL_NR_AREAS 2
147 #ifdef CONFIG_QDIO_DEBUG
148 #define QDIO_DBF_SBAL_LEVEL 6
149 #else /* CONFIG_QDIO_DEBUG */
150 #define QDIO_DBF_SBAL_LEVEL 2
151 #endif /* CONFIG_QDIO_DEBUG */
153 #define QDIO_DBF_TRACE_NAME "qdio_trace"
154 #define QDIO_DBF_TRACE_LEN 8
155 #define QDIO_DBF_TRACE_NR_AREAS 2
156 #ifdef CONFIG_QDIO_DEBUG
157 #define QDIO_DBF_TRACE_PAGES 16
158 #define QDIO_DBF_TRACE_LEVEL 4 /* -------- could be even more verbose here */
159 #else /* CONFIG_QDIO_DEBUG */
160 #define QDIO_DBF_TRACE_PAGES 4
161 #define QDIO_DBF_TRACE_LEVEL 2
162 #endif /* CONFIG_QDIO_DEBUG */
164 #define QDIO_DBF_SENSE_NAME "qdio_sense"
165 #define QDIO_DBF_SENSE_LEN 64
166 #define QDIO_DBF_SENSE_PAGES 2
167 #define QDIO_DBF_SENSE_NR_AREAS 1
168 #ifdef CONFIG_QDIO_DEBUG
169 #define QDIO_DBF_SENSE_LEVEL 6
170 #else /* CONFIG_QDIO_DEBUG */
171 #define QDIO_DBF_SENSE_LEVEL 2
172 #endif /* CONFIG_QDIO_DEBUG */
174 #ifdef CONFIG_QDIO_DEBUG
175 #define QDIO_TRACE_QTYPE QDIO_ZFCP_QFMT
177 #define QDIO_DBF_SLSB_OUT_NAME "qdio_slsb_out"
178 #define QDIO_DBF_SLSB_OUT_LEN QDIO_MAX_BUFFERS_PER_Q
179 #define QDIO_DBF_SLSB_OUT_PAGES 256
180 #define QDIO_DBF_SLSB_OUT_NR_AREAS 1
181 #define QDIO_DBF_SLSB_OUT_LEVEL 6
183 #define QDIO_DBF_SLSB_IN_NAME "qdio_slsb_in"
184 #define QDIO_DBF_SLSB_IN_LEN QDIO_MAX_BUFFERS_PER_Q
185 #define QDIO_DBF_SLSB_IN_PAGES 256
186 #define QDIO_DBF_SLSB_IN_NR_AREAS 1
187 #define QDIO_DBF_SLSB_IN_LEVEL 6
188 #endif /* CONFIG_QDIO_DEBUG */
190 #define QDIO_PRINTK_HEADER QDIO_NAME ": "
192 #if QDIO_VERBOSE_LEVEL>8
193 #define QDIO_PRINT_STUPID(x...) printk( KERN_DEBUG QDIO_PRINTK_HEADER x)
195 #define QDIO_PRINT_STUPID(x...)
198 #if QDIO_VERBOSE_LEVEL>7
199 #define QDIO_PRINT_ALL(x...) printk( QDIO_PRINTK_HEADER x)
201 #define QDIO_PRINT_ALL(x...)
204 #if QDIO_VERBOSE_LEVEL>6
205 #define QDIO_PRINT_INFO(x...) printk( QDIO_PRINTK_HEADER x)
207 #define QDIO_PRINT_INFO(x...)
210 #if QDIO_VERBOSE_LEVEL>5
211 #define QDIO_PRINT_WARN(x...) printk( QDIO_PRINTK_HEADER x)
213 #define QDIO_PRINT_WARN(x...)
216 #if QDIO_VERBOSE_LEVEL>4
217 #define QDIO_PRINT_ERR(x...) printk( QDIO_PRINTK_HEADER x)
219 #define QDIO_PRINT_ERR(x...)
222 #if QDIO_VERBOSE_LEVEL>3
223 #define QDIO_PRINT_CRIT(x...) printk( QDIO_PRINTK_HEADER x)
225 #define QDIO_PRINT_CRIT(x...)
228 #if QDIO_VERBOSE_LEVEL>2
229 #define QDIO_PRINT_ALERT(x...) printk( QDIO_PRINTK_HEADER x)
231 #define QDIO_PRINT_ALERT(x...)
234 #if QDIO_VERBOSE_LEVEL>1
235 #define QDIO_PRINT_EMERG(x...) printk( QDIO_PRINTK_HEADER x)
237 #define QDIO_PRINT_EMERG(x...)
240 #define HEXDUMP16(importance,header,ptr) \
241 QDIO_PRINT_##importance(header "%02x %02x %02x %02x " \
242 "%02x %02x %02x %02x %02x %02x %02x %02x " \
243 "%02x %02x %02x %02x\n",*(((char*)ptr)), \
244 *(((char*)ptr)+1),*(((char*)ptr)+2), \
245 *(((char*)ptr)+3),*(((char*)ptr)+4), \
246 *(((char*)ptr)+5),*(((char*)ptr)+6), \
247 *(((char*)ptr)+7),*(((char*)ptr)+8), \
248 *(((char*)ptr)+9),*(((char*)ptr)+10), \
249 *(((char*)ptr)+11),*(((char*)ptr)+12), \
250 *(((char*)ptr)+13),*(((char*)ptr)+14), \
251 *(((char*)ptr)+15)); \
252 QDIO_PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
253 "%02x %02x %02x %02x %02x %02x %02x %02x\n", \
254 *(((char*)ptr)+16),*(((char*)ptr)+17), \
255 *(((char*)ptr)+18),*(((char*)ptr)+19), \
256 *(((char*)ptr)+20),*(((char*)ptr)+21), \
257 *(((char*)ptr)+22),*(((char*)ptr)+23), \
258 *(((char*)ptr)+24),*(((char*)ptr)+25), \
259 *(((char*)ptr)+26),*(((char*)ptr)+27), \
260 *(((char*)ptr)+28),*(((char*)ptr)+29), \
261 *(((char*)ptr)+30),*(((char*)ptr)+31));
263 /****************** END OF DEBUG FACILITY STUFF *********************/
266 * Some instructions as assembly
268 extern __inline__
int
269 do_siga_sync(unsigned int irq
, unsigned int mask1
, unsigned int mask2
)
273 #ifndef CONFIG_ARCH_S390X
283 : "d" (0x10000|irq
), "d" (mask1
), "d" (mask2
)
284 : "cc", "0", "1", "2", "3"
286 #else /* CONFIG_ARCH_S390X */
296 : "d" (0x10000|irq
), "d" (mask1
), "d" (mask2
)
297 : "cc", "0", "1", "2", "3"
299 #endif /* CONFIG_ARCH_S390X */
303 extern __inline__
int
304 do_siga_input(unsigned int irq
, unsigned int mask
)
308 #ifndef CONFIG_ARCH_S390X
317 : "d" (0x10000|irq
), "d" (mask
)
318 : "cc", "0", "1", "2", "memory"
320 #else /* CONFIG_ARCH_S390X */
329 : "d" (0x10000|irq
), "d" (mask
)
330 : "cc", "0", "1", "2", "memory"
332 #endif /* CONFIG_ARCH_S390X */
337 extern __inline__
int
338 do_siga_output(unsigned long irq
, unsigned long mask
, __u32
*bb
)
343 #ifndef CONFIG_ARCH_S390X
355 ".section .fixup,\"ax\"\n\t"
364 ".section __ex_table,\"a\"\n\t"
368 : "=d" (cc
), "=d" (busy_bit
)
369 : "d" (0x10000|irq
), "d" (mask
),
370 "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION
)
371 : "cc", "0", "1", "2", "memory"
373 #else /* CONFIG_ARCH_S390X */
385 ".section .fixup,\"ax\"\n\t"
389 ".section __ex_table,\"a\"\n\t"
393 : "=d" (cc
), "=d" (busy_bit
)
394 : "d" (0x10000|irq
), "d" (mask
),
395 "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION
)
396 : "cc", "0", "1", "2", "memory"
398 #endif /* CONFIG_ARCH_S390X */
404 extern __inline__
unsigned long
405 do_clear_global_summary(void)
410 #ifndef CONFIG_ARCH_S390X
413 ".insn rre,0xb2650000,2,0 \n\t"
415 : "=d" (time
) : : "cc", "1", "2", "3"
417 #else /* CONFIG_ARCH_S390X */
420 ".insn rre,0xb2650000,2,0 \n\t"
422 : "=d" (time
) : : "cc", "1", "2", "3"
424 #endif /* CONFIG_ARCH_S390X */
430 * QDIO device commands returned by extended Sense-ID
432 #define DEFAULT_ESTABLISH_QS_CMD 0x1b
433 #define DEFAULT_ESTABLISH_QS_COUNT 0x1000
434 #define DEFAULT_ACTIVATE_QS_CMD 0x1f
435 #define DEFAULT_ACTIVATE_QS_COUNT 0
438 * additional CIWs returned by extended Sense-ID
440 #define CIW_TYPE_EQUEUE 0x3 /* establish QDIO queues */
441 #define CIW_TYPE_AQUEUE 0x4 /* activate QDIO queues */
443 #define QDIO_CHSC_RESPONSE_CODE_OK 1
444 /* flags for st qdio sch data */
445 #define CHSC_FLAG_QDIO_CAPABILITY 0x80
446 #define CHSC_FLAG_VALIDITY 0x40
448 #define CHSC_FLAG_SIGA_INPUT_NECESSARY 0x40
449 #define CHSC_FLAG_SIGA_OUTPUT_NECESSARY 0x20
450 #define CHSC_FLAG_SIGA_SYNC_NECESSARY 0x10
451 #define CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS 0x08
452 #define CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS 0x04
454 #ifdef QDIO_PERFORMANCE_STATS
455 struct qdio_perf_stats
{
456 unsigned int tl_runs
;
458 unsigned int siga_outs
;
459 unsigned int siga_ins
;
460 unsigned int siga_syncs
;
462 unsigned int thinints
;
463 unsigned int fast_reqs
;
465 __u64 start_time_outbound
;
466 unsigned int outbound_cnt
;
467 unsigned int outbound_time
;
468 __u64 start_time_inbound
;
469 unsigned int inbound_cnt
;
470 unsigned int inbound_time
;
472 #endif /* QDIO_PERFORMANCE_STATS */
474 #define atomic_swap(a,b) xchg((int*)a.counter,b)
476 /* unlikely as the later the better */
477 #define SYNC_MEMORY if (unlikely(q->siga_sync)) qdio_siga_sync_q(q)
478 #define SYNC_MEMORY_ALL if (unlikely(q->siga_sync)) \
479 qdio_siga_sync(q,~0U,~0U)
480 #define SYNC_MEMORY_ALL_OUTB if (unlikely(q->siga_sync)) \
481 qdio_siga_sync(q,~0U,0)
483 #define NOW qdio_get_micros()
484 #define SAVE_TIMESTAMP(q) q->timing.last_transfer_time=NOW
485 #define GET_SAVED_TIMESTAMP(q) (q->timing.last_transfer_time)
486 #define SAVE_FRONTIER(q,val) q->last_move_ftc=val
487 #define GET_SAVED_FRONTIER(q) (q->last_move_ftc)
489 #define MY_MODULE_STRING(x) #x
491 #ifdef CONFIG_ARCH_S390X
492 #define QDIO_GET_ADDR(x) ((__u32)(unsigned long)x)
493 #else /* CONFIG_ARCH_S390X */
494 #define QDIO_GET_ADDR(x) ((__u32)(long)x)
495 #endif /* CONFIG_ARCH_S390X */
497 #ifdef CONFIG_QDIO_DEBUG
498 #define set_slsb(x,y) \
499 if(q->queue_type==QDIO_TRACE_QTYPE) { \
500 if(q->is_input_q) { \
501 QDIO_DBF_HEX2(0,slsb_in,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \
503 QDIO_DBF_HEX2(0,slsb_out,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \
506 qdio_set_slsb(x,y); \
507 if(q->queue_type==QDIO_TRACE_QTYPE) { \
508 if(q->is_input_q) { \
509 QDIO_DBF_HEX2(0,slsb_in,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \
511 QDIO_DBF_HEX2(0,slsb_out,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \
514 #else /* CONFIG_QDIO_DEBUG */
515 #define set_slsb(x,y) qdio_set_slsb(x,y)
516 #endif /* CONFIG_QDIO_DEBUG */
519 volatile struct slsb slsb
;
521 char unused
[QDIO_MAX_BUFFERS_PER_Q
];
523 __u32
* volatile dev_st_chg_ind
;
527 struct ccw_device
*cdev
;
529 unsigned int is_iqdio_q
;
530 unsigned int is_thinint_q
;
532 /* bit 0 means queue 0, bit 1 means queue 1, ... */
536 qdio_handler_t (*handler
);
538 /* points to the next buffer to be checked for having
539 * been processed by the card (outbound)
540 * or to the next buffer the program should check for (inbound) */
541 volatile int first_to_check
;
542 /* and the last time it was: */
543 volatile int last_move_ftc
;
545 atomic_t number_of_buffers_used
;
548 unsigned int siga_in
;
549 unsigned int siga_out
;
550 unsigned int siga_sync
;
551 unsigned int siga_sync_done_on_thinints
;
552 unsigned int siga_sync_done_on_outb_tis
;
553 unsigned int hydra_gives_outbound_pcis
;
555 /* used to save beginning position when calling dd_handlers */
556 int first_element_to_kick
;
559 atomic_t is_in_shutdown
;
563 #ifdef QDIO_USE_TIMERS_FOR_POLLING
564 struct timer_list timer
;
565 atomic_t timer_already_set
;
566 spinlock_t timer_lock
;
567 #else /* QDIO_USE_TIMERS_FOR_POLLING */
568 struct tasklet_struct tasklet
;
569 #endif /* QDIO_USE_TIMERS_FOR_POLLING */
571 enum qdio_irq_states state
;
573 /* used to store the error condition during a data transfer */
574 unsigned int qdio_error
;
575 unsigned int siga_error
;
576 unsigned int error_status_flags
;
578 /* list of interesting queues */
579 volatile struct qdio_q
*list_next
;
580 volatile struct qdio_q
*list_prev
;
583 volatile struct sbal
*sbal
[QDIO_MAX_BUFFERS_PER_Q
];
585 struct qdio_buffer
*qdio_buffers
[QDIO_MAX_BUFFERS_PER_Q
];
587 unsigned long int_parm
;
590 int in_bh_check_limit;
592 } threshold_classes[QDIO_STATS_CLASSES];*/
595 /* inbound: the time to stop polling
596 outbound: the time to kick peer */
597 int threshold
; /* the real value */
599 /* outbound: last time of do_QDIO
600 inbound: last time of noticing incoming data */
601 /*__u64 last_transfer_times[QDIO_STATS_NUMBER];
602 int last_transfer_index; */
604 __u64 last_transfer_time
;
607 atomic_t busy_siga_counter
;
608 unsigned int queue_type
;
610 /* leave this member at the end. won't be cleared in qdio_fill_qs */
611 struct slib
*slib
; /* a page is allocated under this pointer,
612 sl points into this page, offset PAGE_SIZE/2
614 } __attribute__ ((aligned(256)));
617 __u32
* volatile dev_st_chg_ind
;
619 unsigned long int_parm
;
622 unsigned int is_iqdio_irq
;
623 unsigned int is_thinint_irq
;
624 unsigned int hydra_gives_outbound_pcis
;
625 unsigned int sync_done_on_outb_pcis
;
627 enum qdio_irq_states state
;
629 unsigned int no_input_qs
;
630 unsigned int no_output_qs
;
632 unsigned char qdioac
;
641 void (*original_int_handler
) (struct ccw_device
*,
642 unsigned long, struct irb
*);
644 /* leave these four members together at the end. won't be cleared in qdio_fill_irq */
646 struct qdio_q
*input_qs
[QDIO_MAX_QUEUES_PER_IRQ
];
647 struct qdio_q
*output_qs
[QDIO_MAX_QUEUES_PER_IRQ
];
648 struct semaphore setting_up_sema
;