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 */
13 #define QDIO_USE_PROCESSING_STATE
15 #ifdef CONFIG_QDIO_PERF_STATS
16 #define QDIO_PERFORMANCE_STATS
17 #endif /* CONFIG_QDIO_PERF_STATS */
19 #define QDIO_MINIMAL_BH_RELIEF_TIME 16
20 #define QDIO_TIMER_POLL_VALUE 1
21 #define IQDIO_TIMER_POLL_VALUE 1
24 * unfortunately this can't be (QDIO_MAX_BUFFERS_PER_Q*4/3) or so -- as
25 * we never know, whether we'll get initiative again, e.g. to give the
26 * transmit skb's back to the stack, however the stack may be waiting for
27 * them... therefore we define 4 as threshold to start polling (which
28 * will stop as soon as the asynchronous queue catches up)
29 * btw, this only applies to the asynchronous HiperSockets queue
31 #define IQDIO_FILL_LEVEL_TO_POLL 4
33 #define TIQDIO_THININT_ISC 3
34 #define TIQDIO_DELAY_TARGET 0
35 #define QDIO_BUSY_BIT_PATIENCE 100 /* in microsecs */
36 #define QDIO_BUSY_BIT_GIVE_UP 10000000 /* 10 seconds */
37 #define IQDIO_GLOBAL_LAPS 2 /* GLOBAL_LAPS are not used as we */
38 #define IQDIO_GLOBAL_LAPS_INT 1 /* don't global summary */
39 #define IQDIO_LOCAL_LAPS 4
40 #define IQDIO_LOCAL_LAPS_INT 1
41 #define IQDIO_GLOBAL_SUMMARY_CC_MASK 2
42 /*#define IQDIO_IQDC_INT_PARM 0x1234*/
46 #define QDIO_STORAGE_KEY PAGE_DEFAULT_KEY
48 #define L2_CACHELINE_SIZE 256
49 #define INDICATORS_PER_CACHELINE (L2_CACHELINE_SIZE/sizeof(__u32))
51 #define QDIO_PERF "qdio_perf"
53 /* must be a power of 2 */
54 /*#define QDIO_STATS_NUMBER 4
56 #define QDIO_STATS_CLASSES 2
57 #define QDIO_STATS_COUNT_NEEDED 2*/
59 #define QDIO_NO_USE_COUNT_TIMEOUT (1*HZ) /* wait for 1 sec on each q before
60 exiting without having use_count
63 #define QDIO_ESTABLISH_TIMEOUT (1*HZ)
64 #define QDIO_ACTIVATE_TIMEOUT ((5*HZ)>>10)
65 #define QDIO_CLEANUP_CLEAR_TIMEOUT (20*HZ)
66 #define QDIO_CLEANUP_HALT_TIMEOUT (10*HZ)
68 enum qdio_irq_states {
69 QDIO_IRQ_STATE_INACTIVE,
70 QDIO_IRQ_STATE_ESTABLISHED,
71 QDIO_IRQ_STATE_ACTIVE,
72 QDIO_IRQ_STATE_STOPPED,
73 QDIO_IRQ_STATE_CLEANUP,
78 /* used as intparm in do_IO: */
79 #define QDIO_DOING_SENSEID 0
80 #define QDIO_DOING_ESTABLISH 1
81 #define QDIO_DOING_ACTIVATE 2
82 #define QDIO_DOING_CLEANUP 3
84 /************************* DEBUG FACILITY STUFF *********************/
86 #define QDIO_DBF_HEX(ex,name,level,addr,len) \
89 debug_exception(qdio_dbf_##name,level,(void*)(addr),len); \
91 debug_event(qdio_dbf_##name,level,(void*)(addr),len); \
93 #define QDIO_DBF_TEXT(ex,name,level,text) \
96 debug_text_exception(qdio_dbf_##name,level,text); \
98 debug_text_event(qdio_dbf_##name,level,text); \
102 #define QDIO_DBF_HEX0(ex,name,addr,len) QDIO_DBF_HEX(ex,name,0,addr,len)
103 #define QDIO_DBF_HEX1(ex,name,addr,len) QDIO_DBF_HEX(ex,name,1,addr,len)
104 #define QDIO_DBF_HEX2(ex,name,addr,len) QDIO_DBF_HEX(ex,name,2,addr,len)
105 #ifdef CONFIG_QDIO_DEBUG
106 #define QDIO_DBF_HEX3(ex,name,addr,len) QDIO_DBF_HEX(ex,name,3,addr,len)
107 #define QDIO_DBF_HEX4(ex,name,addr,len) QDIO_DBF_HEX(ex,name,4,addr,len)
108 #define QDIO_DBF_HEX5(ex,name,addr,len) QDIO_DBF_HEX(ex,name,5,addr,len)
109 #define QDIO_DBF_HEX6(ex,name,addr,len) QDIO_DBF_HEX(ex,name,6,addr,len)
110 #else /* CONFIG_QDIO_DEBUG */
111 #define QDIO_DBF_HEX3(ex,name,addr,len) do {} while (0)
112 #define QDIO_DBF_HEX4(ex,name,addr,len) do {} while (0)
113 #define QDIO_DBF_HEX5(ex,name,addr,len) do {} while (0)
114 #define QDIO_DBF_HEX6(ex,name,addr,len) do {} while (0)
115 #endif /* CONFIG_QDIO_DEBUG */
117 #define QDIO_DBF_TEXT0(ex,name,text) QDIO_DBF_TEXT(ex,name,0,text)
118 #define QDIO_DBF_TEXT1(ex,name,text) QDIO_DBF_TEXT(ex,name,1,text)
119 #define QDIO_DBF_TEXT2(ex,name,text) QDIO_DBF_TEXT(ex,name,2,text)
120 #ifdef CONFIG_QDIO_DEBUG
121 #define QDIO_DBF_TEXT3(ex,name,text) QDIO_DBF_TEXT(ex,name,3,text)
122 #define QDIO_DBF_TEXT4(ex,name,text) QDIO_DBF_TEXT(ex,name,4,text)
123 #define QDIO_DBF_TEXT5(ex,name,text) QDIO_DBF_TEXT(ex,name,5,text)
124 #define QDIO_DBF_TEXT6(ex,name,text) QDIO_DBF_TEXT(ex,name,6,text)
125 #else /* CONFIG_QDIO_DEBUG */
126 #define QDIO_DBF_TEXT3(ex,name,text) do {} while (0)
127 #define QDIO_DBF_TEXT4(ex,name,text) do {} while (0)
128 #define QDIO_DBF_TEXT5(ex,name,text) do {} while (0)
129 #define QDIO_DBF_TEXT6(ex,name,text) do {} while (0)
130 #endif /* CONFIG_QDIO_DEBUG */
132 #define QDIO_DBF_SETUP_NAME "qdio_setup"
133 #define QDIO_DBF_SETUP_LEN 8
134 #define QDIO_DBF_SETUP_PAGES 4
135 #define QDIO_DBF_SETUP_NR_AREAS 1
136 #ifdef CONFIG_QDIO_DEBUG
137 #define QDIO_DBF_SETUP_LEVEL 6
138 #else /* CONFIG_QDIO_DEBUG */
139 #define QDIO_DBF_SETUP_LEVEL 2
140 #endif /* CONFIG_QDIO_DEBUG */
142 #define QDIO_DBF_SBAL_NAME "qdio_labs" /* sbal */
143 #define QDIO_DBF_SBAL_LEN 256
144 #define QDIO_DBF_SBAL_PAGES 4
145 #define QDIO_DBF_SBAL_NR_AREAS 2
146 #ifdef CONFIG_QDIO_DEBUG
147 #define QDIO_DBF_SBAL_LEVEL 6
148 #else /* CONFIG_QDIO_DEBUG */
149 #define QDIO_DBF_SBAL_LEVEL 2
150 #endif /* CONFIG_QDIO_DEBUG */
152 #define QDIO_DBF_TRACE_NAME "qdio_trace"
153 #define QDIO_DBF_TRACE_LEN 8
154 #define QDIO_DBF_TRACE_NR_AREAS 2
155 #ifdef CONFIG_QDIO_DEBUG
156 #define QDIO_DBF_TRACE_PAGES 16
157 #define QDIO_DBF_TRACE_LEVEL 4 /* -------- could be even more verbose here */
158 #else /* CONFIG_QDIO_DEBUG */
159 #define QDIO_DBF_TRACE_PAGES 4
160 #define QDIO_DBF_TRACE_LEVEL 2
161 #endif /* CONFIG_QDIO_DEBUG */
163 #define QDIO_DBF_SENSE_NAME "qdio_sense"
164 #define QDIO_DBF_SENSE_LEN 64
165 #define QDIO_DBF_SENSE_PAGES 2
166 #define QDIO_DBF_SENSE_NR_AREAS 1
167 #ifdef CONFIG_QDIO_DEBUG
168 #define QDIO_DBF_SENSE_LEVEL 6
169 #else /* CONFIG_QDIO_DEBUG */
170 #define QDIO_DBF_SENSE_LEVEL 2
171 #endif /* CONFIG_QDIO_DEBUG */
173 #ifdef CONFIG_QDIO_DEBUG
174 #define QDIO_TRACE_QTYPE QDIO_ZFCP_QFMT
176 #define QDIO_DBF_SLSB_OUT_NAME "qdio_slsb_out"
177 #define QDIO_DBF_SLSB_OUT_LEN QDIO_MAX_BUFFERS_PER_Q
178 #define QDIO_DBF_SLSB_OUT_PAGES 256
179 #define QDIO_DBF_SLSB_OUT_NR_AREAS 1
180 #define QDIO_DBF_SLSB_OUT_LEVEL 6
182 #define QDIO_DBF_SLSB_IN_NAME "qdio_slsb_in"
183 #define QDIO_DBF_SLSB_IN_LEN QDIO_MAX_BUFFERS_PER_Q
184 #define QDIO_DBF_SLSB_IN_PAGES 256
185 #define QDIO_DBF_SLSB_IN_NR_AREAS 1
186 #define QDIO_DBF_SLSB_IN_LEVEL 6
187 #endif /* CONFIG_QDIO_DEBUG */
189 #define QDIO_PRINTK_HEADER QDIO_NAME ": "
191 #if QDIO_VERBOSE_LEVEL>8
192 #define QDIO_PRINT_STUPID(x...) printk( KERN_DEBUG QDIO_PRINTK_HEADER x)
194 #define QDIO_PRINT_STUPID(x...) do { } while (0)
197 #if QDIO_VERBOSE_LEVEL>7
198 #define QDIO_PRINT_ALL(x...) printk( QDIO_PRINTK_HEADER x)
200 #define QDIO_PRINT_ALL(x...) do { } while (0)
203 #if QDIO_VERBOSE_LEVEL>6
204 #define QDIO_PRINT_INFO(x...) printk( QDIO_PRINTK_HEADER x)
206 #define QDIO_PRINT_INFO(x...) do { } while (0)
209 #if QDIO_VERBOSE_LEVEL>5
210 #define QDIO_PRINT_WARN(x...) printk( QDIO_PRINTK_HEADER x)
212 #define QDIO_PRINT_WARN(x...) do { } while (0)
215 #if QDIO_VERBOSE_LEVEL>4
216 #define QDIO_PRINT_ERR(x...) printk( QDIO_PRINTK_HEADER x)
218 #define QDIO_PRINT_ERR(x...) do { } while (0)
221 #if QDIO_VERBOSE_LEVEL>3
222 #define QDIO_PRINT_CRIT(x...) printk( QDIO_PRINTK_HEADER x)
224 #define QDIO_PRINT_CRIT(x...) do { } while (0)
227 #if QDIO_VERBOSE_LEVEL>2
228 #define QDIO_PRINT_ALERT(x...) printk( QDIO_PRINTK_HEADER x)
230 #define QDIO_PRINT_ALERT(x...) do { } while (0)
233 #if QDIO_VERBOSE_LEVEL>1
234 #define QDIO_PRINT_EMERG(x...) printk( QDIO_PRINTK_HEADER x)
236 #define QDIO_PRINT_EMERG(x...) do { } while (0)
239 #define QDIO_HEXDUMP16(importance,header,ptr) \
240 QDIO_PRINT_##importance(header "%02x %02x %02x %02x " \
241 "%02x %02x %02x %02x %02x %02x %02x %02x " \
242 "%02x %02x %02x %02x\n",*(((char*)ptr)), \
243 *(((char*)ptr)+1),*(((char*)ptr)+2), \
244 *(((char*)ptr)+3),*(((char*)ptr)+4), \
245 *(((char*)ptr)+5),*(((char*)ptr)+6), \
246 *(((char*)ptr)+7),*(((char*)ptr)+8), \
247 *(((char*)ptr)+9),*(((char*)ptr)+10), \
248 *(((char*)ptr)+11),*(((char*)ptr)+12), \
249 *(((char*)ptr)+13),*(((char*)ptr)+14), \
250 *(((char*)ptr)+15)); \
251 QDIO_PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
252 "%02x %02x %02x %02x %02x %02x %02x %02x\n", \
253 *(((char*)ptr)+16),*(((char*)ptr)+17), \
254 *(((char*)ptr)+18),*(((char*)ptr)+19), \
255 *(((char*)ptr)+20),*(((char*)ptr)+21), \
256 *(((char*)ptr)+22),*(((char*)ptr)+23), \
257 *(((char*)ptr)+24),*(((char*)ptr)+25), \
258 *(((char*)ptr)+26),*(((char*)ptr)+27), \
259 *(((char*)ptr)+28),*(((char*)ptr)+29), \
260 *(((char*)ptr)+30),*(((char*)ptr)+31));
262 /****************** END OF DEBUG FACILITY STUFF *********************/
265 * Some instructions as assembly
269 do_sqbs(unsigned long sch, unsigned char state, int queue,
270 unsigned int *start, unsigned int *count)
273 register unsigned long _ccq asm ("0") = *count;
274 register unsigned long _sch asm ("1") = sch;
275 unsigned long _queuestart = ((unsigned long)queue << 32) | *start;
278 " .insn rsy,0xeb000000008A,%1,0,0(%2)"
279 : "+d" (_ccq), "+d" (_queuestart)
280 : "d" ((unsigned long)state), "d" (_sch)
282 *count = _ccq & 0xff;
283 *start = _queuestart & 0xff;
285 return (_ccq >> 32) & 0xff;
292 do_eqbs(unsigned long sch, unsigned char *state, int queue,
293 unsigned int *start, unsigned int *count)
296 register unsigned long _ccq asm ("0") = *count;
297 register unsigned long _sch asm ("1") = sch;
298 unsigned long _queuestart = ((unsigned long)queue << 32) | *start;
299 unsigned long _state = 0;
302 " .insn rrf,0xB99c0000,%1,%2,0,0"
303 : "+d" (_ccq), "+d" (_queuestart), "+d" (_state)
306 *count = _ccq & 0xff;
307 *start = _queuestart & 0xff;
308 *state = _state & 0xff;
310 return (_ccq >> 32) & 0xff;
318 do_siga_sync(struct subchannel_id schid, unsigned int mask1, unsigned int mask2)
320 register unsigned long reg0 asm ("0") = 2;
321 register struct subchannel_id reg1 asm ("1") = schid;
322 register unsigned long reg2 asm ("2") = mask1;
323 register unsigned long reg3 asm ("3") = mask2;
331 : "d" (reg0), "d" (reg1), "d" (reg2), "d" (reg3) : "cc");
336 do_siga_input(struct subchannel_id schid, unsigned int mask)
338 register unsigned long reg0 asm ("0") = 1;
339 register struct subchannel_id reg1 asm ("1") = schid;
340 register unsigned long reg2 asm ("2") = mask;
348 : "d" (reg0), "d" (reg1), "d" (reg2) : "cc", "memory");
353 do_siga_output(unsigned long schid, unsigned long mask, __u32 *bb,
356 register unsigned long __fc asm("0") = fc;
357 register unsigned long __schid asm("1") = schid;
358 register unsigned long __mask asm("2") = mask;
367 : "=d" (cc), "+d" (__fc), "+d" (__schid), "+d" (__mask)
368 : "0" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION)
370 (*bb) = ((unsigned int) __fc) >> 31;
374 static inline unsigned long
375 do_clear_global_summary(void)
377 register unsigned long __fn asm("1") = 3;
378 register unsigned long __tmp asm("2");
379 register unsigned long __time asm("3");
382 " .insn rre,0xb2650000,2,0"
383 : "+d" (__fn), "=d" (__tmp), "=d" (__time));
388 * QDIO device commands returned by extended Sense-ID
390 #define DEFAULT_ESTABLISH_QS_CMD 0x1b
391 #define DEFAULT_ESTABLISH_QS_COUNT 0x1000
392 #define DEFAULT_ACTIVATE_QS_CMD 0x1f
393 #define DEFAULT_ACTIVATE_QS_COUNT 0
396 * additional CIWs returned by extended Sense-ID
398 #define CIW_TYPE_EQUEUE 0x3 /* establish QDIO queues */
399 #define CIW_TYPE_AQUEUE 0x4 /* activate QDIO queues */
401 #define QDIO_CHSC_RESPONSE_CODE_OK 1
402 /* flags for st qdio sch data */
403 #define CHSC_FLAG_QDIO_CAPABILITY 0x80
404 #define CHSC_FLAG_VALIDITY 0x40
406 #define CHSC_FLAG_SIGA_INPUT_NECESSARY 0x40
407 #define CHSC_FLAG_SIGA_OUTPUT_NECESSARY 0x20
408 #define CHSC_FLAG_SIGA_SYNC_NECESSARY 0x10
409 #define CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS 0x08
410 #define CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS 0x04
412 #ifdef QDIO_PERFORMANCE_STATS
413 struct qdio_perf_stats {
414 unsigned int tl_runs;
416 unsigned int siga_outs;
417 unsigned int siga_ins;
418 unsigned int siga_syncs;
420 unsigned int thinints;
421 unsigned int fast_reqs;
423 __u64 start_time_outbound;
424 unsigned int outbound_cnt;
425 unsigned int outbound_time;
426 __u64 start_time_inbound;
427 unsigned int inbound_cnt;
428 unsigned int inbound_time;
430 #endif /* QDIO_PERFORMANCE_STATS */
432 /* unlikely as the later the better */
433 #define SYNC_MEMORY if (unlikely(q->siga_sync)) qdio_siga_sync_q(q)
434 #define SYNC_MEMORY_ALL if (unlikely(q->siga_sync)) \
435 qdio_siga_sync(q,~0U,~0U)
436 #define SYNC_MEMORY_ALL_OUTB if (unlikely(q->siga_sync)) \
437 qdio_siga_sync(q,~0U,0)
439 #define NOW qdio_get_micros()
440 #define SAVE_TIMESTAMP(q) q->timing.last_transfer_time=NOW
441 #define GET_SAVED_TIMESTAMP(q) (q->timing.last_transfer_time)
442 #define SAVE_FRONTIER(q,val) q->last_move_ftc=val
443 #define GET_SAVED_FRONTIER(q) (q->last_move_ftc)
445 #define MY_MODULE_STRING(x) #x
448 #define QDIO_GET_ADDR(x) ((__u32)(unsigned long)x)
449 #else /* CONFIG_64BIT */
450 #define QDIO_GET_ADDR(x) ((__u32)(long)x)
451 #endif /* CONFIG_64BIT */
454 volatile struct slsb slsb;
456 char unused[QDIO_MAX_BUFFERS_PER_Q];
458 __u32 * dev_st_chg_ind;
461 struct subchannel_id schid;
462 struct ccw_device *cdev;
464 unsigned int is_iqdio_q;
465 unsigned int is_thinint_q;
467 /* bit 0 means queue 0, bit 1 means queue 1, ... */
471 qdio_handler_t (*handler);
473 /* points to the next buffer to be checked for having
474 * been processed by the card (outbound)
475 * or to the next buffer the program should check for (inbound) */
476 volatile int first_to_check;
477 /* and the last time it was: */
478 volatile int last_move_ftc;
480 atomic_t number_of_buffers_used;
483 unsigned int siga_in;
484 unsigned int siga_out;
485 unsigned int siga_sync;
486 unsigned int siga_sync_done_on_thinints;
487 unsigned int siga_sync_done_on_outb_tis;
488 unsigned int hydra_gives_outbound_pcis;
490 /* used to save beginning position when calling dd_handlers */
491 int first_element_to_kick;
494 atomic_t is_in_shutdown;
498 #ifdef QDIO_USE_TIMERS_FOR_POLLING
499 struct timer_list timer;
500 atomic_t timer_already_set;
501 spinlock_t timer_lock;
502 #else /* QDIO_USE_TIMERS_FOR_POLLING */
503 struct tasklet_struct tasklet;
504 #endif /* QDIO_USE_TIMERS_FOR_POLLING */
507 enum qdio_irq_states state;
509 /* used to store the error condition during a data transfer */
510 unsigned int qdio_error;
511 unsigned int siga_error;
512 unsigned int error_status_flags;
514 /* list of interesting queues */
515 volatile struct qdio_q *list_next;
516 volatile struct qdio_q *list_prev;
519 volatile struct sbal *sbal[QDIO_MAX_BUFFERS_PER_Q];
521 struct qdio_buffer *qdio_buffers[QDIO_MAX_BUFFERS_PER_Q];
523 unsigned long int_parm;
526 int in_bh_check_limit;
528 } threshold_classes[QDIO_STATS_CLASSES];*/
531 /* inbound: the time to stop polling
532 outbound: the time to kick peer */
533 int threshold; /* the real value */
535 /* outbound: last time of do_QDIO
536 inbound: last time of noticing incoming data */
537 /*__u64 last_transfer_times[QDIO_STATS_NUMBER];
538 int last_transfer_index; */
540 __u64 last_transfer_time;
543 atomic_t busy_siga_counter;
544 unsigned int queue_type;
546 /* leave this member at the end. won't be cleared in qdio_fill_qs */
547 struct slib *slib; /* a page is allocated under this pointer,
548 sl points into this page, offset PAGE_SIZE/2
550 } __attribute__ ((aligned(256)));
553 __u32 * volatile dev_st_chg_ind;
555 unsigned long int_parm;
556 struct subchannel_id schid;
558 unsigned int is_iqdio_irq;
559 unsigned int is_thinint_irq;
560 unsigned int hydra_gives_outbound_pcis;
561 unsigned int sync_done_on_outb_pcis;
564 unsigned int is_qebsm;
565 unsigned long sch_token;
567 enum qdio_irq_states state;
569 unsigned int no_input_qs;
570 unsigned int no_output_qs;
572 unsigned char qdioac;
581 void (*original_int_handler) (struct ccw_device *,
582 unsigned long, struct irb *);
584 /* leave these four members together at the end. won't be cleared in qdio_fill_irq */
586 struct qdio_q *input_qs[QDIO_MAX_QUEUES_PER_IRQ];
587 struct qdio_q *output_qs[QDIO_MAX_QUEUES_PER_IRQ];
588 struct semaphore setting_up_sema;