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>
49 #include <asm/s390_rdev.h>
60 /****************** MODULE PARAMETER VARIABLES ********************/
61 MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>");
62 MODULE_DESCRIPTION("QDIO base support version 2, " \
63 "Copyright 2000 IBM Corporation");
64 MODULE_LICENSE("GPL");
66 /******************** HERE WE GO ***********************************/
68 static const char version
[] = "QDIO base support version 2";
70 static int qdio_performance_stats
= 0;
71 static int proc_perf_file_registration
;
72 static struct qdio_perf_stats perf_stats
;
74 static int hydra_thinints
;
75 static int is_passthrough
= 0;
78 static int indicator_used
[INDICATORS_PER_CACHELINE
];
79 static __u32
* volatile indicators
;
80 static __u32
volatile spare_indicator
;
81 static atomic_t spare_indicator_usecount
;
82 #define QDIO_MEMPOOL_SCSSC_ELEMENTS 2
83 static mempool_t
*qdio_mempool_scssc
;
85 static debug_info_t
*qdio_dbf_setup
;
86 static debug_info_t
*qdio_dbf_sbal
;
87 static debug_info_t
*qdio_dbf_trace
;
88 static debug_info_t
*qdio_dbf_sense
;
89 #ifdef CONFIG_QDIO_DEBUG
90 static debug_info_t
*qdio_dbf_slsb_out
;
91 static debug_info_t
*qdio_dbf_slsb_in
;
92 #endif /* CONFIG_QDIO_DEBUG */
95 static volatile struct qdio_q
*tiq_list
=NULL
; /* volatile as it could change
96 during a while loop */
97 static DEFINE_SPINLOCK(ttiq_list_lock
);
98 static int register_thinint_result
;
99 static void tiqdio_tl(unsigned long);
100 static DECLARE_TASKLET(tiqdio_tasklet
,tiqdio_tl
,0);
102 /* not a macro, as one of the arguments is atomic_read */
104 qdio_min(int a
,int b
)
112 /***************** SCRUBBER HELPER ROUTINES **********************/
114 static inline void qdio_perf_stat_inc(atomic64_t
*count
)
116 if (qdio_performance_stats
)
120 static inline void qdio_perf_stat_dec(atomic64_t
*count
)
122 if (qdio_performance_stats
)
125 #else /* CONFIG_64BIT */
126 static inline void qdio_perf_stat_inc(atomic_t
*count
)
128 if (qdio_performance_stats
)
132 static inline void qdio_perf_stat_dec(atomic_t
*count
)
134 if (qdio_performance_stats
)
137 #endif /* CONFIG_64BIT */
140 qdio_get_micros(void)
142 return (get_clock() >> 12); /* time>>12 is microseconds */
146 * unfortunately, we can't just xchg the values; in do_QDIO we want to reserve
147 * the q in any case, so that we'll not be interrupted when we are in
148 * qdio_mark_tiq... shouldn't have a really bad impact, as reserving almost
149 * ever works (last famous words)
152 qdio_reserve_q(struct qdio_q
*q
)
154 return atomic_add_return(1,&q
->use_count
) - 1;
158 qdio_release_q(struct qdio_q
*q
)
160 atomic_dec(&q
->use_count
);
165 qdio_check_ccq(struct qdio_q
*q
, unsigned int ccq
)
169 if (ccq
== 0 || ccq
== 32 || ccq
== 96)
173 /*notify devices immediately*/
174 sprintf(dbf_text
,"%d", ccq
);
175 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
178 /* EQBS: extract buffer states */
180 qdio_do_eqbs(struct qdio_q
*q
, unsigned char *state
,
181 unsigned int *start
, unsigned int *cnt
)
183 struct qdio_irq
*irq
;
184 unsigned int tmp_cnt
, q_no
, ccq
;
190 irq
= (struct qdio_irq
*)q
->irq_ptr
;
193 q_no
+= irq
->no_input_qs
;
195 ccq
= do_eqbs(irq
->sch_token
, state
, q_no
, start
, cnt
);
196 rc
= qdio_check_ccq(q
, ccq
);
198 QDIO_DBF_TEXT5(1,trace
,"eqAGAIN");
202 QDIO_DBF_TEXT2(1,trace
,"eqberr");
203 sprintf(dbf_text
,"%2x,%2x,%d,%d",tmp_cnt
, *cnt
, ccq
, q_no
);
204 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
205 q
->handler(q
->cdev
,QDIO_STATUS_ACTIVATE_CHECK_CONDITION
|
206 QDIO_STATUS_LOOK_FOR_ERROR
,
207 0, 0, 0, -1, -1, q
->int_parm
);
210 return (tmp_cnt
- *cnt
);
213 /* SQBS: set buffer states */
215 qdio_do_sqbs(struct qdio_q
*q
, unsigned char state
,
216 unsigned int *start
, unsigned int *cnt
)
218 struct qdio_irq
*irq
;
219 unsigned int tmp_cnt
, q_no
, ccq
;
225 irq
= (struct qdio_irq
*)q
->irq_ptr
;
228 q_no
+= irq
->no_input_qs
;
230 ccq
= do_sqbs(irq
->sch_token
, state
, q_no
, start
, cnt
);
231 rc
= qdio_check_ccq(q
, ccq
);
233 QDIO_DBF_TEXT5(1,trace
,"sqAGAIN");
237 QDIO_DBF_TEXT3(1,trace
,"sqberr");
238 sprintf(dbf_text
,"%2x,%2x",tmp_cnt
,*cnt
);
239 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
240 sprintf(dbf_text
,"%d,%d",ccq
,q_no
);
241 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
242 q
->handler(q
->cdev
,QDIO_STATUS_ACTIVATE_CHECK_CONDITION
|
243 QDIO_STATUS_LOOK_FOR_ERROR
,
244 0, 0, 0, -1, -1, q
->int_parm
);
247 return (tmp_cnt
- *cnt
);
251 qdio_set_slsb(struct qdio_q
*q
, unsigned int *bufno
,
252 unsigned char state
, unsigned int *count
)
255 struct qdio_irq
*irq
;
257 irq
= (struct qdio_irq
*)q
->irq_ptr
;
258 if (!irq
->is_qebsm
) {
259 slsb
= (char *)&q
->slsb
.acc
.val
[(*bufno
)];
263 return qdio_do_sqbs(q
, state
, bufno
, count
);
266 #ifdef CONFIG_QDIO_DEBUG
268 qdio_trace_slsb(struct qdio_q
*q
)
270 if (q
->queue_type
==QDIO_TRACE_QTYPE
) {
272 QDIO_DBF_HEX2(0,slsb_in
,&q
->slsb
,
273 QDIO_MAX_BUFFERS_PER_Q
);
275 QDIO_DBF_HEX2(0,slsb_out
,&q
->slsb
,
276 QDIO_MAX_BUFFERS_PER_Q
);
282 set_slsb(struct qdio_q
*q
, unsigned int *bufno
,
283 unsigned char state
, unsigned int *count
)
286 #ifdef CONFIG_QDIO_DEBUG
289 rc
= qdio_set_slsb(q
, bufno
, state
, count
);
290 #ifdef CONFIG_QDIO_DEBUG
296 qdio_siga_sync(struct qdio_q
*q
, unsigned int gpr2
,
301 QDIO_DBF_TEXT4(0,trace
,"sigasync");
302 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
304 qdio_perf_stat_inc(&perf_stats
.siga_syncs
);
306 cc
= do_siga_sync(q
->schid
, gpr2
, gpr3
);
308 QDIO_DBF_HEX3(0,trace
,&cc
,sizeof(int*));
314 qdio_siga_sync_q(struct qdio_q
*q
)
317 return qdio_siga_sync(q
, 0, q
->mask
);
318 return qdio_siga_sync(q
, q
->mask
, 0);
322 __do_siga_output(struct qdio_q
*q
, unsigned int *busy_bit
)
324 struct qdio_irq
*irq
;
328 irq
= (struct qdio_irq
*) q
->irq_ptr
;
330 schid
= *((u32
*)&q
->schid
);
332 schid
= irq
->sch_token
;
335 return do_siga_output(schid
, q
->mask
, busy_bit
, fc
);
339 * returns QDIO_SIGA_ERROR_ACCESS_EXCEPTION as cc, when SIGA returns
340 * an access exception
343 qdio_siga_output(struct qdio_q
*q
)
349 qdio_perf_stat_inc(&perf_stats
.siga_outs
);
351 QDIO_DBF_TEXT4(0,trace
,"sigaout");
352 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
355 cc
= __do_siga_output(q
, &busy_bit
);
356 //QDIO_PRINT_ERR("cc=%x, busy=%x\n",cc,busy_bit);
357 if ((cc
==2) && (busy_bit
) && (q
->is_iqdio_q
)) {
360 if ((NOW
-start_time
)>QDIO_BUSY_BIT_PATIENCE
)
366 if ((cc
==2) && (busy_bit
))
367 cc
|= QDIO_SIGA_ERROR_B_BIT_SET
;
370 QDIO_DBF_HEX3(0,trace
,&cc
,sizeof(int*));
376 qdio_siga_input(struct qdio_q
*q
)
380 QDIO_DBF_TEXT4(0,trace
,"sigain");
381 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
383 qdio_perf_stat_inc(&perf_stats
.siga_ins
);
385 cc
= do_siga_input(q
->schid
, q
->mask
);
388 QDIO_DBF_HEX3(0,trace
,&cc
,sizeof(int*));
393 /* locked by the locks in qdio_activate and qdio_cleanup */
395 qdio_get_indicator(void)
399 for (i
=1;i
<INDICATORS_PER_CACHELINE
;i
++)
400 if (!indicator_used
[i
]) {
404 atomic_inc(&spare_indicator_usecount
);
405 return (__u32
* volatile) &spare_indicator
;
408 /* locked by the locks in qdio_activate and qdio_cleanup */
410 qdio_put_indicator(__u32
*addr
)
414 if ( (addr
) && (addr
!=&spare_indicator
) ) {
418 if (addr
== &spare_indicator
)
419 atomic_dec(&spare_indicator_usecount
);
423 tiqdio_clear_summary_bit(__u32
*location
)
425 QDIO_DBF_TEXT5(0,trace
,"clrsummb");
426 QDIO_DBF_HEX5(0,trace
,&location
,sizeof(void*));
432 tiqdio_set_summary_bit(__u32
*location
)
434 QDIO_DBF_TEXT5(0,trace
,"setsummb");
435 QDIO_DBF_HEX5(0,trace
,&location
,sizeof(void*));
441 tiqdio_sched_tl(void)
443 tasklet_hi_schedule(&tiqdio_tasklet
);
447 qdio_mark_tiq(struct qdio_q
*q
)
451 QDIO_DBF_TEXT4(0,trace
,"mark iq");
452 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
454 spin_lock_irqsave(&ttiq_list_lock
,flags
);
455 if (unlikely(atomic_read(&q
->is_in_shutdown
)))
461 if ((q
->list_prev
) || (q
->list_next
))
469 q
->list_next
=tiq_list
;
470 q
->list_prev
=tiq_list
->list_prev
;
471 tiq_list
->list_prev
->list_next
=q
;
472 tiq_list
->list_prev
=q
;
474 spin_unlock_irqrestore(&ttiq_list_lock
,flags
);
476 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
480 spin_unlock_irqrestore(&ttiq_list_lock
,flags
);
485 qdio_mark_q(struct qdio_q
*q
)
487 QDIO_DBF_TEXT4(0,trace
,"mark q");
488 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
490 if (unlikely(atomic_read(&q
->is_in_shutdown
)))
493 tasklet_schedule(&q
->tasklet
);
497 qdio_stop_polling(struct qdio_q
*q
)
499 #ifdef QDIO_USE_PROCESSING_STATE
500 unsigned int tmp
, gsf
, count
= 1;
501 unsigned char state
= 0;
502 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
504 if (!atomic_xchg(&q
->polling
,0))
507 QDIO_DBF_TEXT4(0,trace
,"stoppoll");
508 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
510 /* show the card that we are not polling anymore */
514 tmp
= gsf
= GET_SAVED_FRONTIER(q
);
515 tmp
= ((tmp
+ QDIO_MAX_BUFFERS_PER_Q
-1) & (QDIO_MAX_BUFFERS_PER_Q
-1) );
516 set_slsb(q
, &tmp
, SLSB_P_INPUT_NOT_INIT
, &count
);
519 * we don't issue this SYNC_MEMORY, as we trust Rick T and
520 * moreover will not use the PROCESSING state under VM, so
521 * q->polling was 0 anyway
526 qdio_do_eqbs(q
, &state
, &gsf
, &count
);
528 state
= q
->slsb
.acc
.val
[gsf
];
529 if (state
!= SLSB_P_INPUT_PRIMED
)
532 * set our summary bit again, as otherwise there is a
533 * small window we can miss between resetting it and
534 * checking for PRIMED state
537 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
540 #else /* QDIO_USE_PROCESSING_STATE */
542 #endif /* QDIO_USE_PROCESSING_STATE */
546 * see the comment in do_QDIO and before qdio_reserve_q about the
547 * sophisticated locking outside of unmark_q, so that we don't need to
548 * disable the interrupts :-)
551 qdio_unmark_q(struct qdio_q
*q
)
555 QDIO_DBF_TEXT4(0,trace
,"unmark q");
556 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
558 if ((!q
->list_prev
)||(!q
->list_next
))
561 if ((q
->is_thinint_q
)&&(q
->is_input_q
)) {
563 spin_lock_irqsave(&ttiq_list_lock
,flags
);
564 /* in case cleanup has done this already and simultanously
565 * qdio_unmark_q is called from the interrupt handler, we've
566 * got to check this in this specific case again */
567 if ((!q
->list_prev
)||(!q
->list_next
))
569 if (q
->list_next
==q
) {
570 /* q was the only interesting q */
575 q
->list_next
->list_prev
=q
->list_prev
;
576 q
->list_prev
->list_next
=q
->list_next
;
577 tiq_list
=q
->list_next
;
582 spin_unlock_irqrestore(&ttiq_list_lock
,flags
);
586 static inline unsigned long
587 tiqdio_clear_global_summary(void)
591 QDIO_DBF_TEXT5(0,trace
,"clrglobl");
593 time
= do_clear_global_summary();
595 QDIO_DBF_HEX5(0,trace
,&time
,sizeof(unsigned long));
601 /************************* OUTBOUND ROUTINES *******************************/
603 qdio_qebsm_get_outbound_buffer_frontier(struct qdio_q
*q
)
605 struct qdio_irq
*irq
;
607 unsigned int cnt
, count
, ftc
;
609 irq
= (struct qdio_irq
*) q
->irq_ptr
;
610 if ((!q
->is_iqdio_q
) && (!q
->hydra_gives_outbound_pcis
))
613 ftc
= q
->first_to_check
;
614 count
= qdio_min(atomic_read(&q
->number_of_buffers_used
),
615 (QDIO_MAX_BUFFERS_PER_Q
-1));
617 return q
->first_to_check
;
618 cnt
= qdio_do_eqbs(q
, &state
, &ftc
, &count
);
620 return q
->first_to_check
;
622 case SLSB_P_OUTPUT_ERROR
:
623 QDIO_DBF_TEXT3(0,trace
,"outperr");
624 atomic_sub(cnt
, &q
->number_of_buffers_used
);
626 q
->error_status_flags
|=
627 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
628 q
->qdio_error
= SLSB_P_OUTPUT_ERROR
;
629 q
->error_status_flags
|= QDIO_STATUS_LOOK_FOR_ERROR
;
630 q
->first_to_check
= ftc
;
632 case SLSB_P_OUTPUT_EMPTY
:
633 QDIO_DBF_TEXT5(0,trace
,"outpempt");
634 atomic_sub(cnt
, &q
->number_of_buffers_used
);
635 q
->first_to_check
= ftc
;
637 case SLSB_CU_OUTPUT_PRIMED
:
638 /* all buffers primed */
639 QDIO_DBF_TEXT5(0,trace
,"outpprim");
644 QDIO_DBF_HEX4(0,trace
,&q
->first_to_check
,sizeof(int));
645 return q
->first_to_check
;
649 qdio_qebsm_get_inbound_buffer_frontier(struct qdio_q
*q
)
651 struct qdio_irq
*irq
;
653 int tmp
, ftc
, count
, cnt
;
657 irq
= (struct qdio_irq
*) q
->irq_ptr
;
658 ftc
= q
->first_to_check
;
659 count
= qdio_min(atomic_read(&q
->number_of_buffers_used
),
660 (QDIO_MAX_BUFFERS_PER_Q
-1));
662 return q
->first_to_check
;
663 cnt
= qdio_do_eqbs(q
, &state
, &ftc
, &count
);
665 return q
->first_to_check
;
667 case SLSB_P_INPUT_ERROR
:
668 #ifdef CONFIG_QDIO_DEBUG
669 QDIO_DBF_TEXT3(1,trace
,"inperr");
670 sprintf(dbf_text
,"%2x,%2x",ftc
,count
);
671 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
672 #endif /* CONFIG_QDIO_DEBUG */
674 q
->error_status_flags
|=
675 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
676 q
->qdio_error
= SLSB_P_INPUT_ERROR
;
677 q
->error_status_flags
|= QDIO_STATUS_LOOK_FOR_ERROR
;
678 atomic_sub(cnt
, &q
->number_of_buffers_used
);
679 q
->first_to_check
= ftc
;
681 case SLSB_P_INPUT_PRIMED
:
682 QDIO_DBF_TEXT3(0,trace
,"inptprim");
683 sprintf(dbf_text
,"%2x,%2x",ftc
,count
);
684 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
686 ftc
= q
->first_to_check
;
687 #ifdef QDIO_USE_PROCESSING_STATE
690 tmp
= set_slsb(q
, &ftc
, SLSB_P_INPUT_NOT_INIT
, &cnt
);
695 tmp
+= set_slsb(q
, &ftc
,
696 SLSB_P_INPUT_PROCESSING
, &cnt
);
697 atomic_set(&q
->polling
, 1);
699 tmp
= set_slsb(q
, &ftc
, SLSB_P_INPUT_NOT_INIT
, &cnt
);
701 atomic_sub(tmp
, &q
->number_of_buffers_used
);
702 q
->first_to_check
= ftc
;
704 case SLSB_CU_INPUT_EMPTY
:
705 case SLSB_P_INPUT_NOT_INIT
:
706 case SLSB_P_INPUT_PROCESSING
:
707 QDIO_DBF_TEXT5(0,trace
,"inpnipro");
712 QDIO_DBF_HEX4(0,trace
,&q
->first_to_check
,sizeof(int));
713 return q
->first_to_check
;
717 qdio_get_outbound_buffer_frontier(struct qdio_q
*q
)
719 struct qdio_irq
*irq
;
721 unsigned int count
= 1;
722 int first_not_to_check
, f
, f_mod_no
;
725 QDIO_DBF_TEXT4(0,trace
,"getobfro");
726 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
728 irq
= (struct qdio_irq
*) q
->irq_ptr
;
730 return qdio_qebsm_get_outbound_buffer_frontier(q
);
732 slsb
=&q
->slsb
.acc
.val
[0];
733 f_mod_no
=f
=q
->first_to_check
;
735 * f points to already processed elements, so f+no_used is correct...
736 * ... but: we don't check 128 buffers, as otherwise
737 * qdio_has_outbound_q_moved would return 0
739 first_not_to_check
=f
+qdio_min(atomic_read(&q
->number_of_buffers_used
),
740 (QDIO_MAX_BUFFERS_PER_Q
-1));
742 if ((!q
->is_iqdio_q
)&&(!q
->hydra_gives_outbound_pcis
))
746 if (f
==first_not_to_check
)
749 switch(slsb
[f_mod_no
]) {
751 /* the adapter has not fetched the output yet */
752 case SLSB_CU_OUTPUT_PRIMED
:
753 QDIO_DBF_TEXT5(0,trace
,"outpprim");
756 /* the adapter got it */
757 case SLSB_P_OUTPUT_EMPTY
:
758 atomic_dec(&q
->number_of_buffers_used
);
760 f_mod_no
=f
&(QDIO_MAX_BUFFERS_PER_Q
-1);
761 QDIO_DBF_TEXT5(0,trace
,"outpempt");
764 case SLSB_P_OUTPUT_ERROR
:
765 QDIO_DBF_TEXT3(0,trace
,"outperr");
766 sprintf(dbf_text
,"%x-%x-%x",f_mod_no
,
767 q
->sbal
[f_mod_no
]->element
[14].sbalf
.value
,
768 q
->sbal
[f_mod_no
]->element
[15].sbalf
.value
);
769 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
770 QDIO_DBF_HEX2(1,sbal
,q
->sbal
[f_mod_no
],256);
772 /* kind of process the buffer */
773 set_slsb(q
, &f_mod_no
, SLSB_P_OUTPUT_NOT_INIT
, &count
);
776 * we increment the frontier, as this buffer
777 * was processed obviously
779 atomic_dec(&q
->number_of_buffers_used
);
780 f_mod_no
=(f_mod_no
+1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
783 q
->error_status_flags
|=
784 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
785 q
->qdio_error
=SLSB_P_OUTPUT_ERROR
;
786 q
->error_status_flags
|=QDIO_STATUS_LOOK_FOR_ERROR
;
792 QDIO_DBF_TEXT5(0,trace
,"outpni");
795 return (q
->first_to_check
=f_mod_no
);
798 /* all buffers are processed */
800 qdio_is_outbound_q_done(struct qdio_q
*q
)
803 #ifdef CONFIG_QDIO_DEBUG
807 no_used
=atomic_read(&q
->number_of_buffers_used
);
809 #ifdef CONFIG_QDIO_DEBUG
811 sprintf(dbf_text
,"oqisnt%02x",no_used
);
812 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
814 QDIO_DBF_TEXT4(0,trace
,"oqisdone");
816 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
817 #endif /* CONFIG_QDIO_DEBUG */
822 qdio_has_outbound_q_moved(struct qdio_q
*q
)
826 i
=qdio_get_outbound_buffer_frontier(q
);
828 if ( (i
!=GET_SAVED_FRONTIER(q
)) ||
829 (q
->error_status_flags
&QDIO_STATUS_LOOK_FOR_ERROR
) ) {
831 QDIO_DBF_TEXT4(0,trace
,"oqhasmvd");
832 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
835 QDIO_DBF_TEXT4(0,trace
,"oqhsntmv");
836 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
842 qdio_kick_outbound_q(struct qdio_q
*q
)
845 #ifdef CONFIG_QDIO_DEBUG
848 QDIO_DBF_TEXT4(0,trace
,"kickoutq");
849 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
850 #endif /* CONFIG_QDIO_DEBUG */
855 /* here's the story with cc=2 and busy bit set (thanks, Rick):
856 * VM's CP could present us cc=2 and busy bit set on SIGA-write
857 * during reconfiguration of their Guest LAN (only in HIPERS mode,
858 * QDIO mode is asynchronous -- cc=2 and busy bit there will take
859 * the queues down immediately; and not being under VM we have a
860 * problem on cc=2 and busy bit set right away).
862 * Therefore qdio_siga_output will try for a short time constantly,
863 * if such a condition occurs. If it doesn't change, it will
864 * increase the busy_siga_counter and save the timestamp, and
865 * schedule the queue for later processing (via mark_q, using the
866 * queue tasklet). __qdio_outbound_processing will check out the
867 * counter. If non-zero, it will call qdio_kick_outbound_q as often
868 * as the value of the counter. This will attempt further SIGA
869 * instructions. For each successful SIGA, the counter is
870 * decreased, for failing SIGAs the counter remains the same, after
872 * After some time of no movement, qdio_kick_outbound_q will
873 * finally fail and reflect corresponding error codes to call
874 * the upper layer module and have it take the queues down.
876 * Note that this is a change from the original HiperSockets design
877 * (saying cc=2 and busy bit means take the queues down), but in
878 * these days Guest LAN didn't exist... excessive cc=2 with busy bit
879 * conditions will still take the queues down, but the threshold is
880 * higher due to the Guest LAN environment.
884 result
=qdio_siga_output(q
);
888 /* went smooth this time, reset timestamp */
889 #ifdef CONFIG_QDIO_DEBUG
890 QDIO_DBF_TEXT3(0,trace
,"cc2reslv");
891 sprintf(dbf_text
,"%4x%2x%2x",q
->schid
.sch_no
,q
->q_no
,
892 atomic_read(&q
->busy_siga_counter
));
893 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
894 #endif /* CONFIG_QDIO_DEBUG */
895 q
->timing
.busy_start
=0;
897 case (2|QDIO_SIGA_ERROR_B_BIT_SET
):
898 /* cc=2 and busy bit: */
899 atomic_inc(&q
->busy_siga_counter
);
901 /* if the last siga was successful, save
903 if (!q
->timing
.busy_start
)
904 q
->timing
.busy_start
=NOW
;
906 /* if we're in time, don't touch error_status_flags
908 if (NOW
-q
->timing
.busy_start
<QDIO_BUSY_BIT_GIVE_UP
) {
912 QDIO_DBF_TEXT2(0,trace
,"cc2REPRT");
913 #ifdef CONFIG_QDIO_DEBUG
914 sprintf(dbf_text
,"%4x%2x%2x",q
->schid
.sch_no
,q
->q_no
,
915 atomic_read(&q
->busy_siga_counter
));
916 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
917 #endif /* CONFIG_QDIO_DEBUG */
918 /* else fallthrough and report error */
920 /* for plain cc=1, 2 or 3: */
922 q
->error_status_flags
|=
923 QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR
;
924 q
->error_status_flags
|=
925 QDIO_STATUS_LOOK_FOR_ERROR
;
926 q
->siga_error
=result
;
931 qdio_kick_outbound_handler(struct qdio_q
*q
)
933 int start
, end
, real_end
, count
;
934 #ifdef CONFIG_QDIO_DEBUG
938 start
= q
->first_element_to_kick
;
939 /* last_move_ftc was just updated */
940 real_end
= GET_SAVED_FRONTIER(q
);
941 end
= (real_end
+QDIO_MAX_BUFFERS_PER_Q
-1)&
942 (QDIO_MAX_BUFFERS_PER_Q
-1);
943 count
= (end
+QDIO_MAX_BUFFERS_PER_Q
+1-start
)&
944 (QDIO_MAX_BUFFERS_PER_Q
-1);
946 #ifdef CONFIG_QDIO_DEBUG
947 QDIO_DBF_TEXT4(0,trace
,"kickouth");
948 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
950 sprintf(dbf_text
,"s=%2xc=%2x",start
,count
);
951 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
952 #endif /* CONFIG_QDIO_DEBUG */
954 if (q
->state
==QDIO_IRQ_STATE_ACTIVE
)
955 q
->handler(q
->cdev
,QDIO_STATUS_OUTBOUND_INT
|
956 q
->error_status_flags
,
957 q
->qdio_error
,q
->siga_error
,q
->q_no
,start
,count
,
960 /* for the next time: */
961 q
->first_element_to_kick
=real_end
;
964 q
->error_status_flags
=0;
968 __qdio_outbound_processing(struct qdio_q
*q
)
972 QDIO_DBF_TEXT4(0,trace
,"qoutproc");
973 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
975 if (unlikely(qdio_reserve_q(q
))) {
977 qdio_perf_stat_inc(&perf_stats
.outbound_tl_runs_resched
);
978 /* as we're sissies, we'll check next time */
979 if (likely(!atomic_read(&q
->is_in_shutdown
))) {
981 QDIO_DBF_TEXT4(0,trace
,"busy,agn");
985 qdio_perf_stat_inc(&perf_stats
.outbound_tl_runs
);
986 qdio_perf_stat_inc(&perf_stats
.tl_runs
);
988 /* see comment in qdio_kick_outbound_q */
989 siga_attempts
=atomic_read(&q
->busy_siga_counter
);
990 while (siga_attempts
) {
991 atomic_dec(&q
->busy_siga_counter
);
992 qdio_kick_outbound_q(q
);
996 if (qdio_has_outbound_q_moved(q
))
997 qdio_kick_outbound_handler(q
);
999 if (q
->queue_type
== QDIO_ZFCP_QFMT
) {
1000 if ((!q
->hydra_gives_outbound_pcis
) &&
1001 (!qdio_is_outbound_q_done(q
)))
1004 else if (((!q
->is_iqdio_q
) && (!q
->is_pci_out
)) ||
1005 (q
->queue_type
== QDIO_IQDIO_QFMT_ASYNCH
)) {
1007 * make sure buffer switch from PRIMED to EMPTY is noticed
1008 * and outbound_handler is called
1010 if (qdio_is_outbound_q_done(q
)) {
1011 del_timer(&q
->timer
);
1013 if (!timer_pending(&q
->timer
))
1014 mod_timer(&q
->timer
, jiffies
+
1015 QDIO_FORCE_CHECK_TIMEOUT
);
1023 qdio_outbound_processing(struct qdio_q
*q
)
1025 __qdio_outbound_processing(q
);
1028 /************************* INBOUND ROUTINES *******************************/
1032 qdio_get_inbound_buffer_frontier(struct qdio_q
*q
)
1034 struct qdio_irq
*irq
;
1036 volatile char *slsb
;
1037 unsigned int count
= 1;
1038 int first_not_to_check
;
1039 #ifdef CONFIG_QDIO_DEBUG
1041 #endif /* CONFIG_QDIO_DEBUG */
1042 #ifdef QDIO_USE_PROCESSING_STATE
1043 int last_position
=-1;
1044 #endif /* QDIO_USE_PROCESSING_STATE */
1046 QDIO_DBF_TEXT4(0,trace
,"getibfro");
1047 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1049 irq
= (struct qdio_irq
*) q
->irq_ptr
;
1051 return qdio_qebsm_get_inbound_buffer_frontier(q
);
1053 slsb
=&q
->slsb
.acc
.val
[0];
1054 f_mod_no
=f
=q
->first_to_check
;
1056 * we don't check 128 buffers, as otherwise qdio_has_inbound_q_moved
1059 first_not_to_check
=f
+qdio_min(atomic_read(&q
->number_of_buffers_used
),
1060 (QDIO_MAX_BUFFERS_PER_Q
-1));
1063 * we don't use this one, as a PCI or we after a thin interrupt
1064 * will sync the queues
1069 f_mod_no
=f
&(QDIO_MAX_BUFFERS_PER_Q
-1);
1070 if (f
==first_not_to_check
)
1072 switch (slsb
[f_mod_no
]) {
1074 /* CU_EMPTY means frontier is reached */
1075 case SLSB_CU_INPUT_EMPTY
:
1076 QDIO_DBF_TEXT5(0,trace
,"inptempt");
1079 /* P_PRIMED means set slsb to P_PROCESSING and move on */
1080 case SLSB_P_INPUT_PRIMED
:
1081 QDIO_DBF_TEXT5(0,trace
,"inptprim");
1083 #ifdef QDIO_USE_PROCESSING_STATE
1085 * as soon as running under VM, polling the input queues will
1086 * kill VM in terms of CP overhead
1089 set_slsb(q
, &f_mod_no
, SLSB_P_INPUT_NOT_INIT
, &count
);
1091 /* set the previous buffer to NOT_INIT. The current
1092 * buffer will be set to PROCESSING at the end of
1093 * this function to avoid further interrupts. */
1094 if (last_position
>=0)
1095 set_slsb(q
, &last_position
,
1096 SLSB_P_INPUT_NOT_INIT
, &count
);
1097 atomic_set(&q
->polling
,1);
1098 last_position
=f_mod_no
;
1100 #else /* QDIO_USE_PROCESSING_STATE */
1101 set_slsb(q
, &f_mod_no
, SLSB_P_INPUT_NOT_INIT
, &count
);
1102 #endif /* QDIO_USE_PROCESSING_STATE */
1104 * not needed, as the inbound queue will be synced on the next
1105 * siga-r, resp. tiqdio_is_inbound_q_done will do the siga-s
1109 atomic_dec(&q
->number_of_buffers_used
);
1112 case SLSB_P_INPUT_NOT_INIT
:
1113 case SLSB_P_INPUT_PROCESSING
:
1114 QDIO_DBF_TEXT5(0,trace
,"inpnipro");
1117 /* P_ERROR means frontier is reached, break and report error */
1118 case SLSB_P_INPUT_ERROR
:
1119 #ifdef CONFIG_QDIO_DEBUG
1120 sprintf(dbf_text
,"inperr%2x",f_mod_no
);
1121 QDIO_DBF_TEXT3(1,trace
,dbf_text
);
1122 #endif /* CONFIG_QDIO_DEBUG */
1123 QDIO_DBF_HEX2(1,sbal
,q
->sbal
[f_mod_no
],256);
1125 /* kind of process the buffer */
1126 set_slsb(q
, &f_mod_no
, SLSB_P_INPUT_NOT_INIT
, &count
);
1129 q
->error_status_flags
|=
1130 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR
;
1131 q
->qdio_error
=SLSB_P_INPUT_ERROR
;
1132 q
->error_status_flags
|=QDIO_STATUS_LOOK_FOR_ERROR
;
1134 /* we increment the frontier, as this buffer
1135 * was processed obviously */
1136 f_mod_no
=(f_mod_no
+1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
1137 atomic_dec(&q
->number_of_buffers_used
);
1139 #ifdef QDIO_USE_PROCESSING_STATE
1141 #endif /* QDIO_USE_PROCESSING_STATE */
1145 /* everything else means frontier not changed (HALTED or so) */
1150 q
->first_to_check
=f_mod_no
;
1152 #ifdef QDIO_USE_PROCESSING_STATE
1153 if (last_position
>=0)
1154 set_slsb(q
, &last_position
, SLSB_P_INPUT_PROCESSING
, &count
);
1155 #endif /* QDIO_USE_PROCESSING_STATE */
1157 QDIO_DBF_HEX4(0,trace
,&q
->first_to_check
,sizeof(int));
1159 return q
->first_to_check
;
1163 qdio_has_inbound_q_moved(struct qdio_q
*q
)
1167 i
=qdio_get_inbound_buffer_frontier(q
);
1168 if ( (i
!=GET_SAVED_FRONTIER(q
)) ||
1169 (q
->error_status_flags
&QDIO_STATUS_LOOK_FOR_ERROR
) ) {
1171 if ((!q
->siga_sync
)&&(!q
->hydra_gives_outbound_pcis
))
1174 QDIO_DBF_TEXT4(0,trace
,"inhasmvd");
1175 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1178 QDIO_DBF_TEXT4(0,trace
,"inhsntmv");
1179 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1184 /* means, no more buffers to be filled */
1186 tiqdio_is_inbound_q_done(struct qdio_q
*q
)
1189 unsigned int start_buf
, count
;
1190 unsigned char state
= 0;
1191 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
1193 #ifdef CONFIG_QDIO_DEBUG
1197 no_used
=atomic_read(&q
->number_of_buffers_used
);
1199 /* propagate the change from 82 to 80 through VM */
1202 #ifdef CONFIG_QDIO_DEBUG
1204 sprintf(dbf_text
,"iqisnt%02x",no_used
);
1205 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1207 QDIO_DBF_TEXT4(0,trace
,"iniqisdo");
1209 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1210 #endif /* CONFIG_QDIO_DEBUG */
1214 if (!q
->siga_sync
&& !irq
->is_qebsm
)
1215 /* we'll check for more primed buffers in qeth_stop_polling */
1217 if (irq
->is_qebsm
) {
1219 start_buf
= q
->first_to_check
;
1220 qdio_do_eqbs(q
, &state
, &start_buf
, &count
);
1222 state
= q
->slsb
.acc
.val
[q
->first_to_check
];
1223 if (state
!= SLSB_P_INPUT_PRIMED
)
1225 * nothing more to do, if next buffer is not PRIMED.
1226 * note that we did a SYNC_MEMORY before, that there
1227 * has been a sychnronization.
1228 * we will return 0 below, as there is nothing to do
1229 * (stop_polling not necessary, as we have not been
1230 * using the PROCESSING state
1235 * ok, the next input buffer is primed. that means, that device state
1236 * change indicator and adapter local summary are set, so we will find
1238 * we will return 0 below, as there is nothing to do, except scheduling
1239 * ourselves for the next time.
1241 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1247 qdio_is_inbound_q_done(struct qdio_q
*q
)
1250 unsigned int start_buf
, count
;
1251 unsigned char state
= 0;
1252 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
1254 #ifdef CONFIG_QDIO_DEBUG
1258 no_used
=atomic_read(&q
->number_of_buffers_used
);
1261 * we need that one for synchronization with the adapter, as it
1262 * does a kind of PCI avoidance
1267 QDIO_DBF_TEXT4(0,trace
,"inqisdnA");
1268 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1271 if (irq
->is_qebsm
) {
1273 start_buf
= q
->first_to_check
;
1274 qdio_do_eqbs(q
, &state
, &start_buf
, &count
);
1276 state
= q
->slsb
.acc
.val
[q
->first_to_check
];
1277 if (state
== SLSB_P_INPUT_PRIMED
) {
1278 /* we got something to do */
1279 QDIO_DBF_TEXT4(0,trace
,"inqisntA");
1280 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1284 /* on VM, we don't poll, so the q is always done here */
1287 if (q
->hydra_gives_outbound_pcis
)
1291 * at this point we know, that inbound first_to_check
1292 * has (probably) not moved (see qdio_inbound_processing)
1294 if (NOW
>GET_SAVED_TIMESTAMP(q
)+q
->timing
.threshold
) {
1295 #ifdef CONFIG_QDIO_DEBUG
1296 QDIO_DBF_TEXT4(0,trace
,"inqisdon");
1297 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1298 sprintf(dbf_text
,"pf%02xcn%02x",q
->first_to_check
,no_used
);
1299 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1300 #endif /* CONFIG_QDIO_DEBUG */
1303 #ifdef CONFIG_QDIO_DEBUG
1304 QDIO_DBF_TEXT4(0,trace
,"inqisntd");
1305 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1306 sprintf(dbf_text
,"pf%02xcn%02x",q
->first_to_check
,no_used
);
1307 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1308 #endif /* CONFIG_QDIO_DEBUG */
1314 qdio_kick_inbound_handler(struct qdio_q
*q
)
1316 int count
, start
, end
, real_end
, i
;
1317 #ifdef CONFIG_QDIO_DEBUG
1321 QDIO_DBF_TEXT4(0,trace
,"kickinh");
1322 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1324 start
=q
->first_element_to_kick
;
1325 real_end
=q
->first_to_check
;
1326 end
=(real_end
+QDIO_MAX_BUFFERS_PER_Q
-1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
1334 i
=(i
+1)&(QDIO_MAX_BUFFERS_PER_Q
-1);
1337 #ifdef CONFIG_QDIO_DEBUG
1338 sprintf(dbf_text
,"s=%2xc=%2x",start
,count
);
1339 QDIO_DBF_TEXT4(0,trace
,dbf_text
);
1340 #endif /* CONFIG_QDIO_DEBUG */
1342 if (likely(q
->state
==QDIO_IRQ_STATE_ACTIVE
))
1344 QDIO_STATUS_INBOUND_INT
|q
->error_status_flags
,
1345 q
->qdio_error
,q
->siga_error
,q
->q_no
,start
,count
,
1348 /* for the next time: */
1349 q
->first_element_to_kick
=real_end
;
1352 q
->error_status_flags
=0;
1354 qdio_perf_stat_inc(&perf_stats
.inbound_cnt
);
1358 __tiqdio_inbound_processing(struct qdio_q
*q
, int spare_ind_was_set
)
1360 struct qdio_irq
*irq_ptr
;
1364 QDIO_DBF_TEXT4(0,trace
,"iqinproc");
1365 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1368 * we first want to reserve the q, so that we know, that we don't
1369 * interrupt ourselves and call qdio_unmark_q, as is_in_shutdown might
1372 if (unlikely(qdio_reserve_q(q
))) {
1374 qdio_perf_stat_inc(&perf_stats
.inbound_thin_tl_runs_resched
);
1376 * as we might just be about to stop polling, we make
1377 * sure that we check again at least once more
1382 qdio_perf_stat_inc(&perf_stats
.inbound_thin_tl_runs
);
1383 if (unlikely(atomic_read(&q
->is_in_shutdown
))) {
1389 * we reset spare_ind_was_set, when the queue does not use the
1392 if (spare_ind_was_set
)
1393 spare_ind_was_set
= (q
->dev_st_chg_ind
== &spare_indicator
);
1395 if (!(*(q
->dev_st_chg_ind
)) && !spare_ind_was_set
)
1398 * q->dev_st_chg_ind is the indicator, be it shared or not.
1399 * only clear it, if indicator is non-shared
1401 if (!spare_ind_was_set
)
1402 tiqdio_clear_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1404 if (q
->hydra_gives_outbound_pcis
) {
1405 if (!q
->siga_sync_done_on_thinints
) {
1407 } else if ((!q
->siga_sync_done_on_outb_tis
)&&
1408 (q
->hydra_gives_outbound_pcis
)) {
1409 SYNC_MEMORY_ALL_OUTB
;
1415 * maybe we have to do work on our outbound queues... at least
1416 * we have to check the outbound-int-capable thinint-capable
1419 if (q
->hydra_gives_outbound_pcis
) {
1420 irq_ptr
= (struct qdio_irq
*)q
->irq_ptr
;
1421 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
1422 oq
= irq_ptr
->output_qs
[i
];
1423 if (!qdio_is_outbound_q_done(oq
)) {
1424 qdio_perf_stat_dec(&perf_stats
.tl_runs
);
1425 __qdio_outbound_processing(oq
);
1430 if (!qdio_has_inbound_q_moved(q
))
1433 qdio_kick_inbound_handler(q
);
1434 if (tiqdio_is_inbound_q_done(q
))
1435 if (!qdio_stop_polling(q
)) {
1437 * we set the flags to get into the stuff next time,
1438 * see also comment in qdio_stop_polling
1440 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1448 tiqdio_inbound_processing(struct qdio_q
*q
)
1450 __tiqdio_inbound_processing(q
, atomic_read(&spare_indicator_usecount
));
1454 __qdio_inbound_processing(struct qdio_q
*q
)
1458 QDIO_DBF_TEXT4(0,trace
,"qinproc");
1459 QDIO_DBF_HEX4(0,trace
,&q
,sizeof(void*));
1461 if (unlikely(qdio_reserve_q(q
))) {
1463 qdio_perf_stat_inc(&perf_stats
.inbound_tl_runs_resched
);
1464 /* as we're sissies, we'll check next time */
1465 if (likely(!atomic_read(&q
->is_in_shutdown
))) {
1467 QDIO_DBF_TEXT4(0,trace
,"busy,agn");
1471 qdio_perf_stat_inc(&perf_stats
.inbound_tl_runs
);
1472 qdio_perf_stat_inc(&perf_stats
.tl_runs
);
1475 if (qdio_has_inbound_q_moved(q
)) {
1476 qdio_kick_inbound_handler(q
);
1477 if (!qdio_stop_polling(q
)) {
1479 if (q_laps
<QDIO_Q_LAPS
)
1484 if (!qdio_is_inbound_q_done(q
))
1485 /* means poll time is not yet over */
1493 qdio_inbound_processing(struct qdio_q
*q
)
1495 __qdio_inbound_processing(q
);
1498 /************************* MAIN ROUTINES *******************************/
1500 #ifdef QDIO_USE_PROCESSING_STATE
1502 tiqdio_reset_processing_state(struct qdio_q
*q
, int q_laps
)
1510 * under VM, we have not used the PROCESSING state, so no
1511 * need to stop polling
1516 if (unlikely(qdio_reserve_q(q
))) {
1518 qdio_perf_stat_inc(&perf_stats
.inbound_thin_tl_runs_resched
);
1520 * as we might just be about to stop polling, we make
1521 * sure that we check again at least once more
1525 * sanity -- we'd get here without setting the
1528 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1532 if (qdio_stop_polling(q
)) {
1536 if (q_laps
<QDIO_Q_LAPS
-1) {
1541 * we set the flags to get into the stuff
1542 * next time, see also comment in qdio_stop_polling
1544 tiqdio_set_summary_bit((__u32
*)q
->dev_st_chg_ind
);
1550 #endif /* QDIO_USE_PROCESSING_STATE */
1553 tiqdio_inbound_checks(void)
1556 int spare_ind_was_set
=0;
1557 #ifdef QDIO_USE_PROCESSING_STATE
1559 #endif /* QDIO_USE_PROCESSING_STATE */
1561 QDIO_DBF_TEXT4(0,trace
,"iqdinbck");
1562 QDIO_DBF_TEXT5(0,trace
,"iqlocsum");
1564 #ifdef QDIO_USE_PROCESSING_STATE
1566 #endif /* QDIO_USE_PROCESSING_STATE */
1568 /* when the spare indicator is used and set, save that and clear it */
1569 if ((atomic_read(&spare_indicator_usecount
)) && spare_indicator
) {
1570 spare_ind_was_set
= 1;
1571 tiqdio_clear_summary_bit((__u32
*)&spare_indicator
);
1574 q
=(struct qdio_q
*)tiq_list
;
1578 __tiqdio_inbound_processing(q
, spare_ind_was_set
);
1579 q
=(struct qdio_q
*)q
->list_next
;
1580 } while (q
!=(struct qdio_q
*)tiq_list
);
1582 #ifdef QDIO_USE_PROCESSING_STATE
1583 q
=(struct qdio_q
*)tiq_list
;
1587 ret
= tiqdio_reset_processing_state(q
, q_laps
);
1594 q
= (struct qdio_q
*)q
->list_next
;
1600 } while (q
!=(struct qdio_q
*)tiq_list
);
1601 #endif /* QDIO_USE_PROCESSING_STATE */
1605 tiqdio_tl(unsigned long data
)
1607 QDIO_DBF_TEXT4(0,trace
,"iqdio_tl");
1609 qdio_perf_stat_inc(&perf_stats
.tl_runs
);
1611 tiqdio_inbound_checks();
1614 /********************* GENERAL HELPER_ROUTINES ***********************/
1617 qdio_release_irq_memory(struct qdio_irq
*irq_ptr
)
1621 for (i
=0;i
<QDIO_MAX_QUEUES_PER_IRQ
;i
++) {
1622 if (!irq_ptr
->input_qs
[i
])
1625 kfree(irq_ptr
->input_qs
[i
]->slib
);
1626 kfree(irq_ptr
->input_qs
[i
]);
1629 if (!irq_ptr
->output_qs
[i
])
1632 kfree(irq_ptr
->output_qs
[i
]->slib
);
1633 kfree(irq_ptr
->output_qs
[i
]);
1636 kfree(irq_ptr
->qdr
);
1637 free_page((unsigned long) irq_ptr
);
1641 qdio_set_impl_params(struct qdio_irq
*irq_ptr
,
1642 unsigned int qib_param_field_format
,
1643 /* pointer to 128 bytes or NULL, if no param field */
1644 unsigned char *qib_param_field
,
1645 /* pointer to no_queues*128 words of data or NULL */
1646 unsigned int no_input_qs
,
1647 unsigned int no_output_qs
,
1648 unsigned long *input_slib_elements
,
1649 unsigned long *output_slib_elements
)
1656 irq_ptr
->qib
.pfmt
=qib_param_field_format
;
1657 if (qib_param_field
)
1658 memcpy(irq_ptr
->qib
.parm
,qib_param_field
,
1659 QDIO_MAX_BUFFERS_PER_Q
);
1661 if (input_slib_elements
)
1662 for (i
=0;i
<no_input_qs
;i
++) {
1663 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1664 irq_ptr
->input_qs
[i
]->slib
->slibe
[j
].parms
=
1665 input_slib_elements
[
1666 i
*QDIO_MAX_BUFFERS_PER_Q
+j
];
1668 if (output_slib_elements
)
1669 for (i
=0;i
<no_output_qs
;i
++) {
1670 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1671 irq_ptr
->output_qs
[i
]->slib
->slibe
[j
].parms
=
1672 output_slib_elements
[
1673 i
*QDIO_MAX_BUFFERS_PER_Q
+j
];
1678 qdio_alloc_qs(struct qdio_irq
*irq_ptr
,
1679 int no_input_qs
, int no_output_qs
)
1685 for (i
=0;i
<no_input_qs
;i
++) {
1686 q
= kzalloc(sizeof(struct qdio_q
), GFP_KERNEL
);
1689 QDIO_PRINT_ERR("kmalloc of q failed!\n");
1693 q
->slib
= kmalloc(PAGE_SIZE
, GFP_KERNEL
);
1695 QDIO_PRINT_ERR("kmalloc of slib failed!\n");
1699 irq_ptr
->input_qs
[i
]=q
;
1702 for (i
=0;i
<no_output_qs
;i
++) {
1703 q
= kzalloc(sizeof(struct qdio_q
), GFP_KERNEL
);
1709 q
->slib
=kmalloc(PAGE_SIZE
,GFP_KERNEL
);
1711 QDIO_PRINT_ERR("kmalloc of slib failed!\n");
1715 irq_ptr
->output_qs
[i
]=q
;
1724 qdio_fill_qs(struct qdio_irq
*irq_ptr
, struct ccw_device
*cdev
,
1725 int no_input_qs
, int no_output_qs
,
1726 qdio_handler_t
*input_handler
,
1727 qdio_handler_t
*output_handler
,
1728 unsigned long int_parm
,int q_format
,
1729 unsigned long flags
,
1730 void **inbound_sbals_array
,
1731 void **outbound_sbals_array
)
1735 char dbf_text
[20]; /* see qdio_initialize */
1739 sprintf(dbf_text
,"qfqs%4x",cdev
->private->schid
.sch_no
);
1740 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
1741 for (i
=0;i
<no_input_qs
;i
++) {
1742 q
=irq_ptr
->input_qs
[i
];
1744 memset(q
,0,((char*)&q
->slib
)-((char*)q
));
1745 sprintf(dbf_text
,"in-q%4x",i
);
1746 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
1747 QDIO_DBF_HEX0(0,setup
,&q
,sizeof(void*));
1749 memset(q
->slib
,0,PAGE_SIZE
);
1750 q
->sl
=(struct sl
*)(((char*)q
->slib
)+PAGE_SIZE
/2);
1754 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1755 q
->sbal
[j
]=*(inbound_sbals_array
++);
1757 q
->queue_type
=q_format
;
1758 q
->int_parm
=int_parm
;
1759 q
->schid
= irq_ptr
->schid
;
1760 q
->irq_ptr
= irq_ptr
;
1765 q
->first_to_check
=0;
1767 q
->handler
=input_handler
;
1768 q
->dev_st_chg_ind
=irq_ptr
->dev_st_chg_ind
;
1770 q
->tasklet
.data
=(unsigned long)q
;
1771 /* q->is_thinint_q isn't valid at this time, but
1772 * irq_ptr->is_thinint_irq is */
1773 q
->tasklet
.func
=(void(*)(unsigned long))
1774 ((irq_ptr
->is_thinint_irq
)?&tiqdio_inbound_processing
:
1775 &qdio_inbound_processing
);
1777 /* actually this is not used for inbound queues. yet. */
1778 atomic_set(&q
->busy_siga_counter
,0);
1779 q
->timing
.busy_start
=0;
1781 /* for (j=0;j<QDIO_STATS_NUMBER;j++)
1782 q->timing.last_transfer_times[j]=(qdio_get_micros()/
1783 QDIO_STATS_NUMBER)*j;
1784 q->timing.last_transfer_index=QDIO_STATS_NUMBER-1;
1788 if (i
>0) irq_ptr
->input_qs
[i
-1]->slib
->nsliba
=
1789 (unsigned long)(q
->slib
);
1790 q
->slib
->sla
=(unsigned long)(q
->sl
);
1791 q
->slib
->slsba
=(unsigned long)(&q
->slsb
.acc
.val
[0]);
1794 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1795 q
->sl
->element
[j
].sbal
=(unsigned long)(q
->sbal
[j
]);
1797 QDIO_DBF_TEXT2(0,setup
,"sl-sb-b0");
1799 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1800 ptr
=(void*)&q
->slsb
;
1801 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1802 ptr
=(void*)q
->sbal
[0];
1803 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1806 if (!irq_ptr
->is_qebsm
) {
1807 unsigned int count
= 1;
1808 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; j
++)
1809 set_slsb(q
, &j
, SLSB_P_INPUT_NOT_INIT
, &count
);
1813 for (i
=0;i
<no_output_qs
;i
++) {
1814 q
=irq_ptr
->output_qs
[i
];
1815 memset(q
,0,((char*)&q
->slib
)-((char*)q
));
1817 sprintf(dbf_text
,"outq%4x",i
);
1818 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
1819 QDIO_DBF_HEX0(0,setup
,&q
,sizeof(void*));
1821 memset(q
->slib
,0,PAGE_SIZE
);
1822 q
->sl
=(struct sl
*)(((char*)q
->slib
)+PAGE_SIZE
/2);
1826 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1827 q
->sbal
[j
]=*(outbound_sbals_array
++);
1829 q
->queue_type
=q_format
;
1830 if ((q
->queue_type
== QDIO_IQDIO_QFMT
) &&
1831 (no_output_qs
> 1) &&
1832 (i
== no_output_qs
-1))
1833 q
->queue_type
= QDIO_IQDIO_QFMT_ASYNCH
;
1834 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
;
1849 q
->timer
.function
=(void(*)(unsigned long))
1850 &qdio_outbound_processing
;
1851 q
->timer
.data
= (long)q
;
1852 init_timer(&q
->timer
);
1854 atomic_set(&q
->busy_siga_counter
,0);
1855 q
->timing
.busy_start
=0;
1858 if (i
>0) irq_ptr
->output_qs
[i
-1]->slib
->nsliba
=
1859 (unsigned long)(q
->slib
);
1860 q
->slib
->sla
=(unsigned long)(q
->sl
);
1861 q
->slib
->slsba
=(unsigned long)(&q
->slsb
.acc
.val
[0]);
1864 for (j
=0;j
<QDIO_MAX_BUFFERS_PER_Q
;j
++)
1865 q
->sl
->element
[j
].sbal
=(unsigned long)(q
->sbal
[j
]);
1867 QDIO_DBF_TEXT2(0,setup
,"sl-sb-b0");
1869 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1870 ptr
=(void*)&q
->slsb
;
1871 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1872 ptr
=(void*)q
->sbal
[0];
1873 QDIO_DBF_HEX2(0,setup
,&ptr
,sizeof(void*));
1876 if (!irq_ptr
->is_qebsm
) {
1877 unsigned int count
= 1;
1878 for (j
= 0; j
< QDIO_MAX_BUFFERS_PER_Q
; j
++)
1879 set_slsb(q
, &j
, SLSB_P_OUTPUT_NOT_INIT
, &count
);
1885 qdio_fill_thresholds(struct qdio_irq
*irq_ptr
,
1886 unsigned int no_input_qs
,
1887 unsigned int no_output_qs
,
1888 unsigned int min_input_threshold
,
1889 unsigned int max_input_threshold
,
1890 unsigned int min_output_threshold
,
1891 unsigned int max_output_threshold
)
1896 for (i
=0;i
<no_input_qs
;i
++) {
1897 q
=irq_ptr
->input_qs
[i
];
1898 q
->timing
.threshold
=max_input_threshold
;
1899 /* for (j=0;j<QDIO_STATS_CLASSES;j++) {
1900 q->threshold_classes[j].threshold=
1901 min_input_threshold+
1902 (max_input_threshold-min_input_threshold)/
1905 qdio_use_thresholds(q,QDIO_STATS_CLASSES/2);*/
1907 for (i
=0;i
<no_output_qs
;i
++) {
1908 q
=irq_ptr
->output_qs
[i
];
1909 q
->timing
.threshold
=max_output_threshold
;
1910 /* for (j=0;j<QDIO_STATS_CLASSES;j++) {
1911 q->threshold_classes[j].threshold=
1912 min_output_threshold+
1913 (max_output_threshold-min_output_threshold)/
1916 qdio_use_thresholds(q,QDIO_STATS_CLASSES/2);*/
1921 tiqdio_thinint_handler(void)
1923 QDIO_DBF_TEXT4(0,trace
,"thin_int");
1925 qdio_perf_stat_inc(&perf_stats
.thinints
);
1927 /* SVS only when needed:
1928 * issue SVS to benefit from iqdio interrupt avoidance
1929 * (SVS clears AISOI)*/
1931 tiqdio_clear_global_summary();
1933 tiqdio_inbound_checks();
1938 qdio_set_state(struct qdio_irq
*irq_ptr
, enum qdio_irq_states state
)
1941 #ifdef CONFIG_QDIO_DEBUG
1944 QDIO_DBF_TEXT5(0,trace
,"newstate");
1945 sprintf(dbf_text
,"%4x%4x",irq_ptr
->schid
.sch_no
,state
);
1946 QDIO_DBF_TEXT5(0,trace
,dbf_text
);
1947 #endif /* CONFIG_QDIO_DEBUG */
1949 irq_ptr
->state
=state
;
1950 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++)
1951 irq_ptr
->input_qs
[i
]->state
=state
;
1952 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++)
1953 irq_ptr
->output_qs
[i
]->state
=state
;
1958 qdio_irq_check_sense(struct subchannel_id schid
, struct irb
*irb
)
1962 if (irb
->esw
.esw0
.erw
.cons
) {
1963 sprintf(dbf_text
,"sens%4x",schid
.sch_no
);
1964 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
1965 QDIO_DBF_HEX0(0,sense
,irb
,QDIO_DBF_SENSE_LEN
);
1967 QDIO_PRINT_WARN("sense data available on qdio channel.\n");
1968 QDIO_HEXDUMP16(WARN
,"irb: ",irb
);
1969 QDIO_HEXDUMP16(WARN
,"sense data: ",irb
->ecw
);
1975 qdio_handle_pci(struct qdio_irq
*irq_ptr
)
1980 qdio_perf_stat_inc(&perf_stats
.pcis
);
1981 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
1982 q
=irq_ptr
->input_qs
[i
];
1983 if (q
->is_input_q
&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT
)
1986 __qdio_inbound_processing(q
);
1989 if (!irq_ptr
->hydra_gives_outbound_pcis
)
1991 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
1992 q
=irq_ptr
->output_qs
[i
];
1993 if (qdio_is_outbound_q_done(q
))
1995 qdio_perf_stat_dec(&perf_stats
.tl_runs
);
1996 if (!irq_ptr
->sync_done_on_outb_pcis
)
1998 __qdio_outbound_processing(q
);
2002 static void qdio_establish_handle_irq(struct ccw_device
*, int, int);
2005 qdio_handle_activate_check(struct ccw_device
*cdev
, unsigned long intparm
,
2006 int cstat
, int dstat
)
2008 struct qdio_irq
*irq_ptr
;
2012 irq_ptr
= cdev
->private->qdio_data
;
2014 QDIO_DBF_TEXT2(1, trace
, "ick2");
2015 sprintf(dbf_text
,"%s", cdev
->dev
.bus_id
);
2016 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
2017 QDIO_DBF_HEX2(0,trace
,&intparm
,sizeof(int));
2018 QDIO_DBF_HEX2(0,trace
,&dstat
,sizeof(int));
2019 QDIO_DBF_HEX2(0,trace
,&cstat
,sizeof(int));
2020 QDIO_PRINT_ERR("received check condition on activate " \
2021 "queues on device %s (cs=x%x, ds=x%x).\n",
2022 cdev
->dev
.bus_id
, cstat
, dstat
);
2023 if (irq_ptr
->no_input_qs
) {
2024 q
=irq_ptr
->input_qs
[0];
2025 } else if (irq_ptr
->no_output_qs
) {
2026 q
=irq_ptr
->output_qs
[0];
2028 QDIO_PRINT_ERR("oops... no queue registered for device %s!?\n",
2030 goto omit_handler_call
;
2032 q
->handler(q
->cdev
,QDIO_STATUS_ACTIVATE_CHECK_CONDITION
|
2033 QDIO_STATUS_LOOK_FOR_ERROR
,
2034 0,0,0,-1,-1,q
->int_parm
);
2036 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_STOPPED
);
2041 qdio_call_shutdown(struct work_struct
*work
)
2043 struct ccw_device_private
*priv
;
2044 struct ccw_device
*cdev
;
2046 priv
= container_of(work
, struct ccw_device_private
, kick_work
);
2048 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
2049 put_device(&cdev
->dev
);
2053 qdio_timeout_handler(struct ccw_device
*cdev
)
2055 struct qdio_irq
*irq_ptr
;
2058 QDIO_DBF_TEXT2(0, trace
, "qtoh");
2059 sprintf(dbf_text
, "%s", cdev
->dev
.bus_id
);
2060 QDIO_DBF_TEXT2(0, trace
, dbf_text
);
2062 irq_ptr
= cdev
->private->qdio_data
;
2063 sprintf(dbf_text
, "state:%d", irq_ptr
->state
);
2064 QDIO_DBF_TEXT2(0, trace
, dbf_text
);
2066 switch (irq_ptr
->state
) {
2067 case QDIO_IRQ_STATE_INACTIVE
:
2068 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: timed out\n",
2069 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2070 QDIO_DBF_TEXT2(1,setup
,"eq:timeo");
2071 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2073 case QDIO_IRQ_STATE_CLEANUP
:
2074 QDIO_PRINT_INFO("Did not get interrupt on cleanup, "
2076 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2077 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2079 case QDIO_IRQ_STATE_ESTABLISHED
:
2080 case QDIO_IRQ_STATE_ACTIVE
:
2081 /* I/O has been terminated by common I/O layer. */
2082 QDIO_PRINT_INFO("Queues on irq 0.%x.%04x killed by cio.\n",
2083 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2084 QDIO_DBF_TEXT2(1, trace
, "cio:term");
2085 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_STOPPED
);
2086 if (get_device(&cdev
->dev
)) {
2087 /* Can't call shutdown from interrupt context. */
2088 PREPARE_WORK(&cdev
->private->kick_work
,
2089 qdio_call_shutdown
);
2090 queue_work(ccw_device_work
, &cdev
->private->kick_work
);
2096 ccw_device_set_timeout(cdev
, 0);
2097 wake_up(&cdev
->private->wait_q
);
2101 qdio_handler(struct ccw_device
*cdev
, unsigned long intparm
, struct irb
*irb
)
2103 struct qdio_irq
*irq_ptr
;
2107 #ifdef CONFIG_QDIO_DEBUG
2108 QDIO_DBF_TEXT4(0, trace
, "qint");
2109 sprintf(dbf_text
, "%s", cdev
->dev
.bus_id
);
2110 QDIO_DBF_TEXT4(0, trace
, dbf_text
);
2111 #endif /* CONFIG_QDIO_DEBUG */
2114 QDIO_PRINT_ERR("got unsolicited interrupt in qdio " \
2115 "handler, device %s\n", cdev
->dev
.bus_id
);
2119 irq_ptr
= cdev
->private->qdio_data
;
2121 QDIO_DBF_TEXT2(1, trace
, "uint");
2122 sprintf(dbf_text
,"%s", cdev
->dev
.bus_id
);
2123 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
2124 QDIO_PRINT_ERR("received interrupt on unused device %s!\n",
2130 /* Currently running i/o is in error. */
2131 switch (PTR_ERR(irb
)) {
2133 QDIO_PRINT_ERR("i/o error on device %s\n",
2137 qdio_timeout_handler(cdev
);
2140 QDIO_PRINT_ERR("unknown error state %ld on device %s\n",
2141 PTR_ERR(irb
), cdev
->dev
.bus_id
);
2146 qdio_irq_check_sense(irq_ptr
->schid
, irb
);
2148 #ifdef CONFIG_QDIO_DEBUG
2149 sprintf(dbf_text
, "state:%d", irq_ptr
->state
);
2150 QDIO_DBF_TEXT4(0, trace
, dbf_text
);
2151 #endif /* CONFIG_QDIO_DEBUG */
2153 cstat
= irb
->scsw
.cstat
;
2154 dstat
= irb
->scsw
.dstat
;
2156 switch (irq_ptr
->state
) {
2157 case QDIO_IRQ_STATE_INACTIVE
:
2158 qdio_establish_handle_irq(cdev
, cstat
, dstat
);
2161 case QDIO_IRQ_STATE_CLEANUP
:
2162 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2165 case QDIO_IRQ_STATE_ESTABLISHED
:
2166 case QDIO_IRQ_STATE_ACTIVE
:
2167 if (cstat
& SCHN_STAT_PCI
) {
2168 qdio_handle_pci(irq_ptr
);
2172 if ((cstat
&~SCHN_STAT_PCI
)||dstat
) {
2173 qdio_handle_activate_check(cdev
, intparm
, cstat
, dstat
);
2177 QDIO_PRINT_ERR("got interrupt for queues in state %d on " \
2179 irq_ptr
->state
, cdev
->dev
.bus_id
);
2181 wake_up(&cdev
->private->wait_q
);
2186 qdio_synchronize(struct ccw_device
*cdev
, unsigned int flags
,
2187 unsigned int queue_number
)
2191 struct qdio_irq
*irq_ptr
;
2193 #ifdef CONFIG_QDIO_DEBUG
2194 char dbf_text
[15]="SyncXXXX";
2197 irq_ptr
= cdev
->private->qdio_data
;
2201 #ifdef CONFIG_QDIO_DEBUG
2202 *((int*)(&dbf_text
[4])) = irq_ptr
->schid
.sch_no
;
2203 QDIO_DBF_HEX4(0,trace
,dbf_text
,QDIO_DBF_TRACE_LEN
);
2204 *((int*)(&dbf_text
[0]))=flags
;
2205 *((int*)(&dbf_text
[4]))=queue_number
;
2206 QDIO_DBF_HEX4(0,trace
,dbf_text
,QDIO_DBF_TRACE_LEN
);
2207 #endif /* CONFIG_QDIO_DEBUG */
2209 if (flags
&QDIO_FLAG_SYNC_INPUT
) {
2210 q
=irq_ptr
->input_qs
[queue_number
];
2213 if (!(irq_ptr
->is_qebsm
))
2214 cc
= do_siga_sync(q
->schid
, 0, q
->mask
);
2215 } else if (flags
&QDIO_FLAG_SYNC_OUTPUT
) {
2216 q
=irq_ptr
->output_qs
[queue_number
];
2219 if (!(irq_ptr
->is_qebsm
))
2220 cc
= do_siga_sync(q
->schid
, q
->mask
, 0);
2226 QDIO_DBF_HEX3(0,trace
,&ptr
,sizeof(int));
2232 qdio_check_subchannel_qebsm(struct qdio_irq
*irq_ptr
, unsigned char qdioac
,
2233 unsigned long token
)
2237 unsigned int count
, start_buf
;
2240 /*check if QEBSM is disabled */
2241 if (!(irq_ptr
->is_qebsm
) || !(qdioac
& 0x01)) {
2242 irq_ptr
->is_qebsm
= 0;
2243 irq_ptr
->sch_token
= 0;
2244 irq_ptr
->qib
.rflags
&= ~QIB_RFLAGS_ENABLE_QEBSM
;
2245 QDIO_DBF_TEXT0(0,setup
,"noV=V");
2248 irq_ptr
->sch_token
= token
;
2250 for (i
= 0; i
< irq_ptr
->no_input_qs
;i
++) {
2251 q
= irq_ptr
->input_qs
[i
];
2252 count
= QDIO_MAX_BUFFERS_PER_Q
;
2254 set_slsb(q
, &start_buf
, SLSB_P_INPUT_NOT_INIT
, &count
);
2256 sprintf(dbf_text
,"V=V:%2x",irq_ptr
->is_qebsm
);
2257 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2258 sprintf(dbf_text
,"%8lx",irq_ptr
->sch_token
);
2259 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2261 for (i
= 0; i
< irq_ptr
->no_output_qs
; i
++) {
2262 q
= irq_ptr
->output_qs
[i
];
2263 count
= QDIO_MAX_BUFFERS_PER_Q
;
2265 set_slsb(q
, &start_buf
, SLSB_P_OUTPUT_NOT_INIT
, &count
);
2270 qdio_get_ssqd_information(struct qdio_irq
*irq_ptr
)
2273 unsigned char qdioac
;
2275 struct chsc_header request
;
2283 struct chsc_header response
;
2302 QDIO_DBF_TEXT0(0,setup
,"getssqd");
2304 ssqd_area
= mempool_alloc(qdio_mempool_scssc
, GFP_ATOMIC
);
2306 QDIO_PRINT_WARN("Could not get memory for chsc. Using all " \
2307 "SIGAs for sch x%x.\n", irq_ptr
->schid
.sch_no
);
2308 irq_ptr
->qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
||
2309 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
||
2310 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* all flags set */
2311 irq_ptr
->is_qebsm
= 0;
2312 irq_ptr
->sch_token
= 0;
2313 irq_ptr
->qib
.rflags
&= ~QIB_RFLAGS_ENABLE_QEBSM
;
2317 ssqd_area
->request
= (struct chsc_header
) {
2321 ssqd_area
->first_sch
= irq_ptr
->schid
.sch_no
;
2322 ssqd_area
->last_sch
= irq_ptr
->schid
.sch_no
;
2323 ssqd_area
->ssid
= irq_ptr
->schid
.ssid
;
2324 result
= chsc(ssqd_area
);
2327 QDIO_PRINT_WARN("CHSC returned cc %i. Using all " \
2328 "SIGAs for sch 0.%x.%x.\n", result
,
2329 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2330 qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
||
2331 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
||
2332 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* all flags set */
2333 irq_ptr
->is_qebsm
= 0;
2337 if (ssqd_area
->response
.code
!= QDIO_CHSC_RESPONSE_CODE_OK
) {
2338 QDIO_PRINT_WARN("response upon checking SIGA needs " \
2339 "is 0x%x. Using all SIGAs for sch 0.%x.%x.\n",
2340 ssqd_area
->response
.code
,
2341 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2342 qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
||
2343 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
||
2344 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* all flags set */
2345 irq_ptr
->is_qebsm
= 0;
2348 if (!(ssqd_area
->flags
& CHSC_FLAG_QDIO_CAPABILITY
) ||
2349 !(ssqd_area
->flags
& CHSC_FLAG_VALIDITY
) ||
2350 (ssqd_area
->sch
!= irq_ptr
->schid
.sch_no
)) {
2351 QDIO_PRINT_WARN("huh? problems checking out sch 0.%x.%x... " \
2352 "using all SIGAs.\n",
2353 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2354 qdioac
= CHSC_FLAG_SIGA_INPUT_NECESSARY
|
2355 CHSC_FLAG_SIGA_OUTPUT_NECESSARY
|
2356 CHSC_FLAG_SIGA_SYNC_NECESSARY
; /* worst case */
2357 irq_ptr
->is_qebsm
= 0;
2360 qdioac
= ssqd_area
->qdioac1
;
2362 qdio_check_subchannel_qebsm(irq_ptr
, qdioac
,
2363 ssqd_area
->sch_token
);
2364 mempool_free(ssqd_area
, qdio_mempool_scssc
);
2365 irq_ptr
->qdioac
= qdioac
;
2369 tiqdio_check_chsc_availability(void)
2373 if (!css_characteristics_avail
)
2376 /* Check for bit 41. */
2377 if (!css_general_characteristics
.aif
) {
2378 QDIO_PRINT_WARN("Adapter interruption facility not " \
2383 /* Check for bits 107 and 108. */
2384 if (!css_chsc_characteristics
.scssc
||
2385 !css_chsc_characteristics
.scsscf
) {
2386 QDIO_PRINT_WARN("Set Chan Subsys. Char. & Fast-CHSCs " \
2387 "not available.\n");
2391 /* Check for OSA/FCP thin interrupts (bit 67). */
2392 hydra_thinints
= css_general_characteristics
.aif_osa
;
2393 sprintf(dbf_text
,"hydrati%1x", hydra_thinints
);
2394 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2397 /* Check for QEBSM support in general (bit 58). */
2398 is_passthrough
= css_general_characteristics
.qebsm
;
2400 sprintf(dbf_text
,"cssQBS:%1x", is_passthrough
);
2401 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2403 /* Check for aif time delay disablement fac (bit 56). If installed,
2404 * omit svs even under lpar (good point by rick again) */
2405 omit_svs
= css_general_characteristics
.aif_tdd
;
2406 sprintf(dbf_text
,"omitsvs%1x", omit_svs
);
2407 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2413 tiqdio_set_subchannel_ind(struct qdio_irq
*irq_ptr
, int reset_to_zero
)
2415 unsigned long real_addr_local_summary_bit
;
2416 unsigned long real_addr_dev_st_chg_ind
;
2420 unsigned int resp_code
;
2424 struct chsc_header request
;
2429 u64 summary_indicator_addr
;
2430 u64 subchannel_indicator_addr
;
2435 u32 word_with_d_bit
;
2436 /* set to 0x10000000 to enable
2437 * time delay disablement facility */
2439 struct subchannel_id schid
;
2440 u32 reserved6
[1004];
2441 struct chsc_header response
;
2445 if (!irq_ptr
->is_thinint_irq
)
2448 if (reset_to_zero
) {
2449 real_addr_local_summary_bit
=0;
2450 real_addr_dev_st_chg_ind
=0;
2452 real_addr_local_summary_bit
=
2453 virt_to_phys((volatile void *)indicators
);
2454 real_addr_dev_st_chg_ind
=
2455 virt_to_phys((volatile void *)irq_ptr
->dev_st_chg_ind
);
2458 scssc_area
= mempool_alloc(qdio_mempool_scssc
, GFP_ATOMIC
);
2460 QDIO_PRINT_WARN("No memory for setting indicators on " \
2461 "subchannel 0.%x.%x.\n",
2462 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2465 scssc_area
->request
= (struct chsc_header
) {
2469 scssc_area
->operation_code
= 0;
2471 scssc_area
->summary_indicator_addr
= real_addr_local_summary_bit
;
2472 scssc_area
->subchannel_indicator_addr
= real_addr_dev_st_chg_ind
;
2473 scssc_area
->ks
= QDIO_STORAGE_KEY
;
2474 scssc_area
->kc
= QDIO_STORAGE_KEY
;
2475 scssc_area
->isc
= TIQDIO_THININT_ISC
;
2476 scssc_area
->schid
= irq_ptr
->schid
;
2477 /* enables the time delay disablement facility. Don't care
2478 * whether it is really there (i.e. we haven't checked for
2480 if (css_general_characteristics
.aif_tdd
)
2481 scssc_area
->word_with_d_bit
= 0x10000000;
2483 QDIO_PRINT_WARN("Time delay disablement facility " \
2486 result
= chsc(scssc_area
);
2488 QDIO_PRINT_WARN("could not set indicators on irq 0.%x.%x, " \
2490 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,result
);
2495 resp_code
= scssc_area
->response
.code
;
2496 if (resp_code
!=QDIO_CHSC_RESPONSE_CODE_OK
) {
2497 QDIO_PRINT_WARN("response upon setting indicators " \
2498 "is 0x%x.\n",resp_code
);
2499 sprintf(dbf_text
,"sidR%4x",resp_code
);
2500 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2501 QDIO_DBF_TEXT1(0,setup
,dbf_text
);
2502 ptr
=&scssc_area
->response
;
2503 QDIO_DBF_HEX2(1,setup
,&ptr
,QDIO_DBF_SETUP_LEN
);
2508 QDIO_DBF_TEXT2(0,setup
,"setscind");
2509 QDIO_DBF_HEX2(0,setup
,&real_addr_local_summary_bit
,
2510 sizeof(unsigned long));
2511 QDIO_DBF_HEX2(0,setup
,&real_addr_dev_st_chg_ind
,sizeof(unsigned long));
2514 mempool_free(scssc_area
, qdio_mempool_scssc
);
2520 tiqdio_set_delay_target(struct qdio_irq
*irq_ptr
, unsigned long delay_target
)
2522 unsigned int resp_code
;
2528 struct chsc_header request
;
2535 u32 reserved5
[1009];
2536 struct chsc_header response
;
2540 if (!irq_ptr
->is_thinint_irq
)
2543 scsscf_area
= mempool_alloc(qdio_mempool_scssc
, GFP_ATOMIC
);
2545 QDIO_PRINT_WARN("No memory for setting delay target on " \
2546 "subchannel 0.%x.%x.\n",
2547 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
2550 scsscf_area
->request
= (struct chsc_header
) {
2555 scsscf_area
->delay_target
= delay_target
<<16;
2557 result
=chsc(scsscf_area
);
2559 QDIO_PRINT_WARN("could not set delay target on irq 0.%x.%x, " \
2560 "cc=%i. Continuing.\n",
2561 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
2567 resp_code
= scsscf_area
->response
.code
;
2568 if (resp_code
!=QDIO_CHSC_RESPONSE_CODE_OK
) {
2569 QDIO_PRINT_WARN("response upon setting delay target " \
2570 "is 0x%x. Continuing.\n",resp_code
);
2571 sprintf(dbf_text
,"sdtR%4x",resp_code
);
2572 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2573 QDIO_DBF_TEXT1(0,setup
,dbf_text
);
2574 ptr
=&scsscf_area
->response
;
2575 QDIO_DBF_HEX2(1,trace
,&ptr
,QDIO_DBF_TRACE_LEN
);
2577 QDIO_DBF_TEXT2(0,trace
,"delytrgt");
2578 QDIO_DBF_HEX2(0,trace
,&delay_target
,sizeof(unsigned long));
2579 result
= 0; /* not critical */
2581 mempool_free(scsscf_area
, qdio_mempool_scssc
);
2586 qdio_cleanup(struct ccw_device
*cdev
, int how
)
2588 struct qdio_irq
*irq_ptr
;
2592 irq_ptr
= cdev
->private->qdio_data
;
2596 sprintf(dbf_text
,"qcln%4x",irq_ptr
->schid
.sch_no
);
2597 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2598 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2600 rc
= qdio_shutdown(cdev
, how
);
2601 if ((rc
== 0) || (rc
== -EINPROGRESS
))
2602 rc
= qdio_free(cdev
);
2607 qdio_shutdown(struct ccw_device
*cdev
, int how
)
2609 struct qdio_irq
*irq_ptr
;
2613 unsigned long flags
;
2617 irq_ptr
= cdev
->private->qdio_data
;
2621 down(&irq_ptr
->setting_up_sema
);
2623 sprintf(dbf_text
,"qsqs%4x",irq_ptr
->schid
.sch_no
);
2624 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2625 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2627 /* mark all qs as uninteresting */
2628 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++)
2629 atomic_set(&irq_ptr
->input_qs
[i
]->is_in_shutdown
,1);
2631 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++)
2632 atomic_set(&irq_ptr
->output_qs
[i
]->is_in_shutdown
,1);
2634 tasklet_kill(&tiqdio_tasklet
);
2636 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
2637 qdio_unmark_q(irq_ptr
->input_qs
[i
]);
2638 tasklet_kill(&irq_ptr
->input_qs
[i
]->tasklet
);
2639 wait_event_interruptible_timeout(cdev
->private->wait_q
,
2640 !atomic_read(&irq_ptr
->
2643 QDIO_NO_USE_COUNT_TIMEOUT
);
2644 if (atomic_read(&irq_ptr
->input_qs
[i
]->use_count
))
2645 result
=-EINPROGRESS
;
2648 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
2649 tasklet_kill(&irq_ptr
->output_qs
[i
]->tasklet
);
2650 del_timer(&irq_ptr
->output_qs
[i
]->timer
);
2651 wait_event_interruptible_timeout(cdev
->private->wait_q
,
2652 !atomic_read(&irq_ptr
->
2655 QDIO_NO_USE_COUNT_TIMEOUT
);
2656 if (atomic_read(&irq_ptr
->output_qs
[i
]->use_count
))
2657 result
=-EINPROGRESS
;
2660 /* cleanup subchannel */
2661 spin_lock_irqsave(get_ccwdev_lock(cdev
),flags
);
2662 if (how
&QDIO_FLAG_CLEANUP_USING_CLEAR
) {
2663 rc
= ccw_device_clear(cdev
, QDIO_DOING_CLEANUP
);
2664 timeout
=QDIO_CLEANUP_CLEAR_TIMEOUT
;
2665 } else if (how
&QDIO_FLAG_CLEANUP_USING_HALT
) {
2666 rc
= ccw_device_halt(cdev
, QDIO_DOING_CLEANUP
);
2667 timeout
=QDIO_CLEANUP_HALT_TIMEOUT
;
2668 } else { /* default behaviour */
2669 rc
= ccw_device_halt(cdev
, QDIO_DOING_CLEANUP
);
2670 timeout
=QDIO_CLEANUP_HALT_TIMEOUT
;
2672 if (rc
== -ENODEV
) {
2673 /* No need to wait for device no longer present. */
2674 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2675 spin_unlock_irqrestore(get_ccwdev_lock(cdev
), flags
);
2676 } else if (((void *)cdev
->handler
!= (void *)qdio_handler
) && rc
== 0) {
2678 * Whoever put another handler there, has to cope with the
2679 * interrupt theirself. Might happen if qdio_shutdown was
2680 * called on already shutdown queues, but this shouldn't have
2683 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2684 spin_unlock_irqrestore(get_ccwdev_lock(cdev
), flags
);
2685 } else if (rc
== 0) {
2686 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_CLEANUP
);
2687 ccw_device_set_timeout(cdev
, timeout
);
2688 spin_unlock_irqrestore(get_ccwdev_lock(cdev
),flags
);
2690 wait_event(cdev
->private->wait_q
,
2691 irq_ptr
->state
== QDIO_IRQ_STATE_INACTIVE
||
2692 irq_ptr
->state
== QDIO_IRQ_STATE_ERR
);
2694 QDIO_PRINT_INFO("ccw_device_{halt,clear} returned %d for "
2695 "device %s\n", result
, cdev
->dev
.bus_id
);
2696 spin_unlock_irqrestore(get_ccwdev_lock(cdev
), flags
);
2700 if (irq_ptr
->is_thinint_irq
) {
2701 qdio_put_indicator((__u32
*)irq_ptr
->dev_st_chg_ind
);
2702 tiqdio_set_subchannel_ind(irq_ptr
,1);
2703 /* reset adapter interrupt indicators */
2706 /* exchange int handlers, if necessary */
2707 if ((void*)cdev
->handler
== (void*)qdio_handler
)
2708 cdev
->handler
=irq_ptr
->original_int_handler
;
2710 /* Ignore errors. */
2711 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_INACTIVE
);
2712 ccw_device_set_timeout(cdev
, 0);
2714 up(&irq_ptr
->setting_up_sema
);
2719 qdio_free(struct ccw_device
*cdev
)
2721 struct qdio_irq
*irq_ptr
;
2724 irq_ptr
= cdev
->private->qdio_data
;
2728 down(&irq_ptr
->setting_up_sema
);
2730 sprintf(dbf_text
,"qfqs%4x",irq_ptr
->schid
.sch_no
);
2731 QDIO_DBF_TEXT1(0,trace
,dbf_text
);
2732 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2734 cdev
->private->qdio_data
= NULL
;
2736 up(&irq_ptr
->setting_up_sema
);
2738 qdio_release_irq_memory(irq_ptr
);
2739 module_put(THIS_MODULE
);
2744 qdio_allocate_do_dbf(struct qdio_initialize
*init_data
)
2746 char dbf_text
[20]; /* if a printf printed out more than 8 chars */
2748 sprintf(dbf_text
,"qfmt:%x",init_data
->q_format
);
2749 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2750 QDIO_DBF_HEX0(0,setup
,init_data
->adapter_name
,8);
2751 sprintf(dbf_text
,"qpff%4x",init_data
->qib_param_field_format
);
2752 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2753 QDIO_DBF_HEX0(0,setup
,&init_data
->qib_param_field
,sizeof(char*));
2754 QDIO_DBF_HEX0(0,setup
,&init_data
->input_slib_elements
,sizeof(long*));
2755 QDIO_DBF_HEX0(0,setup
,&init_data
->output_slib_elements
,sizeof(long*));
2756 sprintf(dbf_text
,"miit%4x",init_data
->min_input_threshold
);
2757 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2758 sprintf(dbf_text
,"mait%4x",init_data
->max_input_threshold
);
2759 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2760 sprintf(dbf_text
,"miot%4x",init_data
->min_output_threshold
);
2761 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2762 sprintf(dbf_text
,"maot%4x",init_data
->max_output_threshold
);
2763 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2764 sprintf(dbf_text
,"niq:%4x",init_data
->no_input_qs
);
2765 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2766 sprintf(dbf_text
,"noq:%4x",init_data
->no_output_qs
);
2767 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2768 QDIO_DBF_HEX0(0,setup
,&init_data
->input_handler
,sizeof(void*));
2769 QDIO_DBF_HEX0(0,setup
,&init_data
->output_handler
,sizeof(void*));
2770 QDIO_DBF_HEX0(0,setup
,&init_data
->int_parm
,sizeof(long));
2771 QDIO_DBF_HEX0(0,setup
,&init_data
->flags
,sizeof(long));
2772 QDIO_DBF_HEX0(0,setup
,&init_data
->input_sbal_addr_array
,sizeof(void*));
2773 QDIO_DBF_HEX0(0,setup
,&init_data
->output_sbal_addr_array
,sizeof(void*));
2777 qdio_allocate_fill_input_desc(struct qdio_irq
*irq_ptr
, int i
, int iqfmt
)
2779 irq_ptr
->input_qs
[i
]->is_iqdio_q
= iqfmt
;
2780 irq_ptr
->input_qs
[i
]->is_thinint_q
= irq_ptr
->is_thinint_irq
;
2782 irq_ptr
->qdr
->qdf0
[i
].sliba
=(unsigned long)(irq_ptr
->input_qs
[i
]->slib
);
2784 irq_ptr
->qdr
->qdf0
[i
].sla
=(unsigned long)(irq_ptr
->input_qs
[i
]->sl
);
2786 irq_ptr
->qdr
->qdf0
[i
].slsba
=
2787 (unsigned long)(&irq_ptr
->input_qs
[i
]->slsb
.acc
.val
[0]);
2789 irq_ptr
->qdr
->qdf0
[i
].akey
=QDIO_STORAGE_KEY
;
2790 irq_ptr
->qdr
->qdf0
[i
].bkey
=QDIO_STORAGE_KEY
;
2791 irq_ptr
->qdr
->qdf0
[i
].ckey
=QDIO_STORAGE_KEY
;
2792 irq_ptr
->qdr
->qdf0
[i
].dkey
=QDIO_STORAGE_KEY
;
2796 qdio_allocate_fill_output_desc(struct qdio_irq
*irq_ptr
, int i
,
2799 irq_ptr
->output_qs
[i
]->is_iqdio_q
= iqfmt
;
2800 irq_ptr
->output_qs
[i
]->is_thinint_q
= irq_ptr
->is_thinint_irq
;
2802 irq_ptr
->qdr
->qdf0
[i
+j
].sliba
=(unsigned long)(irq_ptr
->output_qs
[i
]->slib
);
2804 irq_ptr
->qdr
->qdf0
[i
+j
].sla
=(unsigned long)(irq_ptr
->output_qs
[i
]->sl
);
2806 irq_ptr
->qdr
->qdf0
[i
+j
].slsba
=
2807 (unsigned long)(&irq_ptr
->output_qs
[i
]->slsb
.acc
.val
[0]);
2809 irq_ptr
->qdr
->qdf0
[i
+j
].akey
=QDIO_STORAGE_KEY
;
2810 irq_ptr
->qdr
->qdf0
[i
+j
].bkey
=QDIO_STORAGE_KEY
;
2811 irq_ptr
->qdr
->qdf0
[i
+j
].ckey
=QDIO_STORAGE_KEY
;
2812 irq_ptr
->qdr
->qdf0
[i
+j
].dkey
=QDIO_STORAGE_KEY
;
2817 qdio_initialize_set_siga_flags_input(struct qdio_irq
*irq_ptr
)
2821 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
2822 irq_ptr
->input_qs
[i
]->siga_sync
=
2823 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_NECESSARY
;
2824 irq_ptr
->input_qs
[i
]->siga_in
=
2825 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_INPUT_NECESSARY
;
2826 irq_ptr
->input_qs
[i
]->siga_out
=
2827 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_OUTPUT_NECESSARY
;
2828 irq_ptr
->input_qs
[i
]->siga_sync_done_on_thinints
=
2829 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
;
2830 irq_ptr
->input_qs
[i
]->hydra_gives_outbound_pcis
=
2831 irq_ptr
->hydra_gives_outbound_pcis
;
2832 irq_ptr
->input_qs
[i
]->siga_sync_done_on_outb_tis
=
2834 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2835 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
))==
2836 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2837 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
));
2843 qdio_initialize_set_siga_flags_output(struct qdio_irq
*irq_ptr
)
2847 for (i
=0;i
<irq_ptr
->no_output_qs
;i
++) {
2848 irq_ptr
->output_qs
[i
]->siga_sync
=
2849 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_NECESSARY
;
2850 irq_ptr
->output_qs
[i
]->siga_in
=
2851 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_INPUT_NECESSARY
;
2852 irq_ptr
->output_qs
[i
]->siga_out
=
2853 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_OUTPUT_NECESSARY
;
2854 irq_ptr
->output_qs
[i
]->siga_sync_done_on_thinints
=
2855 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
;
2856 irq_ptr
->output_qs
[i
]->hydra_gives_outbound_pcis
=
2857 irq_ptr
->hydra_gives_outbound_pcis
;
2858 irq_ptr
->output_qs
[i
]->siga_sync_done_on_outb_tis
=
2860 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2861 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
))==
2862 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
|
2863 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS
));
2869 qdio_establish_irq_check_for_errors(struct ccw_device
*cdev
, int cstat
,
2873 struct qdio_irq
*irq_ptr
;
2875 irq_ptr
= cdev
->private->qdio_data
;
2877 if (cstat
|| (dstat
& ~(DEV_STAT_CHN_END
|DEV_STAT_DEV_END
))) {
2878 sprintf(dbf_text
,"ick1%4x",irq_ptr
->schid
.sch_no
);
2879 QDIO_DBF_TEXT2(1,trace
,dbf_text
);
2880 QDIO_DBF_HEX2(0,trace
,&dstat
,sizeof(int));
2881 QDIO_DBF_HEX2(0,trace
,&cstat
,sizeof(int));
2882 QDIO_PRINT_ERR("received check condition on establish " \
2883 "queues on irq 0.%x.%x (cs=x%x, ds=x%x).\n",
2884 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
2886 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_ERR
);
2889 if (!(dstat
& DEV_STAT_DEV_END
)) {
2890 QDIO_DBF_TEXT2(1,setup
,"eq:no de");
2891 QDIO_DBF_HEX2(0,setup
,&dstat
, sizeof(dstat
));
2892 QDIO_DBF_HEX2(0,setup
,&cstat
, sizeof(cstat
));
2893 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: didn't get "
2894 "device end: dstat=%02x, cstat=%02x\n",
2895 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
2897 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2901 if (dstat
& ~(DEV_STAT_CHN_END
|DEV_STAT_DEV_END
)) {
2902 QDIO_DBF_TEXT2(1,setup
,"eq:badio");
2903 QDIO_DBF_HEX2(0,setup
,&dstat
, sizeof(dstat
));
2904 QDIO_DBF_HEX2(0,setup
,&cstat
, sizeof(cstat
));
2905 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: got "
2906 "the following devstat: dstat=%02x, "
2907 "cstat=%02x\n", irq_ptr
->schid
.ssid
,
2908 irq_ptr
->schid
.sch_no
, dstat
, cstat
);
2909 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ERR
);
2916 qdio_establish_handle_irq(struct ccw_device
*cdev
, int cstat
, int dstat
)
2918 struct qdio_irq
*irq_ptr
;
2921 irq_ptr
= cdev
->private->qdio_data
;
2923 sprintf(dbf_text
,"qehi%4x",cdev
->private->schid
.sch_no
);
2924 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2925 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
2927 if (qdio_establish_irq_check_for_errors(cdev
, cstat
, dstat
)) {
2928 ccw_device_set_timeout(cdev
, 0);
2932 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_ESTABLISHED
);
2933 ccw_device_set_timeout(cdev
, 0);
2937 qdio_initialize(struct qdio_initialize
*init_data
)
2942 sprintf(dbf_text
,"qini%4x",init_data
->cdev
->private->schid
.sch_no
);
2943 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2944 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
2946 rc
= qdio_allocate(init_data
);
2948 rc
= qdio_establish(init_data
);
2950 qdio_free(init_data
->cdev
);
2958 qdio_allocate(struct qdio_initialize
*init_data
)
2960 struct qdio_irq
*irq_ptr
;
2963 sprintf(dbf_text
,"qalc%4x",init_data
->cdev
->private->schid
.sch_no
);
2964 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
2965 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
2966 if ( (init_data
->no_input_qs
>QDIO_MAX_QUEUES_PER_IRQ
) ||
2967 (init_data
->no_output_qs
>QDIO_MAX_QUEUES_PER_IRQ
) ||
2968 ((init_data
->no_input_qs
) && (!init_data
->input_handler
)) ||
2969 ((init_data
->no_output_qs
) && (!init_data
->output_handler
)) )
2972 if (!init_data
->input_sbal_addr_array
)
2975 if (!init_data
->output_sbal_addr_array
)
2978 qdio_allocate_do_dbf(init_data
);
2981 irq_ptr
= (void *) get_zeroed_page(GFP_KERNEL
| GFP_DMA
);
2983 QDIO_DBF_TEXT0(0,setup
,"irq_ptr:");
2984 QDIO_DBF_HEX0(0,setup
,&irq_ptr
,sizeof(void*));
2987 QDIO_PRINT_ERR("kmalloc of irq_ptr failed!\n");
2991 init_MUTEX(&irq_ptr
->setting_up_sema
);
2993 /* QDR must be in DMA area since CCW data address is only 32 bit */
2994 irq_ptr
->qdr
=kmalloc(sizeof(struct qdr
), GFP_KERNEL
| GFP_DMA
);
2995 if (!(irq_ptr
->qdr
)) {
2996 free_page((unsigned long) irq_ptr
);
2997 QDIO_PRINT_ERR("kmalloc of irq_ptr->qdr failed!\n");
3000 QDIO_DBF_TEXT0(0,setup
,"qdr:");
3001 QDIO_DBF_HEX0(0,setup
,&irq_ptr
->qdr
,sizeof(void*));
3003 if (qdio_alloc_qs(irq_ptr
,
3004 init_data
->no_input_qs
,
3005 init_data
->no_output_qs
)) {
3006 qdio_release_irq_memory(irq_ptr
);
3010 init_data
->cdev
->private->qdio_data
= irq_ptr
;
3012 qdio_set_state(irq_ptr
,QDIO_IRQ_STATE_INACTIVE
);
3017 static int qdio_fill_irq(struct qdio_initialize
*init_data
)
3023 struct qdio_irq
*irq_ptr
;
3025 irq_ptr
= init_data
->cdev
->private->qdio_data
;
3027 memset(irq_ptr
,0,((char*)&irq_ptr
->qdr
)-((char*)irq_ptr
));
3029 /* wipes qib.ac, required by ar7063 */
3030 memset(irq_ptr
->qdr
,0,sizeof(struct qdr
));
3032 irq_ptr
->int_parm
=init_data
->int_parm
;
3034 irq_ptr
->schid
= ccw_device_get_subchannel_id(init_data
->cdev
);
3035 irq_ptr
->no_input_qs
=init_data
->no_input_qs
;
3036 irq_ptr
->no_output_qs
=init_data
->no_output_qs
;
3038 if (init_data
->q_format
==QDIO_IQDIO_QFMT
) {
3039 irq_ptr
->is_iqdio_irq
=1;
3040 irq_ptr
->is_thinint_irq
=1;
3042 irq_ptr
->is_iqdio_irq
=0;
3043 irq_ptr
->is_thinint_irq
=hydra_thinints
;
3045 sprintf(dbf_text
,"is_i_t%1x%1x",
3046 irq_ptr
->is_iqdio_irq
,irq_ptr
->is_thinint_irq
);
3047 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3049 if (irq_ptr
->is_thinint_irq
) {
3050 irq_ptr
->dev_st_chg_ind
= qdio_get_indicator();
3051 QDIO_DBF_HEX1(0,setup
,&irq_ptr
->dev_st_chg_ind
,sizeof(void*));
3052 if (!irq_ptr
->dev_st_chg_ind
) {
3053 QDIO_PRINT_WARN("no indicator location available " \
3054 "for irq 0.%x.%x\n",
3055 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
);
3056 qdio_release_irq_memory(irq_ptr
);
3062 irq_ptr
->equeue
.cmd
=DEFAULT_ESTABLISH_QS_CMD
;
3063 irq_ptr
->equeue
.count
=DEFAULT_ESTABLISH_QS_COUNT
;
3064 irq_ptr
->aqueue
.cmd
=DEFAULT_ACTIVATE_QS_CMD
;
3065 irq_ptr
->aqueue
.count
=DEFAULT_ACTIVATE_QS_COUNT
;
3067 qdio_fill_qs(irq_ptr
, init_data
->cdev
,
3068 init_data
->no_input_qs
,
3069 init_data
->no_output_qs
,
3070 init_data
->input_handler
,
3071 init_data
->output_handler
,init_data
->int_parm
,
3072 init_data
->q_format
,init_data
->flags
,
3073 init_data
->input_sbal_addr_array
,
3074 init_data
->output_sbal_addr_array
);
3076 if (!try_module_get(THIS_MODULE
)) {
3077 QDIO_PRINT_CRIT("try_module_get() failed!\n");
3078 qdio_release_irq_memory(irq_ptr
);
3082 qdio_fill_thresholds(irq_ptr
,init_data
->no_input_qs
,
3083 init_data
->no_output_qs
,
3084 init_data
->min_input_threshold
,
3085 init_data
->max_input_threshold
,
3086 init_data
->min_output_threshold
,
3087 init_data
->max_output_threshold
);
3090 irq_ptr
->qdr
->qfmt
=init_data
->q_format
;
3091 irq_ptr
->qdr
->iqdcnt
=init_data
->no_input_qs
;
3092 irq_ptr
->qdr
->oqdcnt
=init_data
->no_output_qs
;
3093 irq_ptr
->qdr
->iqdsz
=sizeof(struct qdesfmt0
)/4; /* size in words */
3094 irq_ptr
->qdr
->oqdsz
=sizeof(struct qdesfmt0
)/4;
3096 irq_ptr
->qdr
->qiba
=(unsigned long)&irq_ptr
->qib
;
3097 irq_ptr
->qdr
->qkey
=QDIO_STORAGE_KEY
;
3100 irq_ptr
->is_qebsm
= is_passthrough
;
3101 if (irq_ptr
->is_qebsm
)
3102 irq_ptr
->qib
.rflags
|= QIB_RFLAGS_ENABLE_QEBSM
;
3104 irq_ptr
->qib
.qfmt
=init_data
->q_format
;
3105 if (init_data
->no_input_qs
)
3106 irq_ptr
->qib
.isliba
=(unsigned long)(irq_ptr
->input_qs
[0]->slib
);
3107 if (init_data
->no_output_qs
)
3108 irq_ptr
->qib
.osliba
=(unsigned long)(irq_ptr
->output_qs
[0]->slib
);
3109 memcpy(irq_ptr
->qib
.ebcnam
,init_data
->adapter_name
,8);
3111 qdio_set_impl_params(irq_ptr
,init_data
->qib_param_field_format
,
3112 init_data
->qib_param_field
,
3113 init_data
->no_input_qs
,
3114 init_data
->no_output_qs
,
3115 init_data
->input_slib_elements
,
3116 init_data
->output_slib_elements
);
3118 /* first input descriptors, then output descriptors */
3119 is_iqdio
= (init_data
->q_format
== QDIO_IQDIO_QFMT
) ? 1 : 0;
3120 for (i
=0;i
<init_data
->no_input_qs
;i
++)
3121 qdio_allocate_fill_input_desc(irq_ptr
, i
, is_iqdio
);
3123 for (i
=0;i
<init_data
->no_output_qs
;i
++)
3124 qdio_allocate_fill_output_desc(irq_ptr
, i
,
3125 init_data
->no_input_qs
,
3128 /* qdr, qib, sls, slsbs, slibs, sbales filled. */
3130 /* get qdio commands */
3131 ciw
= ccw_device_get_ciw(init_data
->cdev
, CIW_TYPE_EQUEUE
);
3133 QDIO_DBF_TEXT2(1,setup
,"no eq");
3134 QDIO_PRINT_INFO("No equeue CIW found for QDIO commands. "
3135 "Trying to use default.\n");
3137 irq_ptr
->equeue
= *ciw
;
3138 ciw
= ccw_device_get_ciw(init_data
->cdev
, CIW_TYPE_AQUEUE
);
3140 QDIO_DBF_TEXT2(1,setup
,"no aq");
3141 QDIO_PRINT_INFO("No aqueue CIW found for QDIO commands. "
3142 "Trying to use default.\n");
3144 irq_ptr
->aqueue
= *ciw
;
3146 /* Set new interrupt handler. */
3147 irq_ptr
->original_int_handler
= init_data
->cdev
->handler
;
3148 init_data
->cdev
->handler
= qdio_handler
;
3154 qdio_establish(struct qdio_initialize
*init_data
)
3156 struct qdio_irq
*irq_ptr
;
3157 unsigned long saveflags
;
3158 int result
, result2
;
3159 struct ccw_device
*cdev
;
3162 cdev
=init_data
->cdev
;
3163 irq_ptr
= cdev
->private->qdio_data
;
3167 if (cdev
->private->state
!= DEV_STATE_ONLINE
)
3170 down(&irq_ptr
->setting_up_sema
);
3172 qdio_fill_irq(init_data
);
3174 /* the thinint CHSC stuff */
3175 if (irq_ptr
->is_thinint_irq
) {
3177 result
= tiqdio_set_subchannel_ind(irq_ptr
,0);
3179 up(&irq_ptr
->setting_up_sema
);
3180 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
3183 tiqdio_set_delay_target(irq_ptr
,TIQDIO_DELAY_TARGET
);
3186 sprintf(dbf_text
,"qest%4x",cdev
->private->schid
.sch_no
);
3187 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
3188 QDIO_DBF_TEXT0(0,trace
,dbf_text
);
3191 irq_ptr
->ccw
.cmd_code
=irq_ptr
->equeue
.cmd
;
3192 irq_ptr
->ccw
.flags
=CCW_FLAG_SLI
;
3193 irq_ptr
->ccw
.count
=irq_ptr
->equeue
.count
;
3194 irq_ptr
->ccw
.cda
=QDIO_GET_ADDR(irq_ptr
->qdr
);
3196 spin_lock_irqsave(get_ccwdev_lock(cdev
),saveflags
);
3198 ccw_device_set_options_mask(cdev
, 0);
3199 result
=ccw_device_start_timeout(cdev
,&irq_ptr
->ccw
,
3200 QDIO_DOING_ESTABLISH
,0, 0,
3201 QDIO_ESTABLISH_TIMEOUT
);
3203 result2
=ccw_device_start_timeout(cdev
,&irq_ptr
->ccw
,
3204 QDIO_DOING_ESTABLISH
,0,0,
3205 QDIO_ESTABLISH_TIMEOUT
);
3206 sprintf(dbf_text
,"eq:io%4x",result
);
3207 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3209 sprintf(dbf_text
,"eq:io%4x",result
);
3210 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3212 QDIO_PRINT_WARN("establish queues on irq 0.%x.%04x: do_IO " \
3213 "returned %i, next try returned %i\n",
3214 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
3218 ccw_device_set_timeout(cdev
, 0);
3221 spin_unlock_irqrestore(get_ccwdev_lock(cdev
),saveflags
);
3224 up(&irq_ptr
->setting_up_sema
);
3225 qdio_shutdown(cdev
,QDIO_FLAG_CLEANUP_USING_CLEAR
);
3229 /* Timeout is cared for already by using ccw_device_start_timeout(). */
3230 wait_event_interruptible(cdev
->private->wait_q
,
3231 irq_ptr
->state
== QDIO_IRQ_STATE_ESTABLISHED
||
3232 irq_ptr
->state
== QDIO_IRQ_STATE_ERR
);
3234 if (irq_ptr
->state
== QDIO_IRQ_STATE_ESTABLISHED
)
3237 up(&irq_ptr
->setting_up_sema
);
3238 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
3242 qdio_get_ssqd_information(irq_ptr
);
3243 /* if this gets set once, we're running under VM and can omit SVSes */
3244 if (irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_NECESSARY
)
3247 sprintf(dbf_text
,"qdioac%2x",irq_ptr
->qdioac
);
3248 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3250 sprintf(dbf_text
,"qib ac%2x",irq_ptr
->qib
.ac
);
3251 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3253 irq_ptr
->hydra_gives_outbound_pcis
=
3254 irq_ptr
->qib
.ac
&QIB_AC_OUTBOUND_PCI_SUPPORTED
;
3255 irq_ptr
->sync_done_on_outb_pcis
=
3256 irq_ptr
->qdioac
&CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS
;
3258 qdio_initialize_set_siga_flags_input(irq_ptr
);
3259 qdio_initialize_set_siga_flags_output(irq_ptr
);
3261 up(&irq_ptr
->setting_up_sema
);
3268 qdio_activate(struct ccw_device
*cdev
, int flags
)
3270 struct qdio_irq
*irq_ptr
;
3271 int i
,result
=0,result2
;
3272 unsigned long saveflags
;
3273 char dbf_text
[20]; /* see qdio_initialize */
3275 irq_ptr
= cdev
->private->qdio_data
;
3279 if (cdev
->private->state
!= DEV_STATE_ONLINE
)
3282 down(&irq_ptr
->setting_up_sema
);
3283 if (irq_ptr
->state
==QDIO_IRQ_STATE_INACTIVE
) {
3288 sprintf(dbf_text
,"qact%4x", irq_ptr
->schid
.sch_no
);
3289 QDIO_DBF_TEXT2(0,setup
,dbf_text
);
3290 QDIO_DBF_TEXT2(0,trace
,dbf_text
);
3293 irq_ptr
->ccw
.cmd_code
=irq_ptr
->aqueue
.cmd
;
3294 irq_ptr
->ccw
.flags
=CCW_FLAG_SLI
;
3295 irq_ptr
->ccw
.count
=irq_ptr
->aqueue
.count
;
3296 irq_ptr
->ccw
.cda
=QDIO_GET_ADDR(0);
3298 spin_lock_irqsave(get_ccwdev_lock(cdev
),saveflags
);
3300 ccw_device_set_timeout(cdev
, 0);
3301 ccw_device_set_options(cdev
, CCWDEV_REPORT_ALL
);
3302 result
=ccw_device_start(cdev
,&irq_ptr
->ccw
,QDIO_DOING_ACTIVATE
,
3303 0, DOIO_DENY_PREFETCH
);
3305 result2
=ccw_device_start(cdev
,&irq_ptr
->ccw
,
3306 QDIO_DOING_ACTIVATE
,0,0);
3307 sprintf(dbf_text
,"aq:io%4x",result
);
3308 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3310 sprintf(dbf_text
,"aq:io%4x",result
);
3311 QDIO_DBF_TEXT2(1,setup
,dbf_text
);
3313 QDIO_PRINT_WARN("activate queues on irq 0.%x.%04x: do_IO " \
3314 "returned %i, next try returned %i\n",
3315 irq_ptr
->schid
.ssid
, irq_ptr
->schid
.sch_no
,
3320 spin_unlock_irqrestore(get_ccwdev_lock(cdev
),saveflags
);
3324 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
3325 if (irq_ptr
->is_thinint_irq
) {
3327 * that way we know, that, if we will get interrupted
3328 * by tiqdio_inbound_processing, qdio_unmark_q will
3331 qdio_reserve_q(irq_ptr
->input_qs
[i
]);
3332 qdio_mark_tiq(irq_ptr
->input_qs
[i
]);
3333 qdio_release_q(irq_ptr
->input_qs
[i
]);
3337 if (flags
&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT
) {
3338 for (i
=0;i
<irq_ptr
->no_input_qs
;i
++) {
3339 irq_ptr
->input_qs
[i
]->is_input_q
|=
3340 QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT
;
3344 wait_event_interruptible_timeout(cdev
->private->wait_q
,
3346 QDIO_IRQ_STATE_STOPPED
) ||
3348 QDIO_IRQ_STATE_ERR
)),
3349 QDIO_ACTIVATE_TIMEOUT
);
3351 switch (irq_ptr
->state
) {
3352 case QDIO_IRQ_STATE_STOPPED
:
3353 case QDIO_IRQ_STATE_ERR
:
3354 up(&irq_ptr
->setting_up_sema
);
3355 qdio_shutdown(cdev
, QDIO_FLAG_CLEANUP_USING_CLEAR
);
3356 down(&irq_ptr
->setting_up_sema
);
3360 qdio_set_state(irq_ptr
, QDIO_IRQ_STATE_ACTIVE
);
3364 up(&irq_ptr
->setting_up_sema
);
3369 /* buffers filled forwards again to make Rick happy */
3371 qdio_do_qdio_fill_input(struct qdio_q
*q
, unsigned int qidx
,
3372 unsigned int count
, struct qdio_buffer
*buffers
)
3374 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
3377 qidx
&= (QDIO_MAX_BUFFERS_PER_Q
- 1);
3378 if (irq
->is_qebsm
) {
3380 tmp
= set_slsb(q
, &qidx
, SLSB_CU_INPUT_EMPTY
, &count
);
3387 set_slsb(q
, &qidx
, SLSB_CU_INPUT_EMPTY
, &count
);
3390 qidx
= (qidx
+ 1) & (QDIO_MAX_BUFFERS_PER_Q
- 1);
3395 qdio_do_qdio_fill_output(struct qdio_q
*q
, unsigned int qidx
,
3396 unsigned int count
, struct qdio_buffer
*buffers
)
3398 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
3401 qidx
&= (QDIO_MAX_BUFFERS_PER_Q
- 1);
3402 if (irq
->is_qebsm
) {
3404 tmp
= set_slsb(q
, &qidx
, SLSB_CU_OUTPUT_PRIMED
, &count
);
3412 set_slsb(q
, &qidx
, SLSB_CU_OUTPUT_PRIMED
, &count
);
3415 qidx
= (qidx
+ 1) & (QDIO_MAX_BUFFERS_PER_Q
- 1);
3420 do_qdio_handle_inbound(struct qdio_q
*q
, unsigned int callflags
,
3421 unsigned int qidx
, unsigned int count
,
3422 struct qdio_buffer
*buffers
)
3426 /* This is the inbound handling of queues */
3427 used_elements
=atomic_add_return(count
, &q
->number_of_buffers_used
) - count
;
3429 qdio_do_qdio_fill_input(q
,qidx
,count
,buffers
);
3431 if ((used_elements
+count
==QDIO_MAX_BUFFERS_PER_Q
)&&
3432 (callflags
&QDIO_FLAG_UNDER_INTERRUPT
))
3433 atomic_xchg(&q
->polling
,0);
3437 if (callflags
&QDIO_FLAG_DONT_SIGA
)
3442 result
=qdio_siga_input(q
);
3445 q
->error_status_flags
|=
3446 QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR
;
3447 q
->error_status_flags
|=QDIO_STATUS_LOOK_FOR_ERROR
;
3448 q
->siga_error
=result
;
3456 do_qdio_handle_outbound(struct qdio_q
*q
, unsigned int callflags
,
3457 unsigned int qidx
, unsigned int count
,
3458 struct qdio_buffer
*buffers
)
3461 unsigned int cnt
, start_buf
;
3462 unsigned char state
= 0;
3463 struct qdio_irq
*irq
= (struct qdio_irq
*) q
->irq_ptr
;
3465 /* This is the outbound handling of queues */
3466 qdio_do_qdio_fill_output(q
,qidx
,count
,buffers
);
3468 used_elements
=atomic_add_return(count
, &q
->number_of_buffers_used
) - count
;
3470 if (callflags
&QDIO_FLAG_DONT_SIGA
) {
3471 qdio_perf_stat_inc(&perf_stats
.outbound_cnt
);
3474 if (callflags
& QDIO_FLAG_PCI_OUT
)
3478 if (q
->is_iqdio_q
) {
3479 /* one siga for every sbal */
3481 qdio_kick_outbound_q(q
);
3483 __qdio_outbound_processing(q
);
3485 /* under VM, we do a SIGA sync unconditionally */
3489 * w/o shadow queues (else branch of
3490 * SYNC_MEMORY :-/ ), we try to
3491 * fast-requeue buffers
3493 if (irq
->is_qebsm
) {
3495 start_buf
= ((qidx
+QDIO_MAX_BUFFERS_PER_Q
-1) &
3496 (QDIO_MAX_BUFFERS_PER_Q
-1));
3497 qdio_do_eqbs(q
, &state
, &start_buf
, &cnt
);
3499 state
= q
->slsb
.acc
.val
[(qidx
+QDIO_MAX_BUFFERS_PER_Q
-1)
3500 &(QDIO_MAX_BUFFERS_PER_Q
-1) ];
3501 if (state
!= SLSB_CU_OUTPUT_PRIMED
) {
3502 qdio_kick_outbound_q(q
);
3504 QDIO_DBF_TEXT3(0,trace
, "fast-req");
3505 qdio_perf_stat_inc(&perf_stats
.fast_reqs
);
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 qdio_perf_stat_inc(&perf_stats
.outbound_cnt
);
3519 /* count must be 1 in iqdio */
3521 do_QDIO(struct ccw_device
*cdev
,unsigned int callflags
,
3522 unsigned int queue_number
, unsigned int qidx
,
3523 unsigned int count
,struct qdio_buffer
*buffers
)
3525 struct qdio_irq
*irq_ptr
;
3526 #ifdef CONFIG_QDIO_DEBUG
3529 sprintf(dbf_text
,"doQD%04x",cdev
->private->schid
.sch_no
);
3530 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
3531 #endif /* CONFIG_QDIO_DEBUG */
3533 if ( (qidx
>QDIO_MAX_BUFFERS_PER_Q
) ||
3534 (count
>QDIO_MAX_BUFFERS_PER_Q
) ||
3535 (queue_number
>QDIO_MAX_QUEUES_PER_IRQ
) )
3541 irq_ptr
= cdev
->private->qdio_data
;
3545 #ifdef CONFIG_QDIO_DEBUG
3546 if (callflags
&QDIO_FLAG_SYNC_INPUT
)
3547 QDIO_DBF_HEX3(0,trace
,&irq_ptr
->input_qs
[queue_number
],
3550 QDIO_DBF_HEX3(0,trace
,&irq_ptr
->output_qs
[queue_number
],
3552 sprintf(dbf_text
,"flag%04x",callflags
);
3553 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
3554 sprintf(dbf_text
,"qi%02xct%02x",qidx
,count
);
3555 QDIO_DBF_TEXT3(0,trace
,dbf_text
);
3556 #endif /* CONFIG_QDIO_DEBUG */
3558 if (irq_ptr
->state
!=QDIO_IRQ_STATE_ACTIVE
)
3561 if (callflags
&QDIO_FLAG_SYNC_INPUT
)
3562 do_qdio_handle_inbound(irq_ptr
->input_qs
[queue_number
],
3563 callflags
, qidx
, count
, buffers
);
3564 else if (callflags
&QDIO_FLAG_SYNC_OUTPUT
)
3565 do_qdio_handle_outbound(irq_ptr
->output_qs
[queue_number
],
3566 callflags
, qidx
, count
, buffers
);
3568 QDIO_DBF_TEXT3(1,trace
,"doQD:inv");
3575 qdio_perf_procfile_read(char *buffer
, char **buffer_location
, off_t offset
,
3576 int buffer_length
, int *eof
, void *data
)
3580 /* we are always called with buffer_length=4k, so we all
3581 deliver on the first read */
3585 #define _OUTP_IT(x...) c+=sprintf(buffer+c,x)
3587 _OUTP_IT("Number of tasklet runs (total) : %li\n",
3588 (long)atomic64_read(&perf_stats
.tl_runs
));
3589 _OUTP_IT("Inbound tasklet runs tried/retried : %li/%li\n",
3590 (long)atomic64_read(&perf_stats
.inbound_tl_runs
),
3591 (long)atomic64_read(&perf_stats
.inbound_tl_runs_resched
));
3592 _OUTP_IT("Inbound-thin tasklet runs tried/retried : %li/%li\n",
3593 (long)atomic64_read(&perf_stats
.inbound_thin_tl_runs
),
3594 (long)atomic64_read(&perf_stats
.inbound_thin_tl_runs_resched
));
3595 _OUTP_IT("Outbound tasklet runs tried/retried : %li/%li\n",
3596 (long)atomic64_read(&perf_stats
.outbound_tl_runs
),
3597 (long)atomic64_read(&perf_stats
.outbound_tl_runs_resched
));
3599 _OUTP_IT("Number of SIGA sync's issued : %li\n",
3600 (long)atomic64_read(&perf_stats
.siga_syncs
));
3601 _OUTP_IT("Number of SIGA in's issued : %li\n",
3602 (long)atomic64_read(&perf_stats
.siga_ins
));
3603 _OUTP_IT("Number of SIGA out's issued : %li\n",
3604 (long)atomic64_read(&perf_stats
.siga_outs
));
3605 _OUTP_IT("Number of PCIs caught : %li\n",
3606 (long)atomic64_read(&perf_stats
.pcis
));
3607 _OUTP_IT("Number of adapter interrupts caught : %li\n",
3608 (long)atomic64_read(&perf_stats
.thinints
));
3609 _OUTP_IT("Number of fast requeues (outg. SBALs w/o SIGA) : %li\n",
3610 (long)atomic64_read(&perf_stats
.fast_reqs
));
3612 _OUTP_IT("Number of inbound transfers : %li\n",
3613 (long)atomic64_read(&perf_stats
.inbound_cnt
));
3614 _OUTP_IT("Number of do_QDIOs outbound : %li\n",
3615 (long)atomic64_read(&perf_stats
.outbound_cnt
));
3616 #else /* CONFIG_64BIT */
3617 _OUTP_IT("Number of tasklet runs (total) : %i\n",
3618 atomic_read(&perf_stats
.tl_runs
));
3619 _OUTP_IT("Inbound tasklet runs tried/retried : %i/%i\n",
3620 atomic_read(&perf_stats
.inbound_tl_runs
),
3621 atomic_read(&perf_stats
.inbound_tl_runs_resched
));
3622 _OUTP_IT("Inbound-thin tasklet runs tried/retried : %i/%i\n",
3623 atomic_read(&perf_stats
.inbound_thin_tl_runs
),
3624 atomic_read(&perf_stats
.inbound_thin_tl_runs_resched
));
3625 _OUTP_IT("Outbound tasklet runs tried/retried : %i/%i\n",
3626 atomic_read(&perf_stats
.outbound_tl_runs
),
3627 atomic_read(&perf_stats
.outbound_tl_runs_resched
));
3629 _OUTP_IT("Number of SIGA sync's issued : %i\n",
3630 atomic_read(&perf_stats
.siga_syncs
));
3631 _OUTP_IT("Number of SIGA in's issued : %i\n",
3632 atomic_read(&perf_stats
.siga_ins
));
3633 _OUTP_IT("Number of SIGA out's issued : %i\n",
3634 atomic_read(&perf_stats
.siga_outs
));
3635 _OUTP_IT("Number of PCIs caught : %i\n",
3636 atomic_read(&perf_stats
.pcis
));
3637 _OUTP_IT("Number of adapter interrupts caught : %i\n",
3638 atomic_read(&perf_stats
.thinints
));
3639 _OUTP_IT("Number of fast requeues (outg. SBALs w/o SIGA) : %i\n",
3640 atomic_read(&perf_stats
.fast_reqs
));
3642 _OUTP_IT("Number of inbound transfers : %i\n",
3643 atomic_read(&perf_stats
.inbound_cnt
));
3644 _OUTP_IT("Number of do_QDIOs outbound : %i\n",
3645 atomic_read(&perf_stats
.outbound_cnt
));
3646 #endif /* CONFIG_64BIT */
3652 static struct proc_dir_entry
*qdio_perf_proc_file
;
3655 qdio_add_procfs_entry(void)
3657 proc_perf_file_registration
=0;
3658 qdio_perf_proc_file
=create_proc_entry(QDIO_PERF
,
3659 S_IFREG
|0444,&proc_root
);
3660 if (qdio_perf_proc_file
) {
3661 qdio_perf_proc_file
->read_proc
=&qdio_perf_procfile_read
;
3662 } else proc_perf_file_registration
=-1;
3664 if (proc_perf_file_registration
)
3665 QDIO_PRINT_WARN("was not able to register perf. " \
3666 "proc-file (%i).\n",
3667 proc_perf_file_registration
);
3671 qdio_remove_procfs_entry(void)
3673 if (!proc_perf_file_registration
) /* means if it went ok earlier */
3674 remove_proc_entry(QDIO_PERF
,&proc_root
);
3678 * attributes in sysfs
3679 *****************************************************************************/
3682 qdio_performance_stats_show(struct bus_type
*bus
, char *buf
)
3684 return sprintf(buf
, "%i\n", qdio_performance_stats
? 1 : 0);
3688 qdio_performance_stats_store(struct bus_type
*bus
, const char *buf
, size_t count
)
3693 i
= simple_strtoul(buf
, &tmp
, 16);
3694 if ((i
== 0) || (i
== 1)) {
3695 if (i
== qdio_performance_stats
)
3697 qdio_performance_stats
= i
;
3699 /* reset perf. stat. info */
3701 atomic64_set(&perf_stats
.tl_runs
, 0);
3702 atomic64_set(&perf_stats
.outbound_tl_runs
, 0);
3703 atomic64_set(&perf_stats
.inbound_tl_runs
, 0);
3704 atomic64_set(&perf_stats
.inbound_tl_runs_resched
, 0);
3705 atomic64_set(&perf_stats
.inbound_thin_tl_runs
, 0);
3706 atomic64_set(&perf_stats
.inbound_thin_tl_runs_resched
,
3708 atomic64_set(&perf_stats
.siga_outs
, 0);
3709 atomic64_set(&perf_stats
.siga_ins
, 0);
3710 atomic64_set(&perf_stats
.siga_syncs
, 0);
3711 atomic64_set(&perf_stats
.pcis
, 0);
3712 atomic64_set(&perf_stats
.thinints
, 0);
3713 atomic64_set(&perf_stats
.fast_reqs
, 0);
3714 atomic64_set(&perf_stats
.outbound_cnt
, 0);
3715 atomic64_set(&perf_stats
.inbound_cnt
, 0);
3716 #else /* CONFIG_64BIT */
3717 atomic_set(&perf_stats
.tl_runs
, 0);
3718 atomic_set(&perf_stats
.outbound_tl_runs
, 0);
3719 atomic_set(&perf_stats
.inbound_tl_runs
, 0);
3720 atomic_set(&perf_stats
.inbound_tl_runs_resched
, 0);
3721 atomic_set(&perf_stats
.inbound_thin_tl_runs
, 0);
3722 atomic_set(&perf_stats
.inbound_thin_tl_runs_resched
, 0);
3723 atomic_set(&perf_stats
.siga_outs
, 0);
3724 atomic_set(&perf_stats
.siga_ins
, 0);
3725 atomic_set(&perf_stats
.siga_syncs
, 0);
3726 atomic_set(&perf_stats
.pcis
, 0);
3727 atomic_set(&perf_stats
.thinints
, 0);
3728 atomic_set(&perf_stats
.fast_reqs
, 0);
3729 atomic_set(&perf_stats
.outbound_cnt
, 0);
3730 atomic_set(&perf_stats
.inbound_cnt
, 0);
3731 #endif /* CONFIG_64BIT */
3734 QDIO_PRINT_WARN("QDIO performance_stats: write 0 or 1 to this file!\n");
3740 static BUS_ATTR(qdio_performance_stats
, 0644, qdio_performance_stats_show
,
3741 qdio_performance_stats_store
);
3744 tiqdio_register_thinints(void)
3747 register_thinint_result
=
3748 s390_register_adapter_interrupt(&tiqdio_thinint_handler
);
3749 if (register_thinint_result
) {
3750 sprintf(dbf_text
,"regthn%x",(register_thinint_result
&0xff));
3751 QDIO_DBF_TEXT0(0,setup
,dbf_text
);
3752 QDIO_PRINT_ERR("failed to register adapter handler " \
3753 "(rc=%i).\nAdapter interrupts might " \
3754 "not work. Continuing.\n",
3755 register_thinint_result
);
3760 tiqdio_unregister_thinints(void)
3762 if (!register_thinint_result
)
3763 s390_unregister_adapter_interrupt(&tiqdio_thinint_handler
);
3767 qdio_get_qdio_memory(void)
3770 indicator_used
[0]=1;
3772 for (i
=1;i
<INDICATORS_PER_CACHELINE
;i
++)
3773 indicator_used
[i
]=0;
3774 indicators
= kzalloc(sizeof(__u32
)*(INDICATORS_PER_CACHELINE
),
3782 qdio_release_qdio_memory(void)
3789 qdio_unregister_dbf_views(void)
3792 debug_unregister(qdio_dbf_setup
);
3794 debug_unregister(qdio_dbf_sbal
);
3796 debug_unregister(qdio_dbf_sense
);
3798 debug_unregister(qdio_dbf_trace
);
3799 #ifdef CONFIG_QDIO_DEBUG
3800 if (qdio_dbf_slsb_out
)
3801 debug_unregister(qdio_dbf_slsb_out
);
3802 if (qdio_dbf_slsb_in
)
3803 debug_unregister(qdio_dbf_slsb_in
);
3804 #endif /* CONFIG_QDIO_DEBUG */
3808 qdio_register_dbf_views(void)
3810 qdio_dbf_setup
=debug_register(QDIO_DBF_SETUP_NAME
,
3811 QDIO_DBF_SETUP_PAGES
,
3812 QDIO_DBF_SETUP_NR_AREAS
,
3813 QDIO_DBF_SETUP_LEN
);
3814 if (!qdio_dbf_setup
)
3816 debug_register_view(qdio_dbf_setup
,&debug_hex_ascii_view
);
3817 debug_set_level(qdio_dbf_setup
,QDIO_DBF_SETUP_LEVEL
);
3819 qdio_dbf_sbal
=debug_register(QDIO_DBF_SBAL_NAME
,
3820 QDIO_DBF_SBAL_PAGES
,
3821 QDIO_DBF_SBAL_NR_AREAS
,
3826 debug_register_view(qdio_dbf_sbal
,&debug_hex_ascii_view
);
3827 debug_set_level(qdio_dbf_sbal
,QDIO_DBF_SBAL_LEVEL
);
3829 qdio_dbf_sense
=debug_register(QDIO_DBF_SENSE_NAME
,
3830 QDIO_DBF_SENSE_PAGES
,
3831 QDIO_DBF_SENSE_NR_AREAS
,
3832 QDIO_DBF_SENSE_LEN
);
3833 if (!qdio_dbf_sense
)
3836 debug_register_view(qdio_dbf_sense
,&debug_hex_ascii_view
);
3837 debug_set_level(qdio_dbf_sense
,QDIO_DBF_SENSE_LEVEL
);
3839 qdio_dbf_trace
=debug_register(QDIO_DBF_TRACE_NAME
,
3840 QDIO_DBF_TRACE_PAGES
,
3841 QDIO_DBF_TRACE_NR_AREAS
,
3842 QDIO_DBF_TRACE_LEN
);
3843 if (!qdio_dbf_trace
)
3846 debug_register_view(qdio_dbf_trace
,&debug_hex_ascii_view
);
3847 debug_set_level(qdio_dbf_trace
,QDIO_DBF_TRACE_LEVEL
);
3849 #ifdef CONFIG_QDIO_DEBUG
3850 qdio_dbf_slsb_out
=debug_register(QDIO_DBF_SLSB_OUT_NAME
,
3851 QDIO_DBF_SLSB_OUT_PAGES
,
3852 QDIO_DBF_SLSB_OUT_NR_AREAS
,
3853 QDIO_DBF_SLSB_OUT_LEN
);
3854 if (!qdio_dbf_slsb_out
)
3856 debug_register_view(qdio_dbf_slsb_out
,&debug_hex_ascii_view
);
3857 debug_set_level(qdio_dbf_slsb_out
,QDIO_DBF_SLSB_OUT_LEVEL
);
3859 qdio_dbf_slsb_in
=debug_register(QDIO_DBF_SLSB_IN_NAME
,
3860 QDIO_DBF_SLSB_IN_PAGES
,
3861 QDIO_DBF_SLSB_IN_NR_AREAS
,
3862 QDIO_DBF_SLSB_IN_LEN
);
3863 if (!qdio_dbf_slsb_in
)
3865 debug_register_view(qdio_dbf_slsb_in
,&debug_hex_ascii_view
);
3866 debug_set_level(qdio_dbf_slsb_in
,QDIO_DBF_SLSB_IN_LEVEL
);
3867 #endif /* CONFIG_QDIO_DEBUG */
3870 QDIO_PRINT_ERR("not enough memory for dbf.\n");
3871 qdio_unregister_dbf_views();
3875 static void *qdio_mempool_alloc(gfp_t gfp_mask
, void *size
)
3877 return (void *) get_zeroed_page(gfp_mask
|GFP_DMA
);
3880 static void qdio_mempool_free(void *element
, void *size
)
3882 free_page((unsigned long) element
);
3891 printk("qdio: loading %s\n",version
);
3893 res
=qdio_get_qdio_memory();
3897 res
= qdio_register_dbf_views();
3901 QDIO_DBF_TEXT0(0,setup
,"initQDIO");
3902 res
= bus_create_file(&ccw_bus_type
, &bus_attr_qdio_performance_stats
);
3904 memset((void*)&perf_stats
,0,sizeof(perf_stats
));
3905 QDIO_DBF_TEXT0(0,setup
,"perfstat");
3907 QDIO_DBF_HEX0(0,setup
,&ptr
,sizeof(void*));
3909 qdio_add_procfs_entry();
3911 qdio_mempool_scssc
= mempool_create(QDIO_MEMPOOL_SCSSC_ELEMENTS
,
3913 qdio_mempool_free
, NULL
);
3915 if (tiqdio_check_chsc_availability())
3916 QDIO_PRINT_ERR("Not all CHSCs supported. Continuing.\n");
3918 tiqdio_register_thinints();
3926 tiqdio_unregister_thinints();
3927 qdio_remove_procfs_entry();
3928 qdio_release_qdio_memory();
3929 qdio_unregister_dbf_views();
3930 mempool_destroy(qdio_mempool_scssc
);
3931 bus_remove_file(&ccw_bus_type
, &bus_attr_qdio_performance_stats
);
3932 printk("qdio: %s: module removed\n",version
);
3935 module_init(init_QDIO
);
3936 module_exit(cleanup_QDIO
);
3938 EXPORT_SYMBOL(qdio_allocate
);
3939 EXPORT_SYMBOL(qdio_establish
);
3940 EXPORT_SYMBOL(qdio_initialize
);
3941 EXPORT_SYMBOL(qdio_activate
);
3942 EXPORT_SYMBOL(do_QDIO
);
3943 EXPORT_SYMBOL(qdio_shutdown
);
3944 EXPORT_SYMBOL(qdio_free
);
3945 EXPORT_SYMBOL(qdio_cleanup
);
3946 EXPORT_SYMBOL(qdio_synchronize
);