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 <cohuck@de.ibm.com>
12 * Restriction: only 63 iqdio subchannels would have its own indicator,
13 * after that, subsequent subchannels share one indicator
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2, or (at your option)
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 #include <linux/config.h>
34 #include <linux/module.h>
35 #include <linux/init.h>
37 #include <linux/slab.h>
38 #include <linux/kernel.h>
39 #include <linux/proc_fs.h>
40 #include <linux/timer.h>
42 #include <asm/ccwdev.h>
44 #include <asm/atomic.h>
45 #include <asm/semaphore.h>
46 #include <asm/timex.h>
48 #include <asm/debug.h>
59 #define VERSION_QDIO_C "$Revision: 1.113 $"
61 /****************** MODULE PARAMETER VARIABLES ********************/
62 MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>");
63 MODULE_DESCRIPTION("QDIO base support version 2, " \
64 "Copyright 2000 IBM Corporation");
65 MODULE_LICENSE("GPL");
67 /******************** HERE WE GO ***********************************/
69 static const char version[] = "QDIO base support version 2 ("
70 VERSION_QDIO_C "/" VERSION_QDIO_H "/" VERSION_CIO_QDIO_H ")";
72 #ifdef QDIO_PERFORMANCE_STATS
73 static int proc_perf_file_registration;
74 static unsigned long i_p_c, i_p_nc, o_p_c, o_p_nc, ii_p_c, ii_p_nc;
75 static struct qdio_perf_stats perf_stats;
76 #endif /* QDIO_PERFORMANCE_STATS */
78 static int hydra_thinints;
79 static int is_passthrough = 0;
82 static int indicator_used[INDICATORS_PER_CACHELINE];
83 static __u32 * volatile indicators;
84 static __u32 volatile spare_indicator;
85 static atomic_t spare_indicator_usecount;
87 static debug_info_t *qdio_dbf_setup;
88 static debug_info_t *qdio_dbf_sbal;
89 static debug_info_t *qdio_dbf_trace;
90 static debug_info_t *qdio_dbf_sense;
91 #ifdef CONFIG_QDIO_DEBUG
92 static debug_info_t *qdio_dbf_slsb_out;
93 static debug_info_t *qdio_dbf_slsb_in;
94 #endif /* CONFIG_QDIO_DEBUG */
97 static volatile struct qdio_q *tiq_list=NULL; /* volatile as it could change
98 during a while loop */
99 static DEFINE_SPINLOCK(ttiq_list_lock);
100 static int register_thinint_result;
101 static void tiqdio_tl(unsigned long);
102 static DECLARE_TASKLET(tiqdio_tasklet,tiqdio_tl,0);
104 /* not a macro, as one of the arguments is atomic_read */
106 qdio_min(int a,int b)
114 /***************** SCRUBBER HELPER ROUTINES **********************/
117 qdio_get_micros(void)
119 return (get_clock() >> 10); /* time>>12 is microseconds */
123 * unfortunately, we can't just xchg the values; in do_QDIO we want to reserve
124 * the q in any case, so that we'll not be interrupted when we are in
125 * qdio_mark_tiq... shouldn't have a really bad impact, as reserving almost
126 * ever works (last famous words)
129 qdio_reserve_q(struct qdio_q *q)
131 return atomic_add_return(1,&q->use_count) - 1;
135 qdio_release_q(struct qdio_q *q)
137 atomic_dec(&q->use_count);
142 qdio_check_ccq(struct qdio_q *q, unsigned int ccq)
146 if (ccq == 0 || ccq == 32 || ccq == 96)
150 /*notify devices immediately*/
151 sprintf(dbf_text,"%d", ccq);
152 QDIO_DBF_TEXT2(1,trace,dbf_text);
155 /* EQBS: extract buffer states */
157 qdio_do_eqbs(struct qdio_q *q, unsigned char *state,
158 unsigned int *start, unsigned int *cnt)
160 struct qdio_irq *irq;
161 unsigned int tmp_cnt, q_no, ccq;
167 irq = (struct qdio_irq*)q->irq_ptr;
170 q_no += irq->no_input_qs;
171 ccq = do_eqbs(irq->sch_token, state, q_no, start, cnt);
172 rc = qdio_check_ccq(q, ccq);
174 QDIO_DBF_TEXT2(1,trace,"eqberr");
175 sprintf(dbf_text,"%2x,%2x,%d,%d",tmp_cnt, *cnt, ccq, q_no);
176 QDIO_DBF_TEXT2(1,trace,dbf_text);
177 q->handler(q->cdev,QDIO_STATUS_ACTIVATE_CHECK_CONDITION|
178 QDIO_STATUS_LOOK_FOR_ERROR,
179 0, 0, 0, -1, -1, q->int_parm);
182 return (tmp_cnt - *cnt);
185 /* SQBS: set buffer states */
187 qdio_do_sqbs(struct qdio_q *q, unsigned char state,
188 unsigned int *start, unsigned int *cnt)
190 struct qdio_irq *irq;
191 unsigned int tmp_cnt, q_no, ccq;
197 irq = (struct qdio_irq*)q->irq_ptr;
200 q_no += irq->no_input_qs;
201 ccq = do_sqbs(irq->sch_token, state, q_no, start, cnt);
202 rc = qdio_check_ccq(q, ccq);
204 QDIO_DBF_TEXT3(1,trace,"sqberr");
205 sprintf(dbf_text,"%2x,%2x,%d,%d",tmp_cnt,*cnt,ccq,q_no);
206 QDIO_DBF_TEXT3(1,trace,dbf_text);
207 q->handler(q->cdev,QDIO_STATUS_ACTIVATE_CHECK_CONDITION|
208 QDIO_STATUS_LOOK_FOR_ERROR,
209 0, 0, 0, -1, -1, q->int_parm);
212 return (tmp_cnt - *cnt);
216 qdio_set_slsb(struct qdio_q *q, unsigned int *bufno,
217 unsigned char state, unsigned int *count)
220 struct qdio_irq *irq;
222 irq = (struct qdio_irq*)q->irq_ptr;
223 if (!irq->is_qebsm) {
224 slsb = (char *)&q->slsb.acc.val[(*bufno)];
228 return qdio_do_sqbs(q, state, bufno, count);
231 #ifdef CONFIG_QDIO_DEBUG
233 qdio_trace_slsb(struct qdio_q *q)
235 if (q->queue_type==QDIO_TRACE_QTYPE) {
237 QDIO_DBF_HEX2(0,slsb_in,&q->slsb,
238 QDIO_MAX_BUFFERS_PER_Q);
240 QDIO_DBF_HEX2(0,slsb_out,&q->slsb,
241 QDIO_MAX_BUFFERS_PER_Q);
247 set_slsb(struct qdio_q *q, unsigned int *bufno,
248 unsigned char state, unsigned int *count)
251 #ifdef CONFIG_QDIO_DEBUG
254 rc = qdio_set_slsb(q, bufno, state, count);
255 #ifdef CONFIG_QDIO_DEBUG
261 qdio_siga_sync(struct qdio_q *q, unsigned int gpr2,
266 QDIO_DBF_TEXT4(0,trace,"sigasync");
267 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
269 #ifdef QDIO_PERFORMANCE_STATS
270 perf_stats.siga_syncs++;
271 #endif /* QDIO_PERFORMANCE_STATS */
273 cc = do_siga_sync(0x10000|q->irq, gpr2, gpr3);
275 QDIO_DBF_HEX3(0,trace,&cc,sizeof(int*));
281 qdio_siga_sync_q(struct qdio_q *q)
284 return qdio_siga_sync(q, 0, q->mask);
285 return qdio_siga_sync(q, q->mask, 0);
289 __do_siga_output(struct qdio_q *q, unsigned int *busy_bit)
291 struct qdio_irq *irq;
294 irq = (struct qdio_irq *) q->irq_ptr;
296 return do_siga_output(0x10000|q->irq, q->mask, busy_bit, fc);
298 return do_siga_output(irq->sch_token, q->mask, busy_bit, fc);
302 * returns QDIO_SIGA_ERROR_ACCESS_EXCEPTION as cc, when SIGA returns
303 * an access exception
306 qdio_siga_output(struct qdio_q *q)
312 #ifdef QDIO_PERFORMANCE_STATS
313 perf_stats.siga_outs++;
314 #endif /* QDIO_PERFORMANCE_STATS */
316 QDIO_DBF_TEXT4(0,trace,"sigaout");
317 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
320 cc = __do_siga_output(q, &busy_bit);
321 //QDIO_PRINT_ERR("cc=%x, busy=%x\n",cc,busy_bit);
322 if ((cc==2) && (busy_bit) && (q->is_iqdio_q)) {
325 if ((NOW-start_time)>QDIO_BUSY_BIT_PATIENCE)
331 if ((cc==2) && (busy_bit))
332 cc |= QDIO_SIGA_ERROR_B_BIT_SET;
335 QDIO_DBF_HEX3(0,trace,&cc,sizeof(int*));
341 qdio_siga_input(struct qdio_q *q)
345 QDIO_DBF_TEXT4(0,trace,"sigain");
346 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
348 #ifdef QDIO_PERFORMANCE_STATS
349 perf_stats.siga_ins++;
350 #endif /* QDIO_PERFORMANCE_STATS */
352 cc = do_siga_input(0x10000|q->irq, q->mask);
355 QDIO_DBF_HEX3(0,trace,&cc,sizeof(int*));
360 /* locked by the locks in qdio_activate and qdio_cleanup */
362 qdio_get_indicator(void)
366 for (i=1;i<INDICATORS_PER_CACHELINE;i++)
367 if (!indicator_used[i]) {
371 atomic_inc(&spare_indicator_usecount);
372 return (__u32 * volatile) &spare_indicator;
375 /* locked by the locks in qdio_activate and qdio_cleanup */
377 qdio_put_indicator(__u32 *addr)
381 if ( (addr) && (addr!=&spare_indicator) ) {
385 if (addr == &spare_indicator)
386 atomic_dec(&spare_indicator_usecount);
390 tiqdio_clear_summary_bit(__u32 *location)
392 QDIO_DBF_TEXT5(0,trace,"clrsummb");
393 QDIO_DBF_HEX5(0,trace,&location,sizeof(void*));
399 tiqdio_set_summary_bit(__u32 *location)
401 QDIO_DBF_TEXT5(0,trace,"setsummb");
402 QDIO_DBF_HEX5(0,trace,&location,sizeof(void*));
408 tiqdio_sched_tl(void)
410 tasklet_hi_schedule(&tiqdio_tasklet);
414 qdio_mark_tiq(struct qdio_q *q)
418 QDIO_DBF_TEXT4(0,trace,"mark iq");
419 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
421 spin_lock_irqsave(&ttiq_list_lock,flags);
422 if (unlikely(atomic_read(&q->is_in_shutdown)))
428 if ((q->list_prev) || (q->list_next))
436 q->list_next=tiq_list;
437 q->list_prev=tiq_list->list_prev;
438 tiq_list->list_prev->list_next=q;
439 tiq_list->list_prev=q;
441 spin_unlock_irqrestore(&ttiq_list_lock,flags);
443 tiqdio_set_summary_bit((__u32*)q->dev_st_chg_ind);
447 spin_unlock_irqrestore(&ttiq_list_lock,flags);
452 qdio_mark_q(struct qdio_q *q)
454 QDIO_DBF_TEXT4(0,trace,"mark q");
455 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
457 if (unlikely(atomic_read(&q->is_in_shutdown)))
460 tasklet_schedule(&q->tasklet);
464 qdio_stop_polling(struct qdio_q *q)
466 #ifdef QDIO_USE_PROCESSING_STATE
467 unsigned int tmp, gsf, count = 1;
468 unsigned char state = 0;
469 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
471 if (!atomic_swap(&q->polling,0))
474 QDIO_DBF_TEXT4(0,trace,"stoppoll");
475 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
477 /* show the card that we are not polling anymore */
481 tmp = gsf = GET_SAVED_FRONTIER(q);
482 tmp = ((tmp + QDIO_MAX_BUFFERS_PER_Q-1) & (QDIO_MAX_BUFFERS_PER_Q-1) );
483 set_slsb(q, &tmp, SLSB_P_INPUT_NOT_INIT, &count);
486 * we don't issue this SYNC_MEMORY, as we trust Rick T and
487 * moreover will not use the PROCESSING state under VM, so
488 * q->polling was 0 anyway
493 qdio_do_eqbs(q, &state, &gsf, &count);
495 state = q->slsb.acc.val[gsf];
496 if (state != SLSB_P_INPUT_PRIMED)
499 * set our summary bit again, as otherwise there is a
500 * small window we can miss between resetting it and
501 * checking for PRIMED state
504 tiqdio_set_summary_bit((__u32*)q->dev_st_chg_ind);
507 #else /* QDIO_USE_PROCESSING_STATE */
509 #endif /* QDIO_USE_PROCESSING_STATE */
513 * see the comment in do_QDIO and before qdio_reserve_q about the
514 * sophisticated locking outside of unmark_q, so that we don't need to
515 * disable the interrupts :-)
518 qdio_unmark_q(struct qdio_q *q)
522 QDIO_DBF_TEXT4(0,trace,"unmark q");
523 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
525 if ((!q->list_prev)||(!q->list_next))
528 if ((q->is_thinint_q)&&(q->is_input_q)) {
530 spin_lock_irqsave(&ttiq_list_lock,flags);
531 /* in case cleanup has done this already and simultanously
532 * qdio_unmark_q is called from the interrupt handler, we've
533 * got to check this in this specific case again */
534 if ((!q->list_prev)||(!q->list_next))
536 if (q->list_next==q) {
537 /* q was the only interesting q */
542 q->list_next->list_prev=q->list_prev;
543 q->list_prev->list_next=q->list_next;
544 tiq_list=q->list_next;
549 spin_unlock_irqrestore(&ttiq_list_lock,flags);
553 static inline unsigned long
554 tiqdio_clear_global_summary(void)
558 QDIO_DBF_TEXT5(0,trace,"clrglobl");
560 time = do_clear_global_summary();
562 QDIO_DBF_HEX5(0,trace,&time,sizeof(unsigned long));
568 /************************* OUTBOUND ROUTINES *******************************/
570 qdio_qebsm_get_outbound_buffer_frontier(struct qdio_q *q)
572 struct qdio_irq *irq;
574 unsigned int cnt, count, ftc;
576 irq = (struct qdio_irq *) q->irq_ptr;
577 if ((!q->is_iqdio_q) && (!q->hydra_gives_outbound_pcis))
580 ftc = q->first_to_check;
581 count = qdio_min(atomic_read(&q->number_of_buffers_used),
582 (QDIO_MAX_BUFFERS_PER_Q-1));
584 return q->first_to_check;
585 cnt = qdio_do_eqbs(q, &state, &ftc, &count);
587 return q->first_to_check;
589 case SLSB_P_OUTPUT_ERROR:
590 QDIO_DBF_TEXT3(0,trace,"outperr");
591 atomic_sub(cnt , &q->number_of_buffers_used);
593 q->error_status_flags |=
594 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR;
595 q->qdio_error = SLSB_P_OUTPUT_ERROR;
596 q->error_status_flags |= QDIO_STATUS_LOOK_FOR_ERROR;
597 q->first_to_check = ftc;
599 case SLSB_P_OUTPUT_EMPTY:
600 QDIO_DBF_TEXT5(0,trace,"outpempt");
601 atomic_sub(cnt, &q->number_of_buffers_used);
602 q->first_to_check = ftc;
604 case SLSB_CU_OUTPUT_PRIMED:
605 /* all buffers primed */
606 QDIO_DBF_TEXT5(0,trace,"outpprim");
611 QDIO_DBF_HEX4(0,trace,&q->first_to_check,sizeof(int));
612 return q->first_to_check;
616 qdio_qebsm_get_inbound_buffer_frontier(struct qdio_q *q)
618 struct qdio_irq *irq;
620 int tmp, ftc, count, cnt;
624 irq = (struct qdio_irq *) q->irq_ptr;
625 ftc = q->first_to_check;
626 count = qdio_min(atomic_read(&q->number_of_buffers_used),
627 (QDIO_MAX_BUFFERS_PER_Q-1));
629 return q->first_to_check;
630 cnt = qdio_do_eqbs(q, &state, &ftc, &count);
632 return q->first_to_check;
634 case SLSB_P_INPUT_ERROR :
635 #ifdef CONFIG_QDIO_DEBUG
636 QDIO_DBF_TEXT3(1,trace,"inperr");
637 sprintf(dbf_text,"%2x,%2x",ftc,count);
638 QDIO_DBF_TEXT3(1,trace,dbf_text);
639 #endif /* CONFIG_QDIO_DEBUG */
641 q->error_status_flags |=
642 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR;
643 q->qdio_error = SLSB_P_INPUT_ERROR;
644 q->error_status_flags |= QDIO_STATUS_LOOK_FOR_ERROR;
645 atomic_sub(cnt, &q->number_of_buffers_used);
646 q->first_to_check = ftc;
648 case SLSB_P_INPUT_PRIMED :
649 QDIO_DBF_TEXT3(0,trace,"inptprim");
650 sprintf(dbf_text,"%2x,%2x",ftc,count);
651 QDIO_DBF_TEXT3(1,trace,dbf_text);
653 ftc = q->first_to_check;
654 #ifdef QDIO_USE_PROCESSING_STATE
657 tmp = set_slsb(q, &ftc, SLSB_P_INPUT_NOT_INIT, &cnt);
662 tmp += set_slsb(q, &ftc,
663 SLSB_P_INPUT_PROCESSING, &cnt);
664 atomic_set(&q->polling, 1);
666 tmp = set_slsb(q, &ftc, SLSB_P_INPUT_NOT_INIT, &cnt);
668 atomic_sub(tmp, &q->number_of_buffers_used);
669 q->first_to_check = ftc;
671 case SLSB_CU_INPUT_EMPTY:
672 case SLSB_P_INPUT_NOT_INIT:
673 case SLSB_P_INPUT_PROCESSING:
674 QDIO_DBF_TEXT5(0,trace,"inpnipro");
679 QDIO_DBF_HEX4(0,trace,&q->first_to_check,sizeof(int));
680 return q->first_to_check;
684 qdio_get_outbound_buffer_frontier(struct qdio_q *q)
686 struct qdio_irq *irq;
688 unsigned int count = 1;
689 int first_not_to_check, f, f_mod_no;
692 QDIO_DBF_TEXT4(0,trace,"getobfro");
693 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
695 irq = (struct qdio_irq *) q->irq_ptr;
697 return qdio_qebsm_get_outbound_buffer_frontier(q);
699 slsb=&q->slsb.acc.val[0];
700 f_mod_no=f=q->first_to_check;
702 * f points to already processed elements, so f+no_used is correct...
703 * ... but: we don't check 128 buffers, as otherwise
704 * qdio_has_outbound_q_moved would return 0
706 first_not_to_check=f+qdio_min(atomic_read(&q->number_of_buffers_used),
707 (QDIO_MAX_BUFFERS_PER_Q-1));
709 if ((!q->is_iqdio_q)&&(!q->hydra_gives_outbound_pcis))
713 if (f==first_not_to_check)
716 switch(slsb[f_mod_no]) {
718 /* the adapter has not fetched the output yet */
719 case SLSB_CU_OUTPUT_PRIMED:
720 QDIO_DBF_TEXT5(0,trace,"outpprim");
723 /* the adapter got it */
724 case SLSB_P_OUTPUT_EMPTY:
725 atomic_dec(&q->number_of_buffers_used);
727 f_mod_no=f&(QDIO_MAX_BUFFERS_PER_Q-1);
728 QDIO_DBF_TEXT5(0,trace,"outpempt");
731 case SLSB_P_OUTPUT_ERROR:
732 QDIO_DBF_TEXT3(0,trace,"outperr");
733 sprintf(dbf_text,"%x-%x-%x",f_mod_no,
734 q->sbal[f_mod_no]->element[14].sbalf.value,
735 q->sbal[f_mod_no]->element[15].sbalf.value);
736 QDIO_DBF_TEXT3(1,trace,dbf_text);
737 QDIO_DBF_HEX2(1,sbal,q->sbal[f_mod_no],256);
739 /* kind of process the buffer */
740 set_slsb(q, &f_mod_no, SLSB_P_OUTPUT_NOT_INIT, &count);
743 * we increment the frontier, as this buffer
744 * was processed obviously
746 atomic_dec(&q->number_of_buffers_used);
747 f_mod_no=(f_mod_no+1)&(QDIO_MAX_BUFFERS_PER_Q-1);
750 q->error_status_flags|=
751 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR;
752 q->qdio_error=SLSB_P_OUTPUT_ERROR;
753 q->error_status_flags|=QDIO_STATUS_LOOK_FOR_ERROR;
759 QDIO_DBF_TEXT5(0,trace,"outpni");
762 return (q->first_to_check=f_mod_no);
765 /* all buffers are processed */
767 qdio_is_outbound_q_done(struct qdio_q *q)
770 #ifdef CONFIG_QDIO_DEBUG
774 no_used=atomic_read(&q->number_of_buffers_used);
776 #ifdef CONFIG_QDIO_DEBUG
778 sprintf(dbf_text,"oqisnt%02x",no_used);
779 QDIO_DBF_TEXT4(0,trace,dbf_text);
781 QDIO_DBF_TEXT4(0,trace,"oqisdone");
783 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
784 #endif /* CONFIG_QDIO_DEBUG */
789 qdio_has_outbound_q_moved(struct qdio_q *q)
793 i=qdio_get_outbound_buffer_frontier(q);
795 if ( (i!=GET_SAVED_FRONTIER(q)) ||
796 (q->error_status_flags&QDIO_STATUS_LOOK_FOR_ERROR) ) {
798 QDIO_DBF_TEXT4(0,trace,"oqhasmvd");
799 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
802 QDIO_DBF_TEXT4(0,trace,"oqhsntmv");
803 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
809 qdio_kick_outbound_q(struct qdio_q *q)
812 #ifdef CONFIG_QDIO_DEBUG
815 QDIO_DBF_TEXT4(0,trace,"kickoutq");
816 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
817 #endif /* CONFIG_QDIO_DEBUG */
822 /* here's the story with cc=2 and busy bit set (thanks, Rick):
823 * VM's CP could present us cc=2 and busy bit set on SIGA-write
824 * during reconfiguration of their Guest LAN (only in HIPERS mode,
825 * QDIO mode is asynchronous -- cc=2 and busy bit there will take
826 * the queues down immediately; and not being under VM we have a
827 * problem on cc=2 and busy bit set right away).
829 * Therefore qdio_siga_output will try for a short time constantly,
830 * if such a condition occurs. If it doesn't change, it will
831 * increase the busy_siga_counter and save the timestamp, and
832 * schedule the queue for later processing (via mark_q, using the
833 * queue tasklet). __qdio_outbound_processing will check out the
834 * counter. If non-zero, it will call qdio_kick_outbound_q as often
835 * as the value of the counter. This will attempt further SIGA
836 * instructions. For each successful SIGA, the counter is
837 * decreased, for failing SIGAs the counter remains the same, after
839 * After some time of no movement, qdio_kick_outbound_q will
840 * finally fail and reflect corresponding error codes to call
841 * the upper layer module and have it take the queues down.
843 * Note that this is a change from the original HiperSockets design
844 * (saying cc=2 and busy bit means take the queues down), but in
845 * these days Guest LAN didn't exist... excessive cc=2 with busy bit
846 * conditions will still take the queues down, but the threshold is
847 * higher due to the Guest LAN environment.
851 result=qdio_siga_output(q);
855 /* went smooth this time, reset timestamp */
856 #ifdef CONFIG_QDIO_DEBUG
857 QDIO_DBF_TEXT3(0,trace,"cc2reslv");
858 sprintf(dbf_text,"%4x%2x%2x",q->irq,q->q_no,
859 atomic_read(&q->busy_siga_counter));
860 QDIO_DBF_TEXT3(0,trace,dbf_text);
861 #endif /* CONFIG_QDIO_DEBUG */
862 q->timing.busy_start=0;
864 case (2|QDIO_SIGA_ERROR_B_BIT_SET):
865 /* cc=2 and busy bit: */
866 atomic_inc(&q->busy_siga_counter);
868 /* if the last siga was successful, save
870 if (!q->timing.busy_start)
871 q->timing.busy_start=NOW;
873 /* if we're in time, don't touch error_status_flags
875 if (NOW-q->timing.busy_start<QDIO_BUSY_BIT_GIVE_UP) {
879 QDIO_DBF_TEXT2(0,trace,"cc2REPRT");
880 #ifdef CONFIG_QDIO_DEBUG
881 sprintf(dbf_text,"%4x%2x%2x",q->irq,q->q_no,
882 atomic_read(&q->busy_siga_counter));
883 QDIO_DBF_TEXT3(0,trace,dbf_text);
884 #endif /* CONFIG_QDIO_DEBUG */
885 /* else fallthrough and report error */
887 /* for plain cc=1, 2 or 3: */
889 q->error_status_flags|=
890 QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR;
891 q->error_status_flags|=
892 QDIO_STATUS_LOOK_FOR_ERROR;
893 q->siga_error=result;
898 qdio_kick_outbound_handler(struct qdio_q *q)
900 int start, end, real_end, count;
901 #ifdef CONFIG_QDIO_DEBUG
905 start = q->first_element_to_kick;
906 /* last_move_ftc was just updated */
907 real_end = GET_SAVED_FRONTIER(q);
908 end = (real_end+QDIO_MAX_BUFFERS_PER_Q-1)&
909 (QDIO_MAX_BUFFERS_PER_Q-1);
910 count = (end+QDIO_MAX_BUFFERS_PER_Q+1-start)&
911 (QDIO_MAX_BUFFERS_PER_Q-1);
913 #ifdef CONFIG_QDIO_DEBUG
914 QDIO_DBF_TEXT4(0,trace,"kickouth");
915 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
917 sprintf(dbf_text,"s=%2xc=%2x",start,count);
918 QDIO_DBF_TEXT4(0,trace,dbf_text);
919 #endif /* CONFIG_QDIO_DEBUG */
921 if (q->state==QDIO_IRQ_STATE_ACTIVE)
922 q->handler(q->cdev,QDIO_STATUS_OUTBOUND_INT|
923 q->error_status_flags,
924 q->qdio_error,q->siga_error,q->q_no,start,count,
927 /* for the next time: */
928 q->first_element_to_kick=real_end;
931 q->error_status_flags=0;
935 __qdio_outbound_processing(struct qdio_q *q)
939 QDIO_DBF_TEXT4(0,trace,"qoutproc");
940 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
942 if (unlikely(qdio_reserve_q(q))) {
944 #ifdef QDIO_PERFORMANCE_STATS
946 #endif /* QDIO_PERFORMANCE_STATS */
947 /* as we're sissies, we'll check next time */
948 if (likely(!atomic_read(&q->is_in_shutdown))) {
950 QDIO_DBF_TEXT4(0,trace,"busy,agn");
954 #ifdef QDIO_PERFORMANCE_STATS
956 perf_stats.tl_runs++;
957 #endif /* QDIO_PERFORMANCE_STATS */
959 /* see comment in qdio_kick_outbound_q */
960 siga_attempts=atomic_read(&q->busy_siga_counter);
961 while (siga_attempts) {
962 atomic_dec(&q->busy_siga_counter);
963 qdio_kick_outbound_q(q);
967 if (qdio_has_outbound_q_moved(q))
968 qdio_kick_outbound_handler(q);
972 * for asynchronous queues, we better check, if the fill
973 * level is too high. for synchronous queues, the fill
974 * level will never be that high.
976 if (atomic_read(&q->number_of_buffers_used)>
977 IQDIO_FILL_LEVEL_TO_POLL)
980 } else if (!q->hydra_gives_outbound_pcis)
981 if (!qdio_is_outbound_q_done(q))
988 qdio_outbound_processing(struct qdio_q *q)
990 __qdio_outbound_processing(q);
993 /************************* INBOUND ROUTINES *******************************/
997 qdio_get_inbound_buffer_frontier(struct qdio_q *q)
999 struct qdio_irq *irq;
1001 volatile char *slsb;
1002 unsigned int count = 1;
1003 int first_not_to_check;
1004 #ifdef CONFIG_QDIO_DEBUG
1006 #endif /* CONFIG_QDIO_DEBUG */
1007 #ifdef QDIO_USE_PROCESSING_STATE
1008 int last_position=-1;
1009 #endif /* QDIO_USE_PROCESSING_STATE */
1011 QDIO_DBF_TEXT4(0,trace,"getibfro");
1012 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
1014 irq = (struct qdio_irq *) q->irq_ptr;
1016 return qdio_qebsm_get_inbound_buffer_frontier(q);
1018 slsb=&q->slsb.acc.val[0];
1019 f_mod_no=f=q->first_to_check;
1021 * we don't check 128 buffers, as otherwise qdio_has_inbound_q_moved
1024 first_not_to_check=f+qdio_min(atomic_read(&q->number_of_buffers_used),
1025 (QDIO_MAX_BUFFERS_PER_Q-1));
1028 * we don't use this one, as a PCI or we after a thin interrupt
1029 * will sync the queues
1034 f_mod_no=f&(QDIO_MAX_BUFFERS_PER_Q-1);
1035 if (f==first_not_to_check)
1037 switch (slsb[f_mod_no]) {
1039 /* CU_EMPTY means frontier is reached */
1040 case SLSB_CU_INPUT_EMPTY:
1041 QDIO_DBF_TEXT5(0,trace,"inptempt");
1044 /* P_PRIMED means set slsb to P_PROCESSING and move on */
1045 case SLSB_P_INPUT_PRIMED:
1046 QDIO_DBF_TEXT5(0,trace,"inptprim");
1048 #ifdef QDIO_USE_PROCESSING_STATE
1050 * as soon as running under VM, polling the input queues will
1051 * kill VM in terms of CP overhead
1054 set_slsb(q, &f_mod_no, SLSB_P_INPUT_NOT_INIT, &count);
1056 /* set the previous buffer to NOT_INIT. The current
1057 * buffer will be set to PROCESSING at the end of
1058 * this function to avoid further interrupts. */
1059 if (last_position>=0)
1060 set_slsb(q, &last_position,
1061 SLSB_P_INPUT_NOT_INIT, &count);
1062 atomic_set(&q->polling,1);
1063 last_position=f_mod_no;
1065 #else /* QDIO_USE_PROCESSING_STATE */
1066 set_slsb(q, &f_mod_no, SLSB_P_INPUT_NOT_INIT, &count);
1067 #endif /* QDIO_USE_PROCESSING_STATE */
1069 * not needed, as the inbound queue will be synced on the next
1070 * siga-r, resp. tiqdio_is_inbound_q_done will do the siga-s
1074 atomic_dec(&q->number_of_buffers_used);
1077 case SLSB_P_INPUT_NOT_INIT:
1078 case SLSB_P_INPUT_PROCESSING:
1079 QDIO_DBF_TEXT5(0,trace,"inpnipro");
1082 /* P_ERROR means frontier is reached, break and report error */
1083 case SLSB_P_INPUT_ERROR:
1084 #ifdef CONFIG_QDIO_DEBUG
1085 sprintf(dbf_text,"inperr%2x",f_mod_no);
1086 QDIO_DBF_TEXT3(1,trace,dbf_text);
1087 #endif /* CONFIG_QDIO_DEBUG */
1088 QDIO_DBF_HEX2(1,sbal,q->sbal[f_mod_no],256);
1090 /* kind of process the buffer */
1091 set_slsb(q, &f_mod_no, SLSB_P_INPUT_NOT_INIT, &count);
1094 q->error_status_flags|=
1095 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR;
1096 q->qdio_error=SLSB_P_INPUT_ERROR;
1097 q->error_status_flags|=QDIO_STATUS_LOOK_FOR_ERROR;
1099 /* we increment the frontier, as this buffer
1100 * was processed obviously */
1101 f_mod_no=(f_mod_no+1)&(QDIO_MAX_BUFFERS_PER_Q-1);
1102 atomic_dec(&q->number_of_buffers_used);
1104 #ifdef QDIO_USE_PROCESSING_STATE
1106 #endif /* QDIO_USE_PROCESSING_STATE */
1110 /* everything else means frontier not changed (HALTED or so) */
1115 q->first_to_check=f_mod_no;
1117 #ifdef QDIO_USE_PROCESSING_STATE
1118 if (last_position>=0)
1119 set_slsb(q, &last_position, SLSB_P_INPUT_NOT_INIT, &count);
1120 #endif /* QDIO_USE_PROCESSING_STATE */
1122 QDIO_DBF_HEX4(0,trace,&q->first_to_check,sizeof(int));
1124 return q->first_to_check;
1128 qdio_has_inbound_q_moved(struct qdio_q *q)
1132 #ifdef QDIO_PERFORMANCE_STATS
1133 static int old_pcis=0;
1134 static int old_thinints=0;
1136 if ((old_pcis==perf_stats.pcis)&&(old_thinints==perf_stats.thinints))
1137 perf_stats.start_time_inbound=NOW;
1139 old_pcis=perf_stats.pcis;
1140 #endif /* QDIO_PERFORMANCE_STATS */
1142 i=qdio_get_inbound_buffer_frontier(q);
1143 if ( (i!=GET_SAVED_FRONTIER(q)) ||
1144 (q->error_status_flags&QDIO_STATUS_LOOK_FOR_ERROR) ) {
1146 if ((!q->siga_sync)&&(!q->hydra_gives_outbound_pcis))
1149 QDIO_DBF_TEXT4(0,trace,"inhasmvd");
1150 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
1153 QDIO_DBF_TEXT4(0,trace,"inhsntmv");
1154 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
1159 /* means, no more buffers to be filled */
1161 tiqdio_is_inbound_q_done(struct qdio_q *q)
1164 unsigned int start_buf, count;
1165 unsigned char state = 0;
1166 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
1168 #ifdef CONFIG_QDIO_DEBUG
1172 no_used=atomic_read(&q->number_of_buffers_used);
1174 /* propagate the change from 82 to 80 through VM */
1177 #ifdef CONFIG_QDIO_DEBUG
1179 sprintf(dbf_text,"iqisnt%02x",no_used);
1180 QDIO_DBF_TEXT4(0,trace,dbf_text);
1182 QDIO_DBF_TEXT4(0,trace,"iniqisdo");
1184 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
1185 #endif /* CONFIG_QDIO_DEBUG */
1191 /* we'll check for more primed buffers in qeth_stop_polling */
1193 if (irq->is_qebsm) {
1195 start_buf = q->first_to_check;
1196 qdio_do_eqbs(q, &state, &start_buf, &count);
1198 state = q->slsb.acc.val[q->first_to_check];
1199 if (state != SLSB_P_INPUT_PRIMED)
1201 * nothing more to do, if next buffer is not PRIMED.
1202 * note that we did a SYNC_MEMORY before, that there
1203 * has been a sychnronization.
1204 * we will return 0 below, as there is nothing to do
1205 * (stop_polling not necessary, as we have not been
1206 * using the PROCESSING state
1211 * ok, the next input buffer is primed. that means, that device state
1212 * change indicator and adapter local summary are set, so we will find
1214 * we will return 0 below, as there is nothing to do, except scheduling
1215 * ourselves for the next time.
1217 tiqdio_set_summary_bit((__u32*)q->dev_st_chg_ind);
1223 qdio_is_inbound_q_done(struct qdio_q *q)
1226 unsigned int start_buf, count;
1227 unsigned char state = 0;
1228 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
1230 #ifdef CONFIG_QDIO_DEBUG
1234 no_used=atomic_read(&q->number_of_buffers_used);
1237 * we need that one for synchronization with the adapter, as it
1238 * does a kind of PCI avoidance
1243 QDIO_DBF_TEXT4(0,trace,"inqisdnA");
1244 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
1245 QDIO_DBF_TEXT4(0,trace,dbf_text);
1248 if (irq->is_qebsm) {
1250 start_buf = q->first_to_check;
1251 qdio_do_eqbs(q, &state, &start_buf, &count);
1253 state = q->slsb.acc.val[q->first_to_check];
1254 if (state == SLSB_P_INPUT_PRIMED) {
1255 /* we got something to do */
1256 QDIO_DBF_TEXT4(0,trace,"inqisntA");
1257 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
1261 /* on VM, we don't poll, so the q is always done here */
1264 if (q->hydra_gives_outbound_pcis)
1268 * at this point we know, that inbound first_to_check
1269 * has (probably) not moved (see qdio_inbound_processing)
1271 if (NOW>GET_SAVED_TIMESTAMP(q)+q->timing.threshold) {
1272 #ifdef CONFIG_QDIO_DEBUG
1273 QDIO_DBF_TEXT4(0,trace,"inqisdon");
1274 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
1275 sprintf(dbf_text,"pf%02xcn%02x",q->first_to_check,no_used);
1276 QDIO_DBF_TEXT4(0,trace,dbf_text);
1277 #endif /* CONFIG_QDIO_DEBUG */
1280 #ifdef CONFIG_QDIO_DEBUG
1281 QDIO_DBF_TEXT4(0,trace,"inqisntd");
1282 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
1283 sprintf(dbf_text,"pf%02xcn%02x",q->first_to_check,no_used);
1284 QDIO_DBF_TEXT4(0,trace,dbf_text);
1285 #endif /* CONFIG_QDIO_DEBUG */
1291 qdio_kick_inbound_handler(struct qdio_q *q)
1293 int count, start, end, real_end, i;
1294 #ifdef CONFIG_QDIO_DEBUG
1298 QDIO_DBF_TEXT4(0,trace,"kickinh");
1299 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
1301 start=q->first_element_to_kick;
1302 real_end=q->first_to_check;
1303 end=(real_end+QDIO_MAX_BUFFERS_PER_Q-1)&(QDIO_MAX_BUFFERS_PER_Q-1);
1311 i=(i+1)&(QDIO_MAX_BUFFERS_PER_Q-1);
1314 #ifdef CONFIG_QDIO_DEBUG
1315 sprintf(dbf_text,"s=%2xc=%2x",start,count);
1316 QDIO_DBF_TEXT4(0,trace,dbf_text);
1317 #endif /* CONFIG_QDIO_DEBUG */
1319 if (likely(q->state==QDIO_IRQ_STATE_ACTIVE))
1321 QDIO_STATUS_INBOUND_INT|q->error_status_flags,
1322 q->qdio_error,q->siga_error,q->q_no,start,count,
1325 /* for the next time: */
1326 q->first_element_to_kick=real_end;
1329 q->error_status_flags=0;
1331 #ifdef QDIO_PERFORMANCE_STATS
1332 perf_stats.inbound_time+=NOW-perf_stats.start_time_inbound;
1333 perf_stats.inbound_cnt++;
1334 #endif /* QDIO_PERFORMANCE_STATS */
1338 __tiqdio_inbound_processing(struct qdio_q *q, int spare_ind_was_set)
1340 struct qdio_irq *irq_ptr;
1344 QDIO_DBF_TEXT4(0,trace,"iqinproc");
1345 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
1348 * we first want to reserve the q, so that we know, that we don't
1349 * interrupt ourselves and call qdio_unmark_q, as is_in_shutdown might
1352 if (unlikely(qdio_reserve_q(q))) {
1354 #ifdef QDIO_PERFORMANCE_STATS
1356 #endif /* QDIO_PERFORMANCE_STATS */
1358 * as we might just be about to stop polling, we make
1359 * sure that we check again at least once more
1364 #ifdef QDIO_PERFORMANCE_STATS
1366 #endif /* QDIO_PERFORMANCE_STATS */
1367 if (unlikely(atomic_read(&q->is_in_shutdown))) {
1373 * we reset spare_ind_was_set, when the queue does not use the
1376 if (spare_ind_was_set)
1377 spare_ind_was_set = (q->dev_st_chg_ind == &spare_indicator);
1379 if (!(*(q->dev_st_chg_ind)) && !spare_ind_was_set)
1382 * q->dev_st_chg_ind is the indicator, be it shared or not.
1383 * only clear it, if indicator is non-shared
1385 if (!spare_ind_was_set)
1386 tiqdio_clear_summary_bit((__u32*)q->dev_st_chg_ind);
1388 if (q->hydra_gives_outbound_pcis) {
1389 if (!q->siga_sync_done_on_thinints) {
1391 } else if ((!q->siga_sync_done_on_outb_tis)&&
1392 (q->hydra_gives_outbound_pcis)) {
1393 SYNC_MEMORY_ALL_OUTB;
1399 * maybe we have to do work on our outbound queues... at least
1400 * we have to check the outbound-int-capable thinint-capable
1403 if (q->hydra_gives_outbound_pcis) {
1404 irq_ptr = (struct qdio_irq*)q->irq_ptr;
1405 for (i=0;i<irq_ptr->no_output_qs;i++) {
1406 oq = irq_ptr->output_qs[i];
1407 #ifdef QDIO_PERFORMANCE_STATS
1408 perf_stats.tl_runs--;
1409 #endif /* QDIO_PERFORMANCE_STATS */
1410 if (!qdio_is_outbound_q_done(oq))
1411 __qdio_outbound_processing(oq);
1415 if (!qdio_has_inbound_q_moved(q))
1418 qdio_kick_inbound_handler(q);
1419 if (tiqdio_is_inbound_q_done(q))
1420 if (!qdio_stop_polling(q)) {
1422 * we set the flags to get into the stuff next time,
1423 * see also comment in qdio_stop_polling
1425 tiqdio_set_summary_bit((__u32*)q->dev_st_chg_ind);
1433 tiqdio_inbound_processing(struct qdio_q *q)
1435 __tiqdio_inbound_processing(q, atomic_read(&spare_indicator_usecount));
1439 __qdio_inbound_processing(struct qdio_q *q)
1443 QDIO_DBF_TEXT4(0,trace,"qinproc");
1444 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
1446 if (unlikely(qdio_reserve_q(q))) {
1448 #ifdef QDIO_PERFORMANCE_STATS
1450 #endif /* QDIO_PERFORMANCE_STATS */
1451 /* as we're sissies, we'll check next time */
1452 if (likely(!atomic_read(&q->is_in_shutdown))) {
1454 QDIO_DBF_TEXT4(0,trace,"busy,agn");
1458 #ifdef QDIO_PERFORMANCE_STATS
1460 perf_stats.tl_runs++;
1461 #endif /* QDIO_PERFORMANCE_STATS */
1464 if (qdio_has_inbound_q_moved(q)) {
1465 qdio_kick_inbound_handler(q);
1466 if (!qdio_stop_polling(q)) {
1468 if (q_laps<QDIO_Q_LAPS)
1473 if (!qdio_is_inbound_q_done(q))
1474 /* means poll time is not yet over */
1482 qdio_inbound_processing(struct qdio_q *q)
1484 __qdio_inbound_processing(q);
1487 /************************* MAIN ROUTINES *******************************/
1489 #ifdef QDIO_USE_PROCESSING_STATE
1491 tiqdio_reset_processing_state(struct qdio_q *q, int q_laps)
1499 * under VM, we have not used the PROCESSING state, so no
1500 * need to stop polling
1505 if (unlikely(qdio_reserve_q(q))) {
1507 #ifdef QDIO_PERFORMANCE_STATS
1509 #endif /* QDIO_PERFORMANCE_STATS */
1511 * as we might just be about to stop polling, we make
1512 * sure that we check again at least once more
1516 * sanity -- we'd get here without setting the
1519 tiqdio_set_summary_bit((__u32*)q->dev_st_chg_ind);
1523 if (qdio_stop_polling(q)) {
1527 if (q_laps<QDIO_Q_LAPS-1) {
1532 * we set the flags to get into the stuff
1533 * next time, see also comment in qdio_stop_polling
1535 tiqdio_set_summary_bit((__u32*)q->dev_st_chg_ind);
1541 #endif /* QDIO_USE_PROCESSING_STATE */
1544 tiqdio_inbound_checks(void)
1547 int spare_ind_was_set=0;
1548 #ifdef QDIO_USE_PROCESSING_STATE
1550 #endif /* QDIO_USE_PROCESSING_STATE */
1552 QDIO_DBF_TEXT4(0,trace,"iqdinbck");
1553 QDIO_DBF_TEXT5(0,trace,"iqlocsum");
1555 #ifdef QDIO_USE_PROCESSING_STATE
1557 #endif /* QDIO_USE_PROCESSING_STATE */
1559 /* when the spare indicator is used and set, save that and clear it */
1560 if ((atomic_read(&spare_indicator_usecount)) && spare_indicator) {
1561 spare_ind_was_set = 1;
1562 tiqdio_clear_summary_bit((__u32*)&spare_indicator);
1565 q=(struct qdio_q*)tiq_list;
1569 __tiqdio_inbound_processing(q, spare_ind_was_set);
1570 q=(struct qdio_q*)q->list_next;
1571 } while (q!=(struct qdio_q*)tiq_list);
1573 #ifdef QDIO_USE_PROCESSING_STATE
1574 q=(struct qdio_q*)tiq_list;
1578 ret = tiqdio_reset_processing_state(q, q_laps);
1585 q = (struct qdio_q*)q->list_next;
1591 } while (q!=(struct qdio_q*)tiq_list);
1592 #endif /* QDIO_USE_PROCESSING_STATE */
1596 tiqdio_tl(unsigned long data)
1598 QDIO_DBF_TEXT4(0,trace,"iqdio_tl");
1600 #ifdef QDIO_PERFORMANCE_STATS
1601 perf_stats.tl_runs++;
1602 #endif /* QDIO_PERFORMANCE_STATS */
1604 tiqdio_inbound_checks();
1607 /********************* GENERAL HELPER_ROUTINES ***********************/
1610 qdio_release_irq_memory(struct qdio_irq *irq_ptr)
1614 for (i=0;i<QDIO_MAX_QUEUES_PER_IRQ;i++) {
1615 if (!irq_ptr->input_qs[i])
1618 kfree(irq_ptr->input_qs[i]->slib);
1619 kfree(irq_ptr->input_qs[i]);
1622 if (!irq_ptr->output_qs[i])
1625 kfree(irq_ptr->output_qs[i]->slib);
1626 kfree(irq_ptr->output_qs[i]);
1629 kfree(irq_ptr->qdr);
1634 qdio_set_impl_params(struct qdio_irq *irq_ptr,
1635 unsigned int qib_param_field_format,
1636 /* pointer to 128 bytes or NULL, if no param field */
1637 unsigned char *qib_param_field,
1638 /* pointer to no_queues*128 words of data or NULL */
1639 unsigned int no_input_qs,
1640 unsigned int no_output_qs,
1641 unsigned long *input_slib_elements,
1642 unsigned long *output_slib_elements)
1649 irq_ptr->qib.pfmt=qib_param_field_format;
1650 if (qib_param_field)
1651 memcpy(irq_ptr->qib.parm,qib_param_field,
1652 QDIO_MAX_BUFFERS_PER_Q);
1654 if (input_slib_elements)
1655 for (i=0;i<no_input_qs;i++) {
1656 for (j=0;j<QDIO_MAX_BUFFERS_PER_Q;j++)
1657 irq_ptr->input_qs[i]->slib->slibe[j].parms=
1658 input_slib_elements[
1659 i*QDIO_MAX_BUFFERS_PER_Q+j];
1661 if (output_slib_elements)
1662 for (i=0;i<no_output_qs;i++) {
1663 for (j=0;j<QDIO_MAX_BUFFERS_PER_Q;j++)
1664 irq_ptr->output_qs[i]->slib->slibe[j].parms=
1665 output_slib_elements[
1666 i*QDIO_MAX_BUFFERS_PER_Q+j];
1671 qdio_alloc_qs(struct qdio_irq *irq_ptr,
1672 int no_input_qs, int no_output_qs)
1678 for (i=0;i<no_input_qs;i++) {
1679 q=kmalloc(sizeof(struct qdio_q),GFP_KERNEL);
1682 QDIO_PRINT_ERR("kmalloc of q failed!\n");
1686 memset(q,0,sizeof(struct qdio_q));
1688 q->slib=kmalloc(PAGE_SIZE,GFP_KERNEL);
1690 QDIO_PRINT_ERR("kmalloc of slib failed!\n");
1694 irq_ptr->input_qs[i]=q;
1697 for (i=0;i<no_output_qs;i++) {
1698 q=kmalloc(sizeof(struct qdio_q),GFP_KERNEL);
1704 memset(q,0,sizeof(struct qdio_q));
1706 q->slib=kmalloc(PAGE_SIZE,GFP_KERNEL);
1708 QDIO_PRINT_ERR("kmalloc of slib failed!\n");
1712 irq_ptr->output_qs[i]=q;
1721 qdio_fill_qs(struct qdio_irq *irq_ptr, struct ccw_device *cdev,
1722 int no_input_qs, int no_output_qs,
1723 qdio_handler_t *input_handler,
1724 qdio_handler_t *output_handler,
1725 unsigned long int_parm,int q_format,
1726 unsigned long flags,
1727 void **inbound_sbals_array,
1728 void **outbound_sbals_array)
1732 char dbf_text[20]; /* see qdio_initialize */
1736 sprintf(dbf_text,"qfqs%4x",cdev->private->irq);
1737 QDIO_DBF_TEXT0(0,setup,dbf_text);
1738 for (i=0;i<no_input_qs;i++) {
1739 q=irq_ptr->input_qs[i];
1741 memset(q,0,((char*)&q->slib)-((char*)q));
1742 sprintf(dbf_text,"in-q%4x",i);
1743 QDIO_DBF_TEXT0(0,setup,dbf_text);
1744 QDIO_DBF_HEX0(0,setup,&q,sizeof(void*));
1746 memset(q->slib,0,PAGE_SIZE);
1747 q->sl=(struct sl*)(((char*)q->slib)+PAGE_SIZE/2);
1751 for (j=0;j<QDIO_MAX_BUFFERS_PER_Q;j++)
1752 q->sbal[j]=*(inbound_sbals_array++);
1754 q->queue_type=q_format;
1755 q->int_parm=int_parm;
1756 q->irq=irq_ptr->irq;
1757 q->irq_ptr = irq_ptr;
1762 q->first_to_check=0;
1764 q->handler=input_handler;
1765 q->dev_st_chg_ind=irq_ptr->dev_st_chg_ind;
1767 q->tasklet.data=(unsigned long)q;
1768 /* q->is_thinint_q isn't valid at this time, but
1769 * irq_ptr->is_thinint_irq is */
1770 q->tasklet.func=(void(*)(unsigned long))
1771 ((irq_ptr->is_thinint_irq)?&tiqdio_inbound_processing:
1772 &qdio_inbound_processing);
1774 /* actually this is not used for inbound queues. yet. */
1775 atomic_set(&q->busy_siga_counter,0);
1776 q->timing.busy_start=0;
1778 /* for (j=0;j<QDIO_STATS_NUMBER;j++)
1779 q->timing.last_transfer_times[j]=(qdio_get_micros()/
1780 QDIO_STATS_NUMBER)*j;
1781 q->timing.last_transfer_index=QDIO_STATS_NUMBER-1;
1785 if (i>0) irq_ptr->input_qs[i-1]->slib->nsliba=
1786 (unsigned long)(q->slib);
1787 q->slib->sla=(unsigned long)(q->sl);
1788 q->slib->slsba=(unsigned long)(&q->slsb.acc.val[0]);
1791 for (j=0;j<QDIO_MAX_BUFFERS_PER_Q;j++)
1792 q->sl->element[j].sbal=(unsigned long)(q->sbal[j]);
1794 QDIO_DBF_TEXT2(0,setup,"sl-sb-b0");
1796 QDIO_DBF_HEX2(0,setup,&ptr,sizeof(void*));
1797 ptr=(void*)&q->slsb;
1798 QDIO_DBF_HEX2(0,setup,&ptr,sizeof(void*));
1799 ptr=(void*)q->sbal[0];
1800 QDIO_DBF_HEX2(0,setup,&ptr,sizeof(void*));
1803 if (!irq_ptr->is_qebsm) {
1804 unsigned int count = 1;
1805 for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++)
1806 set_slsb(q, &j, SLSB_P_INPUT_NOT_INIT, &count);
1810 for (i=0;i<no_output_qs;i++) {
1811 q=irq_ptr->output_qs[i];
1812 memset(q,0,((char*)&q->slib)-((char*)q));
1814 sprintf(dbf_text,"outq%4x",i);
1815 QDIO_DBF_TEXT0(0,setup,dbf_text);
1816 QDIO_DBF_HEX0(0,setup,&q,sizeof(void*));
1818 memset(q->slib,0,PAGE_SIZE);
1819 q->sl=(struct sl*)(((char*)q->slib)+PAGE_SIZE/2);
1823 for (j=0;j<QDIO_MAX_BUFFERS_PER_Q;j++)
1824 q->sbal[j]=*(outbound_sbals_array++);
1826 q->queue_type=q_format;
1827 q->int_parm=int_parm;
1829 q->irq=irq_ptr->irq;
1831 q->irq_ptr = irq_ptr;
1834 q->first_to_check=0;
1836 q->handler=output_handler;
1838 q->tasklet.data=(unsigned long)q;
1839 q->tasklet.func=(void(*)(unsigned long))
1840 &qdio_outbound_processing;
1842 atomic_set(&q->busy_siga_counter,0);
1843 q->timing.busy_start=0;
1846 if (i>0) irq_ptr->output_qs[i-1]->slib->nsliba=
1847 (unsigned long)(q->slib);
1848 q->slib->sla=(unsigned long)(q->sl);
1849 q->slib->slsba=(unsigned long)(&q->slsb.acc.val[0]);
1852 for (j=0;j<QDIO_MAX_BUFFERS_PER_Q;j++)
1853 q->sl->element[j].sbal=(unsigned long)(q->sbal[j]);
1855 QDIO_DBF_TEXT2(0,setup,"sl-sb-b0");
1857 QDIO_DBF_HEX2(0,setup,&ptr,sizeof(void*));
1858 ptr=(void*)&q->slsb;
1859 QDIO_DBF_HEX2(0,setup,&ptr,sizeof(void*));
1860 ptr=(void*)q->sbal[0];
1861 QDIO_DBF_HEX2(0,setup,&ptr,sizeof(void*));
1864 if (!irq_ptr->is_qebsm) {
1865 unsigned int count = 1;
1866 for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++)
1867 set_slsb(q, &j, SLSB_P_OUTPUT_NOT_INIT, &count);
1873 qdio_fill_thresholds(struct qdio_irq *irq_ptr,
1874 unsigned int no_input_qs,
1875 unsigned int no_output_qs,
1876 unsigned int min_input_threshold,
1877 unsigned int max_input_threshold,
1878 unsigned int min_output_threshold,
1879 unsigned int max_output_threshold)
1884 for (i=0;i<no_input_qs;i++) {
1885 q=irq_ptr->input_qs[i];
1886 q->timing.threshold=max_input_threshold;
1887 /* for (j=0;j<QDIO_STATS_CLASSES;j++) {
1888 q->threshold_classes[j].threshold=
1889 min_input_threshold+
1890 (max_input_threshold-min_input_threshold)/
1893 qdio_use_thresholds(q,QDIO_STATS_CLASSES/2);*/
1895 for (i=0;i<no_output_qs;i++) {
1896 q=irq_ptr->output_qs[i];
1897 q->timing.threshold=max_output_threshold;
1898 /* for (j=0;j<QDIO_STATS_CLASSES;j++) {
1899 q->threshold_classes[j].threshold=
1900 min_output_threshold+
1901 (max_output_threshold-min_output_threshold)/
1904 qdio_use_thresholds(q,QDIO_STATS_CLASSES/2);*/
1909 tiqdio_thinint_handler(void)
1911 QDIO_DBF_TEXT4(0,trace,"thin_int");
1913 #ifdef QDIO_PERFORMANCE_STATS
1914 perf_stats.thinints++;
1915 perf_stats.start_time_inbound=NOW;
1916 #endif /* QDIO_PERFORMANCE_STATS */
1918 /* SVS only when needed:
1919 * issue SVS to benefit from iqdio interrupt avoidance
1920 * (SVS clears AISOI)*/
1922 tiqdio_clear_global_summary();
1924 tiqdio_inbound_checks();
1929 qdio_set_state(struct qdio_irq *irq_ptr, enum qdio_irq_states state)
1932 #ifdef CONFIG_QDIO_DEBUG
1935 QDIO_DBF_TEXT5(0,trace,"newstate");
1936 sprintf(dbf_text,"%4x%4x",irq_ptr->irq,state);
1937 QDIO_DBF_TEXT5(0,trace,dbf_text);
1938 #endif /* CONFIG_QDIO_DEBUG */
1940 irq_ptr->state=state;
1941 for (i=0;i<irq_ptr->no_input_qs;i++)
1942 irq_ptr->input_qs[i]->state=state;
1943 for (i=0;i<irq_ptr->no_output_qs;i++)
1944 irq_ptr->output_qs[i]->state=state;
1949 qdio_irq_check_sense(int irq, struct irb *irb)
1953 if (irb->esw.esw0.erw.cons) {
1954 sprintf(dbf_text,"sens%4x",irq);
1955 QDIO_DBF_TEXT2(1,trace,dbf_text);
1956 QDIO_DBF_HEX0(0,sense,irb,QDIO_DBF_SENSE_LEN);
1958 QDIO_PRINT_WARN("sense data available on qdio channel.\n");
1959 HEXDUMP16(WARN,"irb: ",irb);
1960 HEXDUMP16(WARN,"sense data: ",irb->ecw);
1966 qdio_handle_pci(struct qdio_irq *irq_ptr)
1971 #ifdef QDIO_PERFORMANCE_STATS
1973 perf_stats.start_time_inbound=NOW;
1974 #endif /* QDIO_PERFORMANCE_STATS */
1975 for (i=0;i<irq_ptr->no_input_qs;i++) {
1976 q=irq_ptr->input_qs[i];
1977 if (q->is_input_q&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT)
1980 #ifdef QDIO_PERFORMANCE_STATS
1981 perf_stats.tl_runs--;
1982 #endif /* QDIO_PERFORMANCE_STATS */
1983 __qdio_inbound_processing(q);
1986 if (!irq_ptr->hydra_gives_outbound_pcis)
1988 for (i=0;i<irq_ptr->no_output_qs;i++) {
1989 q=irq_ptr->output_qs[i];
1990 #ifdef QDIO_PERFORMANCE_STATS
1991 perf_stats.tl_runs--;
1992 #endif /* QDIO_PERFORMANCE_STATS */
1993 if (qdio_is_outbound_q_done(q))
1995 if (!irq_ptr->sync_done_on_outb_pcis)
1997 __qdio_outbound_processing(q);
2001 static void qdio_establish_handle_irq(struct ccw_device*, int, int);
2004 qdio_handle_activate_check(struct ccw_device *cdev, unsigned long intparm,
2005 int cstat, int dstat)
2007 struct qdio_irq *irq_ptr;
2011 irq_ptr = cdev->private->qdio_data;
2013 QDIO_DBF_TEXT2(1, trace, "ick2");
2014 sprintf(dbf_text,"%s", cdev->dev.bus_id);
2015 QDIO_DBF_TEXT2(1,trace,dbf_text);
2016 QDIO_DBF_HEX2(0,trace,&intparm,sizeof(int));
2017 QDIO_DBF_HEX2(0,trace,&dstat,sizeof(int));
2018 QDIO_DBF_HEX2(0,trace,&cstat,sizeof(int));
2019 QDIO_PRINT_ERR("received check condition on activate " \
2020 "queues on device %s (cs=x%x, ds=x%x).\n",
2021 cdev->dev.bus_id, cstat, dstat);
2022 if (irq_ptr->no_input_qs) {
2023 q=irq_ptr->input_qs[0];
2024 } else if (irq_ptr->no_output_qs) {
2025 q=irq_ptr->output_qs[0];
2027 QDIO_PRINT_ERR("oops... no queue registered for device %s!?\n",
2029 goto omit_handler_call;
2031 q->handler(q->cdev,QDIO_STATUS_ACTIVATE_CHECK_CONDITION|
2032 QDIO_STATUS_LOOK_FOR_ERROR,
2033 0,0,0,-1,-1,q->int_parm);
2035 qdio_set_state(irq_ptr,QDIO_IRQ_STATE_STOPPED);
2040 qdio_call_shutdown(void *data)
2042 struct ccw_device *cdev;
2044 cdev = (struct ccw_device *)data;
2045 qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR);
2046 put_device(&cdev->dev);
2050 qdio_timeout_handler(struct ccw_device *cdev)
2052 struct qdio_irq *irq_ptr;
2055 QDIO_DBF_TEXT2(0, trace, "qtoh");
2056 sprintf(dbf_text, "%s", cdev->dev.bus_id);
2057 QDIO_DBF_TEXT2(0, trace, dbf_text);
2059 irq_ptr = cdev->private->qdio_data;
2060 sprintf(dbf_text, "state:%d", irq_ptr->state);
2061 QDIO_DBF_TEXT2(0, trace, dbf_text);
2063 switch (irq_ptr->state) {
2064 case QDIO_IRQ_STATE_INACTIVE:
2065 QDIO_PRINT_ERR("establish queues on irq %04x: timed out\n",
2067 QDIO_DBF_TEXT2(1,setup,"eq:timeo");
2068 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR);
2070 case QDIO_IRQ_STATE_CLEANUP:
2071 QDIO_PRINT_INFO("Did not get interrupt on cleanup, irq=0x%x.\n",
2073 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR);
2075 case QDIO_IRQ_STATE_ESTABLISHED:
2076 case QDIO_IRQ_STATE_ACTIVE:
2077 /* I/O has been terminated by common I/O layer. */
2078 QDIO_PRINT_INFO("Queues on irq %04x killed by cio.\n",
2080 QDIO_DBF_TEXT2(1, trace, "cio:term");
2081 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_STOPPED);
2082 if (get_device(&cdev->dev)) {
2083 /* Can't call shutdown from interrupt context. */
2084 PREPARE_WORK(&cdev->private->kick_work,
2085 qdio_call_shutdown, (void *)cdev);
2086 queue_work(ccw_device_work, &cdev->private->kick_work);
2092 ccw_device_set_timeout(cdev, 0);
2093 wake_up(&cdev->private->wait_q);
2097 qdio_handler(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
2099 struct qdio_irq *irq_ptr;
2103 #ifdef CONFIG_QDIO_DEBUG
2104 QDIO_DBF_TEXT4(0, trace, "qint");
2105 sprintf(dbf_text, "%s", cdev->dev.bus_id);
2106 QDIO_DBF_TEXT4(0, trace, dbf_text);
2107 #endif /* CONFIG_QDIO_DEBUG */
2110 QDIO_PRINT_ERR("got unsolicited interrupt in qdio " \
2111 "handler, device %s\n", cdev->dev.bus_id);
2115 irq_ptr = cdev->private->qdio_data;
2117 QDIO_DBF_TEXT2(1, trace, "uint");
2118 sprintf(dbf_text,"%s", cdev->dev.bus_id);
2119 QDIO_DBF_TEXT2(1,trace,dbf_text);
2120 QDIO_PRINT_ERR("received interrupt on unused device %s!\n",
2126 /* Currently running i/o is in error. */
2127 switch (PTR_ERR(irb)) {
2129 QDIO_PRINT_ERR("i/o error on device %s\n",
2133 qdio_timeout_handler(cdev);
2136 QDIO_PRINT_ERR("unknown error state %ld on device %s\n",
2137 PTR_ERR(irb), cdev->dev.bus_id);
2142 qdio_irq_check_sense(irq_ptr->irq, irb);
2144 #ifdef CONFIG_QDIO_DEBUG
2145 sprintf(dbf_text, "state:%d", irq_ptr->state);
2146 QDIO_DBF_TEXT4(0, trace, dbf_text);
2147 #endif /* CONFIG_QDIO_DEBUG */
2149 cstat = irb->scsw.cstat;
2150 dstat = irb->scsw.dstat;
2152 switch (irq_ptr->state) {
2153 case QDIO_IRQ_STATE_INACTIVE:
2154 qdio_establish_handle_irq(cdev, cstat, dstat);
2157 case QDIO_IRQ_STATE_CLEANUP:
2158 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE);
2161 case QDIO_IRQ_STATE_ESTABLISHED:
2162 case QDIO_IRQ_STATE_ACTIVE:
2163 if (cstat & SCHN_STAT_PCI) {
2164 qdio_handle_pci(irq_ptr);
2168 if ((cstat&~SCHN_STAT_PCI)||dstat) {
2169 qdio_handle_activate_check(cdev, intparm, cstat, dstat);
2173 QDIO_PRINT_ERR("got interrupt for queues in state %d on " \
2175 irq_ptr->state, cdev->dev.bus_id);
2177 wake_up(&cdev->private->wait_q);
2182 qdio_synchronize(struct ccw_device *cdev, unsigned int flags,
2183 unsigned int queue_number)
2187 struct qdio_irq *irq_ptr;
2189 #ifdef CONFIG_QDIO_DEBUG
2190 char dbf_text[15]="SyncXXXX";
2193 irq_ptr = cdev->private->qdio_data;
2197 #ifdef CONFIG_QDIO_DEBUG
2198 *((int*)(&dbf_text[4])) = irq_ptr->irq;
2199 QDIO_DBF_HEX4(0,trace,dbf_text,QDIO_DBF_TRACE_LEN);
2200 *((int*)(&dbf_text[0]))=flags;
2201 *((int*)(&dbf_text[4]))=queue_number;
2202 QDIO_DBF_HEX4(0,trace,dbf_text,QDIO_DBF_TRACE_LEN);
2203 #endif /* CONFIG_QDIO_DEBUG */
2205 if (flags&QDIO_FLAG_SYNC_INPUT) {
2206 q=irq_ptr->input_qs[queue_number];
2209 if (!(irq_ptr->is_qebsm))
2210 cc = do_siga_sync(0x10000|q->irq, 0, q->mask);
2211 } else if (flags&QDIO_FLAG_SYNC_OUTPUT) {
2212 q=irq_ptr->output_qs[queue_number];
2215 if (!(irq_ptr->is_qebsm))
2216 cc = do_siga_sync(0x10000|q->irq, q->mask, 0);
2222 QDIO_DBF_HEX3(0,trace,&ptr,sizeof(int));
2228 qdio_check_subchannel_qebsm(struct qdio_irq *irq_ptr, unsigned char qdioac,
2229 unsigned long token)
2233 unsigned int count, start_buf;
2236 /*check if QEBSM is disabled */
2237 if (!(irq_ptr->is_qebsm) || !(qdioac & 0x01)) {
2238 irq_ptr->is_qebsm = 0;
2239 irq_ptr->sch_token = 0;
2240 irq_ptr->qib.rflags &= ~QIB_RFLAGS_ENABLE_QEBSM;
2241 QDIO_DBF_TEXT0(0,setup,"noV=V");
2244 irq_ptr->sch_token = token;
2246 for (i = 0; i < irq_ptr->no_input_qs;i++) {
2247 q = irq_ptr->input_qs[i];
2248 count = QDIO_MAX_BUFFERS_PER_Q;
2250 set_slsb(q, &start_buf, SLSB_P_INPUT_NOT_INIT, &count);
2252 sprintf(dbf_text,"V=V:%2x",irq_ptr->is_qebsm);
2253 QDIO_DBF_TEXT0(0,setup,dbf_text);
2254 sprintf(dbf_text,"%8lx",irq_ptr->sch_token);
2255 QDIO_DBF_TEXT0(0,setup,dbf_text);
2257 for (i = 0; i < irq_ptr->no_output_qs; i++) {
2258 q = irq_ptr->output_qs[i];
2259 count = QDIO_MAX_BUFFERS_PER_Q;
2261 set_slsb(q, &start_buf, SLSB_P_OUTPUT_NOT_INIT, &count);
2266 qdio_get_ssqd_information(struct qdio_irq *irq_ptr)
2269 unsigned char qdioac;
2271 struct chsc_header request;
2277 struct chsc_header response;
2296 QDIO_DBF_TEXT0(0,setup,"getssqd");
2298 ssqd_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
2300 QDIO_PRINT_WARN("Could not get memory for chsc. Using all " \
2301 "SIGAs for sch x%x.\n", irq_ptr->irq);
2302 irq_ptr->qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY ||
2303 CHSC_FLAG_SIGA_OUTPUT_NECESSARY ||
2304 CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */
2305 irq_ptr->is_qebsm = 0;
2306 irq_ptr->sch_token = 0;
2307 irq_ptr->qib.rflags &= ~QIB_RFLAGS_ENABLE_QEBSM;
2311 ssqd_area->request = (struct chsc_header) {
2315 ssqd_area->first_sch = irq_ptr->irq;
2316 ssqd_area->last_sch = irq_ptr->irq;
2317 result = chsc(ssqd_area);
2320 QDIO_PRINT_WARN("CHSC returned cc %i. Using all " \
2321 "SIGAs for sch x%x.\n",
2322 result, irq_ptr->irq);
2323 qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY ||
2324 CHSC_FLAG_SIGA_OUTPUT_NECESSARY ||
2325 CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */
2326 irq_ptr->is_qebsm = 0;
2330 if (ssqd_area->response.code != QDIO_CHSC_RESPONSE_CODE_OK) {
2331 QDIO_PRINT_WARN("response upon checking SIGA needs " \
2332 "is 0x%x. Using all SIGAs for sch x%x.\n",
2333 ssqd_area->response.code, irq_ptr->irq);
2334 qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY ||
2335 CHSC_FLAG_SIGA_OUTPUT_NECESSARY ||
2336 CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */
2337 irq_ptr->is_qebsm = 0;
2340 if (!(ssqd_area->flags & CHSC_FLAG_QDIO_CAPABILITY) ||
2341 !(ssqd_area->flags & CHSC_FLAG_VALIDITY) ||
2342 (ssqd_area->sch != irq_ptr->irq)) {
2343 QDIO_PRINT_WARN("huh? problems checking out sch x%x... " \
2344 "using all SIGAs.\n",irq_ptr->irq);
2345 qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY |
2346 CHSC_FLAG_SIGA_OUTPUT_NECESSARY |
2347 CHSC_FLAG_SIGA_SYNC_NECESSARY; /* worst case */
2348 irq_ptr->is_qebsm = 0;
2351 qdioac = ssqd_area->qdioac1;
2353 qdio_check_subchannel_qebsm(irq_ptr, qdioac,
2354 ssqd_area->sch_token);
2355 free_page ((unsigned long) ssqd_area);
2356 irq_ptr->qdioac = qdioac;
2360 tiqdio_check_chsc_availability(void)
2364 if (!css_characteristics_avail)
2367 /* Check for bit 41. */
2368 if (!css_general_characteristics.aif) {
2369 QDIO_PRINT_WARN("Adapter interruption facility not " \
2374 /* Check for bits 107 and 108. */
2375 if (!css_chsc_characteristics.scssc ||
2376 !css_chsc_characteristics.scsscf) {
2377 QDIO_PRINT_WARN("Set Chan Subsys. Char. & Fast-CHSCs " \
2378 "not available.\n");
2382 /* Check for OSA/FCP thin interrupts (bit 67). */
2383 hydra_thinints = css_general_characteristics.aif_osa;
2384 sprintf(dbf_text,"hydrati%1x", hydra_thinints);
2385 QDIO_DBF_TEXT0(0,setup,dbf_text);
2387 #ifdef CONFIG_ARCH_S390X
2388 /* Check for QEBSM support in general (bit 58). */
2389 is_passthrough = css_general_characteristics.qebsm;
2391 sprintf(dbf_text,"cssQBS:%1x", is_passthrough);
2392 QDIO_DBF_TEXT0(0,setup,dbf_text);
2394 /* Check for aif time delay disablement fac (bit 56). If installed,
2395 * omit svs even under lpar (good point by rick again) */
2396 omit_svs = css_general_characteristics.aif_tdd;
2397 sprintf(dbf_text,"omitsvs%1x", omit_svs);
2398 QDIO_DBF_TEXT0(0,setup,dbf_text);
2404 tiqdio_set_subchannel_ind(struct qdio_irq *irq_ptr, int reset_to_zero)
2406 unsigned long real_addr_local_summary_bit;
2407 unsigned long real_addr_dev_st_chg_ind;
2411 unsigned int resp_code;
2415 struct chsc_header request;
2420 u64 summary_indicator_addr;
2421 u64 subchannel_indicator_addr;
2426 u32 word_with_d_bit;
2427 /* set to 0x10000000 to enable
2428 * time delay disablement facility */
2431 u32 reserved6[1004];
2432 struct chsc_header response;
2436 if (!irq_ptr->is_thinint_irq)
2439 if (reset_to_zero) {
2440 real_addr_local_summary_bit=0;
2441 real_addr_dev_st_chg_ind=0;
2443 real_addr_local_summary_bit=
2444 virt_to_phys((volatile void *)indicators);
2445 real_addr_dev_st_chg_ind=
2446 virt_to_phys((volatile void *)irq_ptr->dev_st_chg_ind);
2449 scssc_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
2451 QDIO_PRINT_WARN("No memory for setting indicators on " \
2452 "subchannel x%x.\n", irq_ptr->irq);
2455 scssc_area->request = (struct chsc_header) {
2459 scssc_area->operation_code = 0;
2461 scssc_area->summary_indicator_addr = real_addr_local_summary_bit;
2462 scssc_area->subchannel_indicator_addr = real_addr_dev_st_chg_ind;
2463 scssc_area->ks = QDIO_STORAGE_KEY;
2464 scssc_area->kc = QDIO_STORAGE_KEY;
2465 scssc_area->isc = TIQDIO_THININT_ISC;
2466 scssc_area->subsystem_id = (1<<16) + irq_ptr->irq;
2467 /* enables the time delay disablement facility. Don't care
2468 * whether it is really there (i.e. we haven't checked for
2470 if (css_general_characteristics.aif_tdd)
2471 scssc_area->word_with_d_bit = 0x10000000;
2473 QDIO_PRINT_WARN("Time delay disablement facility " \
2478 result = chsc(scssc_area);
2480 QDIO_PRINT_WARN("could not set indicators on irq x%x, " \
2481 "cc=%i.\n",irq_ptr->irq,result);
2486 resp_code = scssc_area->response.code;
2487 if (resp_code!=QDIO_CHSC_RESPONSE_CODE_OK) {
2488 QDIO_PRINT_WARN("response upon setting indicators " \
2489 "is 0x%x.\n",resp_code);
2490 sprintf(dbf_text,"sidR%4x",resp_code);
2491 QDIO_DBF_TEXT1(0,trace,dbf_text);
2492 QDIO_DBF_TEXT1(0,setup,dbf_text);
2493 ptr=&scssc_area->response;
2494 QDIO_DBF_HEX2(1,setup,&ptr,QDIO_DBF_SETUP_LEN);
2499 QDIO_DBF_TEXT2(0,setup,"setscind");
2500 QDIO_DBF_HEX2(0,setup,&real_addr_local_summary_bit,
2501 sizeof(unsigned long));
2502 QDIO_DBF_HEX2(0,setup,&real_addr_dev_st_chg_ind,sizeof(unsigned long));
2505 free_page ((unsigned long) scssc_area);
2511 tiqdio_set_delay_target(struct qdio_irq *irq_ptr, unsigned long delay_target)
2513 unsigned int resp_code;
2519 struct chsc_header request;
2526 u32 reserved5[1009];
2527 struct chsc_header response;
2531 if (!irq_ptr->is_thinint_irq)
2534 scsscf_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
2536 QDIO_PRINT_WARN("No memory for setting delay target on " \
2537 "subchannel x%x.\n", irq_ptr->irq);
2540 scsscf_area->request = (struct chsc_header) {
2545 scsscf_area->delay_target = delay_target<<16;
2547 result=chsc(scsscf_area);
2549 QDIO_PRINT_WARN("could not set delay target on irq x%x, " \
2550 "cc=%i. Continuing.\n",irq_ptr->irq,result);
2555 resp_code = scsscf_area->response.code;
2556 if (resp_code!=QDIO_CHSC_RESPONSE_CODE_OK) {
2557 QDIO_PRINT_WARN("response upon setting delay target " \
2558 "is 0x%x. Continuing.\n",resp_code);
2559 sprintf(dbf_text,"sdtR%4x",resp_code);
2560 QDIO_DBF_TEXT1(0,trace,dbf_text);
2561 QDIO_DBF_TEXT1(0,setup,dbf_text);
2562 ptr=&scsscf_area->response;
2563 QDIO_DBF_HEX2(1,trace,&ptr,QDIO_DBF_TRACE_LEN);
2565 QDIO_DBF_TEXT2(0,trace,"delytrgt");
2566 QDIO_DBF_HEX2(0,trace,&delay_target,sizeof(unsigned long));
2567 result = 0; /* not critical */
2569 free_page ((unsigned long) scsscf_area);
2574 qdio_cleanup(struct ccw_device *cdev, int how)
2576 struct qdio_irq *irq_ptr;
2580 irq_ptr = cdev->private->qdio_data;
2584 sprintf(dbf_text,"qcln%4x",irq_ptr->irq);
2585 QDIO_DBF_TEXT1(0,trace,dbf_text);
2586 QDIO_DBF_TEXT0(0,setup,dbf_text);
2588 rc = qdio_shutdown(cdev, how);
2589 if ((rc == 0) || (rc == -EINPROGRESS))
2590 rc = qdio_free(cdev);
2595 qdio_shutdown(struct ccw_device *cdev, int how)
2597 struct qdio_irq *irq_ptr;
2601 unsigned long flags;
2605 irq_ptr = cdev->private->qdio_data;
2609 down(&irq_ptr->setting_up_sema);
2611 sprintf(dbf_text,"qsqs%4x",irq_ptr->irq);
2612 QDIO_DBF_TEXT1(0,trace,dbf_text);
2613 QDIO_DBF_TEXT0(0,setup,dbf_text);
2615 /* mark all qs as uninteresting */
2616 for (i=0;i<irq_ptr->no_input_qs;i++)
2617 atomic_set(&irq_ptr->input_qs[i]->is_in_shutdown,1);
2619 for (i=0;i<irq_ptr->no_output_qs;i++)
2620 atomic_set(&irq_ptr->output_qs[i]->is_in_shutdown,1);
2622 tasklet_kill(&tiqdio_tasklet);
2624 for (i=0;i<irq_ptr->no_input_qs;i++) {
2625 qdio_unmark_q(irq_ptr->input_qs[i]);
2626 tasklet_kill(&irq_ptr->input_qs[i]->tasklet);
2627 wait_event_interruptible_timeout(cdev->private->wait_q,
2628 !atomic_read(&irq_ptr->
2631 QDIO_NO_USE_COUNT_TIMEOUT);
2632 if (atomic_read(&irq_ptr->input_qs[i]->use_count))
2633 result=-EINPROGRESS;
2636 for (i=0;i<irq_ptr->no_output_qs;i++) {
2637 tasklet_kill(&irq_ptr->output_qs[i]->tasklet);
2638 wait_event_interruptible_timeout(cdev->private->wait_q,
2639 !atomic_read(&irq_ptr->
2642 QDIO_NO_USE_COUNT_TIMEOUT);
2643 if (atomic_read(&irq_ptr->output_qs[i]->use_count))
2644 result=-EINPROGRESS;
2647 /* cleanup subchannel */
2648 spin_lock_irqsave(get_ccwdev_lock(cdev),flags);
2649 if (how&QDIO_FLAG_CLEANUP_USING_CLEAR) {
2650 rc = ccw_device_clear(cdev, QDIO_DOING_CLEANUP);
2651 timeout=QDIO_CLEANUP_CLEAR_TIMEOUT;
2652 } else if (how&QDIO_FLAG_CLEANUP_USING_HALT) {
2653 rc = ccw_device_halt(cdev, QDIO_DOING_CLEANUP);
2654 timeout=QDIO_CLEANUP_HALT_TIMEOUT;
2655 } else { /* default behaviour */
2656 rc = ccw_device_halt(cdev, QDIO_DOING_CLEANUP);
2657 timeout=QDIO_CLEANUP_HALT_TIMEOUT;
2659 if (rc == -ENODEV) {
2660 /* No need to wait for device no longer present. */
2661 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE);
2662 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
2663 } else if (((void *)cdev->handler != (void *)qdio_handler) && rc == 0) {
2665 * Whoever put another handler there, has to cope with the
2666 * interrupt theirself. Might happen if qdio_shutdown was
2667 * called on already shutdown queues, but this shouldn't have
2670 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE);
2671 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
2672 } else if (rc == 0) {
2673 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_CLEANUP);
2674 ccw_device_set_timeout(cdev, timeout);
2675 spin_unlock_irqrestore(get_ccwdev_lock(cdev),flags);
2677 wait_event(cdev->private->wait_q,
2678 irq_ptr->state == QDIO_IRQ_STATE_INACTIVE ||
2679 irq_ptr->state == QDIO_IRQ_STATE_ERR);
2681 QDIO_PRINT_INFO("ccw_device_{halt,clear} returned %d for "
2682 "device %s\n", result, cdev->dev.bus_id);
2683 spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
2687 if (irq_ptr->is_thinint_irq) {
2688 qdio_put_indicator((__u32*)irq_ptr->dev_st_chg_ind);
2689 tiqdio_set_subchannel_ind(irq_ptr,1);
2690 /* reset adapter interrupt indicators */
2693 /* exchange int handlers, if necessary */
2694 if ((void*)cdev->handler == (void*)qdio_handler)
2695 cdev->handler=irq_ptr->original_int_handler;
2697 /* Ignore errors. */
2698 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_INACTIVE);
2699 ccw_device_set_timeout(cdev, 0);
2701 up(&irq_ptr->setting_up_sema);
2706 qdio_free(struct ccw_device *cdev)
2708 struct qdio_irq *irq_ptr;
2711 irq_ptr = cdev->private->qdio_data;
2715 down(&irq_ptr->setting_up_sema);
2717 sprintf(dbf_text,"qfqs%4x",irq_ptr->irq);
2718 QDIO_DBF_TEXT1(0,trace,dbf_text);
2719 QDIO_DBF_TEXT0(0,setup,dbf_text);
2721 cdev->private->qdio_data = 0;
2723 up(&irq_ptr->setting_up_sema);
2725 qdio_release_irq_memory(irq_ptr);
2726 module_put(THIS_MODULE);
2731 qdio_allocate_do_dbf(struct qdio_initialize *init_data)
2733 char dbf_text[20]; /* if a printf printed out more than 8 chars */
2735 sprintf(dbf_text,"qfmt:%x",init_data->q_format);
2736 QDIO_DBF_TEXT0(0,setup,dbf_text);
2737 QDIO_DBF_HEX0(0,setup,init_data->adapter_name,8);
2738 sprintf(dbf_text,"qpff%4x",init_data->qib_param_field_format);
2739 QDIO_DBF_TEXT0(0,setup,dbf_text);
2740 QDIO_DBF_HEX0(0,setup,&init_data->qib_param_field,sizeof(char*));
2741 QDIO_DBF_HEX0(0,setup,&init_data->input_slib_elements,sizeof(long*));
2742 QDIO_DBF_HEX0(0,setup,&init_data->output_slib_elements,sizeof(long*));
2743 sprintf(dbf_text,"miit%4x",init_data->min_input_threshold);
2744 QDIO_DBF_TEXT0(0,setup,dbf_text);
2745 sprintf(dbf_text,"mait%4x",init_data->max_input_threshold);
2746 QDIO_DBF_TEXT0(0,setup,dbf_text);
2747 sprintf(dbf_text,"miot%4x",init_data->min_output_threshold);
2748 QDIO_DBF_TEXT0(0,setup,dbf_text);
2749 sprintf(dbf_text,"maot%4x",init_data->max_output_threshold);
2750 QDIO_DBF_TEXT0(0,setup,dbf_text);
2751 sprintf(dbf_text,"niq:%4x",init_data->no_input_qs);
2752 QDIO_DBF_TEXT0(0,setup,dbf_text);
2753 sprintf(dbf_text,"noq:%4x",init_data->no_output_qs);
2754 QDIO_DBF_TEXT0(0,setup,dbf_text);
2755 QDIO_DBF_HEX0(0,setup,&init_data->input_handler,sizeof(void*));
2756 QDIO_DBF_HEX0(0,setup,&init_data->output_handler,sizeof(void*));
2757 QDIO_DBF_HEX0(0,setup,&init_data->int_parm,sizeof(long));
2758 QDIO_DBF_HEX0(0,setup,&init_data->flags,sizeof(long));
2759 QDIO_DBF_HEX0(0,setup,&init_data->input_sbal_addr_array,sizeof(void*));
2760 QDIO_DBF_HEX0(0,setup,&init_data->output_sbal_addr_array,sizeof(void*));
2764 qdio_allocate_fill_input_desc(struct qdio_irq *irq_ptr, int i, int iqfmt)
2766 irq_ptr->input_qs[i]->is_iqdio_q = iqfmt;
2767 irq_ptr->input_qs[i]->is_thinint_q = irq_ptr->is_thinint_irq;
2769 irq_ptr->qdr->qdf0[i].sliba=(unsigned long)(irq_ptr->input_qs[i]->slib);
2771 irq_ptr->qdr->qdf0[i].sla=(unsigned long)(irq_ptr->input_qs[i]->sl);
2773 irq_ptr->qdr->qdf0[i].slsba=
2774 (unsigned long)(&irq_ptr->input_qs[i]->slsb.acc.val[0]);
2776 irq_ptr->qdr->qdf0[i].akey=QDIO_STORAGE_KEY;
2777 irq_ptr->qdr->qdf0[i].bkey=QDIO_STORAGE_KEY;
2778 irq_ptr->qdr->qdf0[i].ckey=QDIO_STORAGE_KEY;
2779 irq_ptr->qdr->qdf0[i].dkey=QDIO_STORAGE_KEY;
2783 qdio_allocate_fill_output_desc(struct qdio_irq *irq_ptr, int i,
2786 irq_ptr->output_qs[i]->is_iqdio_q = iqfmt;
2787 irq_ptr->output_qs[i]->is_thinint_q = irq_ptr->is_thinint_irq;
2789 irq_ptr->qdr->qdf0[i+j].sliba=(unsigned long)(irq_ptr->output_qs[i]->slib);
2791 irq_ptr->qdr->qdf0[i+j].sla=(unsigned long)(irq_ptr->output_qs[i]->sl);
2793 irq_ptr->qdr->qdf0[i+j].slsba=
2794 (unsigned long)(&irq_ptr->output_qs[i]->slsb.acc.val[0]);
2796 irq_ptr->qdr->qdf0[i+j].akey=QDIO_STORAGE_KEY;
2797 irq_ptr->qdr->qdf0[i+j].bkey=QDIO_STORAGE_KEY;
2798 irq_ptr->qdr->qdf0[i+j].ckey=QDIO_STORAGE_KEY;
2799 irq_ptr->qdr->qdf0[i+j].dkey=QDIO_STORAGE_KEY;
2804 qdio_initialize_set_siga_flags_input(struct qdio_irq *irq_ptr)
2808 for (i=0;i<irq_ptr->no_input_qs;i++) {
2809 irq_ptr->input_qs[i]->siga_sync=
2810 irq_ptr->qdioac&CHSC_FLAG_SIGA_SYNC_NECESSARY;
2811 irq_ptr->input_qs[i]->siga_in=
2812 irq_ptr->qdioac&CHSC_FLAG_SIGA_INPUT_NECESSARY;
2813 irq_ptr->input_qs[i]->siga_out=
2814 irq_ptr->qdioac&CHSC_FLAG_SIGA_OUTPUT_NECESSARY;
2815 irq_ptr->input_qs[i]->siga_sync_done_on_thinints=
2816 irq_ptr->qdioac&CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS;
2817 irq_ptr->input_qs[i]->hydra_gives_outbound_pcis=
2818 irq_ptr->hydra_gives_outbound_pcis;
2819 irq_ptr->input_qs[i]->siga_sync_done_on_outb_tis=
2821 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS|
2822 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS))==
2823 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS|
2824 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS));
2830 qdio_initialize_set_siga_flags_output(struct qdio_irq *irq_ptr)
2834 for (i=0;i<irq_ptr->no_output_qs;i++) {
2835 irq_ptr->output_qs[i]->siga_sync=
2836 irq_ptr->qdioac&CHSC_FLAG_SIGA_SYNC_NECESSARY;
2837 irq_ptr->output_qs[i]->siga_in=
2838 irq_ptr->qdioac&CHSC_FLAG_SIGA_INPUT_NECESSARY;
2839 irq_ptr->output_qs[i]->siga_out=
2840 irq_ptr->qdioac&CHSC_FLAG_SIGA_OUTPUT_NECESSARY;
2841 irq_ptr->output_qs[i]->siga_sync_done_on_thinints=
2842 irq_ptr->qdioac&CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS;
2843 irq_ptr->output_qs[i]->hydra_gives_outbound_pcis=
2844 irq_ptr->hydra_gives_outbound_pcis;
2845 irq_ptr->output_qs[i]->siga_sync_done_on_outb_tis=
2847 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS|
2848 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS))==
2849 (CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS|
2850 CHSC_FLAG_SIGA_SYNC_DONE_ON_THININTS));
2856 qdio_establish_irq_check_for_errors(struct ccw_device *cdev, int cstat,
2860 struct qdio_irq *irq_ptr;
2862 irq_ptr = cdev->private->qdio_data;
2864 if (cstat || (dstat & ~(DEV_STAT_CHN_END|DEV_STAT_DEV_END))) {
2865 sprintf(dbf_text,"ick1%4x",irq_ptr->irq);
2866 QDIO_DBF_TEXT2(1,trace,dbf_text);
2867 QDIO_DBF_HEX2(0,trace,&dstat,sizeof(int));
2868 QDIO_DBF_HEX2(0,trace,&cstat,sizeof(int));
2869 QDIO_PRINT_ERR("received check condition on establish " \
2870 "queues on irq 0x%x (cs=x%x, ds=x%x).\n",
2871 irq_ptr->irq,cstat,dstat);
2872 qdio_set_state(irq_ptr,QDIO_IRQ_STATE_ERR);
2875 if (!(dstat & DEV_STAT_DEV_END)) {
2876 QDIO_DBF_TEXT2(1,setup,"eq:no de");
2877 QDIO_DBF_HEX2(0,setup,&dstat, sizeof(dstat));
2878 QDIO_DBF_HEX2(0,setup,&cstat, sizeof(cstat));
2879 QDIO_PRINT_ERR("establish queues on irq %04x: didn't get "
2880 "device end: dstat=%02x, cstat=%02x\n",
2881 irq_ptr->irq, dstat, cstat);
2882 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR);
2886 if (dstat & ~(DEV_STAT_CHN_END|DEV_STAT_DEV_END)) {
2887 QDIO_DBF_TEXT2(1,setup,"eq:badio");
2888 QDIO_DBF_HEX2(0,setup,&dstat, sizeof(dstat));
2889 QDIO_DBF_HEX2(0,setup,&cstat, sizeof(cstat));
2890 QDIO_PRINT_ERR("establish queues on irq %04x: got "
2891 "the following devstat: dstat=%02x, "
2893 irq_ptr->irq, dstat, cstat);
2894 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR);
2901 qdio_establish_handle_irq(struct ccw_device *cdev, int cstat, int dstat)
2903 struct qdio_irq *irq_ptr;
2906 irq_ptr = cdev->private->qdio_data;
2908 sprintf(dbf_text,"qehi%4x",cdev->private->irq);
2909 QDIO_DBF_TEXT0(0,setup,dbf_text);
2910 QDIO_DBF_TEXT0(0,trace,dbf_text);
2912 if (qdio_establish_irq_check_for_errors(cdev, cstat, dstat)) {
2913 ccw_device_set_timeout(cdev, 0);
2917 qdio_set_state(irq_ptr,QDIO_IRQ_STATE_ESTABLISHED);
2918 ccw_device_set_timeout(cdev, 0);
2922 qdio_initialize(struct qdio_initialize *init_data)
2927 sprintf(dbf_text,"qini%4x",init_data->cdev->private->irq);
2928 QDIO_DBF_TEXT0(0,setup,dbf_text);
2929 QDIO_DBF_TEXT0(0,trace,dbf_text);
2931 rc = qdio_allocate(init_data);
2933 rc = qdio_establish(init_data);
2935 qdio_free(init_data->cdev);
2943 qdio_allocate(struct qdio_initialize *init_data)
2945 struct qdio_irq *irq_ptr;
2948 sprintf(dbf_text,"qalc%4x",init_data->cdev->private->irq);
2949 QDIO_DBF_TEXT0(0,setup,dbf_text);
2950 QDIO_DBF_TEXT0(0,trace,dbf_text);
2951 if ( (init_data->no_input_qs>QDIO_MAX_QUEUES_PER_IRQ) ||
2952 (init_data->no_output_qs>QDIO_MAX_QUEUES_PER_IRQ) ||
2953 ((init_data->no_input_qs) && (!init_data->input_handler)) ||
2954 ((init_data->no_output_qs) && (!init_data->output_handler)) )
2957 if (!init_data->input_sbal_addr_array)
2960 if (!init_data->output_sbal_addr_array)
2963 qdio_allocate_do_dbf(init_data);
2966 irq_ptr=kmalloc(sizeof(struct qdio_irq), GFP_KERNEL | GFP_DMA);
2968 QDIO_DBF_TEXT0(0,setup,"irq_ptr:");
2969 QDIO_DBF_HEX0(0,setup,&irq_ptr,sizeof(void*));
2972 QDIO_PRINT_ERR("kmalloc of irq_ptr failed!\n");
2976 memset(irq_ptr,0,sizeof(struct qdio_irq));
2978 init_MUTEX(&irq_ptr->setting_up_sema);
2980 /* QDR must be in DMA area since CCW data address is only 32 bit */
2981 irq_ptr->qdr=kmalloc(sizeof(struct qdr), GFP_KERNEL | GFP_DMA);
2982 if (!(irq_ptr->qdr)) {
2984 QDIO_PRINT_ERR("kmalloc of irq_ptr->qdr failed!\n");
2987 QDIO_DBF_TEXT0(0,setup,"qdr:");
2988 QDIO_DBF_HEX0(0,setup,&irq_ptr->qdr,sizeof(void*));
2990 if (qdio_alloc_qs(irq_ptr,
2991 init_data->no_input_qs,
2992 init_data->no_output_qs)) {
2993 qdio_release_irq_memory(irq_ptr);
2997 init_data->cdev->private->qdio_data = irq_ptr;
2999 qdio_set_state(irq_ptr,QDIO_IRQ_STATE_INACTIVE);
3004 int qdio_fill_irq(struct qdio_initialize *init_data)
3010 struct qdio_irq *irq_ptr;
3012 irq_ptr = init_data->cdev->private->qdio_data;
3014 memset(irq_ptr,0,((char*)&irq_ptr->qdr)-((char*)irq_ptr));
3016 /* wipes qib.ac, required by ar7063 */
3017 memset(irq_ptr->qdr,0,sizeof(struct qdr));
3019 irq_ptr->int_parm=init_data->int_parm;
3021 irq_ptr->irq = init_data->cdev->private->irq;
3022 irq_ptr->no_input_qs=init_data->no_input_qs;
3023 irq_ptr->no_output_qs=init_data->no_output_qs;
3025 if (init_data->q_format==QDIO_IQDIO_QFMT) {
3026 irq_ptr->is_iqdio_irq=1;
3027 irq_ptr->is_thinint_irq=1;
3029 irq_ptr->is_iqdio_irq=0;
3030 irq_ptr->is_thinint_irq=hydra_thinints;
3032 sprintf(dbf_text,"is_i_t%1x%1x",
3033 irq_ptr->is_iqdio_irq,irq_ptr->is_thinint_irq);
3034 QDIO_DBF_TEXT2(0,setup,dbf_text);
3036 if (irq_ptr->is_thinint_irq) {
3037 irq_ptr->dev_st_chg_ind = qdio_get_indicator();
3038 QDIO_DBF_HEX1(0,setup,&irq_ptr->dev_st_chg_ind,sizeof(void*));
3039 if (!irq_ptr->dev_st_chg_ind) {
3040 QDIO_PRINT_WARN("no indicator location available " \
3041 "for irq 0x%x\n",irq_ptr->irq);
3042 qdio_release_irq_memory(irq_ptr);
3048 irq_ptr->equeue.cmd=DEFAULT_ESTABLISH_QS_CMD;
3049 irq_ptr->equeue.count=DEFAULT_ESTABLISH_QS_COUNT;
3050 irq_ptr->aqueue.cmd=DEFAULT_ACTIVATE_QS_CMD;
3051 irq_ptr->aqueue.count=DEFAULT_ACTIVATE_QS_COUNT;
3053 qdio_fill_qs(irq_ptr, init_data->cdev,
3054 init_data->no_input_qs,
3055 init_data->no_output_qs,
3056 init_data->input_handler,
3057 init_data->output_handler,init_data->int_parm,
3058 init_data->q_format,init_data->flags,
3059 init_data->input_sbal_addr_array,
3060 init_data->output_sbal_addr_array);
3062 if (!try_module_get(THIS_MODULE)) {
3063 QDIO_PRINT_CRIT("try_module_get() failed!\n");
3064 qdio_release_irq_memory(irq_ptr);
3068 qdio_fill_thresholds(irq_ptr,init_data->no_input_qs,
3069 init_data->no_output_qs,
3070 init_data->min_input_threshold,
3071 init_data->max_input_threshold,
3072 init_data->min_output_threshold,
3073 init_data->max_output_threshold);
3076 irq_ptr->qdr->qfmt=init_data->q_format;
3077 irq_ptr->qdr->iqdcnt=init_data->no_input_qs;
3078 irq_ptr->qdr->oqdcnt=init_data->no_output_qs;
3079 irq_ptr->qdr->iqdsz=sizeof(struct qdesfmt0)/4; /* size in words */
3080 irq_ptr->qdr->oqdsz=sizeof(struct qdesfmt0)/4;
3082 irq_ptr->qdr->qiba=(unsigned long)&irq_ptr->qib;
3083 irq_ptr->qdr->qkey=QDIO_STORAGE_KEY;
3086 irq_ptr->is_qebsm = is_passthrough;
3087 if (irq_ptr->is_qebsm)
3088 irq_ptr->qib.rflags |= QIB_RFLAGS_ENABLE_QEBSM;
3090 irq_ptr->qib.qfmt=init_data->q_format;
3091 if (init_data->no_input_qs)
3092 irq_ptr->qib.isliba=(unsigned long)(irq_ptr->input_qs[0]->slib);
3093 if (init_data->no_output_qs)
3094 irq_ptr->qib.osliba=(unsigned long)(irq_ptr->output_qs[0]->slib);
3095 memcpy(irq_ptr->qib.ebcnam,init_data->adapter_name,8);
3097 qdio_set_impl_params(irq_ptr,init_data->qib_param_field_format,
3098 init_data->qib_param_field,
3099 init_data->no_input_qs,
3100 init_data->no_output_qs,
3101 init_data->input_slib_elements,
3102 init_data->output_slib_elements);
3104 /* first input descriptors, then output descriptors */
3105 is_iqdio = (init_data->q_format == QDIO_IQDIO_QFMT) ? 1 : 0;
3106 for (i=0;i<init_data->no_input_qs;i++)
3107 qdio_allocate_fill_input_desc(irq_ptr, i, is_iqdio);
3109 for (i=0;i<init_data->no_output_qs;i++)
3110 qdio_allocate_fill_output_desc(irq_ptr, i,
3111 init_data->no_input_qs,
3114 /* qdr, qib, sls, slsbs, slibs, sbales filled. */
3116 /* get qdio commands */
3117 ciw = ccw_device_get_ciw(init_data->cdev, CIW_TYPE_EQUEUE);
3119 QDIO_DBF_TEXT2(1,setup,"no eq");
3120 QDIO_PRINT_INFO("No equeue CIW found for QDIO commands. "
3121 "Trying to use default.\n");
3123 irq_ptr->equeue = *ciw;
3124 ciw = ccw_device_get_ciw(init_data->cdev, CIW_TYPE_AQUEUE);
3126 QDIO_DBF_TEXT2(1,setup,"no aq");
3127 QDIO_PRINT_INFO("No aqueue CIW found for QDIO commands. "
3128 "Trying to use default.\n");
3130 irq_ptr->aqueue = *ciw;
3132 /* Set new interrupt handler. */
3133 irq_ptr->original_int_handler = init_data->cdev->handler;
3134 init_data->cdev->handler = qdio_handler;
3140 qdio_establish(struct qdio_initialize *init_data)
3142 struct qdio_irq *irq_ptr;
3143 unsigned long saveflags;
3144 int result, result2;
3145 struct ccw_device *cdev;
3148 cdev=init_data->cdev;
3149 irq_ptr = cdev->private->qdio_data;
3153 if (cdev->private->state != DEV_STATE_ONLINE)
3156 down(&irq_ptr->setting_up_sema);
3158 qdio_fill_irq(init_data);
3160 /* the thinint CHSC stuff */
3161 if (irq_ptr->is_thinint_irq) {
3163 result = tiqdio_set_subchannel_ind(irq_ptr,0);
3165 up(&irq_ptr->setting_up_sema);
3166 qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR);
3169 tiqdio_set_delay_target(irq_ptr,TIQDIO_DELAY_TARGET);
3172 sprintf(dbf_text,"qest%4x",cdev->private->irq);
3173 QDIO_DBF_TEXT0(0,setup,dbf_text);
3174 QDIO_DBF_TEXT0(0,trace,dbf_text);
3177 irq_ptr->ccw.cmd_code=irq_ptr->equeue.cmd;
3178 irq_ptr->ccw.flags=CCW_FLAG_SLI;
3179 irq_ptr->ccw.count=irq_ptr->equeue.count;
3180 irq_ptr->ccw.cda=QDIO_GET_ADDR(irq_ptr->qdr);
3182 spin_lock_irqsave(get_ccwdev_lock(cdev),saveflags);
3184 ccw_device_set_options(cdev, 0);
3185 result=ccw_device_start_timeout(cdev,&irq_ptr->ccw,
3186 QDIO_DOING_ESTABLISH,0, 0,
3187 QDIO_ESTABLISH_TIMEOUT);
3189 result2=ccw_device_start_timeout(cdev,&irq_ptr->ccw,
3190 QDIO_DOING_ESTABLISH,0,0,
3191 QDIO_ESTABLISH_TIMEOUT);
3192 sprintf(dbf_text,"eq:io%4x",result);
3193 QDIO_DBF_TEXT2(1,setup,dbf_text);
3195 sprintf(dbf_text,"eq:io%4x",result);
3196 QDIO_DBF_TEXT2(1,setup,dbf_text);
3198 QDIO_PRINT_WARN("establish queues on irq %04x: do_IO " \
3199 "returned %i, next try returned %i\n",
3200 irq_ptr->irq,result,result2);
3203 ccw_device_set_timeout(cdev, 0);
3206 spin_unlock_irqrestore(get_ccwdev_lock(cdev),saveflags);
3209 up(&irq_ptr->setting_up_sema);
3210 qdio_shutdown(cdev,QDIO_FLAG_CLEANUP_USING_CLEAR);
3214 /* Timeout is cared for already by using ccw_device_start_timeout(). */
3215 wait_event_interruptible(cdev->private->wait_q,
3216 irq_ptr->state == QDIO_IRQ_STATE_ESTABLISHED ||
3217 irq_ptr->state == QDIO_IRQ_STATE_ERR);
3219 if (irq_ptr->state == QDIO_IRQ_STATE_ESTABLISHED)
3222 up(&irq_ptr->setting_up_sema);
3223 qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR);
3227 qdio_get_ssqd_information(irq_ptr);
3228 /* if this gets set once, we're running under VM and can omit SVSes */
3229 if (irq_ptr->qdioac&CHSC_FLAG_SIGA_SYNC_NECESSARY)
3232 sprintf(dbf_text,"qdioac%2x",irq_ptr->qdioac);
3233 QDIO_DBF_TEXT2(0,setup,dbf_text);
3235 sprintf(dbf_text,"qib ac%2x",irq_ptr->qib.ac);
3236 QDIO_DBF_TEXT2(0,setup,dbf_text);
3238 irq_ptr->hydra_gives_outbound_pcis=
3239 irq_ptr->qib.ac&QIB_AC_OUTBOUND_PCI_SUPPORTED;
3240 irq_ptr->sync_done_on_outb_pcis=
3241 irq_ptr->qdioac&CHSC_FLAG_SIGA_SYNC_DONE_ON_OUTB_PCIS;
3243 qdio_initialize_set_siga_flags_input(irq_ptr);
3244 qdio_initialize_set_siga_flags_output(irq_ptr);
3246 up(&irq_ptr->setting_up_sema);
3253 qdio_activate(struct ccw_device *cdev, int flags)
3255 struct qdio_irq *irq_ptr;
3256 int i,result=0,result2;
3257 unsigned long saveflags;
3258 char dbf_text[20]; /* see qdio_initialize */
3260 irq_ptr = cdev->private->qdio_data;
3264 if (cdev->private->state != DEV_STATE_ONLINE)
3267 down(&irq_ptr->setting_up_sema);
3268 if (irq_ptr->state==QDIO_IRQ_STATE_INACTIVE) {
3273 sprintf(dbf_text,"qact%4x", irq_ptr->irq);
3274 QDIO_DBF_TEXT2(0,setup,dbf_text);
3275 QDIO_DBF_TEXT2(0,trace,dbf_text);
3278 irq_ptr->ccw.cmd_code=irq_ptr->aqueue.cmd;
3279 irq_ptr->ccw.flags=CCW_FLAG_SLI;
3280 irq_ptr->ccw.count=irq_ptr->aqueue.count;
3281 irq_ptr->ccw.cda=QDIO_GET_ADDR(0);
3283 spin_lock_irqsave(get_ccwdev_lock(cdev),saveflags);
3285 ccw_device_set_timeout(cdev, 0);
3286 ccw_device_set_options(cdev, CCWDEV_REPORT_ALL);
3287 result=ccw_device_start(cdev,&irq_ptr->ccw,QDIO_DOING_ACTIVATE,
3288 0, DOIO_DENY_PREFETCH);
3290 result2=ccw_device_start(cdev,&irq_ptr->ccw,
3291 QDIO_DOING_ACTIVATE,0,0);
3292 sprintf(dbf_text,"aq:io%4x",result);
3293 QDIO_DBF_TEXT2(1,setup,dbf_text);
3295 sprintf(dbf_text,"aq:io%4x",result);
3296 QDIO_DBF_TEXT2(1,setup,dbf_text);
3298 QDIO_PRINT_WARN("activate queues on irq %04x: do_IO " \
3299 "returned %i, next try returned %i\n",
3300 irq_ptr->irq,result,result2);
3304 spin_unlock_irqrestore(get_ccwdev_lock(cdev),saveflags);
3308 for (i=0;i<irq_ptr->no_input_qs;i++) {
3309 if (irq_ptr->is_thinint_irq) {
3311 * that way we know, that, if we will get interrupted
3312 * by tiqdio_inbound_processing, qdio_unmark_q will
3315 qdio_reserve_q(irq_ptr->input_qs[i]);
3316 qdio_mark_tiq(irq_ptr->input_qs[i]);
3317 qdio_release_q(irq_ptr->input_qs[i]);
3321 if (flags&QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT) {
3322 for (i=0;i<irq_ptr->no_input_qs;i++) {
3323 irq_ptr->input_qs[i]->is_input_q|=
3324 QDIO_FLAG_NO_INPUT_INTERRUPT_CONTEXT;
3328 wait_event_interruptible_timeout(cdev->private->wait_q,
3330 QDIO_IRQ_STATE_STOPPED) ||
3332 QDIO_IRQ_STATE_ERR)),
3333 QDIO_ACTIVATE_TIMEOUT);
3335 switch (irq_ptr->state) {
3336 case QDIO_IRQ_STATE_STOPPED:
3337 case QDIO_IRQ_STATE_ERR:
3338 up(&irq_ptr->setting_up_sema);
3339 qdio_shutdown(cdev, QDIO_FLAG_CLEANUP_USING_CLEAR);
3340 down(&irq_ptr->setting_up_sema);
3344 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ACTIVE);
3348 up(&irq_ptr->setting_up_sema);
3353 /* buffers filled forwards again to make Rick happy */
3355 qdio_do_qdio_fill_input(struct qdio_q *q, unsigned int qidx,
3356 unsigned int count, struct qdio_buffer *buffers)
3358 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
3359 qidx &= (QDIO_MAX_BUFFERS_PER_Q - 1);
3360 if (irq->is_qebsm) {
3362 set_slsb(q, &qidx, SLSB_CU_INPUT_EMPTY, &count);
3366 set_slsb(q, &qidx, SLSB_CU_INPUT_EMPTY, &count);
3369 qidx = (qidx + 1) & (QDIO_MAX_BUFFERS_PER_Q - 1);
3374 qdio_do_qdio_fill_output(struct qdio_q *q, unsigned int qidx,
3375 unsigned int count, struct qdio_buffer *buffers)
3377 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
3379 qidx &= (QDIO_MAX_BUFFERS_PER_Q - 1);
3380 if (irq->is_qebsm) {
3382 set_slsb(q, &qidx, SLSB_CU_OUTPUT_PRIMED, &count);
3387 set_slsb(q, &qidx, SLSB_CU_OUTPUT_PRIMED, &count);
3390 qidx = (qidx + 1) & (QDIO_MAX_BUFFERS_PER_Q - 1);
3395 do_qdio_handle_inbound(struct qdio_q *q, unsigned int callflags,
3396 unsigned int qidx, unsigned int count,
3397 struct qdio_buffer *buffers)
3401 /* This is the inbound handling of queues */
3402 used_elements=atomic_add_return(count, &q->number_of_buffers_used) - count;
3404 qdio_do_qdio_fill_input(q,qidx,count,buffers);
3406 if ((used_elements+count==QDIO_MAX_BUFFERS_PER_Q)&&
3407 (callflags&QDIO_FLAG_UNDER_INTERRUPT))
3408 atomic_swap(&q->polling,0);
3412 if (callflags&QDIO_FLAG_DONT_SIGA)
3417 result=qdio_siga_input(q);
3420 q->error_status_flags|=
3421 QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR;
3422 q->error_status_flags|=QDIO_STATUS_LOOK_FOR_ERROR;
3423 q->siga_error=result;
3431 do_qdio_handle_outbound(struct qdio_q *q, unsigned int callflags,
3432 unsigned int qidx, unsigned int count,
3433 struct qdio_buffer *buffers)
3436 unsigned int cnt, start_buf;
3437 unsigned char state = 0;
3438 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
3440 /* This is the outbound handling of queues */
3441 #ifdef QDIO_PERFORMANCE_STATS
3442 perf_stats.start_time_outbound=NOW;
3443 #endif /* QDIO_PERFORMANCE_STATS */
3445 qdio_do_qdio_fill_output(q,qidx,count,buffers);
3447 used_elements=atomic_add_return(count, &q->number_of_buffers_used) - count;
3449 if (callflags&QDIO_FLAG_DONT_SIGA) {
3450 #ifdef QDIO_PERFORMANCE_STATS
3451 perf_stats.outbound_time+=NOW-perf_stats.start_time_outbound;
3452 perf_stats.outbound_cnt++;
3453 #endif /* QDIO_PERFORMANCE_STATS */
3456 if (q->is_iqdio_q) {
3457 /* one siga for every sbal */
3459 qdio_kick_outbound_q(q);
3461 __qdio_outbound_processing(q);
3463 /* under VM, we do a SIGA sync unconditionally */
3467 * w/o shadow queues (else branch of
3468 * SYNC_MEMORY :-/ ), we try to
3469 * fast-requeue buffers
3471 if (irq->is_qebsm) {
3473 start_buf = ((qidx+QDIO_MAX_BUFFERS_PER_Q-1) &
3474 (QDIO_MAX_BUFFERS_PER_Q-1));
3475 qdio_do_eqbs(q, &state, &start_buf, &cnt);
3477 state = q->slsb.acc.val[(qidx+QDIO_MAX_BUFFERS_PER_Q-1)
3478 &(QDIO_MAX_BUFFERS_PER_Q-1) ];
3479 if (state != SLSB_CU_OUTPUT_PRIMED) {
3480 qdio_kick_outbound_q(q);
3482 QDIO_DBF_TEXT3(0,trace, "fast-req");
3483 #ifdef QDIO_PERFORMANCE_STATS
3484 perf_stats.fast_reqs++;
3485 #endif /* QDIO_PERFORMANCE_STATS */
3489 * only marking the q could take too long,
3490 * the upper layer module could do a lot of
3491 * traffic in that time
3493 __qdio_outbound_processing(q);
3496 #ifdef QDIO_PERFORMANCE_STATS
3497 perf_stats.outbound_time+=NOW-perf_stats.start_time_outbound;
3498 perf_stats.outbound_cnt++;
3499 #endif /* QDIO_PERFORMANCE_STATS */
3502 /* count must be 1 in iqdio */
3504 do_QDIO(struct ccw_device *cdev,unsigned int callflags,
3505 unsigned int queue_number, unsigned int qidx,
3506 unsigned int count,struct qdio_buffer *buffers)
3508 struct qdio_irq *irq_ptr;
3509 #ifdef CONFIG_QDIO_DEBUG
3512 sprintf(dbf_text,"doQD%04x",cdev->private->irq);
3513 QDIO_DBF_TEXT3(0,trace,dbf_text);
3514 #endif /* CONFIG_QDIO_DEBUG */
3516 if ( (qidx>QDIO_MAX_BUFFERS_PER_Q) ||
3517 (count>QDIO_MAX_BUFFERS_PER_Q) ||
3518 (queue_number>QDIO_MAX_QUEUES_PER_IRQ) )
3524 irq_ptr = cdev->private->qdio_data;
3528 #ifdef CONFIG_QDIO_DEBUG
3529 if (callflags&QDIO_FLAG_SYNC_INPUT)
3530 QDIO_DBF_HEX3(0,trace,&irq_ptr->input_qs[queue_number],
3533 QDIO_DBF_HEX3(0,trace,&irq_ptr->output_qs[queue_number],
3535 sprintf(dbf_text,"flag%04x",callflags);
3536 QDIO_DBF_TEXT3(0,trace,dbf_text);
3537 sprintf(dbf_text,"qi%02xct%02x",qidx,count);
3538 QDIO_DBF_TEXT3(0,trace,dbf_text);
3539 #endif /* CONFIG_QDIO_DEBUG */
3541 if (irq_ptr->state!=QDIO_IRQ_STATE_ACTIVE)
3544 if (callflags&QDIO_FLAG_SYNC_INPUT)
3545 do_qdio_handle_inbound(irq_ptr->input_qs[queue_number],
3546 callflags, qidx, count, buffers);
3547 else if (callflags&QDIO_FLAG_SYNC_OUTPUT)
3548 do_qdio_handle_outbound(irq_ptr->output_qs[queue_number],
3549 callflags, qidx, count, buffers);
3551 QDIO_DBF_TEXT3(1,trace,"doQD:inv");
3557 #ifdef QDIO_PERFORMANCE_STATS
3559 qdio_perf_procfile_read(char *buffer, char **buffer_location, off_t offset,
3560 int buffer_length, int *eof, void *data)
3564 /* we are always called with buffer_length=4k, so we all
3565 deliver on the first read */
3569 #define _OUTP_IT(x...) c+=sprintf(buffer+c,x)
3570 _OUTP_IT("i_p_nc/c=%lu/%lu\n",i_p_nc,i_p_c);
3571 _OUTP_IT("ii_p_nc/c=%lu/%lu\n",ii_p_nc,ii_p_c);
3572 _OUTP_IT("o_p_nc/c=%lu/%lu\n",o_p_nc,o_p_c);
3573 _OUTP_IT("Number of tasklet runs (total) : %u\n",
3574 perf_stats.tl_runs);
3576 _OUTP_IT("Number of SIGA sync's issued : %u\n",
3577 perf_stats.siga_syncs);
3578 _OUTP_IT("Number of SIGA in's issued : %u\n",
3579 perf_stats.siga_ins);
3580 _OUTP_IT("Number of SIGA out's issued : %u\n",
3581 perf_stats.siga_outs);
3582 _OUTP_IT("Number of PCIs caught : %u\n",
3584 _OUTP_IT("Number of adapter interrupts caught : %u\n",
3585 perf_stats.thinints);
3586 _OUTP_IT("Number of fast requeues (outg. SBALs w/o SIGA) : %u\n",
3587 perf_stats.fast_reqs);
3589 _OUTP_IT("Total time of all inbound actions (us) incl. UL : %u\n",
3590 perf_stats.inbound_time);
3591 _OUTP_IT("Number of inbound transfers : %u\n",
3592 perf_stats.inbound_cnt);
3593 _OUTP_IT("Total time of all outbound do_QDIOs (us) : %u\n",
3594 perf_stats.outbound_time);
3595 _OUTP_IT("Number of do_QDIOs outbound : %u\n",
3596 perf_stats.outbound_cnt);
3602 static struct proc_dir_entry *qdio_perf_proc_file;
3603 #endif /* QDIO_PERFORMANCE_STATS */
3606 qdio_add_procfs_entry(void)
3608 #ifdef QDIO_PERFORMANCE_STATS
3609 proc_perf_file_registration=0;
3610 qdio_perf_proc_file=create_proc_entry(QDIO_PERF,
3611 S_IFREG|0444,&proc_root);
3612 if (qdio_perf_proc_file) {
3613 qdio_perf_proc_file->read_proc=&qdio_perf_procfile_read;
3614 } else proc_perf_file_registration=-1;
3616 if (proc_perf_file_registration)
3617 QDIO_PRINT_WARN("was not able to register perf. " \
3618 "proc-file (%i).\n",
3619 proc_perf_file_registration);
3620 #endif /* QDIO_PERFORMANCE_STATS */
3624 qdio_remove_procfs_entry(void)
3626 #ifdef QDIO_PERFORMANCE_STATS
3627 perf_stats.tl_runs=0;
3629 if (!proc_perf_file_registration) /* means if it went ok earlier */
3630 remove_proc_entry(QDIO_PERF,&proc_root);
3631 #endif /* QDIO_PERFORMANCE_STATS */
3635 tiqdio_register_thinints(void)
3638 register_thinint_result=
3639 s390_register_adapter_interrupt(&tiqdio_thinint_handler);
3640 if (register_thinint_result) {
3641 sprintf(dbf_text,"regthn%x",(register_thinint_result&0xff));
3642 QDIO_DBF_TEXT0(0,setup,dbf_text);
3643 QDIO_PRINT_ERR("failed to register adapter handler " \
3644 "(rc=%i).\nAdapter interrupts might " \
3645 "not work. Continuing.\n",
3646 register_thinint_result);
3651 tiqdio_unregister_thinints(void)
3653 if (!register_thinint_result)
3654 s390_unregister_adapter_interrupt(&tiqdio_thinint_handler);
3658 qdio_get_qdio_memory(void)
3661 indicator_used[0]=1;
3663 for (i=1;i<INDICATORS_PER_CACHELINE;i++)
3664 indicator_used[i]=0;
3665 indicators=(__u32*)kmalloc(sizeof(__u32)*(INDICATORS_PER_CACHELINE),
3667 if (!indicators) return -ENOMEM;
3668 memset(indicators,0,sizeof(__u32)*(INDICATORS_PER_CACHELINE));
3673 qdio_release_qdio_memory(void)
3679 qdio_unregister_dbf_views(void)
3682 debug_unregister(qdio_dbf_setup);
3684 debug_unregister(qdio_dbf_sbal);
3686 debug_unregister(qdio_dbf_sense);
3688 debug_unregister(qdio_dbf_trace);
3689 #ifdef CONFIG_QDIO_DEBUG
3690 if (qdio_dbf_slsb_out)
3691 debug_unregister(qdio_dbf_slsb_out);
3692 if (qdio_dbf_slsb_in)
3693 debug_unregister(qdio_dbf_slsb_in);
3694 #endif /* CONFIG_QDIO_DEBUG */
3698 qdio_register_dbf_views(void)
3700 qdio_dbf_setup=debug_register(QDIO_DBF_SETUP_NAME,
3701 QDIO_DBF_SETUP_PAGES,
3702 QDIO_DBF_SETUP_NR_AREAS,
3703 QDIO_DBF_SETUP_LEN);
3704 if (!qdio_dbf_setup)
3706 debug_register_view(qdio_dbf_setup,&debug_hex_ascii_view);
3707 debug_set_level(qdio_dbf_setup,QDIO_DBF_SETUP_LEVEL);
3709 qdio_dbf_sbal=debug_register(QDIO_DBF_SBAL_NAME,
3710 QDIO_DBF_SBAL_PAGES,
3711 QDIO_DBF_SBAL_NR_AREAS,
3716 debug_register_view(qdio_dbf_sbal,&debug_hex_ascii_view);
3717 debug_set_level(qdio_dbf_sbal,QDIO_DBF_SBAL_LEVEL);
3719 qdio_dbf_sense=debug_register(QDIO_DBF_SENSE_NAME,
3720 QDIO_DBF_SENSE_PAGES,
3721 QDIO_DBF_SENSE_NR_AREAS,
3722 QDIO_DBF_SENSE_LEN);
3723 if (!qdio_dbf_sense)
3726 debug_register_view(qdio_dbf_sense,&debug_hex_ascii_view);
3727 debug_set_level(qdio_dbf_sense,QDIO_DBF_SENSE_LEVEL);
3729 qdio_dbf_trace=debug_register(QDIO_DBF_TRACE_NAME,
3730 QDIO_DBF_TRACE_PAGES,
3731 QDIO_DBF_TRACE_NR_AREAS,
3732 QDIO_DBF_TRACE_LEN);
3733 if (!qdio_dbf_trace)
3736 debug_register_view(qdio_dbf_trace,&debug_hex_ascii_view);
3737 debug_set_level(qdio_dbf_trace,QDIO_DBF_TRACE_LEVEL);
3739 #ifdef CONFIG_QDIO_DEBUG
3740 qdio_dbf_slsb_out=debug_register(QDIO_DBF_SLSB_OUT_NAME,
3741 QDIO_DBF_SLSB_OUT_PAGES,
3742 QDIO_DBF_SLSB_OUT_NR_AREAS,
3743 QDIO_DBF_SLSB_OUT_LEN);
3744 if (!qdio_dbf_slsb_out)
3746 debug_register_view(qdio_dbf_slsb_out,&debug_hex_ascii_view);
3747 debug_set_level(qdio_dbf_slsb_out,QDIO_DBF_SLSB_OUT_LEVEL);
3749 qdio_dbf_slsb_in=debug_register(QDIO_DBF_SLSB_IN_NAME,
3750 QDIO_DBF_SLSB_IN_PAGES,
3751 QDIO_DBF_SLSB_IN_NR_AREAS,
3752 QDIO_DBF_SLSB_IN_LEN);
3753 if (!qdio_dbf_slsb_in)
3755 debug_register_view(qdio_dbf_slsb_in,&debug_hex_ascii_view);
3756 debug_set_level(qdio_dbf_slsb_in,QDIO_DBF_SLSB_IN_LEVEL);
3757 #endif /* CONFIG_QDIO_DEBUG */
3760 QDIO_PRINT_ERR("not enough memory for dbf.\n");
3761 qdio_unregister_dbf_views();
3769 #ifdef QDIO_PERFORMANCE_STATS
3771 #endif /* QDIO_PERFORMANCE_STATS */
3773 printk("qdio: loading %s\n",version);
3775 res=qdio_get_qdio_memory();
3779 res = qdio_register_dbf_views();
3783 QDIO_DBF_TEXT0(0,setup,"initQDIO");
3785 #ifdef QDIO_PERFORMANCE_STATS
3786 memset((void*)&perf_stats,0,sizeof(perf_stats));
3787 QDIO_DBF_TEXT0(0,setup,"perfstat");
3789 QDIO_DBF_HEX0(0,setup,&ptr,sizeof(void*));
3790 #endif /* QDIO_PERFORMANCE_STATS */
3792 qdio_add_procfs_entry();
3794 if (tiqdio_check_chsc_availability())
3795 QDIO_PRINT_ERR("Not all CHSCs supported. Continuing.\n");
3797 tiqdio_register_thinints();
3805 tiqdio_unregister_thinints();
3806 qdio_remove_procfs_entry();
3807 qdio_release_qdio_memory();
3808 qdio_unregister_dbf_views();
3810 printk("qdio: %s: module removed\n",version);
3813 module_init(init_QDIO);
3814 module_exit(cleanup_QDIO);
3816 EXPORT_SYMBOL(qdio_allocate);
3817 EXPORT_SYMBOL(qdio_establish);
3818 EXPORT_SYMBOL(qdio_initialize);
3819 EXPORT_SYMBOL(qdio_activate);
3820 EXPORT_SYMBOL(do_QDIO);
3821 EXPORT_SYMBOL(qdio_shutdown);
3822 EXPORT_SYMBOL(qdio_free);
3823 EXPORT_SYMBOL(qdio_cleanup);
3824 EXPORT_SYMBOL(qdio_synchronize);