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/module.h>
34 #include <linux/init.h>
36 #include <linux/slab.h>
37 #include <linux/kernel.h>
38 #include <linux/proc_fs.h>
39 #include <linux/timer.h>
40 #include <linux/mempool.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
;
83 #define QDIO_MEMPOOL_SCSSC_ELEMENTS 2
84 static mempool_t
*qdio_mempool_scssc
;
86 static debug_info_t
*qdio_dbf_setup
;
87 static debug_info_t
*qdio_dbf_sbal
;
88 static debug_info_t
*qdio_dbf_trace
;
89 static debug_info_t
*qdio_dbf_sense
;
90 #ifdef CONFIG_QDIO_DEBUG
91 static debug_info_t
*qdio_dbf_slsb_out
;
92 static debug_info_t
*qdio_dbf_slsb_in
;
93 #endif /* CONFIG_QDIO_DEBUG */
96 static volatile struct qdio_q
*tiq_list
=NULL
; /* volatile as it could change
97 during a while loop */
98 static DEFINE_SPINLOCK(ttiq_list_lock
);
99 static int register_thinint_result
;
100 static void tiqdio_tl(unsigned long);
101 static DECLARE_TASKLET(tiqdio_tasklet
,tiqdio_tl
,0);
103 /* not a macro, as one of the arguments is atomic_read */
105 qdio_min(int a
,int b
)
113 /***************** SCRUBBER HELPER ROUTINES **********************/
116 qdio_get_micros(void)
118 return (get_clock() >> 12); /* time>>12 is microseconds */
122 * unfortunately, we can't just xchg the values; in do_QDIO we want to reserve
123 * the q in any case, so that we'll not be interrupted when we are in
124 * qdio_mark_tiq... shouldn't have a really bad impact, as reserving almost
125 * ever works (last famous words)
128 qdio_reserve_q(struct qdio_q
*q
)
130 return atomic_add_return(1,&q
->use_count
) - 1;
134 qdio_release_q(struct qdio_q
*q
)
136 atomic_dec(&q
->use_count
);
141 qdio_check_ccq(struct qdio_q
*q
, unsigned int ccq
)
145 if (ccq
== 0 || ccq
== 32 || ccq
== 96)
149 /*notify devices immediately*/
150 sprintf(dbf_text
,"%d", ccq
);
151 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
154 /* EQBS: extract buffer states */
156 qdio_do_eqbs(struct qdio_q
*q
, unsigned char *state
,
157 unsigned int *start
, unsigned int *cnt
)
159 struct qdio_irq
*irq
;
160 unsigned int tmp_cnt
, q_no
, ccq
;
166 irq
= (struct qdio_irq
*)q
->irq_ptr
;
169 q_no
+= irq
->no_input_qs
;
171 ccq
= do_eqbs(irq
->sch_token
, state
, q_no
, start
, cnt
);
172 rc
= qdio_check_ccq(q
, ccq
);
174 QDIO_DBF_TEXT5(1,trace
,"eqAGAIN");
178 QDIO_DBF_TEXT2(1,trace
,"eqberr");
179 sprintf(dbf_text
,"%2x,%2x,%d,%d",tmp_cnt
, *cnt
, ccq
, q_no
);
180 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
181 q
->handler(q
->cdev
,QDIO_STATUS_ACTIVATE_CHECK_CONDITION
|
182 QDIO_STATUS_LOOK_FOR_ERROR
,
183 0, 0, 0, -1, -1, q
->int_parm
);
186 return (tmp_cnt
- *cnt
);
189 /* SQBS: set buffer states */
191 qdio_do_sqbs(struct qdio_q
*q
, unsigned char state
,
192 unsigned int *start
, unsigned int *cnt
)
194 struct qdio_irq
*irq
;
195 unsigned int tmp_cnt
, q_no
, ccq
;
201 irq
= (struct qdio_irq
*)q
->irq_ptr
;
204 q_no
+= irq
->no_input_qs
;
206 ccq
= do_sqbs(irq
->sch_token
, state
, q_no
, start
, cnt
);
207 rc
= qdio_check_ccq(q
, ccq
);
209 QDIO_DBF_TEXT5(1,trace
,"sqAGAIN");
213 QDIO_DBF_TEXT3(1,trace
,"sqberr");
214 sprintf(dbf_text
,"%2x,%2x,%d,%d",tmp_cnt
,*cnt
,ccq
,q_no
);
215 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
216 q
->handler(q
->cdev
,QDIO_STATUS_ACTIVATE_CHECK_CONDITION
|
217 QDIO_STATUS_LOOK_FOR_ERROR
,
218 0, 0, 0, -1, -1, q
->int_parm
);
221 return (tmp_cnt
- *cnt
);
225 qdio_set_slsb(struct qdio_q
*q
, unsigned int *bufno
,
226 unsigned char state
, unsigned int *count
)
229 struct qdio_irq
*irq
;
231 irq
= (struct qdio_irq
*)q
->irq_ptr
;
232 if (!irq
->is_qebsm
) {
233 slsb
= (char *)&q
->slsb
.acc
.val
[(*bufno
)];
237 return qdio_do_sqbs(q
, state
, bufno
, count
);
240 #ifdef CONFIG_QDIO_DEBUG
242 qdio_trace_slsb(struct qdio_q
*q
)
244 if (q
->queue_type
==QDIO_TRACE_QTYPE
) {
246 QDIO_DBF_HEX2(0,slsb_in
,&q
->slsb
,
247 QDIO_MAX_BUFFERS_PER_Q
);
249 QDIO_DBF_HEX2(0,slsb_out
,&q
->slsb
,
250 QDIO_MAX_BUFFERS_PER_Q
);
256 set_slsb(struct qdio_q
*q
, unsigned int *bufno
,
257 unsigned char state
, unsigned int *count
)
260 #ifdef CONFIG_QDIO_DEBUG
263 rc
= qdio_set_slsb(q
, bufno
, state
, count
);
264 #ifdef CONFIG_QDIO_DEBUG
270 qdio_siga_sync(struct qdio_q
*q
, unsigned int gpr2
,
275 QDIO_DBF_TEXT4(0,trace
,"sigasync");
276 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
278 #ifdef QDIO_PERFORMANCE_STATS
279 perf_stats
.siga_syncs
++;
280 #endif /* QDIO_PERFORMANCE_STATS */
282 cc
= do_siga_sync(q
->schid
, gpr2
, gpr3
);
284 QDIO_DBF_HEX3(0,trace
,&cc
,sizeof(int*));
290 qdio_siga_sync_q(struct qdio_q
*q
)
293 return qdio_siga_sync(q
, 0, q
->mask
);
294 return qdio_siga_sync(q
, q
->mask
, 0);
298 __do_siga_output(struct qdio_q
*q
, unsigned int *busy_bit
)
300 struct qdio_irq
*irq
;
304 irq
= (struct qdio_irq
*) q
->irq_ptr
;
306 schid
= *((u32
*)&q
->schid
);
308 schid
= irq
->sch_token
;
311 return do_siga_output(schid
, q
->mask
, busy_bit
, fc
);
315 * returns QDIO_SIGA_ERROR_ACCESS_EXCEPTION as cc, when SIGA returns
316 * an access exception
319 qdio_siga_output(struct qdio_q
*q
)
325 #ifdef QDIO_PERFORMANCE_STATS
326 perf_stats
.siga_outs
++;
327 #endif /* QDIO_PERFORMANCE_STATS */
329 QDIO_DBF_TEXT4(0,trace
,"sigaout");
330 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
333 cc
= __do_siga_output(q
, &busy_bit
);
334 //QDIO_PRINT_ERR("cc=%x, busy=%x\n",cc,busy_bit);
335 if ((cc
==2) && (busy_bit
) && (q
->is_iqdio_q
)) {
338 if ((NOW
-start_time
)>QDIO_BUSY_BIT_PATIENCE
)
344 if ((cc
==2) && (busy_bit
))
345 cc
|= QDIO_SIGA_ERROR_B_BIT_SET
;
348 QDIO_DBF_HEX3(0,trace
,&cc
,sizeof(int*));
354 qdio_siga_input(struct qdio_q
*q
)
358 QDIO_DBF_TEXT4(0,trace
,"sigain");
359 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
361 #ifdef QDIO_PERFORMANCE_STATS
362 perf_stats
.siga_ins
++;
363 #endif /* QDIO_PERFORMANCE_STATS */
365 cc
= do_siga_input(q
->schid
, q
->mask
);
368 QDIO_DBF_HEX3(0,trace
,&cc
,sizeof(int*));
373 /* locked by the locks in qdio_activate and qdio_cleanup */
375 qdio_get_indicator(void)
379 for (i
=1;i
<INDICATORS_PER_CACHELINE
;i
++)
380 if (!indicator_used
[i
]) {
384 atomic_inc(&spare_indicator_usecount
);
385 return (__u32
* volatile) &spare_indicator
;
388 /* locked by the locks in qdio_activate and qdio_cleanup */
390 qdio_put_indicator(__u32
*addr
)
394 if ( (addr
) && (addr
!=&spare_indicator
) ) {
398 if (addr
== &spare_indicator
)
399 atomic_dec(&spare_indicator_usecount
);
403 tiqdio_clear_summary_bit(__u32
*location
)
405 QDIO_DBF_TEXT5(0,trace
,"clrsummb");
406 QDIO_DBF_HEX5(0,trace
,&location
,sizeof(void*));
412 tiqdio_set_summary_bit(__u32
*location
)
414 QDIO_DBF_TEXT5(0,trace
,"setsummb");
415 QDIO_DBF_HEX5(0,trace
,&location
,sizeof(void*));
421 tiqdio_sched_tl(void)
423 tasklet_hi_schedule(&tiqdio_tasklet
);
427 qdio_mark_tiq(struct qdio_q
*q
)
431 QDIO_DBF_TEXT4(0,trace
,"mark iq");
432 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
434 spin_lock_irqsave(&ttiq_list_lock
,flags
);
435 if (unlikely(atomic_read(&q
->is_in_shutdown
)))
441 if ((q
->list_prev
) || (q
->list_next
))
449 q
->list_next
=tiq_list
;
450 q
->list_prev
=tiq_list
->list_prev
;
451 tiq_list
->list_prev
->list_next
=q
;
452 tiq_list
->list_prev
=q
;
454 spin_unlock_irqrestore(&ttiq_list_lock
,flags
);
456 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
460 spin_unlock_irqrestore(&ttiq_list_lock
,flags
);
465 qdio_mark_q(struct qdio_q
*q
)
467 QDIO_DBF_TEXT4(0,trace
,"mark q");
468 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
470 if (unlikely(atomic_read(&q
->is_in_shutdown
)))
473 tasklet_schedule(&q
->tasklet
);
477 qdio_stop_polling(struct qdio_q
*q
)
479 #ifdef QDIO_USE_PROCESSING_STATE
480 unsigned int tmp
, gsf
, count
= 1;
481 unsigned char state
= 0;
482 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
484 if (!atomic_swap(&q
->polling
,0))
487 QDIO_DBF_TEXT4(0,trace
,"stoppoll");
488 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
490 /* show the card that we are not polling anymore */
494 tmp
= gsf
= GET_SAVED_FRONTIER(q
);
495 tmp
= ((tmp
+ QDIO_MAX_BUFFERS_PER_Q
-1) & (QDIO_MAX_BUFFERS_PER_Q
-1) );
496 set_slsb(q
, &tmp
, SLSB_P_INPUT_NOT_INIT
, &count
);
499 * we don't issue this SYNC_MEMORY, as we trust Rick T and
500 * moreover will not use the PROCESSING state under VM, so
501 * q->polling was 0 anyway
506 qdio_do_eqbs(q
, &state
, &gsf
, &count
);
508 state
= q
->slsb
.acc
.val
[gsf
];
509 if (state
!= SLSB_P_INPUT_PRIMED
)
512 * set our summary bit again, as otherwise there is a
513 * small window we can miss between resetting it and
514 * checking for PRIMED state
517 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
520 #else /* QDIO_USE_PROCESSING_STATE */
522 #endif /* QDIO_USE_PROCESSING_STATE */
526 * see the comment in do_QDIO and before qdio_reserve_q about the
527 * sophisticated locking outside of unmark_q, so that we don't need to
528 * disable the interrupts :-)
531 qdio_unmark_q(struct qdio_q
*q
)
535 QDIO_DBF_TEXT4(0,trace
,"unmark q");
536 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
538 if ((!q
->list_prev
)||(!q
->list_next
))
541 if ((q
->is_thinint_q
)&&(q
->is_input_q
)) {
543 spin_lock_irqsave(&ttiq_list_lock
,flags
);
544 /* in case cleanup has done this already and simultanously
545 * qdio_unmark_q is called from the interrupt handler, we've
546 * got to check this in this specific case again */
547 if ((!q
->list_prev
)||(!q
->list_next
))
549 if (q
->list_next
==q
) {
550 /* q was the only interesting q */
555 q
->list_next
->list_prev
=q
->list_prev
;
556 q
->list_prev
->list_next
=q
->list_next
;
557 tiq_list
=q
->list_next
;
562 spin_unlock_irqrestore(&ttiq_list_lock
,flags
);
566 static inline unsigned long
567 tiqdio_clear_global_summary(void)
571 QDIO_DBF_TEXT5(0,trace
,"clrglobl");
573 time
= do_clear_global_summary();
575 QDIO_DBF_HEX5(0,trace
,&time
,sizeof(unsigned long));
581 /************************* OUTBOUND ROUTINES *******************************/
583 qdio_qebsm_get_outbound_buffer_frontier(struct qdio_q
*q
)
585 struct qdio_irq
*irq
;
587 unsigned int cnt
, count
, ftc
;
589 irq
= (struct qdio_irq
*) q
->irq_ptr
;
590 if ((!q
->is_iqdio_q
) && (!q
->hydra_gives_outbound_pcis
))
593 ftc
= q
->first_to_check
;
594 count
= qdio_min(atomic_read(&q
->number_of_buffers_used
),
595 (QDIO_MAX_BUFFERS_PER_Q
-1));
597 return q
->first_to_check
;
598 cnt
= qdio_do_eqbs(q
, &state
, &ftc
, &count
);
600 return q
->first_to_check
;
602 case SLSB_P_OUTPUT_ERROR
:
603 QDIO_DBF_TEXT3(0,trace
,"outperr");
604 atomic_sub(cnt
, &q
->number_of_buffers_used
);
606 q
->error_status_flags
|=
607 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
608 q
->qdio_error
= SLSB_P_OUTPUT_ERROR
;
609 q
->error_status_flags
|= QDIO_STATUS_LOOK_FOR_ERROR
;
610 q
->first_to_check
= ftc
;
612 case SLSB_P_OUTPUT_EMPTY
:
613 QDIO_DBF_TEXT5(0,trace
,"outpempt");
614 atomic_sub(cnt
, &q
->number_of_buffers_used
);
615 q
->first_to_check
= ftc
;
617 case SLSB_CU_OUTPUT_PRIMED
:
618 /* all buffers primed */
619 QDIO_DBF_TEXT5(0,trace
,"outpprim");
624 QDIO_DBF_HEX4(0,trace
,&q
->first_to_check
,sizeof(int));
625 return q
->first_to_check
;
629 qdio_qebsm_get_inbound_buffer_frontier(struct qdio_q
*q
)
631 struct qdio_irq
*irq
;
633 int tmp
, ftc
, count
, cnt
;
637 irq
= (struct qdio_irq
*) q
->irq_ptr
;
638 ftc
= q
->first_to_check
;
639 count
= qdio_min(atomic_read(&q
->number_of_buffers_used
),
640 (QDIO_MAX_BUFFERS_PER_Q
-1));
642 return q
->first_to_check
;
643 cnt
= qdio_do_eqbs(q
, &state
, &ftc
, &count
);
645 return q
->first_to_check
;
647 case SLSB_P_INPUT_ERROR
:
648 #ifdef CONFIG_QDIO_DEBUG
649 QDIO_DBF_TEXT3(1,trace
,"inperr");
650 sprintf(dbf_text
,"%2x,%2x",ftc
,count
);
651 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
652 #endif /* CONFIG_QDIO_DEBUG */
654 q
->error_status_flags
|=
655 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
656 q
->qdio_error
= SLSB_P_INPUT_ERROR
;
657 q
->error_status_flags
|= QDIO_STATUS_LOOK_FOR_ERROR
;
658 atomic_sub(cnt
, &q
->number_of_buffers_used
);
659 q
->first_to_check
= ftc
;
661 case SLSB_P_INPUT_PRIMED
:
662 QDIO_DBF_TEXT3(0,trace
,"inptprim");
663 sprintf(dbf_text
,"%2x,%2x",ftc
,count
);
664 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
666 ftc
= q
->first_to_check
;
667 #ifdef QDIO_USE_PROCESSING_STATE
670 tmp
= set_slsb(q
, &ftc
, SLSB_P_INPUT_NOT_INIT
, &cnt
);
675 tmp
+= set_slsb(q
, &ftc
,
676 SLSB_P_INPUT_PROCESSING
, &cnt
);
677 atomic_set(&q
->polling
, 1);
679 tmp
= set_slsb(q
, &ftc
, SLSB_P_INPUT_NOT_INIT
, &cnt
);
681 atomic_sub(tmp
, &q
->number_of_buffers_used
);
682 q
->first_to_check
= ftc
;
684 case SLSB_CU_INPUT_EMPTY
:
685 case SLSB_P_INPUT_NOT_INIT
:
686 case SLSB_P_INPUT_PROCESSING
:
687 QDIO_DBF_TEXT5(0,trace
,"inpnipro");
692 QDIO_DBF_HEX4(0,trace
,&q
->first_to_check
,sizeof(int));
693 return q
->first_to_check
;
697 qdio_get_outbound_buffer_frontier(struct qdio_q
*q
)
699 struct qdio_irq
*irq
;
701 unsigned int count
= 1;
702 int first_not_to_check
, f
, f_mod_no
;
705 QDIO_DBF_TEXT4(0,trace
,"getobfro");
706 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
708 irq
= (struct qdio_irq
*) q
->irq_ptr
;
710 return qdio_qebsm_get_outbound_buffer_frontier(q
);
712 slsb
=&q
->slsb
.acc
.val
[0];
713 f_mod_no
=f
=q
->first_to_check
;
715 * f points to already processed elements, so f+no_used is correct...
716 * ... but: we don't check 128 buffers, as otherwise
717 * qdio_has_outbound_q_moved would return 0
719 first_not_to_check
=f
+qdio_min(atomic_read(&q
->number_of_buffers_used
),
720 (QDIO_MAX_BUFFERS_PER_Q
-1));
722 if ((!q
->is_iqdio_q
)&&(!q
->hydra_gives_outbound_pcis
))
726 if (f
==first_not_to_check
)
729 switch(slsb
[f_mod_no
]) {
731 /* the adapter has not fetched the output yet */
732 case SLSB_CU_OUTPUT_PRIMED
:
733 QDIO_DBF_TEXT5(0,trace
,"outpprim");
736 /* the adapter got it */
737 case SLSB_P_OUTPUT_EMPTY
:
738 atomic_dec(&q
->number_of_buffers_used
);
740 f_mod_no
=f
&(QDIO_MAX_BUFFERS_PER_Q
-1);
741 QDIO_DBF_TEXT5(0,trace
,"outpempt");
744 case SLSB_P_OUTPUT_ERROR
:
745 QDIO_DBF_TEXT3(0,trace
,"outperr");
746 sprintf(dbf_text
,"%x-%x-%x",f_mod_no
,
747 q
->sbal
[f_mod_no
]->element
[14].sbalf
.value
,
748 q
->sbal
[f_mod_no
]->element
[15].sbalf
.value
);
749 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
750 QDIO_DBF_HEX2(1,sbal
,q
->sbal
[f_mod_no
],256);
752 /* kind of process the buffer */
753 set_slsb(q
, &f_mod_no
, SLSB_P_OUTPUT_NOT_INIT
, &count
);
756 * we increment the frontier, as this buffer
757 * was processed obviously
759 atomic_dec(&q
->number_of_buffers_used
);
760 f_mod_no
=(f_mod_no
+1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
763 q
->error_status_flags
|=
764 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
765 q
->qdio_error
=SLSB_P_OUTPUT_ERROR
;
766 q
->error_status_flags
|=QDIO_STATUS_LOOK_FOR_ERROR
;
772 QDIO_DBF_TEXT5(0,trace
,"outpni");
775 return (q
->first_to_check
=f_mod_no
);
778 /* all buffers are processed */
780 qdio_is_outbound_q_done(struct qdio_q
*q
)
783 #ifdef CONFIG_QDIO_DEBUG
787 no_used
=atomic_read(&q
->number_of_buffers_used
);
789 #ifdef CONFIG_QDIO_DEBUG
791 sprintf(dbf_text
,"oqisnt%02x",no_used
);
792 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
794 QDIO_DBF_TEXT4(0,trace
,"oqisdone");
796 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
797 #endif /* CONFIG_QDIO_DEBUG */
802 qdio_has_outbound_q_moved(struct qdio_q
*q
)
806 i
=qdio_get_outbound_buffer_frontier(q
);
808 if ( (i
!=GET_SAVED_FRONTIER(q
)) ||
809 (q
->error_status_flags
&QDIO_STATUS_LOOK_FOR_ERROR
) ) {
811 QDIO_DBF_TEXT4(0,trace
,"oqhasmvd");
812 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
815 QDIO_DBF_TEXT4(0,trace
,"oqhsntmv");
816 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
822 qdio_kick_outbound_q(struct qdio_q
*q
)
825 #ifdef CONFIG_QDIO_DEBUG
828 QDIO_DBF_TEXT4(0,trace
,"kickoutq");
829 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
830 #endif /* CONFIG_QDIO_DEBUG */
835 /* here's the story with cc=2 and busy bit set (thanks, Rick):
836 * VM's CP could present us cc=2 and busy bit set on SIGA-write
837 * during reconfiguration of their Guest LAN (only in HIPERS mode,
838 * QDIO mode is asynchronous -- cc=2 and busy bit there will take
839 * the queues down immediately; and not being under VM we have a
840 * problem on cc=2 and busy bit set right away).
842 * Therefore qdio_siga_output will try for a short time constantly,
843 * if such a condition occurs. If it doesn't change, it will
844 * increase the busy_siga_counter and save the timestamp, and
845 * schedule the queue for later processing (via mark_q, using the
846 * queue tasklet). __qdio_outbound_processing will check out the
847 * counter. If non-zero, it will call qdio_kick_outbound_q as often
848 * as the value of the counter. This will attempt further SIGA
849 * instructions. For each successful SIGA, the counter is
850 * decreased, for failing SIGAs the counter remains the same, after
852 * After some time of no movement, qdio_kick_outbound_q will
853 * finally fail and reflect corresponding error codes to call
854 * the upper layer module and have it take the queues down.
856 * Note that this is a change from the original HiperSockets design
857 * (saying cc=2 and busy bit means take the queues down), but in
858 * these days Guest LAN didn't exist... excessive cc=2 with busy bit
859 * conditions will still take the queues down, but the threshold is
860 * higher due to the Guest LAN environment.
864 result
=qdio_siga_output(q
);
868 /* went smooth this time, reset timestamp */
869 #ifdef CONFIG_QDIO_DEBUG
870 QDIO_DBF_TEXT3(0,trace
,"cc2reslv");
871 sprintf(dbf_text
,"%4x%2x%2x",q
->schid
.sch_no
,q
->q_no
,
872 atomic_read(&q
->busy_siga_counter
));
873 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
874 #endif /* CONFIG_QDIO_DEBUG */
875 q
->timing
.busy_start
=0;
877 case (2|QDIO_SIGA_ERROR_B_BIT_SET
):
878 /* cc=2 and busy bit: */
879 atomic_inc(&q
->busy_siga_counter
);
881 /* if the last siga was successful, save
883 if (!q
->timing
.busy_start
)
884 q
->timing
.busy_start
=NOW
;
886 /* if we're in time, don't touch error_status_flags
888 if (NOW
-q
->timing
.busy_start
<QDIO_BUSY_BIT_GIVE_UP
) {
892 QDIO_DBF_TEXT2(0,trace
,"cc2REPRT");
893 #ifdef CONFIG_QDIO_DEBUG
894 sprintf(dbf_text
,"%4x%2x%2x",q
->schid
.sch_no
,q
->q_no
,
895 atomic_read(&q
->busy_siga_counter
));
896 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
897 #endif /* CONFIG_QDIO_DEBUG */
898 /* else fallthrough and report error */
900 /* for plain cc=1, 2 or 3: */
902 q
->error_status_flags
|=
903 QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR
;
904 q
->error_status_flags
|=
905 QDIO_STATUS_LOOK_FOR_ERROR
;
906 q
->siga_error
=result
;
911 qdio_kick_outbound_handler(struct qdio_q
*q
)
913 int start
, end
, real_end
, count
;
914 #ifdef CONFIG_QDIO_DEBUG
918 start
= q
->first_element_to_kick
;
919 /* last_move_ftc was just updated */
920 real_end
= GET_SAVED_FRONTIER(q
);
921 end
= (real_end
+QDIO_MAX_BUFFERS_PER_Q
-1)&
922 (QDIO_MAX_BUFFERS_PER_Q
-1);
923 count
= (end
+QDIO_MAX_BUFFERS_PER_Q
+1-start
)&
924 (QDIO_MAX_BUFFERS_PER_Q
-1);
926 #ifdef CONFIG_QDIO_DEBUG
927 QDIO_DBF_TEXT4(0,trace
,"kickouth");
928 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
930 sprintf(dbf_text
,"s=%2xc=%2x",start
,count
);
931 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
932 #endif /* CONFIG_QDIO_DEBUG */
934 if (q
->state
==QDIO_IRQ_STATE_ACTIVE
)
935 q
->handler(q
->cdev
,QDIO_STATUS_OUTBOUND_INT
|
936 q
->error_status_flags
,
937 q
->qdio_error
,q
->siga_error
,q
->q_no
,start
,count
,
940 /* for the next time: */
941 q
->first_element_to_kick
=real_end
;
944 q
->error_status_flags
=0;
948 __qdio_outbound_processing(struct qdio_q
*q
)
952 QDIO_DBF_TEXT4(0,trace
,"qoutproc");
953 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
955 if (unlikely(qdio_reserve_q(q
))) {
957 #ifdef QDIO_PERFORMANCE_STATS
959 #endif /* QDIO_PERFORMANCE_STATS */
960 /* as we're sissies, we'll check next time */
961 if (likely(!atomic_read(&q
->is_in_shutdown
))) {
963 QDIO_DBF_TEXT4(0,trace
,"busy,agn");
967 #ifdef QDIO_PERFORMANCE_STATS
969 perf_stats
.tl_runs
++;
970 #endif /* QDIO_PERFORMANCE_STATS */
972 /* see comment in qdio_kick_outbound_q */
973 siga_attempts
=atomic_read(&q
->busy_siga_counter
);
974 while (siga_attempts
) {
975 atomic_dec(&q
->busy_siga_counter
);
976 qdio_kick_outbound_q(q
);
980 if (qdio_has_outbound_q_moved(q
))
981 qdio_kick_outbound_handler(q
);
985 * for asynchronous queues, we better check, if the fill
986 * level is too high. for synchronous queues, the fill
987 * level will never be that high.
989 if (atomic_read(&q
->number_of_buffers_used
)>
990 IQDIO_FILL_LEVEL_TO_POLL
)
993 } else if (!q
->hydra_gives_outbound_pcis
)
994 if (!qdio_is_outbound_q_done(q
))
1001 qdio_outbound_processing(struct qdio_q
*q
)
1003 __qdio_outbound_processing(q
);
1006 /************************* INBOUND ROUTINES *******************************/
1010 qdio_get_inbound_buffer_frontier(struct qdio_q
*q
)
1012 struct qdio_irq
*irq
;
1014 volatile char *slsb
;
1015 unsigned int count
= 1;
1016 int first_not_to_check
;
1017 #ifdef CONFIG_QDIO_DEBUG
1019 #endif /* CONFIG_QDIO_DEBUG */
1020 #ifdef QDIO_USE_PROCESSING_STATE
1021 int last_position
=-1;
1022 #endif /* QDIO_USE_PROCESSING_STATE */
1024 QDIO_DBF_TEXT4(0,trace
,"getibfro");
1025 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1027 irq
= (struct qdio_irq
*) q
->irq_ptr
;
1029 return qdio_qebsm_get_inbound_buffer_frontier(q
);
1031 slsb
=&q
->slsb
.acc
.val
[0];
1032 f_mod_no
=f
=q
->first_to_check
;
1034 * we don't check 128 buffers, as otherwise qdio_has_inbound_q_moved
1037 first_not_to_check
=f
+qdio_min(atomic_read(&q
->number_of_buffers_used
),
1038 (QDIO_MAX_BUFFERS_PER_Q
-1));
1041 * we don't use this one, as a PCI or we after a thin interrupt
1042 * will sync the queues
1047 f_mod_no
=f
&(QDIO_MAX_BUFFERS_PER_Q
-1);
1048 if (f
==first_not_to_check
)
1050 switch (slsb
[f_mod_no
]) {
1052 /* CU_EMPTY means frontier is reached */
1053 case SLSB_CU_INPUT_EMPTY
:
1054 QDIO_DBF_TEXT5(0,trace
,"inptempt");
1057 /* P_PRIMED means set slsb to P_PROCESSING and move on */
1058 case SLSB_P_INPUT_PRIMED
:
1059 QDIO_DBF_TEXT5(0,trace
,"inptprim");
1061 #ifdef QDIO_USE_PROCESSING_STATE
1063 * as soon as running under VM, polling the input queues will
1064 * kill VM in terms of CP overhead
1067 set_slsb(q
, &f_mod_no
, SLSB_P_INPUT_NOT_INIT
, &count
);
1069 /* set the previous buffer to NOT_INIT. The current
1070 * buffer will be set to PROCESSING at the end of
1071 * this function to avoid further interrupts. */
1072 if (last_position
>=0)
1073 set_slsb(q
, &last_position
,
1074 SLSB_P_INPUT_NOT_INIT
, &count
);
1075 atomic_set(&q
->polling
,1);
1076 last_position
=f_mod_no
;
1078 #else /* QDIO_USE_PROCESSING_STATE */
1079 set_slsb(q
, &f_mod_no
, SLSB_P_INPUT_NOT_INIT
, &count
);
1080 #endif /* QDIO_USE_PROCESSING_STATE */
1082 * not needed, as the inbound queue will be synced on the next
1083 * siga-r, resp. tiqdio_is_inbound_q_done will do the siga-s
1087 atomic_dec(&q
->number_of_buffers_used
);
1090 case SLSB_P_INPUT_NOT_INIT
:
1091 case SLSB_P_INPUT_PROCESSING
:
1092 QDIO_DBF_TEXT5(0,trace
,"inpnipro");
1095 /* P_ERROR means frontier is reached, break and report error */
1096 case SLSB_P_INPUT_ERROR
:
1097 #ifdef CONFIG_QDIO_DEBUG
1098 sprintf(dbf_text
,"inperr%2x",f_mod_no
);
1099 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
1100 #endif /* CONFIG_QDIO_DEBUG */
1101 QDIO_DBF_HEX2(1,sbal
,q
->sbal
[f_mod_no
],256);
1103 /* kind of process the buffer */
1104 set_slsb(q
, &f_mod_no
, SLSB_P_INPUT_NOT_INIT
, &count
);
1107 q
->error_status_flags
|=
1108 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
1109 q
->qdio_error
=SLSB_P_INPUT_ERROR
;
1110 q
->error_status_flags
|=QDIO_STATUS_LOOK_FOR_ERROR
;
1112 /* we increment the frontier, as this buffer
1113 * was processed obviously */
1114 f_mod_no
=(f_mod_no
+1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
1115 atomic_dec(&q
->number_of_buffers_used
);
1117 #ifdef QDIO_USE_PROCESSING_STATE
1119 #endif /* QDIO_USE_PROCESSING_STATE */
1123 /* everything else means frontier not changed (HALTED or so) */
1128 q
->first_to_check
=f_mod_no
;
1130 #ifdef QDIO_USE_PROCESSING_STATE
1131 if (last_position
>=0)
1132 set_slsb(q
, &last_position
, SLSB_P_INPUT_PROCESSING
, &count
);
1133 #endif /* QDIO_USE_PROCESSING_STATE */
1135 QDIO_DBF_HEX4(0,trace
,&q
->first_to_check
,sizeof(int));
1137 return q
->first_to_check
;
1141 qdio_has_inbound_q_moved(struct qdio_q
*q
)
1145 #ifdef QDIO_PERFORMANCE_STATS
1146 static int old_pcis
=0;
1147 static int old_thinints
=0;
1149 if ((old_pcis
==perf_stats
.pcis
)&&(old_thinints
==perf_stats
.thinints
))
1150 perf_stats
.start_time_inbound
=NOW
;
1152 old_pcis
=perf_stats
.pcis
;
1153 #endif /* QDIO_PERFORMANCE_STATS */
1155 i
=qdio_get_inbound_buffer_frontier(q
);
1156 if ( (i
!=GET_SAVED_FRONTIER(q
)) ||
1157 (q
->error_status_flags
&QDIO_STATUS_LOOK_FOR_ERROR
) ) {
1159 if ((!q
->siga_sync
)&&(!q
->hydra_gives_outbound_pcis
))
1162 QDIO_DBF_TEXT4(0,trace
,"inhasmvd");
1163 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1166 QDIO_DBF_TEXT4(0,trace
,"inhsntmv");
1167 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1172 /* means, no more buffers to be filled */
1174 tiqdio_is_inbound_q_done(struct qdio_q
*q
)
1177 unsigned int start_buf
, count
;
1178 unsigned char state
= 0;
1179 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
1181 #ifdef CONFIG_QDIO_DEBUG
1185 no_used
=atomic_read(&q
->number_of_buffers_used
);
1187 /* propagate the change from 82 to 80 through VM */
1190 #ifdef CONFIG_QDIO_DEBUG
1192 sprintf(dbf_text
,"iqisnt%02x",no_used
);
1193 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1195 QDIO_DBF_TEXT4(0,trace
,"iniqisdo");
1197 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1198 #endif /* CONFIG_QDIO_DEBUG */
1202 if (!q
->siga_sync
&& !irq
->is_qebsm
)
1203 /* we'll check for more primed buffers in qeth_stop_polling */
1205 if (irq
->is_qebsm
) {
1207 start_buf
= q
->first_to_check
;
1208 qdio_do_eqbs(q
, &state
, &start_buf
, &count
);
1210 state
= q
->slsb
.acc
.val
[q
->first_to_check
];
1211 if (state
!= SLSB_P_INPUT_PRIMED
)
1213 * nothing more to do, if next buffer is not PRIMED.
1214 * note that we did a SYNC_MEMORY before, that there
1215 * has been a sychnronization.
1216 * we will return 0 below, as there is nothing to do
1217 * (stop_polling not necessary, as we have not been
1218 * using the PROCESSING state
1223 * ok, the next input buffer is primed. that means, that device state
1224 * change indicator and adapter local summary are set, so we will find
1226 * we will return 0 below, as there is nothing to do, except scheduling
1227 * ourselves for the next time.
1229 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1235 qdio_is_inbound_q_done(struct qdio_q
*q
)
1238 unsigned int start_buf
, count
;
1239 unsigned char state
= 0;
1240 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
1242 #ifdef CONFIG_QDIO_DEBUG
1246 no_used
=atomic_read(&q
->number_of_buffers_used
);
1249 * we need that one for synchronization with the adapter, as it
1250 * does a kind of PCI avoidance
1255 QDIO_DBF_TEXT4(0,trace
,"inqisdnA");
1256 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1257 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1260 if (irq
->is_qebsm
) {
1262 start_buf
= q
->first_to_check
;
1263 qdio_do_eqbs(q
, &state
, &start_buf
, &count
);
1265 state
= q
->slsb
.acc
.val
[q
->first_to_check
];
1266 if (state
== SLSB_P_INPUT_PRIMED
) {
1267 /* we got something to do */
1268 QDIO_DBF_TEXT4(0,trace
,"inqisntA");
1269 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1273 /* on VM, we don't poll, so the q is always done here */
1276 if (q
->hydra_gives_outbound_pcis
)
1280 * at this point we know, that inbound first_to_check
1281 * has (probably) not moved (see qdio_inbound_processing)
1283 if (NOW
>GET_SAVED_TIMESTAMP(q
)+q
->timing
.threshold
) {
1284 #ifdef CONFIG_QDIO_DEBUG
1285 QDIO_DBF_TEXT4(0,trace
,"inqisdon");
1286 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1287 sprintf(dbf_text
,"pf%02xcn%02x",q
->first_to_check
,no_used
);
1288 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1289 #endif /* CONFIG_QDIO_DEBUG */
1292 #ifdef CONFIG_QDIO_DEBUG
1293 QDIO_DBF_TEXT4(0,trace
,"inqisntd");
1294 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1295 sprintf(dbf_text
,"pf%02xcn%02x",q
->first_to_check
,no_used
);
1296 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1297 #endif /* CONFIG_QDIO_DEBUG */
1303 qdio_kick_inbound_handler(struct qdio_q
*q
)
1305 int count
, start
, end
, real_end
, i
;
1306 #ifdef CONFIG_QDIO_DEBUG
1310 QDIO_DBF_TEXT4(0,trace
,"kickinh");
1311 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1313 start
=q
->first_element_to_kick
;
1314 real_end
=q
->first_to_check
;
1315 end
=(real_end
+QDIO_MAX_BUFFERS_PER_Q
-1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
1323 i
=(i
+1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
1326 #ifdef CONFIG_QDIO_DEBUG
1327 sprintf(dbf_text
,"s=%2xc=%2x",start
,count
);
1328 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1329 #endif /* CONFIG_QDIO_DEBUG */
1331 if (likely(q
->state
==QDIO_IRQ_STATE_ACTIVE
))
1333 QDIO_STATUS_INBOUND_INT
|q
->error_status_flags
,
1334 q
->qdio_error
,q
->siga_error
,q
->q_no
,start
,count
,
1337 /* for the next time: */
1338 q
->first_element_to_kick
=real_end
;
1341 q
->error_status_flags
=0;
1343 #ifdef QDIO_PERFORMANCE_STATS
1344 perf_stats
.inbound_time
+=NOW
-perf_stats
.start_time_inbound
;
1345 perf_stats
.inbound_cnt
++;
1346 #endif /* QDIO_PERFORMANCE_STATS */
1350 __tiqdio_inbound_processing(struct qdio_q
*q
, int spare_ind_was_set
)
1352 struct qdio_irq
*irq_ptr
;
1356 QDIO_DBF_TEXT4(0,trace
,"iqinproc");
1357 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1360 * we first want to reserve the q, so that we know, that we don't
1361 * interrupt ourselves and call qdio_unmark_q, as is_in_shutdown might
1364 if (unlikely(qdio_reserve_q(q
))) {
1366 #ifdef QDIO_PERFORMANCE_STATS
1368 #endif /* QDIO_PERFORMANCE_STATS */
1370 * as we might just be about to stop polling, we make
1371 * sure that we check again at least once more
1376 #ifdef QDIO_PERFORMANCE_STATS
1378 #endif /* QDIO_PERFORMANCE_STATS */
1379 if (unlikely(atomic_read(&q
->is_in_shutdown
))) {
1385 * we reset spare_ind_was_set, when the queue does not use the
1388 if (spare_ind_was_set
)
1389 spare_ind_was_set
= (q
->dev_st_chg_ind
== &spare_indicator
);
1391 if (!(*(q
->dev_st_chg_ind
)) && !spare_ind_was_set
)
1394 * q->dev_st_chg_ind is the indicator, be it shared or not.
1395 * only clear it, if indicator is non-shared
1397 if (!spare_ind_was_set
)
1398 tiqdio_clear_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1400 if (q
->hydra_gives_outbound_pcis
) {
1401 if (!q
->siga_sync_done_on_thinints
) {
1403 } else if ((!q
->siga_sync_done_on_outb_tis
)&&
1404 (q
->hydra_gives_outbound_pcis
)) {
1405 SYNC_MEMORY_ALL_OUTB
;
1411 * maybe we have to do work on our outbound queues... at least
1412 * we have to check the outbound-int-capable thinint-capable
1415 if (q
->hydra_gives_outbound_pcis
) {
1416 irq_ptr
= (struct qdio_irq
*)q
->irq_ptr
;
1417 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
1418 oq
= irq_ptr
->output_qs
[i
];
1419 #ifdef QDIO_PERFORMANCE_STATS
1420 perf_stats
.tl_runs
--;
1421 #endif /* QDIO_PERFORMANCE_STATS */
1422 if (!qdio_is_outbound_q_done(oq
))
1423 __qdio_outbound_processing(oq
);
1427 if (!qdio_has_inbound_q_moved(q
))
1430 qdio_kick_inbound_handler(q
);
1431 if (tiqdio_is_inbound_q_done(q
))
1432 if (!qdio_stop_polling(q
)) {
1434 * we set the flags to get into the stuff next time,
1435 * see also comment in qdio_stop_polling
1437 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1445 tiqdio_inbound_processing(struct qdio_q
*q
)
1447 __tiqdio_inbound_processing(q
, atomic_read(&spare_indicator_usecount
));
1451 __qdio_inbound_processing(struct qdio_q
*q
)
1455 QDIO_DBF_TEXT4(0,trace
,"qinproc");
1456 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1458 if (unlikely(qdio_reserve_q(q
))) {
1460 #ifdef QDIO_PERFORMANCE_STATS
1462 #endif /* QDIO_PERFORMANCE_STATS */
1463 /* as we're sissies, we'll check next time */
1464 if (likely(!atomic_read(&q
->is_in_shutdown
))) {
1466 QDIO_DBF_TEXT4(0,trace
,"busy,agn");
1470 #ifdef QDIO_PERFORMANCE_STATS
1472 perf_stats
.tl_runs
++;
1473 #endif /* QDIO_PERFORMANCE_STATS */
1476 if (qdio_has_inbound_q_moved(q
)) {
1477 qdio_kick_inbound_handler(q
);
1478 if (!qdio_stop_polling(q
)) {
1480 if (q_laps
<QDIO_Q_LAPS
)
1485 if (!qdio_is_inbound_q_done(q
))
1486 /* means poll time is not yet over */
1494 qdio_inbound_processing(struct qdio_q
*q
)
1496 __qdio_inbound_processing(q
);
1499 /************************* MAIN ROUTINES *******************************/
1501 #ifdef QDIO_USE_PROCESSING_STATE
1503 tiqdio_reset_processing_state(struct qdio_q
*q
, int q_laps
)
1511 * under VM, we have not used the PROCESSING state, so no
1512 * need to stop polling
1517 if (unlikely(qdio_reserve_q(q
))) {
1519 #ifdef QDIO_PERFORMANCE_STATS
1521 #endif /* QDIO_PERFORMANCE_STATS */
1523 * as we might just be about to stop polling, we make
1524 * sure that we check again at least once more
1528 * sanity -- we'd get here without setting the
1531 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1535 if (qdio_stop_polling(q
)) {
1539 if (q_laps
<QDIO_Q_LAPS
-1) {
1544 * we set the flags to get into the stuff
1545 * next time, see also comment in qdio_stop_polling
1547 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1553 #endif /* QDIO_USE_PROCESSING_STATE */
1556 tiqdio_inbound_checks(void)
1559 int spare_ind_was_set
=0;
1560 #ifdef QDIO_USE_PROCESSING_STATE
1562 #endif /* QDIO_USE_PROCESSING_STATE */
1564 QDIO_DBF_TEXT4(0,trace
,"iqdinbck");
1565 QDIO_DBF_TEXT5(0,trace
,"iqlocsum");
1567 #ifdef QDIO_USE_PROCESSING_STATE
1569 #endif /* QDIO_USE_PROCESSING_STATE */
1571 /* when the spare indicator is used and set, save that and clear it */
1572 if ((atomic_read(&spare_indicator_usecount
)) && spare_indicator
) {
1573 spare_ind_was_set
= 1;
1574 tiqdio_clear_summary_bit((__u32
*)&spare_indicator
);
1577 q
=(struct qdio_q
*)tiq_list
;
1581 __tiqdio_inbound_processing(q
, spare_ind_was_set
);
1582 q
=(struct qdio_q
*)q
->list_next
;
1583 } while (q
!=(struct qdio_q
*)tiq_list
);
1585 #ifdef QDIO_USE_PROCESSING_STATE
1586 q
=(struct qdio_q
*)tiq_list
;
1590 ret
= tiqdio_reset_processing_state(q
, q_laps
);
1597 q
= (struct qdio_q
*)q
->list_next
;
1603 } while (q
!=(struct qdio_q
*)tiq_list
);
1604 #endif /* QDIO_USE_PROCESSING_STATE */
1608 tiqdio_tl(unsigned long data
)
1610 QDIO_DBF_TEXT4(0,trace
,"iqdio_tl");
1612 #ifdef QDIO_PERFORMANCE_STATS
1613 perf_stats
.tl_runs
++;
1614 #endif /* QDIO_PERFORMANCE_STATS */
1616 tiqdio_inbound_checks();
1619 /********************* GENERAL HELPER_ROUTINES ***********************/
1622 qdio_release_irq_memory(struct qdio_irq
*irq_ptr
)
1626 for (i
=0;i
<QDIO_MAX_QUEUES_PER_IRQ
;i
++) {
1627 if (!irq_ptr
->input_qs
[i
])
1630 kfree(irq_ptr
->input_qs
[i
]->slib
);
1631 kfree(irq_ptr
->input_qs
[i
]);
1634 if (!irq_ptr
->output_qs
[i
])
1637 kfree(irq_ptr
->output_qs
[i
]->slib
);
1638 kfree(irq_ptr
->output_qs
[i
]);
1641 kfree(irq_ptr
->qdr
);
1642 free_page((unsigned long) irq_ptr
);
1646 qdio_set_impl_params(struct qdio_irq
*irq_ptr
,
1647 unsigned int qib_param_field_format
,
1648 /* pointer to 128 bytes or NULL, if no param field */
1649 unsigned char *qib_param_field
,
1650 /* pointer to no_queues*128 words of data or NULL */
1651 unsigned int no_input_qs
,
1652 unsigned int no_output_qs
,
1653 unsigned long *input_slib_elements
,
1654 unsigned long *output_slib_elements
)
1661 irq_ptr
->qib
.pfmt
=qib_param_field_format
;
1662 if (qib_param_field
)
1663 memcpy(irq_ptr
->qib
.parm
,qib_param_field
,
1664 QDIO_MAX_BUFFERS_PER_Q
);
1666 if (input_slib_elements
)
1667 for (i
=0;i
<no_input_qs
;i
++) {
1668 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1669 irq_ptr
->input_qs
[i
]->slib
->slibe
[j
].parms
=
1670 input_slib_elements
[
1671 i
*QDIO_MAX_BUFFERS_PER_Q
+j
];
1673 if (output_slib_elements
)
1674 for (i
=0;i
<no_output_qs
;i
++) {
1675 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1676 irq_ptr
->output_qs
[i
]->slib
->slibe
[j
].parms
=
1677 output_slib_elements
[
1678 i
*QDIO_MAX_BUFFERS_PER_Q
+j
];
1683 qdio_alloc_qs(struct qdio_irq
*irq_ptr
,
1684 int no_input_qs
, int no_output_qs
)
1690 for (i
=0;i
<no_input_qs
;i
++) {
1691 q
= kzalloc(sizeof(struct qdio_q
), GFP_KERNEL
);
1694 QDIO_PRINT_ERR("kmalloc of q failed!\n");
1698 q
->slib
= kmalloc(PAGE_SIZE
, GFP_KERNEL
);
1700 QDIO_PRINT_ERR("kmalloc of slib failed!\n");
1704 irq_ptr
->input_qs
[i
]=q
;
1707 for (i
=0;i
<no_output_qs
;i
++) {
1708 q
= kzalloc(sizeof(struct qdio_q
), GFP_KERNEL
);
1714 q
->slib
=kmalloc(PAGE_SIZE
,GFP_KERNEL
);
1716 QDIO_PRINT_ERR("kmalloc of slib failed!\n");
1720 irq_ptr
->output_qs
[i
]=q
;
1729 qdio_fill_qs(struct qdio_irq
*irq_ptr
, struct ccw_device
*cdev
,
1730 int no_input_qs
, int no_output_qs
,
1731 qdio_handler_t
*input_handler
,
1732 qdio_handler_t
*output_handler
,
1733 unsigned long int_parm
,int q_format
,
1734 unsigned long flags
,
1735 void **inbound_sbals_array
,
1736 void **outbound_sbals_array
)
1740 char dbf_text
[20]; /* see qdio_initialize */
1744 sprintf(dbf_text
,"qfqs%4x",cdev
->private->schid
.sch_no
);
1745 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
1746 for (i
=0;i
<no_input_qs
;i
++) {
1747 q
=irq_ptr
->input_qs
[i
];
1749 memset(q
,0,((char*)&q
->slib
)-((char*)q
));
1750 sprintf(dbf_text
,"in-q%4x",i
);
1751 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
1752 QDIO_DBF_HEX0(0,setup
,&q
,sizeof(void*));
1754 memset(q
->slib
,0,PAGE_SIZE
);
1755 q
->sl
=(struct sl
*)(((char*)q
->slib
)+PAGE_SIZE
/2);
1759 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1760 q
->sbal
[j
]=*(inbound_sbals_array
++);
1762 q
->queue_type
=q_format
;
1763 q
->int_parm
=int_parm
;
1764 q
->schid
= irq_ptr
->schid
;
1765 q
->irq_ptr
= irq_ptr
;
1770 q
->first_to_check
=0;
1772 q
->handler
=input_handler
;
1773 q
->dev_st_chg_ind
=irq_ptr
->dev_st_chg_ind
;
1775 q
->tasklet
.data
=(unsigned long)q
;
1776 /* q->is_thinint_q isn't valid at this time, but
1777 * irq_ptr->is_thinint_irq is */
1778 q
->tasklet
.func
=(void(*)(unsigned long))
1779 ((irq_ptr
->is_thinint_irq
)?&tiqdio_inbound_processing
:
1780 &qdio_inbound_processing
);
1782 /* actually this is not used for inbound queues. yet. */
1783 atomic_set(&q
->busy_siga_counter
,0);
1784 q
->timing
.busy_start
=0;
1786 /* for (j=0;j<QDIO_STATS_NUMBER;j++)
1787 q->timing.last_transfer_times[j]=(qdio_get_micros()/
1788 QDIO_STATS_NUMBER)*j;
1789 q->timing.last_transfer_index=QDIO_STATS_NUMBER-1;
1793 if (i
>0) irq_ptr
->input_qs
[i
-1]->slib
->nsliba
=
1794 (unsigned long)(q
->slib
);
1795 q
->slib
->sla
=(unsigned long)(q
->sl
);
1796 q
->slib
->slsba
=(unsigned long)(&q
->slsb
.acc
.val
[0]);
1799 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1800 q
->sl
->element
[j
].sbal
=(unsigned long)(q
->sbal
[j
]);
1802 QDIO_DBF_TEXT2(0,setup
,"sl-sb-b0");
1804 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1805 ptr
=(void*)&q
->slsb
;
1806 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1807 ptr
=(void*)q
->sbal
[0];
1808 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1811 if (!irq_ptr
->is_qebsm
) {
1812 unsigned int count
= 1;
1813 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; j
++)
1814 set_slsb(q
, &j
, SLSB_P_INPUT_NOT_INIT
, &count
);
1818 for (i
=0;i
<no_output_qs
;i
++) {
1819 q
=irq_ptr
->output_qs
[i
];
1820 memset(q
,0,((char*)&q
->slib
)-((char*)q
));
1822 sprintf(dbf_text
,"outq%4x",i
);
1823 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
1824 QDIO_DBF_HEX0(0,setup
,&q
,sizeof(void*));
1826 memset(q
->slib
,0,PAGE_SIZE
);
1827 q
->sl
=(struct sl
*)(((char*)q
->slib
)+PAGE_SIZE
/2);
1831 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1832 q
->sbal
[j
]=*(outbound_sbals_array
++);
1834 q
->queue_type
=q_format
;
1835 q
->int_parm
=int_parm
;
1837 q
->schid
= irq_ptr
->schid
;
1839 q
->irq_ptr
= irq_ptr
;
1842 q
->first_to_check
=0;
1844 q
->handler
=output_handler
;
1846 q
->tasklet
.data
=(unsigned long)q
;
1847 q
->tasklet
.func
=(void(*)(unsigned long))
1848 &qdio_outbound_processing
;
1850 atomic_set(&q
->busy_siga_counter
,0);
1851 q
->timing
.busy_start
=0;
1854 if (i
>0) irq_ptr
->output_qs
[i
-1]->slib
->nsliba
=
1855 (unsigned long)(q
->slib
);
1856 q
->slib
->sla
=(unsigned long)(q
->sl
);
1857 q
->slib
->slsba
=(unsigned long)(&q
->slsb
.acc
.val
[0]);
1860 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1861 q
->sl
->element
[j
].sbal
=(unsigned long)(q
->sbal
[j
]);
1863 QDIO_DBF_TEXT2(0,setup
,"sl-sb-b0");
1865 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1866 ptr
=(void*)&q
->slsb
;
1867 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1868 ptr
=(void*)q
->sbal
[0];
1869 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1872 if (!irq_ptr
->is_qebsm
) {
1873 unsigned int count
= 1;
1874 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; j
++)
1875 set_slsb(q
, &j
, SLSB_P_OUTPUT_NOT_INIT
, &count
);
1881 qdio_fill_thresholds(struct qdio_irq
*irq_ptr
,
1882 unsigned int no_input_qs
,
1883 unsigned int no_output_qs
,
1884 unsigned int min_input_threshold
,
1885 unsigned int max_input_threshold
,
1886 unsigned int min_output_threshold
,
1887 unsigned int max_output_threshold
)
1892 for (i
=0;i
<no_input_qs
;i
++) {
1893 q
=irq_ptr
->input_qs
[i
];
1894 q
->timing
.threshold
=max_input_threshold
;
1895 /* for (j=0;j<QDIO_STATS_CLASSES;j++) {
1896 q->threshold_classes[j].threshold=
1897 min_input_threshold+
1898 (max_input_threshold-min_input_threshold)/
1901 qdio_use_thresholds(q,QDIO_STATS_CLASSES/2);*/
1903 for (i
=0;i
<no_output_qs
;i
++) {
1904 q
=irq_ptr
->output_qs
[i
];
1905 q
->timing
.threshold
=max_output_threshold
;
1906 /* for (j=0;j<QDIO_STATS_CLASSES;j++) {
1907 q->threshold_classes[j].threshold=
1908 min_output_threshold+
1909 (max_output_threshold-min_output_threshold)/
1912 qdio_use_thresholds(q,QDIO_STATS_CLASSES/2);*/
1917 tiqdio_thinint_handler(void)
1919 QDIO_DBF_TEXT4(0,trace
,"thin_int");
1921 #ifdef QDIO_PERFORMANCE_STATS
1922 perf_stats
.thinints
++;
1923 perf_stats
.start_time_inbound
=NOW
;
1924 #endif /* QDIO_PERFORMANCE_STATS */
1926 /* SVS only when needed:
1927 * issue SVS to benefit from iqdio interrupt avoidance
1928 * (SVS clears AISOI)*/
1930 tiqdio_clear_global_summary();
1932 tiqdio_inbound_checks();
1937 qdio_set_state(struct qdio_irq
*irq_ptr
, enum qdio_irq_states state
)
1940 #ifdef CONFIG_QDIO_DEBUG
1943 QDIO_DBF_TEXT5(0,trace
,"newstate");
1944 sprintf(dbf_text
,"%4x%4x",irq_ptr
->schid
.sch_no
,state
);
1945 QDIO_DBF_TEXT5(0,trace
,dbf_text
);
1946 #endif /* CONFIG_QDIO_DEBUG */
1948 irq_ptr
->state
=state
;
1949 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++)
1950 irq_ptr
->input_qs
[i
]->state
=state
;
1951 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++)
1952 irq_ptr
->output_qs
[i
]->state
=state
;
1957 qdio_irq_check_sense(struct subchannel_id schid
, struct irb
*irb
)
1961 if (irb
->esw
.esw0
.erw
.cons
) {
1962 sprintf(dbf_text
,"sens%4x",schid
.sch_no
);
1963 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
1964 QDIO_DBF_HEX0(0,sense
,irb
,QDIO_DBF_SENSE_LEN
);
1966 QDIO_PRINT_WARN("sense data available on qdio channel.\n");
1967 HEXDUMP16(WARN
,"irb: ",irb
);
1968 HEXDUMP16(WARN
,"sense data: ",irb
->ecw
);
1974 qdio_handle_pci(struct qdio_irq
*irq_ptr
)
1979 #ifdef QDIO_PERFORMANCE_STATS
1981 perf_stats
.start_time_inbound
=NOW
;
1982 #endif /* QDIO_PERFORMANCE_STATS */
1983 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
1984 q
=irq_ptr
->input_qs
[i
];
1985 if (q
->is_input_q
&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT
)
1988 #ifdef QDIO_PERFORMANCE_STATS
1989 perf_stats
.tl_runs
--;
1990 #endif /* QDIO_PERFORMANCE_STATS */
1991 __qdio_inbound_processing(q
);
1994 if (!irq_ptr
->hydra_gives_outbound_pcis
)
1996 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
1997 q
=irq_ptr
->output_qs
[i
];
1998 #ifdef QDIO_PERFORMANCE_STATS
1999 perf_stats
.tl_runs
--;
2000 #endif /* QDIO_PERFORMANCE_STATS */
2001 if (qdio_is_outbound_q_done(q
))
2003 if (!irq_ptr
->sync_done_on_outb_pcis
)
2005 __qdio_outbound_processing(q
);
2009 static void qdio_establish_handle_irq(struct ccw_device
*, int, int);
2012 qdio_handle_activate_check(struct ccw_device
*cdev
, unsigned long intparm
,
2013 int cstat
, int dstat
)
2015 struct qdio_irq
*irq_ptr
;
2019 irq_ptr
= cdev
->private->qdio_data
;
2021 QDIO_DBF_TEXT2(1, trace
, "ick2");
2022 sprintf(dbf_text
,"%s", cdev
->dev
.bus_id
);
2023 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
2024 QDIO_DBF_HEX2(0,trace
,&intparm
,sizeof(int));
2025 QDIO_DBF_HEX2(0,trace
,&dstat
,sizeof(int));
2026 QDIO_DBF_HEX2(0,trace
,&cstat
,sizeof(int));
2027 QDIO_PRINT_ERR("received check condition on activate " \
2028 "queues on device %s (cs=x%x, ds=x%x).\n",
2029 cdev
->dev
.bus_id
, cstat
, dstat
);
2030 if (irq_ptr
->no_input_qs
) {
2031 q
=irq_ptr
->input_qs
[0];
2032 } else if (irq_ptr
->no_output_qs
) {
2033 q
=irq_ptr
->output_qs
[0];
2035 QDIO_PRINT_ERR("oops... no queue registered for device %s!?\n",
2037 goto omit_handler_call
;
2039 q
->handler(q
->cdev
,QDIO_STATUS_ACTIVATE_CHECK_CONDITION
|
2040 QDIO_STATUS_LOOK_FOR_ERROR
,
2041 0,0,0,-1,-1,q
->int_parm
);
2043 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_STOPPED
);
2048 qdio_call_shutdown(void *data
)
2050 struct ccw_device
*cdev
;
2052 cdev
= (struct ccw_device
*)data
;
2053 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
2054 put_device(&cdev
->dev
);
2058 qdio_timeout_handler(struct ccw_device
*cdev
)
2060 struct qdio_irq
*irq_ptr
;
2063 QDIO_DBF_TEXT2(0, trace
, "qtoh");
2064 sprintf(dbf_text
, "%s", cdev
->dev
.bus_id
);
2065 QDIO_DBF_TEXT2(0, trace
, dbf_text
);
2067 irq_ptr
= cdev
->private->qdio_data
;
2068 sprintf(dbf_text
, "state:%d", irq_ptr
->state
);
2069 QDIO_DBF_TEXT2(0, trace
, dbf_text
);
2071 switch (irq_ptr
->state
) {
2072 case QDIO_IRQ_STATE_INACTIVE
:
2073 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: timed out\n",
2074 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2075 QDIO_DBF_TEXT2(1,setup
,"eq:timeo");
2076 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2078 case QDIO_IRQ_STATE_CLEANUP
:
2079 QDIO_PRINT_INFO("Did not get interrupt on cleanup, "
2081 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2082 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2084 case QDIO_IRQ_STATE_ESTABLISHED
:
2085 case QDIO_IRQ_STATE_ACTIVE
:
2086 /* I/O has been terminated by common I/O layer. */
2087 QDIO_PRINT_INFO("Queues on irq 0.%x.%04x killed by cio.\n",
2088 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2089 QDIO_DBF_TEXT2(1, trace
, "cio:term");
2090 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_STOPPED
);
2091 if (get_device(&cdev
->dev
)) {
2092 /* Can't call shutdown from interrupt context. */
2093 PREPARE_WORK(&cdev
->private->kick_work
,
2094 qdio_call_shutdown
, (void *)cdev
);
2095 queue_work(ccw_device_work
, &cdev
->private->kick_work
);
2101 ccw_device_set_timeout(cdev
, 0);
2102 wake_up(&cdev
->private->wait_q
);
2106 qdio_handler(struct ccw_device
*cdev
, unsigned long intparm
, struct irb
*irb
)
2108 struct qdio_irq
*irq_ptr
;
2112 #ifdef CONFIG_QDIO_DEBUG
2113 QDIO_DBF_TEXT4(0, trace
, "qint");
2114 sprintf(dbf_text
, "%s", cdev
->dev
.bus_id
);
2115 QDIO_DBF_TEXT4(0, trace
, dbf_text
);
2116 #endif /* CONFIG_QDIO_DEBUG */
2119 QDIO_PRINT_ERR("got unsolicited interrupt in qdio " \
2120 "handler, device %s\n", cdev
->dev
.bus_id
);
2124 irq_ptr
= cdev
->private->qdio_data
;
2126 QDIO_DBF_TEXT2(1, trace
, "uint");
2127 sprintf(dbf_text
,"%s", cdev
->dev
.bus_id
);
2128 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
2129 QDIO_PRINT_ERR("received interrupt on unused device %s!\n",
2135 /* Currently running i/o is in error. */
2136 switch (PTR_ERR(irb
)) {
2138 QDIO_PRINT_ERR("i/o error on device %s\n",
2142 qdio_timeout_handler(cdev
);
2145 QDIO_PRINT_ERR("unknown error state %ld on device %s\n",
2146 PTR_ERR(irb
), cdev
->dev
.bus_id
);
2151 qdio_irq_check_sense(irq_ptr
->schid
, irb
);
2153 #ifdef CONFIG_QDIO_DEBUG
2154 sprintf(dbf_text
, "state:%d", irq_ptr
->state
);
2155 QDIO_DBF_TEXT4(0, trace
, dbf_text
);
2156 #endif /* CONFIG_QDIO_DEBUG */
2158 cstat
= irb
->scsw
.cstat
;
2159 dstat
= irb
->scsw
.dstat
;
2161 switch (irq_ptr
->state
) {
2162 case QDIO_IRQ_STATE_INACTIVE
:
2163 qdio_establish_handle_irq(cdev
, cstat
, dstat
);
2166 case QDIO_IRQ_STATE_CLEANUP
:
2167 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2170 case QDIO_IRQ_STATE_ESTABLISHED
:
2171 case QDIO_IRQ_STATE_ACTIVE
:
2172 if (cstat
& SCHN_STAT_PCI
) {
2173 qdio_handle_pci(irq_ptr
);
2177 if ((cstat
&~SCHN_STAT_PCI
)||dstat
) {
2178 qdio_handle_activate_check(cdev
, intparm
, cstat
, dstat
);
2182 QDIO_PRINT_ERR("got interrupt for queues in state %d on " \
2184 irq_ptr
->state
, cdev
->dev
.bus_id
);
2186 wake_up(&cdev
->private->wait_q
);
2191 qdio_synchronize(struct ccw_device
*cdev
, unsigned int flags
,
2192 unsigned int queue_number
)
2196 struct qdio_irq
*irq_ptr
;
2198 #ifdef CONFIG_QDIO_DEBUG
2199 char dbf_text
[15]="SyncXXXX";
2202 irq_ptr
= cdev
->private->qdio_data
;
2206 #ifdef CONFIG_QDIO_DEBUG
2207 *((int*)(&dbf_text
[4])) = irq_ptr
->schid
.sch_no
;
2208 QDIO_DBF_HEX4(0,trace
,dbf_text
,QDIO_DBF_TRACE_LEN
);
2209 *((int*)(&dbf_text
[0]))=flags
;
2210 *((int*)(&dbf_text
[4]))=queue_number
;
2211 QDIO_DBF_HEX4(0,trace
,dbf_text
,QDIO_DBF_TRACE_LEN
);
2212 #endif /* CONFIG_QDIO_DEBUG */
2214 if (flags
&QDIO_FLAG_SYNC_INPUT
) {
2215 q
=irq_ptr
->input_qs
[queue_number
];
2218 if (!(irq_ptr
->is_qebsm
))
2219 cc
= do_siga_sync(q
->schid
, 0, q
->mask
);
2220 } else if (flags
&QDIO_FLAG_SYNC_OUTPUT
) {
2221 q
=irq_ptr
->output_qs
[queue_number
];
2224 if (!(irq_ptr
->is_qebsm
))
2225 cc
= do_siga_sync(q
->schid
, q
->mask
, 0);
2231 QDIO_DBF_HEX3(0,trace
,&ptr
,sizeof(int));
2237 qdio_check_subchannel_qebsm(struct qdio_irq
*irq_ptr
, unsigned char qdioac
,
2238 unsigned long token
)
2242 unsigned int count
, start_buf
;
2245 /*check if QEBSM is disabled */
2246 if (!(irq_ptr
->is_qebsm
) || !(qdioac
& 0x01)) {
2247 irq_ptr
->is_qebsm
= 0;
2248 irq_ptr
->sch_token
= 0;
2249 irq_ptr
->qib
.rflags
&= ~QIB_RFLAGS_ENABLE_QEBSM
;
2250 QDIO_DBF_TEXT0(0,setup
,"noV=V");
2253 irq_ptr
->sch_token
= token
;
2255 for (i
= 0; i
< irq_ptr
->no_input_qs
;i
++) {
2256 q
= irq_ptr
->input_qs
[i
];
2257 count
= QDIO_MAX_BUFFERS_PER_Q
;
2259 set_slsb(q
, &start_buf
, SLSB_P_INPUT_NOT_INIT
, &count
);
2261 sprintf(dbf_text
,"V=V:%2x",irq_ptr
->is_qebsm
);
2262 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2263 sprintf(dbf_text
,"%8lx",irq_ptr
->sch_token
);
2264 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2266 for (i
= 0; i
< irq_ptr
->no_output_qs
; i
++) {
2267 q
= irq_ptr
->output_qs
[i
];
2268 count
= QDIO_MAX_BUFFERS_PER_Q
;
2270 set_slsb(q
, &start_buf
, SLSB_P_OUTPUT_NOT_INIT
, &count
);
2275 qdio_get_ssqd_information(struct qdio_irq
*irq_ptr
)
2278 unsigned char qdioac
;
2280 struct chsc_header request
;
2288 struct chsc_header response
;
2307 QDIO_DBF_TEXT0(0,setup
,"getssqd");
2309 ssqd_area
= mempool_alloc(qdio_mempool_scssc
, GFP_ATOMIC
);
2311 QDIO_PRINT_WARN("Could not get memory for chsc. Using all " \
2312 "SIGAs for sch x%x.\n", irq_ptr
->schid
.sch_no
);
2313 irq_ptr
->qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
||
2314 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
||
2315 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* all flags set */
2316 irq_ptr
->is_qebsm
= 0;
2317 irq_ptr
->sch_token
= 0;
2318 irq_ptr
->qib
.rflags
&= ~QIB_RFLAGS_ENABLE_QEBSM
;
2322 ssqd_area
->request
= (struct chsc_header
) {
2326 ssqd_area
->first_sch
= irq_ptr
->schid
.sch_no
;
2327 ssqd_area
->last_sch
= irq_ptr
->schid
.sch_no
;
2328 ssqd_area
->ssid
= irq_ptr
->schid
.ssid
;
2329 result
= chsc(ssqd_area
);
2332 QDIO_PRINT_WARN("CHSC returned cc %i. Using all " \
2333 "SIGAs for sch 0.%x.%x.\n", result
,
2334 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2335 qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
||
2336 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
||
2337 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* all flags set */
2338 irq_ptr
->is_qebsm
= 0;
2342 if (ssqd_area
->response
.code
!= QDIO_CHSC_RESPONSE_CODE_OK
) {
2343 QDIO_PRINT_WARN("response upon checking SIGA needs " \
2344 "is 0x%x. Using all SIGAs for sch 0.%x.%x.\n",
2345 ssqd_area
->response
.code
,
2346 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2347 qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
||
2348 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
||
2349 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* all flags set */
2350 irq_ptr
->is_qebsm
= 0;
2353 if (!(ssqd_area
->flags
& CHSC_FLAG_QDIO_CAPABILITY
) ||
2354 !(ssqd_area
->flags
& CHSC_FLAG_VALIDITY
) ||
2355 (ssqd_area
->sch
!= irq_ptr
->schid
.sch_no
)) {
2356 QDIO_PRINT_WARN("huh? problems checking out sch 0.%x.%x... " \
2357 "using all SIGAs.\n",
2358 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2359 qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
|
2360 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
|
2361 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* worst case */
2362 irq_ptr
->is_qebsm
= 0;
2365 qdioac
= ssqd_area
->qdioac1
;
2367 qdio_check_subchannel_qebsm(irq_ptr
, qdioac
,
2368 ssqd_area
->sch_token
);
2369 mempool_free(ssqd_area
, qdio_mempool_scssc
);
2370 irq_ptr
->qdioac
= qdioac
;
2374 tiqdio_check_chsc_availability(void)
2378 if (!css_characteristics_avail
)
2381 /* Check for bit 41. */
2382 if (!css_general_characteristics
.aif
) {
2383 QDIO_PRINT_WARN("Adapter interruption facility not " \
2388 /* Check for bits 107 and 108. */
2389 if (!css_chsc_characteristics
.scssc
||
2390 !css_chsc_characteristics
.scsscf
) {
2391 QDIO_PRINT_WARN("Set Chan Subsys. Char. & Fast-CHSCs " \
2392 "not available.\n");
2396 /* Check for OSA/FCP thin interrupts (bit 67). */
2397 hydra_thinints
= css_general_characteristics
.aif_osa
;
2398 sprintf(dbf_text
,"hydrati%1x", hydra_thinints
);
2399 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2402 /* Check for QEBSM support in general (bit 58). */
2403 is_passthrough
= css_general_characteristics
.qebsm
;
2405 sprintf(dbf_text
,"cssQBS:%1x", is_passthrough
);
2406 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2408 /* Check for aif time delay disablement fac (bit 56). If installed,
2409 * omit svs even under lpar (good point by rick again) */
2410 omit_svs
= css_general_characteristics
.aif_tdd
;
2411 sprintf(dbf_text
,"omitsvs%1x", omit_svs
);
2412 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2418 tiqdio_set_subchannel_ind(struct qdio_irq
*irq_ptr
, int reset_to_zero
)
2420 unsigned long real_addr_local_summary_bit
;
2421 unsigned long real_addr_dev_st_chg_ind
;
2425 unsigned int resp_code
;
2429 struct chsc_header request
;
2434 u64 summary_indicator_addr
;
2435 u64 subchannel_indicator_addr
;
2440 u32 word_with_d_bit
;
2441 /* set to 0x10000000 to enable
2442 * time delay disablement facility */
2444 struct subchannel_id schid
;
2445 u32 reserved6
[1004];
2446 struct chsc_header response
;
2450 if (!irq_ptr
->is_thinint_irq
)
2453 if (reset_to_zero
) {
2454 real_addr_local_summary_bit
=0;
2455 real_addr_dev_st_chg_ind
=0;
2457 real_addr_local_summary_bit
=
2458 virt_to_phys((volatile void *)indicators
);
2459 real_addr_dev_st_chg_ind
=
2460 virt_to_phys((volatile void *)irq_ptr
->dev_st_chg_ind
);
2463 scssc_area
= mempool_alloc(qdio_mempool_scssc
, GFP_ATOMIC
);
2465 QDIO_PRINT_WARN("No memory for setting indicators on " \
2466 "subchannel 0.%x.%x.\n",
2467 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2470 scssc_area
->request
= (struct chsc_header
) {
2474 scssc_area
->operation_code
= 0;
2476 scssc_area
->summary_indicator_addr
= real_addr_local_summary_bit
;
2477 scssc_area
->subchannel_indicator_addr
= real_addr_dev_st_chg_ind
;
2478 scssc_area
->ks
= QDIO_STORAGE_KEY
;
2479 scssc_area
->kc
= QDIO_STORAGE_KEY
;
2480 scssc_area
->isc
= TIQDIO_THININT_ISC
;
2481 scssc_area
->schid
= irq_ptr
->schid
;
2482 /* enables the time delay disablement facility. Don't care
2483 * whether it is really there (i.e. we haven't checked for
2485 if (css_general_characteristics
.aif_tdd
)
2486 scssc_area
->word_with_d_bit
= 0x10000000;
2488 QDIO_PRINT_WARN("Time delay disablement facility " \
2491 result
= chsc(scssc_area
);
2493 QDIO_PRINT_WARN("could not set indicators on irq 0.%x.%x, " \
2495 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,result
);
2500 resp_code
= scssc_area
->response
.code
;
2501 if (resp_code
!=QDIO_CHSC_RESPONSE_CODE_OK
) {
2502 QDIO_PRINT_WARN("response upon setting indicators " \
2503 "is 0x%x.\n",resp_code
);
2504 sprintf(dbf_text
,"sidR%4x",resp_code
);
2505 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2506 QDIO_DBF_TEXT1(0,setup
,dbf_text
);
2507 ptr
=&scssc_area
->response
;
2508 QDIO_DBF_HEX2(1,setup
,&ptr
,QDIO_DBF_SETUP_LEN
);
2513 QDIO_DBF_TEXT2(0,setup
,"setscind");
2514 QDIO_DBF_HEX2(0,setup
,&real_addr_local_summary_bit
,
2515 sizeof(unsigned long));
2516 QDIO_DBF_HEX2(0,setup
,&real_addr_dev_st_chg_ind
,sizeof(unsigned long));
2519 mempool_free(scssc_area
, qdio_mempool_scssc
);
2525 tiqdio_set_delay_target(struct qdio_irq
*irq_ptr
, unsigned long delay_target
)
2527 unsigned int resp_code
;
2533 struct chsc_header request
;
2540 u32 reserved5
[1009];
2541 struct chsc_header response
;
2545 if (!irq_ptr
->is_thinint_irq
)
2548 scsscf_area
= mempool_alloc(qdio_mempool_scssc
, GFP_ATOMIC
);
2550 QDIO_PRINT_WARN("No memory for setting delay target on " \
2551 "subchannel 0.%x.%x.\n",
2552 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2555 scsscf_area
->request
= (struct chsc_header
) {
2560 scsscf_area
->delay_target
= delay_target
<<16;
2562 result
=chsc(scsscf_area
);
2564 QDIO_PRINT_WARN("could not set delay target on irq 0.%x.%x, " \
2565 "cc=%i. Continuing.\n",
2566 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
2572 resp_code
= scsscf_area
->response
.code
;
2573 if (resp_code
!=QDIO_CHSC_RESPONSE_CODE_OK
) {
2574 QDIO_PRINT_WARN("response upon setting delay target " \
2575 "is 0x%x. Continuing.\n",resp_code
);
2576 sprintf(dbf_text
,"sdtR%4x",resp_code
);
2577 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2578 QDIO_DBF_TEXT1(0,setup
,dbf_text
);
2579 ptr
=&scsscf_area
->response
;
2580 QDIO_DBF_HEX2(1,trace
,&ptr
,QDIO_DBF_TRACE_LEN
);
2582 QDIO_DBF_TEXT2(0,trace
,"delytrgt");
2583 QDIO_DBF_HEX2(0,trace
,&delay_target
,sizeof(unsigned long));
2584 result
= 0; /* not critical */
2586 mempool_free(scsscf_area
, qdio_mempool_scssc
);
2591 qdio_cleanup(struct ccw_device
*cdev
, int how
)
2593 struct qdio_irq
*irq_ptr
;
2597 irq_ptr
= cdev
->private->qdio_data
;
2601 sprintf(dbf_text
,"qcln%4x",irq_ptr
->schid
.sch_no
);
2602 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2603 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2605 rc
= qdio_shutdown(cdev
, how
);
2606 if ((rc
== 0) || (rc
== -EINPROGRESS
))
2607 rc
= qdio_free(cdev
);
2612 qdio_shutdown(struct ccw_device
*cdev
, int how
)
2614 struct qdio_irq
*irq_ptr
;
2618 unsigned long flags
;
2622 irq_ptr
= cdev
->private->qdio_data
;
2626 down(&irq_ptr
->setting_up_sema
);
2628 sprintf(dbf_text
,"qsqs%4x",irq_ptr
->schid
.sch_no
);
2629 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2630 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2632 /* mark all qs as uninteresting */
2633 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++)
2634 atomic_set(&irq_ptr
->input_qs
[i
]->is_in_shutdown
,1);
2636 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++)
2637 atomic_set(&irq_ptr
->output_qs
[i
]->is_in_shutdown
,1);
2639 tasklet_kill(&tiqdio_tasklet
);
2641 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
2642 qdio_unmark_q(irq_ptr
->input_qs
[i
]);
2643 tasklet_kill(&irq_ptr
->input_qs
[i
]->tasklet
);
2644 wait_event_interruptible_timeout(cdev
->private->wait_q
,
2645 !atomic_read(&irq_ptr
->
2648 QDIO_NO_USE_COUNT_TIMEOUT
);
2649 if (atomic_read(&irq_ptr
->input_qs
[i
]->use_count
))
2650 result
=-EINPROGRESS
;
2653 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
2654 tasklet_kill(&irq_ptr
->output_qs
[i
]->tasklet
);
2655 wait_event_interruptible_timeout(cdev
->private->wait_q
,
2656 !atomic_read(&irq_ptr
->
2659 QDIO_NO_USE_COUNT_TIMEOUT
);
2660 if (atomic_read(&irq_ptr
->output_qs
[i
]->use_count
))
2661 result
=-EINPROGRESS
;
2664 /* cleanup subchannel */
2665 spin_lock_irqsave(get_ccwdev_lock(cdev
),flags
);
2666 if (how
&QDIO_FLAG_CLEANUP_USING_CLEAR
) {
2667 rc
= ccw_device_clear(cdev
, QDIO_DOING_CLEANUP
);
2668 timeout
=QDIO_CLEANUP_CLEAR_TIMEOUT
;
2669 } else if (how
&QDIO_FLAG_CLEANUP_USING_HALT
) {
2670 rc
= ccw_device_halt(cdev
, QDIO_DOING_CLEANUP
);
2671 timeout
=QDIO_CLEANUP_HALT_TIMEOUT
;
2672 } else { /* default behaviour */
2673 rc
= ccw_device_halt(cdev
, QDIO_DOING_CLEANUP
);
2674 timeout
=QDIO_CLEANUP_HALT_TIMEOUT
;
2676 if (rc
== -ENODEV
) {
2677 /* No need to wait for device no longer present. */
2678 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2679 spin_unlock_irqrestore(get_ccwdev_lock(cdev
), flags
);
2680 } else if (((void *)cdev
->handler
!= (void *)qdio_handler
) && rc
== 0) {
2682 * Whoever put another handler there, has to cope with the
2683 * interrupt theirself. Might happen if qdio_shutdown was
2684 * called on already shutdown queues, but this shouldn't have
2687 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2688 spin_unlock_irqrestore(get_ccwdev_lock(cdev
), flags
);
2689 } else if (rc
== 0) {
2690 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_CLEANUP
);
2691 ccw_device_set_timeout(cdev
, timeout
);
2692 spin_unlock_irqrestore(get_ccwdev_lock(cdev
),flags
);
2694 wait_event(cdev
->private->wait_q
,
2695 irq_ptr
->state
== QDIO_IRQ_STATE_INACTIVE
||
2696 irq_ptr
->state
== QDIO_IRQ_STATE_ERR
);
2698 QDIO_PRINT_INFO("ccw_device_{halt,clear} returned %d for "
2699 "device %s\n", result
, cdev
->dev
.bus_id
);
2700 spin_unlock_irqrestore(get_ccwdev_lock(cdev
), flags
);
2704 if (irq_ptr
->is_thinint_irq
) {
2705 qdio_put_indicator((__u32
*)irq_ptr
->dev_st_chg_ind
);
2706 tiqdio_set_subchannel_ind(irq_ptr
,1);
2707 /* reset adapter interrupt indicators */
2710 /* exchange int handlers, if necessary */
2711 if ((void*)cdev
->handler
== (void*)qdio_handler
)
2712 cdev
->handler
=irq_ptr
->original_int_handler
;
2714 /* Ignore errors. */
2715 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2716 ccw_device_set_timeout(cdev
, 0);
2718 up(&irq_ptr
->setting_up_sema
);
2723 qdio_free(struct ccw_device
*cdev
)
2725 struct qdio_irq
*irq_ptr
;
2728 irq_ptr
= cdev
->private->qdio_data
;
2732 down(&irq_ptr
->setting_up_sema
);
2734 sprintf(dbf_text
,"qfqs%4x",irq_ptr
->schid
.sch_no
);
2735 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2736 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2738 cdev
->private->qdio_data
= NULL
;
2740 up(&irq_ptr
->setting_up_sema
);
2742 qdio_release_irq_memory(irq_ptr
);
2743 module_put(THIS_MODULE
);
2748 qdio_allocate_do_dbf(struct qdio_initialize
*init_data
)
2750 char dbf_text
[20]; /* if a printf printed out more than 8 chars */
2752 sprintf(dbf_text
,"qfmt:%x",init_data
->q_format
);
2753 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2754 QDIO_DBF_HEX0(0,setup
,init_data
->adapter_name
,8);
2755 sprintf(dbf_text
,"qpff%4x",init_data
->qib_param_field_format
);
2756 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2757 QDIO_DBF_HEX0(0,setup
,&init_data
->qib_param_field
,sizeof(char*));
2758 QDIO_DBF_HEX0(0,setup
,&init_data
->input_slib_elements
,sizeof(long*));
2759 QDIO_DBF_HEX0(0,setup
,&init_data
->output_slib_elements
,sizeof(long*));
2760 sprintf(dbf_text
,"miit%4x",init_data
->min_input_threshold
);
2761 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2762 sprintf(dbf_text
,"mait%4x",init_data
->max_input_threshold
);
2763 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2764 sprintf(dbf_text
,"miot%4x",init_data
->min_output_threshold
);
2765 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2766 sprintf(dbf_text
,"maot%4x",init_data
->max_output_threshold
);
2767 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2768 sprintf(dbf_text
,"niq:%4x",init_data
->no_input_qs
);
2769 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2770 sprintf(dbf_text
,"noq:%4x",init_data
->no_output_qs
);
2771 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2772 QDIO_DBF_HEX0(0,setup
,&init_data
->input_handler
,sizeof(void*));
2773 QDIO_DBF_HEX0(0,setup
,&init_data
->output_handler
,sizeof(void*));
2774 QDIO_DBF_HEX0(0,setup
,&init_data
->int_parm
,sizeof(long));
2775 QDIO_DBF_HEX0(0,setup
,&init_data
->flags
,sizeof(long));
2776 QDIO_DBF_HEX0(0,setup
,&init_data
->input_sbal_addr_array
,sizeof(void*));
2777 QDIO_DBF_HEX0(0,setup
,&init_data
->output_sbal_addr_array
,sizeof(void*));
2781 qdio_allocate_fill_input_desc(struct qdio_irq
*irq_ptr
, int i
, int iqfmt
)
2783 irq_ptr
->input_qs
[i
]->is_iqdio_q
= iqfmt
;
2784 irq_ptr
->input_qs
[i
]->is_thinint_q
= irq_ptr
->is_thinint_irq
;
2786 irq_ptr
->qdr
->qdf0
[i
].sliba
=(unsigned long)(irq_ptr
->input_qs
[i
]->slib
);
2788 irq_ptr
->qdr
->qdf0
[i
].sla
=(unsigned long)(irq_ptr
->input_qs
[i
]->sl
);
2790 irq_ptr
->qdr
->qdf0
[i
].slsba
=
2791 (unsigned long)(&irq_ptr
->input_qs
[i
]->slsb
.acc
.val
[0]);
2793 irq_ptr
->qdr
->qdf0
[i
].akey
=QDIO_STORAGE_KEY
;
2794 irq_ptr
->qdr
->qdf0
[i
].bkey
=QDIO_STORAGE_KEY
;
2795 irq_ptr
->qdr
->qdf0
[i
].ckey
=QDIO_STORAGE_KEY
;
2796 irq_ptr
->qdr
->qdf0
[i
].dkey
=QDIO_STORAGE_KEY
;
2800 qdio_allocate_fill_output_desc(struct qdio_irq
*irq_ptr
, int i
,
2803 irq_ptr
->output_qs
[i
]->is_iqdio_q
= iqfmt
;
2804 irq_ptr
->output_qs
[i
]->is_thinint_q
= irq_ptr
->is_thinint_irq
;
2806 irq_ptr
->qdr
->qdf0
[i
+j
].sliba
=(unsigned long)(irq_ptr
->output_qs
[i
]->slib
);
2808 irq_ptr
->qdr
->qdf0
[i
+j
].sla
=(unsigned long)(irq_ptr
->output_qs
[i
]->sl
);
2810 irq_ptr
->qdr
->qdf0
[i
+j
].slsba
=
2811 (unsigned long)(&irq_ptr
->output_qs
[i
]->slsb
.acc
.val
[0]);
2813 irq_ptr
->qdr
->qdf0
[i
+j
].akey
=QDIO_STORAGE_KEY
;
2814 irq_ptr
->qdr
->qdf0
[i
+j
].bkey
=QDIO_STORAGE_KEY
;
2815 irq_ptr
->qdr
->qdf0
[i
+j
].ckey
=QDIO_STORAGE_KEY
;
2816 irq_ptr
->qdr
->qdf0
[i
+j
].dkey
=QDIO_STORAGE_KEY
;
2821 qdio_initialize_set_siga_flags_input(struct qdio_irq
*irq_ptr
)
2825 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
2826 irq_ptr
->input_qs
[i
]->siga_sync
=
2827 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_NECESSARY
;
2828 irq_ptr
->input_qs
[i
]->siga_in
=
2829 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_INPUT_NECESSARY
;
2830 irq_ptr
->input_qs
[i
]->siga_out
=
2831 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_OUTPUT_NECESSARY
;
2832 irq_ptr
->input_qs
[i
]->siga_sync_done_on_thinints
=
2833 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
;
2834 irq_ptr
->input_qs
[i
]->hydra_gives_outbound_pcis
=
2835 irq_ptr
->hydra_gives_outbound_pcis
;
2836 irq_ptr
->input_qs
[i
]->siga_sync_done_on_outb_tis
=
2838 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2839 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
))==
2840 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2841 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
));
2847 qdio_initialize_set_siga_flags_output(struct qdio_irq
*irq_ptr
)
2851 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
2852 irq_ptr
->output_qs
[i
]->siga_sync
=
2853 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_NECESSARY
;
2854 irq_ptr
->output_qs
[i
]->siga_in
=
2855 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_INPUT_NECESSARY
;
2856 irq_ptr
->output_qs
[i
]->siga_out
=
2857 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_OUTPUT_NECESSARY
;
2858 irq_ptr
->output_qs
[i
]->siga_sync_done_on_thinints
=
2859 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
;
2860 irq_ptr
->output_qs
[i
]->hydra_gives_outbound_pcis
=
2861 irq_ptr
->hydra_gives_outbound_pcis
;
2862 irq_ptr
->output_qs
[i
]->siga_sync_done_on_outb_tis
=
2864 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2865 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
))==
2866 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2867 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
));
2873 qdio_establish_irq_check_for_errors(struct ccw_device
*cdev
, int cstat
,
2877 struct qdio_irq
*irq_ptr
;
2879 irq_ptr
= cdev
->private->qdio_data
;
2881 if (cstat
|| (dstat
& ~(DEV_STAT_CHN_END
|DEV_STAT_DEV_END
))) {
2882 sprintf(dbf_text
,"ick1%4x",irq_ptr
->schid
.sch_no
);
2883 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
2884 QDIO_DBF_HEX2(0,trace
,&dstat
,sizeof(int));
2885 QDIO_DBF_HEX2(0,trace
,&cstat
,sizeof(int));
2886 QDIO_PRINT_ERR("received check condition on establish " \
2887 "queues on irq 0.%x.%x (cs=x%x, ds=x%x).\n",
2888 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
2890 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_ERR
);
2893 if (!(dstat
& DEV_STAT_DEV_END
)) {
2894 QDIO_DBF_TEXT2(1,setup
,"eq:no de");
2895 QDIO_DBF_HEX2(0,setup
,&dstat
, sizeof(dstat
));
2896 QDIO_DBF_HEX2(0,setup
,&cstat
, sizeof(cstat
));
2897 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: didn't get "
2898 "device end: dstat=%02x, cstat=%02x\n",
2899 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
2901 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2905 if (dstat
& ~(DEV_STAT_CHN_END
|DEV_STAT_DEV_END
)) {
2906 QDIO_DBF_TEXT2(1,setup
,"eq:badio");
2907 QDIO_DBF_HEX2(0,setup
,&dstat
, sizeof(dstat
));
2908 QDIO_DBF_HEX2(0,setup
,&cstat
, sizeof(cstat
));
2909 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: got "
2910 "the following devstat: dstat=%02x, "
2911 "cstat=%02x\n", irq_ptr
->schid
.ssid
,
2912 irq_ptr
->schid
.sch_no
, dstat
, cstat
);
2913 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2920 qdio_establish_handle_irq(struct ccw_device
*cdev
, int cstat
, int dstat
)
2922 struct qdio_irq
*irq_ptr
;
2925 irq_ptr
= cdev
->private->qdio_data
;
2927 sprintf(dbf_text
,"qehi%4x",cdev
->private->schid
.sch_no
);
2928 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2929 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
2931 if (qdio_establish_irq_check_for_errors(cdev
, cstat
, dstat
)) {
2932 ccw_device_set_timeout(cdev
, 0);
2936 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_ESTABLISHED
);
2937 ccw_device_set_timeout(cdev
, 0);
2941 qdio_initialize(struct qdio_initialize
*init_data
)
2946 sprintf(dbf_text
,"qini%4x",init_data
->cdev
->private->schid
.sch_no
);
2947 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2948 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
2950 rc
= qdio_allocate(init_data
);
2952 rc
= qdio_establish(init_data
);
2954 qdio_free(init_data
->cdev
);
2962 qdio_allocate(struct qdio_initialize
*init_data
)
2964 struct qdio_irq
*irq_ptr
;
2967 sprintf(dbf_text
,"qalc%4x",init_data
->cdev
->private->schid
.sch_no
);
2968 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2969 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
2970 if ( (init_data
->no_input_qs
>QDIO_MAX_QUEUES_PER_IRQ
) ||
2971 (init_data
->no_output_qs
>QDIO_MAX_QUEUES_PER_IRQ
) ||
2972 ((init_data
->no_input_qs
) && (!init_data
->input_handler
)) ||
2973 ((init_data
->no_output_qs
) && (!init_data
->output_handler
)) )
2976 if (!init_data
->input_sbal_addr_array
)
2979 if (!init_data
->output_sbal_addr_array
)
2982 qdio_allocate_do_dbf(init_data
);
2985 irq_ptr
= (void *) get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
2987 QDIO_DBF_TEXT0(0,setup
,"irq_ptr:");
2988 QDIO_DBF_HEX0(0,setup
,&irq_ptr
,sizeof(void*));
2991 QDIO_PRINT_ERR("kmalloc of irq_ptr failed!\n");
2995 init_MUTEX(&irq_ptr
->setting_up_sema
);
2997 /* QDR must be in DMA area since CCW data address is only 32 bit */
2998 irq_ptr
->qdr
=kmalloc(sizeof(struct qdr
), GFP_KERNEL
| GFP_DMA
);
2999 if (!(irq_ptr
->qdr
)) {
3000 free_page((unsigned long) irq_ptr
);
3001 QDIO_PRINT_ERR("kmalloc of irq_ptr->qdr failed!\n");
3004 QDIO_DBF_TEXT0(0,setup
,"qdr:");
3005 QDIO_DBF_HEX0(0,setup
,&irq_ptr
->qdr
,sizeof(void*));
3007 if (qdio_alloc_qs(irq_ptr
,
3008 init_data
->no_input_qs
,
3009 init_data
->no_output_qs
)) {
3010 qdio_release_irq_memory(irq_ptr
);
3014 init_data
->cdev
->private->qdio_data
= irq_ptr
;
3016 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_INACTIVE
);
3021 int qdio_fill_irq(struct qdio_initialize
*init_data
)
3027 struct qdio_irq
*irq_ptr
;
3029 irq_ptr
= init_data
->cdev
->private->qdio_data
;
3031 memset(irq_ptr
,0,((char*)&irq_ptr
->qdr
)-((char*)irq_ptr
));
3033 /* wipes qib.ac, required by ar7063 */
3034 memset(irq_ptr
->qdr
,0,sizeof(struct qdr
));
3036 irq_ptr
->int_parm
=init_data
->int_parm
;
3038 irq_ptr
->schid
= ccw_device_get_subchannel_id(init_data
->cdev
);
3039 irq_ptr
->no_input_qs
=init_data
->no_input_qs
;
3040 irq_ptr
->no_output_qs
=init_data
->no_output_qs
;
3042 if (init_data
->q_format
==QDIO_IQDIO_QFMT
) {
3043 irq_ptr
->is_iqdio_irq
=1;
3044 irq_ptr
->is_thinint_irq
=1;
3046 irq_ptr
->is_iqdio_irq
=0;
3047 irq_ptr
->is_thinint_irq
=hydra_thinints
;
3049 sprintf(dbf_text
,"is_i_t%1x%1x",
3050 irq_ptr
->is_iqdio_irq
,irq_ptr
->is_thinint_irq
);
3051 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3053 if (irq_ptr
->is_thinint_irq
) {
3054 irq_ptr
->dev_st_chg_ind
= qdio_get_indicator();
3055 QDIO_DBF_HEX1(0,setup
,&irq_ptr
->dev_st_chg_ind
,sizeof(void*));
3056 if (!irq_ptr
->dev_st_chg_ind
) {
3057 QDIO_PRINT_WARN("no indicator location available " \
3058 "for irq 0.%x.%x\n",
3059 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
3060 qdio_release_irq_memory(irq_ptr
);
3066 irq_ptr
->equeue
.cmd
=DEFAULT_ESTABLISH_QS_CMD
;
3067 irq_ptr
->equeue
.count
=DEFAULT_ESTABLISH_QS_COUNT
;
3068 irq_ptr
->aqueue
.cmd
=DEFAULT_ACTIVATE_QS_CMD
;
3069 irq_ptr
->aqueue
.count
=DEFAULT_ACTIVATE_QS_COUNT
;
3071 qdio_fill_qs(irq_ptr
, init_data
->cdev
,
3072 init_data
->no_input_qs
,
3073 init_data
->no_output_qs
,
3074 init_data
->input_handler
,
3075 init_data
->output_handler
,init_data
->int_parm
,
3076 init_data
->q_format
,init_data
->flags
,
3077 init_data
->input_sbal_addr_array
,
3078 init_data
->output_sbal_addr_array
);
3080 if (!try_module_get(THIS_MODULE
)) {
3081 QDIO_PRINT_CRIT("try_module_get() failed!\n");
3082 qdio_release_irq_memory(irq_ptr
);
3086 qdio_fill_thresholds(irq_ptr
,init_data
->no_input_qs
,
3087 init_data
->no_output_qs
,
3088 init_data
->min_input_threshold
,
3089 init_data
->max_input_threshold
,
3090 init_data
->min_output_threshold
,
3091 init_data
->max_output_threshold
);
3094 irq_ptr
->qdr
->qfmt
=init_data
->q_format
;
3095 irq_ptr
->qdr
->iqdcnt
=init_data
->no_input_qs
;
3096 irq_ptr
->qdr
->oqdcnt
=init_data
->no_output_qs
;
3097 irq_ptr
->qdr
->iqdsz
=sizeof(struct qdesfmt0
)/4; /* size in words */
3098 irq_ptr
->qdr
->oqdsz
=sizeof(struct qdesfmt0
)/4;
3100 irq_ptr
->qdr
->qiba
=(unsigned long)&irq_ptr
->qib
;
3101 irq_ptr
->qdr
->qkey
=QDIO_STORAGE_KEY
;
3104 irq_ptr
->is_qebsm
= is_passthrough
;
3105 if (irq_ptr
->is_qebsm
)
3106 irq_ptr
->qib
.rflags
|= QIB_RFLAGS_ENABLE_QEBSM
;
3108 irq_ptr
->qib
.qfmt
=init_data
->q_format
;
3109 if (init_data
->no_input_qs
)
3110 irq_ptr
->qib
.isliba
=(unsigned long)(irq_ptr
->input_qs
[0]->slib
);
3111 if (init_data
->no_output_qs
)
3112 irq_ptr
->qib
.osliba
=(unsigned long)(irq_ptr
->output_qs
[0]->slib
);
3113 memcpy(irq_ptr
->qib
.ebcnam
,init_data
->adapter_name
,8);
3115 qdio_set_impl_params(irq_ptr
,init_data
->qib_param_field_format
,
3116 init_data
->qib_param_field
,
3117 init_data
->no_input_qs
,
3118 init_data
->no_output_qs
,
3119 init_data
->input_slib_elements
,
3120 init_data
->output_slib_elements
);
3122 /* first input descriptors, then output descriptors */
3123 is_iqdio
= (init_data
->q_format
== QDIO_IQDIO_QFMT
) ? 1 : 0;
3124 for (i
=0;i
<init_data
->no_input_qs
;i
++)
3125 qdio_allocate_fill_input_desc(irq_ptr
, i
, is_iqdio
);
3127 for (i
=0;i
<init_data
->no_output_qs
;i
++)
3128 qdio_allocate_fill_output_desc(irq_ptr
, i
,
3129 init_data
->no_input_qs
,
3132 /* qdr, qib, sls, slsbs, slibs, sbales filled. */
3134 /* get qdio commands */
3135 ciw
= ccw_device_get_ciw(init_data
->cdev
, CIW_TYPE_EQUEUE
);
3137 QDIO_DBF_TEXT2(1,setup
,"no eq");
3138 QDIO_PRINT_INFO("No equeue CIW found for QDIO commands. "
3139 "Trying to use default.\n");
3141 irq_ptr
->equeue
= *ciw
;
3142 ciw
= ccw_device_get_ciw(init_data
->cdev
, CIW_TYPE_AQUEUE
);
3144 QDIO_DBF_TEXT2(1,setup
,"no aq");
3145 QDIO_PRINT_INFO("No aqueue CIW found for QDIO commands. "
3146 "Trying to use default.\n");
3148 irq_ptr
->aqueue
= *ciw
;
3150 /* Set new interrupt handler. */
3151 irq_ptr
->original_int_handler
= init_data
->cdev
->handler
;
3152 init_data
->cdev
->handler
= qdio_handler
;
3158 qdio_establish(struct qdio_initialize
*init_data
)
3160 struct qdio_irq
*irq_ptr
;
3161 unsigned long saveflags
;
3162 int result
, result2
;
3163 struct ccw_device
*cdev
;
3166 cdev
=init_data
->cdev
;
3167 irq_ptr
= cdev
->private->qdio_data
;
3171 if (cdev
->private->state
!= DEV_STATE_ONLINE
)
3174 down(&irq_ptr
->setting_up_sema
);
3176 qdio_fill_irq(init_data
);
3178 /* the thinint CHSC stuff */
3179 if (irq_ptr
->is_thinint_irq
) {
3181 result
= tiqdio_set_subchannel_ind(irq_ptr
,0);
3183 up(&irq_ptr
->setting_up_sema
);
3184 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
3187 tiqdio_set_delay_target(irq_ptr
,TIQDIO_DELAY_TARGET
);
3190 sprintf(dbf_text
,"qest%4x",cdev
->private->schid
.sch_no
);
3191 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
3192 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
3195 irq_ptr
->ccw
.cmd_code
=irq_ptr
->equeue
.cmd
;
3196 irq_ptr
->ccw
.flags
=CCW_FLAG_SLI
;
3197 irq_ptr
->ccw
.count
=irq_ptr
->equeue
.count
;
3198 irq_ptr
->ccw
.cda
=QDIO_GET_ADDR(irq_ptr
->qdr
);
3200 spin_lock_irqsave(get_ccwdev_lock(cdev
),saveflags
);
3202 ccw_device_set_options(cdev
, 0);
3203 result
=ccw_device_start_timeout(cdev
,&irq_ptr
->ccw
,
3204 QDIO_DOING_ESTABLISH
,0, 0,
3205 QDIO_ESTABLISH_TIMEOUT
);
3207 result2
=ccw_device_start_timeout(cdev
,&irq_ptr
->ccw
,
3208 QDIO_DOING_ESTABLISH
,0,0,
3209 QDIO_ESTABLISH_TIMEOUT
);
3210 sprintf(dbf_text
,"eq:io%4x",result
);
3211 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3213 sprintf(dbf_text
,"eq:io%4x",result
);
3214 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3216 QDIO_PRINT_WARN("establish queues on irq 0.%x.%04x: do_IO " \
3217 "returned %i, next try returned %i\n",
3218 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
3222 ccw_device_set_timeout(cdev
, 0);
3225 spin_unlock_irqrestore(get_ccwdev_lock(cdev
),saveflags
);
3228 up(&irq_ptr
->setting_up_sema
);
3229 qdio_shutdown(cdev
,QDIO_FLAG_CLEANUP_USING_CLEAR
);
3233 /* Timeout is cared for already by using ccw_device_start_timeout(). */
3234 wait_event_interruptible(cdev
->private->wait_q
,
3235 irq_ptr
->state
== QDIO_IRQ_STATE_ESTABLISHED
||
3236 irq_ptr
->state
== QDIO_IRQ_STATE_ERR
);
3238 if (irq_ptr
->state
== QDIO_IRQ_STATE_ESTABLISHED
)
3241 up(&irq_ptr
->setting_up_sema
);
3242 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
3246 qdio_get_ssqd_information(irq_ptr
);
3247 /* if this gets set once, we're running under VM and can omit SVSes */
3248 if (irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_NECESSARY
)
3251 sprintf(dbf_text
,"qdioac%2x",irq_ptr
->qdioac
);
3252 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3254 sprintf(dbf_text
,"qib ac%2x",irq_ptr
->qib
.ac
);
3255 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3257 irq_ptr
->hydra_gives_outbound_pcis
=
3258 irq_ptr
->qib
.ac
&QIB_AC_OUTBOUND_PCI_SUPPORTED
;
3259 irq_ptr
->sync_done_on_outb_pcis
=
3260 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
;
3262 qdio_initialize_set_siga_flags_input(irq_ptr
);
3263 qdio_initialize_set_siga_flags_output(irq_ptr
);
3265 up(&irq_ptr
->setting_up_sema
);
3272 qdio_activate(struct ccw_device
*cdev
, int flags
)
3274 struct qdio_irq
*irq_ptr
;
3275 int i
,result
=0,result2
;
3276 unsigned long saveflags
;
3277 char dbf_text
[20]; /* see qdio_initialize */
3279 irq_ptr
= cdev
->private->qdio_data
;
3283 if (cdev
->private->state
!= DEV_STATE_ONLINE
)
3286 down(&irq_ptr
->setting_up_sema
);
3287 if (irq_ptr
->state
==QDIO_IRQ_STATE_INACTIVE
) {
3292 sprintf(dbf_text
,"qact%4x", irq_ptr
->schid
.sch_no
);
3293 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3294 QDIO_DBF_TEXT2(0,trace
,dbf_text
);
3297 irq_ptr
->ccw
.cmd_code
=irq_ptr
->aqueue
.cmd
;
3298 irq_ptr
->ccw
.flags
=CCW_FLAG_SLI
;
3299 irq_ptr
->ccw
.count
=irq_ptr
->aqueue
.count
;
3300 irq_ptr
->ccw
.cda
=QDIO_GET_ADDR(0);
3302 spin_lock_irqsave(get_ccwdev_lock(cdev
),saveflags
);
3304 ccw_device_set_timeout(cdev
, 0);
3305 ccw_device_set_options(cdev
, CCWDEV_REPORT_ALL
);
3306 result
=ccw_device_start(cdev
,&irq_ptr
->ccw
,QDIO_DOING_ACTIVATE
,
3307 0, DOIO_DENY_PREFETCH
);
3309 result2
=ccw_device_start(cdev
,&irq_ptr
->ccw
,
3310 QDIO_DOING_ACTIVATE
,0,0);
3311 sprintf(dbf_text
,"aq:io%4x",result
);
3312 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3314 sprintf(dbf_text
,"aq:io%4x",result
);
3315 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3317 QDIO_PRINT_WARN("activate queues on irq 0.%x.%04x: do_IO " \
3318 "returned %i, next try returned %i\n",
3319 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
3324 spin_unlock_irqrestore(get_ccwdev_lock(cdev
),saveflags
);
3328 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
3329 if (irq_ptr
->is_thinint_irq
) {
3331 * that way we know, that, if we will get interrupted
3332 * by tiqdio_inbound_processing, qdio_unmark_q will
3335 qdio_reserve_q(irq_ptr
->input_qs
[i
]);
3336 qdio_mark_tiq(irq_ptr
->input_qs
[i
]);
3337 qdio_release_q(irq_ptr
->input_qs
[i
]);
3341 if (flags
&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT
) {
3342 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
3343 irq_ptr
->input_qs
[i
]->is_input_q
|=
3344 QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT
;
3348 wait_event_interruptible_timeout(cdev
->private->wait_q
,
3350 QDIO_IRQ_STATE_STOPPED
) ||
3352 QDIO_IRQ_STATE_ERR
)),
3353 QDIO_ACTIVATE_TIMEOUT
);
3355 switch (irq_ptr
->state
) {
3356 case QDIO_IRQ_STATE_STOPPED
:
3357 case QDIO_IRQ_STATE_ERR
:
3358 up(&irq_ptr
->setting_up_sema
);
3359 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
3360 down(&irq_ptr
->setting_up_sema
);
3364 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ACTIVE
);
3368 up(&irq_ptr
->setting_up_sema
);
3373 /* buffers filled forwards again to make Rick happy */
3375 qdio_do_qdio_fill_input(struct qdio_q
*q
, unsigned int qidx
,
3376 unsigned int count
, struct qdio_buffer
*buffers
)
3378 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
3379 qidx
&= (QDIO_MAX_BUFFERS_PER_Q
- 1);
3380 if (irq
->is_qebsm
) {
3382 set_slsb(q
, &qidx
, SLSB_CU_INPUT_EMPTY
, &count
);
3386 set_slsb(q
, &qidx
, SLSB_CU_INPUT_EMPTY
, &count
);
3389 qidx
= (qidx
+ 1) & (QDIO_MAX_BUFFERS_PER_Q
- 1);
3394 qdio_do_qdio_fill_output(struct qdio_q
*q
, unsigned int qidx
,
3395 unsigned int count
, struct qdio_buffer
*buffers
)
3397 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
3399 qidx
&= (QDIO_MAX_BUFFERS_PER_Q
- 1);
3400 if (irq
->is_qebsm
) {
3402 set_slsb(q
, &qidx
, SLSB_CU_OUTPUT_PRIMED
, &count
);
3407 set_slsb(q
, &qidx
, SLSB_CU_OUTPUT_PRIMED
, &count
);
3410 qidx
= (qidx
+ 1) & (QDIO_MAX_BUFFERS_PER_Q
- 1);
3415 do_qdio_handle_inbound(struct qdio_q
*q
, unsigned int callflags
,
3416 unsigned int qidx
, unsigned int count
,
3417 struct qdio_buffer
*buffers
)
3421 /* This is the inbound handling of queues */
3422 used_elements
=atomic_add_return(count
, &q
->number_of_buffers_used
) - count
;
3424 qdio_do_qdio_fill_input(q
,qidx
,count
,buffers
);
3426 if ((used_elements
+count
==QDIO_MAX_BUFFERS_PER_Q
)&&
3427 (callflags
&QDIO_FLAG_UNDER_INTERRUPT
))
3428 atomic_swap(&q
->polling
,0);
3432 if (callflags
&QDIO_FLAG_DONT_SIGA
)
3437 result
=qdio_siga_input(q
);
3440 q
->error_status_flags
|=
3441 QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR
;
3442 q
->error_status_flags
|=QDIO_STATUS_LOOK_FOR_ERROR
;
3443 q
->siga_error
=result
;
3451 do_qdio_handle_outbound(struct qdio_q
*q
, unsigned int callflags
,
3452 unsigned int qidx
, unsigned int count
,
3453 struct qdio_buffer
*buffers
)
3456 unsigned int cnt
, start_buf
;
3457 unsigned char state
= 0;
3458 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
3460 /* This is the outbound handling of queues */
3461 #ifdef QDIO_PERFORMANCE_STATS
3462 perf_stats
.start_time_outbound
=NOW
;
3463 #endif /* QDIO_PERFORMANCE_STATS */
3465 qdio_do_qdio_fill_output(q
,qidx
,count
,buffers
);
3467 used_elements
=atomic_add_return(count
, &q
->number_of_buffers_used
) - count
;
3469 if (callflags
&QDIO_FLAG_DONT_SIGA
) {
3470 #ifdef QDIO_PERFORMANCE_STATS
3471 perf_stats
.outbound_time
+=NOW
-perf_stats
.start_time_outbound
;
3472 perf_stats
.outbound_cnt
++;
3473 #endif /* QDIO_PERFORMANCE_STATS */
3476 if (q
->is_iqdio_q
) {
3477 /* one siga for every sbal */
3479 qdio_kick_outbound_q(q
);
3481 __qdio_outbound_processing(q
);
3483 /* under VM, we do a SIGA sync unconditionally */
3487 * w/o shadow queues (else branch of
3488 * SYNC_MEMORY :-/ ), we try to
3489 * fast-requeue buffers
3491 if (irq
->is_qebsm
) {
3493 start_buf
= ((qidx
+QDIO_MAX_BUFFERS_PER_Q
-1) &
3494 (QDIO_MAX_BUFFERS_PER_Q
-1));
3495 qdio_do_eqbs(q
, &state
, &start_buf
, &cnt
);
3497 state
= q
->slsb
.acc
.val
[(qidx
+QDIO_MAX_BUFFERS_PER_Q
-1)
3498 &(QDIO_MAX_BUFFERS_PER_Q
-1) ];
3499 if (state
!= SLSB_CU_OUTPUT_PRIMED
) {
3500 qdio_kick_outbound_q(q
);
3502 QDIO_DBF_TEXT3(0,trace
, "fast-req");
3503 #ifdef QDIO_PERFORMANCE_STATS
3504 perf_stats
.fast_reqs
++;
3505 #endif /* QDIO_PERFORMANCE_STATS */
3509 * only marking the q could take too long,
3510 * the upper layer module could do a lot of
3511 * traffic in that time
3513 __qdio_outbound_processing(q
);
3516 #ifdef QDIO_PERFORMANCE_STATS
3517 perf_stats
.outbound_time
+=NOW
-perf_stats
.start_time_outbound
;
3518 perf_stats
.outbound_cnt
++;
3519 #endif /* QDIO_PERFORMANCE_STATS */
3522 /* count must be 1 in iqdio */
3524 do_QDIO(struct ccw_device
*cdev
,unsigned int callflags
,
3525 unsigned int queue_number
, unsigned int qidx
,
3526 unsigned int count
,struct qdio_buffer
*buffers
)
3528 struct qdio_irq
*irq_ptr
;
3529 #ifdef CONFIG_QDIO_DEBUG
3532 sprintf(dbf_text
,"doQD%04x",cdev
->private->schid
.sch_no
);
3533 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
3534 #endif /* CONFIG_QDIO_DEBUG */
3536 if ( (qidx
>QDIO_MAX_BUFFERS_PER_Q
) ||
3537 (count
>QDIO_MAX_BUFFERS_PER_Q
) ||
3538 (queue_number
>QDIO_MAX_QUEUES_PER_IRQ
) )
3544 irq_ptr
= cdev
->private->qdio_data
;
3548 #ifdef CONFIG_QDIO_DEBUG
3549 if (callflags
&QDIO_FLAG_SYNC_INPUT
)
3550 QDIO_DBF_HEX3(0,trace
,&irq_ptr
->input_qs
[queue_number
],
3553 QDIO_DBF_HEX3(0,trace
,&irq_ptr
->output_qs
[queue_number
],
3555 sprintf(dbf_text
,"flag%04x",callflags
);
3556 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
3557 sprintf(dbf_text
,"qi%02xct%02x",qidx
,count
);
3558 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
3559 #endif /* CONFIG_QDIO_DEBUG */
3561 if (irq_ptr
->state
!=QDIO_IRQ_STATE_ACTIVE
)
3564 if (callflags
&QDIO_FLAG_SYNC_INPUT
)
3565 do_qdio_handle_inbound(irq_ptr
->input_qs
[queue_number
],
3566 callflags
, qidx
, count
, buffers
);
3567 else if (callflags
&QDIO_FLAG_SYNC_OUTPUT
)
3568 do_qdio_handle_outbound(irq_ptr
->output_qs
[queue_number
],
3569 callflags
, qidx
, count
, buffers
);
3571 QDIO_DBF_TEXT3(1,trace
,"doQD:inv");
3577 #ifdef QDIO_PERFORMANCE_STATS
3579 qdio_perf_procfile_read(char *buffer
, char **buffer_location
, off_t offset
,
3580 int buffer_length
, int *eof
, void *data
)
3584 /* we are always called with buffer_length=4k, so we all
3585 deliver on the first read */
3589 #define _OUTP_IT(x...) c+=sprintf(buffer+c,x)
3590 _OUTP_IT("i_p_nc/c=%lu/%lu\n",i_p_nc
,i_p_c
);
3591 _OUTP_IT("ii_p_nc/c=%lu/%lu\n",ii_p_nc
,ii_p_c
);
3592 _OUTP_IT("o_p_nc/c=%lu/%lu\n",o_p_nc
,o_p_c
);
3593 _OUTP_IT("Number of tasklet runs (total) : %u\n",
3594 perf_stats
.tl_runs
);
3596 _OUTP_IT("Number of SIGA sync's issued : %u\n",
3597 perf_stats
.siga_syncs
);
3598 _OUTP_IT("Number of SIGA in's issued : %u\n",
3599 perf_stats
.siga_ins
);
3600 _OUTP_IT("Number of SIGA out's issued : %u\n",
3601 perf_stats
.siga_outs
);
3602 _OUTP_IT("Number of PCIs caught : %u\n",
3604 _OUTP_IT("Number of adapter interrupts caught : %u\n",
3605 perf_stats
.thinints
);
3606 _OUTP_IT("Number of fast requeues (outg. SBALs w/o SIGA) : %u\n",
3607 perf_stats
.fast_reqs
);
3609 _OUTP_IT("Total time of all inbound actions (us) incl. UL : %u\n",
3610 perf_stats
.inbound_time
);
3611 _OUTP_IT("Number of inbound transfers : %u\n",
3612 perf_stats
.inbound_cnt
);
3613 _OUTP_IT("Total time of all outbound do_QDIOs (us) : %u\n",
3614 perf_stats
.outbound_time
);
3615 _OUTP_IT("Number of do_QDIOs outbound : %u\n",
3616 perf_stats
.outbound_cnt
);
3622 static struct proc_dir_entry
*qdio_perf_proc_file
;
3623 #endif /* QDIO_PERFORMANCE_STATS */
3626 qdio_add_procfs_entry(void)
3628 #ifdef QDIO_PERFORMANCE_STATS
3629 proc_perf_file_registration
=0;
3630 qdio_perf_proc_file
=create_proc_entry(QDIO_PERF
,
3631 S_IFREG
|0444,&proc_root
);
3632 if (qdio_perf_proc_file
) {
3633 qdio_perf_proc_file
->read_proc
=&qdio_perf_procfile_read
;
3634 } else proc_perf_file_registration
=-1;
3636 if (proc_perf_file_registration
)
3637 QDIO_PRINT_WARN("was not able to register perf. " \
3638 "proc-file (%i).\n",
3639 proc_perf_file_registration
);
3640 #endif /* QDIO_PERFORMANCE_STATS */
3644 qdio_remove_procfs_entry(void)
3646 #ifdef QDIO_PERFORMANCE_STATS
3647 perf_stats
.tl_runs
=0;
3649 if (!proc_perf_file_registration
) /* means if it went ok earlier */
3650 remove_proc_entry(QDIO_PERF
,&proc_root
);
3651 #endif /* QDIO_PERFORMANCE_STATS */
3655 tiqdio_register_thinints(void)
3658 register_thinint_result
=
3659 s390_register_adapter_interrupt(&tiqdio_thinint_handler
);
3660 if (register_thinint_result
) {
3661 sprintf(dbf_text
,"regthn%x",(register_thinint_result
&0xff));
3662 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
3663 QDIO_PRINT_ERR("failed to register adapter handler " \
3664 "(rc=%i).\nAdapter interrupts might " \
3665 "not work. Continuing.\n",
3666 register_thinint_result
);
3671 tiqdio_unregister_thinints(void)
3673 if (!register_thinint_result
)
3674 s390_unregister_adapter_interrupt(&tiqdio_thinint_handler
);
3678 qdio_get_qdio_memory(void)
3681 indicator_used
[0]=1;
3683 for (i
=1;i
<INDICATORS_PER_CACHELINE
;i
++)
3684 indicator_used
[i
]=0;
3685 indicators
= kzalloc(sizeof(__u32
)*(INDICATORS_PER_CACHELINE
),
3693 qdio_release_qdio_memory(void)
3699 qdio_unregister_dbf_views(void)
3702 debug_unregister(qdio_dbf_setup
);
3704 debug_unregister(qdio_dbf_sbal
);
3706 debug_unregister(qdio_dbf_sense
);
3708 debug_unregister(qdio_dbf_trace
);
3709 #ifdef CONFIG_QDIO_DEBUG
3710 if (qdio_dbf_slsb_out
)
3711 debug_unregister(qdio_dbf_slsb_out
);
3712 if (qdio_dbf_slsb_in
)
3713 debug_unregister(qdio_dbf_slsb_in
);
3714 #endif /* CONFIG_QDIO_DEBUG */
3718 qdio_register_dbf_views(void)
3720 qdio_dbf_setup
=debug_register(QDIO_DBF_SETUP_NAME
,
3721 QDIO_DBF_SETUP_PAGES
,
3722 QDIO_DBF_SETUP_NR_AREAS
,
3723 QDIO_DBF_SETUP_LEN
);
3724 if (!qdio_dbf_setup
)
3726 debug_register_view(qdio_dbf_setup
,&debug_hex_ascii_view
);
3727 debug_set_level(qdio_dbf_setup
,QDIO_DBF_SETUP_LEVEL
);
3729 qdio_dbf_sbal
=debug_register(QDIO_DBF_SBAL_NAME
,
3730 QDIO_DBF_SBAL_PAGES
,
3731 QDIO_DBF_SBAL_NR_AREAS
,
3736 debug_register_view(qdio_dbf_sbal
,&debug_hex_ascii_view
);
3737 debug_set_level(qdio_dbf_sbal
,QDIO_DBF_SBAL_LEVEL
);
3739 qdio_dbf_sense
=debug_register(QDIO_DBF_SENSE_NAME
,
3740 QDIO_DBF_SENSE_PAGES
,
3741 QDIO_DBF_SENSE_NR_AREAS
,
3742 QDIO_DBF_SENSE_LEN
);
3743 if (!qdio_dbf_sense
)
3746 debug_register_view(qdio_dbf_sense
,&debug_hex_ascii_view
);
3747 debug_set_level(qdio_dbf_sense
,QDIO_DBF_SENSE_LEVEL
);
3749 qdio_dbf_trace
=debug_register(QDIO_DBF_TRACE_NAME
,
3750 QDIO_DBF_TRACE_PAGES
,
3751 QDIO_DBF_TRACE_NR_AREAS
,
3752 QDIO_DBF_TRACE_LEN
);
3753 if (!qdio_dbf_trace
)
3756 debug_register_view(qdio_dbf_trace
,&debug_hex_ascii_view
);
3757 debug_set_level(qdio_dbf_trace
,QDIO_DBF_TRACE_LEVEL
);
3759 #ifdef CONFIG_QDIO_DEBUG
3760 qdio_dbf_slsb_out
=debug_register(QDIO_DBF_SLSB_OUT_NAME
,
3761 QDIO_DBF_SLSB_OUT_PAGES
,
3762 QDIO_DBF_SLSB_OUT_NR_AREAS
,
3763 QDIO_DBF_SLSB_OUT_LEN
);
3764 if (!qdio_dbf_slsb_out
)
3766 debug_register_view(qdio_dbf_slsb_out
,&debug_hex_ascii_view
);
3767 debug_set_level(qdio_dbf_slsb_out
,QDIO_DBF_SLSB_OUT_LEVEL
);
3769 qdio_dbf_slsb_in
=debug_register(QDIO_DBF_SLSB_IN_NAME
,
3770 QDIO_DBF_SLSB_IN_PAGES
,
3771 QDIO_DBF_SLSB_IN_NR_AREAS
,
3772 QDIO_DBF_SLSB_IN_LEN
);
3773 if (!qdio_dbf_slsb_in
)
3775 debug_register_view(qdio_dbf_slsb_in
,&debug_hex_ascii_view
);
3776 debug_set_level(qdio_dbf_slsb_in
,QDIO_DBF_SLSB_IN_LEVEL
);
3777 #endif /* CONFIG_QDIO_DEBUG */
3780 QDIO_PRINT_ERR("not enough memory for dbf.\n");
3781 qdio_unregister_dbf_views();
3785 static void *qdio_mempool_alloc(gfp_t gfp_mask
, void *size
)
3787 return (void *) get_zeroed_page(gfp_mask
|GFP_DMA
);
3790 static void qdio_mempool_free(void *element
, void *size
)
3792 free_page((unsigned long) element
);
3799 #ifdef QDIO_PERFORMANCE_STATS
3801 #endif /* QDIO_PERFORMANCE_STATS */
3803 printk("qdio: loading %s\n",version
);
3805 res
=qdio_get_qdio_memory();
3809 res
= qdio_register_dbf_views();
3813 QDIO_DBF_TEXT0(0,setup
,"initQDIO");
3815 #ifdef QDIO_PERFORMANCE_STATS
3816 memset((void*)&perf_stats
,0,sizeof(perf_stats
));
3817 QDIO_DBF_TEXT0(0,setup
,"perfstat");
3819 QDIO_DBF_HEX0(0,setup
,&ptr
,sizeof(void*));
3820 #endif /* QDIO_PERFORMANCE_STATS */
3822 qdio_add_procfs_entry();
3824 qdio_mempool_scssc
= mempool_create(QDIO_MEMPOOL_SCSSC_ELEMENTS
,
3826 qdio_mempool_free
, NULL
);
3828 if (tiqdio_check_chsc_availability())
3829 QDIO_PRINT_ERR("Not all CHSCs supported. Continuing.\n");
3831 tiqdio_register_thinints();
3839 tiqdio_unregister_thinints();
3840 qdio_remove_procfs_entry();
3841 qdio_release_qdio_memory();
3842 qdio_unregister_dbf_views();
3843 mempool_destroy(qdio_mempool_scssc
);
3845 printk("qdio: %s: module removed\n",version
);
3848 module_init(init_QDIO
);
3849 module_exit(cleanup_QDIO
);
3851 EXPORT_SYMBOL(qdio_allocate
);
3852 EXPORT_SYMBOL(qdio_establish
);
3853 EXPORT_SYMBOL(qdio_initialize
);
3854 EXPORT_SYMBOL(qdio_activate
);
3855 EXPORT_SYMBOL(do_QDIO
);
3856 EXPORT_SYMBOL(qdio_shutdown
);
3857 EXPORT_SYMBOL(qdio_free
);
3858 EXPORT_SYMBOL(qdio_cleanup
);
3859 EXPORT_SYMBOL(qdio_synchronize
);