patch-2.2.11 linux/drivers/isdn/hisax/isac.c
Next file: linux/drivers/isdn/hisax/isac.h
Previous file: linux/drivers/isdn/hisax/ipac.h
Back to the patch index
Back to the overall index
- Lines: 773
- Date:
Mon Aug 9 12:04:39 1999
- Orig file:
v2.2.10/linux/drivers/isdn/hisax/isac.c
- Orig date:
Thu May 14 18:43:27 1998
diff -u --recursive --new-file v2.2.10/linux/drivers/isdn/hisax/isac.c linux/drivers/isdn/hisax/isac.c
@@ -1,11 +1,43 @@
-/* $Id: isac.c,v 1.12 1998/02/12 23:07:40 keil Exp $
+/* $Id: isac.c,v 1.21 1999/07/12 21:05:17 keil Exp $
* isac.c ISAC specific routines
*
- * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ * Author Karsten Keil (keil@isdn4linux.de)
*
+ * This file is (c) under GNU PUBLIC LICENSE
+ * For changes and modifications please read
+ * ../../../Documentation/isdn/HiSax.cert
*
* $Log: isac.c,v $
+ * Revision 1.21 1999/07/12 21:05:17 keil
+ * fix race in IRQ handling
+ * added watchdog for lost IRQs
+ *
+ * Revision 1.20 1999/07/09 08:23:06 keil
+ * Fix ISAC lost TX IRQ handling
+ *
+ * Revision 1.19 1999/07/01 08:11:43 keil
+ * Common HiSax version for 2.0, 2.1, 2.2 and 2.3 kernel
+ *
+ * Revision 1.18 1998/11/15 23:54:51 keil
+ * changes from 2.0
+ *
+ * Revision 1.17 1998/08/13 23:36:37 keil
+ * HiSax 3.1 - don't work stable with current LinkLevel
+ *
+ * Revision 1.16 1998/05/25 12:58:01 keil
+ * HiSax golden code from certification, Don't use !!!
+ * No leased lines, no X75, but many changes.
+ *
+ * Revision 1.15 1998/04/15 16:45:32 keil
+ * new init code
+ *
+ * Revision 1.14 1998/04/10 10:35:26 paul
+ * fixed (silly?) warnings from egcs on Alpha.
+ *
+ * Revision 1.13 1998/03/07 22:57:01 tsbogend
+ * made HiSax working on Linux/Alpha
+ *
* Revision 1.12 1998/02/12 23:07:40 keil
* change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
*
@@ -47,6 +79,7 @@
#define __NO_VERSION__
#include "hisax.h"
#include "isac.h"
+#include "arcofi.h"
#include "isdnl1.h"
#include <linux/interrupt.h>
@@ -63,60 +96,47 @@
int val;
val = cs->readisac(cs, ISAC_RBCH);
- printk(KERN_INFO "%s ISAC version : %s\n", s, ISACVer[(val >> 5) & 3]);
+ printk(KERN_INFO "%s ISAC version (%x): %s\n", s, val, ISACVer[(val >> 5) & 3]);
}
static void
ph_command(struct IsdnCardState *cs, unsigned int command)
{
- if (cs->debug & L1_DEB_ISAC) {
- char tmp[32];
- sprintf(tmp, "ph_command %x", command);
- debugl1(cs, tmp);
- }
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ph_command %x", command);
cs->writeisac(cs, ISAC_CIX0, (command << 2) | 3);
}
-static void
-manl1_msg(struct IsdnCardState *cs, int msg, void *arg) {
- struct PStack *st;
-
- st = cs->stlist;
- while (st) {
- st->ma.manl1(st, msg, arg);
- st = st->next;
- }
-}
static void
isac_new_ph(struct IsdnCardState *cs)
{
- switch (cs->ph_state) {
+ switch (cs->dc.isac.ph_state) {
case (ISAC_IND_RS):
case (ISAC_IND_EI):
ph_command(cs, ISAC_CMD_DUI);
- manl1_msg(cs, PH_RESET_IND, NULL);
+ l1_msg(cs, HW_RESET | INDICATION, NULL);
break;
case (ISAC_IND_DID):
- manl1_msg(cs, PH_DEACT_CNF, NULL);
+ l1_msg(cs, HW_DEACTIVATE | CONFIRM, NULL);
break;
case (ISAC_IND_DR):
- manl1_msg(cs, PH_DEACT_IND, NULL);
+ l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL);
break;
case (ISAC_IND_PU):
- manl1_msg(cs, PH_POWERUP_CNF, NULL);
+ l1_msg(cs, HW_POWERUP | CONFIRM, NULL);
break;
case (ISAC_IND_RSY):
- manl1_msg(cs, PH_RSYNC_IND, NULL);
+ l1_msg(cs, HW_RSYNC | INDICATION, NULL);
break;
case (ISAC_IND_ARD):
- manl1_msg(cs, PH_INFO2_IND, NULL);
+ l1_msg(cs, HW_INFO2 | INDICATION, NULL);
break;
case (ISAC_IND_AI8):
- manl1_msg(cs, PH_I4_P8_IND, NULL);
+ l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL);
break;
case (ISAC_IND_AI10):
- manl1_msg(cs, PH_I4_P10_IND, NULL);
+ l1_msg(cs, HW_INFO4_P10 | INDICATION, NULL);
break;
default:
break;
@@ -130,13 +150,12 @@
if (!cs)
return;
-
if (test_and_clear_bit(D_CLEARBUSY, &cs->event)) {
if (cs->debug)
debugl1(cs, "D-Channel Busy cleared");
stptr = cs->stlist;
while (stptr != NULL) {
- stptr->l1.l1l2(stptr, PH_PAUSE_CNF, NULL);
+ stptr->l1.l1l2(stptr, PH_PAUSE | CONFIRM, NULL);
stptr = stptr->next;
}
}
@@ -146,14 +165,10 @@
DChannel_proc_rcv(cs);
if (test_and_clear_bit(D_XMTBUFREADY, &cs->event))
DChannel_proc_xmt(cs);
- if (test_and_clear_bit(D_RX_MON0, &cs->event))
- test_and_set_bit(HW_MON0_TX_END, &cs->HW_Flags);
if (test_and_clear_bit(D_RX_MON1, &cs->event))
- test_and_set_bit(HW_MON1_TX_END, &cs->HW_Flags);
- if (test_and_clear_bit(D_TX_MON0, &cs->event))
- test_and_set_bit(HW_MON0_RX_END, &cs->HW_Flags);
+ arcofi_fsm(cs, ARCOFI_RX_END, NULL);
if (test_and_clear_bit(D_TX_MON1, &cs->event))
- test_and_set_bit(HW_MON1_RX_END, &cs->HW_Flags);
+ arcofi_fsm(cs, ARCOFI_TX_END, NULL);
}
void
@@ -165,13 +180,10 @@
if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO))
debugl1(cs, "isac_empty_fifo");
- if ((cs->rcvidx + count) >= MAX_DFRAME_LEN) {
- if (cs->debug & L1_DEB_WARN) {
- char tmp[40];
- sprintf(tmp, "isac_empty_fifo overrun %d",
+ if ((cs->rcvidx + count) >= MAX_DFRAME_LEN_L1) {
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "isac_empty_fifo overrun %d",
cs->rcvidx + count);
- debugl1(cs, tmp);
- }
cs->writeisac(cs, ISAC_CMDR, 0x80);
cs->rcvidx = 0;
return;
@@ -184,12 +196,11 @@
cs->writeisac(cs, ISAC_CMDR, 0x80);
restore_flags(flags);
if (cs->debug & L1_DEB_ISAC_FIFO) {
- char tmp[128];
- char *t = tmp;
+ char *t = cs->dlog;
t += sprintf(t, "isac_empty_fifo cnt %d", count);
QuickHex(t, ptr, count);
- debugl1(cs, tmp);
+ debugl1(cs, cs->dlog);
}
}
@@ -231,12 +242,11 @@
cs->dbusytimer.expires = jiffies + ((DBUSY_TIMER_VALUE * HZ)/1000);
add_timer(&cs->dbusytimer);
if (cs->debug & L1_DEB_ISAC_FIFO) {
- char tmp[128];
- char *t = tmp;
+ char *t = cs->dlog;
t += sprintf(t, "isac_fill_fifo cnt %d", count);
QuickHex(t, ptr, count);
- debugl1(cs, tmp);
+ debugl1(cs, cs->dlog);
}
}
@@ -255,12 +265,9 @@
struct sk_buff *skb;
unsigned int count;
long flags;
- char tmp[32];
- if (cs->debug & L1_DEB_ISAC) {
- sprintf(tmp, "ISAC interrupt %x", val);
- debugl1(cs, tmp);
- }
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ISAC interrupt %x", val);
if (val & 0x80) { /* RME */
exval = cs->readisac(cs, ISAC_RSTA);
if ((exval & 0x70) != 0x20) {
@@ -283,6 +290,7 @@
if (!(skb = alloc_skb(count, GFP_ATOMIC)))
printk(KERN_WARNING "HiSax: D receive out of memory\n");
else {
+ SET_SKB_FREE(skb);
memcpy(skb_put(skb, count), cs->rcvbuf, count);
skb_queue_tail(&cs->rq, skb);
}
@@ -310,7 +318,7 @@
isac_fill_fifo(cs);
goto afterXPR;
} else {
- dev_kfree_skb(cs->tx_skb);
+ idev_kfree_skb(cs->tx_skb, FREE_WRITE);
cs->tx_cnt = 0;
cs->tx_skb = NULL;
}
@@ -323,12 +331,20 @@
}
afterXPR:
if (val & 0x04) { /* CISQ */
- cs->ph_state = (cs->readisac(cs, ISAC_CIX0) >> 2) & 0xf;
- if (cs->debug & L1_DEB_ISAC) {
- sprintf(tmp, "ph_state change %x", cs->ph_state);
- debugl1(cs, tmp);
+ exval = cs->readisac(cs, ISAC_CIR0);
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ISAC CIR0 %02X", exval );
+ if (exval & 2) {
+ cs->dc.isac.ph_state = (exval >> 2) & 0xf;
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ph_state change %x", cs->dc.isac.ph_state);
+ isac_sched_event(cs, D_L1STATECHANGE);
+ }
+ if (exval & 1) {
+ exval = cs->readisac(cs, ISAC_CIR1);
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ISAC CIR1 %02X", exval );
}
- isac_sched_event(cs, D_L1STATECHANGE);
}
if (val & 0x02) { /* SIN */
/* never */
@@ -337,131 +353,149 @@
}
if (val & 0x01) { /* EXI */
exval = cs->readisac(cs, ISAC_EXIR);
- if (cs->debug & L1_DEB_WARN) {
- sprintf(tmp, "ISAC EXIR %02x", exval);
- debugl1(cs, tmp);
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "ISAC EXIR %02x", exval);
+ if (exval & 0x80) { /* XMR */
+ debugl1(cs, "ISAC XMR");
+ printk(KERN_WARNING "HiSax: ISAC XMR\n");
}
- if (exval & 0x04) {
- v1 = cs->readisac(cs, ISAC_MOSR);
- if (cs->debug & L1_DEB_WARN) {
- sprintf(tmp, "ISAC MOSR %02x", v1);
- debugl1(cs, tmp);
+ if (exval & 0x40) { /* XDU */
+ debugl1(cs, "ISAC XDU");
+ printk(KERN_WARNING "HiSax: ISAC XDU\n");
+ if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags))
+ del_timer(&cs->dbusytimer);
+ if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags))
+ isac_sched_event(cs, D_CLEARBUSY);
+ if (cs->tx_skb) { /* Restart frame */
+ skb_push(cs->tx_skb, cs->tx_cnt);
+ cs->tx_cnt = 0;
+ isac_fill_fifo(cs);
+ } else {
+ printk(KERN_WARNING "HiSax: ISAC XDU no skb\n");
+ debugl1(cs, "ISAC XDU no skb");
}
+ }
+ if (exval & 0x04) { /* MOS */
+ v1 = cs->readisac(cs, ISAC_MOSR);
+ if (cs->debug & L1_DEB_MONITOR)
+ debugl1(cs, "ISAC MOSR %02x", v1);
#if ARCOFI_USE
if (v1 & 0x08) {
- if (!cs->mon_rx) {
- if (!(cs->mon_rx = kmalloc(MAX_MON_FRAME, GFP_ATOMIC))) {
+ if (!cs->dc.isac.mon_rx) {
+ if (!(cs->dc.isac.mon_rx = kmalloc(MAX_MON_FRAME, GFP_ATOMIC))) {
if (cs->debug & L1_DEB_WARN)
debugl1(cs, "ISAC MON RX out of memory!");
- cs->mocr &= 0xf0;
- cs->mocr |= 0x0a;
- cs->writeisac(cs, ISAC_MOCR, cs->mocr);
+ cs->dc.isac.mocr &= 0xf0;
+ cs->dc.isac.mocr |= 0x0a;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
goto afterMONR0;
} else
- cs->mon_rxp = 0;
+ cs->dc.isac.mon_rxp = 0;
}
- if (cs->mon_rxp >= MAX_MON_FRAME) {
- cs->mocr &= 0xf0;
- cs->mocr |= 0x0a;
- cs->writeisac(cs, ISAC_MOCR, cs->mocr);
- cs->mon_rxp = 0;
+ if (cs->dc.isac.mon_rxp >= MAX_MON_FRAME) {
+ cs->dc.isac.mocr &= 0xf0;
+ cs->dc.isac.mocr |= 0x0a;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
+ cs->dc.isac.mon_rxp = 0;
if (cs->debug & L1_DEB_WARN)
debugl1(cs, "ISAC MON RX overflow!");
goto afterMONR0;
}
- cs->mon_rx[cs->mon_rxp++] = cs->readisac(cs, ISAC_MOR0);
- if (cs->debug & L1_DEB_WARN) {
- sprintf(tmp, "ISAC MOR0 %02x", cs->mon_rx[cs->mon_rxp -1]);
- debugl1(cs, tmp);
- }
- if (cs->mon_rxp == 1) {
- cs->mocr |= 0x04;
- cs->writeisac(cs, ISAC_MOCR, cs->mocr);
+ cs->dc.isac.mon_rx[cs->dc.isac.mon_rxp++] = cs->readisac(cs, ISAC_MOR0);
+ if (cs->debug & L1_DEB_MONITOR)
+ debugl1(cs, "ISAC MOR0 %02x", cs->dc.isac.mon_rx[cs->dc.isac.mon_rxp -1]);
+ if (cs->dc.isac.mon_rxp == 1) {
+ cs->dc.isac.mocr |= 0x04;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
}
}
afterMONR0:
if (v1 & 0x80) {
- if (!cs->mon_rx) {
- if (!(cs->mon_rx = kmalloc(MAX_MON_FRAME, GFP_ATOMIC))) {
+ if (!cs->dc.isac.mon_rx) {
+ if (!(cs->dc.isac.mon_rx = kmalloc(MAX_MON_FRAME, GFP_ATOMIC))) {
if (cs->debug & L1_DEB_WARN)
debugl1(cs, "ISAC MON RX out of memory!");
- cs->mocr &= 0x0f;
- cs->mocr |= 0xa0;
- cs->writeisac(cs, ISAC_MOCR, cs->mocr);
+ cs->dc.isac.mocr &= 0x0f;
+ cs->dc.isac.mocr |= 0xa0;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
goto afterMONR1;
} else
- cs->mon_rxp = 0;
+ cs->dc.isac.mon_rxp = 0;
}
- if (cs->mon_rxp >= MAX_MON_FRAME) {
- cs->mocr &= 0x0f;
- cs->mocr |= 0xa0;
- cs->writeisac(cs, ISAC_MOCR, cs->mocr);
- cs->mon_rxp = 0;
+ if (cs->dc.isac.mon_rxp >= MAX_MON_FRAME) {
+ cs->dc.isac.mocr &= 0x0f;
+ cs->dc.isac.mocr |= 0xa0;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
+ cs->dc.isac.mon_rxp = 0;
if (cs->debug & L1_DEB_WARN)
debugl1(cs, "ISAC MON RX overflow!");
goto afterMONR1;
}
- cs->mon_rx[cs->mon_rxp++] = cs->readisac(cs, ISAC_MOR1);
- if (cs->debug & L1_DEB_WARN) {
- sprintf(tmp, "ISAC MOR1 %02x", cs->mon_rx[cs->mon_rxp -1]);
- debugl1(cs, tmp);
- }
- if (cs->mon_rxp == 1) {
- cs->mocr |= 0x40;
- cs->writeisac(cs, ISAC_MOCR, cs->mocr);
- }
+ cs->dc.isac.mon_rx[cs->dc.isac.mon_rxp++] = cs->readisac(cs, ISAC_MOR1);
+ if (cs->debug & L1_DEB_MONITOR)
+ debugl1(cs, "ISAC MOR1 %02x", cs->dc.isac.mon_rx[cs->dc.isac.mon_rxp -1]);
+ cs->dc.isac.mocr |= 0x40;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
}
afterMONR1:
if (v1 & 0x04) {
- cs->mocr &= 0xf0;
- cs->mocr |= 0x0a;
- cs->writeisac(cs, ISAC_MOCR, cs->mocr);
+ cs->dc.isac.mocr &= 0xf0;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
+ cs->dc.isac.mocr |= 0x0a;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
isac_sched_event(cs, D_RX_MON0);
}
if (v1 & 0x40) {
- cs->mocr &= 0x0f;
- cs->mocr |= 0xa0;
- cs->writeisac(cs, ISAC_MOCR, cs->mocr);
+ cs->dc.isac.mocr &= 0x0f;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
+ cs->dc.isac.mocr |= 0xa0;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
isac_sched_event(cs, D_RX_MON1);
}
if (v1 & 0x02) {
- if (!cs->mon_tx) {
- cs->mocr &= 0xf0;
- cs->mocr |= 0x0a;
- cs->writeisac(cs, ISAC_MOCR, cs->mocr);
+ if ((!cs->dc.isac.mon_tx) || (cs->dc.isac.mon_txc &&
+ (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc) &&
+ !(v1 & 0x08))) {
+ cs->dc.isac.mocr &= 0xf0;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
+ cs->dc.isac.mocr |= 0x0a;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
+ if (cs->dc.isac.mon_txc &&
+ (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc))
+ isac_sched_event(cs, D_TX_MON0);
goto AfterMOX0;
}
- if (cs->mon_txp >= cs->mon_txc) {
- if (cs->mon_txc)
- isac_sched_event(cs, D_TX_MON0);
+ if (cs->dc.isac.mon_txc && (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc)) {
+ isac_sched_event(cs, D_TX_MON0);
goto AfterMOX0;
}
cs->writeisac(cs, ISAC_MOX0,
- cs->mon_tx[cs->mon_txp++]);
- if (cs->debug & L1_DEB_WARN) {
- sprintf(tmp, "ISAC %02x -> MOX0", cs->mon_tx[cs->mon_txp -1]);
- debugl1(cs, tmp);
- }
+ cs->dc.isac.mon_tx[cs->dc.isac.mon_txp++]);
+ if (cs->debug & L1_DEB_MONITOR)
+ debugl1(cs, "ISAC %02x -> MOX0", cs->dc.isac.mon_tx[cs->dc.isac.mon_txp -1]);
}
AfterMOX0:
if (v1 & 0x20) {
- if (!cs->mon_tx) {
- cs->mocr &= 0x0f;
- cs->mocr |= 0xa0;
- cs->writeisac(cs, ISAC_MOCR, cs->mocr);
+ if ((!cs->dc.isac.mon_tx) || (cs->dc.isac.mon_txc &&
+ (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc) &&
+ !(v1 & 0x80))) {
+ cs->dc.isac.mocr &= 0x0f;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
+ cs->dc.isac.mocr |= 0xa0;
+ cs->writeisac(cs, ISAC_MOCR, cs->dc.isac.mocr);
+ if (cs->dc.isac.mon_txc &&
+ (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc))
+ isac_sched_event(cs, D_TX_MON1);
goto AfterMOX1;
}
- if (cs->mon_txp >= cs->mon_txc) {
- if (cs->mon_txc)
- isac_sched_event(cs, D_TX_MON1);
+ if (cs->dc.isac.mon_txc && (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc)) {
+ isac_sched_event(cs, D_TX_MON1);
goto AfterMOX1;
}
cs->writeisac(cs, ISAC_MOX1,
- cs->mon_tx[cs->mon_txp++]);
- if (cs->debug & L1_DEB_WARN) {
- sprintf(tmp, "ISAC %02x -> MOX1", cs->mon_tx[cs->mon_txp -1]);
- debugl1(cs, tmp);
- }
+ cs->dc.isac.mon_tx[cs->dc.isac.mon_txp++]);
+ if (cs->debug & L1_DEB_MONITOR)
+ debugl1(cs, "ISAC %02x -> MOX1", cs->dc.isac.mon_tx[cs->dc.isac.mon_txp -1]);
}
AfterMOX1:
#endif
@@ -470,14 +504,18 @@
}
static void
-ISAC_l2l1(struct PStack *st, int pr, void *arg)
+ISAC_l1hw(struct PStack *st, int pr, void *arg)
{
struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware;
struct sk_buff *skb = arg;
- char str[64];
+ int val;
switch (pr) {
- case (PH_DATA_REQ):
+ case (PH_DATA |REQUEST):
+ if (cs->debug & DEB_DLOG_HEX)
+ LogFrame(cs, skb->data, skb->len);
+ if (cs->debug & DEB_DLOG_VERBOSE)
+ dlogframe(cs, skb, 0);
if (cs->tx_skb) {
skb_queue_tail(&cs->sq, skb);
#ifdef L2FRAME_DEBUG /* psa */
@@ -485,12 +523,6 @@
Logl2Frame(cs, skb, "PH_DATA Queued", 0);
#endif
} else {
- if ((cs->dlogflag) && (!(skb->data[2] & 1))) { /* I-FRAME */
- LogFrame(cs, skb->data, skb->len);
- sprintf(str, "Q.931 frame user->network tei %d", st->l2.tei);
- dlogframe(cs, skb->data + 4, skb->len - 4,
- str);
- }
cs->tx_skb = skb;
cs->tx_cnt = 0;
#ifdef L2FRAME_DEBUG /* psa */
@@ -500,19 +532,17 @@
isac_fill_fifo(cs);
}
break;
- case (PH_PULL_IND):
+ case (PH_PULL |INDICATION):
if (cs->tx_skb) {
if (cs->debug & L1_DEB_WARN)
debugl1(cs, " l2l1 tx_skb exist this shouldn't happen");
skb_queue_tail(&cs->sq, skb);
break;
}
- if ((cs->dlogflag) && (!(skb->data[2] & 1))) { /* I-FRAME */
+ if (cs->debug & DEB_DLOG_HEX)
LogFrame(cs, skb->data, skb->len);
- sprintf(str, "Q.931 frame user->network tei %d", st->l2.tei);
- dlogframe(cs, skb->data + 4, skb->len - 4,
- str);
- }
+ if (cs->debug & DEB_DLOG_VERBOSE)
+ dlogframe(cs, skb, 0);
cs->tx_skb = skb;
cs->tx_cnt = 0;
#ifdef L2FRAME_DEBUG /* psa */
@@ -521,46 +551,36 @@
#endif
isac_fill_fifo(cs);
break;
- case (PH_PULL_REQ):
+ case (PH_PULL | REQUEST):
#ifdef L2FRAME_DEBUG /* psa */
if (cs->debug & L1_DEB_LAPD)
debugl1(cs, "-> PH_REQUEST_PULL");
#endif
if (!cs->tx_skb) {
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
- st->l1.l1l2(st, PH_PULL_CNF, NULL);
+ st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
break;
- }
-}
-
-void
-isac_l1cmd(struct IsdnCardState *cs, int msg, void *arg)
-{
- u_char val;
- char tmp[32];
-
- switch(msg) {
- case PH_RESET_REQ:
- if ((cs->ph_state == ISAC_IND_EI) ||
- (cs->ph_state == ISAC_IND_DR) ||
- (cs->ph_state == ISAC_IND_RS))
+ case (HW_RESET | REQUEST):
+ if ((cs->dc.isac.ph_state == ISAC_IND_EI) ||
+ (cs->dc.isac.ph_state == ISAC_IND_DR) ||
+ (cs->dc.isac.ph_state == ISAC_IND_RS))
ph_command(cs, ISAC_CMD_TIM);
else
ph_command(cs, ISAC_CMD_RS);
break;
- case PH_ENABLE_REQ:
+ case (HW_ENABLE | REQUEST):
ph_command(cs, ISAC_CMD_TIM);
break;
- case PH_INFO3_REQ:
+ case (HW_INFO3 | REQUEST):
ph_command(cs, ISAC_CMD_AR8);
break;
- case PH_TESTLOOP_REQ:
+ case (HW_TESTLOOP | REQUEST):
val = 0;
- if (1 & (int) arg)
+ if (1 & (long) arg)
val |= 0x0c;
- if (2 & (int) arg)
+ if (2 & (long) arg)
val |= 0x3;
if (test_bit(HW_IOM1, &cs->HW_Flags)) {
/* IOM 1 Mode */
@@ -580,11 +600,21 @@
cs->writeisac(cs, ISAC_ADF1, 0x0);
}
break;
- default:
- if (cs->debug & L1_DEB_WARN) {
- sprintf(tmp, "isac_l1cmd unknown %4x", msg);
- debugl1(cs, tmp);
+ case (HW_DEACTIVATE | RESPONSE):
+ discard_queue(&cs->rq);
+ discard_queue(&cs->sq);
+ if (cs->tx_skb) {
+ idev_kfree_skb(cs->tx_skb, FREE_WRITE);
+ cs->tx_skb = NULL;
}
+ if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags))
+ del_timer(&cs->dbusytimer);
+ if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags))
+ isac_sched_event(cs, D_CLEARBUSY);
+ break;
+ default:
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "isac_l1hw unknown %04x", pr);
break;
}
}
@@ -592,23 +622,53 @@
void
setstack_isac(struct PStack *st, struct IsdnCardState *cs)
{
- st->l2.l2l1 = ISAC_l2l1;
+ st->l1.l1hw = ISAC_l1hw;
+}
+
+void
+DC_Close_isac(struct IsdnCardState *cs) {
+ if (cs->dc.isac.mon_rx) {
+ kfree(cs->dc.isac.mon_rx);
+ cs->dc.isac.mon_rx = NULL;
+ }
+ if (cs->dc.isac.mon_tx) {
+ kfree(cs->dc.isac.mon_tx);
+ cs->dc.isac.mon_tx = NULL;
+ }
}
static void
dbusy_timer_handler(struct IsdnCardState *cs)
{
struct PStack *stptr;
+ int rbch, star;
if (test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) {
- if (cs->debug)
- debugl1(cs, "D-Channel Busy");
- test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags);
- stptr = cs->stlist;
-
- while (stptr != NULL) {
- stptr->l1.l1l2(stptr, PH_PAUSE_IND, NULL);
- stptr = stptr->next;
+ rbch = cs->readisac(cs, ISAC_RBCH);
+ star = cs->readisac(cs, ISAC_STAR);
+ if (cs->debug)
+ debugl1(cs, "D-Channel Busy RBCH %02x STAR %02x",
+ rbch, star);
+ if (rbch & ISAC_RBCH_XAC) { /* D-Channel Busy */
+ test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags);
+ stptr = cs->stlist;
+ while (stptr != NULL) {
+ stptr->l1.l1l2(stptr, PH_PAUSE | INDICATION, NULL);
+ stptr = stptr->next;
+ }
+ } else {
+ /* discard frame; reset transceiver */
+ test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags);
+ if (cs->tx_skb) {
+ idev_kfree_skb(cs->tx_skb, FREE_WRITE);
+ cs->tx_cnt = 0;
+ cs->tx_skb = NULL;
+ } else {
+ printk(KERN_WARNING "HiSax: ISAC D-Channel Busy no skb\n");
+ debugl1(cs, "D-Channel Busy no skb");
+ }
+ cs->writeisac(cs, ISAC_CMDR, 0x01); /* Transmitter reset */
+ cs->irq_func(cs->irq, cs, NULL);
}
}
}
@@ -617,13 +677,15 @@
initisac(struct IsdnCardState *cs))
{
cs->tqueue.routine = (void *) (void *) isac_bh;
- cs->l1cmd = isac_l1cmd;
cs->setstack_d = setstack_isac;
+ cs->DC_Close = DC_Close_isac;
+ cs->dc.isac.mon_tx = NULL;
+ cs->dc.isac.mon_rx = NULL;
cs->dbusytimer.function = (void *) dbusy_timer_handler;
cs->dbusytimer.data = (long) cs;
init_timer(&cs->dbusytimer);
cs->writeisac(cs, ISAC_MASK, 0xff);
- cs->mocr = 0xaa;
+ cs->dc.isac.mocr = 0xaa;
if (test_bit(HW_IOM1, &cs->HW_Flags)) {
/* IOM 1 Mode */
cs->writeisac(cs, ISAC_ADF2, 0x0);
@@ -633,7 +695,9 @@
cs->writeisac(cs, ISAC_MODE, 0xc9);
} else {
/* IOM 2 Mode */
- cs->writeisac(cs, ISAC_ADF2, 0x80);
+ if (!cs->dc.isac.adf2)
+ cs->dc.isac.adf2 = 0x80;
+ cs->writeisac(cs, ISAC_ADF2, cs->dc.isac.adf2);
cs->writeisac(cs, ISAC_SQXR, 0x2f);
cs->writeisac(cs, ISAC_SPCR, 0x00);
cs->writeisac(cs, ISAC_STCR, 0x70);
@@ -648,35 +712,24 @@
HISAX_INITFUNC(void
clear_pending_isac_ints(struct IsdnCardState *cs))
{
- int val;
- char tmp[64];
+ int val, eval;
val = cs->readisac(cs, ISAC_STAR);
- sprintf(tmp, "ISAC STAR %x", val);
- debugl1(cs, tmp);
+ debugl1(cs, "ISAC STAR %x", val);
val = cs->readisac(cs, ISAC_MODE);
- sprintf(tmp, "ISAC MODE %x", val);
- debugl1(cs, tmp);
+ debugl1(cs, "ISAC MODE %x", val);
val = cs->readisac(cs, ISAC_ADF2);
- sprintf(tmp, "ISAC ADF2 %x", val);
- debugl1(cs, tmp);
+ debugl1(cs, "ISAC ADF2 %x", val);
val = cs->readisac(cs, ISAC_ISTA);
- sprintf(tmp, "ISAC ISTA %x", val);
- debugl1(cs, tmp);
+ debugl1(cs, "ISAC ISTA %x", val);
if (val & 0x01) {
- val = cs->readisac(cs, ISAC_EXIR);
- sprintf(tmp, "ISAC EXIR %x", val);
- debugl1(cs, tmp);
- } else if (val & 0x04) {
- val = cs->readisac(cs, ISAC_CIR0);
- sprintf(tmp, "ISAC CIR0 %x", val);
- debugl1(cs, tmp);
- cs->ph_state = (val >> 2) & 0xf;
- } else {
- cs->ph_state = (cs->readisac(cs, ISAC_CIX0) >> 2) & 0xf;
+ eval = cs->readisac(cs, ISAC_EXIR);
+ debugl1(cs, "ISAC EXIR %x", eval);
}
+ val = cs->readisac(cs, ISAC_CIR0);
+ debugl1(cs, "ISAC CIR0 %x", val);
+ cs->dc.isac.ph_state = (val >> 2) & 0xf;
isac_sched_event(cs, D_L1STATECHANGE);
+ /* Disable all IRQ */
cs->writeisac(cs, ISAC_MASK, 0xFF);
- cs->writeisac(cs, ISAC_MASK, 0);
- cs->writeisac(cs, ISAC_CMDR, 0x41);
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)