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>
42 #include <asm/ccwdev.h>
44 #include <asm/atomic.h>
45 #include <asm/semaphore.h>
46 #include <asm/timex.h>
48 #include <asm/debug.h>
59 /****************** MODULE PARAMETER VARIABLES ********************/
60 MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>");
61 MODULE_DESCRIPTION("QDIO base support version 2, " \
62 "Copyright 2000 IBM Corporation");
63 MODULE_LICENSE("GPL");
65 /******************** HERE WE GO ***********************************/
67 static const char version
[] = "QDIO base support version 2";
69 #ifdef QDIO_PERFORMANCE_STATS
70 static int proc_perf_file_registration
;
71 static unsigned long i_p_c
, i_p_nc
, o_p_c
, o_p_nc
, ii_p_c
, ii_p_nc
;
72 static struct qdio_perf_stats perf_stats
;
73 #endif /* QDIO_PERFORMANCE_STATS */
75 static int hydra_thinints
;
76 static int is_passthrough
= 0;
79 static int indicator_used
[INDICATORS_PER_CACHELINE
];
80 static __u32
* volatile indicators
;
81 static __u32
volatile spare_indicator
;
82 static atomic_t spare_indicator_usecount
;
84 static debug_info_t
*qdio_dbf_setup
;
85 static debug_info_t
*qdio_dbf_sbal
;
86 static debug_info_t
*qdio_dbf_trace
;
87 static debug_info_t
*qdio_dbf_sense
;
88 #ifdef CONFIG_QDIO_DEBUG
89 static debug_info_t
*qdio_dbf_slsb_out
;
90 static debug_info_t
*qdio_dbf_slsb_in
;
91 #endif /* CONFIG_QDIO_DEBUG */
94 static volatile struct qdio_q
*tiq_list
=NULL
; /* volatile as it could change
95 during a while loop */
96 static DEFINE_SPINLOCK(ttiq_list_lock
);
97 static int register_thinint_result
;
98 static void tiqdio_tl(unsigned long);
99 static DECLARE_TASKLET(tiqdio_tasklet
,tiqdio_tl
,0);
101 /* not a macro, as one of the arguments is atomic_read */
103 qdio_min(int a
,int b
)
111 /***************** SCRUBBER HELPER ROUTINES **********************/
114 qdio_get_micros(void)
116 return (get_clock() >> 10); /* time>>12 is microseconds */
120 * unfortunately, we can't just xchg the values; in do_QDIO we want to reserve
121 * the q in any case, so that we'll not be interrupted when we are in
122 * qdio_mark_tiq... shouldn't have a really bad impact, as reserving almost
123 * ever works (last famous words)
126 qdio_reserve_q(struct qdio_q
*q
)
128 return atomic_add_return(1,&q
->use_count
) - 1;
132 qdio_release_q(struct qdio_q
*q
)
134 atomic_dec(&q
->use_count
);
139 qdio_check_ccq(struct qdio_q
*q
, unsigned int ccq
)
143 if (ccq
== 0 || ccq
== 32 || ccq
== 96)
147 /*notify devices immediately*/
148 sprintf(dbf_text
,"%d", ccq
);
149 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
152 /* EQBS: extract buffer states */
154 qdio_do_eqbs(struct qdio_q
*q
, unsigned char *state
,
155 unsigned int *start
, unsigned int *cnt
)
157 struct qdio_irq
*irq
;
158 unsigned int tmp_cnt
, q_no
, ccq
;
164 irq
= (struct qdio_irq
*)q
->irq_ptr
;
167 q_no
+= irq
->no_input_qs
;
169 ccq
= do_eqbs(irq
->sch_token
, state
, q_no
, start
, cnt
);
170 rc
= qdio_check_ccq(q
, ccq
);
172 QDIO_DBF_TEXT5(1,trace
,"eqAGAIN");
176 QDIO_DBF_TEXT2(1,trace
,"eqberr");
177 sprintf(dbf_text
,"%2x,%2x,%d,%d",tmp_cnt
, *cnt
, ccq
, q_no
);
178 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
179 q
->handler(q
->cdev
,QDIO_STATUS_ACTIVATE_CHECK_CONDITION
|
180 QDIO_STATUS_LOOK_FOR_ERROR
,
181 0, 0, 0, -1, -1, q
->int_parm
);
184 return (tmp_cnt
- *cnt
);
187 /* SQBS: set buffer states */
189 qdio_do_sqbs(struct qdio_q
*q
, unsigned char state
,
190 unsigned int *start
, unsigned int *cnt
)
192 struct qdio_irq
*irq
;
193 unsigned int tmp_cnt
, q_no
, ccq
;
199 irq
= (struct qdio_irq
*)q
->irq_ptr
;
202 q_no
+= irq
->no_input_qs
;
204 ccq
= do_sqbs(irq
->sch_token
, state
, q_no
, start
, cnt
);
205 rc
= qdio_check_ccq(q
, ccq
);
207 QDIO_DBF_TEXT5(1,trace
,"sqAGAIN");
211 QDIO_DBF_TEXT3(1,trace
,"sqberr");
212 sprintf(dbf_text
,"%2x,%2x,%d,%d",tmp_cnt
,*cnt
,ccq
,q_no
);
213 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
214 q
->handler(q
->cdev
,QDIO_STATUS_ACTIVATE_CHECK_CONDITION
|
215 QDIO_STATUS_LOOK_FOR_ERROR
,
216 0, 0, 0, -1, -1, q
->int_parm
);
219 return (tmp_cnt
- *cnt
);
223 qdio_set_slsb(struct qdio_q
*q
, unsigned int *bufno
,
224 unsigned char state
, unsigned int *count
)
227 struct qdio_irq
*irq
;
229 irq
= (struct qdio_irq
*)q
->irq_ptr
;
230 if (!irq
->is_qebsm
) {
231 slsb
= (char *)&q
->slsb
.acc
.val
[(*bufno
)];
235 return qdio_do_sqbs(q
, state
, bufno
, count
);
238 #ifdef CONFIG_QDIO_DEBUG
240 qdio_trace_slsb(struct qdio_q
*q
)
242 if (q
->queue_type
==QDIO_TRACE_QTYPE
) {
244 QDIO_DBF_HEX2(0,slsb_in
,&q
->slsb
,
245 QDIO_MAX_BUFFERS_PER_Q
);
247 QDIO_DBF_HEX2(0,slsb_out
,&q
->slsb
,
248 QDIO_MAX_BUFFERS_PER_Q
);
254 set_slsb(struct qdio_q
*q
, unsigned int *bufno
,
255 unsigned char state
, unsigned int *count
)
258 #ifdef CONFIG_QDIO_DEBUG
261 rc
= qdio_set_slsb(q
, bufno
, state
, count
);
262 #ifdef CONFIG_QDIO_DEBUG
268 qdio_siga_sync(struct qdio_q
*q
, unsigned int gpr2
,
273 QDIO_DBF_TEXT4(0,trace
,"sigasync");
274 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
276 #ifdef QDIO_PERFORMANCE_STATS
277 perf_stats
.siga_syncs
++;
278 #endif /* QDIO_PERFORMANCE_STATS */
280 cc
= do_siga_sync(q
->schid
, gpr2
, gpr3
);
282 QDIO_DBF_HEX3(0,trace
,&cc
,sizeof(int*));
288 qdio_siga_sync_q(struct qdio_q
*q
)
291 return qdio_siga_sync(q
, 0, q
->mask
);
292 return qdio_siga_sync(q
, q
->mask
, 0);
296 __do_siga_output(struct qdio_q
*q
, unsigned int *busy_bit
)
298 struct qdio_irq
*irq
;
302 irq
= (struct qdio_irq
*) q
->irq_ptr
;
304 schid
= *((u32
*)&q
->schid
);
306 schid
= irq
->sch_token
;
309 return do_siga_output(schid
, q
->mask
, busy_bit
, fc
);
313 * returns QDIO_SIGA_ERROR_ACCESS_EXCEPTION as cc, when SIGA returns
314 * an access exception
317 qdio_siga_output(struct qdio_q
*q
)
323 #ifdef QDIO_PERFORMANCE_STATS
324 perf_stats
.siga_outs
++;
325 #endif /* QDIO_PERFORMANCE_STATS */
327 QDIO_DBF_TEXT4(0,trace
,"sigaout");
328 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
331 cc
= __do_siga_output(q
, &busy_bit
);
332 //QDIO_PRINT_ERR("cc=%x, busy=%x\n",cc,busy_bit);
333 if ((cc
==2) && (busy_bit
) && (q
->is_iqdio_q
)) {
336 if ((NOW
-start_time
)>QDIO_BUSY_BIT_PATIENCE
)
342 if ((cc
==2) && (busy_bit
))
343 cc
|= QDIO_SIGA_ERROR_B_BIT_SET
;
346 QDIO_DBF_HEX3(0,trace
,&cc
,sizeof(int*));
352 qdio_siga_input(struct qdio_q
*q
)
356 QDIO_DBF_TEXT4(0,trace
,"sigain");
357 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
359 #ifdef QDIO_PERFORMANCE_STATS
360 perf_stats
.siga_ins
++;
361 #endif /* QDIO_PERFORMANCE_STATS */
363 cc
= do_siga_input(q
->schid
, q
->mask
);
366 QDIO_DBF_HEX3(0,trace
,&cc
,sizeof(int*));
371 /* locked by the locks in qdio_activate and qdio_cleanup */
373 qdio_get_indicator(void)
377 for (i
=1;i
<INDICATORS_PER_CACHELINE
;i
++)
378 if (!indicator_used
[i
]) {
382 atomic_inc(&spare_indicator_usecount
);
383 return (__u32
* volatile) &spare_indicator
;
386 /* locked by the locks in qdio_activate and qdio_cleanup */
388 qdio_put_indicator(__u32
*addr
)
392 if ( (addr
) && (addr
!=&spare_indicator
) ) {
396 if (addr
== &spare_indicator
)
397 atomic_dec(&spare_indicator_usecount
);
401 tiqdio_clear_summary_bit(__u32
*location
)
403 QDIO_DBF_TEXT5(0,trace
,"clrsummb");
404 QDIO_DBF_HEX5(0,trace
,&location
,sizeof(void*));
410 tiqdio_set_summary_bit(__u32
*location
)
412 QDIO_DBF_TEXT5(0,trace
,"setsummb");
413 QDIO_DBF_HEX5(0,trace
,&location
,sizeof(void*));
419 tiqdio_sched_tl(void)
421 tasklet_hi_schedule(&tiqdio_tasklet
);
425 qdio_mark_tiq(struct qdio_q
*q
)
429 QDIO_DBF_TEXT4(0,trace
,"mark iq");
430 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
432 spin_lock_irqsave(&ttiq_list_lock
,flags
);
433 if (unlikely(atomic_read(&q
->is_in_shutdown
)))
439 if ((q
->list_prev
) || (q
->list_next
))
447 q
->list_next
=tiq_list
;
448 q
->list_prev
=tiq_list
->list_prev
;
449 tiq_list
->list_prev
->list_next
=q
;
450 tiq_list
->list_prev
=q
;
452 spin_unlock_irqrestore(&ttiq_list_lock
,flags
);
454 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
458 spin_unlock_irqrestore(&ttiq_list_lock
,flags
);
463 qdio_mark_q(struct qdio_q
*q
)
465 QDIO_DBF_TEXT4(0,trace
,"mark q");
466 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
468 if (unlikely(atomic_read(&q
->is_in_shutdown
)))
471 tasklet_schedule(&q
->tasklet
);
475 qdio_stop_polling(struct qdio_q
*q
)
477 #ifdef QDIO_USE_PROCESSING_STATE
478 unsigned int tmp
, gsf
, count
= 1;
479 unsigned char state
= 0;
480 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
482 if (!atomic_swap(&q
->polling
,0))
485 QDIO_DBF_TEXT4(0,trace
,"stoppoll");
486 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
488 /* show the card that we are not polling anymore */
492 tmp
= gsf
= GET_SAVED_FRONTIER(q
);
493 tmp
= ((tmp
+ QDIO_MAX_BUFFERS_PER_Q
-1) & (QDIO_MAX_BUFFERS_PER_Q
-1) );
494 set_slsb(q
, &tmp
, SLSB_P_INPUT_NOT_INIT
, &count
);
497 * we don't issue this SYNC_MEMORY, as we trust Rick T and
498 * moreover will not use the PROCESSING state under VM, so
499 * q->polling was 0 anyway
504 qdio_do_eqbs(q
, &state
, &gsf
, &count
);
506 state
= q
->slsb
.acc
.val
[gsf
];
507 if (state
!= SLSB_P_INPUT_PRIMED
)
510 * set our summary bit again, as otherwise there is a
511 * small window we can miss between resetting it and
512 * checking for PRIMED state
515 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
518 #else /* QDIO_USE_PROCESSING_STATE */
520 #endif /* QDIO_USE_PROCESSING_STATE */
524 * see the comment in do_QDIO and before qdio_reserve_q about the
525 * sophisticated locking outside of unmark_q, so that we don't need to
526 * disable the interrupts :-)
529 qdio_unmark_q(struct qdio_q
*q
)
533 QDIO_DBF_TEXT4(0,trace
,"unmark q");
534 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
536 if ((!q
->list_prev
)||(!q
->list_next
))
539 if ((q
->is_thinint_q
)&&(q
->is_input_q
)) {
541 spin_lock_irqsave(&ttiq_list_lock
,flags
);
542 /* in case cleanup has done this already and simultanously
543 * qdio_unmark_q is called from the interrupt handler, we've
544 * got to check this in this specific case again */
545 if ((!q
->list_prev
)||(!q
->list_next
))
547 if (q
->list_next
==q
) {
548 /* q was the only interesting q */
553 q
->list_next
->list_prev
=q
->list_prev
;
554 q
->list_prev
->list_next
=q
->list_next
;
555 tiq_list
=q
->list_next
;
560 spin_unlock_irqrestore(&ttiq_list_lock
,flags
);
564 static inline unsigned long
565 tiqdio_clear_global_summary(void)
569 QDIO_DBF_TEXT5(0,trace
,"clrglobl");
571 time
= do_clear_global_summary();
573 QDIO_DBF_HEX5(0,trace
,&time
,sizeof(unsigned long));
579 /************************* OUTBOUND ROUTINES *******************************/
581 qdio_qebsm_get_outbound_buffer_frontier(struct qdio_q
*q
)
583 struct qdio_irq
*irq
;
585 unsigned int cnt
, count
, ftc
;
587 irq
= (struct qdio_irq
*) q
->irq_ptr
;
588 if ((!q
->is_iqdio_q
) && (!q
->hydra_gives_outbound_pcis
))
591 ftc
= q
->first_to_check
;
592 count
= qdio_min(atomic_read(&q
->number_of_buffers_used
),
593 (QDIO_MAX_BUFFERS_PER_Q
-1));
595 return q
->first_to_check
;
596 cnt
= qdio_do_eqbs(q
, &state
, &ftc
, &count
);
598 return q
->first_to_check
;
600 case SLSB_P_OUTPUT_ERROR
:
601 QDIO_DBF_TEXT3(0,trace
,"outperr");
602 atomic_sub(cnt
, &q
->number_of_buffers_used
);
604 q
->error_status_flags
|=
605 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
606 q
->qdio_error
= SLSB_P_OUTPUT_ERROR
;
607 q
->error_status_flags
|= QDIO_STATUS_LOOK_FOR_ERROR
;
608 q
->first_to_check
= ftc
;
610 case SLSB_P_OUTPUT_EMPTY
:
611 QDIO_DBF_TEXT5(0,trace
,"outpempt");
612 atomic_sub(cnt
, &q
->number_of_buffers_used
);
613 q
->first_to_check
= ftc
;
615 case SLSB_CU_OUTPUT_PRIMED
:
616 /* all buffers primed */
617 QDIO_DBF_TEXT5(0,trace
,"outpprim");
622 QDIO_DBF_HEX4(0,trace
,&q
->first_to_check
,sizeof(int));
623 return q
->first_to_check
;
627 qdio_qebsm_get_inbound_buffer_frontier(struct qdio_q
*q
)
629 struct qdio_irq
*irq
;
631 int tmp
, ftc
, count
, cnt
;
635 irq
= (struct qdio_irq
*) q
->irq_ptr
;
636 ftc
= q
->first_to_check
;
637 count
= qdio_min(atomic_read(&q
->number_of_buffers_used
),
638 (QDIO_MAX_BUFFERS_PER_Q
-1));
640 return q
->first_to_check
;
641 cnt
= qdio_do_eqbs(q
, &state
, &ftc
, &count
);
643 return q
->first_to_check
;
645 case SLSB_P_INPUT_ERROR
:
646 #ifdef CONFIG_QDIO_DEBUG
647 QDIO_DBF_TEXT3(1,trace
,"inperr");
648 sprintf(dbf_text
,"%2x,%2x",ftc
,count
);
649 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
650 #endif /* CONFIG_QDIO_DEBUG */
652 q
->error_status_flags
|=
653 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
654 q
->qdio_error
= SLSB_P_INPUT_ERROR
;
655 q
->error_status_flags
|= QDIO_STATUS_LOOK_FOR_ERROR
;
656 atomic_sub(cnt
, &q
->number_of_buffers_used
);
657 q
->first_to_check
= ftc
;
659 case SLSB_P_INPUT_PRIMED
:
660 QDIO_DBF_TEXT3(0,trace
,"inptprim");
661 sprintf(dbf_text
,"%2x,%2x",ftc
,count
);
662 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
664 ftc
= q
->first_to_check
;
665 #ifdef QDIO_USE_PROCESSING_STATE
668 tmp
= set_slsb(q
, &ftc
, SLSB_P_INPUT_NOT_INIT
, &cnt
);
673 tmp
+= set_slsb(q
, &ftc
,
674 SLSB_P_INPUT_PROCESSING
, &cnt
);
675 atomic_set(&q
->polling
, 1);
677 tmp
= set_slsb(q
, &ftc
, SLSB_P_INPUT_NOT_INIT
, &cnt
);
679 atomic_sub(tmp
, &q
->number_of_buffers_used
);
680 q
->first_to_check
= ftc
;
682 case SLSB_CU_INPUT_EMPTY
:
683 case SLSB_P_INPUT_NOT_INIT
:
684 case SLSB_P_INPUT_PROCESSING
:
685 QDIO_DBF_TEXT5(0,trace
,"inpnipro");
690 QDIO_DBF_HEX4(0,trace
,&q
->first_to_check
,sizeof(int));
691 return q
->first_to_check
;
695 qdio_get_outbound_buffer_frontier(struct qdio_q
*q
)
697 struct qdio_irq
*irq
;
699 unsigned int count
= 1;
700 int first_not_to_check
, f
, f_mod_no
;
703 QDIO_DBF_TEXT4(0,trace
,"getobfro");
704 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
706 irq
= (struct qdio_irq
*) q
->irq_ptr
;
708 return qdio_qebsm_get_outbound_buffer_frontier(q
);
710 slsb
=&q
->slsb
.acc
.val
[0];
711 f_mod_no
=f
=q
->first_to_check
;
713 * f points to already processed elements, so f+no_used is correct...
714 * ... but: we don't check 128 buffers, as otherwise
715 * qdio_has_outbound_q_moved would return 0
717 first_not_to_check
=f
+qdio_min(atomic_read(&q
->number_of_buffers_used
),
718 (QDIO_MAX_BUFFERS_PER_Q
-1));
720 if ((!q
->is_iqdio_q
)&&(!q
->hydra_gives_outbound_pcis
))
724 if (f
==first_not_to_check
)
727 switch(slsb
[f_mod_no
]) {
729 /* the adapter has not fetched the output yet */
730 case SLSB_CU_OUTPUT_PRIMED
:
731 QDIO_DBF_TEXT5(0,trace
,"outpprim");
734 /* the adapter got it */
735 case SLSB_P_OUTPUT_EMPTY
:
736 atomic_dec(&q
->number_of_buffers_used
);
738 f_mod_no
=f
&(QDIO_MAX_BUFFERS_PER_Q
-1);
739 QDIO_DBF_TEXT5(0,trace
,"outpempt");
742 case SLSB_P_OUTPUT_ERROR
:
743 QDIO_DBF_TEXT3(0,trace
,"outperr");
744 sprintf(dbf_text
,"%x-%x-%x",f_mod_no
,
745 q
->sbal
[f_mod_no
]->element
[14].sbalf
.value
,
746 q
->sbal
[f_mod_no
]->element
[15].sbalf
.value
);
747 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
748 QDIO_DBF_HEX2(1,sbal
,q
->sbal
[f_mod_no
],256);
750 /* kind of process the buffer */
751 set_slsb(q
, &f_mod_no
, SLSB_P_OUTPUT_NOT_INIT
, &count
);
754 * we increment the frontier, as this buffer
755 * was processed obviously
757 atomic_dec(&q
->number_of_buffers_used
);
758 f_mod_no
=(f_mod_no
+1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
761 q
->error_status_flags
|=
762 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
763 q
->qdio_error
=SLSB_P_OUTPUT_ERROR
;
764 q
->error_status_flags
|=QDIO_STATUS_LOOK_FOR_ERROR
;
770 QDIO_DBF_TEXT5(0,trace
,"outpni");
773 return (q
->first_to_check
=f_mod_no
);
776 /* all buffers are processed */
778 qdio_is_outbound_q_done(struct qdio_q
*q
)
781 #ifdef CONFIG_QDIO_DEBUG
785 no_used
=atomic_read(&q
->number_of_buffers_used
);
787 #ifdef CONFIG_QDIO_DEBUG
789 sprintf(dbf_text
,"oqisnt%02x",no_used
);
790 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
792 QDIO_DBF_TEXT4(0,trace
,"oqisdone");
794 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
795 #endif /* CONFIG_QDIO_DEBUG */
800 qdio_has_outbound_q_moved(struct qdio_q
*q
)
804 i
=qdio_get_outbound_buffer_frontier(q
);
806 if ( (i
!=GET_SAVED_FRONTIER(q
)) ||
807 (q
->error_status_flags
&QDIO_STATUS_LOOK_FOR_ERROR
) ) {
809 QDIO_DBF_TEXT4(0,trace
,"oqhasmvd");
810 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
813 QDIO_DBF_TEXT4(0,trace
,"oqhsntmv");
814 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
820 qdio_kick_outbound_q(struct qdio_q
*q
)
823 #ifdef CONFIG_QDIO_DEBUG
826 QDIO_DBF_TEXT4(0,trace
,"kickoutq");
827 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
828 #endif /* CONFIG_QDIO_DEBUG */
833 /* here's the story with cc=2 and busy bit set (thanks, Rick):
834 * VM's CP could present us cc=2 and busy bit set on SIGA-write
835 * during reconfiguration of their Guest LAN (only in HIPERS mode,
836 * QDIO mode is asynchronous -- cc=2 and busy bit there will take
837 * the queues down immediately; and not being under VM we have a
838 * problem on cc=2 and busy bit set right away).
840 * Therefore qdio_siga_output will try for a short time constantly,
841 * if such a condition occurs. If it doesn't change, it will
842 * increase the busy_siga_counter and save the timestamp, and
843 * schedule the queue for later processing (via mark_q, using the
844 * queue tasklet). __qdio_outbound_processing will check out the
845 * counter. If non-zero, it will call qdio_kick_outbound_q as often
846 * as the value of the counter. This will attempt further SIGA
847 * instructions. For each successful SIGA, the counter is
848 * decreased, for failing SIGAs the counter remains the same, after
850 * After some time of no movement, qdio_kick_outbound_q will
851 * finally fail and reflect corresponding error codes to call
852 * the upper layer module and have it take the queues down.
854 * Note that this is a change from the original HiperSockets design
855 * (saying cc=2 and busy bit means take the queues down), but in
856 * these days Guest LAN didn't exist... excessive cc=2 with busy bit
857 * conditions will still take the queues down, but the threshold is
858 * higher due to the Guest LAN environment.
862 result
=qdio_siga_output(q
);
866 /* went smooth this time, reset timestamp */
867 #ifdef CONFIG_QDIO_DEBUG
868 QDIO_DBF_TEXT3(0,trace
,"cc2reslv");
869 sprintf(dbf_text
,"%4x%2x%2x",q
->schid
.sch_no
,q
->q_no
,
870 atomic_read(&q
->busy_siga_counter
));
871 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
872 #endif /* CONFIG_QDIO_DEBUG */
873 q
->timing
.busy_start
=0;
875 case (2|QDIO_SIGA_ERROR_B_BIT_SET
):
876 /* cc=2 and busy bit: */
877 atomic_inc(&q
->busy_siga_counter
);
879 /* if the last siga was successful, save
881 if (!q
->timing
.busy_start
)
882 q
->timing
.busy_start
=NOW
;
884 /* if we're in time, don't touch error_status_flags
886 if (NOW
-q
->timing
.busy_start
<QDIO_BUSY_BIT_GIVE_UP
) {
890 QDIO_DBF_TEXT2(0,trace
,"cc2REPRT");
891 #ifdef CONFIG_QDIO_DEBUG
892 sprintf(dbf_text
,"%4x%2x%2x",q
->schid
.sch_no
,q
->q_no
,
893 atomic_read(&q
->busy_siga_counter
));
894 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
895 #endif /* CONFIG_QDIO_DEBUG */
896 /* else fallthrough and report error */
898 /* for plain cc=1, 2 or 3: */
900 q
->error_status_flags
|=
901 QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR
;
902 q
->error_status_flags
|=
903 QDIO_STATUS_LOOK_FOR_ERROR
;
904 q
->siga_error
=result
;
909 qdio_kick_outbound_handler(struct qdio_q
*q
)
911 int start
, end
, real_end
, count
;
912 #ifdef CONFIG_QDIO_DEBUG
916 start
= q
->first_element_to_kick
;
917 /* last_move_ftc was just updated */
918 real_end
= GET_SAVED_FRONTIER(q
);
919 end
= (real_end
+QDIO_MAX_BUFFERS_PER_Q
-1)&
920 (QDIO_MAX_BUFFERS_PER_Q
-1);
921 count
= (end
+QDIO_MAX_BUFFERS_PER_Q
+1-start
)&
922 (QDIO_MAX_BUFFERS_PER_Q
-1);
924 #ifdef CONFIG_QDIO_DEBUG
925 QDIO_DBF_TEXT4(0,trace
,"kickouth");
926 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
928 sprintf(dbf_text
,"s=%2xc=%2x",start
,count
);
929 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
930 #endif /* CONFIG_QDIO_DEBUG */
932 if (q
->state
==QDIO_IRQ_STATE_ACTIVE
)
933 q
->handler(q
->cdev
,QDIO_STATUS_OUTBOUND_INT
|
934 q
->error_status_flags
,
935 q
->qdio_error
,q
->siga_error
,q
->q_no
,start
,count
,
938 /* for the next time: */
939 q
->first_element_to_kick
=real_end
;
942 q
->error_status_flags
=0;
946 __qdio_outbound_processing(struct qdio_q
*q
)
950 QDIO_DBF_TEXT4(0,trace
,"qoutproc");
951 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
953 if (unlikely(qdio_reserve_q(q
))) {
955 #ifdef QDIO_PERFORMANCE_STATS
957 #endif /* QDIO_PERFORMANCE_STATS */
958 /* as we're sissies, we'll check next time */
959 if (likely(!atomic_read(&q
->is_in_shutdown
))) {
961 QDIO_DBF_TEXT4(0,trace
,"busy,agn");
965 #ifdef QDIO_PERFORMANCE_STATS
967 perf_stats
.tl_runs
++;
968 #endif /* QDIO_PERFORMANCE_STATS */
970 /* see comment in qdio_kick_outbound_q */
971 siga_attempts
=atomic_read(&q
->busy_siga_counter
);
972 while (siga_attempts
) {
973 atomic_dec(&q
->busy_siga_counter
);
974 qdio_kick_outbound_q(q
);
978 if (qdio_has_outbound_q_moved(q
))
979 qdio_kick_outbound_handler(q
);
983 * for asynchronous queues, we better check, if the fill
984 * level is too high. for synchronous queues, the fill
985 * level will never be that high.
987 if (atomic_read(&q
->number_of_buffers_used
)>
988 IQDIO_FILL_LEVEL_TO_POLL
)
991 } else if (!q
->hydra_gives_outbound_pcis
)
992 if (!qdio_is_outbound_q_done(q
))
999 qdio_outbound_processing(struct qdio_q
*q
)
1001 __qdio_outbound_processing(q
);
1004 /************************* INBOUND ROUTINES *******************************/
1008 qdio_get_inbound_buffer_frontier(struct qdio_q
*q
)
1010 struct qdio_irq
*irq
;
1012 volatile char *slsb
;
1013 unsigned int count
= 1;
1014 int first_not_to_check
;
1015 #ifdef CONFIG_QDIO_DEBUG
1017 #endif /* CONFIG_QDIO_DEBUG */
1018 #ifdef QDIO_USE_PROCESSING_STATE
1019 int last_position
=-1;
1020 #endif /* QDIO_USE_PROCESSING_STATE */
1022 QDIO_DBF_TEXT4(0,trace
,"getibfro");
1023 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1025 irq
= (struct qdio_irq
*) q
->irq_ptr
;
1027 return qdio_qebsm_get_inbound_buffer_frontier(q
);
1029 slsb
=&q
->slsb
.acc
.val
[0];
1030 f_mod_no
=f
=q
->first_to_check
;
1032 * we don't check 128 buffers, as otherwise qdio_has_inbound_q_moved
1035 first_not_to_check
=f
+qdio_min(atomic_read(&q
->number_of_buffers_used
),
1036 (QDIO_MAX_BUFFERS_PER_Q
-1));
1039 * we don't use this one, as a PCI or we after a thin interrupt
1040 * will sync the queues
1045 f_mod_no
=f
&(QDIO_MAX_BUFFERS_PER_Q
-1);
1046 if (f
==first_not_to_check
)
1048 switch (slsb
[f_mod_no
]) {
1050 /* CU_EMPTY means frontier is reached */
1051 case SLSB_CU_INPUT_EMPTY
:
1052 QDIO_DBF_TEXT5(0,trace
,"inptempt");
1055 /* P_PRIMED means set slsb to P_PROCESSING and move on */
1056 case SLSB_P_INPUT_PRIMED
:
1057 QDIO_DBF_TEXT5(0,trace
,"inptprim");
1059 #ifdef QDIO_USE_PROCESSING_STATE
1061 * as soon as running under VM, polling the input queues will
1062 * kill VM in terms of CP overhead
1065 set_slsb(q
, &f_mod_no
, SLSB_P_INPUT_NOT_INIT
, &count
);
1067 /* set the previous buffer to NOT_INIT. The current
1068 * buffer will be set to PROCESSING at the end of
1069 * this function to avoid further interrupts. */
1070 if (last_position
>=0)
1071 set_slsb(q
, &last_position
,
1072 SLSB_P_INPUT_NOT_INIT
, &count
);
1073 atomic_set(&q
->polling
,1);
1074 last_position
=f_mod_no
;
1076 #else /* QDIO_USE_PROCESSING_STATE */
1077 set_slsb(q
, &f_mod_no
, SLSB_P_INPUT_NOT_INIT
, &count
);
1078 #endif /* QDIO_USE_PROCESSING_STATE */
1080 * not needed, as the inbound queue will be synced on the next
1081 * siga-r, resp. tiqdio_is_inbound_q_done will do the siga-s
1085 atomic_dec(&q
->number_of_buffers_used
);
1088 case SLSB_P_INPUT_NOT_INIT
:
1089 case SLSB_P_INPUT_PROCESSING
:
1090 QDIO_DBF_TEXT5(0,trace
,"inpnipro");
1093 /* P_ERROR means frontier is reached, break and report error */
1094 case SLSB_P_INPUT_ERROR
:
1095 #ifdef CONFIG_QDIO_DEBUG
1096 sprintf(dbf_text
,"inperr%2x",f_mod_no
);
1097 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
1098 #endif /* CONFIG_QDIO_DEBUG */
1099 QDIO_DBF_HEX2(1,sbal
,q
->sbal
[f_mod_no
],256);
1101 /* kind of process the buffer */
1102 set_slsb(q
, &f_mod_no
, SLSB_P_INPUT_NOT_INIT
, &count
);
1105 q
->error_status_flags
|=
1106 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
1107 q
->qdio_error
=SLSB_P_INPUT_ERROR
;
1108 q
->error_status_flags
|=QDIO_STATUS_LOOK_FOR_ERROR
;
1110 /* we increment the frontier, as this buffer
1111 * was processed obviously */
1112 f_mod_no
=(f_mod_no
+1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
1113 atomic_dec(&q
->number_of_buffers_used
);
1115 #ifdef QDIO_USE_PROCESSING_STATE
1117 #endif /* QDIO_USE_PROCESSING_STATE */
1121 /* everything else means frontier not changed (HALTED or so) */
1126 q
->first_to_check
=f_mod_no
;
1128 #ifdef QDIO_USE_PROCESSING_STATE
1129 if (last_position
>=0)
1130 set_slsb(q
, &last_position
, SLSB_P_INPUT_NOT_INIT
, &count
);
1131 #endif /* QDIO_USE_PROCESSING_STATE */
1133 QDIO_DBF_HEX4(0,trace
,&q
->first_to_check
,sizeof(int));
1135 return q
->first_to_check
;
1139 qdio_has_inbound_q_moved(struct qdio_q
*q
)
1143 #ifdef QDIO_PERFORMANCE_STATS
1144 static int old_pcis
=0;
1145 static int old_thinints
=0;
1147 if ((old_pcis
==perf_stats
.pcis
)&&(old_thinints
==perf_stats
.thinints
))
1148 perf_stats
.start_time_inbound
=NOW
;
1150 old_pcis
=perf_stats
.pcis
;
1151 #endif /* QDIO_PERFORMANCE_STATS */
1153 i
=qdio_get_inbound_buffer_frontier(q
);
1154 if ( (i
!=GET_SAVED_FRONTIER(q
)) ||
1155 (q
->error_status_flags
&QDIO_STATUS_LOOK_FOR_ERROR
) ) {
1157 if ((!q
->siga_sync
)&&(!q
->hydra_gives_outbound_pcis
))
1160 QDIO_DBF_TEXT4(0,trace
,"inhasmvd");
1161 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1164 QDIO_DBF_TEXT4(0,trace
,"inhsntmv");
1165 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1170 /* means, no more buffers to be filled */
1172 tiqdio_is_inbound_q_done(struct qdio_q
*q
)
1175 unsigned int start_buf
, count
;
1176 unsigned char state
= 0;
1177 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
1179 #ifdef CONFIG_QDIO_DEBUG
1183 no_used
=atomic_read(&q
->number_of_buffers_used
);
1185 /* propagate the change from 82 to 80 through VM */
1188 #ifdef CONFIG_QDIO_DEBUG
1190 sprintf(dbf_text
,"iqisnt%02x",no_used
);
1191 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1193 QDIO_DBF_TEXT4(0,trace
,"iniqisdo");
1195 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1196 #endif /* CONFIG_QDIO_DEBUG */
1200 if (!q
->siga_sync
&& !irq
->is_qebsm
)
1201 /* we'll check for more primed buffers in qeth_stop_polling */
1203 if (irq
->is_qebsm
) {
1205 start_buf
= q
->first_to_check
;
1206 qdio_do_eqbs(q
, &state
, &start_buf
, &count
);
1208 state
= q
->slsb
.acc
.val
[q
->first_to_check
];
1209 if (state
!= SLSB_P_INPUT_PRIMED
)
1211 * nothing more to do, if next buffer is not PRIMED.
1212 * note that we did a SYNC_MEMORY before, that there
1213 * has been a sychnronization.
1214 * we will return 0 below, as there is nothing to do
1215 * (stop_polling not necessary, as we have not been
1216 * using the PROCESSING state
1221 * ok, the next input buffer is primed. that means, that device state
1222 * change indicator and adapter local summary are set, so we will find
1224 * we will return 0 below, as there is nothing to do, except scheduling
1225 * ourselves for the next time.
1227 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1233 qdio_is_inbound_q_done(struct qdio_q
*q
)
1236 unsigned int start_buf
, count
;
1237 unsigned char state
= 0;
1238 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
1240 #ifdef CONFIG_QDIO_DEBUG
1244 no_used
=atomic_read(&q
->number_of_buffers_used
);
1247 * we need that one for synchronization with the adapter, as it
1248 * does a kind of PCI avoidance
1253 QDIO_DBF_TEXT4(0,trace
,"inqisdnA");
1254 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1255 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1258 if (irq
->is_qebsm
) {
1260 start_buf
= q
->first_to_check
;
1261 qdio_do_eqbs(q
, &state
, &start_buf
, &count
);
1263 state
= q
->slsb
.acc
.val
[q
->first_to_check
];
1264 if (state
== SLSB_P_INPUT_PRIMED
) {
1265 /* we got something to do */
1266 QDIO_DBF_TEXT4(0,trace
,"inqisntA");
1267 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1271 /* on VM, we don't poll, so the q is always done here */
1274 if (q
->hydra_gives_outbound_pcis
)
1278 * at this point we know, that inbound first_to_check
1279 * has (probably) not moved (see qdio_inbound_processing)
1281 if (NOW
>GET_SAVED_TIMESTAMP(q
)+q
->timing
.threshold
) {
1282 #ifdef CONFIG_QDIO_DEBUG
1283 QDIO_DBF_TEXT4(0,trace
,"inqisdon");
1284 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1285 sprintf(dbf_text
,"pf%02xcn%02x",q
->first_to_check
,no_used
);
1286 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1287 #endif /* CONFIG_QDIO_DEBUG */
1290 #ifdef CONFIG_QDIO_DEBUG
1291 QDIO_DBF_TEXT4(0,trace
,"inqisntd");
1292 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1293 sprintf(dbf_text
,"pf%02xcn%02x",q
->first_to_check
,no_used
);
1294 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1295 #endif /* CONFIG_QDIO_DEBUG */
1301 qdio_kick_inbound_handler(struct qdio_q
*q
)
1303 int count
, start
, end
, real_end
, i
;
1304 #ifdef CONFIG_QDIO_DEBUG
1308 QDIO_DBF_TEXT4(0,trace
,"kickinh");
1309 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1311 start
=q
->first_element_to_kick
;
1312 real_end
=q
->first_to_check
;
1313 end
=(real_end
+QDIO_MAX_BUFFERS_PER_Q
-1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
1321 i
=(i
+1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
1324 #ifdef CONFIG_QDIO_DEBUG
1325 sprintf(dbf_text
,"s=%2xc=%2x",start
,count
);
1326 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1327 #endif /* CONFIG_QDIO_DEBUG */
1329 if (likely(q
->state
==QDIO_IRQ_STATE_ACTIVE
))
1331 QDIO_STATUS_INBOUND_INT
|q
->error_status_flags
,
1332 q
->qdio_error
,q
->siga_error
,q
->q_no
,start
,count
,
1335 /* for the next time: */
1336 q
->first_element_to_kick
=real_end
;
1339 q
->error_status_flags
=0;
1341 #ifdef QDIO_PERFORMANCE_STATS
1342 perf_stats
.inbound_time
+=NOW
-perf_stats
.start_time_inbound
;
1343 perf_stats
.inbound_cnt
++;
1344 #endif /* QDIO_PERFORMANCE_STATS */
1348 __tiqdio_inbound_processing(struct qdio_q
*q
, int spare_ind_was_set
)
1350 struct qdio_irq
*irq_ptr
;
1354 QDIO_DBF_TEXT4(0,trace
,"iqinproc");
1355 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1358 * we first want to reserve the q, so that we know, that we don't
1359 * interrupt ourselves and call qdio_unmark_q, as is_in_shutdown might
1362 if (unlikely(qdio_reserve_q(q
))) {
1364 #ifdef QDIO_PERFORMANCE_STATS
1366 #endif /* QDIO_PERFORMANCE_STATS */
1368 * as we might just be about to stop polling, we make
1369 * sure that we check again at least once more
1374 #ifdef QDIO_PERFORMANCE_STATS
1376 #endif /* QDIO_PERFORMANCE_STATS */
1377 if (unlikely(atomic_read(&q
->is_in_shutdown
))) {
1383 * we reset spare_ind_was_set, when the queue does not use the
1386 if (spare_ind_was_set
)
1387 spare_ind_was_set
= (q
->dev_st_chg_ind
== &spare_indicator
);
1389 if (!(*(q
->dev_st_chg_ind
)) && !spare_ind_was_set
)
1392 * q->dev_st_chg_ind is the indicator, be it shared or not.
1393 * only clear it, if indicator is non-shared
1395 if (!spare_ind_was_set
)
1396 tiqdio_clear_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1398 if (q
->hydra_gives_outbound_pcis
) {
1399 if (!q
->siga_sync_done_on_thinints
) {
1401 } else if ((!q
->siga_sync_done_on_outb_tis
)&&
1402 (q
->hydra_gives_outbound_pcis
)) {
1403 SYNC_MEMORY_ALL_OUTB
;
1409 * maybe we have to do work on our outbound queues... at least
1410 * we have to check the outbound-int-capable thinint-capable
1413 if (q
->hydra_gives_outbound_pcis
) {
1414 irq_ptr
= (struct qdio_irq
*)q
->irq_ptr
;
1415 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
1416 oq
= irq_ptr
->output_qs
[i
];
1417 #ifdef QDIO_PERFORMANCE_STATS
1418 perf_stats
.tl_runs
--;
1419 #endif /* QDIO_PERFORMANCE_STATS */
1420 if (!qdio_is_outbound_q_done(oq
))
1421 __qdio_outbound_processing(oq
);
1425 if (!qdio_has_inbound_q_moved(q
))
1428 qdio_kick_inbound_handler(q
);
1429 if (tiqdio_is_inbound_q_done(q
))
1430 if (!qdio_stop_polling(q
)) {
1432 * we set the flags to get into the stuff next time,
1433 * see also comment in qdio_stop_polling
1435 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1443 tiqdio_inbound_processing(struct qdio_q
*q
)
1445 __tiqdio_inbound_processing(q
, atomic_read(&spare_indicator_usecount
));
1449 __qdio_inbound_processing(struct qdio_q
*q
)
1453 QDIO_DBF_TEXT4(0,trace
,"qinproc");
1454 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1456 if (unlikely(qdio_reserve_q(q
))) {
1458 #ifdef QDIO_PERFORMANCE_STATS
1460 #endif /* QDIO_PERFORMANCE_STATS */
1461 /* as we're sissies, we'll check next time */
1462 if (likely(!atomic_read(&q
->is_in_shutdown
))) {
1464 QDIO_DBF_TEXT4(0,trace
,"busy,agn");
1468 #ifdef QDIO_PERFORMANCE_STATS
1470 perf_stats
.tl_runs
++;
1471 #endif /* QDIO_PERFORMANCE_STATS */
1474 if (qdio_has_inbound_q_moved(q
)) {
1475 qdio_kick_inbound_handler(q
);
1476 if (!qdio_stop_polling(q
)) {
1478 if (q_laps
<QDIO_Q_LAPS
)
1483 if (!qdio_is_inbound_q_done(q
))
1484 /* means poll time is not yet over */
1492 qdio_inbound_processing(struct qdio_q
*q
)
1494 __qdio_inbound_processing(q
);
1497 /************************* MAIN ROUTINES *******************************/
1499 #ifdef QDIO_USE_PROCESSING_STATE
1501 tiqdio_reset_processing_state(struct qdio_q
*q
, int q_laps
)
1509 * under VM, we have not used the PROCESSING state, so no
1510 * need to stop polling
1515 if (unlikely(qdio_reserve_q(q
))) {
1517 #ifdef QDIO_PERFORMANCE_STATS
1519 #endif /* QDIO_PERFORMANCE_STATS */
1521 * as we might just be about to stop polling, we make
1522 * sure that we check again at least once more
1526 * sanity -- we'd get here without setting the
1529 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1533 if (qdio_stop_polling(q
)) {
1537 if (q_laps
<QDIO_Q_LAPS
-1) {
1542 * we set the flags to get into the stuff
1543 * next time, see also comment in qdio_stop_polling
1545 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1551 #endif /* QDIO_USE_PROCESSING_STATE */
1554 tiqdio_inbound_checks(void)
1557 int spare_ind_was_set
=0;
1558 #ifdef QDIO_USE_PROCESSING_STATE
1560 #endif /* QDIO_USE_PROCESSING_STATE */
1562 QDIO_DBF_TEXT4(0,trace
,"iqdinbck");
1563 QDIO_DBF_TEXT5(0,trace
,"iqlocsum");
1565 #ifdef QDIO_USE_PROCESSING_STATE
1567 #endif /* QDIO_USE_PROCESSING_STATE */
1569 /* when the spare indicator is used and set, save that and clear it */
1570 if ((atomic_read(&spare_indicator_usecount
)) && spare_indicator
) {
1571 spare_ind_was_set
= 1;
1572 tiqdio_clear_summary_bit((__u32
*)&spare_indicator
);
1575 q
=(struct qdio_q
*)tiq_list
;
1579 __tiqdio_inbound_processing(q
, spare_ind_was_set
);
1580 q
=(struct qdio_q
*)q
->list_next
;
1581 } while (q
!=(struct qdio_q
*)tiq_list
);
1583 #ifdef QDIO_USE_PROCESSING_STATE
1584 q
=(struct qdio_q
*)tiq_list
;
1588 ret
= tiqdio_reset_processing_state(q
, q_laps
);
1595 q
= (struct qdio_q
*)q
->list_next
;
1601 } while (q
!=(struct qdio_q
*)tiq_list
);
1602 #endif /* QDIO_USE_PROCESSING_STATE */
1606 tiqdio_tl(unsigned long data
)
1608 QDIO_DBF_TEXT4(0,trace
,"iqdio_tl");
1610 #ifdef QDIO_PERFORMANCE_STATS
1611 perf_stats
.tl_runs
++;
1612 #endif /* QDIO_PERFORMANCE_STATS */
1614 tiqdio_inbound_checks();
1617 /********************* GENERAL HELPER_ROUTINES ***********************/
1620 qdio_release_irq_memory(struct qdio_irq
*irq_ptr
)
1624 for (i
=0;i
<QDIO_MAX_QUEUES_PER_IRQ
;i
++) {
1625 if (!irq_ptr
->input_qs
[i
])
1628 kfree(irq_ptr
->input_qs
[i
]->slib
);
1629 kfree(irq_ptr
->input_qs
[i
]);
1632 if (!irq_ptr
->output_qs
[i
])
1635 kfree(irq_ptr
->output_qs
[i
]->slib
);
1636 kfree(irq_ptr
->output_qs
[i
]);
1639 kfree(irq_ptr
->qdr
);
1644 qdio_set_impl_params(struct qdio_irq
*irq_ptr
,
1645 unsigned int qib_param_field_format
,
1646 /* pointer to 128 bytes or NULL, if no param field */
1647 unsigned char *qib_param_field
,
1648 /* pointer to no_queues*128 words of data or NULL */
1649 unsigned int no_input_qs
,
1650 unsigned int no_output_qs
,
1651 unsigned long *input_slib_elements
,
1652 unsigned long *output_slib_elements
)
1659 irq_ptr
->qib
.pfmt
=qib_param_field_format
;
1660 if (qib_param_field
)
1661 memcpy(irq_ptr
->qib
.parm
,qib_param_field
,
1662 QDIO_MAX_BUFFERS_PER_Q
);
1664 if (input_slib_elements
)
1665 for (i
=0;i
<no_input_qs
;i
++) {
1666 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1667 irq_ptr
->input_qs
[i
]->slib
->slibe
[j
].parms
=
1668 input_slib_elements
[
1669 i
*QDIO_MAX_BUFFERS_PER_Q
+j
];
1671 if (output_slib_elements
)
1672 for (i
=0;i
<no_output_qs
;i
++) {
1673 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1674 irq_ptr
->output_qs
[i
]->slib
->slibe
[j
].parms
=
1675 output_slib_elements
[
1676 i
*QDIO_MAX_BUFFERS_PER_Q
+j
];
1681 qdio_alloc_qs(struct qdio_irq
*irq_ptr
,
1682 int no_input_qs
, int no_output_qs
)
1688 for (i
=0;i
<no_input_qs
;i
++) {
1689 q
= kzalloc(sizeof(struct qdio_q
), GFP_KERNEL
);
1692 QDIO_PRINT_ERR("kmalloc of q failed!\n");
1696 q
->slib
= kmalloc(PAGE_SIZE
, GFP_KERNEL
);
1698 QDIO_PRINT_ERR("kmalloc of slib failed!\n");
1702 irq_ptr
->input_qs
[i
]=q
;
1705 for (i
=0;i
<no_output_qs
;i
++) {
1706 q
= kzalloc(sizeof(struct qdio_q
), GFP_KERNEL
);
1712 q
->slib
=kmalloc(PAGE_SIZE
,GFP_KERNEL
);
1714 QDIO_PRINT_ERR("kmalloc of slib failed!\n");
1718 irq_ptr
->output_qs
[i
]=q
;
1727 qdio_fill_qs(struct qdio_irq
*irq_ptr
, struct ccw_device
*cdev
,
1728 int no_input_qs
, int no_output_qs
,
1729 qdio_handler_t
*input_handler
,
1730 qdio_handler_t
*output_handler
,
1731 unsigned long int_parm
,int q_format
,
1732 unsigned long flags
,
1733 void **inbound_sbals_array
,
1734 void **outbound_sbals_array
)
1738 char dbf_text
[20]; /* see qdio_initialize */
1742 sprintf(dbf_text
,"qfqs%4x",cdev
->private->sch_no
);
1743 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
1744 for (i
=0;i
<no_input_qs
;i
++) {
1745 q
=irq_ptr
->input_qs
[i
];
1747 memset(q
,0,((char*)&q
->slib
)-((char*)q
));
1748 sprintf(dbf_text
,"in-q%4x",i
);
1749 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
1750 QDIO_DBF_HEX0(0,setup
,&q
,sizeof(void*));
1752 memset(q
->slib
,0,PAGE_SIZE
);
1753 q
->sl
=(struct sl
*)(((char*)q
->slib
)+PAGE_SIZE
/2);
1757 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1758 q
->sbal
[j
]=*(inbound_sbals_array
++);
1760 q
->queue_type
=q_format
;
1761 q
->int_parm
=int_parm
;
1762 q
->schid
= irq_ptr
->schid
;
1763 q
->irq_ptr
= irq_ptr
;
1768 q
->first_to_check
=0;
1770 q
->handler
=input_handler
;
1771 q
->dev_st_chg_ind
=irq_ptr
->dev_st_chg_ind
;
1773 q
->tasklet
.data
=(unsigned long)q
;
1774 /* q->is_thinint_q isn't valid at this time, but
1775 * irq_ptr->is_thinint_irq is */
1776 q
->tasklet
.func
=(void(*)(unsigned long))
1777 ((irq_ptr
->is_thinint_irq
)?&tiqdio_inbound_processing
:
1778 &qdio_inbound_processing
);
1780 /* actually this is not used for inbound queues. yet. */
1781 atomic_set(&q
->busy_siga_counter
,0);
1782 q
->timing
.busy_start
=0;
1784 /* for (j=0;j<QDIO_STATS_NUMBER;j++)
1785 q->timing.last_transfer_times[j]=(qdio_get_micros()/
1786 QDIO_STATS_NUMBER)*j;
1787 q->timing.last_transfer_index=QDIO_STATS_NUMBER-1;
1791 if (i
>0) irq_ptr
->input_qs
[i
-1]->slib
->nsliba
=
1792 (unsigned long)(q
->slib
);
1793 q
->slib
->sla
=(unsigned long)(q
->sl
);
1794 q
->slib
->slsba
=(unsigned long)(&q
->slsb
.acc
.val
[0]);
1797 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1798 q
->sl
->element
[j
].sbal
=(unsigned long)(q
->sbal
[j
]);
1800 QDIO_DBF_TEXT2(0,setup
,"sl-sb-b0");
1802 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1803 ptr
=(void*)&q
->slsb
;
1804 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1805 ptr
=(void*)q
->sbal
[0];
1806 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1809 if (!irq_ptr
->is_qebsm
) {
1810 unsigned int count
= 1;
1811 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; j
++)
1812 set_slsb(q
, &j
, SLSB_P_INPUT_NOT_INIT
, &count
);
1816 for (i
=0;i
<no_output_qs
;i
++) {
1817 q
=irq_ptr
->output_qs
[i
];
1818 memset(q
,0,((char*)&q
->slib
)-((char*)q
));
1820 sprintf(dbf_text
,"outq%4x",i
);
1821 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
1822 QDIO_DBF_HEX0(0,setup
,&q
,sizeof(void*));
1824 memset(q
->slib
,0,PAGE_SIZE
);
1825 q
->sl
=(struct sl
*)(((char*)q
->slib
)+PAGE_SIZE
/2);
1829 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1830 q
->sbal
[j
]=*(outbound_sbals_array
++);
1832 q
->queue_type
=q_format
;
1833 q
->int_parm
=int_parm
;
1835 q
->schid
= irq_ptr
->schid
;
1837 q
->irq_ptr
= irq_ptr
;
1840 q
->first_to_check
=0;
1842 q
->handler
=output_handler
;
1844 q
->tasklet
.data
=(unsigned long)q
;
1845 q
->tasklet
.func
=(void(*)(unsigned long))
1846 &qdio_outbound_processing
;
1848 atomic_set(&q
->busy_siga_counter
,0);
1849 q
->timing
.busy_start
=0;
1852 if (i
>0) irq_ptr
->output_qs
[i
-1]->slib
->nsliba
=
1853 (unsigned long)(q
->slib
);
1854 q
->slib
->sla
=(unsigned long)(q
->sl
);
1855 q
->slib
->slsba
=(unsigned long)(&q
->slsb
.acc
.val
[0]);
1858 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1859 q
->sl
->element
[j
].sbal
=(unsigned long)(q
->sbal
[j
]);
1861 QDIO_DBF_TEXT2(0,setup
,"sl-sb-b0");
1863 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1864 ptr
=(void*)&q
->slsb
;
1865 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1866 ptr
=(void*)q
->sbal
[0];
1867 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1870 if (!irq_ptr
->is_qebsm
) {
1871 unsigned int count
= 1;
1872 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; j
++)
1873 set_slsb(q
, &j
, SLSB_P_OUTPUT_NOT_INIT
, &count
);
1879 qdio_fill_thresholds(struct qdio_irq
*irq_ptr
,
1880 unsigned int no_input_qs
,
1881 unsigned int no_output_qs
,
1882 unsigned int min_input_threshold
,
1883 unsigned int max_input_threshold
,
1884 unsigned int min_output_threshold
,
1885 unsigned int max_output_threshold
)
1890 for (i
=0;i
<no_input_qs
;i
++) {
1891 q
=irq_ptr
->input_qs
[i
];
1892 q
->timing
.threshold
=max_input_threshold
;
1893 /* for (j=0;j<QDIO_STATS_CLASSES;j++) {
1894 q->threshold_classes[j].threshold=
1895 min_input_threshold+
1896 (max_input_threshold-min_input_threshold)/
1899 qdio_use_thresholds(q,QDIO_STATS_CLASSES/2);*/
1901 for (i
=0;i
<no_output_qs
;i
++) {
1902 q
=irq_ptr
->output_qs
[i
];
1903 q
->timing
.threshold
=max_output_threshold
;
1904 /* for (j=0;j<QDIO_STATS_CLASSES;j++) {
1905 q->threshold_classes[j].threshold=
1906 min_output_threshold+
1907 (max_output_threshold-min_output_threshold)/
1910 qdio_use_thresholds(q,QDIO_STATS_CLASSES/2);*/
1915 tiqdio_thinint_handler(void)
1917 QDIO_DBF_TEXT4(0,trace
,"thin_int");
1919 #ifdef QDIO_PERFORMANCE_STATS
1920 perf_stats
.thinints
++;
1921 perf_stats
.start_time_inbound
=NOW
;
1922 #endif /* QDIO_PERFORMANCE_STATS */
1924 /* SVS only when needed:
1925 * issue SVS to benefit from iqdio interrupt avoidance
1926 * (SVS clears AISOI)*/
1928 tiqdio_clear_global_summary();
1930 tiqdio_inbound_checks();
1935 qdio_set_state(struct qdio_irq
*irq_ptr
, enum qdio_irq_states state
)
1938 #ifdef CONFIG_QDIO_DEBUG
1941 QDIO_DBF_TEXT5(0,trace
,"newstate");
1942 sprintf(dbf_text
,"%4x%4x",irq_ptr
->schid
.sch_no
,state
);
1943 QDIO_DBF_TEXT5(0,trace
,dbf_text
);
1944 #endif /* CONFIG_QDIO_DEBUG */
1946 irq_ptr
->state
=state
;
1947 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++)
1948 irq_ptr
->input_qs
[i
]->state
=state
;
1949 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++)
1950 irq_ptr
->output_qs
[i
]->state
=state
;
1955 qdio_irq_check_sense(struct subchannel_id schid
, struct irb
*irb
)
1959 if (irb
->esw
.esw0
.erw
.cons
) {
1960 sprintf(dbf_text
,"sens%4x",schid
.sch_no
);
1961 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
1962 QDIO_DBF_HEX0(0,sense
,irb
,QDIO_DBF_SENSE_LEN
);
1964 QDIO_PRINT_WARN("sense data available on qdio channel.\n");
1965 HEXDUMP16(WARN
,"irb: ",irb
);
1966 HEXDUMP16(WARN
,"sense data: ",irb
->ecw
);
1972 qdio_handle_pci(struct qdio_irq
*irq_ptr
)
1977 #ifdef QDIO_PERFORMANCE_STATS
1979 perf_stats
.start_time_inbound
=NOW
;
1980 #endif /* QDIO_PERFORMANCE_STATS */
1981 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
1982 q
=irq_ptr
->input_qs
[i
];
1983 if (q
->is_input_q
&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT
)
1986 #ifdef QDIO_PERFORMANCE_STATS
1987 perf_stats
.tl_runs
--;
1988 #endif /* QDIO_PERFORMANCE_STATS */
1989 __qdio_inbound_processing(q
);
1992 if (!irq_ptr
->hydra_gives_outbound_pcis
)
1994 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
1995 q
=irq_ptr
->output_qs
[i
];
1996 #ifdef QDIO_PERFORMANCE_STATS
1997 perf_stats
.tl_runs
--;
1998 #endif /* QDIO_PERFORMANCE_STATS */
1999 if (qdio_is_outbound_q_done(q
))
2001 if (!irq_ptr
->sync_done_on_outb_pcis
)
2003 __qdio_outbound_processing(q
);
2007 static void qdio_establish_handle_irq(struct ccw_device
*, int, int);
2010 qdio_handle_activate_check(struct ccw_device
*cdev
, unsigned long intparm
,
2011 int cstat
, int dstat
)
2013 struct qdio_irq
*irq_ptr
;
2017 irq_ptr
= cdev
->private->qdio_data
;
2019 QDIO_DBF_TEXT2(1, trace
, "ick2");
2020 sprintf(dbf_text
,"%s", cdev
->dev
.bus_id
);
2021 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
2022 QDIO_DBF_HEX2(0,trace
,&intparm
,sizeof(int));
2023 QDIO_DBF_HEX2(0,trace
,&dstat
,sizeof(int));
2024 QDIO_DBF_HEX2(0,trace
,&cstat
,sizeof(int));
2025 QDIO_PRINT_ERR("received check condition on activate " \
2026 "queues on device %s (cs=x%x, ds=x%x).\n",
2027 cdev
->dev
.bus_id
, cstat
, dstat
);
2028 if (irq_ptr
->no_input_qs
) {
2029 q
=irq_ptr
->input_qs
[0];
2030 } else if (irq_ptr
->no_output_qs
) {
2031 q
=irq_ptr
->output_qs
[0];
2033 QDIO_PRINT_ERR("oops... no queue registered for device %s!?\n",
2035 goto omit_handler_call
;
2037 q
->handler(q
->cdev
,QDIO_STATUS_ACTIVATE_CHECK_CONDITION
|
2038 QDIO_STATUS_LOOK_FOR_ERROR
,
2039 0,0,0,-1,-1,q
->int_parm
);
2041 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_STOPPED
);
2046 qdio_call_shutdown(void *data
)
2048 struct ccw_device
*cdev
;
2050 cdev
= (struct ccw_device
*)data
;
2051 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
2052 put_device(&cdev
->dev
);
2056 qdio_timeout_handler(struct ccw_device
*cdev
)
2058 struct qdio_irq
*irq_ptr
;
2061 QDIO_DBF_TEXT2(0, trace
, "qtoh");
2062 sprintf(dbf_text
, "%s", cdev
->dev
.bus_id
);
2063 QDIO_DBF_TEXT2(0, trace
, dbf_text
);
2065 irq_ptr
= cdev
->private->qdio_data
;
2066 sprintf(dbf_text
, "state:%d", irq_ptr
->state
);
2067 QDIO_DBF_TEXT2(0, trace
, dbf_text
);
2069 switch (irq_ptr
->state
) {
2070 case QDIO_IRQ_STATE_INACTIVE
:
2071 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: timed out\n",
2072 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2073 QDIO_DBF_TEXT2(1,setup
,"eq:timeo");
2074 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2076 case QDIO_IRQ_STATE_CLEANUP
:
2077 QDIO_PRINT_INFO("Did not get interrupt on cleanup, "
2079 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2080 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2082 case QDIO_IRQ_STATE_ESTABLISHED
:
2083 case QDIO_IRQ_STATE_ACTIVE
:
2084 /* I/O has been terminated by common I/O layer. */
2085 QDIO_PRINT_INFO("Queues on irq 0.%x.%04x killed by cio.\n",
2086 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2087 QDIO_DBF_TEXT2(1, trace
, "cio:term");
2088 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_STOPPED
);
2089 if (get_device(&cdev
->dev
)) {
2090 /* Can't call shutdown from interrupt context. */
2091 PREPARE_WORK(&cdev
->private->kick_work
,
2092 qdio_call_shutdown
, (void *)cdev
);
2093 queue_work(ccw_device_work
, &cdev
->private->kick_work
);
2099 ccw_device_set_timeout(cdev
, 0);
2100 wake_up(&cdev
->private->wait_q
);
2104 qdio_handler(struct ccw_device
*cdev
, unsigned long intparm
, struct irb
*irb
)
2106 struct qdio_irq
*irq_ptr
;
2110 #ifdef CONFIG_QDIO_DEBUG
2111 QDIO_DBF_TEXT4(0, trace
, "qint");
2112 sprintf(dbf_text
, "%s", cdev
->dev
.bus_id
);
2113 QDIO_DBF_TEXT4(0, trace
, dbf_text
);
2114 #endif /* CONFIG_QDIO_DEBUG */
2117 QDIO_PRINT_ERR("got unsolicited interrupt in qdio " \
2118 "handler, device %s\n", cdev
->dev
.bus_id
);
2122 irq_ptr
= cdev
->private->qdio_data
;
2124 QDIO_DBF_TEXT2(1, trace
, "uint");
2125 sprintf(dbf_text
,"%s", cdev
->dev
.bus_id
);
2126 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
2127 QDIO_PRINT_ERR("received interrupt on unused device %s!\n",
2133 /* Currently running i/o is in error. */
2134 switch (PTR_ERR(irb
)) {
2136 QDIO_PRINT_ERR("i/o error on device %s\n",
2140 qdio_timeout_handler(cdev
);
2143 QDIO_PRINT_ERR("unknown error state %ld on device %s\n",
2144 PTR_ERR(irb
), cdev
->dev
.bus_id
);
2149 qdio_irq_check_sense(irq_ptr
->schid
, irb
);
2151 #ifdef CONFIG_QDIO_DEBUG
2152 sprintf(dbf_text
, "state:%d", irq_ptr
->state
);
2153 QDIO_DBF_TEXT4(0, trace
, dbf_text
);
2154 #endif /* CONFIG_QDIO_DEBUG */
2156 cstat
= irb
->scsw
.cstat
;
2157 dstat
= irb
->scsw
.dstat
;
2159 switch (irq_ptr
->state
) {
2160 case QDIO_IRQ_STATE_INACTIVE
:
2161 qdio_establish_handle_irq(cdev
, cstat
, dstat
);
2164 case QDIO_IRQ_STATE_CLEANUP
:
2165 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2168 case QDIO_IRQ_STATE_ESTABLISHED
:
2169 case QDIO_IRQ_STATE_ACTIVE
:
2170 if (cstat
& SCHN_STAT_PCI
) {
2171 qdio_handle_pci(irq_ptr
);
2175 if ((cstat
&~SCHN_STAT_PCI
)||dstat
) {
2176 qdio_handle_activate_check(cdev
, intparm
, cstat
, dstat
);
2180 QDIO_PRINT_ERR("got interrupt for queues in state %d on " \
2182 irq_ptr
->state
, cdev
->dev
.bus_id
);
2184 wake_up(&cdev
->private->wait_q
);
2189 qdio_synchronize(struct ccw_device
*cdev
, unsigned int flags
,
2190 unsigned int queue_number
)
2194 struct qdio_irq
*irq_ptr
;
2196 #ifdef CONFIG_QDIO_DEBUG
2197 char dbf_text
[15]="SyncXXXX";
2200 irq_ptr
= cdev
->private->qdio_data
;
2204 #ifdef CONFIG_QDIO_DEBUG
2205 *((int*)(&dbf_text
[4])) = irq_ptr
->schid
.sch_no
;
2206 QDIO_DBF_HEX4(0,trace
,dbf_text
,QDIO_DBF_TRACE_LEN
);
2207 *((int*)(&dbf_text
[0]))=flags
;
2208 *((int*)(&dbf_text
[4]))=queue_number
;
2209 QDIO_DBF_HEX4(0,trace
,dbf_text
,QDIO_DBF_TRACE_LEN
);
2210 #endif /* CONFIG_QDIO_DEBUG */
2212 if (flags
&QDIO_FLAG_SYNC_INPUT
) {
2213 q
=irq_ptr
->input_qs
[queue_number
];
2216 if (!(irq_ptr
->is_qebsm
))
2217 cc
= do_siga_sync(q
->schid
, 0, q
->mask
);
2218 } else if (flags
&QDIO_FLAG_SYNC_OUTPUT
) {
2219 q
=irq_ptr
->output_qs
[queue_number
];
2222 if (!(irq_ptr
->is_qebsm
))
2223 cc
= do_siga_sync(q
->schid
, q
->mask
, 0);
2229 QDIO_DBF_HEX3(0,trace
,&ptr
,sizeof(int));
2235 qdio_check_subchannel_qebsm(struct qdio_irq
*irq_ptr
, unsigned char qdioac
,
2236 unsigned long token
)
2240 unsigned int count
, start_buf
;
2243 /*check if QEBSM is disabled */
2244 if (!(irq_ptr
->is_qebsm
) || !(qdioac
& 0x01)) {
2245 irq_ptr
->is_qebsm
= 0;
2246 irq_ptr
->sch_token
= 0;
2247 irq_ptr
->qib
.rflags
&= ~QIB_RFLAGS_ENABLE_QEBSM
;
2248 QDIO_DBF_TEXT0(0,setup
,"noV=V");
2251 irq_ptr
->sch_token
= token
;
2253 for (i
= 0; i
< irq_ptr
->no_input_qs
;i
++) {
2254 q
= irq_ptr
->input_qs
[i
];
2255 count
= QDIO_MAX_BUFFERS_PER_Q
;
2257 set_slsb(q
, &start_buf
, SLSB_P_INPUT_NOT_INIT
, &count
);
2259 sprintf(dbf_text
,"V=V:%2x",irq_ptr
->is_qebsm
);
2260 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2261 sprintf(dbf_text
,"%8lx",irq_ptr
->sch_token
);
2262 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2264 for (i
= 0; i
< irq_ptr
->no_output_qs
; i
++) {
2265 q
= irq_ptr
->output_qs
[i
];
2266 count
= QDIO_MAX_BUFFERS_PER_Q
;
2268 set_slsb(q
, &start_buf
, SLSB_P_OUTPUT_NOT_INIT
, &count
);
2273 qdio_get_ssqd_information(struct qdio_irq
*irq_ptr
)
2276 unsigned char qdioac
;
2278 struct chsc_header request
;
2286 struct chsc_header response
;
2305 QDIO_DBF_TEXT0(0,setup
,"getssqd");
2307 ssqd_area
= (void *)get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
2309 QDIO_PRINT_WARN("Could not get memory for chsc. Using all " \
2310 "SIGAs for sch x%x.\n", irq_ptr
->schid
.sch_no
);
2311 irq_ptr
->qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
||
2312 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
||
2313 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* all flags set */
2314 irq_ptr
->is_qebsm
= 0;
2315 irq_ptr
->sch_token
= 0;
2316 irq_ptr
->qib
.rflags
&= ~QIB_RFLAGS_ENABLE_QEBSM
;
2320 ssqd_area
->request
= (struct chsc_header
) {
2324 ssqd_area
->first_sch
= irq_ptr
->schid
.sch_no
;
2325 ssqd_area
->last_sch
= irq_ptr
->schid
.sch_no
;
2326 ssqd_area
->ssid
= irq_ptr
->schid
.ssid
;
2327 result
= chsc(ssqd_area
);
2330 QDIO_PRINT_WARN("CHSC returned cc %i. Using all " \
2331 "SIGAs for sch 0.%x.%x.\n", result
,
2332 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2333 qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
||
2334 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
||
2335 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* all flags set */
2336 irq_ptr
->is_qebsm
= 0;
2340 if (ssqd_area
->response
.code
!= QDIO_CHSC_RESPONSE_CODE_OK
) {
2341 QDIO_PRINT_WARN("response upon checking SIGA needs " \
2342 "is 0x%x. Using all SIGAs for sch 0.%x.%x.\n",
2343 ssqd_area
->response
.code
,
2344 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2345 qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
||
2346 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
||
2347 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* all flags set */
2348 irq_ptr
->is_qebsm
= 0;
2351 if (!(ssqd_area
->flags
& CHSC_FLAG_QDIO_CAPABILITY
) ||
2352 !(ssqd_area
->flags
& CHSC_FLAG_VALIDITY
) ||
2353 (ssqd_area
->sch
!= irq_ptr
->schid
.sch_no
)) {
2354 QDIO_PRINT_WARN("huh? problems checking out sch 0.%x.%x... " \
2355 "using all SIGAs.\n",
2356 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2357 qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
|
2358 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
|
2359 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* worst case */
2360 irq_ptr
->is_qebsm
= 0;
2363 qdioac
= ssqd_area
->qdioac1
;
2365 qdio_check_subchannel_qebsm(irq_ptr
, qdioac
,
2366 ssqd_area
->sch_token
);
2367 free_page ((unsigned long) ssqd_area
);
2368 irq_ptr
->qdioac
= qdioac
;
2372 tiqdio_check_chsc_availability(void)
2376 if (!css_characteristics_avail
)
2379 /* Check for bit 41. */
2380 if (!css_general_characteristics
.aif
) {
2381 QDIO_PRINT_WARN("Adapter interruption facility not " \
2386 /* Check for bits 107 and 108. */
2387 if (!css_chsc_characteristics
.scssc
||
2388 !css_chsc_characteristics
.scsscf
) {
2389 QDIO_PRINT_WARN("Set Chan Subsys. Char. & Fast-CHSCs " \
2390 "not available.\n");
2394 /* Check for OSA/FCP thin interrupts (bit 67). */
2395 hydra_thinints
= css_general_characteristics
.aif_osa
;
2396 sprintf(dbf_text
,"hydrati%1x", hydra_thinints
);
2397 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2400 /* Check for QEBSM support in general (bit 58). */
2401 is_passthrough
= css_general_characteristics
.qebsm
;
2403 sprintf(dbf_text
,"cssQBS:%1x", is_passthrough
);
2404 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2406 /* Check for aif time delay disablement fac (bit 56). If installed,
2407 * omit svs even under lpar (good point by rick again) */
2408 omit_svs
= css_general_characteristics
.aif_tdd
;
2409 sprintf(dbf_text
,"omitsvs%1x", omit_svs
);
2410 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2416 tiqdio_set_subchannel_ind(struct qdio_irq
*irq_ptr
, int reset_to_zero
)
2418 unsigned long real_addr_local_summary_bit
;
2419 unsigned long real_addr_dev_st_chg_ind
;
2423 unsigned int resp_code
;
2427 struct chsc_header request
;
2432 u64 summary_indicator_addr
;
2433 u64 subchannel_indicator_addr
;
2438 u32 word_with_d_bit
;
2439 /* set to 0x10000000 to enable
2440 * time delay disablement facility */
2442 struct subchannel_id schid
;
2443 u32 reserved6
[1004];
2444 struct chsc_header response
;
2448 if (!irq_ptr
->is_thinint_irq
)
2451 if (reset_to_zero
) {
2452 real_addr_local_summary_bit
=0;
2453 real_addr_dev_st_chg_ind
=0;
2455 real_addr_local_summary_bit
=
2456 virt_to_phys((volatile void *)indicators
);
2457 real_addr_dev_st_chg_ind
=
2458 virt_to_phys((volatile void *)irq_ptr
->dev_st_chg_ind
);
2461 scssc_area
= (void *)get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
2463 QDIO_PRINT_WARN("No memory for setting indicators on " \
2464 "subchannel 0.%x.%x.\n",
2465 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2468 scssc_area
->request
= (struct chsc_header
) {
2472 scssc_area
->operation_code
= 0;
2474 scssc_area
->summary_indicator_addr
= real_addr_local_summary_bit
;
2475 scssc_area
->subchannel_indicator_addr
= real_addr_dev_st_chg_ind
;
2476 scssc_area
->ks
= QDIO_STORAGE_KEY
;
2477 scssc_area
->kc
= QDIO_STORAGE_KEY
;
2478 scssc_area
->isc
= TIQDIO_THININT_ISC
;
2479 scssc_area
->schid
= irq_ptr
->schid
;
2480 /* enables the time delay disablement facility. Don't care
2481 * whether it is really there (i.e. we haven't checked for
2483 if (css_general_characteristics
.aif_tdd
)
2484 scssc_area
->word_with_d_bit
= 0x10000000;
2486 QDIO_PRINT_WARN("Time delay disablement facility " \
2489 result
= chsc(scssc_area
);
2491 QDIO_PRINT_WARN("could not set indicators on irq 0.%x.%x, " \
2493 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,result
);
2498 resp_code
= scssc_area
->response
.code
;
2499 if (resp_code
!=QDIO_CHSC_RESPONSE_CODE_OK
) {
2500 QDIO_PRINT_WARN("response upon setting indicators " \
2501 "is 0x%x.\n",resp_code
);
2502 sprintf(dbf_text
,"sidR%4x",resp_code
);
2503 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2504 QDIO_DBF_TEXT1(0,setup
,dbf_text
);
2505 ptr
=&scssc_area
->response
;
2506 QDIO_DBF_HEX2(1,setup
,&ptr
,QDIO_DBF_SETUP_LEN
);
2511 QDIO_DBF_TEXT2(0,setup
,"setscind");
2512 QDIO_DBF_HEX2(0,setup
,&real_addr_local_summary_bit
,
2513 sizeof(unsigned long));
2514 QDIO_DBF_HEX2(0,setup
,&real_addr_dev_st_chg_ind
,sizeof(unsigned long));
2517 free_page ((unsigned long) scssc_area
);
2523 tiqdio_set_delay_target(struct qdio_irq
*irq_ptr
, unsigned long delay_target
)
2525 unsigned int resp_code
;
2531 struct chsc_header request
;
2538 u32 reserved5
[1009];
2539 struct chsc_header response
;
2543 if (!irq_ptr
->is_thinint_irq
)
2546 scsscf_area
= (void *)get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
2548 QDIO_PRINT_WARN("No memory for setting delay target on " \
2549 "subchannel 0.%x.%x.\n",
2550 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2553 scsscf_area
->request
= (struct chsc_header
) {
2558 scsscf_area
->delay_target
= delay_target
<<16;
2560 result
=chsc(scsscf_area
);
2562 QDIO_PRINT_WARN("could not set delay target on irq 0.%x.%x, " \
2563 "cc=%i. Continuing.\n",
2564 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
2570 resp_code
= scsscf_area
->response
.code
;
2571 if (resp_code
!=QDIO_CHSC_RESPONSE_CODE_OK
) {
2572 QDIO_PRINT_WARN("response upon setting delay target " \
2573 "is 0x%x. Continuing.\n",resp_code
);
2574 sprintf(dbf_text
,"sdtR%4x",resp_code
);
2575 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2576 QDIO_DBF_TEXT1(0,setup
,dbf_text
);
2577 ptr
=&scsscf_area
->response
;
2578 QDIO_DBF_HEX2(1,trace
,&ptr
,QDIO_DBF_TRACE_LEN
);
2580 QDIO_DBF_TEXT2(0,trace
,"delytrgt");
2581 QDIO_DBF_HEX2(0,trace
,&delay_target
,sizeof(unsigned long));
2582 result
= 0; /* not critical */
2584 free_page ((unsigned long) scsscf_area
);
2589 qdio_cleanup(struct ccw_device
*cdev
, int how
)
2591 struct qdio_irq
*irq_ptr
;
2595 irq_ptr
= cdev
->private->qdio_data
;
2599 sprintf(dbf_text
,"qcln%4x",irq_ptr
->schid
.sch_no
);
2600 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2601 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2603 rc
= qdio_shutdown(cdev
, how
);
2604 if ((rc
== 0) || (rc
== -EINPROGRESS
))
2605 rc
= qdio_free(cdev
);
2610 qdio_shutdown(struct ccw_device
*cdev
, int how
)
2612 struct qdio_irq
*irq_ptr
;
2616 unsigned long flags
;
2620 irq_ptr
= cdev
->private->qdio_data
;
2624 down(&irq_ptr
->setting_up_sema
);
2626 sprintf(dbf_text
,"qsqs%4x",irq_ptr
->schid
.sch_no
);
2627 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2628 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2630 /* mark all qs as uninteresting */
2631 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++)
2632 atomic_set(&irq_ptr
->input_qs
[i
]->is_in_shutdown
,1);
2634 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++)
2635 atomic_set(&irq_ptr
->output_qs
[i
]->is_in_shutdown
,1);
2637 tasklet_kill(&tiqdio_tasklet
);
2639 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
2640 qdio_unmark_q(irq_ptr
->input_qs
[i
]);
2641 tasklet_kill(&irq_ptr
->input_qs
[i
]->tasklet
);
2642 wait_event_interruptible_timeout(cdev
->private->wait_q
,
2643 !atomic_read(&irq_ptr
->
2646 QDIO_NO_USE_COUNT_TIMEOUT
);
2647 if (atomic_read(&irq_ptr
->input_qs
[i
]->use_count
))
2648 result
=-EINPROGRESS
;
2651 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
2652 tasklet_kill(&irq_ptr
->output_qs
[i
]->tasklet
);
2653 wait_event_interruptible_timeout(cdev
->private->wait_q
,
2654 !atomic_read(&irq_ptr
->
2657 QDIO_NO_USE_COUNT_TIMEOUT
);
2658 if (atomic_read(&irq_ptr
->output_qs
[i
]->use_count
))
2659 result
=-EINPROGRESS
;
2662 /* cleanup subchannel */
2663 spin_lock_irqsave(get_ccwdev_lock(cdev
),flags
);
2664 if (how
&QDIO_FLAG_CLEANUP_USING_CLEAR
) {
2665 rc
= ccw_device_clear(cdev
, QDIO_DOING_CLEANUP
);
2666 timeout
=QDIO_CLEANUP_CLEAR_TIMEOUT
;
2667 } else if (how
&QDIO_FLAG_CLEANUP_USING_HALT
) {
2668 rc
= ccw_device_halt(cdev
, QDIO_DOING_CLEANUP
);
2669 timeout
=QDIO_CLEANUP_HALT_TIMEOUT
;
2670 } else { /* default behaviour */
2671 rc
= ccw_device_halt(cdev
, QDIO_DOING_CLEANUP
);
2672 timeout
=QDIO_CLEANUP_HALT_TIMEOUT
;
2674 if (rc
== -ENODEV
) {
2675 /* No need to wait for device no longer present. */
2676 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2677 spin_unlock_irqrestore(get_ccwdev_lock(cdev
), flags
);
2678 } else if (((void *)cdev
->handler
!= (void *)qdio_handler
) && rc
== 0) {
2680 * Whoever put another handler there, has to cope with the
2681 * interrupt theirself. Might happen if qdio_shutdown was
2682 * called on already shutdown queues, but this shouldn't have
2685 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2686 spin_unlock_irqrestore(get_ccwdev_lock(cdev
), flags
);
2687 } else if (rc
== 0) {
2688 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_CLEANUP
);
2689 ccw_device_set_timeout(cdev
, timeout
);
2690 spin_unlock_irqrestore(get_ccwdev_lock(cdev
),flags
);
2692 wait_event(cdev
->private->wait_q
,
2693 irq_ptr
->state
== QDIO_IRQ_STATE_INACTIVE
||
2694 irq_ptr
->state
== QDIO_IRQ_STATE_ERR
);
2696 QDIO_PRINT_INFO("ccw_device_{halt,clear} returned %d for "
2697 "device %s\n", result
, cdev
->dev
.bus_id
);
2698 spin_unlock_irqrestore(get_ccwdev_lock(cdev
), flags
);
2702 if (irq_ptr
->is_thinint_irq
) {
2703 qdio_put_indicator((__u32
*)irq_ptr
->dev_st_chg_ind
);
2704 tiqdio_set_subchannel_ind(irq_ptr
,1);
2705 /* reset adapter interrupt indicators */
2708 /* exchange int handlers, if necessary */
2709 if ((void*)cdev
->handler
== (void*)qdio_handler
)
2710 cdev
->handler
=irq_ptr
->original_int_handler
;
2712 /* Ignore errors. */
2713 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2714 ccw_device_set_timeout(cdev
, 0);
2716 up(&irq_ptr
->setting_up_sema
);
2721 qdio_free(struct ccw_device
*cdev
)
2723 struct qdio_irq
*irq_ptr
;
2726 irq_ptr
= cdev
->private->qdio_data
;
2730 down(&irq_ptr
->setting_up_sema
);
2732 sprintf(dbf_text
,"qfqs%4x",irq_ptr
->schid
.sch_no
);
2733 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2734 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2736 cdev
->private->qdio_data
= 0;
2738 up(&irq_ptr
->setting_up_sema
);
2740 qdio_release_irq_memory(irq_ptr
);
2741 module_put(THIS_MODULE
);
2746 qdio_allocate_do_dbf(struct qdio_initialize
*init_data
)
2748 char dbf_text
[20]; /* if a printf printed out more than 8 chars */
2750 sprintf(dbf_text
,"qfmt:%x",init_data
->q_format
);
2751 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2752 QDIO_DBF_HEX0(0,setup
,init_data
->adapter_name
,8);
2753 sprintf(dbf_text
,"qpff%4x",init_data
->qib_param_field_format
);
2754 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2755 QDIO_DBF_HEX0(0,setup
,&init_data
->qib_param_field
,sizeof(char*));
2756 QDIO_DBF_HEX0(0,setup
,&init_data
->input_slib_elements
,sizeof(long*));
2757 QDIO_DBF_HEX0(0,setup
,&init_data
->output_slib_elements
,sizeof(long*));
2758 sprintf(dbf_text
,"miit%4x",init_data
->min_input_threshold
);
2759 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2760 sprintf(dbf_text
,"mait%4x",init_data
->max_input_threshold
);
2761 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2762 sprintf(dbf_text
,"miot%4x",init_data
->min_output_threshold
);
2763 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2764 sprintf(dbf_text
,"maot%4x",init_data
->max_output_threshold
);
2765 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2766 sprintf(dbf_text
,"niq:%4x",init_data
->no_input_qs
);
2767 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2768 sprintf(dbf_text
,"noq:%4x",init_data
->no_output_qs
);
2769 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2770 QDIO_DBF_HEX0(0,setup
,&init_data
->input_handler
,sizeof(void*));
2771 QDIO_DBF_HEX0(0,setup
,&init_data
->output_handler
,sizeof(void*));
2772 QDIO_DBF_HEX0(0,setup
,&init_data
->int_parm
,sizeof(long));
2773 QDIO_DBF_HEX0(0,setup
,&init_data
->flags
,sizeof(long));
2774 QDIO_DBF_HEX0(0,setup
,&init_data
->input_sbal_addr_array
,sizeof(void*));
2775 QDIO_DBF_HEX0(0,setup
,&init_data
->output_sbal_addr_array
,sizeof(void*));
2779 qdio_allocate_fill_input_desc(struct qdio_irq
*irq_ptr
, int i
, int iqfmt
)
2781 irq_ptr
->input_qs
[i
]->is_iqdio_q
= iqfmt
;
2782 irq_ptr
->input_qs
[i
]->is_thinint_q
= irq_ptr
->is_thinint_irq
;
2784 irq_ptr
->qdr
->qdf0
[i
].sliba
=(unsigned long)(irq_ptr
->input_qs
[i
]->slib
);
2786 irq_ptr
->qdr
->qdf0
[i
].sla
=(unsigned long)(irq_ptr
->input_qs
[i
]->sl
);
2788 irq_ptr
->qdr
->qdf0
[i
].slsba
=
2789 (unsigned long)(&irq_ptr
->input_qs
[i
]->slsb
.acc
.val
[0]);
2791 irq_ptr
->qdr
->qdf0
[i
].akey
=QDIO_STORAGE_KEY
;
2792 irq_ptr
->qdr
->qdf0
[i
].bkey
=QDIO_STORAGE_KEY
;
2793 irq_ptr
->qdr
->qdf0
[i
].ckey
=QDIO_STORAGE_KEY
;
2794 irq_ptr
->qdr
->qdf0
[i
].dkey
=QDIO_STORAGE_KEY
;
2798 qdio_allocate_fill_output_desc(struct qdio_irq
*irq_ptr
, int i
,
2801 irq_ptr
->output_qs
[i
]->is_iqdio_q
= iqfmt
;
2802 irq_ptr
->output_qs
[i
]->is_thinint_q
= irq_ptr
->is_thinint_irq
;
2804 irq_ptr
->qdr
->qdf0
[i
+j
].sliba
=(unsigned long)(irq_ptr
->output_qs
[i
]->slib
);
2806 irq_ptr
->qdr
->qdf0
[i
+j
].sla
=(unsigned long)(irq_ptr
->output_qs
[i
]->sl
);
2808 irq_ptr
->qdr
->qdf0
[i
+j
].slsba
=
2809 (unsigned long)(&irq_ptr
->output_qs
[i
]->slsb
.acc
.val
[0]);
2811 irq_ptr
->qdr
->qdf0
[i
+j
].akey
=QDIO_STORAGE_KEY
;
2812 irq_ptr
->qdr
->qdf0
[i
+j
].bkey
=QDIO_STORAGE_KEY
;
2813 irq_ptr
->qdr
->qdf0
[i
+j
].ckey
=QDIO_STORAGE_KEY
;
2814 irq_ptr
->qdr
->qdf0
[i
+j
].dkey
=QDIO_STORAGE_KEY
;
2819 qdio_initialize_set_siga_flags_input(struct qdio_irq
*irq_ptr
)
2823 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
2824 irq_ptr
->input_qs
[i
]->siga_sync
=
2825 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_NECESSARY
;
2826 irq_ptr
->input_qs
[i
]->siga_in
=
2827 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_INPUT_NECESSARY
;
2828 irq_ptr
->input_qs
[i
]->siga_out
=
2829 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_OUTPUT_NECESSARY
;
2830 irq_ptr
->input_qs
[i
]->siga_sync_done_on_thinints
=
2831 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
;
2832 irq_ptr
->input_qs
[i
]->hydra_gives_outbound_pcis
=
2833 irq_ptr
->hydra_gives_outbound_pcis
;
2834 irq_ptr
->input_qs
[i
]->siga_sync_done_on_outb_tis
=
2836 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2837 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
))==
2838 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2839 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
));
2845 qdio_initialize_set_siga_flags_output(struct qdio_irq
*irq_ptr
)
2849 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
2850 irq_ptr
->output_qs
[i
]->siga_sync
=
2851 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_NECESSARY
;
2852 irq_ptr
->output_qs
[i
]->siga_in
=
2853 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_INPUT_NECESSARY
;
2854 irq_ptr
->output_qs
[i
]->siga_out
=
2855 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_OUTPUT_NECESSARY
;
2856 irq_ptr
->output_qs
[i
]->siga_sync_done_on_thinints
=
2857 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
;
2858 irq_ptr
->output_qs
[i
]->hydra_gives_outbound_pcis
=
2859 irq_ptr
->hydra_gives_outbound_pcis
;
2860 irq_ptr
->output_qs
[i
]->siga_sync_done_on_outb_tis
=
2862 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2863 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
))==
2864 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2865 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
));
2871 qdio_establish_irq_check_for_errors(struct ccw_device
*cdev
, int cstat
,
2875 struct qdio_irq
*irq_ptr
;
2877 irq_ptr
= cdev
->private->qdio_data
;
2879 if (cstat
|| (dstat
& ~(DEV_STAT_CHN_END
|DEV_STAT_DEV_END
))) {
2880 sprintf(dbf_text
,"ick1%4x",irq_ptr
->schid
.sch_no
);
2881 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
2882 QDIO_DBF_HEX2(0,trace
,&dstat
,sizeof(int));
2883 QDIO_DBF_HEX2(0,trace
,&cstat
,sizeof(int));
2884 QDIO_PRINT_ERR("received check condition on establish " \
2885 "queues on irq 0.%x.%x (cs=x%x, ds=x%x).\n",
2886 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
2888 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_ERR
);
2891 if (!(dstat
& DEV_STAT_DEV_END
)) {
2892 QDIO_DBF_TEXT2(1,setup
,"eq:no de");
2893 QDIO_DBF_HEX2(0,setup
,&dstat
, sizeof(dstat
));
2894 QDIO_DBF_HEX2(0,setup
,&cstat
, sizeof(cstat
));
2895 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: didn't get "
2896 "device end: dstat=%02x, cstat=%02x\n",
2897 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
2899 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2903 if (dstat
& ~(DEV_STAT_CHN_END
|DEV_STAT_DEV_END
)) {
2904 QDIO_DBF_TEXT2(1,setup
,"eq:badio");
2905 QDIO_DBF_HEX2(0,setup
,&dstat
, sizeof(dstat
));
2906 QDIO_DBF_HEX2(0,setup
,&cstat
, sizeof(cstat
));
2907 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: got "
2908 "the following devstat: dstat=%02x, "
2909 "cstat=%02x\n", irq_ptr
->schid
.ssid
,
2910 irq_ptr
->schid
.sch_no
, dstat
, cstat
);
2911 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2918 qdio_establish_handle_irq(struct ccw_device
*cdev
, int cstat
, int dstat
)
2920 struct qdio_irq
*irq_ptr
;
2923 irq_ptr
= cdev
->private->qdio_data
;
2925 sprintf(dbf_text
,"qehi%4x",cdev
->private->sch_no
);
2926 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2927 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
2929 if (qdio_establish_irq_check_for_errors(cdev
, cstat
, dstat
)) {
2930 ccw_device_set_timeout(cdev
, 0);
2934 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_ESTABLISHED
);
2935 ccw_device_set_timeout(cdev
, 0);
2939 qdio_initialize(struct qdio_initialize
*init_data
)
2944 sprintf(dbf_text
,"qini%4x",init_data
->cdev
->private->sch_no
);
2945 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2946 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
2948 rc
= qdio_allocate(init_data
);
2950 rc
= qdio_establish(init_data
);
2952 qdio_free(init_data
->cdev
);
2960 qdio_allocate(struct qdio_initialize
*init_data
)
2962 struct qdio_irq
*irq_ptr
;
2965 sprintf(dbf_text
,"qalc%4x",init_data
->cdev
->private->sch_no
);
2966 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2967 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
2968 if ( (init_data
->no_input_qs
>QDIO_MAX_QUEUES_PER_IRQ
) ||
2969 (init_data
->no_output_qs
>QDIO_MAX_QUEUES_PER_IRQ
) ||
2970 ((init_data
->no_input_qs
) && (!init_data
->input_handler
)) ||
2971 ((init_data
->no_output_qs
) && (!init_data
->output_handler
)) )
2974 if (!init_data
->input_sbal_addr_array
)
2977 if (!init_data
->output_sbal_addr_array
)
2980 qdio_allocate_do_dbf(init_data
);
2983 irq_ptr
= kzalloc(sizeof(struct qdio_irq
), GFP_KERNEL
| GFP_DMA
);
2985 QDIO_DBF_TEXT0(0,setup
,"irq_ptr:");
2986 QDIO_DBF_HEX0(0,setup
,&irq_ptr
,sizeof(void*));
2989 QDIO_PRINT_ERR("kmalloc of irq_ptr failed!\n");
2993 init_MUTEX(&irq_ptr
->setting_up_sema
);
2995 /* QDR must be in DMA area since CCW data address is only 32 bit */
2996 irq_ptr
->qdr
=kmalloc(sizeof(struct qdr
), GFP_KERNEL
| GFP_DMA
);
2997 if (!(irq_ptr
->qdr
)) {
2999 QDIO_PRINT_ERR("kmalloc of irq_ptr->qdr failed!\n");
3002 QDIO_DBF_TEXT0(0,setup
,"qdr:");
3003 QDIO_DBF_HEX0(0,setup
,&irq_ptr
->qdr
,sizeof(void*));
3005 if (qdio_alloc_qs(irq_ptr
,
3006 init_data
->no_input_qs
,
3007 init_data
->no_output_qs
)) {
3008 qdio_release_irq_memory(irq_ptr
);
3012 init_data
->cdev
->private->qdio_data
= irq_ptr
;
3014 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_INACTIVE
);
3019 int qdio_fill_irq(struct qdio_initialize
*init_data
)
3025 struct qdio_irq
*irq_ptr
;
3027 irq_ptr
= init_data
->cdev
->private->qdio_data
;
3029 memset(irq_ptr
,0,((char*)&irq_ptr
->qdr
)-((char*)irq_ptr
));
3031 /* wipes qib.ac, required by ar7063 */
3032 memset(irq_ptr
->qdr
,0,sizeof(struct qdr
));
3034 irq_ptr
->int_parm
=init_data
->int_parm
;
3036 irq_ptr
->schid
= ccw_device_get_subchannel_id(init_data
->cdev
);
3037 irq_ptr
->no_input_qs
=init_data
->no_input_qs
;
3038 irq_ptr
->no_output_qs
=init_data
->no_output_qs
;
3040 if (init_data
->q_format
==QDIO_IQDIO_QFMT
) {
3041 irq_ptr
->is_iqdio_irq
=1;
3042 irq_ptr
->is_thinint_irq
=1;
3044 irq_ptr
->is_iqdio_irq
=0;
3045 irq_ptr
->is_thinint_irq
=hydra_thinints
;
3047 sprintf(dbf_text
,"is_i_t%1x%1x",
3048 irq_ptr
->is_iqdio_irq
,irq_ptr
->is_thinint_irq
);
3049 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3051 if (irq_ptr
->is_thinint_irq
) {
3052 irq_ptr
->dev_st_chg_ind
= qdio_get_indicator();
3053 QDIO_DBF_HEX1(0,setup
,&irq_ptr
->dev_st_chg_ind
,sizeof(void*));
3054 if (!irq_ptr
->dev_st_chg_ind
) {
3055 QDIO_PRINT_WARN("no indicator location available " \
3056 "for irq 0.%x.%x\n",
3057 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
3058 qdio_release_irq_memory(irq_ptr
);
3064 irq_ptr
->equeue
.cmd
=DEFAULT_ESTABLISH_QS_CMD
;
3065 irq_ptr
->equeue
.count
=DEFAULT_ESTABLISH_QS_COUNT
;
3066 irq_ptr
->aqueue
.cmd
=DEFAULT_ACTIVATE_QS_CMD
;
3067 irq_ptr
->aqueue
.count
=DEFAULT_ACTIVATE_QS_COUNT
;
3069 qdio_fill_qs(irq_ptr
, init_data
->cdev
,
3070 init_data
->no_input_qs
,
3071 init_data
->no_output_qs
,
3072 init_data
->input_handler
,
3073 init_data
->output_handler
,init_data
->int_parm
,
3074 init_data
->q_format
,init_data
->flags
,
3075 init_data
->input_sbal_addr_array
,
3076 init_data
->output_sbal_addr_array
);
3078 if (!try_module_get(THIS_MODULE
)) {
3079 QDIO_PRINT_CRIT("try_module_get() failed!\n");
3080 qdio_release_irq_memory(irq_ptr
);
3084 qdio_fill_thresholds(irq_ptr
,init_data
->no_input_qs
,
3085 init_data
->no_output_qs
,
3086 init_data
->min_input_threshold
,
3087 init_data
->max_input_threshold
,
3088 init_data
->min_output_threshold
,
3089 init_data
->max_output_threshold
);
3092 irq_ptr
->qdr
->qfmt
=init_data
->q_format
;
3093 irq_ptr
->qdr
->iqdcnt
=init_data
->no_input_qs
;
3094 irq_ptr
->qdr
->oqdcnt
=init_data
->no_output_qs
;
3095 irq_ptr
->qdr
->iqdsz
=sizeof(struct qdesfmt0
)/4; /* size in words */
3096 irq_ptr
->qdr
->oqdsz
=sizeof(struct qdesfmt0
)/4;
3098 irq_ptr
->qdr
->qiba
=(unsigned long)&irq_ptr
->qib
;
3099 irq_ptr
->qdr
->qkey
=QDIO_STORAGE_KEY
;
3102 irq_ptr
->is_qebsm
= is_passthrough
;
3103 if (irq_ptr
->is_qebsm
)
3104 irq_ptr
->qib
.rflags
|= QIB_RFLAGS_ENABLE_QEBSM
;
3106 irq_ptr
->qib
.qfmt
=init_data
->q_format
;
3107 if (init_data
->no_input_qs
)
3108 irq_ptr
->qib
.isliba
=(unsigned long)(irq_ptr
->input_qs
[0]->slib
);
3109 if (init_data
->no_output_qs
)
3110 irq_ptr
->qib
.osliba
=(unsigned long)(irq_ptr
->output_qs
[0]->slib
);
3111 memcpy(irq_ptr
->qib
.ebcnam
,init_data
->adapter_name
,8);
3113 qdio_set_impl_params(irq_ptr
,init_data
->qib_param_field_format
,
3114 init_data
->qib_param_field
,
3115 init_data
->no_input_qs
,
3116 init_data
->no_output_qs
,
3117 init_data
->input_slib_elements
,
3118 init_data
->output_slib_elements
);
3120 /* first input descriptors, then output descriptors */
3121 is_iqdio
= (init_data
->q_format
== QDIO_IQDIO_QFMT
) ? 1 : 0;
3122 for (i
=0;i
<init_data
->no_input_qs
;i
++)
3123 qdio_allocate_fill_input_desc(irq_ptr
, i
, is_iqdio
);
3125 for (i
=0;i
<init_data
->no_output_qs
;i
++)
3126 qdio_allocate_fill_output_desc(irq_ptr
, i
,
3127 init_data
->no_input_qs
,
3130 /* qdr, qib, sls, slsbs, slibs, sbales filled. */
3132 /* get qdio commands */
3133 ciw
= ccw_device_get_ciw(init_data
->cdev
, CIW_TYPE_EQUEUE
);
3135 QDIO_DBF_TEXT2(1,setup
,"no eq");
3136 QDIO_PRINT_INFO("No equeue CIW found for QDIO commands. "
3137 "Trying to use default.\n");
3139 irq_ptr
->equeue
= *ciw
;
3140 ciw
= ccw_device_get_ciw(init_data
->cdev
, CIW_TYPE_AQUEUE
);
3142 QDIO_DBF_TEXT2(1,setup
,"no aq");
3143 QDIO_PRINT_INFO("No aqueue CIW found for QDIO commands. "
3144 "Trying to use default.\n");
3146 irq_ptr
->aqueue
= *ciw
;
3148 /* Set new interrupt handler. */
3149 irq_ptr
->original_int_handler
= init_data
->cdev
->handler
;
3150 init_data
->cdev
->handler
= qdio_handler
;
3156 qdio_establish(struct qdio_initialize
*init_data
)
3158 struct qdio_irq
*irq_ptr
;
3159 unsigned long saveflags
;
3160 int result
, result2
;
3161 struct ccw_device
*cdev
;
3164 cdev
=init_data
->cdev
;
3165 irq_ptr
= cdev
->private->qdio_data
;
3169 if (cdev
->private->state
!= DEV_STATE_ONLINE
)
3172 down(&irq_ptr
->setting_up_sema
);
3174 qdio_fill_irq(init_data
);
3176 /* the thinint CHSC stuff */
3177 if (irq_ptr
->is_thinint_irq
) {
3179 result
= tiqdio_set_subchannel_ind(irq_ptr
,0);
3181 up(&irq_ptr
->setting_up_sema
);
3182 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
3185 tiqdio_set_delay_target(irq_ptr
,TIQDIO_DELAY_TARGET
);
3188 sprintf(dbf_text
,"qest%4x",cdev
->private->sch_no
);
3189 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
3190 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
3193 irq_ptr
->ccw
.cmd_code
=irq_ptr
->equeue
.cmd
;
3194 irq_ptr
->ccw
.flags
=CCW_FLAG_SLI
;
3195 irq_ptr
->ccw
.count
=irq_ptr
->equeue
.count
;
3196 irq_ptr
->ccw
.cda
=QDIO_GET_ADDR(irq_ptr
->qdr
);
3198 spin_lock_irqsave(get_ccwdev_lock(cdev
),saveflags
);
3200 ccw_device_set_options(cdev
, 0);
3201 result
=ccw_device_start_timeout(cdev
,&irq_ptr
->ccw
,
3202 QDIO_DOING_ESTABLISH
,0, 0,
3203 QDIO_ESTABLISH_TIMEOUT
);
3205 result2
=ccw_device_start_timeout(cdev
,&irq_ptr
->ccw
,
3206 QDIO_DOING_ESTABLISH
,0,0,
3207 QDIO_ESTABLISH_TIMEOUT
);
3208 sprintf(dbf_text
,"eq:io%4x",result
);
3209 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3211 sprintf(dbf_text
,"eq:io%4x",result
);
3212 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3214 QDIO_PRINT_WARN("establish queues on irq 0.%x.%04x: do_IO " \
3215 "returned %i, next try returned %i\n",
3216 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
3220 ccw_device_set_timeout(cdev
, 0);
3223 spin_unlock_irqrestore(get_ccwdev_lock(cdev
),saveflags
);
3226 up(&irq_ptr
->setting_up_sema
);
3227 qdio_shutdown(cdev
,QDIO_FLAG_CLEANUP_USING_CLEAR
);
3231 /* Timeout is cared for already by using ccw_device_start_timeout(). */
3232 wait_event_interruptible(cdev
->private->wait_q
,
3233 irq_ptr
->state
== QDIO_IRQ_STATE_ESTABLISHED
||
3234 irq_ptr
->state
== QDIO_IRQ_STATE_ERR
);
3236 if (irq_ptr
->state
== QDIO_IRQ_STATE_ESTABLISHED
)
3239 up(&irq_ptr
->setting_up_sema
);
3240 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
3244 qdio_get_ssqd_information(irq_ptr
);
3245 /* if this gets set once, we're running under VM and can omit SVSes */
3246 if (irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_NECESSARY
)
3249 sprintf(dbf_text
,"qdioac%2x",irq_ptr
->qdioac
);
3250 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3252 sprintf(dbf_text
,"qib ac%2x",irq_ptr
->qib
.ac
);
3253 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3255 irq_ptr
->hydra_gives_outbound_pcis
=
3256 irq_ptr
->qib
.ac
&QIB_AC_OUTBOUND_PCI_SUPPORTED
;
3257 irq_ptr
->sync_done_on_outb_pcis
=
3258 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
;
3260 qdio_initialize_set_siga_flags_input(irq_ptr
);
3261 qdio_initialize_set_siga_flags_output(irq_ptr
);
3263 up(&irq_ptr
->setting_up_sema
);
3270 qdio_activate(struct ccw_device
*cdev
, int flags
)
3272 struct qdio_irq
*irq_ptr
;
3273 int i
,result
=0,result2
;
3274 unsigned long saveflags
;
3275 char dbf_text
[20]; /* see qdio_initialize */
3277 irq_ptr
= cdev
->private->qdio_data
;
3281 if (cdev
->private->state
!= DEV_STATE_ONLINE
)
3284 down(&irq_ptr
->setting_up_sema
);
3285 if (irq_ptr
->state
==QDIO_IRQ_STATE_INACTIVE
) {
3290 sprintf(dbf_text
,"qact%4x", irq_ptr
->schid
.sch_no
);
3291 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3292 QDIO_DBF_TEXT2(0,trace
,dbf_text
);
3295 irq_ptr
->ccw
.cmd_code
=irq_ptr
->aqueue
.cmd
;
3296 irq_ptr
->ccw
.flags
=CCW_FLAG_SLI
;
3297 irq_ptr
->ccw
.count
=irq_ptr
->aqueue
.count
;
3298 irq_ptr
->ccw
.cda
=QDIO_GET_ADDR(0);
3300 spin_lock_irqsave(get_ccwdev_lock(cdev
),saveflags
);
3302 ccw_device_set_timeout(cdev
, 0);
3303 ccw_device_set_options(cdev
, CCWDEV_REPORT_ALL
);
3304 result
=ccw_device_start(cdev
,&irq_ptr
->ccw
,QDIO_DOING_ACTIVATE
,
3305 0, DOIO_DENY_PREFETCH
);
3307 result2
=ccw_device_start(cdev
,&irq_ptr
->ccw
,
3308 QDIO_DOING_ACTIVATE
,0,0);
3309 sprintf(dbf_text
,"aq:io%4x",result
);
3310 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3312 sprintf(dbf_text
,"aq:io%4x",result
);
3313 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3315 QDIO_PRINT_WARN("activate queues on irq 0.%x.%04x: do_IO " \
3316 "returned %i, next try returned %i\n",
3317 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
3322 spin_unlock_irqrestore(get_ccwdev_lock(cdev
),saveflags
);
3326 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
3327 if (irq_ptr
->is_thinint_irq
) {
3329 * that way we know, that, if we will get interrupted
3330 * by tiqdio_inbound_processing, qdio_unmark_q will
3333 qdio_reserve_q(irq_ptr
->input_qs
[i
]);
3334 qdio_mark_tiq(irq_ptr
->input_qs
[i
]);
3335 qdio_release_q(irq_ptr
->input_qs
[i
]);
3339 if (flags
&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT
) {
3340 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
3341 irq_ptr
->input_qs
[i
]->is_input_q
|=
3342 QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT
;
3346 wait_event_interruptible_timeout(cdev
->private->wait_q
,
3348 QDIO_IRQ_STATE_STOPPED
) ||
3350 QDIO_IRQ_STATE_ERR
)),
3351 QDIO_ACTIVATE_TIMEOUT
);
3353 switch (irq_ptr
->state
) {
3354 case QDIO_IRQ_STATE_STOPPED
:
3355 case QDIO_IRQ_STATE_ERR
:
3356 up(&irq_ptr
->setting_up_sema
);
3357 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
3358 down(&irq_ptr
->setting_up_sema
);
3362 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ACTIVE
);
3366 up(&irq_ptr
->setting_up_sema
);
3371 /* buffers filled forwards again to make Rick happy */
3373 qdio_do_qdio_fill_input(struct qdio_q
*q
, unsigned int qidx
,
3374 unsigned int count
, struct qdio_buffer
*buffers
)
3376 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
3377 qidx
&= (QDIO_MAX_BUFFERS_PER_Q
- 1);
3378 if (irq
->is_qebsm
) {
3380 set_slsb(q
, &qidx
, SLSB_CU_INPUT_EMPTY
, &count
);
3384 set_slsb(q
, &qidx
, SLSB_CU_INPUT_EMPTY
, &count
);
3387 qidx
= (qidx
+ 1) & (QDIO_MAX_BUFFERS_PER_Q
- 1);
3392 qdio_do_qdio_fill_output(struct qdio_q
*q
, unsigned int qidx
,
3393 unsigned int count
, struct qdio_buffer
*buffers
)
3395 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
3397 qidx
&= (QDIO_MAX_BUFFERS_PER_Q
- 1);
3398 if (irq
->is_qebsm
) {
3400 set_slsb(q
, &qidx
, SLSB_CU_OUTPUT_PRIMED
, &count
);
3405 set_slsb(q
, &qidx
, SLSB_CU_OUTPUT_PRIMED
, &count
);
3408 qidx
= (qidx
+ 1) & (QDIO_MAX_BUFFERS_PER_Q
- 1);
3413 do_qdio_handle_inbound(struct qdio_q
*q
, unsigned int callflags
,
3414 unsigned int qidx
, unsigned int count
,
3415 struct qdio_buffer
*buffers
)
3419 /* This is the inbound handling of queues */
3420 used_elements
=atomic_add_return(count
, &q
->number_of_buffers_used
) - count
;
3422 qdio_do_qdio_fill_input(q
,qidx
,count
,buffers
);
3424 if ((used_elements
+count
==QDIO_MAX_BUFFERS_PER_Q
)&&
3425 (callflags
&QDIO_FLAG_UNDER_INTERRUPT
))
3426 atomic_swap(&q
->polling
,0);
3430 if (callflags
&QDIO_FLAG_DONT_SIGA
)
3435 result
=qdio_siga_input(q
);
3438 q
->error_status_flags
|=
3439 QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR
;
3440 q
->error_status_flags
|=QDIO_STATUS_LOOK_FOR_ERROR
;
3441 q
->siga_error
=result
;
3449 do_qdio_handle_outbound(struct qdio_q
*q
, unsigned int callflags
,
3450 unsigned int qidx
, unsigned int count
,
3451 struct qdio_buffer
*buffers
)
3454 unsigned int cnt
, start_buf
;
3455 unsigned char state
= 0;
3456 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
3458 /* This is the outbound handling of queues */
3459 #ifdef QDIO_PERFORMANCE_STATS
3460 perf_stats
.start_time_outbound
=NOW
;
3461 #endif /* QDIO_PERFORMANCE_STATS */
3463 qdio_do_qdio_fill_output(q
,qidx
,count
,buffers
);
3465 used_elements
=atomic_add_return(count
, &q
->number_of_buffers_used
) - count
;
3467 if (callflags
&QDIO_FLAG_DONT_SIGA
) {
3468 #ifdef QDIO_PERFORMANCE_STATS
3469 perf_stats
.outbound_time
+=NOW
-perf_stats
.start_time_outbound
;
3470 perf_stats
.outbound_cnt
++;
3471 #endif /* QDIO_PERFORMANCE_STATS */
3474 if (q
->is_iqdio_q
) {
3475 /* one siga for every sbal */
3477 qdio_kick_outbound_q(q
);
3479 __qdio_outbound_processing(q
);
3481 /* under VM, we do a SIGA sync unconditionally */
3485 * w/o shadow queues (else branch of
3486 * SYNC_MEMORY :-/ ), we try to
3487 * fast-requeue buffers
3489 if (irq
->is_qebsm
) {
3491 start_buf
= ((qidx
+QDIO_MAX_BUFFERS_PER_Q
-1) &
3492 (QDIO_MAX_BUFFERS_PER_Q
-1));
3493 qdio_do_eqbs(q
, &state
, &start_buf
, &cnt
);
3495 state
= q
->slsb
.acc
.val
[(qidx
+QDIO_MAX_BUFFERS_PER_Q
-1)
3496 &(QDIO_MAX_BUFFERS_PER_Q
-1) ];
3497 if (state
!= SLSB_CU_OUTPUT_PRIMED
) {
3498 qdio_kick_outbound_q(q
);
3500 QDIO_DBF_TEXT3(0,trace
, "fast-req");
3501 #ifdef QDIO_PERFORMANCE_STATS
3502 perf_stats
.fast_reqs
++;
3503 #endif /* QDIO_PERFORMANCE_STATS */
3507 * only marking the q could take too long,
3508 * the upper layer module could do a lot of
3509 * traffic in that time
3511 __qdio_outbound_processing(q
);
3514 #ifdef QDIO_PERFORMANCE_STATS
3515 perf_stats
.outbound_time
+=NOW
-perf_stats
.start_time_outbound
;
3516 perf_stats
.outbound_cnt
++;
3517 #endif /* QDIO_PERFORMANCE_STATS */
3520 /* count must be 1 in iqdio */
3522 do_QDIO(struct ccw_device
*cdev
,unsigned int callflags
,
3523 unsigned int queue_number
, unsigned int qidx
,
3524 unsigned int count
,struct qdio_buffer
*buffers
)
3526 struct qdio_irq
*irq_ptr
;
3527 #ifdef CONFIG_QDIO_DEBUG
3530 sprintf(dbf_text
,"doQD%04x",cdev
->private->sch_no
);
3531 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
3532 #endif /* CONFIG_QDIO_DEBUG */
3534 if ( (qidx
>QDIO_MAX_BUFFERS_PER_Q
) ||
3535 (count
>QDIO_MAX_BUFFERS_PER_Q
) ||
3536 (queue_number
>QDIO_MAX_QUEUES_PER_IRQ
) )
3542 irq_ptr
= cdev
->private->qdio_data
;
3546 #ifdef CONFIG_QDIO_DEBUG
3547 if (callflags
&QDIO_FLAG_SYNC_INPUT
)
3548 QDIO_DBF_HEX3(0,trace
,&irq_ptr
->input_qs
[queue_number
],
3551 QDIO_DBF_HEX3(0,trace
,&irq_ptr
->output_qs
[queue_number
],
3553 sprintf(dbf_text
,"flag%04x",callflags
);
3554 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
3555 sprintf(dbf_text
,"qi%02xct%02x",qidx
,count
);
3556 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
3557 #endif /* CONFIG_QDIO_DEBUG */
3559 if (irq_ptr
->state
!=QDIO_IRQ_STATE_ACTIVE
)
3562 if (callflags
&QDIO_FLAG_SYNC_INPUT
)
3563 do_qdio_handle_inbound(irq_ptr
->input_qs
[queue_number
],
3564 callflags
, qidx
, count
, buffers
);
3565 else if (callflags
&QDIO_FLAG_SYNC_OUTPUT
)
3566 do_qdio_handle_outbound(irq_ptr
->output_qs
[queue_number
],
3567 callflags
, qidx
, count
, buffers
);
3569 QDIO_DBF_TEXT3(1,trace
,"doQD:inv");
3575 #ifdef QDIO_PERFORMANCE_STATS
3577 qdio_perf_procfile_read(char *buffer
, char **buffer_location
, off_t offset
,
3578 int buffer_length
, int *eof
, void *data
)
3582 /* we are always called with buffer_length=4k, so we all
3583 deliver on the first read */
3587 #define _OUTP_IT(x...) c+=sprintf(buffer+c,x)
3588 _OUTP_IT("i_p_nc/c=%lu/%lu\n",i_p_nc
,i_p_c
);
3589 _OUTP_IT("ii_p_nc/c=%lu/%lu\n",ii_p_nc
,ii_p_c
);
3590 _OUTP_IT("o_p_nc/c=%lu/%lu\n",o_p_nc
,o_p_c
);
3591 _OUTP_IT("Number of tasklet runs (total) : %u\n",
3592 perf_stats
.tl_runs
);
3594 _OUTP_IT("Number of SIGA sync's issued : %u\n",
3595 perf_stats
.siga_syncs
);
3596 _OUTP_IT("Number of SIGA in's issued : %u\n",
3597 perf_stats
.siga_ins
);
3598 _OUTP_IT("Number of SIGA out's issued : %u\n",
3599 perf_stats
.siga_outs
);
3600 _OUTP_IT("Number of PCIs caught : %u\n",
3602 _OUTP_IT("Number of adapter interrupts caught : %u\n",
3603 perf_stats
.thinints
);
3604 _OUTP_IT("Number of fast requeues (outg. SBALs w/o SIGA) : %u\n",
3605 perf_stats
.fast_reqs
);
3607 _OUTP_IT("Total time of all inbound actions (us) incl. UL : %u\n",
3608 perf_stats
.inbound_time
);
3609 _OUTP_IT("Number of inbound transfers : %u\n",
3610 perf_stats
.inbound_cnt
);
3611 _OUTP_IT("Total time of all outbound do_QDIOs (us) : %u\n",
3612 perf_stats
.outbound_time
);
3613 _OUTP_IT("Number of do_QDIOs outbound : %u\n",
3614 perf_stats
.outbound_cnt
);
3620 static struct proc_dir_entry
*qdio_perf_proc_file
;
3621 #endif /* QDIO_PERFORMANCE_STATS */
3624 qdio_add_procfs_entry(void)
3626 #ifdef QDIO_PERFORMANCE_STATS
3627 proc_perf_file_registration
=0;
3628 qdio_perf_proc_file
=create_proc_entry(QDIO_PERF
,
3629 S_IFREG
|0444,&proc_root
);
3630 if (qdio_perf_proc_file
) {
3631 qdio_perf_proc_file
->read_proc
=&qdio_perf_procfile_read
;
3632 } else proc_perf_file_registration
=-1;
3634 if (proc_perf_file_registration
)
3635 QDIO_PRINT_WARN("was not able to register perf. " \
3636 "proc-file (%i).\n",
3637 proc_perf_file_registration
);
3638 #endif /* QDIO_PERFORMANCE_STATS */
3642 qdio_remove_procfs_entry(void)
3644 #ifdef QDIO_PERFORMANCE_STATS
3645 perf_stats
.tl_runs
=0;
3647 if (!proc_perf_file_registration
) /* means if it went ok earlier */
3648 remove_proc_entry(QDIO_PERF
,&proc_root
);
3649 #endif /* QDIO_PERFORMANCE_STATS */
3653 tiqdio_register_thinints(void)
3656 register_thinint_result
=
3657 s390_register_adapter_interrupt(&tiqdio_thinint_handler
);
3658 if (register_thinint_result
) {
3659 sprintf(dbf_text
,"regthn%x",(register_thinint_result
&0xff));
3660 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
3661 QDIO_PRINT_ERR("failed to register adapter handler " \
3662 "(rc=%i).\nAdapter interrupts might " \
3663 "not work. Continuing.\n",
3664 register_thinint_result
);
3669 tiqdio_unregister_thinints(void)
3671 if (!register_thinint_result
)
3672 s390_unregister_adapter_interrupt(&tiqdio_thinint_handler
);
3676 qdio_get_qdio_memory(void)
3679 indicator_used
[0]=1;
3681 for (i
=1;i
<INDICATORS_PER_CACHELINE
;i
++)
3682 indicator_used
[i
]=0;
3683 indicators
= kzalloc(sizeof(__u32
)*(INDICATORS_PER_CACHELINE
),
3691 qdio_release_qdio_memory(void)
3697 qdio_unregister_dbf_views(void)
3700 debug_unregister(qdio_dbf_setup
);
3702 debug_unregister(qdio_dbf_sbal
);
3704 debug_unregister(qdio_dbf_sense
);
3706 debug_unregister(qdio_dbf_trace
);
3707 #ifdef CONFIG_QDIO_DEBUG
3708 if (qdio_dbf_slsb_out
)
3709 debug_unregister(qdio_dbf_slsb_out
);
3710 if (qdio_dbf_slsb_in
)
3711 debug_unregister(qdio_dbf_slsb_in
);
3712 #endif /* CONFIG_QDIO_DEBUG */
3716 qdio_register_dbf_views(void)
3718 qdio_dbf_setup
=debug_register(QDIO_DBF_SETUP_NAME
,
3719 QDIO_DBF_SETUP_PAGES
,
3720 QDIO_DBF_SETUP_NR_AREAS
,
3721 QDIO_DBF_SETUP_LEN
);
3722 if (!qdio_dbf_setup
)
3724 debug_register_view(qdio_dbf_setup
,&debug_hex_ascii_view
);
3725 debug_set_level(qdio_dbf_setup
,QDIO_DBF_SETUP_LEVEL
);
3727 qdio_dbf_sbal
=debug_register(QDIO_DBF_SBAL_NAME
,
3728 QDIO_DBF_SBAL_PAGES
,
3729 QDIO_DBF_SBAL_NR_AREAS
,
3734 debug_register_view(qdio_dbf_sbal
,&debug_hex_ascii_view
);
3735 debug_set_level(qdio_dbf_sbal
,QDIO_DBF_SBAL_LEVEL
);
3737 qdio_dbf_sense
=debug_register(QDIO_DBF_SENSE_NAME
,
3738 QDIO_DBF_SENSE_PAGES
,
3739 QDIO_DBF_SENSE_NR_AREAS
,
3740 QDIO_DBF_SENSE_LEN
);
3741 if (!qdio_dbf_sense
)
3744 debug_register_view(qdio_dbf_sense
,&debug_hex_ascii_view
);
3745 debug_set_level(qdio_dbf_sense
,QDIO_DBF_SENSE_LEVEL
);
3747 qdio_dbf_trace
=debug_register(QDIO_DBF_TRACE_NAME
,
3748 QDIO_DBF_TRACE_PAGES
,
3749 QDIO_DBF_TRACE_NR_AREAS
,
3750 QDIO_DBF_TRACE_LEN
);
3751 if (!qdio_dbf_trace
)
3754 debug_register_view(qdio_dbf_trace
,&debug_hex_ascii_view
);
3755 debug_set_level(qdio_dbf_trace
,QDIO_DBF_TRACE_LEVEL
);
3757 #ifdef CONFIG_QDIO_DEBUG
3758 qdio_dbf_slsb_out
=debug_register(QDIO_DBF_SLSB_OUT_NAME
,
3759 QDIO_DBF_SLSB_OUT_PAGES
,
3760 QDIO_DBF_SLSB_OUT_NR_AREAS
,
3761 QDIO_DBF_SLSB_OUT_LEN
);
3762 if (!qdio_dbf_slsb_out
)
3764 debug_register_view(qdio_dbf_slsb_out
,&debug_hex_ascii_view
);
3765 debug_set_level(qdio_dbf_slsb_out
,QDIO_DBF_SLSB_OUT_LEVEL
);
3767 qdio_dbf_slsb_in
=debug_register(QDIO_DBF_SLSB_IN_NAME
,
3768 QDIO_DBF_SLSB_IN_PAGES
,
3769 QDIO_DBF_SLSB_IN_NR_AREAS
,
3770 QDIO_DBF_SLSB_IN_LEN
);
3771 if (!qdio_dbf_slsb_in
)
3773 debug_register_view(qdio_dbf_slsb_in
,&debug_hex_ascii_view
);
3774 debug_set_level(qdio_dbf_slsb_in
,QDIO_DBF_SLSB_IN_LEVEL
);
3775 #endif /* CONFIG_QDIO_DEBUG */
3778 QDIO_PRINT_ERR("not enough memory for dbf.\n");
3779 qdio_unregister_dbf_views();
3787 #ifdef QDIO_PERFORMANCE_STATS
3789 #endif /* QDIO_PERFORMANCE_STATS */
3791 printk("qdio: loading %s\n",version
);
3793 res
=qdio_get_qdio_memory();
3797 res
= qdio_register_dbf_views();
3801 QDIO_DBF_TEXT0(0,setup
,"initQDIO");
3803 #ifdef QDIO_PERFORMANCE_STATS
3804 memset((void*)&perf_stats
,0,sizeof(perf_stats
));
3805 QDIO_DBF_TEXT0(0,setup
,"perfstat");
3807 QDIO_DBF_HEX0(0,setup
,&ptr
,sizeof(void*));
3808 #endif /* QDIO_PERFORMANCE_STATS */
3810 qdio_add_procfs_entry();
3812 if (tiqdio_check_chsc_availability())
3813 QDIO_PRINT_ERR("Not all CHSCs supported. Continuing.\n");
3815 tiqdio_register_thinints();
3823 tiqdio_unregister_thinints();
3824 qdio_remove_procfs_entry();
3825 qdio_release_qdio_memory();
3826 qdio_unregister_dbf_views();
3828 printk("qdio: %s: module removed\n",version
);
3831 module_init(init_QDIO
);
3832 module_exit(cleanup_QDIO
);
3834 EXPORT_SYMBOL(qdio_allocate
);
3835 EXPORT_SYMBOL(qdio_establish
);
3836 EXPORT_SYMBOL(qdio_initialize
);
3837 EXPORT_SYMBOL(qdio_activate
);
3838 EXPORT_SYMBOL(do_QDIO
);
3839 EXPORT_SYMBOL(qdio_shutdown
);
3840 EXPORT_SYMBOL(qdio_free
);
3841 EXPORT_SYMBOL(qdio_cleanup
);
3842 EXPORT_SYMBOL(qdio_synchronize
);