1 /* $Id: isdnl1.c,v 1.15 1997/05/27 15:17:55 fritz Exp $
3 * isdnl1.c common low level stuff for Siemens Chipsetbased isdn cards
4 * based on the teles driver from Jan den Ouden
6 * Author Karsten Keil (keil@temic-ech.spacenet.de)
8 * Thanks to Jan den Ouden
14 * Revision 1.15 1997/05/27 15:17:55 fritz
15 * Added changes for recent 2.1.x kernels:
16 * changed return type of isdn_close
17 * queue_task_* -> queue_task
18 * clear/set_bit -> test_and_... where apropriate.
19 * changed type of hard_header_cache parameter.
21 * Revision 1.14 1997/04/07 23:00:08 keil
22 * GFP_KERNEL ---> GFP_ATOMIC
24 * Revision 1.13 1997/04/06 22:55:50 keil
27 * Revision 1.12 1997/03/26 13:43:57 keil
30 * Revision 1.11 1997/03/25 23:11:23 keil
33 * Revision 1.10 1997/03/13 14:45:05 keil
34 * using IRQ proof queue_task
36 * Revision 1.9 1997/03/12 21:44:21 keil
37 * change Interrupt routine from atomic quick to normal
39 * Revision 1.8 1997/02/09 00:24:31 keil
40 * new interface handling, one interface per card
42 * Revision 1.7 1997/01/27 15:56:03 keil
43 * PCMCIA Teles card and ITK ix1 micro added
45 * Revision 1.6 1997/01/21 22:20:00 keil
46 * changes for D-channel log; Elsa Quickstep support
48 * Revision 1.5 1997/01/10 12:51:19 keil
49 * cleanup; set newversion
51 * Revision 1.4 1996/12/08 19:44:53 keil
52 * L2FRAME_DEBUG and other changes from Pekka Sarnila
54 * Revision 1.3 1996/11/18 15:34:47 keil
55 * fix HSCX version code
57 * Revision 1.2 1996/10/27 22:16:54 keil
58 * ISAC/HSCX version lookup
60 * Revision 1.1 1996/10/13 20:04:53 keil
67 const char *l1_revision
= "$Revision: 1.15 $";
69 #define __NO_VERSION__
70 #include <linux/config.h>
91 #include "ix1_micro.h"
94 /* #define I4L_IRQ_FLAG SA_INTERRUPT */
95 #define I4L_IRQ_FLAG 0
97 #define HISAX_STATUS_BUFSIZE 4096
99 #define INCLUDE_INLINE_FUNCS
100 #include <linux/tqueue.h>
101 #include <linux/interrupt.h>
103 const char *CardType
[] =
104 {"No Card", "Teles 16.0", "Teles 8.0", "Teles 16.3",
105 "Creatix/Teles PnP", "AVM A1", "Elsa ML",
106 #ifdef CONFIG_HISAX_ELSA_PCMCIA
111 "Teles PCMCIA", "ITK ix1-micro Rev.2"};
113 static char *HSCXVer
[] =
114 {"A1", "?1", "A2", "?3", "A3", "V2.1", "?6", "?7",
115 "?8", "?9", "?10", "?11", "?12", "?13", "?14", "???"};
117 static char *ISACVer
[] =
118 {"2086/2186 V1.1", "2085 B1", "2085 B2",
121 extern struct IsdnCard cards
[];
123 extern char *HiSax_id
;
126 * Find card with given driverId
128 static inline struct IsdnCardState
130 hisax_findcard(int driverid
)
134 for (i
= 0; i
< nrcards
; i
++)
136 if (cards
[i
].sp
->myid
== driverid
)
137 return (cards
[i
].sp
);
138 return (struct IsdnCardState
*) 0;
142 HiSax_readstatus(u_char
* buf
, int len
, int user
, int id
, int channel
)
146 struct IsdnCardState
*csta
= hisax_findcard(id
);
149 for (p
= buf
, count
= 0; count
< len
; p
++, count
++) {
151 put_user(*csta
->status_read
++, p
);
153 *p
++ = *csta
->status_read
++;
154 if (csta
->status_read
> csta
->status_end
)
155 csta
->status_read
= csta
->status_buf
;
160 "HiSax: if_readstatus called with invalid driverId!\n");
166 HiSax_putstatus(struct IsdnCardState
*csta
, char *buf
)
179 printk(KERN_WARNING
"HiSax: No CardStatus for message %s", buf
);
180 restore_flags(flags
);
183 for (p
= buf
, i
= len
; i
> 0; i
--, p
++) {
184 *csta
->status_write
++ = *p
;
185 if (csta
->status_write
> csta
->status_end
)
186 csta
->status_write
= csta
->status_buf
;
189 restore_flags(flags
);
191 ic
.command
= ISDN_STAT_STAVAIL
;
192 ic
.driver
= csta
->myid
;
194 csta
->iif
.statcallb(&ic
);
199 ll_run(struct IsdnCardState
*csta
)
206 ic
.driver
= csta
->myid
;
207 ic
.command
= ISDN_STAT_RUN
;
208 csta
->iif
.statcallb(&ic
);
209 restore_flags(flags
);
214 ll_stop(struct IsdnCardState
*csta
)
218 ic
.command
= ISDN_STAT_STOP
;
219 ic
.driver
= csta
->myid
;
220 csta
->iif
.statcallb(&ic
);
225 ll_unload(struct IsdnCardState
*csta
)
229 ic
.command
= ISDN_STAT_UNLOAD
;
230 ic
.driver
= csta
->myid
;
231 csta
->iif
.statcallb(&ic
);
232 if (csta
->status_buf
)
233 kfree(csta
->status_buf
);
234 csta
->status_read
= NULL
;
235 csta
->status_write
= NULL
;
236 csta
->status_end
= NULL
;
237 kfree(csta
->dlogspace
);
241 debugl1(struct IsdnCardState
*sp
, char *msg
)
243 char tmp
[256], tm
[32];
245 jiftime(tm
, jiffies
);
246 sprintf(tmp
, "%s Card %d %s\n", tm
, sp
->cardnr
+ 1, msg
);
247 HiSax_putstatus(sp
, tmp
);
251 * HSCX stuff goes here
256 HscxVersion(u_char v
)
258 return (HSCXVer
[v
& 0xf]);
262 hscx_sched_event(struct HscxState
*hsp
, int event
)
264 hsp
->event
|= 1 << event
;
265 queue_task(&hsp
->tqueue
, &tq_immediate
);
266 mark_bh(IMMEDIATE_BH
);
270 * ISAC stuff goes here
274 ISACVersion(u_char v
)
276 return (ISACVer
[(v
>> 5) & 3]);
280 isac_sched_event(struct IsdnCardState
*sp
, int event
)
282 sp
->event
|= 1 << event
;
283 queue_task(&sp
->tqueue
, &tq_immediate
);
284 mark_bh(IMMEDIATE_BH
);
288 act_wanted(struct IsdnCardState
*sp
)
294 if (st
->l1
.act_state
)
302 isac_new_ph(struct IsdnCardState
*sp
)
306 enq
= act_wanted(sp
);
308 switch (sp
->ph_state
) {
311 sp
->ph_command(sp
, 15);
316 sp
->ph_command(sp
, 0);
321 sp
->ph_command(sp
, 0);
324 sp
->ph_command(sp
, 15);
330 sp
->ph_command(sp
, 9);
333 sp
->ph_command(sp
, 8);
335 isac_sched_event(sp
, ISAC_PHCHANGE
);
337 sp
->tx_skb
= skb_dequeue(&sp
->sq
);
340 sp
->isac_fill_fifo(sp
);
344 sp
->ph_command(sp
, 9);
346 isac_sched_event(sp
, ISAC_PHCHANGE
);
348 sp
->tx_skb
= skb_dequeue(&sp
->sq
);
351 sp
->isac_fill_fifo(sp
);
365 restart_ph(struct IsdnCardState
*sp
)
367 if (!sp
->ph_active
) {
368 if ((sp
->ph_state
== 6) || (sp
->ph_state
== 0)) {
369 sp
->ph_command(sp
, 0);
372 sp
->ph_command(sp
, 1);
375 } else if (sp
->ph_active
== 2) {
376 sp
->ph_command(sp
, 1);
383 act_ivated(struct IsdnCardState
*sp
)
389 if (st
->l1
.act_state
== 1) {
390 st
->l1
.act_state
= 2;
391 st
->l1
.l1man(st
, PH_ACTIVATE
, NULL
);
398 process_new_ph(struct IsdnCardState
*sp
)
400 if (sp
->ph_active
== 5)
405 process_xmt(struct IsdnCardState
*sp
)
407 struct PStack
*stptr
;
413 while (stptr
!= NULL
)
414 if (stptr
->l1
.requestpull
) {
415 stptr
->l1
.requestpull
= 0;
416 stptr
->l1
.l1l2(stptr
, PH_PULL_ACK
, NULL
);
423 process_rcv(struct IsdnCardState
*sp
)
425 struct sk_buff
*skb
, *nskb
;
426 struct PStack
*stptr
;
430 while ((skb
= skb_dequeue(&sp
->rq
))) {
431 #ifdef L2FRAME_DEBUG /* psa */
432 if (sp
->debug
& L1_DEB_LAPD
)
433 Logl2Frame(sp
, skb
, "PH_DATA", 1);
436 broadc
= (skb
->data
[1] >> 1) == 127;
439 if (!(skb
->data
[0] >> 2)) { /* sapi 0 */
442 LogFrame(sp
, skb
->data
, skb
->len
);
443 dlogframe(sp
, skb
->data
+ 3, skb
->len
- 3,
444 "Q.931 frame network->user broadcast");
447 while (stptr
!= NULL
) {
448 if ((skb
->data
[0] >> 2) == stptr
->l2
.sap
)
449 if ((nskb
= skb_clone(skb
, GFP_ATOMIC
)))
450 stptr
->l1
.l1l2(stptr
, PH_DATA
, nskb
);
452 printk(KERN_WARNING
"HiSax: isdn broadcast buffer shortage\n");
456 dev_kfree_skb(skb
, FREE_READ
);
459 while (stptr
!= NULL
)
460 if (((skb
->data
[0] >> 2) == stptr
->l2
.sap
) &&
461 ((skb
->data
[1] >> 1) == stptr
->l2
.tei
)) {
462 stptr
->l1
.l1l2(stptr
, PH_DATA
, skb
);
469 * Print out D-Channel msg not processed
473 if ((!(skb
->data
[0] >> 2)) && (!(skb
->data
[2] & 0x01))) {
475 "Q.931 frame network->user with tei %d (not for us)",
477 LogFrame(sp
, skb
->data
, skb
->len
);
478 dlogframe(sp
, skb
->data
+ 4, skb
->len
- 4, tmp
);
481 dev_kfree_skb(skb
, FREE_READ
);
490 isac_bh(struct IsdnCardState
*sp
)
495 if (test_and_clear_bit(ISAC_PHCHANGE
, &sp
->event
))
497 if (test_and_clear_bit(ISAC_RCVBUFREADY
, &sp
->event
))
499 if (test_and_clear_bit(ISAC_XMTBUFREADY
, &sp
->event
))
504 l2l1(struct PStack
*st
, int pr
, void *arg
)
506 struct IsdnCardState
*sp
= (struct IsdnCardState
*) st
->l1
.hardware
;
507 struct sk_buff
*skb
= arg
;
513 skb_queue_tail(&sp
->sq
, skb
);
514 #ifdef L2FRAME_DEBUG /* psa */
515 if (sp
->debug
& L1_DEB_LAPD
)
516 Logl2Frame(sp
, skb
, "PH_DATA Queued", 0);
519 if ((sp
->dlogflag
) && (!(skb
->data
[2] & 1))) { /* I-FRAME */
520 LogFrame(sp
, skb
->data
, skb
->len
);
521 sprintf(str
, "Q.931 frame user->network tei %d", st
->l2
.tei
);
522 dlogframe(sp
, skb
->data
+ st
->l2
.ihsize
, skb
->len
- st
->l2
.ihsize
,
527 #ifdef L2FRAME_DEBUG /* psa */
528 if (sp
->debug
& L1_DEB_LAPD
)
529 Logl2Frame(sp
, skb
, "PH_DATA", 0);
531 sp
->isac_fill_fifo(sp
);
534 case (PH_DATA_PULLED
):
536 if (sp
->debug
& L1_DEB_WARN
)
537 debugl1(sp
, " l2l1 tx_skb exist this shouldn't happen");
540 if ((sp
->dlogflag
) && (!(skb
->data
[2] & 1))) { /* I-FRAME */
541 LogFrame(sp
, skb
->data
, skb
->len
);
542 sprintf(str
, "Q.931 frame user->network tei %d", st
->l2
.tei
);
543 dlogframe(sp
, skb
->data
+ st
->l2
.ihsize
, skb
->len
- st
->l2
.ihsize
,
548 #ifdef L2FRAME_DEBUG /* psa */
549 if (sp
->debug
& L1_DEB_LAPD
)
550 Logl2Frame(sp
, skb
, "PH_DATA_PULLED", 0);
552 sp
->isac_fill_fifo(sp
);
554 case (PH_REQUEST_PULL
):
555 #ifdef L2FRAME_DEBUG /* psa */
556 if (sp
->debug
& L1_DEB_LAPD
)
557 debugl1(sp
, "-> PH_REQUEST_PULL");
560 st
->l1
.requestpull
= 0;
561 st
->l1
.l1l2(st
, PH_PULL_ACK
, NULL
);
563 st
->l1
.requestpull
= !0;
570 hscx_process_xmt(struct HscxState
*hsp
)
572 struct PStack
*st
= hsp
->st
;
577 if (st
->l1
.requestpull
) {
578 st
->l1
.requestpull
= 0;
579 st
->l1
.l1l2(st
, PH_PULL_ACK
, NULL
);
582 if ((!hsp
->tx_skb
) && (!skb_queue_len(&hsp
->squeue
)))
583 hsp
->sp
->modehscx(hsp
, 0, 0);
587 hscx_process_rcv(struct HscxState
*hsp
)
592 if (hsp
->magic
!= 301270) {
593 printk(KERN_DEBUG
"hscx_process_rcv magic not 301270\n");
597 while ((skb
= skb_dequeue(&hsp
->rqueue
))) {
598 hsp
->st
->l1
.l1l2(hsp
->st
, PH_DATA
, skb
);
603 hscx_bh(struct HscxState
*hsp
)
609 if (test_and_clear_bit(HSCX_RCVBUFREADY
, &hsp
->event
))
610 hscx_process_rcv(hsp
);
611 if (test_and_clear_bit(HSCX_XMTBUFREADY
, &hsp
->event
))
612 hscx_process_xmt(hsp
);
617 * interrupt stuff ends here
621 HiSax_addlist(struct IsdnCardState
*sp
,
624 st
->next
= sp
->stlist
;
629 HiSax_rmlist(struct IsdnCardState
*sp
,
634 if (sp
->stlist
== st
)
635 sp
->stlist
= st
->next
;
648 check_ph_act(struct IsdnCardState
*sp
)
650 struct PStack
*st
= sp
->stlist
;
653 if (st
->l1
.act_state
)
657 if (sp
->ph_active
== 5)
662 HiSax_manl1(struct PStack
*st
, int pr
,
665 struct IsdnCardState
*sp
= (struct IsdnCardState
*)
673 sprintf(tmp
, "PH_ACT ph_active %d", sp
->ph_active
);
678 if (sp
->ph_active
& 4) {
680 st
->l1
.act_state
= 2;
681 restore_flags(flags
);
682 st
->l1
.l1man(st
, PH_ACTIVATE
, NULL
);
684 st
->l1
.act_state
= 1;
685 if (sp
->ph_active
== 0)
687 restore_flags(flags
);
690 case (PH_DEACTIVATE
):
691 st
->l1
.act_state
= 0;
693 sprintf(tmp
, "PH_DEACT ph_active %d", sp
->ph_active
);
702 HiSax_l2l1discardq(struct PStack
*st
, int pr
,
703 void *heldby
, int releasetoo
)
705 struct IsdnCardState
*sp
= (struct IsdnCardState
*) st
->l1
.hardware
;
709 if (sp
->magic
!= 301271) {
710 printk(KERN_DEBUG
"isac_discardq magic not 301271\n");
715 while ((skb
= skb_dequeue(&sp
->sq
))) {
717 dev_kfree_skb(skb
, FREE_WRITE
);
722 setstack_HiSax(struct PStack
*st
, struct IsdnCardState
*sp
)
724 st
->l1
.hardware
= sp
;
725 st
->protocol
= sp
->protocol
;
729 st
->l1
.stlistp
= &(sp
->stlist
);
730 st
->l1
.act_state
= 0;
732 st
->l2
.l2l1discardq
= HiSax_l2l1discardq
;
733 st
->ma
.manl1
= HiSax_manl1
;
734 st
->l1
.requestpull
= 0;
738 init_hscxstate(struct IsdnCardState
*sp
,
741 struct HscxState
*hsp
= sp
->hs
+ hscx
;
746 hsp
->tqueue
.next
= 0;
747 hsp
->tqueue
.sync
= 0;
748 hsp
->tqueue
.routine
= (void *) (void *) hscx_bh
;
749 hsp
->tqueue
.data
= hsp
;
761 get_irq(int cardnr
, void *routine
)
763 struct IsdnCard
*card
= cards
+ cardnr
;
768 if (request_irq(card
->sp
->irq
, routine
,
769 I4L_IRQ_FLAG
, "HiSax", NULL
)) {
770 printk(KERN_WARNING
"HiSax: couldn't get interrupt %d\n",
772 restore_flags(flags
);
775 irq2dev_map
[card
->sp
->irq
] = (void *) card
->sp
;
776 restore_flags(flags
);
781 release_irq(int cardnr
)
783 struct IsdnCard
*card
= cards
+ cardnr
;
785 irq2dev_map
[card
->sp
->irq
] = NULL
;
786 free_irq(card
->sp
->irq
, NULL
);
790 close_hscxstate(struct HscxState
*hs
)
794 hs
->sp
->modehscx(hs
, 0, 0);
801 while ((skb
= skb_dequeue(&hs
->rqueue
))) {
803 dev_kfree_skb(skb
, FREE_READ
);
805 while ((skb
= skb_dequeue(&hs
->squeue
))) {
807 dev_kfree_skb(skb
, FREE_WRITE
);
810 SET_SKB_FREE(hs
->tx_skb
);
811 dev_kfree_skb(hs
->tx_skb
, FREE_WRITE
);
819 closecard(int cardnr
)
821 struct IsdnCardState
*csta
= cards
[cardnr
].sp
;
824 close_hscxstate(csta
->hs
+ 1);
825 close_hscxstate(csta
->hs
);
831 while ((skb
= skb_dequeue(&csta
->rq
))) {
833 dev_kfree_skb(skb
, FREE_READ
);
835 while ((skb
= skb_dequeue(&csta
->sq
))) {
837 dev_kfree_skb(skb
, FREE_WRITE
);
840 SET_SKB_FREE(csta
->tx_skb
);
841 dev_kfree_skb(csta
->tx_skb
, FREE_WRITE
);
846 case ISDN_CTYPE_16_0
:
848 release_io_teles0(cards
+ cardnr
);
853 case ISDN_CTYPE_16_3
:
854 case ISDN_CTYPE_TELESPCMCIA
:
855 release_io_teles3(cards
+ cardnr
);
860 release_io_avm_a1(cards
+ cardnr
);
864 case ISDN_CTYPE_ELSA
:
865 case ISDN_CTYPE_ELSA_QS1000
:
866 release_io_elsa(cards
+ cardnr
);
870 case ISDN_CTYPE_IX1MICROR2
:
871 release_io_ix1micro(cards
+ cardnr
);
881 checkcard(int cardnr
, char *id
)
885 struct IsdnCard
*card
= cards
+ cardnr
;
886 struct IsdnCardState
*sp
;
890 if (!(sp
= (struct IsdnCardState
*)
891 kmalloc(sizeof(struct IsdnCardState
), GFP_ATOMIC
))) {
893 "HiSax: No memory for IsdnCardState(card %d)\n",
895 restore_flags(flags
);
901 sp
->protocol
= card
->protocol
;
903 if ((card
->typ
> 0) && (card
->typ
< 31)) {
904 if (!((1 << card
->typ
) & SUPORTED_CARDS
)) {
906 "HiSax: Support for %s Card not selected\n",
907 CardType
[card
->typ
]);
908 restore_flags(flags
);
913 "HiSax: Card Type %d out of range\n",
915 restore_flags(flags
);
918 if (!(sp
->dlogspace
= kmalloc(4096, GFP_ATOMIC
))) {
920 "HiSax: No memory for dlogspace(card %d)\n",
922 restore_flags(flags
);
925 if (!(sp
->status_buf
= kmalloc(HISAX_STATUS_BUFSIZE
, GFP_ATOMIC
))) {
927 "HiSax: No memory for status_buf(card %d)\n",
929 kfree(sp
->dlogspace
);
930 restore_flags(flags
);
933 sp
->status_read
= sp
->status_buf
;
934 sp
->status_write
= sp
->status_buf
;
935 sp
->status_end
= sp
->status_buf
+ HISAX_STATUS_BUFSIZE
- 1;
938 strcpy(sp
->iif
.id
, id
);
939 sp
->iif
.channels
= 2;
940 sp
->iif
.maxbufsize
= MAX_DATA_SIZE
;
941 sp
->iif
.hl_hdrlen
= MAX_HEADER_LEN
;
943 ISDN_FEATURE_L2_X75I
|
944 ISDN_FEATURE_L2_HDLC
|
945 ISDN_FEATURE_L2_TRANS
|
946 ISDN_FEATURE_L3_TRANS
|
947 #ifdef CONFIG_HISAX_1TR6
948 ISDN_FEATURE_P_1TR6
|
950 #ifdef CONFIG_HISAX_EURO
951 ISDN_FEATURE_P_EURO
|
953 #ifdef CONFIG_HISAX_NI1
958 sp
->iif
.command
= HiSax_command
;
959 sp
->iif
.writebuf
= NULL
;
960 sp
->iif
.writecmd
= NULL
;
961 sp
->iif
.writebuf_skb
= HiSax_writebuf_skb
;
962 sp
->iif
.readstat
= HiSax_readstatus
;
963 register_isdn(&sp
->iif
);
964 sp
->myid
= sp
->iif
.channels
;
965 restore_flags(flags
);
967 "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr
+ 1,
968 (card
->protocol
== ISDN_PTYPE_1TR6
) ? "1TR6" :
969 (card
->protocol
== ISDN_PTYPE_EURO
) ? "EDSS1" :
970 (card
->protocol
== ISDN_PTYPE_LEASED
) ? "LEASED" :
971 (card
->protocol
== ISDN_PTYPE_NI1
) ? "NI1" :
972 "NONE", sp
->iif
.id
, sp
->myid
);
975 case ISDN_CTYPE_16_0
:
977 ret
= setup_teles0(card
);
981 case ISDN_CTYPE_16_3
:
983 case ISDN_CTYPE_TELESPCMCIA
:
984 ret
= setup_teles3(card
);
989 ret
= setup_avm_a1(card
);
993 case ISDN_CTYPE_ELSA
:
994 case ISDN_CTYPE_ELSA_QS1000
:
995 ret
= setup_elsa(card
);
999 case ISDN_CTYPE_IX1MICROR2
:
1000 ret
= setup_ix1micro(card
);
1004 printk(KERN_WARNING
"HiSax: Unknown Card Typ %d\n",
1013 if (!(sp
->rcvbuf
= kmalloc(MAX_DFRAME_LEN
, GFP_ATOMIC
))) {
1015 "HiSax: No memory for isac rcvbuf\n");
1022 sp
->tqueue
.next
= 0;
1023 sp
->tqueue
.sync
= 0;
1024 sp
->tqueue
.routine
= (void *) (void *) isac_bh
;
1025 sp
->tqueue
.data
= sp
;
1027 skb_queue_head_init(&sp
->rq
);
1028 skb_queue_head_init(&sp
->sq
);
1033 sp
->debug
= L1_DEB_WARN
;
1038 init_hscxstate(sp
, 0);
1039 init_hscxstate(sp
, 1);
1041 switch (card
->typ
) {
1043 case ISDN_CTYPE_16_0
:
1044 case ISDN_CTYPE_8_0
:
1045 ret
= initteles0(sp
);
1049 case ISDN_CTYPE_16_3
:
1050 case ISDN_CTYPE_PNP
:
1051 case ISDN_CTYPE_TELESPCMCIA
:
1052 ret
= initteles3(sp
);
1057 ret
= initavm_a1(sp
);
1061 case ISDN_CTYPE_ELSA
:
1062 case ISDN_CTYPE_ELSA_QS1000
:
1067 case ISDN_CTYPE_IX1MICROR2
:
1068 ret
= initix1micro(sp
);
1079 init_tei(sp
, sp
->protocol
);
1086 HiSax_shiftcards(int idx
)
1090 for (i
= idx
; i
< 15; i
++)
1091 memcpy(&cards
[i
], &cards
[i
+ 1], sizeof(cards
[i
]));
1095 HiSax_inithardware(void)
1102 char *next_id
= HiSax_id
;
1105 if (strchr(HiSax_id
, ','))
1107 else if (strchr(HiSax_id
, '%'))
1110 while (i
< nrcards
) {
1111 if (cards
[i
].typ
< 1)
1114 if ((next_id
= strchr(id
, t
))) {
1123 sprintf(ids
, "%s%d", id
, i
);
1125 if (checkcard(i
, ids
)) {
1129 printk(KERN_WARNING
"HiSax: Card %s not installed !\n",
1130 CardType
[cards
[i
].typ
]);
1132 kfree((void *) cards
[i
].sp
);
1134 HiSax_shiftcards(i
);
1141 HiSax_closehardware(void)
1148 for (i
= 0; i
< nrcards
; i
++)
1150 ll_stop(cards
[i
].sp
);
1151 CallcFreeChan(cards
[i
].sp
);
1152 release_tei(cards
[i
].sp
);
1155 kfree((void *) cards
[i
].sp
);
1160 restore_flags(flags
);
1164 hscx_l2l1(struct PStack
*st
, int pr
, void *arg
)
1166 struct sk_buff
*skb
= arg
;
1167 struct IsdnCardState
*sp
= (struct IsdnCardState
*) st
->l1
.hardware
;
1168 struct HscxState
*hsp
= sp
->hs
+ st
->l1
.hscx
;
1176 skb_queue_tail(&hsp
->squeue
, skb
);
1177 restore_flags(flags
);
1179 restore_flags(flags
);
1182 sp
->hscx_fill_fifo(hsp
);
1185 case (PH_DATA_PULLED
):
1187 printk(KERN_WARNING
"hscx_l2l1: this shouldn't happen\n");
1192 sp
->hscx_fill_fifo(hsp
);
1194 case (PH_REQUEST_PULL
):
1196 st
->l1
.requestpull
= 0;
1197 st
->l1
.l1l2(st
, PH_PULL_ACK
, NULL
);
1199 st
->l1
.requestpull
= !0;
1204 extern struct IsdnBuffers
*tracebuf
;
1207 hscx_l2l1discardq(struct PStack
*st
, int pr
, void *heldby
,
1210 struct IsdnCardState
*sp
= (struct IsdnCardState
*)
1212 struct HscxState
*hsp
= sp
->hs
+ st
->l1
.hscx
;
1213 struct sk_buff
*skb
;
1216 if (hsp
->magic
!= 301270) {
1217 printk(KERN_DEBUG
"hscx_discardq magic not 301270\n");
1222 while ((skb
= skb_dequeue(&hsp
->squeue
))) {
1224 dev_kfree_skb(skb
, FREE_WRITE
);
1229 open_hscxstate(struct IsdnCardState
*sp
,
1232 struct HscxState
*hsp
= sp
->hs
+ hscx
;
1235 if (!(hsp
->rcvbuf
= kmalloc(HSCX_BUFMAX
, GFP_ATOMIC
))) {
1237 "HiSax: No memory for hscx_rcvbuf\n");
1240 skb_queue_head_init(&hsp
->rqueue
);
1241 skb_queue_head_init(&hsp
->squeue
);
1253 hscx_manl1(struct PStack
*st
, int pr
,
1256 struct IsdnCardState
*sp
= (struct IsdnCardState
*) st
->l1
.hardware
;
1257 struct HscxState
*hsp
= sp
->hs
+ st
->l1
.hscx
;
1262 sp
->modehscx(hsp
, st
->l1
.hscxmode
, st
->l1
.hscxchannel
);
1263 st
->l1
.l1man(st
, PH_ACTIVATE
, NULL
);
1265 case (PH_DEACTIVATE
):
1267 sp
->modehscx(hsp
, 0, 0);
1275 setstack_hscx(struct PStack
*st
, struct HscxState
*hs
)
1277 if (open_hscxstate(st
->l1
.hardware
, hs
->hscx
))
1280 st
->l1
.hscx
= hs
->hscx
;
1281 st
->l2
.l2l1
= hscx_l2l1
;
1282 st
->ma
.manl1
= hscx_manl1
;
1283 st
->l2
.l2l1discardq
= hscx_l2l1discardq
;
1285 st
->l1
.act_state
= 0;
1286 st
->l1
.requestpull
= 0;
1293 HiSax_reportcard(int cardnr
)
1295 struct IsdnCardState
*sp
= cards
[cardnr
].sp
;
1297 printk(KERN_DEBUG
"HiSax: reportcard No %d\n", cardnr
+ 1);
1298 printk(KERN_DEBUG
"HiSax: Type %s\n", CardType
[sp
->typ
]);
1299 printk(KERN_DEBUG
"HiSax: debuglevel %x\n", sp
->debug
);
1300 printk(KERN_DEBUG
"HiSax: HiSax_reportcard address 0x%lX\n",
1301 (ulong
) & HiSax_reportcard
);
1304 #ifdef L2FRAME_DEBUG /* psa */
1309 switch (cmd
& ~0x10) {
1334 return "invalid command";
1338 static char tmp
[20];
1341 l2frames(u_char
* ptr
)
1343 switch (ptr
[2] & ~0x10) {
1347 sprintf(tmp
, "%s[%d](nr %d)", l2cmd(ptr
[2]), ptr
[3] & 1, ptr
[3] >> 1);
1356 sprintf(tmp
, "%s[%d]", l2cmd(ptr
[2]), (ptr
[2] & 0x10) >> 4);
1359 if (!(ptr
[2] & 1)) {
1360 sprintf(tmp
, "I[%d](ns %d, nr %d)", ptr
[3] & 1, ptr
[2] >> 1, ptr
[3] >> 1);
1363 return "invalid command";
1371 Logl2Frame(struct IsdnCardState
*sp
, struct sk_buff
*skb
, char *buf
, int dir
)
1378 if (ptr
[0] & 1 || !(ptr
[1] & 1))
1379 debugl1(sp
, "Addres not LAPD");
1381 sprintf(tmp
, "%s %s: %s%c (sapi %d, tei %d)",
1382 (dir
? "<-" : "->"), buf
, l2frames(ptr
),
1383 ((ptr
[0] & 2) >> 1) == dir
? 'C' : 'R', ptr
[0] >> 2, ptr
[1] >> 1);