3 * linux/drivers/s390/cio/qdio.c
5 * Linux for S/390 QDIO base support, Hipersocket base support
8 * Copyright 2000,2002 IBM Corporation
9 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>
10 * 2.6 cio integration by Cornelia Huck <cornelia.huck@de.ibm.com>
12 * Restriction: only 63 iqdio subchannels would have its own indicator,
13 * after that, subsequent subchannels share one indicator
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2, or (at your option)
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 #include <linux/config.h>
34 #include <linux/module.h>
35 #include <linux/init.h>
37 #include <linux/slab.h>
38 #include <linux/kernel.h>
39 #include <linux/proc_fs.h>
40 #include <linux/timer.h>
41 #include <linux/mempool.h>
43 #include <asm/ccwdev.h>
45 #include <asm/atomic.h>
46 #include <asm/semaphore.h>
47 #include <asm/timex.h>
49 #include <asm/debug.h>
60 /****************** MODULE PARAMETER VARIABLES ********************/
61 MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>");
62 MODULE_DESCRIPTION("QDIO base support version 2, " \
63 "Copyright 2000 IBM Corporation");
64 MODULE_LICENSE("GPL");
66 /******************** HERE WE GO ***********************************/
68 static const char version
[] = "QDIO base support version 2";
70 #ifdef QDIO_PERFORMANCE_STATS
71 static int proc_perf_file_registration
;
72 static unsigned long i_p_c
, i_p_nc
, o_p_c
, o_p_nc
, ii_p_c
, ii_p_nc
;
73 static struct qdio_perf_stats perf_stats
;
74 #endif /* QDIO_PERFORMANCE_STATS */
76 static int hydra_thinints
;
77 static int is_passthrough
= 0;
80 static int indicator_used
[INDICATORS_PER_CACHELINE
];
81 static __u32
* volatile indicators
;
82 static __u32
volatile spare_indicator
;
83 static atomic_t spare_indicator_usecount
;
84 #define QDIO_MEMPOOL_SCSSC_ELEMENTS 2
85 static mempool_t
*qdio_mempool_scssc
;
87 static debug_info_t
*qdio_dbf_setup
;
88 static debug_info_t
*qdio_dbf_sbal
;
89 static debug_info_t
*qdio_dbf_trace
;
90 static debug_info_t
*qdio_dbf_sense
;
91 #ifdef CONFIG_QDIO_DEBUG
92 static debug_info_t
*qdio_dbf_slsb_out
;
93 static debug_info_t
*qdio_dbf_slsb_in
;
94 #endif /* CONFIG_QDIO_DEBUG */
97 static volatile struct qdio_q
*tiq_list
=NULL
; /* volatile as it could change
98 during a while loop */
99 static DEFINE_SPINLOCK(ttiq_list_lock
);
100 static int register_thinint_result
;
101 static void tiqdio_tl(unsigned long);
102 static DECLARE_TASKLET(tiqdio_tasklet
,tiqdio_tl
,0);
104 /* not a macro, as one of the arguments is atomic_read */
106 qdio_min(int a
,int b
)
114 /***************** SCRUBBER HELPER ROUTINES **********************/
117 qdio_get_micros(void)
119 return (get_clock() >> 10); /* time>>12 is microseconds */
123 * unfortunately, we can't just xchg the values; in do_QDIO we want to reserve
124 * the q in any case, so that we'll not be interrupted when we are in
125 * qdio_mark_tiq... shouldn't have a really bad impact, as reserving almost
126 * ever works (last famous words)
129 qdio_reserve_q(struct qdio_q
*q
)
131 return atomic_add_return(1,&q
->use_count
) - 1;
135 qdio_release_q(struct qdio_q
*q
)
137 atomic_dec(&q
->use_count
);
142 qdio_check_ccq(struct qdio_q
*q
, unsigned int ccq
)
146 if (ccq
== 0 || ccq
== 32 || ccq
== 96)
150 /*notify devices immediately*/
151 sprintf(dbf_text
,"%d", ccq
);
152 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
155 /* EQBS: extract buffer states */
157 qdio_do_eqbs(struct qdio_q
*q
, unsigned char *state
,
158 unsigned int *start
, unsigned int *cnt
)
160 struct qdio_irq
*irq
;
161 unsigned int tmp_cnt
, q_no
, ccq
;
167 irq
= (struct qdio_irq
*)q
->irq_ptr
;
170 q_no
+= irq
->no_input_qs
;
172 ccq
= do_eqbs(irq
->sch_token
, state
, q_no
, start
, cnt
);
173 rc
= qdio_check_ccq(q
, ccq
);
175 QDIO_DBF_TEXT5(1,trace
,"eqAGAIN");
179 QDIO_DBF_TEXT2(1,trace
,"eqberr");
180 sprintf(dbf_text
,"%2x,%2x,%d,%d",tmp_cnt
, *cnt
, ccq
, q_no
);
181 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
182 q
->handler(q
->cdev
,QDIO_STATUS_ACTIVATE_CHECK_CONDITION
|
183 QDIO_STATUS_LOOK_FOR_ERROR
,
184 0, 0, 0, -1, -1, q
->int_parm
);
187 return (tmp_cnt
- *cnt
);
190 /* SQBS: set buffer states */
192 qdio_do_sqbs(struct qdio_q
*q
, unsigned char state
,
193 unsigned int *start
, unsigned int *cnt
)
195 struct qdio_irq
*irq
;
196 unsigned int tmp_cnt
, q_no
, ccq
;
202 irq
= (struct qdio_irq
*)q
->irq_ptr
;
205 q_no
+= irq
->no_input_qs
;
207 ccq
= do_sqbs(irq
->sch_token
, state
, q_no
, start
, cnt
);
208 rc
= qdio_check_ccq(q
, ccq
);
210 QDIO_DBF_TEXT5(1,trace
,"sqAGAIN");
214 QDIO_DBF_TEXT3(1,trace
,"sqberr");
215 sprintf(dbf_text
,"%2x,%2x,%d,%d",tmp_cnt
,*cnt
,ccq
,q_no
);
216 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
217 q
->handler(q
->cdev
,QDIO_STATUS_ACTIVATE_CHECK_CONDITION
|
218 QDIO_STATUS_LOOK_FOR_ERROR
,
219 0, 0, 0, -1, -1, q
->int_parm
);
222 return (tmp_cnt
- *cnt
);
226 qdio_set_slsb(struct qdio_q
*q
, unsigned int *bufno
,
227 unsigned char state
, unsigned int *count
)
230 struct qdio_irq
*irq
;
232 irq
= (struct qdio_irq
*)q
->irq_ptr
;
233 if (!irq
->is_qebsm
) {
234 slsb
= (char *)&q
->slsb
.acc
.val
[(*bufno
)];
238 return qdio_do_sqbs(q
, state
, bufno
, count
);
241 #ifdef CONFIG_QDIO_DEBUG
243 qdio_trace_slsb(struct qdio_q
*q
)
245 if (q
->queue_type
==QDIO_TRACE_QTYPE
) {
247 QDIO_DBF_HEX2(0,slsb_in
,&q
->slsb
,
248 QDIO_MAX_BUFFERS_PER_Q
);
250 QDIO_DBF_HEX2(0,slsb_out
,&q
->slsb
,
251 QDIO_MAX_BUFFERS_PER_Q
);
257 set_slsb(struct qdio_q
*q
, unsigned int *bufno
,
258 unsigned char state
, unsigned int *count
)
261 #ifdef CONFIG_QDIO_DEBUG
264 rc
= qdio_set_slsb(q
, bufno
, state
, count
);
265 #ifdef CONFIG_QDIO_DEBUG
271 qdio_siga_sync(struct qdio_q
*q
, unsigned int gpr2
,
276 QDIO_DBF_TEXT4(0,trace
,"sigasync");
277 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
279 #ifdef QDIO_PERFORMANCE_STATS
280 perf_stats
.siga_syncs
++;
281 #endif /* QDIO_PERFORMANCE_STATS */
283 cc
= do_siga_sync(q
->schid
, gpr2
, gpr3
);
285 QDIO_DBF_HEX3(0,trace
,&cc
,sizeof(int*));
291 qdio_siga_sync_q(struct qdio_q
*q
)
294 return qdio_siga_sync(q
, 0, q
->mask
);
295 return qdio_siga_sync(q
, q
->mask
, 0);
299 __do_siga_output(struct qdio_q
*q
, unsigned int *busy_bit
)
301 struct qdio_irq
*irq
;
305 irq
= (struct qdio_irq
*) q
->irq_ptr
;
307 schid
= *((u32
*)&q
->schid
);
309 schid
= irq
->sch_token
;
312 return do_siga_output(schid
, q
->mask
, busy_bit
, fc
);
316 * returns QDIO_SIGA_ERROR_ACCESS_EXCEPTION as cc, when SIGA returns
317 * an access exception
320 qdio_siga_output(struct qdio_q
*q
)
326 #ifdef QDIO_PERFORMANCE_STATS
327 perf_stats
.siga_outs
++;
328 #endif /* QDIO_PERFORMANCE_STATS */
330 QDIO_DBF_TEXT4(0,trace
,"sigaout");
331 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
334 cc
= __do_siga_output(q
, &busy_bit
);
335 //QDIO_PRINT_ERR("cc=%x, busy=%x\n",cc,busy_bit);
336 if ((cc
==2) && (busy_bit
) && (q
->is_iqdio_q
)) {
339 if ((NOW
-start_time
)>QDIO_BUSY_BIT_PATIENCE
)
345 if ((cc
==2) && (busy_bit
))
346 cc
|= QDIO_SIGA_ERROR_B_BIT_SET
;
349 QDIO_DBF_HEX3(0,trace
,&cc
,sizeof(int*));
355 qdio_siga_input(struct qdio_q
*q
)
359 QDIO_DBF_TEXT4(0,trace
,"sigain");
360 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
362 #ifdef QDIO_PERFORMANCE_STATS
363 perf_stats
.siga_ins
++;
364 #endif /* QDIO_PERFORMANCE_STATS */
366 cc
= do_siga_input(q
->schid
, q
->mask
);
369 QDIO_DBF_HEX3(0,trace
,&cc
,sizeof(int*));
374 /* locked by the locks in qdio_activate and qdio_cleanup */
376 qdio_get_indicator(void)
380 for (i
=1;i
<INDICATORS_PER_CACHELINE
;i
++)
381 if (!indicator_used
[i
]) {
385 atomic_inc(&spare_indicator_usecount
);
386 return (__u32
* volatile) &spare_indicator
;
389 /* locked by the locks in qdio_activate and qdio_cleanup */
391 qdio_put_indicator(__u32
*addr
)
395 if ( (addr
) && (addr
!=&spare_indicator
) ) {
399 if (addr
== &spare_indicator
)
400 atomic_dec(&spare_indicator_usecount
);
404 tiqdio_clear_summary_bit(__u32
*location
)
406 QDIO_DBF_TEXT5(0,trace
,"clrsummb");
407 QDIO_DBF_HEX5(0,trace
,&location
,sizeof(void*));
413 tiqdio_set_summary_bit(__u32
*location
)
415 QDIO_DBF_TEXT5(0,trace
,"setsummb");
416 QDIO_DBF_HEX5(0,trace
,&location
,sizeof(void*));
422 tiqdio_sched_tl(void)
424 tasklet_hi_schedule(&tiqdio_tasklet
);
428 qdio_mark_tiq(struct qdio_q
*q
)
432 QDIO_DBF_TEXT4(0,trace
,"mark iq");
433 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
435 spin_lock_irqsave(&ttiq_list_lock
,flags
);
436 if (unlikely(atomic_read(&q
->is_in_shutdown
)))
442 if ((q
->list_prev
) || (q
->list_next
))
450 q
->list_next
=tiq_list
;
451 q
->list_prev
=tiq_list
->list_prev
;
452 tiq_list
->list_prev
->list_next
=q
;
453 tiq_list
->list_prev
=q
;
455 spin_unlock_irqrestore(&ttiq_list_lock
,flags
);
457 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
461 spin_unlock_irqrestore(&ttiq_list_lock
,flags
);
466 qdio_mark_q(struct qdio_q
*q
)
468 QDIO_DBF_TEXT4(0,trace
,"mark q");
469 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
471 if (unlikely(atomic_read(&q
->is_in_shutdown
)))
474 tasklet_schedule(&q
->tasklet
);
478 qdio_stop_polling(struct qdio_q
*q
)
480 #ifdef QDIO_USE_PROCESSING_STATE
481 unsigned int tmp
, gsf
, count
= 1;
482 unsigned char state
= 0;
483 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
485 if (!atomic_swap(&q
->polling
,0))
488 QDIO_DBF_TEXT4(0,trace
,"stoppoll");
489 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
491 /* show the card that we are not polling anymore */
495 tmp
= gsf
= GET_SAVED_FRONTIER(q
);
496 tmp
= ((tmp
+ QDIO_MAX_BUFFERS_PER_Q
-1) & (QDIO_MAX_BUFFERS_PER_Q
-1) );
497 set_slsb(q
, &tmp
, SLSB_P_INPUT_NOT_INIT
, &count
);
500 * we don't issue this SYNC_MEMORY, as we trust Rick T and
501 * moreover will not use the PROCESSING state under VM, so
502 * q->polling was 0 anyway
507 qdio_do_eqbs(q
, &state
, &gsf
, &count
);
509 state
= q
->slsb
.acc
.val
[gsf
];
510 if (state
!= SLSB_P_INPUT_PRIMED
)
513 * set our summary bit again, as otherwise there is a
514 * small window we can miss between resetting it and
515 * checking for PRIMED state
518 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
521 #else /* QDIO_USE_PROCESSING_STATE */
523 #endif /* QDIO_USE_PROCESSING_STATE */
527 * see the comment in do_QDIO and before qdio_reserve_q about the
528 * sophisticated locking outside of unmark_q, so that we don't need to
529 * disable the interrupts :-)
532 qdio_unmark_q(struct qdio_q
*q
)
536 QDIO_DBF_TEXT4(0,trace
,"unmark q");
537 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
539 if ((!q
->list_prev
)||(!q
->list_next
))
542 if ((q
->is_thinint_q
)&&(q
->is_input_q
)) {
544 spin_lock_irqsave(&ttiq_list_lock
,flags
);
545 /* in case cleanup has done this already and simultanously
546 * qdio_unmark_q is called from the interrupt handler, we've
547 * got to check this in this specific case again */
548 if ((!q
->list_prev
)||(!q
->list_next
))
550 if (q
->list_next
==q
) {
551 /* q was the only interesting q */
556 q
->list_next
->list_prev
=q
->list_prev
;
557 q
->list_prev
->list_next
=q
->list_next
;
558 tiq_list
=q
->list_next
;
563 spin_unlock_irqrestore(&ttiq_list_lock
,flags
);
567 static inline unsigned long
568 tiqdio_clear_global_summary(void)
572 QDIO_DBF_TEXT5(0,trace
,"clrglobl");
574 time
= do_clear_global_summary();
576 QDIO_DBF_HEX5(0,trace
,&time
,sizeof(unsigned long));
582 /************************* OUTBOUND ROUTINES *******************************/
584 qdio_qebsm_get_outbound_buffer_frontier(struct qdio_q
*q
)
586 struct qdio_irq
*irq
;
588 unsigned int cnt
, count
, ftc
;
590 irq
= (struct qdio_irq
*) q
->irq_ptr
;
591 if ((!q
->is_iqdio_q
) && (!q
->hydra_gives_outbound_pcis
))
594 ftc
= q
->first_to_check
;
595 count
= qdio_min(atomic_read(&q
->number_of_buffers_used
),
596 (QDIO_MAX_BUFFERS_PER_Q
-1));
598 return q
->first_to_check
;
599 cnt
= qdio_do_eqbs(q
, &state
, &ftc
, &count
);
601 return q
->first_to_check
;
603 case SLSB_P_OUTPUT_ERROR
:
604 QDIO_DBF_TEXT3(0,trace
,"outperr");
605 atomic_sub(cnt
, &q
->number_of_buffers_used
);
607 q
->error_status_flags
|=
608 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
609 q
->qdio_error
= SLSB_P_OUTPUT_ERROR
;
610 q
->error_status_flags
|= QDIO_STATUS_LOOK_FOR_ERROR
;
611 q
->first_to_check
= ftc
;
613 case SLSB_P_OUTPUT_EMPTY
:
614 QDIO_DBF_TEXT5(0,trace
,"outpempt");
615 atomic_sub(cnt
, &q
->number_of_buffers_used
);
616 q
->first_to_check
= ftc
;
618 case SLSB_CU_OUTPUT_PRIMED
:
619 /* all buffers primed */
620 QDIO_DBF_TEXT5(0,trace
,"outpprim");
625 QDIO_DBF_HEX4(0,trace
,&q
->first_to_check
,sizeof(int));
626 return q
->first_to_check
;
630 qdio_qebsm_get_inbound_buffer_frontier(struct qdio_q
*q
)
632 struct qdio_irq
*irq
;
634 int tmp
, ftc
, count
, cnt
;
638 irq
= (struct qdio_irq
*) q
->irq_ptr
;
639 ftc
= q
->first_to_check
;
640 count
= qdio_min(atomic_read(&q
->number_of_buffers_used
),
641 (QDIO_MAX_BUFFERS_PER_Q
-1));
643 return q
->first_to_check
;
644 cnt
= qdio_do_eqbs(q
, &state
, &ftc
, &count
);
646 return q
->first_to_check
;
648 case SLSB_P_INPUT_ERROR
:
649 #ifdef CONFIG_QDIO_DEBUG
650 QDIO_DBF_TEXT3(1,trace
,"inperr");
651 sprintf(dbf_text
,"%2x,%2x",ftc
,count
);
652 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
653 #endif /* CONFIG_QDIO_DEBUG */
655 q
->error_status_flags
|=
656 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
657 q
->qdio_error
= SLSB_P_INPUT_ERROR
;
658 q
->error_status_flags
|= QDIO_STATUS_LOOK_FOR_ERROR
;
659 atomic_sub(cnt
, &q
->number_of_buffers_used
);
660 q
->first_to_check
= ftc
;
662 case SLSB_P_INPUT_PRIMED
:
663 QDIO_DBF_TEXT3(0,trace
,"inptprim");
664 sprintf(dbf_text
,"%2x,%2x",ftc
,count
);
665 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
667 ftc
= q
->first_to_check
;
668 #ifdef QDIO_USE_PROCESSING_STATE
671 tmp
= set_slsb(q
, &ftc
, SLSB_P_INPUT_NOT_INIT
, &cnt
);
676 tmp
+= set_slsb(q
, &ftc
,
677 SLSB_P_INPUT_PROCESSING
, &cnt
);
678 atomic_set(&q
->polling
, 1);
680 tmp
= set_slsb(q
, &ftc
, SLSB_P_INPUT_NOT_INIT
, &cnt
);
682 atomic_sub(tmp
, &q
->number_of_buffers_used
);
683 q
->first_to_check
= ftc
;
685 case SLSB_CU_INPUT_EMPTY
:
686 case SLSB_P_INPUT_NOT_INIT
:
687 case SLSB_P_INPUT_PROCESSING
:
688 QDIO_DBF_TEXT5(0,trace
,"inpnipro");
693 QDIO_DBF_HEX4(0,trace
,&q
->first_to_check
,sizeof(int));
694 return q
->first_to_check
;
698 qdio_get_outbound_buffer_frontier(struct qdio_q
*q
)
700 struct qdio_irq
*irq
;
702 unsigned int count
= 1;
703 int first_not_to_check
, f
, f_mod_no
;
706 QDIO_DBF_TEXT4(0,trace
,"getobfro");
707 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
709 irq
= (struct qdio_irq
*) q
->irq_ptr
;
711 return qdio_qebsm_get_outbound_buffer_frontier(q
);
713 slsb
=&q
->slsb
.acc
.val
[0];
714 f_mod_no
=f
=q
->first_to_check
;
716 * f points to already processed elements, so f+no_used is correct...
717 * ... but: we don't check 128 buffers, as otherwise
718 * qdio_has_outbound_q_moved would return 0
720 first_not_to_check
=f
+qdio_min(atomic_read(&q
->number_of_buffers_used
),
721 (QDIO_MAX_BUFFERS_PER_Q
-1));
723 if ((!q
->is_iqdio_q
)&&(!q
->hydra_gives_outbound_pcis
))
727 if (f
==first_not_to_check
)
730 switch(slsb
[f_mod_no
]) {
732 /* the adapter has not fetched the output yet */
733 case SLSB_CU_OUTPUT_PRIMED
:
734 QDIO_DBF_TEXT5(0,trace
,"outpprim");
737 /* the adapter got it */
738 case SLSB_P_OUTPUT_EMPTY
:
739 atomic_dec(&q
->number_of_buffers_used
);
741 f_mod_no
=f
&(QDIO_MAX_BUFFERS_PER_Q
-1);
742 QDIO_DBF_TEXT5(0,trace
,"outpempt");
745 case SLSB_P_OUTPUT_ERROR
:
746 QDIO_DBF_TEXT3(0,trace
,"outperr");
747 sprintf(dbf_text
,"%x-%x-%x",f_mod_no
,
748 q
->sbal
[f_mod_no
]->element
[14].sbalf
.value
,
749 q
->sbal
[f_mod_no
]->element
[15].sbalf
.value
);
750 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
751 QDIO_DBF_HEX2(1,sbal
,q
->sbal
[f_mod_no
],256);
753 /* kind of process the buffer */
754 set_slsb(q
, &f_mod_no
, SLSB_P_OUTPUT_NOT_INIT
, &count
);
757 * we increment the frontier, as this buffer
758 * was processed obviously
760 atomic_dec(&q
->number_of_buffers_used
);
761 f_mod_no
=(f_mod_no
+1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
764 q
->error_status_flags
|=
765 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
766 q
->qdio_error
=SLSB_P_OUTPUT_ERROR
;
767 q
->error_status_flags
|=QDIO_STATUS_LOOK_FOR_ERROR
;
773 QDIO_DBF_TEXT5(0,trace
,"outpni");
776 return (q
->first_to_check
=f_mod_no
);
779 /* all buffers are processed */
781 qdio_is_outbound_q_done(struct qdio_q
*q
)
784 #ifdef CONFIG_QDIO_DEBUG
788 no_used
=atomic_read(&q
->number_of_buffers_used
);
790 #ifdef CONFIG_QDIO_DEBUG
792 sprintf(dbf_text
,"oqisnt%02x",no_used
);
793 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
795 QDIO_DBF_TEXT4(0,trace
,"oqisdone");
797 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
798 #endif /* CONFIG_QDIO_DEBUG */
803 qdio_has_outbound_q_moved(struct qdio_q
*q
)
807 i
=qdio_get_outbound_buffer_frontier(q
);
809 if ( (i
!=GET_SAVED_FRONTIER(q
)) ||
810 (q
->error_status_flags
&QDIO_STATUS_LOOK_FOR_ERROR
) ) {
812 QDIO_DBF_TEXT4(0,trace
,"oqhasmvd");
813 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
816 QDIO_DBF_TEXT4(0,trace
,"oqhsntmv");
817 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
823 qdio_kick_outbound_q(struct qdio_q
*q
)
826 #ifdef CONFIG_QDIO_DEBUG
829 QDIO_DBF_TEXT4(0,trace
,"kickoutq");
830 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
831 #endif /* CONFIG_QDIO_DEBUG */
836 /* here's the story with cc=2 and busy bit set (thanks, Rick):
837 * VM's CP could present us cc=2 and busy bit set on SIGA-write
838 * during reconfiguration of their Guest LAN (only in HIPERS mode,
839 * QDIO mode is asynchronous -- cc=2 and busy bit there will take
840 * the queues down immediately; and not being under VM we have a
841 * problem on cc=2 and busy bit set right away).
843 * Therefore qdio_siga_output will try for a short time constantly,
844 * if such a condition occurs. If it doesn't change, it will
845 * increase the busy_siga_counter and save the timestamp, and
846 * schedule the queue for later processing (via mark_q, using the
847 * queue tasklet). __qdio_outbound_processing will check out the
848 * counter. If non-zero, it will call qdio_kick_outbound_q as often
849 * as the value of the counter. This will attempt further SIGA
850 * instructions. For each successful SIGA, the counter is
851 * decreased, for failing SIGAs the counter remains the same, after
853 * After some time of no movement, qdio_kick_outbound_q will
854 * finally fail and reflect corresponding error codes to call
855 * the upper layer module and have it take the queues down.
857 * Note that this is a change from the original HiperSockets design
858 * (saying cc=2 and busy bit means take the queues down), but in
859 * these days Guest LAN didn't exist... excessive cc=2 with busy bit
860 * conditions will still take the queues down, but the threshold is
861 * higher due to the Guest LAN environment.
865 result
=qdio_siga_output(q
);
869 /* went smooth this time, reset timestamp */
870 #ifdef CONFIG_QDIO_DEBUG
871 QDIO_DBF_TEXT3(0,trace
,"cc2reslv");
872 sprintf(dbf_text
,"%4x%2x%2x",q
->schid
.sch_no
,q
->q_no
,
873 atomic_read(&q
->busy_siga_counter
));
874 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
875 #endif /* CONFIG_QDIO_DEBUG */
876 q
->timing
.busy_start
=0;
878 case (2|QDIO_SIGA_ERROR_B_BIT_SET
):
879 /* cc=2 and busy bit: */
880 atomic_inc(&q
->busy_siga_counter
);
882 /* if the last siga was successful, save
884 if (!q
->timing
.busy_start
)
885 q
->timing
.busy_start
=NOW
;
887 /* if we're in time, don't touch error_status_flags
889 if (NOW
-q
->timing
.busy_start
<QDIO_BUSY_BIT_GIVE_UP
) {
893 QDIO_DBF_TEXT2(0,trace
,"cc2REPRT");
894 #ifdef CONFIG_QDIO_DEBUG
895 sprintf(dbf_text
,"%4x%2x%2x",q
->schid
.sch_no
,q
->q_no
,
896 atomic_read(&q
->busy_siga_counter
));
897 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
898 #endif /* CONFIG_QDIO_DEBUG */
899 /* else fallthrough and report error */
901 /* for plain cc=1, 2 or 3: */
903 q
->error_status_flags
|=
904 QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR
;
905 q
->error_status_flags
|=
906 QDIO_STATUS_LOOK_FOR_ERROR
;
907 q
->siga_error
=result
;
912 qdio_kick_outbound_handler(struct qdio_q
*q
)
914 int start
, end
, real_end
, count
;
915 #ifdef CONFIG_QDIO_DEBUG
919 start
= q
->first_element_to_kick
;
920 /* last_move_ftc was just updated */
921 real_end
= GET_SAVED_FRONTIER(q
);
922 end
= (real_end
+QDIO_MAX_BUFFERS_PER_Q
-1)&
923 (QDIO_MAX_BUFFERS_PER_Q
-1);
924 count
= (end
+QDIO_MAX_BUFFERS_PER_Q
+1-start
)&
925 (QDIO_MAX_BUFFERS_PER_Q
-1);
927 #ifdef CONFIG_QDIO_DEBUG
928 QDIO_DBF_TEXT4(0,trace
,"kickouth");
929 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
931 sprintf(dbf_text
,"s=%2xc=%2x",start
,count
);
932 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
933 #endif /* CONFIG_QDIO_DEBUG */
935 if (q
->state
==QDIO_IRQ_STATE_ACTIVE
)
936 q
->handler(q
->cdev
,QDIO_STATUS_OUTBOUND_INT
|
937 q
->error_status_flags
,
938 q
->qdio_error
,q
->siga_error
,q
->q_no
,start
,count
,
941 /* for the next time: */
942 q
->first_element_to_kick
=real_end
;
945 q
->error_status_flags
=0;
949 __qdio_outbound_processing(struct qdio_q
*q
)
953 QDIO_DBF_TEXT4(0,trace
,"qoutproc");
954 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
956 if (unlikely(qdio_reserve_q(q
))) {
958 #ifdef QDIO_PERFORMANCE_STATS
960 #endif /* QDIO_PERFORMANCE_STATS */
961 /* as we're sissies, we'll check next time */
962 if (likely(!atomic_read(&q
->is_in_shutdown
))) {
964 QDIO_DBF_TEXT4(0,trace
,"busy,agn");
968 #ifdef QDIO_PERFORMANCE_STATS
970 perf_stats
.tl_runs
++;
971 #endif /* QDIO_PERFORMANCE_STATS */
973 /* see comment in qdio_kick_outbound_q */
974 siga_attempts
=atomic_read(&q
->busy_siga_counter
);
975 while (siga_attempts
) {
976 atomic_dec(&q
->busy_siga_counter
);
977 qdio_kick_outbound_q(q
);
981 if (qdio_has_outbound_q_moved(q
))
982 qdio_kick_outbound_handler(q
);
986 * for asynchronous queues, we better check, if the fill
987 * level is too high. for synchronous queues, the fill
988 * level will never be that high.
990 if (atomic_read(&q
->number_of_buffers_used
)>
991 IQDIO_FILL_LEVEL_TO_POLL
)
994 } else if (!q
->hydra_gives_outbound_pcis
)
995 if (!qdio_is_outbound_q_done(q
))
1002 qdio_outbound_processing(struct qdio_q
*q
)
1004 __qdio_outbound_processing(q
);
1007 /************************* INBOUND ROUTINES *******************************/
1011 qdio_get_inbound_buffer_frontier(struct qdio_q
*q
)
1013 struct qdio_irq
*irq
;
1015 volatile char *slsb
;
1016 unsigned int count
= 1;
1017 int first_not_to_check
;
1018 #ifdef CONFIG_QDIO_DEBUG
1020 #endif /* CONFIG_QDIO_DEBUG */
1021 #ifdef QDIO_USE_PROCESSING_STATE
1022 int last_position
=-1;
1023 #endif /* QDIO_USE_PROCESSING_STATE */
1025 QDIO_DBF_TEXT4(0,trace
,"getibfro");
1026 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1028 irq
= (struct qdio_irq
*) q
->irq_ptr
;
1030 return qdio_qebsm_get_inbound_buffer_frontier(q
);
1032 slsb
=&q
->slsb
.acc
.val
[0];
1033 f_mod_no
=f
=q
->first_to_check
;
1035 * we don't check 128 buffers, as otherwise qdio_has_inbound_q_moved
1038 first_not_to_check
=f
+qdio_min(atomic_read(&q
->number_of_buffers_used
),
1039 (QDIO_MAX_BUFFERS_PER_Q
-1));
1042 * we don't use this one, as a PCI or we after a thin interrupt
1043 * will sync the queues
1048 f_mod_no
=f
&(QDIO_MAX_BUFFERS_PER_Q
-1);
1049 if (f
==first_not_to_check
)
1051 switch (slsb
[f_mod_no
]) {
1053 /* CU_EMPTY means frontier is reached */
1054 case SLSB_CU_INPUT_EMPTY
:
1055 QDIO_DBF_TEXT5(0,trace
,"inptempt");
1058 /* P_PRIMED means set slsb to P_PROCESSING and move on */
1059 case SLSB_P_INPUT_PRIMED
:
1060 QDIO_DBF_TEXT5(0,trace
,"inptprim");
1062 #ifdef QDIO_USE_PROCESSING_STATE
1064 * as soon as running under VM, polling the input queues will
1065 * kill VM in terms of CP overhead
1068 set_slsb(q
, &f_mod_no
, SLSB_P_INPUT_NOT_INIT
, &count
);
1070 /* set the previous buffer to NOT_INIT. The current
1071 * buffer will be set to PROCESSING at the end of
1072 * this function to avoid further interrupts. */
1073 if (last_position
>=0)
1074 set_slsb(q
, &last_position
,
1075 SLSB_P_INPUT_NOT_INIT
, &count
);
1076 atomic_set(&q
->polling
,1);
1077 last_position
=f_mod_no
;
1079 #else /* QDIO_USE_PROCESSING_STATE */
1080 set_slsb(q
, &f_mod_no
, SLSB_P_INPUT_NOT_INIT
, &count
);
1081 #endif /* QDIO_USE_PROCESSING_STATE */
1083 * not needed, as the inbound queue will be synced on the next
1084 * siga-r, resp. tiqdio_is_inbound_q_done will do the siga-s
1088 atomic_dec(&q
->number_of_buffers_used
);
1091 case SLSB_P_INPUT_NOT_INIT
:
1092 case SLSB_P_INPUT_PROCESSING
:
1093 QDIO_DBF_TEXT5(0,trace
,"inpnipro");
1096 /* P_ERROR means frontier is reached, break and report error */
1097 case SLSB_P_INPUT_ERROR
:
1098 #ifdef CONFIG_QDIO_DEBUG
1099 sprintf(dbf_text
,"inperr%2x",f_mod_no
);
1100 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
1101 #endif /* CONFIG_QDIO_DEBUG */
1102 QDIO_DBF_HEX2(1,sbal
,q
->sbal
[f_mod_no
],256);
1104 /* kind of process the buffer */
1105 set_slsb(q
, &f_mod_no
, SLSB_P_INPUT_NOT_INIT
, &count
);
1108 q
->error_status_flags
|=
1109 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
1110 q
->qdio_error
=SLSB_P_INPUT_ERROR
;
1111 q
->error_status_flags
|=QDIO_STATUS_LOOK_FOR_ERROR
;
1113 /* we increment the frontier, as this buffer
1114 * was processed obviously */
1115 f_mod_no
=(f_mod_no
+1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
1116 atomic_dec(&q
->number_of_buffers_used
);
1118 #ifdef QDIO_USE_PROCESSING_STATE
1120 #endif /* QDIO_USE_PROCESSING_STATE */
1124 /* everything else means frontier not changed (HALTED or so) */
1129 q
->first_to_check
=f_mod_no
;
1131 #ifdef QDIO_USE_PROCESSING_STATE
1132 if (last_position
>=0)
1133 set_slsb(q
, &last_position
, SLSB_P_INPUT_NOT_INIT
, &count
);
1134 #endif /* QDIO_USE_PROCESSING_STATE */
1136 QDIO_DBF_HEX4(0,trace
,&q
->first_to_check
,sizeof(int));
1138 return q
->first_to_check
;
1142 qdio_has_inbound_q_moved(struct qdio_q
*q
)
1146 #ifdef QDIO_PERFORMANCE_STATS
1147 static int old_pcis
=0;
1148 static int old_thinints
=0;
1150 if ((old_pcis
==perf_stats
.pcis
)&&(old_thinints
==perf_stats
.thinints
))
1151 perf_stats
.start_time_inbound
=NOW
;
1153 old_pcis
=perf_stats
.pcis
;
1154 #endif /* QDIO_PERFORMANCE_STATS */
1156 i
=qdio_get_inbound_buffer_frontier(q
);
1157 if ( (i
!=GET_SAVED_FRONTIER(q
)) ||
1158 (q
->error_status_flags
&QDIO_STATUS_LOOK_FOR_ERROR
) ) {
1160 if ((!q
->siga_sync
)&&(!q
->hydra_gives_outbound_pcis
))
1163 QDIO_DBF_TEXT4(0,trace
,"inhasmvd");
1164 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1167 QDIO_DBF_TEXT4(0,trace
,"inhsntmv");
1168 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1173 /* means, no more buffers to be filled */
1175 tiqdio_is_inbound_q_done(struct qdio_q
*q
)
1178 unsigned int start_buf
, count
;
1179 unsigned char state
= 0;
1180 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
1182 #ifdef CONFIG_QDIO_DEBUG
1186 no_used
=atomic_read(&q
->number_of_buffers_used
);
1188 /* propagate the change from 82 to 80 through VM */
1191 #ifdef CONFIG_QDIO_DEBUG
1193 sprintf(dbf_text
,"iqisnt%02x",no_used
);
1194 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1196 QDIO_DBF_TEXT4(0,trace
,"iniqisdo");
1198 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1199 #endif /* CONFIG_QDIO_DEBUG */
1203 if (!q
->siga_sync
&& !irq
->is_qebsm
)
1204 /* we'll check for more primed buffers in qeth_stop_polling */
1206 if (irq
->is_qebsm
) {
1208 start_buf
= q
->first_to_check
;
1209 qdio_do_eqbs(q
, &state
, &start_buf
, &count
);
1211 state
= q
->slsb
.acc
.val
[q
->first_to_check
];
1212 if (state
!= SLSB_P_INPUT_PRIMED
)
1214 * nothing more to do, if next buffer is not PRIMED.
1215 * note that we did a SYNC_MEMORY before, that there
1216 * has been a sychnronization.
1217 * we will return 0 below, as there is nothing to do
1218 * (stop_polling not necessary, as we have not been
1219 * using the PROCESSING state
1224 * ok, the next input buffer is primed. that means, that device state
1225 * change indicator and adapter local summary are set, so we will find
1227 * we will return 0 below, as there is nothing to do, except scheduling
1228 * ourselves for the next time.
1230 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1236 qdio_is_inbound_q_done(struct qdio_q
*q
)
1239 unsigned int start_buf
, count
;
1240 unsigned char state
= 0;
1241 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
1243 #ifdef CONFIG_QDIO_DEBUG
1247 no_used
=atomic_read(&q
->number_of_buffers_used
);
1250 * we need that one for synchronization with the adapter, as it
1251 * does a kind of PCI avoidance
1256 QDIO_DBF_TEXT4(0,trace
,"inqisdnA");
1257 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1258 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1261 if (irq
->is_qebsm
) {
1263 start_buf
= q
->first_to_check
;
1264 qdio_do_eqbs(q
, &state
, &start_buf
, &count
);
1266 state
= q
->slsb
.acc
.val
[q
->first_to_check
];
1267 if (state
== SLSB_P_INPUT_PRIMED
) {
1268 /* we got something to do */
1269 QDIO_DBF_TEXT4(0,trace
,"inqisntA");
1270 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1274 /* on VM, we don't poll, so the q is always done here */
1277 if (q
->hydra_gives_outbound_pcis
)
1281 * at this point we know, that inbound first_to_check
1282 * has (probably) not moved (see qdio_inbound_processing)
1284 if (NOW
>GET_SAVED_TIMESTAMP(q
)+q
->timing
.threshold
) {
1285 #ifdef CONFIG_QDIO_DEBUG
1286 QDIO_DBF_TEXT4(0,trace
,"inqisdon");
1287 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1288 sprintf(dbf_text
,"pf%02xcn%02x",q
->first_to_check
,no_used
);
1289 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1290 #endif /* CONFIG_QDIO_DEBUG */
1293 #ifdef CONFIG_QDIO_DEBUG
1294 QDIO_DBF_TEXT4(0,trace
,"inqisntd");
1295 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1296 sprintf(dbf_text
,"pf%02xcn%02x",q
->first_to_check
,no_used
);
1297 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1298 #endif /* CONFIG_QDIO_DEBUG */
1304 qdio_kick_inbound_handler(struct qdio_q
*q
)
1306 int count
, start
, end
, real_end
, i
;
1307 #ifdef CONFIG_QDIO_DEBUG
1311 QDIO_DBF_TEXT4(0,trace
,"kickinh");
1312 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1314 start
=q
->first_element_to_kick
;
1315 real_end
=q
->first_to_check
;
1316 end
=(real_end
+QDIO_MAX_BUFFERS_PER_Q
-1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
1324 i
=(i
+1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
1327 #ifdef CONFIG_QDIO_DEBUG
1328 sprintf(dbf_text
,"s=%2xc=%2x",start
,count
);
1329 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1330 #endif /* CONFIG_QDIO_DEBUG */
1332 if (likely(q
->state
==QDIO_IRQ_STATE_ACTIVE
))
1334 QDIO_STATUS_INBOUND_INT
|q
->error_status_flags
,
1335 q
->qdio_error
,q
->siga_error
,q
->q_no
,start
,count
,
1338 /* for the next time: */
1339 q
->first_element_to_kick
=real_end
;
1342 q
->error_status_flags
=0;
1344 #ifdef QDIO_PERFORMANCE_STATS
1345 perf_stats
.inbound_time
+=NOW
-perf_stats
.start_time_inbound
;
1346 perf_stats
.inbound_cnt
++;
1347 #endif /* QDIO_PERFORMANCE_STATS */
1351 __tiqdio_inbound_processing(struct qdio_q
*q
, int spare_ind_was_set
)
1353 struct qdio_irq
*irq_ptr
;
1357 QDIO_DBF_TEXT4(0,trace
,"iqinproc");
1358 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1361 * we first want to reserve the q, so that we know, that we don't
1362 * interrupt ourselves and call qdio_unmark_q, as is_in_shutdown might
1365 if (unlikely(qdio_reserve_q(q
))) {
1367 #ifdef QDIO_PERFORMANCE_STATS
1369 #endif /* QDIO_PERFORMANCE_STATS */
1371 * as we might just be about to stop polling, we make
1372 * sure that we check again at least once more
1377 #ifdef QDIO_PERFORMANCE_STATS
1379 #endif /* QDIO_PERFORMANCE_STATS */
1380 if (unlikely(atomic_read(&q
->is_in_shutdown
))) {
1386 * we reset spare_ind_was_set, when the queue does not use the
1389 if (spare_ind_was_set
)
1390 spare_ind_was_set
= (q
->dev_st_chg_ind
== &spare_indicator
);
1392 if (!(*(q
->dev_st_chg_ind
)) && !spare_ind_was_set
)
1395 * q->dev_st_chg_ind is the indicator, be it shared or not.
1396 * only clear it, if indicator is non-shared
1398 if (!spare_ind_was_set
)
1399 tiqdio_clear_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1401 if (q
->hydra_gives_outbound_pcis
) {
1402 if (!q
->siga_sync_done_on_thinints
) {
1404 } else if ((!q
->siga_sync_done_on_outb_tis
)&&
1405 (q
->hydra_gives_outbound_pcis
)) {
1406 SYNC_MEMORY_ALL_OUTB
;
1412 * maybe we have to do work on our outbound queues... at least
1413 * we have to check the outbound-int-capable thinint-capable
1416 if (q
->hydra_gives_outbound_pcis
) {
1417 irq_ptr
= (struct qdio_irq
*)q
->irq_ptr
;
1418 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
1419 oq
= irq_ptr
->output_qs
[i
];
1420 #ifdef QDIO_PERFORMANCE_STATS
1421 perf_stats
.tl_runs
--;
1422 #endif /* QDIO_PERFORMANCE_STATS */
1423 if (!qdio_is_outbound_q_done(oq
))
1424 __qdio_outbound_processing(oq
);
1428 if (!qdio_has_inbound_q_moved(q
))
1431 qdio_kick_inbound_handler(q
);
1432 if (tiqdio_is_inbound_q_done(q
))
1433 if (!qdio_stop_polling(q
)) {
1435 * we set the flags to get into the stuff next time,
1436 * see also comment in qdio_stop_polling
1438 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1446 tiqdio_inbound_processing(struct qdio_q
*q
)
1448 __tiqdio_inbound_processing(q
, atomic_read(&spare_indicator_usecount
));
1452 __qdio_inbound_processing(struct qdio_q
*q
)
1456 QDIO_DBF_TEXT4(0,trace
,"qinproc");
1457 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1459 if (unlikely(qdio_reserve_q(q
))) {
1461 #ifdef QDIO_PERFORMANCE_STATS
1463 #endif /* QDIO_PERFORMANCE_STATS */
1464 /* as we're sissies, we'll check next time */
1465 if (likely(!atomic_read(&q
->is_in_shutdown
))) {
1467 QDIO_DBF_TEXT4(0,trace
,"busy,agn");
1471 #ifdef QDIO_PERFORMANCE_STATS
1473 perf_stats
.tl_runs
++;
1474 #endif /* QDIO_PERFORMANCE_STATS */
1477 if (qdio_has_inbound_q_moved(q
)) {
1478 qdio_kick_inbound_handler(q
);
1479 if (!qdio_stop_polling(q
)) {
1481 if (q_laps
<QDIO_Q_LAPS
)
1486 if (!qdio_is_inbound_q_done(q
))
1487 /* means poll time is not yet over */
1495 qdio_inbound_processing(struct qdio_q
*q
)
1497 __qdio_inbound_processing(q
);
1500 /************************* MAIN ROUTINES *******************************/
1502 #ifdef QDIO_USE_PROCESSING_STATE
1504 tiqdio_reset_processing_state(struct qdio_q
*q
, int q_laps
)
1512 * under VM, we have not used the PROCESSING state, so no
1513 * need to stop polling
1518 if (unlikely(qdio_reserve_q(q
))) {
1520 #ifdef QDIO_PERFORMANCE_STATS
1522 #endif /* QDIO_PERFORMANCE_STATS */
1524 * as we might just be about to stop polling, we make
1525 * sure that we check again at least once more
1529 * sanity -- we'd get here without setting the
1532 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1536 if (qdio_stop_polling(q
)) {
1540 if (q_laps
<QDIO_Q_LAPS
-1) {
1545 * we set the flags to get into the stuff
1546 * next time, see also comment in qdio_stop_polling
1548 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1554 #endif /* QDIO_USE_PROCESSING_STATE */
1557 tiqdio_inbound_checks(void)
1560 int spare_ind_was_set
=0;
1561 #ifdef QDIO_USE_PROCESSING_STATE
1563 #endif /* QDIO_USE_PROCESSING_STATE */
1565 QDIO_DBF_TEXT4(0,trace
,"iqdinbck");
1566 QDIO_DBF_TEXT5(0,trace
,"iqlocsum");
1568 #ifdef QDIO_USE_PROCESSING_STATE
1570 #endif /* QDIO_USE_PROCESSING_STATE */
1572 /* when the spare indicator is used and set, save that and clear it */
1573 if ((atomic_read(&spare_indicator_usecount
)) && spare_indicator
) {
1574 spare_ind_was_set
= 1;
1575 tiqdio_clear_summary_bit((__u32
*)&spare_indicator
);
1578 q
=(struct qdio_q
*)tiq_list
;
1582 __tiqdio_inbound_processing(q
, spare_ind_was_set
);
1583 q
=(struct qdio_q
*)q
->list_next
;
1584 } while (q
!=(struct qdio_q
*)tiq_list
);
1586 #ifdef QDIO_USE_PROCESSING_STATE
1587 q
=(struct qdio_q
*)tiq_list
;
1591 ret
= tiqdio_reset_processing_state(q
, q_laps
);
1598 q
= (struct qdio_q
*)q
->list_next
;
1604 } while (q
!=(struct qdio_q
*)tiq_list
);
1605 #endif /* QDIO_USE_PROCESSING_STATE */
1609 tiqdio_tl(unsigned long data
)
1611 QDIO_DBF_TEXT4(0,trace
,"iqdio_tl");
1613 #ifdef QDIO_PERFORMANCE_STATS
1614 perf_stats
.tl_runs
++;
1615 #endif /* QDIO_PERFORMANCE_STATS */
1617 tiqdio_inbound_checks();
1620 /********************* GENERAL HELPER_ROUTINES ***********************/
1623 qdio_release_irq_memory(struct qdio_irq
*irq_ptr
)
1627 for (i
=0;i
<QDIO_MAX_QUEUES_PER_IRQ
;i
++) {
1628 if (!irq_ptr
->input_qs
[i
])
1631 kfree(irq_ptr
->input_qs
[i
]->slib
);
1632 kfree(irq_ptr
->input_qs
[i
]);
1635 if (!irq_ptr
->output_qs
[i
])
1638 kfree(irq_ptr
->output_qs
[i
]->slib
);
1639 kfree(irq_ptr
->output_qs
[i
]);
1642 kfree(irq_ptr
->qdr
);
1643 free_page((unsigned long) irq_ptr
);
1647 qdio_set_impl_params(struct qdio_irq
*irq_ptr
,
1648 unsigned int qib_param_field_format
,
1649 /* pointer to 128 bytes or NULL, if no param field */
1650 unsigned char *qib_param_field
,
1651 /* pointer to no_queues*128 words of data or NULL */
1652 unsigned int no_input_qs
,
1653 unsigned int no_output_qs
,
1654 unsigned long *input_slib_elements
,
1655 unsigned long *output_slib_elements
)
1662 irq_ptr
->qib
.pfmt
=qib_param_field_format
;
1663 if (qib_param_field
)
1664 memcpy(irq_ptr
->qib
.parm
,qib_param_field
,
1665 QDIO_MAX_BUFFERS_PER_Q
);
1667 if (input_slib_elements
)
1668 for (i
=0;i
<no_input_qs
;i
++) {
1669 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1670 irq_ptr
->input_qs
[i
]->slib
->slibe
[j
].parms
=
1671 input_slib_elements
[
1672 i
*QDIO_MAX_BUFFERS_PER_Q
+j
];
1674 if (output_slib_elements
)
1675 for (i
=0;i
<no_output_qs
;i
++) {
1676 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1677 irq_ptr
->output_qs
[i
]->slib
->slibe
[j
].parms
=
1678 output_slib_elements
[
1679 i
*QDIO_MAX_BUFFERS_PER_Q
+j
];
1684 qdio_alloc_qs(struct qdio_irq
*irq_ptr
,
1685 int no_input_qs
, int no_output_qs
)
1691 for (i
=0;i
<no_input_qs
;i
++) {
1692 q
= kzalloc(sizeof(struct qdio_q
), GFP_KERNEL
);
1695 QDIO_PRINT_ERR("kmalloc of q failed!\n");
1699 q
->slib
= kmalloc(PAGE_SIZE
, GFP_KERNEL
);
1701 QDIO_PRINT_ERR("kmalloc of slib failed!\n");
1705 irq_ptr
->input_qs
[i
]=q
;
1708 for (i
=0;i
<no_output_qs
;i
++) {
1709 q
= kzalloc(sizeof(struct qdio_q
), GFP_KERNEL
);
1715 q
->slib
=kmalloc(PAGE_SIZE
,GFP_KERNEL
);
1717 QDIO_PRINT_ERR("kmalloc of slib failed!\n");
1721 irq_ptr
->output_qs
[i
]=q
;
1730 qdio_fill_qs(struct qdio_irq
*irq_ptr
, struct ccw_device
*cdev
,
1731 int no_input_qs
, int no_output_qs
,
1732 qdio_handler_t
*input_handler
,
1733 qdio_handler_t
*output_handler
,
1734 unsigned long int_parm
,int q_format
,
1735 unsigned long flags
,
1736 void **inbound_sbals_array
,
1737 void **outbound_sbals_array
)
1741 char dbf_text
[20]; /* see qdio_initialize */
1745 sprintf(dbf_text
,"qfqs%4x",cdev
->private->sch_no
);
1746 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
1747 for (i
=0;i
<no_input_qs
;i
++) {
1748 q
=irq_ptr
->input_qs
[i
];
1750 memset(q
,0,((char*)&q
->slib
)-((char*)q
));
1751 sprintf(dbf_text
,"in-q%4x",i
);
1752 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
1753 QDIO_DBF_HEX0(0,setup
,&q
,sizeof(void*));
1755 memset(q
->slib
,0,PAGE_SIZE
);
1756 q
->sl
=(struct sl
*)(((char*)q
->slib
)+PAGE_SIZE
/2);
1760 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1761 q
->sbal
[j
]=*(inbound_sbals_array
++);
1763 q
->queue_type
=q_format
;
1764 q
->int_parm
=int_parm
;
1765 q
->schid
= irq_ptr
->schid
;
1766 q
->irq_ptr
= irq_ptr
;
1771 q
->first_to_check
=0;
1773 q
->handler
=input_handler
;
1774 q
->dev_st_chg_ind
=irq_ptr
->dev_st_chg_ind
;
1776 q
->tasklet
.data
=(unsigned long)q
;
1777 /* q->is_thinint_q isn't valid at this time, but
1778 * irq_ptr->is_thinint_irq is */
1779 q
->tasklet
.func
=(void(*)(unsigned long))
1780 ((irq_ptr
->is_thinint_irq
)?&tiqdio_inbound_processing
:
1781 &qdio_inbound_processing
);
1783 /* actually this is not used for inbound queues. yet. */
1784 atomic_set(&q
->busy_siga_counter
,0);
1785 q
->timing
.busy_start
=0;
1787 /* for (j=0;j<QDIO_STATS_NUMBER;j++)
1788 q->timing.last_transfer_times[j]=(qdio_get_micros()/
1789 QDIO_STATS_NUMBER)*j;
1790 q->timing.last_transfer_index=QDIO_STATS_NUMBER-1;
1794 if (i
>0) irq_ptr
->input_qs
[i
-1]->slib
->nsliba
=
1795 (unsigned long)(q
->slib
);
1796 q
->slib
->sla
=(unsigned long)(q
->sl
);
1797 q
->slib
->slsba
=(unsigned long)(&q
->slsb
.acc
.val
[0]);
1800 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1801 q
->sl
->element
[j
].sbal
=(unsigned long)(q
->sbal
[j
]);
1803 QDIO_DBF_TEXT2(0,setup
,"sl-sb-b0");
1805 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1806 ptr
=(void*)&q
->slsb
;
1807 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1808 ptr
=(void*)q
->sbal
[0];
1809 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1812 if (!irq_ptr
->is_qebsm
) {
1813 unsigned int count
= 1;
1814 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; j
++)
1815 set_slsb(q
, &j
, SLSB_P_INPUT_NOT_INIT
, &count
);
1819 for (i
=0;i
<no_output_qs
;i
++) {
1820 q
=irq_ptr
->output_qs
[i
];
1821 memset(q
,0,((char*)&q
->slib
)-((char*)q
));
1823 sprintf(dbf_text
,"outq%4x",i
);
1824 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
1825 QDIO_DBF_HEX0(0,setup
,&q
,sizeof(void*));
1827 memset(q
->slib
,0,PAGE_SIZE
);
1828 q
->sl
=(struct sl
*)(((char*)q
->slib
)+PAGE_SIZE
/2);
1832 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1833 q
->sbal
[j
]=*(outbound_sbals_array
++);
1835 q
->queue_type
=q_format
;
1836 q
->int_parm
=int_parm
;
1838 q
->schid
= irq_ptr
->schid
;
1840 q
->irq_ptr
= irq_ptr
;
1843 q
->first_to_check
=0;
1845 q
->handler
=output_handler
;
1847 q
->tasklet
.data
=(unsigned long)q
;
1848 q
->tasklet
.func
=(void(*)(unsigned long))
1849 &qdio_outbound_processing
;
1851 atomic_set(&q
->busy_siga_counter
,0);
1852 q
->timing
.busy_start
=0;
1855 if (i
>0) irq_ptr
->output_qs
[i
-1]->slib
->nsliba
=
1856 (unsigned long)(q
->slib
);
1857 q
->slib
->sla
=(unsigned long)(q
->sl
);
1858 q
->slib
->slsba
=(unsigned long)(&q
->slsb
.acc
.val
[0]);
1861 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1862 q
->sl
->element
[j
].sbal
=(unsigned long)(q
->sbal
[j
]);
1864 QDIO_DBF_TEXT2(0,setup
,"sl-sb-b0");
1866 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1867 ptr
=(void*)&q
->slsb
;
1868 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1869 ptr
=(void*)q
->sbal
[0];
1870 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1873 if (!irq_ptr
->is_qebsm
) {
1874 unsigned int count
= 1;
1875 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; j
++)
1876 set_slsb(q
, &j
, SLSB_P_OUTPUT_NOT_INIT
, &count
);
1882 qdio_fill_thresholds(struct qdio_irq
*irq_ptr
,
1883 unsigned int no_input_qs
,
1884 unsigned int no_output_qs
,
1885 unsigned int min_input_threshold
,
1886 unsigned int max_input_threshold
,
1887 unsigned int min_output_threshold
,
1888 unsigned int max_output_threshold
)
1893 for (i
=0;i
<no_input_qs
;i
++) {
1894 q
=irq_ptr
->input_qs
[i
];
1895 q
->timing
.threshold
=max_input_threshold
;
1896 /* for (j=0;j<QDIO_STATS_CLASSES;j++) {
1897 q->threshold_classes[j].threshold=
1898 min_input_threshold+
1899 (max_input_threshold-min_input_threshold)/
1902 qdio_use_thresholds(q,QDIO_STATS_CLASSES/2);*/
1904 for (i
=0;i
<no_output_qs
;i
++) {
1905 q
=irq_ptr
->output_qs
[i
];
1906 q
->timing
.threshold
=max_output_threshold
;
1907 /* for (j=0;j<QDIO_STATS_CLASSES;j++) {
1908 q->threshold_classes[j].threshold=
1909 min_output_threshold+
1910 (max_output_threshold-min_output_threshold)/
1913 qdio_use_thresholds(q,QDIO_STATS_CLASSES/2);*/
1918 tiqdio_thinint_handler(void)
1920 QDIO_DBF_TEXT4(0,trace
,"thin_int");
1922 #ifdef QDIO_PERFORMANCE_STATS
1923 perf_stats
.thinints
++;
1924 perf_stats
.start_time_inbound
=NOW
;
1925 #endif /* QDIO_PERFORMANCE_STATS */
1927 /* SVS only when needed:
1928 * issue SVS to benefit from iqdio interrupt avoidance
1929 * (SVS clears AISOI)*/
1931 tiqdio_clear_global_summary();
1933 tiqdio_inbound_checks();
1938 qdio_set_state(struct qdio_irq
*irq_ptr
, enum qdio_irq_states state
)
1941 #ifdef CONFIG_QDIO_DEBUG
1944 QDIO_DBF_TEXT5(0,trace
,"newstate");
1945 sprintf(dbf_text
,"%4x%4x",irq_ptr
->schid
.sch_no
,state
);
1946 QDIO_DBF_TEXT5(0,trace
,dbf_text
);
1947 #endif /* CONFIG_QDIO_DEBUG */
1949 irq_ptr
->state
=state
;
1950 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++)
1951 irq_ptr
->input_qs
[i
]->state
=state
;
1952 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++)
1953 irq_ptr
->output_qs
[i
]->state
=state
;
1958 qdio_irq_check_sense(struct subchannel_id schid
, struct irb
*irb
)
1962 if (irb
->esw
.esw0
.erw
.cons
) {
1963 sprintf(dbf_text
,"sens%4x",schid
.sch_no
);
1964 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
1965 QDIO_DBF_HEX0(0,sense
,irb
,QDIO_DBF_SENSE_LEN
);
1967 QDIO_PRINT_WARN("sense data available on qdio channel.\n");
1968 HEXDUMP16(WARN
,"irb: ",irb
);
1969 HEXDUMP16(WARN
,"sense data: ",irb
->ecw
);
1975 qdio_handle_pci(struct qdio_irq
*irq_ptr
)
1980 #ifdef QDIO_PERFORMANCE_STATS
1982 perf_stats
.start_time_inbound
=NOW
;
1983 #endif /* QDIO_PERFORMANCE_STATS */
1984 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
1985 q
=irq_ptr
->input_qs
[i
];
1986 if (q
->is_input_q
&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT
)
1989 #ifdef QDIO_PERFORMANCE_STATS
1990 perf_stats
.tl_runs
--;
1991 #endif /* QDIO_PERFORMANCE_STATS */
1992 __qdio_inbound_processing(q
);
1995 if (!irq_ptr
->hydra_gives_outbound_pcis
)
1997 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
1998 q
=irq_ptr
->output_qs
[i
];
1999 #ifdef QDIO_PERFORMANCE_STATS
2000 perf_stats
.tl_runs
--;
2001 #endif /* QDIO_PERFORMANCE_STATS */
2002 if (qdio_is_outbound_q_done(q
))
2004 if (!irq_ptr
->sync_done_on_outb_pcis
)
2006 __qdio_outbound_processing(q
);
2010 static void qdio_establish_handle_irq(struct ccw_device
*, int, int);
2013 qdio_handle_activate_check(struct ccw_device
*cdev
, unsigned long intparm
,
2014 int cstat
, int dstat
)
2016 struct qdio_irq
*irq_ptr
;
2020 irq_ptr
= cdev
->private->qdio_data
;
2022 QDIO_DBF_TEXT2(1, trace
, "ick2");
2023 sprintf(dbf_text
,"%s", cdev
->dev
.bus_id
);
2024 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
2025 QDIO_DBF_HEX2(0,trace
,&intparm
,sizeof(int));
2026 QDIO_DBF_HEX2(0,trace
,&dstat
,sizeof(int));
2027 QDIO_DBF_HEX2(0,trace
,&cstat
,sizeof(int));
2028 QDIO_PRINT_ERR("received check condition on activate " \
2029 "queues on device %s (cs=x%x, ds=x%x).\n",
2030 cdev
->dev
.bus_id
, cstat
, dstat
);
2031 if (irq_ptr
->no_input_qs
) {
2032 q
=irq_ptr
->input_qs
[0];
2033 } else if (irq_ptr
->no_output_qs
) {
2034 q
=irq_ptr
->output_qs
[0];
2036 QDIO_PRINT_ERR("oops... no queue registered for device %s!?\n",
2038 goto omit_handler_call
;
2040 q
->handler(q
->cdev
,QDIO_STATUS_ACTIVATE_CHECK_CONDITION
|
2041 QDIO_STATUS_LOOK_FOR_ERROR
,
2042 0,0,0,-1,-1,q
->int_parm
);
2044 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_STOPPED
);
2049 qdio_call_shutdown(void *data
)
2051 struct ccw_device
*cdev
;
2053 cdev
= (struct ccw_device
*)data
;
2054 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
2055 put_device(&cdev
->dev
);
2059 qdio_timeout_handler(struct ccw_device
*cdev
)
2061 struct qdio_irq
*irq_ptr
;
2064 QDIO_DBF_TEXT2(0, trace
, "qtoh");
2065 sprintf(dbf_text
, "%s", cdev
->dev
.bus_id
);
2066 QDIO_DBF_TEXT2(0, trace
, dbf_text
);
2068 irq_ptr
= cdev
->private->qdio_data
;
2069 sprintf(dbf_text
, "state:%d", irq_ptr
->state
);
2070 QDIO_DBF_TEXT2(0, trace
, dbf_text
);
2072 switch (irq_ptr
->state
) {
2073 case QDIO_IRQ_STATE_INACTIVE
:
2074 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: timed out\n",
2075 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2076 QDIO_DBF_TEXT2(1,setup
,"eq:timeo");
2077 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2079 case QDIO_IRQ_STATE_CLEANUP
:
2080 QDIO_PRINT_INFO("Did not get interrupt on cleanup, "
2082 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2083 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2085 case QDIO_IRQ_STATE_ESTABLISHED
:
2086 case QDIO_IRQ_STATE_ACTIVE
:
2087 /* I/O has been terminated by common I/O layer. */
2088 QDIO_PRINT_INFO("Queues on irq 0.%x.%04x killed by cio.\n",
2089 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2090 QDIO_DBF_TEXT2(1, trace
, "cio:term");
2091 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_STOPPED
);
2092 if (get_device(&cdev
->dev
)) {
2093 /* Can't call shutdown from interrupt context. */
2094 PREPARE_WORK(&cdev
->private->kick_work
,
2095 qdio_call_shutdown
, (void *)cdev
);
2096 queue_work(ccw_device_work
, &cdev
->private->kick_work
);
2102 ccw_device_set_timeout(cdev
, 0);
2103 wake_up(&cdev
->private->wait_q
);
2107 qdio_handler(struct ccw_device
*cdev
, unsigned long intparm
, struct irb
*irb
)
2109 struct qdio_irq
*irq_ptr
;
2113 #ifdef CONFIG_QDIO_DEBUG
2114 QDIO_DBF_TEXT4(0, trace
, "qint");
2115 sprintf(dbf_text
, "%s", cdev
->dev
.bus_id
);
2116 QDIO_DBF_TEXT4(0, trace
, dbf_text
);
2117 #endif /* CONFIG_QDIO_DEBUG */
2120 QDIO_PRINT_ERR("got unsolicited interrupt in qdio " \
2121 "handler, device %s\n", cdev
->dev
.bus_id
);
2125 irq_ptr
= cdev
->private->qdio_data
;
2127 QDIO_DBF_TEXT2(1, trace
, "uint");
2128 sprintf(dbf_text
,"%s", cdev
->dev
.bus_id
);
2129 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
2130 QDIO_PRINT_ERR("received interrupt on unused device %s!\n",
2136 /* Currently running i/o is in error. */
2137 switch (PTR_ERR(irb
)) {
2139 QDIO_PRINT_ERR("i/o error on device %s\n",
2143 qdio_timeout_handler(cdev
);
2146 QDIO_PRINT_ERR("unknown error state %ld on device %s\n",
2147 PTR_ERR(irb
), cdev
->dev
.bus_id
);
2152 qdio_irq_check_sense(irq_ptr
->schid
, irb
);
2154 #ifdef CONFIG_QDIO_DEBUG
2155 sprintf(dbf_text
, "state:%d", irq_ptr
->state
);
2156 QDIO_DBF_TEXT4(0, trace
, dbf_text
);
2157 #endif /* CONFIG_QDIO_DEBUG */
2159 cstat
= irb
->scsw
.cstat
;
2160 dstat
= irb
->scsw
.dstat
;
2162 switch (irq_ptr
->state
) {
2163 case QDIO_IRQ_STATE_INACTIVE
:
2164 qdio_establish_handle_irq(cdev
, cstat
, dstat
);
2167 case QDIO_IRQ_STATE_CLEANUP
:
2168 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2171 case QDIO_IRQ_STATE_ESTABLISHED
:
2172 case QDIO_IRQ_STATE_ACTIVE
:
2173 if (cstat
& SCHN_STAT_PCI
) {
2174 qdio_handle_pci(irq_ptr
);
2178 if ((cstat
&~SCHN_STAT_PCI
)||dstat
) {
2179 qdio_handle_activate_check(cdev
, intparm
, cstat
, dstat
);
2183 QDIO_PRINT_ERR("got interrupt for queues in state %d on " \
2185 irq_ptr
->state
, cdev
->dev
.bus_id
);
2187 wake_up(&cdev
->private->wait_q
);
2192 qdio_synchronize(struct ccw_device
*cdev
, unsigned int flags
,
2193 unsigned int queue_number
)
2197 struct qdio_irq
*irq_ptr
;
2199 #ifdef CONFIG_QDIO_DEBUG
2200 char dbf_text
[15]="SyncXXXX";
2203 irq_ptr
= cdev
->private->qdio_data
;
2207 #ifdef CONFIG_QDIO_DEBUG
2208 *((int*)(&dbf_text
[4])) = irq_ptr
->schid
.sch_no
;
2209 QDIO_DBF_HEX4(0,trace
,dbf_text
,QDIO_DBF_TRACE_LEN
);
2210 *((int*)(&dbf_text
[0]))=flags
;
2211 *((int*)(&dbf_text
[4]))=queue_number
;
2212 QDIO_DBF_HEX4(0,trace
,dbf_text
,QDIO_DBF_TRACE_LEN
);
2213 #endif /* CONFIG_QDIO_DEBUG */
2215 if (flags
&QDIO_FLAG_SYNC_INPUT
) {
2216 q
=irq_ptr
->input_qs
[queue_number
];
2219 if (!(irq_ptr
->is_qebsm
))
2220 cc
= do_siga_sync(q
->schid
, 0, q
->mask
);
2221 } else if (flags
&QDIO_FLAG_SYNC_OUTPUT
) {
2222 q
=irq_ptr
->output_qs
[queue_number
];
2225 if (!(irq_ptr
->is_qebsm
))
2226 cc
= do_siga_sync(q
->schid
, q
->mask
, 0);
2232 QDIO_DBF_HEX3(0,trace
,&ptr
,sizeof(int));
2238 qdio_check_subchannel_qebsm(struct qdio_irq
*irq_ptr
, unsigned char qdioac
,
2239 unsigned long token
)
2243 unsigned int count
, start_buf
;
2246 /*check if QEBSM is disabled */
2247 if (!(irq_ptr
->is_qebsm
) || !(qdioac
& 0x01)) {
2248 irq_ptr
->is_qebsm
= 0;
2249 irq_ptr
->sch_token
= 0;
2250 irq_ptr
->qib
.rflags
&= ~QIB_RFLAGS_ENABLE_QEBSM
;
2251 QDIO_DBF_TEXT0(0,setup
,"noV=V");
2254 irq_ptr
->sch_token
= token
;
2256 for (i
= 0; i
< irq_ptr
->no_input_qs
;i
++) {
2257 q
= irq_ptr
->input_qs
[i
];
2258 count
= QDIO_MAX_BUFFERS_PER_Q
;
2260 set_slsb(q
, &start_buf
, SLSB_P_INPUT_NOT_INIT
, &count
);
2262 sprintf(dbf_text
,"V=V:%2x",irq_ptr
->is_qebsm
);
2263 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2264 sprintf(dbf_text
,"%8lx",irq_ptr
->sch_token
);
2265 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2267 for (i
= 0; i
< irq_ptr
->no_output_qs
; i
++) {
2268 q
= irq_ptr
->output_qs
[i
];
2269 count
= QDIO_MAX_BUFFERS_PER_Q
;
2271 set_slsb(q
, &start_buf
, SLSB_P_OUTPUT_NOT_INIT
, &count
);
2276 qdio_get_ssqd_information(struct qdio_irq
*irq_ptr
)
2279 unsigned char qdioac
;
2281 struct chsc_header request
;
2289 struct chsc_header response
;
2308 QDIO_DBF_TEXT0(0,setup
,"getssqd");
2310 ssqd_area
= mempool_alloc(qdio_mempool_scssc
, GFP_ATOMIC
);
2312 QDIO_PRINT_WARN("Could not get memory for chsc. Using all " \
2313 "SIGAs for sch x%x.\n", irq_ptr
->schid
.sch_no
);
2314 irq_ptr
->qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
||
2315 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
||
2316 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* all flags set */
2317 irq_ptr
->is_qebsm
= 0;
2318 irq_ptr
->sch_token
= 0;
2319 irq_ptr
->qib
.rflags
&= ~QIB_RFLAGS_ENABLE_QEBSM
;
2323 ssqd_area
->request
= (struct chsc_header
) {
2327 ssqd_area
->first_sch
= irq_ptr
->schid
.sch_no
;
2328 ssqd_area
->last_sch
= irq_ptr
->schid
.sch_no
;
2329 ssqd_area
->ssid
= irq_ptr
->schid
.ssid
;
2330 result
= chsc(ssqd_area
);
2333 QDIO_PRINT_WARN("CHSC returned cc %i. Using all " \
2334 "SIGAs for sch 0.%x.%x.\n", result
,
2335 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2336 qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
||
2337 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
||
2338 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* all flags set */
2339 irq_ptr
->is_qebsm
= 0;
2343 if (ssqd_area
->response
.code
!= QDIO_CHSC_RESPONSE_CODE_OK
) {
2344 QDIO_PRINT_WARN("response upon checking SIGA needs " \
2345 "is 0x%x. Using all SIGAs for sch 0.%x.%x.\n",
2346 ssqd_area
->response
.code
,
2347 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2348 qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
||
2349 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
||
2350 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* all flags set */
2351 irq_ptr
->is_qebsm
= 0;
2354 if (!(ssqd_area
->flags
& CHSC_FLAG_QDIO_CAPABILITY
) ||
2355 !(ssqd_area
->flags
& CHSC_FLAG_VALIDITY
) ||
2356 (ssqd_area
->sch
!= irq_ptr
->schid
.sch_no
)) {
2357 QDIO_PRINT_WARN("huh? problems checking out sch 0.%x.%x... " \
2358 "using all SIGAs.\n",
2359 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2360 qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
|
2361 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
|
2362 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* worst case */
2363 irq_ptr
->is_qebsm
= 0;
2366 qdioac
= ssqd_area
->qdioac1
;
2368 qdio_check_subchannel_qebsm(irq_ptr
, qdioac
,
2369 ssqd_area
->sch_token
);
2370 mempool_free(ssqd_area
, qdio_mempool_scssc
);
2371 irq_ptr
->qdioac
= qdioac
;
2375 tiqdio_check_chsc_availability(void)
2379 if (!css_characteristics_avail
)
2382 /* Check for bit 41. */
2383 if (!css_general_characteristics
.aif
) {
2384 QDIO_PRINT_WARN("Adapter interruption facility not " \
2389 /* Check for bits 107 and 108. */
2390 if (!css_chsc_characteristics
.scssc
||
2391 !css_chsc_characteristics
.scsscf
) {
2392 QDIO_PRINT_WARN("Set Chan Subsys. Char. & Fast-CHSCs " \
2393 "not available.\n");
2397 /* Check for OSA/FCP thin interrupts (bit 67). */
2398 hydra_thinints
= css_general_characteristics
.aif_osa
;
2399 sprintf(dbf_text
,"hydrati%1x", hydra_thinints
);
2400 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2403 /* Check for QEBSM support in general (bit 58). */
2404 is_passthrough
= css_general_characteristics
.qebsm
;
2406 sprintf(dbf_text
,"cssQBS:%1x", is_passthrough
);
2407 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2409 /* Check for aif time delay disablement fac (bit 56). If installed,
2410 * omit svs even under lpar (good point by rick again) */
2411 omit_svs
= css_general_characteristics
.aif_tdd
;
2412 sprintf(dbf_text
,"omitsvs%1x", omit_svs
);
2413 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2419 tiqdio_set_subchannel_ind(struct qdio_irq
*irq_ptr
, int reset_to_zero
)
2421 unsigned long real_addr_local_summary_bit
;
2422 unsigned long real_addr_dev_st_chg_ind
;
2426 unsigned int resp_code
;
2430 struct chsc_header request
;
2435 u64 summary_indicator_addr
;
2436 u64 subchannel_indicator_addr
;
2441 u32 word_with_d_bit
;
2442 /* set to 0x10000000 to enable
2443 * time delay disablement facility */
2445 struct subchannel_id schid
;
2446 u32 reserved6
[1004];
2447 struct chsc_header response
;
2451 if (!irq_ptr
->is_thinint_irq
)
2454 if (reset_to_zero
) {
2455 real_addr_local_summary_bit
=0;
2456 real_addr_dev_st_chg_ind
=0;
2458 real_addr_local_summary_bit
=
2459 virt_to_phys((volatile void *)indicators
);
2460 real_addr_dev_st_chg_ind
=
2461 virt_to_phys((volatile void *)irq_ptr
->dev_st_chg_ind
);
2464 scssc_area
= mempool_alloc(qdio_mempool_scssc
, GFP_ATOMIC
);
2466 QDIO_PRINT_WARN("No memory for setting indicators on " \
2467 "subchannel 0.%x.%x.\n",
2468 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2471 scssc_area
->request
= (struct chsc_header
) {
2475 scssc_area
->operation_code
= 0;
2477 scssc_area
->summary_indicator_addr
= real_addr_local_summary_bit
;
2478 scssc_area
->subchannel_indicator_addr
= real_addr_dev_st_chg_ind
;
2479 scssc_area
->ks
= QDIO_STORAGE_KEY
;
2480 scssc_area
->kc
= QDIO_STORAGE_KEY
;
2481 scssc_area
->isc
= TIQDIO_THININT_ISC
;
2482 scssc_area
->schid
= irq_ptr
->schid
;
2483 /* enables the time delay disablement facility. Don't care
2484 * whether it is really there (i.e. we haven't checked for
2486 if (css_general_characteristics
.aif_tdd
)
2487 scssc_area
->word_with_d_bit
= 0x10000000;
2489 QDIO_PRINT_WARN("Time delay disablement facility " \
2492 result
= chsc(scssc_area
);
2494 QDIO_PRINT_WARN("could not set indicators on irq 0.%x.%x, " \
2496 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,result
);
2501 resp_code
= scssc_area
->response
.code
;
2502 if (resp_code
!=QDIO_CHSC_RESPONSE_CODE_OK
) {
2503 QDIO_PRINT_WARN("response upon setting indicators " \
2504 "is 0x%x.\n",resp_code
);
2505 sprintf(dbf_text
,"sidR%4x",resp_code
);
2506 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2507 QDIO_DBF_TEXT1(0,setup
,dbf_text
);
2508 ptr
=&scssc_area
->response
;
2509 QDIO_DBF_HEX2(1,setup
,&ptr
,QDIO_DBF_SETUP_LEN
);
2514 QDIO_DBF_TEXT2(0,setup
,"setscind");
2515 QDIO_DBF_HEX2(0,setup
,&real_addr_local_summary_bit
,
2516 sizeof(unsigned long));
2517 QDIO_DBF_HEX2(0,setup
,&real_addr_dev_st_chg_ind
,sizeof(unsigned long));
2520 mempool_free(scssc_area
, qdio_mempool_scssc
);
2526 tiqdio_set_delay_target(struct qdio_irq
*irq_ptr
, unsigned long delay_target
)
2528 unsigned int resp_code
;
2534 struct chsc_header request
;
2541 u32 reserved5
[1009];
2542 struct chsc_header response
;
2546 if (!irq_ptr
->is_thinint_irq
)
2549 scsscf_area
= mempool_alloc(qdio_mempool_scssc
, GFP_ATOMIC
);
2551 QDIO_PRINT_WARN("No memory for setting delay target on " \
2552 "subchannel 0.%x.%x.\n",
2553 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2556 scsscf_area
->request
= (struct chsc_header
) {
2561 scsscf_area
->delay_target
= delay_target
<<16;
2563 result
=chsc(scsscf_area
);
2565 QDIO_PRINT_WARN("could not set delay target on irq 0.%x.%x, " \
2566 "cc=%i. Continuing.\n",
2567 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
2573 resp_code
= scsscf_area
->response
.code
;
2574 if (resp_code
!=QDIO_CHSC_RESPONSE_CODE_OK
) {
2575 QDIO_PRINT_WARN("response upon setting delay target " \
2576 "is 0x%x. Continuing.\n",resp_code
);
2577 sprintf(dbf_text
,"sdtR%4x",resp_code
);
2578 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2579 QDIO_DBF_TEXT1(0,setup
,dbf_text
);
2580 ptr
=&scsscf_area
->response
;
2581 QDIO_DBF_HEX2(1,trace
,&ptr
,QDIO_DBF_TRACE_LEN
);
2583 QDIO_DBF_TEXT2(0,trace
,"delytrgt");
2584 QDIO_DBF_HEX2(0,trace
,&delay_target
,sizeof(unsigned long));
2585 result
= 0; /* not critical */
2587 mempool_free(scsscf_area
, qdio_mempool_scssc
);
2592 qdio_cleanup(struct ccw_device
*cdev
, int how
)
2594 struct qdio_irq
*irq_ptr
;
2598 irq_ptr
= cdev
->private->qdio_data
;
2602 sprintf(dbf_text
,"qcln%4x",irq_ptr
->schid
.sch_no
);
2603 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2604 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2606 rc
= qdio_shutdown(cdev
, how
);
2607 if ((rc
== 0) || (rc
== -EINPROGRESS
))
2608 rc
= qdio_free(cdev
);
2613 qdio_shutdown(struct ccw_device
*cdev
, int how
)
2615 struct qdio_irq
*irq_ptr
;
2619 unsigned long flags
;
2623 irq_ptr
= cdev
->private->qdio_data
;
2627 down(&irq_ptr
->setting_up_sema
);
2629 sprintf(dbf_text
,"qsqs%4x",irq_ptr
->schid
.sch_no
);
2630 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2631 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2633 /* mark all qs as uninteresting */
2634 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++)
2635 atomic_set(&irq_ptr
->input_qs
[i
]->is_in_shutdown
,1);
2637 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++)
2638 atomic_set(&irq_ptr
->output_qs
[i
]->is_in_shutdown
,1);
2640 tasklet_kill(&tiqdio_tasklet
);
2642 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
2643 qdio_unmark_q(irq_ptr
->input_qs
[i
]);
2644 tasklet_kill(&irq_ptr
->input_qs
[i
]->tasklet
);
2645 wait_event_interruptible_timeout(cdev
->private->wait_q
,
2646 !atomic_read(&irq_ptr
->
2649 QDIO_NO_USE_COUNT_TIMEOUT
);
2650 if (atomic_read(&irq_ptr
->input_qs
[i
]->use_count
))
2651 result
=-EINPROGRESS
;
2654 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
2655 tasklet_kill(&irq_ptr
->output_qs
[i
]->tasklet
);
2656 wait_event_interruptible_timeout(cdev
->private->wait_q
,
2657 !atomic_read(&irq_ptr
->
2660 QDIO_NO_USE_COUNT_TIMEOUT
);
2661 if (atomic_read(&irq_ptr
->output_qs
[i
]->use_count
))
2662 result
=-EINPROGRESS
;
2665 /* cleanup subchannel */
2666 spin_lock_irqsave(get_ccwdev_lock(cdev
),flags
);
2667 if (how
&QDIO_FLAG_CLEANUP_USING_CLEAR
) {
2668 rc
= ccw_device_clear(cdev
, QDIO_DOING_CLEANUP
);
2669 timeout
=QDIO_CLEANUP_CLEAR_TIMEOUT
;
2670 } else if (how
&QDIO_FLAG_CLEANUP_USING_HALT
) {
2671 rc
= ccw_device_halt(cdev
, QDIO_DOING_CLEANUP
);
2672 timeout
=QDIO_CLEANUP_HALT_TIMEOUT
;
2673 } else { /* default behaviour */
2674 rc
= ccw_device_halt(cdev
, QDIO_DOING_CLEANUP
);
2675 timeout
=QDIO_CLEANUP_HALT_TIMEOUT
;
2677 if (rc
== -ENODEV
) {
2678 /* No need to wait for device no longer present. */
2679 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2680 spin_unlock_irqrestore(get_ccwdev_lock(cdev
), flags
);
2681 } else if (((void *)cdev
->handler
!= (void *)qdio_handler
) && rc
== 0) {
2683 * Whoever put another handler there, has to cope with the
2684 * interrupt theirself. Might happen if qdio_shutdown was
2685 * called on already shutdown queues, but this shouldn't have
2688 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2689 spin_unlock_irqrestore(get_ccwdev_lock(cdev
), flags
);
2690 } else if (rc
== 0) {
2691 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_CLEANUP
);
2692 ccw_device_set_timeout(cdev
, timeout
);
2693 spin_unlock_irqrestore(get_ccwdev_lock(cdev
),flags
);
2695 wait_event(cdev
->private->wait_q
,
2696 irq_ptr
->state
== QDIO_IRQ_STATE_INACTIVE
||
2697 irq_ptr
->state
== QDIO_IRQ_STATE_ERR
);
2699 QDIO_PRINT_INFO("ccw_device_{halt,clear} returned %d for "
2700 "device %s\n", result
, cdev
->dev
.bus_id
);
2701 spin_unlock_irqrestore(get_ccwdev_lock(cdev
), flags
);
2705 if (irq_ptr
->is_thinint_irq
) {
2706 qdio_put_indicator((__u32
*)irq_ptr
->dev_st_chg_ind
);
2707 tiqdio_set_subchannel_ind(irq_ptr
,1);
2708 /* reset adapter interrupt indicators */
2711 /* exchange int handlers, if necessary */
2712 if ((void*)cdev
->handler
== (void*)qdio_handler
)
2713 cdev
->handler
=irq_ptr
->original_int_handler
;
2715 /* Ignore errors. */
2716 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2717 ccw_device_set_timeout(cdev
, 0);
2719 up(&irq_ptr
->setting_up_sema
);
2724 qdio_free(struct ccw_device
*cdev
)
2726 struct qdio_irq
*irq_ptr
;
2729 irq_ptr
= cdev
->private->qdio_data
;
2733 down(&irq_ptr
->setting_up_sema
);
2735 sprintf(dbf_text
,"qfqs%4x",irq_ptr
->schid
.sch_no
);
2736 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2737 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2739 cdev
->private->qdio_data
= 0;
2741 up(&irq_ptr
->setting_up_sema
);
2743 qdio_release_irq_memory(irq_ptr
);
2744 module_put(THIS_MODULE
);
2749 qdio_allocate_do_dbf(struct qdio_initialize
*init_data
)
2751 char dbf_text
[20]; /* if a printf printed out more than 8 chars */
2753 sprintf(dbf_text
,"qfmt:%x",init_data
->q_format
);
2754 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2755 QDIO_DBF_HEX0(0,setup
,init_data
->adapter_name
,8);
2756 sprintf(dbf_text
,"qpff%4x",init_data
->qib_param_field_format
);
2757 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2758 QDIO_DBF_HEX0(0,setup
,&init_data
->qib_param_field
,sizeof(char*));
2759 QDIO_DBF_HEX0(0,setup
,&init_data
->input_slib_elements
,sizeof(long*));
2760 QDIO_DBF_HEX0(0,setup
,&init_data
->output_slib_elements
,sizeof(long*));
2761 sprintf(dbf_text
,"miit%4x",init_data
->min_input_threshold
);
2762 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2763 sprintf(dbf_text
,"mait%4x",init_data
->max_input_threshold
);
2764 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2765 sprintf(dbf_text
,"miot%4x",init_data
->min_output_threshold
);
2766 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2767 sprintf(dbf_text
,"maot%4x",init_data
->max_output_threshold
);
2768 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2769 sprintf(dbf_text
,"niq:%4x",init_data
->no_input_qs
);
2770 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2771 sprintf(dbf_text
,"noq:%4x",init_data
->no_output_qs
);
2772 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2773 QDIO_DBF_HEX0(0,setup
,&init_data
->input_handler
,sizeof(void*));
2774 QDIO_DBF_HEX0(0,setup
,&init_data
->output_handler
,sizeof(void*));
2775 QDIO_DBF_HEX0(0,setup
,&init_data
->int_parm
,sizeof(long));
2776 QDIO_DBF_HEX0(0,setup
,&init_data
->flags
,sizeof(long));
2777 QDIO_DBF_HEX0(0,setup
,&init_data
->input_sbal_addr_array
,sizeof(void*));
2778 QDIO_DBF_HEX0(0,setup
,&init_data
->output_sbal_addr_array
,sizeof(void*));
2782 qdio_allocate_fill_input_desc(struct qdio_irq
*irq_ptr
, int i
, int iqfmt
)
2784 irq_ptr
->input_qs
[i
]->is_iqdio_q
= iqfmt
;
2785 irq_ptr
->input_qs
[i
]->is_thinint_q
= irq_ptr
->is_thinint_irq
;
2787 irq_ptr
->qdr
->qdf0
[i
].sliba
=(unsigned long)(irq_ptr
->input_qs
[i
]->slib
);
2789 irq_ptr
->qdr
->qdf0
[i
].sla
=(unsigned long)(irq_ptr
->input_qs
[i
]->sl
);
2791 irq_ptr
->qdr
->qdf0
[i
].slsba
=
2792 (unsigned long)(&irq_ptr
->input_qs
[i
]->slsb
.acc
.val
[0]);
2794 irq_ptr
->qdr
->qdf0
[i
].akey
=QDIO_STORAGE_KEY
;
2795 irq_ptr
->qdr
->qdf0
[i
].bkey
=QDIO_STORAGE_KEY
;
2796 irq_ptr
->qdr
->qdf0
[i
].ckey
=QDIO_STORAGE_KEY
;
2797 irq_ptr
->qdr
->qdf0
[i
].dkey
=QDIO_STORAGE_KEY
;
2801 qdio_allocate_fill_output_desc(struct qdio_irq
*irq_ptr
, int i
,
2804 irq_ptr
->output_qs
[i
]->is_iqdio_q
= iqfmt
;
2805 irq_ptr
->output_qs
[i
]->is_thinint_q
= irq_ptr
->is_thinint_irq
;
2807 irq_ptr
->qdr
->qdf0
[i
+j
].sliba
=(unsigned long)(irq_ptr
->output_qs
[i
]->slib
);
2809 irq_ptr
->qdr
->qdf0
[i
+j
].sla
=(unsigned long)(irq_ptr
->output_qs
[i
]->sl
);
2811 irq_ptr
->qdr
->qdf0
[i
+j
].slsba
=
2812 (unsigned long)(&irq_ptr
->output_qs
[i
]->slsb
.acc
.val
[0]);
2814 irq_ptr
->qdr
->qdf0
[i
+j
].akey
=QDIO_STORAGE_KEY
;
2815 irq_ptr
->qdr
->qdf0
[i
+j
].bkey
=QDIO_STORAGE_KEY
;
2816 irq_ptr
->qdr
->qdf0
[i
+j
].ckey
=QDIO_STORAGE_KEY
;
2817 irq_ptr
->qdr
->qdf0
[i
+j
].dkey
=QDIO_STORAGE_KEY
;
2822 qdio_initialize_set_siga_flags_input(struct qdio_irq
*irq_ptr
)
2826 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
2827 irq_ptr
->input_qs
[i
]->siga_sync
=
2828 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_NECESSARY
;
2829 irq_ptr
->input_qs
[i
]->siga_in
=
2830 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_INPUT_NECESSARY
;
2831 irq_ptr
->input_qs
[i
]->siga_out
=
2832 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_OUTPUT_NECESSARY
;
2833 irq_ptr
->input_qs
[i
]->siga_sync_done_on_thinints
=
2834 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
;
2835 irq_ptr
->input_qs
[i
]->hydra_gives_outbound_pcis
=
2836 irq_ptr
->hydra_gives_outbound_pcis
;
2837 irq_ptr
->input_qs
[i
]->siga_sync_done_on_outb_tis
=
2839 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2840 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
))==
2841 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2842 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
));
2848 qdio_initialize_set_siga_flags_output(struct qdio_irq
*irq_ptr
)
2852 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
2853 irq_ptr
->output_qs
[i
]->siga_sync
=
2854 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_NECESSARY
;
2855 irq_ptr
->output_qs
[i
]->siga_in
=
2856 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_INPUT_NECESSARY
;
2857 irq_ptr
->output_qs
[i
]->siga_out
=
2858 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_OUTPUT_NECESSARY
;
2859 irq_ptr
->output_qs
[i
]->siga_sync_done_on_thinints
=
2860 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
;
2861 irq_ptr
->output_qs
[i
]->hydra_gives_outbound_pcis
=
2862 irq_ptr
->hydra_gives_outbound_pcis
;
2863 irq_ptr
->output_qs
[i
]->siga_sync_done_on_outb_tis
=
2865 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2866 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
))==
2867 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2868 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
));
2874 qdio_establish_irq_check_for_errors(struct ccw_device
*cdev
, int cstat
,
2878 struct qdio_irq
*irq_ptr
;
2880 irq_ptr
= cdev
->private->qdio_data
;
2882 if (cstat
|| (dstat
& ~(DEV_STAT_CHN_END
|DEV_STAT_DEV_END
))) {
2883 sprintf(dbf_text
,"ick1%4x",irq_ptr
->schid
.sch_no
);
2884 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
2885 QDIO_DBF_HEX2(0,trace
,&dstat
,sizeof(int));
2886 QDIO_DBF_HEX2(0,trace
,&cstat
,sizeof(int));
2887 QDIO_PRINT_ERR("received check condition on establish " \
2888 "queues on irq 0.%x.%x (cs=x%x, ds=x%x).\n",
2889 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
2891 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_ERR
);
2894 if (!(dstat
& DEV_STAT_DEV_END
)) {
2895 QDIO_DBF_TEXT2(1,setup
,"eq:no de");
2896 QDIO_DBF_HEX2(0,setup
,&dstat
, sizeof(dstat
));
2897 QDIO_DBF_HEX2(0,setup
,&cstat
, sizeof(cstat
));
2898 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: didn't get "
2899 "device end: dstat=%02x, cstat=%02x\n",
2900 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
2902 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2906 if (dstat
& ~(DEV_STAT_CHN_END
|DEV_STAT_DEV_END
)) {
2907 QDIO_DBF_TEXT2(1,setup
,"eq:badio");
2908 QDIO_DBF_HEX2(0,setup
,&dstat
, sizeof(dstat
));
2909 QDIO_DBF_HEX2(0,setup
,&cstat
, sizeof(cstat
));
2910 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: got "
2911 "the following devstat: dstat=%02x, "
2912 "cstat=%02x\n", irq_ptr
->schid
.ssid
,
2913 irq_ptr
->schid
.sch_no
, dstat
, cstat
);
2914 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2921 qdio_establish_handle_irq(struct ccw_device
*cdev
, int cstat
, int dstat
)
2923 struct qdio_irq
*irq_ptr
;
2926 irq_ptr
= cdev
->private->qdio_data
;
2928 sprintf(dbf_text
,"qehi%4x",cdev
->private->sch_no
);
2929 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2930 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
2932 if (qdio_establish_irq_check_for_errors(cdev
, cstat
, dstat
)) {
2933 ccw_device_set_timeout(cdev
, 0);
2937 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_ESTABLISHED
);
2938 ccw_device_set_timeout(cdev
, 0);
2942 qdio_initialize(struct qdio_initialize
*init_data
)
2947 sprintf(dbf_text
,"qini%4x",init_data
->cdev
->private->sch_no
);
2948 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2949 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
2951 rc
= qdio_allocate(init_data
);
2953 rc
= qdio_establish(init_data
);
2955 qdio_free(init_data
->cdev
);
2963 qdio_allocate(struct qdio_initialize
*init_data
)
2965 struct qdio_irq
*irq_ptr
;
2968 sprintf(dbf_text
,"qalc%4x",init_data
->cdev
->private->sch_no
);
2969 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2970 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
2971 if ( (init_data
->no_input_qs
>QDIO_MAX_QUEUES_PER_IRQ
) ||
2972 (init_data
->no_output_qs
>QDIO_MAX_QUEUES_PER_IRQ
) ||
2973 ((init_data
->no_input_qs
) && (!init_data
->input_handler
)) ||
2974 ((init_data
->no_output_qs
) && (!init_data
->output_handler
)) )
2977 if (!init_data
->input_sbal_addr_array
)
2980 if (!init_data
->output_sbal_addr_array
)
2983 qdio_allocate_do_dbf(init_data
);
2986 irq_ptr
= (void *) get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
2988 QDIO_DBF_TEXT0(0,setup
,"irq_ptr:");
2989 QDIO_DBF_HEX0(0,setup
,&irq_ptr
,sizeof(void*));
2992 QDIO_PRINT_ERR("kmalloc of irq_ptr failed!\n");
2996 init_MUTEX(&irq_ptr
->setting_up_sema
);
2998 /* QDR must be in DMA area since CCW data address is only 32 bit */
2999 irq_ptr
->qdr
=kmalloc(sizeof(struct qdr
), GFP_KERNEL
| GFP_DMA
);
3000 if (!(irq_ptr
->qdr
)) {
3001 free_page((unsigned long) irq_ptr
);
3002 QDIO_PRINT_ERR("kmalloc of irq_ptr->qdr failed!\n");
3005 QDIO_DBF_TEXT0(0,setup
,"qdr:");
3006 QDIO_DBF_HEX0(0,setup
,&irq_ptr
->qdr
,sizeof(void*));
3008 if (qdio_alloc_qs(irq_ptr
,
3009 init_data
->no_input_qs
,
3010 init_data
->no_output_qs
)) {
3011 qdio_release_irq_memory(irq_ptr
);
3015 init_data
->cdev
->private->qdio_data
= irq_ptr
;
3017 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_INACTIVE
);
3022 int qdio_fill_irq(struct qdio_initialize
*init_data
)
3028 struct qdio_irq
*irq_ptr
;
3030 irq_ptr
= init_data
->cdev
->private->qdio_data
;
3032 memset(irq_ptr
,0,((char*)&irq_ptr
->qdr
)-((char*)irq_ptr
));
3034 /* wipes qib.ac, required by ar7063 */
3035 memset(irq_ptr
->qdr
,0,sizeof(struct qdr
));
3037 irq_ptr
->int_parm
=init_data
->int_parm
;
3039 irq_ptr
->schid
= ccw_device_get_subchannel_id(init_data
->cdev
);
3040 irq_ptr
->no_input_qs
=init_data
->no_input_qs
;
3041 irq_ptr
->no_output_qs
=init_data
->no_output_qs
;
3043 if (init_data
->q_format
==QDIO_IQDIO_QFMT
) {
3044 irq_ptr
->is_iqdio_irq
=1;
3045 irq_ptr
->is_thinint_irq
=1;
3047 irq_ptr
->is_iqdio_irq
=0;
3048 irq_ptr
->is_thinint_irq
=hydra_thinints
;
3050 sprintf(dbf_text
,"is_i_t%1x%1x",
3051 irq_ptr
->is_iqdio_irq
,irq_ptr
->is_thinint_irq
);
3052 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3054 if (irq_ptr
->is_thinint_irq
) {
3055 irq_ptr
->dev_st_chg_ind
= qdio_get_indicator();
3056 QDIO_DBF_HEX1(0,setup
,&irq_ptr
->dev_st_chg_ind
,sizeof(void*));
3057 if (!irq_ptr
->dev_st_chg_ind
) {
3058 QDIO_PRINT_WARN("no indicator location available " \
3059 "for irq 0.%x.%x\n",
3060 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
3061 qdio_release_irq_memory(irq_ptr
);
3067 irq_ptr
->equeue
.cmd
=DEFAULT_ESTABLISH_QS_CMD
;
3068 irq_ptr
->equeue
.count
=DEFAULT_ESTABLISH_QS_COUNT
;
3069 irq_ptr
->aqueue
.cmd
=DEFAULT_ACTIVATE_QS_CMD
;
3070 irq_ptr
->aqueue
.count
=DEFAULT_ACTIVATE_QS_COUNT
;
3072 qdio_fill_qs(irq_ptr
, init_data
->cdev
,
3073 init_data
->no_input_qs
,
3074 init_data
->no_output_qs
,
3075 init_data
->input_handler
,
3076 init_data
->output_handler
,init_data
->int_parm
,
3077 init_data
->q_format
,init_data
->flags
,
3078 init_data
->input_sbal_addr_array
,
3079 init_data
->output_sbal_addr_array
);
3081 if (!try_module_get(THIS_MODULE
)) {
3082 QDIO_PRINT_CRIT("try_module_get() failed!\n");
3083 qdio_release_irq_memory(irq_ptr
);
3087 qdio_fill_thresholds(irq_ptr
,init_data
->no_input_qs
,
3088 init_data
->no_output_qs
,
3089 init_data
->min_input_threshold
,
3090 init_data
->max_input_threshold
,
3091 init_data
->min_output_threshold
,
3092 init_data
->max_output_threshold
);
3095 irq_ptr
->qdr
->qfmt
=init_data
->q_format
;
3096 irq_ptr
->qdr
->iqdcnt
=init_data
->no_input_qs
;
3097 irq_ptr
->qdr
->oqdcnt
=init_data
->no_output_qs
;
3098 irq_ptr
->qdr
->iqdsz
=sizeof(struct qdesfmt0
)/4; /* size in words */
3099 irq_ptr
->qdr
->oqdsz
=sizeof(struct qdesfmt0
)/4;
3101 irq_ptr
->qdr
->qiba
=(unsigned long)&irq_ptr
->qib
;
3102 irq_ptr
->qdr
->qkey
=QDIO_STORAGE_KEY
;
3105 irq_ptr
->is_qebsm
= is_passthrough
;
3106 if (irq_ptr
->is_qebsm
)
3107 irq_ptr
->qib
.rflags
|= QIB_RFLAGS_ENABLE_QEBSM
;
3109 irq_ptr
->qib
.qfmt
=init_data
->q_format
;
3110 if (init_data
->no_input_qs
)
3111 irq_ptr
->qib
.isliba
=(unsigned long)(irq_ptr
->input_qs
[0]->slib
);
3112 if (init_data
->no_output_qs
)
3113 irq_ptr
->qib
.osliba
=(unsigned long)(irq_ptr
->output_qs
[0]->slib
);
3114 memcpy(irq_ptr
->qib
.ebcnam
,init_data
->adapter_name
,8);
3116 qdio_set_impl_params(irq_ptr
,init_data
->qib_param_field_format
,
3117 init_data
->qib_param_field
,
3118 init_data
->no_input_qs
,
3119 init_data
->no_output_qs
,
3120 init_data
->input_slib_elements
,
3121 init_data
->output_slib_elements
);
3123 /* first input descriptors, then output descriptors */
3124 is_iqdio
= (init_data
->q_format
== QDIO_IQDIO_QFMT
) ? 1 : 0;
3125 for (i
=0;i
<init_data
->no_input_qs
;i
++)
3126 qdio_allocate_fill_input_desc(irq_ptr
, i
, is_iqdio
);
3128 for (i
=0;i
<init_data
->no_output_qs
;i
++)
3129 qdio_allocate_fill_output_desc(irq_ptr
, i
,
3130 init_data
->no_input_qs
,
3133 /* qdr, qib, sls, slsbs, slibs, sbales filled. */
3135 /* get qdio commands */
3136 ciw
= ccw_device_get_ciw(init_data
->cdev
, CIW_TYPE_EQUEUE
);
3138 QDIO_DBF_TEXT2(1,setup
,"no eq");
3139 QDIO_PRINT_INFO("No equeue CIW found for QDIO commands. "
3140 "Trying to use default.\n");
3142 irq_ptr
->equeue
= *ciw
;
3143 ciw
= ccw_device_get_ciw(init_data
->cdev
, CIW_TYPE_AQUEUE
);
3145 QDIO_DBF_TEXT2(1,setup
,"no aq");
3146 QDIO_PRINT_INFO("No aqueue CIW found for QDIO commands. "
3147 "Trying to use default.\n");
3149 irq_ptr
->aqueue
= *ciw
;
3151 /* Set new interrupt handler. */
3152 irq_ptr
->original_int_handler
= init_data
->cdev
->handler
;
3153 init_data
->cdev
->handler
= qdio_handler
;
3159 qdio_establish(struct qdio_initialize
*init_data
)
3161 struct qdio_irq
*irq_ptr
;
3162 unsigned long saveflags
;
3163 int result
, result2
;
3164 struct ccw_device
*cdev
;
3167 cdev
=init_data
->cdev
;
3168 irq_ptr
= cdev
->private->qdio_data
;
3172 if (cdev
->private->state
!= DEV_STATE_ONLINE
)
3175 down(&irq_ptr
->setting_up_sema
);
3177 qdio_fill_irq(init_data
);
3179 /* the thinint CHSC stuff */
3180 if (irq_ptr
->is_thinint_irq
) {
3182 result
= tiqdio_set_subchannel_ind(irq_ptr
,0);
3184 up(&irq_ptr
->setting_up_sema
);
3185 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
3188 tiqdio_set_delay_target(irq_ptr
,TIQDIO_DELAY_TARGET
);
3191 sprintf(dbf_text
,"qest%4x",cdev
->private->sch_no
);
3192 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
3193 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
3196 irq_ptr
->ccw
.cmd_code
=irq_ptr
->equeue
.cmd
;
3197 irq_ptr
->ccw
.flags
=CCW_FLAG_SLI
;
3198 irq_ptr
->ccw
.count
=irq_ptr
->equeue
.count
;
3199 irq_ptr
->ccw
.cda
=QDIO_GET_ADDR(irq_ptr
->qdr
);
3201 spin_lock_irqsave(get_ccwdev_lock(cdev
),saveflags
);
3203 ccw_device_set_options(cdev
, 0);
3204 result
=ccw_device_start_timeout(cdev
,&irq_ptr
->ccw
,
3205 QDIO_DOING_ESTABLISH
,0, 0,
3206 QDIO_ESTABLISH_TIMEOUT
);
3208 result2
=ccw_device_start_timeout(cdev
,&irq_ptr
->ccw
,
3209 QDIO_DOING_ESTABLISH
,0,0,
3210 QDIO_ESTABLISH_TIMEOUT
);
3211 sprintf(dbf_text
,"eq:io%4x",result
);
3212 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3214 sprintf(dbf_text
,"eq:io%4x",result
);
3215 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3217 QDIO_PRINT_WARN("establish queues on irq 0.%x.%04x: do_IO " \
3218 "returned %i, next try returned %i\n",
3219 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
3223 ccw_device_set_timeout(cdev
, 0);
3226 spin_unlock_irqrestore(get_ccwdev_lock(cdev
),saveflags
);
3229 up(&irq_ptr
->setting_up_sema
);
3230 qdio_shutdown(cdev
,QDIO_FLAG_CLEANUP_USING_CLEAR
);
3234 /* Timeout is cared for already by using ccw_device_start_timeout(). */
3235 wait_event_interruptible(cdev
->private->wait_q
,
3236 irq_ptr
->state
== QDIO_IRQ_STATE_ESTABLISHED
||
3237 irq_ptr
->state
== QDIO_IRQ_STATE_ERR
);
3239 if (irq_ptr
->state
== QDIO_IRQ_STATE_ESTABLISHED
)
3242 up(&irq_ptr
->setting_up_sema
);
3243 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
3247 qdio_get_ssqd_information(irq_ptr
);
3248 /* if this gets set once, we're running under VM and can omit SVSes */
3249 if (irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_NECESSARY
)
3252 sprintf(dbf_text
,"qdioac%2x",irq_ptr
->qdioac
);
3253 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3255 sprintf(dbf_text
,"qib ac%2x",irq_ptr
->qib
.ac
);
3256 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3258 irq_ptr
->hydra_gives_outbound_pcis
=
3259 irq_ptr
->qib
.ac
&QIB_AC_OUTBOUND_PCI_SUPPORTED
;
3260 irq_ptr
->sync_done_on_outb_pcis
=
3261 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
;
3263 qdio_initialize_set_siga_flags_input(irq_ptr
);
3264 qdio_initialize_set_siga_flags_output(irq_ptr
);
3266 up(&irq_ptr
->setting_up_sema
);
3273 qdio_activate(struct ccw_device
*cdev
, int flags
)
3275 struct qdio_irq
*irq_ptr
;
3276 int i
,result
=0,result2
;
3277 unsigned long saveflags
;
3278 char dbf_text
[20]; /* see qdio_initialize */
3280 irq_ptr
= cdev
->private->qdio_data
;
3284 if (cdev
->private->state
!= DEV_STATE_ONLINE
)
3287 down(&irq_ptr
->setting_up_sema
);
3288 if (irq_ptr
->state
==QDIO_IRQ_STATE_INACTIVE
) {
3293 sprintf(dbf_text
,"qact%4x", irq_ptr
->schid
.sch_no
);
3294 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3295 QDIO_DBF_TEXT2(0,trace
,dbf_text
);
3298 irq_ptr
->ccw
.cmd_code
=irq_ptr
->aqueue
.cmd
;
3299 irq_ptr
->ccw
.flags
=CCW_FLAG_SLI
;
3300 irq_ptr
->ccw
.count
=irq_ptr
->aqueue
.count
;
3301 irq_ptr
->ccw
.cda
=QDIO_GET_ADDR(0);
3303 spin_lock_irqsave(get_ccwdev_lock(cdev
),saveflags
);
3305 ccw_device_set_timeout(cdev
, 0);
3306 ccw_device_set_options(cdev
, CCWDEV_REPORT_ALL
);
3307 result
=ccw_device_start(cdev
,&irq_ptr
->ccw
,QDIO_DOING_ACTIVATE
,
3308 0, DOIO_DENY_PREFETCH
);
3310 result2
=ccw_device_start(cdev
,&irq_ptr
->ccw
,
3311 QDIO_DOING_ACTIVATE
,0,0);
3312 sprintf(dbf_text
,"aq:io%4x",result
);
3313 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3315 sprintf(dbf_text
,"aq:io%4x",result
);
3316 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3318 QDIO_PRINT_WARN("activate queues on irq 0.%x.%04x: do_IO " \
3319 "returned %i, next try returned %i\n",
3320 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
3325 spin_unlock_irqrestore(get_ccwdev_lock(cdev
),saveflags
);
3329 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
3330 if (irq_ptr
->is_thinint_irq
) {
3332 * that way we know, that, if we will get interrupted
3333 * by tiqdio_inbound_processing, qdio_unmark_q will
3336 qdio_reserve_q(irq_ptr
->input_qs
[i
]);
3337 qdio_mark_tiq(irq_ptr
->input_qs
[i
]);
3338 qdio_release_q(irq_ptr
->input_qs
[i
]);
3342 if (flags
&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT
) {
3343 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
3344 irq_ptr
->input_qs
[i
]->is_input_q
|=
3345 QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT
;
3349 wait_event_interruptible_timeout(cdev
->private->wait_q
,
3351 QDIO_IRQ_STATE_STOPPED
) ||
3353 QDIO_IRQ_STATE_ERR
)),
3354 QDIO_ACTIVATE_TIMEOUT
);
3356 switch (irq_ptr
->state
) {
3357 case QDIO_IRQ_STATE_STOPPED
:
3358 case QDIO_IRQ_STATE_ERR
:
3359 up(&irq_ptr
->setting_up_sema
);
3360 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
3361 down(&irq_ptr
->setting_up_sema
);
3365 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ACTIVE
);
3369 up(&irq_ptr
->setting_up_sema
);
3374 /* buffers filled forwards again to make Rick happy */
3376 qdio_do_qdio_fill_input(struct qdio_q
*q
, unsigned int qidx
,
3377 unsigned int count
, struct qdio_buffer
*buffers
)
3379 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
3380 qidx
&= (QDIO_MAX_BUFFERS_PER_Q
- 1);
3381 if (irq
->is_qebsm
) {
3383 set_slsb(q
, &qidx
, SLSB_CU_INPUT_EMPTY
, &count
);
3387 set_slsb(q
, &qidx
, SLSB_CU_INPUT_EMPTY
, &count
);
3390 qidx
= (qidx
+ 1) & (QDIO_MAX_BUFFERS_PER_Q
- 1);
3395 qdio_do_qdio_fill_output(struct qdio_q
*q
, unsigned int qidx
,
3396 unsigned int count
, struct qdio_buffer
*buffers
)
3398 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
3400 qidx
&= (QDIO_MAX_BUFFERS_PER_Q
- 1);
3401 if (irq
->is_qebsm
) {
3403 set_slsb(q
, &qidx
, SLSB_CU_OUTPUT_PRIMED
, &count
);
3408 set_slsb(q
, &qidx
, SLSB_CU_OUTPUT_PRIMED
, &count
);
3411 qidx
= (qidx
+ 1) & (QDIO_MAX_BUFFERS_PER_Q
- 1);
3416 do_qdio_handle_inbound(struct qdio_q
*q
, unsigned int callflags
,
3417 unsigned int qidx
, unsigned int count
,
3418 struct qdio_buffer
*buffers
)
3422 /* This is the inbound handling of queues */
3423 used_elements
=atomic_add_return(count
, &q
->number_of_buffers_used
) - count
;
3425 qdio_do_qdio_fill_input(q
,qidx
,count
,buffers
);
3427 if ((used_elements
+count
==QDIO_MAX_BUFFERS_PER_Q
)&&
3428 (callflags
&QDIO_FLAG_UNDER_INTERRUPT
))
3429 atomic_swap(&q
->polling
,0);
3433 if (callflags
&QDIO_FLAG_DONT_SIGA
)
3438 result
=qdio_siga_input(q
);
3441 q
->error_status_flags
|=
3442 QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR
;
3443 q
->error_status_flags
|=QDIO_STATUS_LOOK_FOR_ERROR
;
3444 q
->siga_error
=result
;
3452 do_qdio_handle_outbound(struct qdio_q
*q
, unsigned int callflags
,
3453 unsigned int qidx
, unsigned int count
,
3454 struct qdio_buffer
*buffers
)
3457 unsigned int cnt
, start_buf
;
3458 unsigned char state
= 0;
3459 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
3461 /* This is the outbound handling of queues */
3462 #ifdef QDIO_PERFORMANCE_STATS
3463 perf_stats
.start_time_outbound
=NOW
;
3464 #endif /* QDIO_PERFORMANCE_STATS */
3466 qdio_do_qdio_fill_output(q
,qidx
,count
,buffers
);
3468 used_elements
=atomic_add_return(count
, &q
->number_of_buffers_used
) - count
;
3470 if (callflags
&QDIO_FLAG_DONT_SIGA
) {
3471 #ifdef QDIO_PERFORMANCE_STATS
3472 perf_stats
.outbound_time
+=NOW
-perf_stats
.start_time_outbound
;
3473 perf_stats
.outbound_cnt
++;
3474 #endif /* QDIO_PERFORMANCE_STATS */
3477 if (q
->is_iqdio_q
) {
3478 /* one siga for every sbal */
3480 qdio_kick_outbound_q(q
);
3482 __qdio_outbound_processing(q
);
3484 /* under VM, we do a SIGA sync unconditionally */
3488 * w/o shadow queues (else branch of
3489 * SYNC_MEMORY :-/ ), we try to
3490 * fast-requeue buffers
3492 if (irq
->is_qebsm
) {
3494 start_buf
= ((qidx
+QDIO_MAX_BUFFERS_PER_Q
-1) &
3495 (QDIO_MAX_BUFFERS_PER_Q
-1));
3496 qdio_do_eqbs(q
, &state
, &start_buf
, &cnt
);
3498 state
= q
->slsb
.acc
.val
[(qidx
+QDIO_MAX_BUFFERS_PER_Q
-1)
3499 &(QDIO_MAX_BUFFERS_PER_Q
-1) ];
3500 if (state
!= SLSB_CU_OUTPUT_PRIMED
) {
3501 qdio_kick_outbound_q(q
);
3503 QDIO_DBF_TEXT3(0,trace
, "fast-req");
3504 #ifdef QDIO_PERFORMANCE_STATS
3505 perf_stats
.fast_reqs
++;
3506 #endif /* QDIO_PERFORMANCE_STATS */
3510 * only marking the q could take too long,
3511 * the upper layer module could do a lot of
3512 * traffic in that time
3514 __qdio_outbound_processing(q
);
3517 #ifdef QDIO_PERFORMANCE_STATS
3518 perf_stats
.outbound_time
+=NOW
-perf_stats
.start_time_outbound
;
3519 perf_stats
.outbound_cnt
++;
3520 #endif /* QDIO_PERFORMANCE_STATS */
3523 /* count must be 1 in iqdio */
3525 do_QDIO(struct ccw_device
*cdev
,unsigned int callflags
,
3526 unsigned int queue_number
, unsigned int qidx
,
3527 unsigned int count
,struct qdio_buffer
*buffers
)
3529 struct qdio_irq
*irq_ptr
;
3530 #ifdef CONFIG_QDIO_DEBUG
3533 sprintf(dbf_text
,"doQD%04x",cdev
->private->sch_no
);
3534 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
3535 #endif /* CONFIG_QDIO_DEBUG */
3537 if ( (qidx
>QDIO_MAX_BUFFERS_PER_Q
) ||
3538 (count
>QDIO_MAX_BUFFERS_PER_Q
) ||
3539 (queue_number
>QDIO_MAX_QUEUES_PER_IRQ
) )
3545 irq_ptr
= cdev
->private->qdio_data
;
3549 #ifdef CONFIG_QDIO_DEBUG
3550 if (callflags
&QDIO_FLAG_SYNC_INPUT
)
3551 QDIO_DBF_HEX3(0,trace
,&irq_ptr
->input_qs
[queue_number
],
3554 QDIO_DBF_HEX3(0,trace
,&irq_ptr
->output_qs
[queue_number
],
3556 sprintf(dbf_text
,"flag%04x",callflags
);
3557 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
3558 sprintf(dbf_text
,"qi%02xct%02x",qidx
,count
);
3559 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
3560 #endif /* CONFIG_QDIO_DEBUG */
3562 if (irq_ptr
->state
!=QDIO_IRQ_STATE_ACTIVE
)
3565 if (callflags
&QDIO_FLAG_SYNC_INPUT
)
3566 do_qdio_handle_inbound(irq_ptr
->input_qs
[queue_number
],
3567 callflags
, qidx
, count
, buffers
);
3568 else if (callflags
&QDIO_FLAG_SYNC_OUTPUT
)
3569 do_qdio_handle_outbound(irq_ptr
->output_qs
[queue_number
],
3570 callflags
, qidx
, count
, buffers
);
3572 QDIO_DBF_TEXT3(1,trace
,"doQD:inv");
3578 #ifdef QDIO_PERFORMANCE_STATS
3580 qdio_perf_procfile_read(char *buffer
, char **buffer_location
, off_t offset
,
3581 int buffer_length
, int *eof
, void *data
)
3585 /* we are always called with buffer_length=4k, so we all
3586 deliver on the first read */
3590 #define _OUTP_IT(x...) c+=sprintf(buffer+c,x)
3591 _OUTP_IT("i_p_nc/c=%lu/%lu\n",i_p_nc
,i_p_c
);
3592 _OUTP_IT("ii_p_nc/c=%lu/%lu\n",ii_p_nc
,ii_p_c
);
3593 _OUTP_IT("o_p_nc/c=%lu/%lu\n",o_p_nc
,o_p_c
);
3594 _OUTP_IT("Number of tasklet runs (total) : %u\n",
3595 perf_stats
.tl_runs
);
3597 _OUTP_IT("Number of SIGA sync's issued : %u\n",
3598 perf_stats
.siga_syncs
);
3599 _OUTP_IT("Number of SIGA in's issued : %u\n",
3600 perf_stats
.siga_ins
);
3601 _OUTP_IT("Number of SIGA out's issued : %u\n",
3602 perf_stats
.siga_outs
);
3603 _OUTP_IT("Number of PCIs caught : %u\n",
3605 _OUTP_IT("Number of adapter interrupts caught : %u\n",
3606 perf_stats
.thinints
);
3607 _OUTP_IT("Number of fast requeues (outg. SBALs w/o SIGA) : %u\n",
3608 perf_stats
.fast_reqs
);
3610 _OUTP_IT("Total time of all inbound actions (us) incl. UL : %u\n",
3611 perf_stats
.inbound_time
);
3612 _OUTP_IT("Number of inbound transfers : %u\n",
3613 perf_stats
.inbound_cnt
);
3614 _OUTP_IT("Total time of all outbound do_QDIOs (us) : %u\n",
3615 perf_stats
.outbound_time
);
3616 _OUTP_IT("Number of do_QDIOs outbound : %u\n",
3617 perf_stats
.outbound_cnt
);
3623 static struct proc_dir_entry
*qdio_perf_proc_file
;
3624 #endif /* QDIO_PERFORMANCE_STATS */
3627 qdio_add_procfs_entry(void)
3629 #ifdef QDIO_PERFORMANCE_STATS
3630 proc_perf_file_registration
=0;
3631 qdio_perf_proc_file
=create_proc_entry(QDIO_PERF
,
3632 S_IFREG
|0444,&proc_root
);
3633 if (qdio_perf_proc_file
) {
3634 qdio_perf_proc_file
->read_proc
=&qdio_perf_procfile_read
;
3635 } else proc_perf_file_registration
=-1;
3637 if (proc_perf_file_registration
)
3638 QDIO_PRINT_WARN("was not able to register perf. " \
3639 "proc-file (%i).\n",
3640 proc_perf_file_registration
);
3641 #endif /* QDIO_PERFORMANCE_STATS */
3645 qdio_remove_procfs_entry(void)
3647 #ifdef QDIO_PERFORMANCE_STATS
3648 perf_stats
.tl_runs
=0;
3650 if (!proc_perf_file_registration
) /* means if it went ok earlier */
3651 remove_proc_entry(QDIO_PERF
,&proc_root
);
3652 #endif /* QDIO_PERFORMANCE_STATS */
3656 tiqdio_register_thinints(void)
3659 register_thinint_result
=
3660 s390_register_adapter_interrupt(&tiqdio_thinint_handler
);
3661 if (register_thinint_result
) {
3662 sprintf(dbf_text
,"regthn%x",(register_thinint_result
&0xff));
3663 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
3664 QDIO_PRINT_ERR("failed to register adapter handler " \
3665 "(rc=%i).\nAdapter interrupts might " \
3666 "not work. Continuing.\n",
3667 register_thinint_result
);
3672 tiqdio_unregister_thinints(void)
3674 if (!register_thinint_result
)
3675 s390_unregister_adapter_interrupt(&tiqdio_thinint_handler
);
3679 qdio_get_qdio_memory(void)
3682 indicator_used
[0]=1;
3684 for (i
=1;i
<INDICATORS_PER_CACHELINE
;i
++)
3685 indicator_used
[i
]=0;
3686 indicators
= kzalloc(sizeof(__u32
)*(INDICATORS_PER_CACHELINE
),
3694 qdio_release_qdio_memory(void)
3700 qdio_unregister_dbf_views(void)
3703 debug_unregister(qdio_dbf_setup
);
3705 debug_unregister(qdio_dbf_sbal
);
3707 debug_unregister(qdio_dbf_sense
);
3709 debug_unregister(qdio_dbf_trace
);
3710 #ifdef CONFIG_QDIO_DEBUG
3711 if (qdio_dbf_slsb_out
)
3712 debug_unregister(qdio_dbf_slsb_out
);
3713 if (qdio_dbf_slsb_in
)
3714 debug_unregister(qdio_dbf_slsb_in
);
3715 #endif /* CONFIG_QDIO_DEBUG */
3719 qdio_register_dbf_views(void)
3721 qdio_dbf_setup
=debug_register(QDIO_DBF_SETUP_NAME
,
3722 QDIO_DBF_SETUP_PAGES
,
3723 QDIO_DBF_SETUP_NR_AREAS
,
3724 QDIO_DBF_SETUP_LEN
);
3725 if (!qdio_dbf_setup
)
3727 debug_register_view(qdio_dbf_setup
,&debug_hex_ascii_view
);
3728 debug_set_level(qdio_dbf_setup
,QDIO_DBF_SETUP_LEVEL
);
3730 qdio_dbf_sbal
=debug_register(QDIO_DBF_SBAL_NAME
,
3731 QDIO_DBF_SBAL_PAGES
,
3732 QDIO_DBF_SBAL_NR_AREAS
,
3737 debug_register_view(qdio_dbf_sbal
,&debug_hex_ascii_view
);
3738 debug_set_level(qdio_dbf_sbal
,QDIO_DBF_SBAL_LEVEL
);
3740 qdio_dbf_sense
=debug_register(QDIO_DBF_SENSE_NAME
,
3741 QDIO_DBF_SENSE_PAGES
,
3742 QDIO_DBF_SENSE_NR_AREAS
,
3743 QDIO_DBF_SENSE_LEN
);
3744 if (!qdio_dbf_sense
)
3747 debug_register_view(qdio_dbf_sense
,&debug_hex_ascii_view
);
3748 debug_set_level(qdio_dbf_sense
,QDIO_DBF_SENSE_LEVEL
);
3750 qdio_dbf_trace
=debug_register(QDIO_DBF_TRACE_NAME
,
3751 QDIO_DBF_TRACE_PAGES
,
3752 QDIO_DBF_TRACE_NR_AREAS
,
3753 QDIO_DBF_TRACE_LEN
);
3754 if (!qdio_dbf_trace
)
3757 debug_register_view(qdio_dbf_trace
,&debug_hex_ascii_view
);
3758 debug_set_level(qdio_dbf_trace
,QDIO_DBF_TRACE_LEVEL
);
3760 #ifdef CONFIG_QDIO_DEBUG
3761 qdio_dbf_slsb_out
=debug_register(QDIO_DBF_SLSB_OUT_NAME
,
3762 QDIO_DBF_SLSB_OUT_PAGES
,
3763 QDIO_DBF_SLSB_OUT_NR_AREAS
,
3764 QDIO_DBF_SLSB_OUT_LEN
);
3765 if (!qdio_dbf_slsb_out
)
3767 debug_register_view(qdio_dbf_slsb_out
,&debug_hex_ascii_view
);
3768 debug_set_level(qdio_dbf_slsb_out
,QDIO_DBF_SLSB_OUT_LEVEL
);
3770 qdio_dbf_slsb_in
=debug_register(QDIO_DBF_SLSB_IN_NAME
,
3771 QDIO_DBF_SLSB_IN_PAGES
,
3772 QDIO_DBF_SLSB_IN_NR_AREAS
,
3773 QDIO_DBF_SLSB_IN_LEN
);
3774 if (!qdio_dbf_slsb_in
)
3776 debug_register_view(qdio_dbf_slsb_in
,&debug_hex_ascii_view
);
3777 debug_set_level(qdio_dbf_slsb_in
,QDIO_DBF_SLSB_IN_LEVEL
);
3778 #endif /* CONFIG_QDIO_DEBUG */
3781 QDIO_PRINT_ERR("not enough memory for dbf.\n");
3782 qdio_unregister_dbf_views();
3786 static void *qdio_mempool_alloc(gfp_t gfp_mask
, void *size
)
3788 return (void *) get_zeroed_page(gfp_mask
|GFP_DMA
);
3791 static void qdio_mempool_free(void *element
, void *size
)
3793 free_page((unsigned long) element
);
3800 #ifdef QDIO_PERFORMANCE_STATS
3802 #endif /* QDIO_PERFORMANCE_STATS */
3804 printk("qdio: loading %s\n",version
);
3806 res
=qdio_get_qdio_memory();
3810 res
= qdio_register_dbf_views();
3814 QDIO_DBF_TEXT0(0,setup
,"initQDIO");
3816 #ifdef QDIO_PERFORMANCE_STATS
3817 memset((void*)&perf_stats
,0,sizeof(perf_stats
));
3818 QDIO_DBF_TEXT0(0,setup
,"perfstat");
3820 QDIO_DBF_HEX0(0,setup
,&ptr
,sizeof(void*));
3821 #endif /* QDIO_PERFORMANCE_STATS */
3823 qdio_add_procfs_entry();
3825 qdio_mempool_scssc
= mempool_create(QDIO_MEMPOOL_SCSSC_ELEMENTS
,
3827 qdio_mempool_free
, NULL
);
3829 if (tiqdio_check_chsc_availability())
3830 QDIO_PRINT_ERR("Not all CHSCs supported. Continuing.\n");
3832 tiqdio_register_thinints();
3840 tiqdio_unregister_thinints();
3841 qdio_remove_procfs_entry();
3842 qdio_release_qdio_memory();
3843 qdio_unregister_dbf_views();
3844 mempool_destroy(qdio_mempool_scssc
);
3846 printk("qdio: %s: module removed\n",version
);
3849 module_init(init_QDIO
);
3850 module_exit(cleanup_QDIO
);
3852 EXPORT_SYMBOL(qdio_allocate
);
3853 EXPORT_SYMBOL(qdio_establish
);
3854 EXPORT_SYMBOL(qdio_initialize
);
3855 EXPORT_SYMBOL(qdio_activate
);
3856 EXPORT_SYMBOL(do_QDIO
);
3857 EXPORT_SYMBOL(qdio_shutdown
);
3858 EXPORT_SYMBOL(qdio_free
);
3859 EXPORT_SYMBOL(qdio_cleanup
);
3860 EXPORT_SYMBOL(qdio_synchronize
);