8 #define VERSION_CIO_QDIO_H "$Revision: 1.40 $"
10 #ifdef CONFIG_QDIO_DEBUG
11 #define QDIO_VERBOSE_LEVEL 9
12 #else /* CONFIG_QDIO_DEBUG */
13 #define QDIO_VERBOSE_LEVEL 5
14 #endif /* CONFIG_QDIO_DEBUG */
15 #define QDIO_USE_PROCESSING_STATE
17 #ifdef CONFIG_QDIO_PERF_STATS
18 #define QDIO_PERFORMANCE_STATS
19 #endif /* CONFIG_QDIO_PERF_STATS */
21 #define QDIO_MINIMAL_BH_RELIEF_TIME 16
22 #define QDIO_TIMER_POLL_VALUE 1
23 #define IQDIO_TIMER_POLL_VALUE 1
26 * unfortunately this can't be (QDIO_MAX_BUFFERS_PER_Q*4/3) or so -- as
27 * we never know, whether we'll get initiative again, e.g. to give the
28 * transmit skb's back to the stack, however the stack may be waiting for
29 * them... therefore we define 4 as threshold to start polling (which
30 * will stop as soon as the asynchronous queue catches up)
31 * btw, this only applies to the asynchronous HiperSockets queue
33 #define IQDIO_FILL_LEVEL_TO_POLL 4
35 #define TIQDIO_THININT_ISC 3
36 #define TIQDIO_DELAY_TARGET 0
37 #define QDIO_BUSY_BIT_PATIENCE 100 /* in microsecs */
38 #define QDIO_BUSY_BIT_GIVE_UP 10000000 /* 10 seconds */
39 #define IQDIO_GLOBAL_LAPS 2 /* GLOBAL_LAPS are not used as we */
40 #define IQDIO_GLOBAL_LAPS_INT 1 /* don't global summary */
41 #define IQDIO_LOCAL_LAPS 4
42 #define IQDIO_LOCAL_LAPS_INT 1
43 #define IQDIO_GLOBAL_SUMMARY_CC_MASK 2
44 /*#define IQDIO_IQDC_INT_PARM 0x1234*/
48 #define QDIO_STORAGE_KEY PAGE_DEFAULT_KEY
50 #define L2_CACHELINE_SIZE 256
51 #define INDICATORS_PER_CACHELINE (L2_CACHELINE_SIZE/sizeof(__u32))
53 #define QDIO_PERF "qdio_perf"
55 /* must be a power of 2 */
56 /*#define QDIO_STATS_NUMBER 4
58 #define QDIO_STATS_CLASSES 2
59 #define QDIO_STATS_COUNT_NEEDED 2*/
61 #define QDIO_NO_USE_COUNT_TIMEOUT (1*HZ) /* wait for 1 sec on each q before
62 exiting without having use_count
65 #define QDIO_ESTABLISH_TIMEOUT (1*HZ)
66 #define QDIO_ACTIVATE_TIMEOUT ((5*HZ)>>10)
67 #define QDIO_CLEANUP_CLEAR_TIMEOUT (20*HZ)
68 #define QDIO_CLEANUP_HALT_TIMEOUT (10*HZ)
70 enum qdio_irq_states {
71 QDIO_IRQ_STATE_INACTIVE,
72 QDIO_IRQ_STATE_ESTABLISHED,
73 QDIO_IRQ_STATE_ACTIVE,
74 QDIO_IRQ_STATE_STOPPED,
75 QDIO_IRQ_STATE_CLEANUP,
80 /* used as intparm in do_IO: */
81 #define QDIO_DOING_SENSEID 0
82 #define QDIO_DOING_ESTABLISH 1
83 #define QDIO_DOING_ACTIVATE 2
84 #define QDIO_DOING_CLEANUP 3
86 /************************* DEBUG FACILITY STUFF *********************/
88 #define QDIO_DBF_HEX(ex,name,level,addr,len) \
91 debug_exception(qdio_dbf_##name,level,(void*)(addr),len); \
93 debug_event(qdio_dbf_##name,level,(void*)(addr),len); \
95 #define QDIO_DBF_TEXT(ex,name,level,text) \
98 debug_text_exception(qdio_dbf_##name,level,text); \
100 debug_text_event(qdio_dbf_##name,level,text); \
104 #define QDIO_DBF_HEX0(ex,name,addr,len) QDIO_DBF_HEX(ex,name,0,addr,len)
105 #define QDIO_DBF_HEX1(ex,name,addr,len) QDIO_DBF_HEX(ex,name,1,addr,len)
106 #define QDIO_DBF_HEX2(ex,name,addr,len) QDIO_DBF_HEX(ex,name,2,addr,len)
107 #ifdef CONFIG_QDIO_DEBUG
108 #define QDIO_DBF_HEX3(ex,name,addr,len) QDIO_DBF_HEX(ex,name,3,addr,len)
109 #define QDIO_DBF_HEX4(ex,name,addr,len) QDIO_DBF_HEX(ex,name,4,addr,len)
110 #define QDIO_DBF_HEX5(ex,name,addr,len) QDIO_DBF_HEX(ex,name,5,addr,len)
111 #define QDIO_DBF_HEX6(ex,name,addr,len) QDIO_DBF_HEX(ex,name,6,addr,len)
112 #else /* CONFIG_QDIO_DEBUG */
113 #define QDIO_DBF_HEX3(ex,name,addr,len) do {} while (0)
114 #define QDIO_DBF_HEX4(ex,name,addr,len) do {} while (0)
115 #define QDIO_DBF_HEX5(ex,name,addr,len) do {} while (0)
116 #define QDIO_DBF_HEX6(ex,name,addr,len) do {} while (0)
117 #endif /* CONFIG_QDIO_DEBUG */
119 #define QDIO_DBF_TEXT0(ex,name,text) QDIO_DBF_TEXT(ex,name,0,text)
120 #define QDIO_DBF_TEXT1(ex,name,text) QDIO_DBF_TEXT(ex,name,1,text)
121 #define QDIO_DBF_TEXT2(ex,name,text) QDIO_DBF_TEXT(ex,name,2,text)
122 #ifdef CONFIG_QDIO_DEBUG
123 #define QDIO_DBF_TEXT3(ex,name,text) QDIO_DBF_TEXT(ex,name,3,text)
124 #define QDIO_DBF_TEXT4(ex,name,text) QDIO_DBF_TEXT(ex,name,4,text)
125 #define QDIO_DBF_TEXT5(ex,name,text) QDIO_DBF_TEXT(ex,name,5,text)
126 #define QDIO_DBF_TEXT6(ex,name,text) QDIO_DBF_TEXT(ex,name,6,text)
127 #else /* CONFIG_QDIO_DEBUG */
128 #define QDIO_DBF_TEXT3(ex,name,text) do {} while (0)
129 #define QDIO_DBF_TEXT4(ex,name,text) do {} while (0)
130 #define QDIO_DBF_TEXT5(ex,name,text) do {} while (0)
131 #define QDIO_DBF_TEXT6(ex,name,text) do {} while (0)
132 #endif /* CONFIG_QDIO_DEBUG */
134 #define QDIO_DBF_SETUP_NAME "qdio_setup"
135 #define QDIO_DBF_SETUP_LEN 8
136 #define QDIO_DBF_SETUP_PAGES 4
137 #define QDIO_DBF_SETUP_NR_AREAS 1
138 #ifdef CONFIG_QDIO_DEBUG
139 #define QDIO_DBF_SETUP_LEVEL 6
140 #else /* CONFIG_QDIO_DEBUG */
141 #define QDIO_DBF_SETUP_LEVEL 2
142 #endif /* CONFIG_QDIO_DEBUG */
144 #define QDIO_DBF_SBAL_NAME "qdio_labs" /* sbal */
145 #define QDIO_DBF_SBAL_LEN 256
146 #define QDIO_DBF_SBAL_PAGES 4
147 #define QDIO_DBF_SBAL_NR_AREAS 2
148 #ifdef CONFIG_QDIO_DEBUG
149 #define QDIO_DBF_SBAL_LEVEL 6
150 #else /* CONFIG_QDIO_DEBUG */
151 #define QDIO_DBF_SBAL_LEVEL 2
152 #endif /* CONFIG_QDIO_DEBUG */
154 #define QDIO_DBF_TRACE_NAME "qdio_trace"
155 #define QDIO_DBF_TRACE_LEN 8
156 #define QDIO_DBF_TRACE_NR_AREAS 2
157 #ifdef CONFIG_QDIO_DEBUG
158 #define QDIO_DBF_TRACE_PAGES 16
159 #define QDIO_DBF_TRACE_LEVEL 4 /* -------- could be even more verbose here */
160 #else /* CONFIG_QDIO_DEBUG */
161 #define QDIO_DBF_TRACE_PAGES 4
162 #define QDIO_DBF_TRACE_LEVEL 2
163 #endif /* CONFIG_QDIO_DEBUG */
165 #define QDIO_DBF_SENSE_NAME "qdio_sense"
166 #define QDIO_DBF_SENSE_LEN 64
167 #define QDIO_DBF_SENSE_PAGES 2
168 #define QDIO_DBF_SENSE_NR_AREAS 1
169 #ifdef CONFIG_QDIO_DEBUG
170 #define QDIO_DBF_SENSE_LEVEL 6
171 #else /* CONFIG_QDIO_DEBUG */
172 #define QDIO_DBF_SENSE_LEVEL 2
173 #endif /* CONFIG_QDIO_DEBUG */
175 #ifdef CONFIG_QDIO_DEBUG
176 #define QDIO_TRACE_QTYPE QDIO_ZFCP_QFMT
178 #define QDIO_DBF_SLSB_OUT_NAME "qdio_slsb_out"
179 #define QDIO_DBF_SLSB_OUT_LEN QDIO_MAX_BUFFERS_PER_Q
180 #define QDIO_DBF_SLSB_OUT_PAGES 256
181 #define QDIO_DBF_SLSB_OUT_NR_AREAS 1
182 #define QDIO_DBF_SLSB_OUT_LEVEL 6
184 #define QDIO_DBF_SLSB_IN_NAME "qdio_slsb_in"
185 #define QDIO_DBF_SLSB_IN_LEN QDIO_MAX_BUFFERS_PER_Q
186 #define QDIO_DBF_SLSB_IN_PAGES 256
187 #define QDIO_DBF_SLSB_IN_NR_AREAS 1
188 #define QDIO_DBF_SLSB_IN_LEVEL 6
189 #endif /* CONFIG_QDIO_DEBUG */
191 #define QDIO_PRINTK_HEADER QDIO_NAME ": "
193 #if QDIO_VERBOSE_LEVEL>8
194 #define QDIO_PRINT_STUPID(x...) printk( KERN_DEBUG QDIO_PRINTK_HEADER x)
196 #define QDIO_PRINT_STUPID(x...)
199 #if QDIO_VERBOSE_LEVEL>7
200 #define QDIO_PRINT_ALL(x...) printk( QDIO_PRINTK_HEADER x)
202 #define QDIO_PRINT_ALL(x...)
205 #if QDIO_VERBOSE_LEVEL>6
206 #define QDIO_PRINT_INFO(x...) printk( QDIO_PRINTK_HEADER x)
208 #define QDIO_PRINT_INFO(x...)
211 #if QDIO_VERBOSE_LEVEL>5
212 #define QDIO_PRINT_WARN(x...) printk( QDIO_PRINTK_HEADER x)
214 #define QDIO_PRINT_WARN(x...)
217 #if QDIO_VERBOSE_LEVEL>4
218 #define QDIO_PRINT_ERR(x...) printk( QDIO_PRINTK_HEADER x)
220 #define QDIO_PRINT_ERR(x...)
223 #if QDIO_VERBOSE_LEVEL>3
224 #define QDIO_PRINT_CRIT(x...) printk( QDIO_PRINTK_HEADER x)
226 #define QDIO_PRINT_CRIT(x...)
229 #if QDIO_VERBOSE_LEVEL>2
230 #define QDIO_PRINT_ALERT(x...) printk( QDIO_PRINTK_HEADER x)
232 #define QDIO_PRINT_ALERT(x...)
235 #if QDIO_VERBOSE_LEVEL>1
236 #define QDIO_PRINT_EMERG(x...) printk( QDIO_PRINTK_HEADER x)
238 #define QDIO_PRINT_EMERG(x...)
241 #define HEXDUMP16(importance,header,ptr) \
242 QDIO_PRINT_##importance(header "%02x %02x %02x %02x " \
243 "%02x %02x %02x %02x %02x %02x %02x %02x " \
244 "%02x %02x %02x %02x\n",*(((char*)ptr)), \
245 *(((char*)ptr)+1),*(((char*)ptr)+2), \
246 *(((char*)ptr)+3),*(((char*)ptr)+4), \
247 *(((char*)ptr)+5),*(((char*)ptr)+6), \
248 *(((char*)ptr)+7),*(((char*)ptr)+8), \
249 *(((char*)ptr)+9),*(((char*)ptr)+10), \
250 *(((char*)ptr)+11),*(((char*)ptr)+12), \
251 *(((char*)ptr)+13),*(((char*)ptr)+14), \
252 *(((char*)ptr)+15)); \
253 QDIO_PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
254 "%02x %02x %02x %02x %02x %02x %02x %02x\n", \
255 *(((char*)ptr)+16),*(((char*)ptr)+17), \
256 *(((char*)ptr)+18),*(((char*)ptr)+19), \
257 *(((char*)ptr)+20),*(((char*)ptr)+21), \
258 *(((char*)ptr)+22),*(((char*)ptr)+23), \
259 *(((char*)ptr)+24),*(((char*)ptr)+25), \
260 *(((char*)ptr)+26),*(((char*)ptr)+27), \
261 *(((char*)ptr)+28),*(((char*)ptr)+29), \
262 *(((char*)ptr)+30),*(((char*)ptr)+31));
264 /****************** END OF DEBUG FACILITY STUFF *********************/
267 * Some instructions as assembly
271 do_sqbs(unsigned long sch, unsigned char state, int queue,
272 unsigned int *start, unsigned int *count)
275 register unsigned long _ccq asm ("0") = *count;
276 register unsigned long _sch asm ("1") = sch;
277 unsigned long _queuestart = ((unsigned long)queue << 32) | *start;
280 " .insn rsy,0xeb000000008A,%1,0,0(%2)\n\t"
281 : "+d" (_ccq), "+d" (_queuestart)
282 : "d" ((unsigned long)state), "d" (_sch)
285 *count = _ccq & 0xff;
286 *start = _queuestart & 0xff;
288 return (_ccq >> 32) & 0xff;
295 do_eqbs(unsigned long sch, unsigned char *state, int queue,
296 unsigned int *start, unsigned int *count)
299 register unsigned long _ccq asm ("0") = *count;
300 register unsigned long _sch asm ("1") = sch;
301 unsigned long _queuestart = ((unsigned long)queue << 32) | *start;
302 unsigned long _state = 0;
305 " .insn rrf,0xB99c0000,%1,%2,0,0 \n\t"
306 : "+d" (_ccq), "+d" (_queuestart), "+d" (_state)
310 *count = _ccq & 0xff;
311 *start = _queuestart & 0xff;
312 *state = _state & 0xff;
314 return (_ccq >> 32) & 0xff;
322 do_siga_sync(struct subchannel_id schid, unsigned int mask1, unsigned int mask2)
336 : "d" (schid), "d" (mask1), "d" (mask2)
337 : "cc", "0", "1", "2", "3"
339 #else /* CONFIG_64BIT */
349 : "d" (schid), "d" (mask1), "d" (mask2)
350 : "cc", "0", "1", "2", "3"
352 #endif /* CONFIG_64BIT */
357 do_siga_input(struct subchannel_id schid, unsigned int mask)
370 : "d" (schid), "d" (mask)
371 : "cc", "0", "1", "2", "memory"
373 #else /* CONFIG_64BIT */
382 : "d" (schid), "d" (mask)
383 : "cc", "0", "1", "2", "memory"
385 #endif /* CONFIG_64BIT */
391 do_siga_output(unsigned long schid, unsigned long mask, __u32 *bb,
409 ".section .fixup,\"ax\"\n\t"
418 ".section __ex_table,\"a\"\n\t"
422 : "=d" (cc), "=d" (busy_bit)
423 : "d" (schid), "d" (mask),
424 "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION)
425 : "cc", "0", "1", "2", "memory"
427 #else /* CONFIG_64BIT */
439 ".section .fixup,\"ax\"\n\t"
443 ".section __ex_table,\"a\"\n\t"
447 : "=d" (cc), "=d" (busy_bit)
448 : "d" (schid), "d" (mask),
449 "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION), "d" (fc)
450 : "cc", "0", "1", "2", "memory"
452 #endif /* CONFIG_64BIT */
458 static inline unsigned long
459 do_clear_global_summary(void)
467 ".insn rre,0xb2650000,2,0 \n\t"
469 : "=d" (time) : : "cc", "1", "2", "3"
471 #else /* CONFIG_64BIT */
474 ".insn rre,0xb2650000,2,0 \n\t"
476 : "=d" (time) : : "cc", "1", "2", "3"
478 #endif /* CONFIG_64BIT */
484 * QDIO device commands returned by extended Sense-ID
486 #define DEFAULT_ESTABLISH_QS_CMD 0x1b
487 #define DEFAULT_ESTABLISH_QS_COUNT 0x1000
488 #define DEFAULT_ACTIVATE_QS_CMD 0x1f
489 #define DEFAULT_ACTIVATE_QS_COUNT 0
492 * additional CIWs returned by extended Sense-ID
494 #define CIW_TYPE_EQUEUE 0x3 /* establish QDIO queues */
495 #define CIW_TYPE_AQUEUE 0x4 /* activate QDIO queues */
497 #define QDIO_CHSC_RESPONSE_CODE_OK 1
498 /* flags for st qdio sch data */
499 #define CHSC_FLAG_QDIO_CAPABILITY 0x80
500 #define CHSC_FLAG_VALIDITY 0x40
502 #define CHSC_FLAG_SIGA_INPUT_NECESSARY 0x40
503 #define CHSC_FLAG_SIGA_OUTPUT_NECESSARY 0x20
504 #define CHSC_FLAG_SIGA_SYNC_NECESSARY 0x10
505 #define CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS 0x08
506 #define CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS 0x04
508 #ifdef QDIO_PERFORMANCE_STATS
509 struct qdio_perf_stats {
510 unsigned int tl_runs;
512 unsigned int siga_outs;
513 unsigned int siga_ins;
514 unsigned int siga_syncs;
516 unsigned int thinints;
517 unsigned int fast_reqs;
519 __u64 start_time_outbound;
520 unsigned int outbound_cnt;
521 unsigned int outbound_time;
522 __u64 start_time_inbound;
523 unsigned int inbound_cnt;
524 unsigned int inbound_time;
526 #endif /* QDIO_PERFORMANCE_STATS */
528 #define atomic_swap(a,b) xchg((int*)a.counter,b)
530 /* unlikely as the later the better */
531 #define SYNC_MEMORY if (unlikely(q->siga_sync)) qdio_siga_sync_q(q)
532 #define SYNC_MEMORY_ALL if (unlikely(q->siga_sync)) \
533 qdio_siga_sync(q,~0U,~0U)
534 #define SYNC_MEMORY_ALL_OUTB if (unlikely(q->siga_sync)) \
535 qdio_siga_sync(q,~0U,0)
537 #define NOW qdio_get_micros()
538 #define SAVE_TIMESTAMP(q) q->timing.last_transfer_time=NOW
539 #define GET_SAVED_TIMESTAMP(q) (q->timing.last_transfer_time)
540 #define SAVE_FRONTIER(q,val) q->last_move_ftc=val
541 #define GET_SAVED_FRONTIER(q) (q->last_move_ftc)
543 #define MY_MODULE_STRING(x) #x
546 #define QDIO_GET_ADDR(x) ((__u32)(unsigned long)x)
547 #else /* CONFIG_64BIT */
548 #define QDIO_GET_ADDR(x) ((__u32)(long)x)
549 #endif /* CONFIG_64BIT */
552 volatile struct slsb slsb;
554 char unused[QDIO_MAX_BUFFERS_PER_Q];
556 __u32 * dev_st_chg_ind;
559 struct subchannel_id schid;
560 struct ccw_device *cdev;
562 unsigned int is_iqdio_q;
563 unsigned int is_thinint_q;
565 /* bit 0 means queue 0, bit 1 means queue 1, ... */
569 qdio_handler_t (*handler);
571 /* points to the next buffer to be checked for having
572 * been processed by the card (outbound)
573 * or to the next buffer the program should check for (inbound) */
574 volatile int first_to_check;
575 /* and the last time it was: */
576 volatile int last_move_ftc;
578 atomic_t number_of_buffers_used;
581 unsigned int siga_in;
582 unsigned int siga_out;
583 unsigned int siga_sync;
584 unsigned int siga_sync_done_on_thinints;
585 unsigned int siga_sync_done_on_outb_tis;
586 unsigned int hydra_gives_outbound_pcis;
588 /* used to save beginning position when calling dd_handlers */
589 int first_element_to_kick;
592 atomic_t is_in_shutdown;
596 #ifdef QDIO_USE_TIMERS_FOR_POLLING
597 struct timer_list timer;
598 atomic_t timer_already_set;
599 spinlock_t timer_lock;
600 #else /* QDIO_USE_TIMERS_FOR_POLLING */
601 struct tasklet_struct tasklet;
602 #endif /* QDIO_USE_TIMERS_FOR_POLLING */
605 enum qdio_irq_states state;
607 /* used to store the error condition during a data transfer */
608 unsigned int qdio_error;
609 unsigned int siga_error;
610 unsigned int error_status_flags;
612 /* list of interesting queues */
613 volatile struct qdio_q *list_next;
614 volatile struct qdio_q *list_prev;
617 volatile struct sbal *sbal[QDIO_MAX_BUFFERS_PER_Q];
619 struct qdio_buffer *qdio_buffers[QDIO_MAX_BUFFERS_PER_Q];
621 unsigned long int_parm;
624 int in_bh_check_limit;
626 } threshold_classes[QDIO_STATS_CLASSES];*/
629 /* inbound: the time to stop polling
630 outbound: the time to kick peer */
631 int threshold; /* the real value */
633 /* outbound: last time of do_QDIO
634 inbound: last time of noticing incoming data */
635 /*__u64 last_transfer_times[QDIO_STATS_NUMBER];
636 int last_transfer_index; */
638 __u64 last_transfer_time;
641 atomic_t busy_siga_counter;
642 unsigned int queue_type;
644 /* leave this member at the end. won't be cleared in qdio_fill_qs */
645 struct slib *slib; /* a page is allocated under this pointer,
646 sl points into this page, offset PAGE_SIZE/2
648 } __attribute__ ((aligned(256)));
651 __u32 * volatile dev_st_chg_ind;
653 unsigned long int_parm;
654 struct subchannel_id schid;
656 unsigned int is_iqdio_irq;
657 unsigned int is_thinint_irq;
658 unsigned int hydra_gives_outbound_pcis;
659 unsigned int sync_done_on_outb_pcis;
662 unsigned int is_qebsm;
663 unsigned long sch_token;
665 enum qdio_irq_states state;
667 unsigned int no_input_qs;
668 unsigned int no_output_qs;
670 unsigned char qdioac;
679 void (*original_int_handler) (struct ccw_device *,
680 unsigned long, struct irb *);
682 /* leave these four members together at the end. won't be cleared in qdio_fill_irq */
684 struct qdio_q *input_qs[QDIO_MAX_QUEUES_PER_IRQ];
685 struct qdio_q *output_qs[QDIO_MAX_QUEUES_PER_IRQ];
686 struct semaphore setting_up_sema;