summaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hisax
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/hisax')
-rw-r--r--drivers/isdn/hisax/Makefile95
-rw-r--r--drivers/isdn/hisax/amd7930.c768
-rw-r--r--drivers/isdn/hisax/arcofi.c51
-rw-r--r--drivers/isdn/hisax/arcofi.h17
-rw-r--r--drivers/isdn/hisax/asuscom.c292
-rw-r--r--drivers/isdn/hisax/avm_a1.c966
-rw-r--r--drivers/isdn/hisax/callc.c1743
-rw-r--r--drivers/isdn/hisax/config.c457
-rw-r--r--drivers/isdn/hisax/diva.c465
-rw-r--r--drivers/isdn/hisax/elsa.c1921
-rw-r--r--drivers/isdn/hisax/fsm.c53
-rw-r--r--drivers/isdn/hisax/hfc_2bds0.c1297
-rw-r--r--drivers/isdn/hisax/hfc_2bds0.h131
-rw-r--r--drivers/isdn/hisax/hfc_2bs0.c615
-rw-r--r--drivers/isdn/hisax/hfc_2bs0.h62
-rw-r--r--drivers/isdn/hisax/hisax.h940
-rw-r--r--drivers/isdn/hisax/hscx.c280
-rw-r--r--drivers/isdn/hisax/hscx.h46
-rw-r--r--drivers/isdn/hisax/hscx_irq.c320
-rw-r--r--drivers/isdn/hisax/ipac.h35
-rw-r--r--drivers/isdn/hisax/isac.c679
-rw-r--r--drivers/isdn/hisax/isac.h74
-rw-r--r--drivers/isdn/hisax/isdnl1.c1621
-rw-r--r--drivers/isdn/hisax/isdnl1.h52
-rw-r--r--drivers/isdn/hisax/isdnl2.c1614
-rw-r--r--drivers/isdn/hisax/isdnl3.c229
-rw-r--r--drivers/isdn/hisax/isdnl3.h27
-rw-r--r--drivers/isdn/hisax/ix1_micro.c925
-rw-r--r--drivers/isdn/hisax/l3_1tr6.c610
-rw-r--r--drivers/isdn/hisax/l3_1tr6.h18
-rw-r--r--drivers/isdn/hisax/l3dss1.c1409
-rw-r--r--drivers/isdn/hisax/l3dss1.h71
-rw-r--r--drivers/isdn/hisax/lmgr.c58
-rw-r--r--drivers/isdn/hisax/mic.c284
-rw-r--r--drivers/isdn/hisax/netjet.c1108
-rw-r--r--drivers/isdn/hisax/niccy.c354
-rw-r--r--drivers/isdn/hisax/q931.c51
-rw-r--r--drivers/isdn/hisax/rawhdlc.c539
-rw-r--r--drivers/isdn/hisax/rawhdlc.h26
-rw-r--r--drivers/isdn/hisax/sedlbauer.c356
-rw-r--r--drivers/isdn/hisax/sportster.c291
-rw-r--r--drivers/isdn/hisax/tei.c599
-rw-r--r--drivers/isdn/hisax/teleint.c363
-rw-r--r--drivers/isdn/hisax/teles0.c978
-rw-r--r--drivers/isdn/hisax/teles3.c1149
-rw-r--r--drivers/isdn/hisax/teles3c.c199
46 files changed, 16380 insertions, 7858 deletions
diff --git a/drivers/isdn/hisax/Makefile b/drivers/isdn/hisax/Makefile
index 2cc325b1f..a8e1f83ef 100644
--- a/drivers/isdn/hisax/Makefile
+++ b/drivers/isdn/hisax/Makefile
@@ -1,7 +1,14 @@
L_OBJS :=
M_OBJS :=
-O_OBJS := isdnl1.o config.o tei.o isdnl2.o isdnl3.o \
- q931.o callc.o fsm.o
+LX_OBJS :=
+MX_OBJS :=
+O_OBJS :=
+OX_OBJS :=
+L_TARGET :=
+O_TARGET :=
+
+O_OBJS := isdnl1.o tei.o isdnl2.o isdnl3.o \
+ lmgr.o q931.o callc.o fsm.o
# EXTRA_CFLAGS += -S
@@ -17,31 +24,105 @@ ifeq ($(CONFIG_HISAX_1TR6),y)
O_OBJS += l3_1tr6.o
endif
+ISAC_OBJ :=
+ARCOFI_OBJ :=
+HSCX_OBJ :=
+HFC_OBJ :=
+HFC_2BDS0 :=
+RAWHDLC_OBJ :=
+
ifeq ($(CONFIG_HISAX_16_0),y)
O_OBJS += teles0.o
+ ISAC_OBJ := isac.o
+ HSCX_OBJ := hscx.o
endif
ifeq ($(CONFIG_HISAX_16_3),y)
O_OBJS += teles3.o
+ ISAC_OBJ := isac.o
+ HSCX_OBJ := hscx.o
endif
ifeq ($(CONFIG_HISAX_AVM_A1),y)
O_OBJS += avm_a1.o
+ ISAC_OBJ := isac.o
+ HSCX_OBJ := hscx.o
endif
-ifeq ($(CONFIG_HISAX_ELSA_PCC),y)
- O_OBJS += elsa.o
-endif
-
-ifeq ($(CONFIG_HISAX_ELSA_PCMCIA),y)
+ifeq ($(CONFIG_HISAX_ELSA),y)
O_OBJS += elsa.o
+ ISAC_OBJ := isac.o
+ HSCX_OBJ := hscx.o
+ ARCOFI_OBJ := arcofi.o
endif
ifeq ($(CONFIG_HISAX_IX1MICROR2),y)
O_OBJS += ix1_micro.o
+ ISAC_OBJ := isac.o
+ HSCX_OBJ := hscx.o
+endif
+
+ifeq ($(CONFIG_HISAX_DIEHLDIVA),y)
+ O_OBJS += diva.o
+ ISAC_OBJ := isac.o
+ HSCX_OBJ := hscx.o
+endif
+
+ifeq ($(CONFIG_HISAX_ASUSCOM),y)
+ O_OBJS += asuscom.o
+ ISAC_OBJ := isac.o
+ HSCX_OBJ := hscx.o
+endif
+
+ifeq ($(CONFIG_HISAX_TELEINT),y)
+ O_OBJS += teleint.o
+ ISAC_OBJ := isac.o
+ HFC_OBJ := hfc_2bs0.o
+endif
+
+ifeq ($(CONFIG_HISAX_SEDLBAUER),y)
+ O_OBJS += sedlbauer.o
+ ISAC_OBJ := isac.o
+ HSCX_OBJ := hscx.o
endif
+ifeq ($(CONFIG_HISAX_SPORTSTER),y)
+ O_OBJS += sportster.o
+ ISAC_OBJ := isac.o
+ HSCX_OBJ := hscx.o
+endif
+
+ifeq ($(CONFIG_HISAX_MIC),y)
+ O_OBJS += mic.o
+ ISAC_OBJ := isac.o
+ HSCX_OBJ := hscx.o
+endif
+
+ifeq ($(CONFIG_HISAX_NETJET),y)
+ O_OBJS += netjet.o
+ ISAC_OBJ := isac.o
+endif
+
+ifeq ($(CONFIG_HISAX_TELES3C),y)
+ O_OBJS += teles3c.o
+ HFC_2BDS0 := hfc_2bds0.o
+endif
+ifeq ($(CONFIG_HISAX_AMD7930),y)
+ O_OBJS += amd7930.o
+ RAWHDLC_OBJ := rawhdlc.o
+endif
+
+ifeq ($(CONFIG_HISAX_NICCY),y)
+ O_OBJS += niccy.o
+ ISAC_OBJ := isac.o
+ HSCX_OBJ := hscx.o
+endif
+
+O_OBJS += $(ISAC_OBJ) $(HSCX_OBJ) $(HFC_OBJ) $(ARCOFI_OBJ) $(HFC_2BDS0) $(RAWHDLC_OBJ)
+OX_OBJS += config.o
+
O_TARGET :=
+
ifeq ($(CONFIG_ISDN_DRV_HISAX),y)
O_TARGET += hisax.o
else
diff --git a/drivers/isdn/hisax/amd7930.c b/drivers/isdn/hisax/amd7930.c
new file mode 100644
index 000000000..202599948
--- /dev/null
+++ b/drivers/isdn/hisax/amd7930.c
@@ -0,0 +1,768 @@
+/* $Id: amd7930.c,v 1.2 1998/02/12 23:07:10 keil Exp $
+ *
+ * HiSax ISDN driver - chip specific routines for AMD 7930
+ *
+ * Author Brent Baccala (baccala@FreeSoft.org)
+ *
+ *
+ *
+ * $Log: amd7930.c,v $
+ * Revision 1.2 1998/02/12 23:07:10 keil
+ * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
+ *
+ * Revision 1.1 1998/02/03 23:20:51 keil
+ * New files for SPARC isdn support
+ *
+ * Revision 1.1 1998/01/08 04:17:12 baccala
+ * ISDN comes to the Sparc. Key points:
+ *
+ * - Existing ISDN HiSax driver provides all the smarts
+ * - it compiles, runs, talks to an isolated phone switch, connects
+ * to a Cisco, pings go through
+ * - AMD 7930 support only (no DBRI yet)
+ * - no US NI-1 support (may not work on US phone system - untested)
+ * - periodic packet loss, apparently due to lost interrupts
+ * - ISDN sometimes freezes, requiring reboot before it will work again
+ *
+ * The code is unreliable enough to be consider alpha
+ *
+ *
+ * Advanced Micro Devices' Am79C30A is an ISDN/audio chip used in the
+ * SparcStation 1+. The chip provides microphone and speaker interfaces
+ * which provide mono-channel audio at 8K samples per second via either
+ * 8-bit A-law or 8-bit mu-law encoding. Also, the chip features an
+ * ISDN BRI Line Interface Unit (LIU), I.430 S/T physical interface,
+ * which performs basic D channel LAPD processing and provides raw
+ * B channel data. The digital audio channel, the two ISDN B channels,
+ * and two 64 Kbps channels to the microprocessor are all interconnected
+ * via a multiplexer.
+ *
+ * This driver interfaces to the Linux HiSax ISDN driver, which performs
+ * all high-level Q.921 and Q.931 ISDN functions. The file is not
+ * itself a hardware driver; rather it uses functions exported by
+ * the AMD7930 driver in the sparcaudio subsystem (drivers/sbus/audio),
+ * allowing the chip to be simultaneously used for both audio and ISDN data.
+ * The hardware driver does _no_ buffering, but provides several callbacks
+ * which are called during interrupt service and should therefore run quickly.
+ *
+ * D channel transmission is performed by passing the hardware driver the
+ * address and size of an skb's data area, then waiting for a callback
+ * to signal successful transmission of the packet. A task is then
+ * queued to notify the HiSax driver that another packet may be transmitted.
+ *
+ * D channel reception is quite simple, mainly because of:
+ * 1) the slow speed of the D channel - 16 kbps, and
+ * 2) the presence of an 8- or 32-byte (depending on chip version) FIFO
+ * to buffer the D channel data on the chip
+ * Worst case scenario of back-to-back packets with the 8 byte buffer
+ * at 16 kbps yields an service time of 4 ms - long enough to preclude
+ * the need for fancy buffering. We queue a background task that copies
+ * data out of the receive buffer into an skb, and the hardware driver
+ * simply does nothing until we're done with the receive buffer and
+ * reset it for a new packet.
+ *
+ * B channel processing is more complex, because of:
+ * 1) the faster speed - 64 kbps,
+ * 2) the lack of any on-chip buffering (it interrupts for every byte), and
+ * 3) the lack of any chip support for HDLC encapsulation
+ *
+ * The HiSax driver can put each B channel into one of three modes -
+ * L1_MODE_NULL (channel disabled), L1_MODE_TRANS (transparent data relay),
+ * and L1_MODE_HDLC (HDLC encapsulation by low-level driver).
+ * L1_MODE_HDLC is the most common, used for almost all "pure" digital
+ * data sessions. L1_MODE_TRANS is used for ISDN audio.
+ *
+ * HDLC B channel transmission is performed via a large buffer into
+ * which the skb is copied while performing HDLC bit-stuffing. A CRC
+ * is computed and attached to the end of the buffer, which is then
+ * passed to the low-level routines for raw transmission. Once
+ * transmission is complete, the hardware driver is set to enter HDLC
+ * idle by successive transmission of mark (all 1) bytes, waiting for
+ * the ISDN driver to prepare another packet for transmission and
+ * deliver it.
+ *
+ * HDLC B channel reception is performed via an X-byte ring buffer
+ * divided into N sections of X/N bytes each. Defaults: X=256 bytes, N=4.
+ * As the hardware driver notifies us that each section is full, we
+ * hand it the next section and schedule a background task to peruse
+ * the received section, bit-by-bit, with an HDLC decoder. As
+ * packets are detected, they are copied into a large buffer while
+ * decoding HDLC bit-stuffing. The ending CRC is verified, and if
+ * it is correct, we alloc a new skb of the correct length (which we
+ * now know), copy the packet into it, and hand it to the upper layers.
+ * Optimization: for large packets, we hand the buffer (which also
+ * happens to be an skb) directly to the upper layer after an skb_trim,
+ * and alloc a new large buffer for future packets, thus avoiding a copy.
+ * Then we return to HDLC processing; state is saved between calls.
+ *
+ */
+
+#define __NO_VERSION__
+#include "hisax.h"
+#include "../../sbus/audio/amd7930.h"
+#include "isac.h"
+#include "isdnl1.h"
+#include "rawhdlc.h"
+#include <linux/interrupt.h>
+
+static const char *amd7930_revision = "$Revision: 1.2 $";
+
+#define RCV_BUFSIZE 1024 /* Size of raw receive buffer in bytes */
+#define RCV_BUFBLKS 4 /* Number of blocks to divide buffer into
+ * (must divide RCV_BUFSIZE) */
+
+static void Bchan_fill_fifo(struct BCState *, struct sk_buff *);
+
+static void
+Bchan_xmt_bh(struct BCState *bcs)
+{
+ struct sk_buff *skb;
+
+ if (bcs->hw.amd7930.tx_skb != NULL) {
+ dev_kfree_skb(bcs->hw.amd7930.tx_skb);
+ bcs->hw.amd7930.tx_skb = NULL;
+ }
+
+ if ((skb = skb_dequeue(&bcs->squeue))) {
+ Bchan_fill_fifo(bcs, skb);
+ } else {
+ clear_bit(BC_FLG_BUSY, &bcs->Flag);
+ bcs->event |= 1 << B_XMTBUFREADY;
+ queue_task(&bcs->tqueue, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+ }
+}
+
+static void
+Bchan_xmit_callback(struct BCState *bcs)
+{
+ queue_task(&bcs->hw.amd7930.tq_xmt, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+}
+
+/* B channel transmission: two modes (three, if you count L1_MODE_NULL)
+ *
+ * L1_MODE_HDLC - We need to do HDLC encapsulation before transmiting
+ * the packet (i.e. make_raw_hdlc_data). Since this can be a
+ * time-consuming operation, our completion callback just schedules
+ * a bottom half to do encapsulation for the next packet. In between,
+ * the link will just idle
+ *
+ * L1_MODE_TRANS - Data goes through, well, transparent. No HDLC encap,
+ * and we can't just let the link idle, so the "bottom half" actually
+ * gets called during the top half (it's our callback routine in this case),
+ * but it's a lot faster now since we don't call make_raw_hdlc_data
+ */
+
+static void
+Bchan_fill_fifo(struct BCState *bcs, struct sk_buff *skb)
+{
+ struct IsdnCardState *cs = bcs->cs;
+ int len;
+
+ if ((cs->debug & L1_DEB_HSCX) || (cs->debug & L1_DEB_HSCX_FIFO)) {
+ char tmp[1024];
+ char *t = tmp;
+
+ t += sprintf(t, "amd7930_fill_fifo %c cnt %d",
+ bcs->channel ? 'B' : 'A', skb->len);
+ if (cs->debug & L1_DEB_HSCX_FIFO)
+ QuickHex(t, skb->data, skb->len);
+ debugl1(cs, tmp);
+ }
+
+ if (bcs->mode == L1_MODE_HDLC) {
+ len = make_raw_hdlc_data(skb->data, skb->len,
+ bcs->hw.amd7930.tx_buff, RAW_BUFMAX);
+ if (len > 0)
+ amd7930_bxmit(0, bcs->channel,
+ bcs->hw.amd7930.tx_buff, len,
+ (void *) &Bchan_xmit_callback,
+ (void *) bcs);
+ dev_kfree_skb(skb);
+ } else if (bcs->mode == L1_MODE_TRANS) {
+ amd7930_bxmit(0, bcs->channel,
+ bcs->hw.amd7930.tx_buff, skb->len,
+ (void *) &Bchan_xmt_bh,
+ (void *) bcs);
+ bcs->hw.amd7930.tx_skb = skb;
+ } else {
+ dev_kfree_skb(skb);
+ }
+}
+
+static void
+Bchan_mode(struct BCState *bcs, int mode, int bc)
+{
+ struct IsdnCardState *cs = bcs->cs;
+
+ if (cs->debug & L1_DEB_HSCX) {
+ char tmp[40];
+ sprintf(tmp, "AMD 7930 mode %d bchan %d/%d",
+ mode, bc, bcs->channel);
+ debugl1(cs, tmp);
+ }
+ bcs->mode = mode;
+}
+
+/* Bchan_l2l1 is the entry point for upper layer routines that want to
+ * transmit on the B channel. PH_DATA_REQ is a normal packet that
+ * we either start transmitting (if idle) or queue (if busy).
+ * PH_PULL_REQ can be called to request a callback message (PH_PULL_CNF)
+ * once the link is idle. After a "pull" callback, the upper layer
+ * routines can use PH_PULL_IND to send data.
+ */
+
+static void
+Bchan_l2l1(struct PStack *st, int pr, void *arg)
+{
+ struct sk_buff *skb = arg;
+
+ switch (pr) {
+ case (PH_DATA_REQ):
+ if (test_bit(BC_FLG_BUSY, &st->l1.bcs->Flag)) {
+ skb_queue_tail(&st->l1.bcs->squeue, skb);
+ } else {
+ test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
+ Bchan_fill_fifo(st->l1.bcs, skb);
+ }
+ break;
+ case (PH_PULL_IND):
+ if (test_bit(BC_FLG_BUSY, &st->l1.bcs->Flag)) {
+ printk(KERN_WARNING "amd7930: this shouldn't happen\n");
+ break;
+ }
+ test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
+ Bchan_fill_fifo(st->l1.bcs, skb);
+ break;
+ case (PH_PULL_REQ):
+ if (!test_bit(BC_FLG_BUSY, &st->l1.bcs->Flag)) {
+ clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
+ st->l1.l1l2(st, PH_PULL_CNF, NULL);
+ } else
+ set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
+ break;
+ }
+}
+
+/* Receiver callback and bottom half - decodes HDLC at leisure (if
+ * L1_MODE_HDLC) and passes newly received skb on via bcs->rqueue. If
+ * a large packet is received, stick rv_skb (the buffer that the
+ * packet has been decoded into) on the receive queue and alloc a new
+ * (large) skb to act as buffer for future receives. If a small
+ * packet is received, leave rv_skb alone, alloc a new skb of the
+ * correct size, and copy the packet into it
+ */
+
+static void
+Bchan_recv_callback(struct BCState *bcs)
+{
+ struct amd7930_hw *hw = &bcs->hw.amd7930;
+
+ hw->rv_buff_in += RCV_BUFSIZE/RCV_BUFBLKS;
+ hw->rv_buff_in %= RCV_BUFSIZE;
+
+ if (hw->rv_buff_in != hw->rv_buff_out) {
+ amd7930_brecv(0, bcs->channel,
+ hw->rv_buff + hw->rv_buff_in,
+ RCV_BUFSIZE/RCV_BUFBLKS,
+ (void *) &Bchan_recv_callback, (void *) bcs);
+ }
+
+ queue_task(&hw->tq_rcv, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+}
+
+static void
+Bchan_rcv_bh(struct BCState *bcs)
+{
+ struct IsdnCardState *cs = bcs->cs;
+ struct amd7930_hw *hw = &bcs->hw.amd7930;
+ struct sk_buff *skb;
+ int len;
+
+ if (cs->debug & L1_DEB_HSCX) {
+ char tmp[1024];
+
+ sprintf(tmp, "amd7930_Bchan_rcv (%d/%d)",
+ hw->rv_buff_in, hw->rv_buff_out);
+ debugl1(cs, tmp);
+ QuickHex(tmp, hw->rv_buff + hw->rv_buff_out,
+ RCV_BUFSIZE/RCV_BUFBLKS);
+ debugl1(cs, tmp);
+ }
+
+ do {
+ if (bcs->mode == L1_MODE_HDLC) {
+ while ((len = read_raw_hdlc_data(hw->hdlc_state,
+ hw->rv_buff + hw->rv_buff_out, RCV_BUFSIZE/RCV_BUFBLKS,
+ hw->rv_skb->tail, HSCX_BUFMAX))) {
+ if (len > 0 && (cs->debug & L1_DEB_HSCX_FIFO)) {
+ char tmp[1024];
+ char *t = tmp;
+
+ t += sprintf(t, "amd7930_Bchan_rcv %c cnt %d", bcs->channel ? 'B' : 'A', len);
+ QuickHex(t, hw->rv_skb->tail, len);
+ debugl1(cs, tmp);
+ }
+
+ if (len > HSCX_BUFMAX/2) {
+ /* Large packet received */
+
+ if (!(skb = dev_alloc_skb(HSCX_BUFMAX))) {
+ printk(KERN_WARNING "amd7930: receive out of memory");
+ } else {
+ skb_put(hw->rv_skb, len);
+ skb_queue_tail(&bcs->rqueue, hw->rv_skb);
+ hw->rv_skb = skb;
+ bcs->event |= 1 << B_RCVBUFREADY;
+ queue_task(&bcs->tqueue, &tq_immediate);
+ }
+ } else if (len > 0) {
+ /* Small packet received */
+
+ if (!(skb = dev_alloc_skb(len))) {
+ printk(KERN_WARNING "amd7930: receive out of memory\n");
+ } else {
+ memcpy(skb_put(skb, len), hw->rv_skb->tail, len);
+ skb_queue_tail(&bcs->rqueue, skb);
+ bcs->event |= 1 << B_RCVBUFREADY;
+ queue_task(&bcs->tqueue, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+ }
+ } else {
+ /* Reception Error */
+ /* printk("amd7930: B channel receive error\n"); */
+ }
+ }
+ } else if (bcs->mode == L1_MODE_TRANS) {
+ if (!(skb = dev_alloc_skb(RCV_BUFSIZE/RCV_BUFBLKS))) {
+ printk(KERN_WARNING "amd7930: receive out of memory\n");
+ } else {
+ memcpy(skb_put(skb, RCV_BUFSIZE/RCV_BUFBLKS),
+ hw->rv_buff + hw->rv_buff_out,
+ RCV_BUFSIZE/RCV_BUFBLKS);
+ skb_queue_tail(&bcs->rqueue, skb);
+ bcs->event |= 1 << B_RCVBUFREADY;
+ queue_task(&bcs->tqueue, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+ }
+ }
+
+ if (hw->rv_buff_in == hw->rv_buff_out) {
+ /* Buffer was filled up - need to restart receiver */
+ amd7930_brecv(0, bcs->channel,
+ hw->rv_buff + hw->rv_buff_in,
+ RCV_BUFSIZE/RCV_BUFBLKS,
+ (void *) &Bchan_recv_callback,
+ (void *) bcs);
+ }
+
+ hw->rv_buff_out += RCV_BUFSIZE/RCV_BUFBLKS;
+ hw->rv_buff_out %= RCV_BUFSIZE;
+
+ } while (hw->rv_buff_in != hw->rv_buff_out);
+}
+
+static void
+Bchan_close(struct BCState *bcs)
+{
+ struct sk_buff *skb;
+
+ Bchan_mode(bcs, 0, 0);
+ amd7930_bclose(0, bcs->channel);
+
+ if (test_bit(BC_FLG_INIT, &bcs->Flag)) {
+ while ((skb = skb_dequeue(&bcs->rqueue))) {
+ dev_kfree_skb(skb);
+ }
+ while ((skb = skb_dequeue(&bcs->squeue))) {
+ dev_kfree_skb(skb);
+ }
+ }
+ test_and_clear_bit(BC_FLG_INIT, &bcs->Flag);
+}
+
+static int
+Bchan_open(struct BCState *bcs)
+{
+ struct amd7930_hw *hw = &bcs->hw.amd7930;
+
+ if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) {
+ skb_queue_head_init(&bcs->rqueue);
+ skb_queue_head_init(&bcs->squeue);
+ }
+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
+
+ amd7930_bopen(0, bcs->channel, 0xff);
+ hw->rv_buff_in = 0;
+ hw->rv_buff_out = 0;
+ hw->tx_skb = NULL;
+ init_hdlc_state(hw->hdlc_state, 0);
+ amd7930_brecv(0, bcs->channel,
+ hw->rv_buff + hw->rv_buff_in, RCV_BUFSIZE/RCV_BUFBLKS,
+ (void *) &Bchan_recv_callback, (void *) bcs);
+
+ bcs->event = 0;
+ bcs->tx_cnt = 0;
+ return (0);
+}
+
+static void
+Bchan_init(struct BCState *bcs)
+{
+ if (!(bcs->hw.amd7930.tx_buff = kmalloc(RAW_BUFMAX, GFP_ATOMIC))) {
+ printk(KERN_WARNING
+ "HiSax: No memory for amd7930.tx_buff\n");
+ return;
+ }
+ if (!(bcs->hw.amd7930.rv_buff = kmalloc(RCV_BUFSIZE, GFP_ATOMIC))) {
+ printk(KERN_WARNING
+ "HiSax: No memory for amd7930.rv_buff\n");
+ return;
+ }
+ if (!(bcs->hw.amd7930.rv_skb = dev_alloc_skb(HSCX_BUFMAX))) {
+ printk(KERN_WARNING
+ "HiSax: No memory for amd7930.rv_skb\n");
+ return;
+ }
+ if (!(bcs->hw.amd7930.hdlc_state = kmalloc(sizeof(struct hdlc_state),
+ GFP_ATOMIC))) {
+ printk(KERN_WARNING
+ "HiSax: No memory for amd7930.hdlc_state\n");
+ return;
+ }
+
+ bcs->hw.amd7930.tq_rcv.sync = 0;
+ bcs->hw.amd7930.tq_rcv.routine = (void (*)(void *)) &Bchan_rcv_bh;
+ bcs->hw.amd7930.tq_rcv.data = (void *) bcs;
+
+ bcs->hw.amd7930.tq_xmt.sync = 0;
+ bcs->hw.amd7930.tq_xmt.routine = (void (*)(void *)) &Bchan_xmt_bh;
+ bcs->hw.amd7930.tq_xmt.data = (void *) bcs;
+}
+
+static void
+Bchan_manl1(struct PStack *st, int pr,
+ void *arg)
+{
+ switch (pr) {
+ case (PH_ACTIVATE_REQ):
+ test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
+ Bchan_mode(st->l1.bcs, st->l1.mode, st->l1.bc);
+ st->l1.l1man(st, PH_ACTIVATE_CNF, NULL);
+ break;
+ case (PH_DEACTIVATE_REQ):
+ if (!test_bit(BC_FLG_BUSY, &st->l1.bcs->Flag))
+ Bchan_mode(st->l1.bcs, 0, 0);
+ test_and_clear_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
+ break;
+ }
+}
+
+int
+setstack_amd7930(struct PStack *st, struct BCState *bcs)
+{
+ if (Bchan_open(bcs))
+ return (-1);
+ st->l1.bcs = bcs;
+ st->l2.l2l1 = Bchan_l2l1;
+ st->ma.manl1 = Bchan_manl1;
+ setstack_manager(st);
+ bcs->st = st;
+ return (0);
+}
+
+
+static void
+amd7930_drecv_callback(void *arg, int error, unsigned int count)
+{
+ struct IsdnCardState *cs = (struct IsdnCardState *) arg;
+ static struct tq_struct task;
+ struct sk_buff *skb;
+
+ /* NOTE: This function is called directly from an interrupt handler */
+
+ if (1) {
+ if (!(skb = alloc_skb(count, GFP_ATOMIC)))
+ printk(KERN_WARNING "HiSax: D receive out of memory\n");
+ else {
+ memcpy(skb_put(skb, count), cs->rcvbuf, count);
+ skb_queue_tail(&cs->rq, skb);
+ }
+
+ task.routine = (void *) DChannel_proc_rcv;
+ task.data = (void *) cs;
+ queue_task(&task, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+ }
+
+ if (cs->debug & L1_DEB_ISAC_FIFO) {
+ char tmp[128];
+ char *t = tmp;
+
+ t += sprintf(t, "amd7930 Drecv cnt %d", count);
+ if (error) t += sprintf(t, " ERR %x", error);
+ QuickHex(t, cs->rcvbuf, count);
+ debugl1(cs, tmp);
+ }
+
+ amd7930_drecv(0, cs->rcvbuf, MAX_DFRAME_LEN,
+ &amd7930_drecv_callback, cs);
+}
+
+static void
+amd7930_dxmit_callback(void *arg, int error)
+{
+ struct IsdnCardState *cs = (struct IsdnCardState *) arg;
+ static struct tq_struct task;
+
+ /* NOTE: This function is called directly from an interrupt handler */
+
+ /* may wish to do retransmission here, if error indicates collision */
+
+ if (cs->debug & L1_DEB_ISAC_FIFO) {
+ char tmp[128];
+ char *t = tmp;
+
+ t += sprintf(t, "amd7930 Dxmit cnt %d", cs->tx_skb->len);
+ if (error) t += sprintf(t, " ERR %x", error);
+ QuickHex(t, cs->tx_skb->data, cs->tx_skb->len);
+ debugl1(cs, tmp);
+ }
+
+ cs->tx_skb = NULL;
+
+ task.routine = (void *) DChannel_proc_xmt;
+ task.data = (void *) cs;
+ queue_task(&task, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+}
+
+static void
+amd7930_Dchan_l2l1(struct PStack *st, int pr, void *arg)
+{
+ struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware;
+ struct sk_buff *skb = arg;
+ char str[64];
+
+ switch (pr) {
+ case (PH_DATA_REQ):
+ if (cs->tx_skb) {
+ skb_queue_tail(&cs->sq, skb);
+#ifdef L2FRAME_DEBUG /* psa */
+ if (cs->debug & L1_DEB_LAPD)
+ 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 */
+ if (cs->debug & L1_DEB_LAPD)
+ Logl2Frame(cs, skb, "PH_DATA", 0);
+#endif
+ amd7930_dxmit(0, skb->data, skb->len,
+ &amd7930_dxmit_callback, cs);
+ }
+ break;
+ case (PH_PULL_IND):
+ 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 */
+ 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 */
+ if (cs->debug & L1_DEB_LAPD)
+ Logl2Frame(cs, skb, "PH_DATA_PULLED", 0);
+#endif
+ amd7930_dxmit(0, cs->tx_skb->data, cs->tx_skb->len,
+ &amd7930_dxmit_callback, cs);
+ break;
+ case (PH_PULL_REQ):
+#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);
+ } else
+ test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
+ break;
+ }
+}
+
+int
+setDstack_amd7930(struct PStack *st, struct IsdnCardState *cs)
+{
+ st->l2.l2l1 = amd7930_Dchan_l2l1;
+ if (! cs->rcvbuf) {
+ printk("setDstack_amd7930: No cs->rcvbuf!\n");
+ } else {
+ amd7930_drecv(0, cs->rcvbuf, MAX_DFRAME_LEN,
+ &amd7930_drecv_callback, cs);
+ }
+ return (0);
+}
+
+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
+amd7930_new_ph(struct IsdnCardState *cs)
+{
+ switch (amd7930_get_liu_state(0)) {
+ case 3:
+ manl1_msg(cs, PH_POWERUP_CNF, NULL);
+ break;
+
+ case 7:
+ manl1_msg(cs, PH_I4_P8_IND, NULL);
+ break;
+
+ case 8:
+ manl1_msg(cs, PH_RSYNC_IND, NULL);
+ break;
+ }
+}
+
+/* amd7930 LIU state change callback */
+
+static void
+amd7930_liu_callback(struct IsdnCardState *cs)
+{
+ static struct tq_struct task;
+
+ if (!cs)
+ return;
+
+ if (cs->debug & L1_DEB_ISAC) {
+ char tmp[32];
+ sprintf(tmp, "amd7930_liu state %d", amd7930_get_liu_state(0));
+ debugl1(cs, tmp);
+ }
+
+ task.sync = 0;
+ task.routine = (void *) &amd7930_new_ph;
+ task.data = (void *) cs;
+ queue_task(&task, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+}
+
+void
+amd7930_l1cmd(struct IsdnCardState *cs, int msg, void *arg)
+{
+ u_char val;
+ char tmp[32];
+
+ if (cs->debug & L1_DEB_ISAC) {
+ char tmp[32];
+ sprintf(tmp, "amd7930_l1cmd msg %x", msg);
+ debugl1(cs, tmp);
+ }
+
+ switch(msg) {
+ case PH_RESET_REQ:
+ if (amd7930_get_liu_state(0) <= 3)
+ amd7930_liu_activate(0,0);
+ else
+ amd7930_liu_deactivate(0);
+ break;
+ case PH_ENABLE_REQ:
+ break;
+ case PH_INFO3_REQ:
+ amd7930_liu_activate(0,0);
+ break;
+ case PH_TESTLOOP_REQ:
+ break;
+ default:
+ if (cs->debug & L1_DEB_WARN) {
+ sprintf(tmp, "amd7930_l1cmd unknown %4x", msg);
+ debugl1(cs, tmp);
+ }
+ break;
+ }
+}
+
+static void init_amd7930(struct IsdnCardState *cs)
+{
+ Bchan_init(&cs->bcs[0]);
+ Bchan_init(&cs->bcs[1]);
+ cs->bcs[0].BC_SetStack = setstack_amd7930;
+ cs->bcs[1].BC_SetStack = setstack_amd7930;
+ cs->bcs[0].BC_Close = Bchan_close;
+ cs->bcs[1].BC_Close = Bchan_close;
+ Bchan_mode(cs->bcs, 0, 0);
+ Bchan_mode(cs->bcs + 1, 0, 0);
+}
+
+void
+release_amd7930(struct IsdnCardState *cs)
+{
+}
+
+static int
+amd7930_card_msg(struct IsdnCardState *cs, int mt, void *arg)
+{
+ switch (mt) {
+ case CARD_RESET:
+ return(0);
+ case CARD_RELEASE:
+ release_amd7930(cs);
+ return(0);
+ case CARD_SETIRQ:
+ return(0);
+ case CARD_INIT:
+ cs->l1cmd = amd7930_l1cmd;
+ amd7930_liu_init(0, &amd7930_liu_callback, (void *)cs);
+ init_amd7930(cs);
+ return(0);
+ case CARD_TEST:
+ return(0);
+ }
+ return(0);
+}
+
+__initfunc(int
+setup_amd7930(struct IsdnCard *card))
+{
+ struct IsdnCardState *cs = card->cs;
+ char tmp[64];
+
+ strcpy(tmp, amd7930_revision);
+ printk(KERN_INFO "HiSax: AMD7930 driver Rev. %s\n", HiSax_getrev(tmp));
+ if (cs->typ != ISDN_CTYPE_AMD7930)
+ return (0);
+
+ cs->irq = amd7930_get_irqnum(0);
+ if (cs->irq == 0)
+ return (0);
+
+ cs->cardmsg = &amd7930_card_msg;
+
+ return (1);
+}
diff --git a/drivers/isdn/hisax/arcofi.c b/drivers/isdn/hisax/arcofi.c
new file mode 100644
index 000000000..dad1711c3
--- /dev/null
+++ b/drivers/isdn/hisax/arcofi.c
@@ -0,0 +1,51 @@
+/* $Id: arcofi.c,v 1.1 1997/10/29 18:51:20 keil Exp $
+
+ * arcofi.h Ansteuerung ARCOFI 2165
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ *
+ *
+ * $Log: arcofi.c,v $
+ * Revision 1.1 1997/10/29 18:51:20 keil
+ * New files
+ *
+ */
+
+#define __NO_VERSION__
+#include "hisax.h"
+#include "isdnl1.h"
+#include "isac.h"
+
+int
+send_arcofi(struct IsdnCardState *cs, const u_char *msg) {
+ u_char val;
+ char tmp[32];
+ long flags;
+ int cnt=2;
+
+ cs->mon_txp = 0;
+ cs->mon_txc = msg[0];
+ memcpy(cs->mon_tx, &msg[1], cs->mon_txc);
+ cs->mocr &= 0x0f;
+ cs->mocr |= 0xa0;
+ test_and_clear_bit(HW_MON1_TX_END, &cs->HW_Flags);
+ cs->writeisac(cs, ISAC_MOCR, cs->mocr);
+ val = cs->readisac(cs, ISAC_MOSR);
+ cs->writeisac(cs, ISAC_MOX1, cs->mon_tx[cs->mon_txp++]);
+ cs->mocr |= 0x10;
+ cs->writeisac(cs, ISAC_MOCR, cs->mocr);
+ save_flags(flags);
+ sti();
+ while (cnt && !test_bit(HW_MON1_TX_END, &cs->HW_Flags)) {
+ cnt--;
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + (10 * HZ) / 1000; /* Timeout 10ms */
+ schedule();
+ }
+ restore_flags(flags);
+ sprintf(tmp, "arcofi tout %d", cnt);
+ debugl1(cs, tmp);
+ return(cnt);
+}
+
diff --git a/drivers/isdn/hisax/arcofi.h b/drivers/isdn/hisax/arcofi.h
new file mode 100644
index 000000000..5e1bb9e99
--- /dev/null
+++ b/drivers/isdn/hisax/arcofi.h
@@ -0,0 +1,17 @@
+/* $Id: arcofi.h,v 1.1 1997/10/29 18:51:20 keil Exp $
+
+ * arcofi.h Ansteuerung ARCOFI 2165
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ *
+ *
+ * $Log: arcofi.h,v $
+ * Revision 1.1 1997/10/29 18:51:20 keil
+ * New files
+ *
+ */
+
+#define ARCOFI_USE 1
+
+extern int send_arcofi(struct IsdnCardState *cs, const u_char *msg);
diff --git a/drivers/isdn/hisax/asuscom.c b/drivers/isdn/hisax/asuscom.c
new file mode 100644
index 000000000..c84917446
--- /dev/null
+++ b/drivers/isdn/hisax/asuscom.c
@@ -0,0 +1,292 @@
+/* $Id: asuscom.c,v 1.2 1998/02/02 13:27:06 keil Exp $
+
+ * asuscom.c low level stuff for ASUSCOM NETWORK INC. ISDNLink cards
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ * Thanks to ASUSCOM NETWORK INC. Taiwan and Dynalink NL for informations
+ *
+ *
+ * $Log: asuscom.c,v $
+ * Revision 1.2 1998/02/02 13:27:06 keil
+ * New
+ *
+ *
+ */
+
+#define __NO_VERSION__
+#include "hisax.h"
+#include "isac.h"
+#include "hscx.h"
+#include "isdnl1.h"
+
+extern const char *CardType[];
+
+const char *Asuscom_revision = "$Revision: 1.2 $";
+
+#define byteout(addr,val) outb(val,addr)
+#define bytein(addr) inb(addr)
+
+#define ASUS_ISAC 0
+#define ASUS_HSCX 1
+#define ASUS_ADR 2
+#define ASUS_CTRL_U7 3
+#define ASUS_CTRL_POTS 5
+
+/* CARD_ADR (Write) */
+#define ASUS_RESET 0x80 /* Bit 7 Reset-Leitung */
+
+static inline u_char
+readreg(unsigned int ale, unsigned int adr, u_char off)
+{
+ register u_char ret;
+ long flags;
+
+ save_flags(flags);
+ cli();
+ byteout(ale, off);
+ ret = bytein(adr);
+ restore_flags(flags);
+ return (ret);
+}
+
+static inline void
+readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
+{
+ /* fifo read without cli because it's allready done */
+
+ byteout(ale, off);
+ insb(adr, data, size);
+}
+
+
+static inline void
+writereg(unsigned int ale, unsigned int adr, u_char off, u_char data)
+{
+ long flags;
+
+ save_flags(flags);
+ cli();
+ byteout(ale, off);
+ byteout(adr, data);
+ restore_flags(flags);
+}
+
+static inline void
+writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
+{
+ /* fifo write without cli because it's allready done */
+ byteout(ale, off);
+ outsb(adr, data, size);
+}
+
+/* Interface functions */
+
+static u_char
+ReadISAC(struct IsdnCardState *cs, u_char offset)
+{
+ return (readreg(cs->hw.asus.adr, cs->hw.asus.isac, offset));
+}
+
+static void
+WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
+{
+ writereg(cs->hw.asus.adr, cs->hw.asus.isac, offset, value);
+}
+
+static void
+ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
+{
+ readfifo(cs->hw.asus.adr, cs->hw.asus.isac, 0, data, size);
+}
+
+static void
+WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
+{
+ writefifo(cs->hw.asus.adr, cs->hw.asus.isac, 0, data, size);
+}
+
+static u_char
+ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
+{
+ return (readreg(cs->hw.asus.adr,
+ cs->hw.asus.hscx, offset + (hscx ? 0x40 : 0)));
+}
+
+static void
+WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
+{
+ writereg(cs->hw.asus.adr,
+ cs->hw.asus.hscx, offset + (hscx ? 0x40 : 0), value);
+}
+
+/*
+ * fast interrupt HSCX stuff goes here
+ */
+
+#define READHSCX(cs, nr, reg) readreg(cs->hw.asus.adr, \
+ cs->hw.asus.hscx, reg + (nr ? 0x40 : 0))
+#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.asus.adr, \
+ cs->hw.asus.hscx, reg + (nr ? 0x40 : 0), data)
+
+#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.asus.adr, \
+ cs->hw.asus.hscx, (nr ? 0x40 : 0), ptr, cnt)
+
+#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.asus.adr, \
+ cs->hw.asus.hscx, (nr ? 0x40 : 0), ptr, cnt)
+
+#include "hscx_irq.c"
+
+static void
+asuscom_interrupt(int intno, void *dev_id, struct pt_regs *regs)
+{
+ struct IsdnCardState *cs = dev_id;
+ u_char val, stat = 0;
+
+ if (!cs) {
+ printk(KERN_WARNING "ISDNLink: Spurious interrupt!\n");
+ return;
+ }
+ val = readreg(cs->hw.asus.adr, cs->hw.asus.hscx, HSCX_ISTA + 0x40);
+ Start_HSCX:
+ if (val) {
+ hscx_int_main(cs, val);
+ stat |= 1;
+ }
+ val = readreg(cs->hw.asus.adr, cs->hw.asus.isac, ISAC_ISTA);
+ Start_ISAC:
+ if (val) {
+ isac_interrupt(cs, val);
+ stat |= 2;
+ }
+ val = readreg(cs->hw.asus.adr, cs->hw.asus.hscx, HSCX_ISTA + 0x40);
+ if (val) {
+ if (cs->debug & L1_DEB_HSCX)
+ debugl1(cs, "HSCX IntStat after IntRoutine");
+ goto Start_HSCX;
+ }
+ val = readreg(cs->hw.asus.adr, cs->hw.asus.isac, ISAC_ISTA);
+ if (val) {
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ISAC IntStat after IntRoutine");
+ goto Start_ISAC;
+ }
+ if (stat & 1) {
+ writereg(cs->hw.asus.adr, cs->hw.asus.hscx, HSCX_MASK, 0xFF);
+ writereg(cs->hw.asus.adr, cs->hw.asus.hscx, HSCX_MASK + 0x40, 0xFF);
+ writereg(cs->hw.asus.adr, cs->hw.asus.hscx, HSCX_MASK, 0x0);
+ writereg(cs->hw.asus.adr, cs->hw.asus.hscx, HSCX_MASK + 0x40, 0x0);
+ }
+ if (stat & 2) {
+ writereg(cs->hw.asus.adr, cs->hw.asus.isac, ISAC_MASK, 0xFF);
+ writereg(cs->hw.asus.adr, cs->hw.asus.isac, ISAC_MASK, 0x0);
+ }
+}
+
+void
+release_io_asuscom(struct IsdnCardState *cs)
+{
+ int bytecnt = 8;
+
+ if (cs->hw.asus.cfg_reg)
+ release_region(cs->hw.asus.cfg_reg, bytecnt);
+}
+
+static void
+reset_asuscom(struct IsdnCardState *cs)
+{
+ long flags;
+
+ byteout(cs->hw.asus.adr, ASUS_RESET); /* Reset On */
+ save_flags(flags);
+ sti();
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + 1;
+ schedule();
+ byteout(cs->hw.asus.adr, 0); /* Reset Off */
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + 1;
+ schedule();
+ restore_flags(flags);
+}
+
+static int
+Asus_card_msg(struct IsdnCardState *cs, int mt, void *arg)
+{
+ switch (mt) {
+ case CARD_RESET:
+ reset_asuscom(cs);
+ return(0);
+ case CARD_RELEASE:
+ release_io_asuscom(cs);
+ return(0);
+ case CARD_SETIRQ:
+ return(request_irq(cs->irq, &asuscom_interrupt,
+ I4L_IRQ_FLAG, "HiSax", cs));
+ case CARD_INIT:
+ clear_pending_isac_ints(cs);
+ clear_pending_hscx_ints(cs);
+ initisac(cs);
+ inithscx(cs);
+ return(0);
+ case CARD_TEST:
+ return(0);
+ }
+ return(0);
+}
+
+__initfunc(int
+setup_asuscom(struct IsdnCard *card))
+{
+ int bytecnt;
+ struct IsdnCardState *cs = card->cs;
+ char tmp[64];
+
+ strcpy(tmp, Asuscom_revision);
+ printk(KERN_INFO "HiSax: Asuscom ISDNLink driver Rev. %s\n", HiSax_getrev(tmp));
+ if (cs->typ != ISDN_CTYPE_ASUSCOM)
+ return (0);
+
+ bytecnt = 8;
+ cs->hw.asus.cfg_reg = card->para[1];
+ cs->irq = card->para[0];
+ cs->hw.asus.adr = cs->hw.asus.cfg_reg + ASUS_ADR;
+ cs->hw.asus.isac = cs->hw.asus.cfg_reg + ASUS_ISAC;
+ cs->hw.asus.hscx = cs->hw.asus.cfg_reg + ASUS_HSCX;
+ cs->hw.asus.u7 = cs->hw.asus.cfg_reg + ASUS_CTRL_U7;
+ cs->hw.asus.pots = cs->hw.asus.cfg_reg + ASUS_CTRL_POTS;
+
+ if (check_region((cs->hw.asus.cfg_reg), bytecnt)) {
+ printk(KERN_WARNING
+ "HiSax: %s config port %x-%x already in use\n",
+ CardType[card->typ],
+ cs->hw.asus.cfg_reg,
+ cs->hw.asus.cfg_reg + bytecnt);
+ return (0);
+ } else {
+ request_region(cs->hw.asus.cfg_reg, bytecnt, "asuscom isdn");
+ }
+
+ printk(KERN_INFO
+ "ISDNLink: defined at 0x%x IRQ %d\n",
+ cs->hw.asus.cfg_reg,
+ cs->irq);
+ printk(KERN_INFO "ISDNLink: resetting card\n");
+ reset_asuscom(cs);
+ cs->readisac = &ReadISAC;
+ cs->writeisac = &WriteISAC;
+ cs->readisacfifo = &ReadISACfifo;
+ cs->writeisacfifo = &WriteISACfifo;
+ cs->BC_Read_Reg = &ReadHSCX;
+ cs->BC_Write_Reg = &WriteHSCX;
+ cs->BC_Send_Data = &hscx_fill_fifo;
+ cs->cardmsg = &Asus_card_msg;
+ ISACVersion(cs, "ISDNLink:");
+ if (HscxVersion(cs, "ISDNLink:")) {
+ printk(KERN_WARNING
+ "ISDNLink: wrong HSCX versions check IO address\n");
+ release_io_asuscom(cs);
+ return (0);
+ }
+ return (1);
+}
diff --git a/drivers/isdn/hisax/avm_a1.c b/drivers/isdn/hisax/avm_a1.c
index e6c775546..464bc33fd 100644
--- a/drivers/isdn/hisax/avm_a1.c
+++ b/drivers/isdn/hisax/avm_a1.c
@@ -1,4 +1,4 @@
-/* $Id: avm_a1.c,v 1.6 1997/04/13 19:54:07 keil Exp $
+/* $Id: avm_a1.c,v 2.7 1998/02/02 13:29:37 keil Exp $
* avm_a1.c low level stuff for AVM A1 (Fritz) isdn cards
*
@@ -6,6 +6,30 @@
*
*
* $Log: avm_a1.c,v $
+ * Revision 2.7 1998/02/02 13:29:37 keil
+ * fast io
+ *
+ * Revision 2.6 1998/01/13 23:09:46 keil
+ * really disable timer
+ *
+ * Revision 2.5 1998/01/02 06:50:29 calle
+ * Perodic timer of A1 now disabled, no need for linux driver.
+ *
+ * Revision 2.4 1997/11/08 21:35:42 keil
+ * new l1 init
+ *
+ * Revision 2.3 1997/11/06 17:13:32 keil
+ * New 2.1 init code
+ *
+ * Revision 2.2 1997/10/29 18:55:48 keil
+ * changes for 2.1.60 (irq2dev_map)
+ *
+ * Revision 2.1 1997/07/27 21:47:13 keil
+ * new interface structures
+ *
+ * Revision 2.0 1997/06/26 11:02:48 keil
+ * New Layer and card interface
+ *
* Revision 1.6 1997/04/13 19:54:07 keil
* Change in IRQ check delay for SMP
*
@@ -27,17 +51,20 @@
*
*/
#define __NO_VERSION__
-#include "siemens.h"
#include "hisax.h"
-#include "avm_a1.h"
+#include "isac.h"
+#include "hscx.h"
#include "isdnl1.h"
-#include <linux/kernel_stat.h>
extern const char *CardType[];
-const char *avm_revision = "$Revision: 1.6 $";
+const char *avm_revision = "$Revision: 2.7 $";
+
+#define AVM_A1_STAT_ISAC 0x01
+#define AVM_A1_STAT_HSCX 0x02
+#define AVM_A1_STAT_TIMER 0x04
-#define byteout(addr,val) outb_p(val,addr)
-#define bytein(addr) inb_p(addr)
+#define byteout(addr,val) outb(val,addr)
+#define bytein(addr) inb(addr)
static inline u_char
readreg(unsigned int adr, u_char off)
@@ -55,906 +82,303 @@ writereg(unsigned int adr, u_char off, u_char data)
static inline void
read_fifo(unsigned int adr, u_char * data, int size)
{
- insb(adr - 0x400, data, size);
+ insb(adr, data, size);
}
static void
write_fifo(unsigned int adr, u_char * data, int size)
{
- outsb(adr - 0x400, data, size);
-}
-
-static inline void
-waitforCEC(int adr)
-{
- int to = 50;
-
- while ((readreg(adr, HSCX_STAR) & 0x04) && to) {
- udelay(1);
- to--;
- }
- if (!to)
- printk(KERN_WARNING "AVM A1: waitforCEC timeout\n");
+ outsb(adr, data, size);
}
+/* Interface functions */
-static inline void
-waitforXFW(int adr)
-{
- int to = 50;
-
- while ((!(readreg(adr, HSCX_STAR) & 0x44) == 0x40) && to) {
- udelay(1);
- to--;
- }
- if (!to)
- printk(KERN_WARNING "AVM A1: waitforXFW timeout\n");
-}
-
-static inline void
-writehscxCMDR(int adr, u_char data)
+static u_char
+ReadISAC(struct IsdnCardState *cs, u_char offset)
{
- long flags;
-
- save_flags(flags);
- cli();
- waitforCEC(adr);
- writereg(adr, HSCX_CMDR, data);
- restore_flags(flags);
+ return (readreg(cs->hw.avm.isac, offset));
}
-/*
- * fast interrupt here
- */
-
static void
-hscxreport(struct IsdnCardState *sp, int hscx)
+WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
{
- printk(KERN_DEBUG "HSCX %d\n", hscx);
- printk(KERN_DEBUG "ISTA %x\n", readreg(sp->hscx[hscx], HSCX_ISTA));
- printk(KERN_DEBUG "STAR %x\n", readreg(sp->hscx[hscx], HSCX_STAR));
- printk(KERN_DEBUG "EXIR %x\n", readreg(sp->hscx[hscx], HSCX_EXIR));
+ writereg(cs->hw.avm.isac, offset, value);
}
-void
-avm_a1_report(struct IsdnCardState *sp)
-{
- printk(KERN_DEBUG "ISAC\n");
- printk(KERN_DEBUG "ISTA %x\n", readreg(sp->isac, ISAC_ISTA));
- printk(KERN_DEBUG "STAR %x\n", readreg(sp->isac, ISAC_STAR));
- printk(KERN_DEBUG "EXIR %x\n", readreg(sp->isac, ISAC_EXIR));
- hscxreport(sp, 0);
- hscxreport(sp, 1);
-}
-
-/*
- * HSCX stuff goes here
- */
-
static void
-hscx_empty_fifo(struct HscxState *hsp, int count)
+ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
{
- u_char *ptr;
- struct IsdnCardState *sp = hsp->sp;
- long flags;
-
- if ((sp->debug & L1_DEB_HSCX) && !(sp->debug & L1_DEB_HSCX_FIFO))
- debugl1(sp, "hscx_empty_fifo");
-
- if (hsp->rcvidx + count > HSCX_BUFMAX) {
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "hscx_empty_fifo: incoming packet too large");
- writehscxCMDR(sp->hscx[hsp->hscx], 0x80);
- hsp->rcvidx = 0;
- return;
- }
- ptr = hsp->rcvbuf + hsp->rcvidx;
- hsp->rcvidx += count;
- save_flags(flags);
- cli();
- read_fifo(sp->hscx[hsp->hscx], ptr, count);
- writehscxCMDR(sp->hscx[hsp->hscx], 0x80);
- restore_flags(flags);
- if (sp->debug & L1_DEB_HSCX_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "hscx_empty_fifo %c cnt %d",
- hsp->hscx ? 'B' : 'A', count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ read_fifo(cs->hw.avm.isacfifo, data, size);
}
static void
-hscx_fill_fifo(struct HscxState *hsp)
+WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
{
- struct IsdnCardState *sp = hsp->sp;
- int more, count;
- u_char *ptr;
- long flags;
-
- if ((sp->debug & L1_DEB_HSCX) && !(sp->debug & L1_DEB_HSCX_FIFO))
- debugl1(sp, "hscx_fill_fifo");
-
- if (!hsp->tx_skb)
- return;
- if (hsp->tx_skb->len <= 0)
- return;
-
- more = (hsp->mode == 1) ? 1 : 0;
- if (hsp->tx_skb->len > 32) {
- more = !0;
- count = 32;
- } else
- count = hsp->tx_skb->len;
-
- waitforXFW(sp->hscx[hsp->hscx]);
- save_flags(flags);
- cli();
- ptr = hsp->tx_skb->data;
- skb_pull(hsp->tx_skb, count);
- hsp->tx_cnt -= count;
- hsp->count += count;
- write_fifo(sp->hscx[hsp->hscx], ptr, count);
- writehscxCMDR(sp->hscx[hsp->hscx], more ? 0x8 : 0xa);
- restore_flags(flags);
- if (sp->debug & L1_DEB_HSCX_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "hscx_fill_fifo %c cnt %d",
- hsp->hscx ? 'B' : 'A', count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ write_fifo(cs->hw.avm.isacfifo, data, size);
}
-static inline void
-hscx_interrupt(struct IsdnCardState *sp, u_char val, u_char hscx)
+static u_char
+ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
{
- u_char r;
- struct HscxState *hsp = sp->hs + hscx;
- struct sk_buff *skb;
- int count;
- char tmp[32];
-
- if (!hsp->init)
- return;
-
- if (val & 0x80) { /* RME */
-
- r = readreg(sp->hscx[hsp->hscx], HSCX_RSTA);
- if ((r & 0xf0) != 0xa0) {
- if (!r & 0x80)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "HSCX invalid frame");
- if ((r & 0x40) && hsp->mode)
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX RDO mode=%d",
- hsp->mode);
- debugl1(sp, tmp);
- }
- if (!r & 0x20)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "HSCX CRC error");
- writehscxCMDR(sp->hscx[hsp->hscx], 0x80);
- } else {
- count = readreg(sp->hscx[hsp->hscx], HSCX_RBCL) & 0x1f;
- if (count == 0)
- count = 32;
- hscx_empty_fifo(hsp, count);
- if ((count = hsp->rcvidx - 1) > 0) {
- if (!(skb = dev_alloc_skb(count)))
- printk(KERN_WARNING "AVM: receive out of memory\n");
- else {
- memcpy(skb_put(skb, count), hsp->rcvbuf, count);
- skb_queue_tail(&hsp->rqueue, skb);
- }
- }
- }
- hsp->rcvidx = 0;
- hscx_sched_event(hsp, HSCX_RCVBUFREADY);
- }
- if (val & 0x40) { /* RPF */
- hscx_empty_fifo(hsp, 32);
- if (hsp->mode == 1) {
- /* receive audio data */
- if (!(skb = dev_alloc_skb(32)))
- printk(KERN_WARNING "AVM: receive out of memory\n");
- else {
- memcpy(skb_put(skb, 32), hsp->rcvbuf, 32);
- skb_queue_tail(&hsp->rqueue, skb);
- }
- hsp->rcvidx = 0;
- hscx_sched_event(hsp, HSCX_RCVBUFREADY);
- }
- }
- if (val & 0x10) { /* XPR */
- if (hsp->tx_skb)
- if (hsp->tx_skb->len) {
- hscx_fill_fifo(hsp);
- return;
- } else {
- SET_SKB_FREE(hsp->tx_skb);
- dev_kfree_skb(hsp->tx_skb);
- hsp->count = 0;
- if (hsp->st->l4.l1writewakeup)
- hsp->st->l4.l1writewakeup(hsp->st);
- hsp->tx_skb = NULL;
- }
- if ((hsp->tx_skb = skb_dequeue(&hsp->squeue))) {
- hsp->count = 0;
- hscx_fill_fifo(hsp);
- } else
- hscx_sched_event(hsp, HSCX_XMTBUFREADY);
- }
+ return (readreg(cs->hw.avm.hscx[hscx], offset));
}
-/*
- * ISAC stuff goes here
- */
-
static void
-isac_empty_fifo(struct IsdnCardState *sp, int count)
+WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
{
- u_char *ptr;
- long flags;
-
- if ((sp->debug & L1_DEB_ISAC) && !(sp->debug & L1_DEB_ISAC_FIFO))
- if (sp->debug & L1_DEB_ISAC)
- debugl1(sp, "isac_empty_fifo");
-
- if ((sp->rcvidx + count) >= MAX_DFRAME_LEN) {
- if (sp->debug & L1_DEB_WARN) {
- char tmp[40];
- sprintf(tmp, "isac_empty_fifo overrun %d",
- sp->rcvidx + count);
- debugl1(sp, tmp);
- }
- writereg(sp->isac, ISAC_CMDR, 0x80);
- sp->rcvidx = 0;
- return;
- }
- ptr = sp->rcvbuf + sp->rcvidx;
- sp->rcvidx += count;
- save_flags(flags);
- cli();
- read_fifo(sp->isac, ptr, count);
- writereg(sp->isac, ISAC_CMDR, 0x80);
- restore_flags(flags);
- if (sp->debug & L1_DEB_ISAC_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "isac_empty_fifo cnt %d", count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ writereg(cs->hw.avm.hscx[hscx], offset, value);
}
-static void
-isac_fill_fifo(struct IsdnCardState *sp)
-{
- int count, more;
- u_char *ptr;
- long flags;
-
- if ((sp->debug & L1_DEB_ISAC) && !(sp->debug & L1_DEB_ISAC_FIFO))
- debugl1(sp, "isac_fill_fifo");
-
- if (!sp->tx_skb)
- return;
-
- count = sp->tx_skb->len;
- if (count <= 0)
- return;
-
- more = 0;
- if (count > 32) {
- more = !0;
- count = 32;
- }
- save_flags(flags);
- cli();
- ptr = sp->tx_skb->data;
- skb_pull(sp->tx_skb, count);
- sp->tx_cnt += count;
- write_fifo(sp->isac, ptr, count);
- writereg(sp->isac, ISAC_CMDR, more ? 0x8 : 0xa);
- restore_flags(flags);
- if (sp->debug & L1_DEB_ISAC_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "isac_fill_fifo cnt %d", count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
-}
-
-static void
-ph_command(struct IsdnCardState *sp, unsigned int command)
-{
- if (sp->debug & L1_DEB_ISAC) {
- char tmp[32];
- sprintf(tmp, "ph_command %d", command);
- debugl1(sp, tmp);
- }
- writereg(sp->isac, ISAC_CIX0, (command << 2) | 3);
-}
-
-
-static inline void
-isac_interrupt(struct IsdnCardState *sp, u_char val)
-{
- u_char exval;
- struct sk_buff *skb;
- unsigned int count;
- char tmp[32];
-
- if (sp->debug & L1_DEB_ISAC) {
- sprintf(tmp, "ISAC interrupt %x", val);
- debugl1(sp, tmp);
- }
- if (val & 0x80) { /* RME */
- exval = readreg(sp->isac, ISAC_RSTA);
- if ((exval & 0x70) != 0x20) {
- if (exval & 0x40)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC RDO");
- if (!exval & 0x20)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC CRC error");
- writereg(sp->isac, ISAC_CMDR, 0x80);
- } else {
- count = readreg(sp->isac, ISAC_RBCL) & 0x1f;
- if (count == 0)
- count = 32;
- isac_empty_fifo(sp, count);
- if ((count = sp->rcvidx) > 0) {
- if (!(skb = alloc_skb(count, GFP_ATOMIC)))
- printk(KERN_WARNING "AVM: D receive out of memory\n");
- else {
- memcpy(skb_put(skb, count), sp->rcvbuf, count);
- skb_queue_tail(&sp->rq, skb);
- }
- }
- }
- sp->rcvidx = 0;
- isac_sched_event(sp, ISAC_RCVBUFREADY);
- }
- if (val & 0x40) { /* RPF */
- isac_empty_fifo(sp, 32);
- }
- if (val & 0x20) { /* RSC */
- /* never */
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC RSC interrupt");
- }
- if (val & 0x10) { /* XPR */
- if (sp->tx_skb)
- if (sp->tx_skb->len) {
- isac_fill_fifo(sp);
- goto afterXPR;
- } else {
- SET_SKB_FREE(sp->tx_skb);
- dev_kfree_skb(sp->tx_skb);
- sp->tx_cnt = 0;
- sp->tx_skb = NULL;
- }
- if ((sp->tx_skb = skb_dequeue(&sp->sq))) {
- sp->tx_cnt = 0;
- isac_fill_fifo(sp);
- } else
- isac_sched_event(sp, ISAC_XMTBUFREADY);
- }
- afterXPR:
- if (val & 0x04) { /* CISQ */
- sp->ph_state = (readreg(sp->isac, ISAC_CIX0) >> 2)
- & 0xf;
- if (sp->debug & L1_DEB_ISAC) {
- sprintf(tmp, "l1state %d", sp->ph_state);
- debugl1(sp, tmp);
- }
- isac_new_ph(sp);
- }
- if (val & 0x02) { /* SIN */
- /* never */
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC SIN interrupt");
- }
- if (val & 0x01) { /* EXI */
- exval = readreg(sp->isac, ISAC_EXIR);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "ISAC EXIR %02x", exval);
- debugl1(sp, tmp);
- }
- }
-}
-
-static inline void
-hscx_int_main(struct IsdnCardState *sp, u_char val)
-{
-
- u_char exval;
- struct HscxState *hsp;
- char tmp[32];
+/*
+ * fast interrupt HSCX stuff goes here
+ */
+#define READHSCX(cs, nr, reg) readreg(cs->hw.avm.hscx[nr], reg)
+#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.avm.hscx[nr], reg, data)
+#define READHSCXFIFO(cs, nr, ptr, cnt) read_fifo(cs->hw.avm.hscxfifo[nr], ptr, cnt)
+#define WRITEHSCXFIFO(cs, nr, ptr, cnt) write_fifo(cs->hw.avm.hscxfifo[nr], ptr, cnt)
- if (val & 0x01) {
- hsp = sp->hs + 1;
- exval = readreg(sp->hscx[1], HSCX_EXIR);
- if (exval == 0x40) {
- if (hsp->mode == 1)
- hscx_fill_fifo(hsp);
- else {
- /* Here we lost an TX interrupt, so
- * restart transmitting the whole frame.
- */
- if (hsp->tx_skb) {
- skb_push(hsp->tx_skb, hsp->count);
- hsp->tx_cnt += hsp->count;
- hsp->count = 0;
- }
- writehscxCMDR(sp->hscx[hsp->hscx], 0x01);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX B EXIR %x Lost TX", exval);
- debugl1(sp, tmp);
- }
- }
- } else if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX B EXIR %x", exval);
- debugl1(sp, tmp);
- }
- }
- if (val & 0xf8) {
- if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX B interrupt %x", val);
- debugl1(sp, tmp);
- }
- hscx_interrupt(sp, val, 1);
- }
- if (val & 0x02) {
- hsp = sp->hs;
- exval = readreg(sp->hscx[0], HSCX_EXIR);
- if (exval == 0x40) {
- if (hsp->mode == 1)
- hscx_fill_fifo(hsp);
- else {
- /* Here we lost an TX interrupt, so
- * restart transmitting the whole frame.
- */
- if (hsp->tx_skb) {
- skb_push(hsp->tx_skb, hsp->count);
- hsp->tx_cnt += hsp->count;
- hsp->count = 0;
- }
- writehscxCMDR(sp->hscx[hsp->hscx], 0x01);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX A EXIR %x Lost TX", exval);
- debugl1(sp, tmp);
- }
- }
- } else if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX A EXIR %x", exval);
- debugl1(sp, tmp);
- }
- }
- if (val & 0x04) {
- exval = readreg(sp->hscx[0], HSCX_ISTA);
- if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX A interrupt %x", exval);
- debugl1(sp, tmp);
- }
- hscx_interrupt(sp, exval, 0);
- }
-}
+#include "hscx_irq.c"
static void
avm_a1_interrupt(int intno, void *dev_id, struct pt_regs *regs)
{
- struct IsdnCardState *sp;
+ struct IsdnCardState *cs = dev_id;
u_char val, sval, stat = 0;
char tmp[32];
- sp = (struct IsdnCardState *) dev_id;
-
- if (!sp) {
+ if (!cs) {
printk(KERN_WARNING "AVM A1: Spurious interrupt!\n");
return;
}
- while (((sval = bytein(sp->cfg_reg)) & 0xf) != 0x7) {
+ while (((sval = bytein(cs->hw.avm.cfg_reg)) & 0xf) != 0x7) {
if (!(sval & AVM_A1_STAT_TIMER)) {
- byteout(sp->cfg_reg, 0x14);
- byteout(sp->cfg_reg, 0x18);
- sval = bytein(sp->cfg_reg);
- } else if (sp->debug & L1_DEB_INTSTAT) {
+ byteout(cs->hw.avm.cfg_reg, 0x1E);
+ sval = bytein(cs->hw.avm.cfg_reg);
+ } else if (cs->debug & L1_DEB_INTSTAT) {
sprintf(tmp, "avm IntStatus %x", sval);
- debugl1(sp, tmp);
+ debugl1(cs, tmp);
}
if (!(sval & AVM_A1_STAT_HSCX)) {
- val = readreg(sp->hscx[1], HSCX_ISTA);
+ val = readreg(cs->hw.avm.hscx[1], HSCX_ISTA);
if (val) {
- hscx_int_main(sp, val);
+ hscx_int_main(cs, val);
stat |= 1;
}
}
if (!(sval & AVM_A1_STAT_ISAC)) {
- val = readreg(sp->isac, ISAC_ISTA);
+ val = readreg(cs->hw.avm.isac, ISAC_ISTA);
if (val) {
- isac_interrupt(sp, val);
+ isac_interrupt(cs, val);
stat |= 2;
}
}
}
if (stat & 1) {
- writereg(sp->hscx[0], HSCX_MASK, 0xFF);
- writereg(sp->hscx[1], HSCX_MASK, 0xFF);
- writereg(sp->hscx[0], HSCX_MASK, 0x0);
- writereg(sp->hscx[1], HSCX_MASK, 0x0);
+ writereg(cs->hw.avm.hscx[0], HSCX_MASK, 0xFF);
+ writereg(cs->hw.avm.hscx[1], HSCX_MASK, 0xFF);
+ writereg(cs->hw.avm.hscx[0], HSCX_MASK, 0x0);
+ writereg(cs->hw.avm.hscx[1], HSCX_MASK, 0x0);
}
if (stat & 2) {
- writereg(sp->isac, ISAC_MASK, 0xFF);
- writereg(sp->isac, ISAC_MASK, 0x0);
+ writereg(cs->hw.avm.isac, ISAC_MASK, 0xFF);
+ writereg(cs->hw.avm.isac, ISAC_MASK, 0x0);
}
}
-
-static void
-initisac(struct IsdnCardState *sp)
-{
- unsigned int adr = sp->isac;
-
- /* 16.3 IOM 2 Mode */
- writereg(adr, ISAC_MASK, 0xff);
- writereg(adr, ISAC_ADF2, 0x80);
- writereg(adr, ISAC_SQXR, 0x2f);
- writereg(adr, ISAC_SPCR, 0x0);
- writereg(adr, ISAC_ADF1, 0x2);
- writereg(adr, ISAC_STCR, 0x70);
- writereg(adr, ISAC_MODE, 0xc9);
- writereg(adr, ISAC_TIMR, 0x0);
- writereg(adr, ISAC_ADF1, 0x0);
- writereg(adr, ISAC_CMDR, 0x41);
- writereg(adr, ISAC_CIX0, (1 << 2) | 3);
- writereg(adr, ISAC_MASK, 0xff);
- writereg(adr, ISAC_MASK, 0x0);
-}
-
-static void
-modehscx(struct HscxState *hs, int mode, int ichan)
-{
- struct IsdnCardState *sp = hs->sp;
- int hscx = hs->hscx;
-
- if (sp->debug & L1_DEB_HSCX) {
- char tmp[40];
- sprintf(tmp, "hscx %c mode %d ichan %d",
- 'A' + hscx, mode, ichan);
- debugl1(sp, tmp);
- }
- hs->mode = mode;
- writereg(sp->hscx[hscx], HSCX_CCR1, 0x85);
- writereg(sp->hscx[hscx], HSCX_XAD1, 0xFF);
- writereg(sp->hscx[hscx], HSCX_XAD2, 0xFF);
- writereg(sp->hscx[hscx], HSCX_RAH2, 0xFF);
- writereg(sp->hscx[hscx], HSCX_XBCH, 0x0);
- writereg(sp->hscx[hscx], HSCX_RLCR, 0x0);
-
- switch (mode) {
- case (0):
- writereg(sp->hscx[hscx], HSCX_CCR2, 0x30);
- writereg(sp->hscx[hscx], HSCX_TSAX, 0xff);
- writereg(sp->hscx[hscx], HSCX_TSAR, 0xff);
- writereg(sp->hscx[hscx], HSCX_XCCR, 7);
- writereg(sp->hscx[hscx], HSCX_RCCR, 7);
- writereg(sp->hscx[hscx], HSCX_MODE, 0x84);
- break;
- case (1):
- if (ichan == 0) {
- writereg(sp->hscx[hscx], HSCX_CCR2, 0x30);
- writereg(sp->hscx[hscx], HSCX_TSAX, 0x2f);
- writereg(sp->hscx[hscx], HSCX_TSAR, 0x2f);
- writereg(sp->hscx[hscx], HSCX_XCCR, 7);
- writereg(sp->hscx[hscx], HSCX_RCCR, 7);
- } else {
- writereg(sp->hscx[hscx], HSCX_CCR2, 0x30);
- writereg(sp->hscx[hscx], HSCX_TSAX, 0x3);
- writereg(sp->hscx[hscx], HSCX_TSAR, 0x3);
- writereg(sp->hscx[hscx], HSCX_XCCR, 7);
- writereg(sp->hscx[hscx], HSCX_RCCR, 7);
- }
- writereg(sp->hscx[hscx], HSCX_MODE, 0xe4);
- writereg(sp->hscx[hscx], HSCX_CMDR, 0x41);
- break;
- case (2):
- if (ichan == 0) {
- writereg(sp->hscx[hscx], HSCX_CCR2, 0x30);
- writereg(sp->hscx[hscx], HSCX_TSAX, 0x2f);
- writereg(sp->hscx[hscx], HSCX_TSAR, 0x2f);
- writereg(sp->hscx[hscx], HSCX_XCCR, 7);
- writereg(sp->hscx[hscx], HSCX_RCCR, 7);
- } else {
- writereg(sp->hscx[hscx], HSCX_CCR2, 0x30);
- writereg(sp->hscx[hscx], HSCX_TSAX, 0x3);
- writereg(sp->hscx[hscx], HSCX_TSAR, 0x3);
- writereg(sp->hscx[hscx], HSCX_XCCR, 7);
- writereg(sp->hscx[hscx], HSCX_RCCR, 7);
- }
- writereg(sp->hscx[hscx], HSCX_MODE, 0x8c);
- writereg(sp->hscx[hscx], HSCX_CMDR, 0x41);
- break;
- }
- writereg(sp->hscx[hscx], HSCX_ISTA, 0x00);
-}
-
inline static void
-release_ioregs(struct IsdnCard *card, int mask)
+release_ioregs(struct IsdnCardState *cs, int mask)
{
- release_region(card->sp->cfg_reg, 8);
+ release_region(cs->hw.avm.cfg_reg, 8);
if (mask & 1)
- release_region(card->sp->isac, 32);
+ release_region(cs->hw.avm.isac + 32, 32);
if (mask & 2)
- release_region(card->sp->isac - 0x400, 1);
+ release_region(cs->hw.avm.isacfifo, 1);
if (mask & 4)
- release_region(card->sp->hscx[0], 32);
+ release_region(cs->hw.avm.hscx[0] + 32, 32);
if (mask & 8)
- release_region(card->sp->hscx[0] - 0x400, 1);
+ release_region(cs->hw.avm.hscxfifo[0], 1);
if (mask & 0x10)
- release_region(card->sp->hscx[1], 32);
+ release_region(cs->hw.avm.hscx[1] + 32, 32);
if (mask & 0x20)
- release_region(card->sp->hscx[1] - 0x400, 1);
+ release_region(cs->hw.avm.hscxfifo[1], 1);
}
-void
-release_io_avm_a1(struct IsdnCard *card)
+static int
+AVM_card_msg(struct IsdnCardState *cs, int mt, void *arg)
{
- release_ioregs(card, 0x3f);
+ switch (mt) {
+ case CARD_RESET:
+ return(0);
+ case CARD_RELEASE:
+ release_ioregs(cs, 0x3f);
+ return(0);
+ case CARD_SETIRQ:
+ return(request_irq(cs->irq, &avm_a1_interrupt,
+ I4L_IRQ_FLAG, "HiSax", cs));
+ case CARD_INIT:
+ clear_pending_isac_ints(cs);
+ clear_pending_hscx_ints(cs);
+ initisac(cs);
+ inithscx(cs);
+ return(0);
+ case CARD_TEST:
+ return(0);
+ }
+ return(0);
}
-static void
-clear_pending_ints(struct IsdnCardState *sp)
+__initfunc(int
+setup_avm_a1(struct IsdnCard *card))
{
- int val;
- char tmp[64];
-
- val = readreg(sp->hscx[1], HSCX_ISTA);
- sprintf(tmp, "HSCX B ISTA %x", val);
- debugl1(sp, tmp);
- if (val & 0x01) {
- val = readreg(sp->hscx[1], HSCX_EXIR);
- sprintf(tmp, "HSCX B EXIR %x", val);
- debugl1(sp, tmp);
- } else if (val & 0x02) {
- val = readreg(sp->hscx[0], HSCX_EXIR);
- sprintf(tmp, "HSCX A EXIR %x", val);
- debugl1(sp, tmp);
- }
- val = readreg(sp->hscx[0], HSCX_ISTA);
- sprintf(tmp, "HSCX A ISTA %x", val);
- debugl1(sp, tmp);
- val = readreg(sp->hscx[1], HSCX_STAR);
- sprintf(tmp, "HSCX B STAR %x", val);
- debugl1(sp, tmp);
- val = readreg(sp->hscx[0], HSCX_STAR);
- sprintf(tmp, "HSCX A STAR %x", val);
- debugl1(sp, tmp);
- val = readreg(sp->isac, ISAC_STAR);
- sprintf(tmp, "ISAC STAR %x", val);
- debugl1(sp, tmp);
- val = readreg(sp->isac, ISAC_MODE);
- sprintf(tmp, "ISAC MODE %x", val);
- debugl1(sp, tmp);
- val = readreg(sp->isac, ISAC_ADF2);
- sprintf(tmp, "ISAC ADF2 %x", val);
- debugl1(sp, tmp);
- val = readreg(sp->isac, ISAC_ISTA);
- sprintf(tmp, "ISAC ISTA %x", val);
- debugl1(sp, tmp);
- if (val & 0x01) {
- val = readreg(sp->isac, ISAC_EXIR);
- sprintf(tmp, "ISAC EXIR %x", val);
- debugl1(sp, tmp);
- } else if (val & 0x04) {
- val = readreg(sp->isac, ISAC_CIR0);
- sprintf(tmp, "ISAC CIR0 %x", val);
- debugl1(sp, tmp);
- }
- writereg(sp->isac, ISAC_MASK, 0);
- writereg(sp->isac, ISAC_CMDR, 0x41);
-}
-
-int
-initavm_a1(struct IsdnCardState *sp)
-{
- int ret;
- int loop = 0;
- char tmp[40];
-
- sp->counter = kstat_irqs(sp->irq);
- sprintf(tmp, "IRQ %d count %d", sp->irq, sp->counter);
- debugl1(sp, tmp);
- clear_pending_ints(sp);
- ret = get_irq(sp->cardnr, &avm_a1_interrupt);
- if (ret) {
- initisac(sp);
- sp->modehscx(sp->hs, 0, 0);
- sp->modehscx(sp->hs + 1, 0, 0);
- while (loop++ < 10) {
- /* At least 1-3 irqs must happen
- * (one from HSCX A, one from HSCX B, 3rd from ISAC)
- */
- if (kstat_irqs(sp->irq) > sp->counter)
- break;
- current->state = TASK_INTERRUPTIBLE;
- current->timeout = jiffies + 1;
- schedule();
- }
- sprintf(tmp, "IRQ %d count %d", sp->irq,
- kstat_irqs(sp->irq));
- debugl1(sp, tmp);
- if (kstat_irqs(sp->irq) == sp->counter) {
- printk(KERN_WARNING
- "AVM A1: IRQ(%d) getting no interrupts during init\n",
- sp->irq);
- free_irq(sp->irq, sp);
- return (0);
- }
- }
- return (ret);
-}
-
-int
-setup_avm_a1(struct IsdnCard *card)
-{
- u_char val, verA, verB;
- struct IsdnCardState *sp = card->sp;
+ u_char val;
+ struct IsdnCardState *cs = card->cs;
long flags;
char tmp[64];
strcpy(tmp, avm_revision);
- printk(KERN_NOTICE "HiSax: AVM driver Rev. %s\n", HiSax_getrev(tmp));
- if (sp->typ != ISDN_CTYPE_A1)
+ printk(KERN_INFO "HiSax: AVM driver Rev. %s\n", HiSax_getrev(tmp));
+ if (cs->typ != ISDN_CTYPE_A1)
return (0);
- sp->cfg_reg = card->para[1] + 0x1800;
- sp->isac = card->para[1] + 0x1400;
- sp->hscx[0] = card->para[1] + 0x400;
- sp->hscx[1] = card->para[1] + 0xc00;
- sp->irq = card->para[0];
- if (check_region((sp->cfg_reg), 8)) {
+ cs->hw.avm.cfg_reg = card->para[1] + 0x1800;
+ cs->hw.avm.isac = card->para[1] + 0x1400 - 0x20;
+ cs->hw.avm.hscx[0] = card->para[1] + 0x400 - 0x20;
+ cs->hw.avm.hscx[1] = card->para[1] + 0xc00 - 0x20;
+ cs->hw.avm.isacfifo = card->para[1] + 0x1000;
+ cs->hw.avm.hscxfifo[0] = card->para[1];
+ cs->hw.avm.hscxfifo[1] = card->para[1] + 0x800;
+ cs->irq = card->para[0];
+ if (check_region((cs->hw.avm.cfg_reg), 8)) {
printk(KERN_WARNING
"HiSax: %s config port %x-%x already in use\n",
CardType[card->typ],
- sp->cfg_reg,
- sp->cfg_reg + 8);
+ cs->hw.avm.cfg_reg,
+ cs->hw.avm.cfg_reg + 8);
return (0);
} else {
- request_region(sp->cfg_reg, 8, "avm cfg");
+ request_region(cs->hw.avm.cfg_reg, 8, "avm cfg");
}
- if (check_region((sp->isac), 32)) {
+ if (check_region((cs->hw.avm.isac + 32), 32)) {
printk(KERN_WARNING
"HiSax: %s isac ports %x-%x already in use\n",
- CardType[sp->typ],
- sp->isac,
- sp->isac + 32);
- release_ioregs(card, 0);
+ CardType[cs->typ],
+ cs->hw.avm.isac + 32,
+ cs->hw.avm.isac + 64);
+ release_ioregs(cs, 0);
return (0);
} else {
- request_region(sp->isac, 32, "HiSax isac");
+ request_region(cs->hw.avm.isac + 32, 32, "HiSax isac");
}
- if (check_region((sp->isac - 0x400), 1)) {
+ if (check_region((cs->hw.avm.isacfifo), 1)) {
printk(KERN_WARNING
"HiSax: %s isac fifo port %x already in use\n",
- CardType[sp->typ],
- sp->isac - 0x400);
- release_ioregs(card, 1);
+ CardType[cs->typ],
+ cs->hw.avm.isacfifo);
+ release_ioregs(cs, 1);
return (0);
} else {
- request_region(sp->isac - 0x400, 1, "HiSax isac fifo");
+ request_region(cs->hw.avm.isacfifo, 1, "HiSax isac fifo");
}
- if (check_region((sp->hscx[0]), 32)) {
+ if (check_region((cs->hw.avm.hscx[0]) + 32, 32)) {
printk(KERN_WARNING
"HiSax: %s hscx A ports %x-%x already in use\n",
- CardType[sp->typ],
- sp->hscx[0],
- sp->hscx[0] + 32);
- release_ioregs(card, 3);
+ CardType[cs->typ],
+ cs->hw.avm.hscx[0] + 32,
+ cs->hw.avm.hscx[0] + 64);
+ release_ioregs(cs, 3);
return (0);
} else {
- request_region(sp->hscx[0], 32, "HiSax hscx A");
+ request_region(cs->hw.avm.hscx[0] + 32, 32, "HiSax hscx A");
}
- if (check_region((sp->hscx[0] - 0x400), 1)) {
+ if (check_region(cs->hw.avm.hscxfifo[0], 1)) {
printk(KERN_WARNING
"HiSax: %s hscx A fifo port %x already in use\n",
- CardType[sp->typ],
- sp->hscx[0] - 0x400);
- release_ioregs(card, 7);
+ CardType[cs->typ],
+ cs->hw.avm.hscxfifo[0]);
+ release_ioregs(cs, 7);
return (0);
} else {
- request_region(sp->hscx[0] - 0x400, 1, "HiSax hscx A fifo");
+ request_region(cs->hw.avm.hscxfifo[0], 1, "HiSax hscx A fifo");
}
- if (check_region((sp->hscx[1]), 32)) {
+ if (check_region(cs->hw.avm.hscx[1] + 32, 32)) {
printk(KERN_WARNING
"HiSax: %s hscx B ports %x-%x already in use\n",
- CardType[sp->typ],
- sp->hscx[1],
- sp->hscx[1] + 32);
- release_ioregs(card, 0xf);
+ CardType[cs->typ],
+ cs->hw.avm.hscx[1] + 32,
+ cs->hw.avm.hscx[1] + 64);
+ release_ioregs(cs, 0xf);
return (0);
} else {
- request_region(sp->hscx[1], 32, "HiSax hscx B");
+ request_region(cs->hw.avm.hscx[1] + 32, 32, "HiSax hscx B");
}
- if (check_region((sp->hscx[1] - 0x400), 1)) {
+ if (check_region(cs->hw.avm.hscxfifo[1], 1)) {
printk(KERN_WARNING
"HiSax: %s hscx B fifo port %x already in use\n",
- CardType[sp->typ],
- sp->hscx[1] - 0x400);
- release_ioregs(card, 0x1f);
+ CardType[cs->typ],
+ cs->hw.avm.hscxfifo[1]);
+ release_ioregs(cs, 0x1f);
return (0);
} else {
- request_region(sp->hscx[1] - 0x400, 1, "HiSax hscx B fifo");
+ request_region(cs->hw.avm.hscxfifo[1], 1, "HiSax hscx B fifo");
}
save_flags(flags);
- byteout(sp->cfg_reg, 0x0);
+ byteout(cs->hw.avm.cfg_reg, 0x0);
sti();
HZDELAY(HZ / 5 + 1);
- byteout(sp->cfg_reg, 0x1);
+ byteout(cs->hw.avm.cfg_reg, 0x1);
HZDELAY(HZ / 5 + 1);
- byteout(sp->cfg_reg, 0x0);
+ byteout(cs->hw.avm.cfg_reg, 0x0);
HZDELAY(HZ / 5 + 1);
- val = sp->irq;
+ val = cs->irq;
if (val == 9)
val = 2;
- byteout(sp->cfg_reg + 1, val);
+ byteout(cs->hw.avm.cfg_reg + 1, val);
HZDELAY(HZ / 5 + 1);
- byteout(sp->cfg_reg, 0x0);
+ byteout(cs->hw.avm.cfg_reg, 0x0);
HZDELAY(HZ / 5 + 1);
restore_flags(flags);
- val = bytein(sp->cfg_reg);
+ val = bytein(cs->hw.avm.cfg_reg);
printk(KERN_INFO "AVM A1: Byte at %x is %x\n",
- sp->cfg_reg, val);
- val = bytein(sp->cfg_reg + 3);
+ cs->hw.avm.cfg_reg, val);
+ val = bytein(cs->hw.avm.cfg_reg + 3);
printk(KERN_INFO "AVM A1: Byte at %x is %x\n",
- sp->cfg_reg + 3, val);
- val = bytein(sp->cfg_reg + 2);
+ cs->hw.avm.cfg_reg + 3, val);
+ val = bytein(cs->hw.avm.cfg_reg + 2);
printk(KERN_INFO "AVM A1: Byte at %x is %x\n",
- sp->cfg_reg + 2, val);
- byteout(sp->cfg_reg, 0x14);
- byteout(sp->cfg_reg, 0x18);
- val = bytein(sp->cfg_reg);
+ cs->hw.avm.cfg_reg + 2, val);
+ byteout(cs->hw.avm.cfg_reg, 0x1E);
+ val = bytein(cs->hw.avm.cfg_reg);
printk(KERN_INFO "AVM A1: Byte at %x is %x\n",
- sp->cfg_reg, val);
-
- printk(KERN_NOTICE
- "HiSax: %s config irq:%d cfg:%x\n",
- CardType[sp->typ], sp->irq,
- sp->cfg_reg);
- printk(KERN_NOTICE
- "HiSax: isac:%x/%x\n",
- sp->isac, sp->isac - 0x400);
- printk(KERN_NOTICE
- "HiSax: hscx A:%x/%x hscx B:%x/%x\n",
- sp->hscx[0], sp->hscx[0] - 0x400,
- sp->hscx[1], sp->hscx[1] - 0x400);
- verA = readreg(sp->hscx[0], HSCX_VSTR) & 0xf;
- verB = readreg(sp->hscx[1], HSCX_VSTR) & 0xf;
- printk(KERN_INFO "AVM A1: HSCX version A: %s B: %s\n",
- HscxVersion(verA), HscxVersion(verB));
- val = readreg(sp->isac, ISAC_RBCH);
- printk(KERN_INFO "AVM A1: ISAC %s\n",
- ISACVersion(val));
- if ((verA == 0) | (verA == 0xf) | (verB == 0) | (verB == 0xf)) {
+ cs->hw.avm.cfg_reg, val);
+
+ printk(KERN_INFO
+ "HiSax: %s config irq:%d cfg:0x%X\n",
+ CardType[cs->typ], cs->irq,
+ cs->hw.avm.cfg_reg);
+ printk(KERN_INFO
+ "HiSax: isac:0x%X/0x%X\n",
+ cs->hw.avm.isac + 32, cs->hw.avm.isacfifo);
+ printk(KERN_INFO
+ "HiSax: hscx A:0x%X/0x%X hscx B:0x%X/0x%X\n",
+ cs->hw.avm.hscx[0] + 32, cs->hw.avm.hscxfifo[0],
+ cs->hw.avm.hscx[1] + 32, cs->hw.avm.hscxfifo[1]);
+
+ cs->readisac = &ReadISAC;
+ cs->writeisac = &WriteISAC;
+ cs->readisacfifo = &ReadISACfifo;
+ cs->writeisacfifo = &WriteISACfifo;
+ cs->BC_Read_Reg = &ReadHSCX;
+ cs->BC_Write_Reg = &WriteHSCX;
+ cs->BC_Send_Data = &hscx_fill_fifo;
+ cs->cardmsg = &AVM_card_msg;
+ ISACVersion(cs, "AVM A1:");
+ if (HscxVersion(cs, "AVM A1:")) {
printk(KERN_WARNING
"AVM A1: wrong HSCX versions check IO address\n");
- release_io_avm_a1(card);
+ release_ioregs(cs, 0x3f);
return (0);
}
- sp->modehscx = &modehscx;
- sp->ph_command = &ph_command;
- sp->hscx_fill_fifo = &hscx_fill_fifo;
- sp->isac_fill_fifo = &isac_fill_fifo;
return (1);
}
diff --git a/drivers/isdn/hisax/callc.c b/drivers/isdn/hisax/callc.c
index fbf045574..6924e3f9e 100644
--- a/drivers/isdn/hisax/callc.c
+++ b/drivers/isdn/hisax/callc.c
@@ -1,4 +1,4 @@
-/* $Id: callc.c,v 1.30 1997/05/29 10:40:43 keil Exp $
+/* $Id: callc.c,v 2.13 1998/02/12 23:07:16 keil Exp $
* Author Karsten Keil (keil@temic-ech.spacenet.de)
* based on the teles driver from Jan den Ouden
@@ -7,96 +7,54 @@
* Fritz Elfert
*
* $Log: callc.c,v $
- * Revision 1.30 1997/05/29 10:40:43 keil
- * chanp->impair was uninitialised
+ * Revision 2.13 1998/02/12 23:07:16 keil
+ * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
*
- * Revision 1.29 1997/04/23 20:09:49 fritz
- * Removed tmp, used by removed debugging code.
+ * Revision 2.12 1998/02/09 10:55:54 keil
+ * New leased line mode
*
- * Revision 1.28 1997/04/21 13:42:25 keil
- * Remove unneeded debug
+ * Revision 2.11 1998/02/02 13:35:19 keil
+ * config B-channel delay
*
- * Revision 1.27 1997/04/16 14:21:01 keil
- * remove unused variable
+ * Revision 2.10 1997/11/06 17:09:15 keil
+ * New 2.1 init code
*
- * Revision 1.26 1997/04/13 19:55:21 keil
- * Changes in debugging code
+ * Revision 2.9 1997/10/29 19:01:58 keil
+ * new LL interface
*
- * Revision 1.25 1997/04/06 22:54:08 keil
- * Using SKB's
+ * Revision 2.8 1997/10/10 20:56:44 fritz
+ * New HL interface.
*
- * Revision 1.24 1997/03/05 11:28:03 keil
- * fixed undefined l2tei procedure
- * a layer1 release delete now the drel timer
+ * Revision 2.7 1997/10/01 09:21:28 fritz
+ * Removed old compatibility stuff for 2.0.X kernels.
+ * From now on, this code is for 2.1.X ONLY!
+ * Old stuff is still in the separate branch.
*
- * Revision 1.23 1997/03/04 23:07:42 keil
- * bugfix dial parameter
+ * Revision 2.6 1997/09/11 17:26:58 keil
+ * Open B-channel if here are incomming packets
*
- * Revision 1.22 1997/02/27 13:51:55 keil
- * Reset B-channel (dlc) statemachine in every release
+ * Revision 2.5 1997/08/07 17:46:05 keil
+ * Fix Incomming Call without broadcast
*
- * Revision 1.21 1997/02/19 09:24:27 keil
- * Bugfix: Hangup to LL if a ttyI rings
+ * Revision 2.4 1997/08/03 14:37:58 keil
+ * Activate Layer2 in PtP mode
*
- * Revision 1.20 1997/02/17 00:32:47 keil
- * Bugfix: No Busy reported to LL
+ * Revision 2.3 1997/07/31 19:23:40 keil
+ * LAYER2_WATCHING for PtP
*
- * Revision 1.19 1997/02/14 12:23:10 fritz
- * Added support for new insmod parameter handling.
+ * Revision 2.2 1997/07/31 11:48:18 keil
+ * experimental REJECT after ALERTING
*
- * Revision 1.18 1997/02/11 01:36:58 keil
- * Changed setup-interface (incoming and outgoing), cause reporting
+ * Revision 2.1 1997/07/30 17:12:59 keil
+ * more changes for 'One TEI per card'
*
- * Revision 1.17 1997/02/09 00:23:10 keil
- * new interface handling, one interface per card
- * some changes in debug and leased line mode
+ * Revision 2.0 1997/07/27 21:12:21 keil
+ * CRef based L3; new channel handling; many other stuff
*
- * Revision 1.16 1997/01/27 23:17:03 keil
- * delete timers while unloading
+ * Revision 1.31 1997/06/26 11:09:23 keil
+ * New managment and minor changes
*
- * Revision 1.15 1997/01/27 16:00:38 keil
- * D-channel shutdown delay; improved callback
- *
- * Revision 1.14 1997/01/21 22:16:39 keil
- * new statemachine; leased line support; cleanup for 2.0
- *
- * Revision 1.13 1996/12/08 19:51:17 keil
- * bugfixes from Pekka Sarnila
- *
- * Revision 1.12 1996/11/26 20:20:03 keil
- * fixed warning while compile
- *
- * Revision 1.11 1996/11/26 18:43:17 keil
- * change ioctl 555 --> 55 (555 didn't work)
- *
- * Revision 1.10 1996/11/26 18:06:07 keil
- * fixed missing break statement,ioctl 555 reset modcount
- *
- * Revision 1.9 1996/11/18 20:23:19 keil
- * log writebuf channel not open changed
- *
- * Revision 1.8 1996/11/06 17:43:17 keil
- * more changes for 2.1.X;block fixed ST_PRO_W
- *
- * Revision 1.7 1996/11/06 15:13:51 keil
- * typo 0x64 --->64 in debug code
- *
- * Revision 1.6 1996/11/05 19:40:33 keil
- * X.75 windowsize
- *
- * Revision 1.5 1996/10/30 10:11:06 keil
- * debugging LOCK changed;ST_REL_W EV_HANGUP added
- *
- * Revision 1.4 1996/10/27 22:20:16 keil
- * alerting bugfixes
- * no static b-channel<->channel mapping
- *
- * Revision 1.2 1996/10/16 21:29:45 keil
- * compile bug as "not module"
- * Callback with euro
- *
- * Revision 1.1 1996/10/13 20:04:50 keil
- * Initial revision
+ * old logs removed /KKe
*
*/
@@ -104,53 +62,63 @@
#include "hisax.h"
#ifdef MODULE
-#if (LINUX_VERSION_CODE < 0x020111)
-extern long mod_use_count_;
-#define MOD_USE_COUNT mod_use_count_
-#else
#define MOD_USE_COUNT ((&__this_module)->usecount)
-#endif
#endif /* MODULE */
-const char *l4_revision = "$Revision: 1.30 $";
+const char *lli_revision = "$Revision: 2.13 $";
extern struct IsdnCard cards[];
extern int nrcards;
extern void HiSax_mod_dec_use_count(void);
extern void HiSax_mod_inc_use_count(void);
-static int init_ds(struct Channel *chanp, int incoming);
-static void release_ds(struct Channel *chanp);
+static int init_b_st(struct Channel *chanp, int incoming);
+static void release_b_st(struct Channel *chanp);
static struct Fsm callcfsm =
-{NULL, 0, 0};
+{NULL, 0, 0, NULL, NULL};
static struct Fsm lcfsm =
-{NULL, 0, 0};
+{NULL, 0, 0, NULL, NULL};
static int chancount = 0;
-/* Flags for remembering action done in l4 */
-
-#define FLG_START_D 0x0001
-#define FLG_ESTAB_D 0x0002
-#define FLG_CALL_SEND 0x0004
-#define FLG_CALL_REC 0x0008
-#define FLG_CALL_ALERT 0x0010
-#define FLG_START_B 0x0020
-#define FLG_CONNECT_B 0x0040
-#define FLG_LL_DCONN 0x0080
-#define FLG_LL_BCONN 0x0100
-#define FLG_DISC_SEND 0x0200
-#define FLG_DISC_REC 0x0400
-#define FLG_REL_REC 0x0800
-
-#define SETBIT(flg, item) flg |= item
-#define RESBIT(flg, item) flg &= (~item)
+/* experimental REJECT after ALERTING for CALLBACK to beat the 4s delay */
+#define ALERT_REJECT 1
+
+/* Value to delay the sending of the first B-channel paket after CONNECT
+ * here is no value given by ITU, but experience shows that 300 ms will
+ * work on many networks, if you or your other side is behind local exchanges
+ * a greater value may be recommented. If the delay is to short the first paket
+ * will be lost and autodetect on many comercial routers goes wrong !
+ * You can adjust this value on runtime with
+ * hisaxctrl <id> 2 <value>
+ * value is in milliseconds
+ */
+#define DEFAULT_B_DELAY 300
+
+/* Flags for remembering action done in lli */
+
+#define FLG_START_D 0
+#define FLG_ESTAB_D 1
+#define FLG_CALL_SEND 2
+#define FLG_CALL_REC 3
+#define FLG_CALL_ALERT 4
+#define FLG_START_B 5
+#define FLG_CONNECT_B 6
+#define FLG_LL_DCONN 7
+#define FLG_LL_BCONN 8
+#define FLG_DISC_SEND 9
+#define FLG_DISC_REC 10
+#define FLG_REL_REC 11
+#define FLG_DO_ALERT 12
+#define FLG_DO_HANGUP 13
+#define FLG_DO_CONNECT 14
+#define FLG_DO_ESTAB 15
/*
* Because of callback it's a good idea to delay the shutdown of the d-channel
*/
-#define DREL_TIMER_VALUE 30000
+#define DREL_TIMER_VALUE 10000
/*
* Find card with given driverId
@@ -162,9 +130,9 @@ hisax_findcard(int driverid)
int i;
for (i = 0; i < nrcards; i++)
- if (cards[i].sp)
- if (cards[i].sp->myid == driverid)
- return (cards[i].sp);
+ if (cards[i].cs)
+ if (cards[i].cs->myid == driverid)
+ return (cards[i].cs);
return (struct IsdnCardState *) 0;
}
@@ -176,7 +144,7 @@ link_debug(struct Channel *chanp, char *s, int direction)
jiftime(tm, jiffies);
sprintf(tmp, "%s Channel %d %s %s\n", tm, chanp->chan,
direction ? "LL->HL" : "HL->LL", s);
- HiSax_putstatus(chanp->sp, tmp);
+ HiSax_putstatus(chanp->cs, tmp);
}
@@ -233,7 +201,7 @@ enum {
EV_SETUP_CMPL_IND, /* 10 */
EV_BC_EST, /* 11 */
EV_WRITEBUF, /* 12 */
- EV_DATAIN, /* 13 */
+ EV_ESTABLISH, /* 13 */
EV_HANGUP, /* 14 */
EV_BC_REL, /* 15 */
EV_CINF, /* 16 */
@@ -263,7 +231,7 @@ static char *strEvent[] =
"EV_SETUP_CMPL_IND",
"EV_BC_EST",
"EV_WRITEBUF",
- "EV_DATAIN",
+ "EV_ESTABLISH",
"EV_HANGUP",
"EV_BC_REL",
"EV_CINF",
@@ -283,7 +251,6 @@ enum {
ST_LC_ESTABLISH_WAIT,
ST_LC_CONNECTED,
ST_LC_FLUSH_WAIT,
- ST_LC_FLUSH_DELAY,
ST_LC_RELEASE_WAIT,
};
@@ -297,7 +264,6 @@ static char *strLcState[] =
"ST_LC_ESTABLISH_WAIT",
"ST_LC_CONNECTED",
"ST_LC_FLUSH_WAIT",
- "ST_LC_FLUSH_DELAY",
"ST_LC_RELEASE_WAIT",
};
@@ -307,9 +273,7 @@ enum {
EV_LC_PH_DEACTIVATE,
EV_LC_DL_ESTABLISH,
EV_LC_TIMER,
- EV_LC_DL_FLUSH,
EV_LC_DL_RELEASE,
- EV_LC_FLUSH,
EV_LC_RELEASE,
};
@@ -322,9 +286,7 @@ static char *strLcEvent[] =
"EV_LC_PH_DEACTIVATE",
"EV_LC_DL_ESTABLISH",
"EV_LC_TIMER",
- "EV_LC_DL_FLUSH",
"EV_LC_DL_RELEASE",
- "EV_LC_FLUSH",
"EV_LC_RELEASE",
};
@@ -332,788 +294,962 @@ static char *strLcEvent[] =
#define LC_B 1
static inline void
-l4_deliver_cause(struct Channel *chanp)
+lli_deliver_cause(struct Channel *chanp)
{
isdn_ctrl ic;
- if (chanp->para.cause < 0)
+ if (chanp->proc->para.cause < 0)
return;
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_CAUSE;
ic.arg = chanp->chan;
- if (chanp->sp->protocol == ISDN_PTYPE_EURO)
- sprintf(ic.parm.num, "E%02X%02X", chanp->para.loc & 0x7f,
- chanp->para.cause & 0x7f);
+ if (chanp->cs->protocol == ISDN_PTYPE_EURO)
+ sprintf(ic.parm.num, "E%02X%02X", chanp->proc->para.loc & 0x7f,
+ chanp->proc->para.cause & 0x7f);
else
- sprintf(ic.parm.num, "%02X%02X", chanp->para.loc & 0x7f,
- chanp->para.cause & 0x7f);
- chanp->sp->iif.statcallb(&ic);
+ sprintf(ic.parm.num, "%02X%02X", chanp->proc->para.loc & 0x7f,
+ chanp->proc->para.cause & 0x7f);
+ chanp->cs->iif.statcallb(&ic);
+}
+
+static void
+lli_d_established(struct FsmInst *fi, int event, void *arg)
+{
+ struct Channel *chanp = fi->userdata;
+
+ test_and_set_bit(FLG_ESTAB_D, &chanp->Flags);
+ if (chanp->leased) {
+ isdn_ctrl ic;
+ int ret;
+ char txt[32];
+
+ chanp->cs->cardmsg(chanp->cs, MDL_INFO_SETUP, (void *) chanp->chan);
+ FsmChangeState(fi, ST_IN_WAIT_LL);
+ test_and_set_bit(FLG_CALL_REC, &chanp->Flags);
+ if (chanp->debug & 1)
+ link_debug(chanp, "STAT_ICALL_LEASED", 0);
+ ic.driver = chanp->cs->myid;
+ ic.command = ISDN_STAT_ICALL;
+ ic.arg = chanp->chan;
+ ic.parm.setup.si1 = 7;
+ ic.parm.setup.si2 = 0;
+ ic.parm.setup.plan = 0;
+ ic.parm.setup.screen = 0;
+ sprintf(ic.parm.setup.eazmsn,"%d", chanp->chan + 1);
+ sprintf(ic.parm.setup.phone,"LEASED%d", chanp->cs->myid);
+ ret = chanp->cs->iif.statcallb(&ic);
+ if (chanp->debug & 1) {
+ sprintf(txt, "statcallb ret=%d", ret);
+ link_debug(chanp, txt, 1);
+ }
+ if (!ret) {
+ chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) chanp->chan);
+ FsmChangeState(fi, ST_NULL);
+ }
+ } else if (fi->state == ST_WAIT_DSHUTDOWN)
+ FsmChangeState(fi, ST_NULL);
+}
+
+static void
+lli_d_released(struct FsmInst *fi, int event, void *arg)
+{
+ struct Channel *chanp = fi->userdata;
+
+ test_and_clear_bit(FLG_START_D, &chanp->Flags);
}
/*
* Dial out
*/
static void
-l4_prep_dialout(struct FsmInst *fi, int event, void *arg)
+lli_prep_dialout(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
FsmChangeState(fi, ST_OUT_WAIT_D);
FsmDelTimer(&chanp->drel_timer, 60);
FsmDelTimer(&chanp->dial_timer, 73);
-
chanp->l2_active_protocol = chanp->l2_protocol;
chanp->incoming = 0;
- chanp->lc_b.l2_start = !0;
+ chanp->lc_b->l2_start = !0;
switch (chanp->l2_active_protocol) {
case (ISDN_PROTO_L2_X75I):
- chanp->lc_b.l2_establish = !0;
+ chanp->lc_b->l2_establish = !0;
break;
case (ISDN_PROTO_L2_HDLC):
case (ISDN_PROTO_L2_TRANS):
- chanp->lc_b.l2_establish = 0;
+ chanp->lc_b->l2_establish = 0;
break;
default:
- printk(KERN_WARNING "l4_prep_dialout unknown protocol\n");
+ printk(KERN_WARNING "lli_prep_dialout unknown protocol\n");
break;
}
- if (chanp->Flags & FLG_ESTAB_D) {
+ if (test_bit(FLG_ESTAB_D, &chanp->Flags)) {
FsmEvent(fi, EV_DLEST, NULL);
} else {
- chanp->Flags = FLG_START_D;
+ chanp->Flags = 0;
+ test_and_set_bit(FLG_START_D, &chanp->Flags);
if (chanp->leased) {
- chanp->lc_d.l2_establish = 0;
+ chanp->lc_d->l2_establish = 0;
}
- FsmEvent(&chanp->lc_d.lcfi, EV_LC_ESTABLISH, NULL);
+ FsmEvent(&chanp->lc_d->lcfi, EV_LC_ESTABLISH, NULL);
}
}
static void
-l4_do_dialout(struct FsmInst *fi, int event, void *arg)
+lli_do_dialout(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
FsmChangeState(fi, ST_OUT_DIAL);
+ chanp->cs->cardmsg(chanp->cs, MDL_INFO_SETUP, (void *) chanp->chan);
if (chanp->leased) {
- chanp->para.bchannel = (chanp->chan & 1) + 1;
FsmEvent(&chanp->fi, EV_SETUP_CNF, NULL);
} else {
- SETBIT(chanp->Flags, FLG_ESTAB_D);
- chanp->para.callref = chanp->outcallref;
- chanp->outcallref++;
- if (chanp->outcallref == 128)
- chanp->outcallref = 64;
- chanp->is.l4.l4l3(&chanp->is, CC_SETUP_REQ, NULL);
- SETBIT(chanp->Flags, FLG_CALL_SEND);
+ test_and_set_bit(FLG_ESTAB_D, &chanp->Flags);
+ chanp->d_st->lli.l4l3(chanp->d_st, CC_SETUP_REQ, chanp);
+ test_and_set_bit(FLG_CALL_SEND, &chanp->Flags);
}
}
static void
-l4_init_bchan_out(struct FsmInst *fi, int event, void *arg)
+lli_init_bchan_out(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
FsmChangeState(fi, ST_WAIT_BCONN);
- SETBIT(chanp->Flags, FLG_LL_DCONN);
+ test_and_set_bit(FLG_LL_DCONN, &chanp->Flags);
if (chanp->debug & 1)
link_debug(chanp, "STAT_DCONN", 0);
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_DCONN;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
- init_ds(chanp, 0);
- SETBIT(chanp->Flags, FLG_START_B);
- FsmEvent(&chanp->lc_b.lcfi, EV_LC_ESTABLISH, NULL);
+ chanp->cs->iif.statcallb(&ic);
+ init_b_st(chanp, 0);
+ test_and_set_bit(FLG_START_B, &chanp->Flags);
+ FsmEvent(&chanp->lc_b->lcfi, EV_LC_ESTABLISH, NULL);
}
static void
-l4_go_active(struct FsmInst *fi, int event, void *arg)
+lli_go_active(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
FsmChangeState(fi, ST_ACTIVE);
chanp->data_open = !0;
- SETBIT(chanp->Flags, FLG_CONNECT_B);
+ test_and_set_bit(FLG_CONNECT_B, &chanp->Flags);
if (chanp->debug & 1)
link_debug(chanp, "STAT_BCONN", 0);
- SETBIT(chanp->Flags, FLG_LL_BCONN);
- ic.driver = chanp->sp->myid;
+ test_and_set_bit(FLG_LL_BCONN, &chanp->Flags);
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_BCONN;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ chanp->cs->iif.statcallb(&ic);
+ chanp->cs->cardmsg(chanp->cs, MDL_INFO_CONN, (void *) chanp->chan);
}
/* incomming call */
static void
-l4_start_dchan(struct FsmInst *fi, int event, void *arg)
+lli_start_dchan(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
FsmChangeState(fi, ST_IN_WAIT_D);
FsmDelTimer(&chanp->drel_timer, 61);
- if (chanp->Flags & FLG_ESTAB_D) {
+ if (event == EV_ACCEPTD)
+ test_and_set_bit(FLG_DO_CONNECT, &chanp->Flags);
+ else if (event == EV_HANGUP) {
+ test_and_set_bit(FLG_DO_HANGUP, &chanp->Flags);
+#ifdef ALERT_REJECT
+ test_and_set_bit(FLG_DO_ALERT, &chanp->Flags);
+#endif
+ }
+ if (test_bit(FLG_ESTAB_D, &chanp->Flags)) {
FsmEvent(fi, EV_DLEST, NULL);
- } else {
- chanp->Flags = FLG_START_D;
- FsmEvent(&chanp->lc_d.lcfi, EV_LC_ESTABLISH, NULL);
- }
+ } else if (!test_and_set_bit(FLG_START_D, &chanp->Flags))
+ FsmEvent(&chanp->lc_d->lcfi, EV_LC_ESTABLISH, NULL);
}
static void
-l4_deliver_call(struct FsmInst *fi, int event, void *arg)
+lli_deliver_call(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
int ret;
char txt[32];
+ chanp->cs->cardmsg(chanp->cs, MDL_INFO_SETUP, (void *) chanp->chan);
/*
* Report incoming calls only once to linklevel, use CallFlags
* which is set to 3 with each broadcast message in isdnl1.c
* and resetted if a interface answered the STAT_ICALL.
*/
- if ((chanp->sp) && (chanp->sp->CallFlags == 3)) {
+ if (1) { /* for only one TEI */
FsmChangeState(fi, ST_IN_WAIT_LL);
- SETBIT(chanp->Flags, FLG_ESTAB_D);
- SETBIT(chanp->Flags, FLG_CALL_REC);
+ test_and_set_bit(FLG_CALL_REC, &chanp->Flags);
if (chanp->debug & 1)
link_debug(chanp, "STAT_ICALL", 0);
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_ICALL;
ic.arg = chanp->chan;
/*
* No need to return "unknown" for calls without OAD,
* cause that's handled in linklevel now (replaced by '0')
*/
- ic.parm.setup = chanp->para.setup;
- ret = chanp->sp->iif.statcallb(&ic);
+ ic.parm.setup = chanp->proc->para.setup;
+ ret = chanp->cs->iif.statcallb(&ic);
if (chanp->debug & 1) {
sprintf(txt, "statcallb ret=%d", ret);
link_debug(chanp, txt, 1);
}
- if (ret) /* if a interface knows this call, reset the CallFlag
- * to avoid a second Call report to the linklevel
- */
- chanp->sp->CallFlags &= ~(chanp->chan + 1);
switch (ret) {
case 1: /* OK, anybody likes this call */
- FsmChangeState(fi, ST_IN_ALERT_SEND);
- SETBIT(chanp->Flags, FLG_CALL_ALERT);
- chanp->is.l4.l4l3(&chanp->is, CC_ALERTING_REQ, NULL);
+ FsmDelTimer(&chanp->drel_timer, 61);
+ if (test_bit(FLG_ESTAB_D, &chanp->Flags)) {
+ FsmChangeState(fi, ST_IN_ALERT_SEND);
+ test_and_set_bit(FLG_CALL_ALERT, &chanp->Flags);
+ chanp->d_st->lli.l4l3(chanp->d_st, CC_ALERTING_REQ, chanp->proc);
+ } else {
+ test_and_set_bit(FLG_DO_ALERT, &chanp->Flags);
+ FsmChangeState(fi, ST_IN_WAIT_D);
+ test_and_set_bit(FLG_START_D, &chanp->Flags);
+ FsmEvent(&chanp->lc_d->lcfi, EV_LC_ESTABLISH, NULL);
+ }
break;
case 2: /* Rejecting Call */
- RESBIT(chanp->Flags, FLG_CALL_REC);
+ test_and_clear_bit(FLG_CALL_REC, &chanp->Flags);
break;
case 0: /* OK, nobody likes this call */
default: /* statcallb problems */
- chanp->is.l4.l4l3(&chanp->is, CC_IGNORE, NULL);
+ chanp->d_st->lli.l4l3(chanp->d_st, CC_IGNORE, chanp->proc);
+ chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) chanp->chan);
FsmChangeState(fi, ST_NULL);
- chanp->Flags = FLG_ESTAB_D;
- FsmAddTimer(&chanp->drel_timer, DREL_TIMER_VALUE, EV_SHUTDOWN_D, NULL, 61);
+#ifndef LAYER2_WATCHING
+ if (test_bit(FLG_ESTAB_D, &chanp->Flags))
+ FsmRestartTimer(&chanp->drel_timer, DREL_TIMER_VALUE, EV_SHUTDOWN_D, NULL, 61);
+#endif
break;
}
} else {
- chanp->is.l4.l4l3(&chanp->is, CC_IGNORE, NULL);
+ chanp->d_st->lli.l4l3(chanp->d_st, CC_IGNORE, chanp->proc);
+ chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) chanp->chan);
+ FsmChangeState(fi, ST_NULL);
+#ifndef LAYER2_WATCHING
+ if (test_bit(FLG_ESTAB_D, &chanp->Flags))
+ FsmRestartTimer(&chanp->drel_timer, DREL_TIMER_VALUE, EV_SHUTDOWN_D, NULL, 62);
+#endif
+ }
+}
+
+static void
+lli_establish_d(struct FsmInst *fi, int event, void *arg)
+{
+ /* This establish the D-channel for pending L3 messages
+ * without blocking th channel
+ */
+ struct Channel *chanp = fi->userdata;
+
+ test_and_set_bit(FLG_DO_ESTAB, &chanp->Flags);
+ FsmChangeState(fi, ST_IN_WAIT_D);
+ test_and_set_bit(FLG_START_D, &chanp->Flags);
+ FsmEvent(&chanp->lc_d->lcfi, EV_LC_ESTABLISH, NULL);
+}
+
+static void
+lli_do_action(struct FsmInst *fi, int event, void *arg)
+{
+ struct Channel *chanp = fi->userdata;
+
+ test_and_set_bit(FLG_ESTAB_D, &chanp->Flags);
+ if (chanp->leased) {
+ FsmChangeState(fi, ST_IN_WAIT_CONN_ACK);
+ test_and_clear_bit(FLG_DO_ALERT, &chanp->Flags);
+ test_and_clear_bit(FLG_DO_CONNECT, &chanp->Flags);
+ FsmEvent(&chanp->fi, EV_SETUP_CMPL_IND, NULL);
+ } else if (test_and_clear_bit(FLG_DO_CONNECT, &chanp->Flags) &&
+ !test_bit(FLG_DO_HANGUP, &chanp->Flags)) {
+ FsmChangeState(fi, ST_IN_WAIT_CONN_ACK);
+ test_and_clear_bit(FLG_DO_ALERT, &chanp->Flags);
+ chanp->d_st->lli.l4l3(chanp->d_st, CC_SETUP_RSP, chanp->proc);
+ } else if (test_and_clear_bit(FLG_DO_ALERT, &chanp->Flags)) {
+ if (test_bit(FLG_DO_HANGUP, &chanp->Flags))
+ FsmRestartTimer(&chanp->drel_timer, 40, EV_HANGUP, NULL, 63);
+ FsmChangeState(fi, ST_IN_ALERT_SEND);
+ test_and_set_bit(FLG_CALL_ALERT, &chanp->Flags);
+ chanp->d_st->lli.l4l3(chanp->d_st, CC_ALERTING_REQ, chanp->proc);
+ } else if (test_and_clear_bit(FLG_DO_HANGUP, &chanp->Flags)) {
+ FsmChangeState(fi, ST_WAIT_DRELEASE);
+ chanp->proc->para.cause = 0x15; /* Call Rejected */
+ chanp->d_st->lli.l4l3(chanp->d_st, CC_REJECT_REQ, chanp->proc);
+ test_and_set_bit(FLG_DISC_SEND, &chanp->Flags);
+ } else if (test_and_clear_bit(FLG_DO_ESTAB, &chanp->Flags)) {
FsmChangeState(fi, ST_NULL);
- chanp->Flags = FLG_ESTAB_D;
- FsmAddTimer(&chanp->drel_timer, DREL_TIMER_VALUE, EV_SHUTDOWN_D, NULL, 62);
+ chanp->Flags = 0;
+ test_and_set_bit(FLG_ESTAB_D, &chanp->Flags);
+ chanp->d_st->lli.l4l3(chanp->d_st, CC_ESTABLISH, chanp->proc);
+ chanp->proc = NULL;
+#ifndef LAYER2_WATCHING
+ FsmAddTimer(&chanp->drel_timer, DREL_TIMER_VALUE, EV_SHUTDOWN_D, NULL, 60);
+#endif
}
}
static void
-l4_send_dconnect(struct FsmInst *fi, int event, void *arg)
+lli_send_dconnect(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
FsmChangeState(fi, ST_IN_WAIT_CONN_ACK);
- chanp->is.l4.l4l3(&chanp->is, CC_SETUP_RSP, NULL);
+ chanp->d_st->lli.l4l3(chanp->d_st, CC_SETUP_RSP, chanp->proc);
}
static void
-l4_init_bchan_in(struct FsmInst *fi, int event, void *arg)
+lli_init_bchan_in(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
FsmChangeState(fi, ST_WAIT_BCONN);
- SETBIT(chanp->Flags, FLG_LL_DCONN);
+ test_and_set_bit(FLG_LL_DCONN, &chanp->Flags);
if (chanp->debug & 1)
link_debug(chanp, "STAT_DCONN", 0);
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_DCONN;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ chanp->cs->iif.statcallb(&ic);
chanp->l2_active_protocol = chanp->l2_protocol;
chanp->incoming = !0;
- chanp->lc_b.l2_start = 0;
+ chanp->lc_b->l2_start = 0;
switch (chanp->l2_active_protocol) {
case (ISDN_PROTO_L2_X75I):
- chanp->lc_b.l2_establish = !0;
+ chanp->lc_b->l2_establish = !0;
break;
case (ISDN_PROTO_L2_HDLC):
case (ISDN_PROTO_L2_TRANS):
- chanp->lc_b.l2_establish = 0;
+ chanp->lc_b->l2_establish = 0;
break;
default:
- printk(KERN_WARNING "r9 unknown protocol\n");
+ printk(KERN_WARNING "bchannel unknown protocol\n");
break;
}
- init_ds(chanp, !0);
- SETBIT(chanp->Flags, FLG_START_B);
- FsmEvent(&chanp->lc_b.lcfi, EV_LC_ESTABLISH, NULL);
+ init_b_st(chanp, !0);
+ test_and_set_bit(FLG_START_B, &chanp->Flags);
+ FsmEvent(&chanp->lc_b->lcfi, EV_LC_ESTABLISH, NULL);
}
/* Call clearing */
static void
-l4_reject_call(struct FsmInst *fi, int event, void *arg)
-{
- struct Channel *chanp = fi->userdata;
-
- FsmChangeState(fi, ST_WAIT_DRELEASE);
- chanp->para.cause = 0x15; /* Call Rejected */
- chanp->is.l4.l4l3(&chanp->is, CC_REJECT_REQ, NULL);
- SETBIT(chanp->Flags, FLG_DISC_SEND);
-}
-
-static void
-l4_cancel_call(struct FsmInst *fi, int event, void *arg)
+lli_cancel_call(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
FsmChangeState(fi, ST_WAIT_DRELEASE);
- if (chanp->Flags & FLG_LL_BCONN) {
+ if (test_and_clear_bit(FLG_LL_BCONN, &chanp->Flags)) {
if (chanp->debug & 1)
link_debug(chanp, "STAT_BHUP", 0);
- RESBIT(chanp->Flags, FLG_LL_BCONN);
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_BHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
- }
- if (chanp->Flags & FLG_START_B) {
- release_ds(chanp);
- RESBIT(chanp->Flags, FLG_START_B);
+ chanp->cs->iif.statcallb(&ic);
}
- chanp->para.cause = 0x10; /* Normal Call Clearing */
- chanp->is.l4.l4l3(&chanp->is, CC_DISCONNECT_REQ, NULL);
- SETBIT(chanp->Flags, FLG_DISC_SEND);
+ if (test_and_clear_bit(FLG_START_B, &chanp->Flags))
+ release_b_st(chanp);
+ chanp->proc->para.cause = 0x10; /* Normal Call Clearing */
+ chanp->d_st->lli.l4l3(chanp->d_st, CC_DISCONNECT_REQ, chanp->proc);
+ test_and_set_bit(FLG_DISC_SEND, &chanp->Flags);
}
static void
-l4_shutdown_d(struct FsmInst *fi, int event, void *arg)
+lli_shutdown_d(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
- FsmChangeState(fi, ST_WAIT_DSHUTDOWN);
FsmDelTimer(&chanp->drel_timer, 62);
- RESBIT(chanp->Flags, FLG_ESTAB_D);
- FsmEvent(&chanp->lc_d.lcfi, EV_LC_RELEASE, NULL);
+#ifdef LAYER2_WATCHING
+ FsmChangeState(fi, ST_NULL);
+#else
+ if (!test_bit(FLG_TWO_DCHAN, &chanp->cs->HW_Flags)) {
+ if (chanp->chan) {
+ if (chanp->cs->channel[0].fi.state != ST_NULL)
+ return;
+ } else {
+ if (chanp->cs->channel[1].fi.state != ST_NULL)
+ return;
+ }
+ }
+ FsmChangeState(fi, ST_WAIT_DSHUTDOWN);
+ test_and_clear_bit(FLG_ESTAB_D, &chanp->Flags);
+ FsmEvent(&chanp->lc_d->lcfi, EV_LC_RELEASE, NULL);
+#endif
}
static void
-l4_timeout_d(struct FsmInst *fi, int event, void *arg)
+lli_timeout_d(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
- if (chanp->Flags & FLG_LL_DCONN) {
+ if (test_and_clear_bit(FLG_LL_DCONN, &chanp->Flags)) {
if (chanp->debug & 1)
link_debug(chanp, "STAT_DHUP", 0);
- RESBIT(chanp->Flags, FLG_LL_DCONN);
- l4_deliver_cause(chanp);
- ic.driver = chanp->sp->myid;
+ lli_deliver_cause(chanp);
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_DHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ chanp->cs->iif.statcallb(&ic);
}
FsmChangeState(fi, ST_NULL);
- chanp->Flags = FLG_ESTAB_D;
+ chanp->Flags = 0;
+ test_and_set_bit(FLG_ESTAB_D, &chanp->Flags);
+#ifndef LAYER2_WATCHING
FsmAddTimer(&chanp->drel_timer, DREL_TIMER_VALUE, EV_SHUTDOWN_D, NULL, 60);
+#endif
+ chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) chanp->chan);
}
static void
-l4_go_null(struct FsmInst *fi, int event, void *arg)
+lli_go_null(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
FsmChangeState(fi, ST_NULL);
chanp->Flags = 0;
FsmDelTimer(&chanp->drel_timer, 63);
+ chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) chanp->chan);
}
static void
-l4_disconn_bchan(struct FsmInst *fi, int event, void *arg)
+lli_disconn_bchan(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
chanp->data_open = 0;
FsmChangeState(fi, ST_WAIT_BRELEASE);
- RESBIT(chanp->Flags, FLG_CONNECT_B);
- FsmEvent(&chanp->lc_b.lcfi, EV_LC_RELEASE, NULL);
+ test_and_clear_bit(FLG_CONNECT_B, &chanp->Flags);
+ FsmEvent(&chanp->lc_b->lcfi, EV_LC_RELEASE, NULL);
}
static void
-l4_send_d_disc(struct FsmInst *fi, int event, void *arg)
+lli_send_d_disc(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
-
- if (chanp->Flags & (FLG_DISC_REC | FLG_REL_REC))
+ if (test_bit(FLG_DISC_REC, &chanp->Flags) ||
+ test_bit(FLG_REL_REC, &chanp->Flags))
return;
FsmChangeState(fi, ST_WAIT_DRELEASE);
- if (chanp->Flags & FLG_LL_BCONN) {
+ if (test_and_clear_bit(FLG_LL_BCONN, &chanp->Flags)) {
if (chanp->debug & 1)
link_debug(chanp, "STAT_BHUP", 0);
- RESBIT(chanp->Flags, FLG_LL_BCONN);
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_BHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ chanp->cs->iif.statcallb(&ic);
}
- if (chanp->Flags & FLG_START_B) {
- release_ds(chanp);
- RESBIT(chanp->Flags, FLG_START_B);
+ if (test_and_clear_bit(FLG_START_B, &chanp->Flags))
+ release_b_st(chanp);
+ if (chanp->leased) {
+ ic.command = ISDN_STAT_CAUSE;
+ ic.arg = chanp->chan;
+ sprintf(ic.parm.num, "L0010");
+ chanp->cs->iif.statcallb(&ic);
+ if (chanp->debug & 1)
+ link_debug(chanp, "STAT_DHUP", 0);
+ ic.driver = chanp->cs->myid;
+ ic.command = ISDN_STAT_DHUP;
+ ic.arg = chanp->chan;
+ chanp->cs->iif.statcallb(&ic);
+ FsmChangeState(fi, ST_WAIT_DSHUTDOWN);
+ test_and_clear_bit(FLG_ESTAB_D, &chanp->Flags);
+ FsmEvent(&chanp->lc_d->lcfi, EV_LC_RELEASE, NULL);
+ } else {
+ if (test_and_clear_bit(FLG_DO_HANGUP, &chanp->Flags))
+ chanp->proc->para.cause = 0x15; /* Call Reject */
+ else
+ chanp->proc->para.cause = 0x10; /* Normal Call Clearing */
+ chanp->d_st->lli.l4l3(chanp->d_st, CC_DISCONNECT_REQ, chanp->proc);
+ test_and_set_bit(FLG_DISC_SEND, &chanp->Flags);
}
- chanp->para.cause = 0x10; /* Normal Call Clearing */
- chanp->is.l4.l4l3(&chanp->is, CC_DISCONNECT_REQ, NULL);
- SETBIT(chanp->Flags, FLG_DISC_SEND);
}
static void
-l4_released_bchan(struct FsmInst *fi, int event, void *arg)
+lli_released_bchan(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
FsmChangeState(fi, ST_WAIT_DCOMMAND);
chanp->data_open = 0;
- if (chanp->Flags & FLG_LL_BCONN) {
+ if (test_and_clear_bit(FLG_LL_BCONN, &chanp->Flags)) {
if (chanp->debug & 1)
link_debug(chanp, "STAT_BHUP", 0);
- RESBIT(chanp->Flags, FLG_LL_BCONN);
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_BHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ chanp->cs->iif.statcallb(&ic);
}
- release_ds(chanp);
- RESBIT(chanp->Flags, FLG_START_B);
+ release_b_st(chanp);
+ test_and_clear_bit(FLG_START_B, &chanp->Flags);
}
static void
-l4_release_bchan(struct FsmInst *fi, int event, void *arg)
+lli_release_bchan(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
chanp->data_open = 0;
- SETBIT(chanp->Flags, FLG_DISC_REC);
+ test_and_set_bit(FLG_DISC_REC, &chanp->Flags);
FsmChangeState(fi, ST_WAIT_BREL_DISC);
- RESBIT(chanp->Flags, FLG_CONNECT_B);
- FsmEvent(&chanp->lc_b.lcfi, EV_LC_RELEASE, NULL);
+ test_and_clear_bit(FLG_CONNECT_B, &chanp->Flags);
+ FsmEvent(&chanp->lc_b->lcfi, EV_LC_RELEASE, NULL);
}
static void
-l4_received_d_rel(struct FsmInst *fi, int event, void *arg)
+lli_received_d_rel(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
chanp->data_open = 0;
- FsmChangeState(fi, ST_WAIT_DSHUTDOWN);
- SETBIT(chanp->Flags, FLG_REL_REC);
- if (chanp->Flags & FLG_CONNECT_B) {
- chanp->lc_b.l2_establish = 0; /* direct reset in lc_b.lcfi */
- FsmEvent(&chanp->lc_b.lcfi, EV_LC_RELEASE, NULL);
- RESBIT(chanp->Flags, FLG_CONNECT_B);
+ FsmChangeState(fi, ST_NULL);
+ test_and_set_bit(FLG_REL_REC, &chanp->Flags);
+ if (test_and_clear_bit(FLG_CONNECT_B, &chanp->Flags)) {
+ chanp->lc_b->l2_establish = 0; /* direct reset in lc_b->lcfi */
+ FsmEvent(&chanp->lc_b->lcfi, EV_LC_RELEASE, NULL);
}
- if (chanp->Flags & FLG_LL_BCONN) {
+ if (test_and_clear_bit(FLG_LL_BCONN, &chanp->Flags)) {
if (chanp->debug & 1)
link_debug(chanp, "STAT_BHUP", 0);
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_BHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
- RESBIT(chanp->Flags, FLG_LL_BCONN);
- }
- if (chanp->Flags & FLG_START_B) {
- release_ds(chanp);
- RESBIT(chanp->Flags, FLG_START_B);
+ chanp->cs->iif.statcallb(&ic);
}
- if (chanp->Flags & (FLG_LL_DCONN | FLG_CALL_SEND | FLG_CALL_ALERT)) {
+ if (test_and_clear_bit(FLG_START_B, &chanp->Flags))
+ release_b_st(chanp);
+ if (test_bit(FLG_LL_DCONN, &chanp->Flags) ||
+ test_bit(FLG_CALL_SEND, &chanp->Flags) ||
+ test_bit(FLG_CALL_ALERT, &chanp->Flags)) {
if (chanp->debug & 1)
link_debug(chanp, "STAT_DHUP", 0);
- l4_deliver_cause(chanp);
- ic.driver = chanp->sp->myid;
+ lli_deliver_cause(chanp);
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_DHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ chanp->cs->iif.statcallb(&ic);
}
- FsmEvent(&chanp->lc_d.lcfi, EV_LC_FLUSH, NULL);
- RESBIT(chanp->Flags, FLG_ESTAB_D);
- RESBIT(chanp->Flags, FLG_DISC_SEND);
- RESBIT(chanp->Flags, FLG_CALL_REC);
- RESBIT(chanp->Flags, FLG_CALL_ALERT);
- RESBIT(chanp->Flags, FLG_LL_DCONN);
- RESBIT(chanp->Flags, FLG_CALL_SEND);
+ test_and_clear_bit(FLG_DISC_SEND, &chanp->Flags);
+ test_and_clear_bit(FLG_CALL_REC, &chanp->Flags);
+ test_and_clear_bit(FLG_CALL_ALERT, &chanp->Flags);
+ test_and_clear_bit(FLG_LL_DCONN, &chanp->Flags);
+ test_and_clear_bit(FLG_CALL_SEND, &chanp->Flags);
+ lli_timeout_d(fi, event, arg);
}
static void
-l4_received_d_relcnf(struct FsmInst *fi, int event, void *arg)
+lli_received_d_relcnf(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
chanp->data_open = 0;
- FsmChangeState(fi, ST_WAIT_DSHUTDOWN);
- if (chanp->Flags & FLG_CONNECT_B) {
- chanp->lc_b.l2_establish = 0; /* direct reset in lc_b.lcfi */
- FsmEvent(&chanp->lc_b.lcfi, EV_LC_RELEASE, NULL);
- RESBIT(chanp->Flags, FLG_CONNECT_B);
+ FsmChangeState(fi, ST_NULL);
+ if (test_and_clear_bit(FLG_CONNECT_B, &chanp->Flags)) {
+ chanp->lc_b->l2_establish = 0; /* direct reset in lc_b->lcfi */
+ FsmEvent(&chanp->lc_b->lcfi, EV_LC_RELEASE, NULL);
}
- if (chanp->Flags & FLG_LL_BCONN) {
+ if (test_and_clear_bit(FLG_LL_BCONN, &chanp->Flags)) {
if (chanp->debug & 1)
link_debug(chanp, "STAT_BHUP", 0);
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_BHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
- RESBIT(chanp->Flags, FLG_LL_BCONN);
+ chanp->cs->iif.statcallb(&ic);
}
- if (chanp->Flags & FLG_START_B) {
- release_ds(chanp);
- RESBIT(chanp->Flags, FLG_START_B);
- }
- if (chanp->Flags & (FLG_LL_DCONN | FLG_CALL_SEND | FLG_CALL_ALERT)) {
+ if (test_and_clear_bit(FLG_START_B, &chanp->Flags))
+ release_b_st(chanp);
+ if (test_bit(FLG_LL_DCONN, &chanp->Flags) ||
+ test_bit(FLG_CALL_SEND, &chanp->Flags) ||
+ test_bit(FLG_CALL_ALERT, &chanp->Flags)) {
if (chanp->debug & 1)
link_debug(chanp, "STAT_DHUP", 0);
- l4_deliver_cause(chanp);
- ic.driver = chanp->sp->myid;
+ lli_deliver_cause(chanp);
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_DHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ chanp->cs->iif.statcallb(&ic);
}
- FsmEvent(&chanp->lc_d.lcfi, EV_LC_RELEASE, NULL);
- RESBIT(chanp->Flags, FLG_ESTAB_D);
- RESBIT(chanp->Flags, FLG_DISC_SEND);
- RESBIT(chanp->Flags, FLG_CALL_REC);
- RESBIT(chanp->Flags, FLG_CALL_ALERT);
- RESBIT(chanp->Flags, FLG_LL_DCONN);
- RESBIT(chanp->Flags, FLG_CALL_SEND);
+ test_and_clear_bit(FLG_DISC_SEND, &chanp->Flags);
+ test_and_clear_bit(FLG_CALL_REC, &chanp->Flags);
+ test_and_clear_bit(FLG_CALL_ALERT, &chanp->Flags);
+ test_and_clear_bit(FLG_LL_DCONN, &chanp->Flags);
+ test_and_clear_bit(FLG_CALL_SEND, &chanp->Flags);
+ lli_timeout_d(fi, event, arg);
}
static void
-l4_received_d_disc(struct FsmInst *fi, int event, void *arg)
+lli_received_d_disc(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
chanp->data_open = 0;
FsmChangeState(fi, ST_WAIT_D_REL_CNF);
- SETBIT(chanp->Flags, FLG_DISC_REC);
- if (chanp->Flags & FLG_LL_BCONN) {
+ test_and_set_bit(FLG_DISC_REC, &chanp->Flags);
+ if (test_and_clear_bit(FLG_LL_BCONN, &chanp->Flags)) {
if (chanp->debug & 1)
link_debug(chanp, "STAT_BHUP", 0);
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_BHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
- RESBIT(chanp->Flags, FLG_LL_BCONN);
- }
- if (chanp->Flags & FLG_START_B) {
- release_ds(chanp);
- RESBIT(chanp->Flags, FLG_START_B);
+ chanp->cs->iif.statcallb(&ic);
}
- if (chanp->Flags & (FLG_LL_DCONN | FLG_CALL_SEND | FLG_CALL_ALERT)) {
+ if (test_and_clear_bit(FLG_START_B, &chanp->Flags))
+ release_b_st(chanp);
+ if (test_bit(FLG_LL_DCONN, &chanp->Flags) ||
+ test_bit(FLG_CALL_SEND, &chanp->Flags) ||
+ test_bit(FLG_CALL_ALERT, &chanp->Flags)) {
if (chanp->debug & 1)
link_debug(chanp, "STAT_DHUP", 0);
- l4_deliver_cause(chanp);
- ic.driver = chanp->sp->myid;
+ lli_deliver_cause(chanp);
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_DHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ chanp->cs->iif.statcallb(&ic);
}
- RESBIT(chanp->Flags, FLG_LL_DCONN);
- RESBIT(chanp->Flags, FLG_CALL_SEND);
- RESBIT(chanp->Flags, FLG_CALL_ALERT);
- chanp->is.l4.l4l3(&chanp->is, CC_RELEASE_REQ, NULL);
+ test_and_clear_bit(FLG_CALL_ALERT, &chanp->Flags);
+ test_and_clear_bit(FLG_LL_DCONN, &chanp->Flags);
+ test_and_clear_bit(FLG_CALL_SEND, &chanp->Flags);
+ chanp->d_st->lli.l4l3(chanp->d_st, CC_RELEASE_REQ, chanp->proc);
}
/* processing charge info */
static void
-l4_charge_info(struct FsmInst *fi, int event, void *arg)
+lli_charge_info(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_CINF;
ic.arg = chanp->chan;
- sprintf(ic.parm.num, "%d", chanp->para.chargeinfo);
- chanp->sp->iif.statcallb(&ic);
+ sprintf(ic.parm.num, "%d", chanp->proc->para.chargeinfo);
+ chanp->cs->iif.statcallb(&ic);
}
/* error procedures */
static void
-l4_no_dchan(struct FsmInst *fi, int event, void *arg)
+lli_no_dchan(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
if (chanp->debug & 1)
link_debug(chanp, "STAT_NODCH", 0);
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_NODCH;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ chanp->cs->iif.statcallb(&ic);
chanp->Flags = 0;
FsmChangeState(fi, ST_NULL);
- FsmEvent(&chanp->lc_d.lcfi, EV_LC_RELEASE, NULL);
+ FsmEvent(&chanp->lc_d->lcfi, EV_LC_RELEASE, NULL);
}
static void
-l4_no_dchan_ready(struct FsmInst *fi, int event, void *arg)
+lli_no_dchan_ready(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
if (chanp->debug & 1)
link_debug(chanp, "STAT_DHUP", 0);
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_DHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ chanp->cs->iif.statcallb(&ic);
}
static void
-l4_no_dchan_in(struct FsmInst *fi, int event, void *arg)
+lli_no_dchan_in(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
+ isdn_ctrl ic;
- chanp->is.l4.l4l3(&chanp->is, CC_DLRL, NULL);
+ if (chanp->debug & 1)
+ link_debug(chanp, "STAT_DHUP", 0);
+ ic.driver = chanp->cs->myid;
+ ic.command = ISDN_STAT_DHUP;
+ ic.arg = chanp->chan;
+ chanp->cs->iif.statcallb(&ic);
+ chanp->d_st->lli.l4l3(chanp->d_st, CC_DLRL, chanp->proc);
chanp->Flags = 0;
FsmChangeState(fi, ST_NULL);
- FsmEvent(&chanp->lc_d.lcfi, EV_LC_RELEASE, NULL);
+ FsmEvent(&chanp->lc_d->lcfi, EV_LC_RELEASE, NULL);
}
static void
-l4_no_setup_rsp(struct FsmInst *fi, int event, void *arg)
+lli_no_setup_rsp(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
- chanp->Flags = 0;
FsmChangeState(fi, ST_NULL);
- FsmEvent(&chanp->lc_d.lcfi, EV_LC_RELEASE, NULL);
+ test_and_clear_bit(FLG_CALL_SEND, &chanp->Flags);
if (chanp->debug & 1)
link_debug(chanp, "STAT_DHUP", 0);
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_DHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ chanp->cs->iif.statcallb(&ic);
+ lli_shutdown_d(fi, event, arg);
}
static void
-l4_setup_err(struct FsmInst *fi, int event, void *arg)
+lli_setup_err(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
FsmChangeState(fi, ST_WAIT_DRELEASE);
- if (chanp->Flags & FLG_LL_DCONN) {
+ if (test_and_clear_bit(FLG_LL_DCONN, &chanp->Flags)) {
if (chanp->debug & 1)
link_debug(chanp, "STAT_DHUP", 0);
- RESBIT(chanp->Flags, FLG_LL_DCONN);
- l4_deliver_cause(chanp);
- ic.driver = chanp->sp->myid;
+ lli_deliver_cause(chanp);
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_DHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ chanp->cs->iif.statcallb(&ic);
}
- SETBIT(chanp->Flags, FLG_DISC_SEND); /* DISCONN was sent from L3 */
+ test_and_set_bit(FLG_DISC_SEND, &chanp->Flags); /* DISCONN was sent from L3 */
}
static void
-l4_connect_err(struct FsmInst *fi, int event, void *arg)
+lli_connect_err(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
FsmChangeState(fi, ST_WAIT_DRELEASE);
- if (chanp->Flags & FLG_LL_DCONN) {
+ if (test_and_clear_bit(FLG_LL_DCONN, &chanp->Flags)) {
if (chanp->debug & 1)
link_debug(chanp, "STAT_DHUP", 0);
- RESBIT(chanp->Flags, FLG_LL_DCONN);
- l4_deliver_cause(chanp);
- ic.driver = chanp->sp->myid;
+ lli_deliver_cause(chanp);
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_DHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ chanp->cs->iif.statcallb(&ic);
}
- SETBIT(chanp->Flags, FLG_DISC_SEND); /* DISCONN was sent from L3 */
+ test_and_set_bit(FLG_DISC_SEND, &chanp->Flags); /* DISCONN was sent from L3 */
}
static void
-l4_active_dlrl(struct FsmInst *fi, int event, void *arg)
+lli_got_dlrl(struct FsmInst *fi, int event, void *arg)
{
struct Channel *chanp = fi->userdata;
isdn_ctrl ic;
chanp->data_open = 0;
FsmChangeState(fi, ST_NULL);
- if (chanp->Flags & FLG_CONNECT_B) {
- chanp->lc_b.l2_establish = 0; /* direct reset in lc_b.lcfi */
- FsmEvent(&chanp->lc_b.lcfi, EV_LC_RELEASE, NULL);
- RESBIT(chanp->Flags, FLG_CONNECT_B);
+ if (test_and_clear_bit(FLG_CONNECT_B, &chanp->Flags)) {
+ chanp->lc_b->l2_establish = 0; /* direct reset in lc_b->lcfi */
+ FsmEvent(&chanp->lc_b->lcfi, EV_LC_RELEASE, NULL);
}
- if (chanp->Flags & FLG_LL_BCONN) {
+ if (test_and_clear_bit(FLG_LL_BCONN, &chanp->Flags)) {
if (chanp->debug & 1)
link_debug(chanp, "STAT_BHUP", 0);
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_BHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
- RESBIT(chanp->Flags, FLG_LL_BCONN);
- }
- if (chanp->Flags & FLG_START_B) {
- release_ds(chanp);
- RESBIT(chanp->Flags, FLG_START_B);
+ chanp->cs->iif.statcallb(&ic);
}
- if (chanp->Flags & FLG_LL_DCONN) {
- if (chanp->debug & 1)
- link_debug(chanp, "STAT_DHUP", 0);
- RESBIT(chanp->Flags, FLG_LL_DCONN);
- if (chanp->sp->protocol == ISDN_PTYPE_EURO) {
- chanp->para.cause = 0x2f;
- chanp->para.loc = 0;
- } else {
- chanp->para.cause = 0x70;
- chanp->para.loc = 0;
- }
- l4_deliver_cause(chanp);
- ic.driver = chanp->sp->myid;
+ if (test_and_clear_bit(FLG_START_B, &chanp->Flags))
+ release_b_st(chanp);
+ if (chanp->leased) {
+ ic.driver = chanp->cs->myid;
+ ic.command = ISDN_STAT_CAUSE;
+ ic.arg = chanp->chan;
+ sprintf(ic.parm.num, "L%02X%02X", 0, 0x2f);
+ chanp->cs->iif.statcallb(&ic);
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_DHUP;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ chanp->cs->iif.statcallb(&ic);
+ chanp->Flags = 0;
+ } else {
+ if (test_and_clear_bit(FLG_LL_DCONN, &chanp->Flags)) {
+ if (chanp->debug & 1)
+ link_debug(chanp, "STAT_DHUP", 0);
+ if (chanp->cs->protocol == ISDN_PTYPE_EURO) {
+ chanp->proc->para.cause = 0x2f;
+ chanp->proc->para.loc = 0;
+ } else {
+ chanp->proc->para.cause = 0x70;
+ chanp->proc->para.loc = 0;
+ }
+ lli_deliver_cause(chanp);
+ ic.driver = chanp->cs->myid;
+ ic.command = ISDN_STAT_DHUP;
+ ic.arg = chanp->chan;
+ chanp->cs->iif.statcallb(&ic);
+ }
+ chanp->d_st->lli.l4l3(chanp->d_st, CC_DLRL, chanp->proc);
+ chanp->Flags = 0;
+ FsmEvent(&chanp->lc_d->lcfi, EV_LC_RELEASE, NULL);
}
- chanp->Flags = 0;
- chanp->is.l4.l4l3(&chanp->is, CC_DLRL, NULL);
- FsmEvent(&chanp->lc_d.lcfi, EV_LC_RELEASE, NULL);
+ chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) chanp->chan);
}
+
/* *INDENT-OFF* */
-static struct FsmNode fnlist[] =
-{
- {ST_NULL, EV_DIAL, l4_prep_dialout},
- {ST_NULL, EV_SETUP_IND, l4_start_dchan},
- {ST_NULL, EV_SHUTDOWN_D, l4_shutdown_d},
- {ST_NULL, EV_DLRL, l4_go_null},
- {ST_OUT_WAIT_D, EV_DLEST, l4_do_dialout},
- {ST_OUT_WAIT_D, EV_DLRL, l4_no_dchan},
- {ST_OUT_WAIT_D, EV_HANGUP, l4_no_dchan},
- {ST_IN_WAIT_D, EV_DLEST, l4_deliver_call},
- {ST_IN_WAIT_D, EV_DLRL, l4_no_dchan_in},
- {ST_IN_WAIT_D, EV_HANGUP, l4_no_dchan_in},
- {ST_OUT_DIAL, EV_SETUP_CNF, l4_init_bchan_out},
- {ST_OUT_DIAL, EV_HANGUP, l4_cancel_call},
- {ST_OUT_DIAL, EV_DISCONNECT_IND, l4_received_d_disc},
- {ST_OUT_DIAL, EV_RELEASE_IND, l4_received_d_rel},
- {ST_OUT_DIAL, EV_RELEASE_CNF, l4_received_d_relcnf},
- {ST_OUT_DIAL, EV_NOSETUP_RSP, l4_no_setup_rsp},
- {ST_OUT_DIAL, EV_SETUP_ERR, l4_setup_err},
- {ST_IN_WAIT_LL, EV_SETUP_CMPL_IND, l4_init_bchan_in},
- {ST_IN_WAIT_LL, EV_ACCEPTD, l4_send_dconnect},
- {ST_IN_WAIT_LL, EV_HANGUP, l4_reject_call},
- {ST_IN_WAIT_LL, EV_DISCONNECT_IND, l4_received_d_disc},
- {ST_IN_WAIT_LL, EV_RELEASE_IND, l4_received_d_rel},
- {ST_IN_WAIT_LL, EV_RELEASE_CNF, l4_received_d_relcnf},
- {ST_IN_ALERT_SEND, EV_SETUP_CMPL_IND, l4_init_bchan_in},
- {ST_IN_ALERT_SEND, EV_ACCEPTD, l4_send_dconnect},
- {ST_IN_ALERT_SEND, EV_HANGUP, l4_send_d_disc},
- {ST_IN_ALERT_SEND, EV_DISCONNECT_IND, l4_received_d_disc},
- {ST_IN_ALERT_SEND, EV_RELEASE_IND, l4_received_d_rel},
- {ST_IN_ALERT_SEND, EV_RELEASE_CNF, l4_received_d_relcnf},
- {ST_IN_WAIT_CONN_ACK, EV_SETUP_CMPL_IND, l4_init_bchan_in},
- {ST_IN_WAIT_CONN_ACK, EV_HANGUP, l4_send_d_disc},
- {ST_IN_WAIT_CONN_ACK, EV_DISCONNECT_IND, l4_received_d_disc},
- {ST_IN_WAIT_CONN_ACK, EV_RELEASE_IND, l4_received_d_rel},
- {ST_IN_WAIT_CONN_ACK, EV_RELEASE_CNF, l4_received_d_relcnf},
- {ST_IN_WAIT_CONN_ACK, EV_CONNECT_ERR, l4_connect_err},
- {ST_WAIT_BCONN, EV_BC_EST, l4_go_active},
- {ST_WAIT_BCONN, EV_BC_REL, l4_send_d_disc},
- {ST_WAIT_BCONN, EV_HANGUP, l4_send_d_disc},
- {ST_WAIT_BCONN, EV_DISCONNECT_IND, l4_received_d_disc},
- {ST_WAIT_BCONN, EV_RELEASE_IND, l4_received_d_rel},
- {ST_WAIT_BCONN, EV_RELEASE_CNF, l4_received_d_relcnf},
- {ST_ACTIVE, EV_CINF, l4_charge_info},
- {ST_ACTIVE, EV_BC_REL, l4_released_bchan},
- {ST_ACTIVE, EV_HANGUP, l4_disconn_bchan},
- {ST_ACTIVE, EV_DISCONNECT_IND, l4_release_bchan},
- {ST_ACTIVE, EV_RELEASE_CNF, l4_received_d_relcnf},
- {ST_ACTIVE, EV_RELEASE_IND, l4_received_d_rel},
- {ST_ACTIVE, EV_DLRL, l4_active_dlrl},
- {ST_WAIT_BRELEASE, EV_BC_REL, l4_send_d_disc},
- {ST_WAIT_BRELEASE, EV_DISCONNECT_IND, l4_received_d_disc},
- {ST_WAIT_BRELEASE, EV_RELEASE_CNF, l4_received_d_relcnf},
- {ST_WAIT_BRELEASE, EV_RELEASE_IND, l4_received_d_rel},
- {ST_WAIT_BREL_DISC, EV_BC_REL, l4_received_d_disc},
- {ST_WAIT_BREL_DISC, EV_RELEASE_CNF, l4_received_d_relcnf},
- {ST_WAIT_BREL_DISC, EV_RELEASE_IND, l4_received_d_rel},
- {ST_WAIT_DCOMMAND, EV_HANGUP, l4_send_d_disc},
- {ST_WAIT_DCOMMAND, EV_DISCONNECT_IND, l4_received_d_disc},
- {ST_WAIT_DCOMMAND, EV_RELEASE_CNF, l4_received_d_relcnf},
- {ST_WAIT_DCOMMAND, EV_RELEASE_IND, l4_received_d_rel},
- {ST_WAIT_DRELEASE, EV_RELEASE_IND, l4_timeout_d},
- {ST_WAIT_DRELEASE, EV_RELEASE_CNF, l4_timeout_d},
- {ST_WAIT_DRELEASE, EV_RELEASE_ERR, l4_timeout_d},
- {ST_WAIT_DRELEASE, EV_DIAL, l4_no_dchan_ready},
- {ST_WAIT_D_REL_CNF, EV_RELEASE_CNF, l4_timeout_d},
- {ST_WAIT_D_REL_CNF, EV_RELEASE_ERR, l4_timeout_d},
- {ST_WAIT_D_REL_CNF, EV_DIAL, l4_no_dchan_ready},
- {ST_WAIT_DSHUTDOWN, EV_DLRL, l4_go_null},
- {ST_WAIT_DSHUTDOWN, EV_DIAL, l4_prep_dialout},
- {ST_WAIT_DSHUTDOWN, EV_SETUP_IND, l4_start_dchan},
+static struct FsmNode fnlist[] HISAX_INITDATA =
+{
+ {ST_NULL, EV_DIAL, lli_prep_dialout},
+ {ST_NULL, EV_SETUP_IND, lli_deliver_call},
+ {ST_NULL, EV_SHUTDOWN_D, lli_shutdown_d},
+ {ST_NULL, EV_DLRL, lli_go_null},
+ {ST_NULL, EV_DLEST, lli_d_established},
+ {ST_NULL, EV_ESTABLISH, lli_establish_d},
+ {ST_OUT_WAIT_D, EV_DLEST, lli_do_dialout},
+ {ST_OUT_WAIT_D, EV_DLRL, lli_no_dchan},
+ {ST_OUT_WAIT_D, EV_HANGUP, lli_no_dchan},
+ {ST_IN_WAIT_D, EV_DLEST, lli_do_action},
+ {ST_IN_WAIT_D, EV_DLRL, lli_no_dchan_in},
+ {ST_IN_WAIT_D, EV_ACCEPTD, lli_start_dchan},
+ {ST_IN_WAIT_D, EV_HANGUP, lli_start_dchan},
+ {ST_OUT_DIAL, EV_SETUP_CNF, lli_init_bchan_out},
+ {ST_OUT_DIAL, EV_HANGUP, lli_cancel_call},
+ {ST_OUT_DIAL, EV_DISCONNECT_IND, lli_received_d_disc},
+ {ST_OUT_DIAL, EV_RELEASE_IND, lli_received_d_rel},
+ {ST_OUT_DIAL, EV_RELEASE_CNF, lli_received_d_relcnf},
+ {ST_OUT_DIAL, EV_NOSETUP_RSP, lli_no_setup_rsp},
+ {ST_OUT_DIAL, EV_SETUP_ERR, lli_setup_err},
+ {ST_OUT_DIAL, EV_DLRL, lli_got_dlrl},
+ {ST_IN_WAIT_LL, EV_DLEST, lli_d_established},
+ {ST_IN_WAIT_LL, EV_DLRL, lli_d_released},
+ {ST_IN_WAIT_LL, EV_ACCEPTD, lli_start_dchan},
+ {ST_IN_WAIT_LL, EV_HANGUP, lli_start_dchan},
+ {ST_IN_WAIT_LL, EV_DISCONNECT_IND, lli_received_d_disc},
+ {ST_IN_WAIT_LL, EV_RELEASE_IND, lli_received_d_rel},
+ {ST_IN_WAIT_LL, EV_RELEASE_CNF, lli_received_d_relcnf},
+ {ST_IN_ALERT_SEND, EV_SETUP_CMPL_IND, lli_init_bchan_in},
+ {ST_IN_ALERT_SEND, EV_ACCEPTD, lli_send_dconnect},
+ {ST_IN_ALERT_SEND, EV_HANGUP, lli_send_d_disc},
+ {ST_IN_ALERT_SEND, EV_DISCONNECT_IND, lli_received_d_disc},
+ {ST_IN_ALERT_SEND, EV_RELEASE_IND, lli_received_d_rel},
+ {ST_IN_ALERT_SEND, EV_RELEASE_CNF, lli_received_d_relcnf},
+ {ST_IN_ALERT_SEND, EV_DLRL, lli_got_dlrl},
+ {ST_IN_WAIT_CONN_ACK, EV_SETUP_CMPL_IND, lli_init_bchan_in},
+ {ST_IN_WAIT_CONN_ACK, EV_HANGUP, lli_send_d_disc},
+ {ST_IN_WAIT_CONN_ACK, EV_DISCONNECT_IND, lli_received_d_disc},
+ {ST_IN_WAIT_CONN_ACK, EV_RELEASE_IND, lli_received_d_rel},
+ {ST_IN_WAIT_CONN_ACK, EV_RELEASE_CNF, lli_received_d_relcnf},
+ {ST_IN_WAIT_CONN_ACK, EV_CONNECT_ERR, lli_connect_err},
+ {ST_IN_WAIT_CONN_ACK, EV_DLRL, lli_got_dlrl},
+ {ST_WAIT_BCONN, EV_BC_EST, lli_go_active},
+ {ST_WAIT_BCONN, EV_BC_REL, lli_send_d_disc},
+ {ST_WAIT_BCONN, EV_HANGUP, lli_send_d_disc},
+ {ST_WAIT_BCONN, EV_DISCONNECT_IND, lli_received_d_disc},
+ {ST_WAIT_BCONN, EV_RELEASE_IND, lli_received_d_rel},
+ {ST_WAIT_BCONN, EV_RELEASE_CNF, lli_received_d_relcnf},
+ {ST_WAIT_BCONN, EV_DLRL, lli_got_dlrl},
+ {ST_WAIT_BCONN, EV_CINF, lli_charge_info},
+ {ST_ACTIVE, EV_CINF, lli_charge_info},
+ {ST_ACTIVE, EV_BC_REL, lli_released_bchan},
+ {ST_ACTIVE, EV_HANGUP, lli_disconn_bchan},
+ {ST_ACTIVE, EV_DISCONNECT_IND, lli_release_bchan},
+ {ST_ACTIVE, EV_RELEASE_CNF, lli_received_d_relcnf},
+ {ST_ACTIVE, EV_RELEASE_IND, lli_received_d_rel},
+ {ST_ACTIVE, EV_DLRL, lli_got_dlrl},
+ {ST_WAIT_BRELEASE, EV_BC_REL, lli_send_d_disc},
+ {ST_WAIT_BRELEASE, EV_DISCONNECT_IND, lli_received_d_disc},
+ {ST_WAIT_BRELEASE, EV_RELEASE_CNF, lli_received_d_relcnf},
+ {ST_WAIT_BRELEASE, EV_RELEASE_IND, lli_received_d_rel},
+ {ST_WAIT_BRELEASE, EV_DLRL, lli_got_dlrl},
+ {ST_WAIT_BREL_DISC, EV_BC_REL, lli_received_d_disc},
+ {ST_WAIT_BREL_DISC, EV_RELEASE_CNF, lli_received_d_relcnf},
+ {ST_WAIT_BREL_DISC, EV_RELEASE_IND, lli_received_d_rel},
+ {ST_WAIT_BREL_DISC, EV_DLRL, lli_got_dlrl},
+ {ST_WAIT_DCOMMAND, EV_HANGUP, lli_send_d_disc},
+ {ST_WAIT_DCOMMAND, EV_DISCONNECT_IND, lli_received_d_disc},
+ {ST_WAIT_DCOMMAND, EV_RELEASE_CNF, lli_received_d_relcnf},
+ {ST_WAIT_DCOMMAND, EV_RELEASE_IND, lli_received_d_rel},
+ {ST_WAIT_DCOMMAND, EV_DLRL, lli_got_dlrl},
+ {ST_WAIT_DRELEASE, EV_RELEASE_IND, lli_timeout_d},
+ {ST_WAIT_DRELEASE, EV_RELEASE_CNF, lli_timeout_d},
+ {ST_WAIT_DRELEASE, EV_RELEASE_ERR, lli_timeout_d},
+ {ST_WAIT_DRELEASE, EV_DIAL, lli_no_dchan_ready},
+ {ST_WAIT_DRELEASE, EV_DLRL, lli_got_dlrl},
+ {ST_WAIT_D_REL_CNF, EV_RELEASE_CNF, lli_timeout_d},
+ {ST_WAIT_D_REL_CNF, EV_RELEASE_ERR, lli_timeout_d},
+/* ETS 300-104 16.1 */
+ {ST_WAIT_D_REL_CNF, EV_RELEASE_IND, lli_timeout_d},
+ {ST_WAIT_D_REL_CNF, EV_DIAL, lli_no_dchan_ready},
+ {ST_WAIT_D_REL_CNF, EV_DLRL, lli_got_dlrl},
+ {ST_WAIT_DSHUTDOWN, EV_DLRL, lli_go_null},
+ {ST_WAIT_DSHUTDOWN, EV_DLEST, lli_d_established},
+ {ST_WAIT_DSHUTDOWN, EV_DIAL, lli_prep_dialout},
+ {ST_WAIT_DSHUTDOWN, EV_SETUP_IND, lli_deliver_call},
};
/* *INDENT-ON* */
-
-
#define FNCOUNT (sizeof(fnlist)/sizeof(struct FsmNode))
static void
-lc_r1(struct FsmInst *fi, int event, void *arg)
+lc_activate_l1(struct FsmInst *fi, int event, void *arg)
{
struct LcFsm *lf = fi->userdata;
+ FsmDelTimer(&lf->act_timer, 50);
FsmChangeState(fi, ST_LC_ACTIVATE_WAIT);
- FsmAddTimer(&lf->act_timer, 1000, EV_LC_TIMER, NULL, 50);
- lf->st->ma.manl1(lf->st, PH_ACTIVATE, NULL);
+ /* This timeout is to avoid a hang if no L1 activation is possible */
+ FsmAddTimer(&lf->act_timer, 30000, EV_LC_TIMER, NULL, 50);
+ lf->st->ma.manl1(lf->st, PH_ACTIVATE_REQ, NULL);
+}
+static void
+lc_activated_from_l1(struct FsmInst *fi, int event, void *arg)
+{
+ struct LcFsm *lf = fi->userdata;
+
+ if (lf->l2_establish)
+ FsmChangeState(fi, ST_LC_DELAY);
+ else {
+ FsmChangeState(fi, ST_LC_CONNECTED);
+ lf->lccall(lf, LC_ESTABLISH, NULL);
+ }
}
static void
-lc_r6(struct FsmInst *fi, int event, void *arg)
+lc_l1_activated(struct FsmInst *fi, int event, void *arg)
{
struct LcFsm *lf = fi->userdata;
FsmDelTimer(&lf->act_timer, 50);
FsmChangeState(fi, ST_LC_DELAY);
- FsmAddTimer(&lf->act_timer, 40, EV_LC_TIMER, NULL, 51);
+ /* This timer is needed for delay the first paket on a channel
+ to be shure that the other side is ready too */
+ if (lf->delay)
+ FsmAddTimer(&lf->act_timer, lf->delay, EV_LC_TIMER, NULL, 51);
+ else
+ FsmEvent(fi, EV_LC_TIMER, NULL);
}
static void
-lc_r2(struct FsmInst *fi, int event, void *arg)
+lc_start_l2(struct FsmInst *fi, int event, void *arg)
{
struct LcFsm *lf = fi->userdata;
- if (lf->l2_establish) {
+/* if (!lf->st->l1.act_state)
+ lf->st->l1.act_state = 2;
+*/ if (lf->l2_establish) {
FsmChangeState(fi, ST_LC_ESTABLISH_WAIT);
if (lf->l2_start)
lf->st->ma.manl2(lf->st, DL_ESTABLISH, NULL);
@@ -1124,107 +1260,97 @@ lc_r2(struct FsmInst *fi, int event, void *arg)
}
static void
-lc_r3(struct FsmInst *fi, int event, void *arg)
+lc_connected(struct FsmInst *fi, int event, void *arg)
{
struct LcFsm *lf = fi->userdata;
+ FsmDelTimer(&lf->act_timer, 50);
FsmChangeState(fi, ST_LC_CONNECTED);
lf->lccall(lf, LC_ESTABLISH, NULL);
}
static void
-lc_r7(struct FsmInst *fi, int event, void *arg)
-{
- struct LcFsm *lf = fi->userdata;
-
- FsmChangeState(fi, ST_LC_FLUSH_WAIT);
- lf->st->ma.manl2(lf->st, DL_FLUSH, NULL);
-}
-
-static void
-lc_r4(struct FsmInst *fi, int event, void *arg)
+lc_release_l2(struct FsmInst *fi, int event, void *arg)
{
struct LcFsm *lf = fi->userdata;
if (lf->l2_establish) {
FsmChangeState(fi, ST_LC_RELEASE_WAIT);
lf->st->ma.manl2(lf->st, DL_RELEASE, NULL);
- /* This timer is for releasing the channel even
- * there is a hang in layer 2 ; 5 sec are a try
- */
- FsmAddTimer(&lf->act_timer, 5000, EV_LC_TIMER, NULL, 53);
} else {
FsmChangeState(fi, ST_LC_NULL);
- lf->st->ma.manl1(lf->st, PH_DEACTIVATE, NULL);
+ lf->st->ma.manl1(lf->st, PH_DEACTIVATE_REQ, NULL);
lf->lccall(lf, LC_RELEASE, NULL);
}
}
static void
-lc_r4_1(struct FsmInst *fi, int event, void *arg)
+lc_l2_released(struct FsmInst *fi, int event, void *arg)
{
struct LcFsm *lf = fi->userdata;
- FsmChangeState(fi, ST_LC_FLUSH_DELAY);
- FsmAddTimer(&lf->act_timer, 50, EV_LC_TIMER, NULL, 52);
+ FsmChangeState(fi, ST_LC_RELEASE_WAIT);
+ FsmDelTimer(&lf->act_timer, 51);
+ /* This delay is needed for send out the UA frame before
+ * PH_DEACTIVATE the interface
+ */
+ FsmAddTimer(&lf->act_timer, 20, EV_LC_TIMER, NULL, 54);
}
static void
-lc_r5_1(struct FsmInst *fi, int event, void *arg)
+lc_release_l1(struct FsmInst *fi, int event, void *arg)
{
struct LcFsm *lf = fi->userdata;
- FsmChangeState(fi, ST_LC_RELEASE_WAIT);
- /* This delay is needed for send out the UA frame before
- * PH_DEACTIVATE the interface
- */
- FsmAddTimer(&lf->act_timer, 10, EV_LC_TIMER, NULL, 54);
+ FsmDelTimer(&lf->act_timer, 54);
+ FsmChangeState(fi, ST_LC_NULL);
+ lf->st->ma.manl1(lf->st, PH_DEACTIVATE_REQ, NULL);
+ lf->lccall(lf, LC_RELEASE, NULL);
}
static void
-lc_r5(struct FsmInst *fi, int event, void *arg)
+lc_l1_deactivated(struct FsmInst *fi, int event, void *arg)
{
struct LcFsm *lf = fi->userdata;
FsmDelTimer(&lf->act_timer, 54);
FsmChangeState(fi, ST_LC_NULL);
- lf->st->ma.manl1(lf->st, PH_DEACTIVATE, NULL);
lf->lccall(lf, LC_RELEASE, NULL);
}
/* *INDENT-OFF* */
-static struct FsmNode LcFnList[] =
-{
- {ST_LC_NULL, EV_LC_ESTABLISH, lc_r1},
- {ST_LC_ACTIVATE_WAIT, EV_LC_PH_ACTIVATE, lc_r6},
- {ST_LC_DELAY, EV_LC_TIMER, lc_r2},
- {ST_LC_DELAY, EV_LC_DL_ESTABLISH, lc_r3},
- {ST_LC_ESTABLISH_WAIT, EV_LC_DL_ESTABLISH, lc_r3},
- {ST_LC_ESTABLISH_WAIT, EV_LC_RELEASE, lc_r5},
- {ST_LC_CONNECTED, EV_LC_FLUSH, lc_r7},
- {ST_LC_CONNECTED, EV_LC_RELEASE, lc_r4},
- {ST_LC_CONNECTED, EV_LC_DL_RELEASE, lc_r5_1},
- {ST_LC_FLUSH_WAIT, EV_LC_DL_FLUSH, lc_r4_1},
- {ST_LC_FLUSH_DELAY, EV_LC_TIMER, lc_r4},
- {ST_LC_RELEASE_WAIT, EV_LC_DL_RELEASE, lc_r5},
- {ST_LC_RELEASE_WAIT, EV_LC_TIMER, lc_r5},
- {ST_LC_ACTIVATE_WAIT, EV_LC_TIMER, lc_r5},
- {ST_LC_ESTABLISH_WAIT, EV_LC_DL_RELEASE, lc_r5},
+static struct FsmNode LcFnList[] HISAX_INITDATA =
+{
+ {ST_LC_NULL, EV_LC_ESTABLISH, lc_activate_l1},
+ {ST_LC_NULL, EV_LC_PH_ACTIVATE, lc_activated_from_l1},
+ {ST_LC_NULL, EV_LC_DL_ESTABLISH, lc_connected},
+ {ST_LC_ACTIVATE_WAIT, EV_LC_PH_ACTIVATE, lc_l1_activated},
+ {ST_LC_ACTIVATE_WAIT, EV_LC_TIMER, lc_release_l1},
+ {ST_LC_ACTIVATE_WAIT, EV_LC_PH_DEACTIVATE, lc_l1_deactivated},
+ {ST_LC_DELAY, EV_LC_ESTABLISH, lc_start_l2},
+ {ST_LC_DELAY, EV_LC_TIMER, lc_start_l2},
+ {ST_LC_DELAY, EV_LC_DL_ESTABLISH, lc_connected},
+ {ST_LC_DELAY, EV_LC_PH_DEACTIVATE, lc_l1_deactivated},
+ {ST_LC_ESTABLISH_WAIT, EV_LC_DL_ESTABLISH, lc_connected},
+ {ST_LC_ESTABLISH_WAIT, EV_LC_RELEASE, lc_release_l1},
+ {ST_LC_ESTABLISH_WAIT, EV_LC_DL_RELEASE, lc_release_l1},
+ {ST_LC_ESTABLISH_WAIT, EV_LC_PH_DEACTIVATE, lc_l1_deactivated},
+ {ST_LC_CONNECTED, EV_LC_ESTABLISH, lc_connected},
+ {ST_LC_CONNECTED, EV_LC_RELEASE, lc_release_l2},
+ {ST_LC_CONNECTED, EV_LC_DL_RELEASE, lc_l2_released},
+ {ST_LC_CONNECTED, EV_LC_PH_DEACTIVATE, lc_l1_deactivated},
+ {ST_LC_FLUSH_WAIT, EV_LC_TIMER, lc_release_l2},
+ {ST_LC_FLUSH_WAIT, EV_LC_PH_DEACTIVATE, lc_l1_deactivated},
+ {ST_LC_RELEASE_WAIT, EV_LC_DL_RELEASE, lc_release_l1},
+ {ST_LC_RELEASE_WAIT, EV_LC_TIMER, lc_release_l1},
+ {ST_LC_FLUSH_WAIT, EV_LC_PH_DEACTIVATE, lc_l1_deactivated},
};
/* *INDENT-ON* */
-
-
-
-
-
-
-
-
#define LC_FN_COUNT (sizeof(LcFnList)/sizeof(struct FsmNode))
-void
-CallcNew(void)
+HISAX_INITFUNC(void
+CallcNew(void))
{
callcfsm.state_count = STATE_COUNT;
callcfsm.event_count = EVENT_COUNT;
@@ -1247,17 +1373,11 @@ CallcFree(void)
}
static void
-release_ds(struct Channel *chanp)
+release_b_st(struct Channel *chanp)
{
- struct PStack *st = &chanp->ds;
- struct IsdnCardState *sp;
- struct HscxState *hsp;
-
- sp = st->l1.hardware;
- hsp = sp->hs + chanp->hscx;
-
- close_hscxstate(hsp);
+ struct PStack *st = chanp->b_st;
+ chanp->bcs->BC_Close(chanp->bcs);
switch (chanp->l2_active_protocol) {
case (ISDN_PROTO_L2_X75I):
releasestack_isdnl2(st);
@@ -1268,90 +1388,145 @@ release_ds(struct Channel *chanp)
break;
}
/* Reset B-Channel Statemachine */
- FsmDelTimer(&chanp->lc_b.act_timer, 79);
- FsmChangeState(&chanp->lc_b.lcfi, ST_LC_NULL);
+ FsmDelTimer(&chanp->lc_b->act_timer, 79);
+ FsmChangeState(&chanp->lc_b->lcfi, ST_LC_NULL);
}
static void
-cc_l1man(struct PStack *st, int pr, void *arg)
+dc_l1man(struct PStack *st, int pr, void *arg)
{
- struct Channel *chanp = (struct Channel *) st->l4.userdata;
+ struct Channel *chanp;
+ chanp = (struct Channel *) st->lli.userdata;
switch (pr) {
- case (PH_ACTIVATE):
- FsmEvent(&chanp->lc_d.lcfi, EV_LC_PH_ACTIVATE, NULL);
+ case (PH_ACTIVATE_CNF):
+ case (PH_ACTIVATE_IND):
+ FsmEvent(&chanp->lc_d->lcfi, EV_LC_PH_ACTIVATE, NULL);
break;
- case (PH_DEACTIVATE):
- FsmEvent(&chanp->lc_d.lcfi, EV_LC_PH_DEACTIVATE, NULL);
+ case (PH_DEACTIVATE_IND):
+ FsmEvent(&chanp->lc_d->lcfi, EV_LC_PH_DEACTIVATE, NULL);
break;
}
}
static void
-cc_l2man(struct PStack *st, int pr, void *arg)
+dc_l2man(struct PStack *st, int pr, void *arg)
{
- struct Channel *chanp = (struct Channel *) st->l4.userdata;
+ struct Channel *chanp = (struct Channel *) st->lli.userdata;
switch (pr) {
case (DL_ESTABLISH):
- FsmEvent(&chanp->lc_d.lcfi, EV_LC_DL_ESTABLISH, NULL);
+ FsmEvent(&chanp->lc_d->lcfi, EV_LC_DL_ESTABLISH, NULL);
break;
case (DL_RELEASE):
- FsmEvent(&chanp->lc_d.lcfi, EV_LC_DL_RELEASE, NULL);
- break;
- case (DL_FLUSH):
- FsmEvent(&chanp->lc_d.lcfi, EV_LC_DL_FLUSH, NULL);
+ FsmEvent(&chanp->lc_d->lcfi, EV_LC_DL_RELEASE, NULL);
break;
}
}
static void
-dcc_l1man(struct PStack *st, int pr, void *arg)
+bc_l1man(struct PStack *st, int pr, void *arg)
{
- struct Channel *chanp = (struct Channel *) st->l4.userdata;
+ struct Channel *chanp = (struct Channel *) st->lli.userdata;
switch (pr) {
- case (PH_ACTIVATE):
- FsmEvent(&chanp->lc_b.lcfi, EV_LC_PH_ACTIVATE, NULL);
+ case (PH_ACTIVATE_IND):
+ case (PH_ACTIVATE_CNF):
+ FsmEvent(&chanp->lc_b->lcfi, EV_LC_PH_ACTIVATE, NULL);
break;
- case (PH_DEACTIVATE):
- FsmEvent(&chanp->lc_b.lcfi, EV_LC_PH_DEACTIVATE, NULL);
+ case (PH_DEACTIVATE_IND):
+ FsmEvent(&chanp->lc_b->lcfi, EV_LC_PH_DEACTIVATE, NULL);
break;
}
}
static void
-dcc_l2man(struct PStack *st, int pr, void *arg)
+bc_l2man(struct PStack *st, int pr, void *arg)
{
- struct Channel *chanp = (struct Channel *) st->l4.userdata;
+ struct Channel *chanp = (struct Channel *) st->lli.userdata;
switch (pr) {
case (DL_ESTABLISH):
- FsmEvent(&chanp->lc_b.lcfi, EV_LC_DL_ESTABLISH, NULL);
+ FsmEvent(&chanp->lc_b->lcfi, EV_LC_DL_ESTABLISH, NULL);
break;
case (DL_RELEASE):
- FsmEvent(&chanp->lc_b.lcfi, EV_LC_DL_RELEASE, NULL);
+ FsmEvent(&chanp->lc_b->lcfi, EV_LC_DL_RELEASE, NULL);
break;
}
}
-static void
-l2tei_dummy(struct PStack *st, int pr, void *arg)
+struct Channel
+*selectfreechannel(struct PStack *st)
{
- struct Channel *chanp = (struct Channel *) st->l4.userdata;
- char tmp[64], tm[32];
+ struct IsdnCardState *cs = st->l1.hardware;
+ struct Channel *chanp = st->lli.userdata;
+ int i;
- jiftime(tm, jiffies);
- sprintf(tmp, "%s Channel %d Warning! Dummy l2tei called pr=%d\n", tm, chanp->chan, pr);
- HiSax_putstatus(chanp->sp, tmp);
+ if (test_bit(FLG_TWO_DCHAN, &cs->HW_Flags))
+ i=1;
+ else
+ i=0;
+ while (i<2) {
+ if (chanp->fi.state == ST_NULL)
+ return (chanp);
+ chanp++;
+ i++;
+ }
+ return (NULL);
+}
+
+int
+is_activ(struct PStack *st)
+{
+ struct IsdnCardState *cs = st->l1.hardware;
+ struct Channel *chanp = st->lli.userdata;
+ int i;
+
+ if (test_bit(FLG_TWO_DCHAN, &cs->HW_Flags))
+ i=1;
+ else
+ i=0;
+ while (i<2) {
+ if (test_bit(FLG_ESTAB_D, &chanp->Flags))
+ return (1);
+ chanp++;
+ i++;
+ }
+ return (0);
}
static void
-ll_handler(struct PStack *st, int pr, void *arg)
+ll_handler(struct l3_process *pc, int pr, void *arg)
{
- struct Channel *chanp = (struct Channel *) st->l4.userdata;
+ struct Channel *chanp;
char tmp[64], tm[32];
+ if (pr == CC_SETUP_IND) {
+ if (!(chanp = selectfreechannel(pc->st))) {
+ pc->st->lli.l4l3(pc->st, CC_DLRL, pc);
+ return;
+ } else {
+ chanp->proc = pc;
+ pc->chan = chanp;
+ FsmEvent(&chanp->fi, EV_SETUP_IND, NULL);
+ return;
+ }
+ } else if (pr == CC_ESTABLISH) {
+ if (is_activ(pc->st)) {
+ pc->st->lli.l4l3(pc->st, CC_ESTABLISH, pc);
+ return;
+ } else if (!(chanp = selectfreechannel(pc->st))) {
+ pc->st->lli.l4l3(pc->st, CC_DLRL, pc);
+ return;
+ } else {
+ chanp->proc = pc;
+ FsmEvent(&chanp->fi, EV_ESTABLISH, NULL);
+ return;
+ }
+
+
+ }
+ chanp = pc->chan;
switch (pr) {
case (CC_DISCONNECT_IND):
FsmEvent(&chanp->fi, EV_DISCONNECT_IND, NULL);
@@ -1359,9 +1534,6 @@ ll_handler(struct PStack *st, int pr, void *arg)
case (CC_RELEASE_CNF):
FsmEvent(&chanp->fi, EV_RELEASE_CNF, NULL);
break;
- case (CC_SETUP_IND):
- FsmEvent(&chanp->fi, EV_SETUP_IND, NULL);
- break;
case (CC_RELEASE_IND):
FsmEvent(&chanp->fi, EV_RELEASE_IND, NULL);
break;
@@ -1386,49 +1558,51 @@ ll_handler(struct PStack *st, int pr, void *arg)
case (CC_RELEASE_ERR):
FsmEvent(&chanp->fi, EV_RELEASE_ERR, NULL);
break;
+ case (CC_PROCEEDING_IND):
+ case (CC_ALERTING_IND):
+ break;
default:
- if (chanp->debug & 2048) {
+ if (chanp->debug & 0x800) {
jiftime(tm, jiffies);
sprintf(tmp, "%s Channel %d L3->L4 unknown primitiv %d\n",
tm, chanp->chan, pr);
- HiSax_putstatus(chanp->sp, tmp);
+ HiSax_putstatus(chanp->cs, tmp);
}
}
}
static void
-init_is(struct Channel *chanp, unsigned int ces)
+init_d_st(struct Channel *chanp)
{
- struct PStack *st = &chanp->is;
- struct IsdnCardState *sp = chanp->sp;
+ struct PStack *st = chanp->d_st;
+ struct IsdnCardState *cs = chanp->cs;
char tmp[128];
- setstack_HiSax(st, sp);
+ HiSax_addlist(cs, st);
+ setstack_HiSax(st, cs);
st->l2.sap = 0;
- st->l2.tei = 255;
- st->l2.ces = ces;
- st->l2.extended = !0;
- st->l2.laptype = LAPD;
+ st->l2.tei = -1;
+ st->l2.flag = 0;
+ test_and_set_bit(FLG_MOD128, &st->l2.flag);
+ test_and_set_bit(FLG_LAPD, &st->l2.flag);
+ test_and_set_bit(FLG_ORIG, &st->l2.flag);
+ st->l2.maxlen = MAX_DFRAME_LEN;
st->l2.window = 1;
- st->l2.orig = !0;
- st->l2.t200 = 1000; /* 1000 milliseconds */
- if (st->protocol == ISDN_PTYPE_1TR6) {
- st->l2.n200 = 3; /* try 3 times */
- st->l2.t203 = 10000; /* 10000 milliseconds */
- } else {
- st->l2.n200 = 4; /* try 4 times */
- st->l2.t203 = 5000; /* 5000 milliseconds */
- }
+ st->l2.T200 = 1000; /* 1000 milliseconds */
+ st->l2.N200 = 3; /* try 3 times */
+ if (st->protocol == ISDN_PTYPE_1TR6)
+ st->l2.T203 = 10000; /* 10000 milliseconds */
+ else
+ st->l2.T203 = 10000; /* 5000 milliseconds */
+
sprintf(tmp, "Channel %d q.921", chanp->chan);
setstack_isdnl2(st, tmp);
setstack_isdnl3(st, chanp);
- st->l4.userdata = chanp;
- st->l4.l2writewakeup = NULL;
+ st->lli.userdata = chanp;
+ st->lli.l2writewakeup = NULL;
st->l3.l3l4 = ll_handler;
- st->l1.l1man = cc_l1man;
- st->l2.l2man = cc_l2man;
- st->pa = &chanp->para;
- HiSax_addlist(sp, st);
+ st->l1.l1man = dc_l1man;
+ st->l2.l2man = dc_l2man;
}
static void
@@ -1439,7 +1613,7 @@ callc_debug(struct FsmInst *fi, char *s)
jiftime(tm, jiffies);
sprintf(str, "%s Channel %d callc %s\n", tm, chanp->chan, s);
- HiSax_putstatus(chanp->sp, str);
+ HiSax_putstatus(chanp->cs, str);
}
static void
@@ -1449,8 +1623,8 @@ lc_debug(struct FsmInst *fi, char *s)
struct LcFsm *lf = fi->userdata;
jiftime(tm, jiffies);
- sprintf(str, "%s Channel %d lc %s\n", tm, lf->ch->chan, s);
- HiSax_putstatus(lf->ch->sp, str);
+ sprintf(str, "%s Channel %d dc %s\n", tm, lf->ch->chan, s);
+ HiSax_putstatus(lf->ch->cs, str);
}
static void
@@ -1460,22 +1634,35 @@ dlc_debug(struct FsmInst *fi, char *s)
struct LcFsm *lf = fi->userdata;
jiftime(tm, jiffies);
- sprintf(str, "%s Channel %d dlc %s\n", tm, lf->ch->chan, s);
- HiSax_putstatus(lf->ch->sp, str);
+ sprintf(str, "%s Channel %d bc %s\n", tm, lf->ch->chan, s);
+ HiSax_putstatus(lf->ch->cs, str);
}
static void
lccall_d(struct LcFsm *lf, int pr, void *arg)
{
- struct Channel *chanp = lf->ch;
+ struct IsdnCardState *cs = lf->st->l1.hardware;
+ struct Channel *chanp;
+ int i;
- switch (pr) {
- case (LC_ESTABLISH):
- FsmEvent(&chanp->fi, EV_DLEST, NULL);
- break;
- case (LC_RELEASE):
- FsmEvent(&chanp->fi, EV_DLRL, NULL);
- break;
+ if (test_bit(FLG_TWO_DCHAN, &cs->HW_Flags)) {
+ chanp = lf->ch;
+ i = 1;
+ } else {
+ chanp = cs->channel;
+ i = 0;
+ }
+ while (i < 2) {
+ switch (pr) {
+ case (LC_ESTABLISH):
+ FsmEvent(&chanp->fi, EV_DLEST, NULL);
+ break;
+ case (LC_RELEASE):
+ FsmEvent(&chanp->fi, EV_DLRL, NULL);
+ break;
+ }
+ chanp++;
+ i++;
}
}
@@ -1495,20 +1682,19 @@ lccall_b(struct LcFsm *lf, int pr, void *arg)
}
static void
-init_chan(int chan, struct IsdnCardState *csta, int hscx,
- unsigned int ces)
+init_chan(int chan, struct IsdnCardState *csta)
{
struct Channel *chanp = csta->channel + chan;
- chanp->sp = csta;
- chanp->hscx = hscx;
+ chanp->cs = csta;
+ chanp->bcs = csta->bcs + chan;
chanp->chan = chan;
chanp->incoming = 0;
chanp->debug = 0;
chanp->Flags = 0;
chanp->leased = 0;
- chanp->impair = 0;
- init_is(chanp, ces);
+ chanp->b_st = kmalloc(sizeof(struct PStack), GFP_ATOMIC);
+ chanp->b_st->next = NULL;
chanp->fi.fsm = &callcfsm;
chanp->fi.state = ST_NULL;
@@ -1517,58 +1703,72 @@ init_chan(int chan, struct IsdnCardState *csta, int hscx,
chanp->fi.printdebug = callc_debug;
FsmInitTimer(&chanp->fi, &chanp->dial_timer);
FsmInitTimer(&chanp->fi, &chanp->drel_timer);
-
- chanp->lc_d.lcfi.fsm = &lcfsm;
- chanp->lc_d.lcfi.state = ST_LC_NULL;
- chanp->lc_d.lcfi.debug = 0;
- chanp->lc_d.lcfi.userdata = &chanp->lc_d;
- chanp->lc_d.lcfi.printdebug = lc_debug;
- chanp->lc_d.type = LC_D;
- chanp->lc_d.ch = chanp;
- chanp->lc_d.st = &chanp->is;
- chanp->lc_d.l2_establish = !0;
- chanp->lc_d.l2_start = !0;
- chanp->lc_d.lccall = lccall_d;
- FsmInitTimer(&chanp->lc_d.lcfi, &chanp->lc_d.act_timer);
-
- chanp->lc_b.lcfi.fsm = &lcfsm;
- chanp->lc_b.lcfi.state = ST_LC_NULL;
- chanp->lc_b.lcfi.debug = 0;
- chanp->lc_b.lcfi.userdata = &chanp->lc_b;
- chanp->lc_b.lcfi.printdebug = dlc_debug;
- chanp->lc_b.type = LC_B;
- chanp->lc_b.ch = chanp;
- chanp->lc_b.st = &chanp->ds;
- chanp->lc_b.l2_establish = !0;
- chanp->lc_b.l2_start = !0;
- chanp->lc_b.lccall = lccall_b;
- FsmInitTimer(&chanp->lc_b.lcfi, &chanp->lc_b.act_timer);
- chanp->outcallref = 64;
+ if (!chan || test_bit(FLG_TWO_DCHAN, &csta->HW_Flags)) {
+ chanp->d_st = kmalloc(sizeof(struct PStack), GFP_ATOMIC);
+ chanp->d_st->next = NULL;
+ init_d_st(chanp);
+ chanp->lc_d = kmalloc(sizeof(struct LcFsm), GFP_ATOMIC);
+ chanp->lc_d->lcfi.fsm = &lcfsm;
+ chanp->lc_d->lcfi.state = ST_LC_NULL;
+ chanp->lc_d->lcfi.debug = 0;
+ chanp->lc_d->lcfi.userdata = chanp->lc_d;
+ chanp->lc_d->lcfi.printdebug = lc_debug;
+ chanp->lc_d->type = LC_D;
+ chanp->lc_d->delay = 0;
+ chanp->lc_d->ch = chanp;
+ chanp->lc_d->st = chanp->d_st;
+ chanp->lc_d->l2_establish = !0;
+ chanp->lc_d->l2_start = !0;
+ chanp->lc_d->lccall = lccall_d;
+ FsmInitTimer(&chanp->lc_d->lcfi, &chanp->lc_d->act_timer);
+ } else {
+ chanp->d_st = csta->channel->d_st;
+ chanp->lc_d = csta->channel->lc_d;
+ }
+ chanp->lc_b = kmalloc(sizeof(struct LcFsm), GFP_ATOMIC);
+ chanp->lc_b->lcfi.fsm = &lcfsm;
+ chanp->lc_b->lcfi.state = ST_LC_NULL;
+ chanp->lc_b->lcfi.debug = 0;
+ chanp->lc_b->lcfi.userdata = chanp->lc_b;
+ chanp->lc_b->lcfi.printdebug = dlc_debug;
+ chanp->lc_b->type = LC_B;
+ chanp->lc_b->delay = DEFAULT_B_DELAY;
+ chanp->lc_b->ch = chanp;
+ chanp->lc_b->st = chanp->b_st;
+ chanp->lc_b->l2_establish = !0;
+ chanp->lc_b->l2_start = !0;
+ chanp->lc_b->lccall = lccall_b;
+ FsmInitTimer(&chanp->lc_b->lcfi, &chanp->lc_b->act_timer);
chanp->data_open = 0;
}
int
CallcNewChan(struct IsdnCardState *csta)
{
- int ces;
-
chancount += 2;
- ces = randomces();
- init_chan(0, csta, 1, ces++);
- ces %= 0xffff;
- init_chan(1, csta, 0, ces++);
+ init_chan(0, csta);
+ init_chan(1, csta);
printk(KERN_INFO "HiSax: 2 channels added\n");
+#ifdef LAYER2_WATCHING
+ printk(KERN_INFO "LAYER2 ESTABLISH\n");
+ test_and_set_bit(FLG_START_D, &csta->channel->Flags);
+ FsmEvent(&csta->channel->lc_d->lcfi, EV_LC_ESTABLISH, NULL);
+#endif
return (2);
}
static void
-release_is(struct Channel *chanp)
+release_d_st(struct Channel *chanp)
{
- struct PStack *st = &chanp->is;
+ struct PStack *st = chanp->d_st;
+ if (!st)
+ return;
releasestack_isdnl2(st);
releasestack_isdnl3(st);
HiSax_rmlist(st->l1.hardware, st);
+ kfree(st);
+ chanp->d_st = NULL;
}
void
@@ -1579,27 +1779,45 @@ CallcFreeChan(struct IsdnCardState *csta)
for (i = 0; i < 2; i++) {
FsmDelTimer(&csta->channel[i].drel_timer, 74);
FsmDelTimer(&csta->channel[i].dial_timer, 75);
- FsmDelTimer(&csta->channel[i].lc_b.act_timer, 76);
- FsmDelTimer(&csta->channel[i].lc_d.act_timer, 77);
- if (csta->channel[i].Flags & FLG_START_B) {
- release_ds(csta->channel + i);
+ FsmDelTimer(&csta->channel[i].lc_d->act_timer, 77);
+ FsmDelTimer(&csta->channel[i].lc_b->act_timer, 76);
+ if (i || test_bit(FLG_TWO_DCHAN, &csta->HW_Flags))
+ release_d_st(csta->channel + i);
+ if (csta->channel[i].b_st) {
+ if (test_and_clear_bit(FLG_START_B, &csta->channel[i].Flags))
+ release_b_st(csta->channel + i);
+ kfree(csta->channel[i].b_st);
+ csta->channel[i].b_st = NULL;
+ } else
+ printk(KERN_WARNING "CallcFreeChan b_st ch%d allready freed\n", i);
+ if (csta->channel[i].lc_b) {
+ kfree(csta->channel[i].lc_b);
+ csta->channel[i].b_st = NULL;
}
- release_is(csta->channel + i);
+ if (i || test_bit(FLG_TWO_DCHAN, &csta->HW_Flags)) {
+ release_d_st(csta->channel + i);
+ FsmDelTimer(&csta->channel[i].lc_d->act_timer, 77);
+ if (csta->channel[i].lc_d) {
+ kfree(csta->channel[i].lc_d);
+ csta->channel[i].d_st = NULL;
+ } else
+ printk(KERN_WARNING "CallcFreeChan lc_d ch%d allready freed\n", i);
+ } else
+ csta->channel[i].d_st = NULL;
}
}
static void
lldata_handler(struct PStack *st, int pr, void *arg)
{
- struct Channel *chanp = (struct Channel *) st->l4.userdata;
+ struct Channel *chanp = (struct Channel *) st->lli.userdata;
struct sk_buff *skb = arg;
switch (pr) {
case (DL_DATA):
if (chanp->data_open)
- chanp->sp->iif.rcvcallb_skb(chanp->sp->myid, chanp->chan, skb);
+ chanp->cs->iif.rcvcallb_skb(chanp->cs->myid, chanp->chan, skb);
else {
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
}
break;
@@ -1613,16 +1831,22 @@ lldata_handler(struct PStack *st, int pr, void *arg)
static void
lltrans_handler(struct PStack *st, int pr, void *arg)
{
- struct Channel *chanp = (struct Channel *) st->l4.userdata;
+ struct Channel *chanp = (struct Channel *) st->lli.userdata;
struct sk_buff *skb = arg;
switch (pr) {
- case (PH_DATA):
+ case (PH_DATA_IND):
if (chanp->data_open)
- chanp->sp->iif.rcvcallb_skb(chanp->sp->myid, chanp->chan, skb);
+ chanp->cs->iif.rcvcallb_skb(chanp->cs->myid, chanp->chan, skb);
else {
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
+ if (chanp->lc_b->lcfi.state == ST_LC_DELAY)
+ FsmEvent(&chanp->lc_b->lcfi, EV_LC_DL_ESTABLISH, NULL);
+ if (chanp->data_open) {
+ link_debug(chanp, "channel now open", 0);
+ chanp->cs->iif.rcvcallb_skb(chanp->cs->myid,
+ chanp->chan, skb);
+ } else
+ dev_kfree_skb(skb);
}
break;
default:
@@ -1633,73 +1857,79 @@ lltrans_handler(struct PStack *st, int pr, void *arg)
}
static void
-ll_writewakeup(struct PStack *st)
+ll_writewakeup(struct PStack *st, int len)
{
- struct Channel *chanp = st->l4.userdata;
+ struct Channel *chanp = st->lli.userdata;
isdn_ctrl ic;
- ic.driver = chanp->sp->myid;
+ ic.driver = chanp->cs->myid;
ic.command = ISDN_STAT_BSENT;
ic.arg = chanp->chan;
- chanp->sp->iif.statcallb(&ic);
+ ic.parm.length = len;
+ chanp->cs->iif.statcallb(&ic);
}
static int
-init_ds(struct Channel *chanp, int incoming)
+init_b_st(struct Channel *chanp, int incoming)
{
- struct PStack *st = &chanp->ds;
- struct IsdnCardState *sp = chanp->sp;
- struct HscxState *hsp = sp->hs + chanp->hscx;
+ struct PStack *st = chanp->b_st;
+ struct IsdnCardState *cs = chanp->cs;
char tmp[128];
- st->l1.hardware = sp;
-
- hsp->mode = 2;
-
- if (setstack_hscx(st, hsp))
+ st->l1.hardware = cs;
+ chanp->bcs->mode = 2;
+ if (chanp->bcs->BC_SetStack(st, chanp->bcs))
return (-1);
-
- st->l2.extended = 0;
- st->l2.laptype = LAPB;
- st->l2.orig = !incoming;
- st->l2.t200 = 1000; /* 1000 milliseconds */
+ st->l2.flag = 0;
+ test_and_set_bit(FLG_LAPB, &st->l2.flag);
+ st->l2.maxlen = MAX_DATA_SIZE;
+ if (!incoming)
+ test_and_set_bit(FLG_ORIG, &st->l2.flag);
+ st->l2.T200 = 1000; /* 1000 milliseconds */
st->l2.window = 7;
- st->l2.n200 = 4; /* try 4 times */
- st->l2.t203 = 5000; /* 5000 milliseconds */
-
+ st->l2.N200 = 4; /* try 4 times */
+ st->l2.T203 = 5000; /* 5000 milliseconds */
st->l3.debug = 0;
switch (chanp->l2_active_protocol) {
case (ISDN_PROTO_L2_X75I):
sprintf(tmp, "Channel %d x.75", chanp->chan);
setstack_isdnl2(st, tmp);
st->l2.l2l3 = lldata_handler;
- st->l1.l1man = dcc_l1man;
- st->l2.l2man = dcc_l2man;
- st->l2.l2tei = l2tei_dummy;
- st->l4.userdata = chanp;
- st->l4.l1writewakeup = NULL;
- st->l4.l2writewakeup = ll_writewakeup;
+ st->l1.l1man = bc_l1man;
+ st->l2.l2man = bc_l2man;
+ st->lli.userdata = chanp;
+ st->lli.l1writewakeup = NULL;
+ st->lli.l2writewakeup = ll_writewakeup;
st->l2.l2m.debug = chanp->debug & 16;
st->l2.debug = chanp->debug & 64;
st->ma.manl2(st, MDL_NOTEIPROC, NULL);
- st->l1.hscxmode = 2; /* Packet-Mode ? */
- st->l1.hscxchannel = chanp->para.bchannel - 1;
+ st->l1.mode = L1_MODE_HDLC;
+ if (chanp->leased)
+ st->l1.bc = chanp->chan & 1;
+ else
+ st->l1.bc = chanp->proc->para.bchannel - 1;
break;
case (ISDN_PROTO_L2_HDLC):
st->l1.l1l2 = lltrans_handler;
- st->l1.l1man = dcc_l1man;
- st->l4.userdata = chanp;
- st->l4.l1writewakeup = ll_writewakeup;
- st->l1.hscxmode = 2;
- st->l1.hscxchannel = chanp->para.bchannel - 1;
+ st->l1.l1man = bc_l1man;
+ st->lli.userdata = chanp;
+ st->lli.l1writewakeup = ll_writewakeup;
+ st->l1.mode = L1_MODE_HDLC;
+ if (chanp->leased)
+ st->l1.bc = chanp->chan & 1;
+ else
+ st->l1.bc = chanp->proc->para.bchannel - 1;
break;
case (ISDN_PROTO_L2_TRANS):
st->l1.l1l2 = lltrans_handler;
- st->l1.l1man = dcc_l1man;
- st->l4.userdata = chanp;
- st->l4.l1writewakeup = ll_writewakeup;
- st->l1.hscxmode = 1;
- st->l1.hscxchannel = chanp->para.bchannel - 1;
+ st->l1.l1man = bc_l1man;
+ st->lli.userdata = chanp;
+ st->lli.l1writewakeup = ll_writewakeup;
+ st->l1.mode = L1_MODE_TRANS;
+ if (chanp->leased)
+ st->l1.bc = chanp->chan & 1;
+ else
+ st->l1.bc = chanp->proc->para.bchannel - 1;
break;
}
return (0);
@@ -1719,15 +1949,17 @@ distr_debug(struct IsdnCardState *csta, int debugflags)
for (i = 0; i < 2; i++) {
chanp[i].debug = debugflags;
chanp[i].fi.debug = debugflags & 2;
- chanp[i].is.l2.l2m.debug = debugflags & 8;
- chanp[i].ds.l2.l2m.debug = debugflags & 16;
- chanp[i].is.l2.debug = debugflags & 32;
- chanp[i].ds.l2.debug = debugflags & 64;
- chanp[i].lc_d.lcfi.debug = debugflags & 128;
- chanp[i].lc_b.lcfi.debug = debugflags & 256;
+ chanp[i].d_st->l2.l2m.debug = debugflags & 8;
+ chanp[i].b_st->l2.l2m.debug = debugflags & 0x10;
+ chanp[i].d_st->l2.debug = debugflags & 0x20;
+ chanp[i].b_st->l2.debug = debugflags & 0x40;
+ chanp[i].lc_d->lcfi.debug = debugflags & 0x80;
+ chanp[i].lc_b->lcfi.debug = debugflags & 0x100;
+ chanp[i].b_st->ma.tei_m.debug = debugflags & 0x200;
+ chanp[i].b_st->ma.debug = debugflags & 0x200;
+ chanp[i].d_st->l1.l1m.debug = debugflags & 0x1000;
}
csta->dlogflag = debugflags & 4;
- csta->teistack->l2.l2m.debug = debugflags & 512;
}
int
@@ -1748,8 +1980,11 @@ HiSax_command(isdn_ctrl * ic)
switch (ic->command) {
case (ISDN_CMD_SETEAZ):
chanp = csta->channel + ic->arg;
- if (chanp->debug & 1)
- link_debug(chanp, "SETEAZ", 1);
+ if (chanp->debug & 1) {
+ sprintf(tmp, "SETEAZ card %d %s", csta->cardnr + 1,
+ ic->parm.num);
+ link_debug(chanp, tmp, 1);
+ }
break;
case (ISDN_CMD_SETL2):
chanp = csta->channel + (ic->arg & 0xff);
@@ -1768,9 +2003,9 @@ HiSax_command(isdn_ctrl * ic)
ic->parm.setup.si1, ic->parm.setup.si2);
link_debug(chanp, tmp, 1);
}
- chanp->para.setup = ic->parm.setup;
- if (!strcmp(chanp->para.setup.eazmsn, "0"))
- chanp->para.setup.eazmsn[0] = '\0';
+ chanp->setup = ic->parm.setup;
+ if (!strcmp(chanp->setup.eazmsn, "0"))
+ chanp->setup.eazmsn[0] = '\0';
/* this solution is dirty and may be change, if
* we make a callreference based callmanager */
if (chanp->fi.state == ST_NULL) {
@@ -1817,7 +2052,7 @@ HiSax_command(isdn_ctrl * ic)
case (ISDN_CMD_LOCK):
HiSax_mod_inc_use_count();
#ifdef MODULE
- if (csta->channel[0].debug & 1024) {
+ if (csta->channel[0].debug & 0x400) {
jiftime(tmp, jiffies);
i = strlen(tmp);
sprintf(tmp + i, " LOCK modcnt %lx\n", MOD_USE_COUNT);
@@ -1828,7 +2063,7 @@ HiSax_command(isdn_ctrl * ic)
case (ISDN_CMD_UNLOCK):
HiSax_mod_dec_use_count();
#ifdef MODULE
- if (csta->channel[0].debug & 1024) {
+ if (csta->channel[0].debug & 0x400) {
jiftime(tmp, jiffies);
i = strlen(tmp);
sprintf(tmp + i, " UNLOCK modcnt %lx\n", MOD_USE_COUNT);
@@ -1852,16 +2087,13 @@ HiSax_command(isdn_ctrl * ic)
printk(KERN_DEBUG "HiSax: %s", tmp);
break;
case (2):
- num = *(unsigned int *) ic->parm.num;
- i = num >> 8;
- if (i >= 2)
- break;
- chanp = csta->channel + i;
- chanp->impair = num & 0xff;
- if (chanp->debug & 1) {
- sprintf(tmp, "IMPAIR %x", chanp->impair);
- link_debug(chanp, tmp, 1);
- }
+ num = *(unsigned int *) ic->parm.num;
+ csta->channel[0].lc_b->delay = num;
+ csta->channel[1].lc_b->delay = num;
+ sprintf(tmp, "delay card %d set to %d ms\n",
+ csta->cardnr + 1, num);
+ HiSax_putstatus(csta, tmp);
+ printk(KERN_DEBUG "HiSax: %s", tmp);
break;
case (3):
for (i = 0; i < *(unsigned int *) ic->parm.num; i++)
@@ -1872,35 +2104,47 @@ HiSax_command(isdn_ctrl * ic)
HiSax_mod_inc_use_count();
break;
case (5): /* set card in leased mode */
- csta->channel[0].leased = 1;
- csta->channel[1].leased = 1;
- sprintf(tmp, "card %d set into leased mode\n",
- csta->cardnr + 1);
- HiSax_putstatus(csta, tmp);
+ num = *(unsigned int *) ic->parm.num;
+ if ((num <1) || (num > 2)) {
+ sprintf(tmp, "Set LEASED wrong channel %d\n",
+ num);
+ HiSax_putstatus(csta, tmp);
+ printk(KERN_WARNING "HiSax: %s", tmp);
+ } else {
+ num--;
+ csta->channel[num].leased = 1;
+ csta->channel[num].lc_d->l2_establish = 0;
+ sprintf(tmp, "card %d channel %d set leased mode\n",
+ csta->cardnr + 1, num + 1);
+ HiSax_putstatus(csta, tmp);
+ FsmEvent(&csta->channel[num].lc_d->lcfi, EV_LC_ESTABLISH, NULL);
+ }
+ break;
+ case (6): /* set B-channel test loop */
+ num = *(unsigned int *) ic->parm.num;
+ if (csta->stlist)
+ csta->stlist->ma.manl1(csta->stlist,
+ PH_TESTLOOP_REQ, (void *) num);
break;
#ifdef MODULE
case (55):
-#if (LINUX_VERSION_CODE < 0x020111)
- MOD_USE_COUNT = MOD_VISITED;
-#else
MOD_USE_COUNT = 0;
-#endif
HiSax_mod_inc_use_count();
break;
#endif /* MODULE */
case (11):
csta->debug = *(unsigned int *) ic->parm.num;
sprintf(tmp, "l1 debugging flags card %d set to %x\n",
- csta->cardnr + 1, csta->debug);
- HiSax_putstatus(cards[0].sp, tmp);
+ csta->cardnr + 1, csta->debug);
+ HiSax_putstatus(cards[0].cs, tmp);
printk(KERN_DEBUG "HiSax: %s", tmp);
break;
case (13):
- csta->channel[0].is.l3.debug = *(unsigned int *) ic->parm.num;
- csta->channel[1].is.l3.debug = *(unsigned int *) ic->parm.num;
+ csta->channel[0].d_st->l3.debug = *(unsigned int *) ic->parm.num;
+ csta->channel[1].d_st->l3.debug = *(unsigned int *) ic->parm.num;
sprintf(tmp, "l3 debugging flags card %d set to %x\n",
csta->cardnr + 1, *(unsigned int *) ic->parm.num);
- HiSax_putstatus(cards[0].sp, tmp);
+ HiSax_putstatus(cards[0].cs, tmp);
printk(KERN_DEBUG "HiSax: %s", tmp);
break;
default:
@@ -1917,7 +2161,7 @@ HiSax_command(isdn_ctrl * ic)
}
int
-HiSax_writebuf_skb(int id, int chan, struct sk_buff *skb)
+HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb)
{
struct IsdnCardState *csta = hisax_findcard(id);
struct Channel *chanp;
@@ -1933,7 +2177,7 @@ HiSax_writebuf_skb(int id, int chan, struct sk_buff *skb)
return -ENODEV;
}
chanp = csta->channel + chan;
- st = &chanp->ds;
+ st = chanp->b_st;
if (!chanp->data_open) {
link_debug(chanp, "writebuf: channel not open", 1);
return -EIO;
@@ -1945,11 +2189,11 @@ HiSax_writebuf_skb(int id, int chan, struct sk_buff *skb)
return -EINVAL;
}
if (len) {
- if ((len + csta->hs[chanp->hscx].tx_cnt) > MAX_DATA_MEM) {
+ if ((len + chanp->bcs->tx_cnt) > MAX_DATA_MEM) {
/* Must return 0 here, since this is not an error
* but a temporary lack of resources.
*/
- if (chanp->debug & 2048) {
+ if (chanp->debug & 0x800) {
sprintf(tmp, "writebuf: no buffers for %d bytes", len);
link_debug(chanp, tmp, 1);
}
@@ -1959,12 +2203,13 @@ HiSax_writebuf_skb(int id, int chan, struct sk_buff *skb)
cli();
nskb = skb_clone(skb, GFP_ATOMIC);
if (nskb) {
- if (chanp->lc_b.l2_establish) {
- csta->hs[chanp->hscx].tx_cnt += len + st->l2.ihsize;
- chanp->ds.l3.l3l2(&chanp->ds, DL_DATA, nskb);
- } else {
- csta->hs[chanp->hscx].tx_cnt += len;
- chanp->ds.l2.l2l1(&chanp->ds, PH_DATA, nskb);
+ if (!ack)
+ nskb->pkt_type = PACKET_NOACK;
+ if (chanp->lc_b->l2_establish)
+ st->l3.l3l2(st, DL_DATA, nskb);
+ else {
+ chanp->bcs->tx_cnt += len;
+ st->l2.l2l1(st, PH_DATA_REQ, nskb);
}
dev_kfree_skb(skb);
} else
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 7379c8a77..67e308e43 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -1,58 +1,53 @@
-/* $Id: config.c,v 1.15 1997/04/06 22:57:24 keil Exp $
+/* $Id: config.c,v 2.12 1998/02/11 17:28:02 keil Exp $
* Author Karsten Keil (keil@temic-ech.spacenet.de)
* based on the teles driver from Jan den Ouden
*
*
* $Log: config.c,v $
- * Revision 1.15 1997/04/06 22:57:24 keil
- * Hisax version 2.1
+ * Revision 2.12 1998/02/11 17:28:02 keil
+ * Niccy PnP/PCI support
*
- * Revision 1.14 1997/03/25 23:11:22 keil
- * US NI-1 protocol
+ * Revision 2.11 1998/02/09 21:26:13 keil
+ * fix export module for 2.1
*
- * Revision 1.13 1997/03/23 21:45:49 keil
- * Add support for ELSA PCMCIA
+ * Revision 2.10 1998/02/09 18:46:05 keil
+ * Support for Sedlbauer PCMCIA (Marcus Niemann)
*
- * Revision 1.12 1997/03/11 21:01:43 keil
- * nzproto is only used with modules
+ * Revision 2.9 1998/02/03 23:31:28 keil
+ * add AMD7930 support
*
- * Revision 1.11 1997/02/14 12:23:12 fritz
- * Added support for new insmod parameter handling.
+ * Revision 2.8 1998/02/02 13:32:59 keil
+ * New card support
*
- * Revision 1.10 1997/02/14 09:22:09 keil
- * Final 2.0 version
+ * Revision 2.7 1998/01/31 21:41:44 keil
+ * changes for newer 2.1 kernels
*
- * Revision 1.9 1997/02/10 11:45:09 fritz
- * More changes for Kernel 2.1.X compatibility.
+ * Revision 2.6 1997/11/08 21:35:43 keil
+ * new l1 init
*
- * Revision 1.8 1997/02/09 00:28:05 keil
- * new interface handling, one interface per card
- * default protocol now works again
+ * Revision 2.5 1997/11/06 17:15:08 keil
+ * New 2.1 init; PCMCIA wrapper changes
*
- * Revision 1.7 1997/01/27 15:56:57 keil
- * Teles PCMCIA ITK ix1 micro added
+ * Revision 2.4 1997/10/29 19:07:52 keil
+ * changes for 2.1
*
- * Revision 1.6 1997/01/21 22:17:56 keil
- * new module load syntax
+ * Revision 2.3 1997/10/01 09:21:33 fritz
+ * Removed old compatibility stuff for 2.0.X kernels.
+ * From now on, this code is for 2.1.X ONLY!
+ * Old stuff is still in the separate branch.
*
- * Revision 1.5 1997/01/09 18:28:20 keil
- * cosmetic cleanups
+ * Revision 2.2 1997/09/11 17:24:46 keil
+ * Add new cards
*
- * Revision 1.4 1996/11/05 19:35:17 keil
- * using config.h; some spelling fixes
- *
- * Revision 1.3 1996/10/23 17:23:28 keil
- * default config changes
- *
- * Revision 1.2 1996/10/23 11:58:48 fritz
- * Changed default setup to reflect user's selection of supported
- * cards/protocols.
- *
- * Revision 1.1 1996/10/13 20:04:51 keil
- * Initial revision
+ * Revision 2.1 1997/07/27 21:41:35 keil
+ * version change
*
+ * Revision 2.0 1997/06/26 11:06:28 keil
+ * New card and L1 interface.
+ * Eicon.Diehl Diva and Dynalink IS64PH support
*
+ * old changes removed /KKe
*
*/
#include <linux/types.h>
@@ -68,16 +63,30 @@
* { type, protocol, p0, p1, p2, NULL }
*
* type
- * 1 Teles 16.0 p0=irq p1=membase p2=iobase
- * 2 Teles 8.0 p0=irq p1=membase
- * 3 Teles 16.3 p0=irq p1=iobase
- * 4 Creatix PNP p0=irq p1=IO0 (ISAC) p2=IO1 (HSCX)
- * 5 AVM A1 (Fritz) p0=irq p1=iobase
- * 6 ELSA PC [p0=iobase] or nothing (autodetect)
- * 7 ELSA Quickstep p0=irq p1=iobase
- * ELSA PCMCIA p0=irq p1=iobase
- * 8 Teles PCMCIA p0=irq p1=iobase
- * 9 ITK ix1-micro p0=irq p1=iobase
+ * 1 Teles 16.0 p0=irq p1=membase p2=iobase
+ * 2 Teles 8.0 p0=irq p1=membase
+ * 3 Teles 16.3 p0=irq p1=iobase
+ * 4 Creatix PNP p0=irq p1=IO0 (ISAC) p2=IO1 (HSCX)
+ * 5 AVM A1 (Fritz) p0=irq p1=iobase
+ * 6 ELSA PC [p0=iobase] or nothing (autodetect)
+ * 7 ELSA Quickstep p0=irq p1=iobase
+ * 8 Teles PCMCIA p0=irq p1=iobase
+ * 9 ITK ix1-micro p0=irq p1=iobase
+ * 10 ELSA PCMCIA p0=irq p1=iobase
+ * 11 Eicon.Diehl Diva p0=irq p1=iobase
+ * 12 Asuscom ISDNLink p0=irq p1=iobase
+ * 13 Teleint p0=irq p1=iobase
+ * 14 Teles 16.3c p0=irq p1=iobase
+ * 15 Sedlbauer speed p0=irq p1=iobase
+ * 16 USR Sportster internal p0=irq p1=iobase
+ * 17 MIC card p0=irq p1=iobase
+ * 18 ELSA Quickstep 1000PCI no parameter
+ * 19 Compaq ISDN S0 ISA card p0=irq p1=IO0 (HSCX) p2=IO1 (ISAC) p3=IO2
+ * 20 Travers Technologies NETjet PCI card
+ * 21 reserved TELES PCI
+ * 22 Sedlbauer Speed Star p0=irq p1=iobase
+ * 23 reserved
+ * 24 Dr Neuhaus Niccy PnP/PCI card p0=irq p1=IO0 p2=IO1 (PnP only)
*
*
* protocol can be either ISDN_PTYPE_EURO or ISDN_PTYPE_1TR6 or ISDN_PTYPE_NI1
@@ -85,38 +94,108 @@
*
*/
-#ifdef CONFIG_HISAX_ELSA_PCC
+#ifdef CONFIG_HISAX_ELSA
#define DEFAULT_CARD ISDN_CTYPE_ELSA
-#define DEFAULT_CFG {0,0,0}
-#endif
-#ifdef CONFIG_HISAX_ELSA_PCMCIA
-#define DEFAULT_CARD ISDN_CTYPE_ELSA_QS1000
-#define DEFAULT_CFG {3,0x2f8,0}
+#define DEFAULT_CFG {0,0,0,0}
+int elsa_init_pcmcia(void*, int, int*, int);
+EXPORT_SYMBOL(elsa_init_pcmcia);
#endif
#ifdef CONFIG_HISAX_AVM_A1
#undef DEFAULT_CARD
#undef DEFAULT_CFG
#define DEFAULT_CARD ISDN_CTYPE_A1
-#define DEFAULT_CFG {10,0x340,0}
+#define DEFAULT_CFG {10,0x340,0,0}
#endif
#ifdef CONFIG_HISAX_16_3
#undef DEFAULT_CARD
#undef DEFAULT_CFG
#define DEFAULT_CARD ISDN_CTYPE_16_3
-#define DEFAULT_CFG {15,0x180,0}
+#define DEFAULT_CFG {15,0x180,0,0}
#endif
#ifdef CONFIG_HISAX_16_0
#undef DEFAULT_CARD
#undef DEFAULT_CFG
#define DEFAULT_CARD ISDN_CTYPE_16_0
-#define DEFAULT_CFG {15,0xd0000,0xd80}
+#define DEFAULT_CFG {15,0xd0000,0xd80,0}
#endif
#ifdef CONFIG_HISAX_IX1MICROR2
#undef DEFAULT_CARD
#undef DEFAULT_CFG
#define DEFAULT_CARD ISDN_CTYPE_IX1MICROR2
-#define DEFAULT_CFG {5,0x390,0}
+#define DEFAULT_CFG {5,0x390,0,0}
+#endif
+
+#ifdef CONFIG_HISAX_DIEHLDIVA
+#undef DEFAULT_CARD
+#undef DEFAULT_CFG
+#define DEFAULT_CARD ISDN_CTYPE_DIEHLDIVA
+#define DEFAULT_CFG {0,0x0,0,0}
+#endif
+
+#ifdef CONFIG_HISAX_ASUSCOM
+#undef DEFAULT_CARD
+#undef DEFAULT_CFG
+#define DEFAULT_CARD ISDN_CTYPE_ASUSCOM
+#define DEFAULT_CFG {5,0x200,0,0}
+#endif
+
+#ifdef CONFIG_HISAX_TELEINT
+#undef DEFAULT_CARD
+#undef DEFAULT_CFG
+#define DEFAULT_CARD ISDN_CTYPE_TELEINT
+#define DEFAULT_CFG {5,0x300,0,0}
+#endif
+
+#ifdef CONFIG_HISAX_SEDLBAUER
+#undef DEFAULT_CARD
+#undef DEFAULT_CFG
+#define DEFAULT_CARD ISDN_CTYPE_SEDLBAUER
+#define DEFAULT_CFG {11,0x270,0,0}
+int sedl_init_pcmcia(void*, int, int*, int);
+EXPORT_SYMBOL(sedl_init_pcmcia);
+#endif
+
+#ifdef CONFIG_HISAX_SPORTSTER
+#undef DEFAULT_CARD
+#undef DEFAULT_CFG
+#define DEFAULT_CARD ISDN_CTYPE_SPORTSTER
+#define DEFAULT_CFG {7,0x268,0,0}
+#endif
+
+#ifdef CONFIG_HISAX_MIC
+#undef DEFAULT_CARD
+#undef DEFAULT_CFG
+#define DEFAULT_CARD ISDN_CTYPE_MIC
+#define DEFAULT_CFG {12,0x3e0,0,0}
+#endif
+
+#ifdef CONFIG_HISAX_NETJET
+#undef DEFAULT_CARD
+#undef DEFAULT_CFG
+#define DEFAULT_CARD ISDN_CTYPE_NETJET
+#define DEFAULT_CFG {0,0,0,0}
+#endif
+
+#ifdef CONFIG_HISAX_TELES3C
+#undef DEFAULT_CARD
+#undef DEFAULT_CFG
+#define DEFAULT_CARD ISDN_CTYPE_TELES3C
+#define DEFAULT_CFG {5,0x500,0,0}
+#endif
+
+#ifdef CONFIG_HISAX_AMD7930
+#undef DEFAULT_CARD
+#undef DEFAULT_CFG
+#define DEFAULT_CARD ISDN_CTYPE_AMD7930
+#define DEFAULT_CFG {12,0x3e0,0,0}
+#endif
+
+#ifdef CONFIG_HISAX_NICCY
+#undef DEFAULT_CARD
+#undef DEFAULT_CFG
+#define DEFAULT_CARD ISDN_CTYPE_NICCY
+#define DEFAULT_CFG {0,0x0,0,0}
#endif
#ifdef CONFIG_HISAX_1TR6
@@ -150,7 +229,7 @@
NULL, \
}
-#define EMPTY_CARD {0, DEFAULT_PROTO, {0, 0, 0}, NULL}
+#define EMPTY_CARD {0, DEFAULT_PROTO, {0, 0, 0, 0}, NULL}
struct IsdnCard cards[] =
{
@@ -172,55 +251,63 @@ struct IsdnCard cards[] =
EMPTY_CARD,
};
-static char HiSaxID[96] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" \
+static char HiSaxID[96] HISAX_INITDATA = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" \
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" \
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" \
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
-char *HiSax_id = HiSaxID;
+char *HiSax_id HISAX_INITDATA = HiSaxID;
#ifdef MODULE
/* Variables for insmod */
-static int type[] =
+static int type[] HISAX_INITDATA =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-static int protocol[] =
+static int protocol[] HISAX_INITDATA =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-static int io[] =
+static int io[] HISAX_INITDATA =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-#ifdef CONFIG_HISAX_16_3 /* For Creatix/Teles PnP */
-static int io0[] =
+#undef IO0_IO1
+#ifdef CONFIG_HISAX_16_3
+#define IO0_IO1
+#endif
+#ifdef CONFIG_HISAX_NICCY
+#undef IO0_IO1
+#define IO0_IO1
+#endif
+#ifdef IO0_IO1
+static int io0[] HISAX_INITDATA =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-static int io1[] =
+static int io1[] HISAX_INITDATA =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
#endif
-static int irq[] =
+static int irq[] HISAX_INITDATA =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-static int mem[] =
+static int mem[] HISAX_INITDATA =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-static char *id = HiSaxID;
+static char *id HISAX_INITDATA = HiSaxID;
-#if (LINUX_VERSION_CODE > 0x020111)
MODULE_AUTHOR("Karsten Keil");
-MODULE_PARM(type, "1-16i");
-MODULE_PARM(protocol, "1-16i");
-MODULE_PARM(io, "1-16i");
-MODULE_PARM(irq, "1-16i");
-MODULE_PARM(mem, "1-16i");
+MODULE_PARM(type, "1-3i");
+MODULE_PARM(protocol, "1-2i");
+MODULE_PARM(io, "1-8i");
+MODULE_PARM(irq, "1-2i");
+MODULE_PARM(mem, "1-12i");
MODULE_PARM(id, "s");
#ifdef CONFIG_HISAX_16_3 /* For Creatix/Teles PnP */
-MODULE_PARM(io0, "1-16i");
-MODULE_PARM(io1, "1-16i");
-#endif
+MODULE_PARM(io0, "1-8i");
+MODULE_PARM(io1, "1-8i");
#endif
#endif
+int nrcards;
+
extern char *l1_revision;
extern char *l2_revision;
extern char *l3_revision;
-extern char *l4_revision;
+extern char *lli_revision;
extern char *tei_revision;
-char *
-HiSax_getrev(const char *revision)
+HISAX_INITFUNC(char *
+HiSax_getrev(const char *revision))
{
char *rev;
char *p;
@@ -234,7 +321,27 @@ HiSax_getrev(const char *revision)
return rev;
}
-int nrcards;
+HISAX_INITFUNC(void
+HiSaxVersion(void))
+{
+ char tmp[64], rev[64];
+ char *r = rev;
+
+ strcpy(tmp, l1_revision);
+ r += sprintf(r, "%s/", HiSax_getrev(tmp));
+ strcpy(tmp, l2_revision);
+ r += sprintf(r, "%s/", HiSax_getrev(tmp));
+ strcpy(tmp, l3_revision);
+ r += sprintf(r, "%s/", HiSax_getrev(tmp));
+ strcpy(tmp, lli_revision);
+ r += sprintf(r, "%s/", HiSax_getrev(tmp));
+ strcpy(tmp, tei_revision);
+ r += sprintf(r, "%s", HiSax_getrev(tmp));
+
+ printk(KERN_INFO "HiSax: Driver for Siemens chip set ISDN cards\n");
+ printk(KERN_INFO "HiSax: Version 2.8\n");
+ printk(KERN_INFO "HiSax: Revisions %s\n", rev);
+}
void
HiSax_mod_dec_use_count(void)
@@ -251,8 +358,8 @@ HiSax_mod_inc_use_count(void)
#ifdef MODULE
#define HiSax_init init_module
#else
-void
-HiSax_setup(char *str, int *ints)
+__initfunc(void
+HiSax_setup(char *str, int *ints))
{
int i, j, argc;
@@ -297,31 +404,28 @@ HiSax_setup(char *str, int *ints)
}
#endif
-int
-HiSax_init(void)
+__initfunc(int
+HiSax_init(void))
{
int i;
- char tmp[64], rev[64];
- char *r = rev;
+
#ifdef MODULE
int nzproto = 0;
+#ifdef CONFIG_HISAX_ELSA
+ if (type[0] == ISDN_CTYPE_ELSA_PCMCIA) {
+ /* we have exported and return in this case */
+ return 0;
+ }
+#endif
+#ifdef CONFIG_HISAX_SEDLBAUER
+ if (type[0] == ISDN_CTYPE_SEDLBAUER_PCMCIA) {
+ /* we have to export and return in this case */
+ return 0;
+ }
+#endif
#endif
+ HiSaxVersion();
nrcards = 0;
- strcpy(tmp, l1_revision);
- r += sprintf(r, "%s/", HiSax_getrev(tmp));
- strcpy(tmp, l2_revision);
- r += sprintf(r, "%s/", HiSax_getrev(tmp));
- strcpy(tmp, l3_revision);
- r += sprintf(r, "%s/", HiSax_getrev(tmp));
- strcpy(tmp, l4_revision);
- r += sprintf(r, "%s/", HiSax_getrev(tmp));
- strcpy(tmp, tei_revision);
- r += sprintf(r, "%s", HiSax_getrev(tmp));
-
- printk(KERN_NOTICE "HiSax: Driver for Siemens chip set ISDN cards\n");
- printk(KERN_NOTICE "HiSax: Version 2.1\n");
- printk(KERN_NOTICE "HiSax: Revisions %s\n", rev);
-
#ifdef MODULE
if (id) /* If id= string used */
HiSax_id = id;
@@ -343,37 +447,44 @@ HiSax_init(void)
cards[i].para[1] = mem[i];
break;
- case ISDN_CTYPE_16_3:
- case ISDN_CTYPE_TELESPCMCIA:
- cards[i].para[0] = irq[i];
- cards[i].para[1] = io[i];
- break;
-
-#ifdef CONFIG_HISAX_16_3 /* For Creatix/Teles PnP */
+#ifdef IO0_IO1
case ISDN_CTYPE_PNP:
+ case ISDN_CTYPE_NICCY:
cards[i].para[0] = irq[i];
cards[i].para[1] = io0[i];
cards[i].para[2] = io1[i];
break;
-#endif
- case ISDN_CTYPE_A1:
+ case ISDN_CTYPE_COMPAQ_ISA:
cards[i].para[0] = irq[i];
- cards[i].para[1] = io[i];
+ cards[i].para[1] = io0[i];
+ cards[i].para[2] = io1[i];
+ cards[i].para[3] = io[i];
break;
-
+#endif
case ISDN_CTYPE_ELSA:
cards[i].para[0] = io[i];
break;
- case ISDN_CTYPE_ELSA_QS1000:
- cards[i].para[0] = irq[i];
- cards[i].para[1] = io[i];
- break;
-
+ case ISDN_CTYPE_16_3:
+ case ISDN_CTYPE_TELESPCMCIA:
+ case ISDN_CTYPE_A1:
+ case ISDN_CTYPE_ELSA_PNP:
+ case ISDN_CTYPE_ELSA_PCMCIA:
case ISDN_CTYPE_IX1MICROR2:
+ case ISDN_CTYPE_DIEHLDIVA:
+ case ISDN_CTYPE_ASUSCOM:
+ case ISDN_CTYPE_TELEINT:
+ case ISDN_CTYPE_SEDLBAUER:
+ case ISDN_CTYPE_SEDLBAUER_PCMCIA:
+ case ISDN_CTYPE_SPORTSTER:
+ case ISDN_CTYPE_MIC:
+ case ISDN_CTYPE_TELES3C:
cards[i].para[0] = irq[i];
cards[i].para[1] = io[i];
break;
-
+ case ISDN_CTYPE_ELSA_PCI:
+ case ISDN_CTYPE_NETJET:
+ case ISDN_CTYPE_AMD7930:
+ break;
}
}
if (!nzproto) {
@@ -394,20 +505,20 @@ HiSax_init(void)
CallcNew();
Isdnl2New();
- if (HiSax_inithardware()) {
+ TeiNew();
+ Isdnl1New();
+ if (HiSax_inithardware(NULL)) {
/* Install only, if at least one card found */
/* No symbols to export, hide all symbols */
#ifdef MODULE
-#if (LINUX_VERSION_CODE < 0x020111)
- register_symtab(NULL);
-#else
EXPORT_NO_SYMBOLS;
-#endif
- printk(KERN_NOTICE "HiSax: module installed\n");
+ printk(KERN_INFO "HiSax: module installed\n");
#endif
return (0);
} else {
+ Isdnl1Free();
+ TeiFree();
Isdnl2Free();
CallcFree();
return -EIO;
@@ -419,7 +530,101 @@ void
cleanup_module(void)
{
HiSax_closehardware();
- printk(KERN_NOTICE "HiSax module removed\n");
+ printk(KERN_INFO "HiSax module removed\n");
}
+#ifdef CONFIG_HISAX_ELSA
+int elsa_init_pcmcia(void *pcm_iob, int pcm_irq, int *busy_flag, int prot)
+{
+ int i;
+ int nzproto = 0;
+
+ nrcards = 0;
+ HiSaxVersion();
+ if (id) /* If id= string used */
+ HiSax_id = id;
+ /* Initialize all 16 structs, even though we only accept
+ two pcmcia cards
+ */
+ for (i = 0; i < 16; i++) {
+ cards[i].para[0] = irq[i];
+ cards[i].para[1] = io[i];
+ cards[i].typ = type[i];
+ if (protocol[i]) {
+ cards[i].protocol = protocol[i];
+ nzproto++;
+ }
+ }
+ cards[0].para[0] = pcm_irq;
+ cards[0].para[1] = (int)pcm_iob;
+ cards[0].protocol = prot;
+ cards[0].typ = 10;
+ nzproto = 1;
+
+ if (!HiSax_id)
+ HiSax_id = HiSaxID;
+ if (!HiSaxID[0])
+ strcpy(HiSaxID, "HiSax");
+ for (i = 0; i < 16; i++)
+ if (cards[i].typ > 0)
+ nrcards++;
+ printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
+ nrcards, (nrcards > 1) ? "s" : "");
+
+ Isdnl1New();
+ CallcNew();
+ Isdnl2New();
+ TeiNew();
+ HiSax_inithardware(busy_flag);
+ printk(KERN_NOTICE "HiSax: module installed\n");
+ return (0);
+}
+#endif
+#ifdef CONFIG_HISAX_SEDLBAUER
+int sedl_init_pcmcia(void *pcm_iob, int pcm_irq, int *busy_flag, int prot)
+{
+ int i;
+ int nzproto = 0;
+
+ nrcards = 0;
+ HiSaxVersion();
+ if (id) /* If id= string used */
+ HiSax_id = id;
+ /* Initialize all 16 structs, even though we only accept
+ two pcmcia cards
+ */
+ for (i = 0; i < 16; i++) {
+ cards[i].para[0] = irq[i];
+ cards[i].para[1] = io[i];
+ cards[i].typ = type[i];
+ if (protocol[i]) {
+ cards[i].protocol = protocol[i];
+ nzproto++;
+ }
+ }
+ cards[0].para[0] = pcm_irq;
+ cards[0].para[1] = (int)pcm_iob;
+ cards[0].protocol = prot;
+ cards[0].typ = ISDN_CTYPE_SEDLBAUER_PCMCIA;
+ nzproto = 1;
+
+ if (!HiSax_id)
+ HiSax_id = HiSaxID;
+ if (!HiSaxID[0])
+ strcpy(HiSaxID, "HiSax");
+ for (i = 0; i < 16; i++)
+ if (cards[i].typ > 0)
+ nrcards++;
+ printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
+ nrcards, (nrcards > 1) ? "s" : "");
+
+ Isdnl1New();
+ CallcNew();
+ Isdnl2New();
+ TeiNew();
+ HiSax_inithardware(busy_flag);
+ printk(KERN_NOTICE "HiSax: module installed\n");
+ return (0);
+}
#endif
+#endif
diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
new file mode 100644
index 000000000..fa3a45b72
--- /dev/null
+++ b/drivers/isdn/hisax/diva.c
@@ -0,0 +1,465 @@
+/* $Id: diva.c,v 1.5 1998/02/02 13:29:38 keil Exp $
+
+ * diva.c low level stuff for Eicon.Diehl Diva Family ISDN cards
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ * Thanks to Eicon Technology Diehl GmbH & Co. oHG for documents and informations
+ *
+ *
+ * $Log: diva.c,v $
+ * Revision 1.5 1998/02/02 13:29:38 keil
+ * fast io
+ *
+ * Revision 1.4 1997/11/08 21:35:44 keil
+ * new l1 init
+ *
+ * Revision 1.3 1997/11/06 17:13:33 keil
+ * New 2.1 init code
+ *
+ * Revision 1.2 1997/10/29 18:55:55 keil
+ * changes for 2.1.60 (irq2dev_map)
+ *
+ * Revision 1.1 1997/09/18 17:11:20 keil
+ * first version
+ *
+ *
+ */
+
+#define __NO_VERSION__
+#include <linux/config.h>
+#include "hisax.h"
+#include "isac.h"
+#include "hscx.h"
+#include "isdnl1.h"
+#include <linux/pci.h>
+#include <linux/bios32.h>
+
+extern const char *CardType[];
+
+const char *Diva_revision = "$Revision: 1.5 $";
+
+#define byteout(addr,val) outb(val,addr)
+#define bytein(addr) inb(addr)
+
+#define DIVA_HSCX_DATA 0
+#define DIVA_HSCX_ADR 4
+#define DIVA_ISA_ISAC_DATA 2
+#define DIVA_ISA_ISAC_ADR 6
+#define DIVA_ISA_CTRL 7
+
+#define DIVA_PCI_ISAC_DATA 8
+#define DIVA_PCI_ISAC_ADR 0xc
+#define DIVA_PCI_CTRL 0x10
+
+/* SUB Types */
+#define DIVA_ISA 1
+#define DIVA_PCI 2
+
+/* PCI stuff */
+#define PCI_VENDOR_EICON_DIEHL 0x1133
+#define PCI_DIVA20PRO_ID 0xe001
+#define PCI_DIVA20_ID 0xe002
+#define PCI_DIVA20PRO_U_ID 0xe003
+#define PCI_DIVA20_U_ID 0xe004
+
+/* CTRL (Read) */
+#define DIVA_IRQ_STAT 0x01
+#define DIVA_EEPROM_SDA 0x02
+/* CTRL (Write) */
+#define DIVA_IRQ_REQ 0x01
+#define DIVA_RESET 0x08
+#define DIVA_EEPROM_CLK 0x40
+#define DIVA_PCI_LED_A 0x10
+#define DIVA_PCI_LED_B 0x20
+#define DIVA_ISA_LED_A 0x20
+#define DIVA_ISA_LED_B 0x40
+#define DIVA_IRQ_CLR 0x80
+
+static inline u_char
+readreg(unsigned int ale, unsigned int adr, u_char off)
+{
+ register u_char ret;
+ long flags;
+
+ save_flags(flags);
+ cli();
+ byteout(ale, off);
+ ret = bytein(adr);
+ restore_flags(flags);
+ return (ret);
+}
+
+static inline void
+readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
+{
+ /* fifo read without cli because it's allready done */
+
+ byteout(ale, off);
+ insb(adr, data, size);
+}
+
+
+static inline void
+writereg(unsigned int ale, unsigned int adr, u_char off, u_char data)
+{
+ long flags;
+
+ save_flags(flags);
+ cli();
+ byteout(ale, off);
+ byteout(adr, data);
+ restore_flags(flags);
+}
+
+static inline void
+writefifo(unsigned int ale, unsigned int adr, u_char off, u_char *data, int size)
+{
+ /* fifo write without cli because it's allready done */
+ byteout(ale, off);
+ outsb(adr, data, size);
+}
+
+/* Interface functions */
+
+static u_char
+ReadISAC(struct IsdnCardState *cs, u_char offset)
+{
+ return(readreg(cs->hw.diva.isac_adr, cs->hw.diva.isac, offset));
+}
+
+static void
+WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
+{
+ writereg(cs->hw.diva.isac_adr, cs->hw.diva.isac, offset, value);
+}
+
+static void
+ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size)
+{
+ readfifo(cs->hw.diva.isac_adr, cs->hw.diva.isac, 0, data, size);
+}
+
+static void
+WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size)
+{
+ writefifo(cs->hw.diva.isac_adr, cs->hw.diva.isac, 0, data, size);
+}
+
+static u_char
+ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
+{
+ return(readreg(cs->hw.diva.hscx_adr,
+ cs->hw.diva.hscx, offset + (hscx ? 0x40 : 0)));
+}
+
+static void
+WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
+{
+ writereg(cs->hw.diva.hscx_adr,
+ cs->hw.diva.hscx, offset + (hscx ? 0x40 : 0), value);
+}
+
+/*
+ * fast interrupt HSCX stuff goes here
+ */
+
+#define READHSCX(cs, nr, reg) readreg(cs->hw.diva.hscx_adr, \
+ cs->hw.diva.hscx, reg + (nr ? 0x40 : 0))
+#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.diva.hscx_adr, \
+ cs->hw.diva.hscx, reg + (nr ? 0x40 : 0), data)
+
+#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.diva.hscx_adr, \
+ cs->hw.diva.hscx, (nr ? 0x40 : 0), ptr, cnt)
+
+#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.diva.hscx_adr, \
+ cs->hw.diva.hscx, (nr ? 0x40 : 0), ptr, cnt)
+
+#include "hscx_irq.c"
+
+static void
+diva_interrupt(int intno, void *dev_id, struct pt_regs *regs)
+{
+ struct IsdnCardState *cs = dev_id;
+ u_char val, sval, stat = 0;
+ int cnt=8;
+
+ if (!cs) {
+ printk(KERN_WARNING "Diva: Spurious interrupt!\n");
+ return;
+ }
+ while (((sval = bytein(cs->hw.diva.ctrl)) & DIVA_IRQ_REQ) && cnt) {
+ val = readreg(cs->hw.diva.hscx_adr, cs->hw.diva.hscx, HSCX_ISTA + 0x40);
+ if (val) {
+ hscx_int_main(cs, val);
+ stat |= 1;
+ }
+ val = readreg(cs->hw.diva.isac_adr, cs->hw.diva.isac, ISAC_ISTA);
+ if (val) {
+ isac_interrupt(cs, val);
+ stat |= 2;
+ }
+ cnt--;
+ }
+ if (!cnt)
+ printk(KERN_WARNING "Diva: IRQ LOOP\n");
+ if (stat & 1) {
+ writereg(cs->hw.diva.hscx_adr, cs->hw.diva.hscx, HSCX_MASK, 0xFF);
+ writereg(cs->hw.diva.hscx_adr, cs->hw.diva.hscx, HSCX_MASK + 0x40, 0xFF);
+ writereg(cs->hw.diva.hscx_adr, cs->hw.diva.hscx, HSCX_MASK, 0x0);
+ writereg(cs->hw.diva.hscx_adr, cs->hw.diva.hscx, HSCX_MASK + 0x40, 0x0);
+ }
+ if (stat & 2) {
+ writereg(cs->hw.diva.isac_adr, cs->hw.diva.isac, ISAC_MASK, 0xFF);
+ writereg(cs->hw.diva.isac_adr, cs->hw.diva.isac, ISAC_MASK, 0x0);
+ }
+}
+
+void
+release_io_diva(struct IsdnCardState *cs)
+{
+ int bytecnt;
+
+ del_timer(&cs->hw.diva.tl);
+ if (cs->subtyp == DIVA_ISA)
+ bytecnt = 8;
+ else
+ bytecnt = 32;
+ if (cs->hw.diva.cfg_reg) {
+ byteout(cs->hw.diva.ctrl, 0); /* LED off, Reset */
+ release_region(cs->hw.diva.cfg_reg, bytecnt);
+ }
+}
+
+static void
+reset_diva(struct IsdnCardState *cs)
+{
+ long flags;
+
+ save_flags(flags);
+ sti();
+ cs->hw.diva.ctrl_reg = 0; /* Reset On */
+ byteout(cs->hw.diva.ctrl, cs->hw.diva.ctrl_reg);
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + (10 * HZ) / 1000; /* Timeout 10ms */
+ schedule();
+ cs->hw.diva.ctrl_reg |= DIVA_RESET; /* Reset Off */
+ byteout(cs->hw.diva.ctrl, cs->hw.diva.ctrl_reg);
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + (10 * HZ) / 1000; /* Timeout 10ms */
+ schedule();
+ if (cs->subtyp == DIVA_ISA)
+ cs->hw.diva.ctrl_reg |= DIVA_ISA_LED_A;
+ else
+ cs->hw.diva.ctrl_reg |= DIVA_PCI_LED_A;
+ byteout(cs->hw.diva.ctrl, cs->hw.diva.ctrl_reg);
+}
+
+#define DIVA_ASSIGN 1
+
+static void
+diva_led_handler(struct IsdnCardState *cs)
+{
+ int blink = 0;
+
+ del_timer(&cs->hw.diva.tl);
+ if (cs->hw.diva.status & DIVA_ASSIGN)
+ cs->hw.diva.ctrl_reg |= (DIVA_ISA == cs->subtyp) ?
+ DIVA_ISA_LED_A : DIVA_PCI_LED_A;
+ else {
+ cs->hw.diva.ctrl_reg ^= (DIVA_ISA == cs->subtyp) ?
+ DIVA_ISA_LED_A : DIVA_PCI_LED_A;
+ blink = 250;
+ }
+ if (cs->hw.diva.status & 0xf000)
+ cs->hw.diva.ctrl_reg |= (DIVA_ISA == cs->subtyp) ?
+ DIVA_ISA_LED_B : DIVA_PCI_LED_B;
+ else if (cs->hw.diva.status & 0x0f00) {
+ cs->hw.diva.ctrl_reg ^= (DIVA_ISA == cs->subtyp) ?
+ DIVA_ISA_LED_B : DIVA_PCI_LED_B;
+ blink = 500;
+ } else
+ cs->hw.diva.ctrl_reg &= ~((DIVA_ISA == cs->subtyp) ?
+ DIVA_ISA_LED_B : DIVA_PCI_LED_B);
+
+ byteout(cs->hw.diva.ctrl, cs->hw.diva.ctrl_reg);
+ if (blink) {
+ init_timer(&cs->hw.diva.tl);
+ cs->hw.diva.tl.expires = jiffies + ((blink * HZ) / 1000);
+ add_timer(&cs->hw.diva.tl);
+ }
+}
+
+static int
+Diva_card_msg(struct IsdnCardState *cs, int mt, void *arg)
+{
+ switch (mt) {
+ case CARD_RESET:
+ reset_diva(cs);
+ return(0);
+ case CARD_RELEASE:
+ release_io_diva(cs);
+ return(0);
+ case CARD_SETIRQ:
+ return(request_irq(cs->irq, &diva_interrupt,
+ I4L_IRQ_FLAG, "HiSax", cs));
+ case CARD_INIT:
+ clear_pending_isac_ints(cs);
+ clear_pending_hscx_ints(cs);
+ initisac(cs);
+ inithscx(cs);
+ return(0);
+ case CARD_TEST:
+ return(0);
+ case MDL_REMOVE_REQ:
+ cs->hw.diva.status = 0;
+ break;
+ case MDL_ASSIGN_REQ:
+ cs->hw.diva.status |= DIVA_ASSIGN;
+ break;
+ case MDL_INFO_SETUP:
+ if ((int)arg)
+ cs->hw.diva.status |= 0x0200;
+ else
+ cs->hw.diva.status |= 0x0100;
+ break;
+ case MDL_INFO_CONN:
+ if ((int)arg)
+ cs->hw.diva.status |= 0x2000;
+ else
+ cs->hw.diva.status |= 0x1000;
+ break;
+ case MDL_INFO_REL:
+ if ((int)arg) {
+ cs->hw.diva.status &= ~0x2000;
+ cs->hw.diva.status &= ~0x0200;
+ } else {
+ cs->hw.diva.status &= ~0x1000;
+ cs->hw.diva.status &= ~0x0100;
+ }
+ break;
+ }
+ diva_led_handler(cs);
+ return(0);
+}
+
+
+
+static int pci_index __initdata = 0;
+
+__initfunc(int
+setup_diva(struct IsdnCard *card))
+{
+ int bytecnt;
+ struct IsdnCardState *cs = card->cs;
+ char tmp[64];
+
+ strcpy(tmp, Diva_revision);
+ printk(KERN_INFO "HiSax: Eicon.Diehl Diva driver Rev. %s\n", HiSax_getrev(tmp));
+ if (cs->typ != ISDN_CTYPE_DIEHLDIVA)
+ return(0);
+ cs->hw.diva.status = 0;
+ if (card->para[1]) {
+ cs->subtyp = DIVA_ISA;
+ cs->hw.diva.ctrl_reg = 0;
+ cs->hw.diva.cfg_reg = card->para[1];
+ cs->hw.diva.ctrl = card->para[1] + DIVA_ISA_CTRL;
+ cs->hw.diva.isac = card->para[1] + DIVA_ISA_ISAC_DATA;
+ cs->hw.diva.hscx = card->para[1] + DIVA_HSCX_DATA;
+ cs->hw.diva.isac_adr = card->para[1] + DIVA_ISA_ISAC_ADR;
+ cs->hw.diva.hscx_adr = card->para[1] + DIVA_HSCX_ADR;
+ cs->irq = card->para[0];
+ bytecnt = 8;
+ } else {
+#if CONFIG_PCI
+ u_char pci_bus, pci_device_fn, pci_irq;
+ u_int pci_ioaddr;
+
+ cs->subtyp = 0;
+ for (; pci_index < 0xff; pci_index++) {
+ if (pcibios_find_device(PCI_VENDOR_EICON_DIEHL,
+ PCI_DIVA20_ID, pci_index, &pci_bus, &pci_device_fn)
+ == PCIBIOS_SUCCESSFUL)
+ cs->subtyp = DIVA_PCI;
+ else if (pcibios_find_device(PCI_VENDOR_EICON_DIEHL,
+ PCI_DIVA20_ID, pci_index, &pci_bus, &pci_device_fn)
+ == PCIBIOS_SUCCESSFUL)
+ cs->subtyp = DIVA_PCI;
+ else
+ break;
+ /* get IRQ */
+ pcibios_read_config_byte(pci_bus, pci_device_fn,
+ PCI_INTERRUPT_LINE, &pci_irq);
+
+ /* get IO address */
+ pcibios_read_config_dword(pci_bus, pci_device_fn,
+ PCI_BASE_ADDRESS_2, &pci_ioaddr);
+ if (cs->subtyp)
+ break;
+ }
+ if (!cs->subtyp) {
+ printk(KERN_WARNING "Diva: No PCI card found\n");
+ return(0);
+ }
+ if (!pci_irq) {
+ printk(KERN_WARNING "Diva: No IRQ for PCI card found\n");
+ return(0);
+ }
+
+ if (!pci_ioaddr) {
+ printk(KERN_WARNING "Diva: No IO-Adr for PCI card found\n");
+ return(0);
+ }
+ pci_ioaddr &= ~3; /* remove io/mem flag */
+ cs->hw.diva.cfg_reg = pci_ioaddr;
+ cs->hw.diva.ctrl = pci_ioaddr + DIVA_PCI_CTRL;
+ cs->hw.diva.isac = pci_ioaddr + DIVA_PCI_ISAC_DATA;
+ cs->hw.diva.hscx = pci_ioaddr + DIVA_HSCX_DATA;
+ cs->hw.diva.isac_adr = pci_ioaddr + DIVA_PCI_ISAC_ADR;
+ cs->hw.diva.hscx_adr = pci_ioaddr + DIVA_HSCX_ADR;
+ cs->irq = pci_irq;
+ bytecnt = 32;
+#else
+ printk(KERN_WARNING "Diva: cfgreg 0 and NO_PCI_BIOS\n");
+ printk(KERN_WARNING "Diva: unable to config DIVA PCI\n");
+ return (0);
+#endif /* CONFIG_PCI */
+ }
+
+ printk(KERN_INFO
+ "Diva: %s card configured at 0x%x IRQ %d\n",
+ (cs->subtyp == DIVA_ISA) ? "ISA" : "PCI",
+ cs->hw.diva.cfg_reg, cs->irq);
+ if (check_region(cs->hw.diva.cfg_reg, bytecnt)) {
+ printk(KERN_WARNING
+ "HiSax: %s config port %x-%x already in use\n",
+ CardType[card->typ],
+ cs->hw.diva.cfg_reg,
+ cs->hw.diva.cfg_reg + bytecnt);
+ return (0);
+ } else {
+ request_region(cs->hw.diva.cfg_reg, bytecnt, "diva isdn");
+ }
+
+ reset_diva(cs);
+ cs->hw.diva.tl.function = (void *) diva_led_handler;
+ cs->hw.diva.tl.data = (long) cs;
+ init_timer(&cs->hw.diva.tl);
+ cs->readisac = &ReadISAC;
+ cs->writeisac = &WriteISAC;
+ cs->readisacfifo = &ReadISACfifo;
+ cs->writeisacfifo = &WriteISACfifo;
+ cs->BC_Read_Reg = &ReadHSCX;
+ cs->BC_Write_Reg = &WriteHSCX;
+ cs->BC_Send_Data = &hscx_fill_fifo;
+ cs->cardmsg = &Diva_card_msg;
+
+ ISACVersion(cs, "Diva:");
+ if (HscxVersion(cs, "Diva:")) {
+ printk(KERN_WARNING
+ "Diva: wrong HSCX versions check IO address\n");
+ release_io_diva(cs);
+ return (0);
+ }
+ return (1);
+}
diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
index 5cea59d9d..6a9966431 100644
--- a/drivers/isdn/hisax/elsa.c
+++ b/drivers/isdn/hisax/elsa.c
@@ -1,4 +1,4 @@
-/* $Id: elsa.c,v 1.14 1997/04/13 19:53:25 keil Exp $
+/* $Id: elsa.c,v 2.6 1998/02/02 13:29:40 keil Exp $
* elsa.c low level stuff for Elsa isdn cards
*
@@ -8,1241 +8,726 @@
*
*
* $Log: elsa.c,v $
- * Revision 1.14 1997/04/13 19:53:25 keil
- * Fixed QS1000 init, change in IRQ check delay for SMP
+ * Revision 2.6 1998/02/02 13:29:40 keil
+ * fast io
*
- * Revision 1.13 1997/04/07 22:58:07 keil
- * need include config.h
- *
- * Revision 1.12 1997/04/06 22:54:14 keil
- * Using SKB's
+ * Revision 2.5 1998/01/31 21:41:45 keil
+ * changes for newer 2.1 kernels
*
- * Revision 1.11 1997/03/23 21:45:46 keil
- * Add support for ELSA PCMCIA
+ * Revision 2.4 1997/11/08 21:35:46 keil
+ * new l1 init
*
- * Revision 1.10 1997/03/12 21:42:19 keil
- * Bugfix: IRQ hangs with QS1000
+ * Revision 2.3 1997/11/06 17:15:09 keil
+ * New 2.1 init; PCMCIA wrapper changes
*
- * Revision 1.9 1997/03/04 15:57:39 keil
- * bugfix IRQ reset Quickstep, ELSA PC changes, some stuff for new cards
+ * Revision 2.2 1997/10/29 18:57:09 keil
+ * changes for 2.1.60, arcofi support
*
- * Revision 1.8 1997/01/27 15:51:48 keil
- * SMP proof,cosmetics
+ * Revision 2.1 1997/07/27 21:47:08 keil
+ * new interface structures
*
- * Revision 1.7 1997/01/21 22:20:48 keil
- * Elsa Quickstep support
+ * Revision 2.0 1997/06/26 11:02:40 keil
+ * New Layer and card interface
*
- * Revision 1.6 1997/01/09 18:22:46 keil
- * one more PCC-8 fix
- *
- * Revision 1.5 1996/12/08 19:46:14 keil
- * PCC-8 correct IRQs; starting ARCOFI support
- *
- * Revision 1.4 1996/11/18 20:50:54 keil
- * with PCF Pro release 16 Byte IO
- *
- * Revision 1.3 1996/11/18 15:33:04 keil
- * PCC and PCFPro support
+ * Revision 1.14 1997/04/13 19:53:25 keil
+ * Fixed QS1000 init, change in IRQ check delay for SMP
*
- * Revision 1.2 1996/10/27 22:08:03 keil
- * cosmetic changes
+ * Revision 1.13 1997/04/07 22:58:07 keil
+ * need include config.h
*
- * Revision 1.1 1996/10/13 20:04:52 keil
- * Initial revision
+ * Revision 1.12 1997/04/06 22:54:14 keil
+ * Using SKB's
*
+ * old changes removed KKe
*
*/
-#define ARCOFI_USE 0
-
#define __NO_VERSION__
#include <linux/config.h>
-#include "siemens.h"
#include "hisax.h"
-#include "elsa.h"
+#include "arcofi.h"
+#include "isac.h"
+#include "ipac.h"
+#include "hscx.h"
#include "isdnl1.h"
-#include <linux/kernel_stat.h>
+#include <linux/pci.h>
+#include <linux/bios32.h>
extern const char *CardType[];
-const char *Elsa_revision = "$Revision: 1.14 $";
+const char *Elsa_revision = "$Revision: 2.6 $";
const char *Elsa_Types[] =
{"None", "PC", "PCC-8", "PCC-16", "PCF", "PCF-Pro",
- "PCMCIA", "QS 1000", "QS 3000"};
+ "PCMCIA", "QS 1000", "QS 3000", "QS 1000 PCI"};
const char *ITACVer[] =
{"?0?", "?1?", "?2?", "?3?", "?4?", "V2.2",
"B1", "A1"};
-#define byteout(addr,val) outb_p(val,addr)
-#define bytein(addr) inb_p(addr)
+#define byteout(addr,val) outb(val,addr)
+#define bytein(addr) inb(addr)
+
+#define ELSA_ISAC 0
+#define ELSA_ISAC_PCM 1
+#define ELSA_ITAC 1
+#define ELSA_HSCX 2
+#define ELSA_ALE 3
+#define ELSA_ALE_PCM 4
+#define ELSA_CONTROL 4
+#define ELSA_CONFIG 5
+#define ELSA_START_TIMER 6
+#define ELSA_TRIG_IRQ 7
+
+#define ELSA_PC 1
+#define ELSA_PCC8 2
+#define ELSA_PCC16 3
+#define ELSA_PCF 4
+#define ELSA_PCFPRO 5
+#define ELSA_PCMCIA 6
+#define ELSA_QS1000 7
+#define ELSA_QS3000 8
+#define ELSA_QS1000PCI 9
+
+/* PCI stuff */
+#define PCI_VENDOR_ELSA 0x1048
+#define PCI_QS1000_ID 0x1000
+
+
+/* ITAC Registeradressen (only Microlink PC) */
+#define ITAC_SYS 0x34
+#define ITAC_ISEN 0x48
+#define ITAC_RFIE 0x4A
+#define ITAC_XFIE 0x4C
+#define ITAC_SCIE 0x4E
+#define ITAC_STIE 0x46
+
+/*** ***
+ *** Makros als Befehle fuer die Kartenregister ***
+ *** (mehrere Befehle werden durch Bit-Oderung kombiniert) ***
+ *** ***/
+
+/* Config-Register (Read) */
+#define ELSA_TIMER_RUN 0x02 /* Bit 1 des Config-Reg */
+#define ELSA_TIMER_RUN_PCC8 0x01 /* Bit 0 des Config-Reg bei PCC */
+#define ELSA_IRQ_IDX 0x38 /* Bit 3,4,5 des Config-Reg */
+#define ELSA_IRQ_IDX_PCC8 0x30 /* Bit 4,5 des Config-Reg */
+#define ELSA_IRQ_IDX_PC 0x0c /* Bit 2,3 des Config-Reg */
+
+/* Control-Register (Write) */
+#define ELSA_LINE_LED 0x02 /* Bit 1 Gelbe LED */
+#define ELSA_STAT_LED 0x08 /* Bit 3 Gruene LED */
+#define ELSA_ISDN_RESET 0x20 /* Bit 5 Reset-Leitung */
+#define ELSA_ENA_TIMER_INT 0x80 /* Bit 7 Freigabe Timer Interrupt */
+
+/* ALE-Register (Read) */
+#define ELSA_HW_RELEASE 0x07 /* Bit 0-2 Hardwarerkennung */
+#define ELSA_S0_POWER_BAD 0x08 /* Bit 3 S0-Bus Spannung fehlt */
+
+/* Status Flags */
+#define ELSA_TIMER_AKTIV 1
+#define ELSA_BAD_PWR 2
+#define ELSA_ASSIGN 4
static inline u_char
-readhscx(unsigned int adr, int hscx, u_char off)
+readreg(unsigned int ale, unsigned int adr, u_char off)
{
register u_char ret;
long flags;
save_flags(flags);
cli();
- byteout(adr + CARD_ALE, off + (hscx ? 0x60 : 0x20));
- ret = bytein(adr + CARD_HSCX);
+ byteout(ale, off);
+ ret = bytein(adr);
restore_flags(flags);
return (ret);
}
static inline void
-read_fifo_hscx(unsigned int adr, int hscx, u_char * data, int size)
+readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
{
/* fifo read without cli because it's allready done */
- byteout(adr + CARD_ALE, (hscx ? 0x40 : 0));
- insb(adr + CARD_HSCX, data, size);
+ byteout(ale, off);
+ insb(adr, data, size);
}
static inline void
-writehscx(unsigned int adr, int hscx, u_char off, u_char data)
+writereg(unsigned int ale, unsigned int adr, u_char off, u_char data)
{
long flags;
save_flags(flags);
cli();
- byteout(adr + CARD_ALE, off + (hscx ? 0x60 : 0x20));
- byteout(adr + CARD_HSCX, data);
+ byteout(ale, off);
+ byteout(adr, data);
restore_flags(flags);
}
static inline void
-write_fifo_hscx(unsigned int adr, int hscx, u_char * data, int size)
+writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
{
/* fifo write without cli because it's allready done */
- byteout(adr + CARD_ALE, (hscx ? 0x40 : 0));
- outsb(adr + CARD_HSCX, data, size);
-}
-
-static inline u_char
-readisac(unsigned int adr, u_char off)
-{
- register u_char ret;
- long flags;
-
- save_flags(flags);
- cli();
- byteout(adr + CARD_ALE, off + 0x20);
- ret = bytein(adr + CARD_ISAC);
- restore_flags(flags);
- return (ret);
+ byteout(ale, off);
+ outsb(adr, data, size);
}
-static inline void
-read_fifo_isac(unsigned int adr, u_char * data, int size)
-{
- /* fifo read without cli because it's allready done */
-
- byteout(adr + CARD_ALE, 0);
- insb(adr + CARD_ISAC, data, size);
-}
-
-
-static inline void
-writeisac(unsigned int adr, u_char off, u_char data)
-{
- long flags;
+/* Interface functions */
- save_flags(flags);
- cli();
- byteout(adr + CARD_ALE, off + 0x20);
- byteout(adr + CARD_ISAC, data);
- restore_flags(flags);
-}
-
-static inline void
-write_fifo_isac(unsigned int adr, u_char * data, int size)
-{
- /* fifo write without cli because it's allready done */
-
- byteout(adr + CARD_ALE, 0);
- outsb(adr + CARD_ISAC, data, size);
-}
-
-#ifdef CONFIG_HISAX_ELSA_PCC
-static inline u_char
-readitac(unsigned int adr, u_char off)
+static u_char
+ReadISAC(struct IsdnCardState *cs, u_char offset)
{
- register u_char ret;
- long flags;
-
- save_flags(flags);
- cli();
- byteout(adr + CARD_ALE, off);
- ret = bytein(adr + CARD_ITAC);
- restore_flags(flags);
- return (ret);
+ return (readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset));
}
-static inline void
-writeitac(unsigned int adr, u_char off, u_char data)
+static void
+WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
{
- long flags;
-
- save_flags(flags);
- cli();
- byteout(adr + CARD_ALE, off);
- byteout(adr + CARD_ITAC, data);
- restore_flags(flags);
+ writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset, value);
}
-static inline int
-TimerRun(struct IsdnCardState *sp)
+static void
+ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
{
- register u_char val;
-
- val = bytein(sp->cfg_reg + CARD_CONFIG);
- if (sp->subtyp == ELSA_QS1000)
- return (0 == (val & TIMER_RUN));
- else if (sp->subtyp == ELSA_PCC8)
- return (val & TIMER_RUN_PCC8);
- return (val & TIMER_RUN);
+ readfifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0, data, size);
}
-static inline void
-elsa_led_handler(struct IsdnCardState *sp)
+static void
+WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
{
-
- u_char outval = 0xf0;
- int stat = 0, cval;
-
-
- if ((sp->ph_state == 0) || (sp->ph_state == 15)) {
- stat = 1;
- } else {
- if (sp->hs[0].mode != 0)
- stat |= 2;
- if (sp->hs[1].mode != 0)
- stat |= 4;
- }
- cval = (sp->counter >> 6) & 3;
- switch (cval) {
- case 0:
- if (!stat)
- outval |= STAT_LED;
- else if (stat == 1)
- outval |= LINE_LED | STAT_LED;
- else {
- if (stat & 2)
- outval |= STAT_LED;
- if (stat & 4)
- outval |= LINE_LED;
- }
- break;
- case 1:
- if (!stat)
- outval |= LINE_LED;
- else if (stat == 1)
- outval |= LINE_LED | STAT_LED;
- else {
- if (stat & 2)
- outval |= STAT_LED;
- if (stat & 4)
- outval |= LINE_LED;
- }
- break;
- case 2:
- if (!stat)
- outval |= STAT_LED;
- else if (stat == 1)
- outval |= 0;
- else {
- if (stat & 2)
- outval |= STAT_LED;
- if (stat & 4)
- outval |= LINE_LED;
- }
- break;
- case 3:
- if (!stat)
- outval |= LINE_LED;
- break;
- }
- byteout(sp->cfg_reg + CARD_CONTROL, outval);
+ writefifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0, data, size);
}
-#endif
-static inline void
-waitforCEC(int adr, int hscx)
+static u_char
+ReadISAC_IPAC(struct IsdnCardState *cs, u_char offset)
{
- int to = 50;
-
- while ((readhscx(adr, hscx, HSCX_STAR) & 0x04) && to) {
- udelay(1);
- to--;
- }
- if (!to)
- printk(KERN_WARNING "Elsa: waitforCEC timeout\n");
+ return (readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset+0x80));
}
-
-static inline void
-waitforXFW(int adr, int hscx)
+static void
+WriteISAC_IPAC(struct IsdnCardState *cs, u_char offset, u_char value)
{
- int to = 50;
-
- while ((!(readhscx(adr, hscx, HSCX_STAR) & 0x44) == 0x40) && to) {
- udelay(1);
- to--;
- }
- if (!to)
- printk(KERN_WARNING "Elsa: waitforXFW timeout\n");
+ writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset|0x80, value);
}
-static inline void
-writehscxCMDR(int adr, int hscx, u_char data)
+static void
+ReadISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size)
{
- long flags;
-
- save_flags(flags);
- cli();
- waitforCEC(adr, hscx);
- writehscx(adr, hscx, HSCX_CMDR, data);
- restore_flags(flags);
+ readfifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0x80, data, size);
}
-/*
- * fast interrupt here
- */
-
-
static void
-hscxreport(struct IsdnCardState *sp, int hscx)
+WriteISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size)
{
- printk(KERN_DEBUG "HSCX %d\n", hscx);
- printk(KERN_DEBUG "ISTA %x\n", readhscx(sp->cfg_reg, hscx, HSCX_ISTA));
- printk(KERN_DEBUG "STAR %x\n", readhscx(sp->cfg_reg, hscx, HSCX_STAR));
- printk(KERN_DEBUG "EXIR %x\n", readhscx(sp->cfg_reg, hscx, HSCX_EXIR));
+ writefifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0x80, data, size);
}
-void
-elsa_report(struct IsdnCardState *sp)
+static u_char
+ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
{
- printk(KERN_DEBUG "ISAC\n");
- printk(KERN_DEBUG "ISTA %x\n", readisac(sp->cfg_reg, ISAC_ISTA));
- printk(KERN_DEBUG "STAR %x\n", readisac(sp->cfg_reg, ISAC_STAR));
- printk(KERN_DEBUG "EXIR %x\n", readisac(sp->cfg_reg, ISAC_EXIR));
- hscxreport(sp, 0);
- hscxreport(sp, 1);
+ return (readreg(cs->hw.elsa.ale,
+ cs->hw.elsa.hscx, offset + (hscx ? 0x40 : 0)));
}
-/*
- * HSCX stuff goes here
- */
-
static void
-hscx_empty_fifo(struct HscxState *hsp, int count)
+WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
{
- u_char *ptr;
- struct IsdnCardState *sp = hsp->sp;
- long flags;
-
- if ((sp->debug & L1_DEB_HSCX) && !(sp->debug & L1_DEB_HSCX_FIFO))
- debugl1(sp, "hscx_empty_fifo");
-
- if (hsp->rcvidx + count > HSCX_BUFMAX) {
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "hscx_empty_fifo: incoming packet too large");
- writehscxCMDR(sp->cfg_reg, hsp->hscx, 0x80);
- hsp->rcvidx = 0;
- return;
- }
- ptr = hsp->rcvbuf + hsp->rcvidx;
- hsp->rcvidx += count;
- save_flags(flags);
- cli();
- read_fifo_hscx(sp->cfg_reg, hsp->hscx, ptr, count);
- writehscxCMDR(sp->cfg_reg, hsp->hscx, 0x80);
- restore_flags(flags);
- if (sp->debug & L1_DEB_HSCX_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "hscx_empty_fifo %c cnt %d",
- hsp->hscx ? 'B' : 'A', count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ writereg(cs->hw.elsa.ale,
+ cs->hw.elsa.hscx, offset + (hscx ? 0x40 : 0), value);
}
-static void
-hscx_fill_fifo(struct HscxState *hsp)
+static inline u_char
+readitac(struct IsdnCardState *cs, u_char off)
{
- struct IsdnCardState *sp = hsp->sp;
- int more, count;
- u_char *ptr;
+ register u_char ret;
long flags;
-
- if ((sp->debug & L1_DEB_HSCX) && !(sp->debug & L1_DEB_HSCX_FIFO))
- debugl1(sp, "hscx_fill_fifo");
-
- if (!hsp->tx_skb)
- return;
- if (hsp->tx_skb->len <= 0)
- return;
-
- more = (hsp->mode == 1) ? 1 : 0;
- if (hsp->tx_skb->len > 32) {
- more = !0;
- count = 32;
- } else
- count = hsp->tx_skb->len;
-
- waitforXFW(sp->cfg_reg, hsp->hscx);
save_flags(flags);
cli();
- ptr = hsp->tx_skb->data;
- skb_pull(hsp->tx_skb, count);
- hsp->tx_cnt -= count;
- hsp->count += count;
- write_fifo_hscx(sp->cfg_reg, hsp->hscx, ptr, count);
- writehscxCMDR(sp->cfg_reg, hsp->hscx, more ? 0x8 : 0xa);
+ byteout(cs->hw.elsa.ale, off);
+ ret = bytein(cs->hw.elsa.itac);
restore_flags(flags);
- if (sp->debug & L1_DEB_HSCX_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "hscx_fill_fifo %c cnt %d",
- hsp->hscx ? 'B' : 'A', count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ return (ret);
}
static inline void
-hscx_interrupt(struct IsdnCardState *sp, u_char val, u_char hscx)
-{
- u_char r;
- struct HscxState *hsp = sp->hs + hscx;
- struct sk_buff *skb;
- int count;
- char tmp[32];
-
- if (!hsp->init)
- return;
-
- if (val & 0x80) { /* RME */
-
- r = readhscx(sp->cfg_reg, hsp->hscx, HSCX_RSTA);
- if ((r & 0xf0) != 0xa0) {
- if (!r & 0x80)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "HSCX invalid frame");
- if ((r & 0x40) && hsp->mode)
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX RDO mode=%d",
- hsp->mode);
- debugl1(sp, tmp);
- }
- if (!r & 0x20)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "HSCX CRC error");
- writehscxCMDR(sp->cfg_reg, hsp->hscx, 0x80);
- } else {
- count = readhscx(sp->cfg_reg, hsp->hscx, HSCX_RBCL) & 0x1f;
- if (count == 0)
- count = 32;
- hscx_empty_fifo(hsp, count);
- if ((count = hsp->rcvidx - 1) > 0) {
- if (sp->debug & L1_DEB_HSCX_FIFO) {
- sprintf(tmp, "HX Frame %d", count);
- debugl1(sp, tmp);
- }
- if (!(skb = dev_alloc_skb(count)))
- printk(KERN_WARNING "Elsa: receive out of memory\n");
- else {
- memcpy(skb_put(skb, count), hsp->rcvbuf, count);
- skb_queue_tail(&hsp->rqueue, skb);
- }
- }
- }
- hsp->rcvidx = 0;
- hscx_sched_event(hsp, HSCX_RCVBUFREADY);
- }
- if (val & 0x40) { /* RPF */
- hscx_empty_fifo(hsp, 32);
- if (hsp->mode == 1) {
- /* receive audio data */
- if (!(skb = dev_alloc_skb(32)))
- printk(KERN_WARNING "elsa: receive out of memory\n");
- else {
- memcpy(skb_put(skb, 32), hsp->rcvbuf, 32);
- skb_queue_tail(&hsp->rqueue, skb);
- }
- hsp->rcvidx = 0;
- hscx_sched_event(hsp, HSCX_RCVBUFREADY);
- }
- }
- if (val & 0x10) { /* XPR */
- if (hsp->tx_skb)
- if (hsp->tx_skb->len) {
- hscx_fill_fifo(hsp);
- return;
- } else {
- SET_SKB_FREE(hsp->tx_skb);
- dev_kfree_skb(hsp->tx_skb);
- hsp->count = 0;
- if (hsp->st->l4.l1writewakeup)
- hsp->st->l4.l1writewakeup(hsp->st);
- hsp->tx_skb = NULL;
- }
- if ((hsp->tx_skb = skb_dequeue(&hsp->squeue))) {
- hsp->count = 0;
- hscx_fill_fifo(hsp);
- } else
- hscx_sched_event(hsp, HSCX_XMTBUFREADY);
- }
-}
-
-/*
- * ISAC stuff goes here
- */
-
-static void
-isac_empty_fifo(struct IsdnCardState *sp, int count)
+writeitac(struct IsdnCardState *cs, u_char off, u_char data)
{
- u_char *ptr;
long flags;
- if ((sp->debug & L1_DEB_ISAC) && !(sp->debug & L1_DEB_ISAC_FIFO))
- debugl1(sp, "isac_empty_fifo");
-
- if ((sp->rcvidx + count) >= MAX_DFRAME_LEN) {
- if (sp->debug & L1_DEB_WARN) {
- char tmp[40];
- sprintf(tmp, "isac_empty_fifo overrun %d",
- sp->rcvidx + count);
- debugl1(sp, tmp);
- }
- writeisac(sp->cfg_reg, ISAC_CMDR, 0x80);
- sp->rcvidx = 0;
- return;
- }
- ptr = sp->rcvbuf + sp->rcvidx;
- sp->rcvidx += count;
save_flags(flags);
cli();
- read_fifo_isac(sp->cfg_reg, ptr, count);
- writeisac(sp->cfg_reg, ISAC_CMDR, 0x80);
+ byteout(cs->hw.elsa.ale, off);
+ byteout(cs->hw.elsa.itac, data);
restore_flags(flags);
- if (sp->debug & L1_DEB_ISAC_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "isac_empty_fifo cnt %d", count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
}
-static void
-isac_fill_fifo(struct IsdnCardState *sp)
+static inline int
+TimerRun(struct IsdnCardState *cs)
{
- int count, more;
- u_char *ptr;
- long flags;
-
- if ((sp->debug & L1_DEB_ISAC) && !(sp->debug & L1_DEB_ISAC_FIFO))
- debugl1(sp, "isac_fill_fifo");
-
- if (!sp->tx_skb)
- return;
-
- count = sp->tx_skb->len;
- if (count <= 0)
- return;
-
- more = 0;
- if (count > 32) {
- more = !0;
- count = 32;
- }
- save_flags(flags);
- cli();
- ptr = sp->tx_skb->data;
- skb_pull(sp->tx_skb, count);
- sp->tx_cnt += count;
- write_fifo_isac(sp->cfg_reg, ptr, count);
- writeisac(sp->cfg_reg, ISAC_CMDR, more ? 0x8 : 0xa);
- restore_flags(flags);
- if (sp->debug & L1_DEB_ISAC_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "isac_fill_fifo cnt %d", count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
-}
-
-static void
-ph_command(struct IsdnCardState *sp, unsigned int command)
-{
- if (sp->debug & L1_DEB_ISAC) {
- char tmp[32];
- sprintf(tmp, "ph_command %d", command);
- debugl1(sp, tmp);
- }
- writeisac(sp->cfg_reg, ISAC_CIX0, (command << 2) | 3);
+ register u_char v;
+
+ v = bytein(cs->hw.elsa.cfg);
+ if ((cs->subtyp == ELSA_QS1000) || (cs->subtyp == ELSA_QS3000))
+ return (0 == (v & ELSA_TIMER_RUN));
+ else if (cs->subtyp == ELSA_PCC8)
+ return (v & ELSA_TIMER_RUN_PCC8);
+ return (v & ELSA_TIMER_RUN);
}
+/*
+ * fast interrupt HSCX stuff goes here
+ */
-static inline void
-isac_interrupt(struct IsdnCardState *sp, u_char val)
-{
- u_char exval, v1;
- struct sk_buff *skb;
- unsigned int count;
- char tmp[32];
-#if ARCOFI_USE
- struct BufHeader *ibh;
- u_char *ptr;
-#endif
+#define READHSCX(cs, nr, reg) readreg(cs->hw.elsa.ale, \
+ cs->hw.elsa.hscx, reg + (nr ? 0x40 : 0))
+#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.elsa.ale, \
+ cs->hw.elsa.hscx, reg + (nr ? 0x40 : 0), data)
- if (sp->debug & L1_DEB_ISAC) {
- sprintf(tmp, "ISAC interrupt %x", val);
- debugl1(sp, tmp);
- }
- if (val & 0x80) { /* RME */
- exval = readisac(sp->cfg_reg, ISAC_RSTA);
- if ((exval & 0x70) != 0x20) {
- if (exval & 0x40)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC RDO");
- if (!exval & 0x20)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC CRC error");
- writeisac(sp->cfg_reg, ISAC_CMDR, 0x80);
- } else {
- count = readisac(sp->cfg_reg, ISAC_RBCL) & 0x1f;
- if (count == 0)
- count = 32;
- isac_empty_fifo(sp, count);
- if ((count = sp->rcvidx) > 0) {
- sp->rcvidx = 0;
- if (!(skb = alloc_skb(count, GFP_ATOMIC)))
- printk(KERN_WARNING "Elsa: D receive out of memory\n");
- else {
- memcpy(skb_put(skb, count), sp->rcvbuf, count);
- skb_queue_tail(&sp->rq, skb);
- }
- }
- }
- sp->rcvidx = 0;
- isac_sched_event(sp, ISAC_RCVBUFREADY);
- }
- if (val & 0x40) { /* RPF */
- isac_empty_fifo(sp, 32);
- }
- if (val & 0x20) { /* RSC */
- /* never */
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC RSC interrupt");
- }
- if (val & 0x10) { /* XPR */
- if (sp->tx_skb)
- if (sp->tx_skb->len) {
- isac_fill_fifo(sp);
- goto afterXPR;
- } else {
- SET_SKB_FREE(sp->tx_skb);
- dev_kfree_skb(sp->tx_skb);
- sp->tx_cnt = 0;
- sp->tx_skb = NULL;
- }
- if ((sp->tx_skb = skb_dequeue(&sp->sq))) {
- sp->tx_cnt = 0;
- isac_fill_fifo(sp);
- } else
- isac_sched_event(sp, ISAC_XMTBUFREADY);
- }
- afterXPR:
- if (val & 0x04) { /* CISQ */
- sp->ph_state = (readisac(sp->cfg_reg, ISAC_CIX0) >> 2)
- & 0xf;
- if (sp->debug & L1_DEB_ISAC) {
- sprintf(tmp, "l1state %d", sp->ph_state);
- debugl1(sp, tmp);
- }
- isac_new_ph(sp);
- }
- if (val & 0x02) { /* SIN */
- /* never */
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC SIN interrupt");
- }
- if (val & 0x01) { /* EXI */
- exval = readisac(sp->cfg_reg, ISAC_EXIR);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "ISAC EXIR %02x", exval);
- debugl1(sp, tmp);
- }
- if (exval & 0x08) {
- v1 = readisac(sp->cfg_reg, ISAC_MOSR);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "ISAC MOSR %02x", v1);
- debugl1(sp, tmp);
- }
-#if ARCOFI_USE
- if (v1 & 0x08) {
- if (!sp->mon_rx)
- if (BufPoolGet(&(sp->mon_rx), &(sp->rbufpool),
- GFP_ATOMIC, (void *) 1, 3)) {
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC MON RX out of buffers!");
- writeisac(sp->cfg_reg, ISAC_MOCR, 0x0a);
- goto afterMONR0;
- } else
- sp->mon_rxp = 0;
- ibh = sp->mon_rx;
- ptr = DATAPTR(ibh);
- ptr += sp->mon_rxp;
- sp->mon_rxp++;
- if (sp->mon_rxp >= 3072) {
- writeisac(sp->cfg_reg, ISAC_MOCR, 0x0a);
- sp->mon_rxp = 0;
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC MON RX overflow!");
- goto afterMONR0;
- }
- *ptr = readisac(sp->cfg_reg, ISAC_MOR0);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "ISAC MOR0 %02x", *ptr);
- debugl1(sp, tmp);
- }
- }
- afterMONR0:
- if (v1 & 0x80) {
- if (!sp->mon_rx)
- if (BufPoolGet(&(sp->mon_rx), &(sp->rbufpool),
- GFP_ATOMIC, (void *) 1, 3)) {
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC MON RX out of buffers!");
- writeisac(sp->cfg_reg, ISAC_MOCR, 0xa0);
- goto afterMONR1;
- } else
- sp->mon_rxp = 0;
- ibh = sp->mon_rx;
- ptr = DATAPTR(ibh);
- ptr += sp->mon_rxp;
- sp->mon_rxp++;
- if (sp->mon_rxp >= 3072) {
- writeisac(sp->cfg_reg, ISAC_MOCR, 0xa0);
- sp->mon_rxp = 0;
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC MON RX overflow!");
- goto afterMONR1;
- }
- *ptr = readisac(sp->cfg_reg, ISAC_MOR1);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "ISAC MOR1 %02x", *ptr);
- debugl1(sp, tmp);
- }
- }
- afterMONR1:
- if (v1 & 0x04) {
- writeisac(sp->cfg_reg, ISAC_MOCR, 0x0a);
- sp->mon_rx->datasize = sp->mon_rxp;
- sp->mon_flg |= MON0_RX;
- }
- if (v1 & 0x40) {
- writeisac(sp->cfg_reg, ISAC_MOCR, 0xa0);
- sp->mon_rx->datasize = sp->mon_rxp;
- sp->mon_flg |= MON1_RX;
- }
- if (v1 == 0x02) {
- ibh = sp->mon_tx;
- if (!ibh) {
- writeisac(sp->cfg_reg, ISAC_MOCR, 0x0a);
- goto AfterMOX0;
- }
- count = ibh->datasize - sp->mon_txp;
- if (count <= 0) {
- writeisac(sp->cfg_reg, ISAC_MOCR, 0x0f);
- BufPoolRelease(sp->mon_tx);
- sp->mon_tx = NULL;
- sp->mon_txp = 0;
- sp->mon_flg |= MON0_TX;
- goto AfterMOX0;
- }
- ptr = DATAPTR(ibh);
- ptr += sp->mon_txp;
- sp->mon_txp++;
- writeisac(sp->cfg_reg, ISAC_MOX0, *ptr);
- }
- AfterMOX0:
- if (v1 == 0x20) {
- ibh = sp->mon_tx;
- if (!ibh) {
- writeisac(sp->cfg_reg, ISAC_MOCR, 0xa0);
- goto AfterMOX1;
- }
- count = ibh->datasize - sp->mon_txp;
- if (count <= 0) {
- writeisac(sp->cfg_reg, ISAC_MOCR, 0xf0);
- BufPoolRelease(sp->mon_tx);
- sp->mon_tx = NULL;
- sp->mon_txp = 0;
- sp->mon_flg |= MON1_TX;
- goto AfterMOX1;
- }
- ptr = DATAPTR(ibh);
- ptr += sp->mon_txp;
- sp->mon_txp++;
- writeisac(sp->cfg_reg, ISAC_MOX1, *ptr);
- }
- AfterMOX1:
-#endif
- }
- }
-}
+#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.elsa.ale, \
+ cs->hw.elsa.hscx, (nr ? 0x40 : 0), ptr, cnt)
-static inline void
-hscx_int_main(struct IsdnCardState *sp, u_char val)
-{
+#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.elsa.ale, \
+ cs->hw.elsa.hscx, (nr ? 0x40 : 0), ptr, cnt)
- u_char exval;
- struct HscxState *hsp;
- char tmp[32];
-
- if (val & 0x01) {
- hsp = sp->hs + 1;
- exval = readhscx(sp->cfg_reg, 1, HSCX_EXIR);
- if (exval == 0x40) {
- if (hsp->mode == 1)
- hscx_fill_fifo(hsp);
- else {
- /* Here we lost an TX interrupt, so
- * restart transmitting the whole frame.
- */
- if (hsp->tx_skb) {
- skb_push(hsp->tx_skb, hsp->count);
- hsp->tx_cnt += hsp->count;
- hsp->count = 0;
- }
- writehscxCMDR(sp->cfg_reg, hsp->hscx, 0x01);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX B EXIR %x Lost TX", exval);
- debugl1(sp, tmp);
- }
- }
- } else if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX B EXIR %x", exval);
- debugl1(sp, tmp);
- }
- }
- if (val & 0xf8) {
- if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX B interrupt %x", val);
- debugl1(sp, tmp);
- }
- hscx_interrupt(sp, val, 1);
- }
- if (val & 0x02) {
- hsp = sp->hs;
- exval = readhscx(sp->cfg_reg, 0, HSCX_EXIR);
- if (exval == 0x40) {
- if (hsp->mode == 1)
- hscx_fill_fifo(hsp);
- else {
- /* Here we lost an TX interrupt, so
- * restart transmitting the whole frame.
- */
- if (hsp->tx_skb) {
- skb_push(hsp->tx_skb, hsp->count);
- hsp->tx_cnt += hsp->count;
- hsp->count = 0;
- }
- writehscxCMDR(sp->cfg_reg, hsp->hscx, 0x01);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX A EXIR %x Lost TX", exval);
- debugl1(sp, tmp);
- }
- }
- } else if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX A EXIR %x", exval);
- debugl1(sp, tmp);
- }
- }
- if (val & 0x04) {
- exval = readhscx(sp->cfg_reg, 0, HSCX_ISTA);
- if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX A interrupt %x", exval);
- debugl1(sp, tmp);
- }
- hscx_interrupt(sp, exval, 0);
- }
-}
+#include "hscx_irq.c"
static void
elsa_interrupt(int intno, void *dev_id, struct pt_regs *regs)
{
- struct IsdnCardState *sp;
+ struct IsdnCardState *cs = dev_id;
u_char val;
+ int icnt=20;
- sp = (struct IsdnCardState *) dev_id;
-
- if (!sp) {
+ if (!cs) {
printk(KERN_WARNING "Elsa: Spurious interrupt!\n");
return;
}
-#ifdef CONFIG_HISAX_ELSA_PCC
- INT_RESTART:
- if (!TimerRun(sp)) {
- /* Timer Restart */
- byteout(sp->cfg_reg + CARD_START_TIMER, 0);
- if (!(sp->counter++ & 0x3f)) {
- /* Call LEDs all 64 tics */
- elsa_led_handler(sp);
- }
- }
-#endif
- val = readhscx(sp->cfg_reg, 1, HSCX_ISTA);
+ val = readreg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_ISTA + 0x40);
Start_HSCX:
if (val) {
- hscx_int_main(sp, val);
+ hscx_int_main(cs, val);
}
- val = readisac(sp->cfg_reg, ISAC_ISTA);
+ val = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_ISTA);
Start_ISAC:
if (val) {
- isac_interrupt(sp, val);
+ isac_interrupt(cs, val);
}
-#ifdef CONFIG_HISAX_ELSA_PCC
- if (!TimerRun(sp))
- goto INT_RESTART;
-#endif
- val = readhscx(sp->cfg_reg, 1, HSCX_ISTA);
- if (val) {
- if (sp->debug & L1_DEB_HSCX)
- debugl1(sp, "HSCX IntStat after IntRoutine");
+ val = readreg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_ISTA + 0x40);
+ if (val && icnt) {
+ if (cs->debug & L1_DEB_HSCX)
+ debugl1(cs, "HSCX IntStat after IntRoutine");
+ icnt--;
goto Start_HSCX;
}
- val = readisac(sp->cfg_reg, ISAC_ISTA);
- if (val) {
- if (sp->debug & L1_DEB_ISAC)
- debugl1(sp, "ISAC IntStat after IntRoutine");
+ val = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_ISTA);
+ if (val && icnt) {
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ISAC IntStat after IntRoutine");
+ icnt--;
goto Start_ISAC;
}
- writehscx(sp->cfg_reg, 0, HSCX_MASK, 0xFF);
- writehscx(sp->cfg_reg, 1, HSCX_MASK, 0xFF);
- writeisac(sp->cfg_reg, ISAC_MASK, 0xFF);
-#ifdef CONFIG_HISAX_ELSA_PCC
- if (sp->subtyp == ELSA_QS1000) {
- byteout(sp->cfg_reg + CARD_START_TIMER, 0);
- byteout(sp->cfg_reg + CARD_TRIG_IRQ, 0xff);
+ if (!icnt)
+ printk(KERN_WARNING"ELSA IRQ LOOP\n");
+ writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK, 0xFF);
+ writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK + 0x40, 0xFF);
+ writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_MASK, 0xFF);
+ if (cs->hw.elsa.status & ELSA_TIMER_AKTIV) {
+ if (!TimerRun(cs)) {
+ /* Timer Restart */
+ byteout(cs->hw.elsa.timer, 0);
+ cs->hw.elsa.counter++;
+ }
}
-#endif
- writehscx(sp->cfg_reg, 0, HSCX_MASK, 0x0);
- writehscx(sp->cfg_reg, 1, HSCX_MASK, 0x0);
- writeisac(sp->cfg_reg, ISAC_MASK, 0x0);
+ if (cs->hw.elsa.trig)
+ byteout(cs->hw.elsa.trig, 0x00);
+ writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK, 0x0);
+ writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK + 0x40, 0x0);
+ writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_MASK, 0x0);
}
-
static void
-initisac(struct IsdnCardState *sp)
+elsa_interrupt_ipac(int intno, void *dev_id, struct pt_regs *regs)
{
- unsigned int adr = sp->cfg_reg;
-
- /* Elsa IOM 2 Mode */
- writeisac(adr, ISAC_MASK, 0xff);
- writeisac(adr, ISAC_ADF2, 0x80);
- writeisac(adr, ISAC_SQXR, 0x2f);
- writeisac(adr, ISAC_SPCR, 0x00);
- writeisac(adr, ISAC_STCR, 0x70);
- writeisac(adr, ISAC_MODE, 0xc9);
- writeisac(adr, ISAC_TIMR, 0x00);
- writeisac(adr, ISAC_ADF1, 0x00);
- writeisac(adr, ISAC_CIX0, (1 << 2) | 3);
- writeisac(adr, ISAC_MASK, 0xff);
- writeisac(adr, ISAC_MASK, 0x0);
-}
+ struct IsdnCardState *cs = dev_id;
+ u_char ista,val;
+ char tmp[64];
+ int icnt=20;
-static void
-modehscx(struct HscxState *hs, int mode, int ichan)
-{
- struct IsdnCardState *sp = hs->sp;
- int hscx = hs->hscx;
-
- if (sp->debug & L1_DEB_HSCX) {
- char tmp[40];
- sprintf(tmp, "hscx %c mode %d ichan %d",
- 'A' + hscx, mode, ichan);
- debugl1(sp, tmp);
+ if (!cs) {
+ printk(KERN_WARNING "Elsa: Spurious interrupt!\n");
+ return;
}
- hs->mode = mode;
- writehscx(sp->cfg_reg, hscx, HSCX_CCR1, 0x85);
- writehscx(sp->cfg_reg, hscx, HSCX_XAD1, 0xFF);
- writehscx(sp->cfg_reg, hscx, HSCX_XAD2, 0xFF);
- writehscx(sp->cfg_reg, hscx, HSCX_RAH2, 0xFF);
- writehscx(sp->cfg_reg, hscx, HSCX_XBCH, 0x0);
- writehscx(sp->cfg_reg, hscx, HSCX_RLCR, 0x0);
- writehscx(sp->cfg_reg, hscx, HSCX_CCR2, 0x30);
-
- switch (mode) {
- case (0):
- writehscx(sp->cfg_reg, hscx, HSCX_TSAX, 0xff);
- writehscx(sp->cfg_reg, hscx, HSCX_TSAR, 0xff);
- writehscx(sp->cfg_reg, hscx, HSCX_XCCR, 7);
- writehscx(sp->cfg_reg, hscx, HSCX_RCCR, 7);
- writehscx(sp->cfg_reg, hscx, HSCX_MODE, 0x84);
- break;
- case (1):
- if (ichan == 0) {
- writehscx(sp->cfg_reg, hscx, HSCX_TSAX, 0x2f);
- writehscx(sp->cfg_reg, hscx, HSCX_TSAR, 0x2f);
- } else {
- writehscx(sp->cfg_reg, hscx, HSCX_TSAX, 0x3);
- writehscx(sp->cfg_reg, hscx, HSCX_TSAR, 0x3);
- }
- writehscx(sp->cfg_reg, hscx, HSCX_XCCR, 7);
- writehscx(sp->cfg_reg, hscx, HSCX_RCCR, 7);
- writehscx(sp->cfg_reg, hscx, HSCX_MODE, 0xe4);
- writehscx(sp->cfg_reg, hscx, HSCX_CMDR, 0x41);
- break;
- case (2):
- if (ichan == 0) {
- writehscx(sp->cfg_reg, hscx, HSCX_TSAX, 0x2f);
- writehscx(sp->cfg_reg, hscx, HSCX_TSAR, 0x2f);
- } else {
- writehscx(sp->cfg_reg, hscx, HSCX_TSAX, 0x3);
- writehscx(sp->cfg_reg, hscx, HSCX_TSAR, 0x3);
- }
- writehscx(sp->cfg_reg, hscx, HSCX_XCCR, 7);
- writehscx(sp->cfg_reg, hscx, HSCX_RCCR, 7);
- writehscx(sp->cfg_reg, hscx, HSCX_MODE, 0x8c);
- writehscx(sp->cfg_reg, hscx, HSCX_CMDR, 0x41);
- break;
+ if ((cs->typ == ISDN_CTYPE_ELSA_PCMCIA) && (*cs->busy_flag == 1)) {
+ /* The card tends to generate interrupts while being removed
+ causing us to just crash the kernel. bad. */
+ printk(KERN_WARNING "Elsa: card not available!\n");
+ return;
+ }
+ ista = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ISTA);
+Start_IPAC:
+ if (cs->debug & L1_DEB_IPAC) {
+ sprintf(tmp, "IPAC ISTA %02X", ista);
+ debugl1(cs, tmp);
+ }
+ if (ista & 0x0f) {
+ val = readreg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_ISTA + 0x40);
+ if (ista & 0x01)
+ val |= 0x01;
+ if (ista & 0x04)
+ val |= 0x02;
+ if (ista & 0x08)
+ val |= 0x04;
+ if (val)
+ hscx_int_main(cs, val);
+ }
+ if (ista & 0x20) {
+ val = 0xfe & readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_ISTA + 0x80);
+ if (val) {
+ isac_interrupt(cs, val);
+ }
+ }
+ if (ista & 0x10) {
+ val = 0x01;
+ isac_interrupt(cs, val);
}
- writehscx(sp->cfg_reg, hscx, HSCX_ISTA, 0x00);
+ ista = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ISTA);
+ if ((ista & 0x3f) && icnt) {
+ icnt--;
+ goto Start_IPAC;
+ }
+ if (!icnt)
+ printk(KERN_WARNING "ELSA IRQ LOOP\n");
+ writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_MASK, 0xFF);
+ writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_MASK, 0xC0);
}
void
-release_io_elsa(struct IsdnCard *card)
+release_io_elsa(struct IsdnCardState *cs)
{
int bytecnt = 8;
- if (card->sp->subtyp == ELSA_PCFPRO)
+ del_timer(&cs->hw.elsa.tl);
+ if (cs->hw.elsa.ctrl)
+ byteout(cs->hw.elsa.ctrl, 0); /* LEDs Out */
+ if ((cs->subtyp == ELSA_PCFPRO) ||
+ (cs->subtyp == ELSA_QS3000) ||
+ (cs->subtyp == ELSA_PCF))
bytecnt = 16;
- if (card->sp->cfg_reg)
- release_region(card->sp->cfg_reg, bytecnt);
-}
-
-static void
-reset_elsa(struct IsdnCardState *sp)
-{
-#ifdef CONFIG_HISAX_ELSA_PCC
- /* Wait 1 Timer */
- byteout(sp->cfg_reg + CARD_START_TIMER, 0);
- while (TimerRun(sp));
- byteout(sp->cfg_reg + CARD_CONTROL, 0x00); /* Reset On */
- /* Wait 1 Timer */
- byteout(sp->cfg_reg + CARD_START_TIMER, 0);
- while (TimerRun(sp));
- byteout(sp->cfg_reg + CARD_CONTROL, ISDN_RESET); /* Reset Off */
- /* Wait 1 Timer */
- byteout(sp->cfg_reg + CARD_START_TIMER, 0);
- while (TimerRun(sp));
- byteout(sp->cfg_reg + CARD_TRIG_IRQ, 0xff);
-#endif
+ if (cs->subtyp == ELSA_QS1000PCI) {
+ byteout(cs->hw.elsa.cfg + 0x4c, 0x01); /* disable IRQ */
+ bytecnt = 2;
+ release_region(cs->hw.elsa.cfg, 0x80);
+ }
+ if (cs->hw.elsa.base)
+ release_region(cs->hw.elsa.base, bytecnt);
}
static void
-clear_pending_ints(struct IsdnCardState *sp)
+reset_elsa(struct IsdnCardState *cs)
{
-#ifdef CONFIG_HISAX_ELSA_PCMCIA
- int val;
- char tmp[64];
+ long flags;
- val = readhscx(sp->cfg_reg, 1, HSCX_ISTA);
- sprintf(tmp, "HSCX B ISTA %x", val);
- debugl1(sp, tmp);
- if (val & 0x01) {
- val = readhscx(sp->cfg_reg, 1, HSCX_EXIR);
- sprintf(tmp, "HSCX B EXIR %x", val);
- debugl1(sp, tmp);
- } else if (val & 0x02) {
- val = readhscx(sp->cfg_reg, 0, HSCX_EXIR);
- sprintf(tmp, "HSCX A EXIR %x", val);
- debugl1(sp, tmp);
+ if (cs->hw.elsa.timer) {
+ /* Wait 1 Timer */
+ byteout(cs->hw.elsa.timer, 0);
+ while (TimerRun(cs));
+ cs->hw.elsa.ctrl_reg |= 0x50;
+ cs->hw.elsa.ctrl_reg &= ~ELSA_ISDN_RESET; /* Reset On */
+ byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
+ /* Wait 1 Timer */
+ byteout(cs->hw.elsa.timer, 0);
+ while (TimerRun(cs));
+ cs->hw.elsa.ctrl_reg |= ELSA_ISDN_RESET; /* Reset Off */
+ byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
+ /* Wait 1 Timer */
+ byteout(cs->hw.elsa.timer, 0);
+ while (TimerRun(cs));
+ if (cs->hw.elsa.trig)
+ byteout(cs->hw.elsa.trig, 0xff);
}
- val = readhscx(sp->cfg_reg, 0, HSCX_ISTA);
- sprintf(tmp, "HSCX A ISTA %x", val);
- debugl1(sp, tmp);
- val = readhscx(sp->cfg_reg, 1, HSCX_STAR);
- sprintf(tmp, "HSCX B STAR %x", val);
- debugl1(sp, tmp);
- val = readhscx(sp->cfg_reg, 0, HSCX_STAR);
- sprintf(tmp, "HSCX A STAR %x", val);
- debugl1(sp, tmp);
- val = readisac(sp->cfg_reg, ISAC_STAR);
- sprintf(tmp, "ISAC STAR %x", val);
- debugl1(sp, tmp);
- val = readisac(sp->cfg_reg, ISAC_MODE);
- sprintf(tmp, "ISAC MODE %x", val);
- debugl1(sp, tmp);
- val = readisac(sp->cfg_reg, ISAC_ADF2);
- sprintf(tmp, "ISAC ADF2 %x", val);
- debugl1(sp, tmp);
- val = readisac(sp->cfg_reg, ISAC_ISTA);
- sprintf(tmp, "ISAC ISTA %x", val);
- debugl1(sp, tmp);
- if (val & 0x01) {
- val = readisac(sp->cfg_reg, ISAC_EXIR);
- sprintf(tmp, "ISAC EXIR %x", val);
- debugl1(sp, tmp);
- } else if (val & 0x04) {
- val = readisac(sp->cfg_reg, ISAC_CIR0);
- sprintf(tmp, "ISAC CIR0 %x", val);
- debugl1(sp, tmp);
- }
-#endif
- writehscx(sp->cfg_reg, 0, HSCX_MASK, 0xFF);
- writehscx(sp->cfg_reg, 1, HSCX_MASK, 0xFF);
- writeisac(sp->cfg_reg, ISAC_MASK, 0xFF);
-#ifdef CONFIG_HISAX_ELSA_PCC
- if (sp->subtyp == ELSA_QS1000) {
- byteout(sp->cfg_reg + CARD_START_TIMER, 0);
- byteout(sp->cfg_reg + CARD_TRIG_IRQ, 0xff);
+ if (cs->subtyp == ELSA_QS1000PCI) {
+ save_flags(flags);
+ sti();
+ writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_POTA2, 0x20);
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + (10 * HZ) / 1000; /* Timeout 10ms */
+ schedule();
+ writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_POTA2, 0x00);
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + (10 * HZ) / 1000; /* Timeout 10ms */
+ schedule();
+ writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_MASK, 0xc0);
+ schedule();
+ restore_flags(flags);
+ byteout(cs->hw.elsa.cfg + 0x4c, 0x41); /* enable ELSA PCI IRQ */
}
-#endif
- writehscx(sp->cfg_reg, 0, HSCX_MASK, 0x0);
- writehscx(sp->cfg_reg, 1, HSCX_MASK, 0x0);
- writeisac(sp->cfg_reg, ISAC_MASK, 0x0);
- writeisac(sp->cfg_reg, ISAC_CMDR, 0x41);
+}
+
+const u_char ARCOFI_VERSION[] = {2,0xa0,0};
+const u_char ARCOFI_COP_5[] = {4,0xa1,0x25,0xbb,0x4a}; /* GTX */
+const u_char ARCOFI_COP_6[] = {6,0xa1,0x26,0,0,0x82,0x7c}; /* GRL GRH */
+const u_char ARCOFI_COP_7[] = {4,0xa1,0x27,0x80,0x80}; /* GZ */
+const u_char ARCOFI_COP_8[] = {10,0xa1,0x28,0x49,0x31,0x8,0x13,0x6e,0x88,0x2a,0x61}; /* TX */
+const u_char ARCOFI_COP_9[] = {10,0xa1,0x29,0x80,0xcb,0x9e,0x88,0x00,0xc8,0xd8,0x80}; /* RX */
+const u_char ARCOFI_XOP_0[] = {2,0xa1,0x30}; /* PWR Down */
+const u_char ARCOFI_XOP_1[] = {2,0xa1,0x31}; /* PWR Down */
+const u_char ARCOFI_XOP_F[] = {2,0xa1,0x3f}; /* PWR Down */
+const u_char ARCOFI_SOP_F[] = {10,0xa1,0x1f,0x00,0x50,0x10,0x00,0x00,0x80,0x02,0x12};
+
+static void
+init_arcofi(struct IsdnCardState *cs) {
+ send_arcofi(cs, ARCOFI_COP_5);
+ send_arcofi(cs, ARCOFI_COP_6);
+ send_arcofi(cs, ARCOFI_COP_7);
+ send_arcofi(cs, ARCOFI_COP_8);
+ send_arcofi(cs, ARCOFI_COP_9);
+ send_arcofi(cs, ARCOFI_SOP_F);
+ send_arcofi(cs, ARCOFI_XOP_F);
}
static void
-check_arcofi(struct IsdnCardState *sp)
+check_arcofi(struct IsdnCardState *cs)
{
-#if 0
- u_char val;
+#if ARCOFI_USE
+ int arcofi_present = 0;
char tmp[40];
char *t;
- long flags;
u_char *p;
- if (BufPoolGet(&(sp->mon_tx), &(sp->sbufpool),
- GFP_ATOMIC, (void *) 1, 3)) {
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC MON TX out of buffers!");
- return;
- } else
- sp->mon_txp = 0;
- p = DATAPTR(sp->mon_tx);
- *p++ = 0xa0;
- *p++ = 0x0;
- sp->mon_tx->datasize = 2;
- sp->mon_txp = 1;
- sp->mon_flg = 0;
- writeisac(sp->cfg_reg, ISAC_MOCR, 0xa0);
- val = readisac(sp->cfg_reg, ISAC_MOSR);
- writeisac(sp->cfg_reg, ISAC_MOX1, 0xa0);
- writeisac(sp->cfg_reg, ISAC_MOCR, 0xb0);
- save_flags(flags);
- sti();
- HZDELAY(3);
- restore_flags(flags);
- if (sp->mon_flg & MON1_TX) {
- if (sp->mon_flg & MON1_RX) {
- sprintf(tmp, "Arcofi response received %d bytes", sp->mon_rx->datasize);
- debugl1(sp, tmp);
- p = DATAPTR(sp->mon_rx);
+ if (!cs->mon_tx)
+ if (!(cs->mon_tx=kmalloc(MAX_MON_FRAME, GFP_ATOMIC))) {
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "ISAC MON TX out of buffers!");
+ return;
+ }
+ send_arcofi(cs, ARCOFI_VERSION);
+ if (test_and_clear_bit(HW_MON1_TX_END, &cs->HW_Flags)) {
+ if (test_and_clear_bit(HW_MON1_RX_END, &cs->HW_Flags)) {
+ sprintf(tmp, "Arcofi response received %d bytes", cs->mon_rxp);
+ debugl1(cs, tmp);
+ p = cs->mon_rx;
t = tmp;
t += sprintf(tmp, "Arcofi data");
- QuickHex(t, p, sp->mon_rx->datasize);
- debugl1(sp, tmp);
- BufPoolRelease(sp->mon_rx);
- sp->mon_rx = NULL;
- sp->mon_rxp = 0;
- sp->mon_flg = 0;
+ QuickHex(t, p, cs->mon_rxp);
+ debugl1(cs, tmp);
+ if ((cs->mon_rxp == 2) && (cs->mon_rx[0] == 0xa0)) {
+ switch(cs->mon_rx[1]) {
+ case 0x80:
+ debugl1(cs, "Arcofi 2160 detected");
+ arcofi_present = 1;
+ break;
+ case 0x82:
+ debugl1(cs, "Arcofi 2165 detected");
+ arcofi_present = 2;
+ break;
+ case 0x84:
+ debugl1(cs, "Arcofi 2163 detected");
+ arcofi_present = 3;
+ break;
+ default:
+ debugl1(cs, "unknown Arcofi response");
+ break;
+ }
+ } else
+ debugl1(cs, "undefined Monitor response");
+ cs->mon_rxp = 0;
}
- } else if (sp->mon_tx) {
- BufPoolRelease(sp->mon_tx);
- sp->mon_tx = NULL;
- sp->mon_txp = 0;
+ } else if (cs->mon_tx) {
sprintf(tmp, "Arcofi not detected");
- debugl1(sp, tmp);
+ debugl1(cs, tmp);
+ }
+ if (arcofi_present) {
+ if (cs->subtyp==ELSA_QS1000) {
+ cs->subtyp = ELSA_QS3000;
+ printk(KERN_INFO
+ "Elsa: %s detected modem at 0x%x\n",
+ Elsa_Types[cs->subtyp],
+ cs->hw.elsa.base+8);
+ release_region(cs->hw.elsa.base, 8);
+ if (check_region(cs->hw.elsa.base, 16)) {
+ printk(KERN_WARNING
+ "HiSax: %s config port %x-%x already in use\n",
+ Elsa_Types[cs->subtyp],
+ cs->hw.elsa.base + 8,
+ cs->hw.elsa.base + 16);
+ } else
+ request_region(cs->hw.elsa.base, 16,
+ "elsa isdn modem");
+ } else if (cs->subtyp==ELSA_PCC16) {
+ cs->subtyp = ELSA_PCF;
+ printk(KERN_INFO
+ "Elsa: %s detected modem at 0x%x\n",
+ Elsa_Types[cs->subtyp],
+ cs->hw.elsa.base+8);
+ release_region(cs->hw.elsa.base, 8);
+ if (check_region(cs->hw.elsa.base, 16)) {
+ printk(KERN_WARNING
+ "HiSax: %s config port %x-%x already in use\n",
+ Elsa_Types[cs->subtyp],
+ cs->hw.elsa.base + 8,
+ cs->hw.elsa.base + 16);
+ } else
+ request_region(cs->hw.elsa.base, 16,
+ "elsa isdn modem");
+ } else
+ printk(KERN_INFO
+ "Elsa: %s detected modem at 0x%x\n",
+ Elsa_Types[cs->subtyp],
+ cs->hw.elsa.base+8);
+ init_arcofi(cs);
}
- sp->mon_flg = 0;
#endif
}
-int
-initelsa(struct IsdnCardState *sp)
+static void
+elsa_led_handler(struct IsdnCardState *cs)
{
- int ret, irq_cnt, cnt = 3;
- long flags;
+ int blink = 0;
- irq_cnt = kstat_irqs(sp->irq);
- printk(KERN_INFO "Elsa: IRQ %d count %d\n", sp->irq, irq_cnt);
- ret = get_irq(sp->cardnr, &elsa_interrupt);
-#ifdef CONFIG_HISAX_ELSA_PCC
- byteout(sp->cfg_reg + CARD_TRIG_IRQ, 0xff);
-#endif
- while (ret && cnt) {
- sp->counter = 0;
- clear_pending_ints(sp);
- initisac(sp);
- sp->modehscx(sp->hs, 0, 0);
- sp->modehscx(sp->hs + 1, 0, 0);
- save_flags(flags);
- sp->counter = 0;
- sti();
-#ifdef CONFIG_HISAX_ELSA_PCC
- byteout(sp->cfg_reg + CARD_CONTROL, ISDN_RESET | ENABLE_TIM_INT);
- byteout(sp->cfg_reg + CARD_START_TIMER, 0);
- current->state = TASK_INTERRUPTIBLE;
- current->timeout = jiffies + (110 * HZ) / 1000; /* Timeout 110ms */
- schedule();
- restore_flags(flags);
- printk(KERN_INFO "Elsa: %d timer tics in 110 msek\n",
- sp->counter);
- if (abs(sp->counter - 13) < 3) {
- printk(KERN_INFO "Elsa: timer and irq OK\n");
- } else {
- printk(KERN_WARNING
- "Elsa: timer tic problem (%d/12) maybe an IRQ(%d) conflict\n",
- sp->counter, sp->irq);
- }
-#endif
- printk(KERN_INFO "Elsa: IRQ %d count %d\n", sp->irq,
- kstat_irqs(sp->irq));
- if (kstat_irqs(sp->irq) == irq_cnt) {
- printk(KERN_WARNING
- "Elsa: IRQ(%d) getting no interrupts during init %d\n",
- sp->irq, 4 - cnt);
- if (cnt == 1) {
- free_irq(sp->irq, sp);
- return (0);
+ if ((cs->subtyp == ELSA_PCMCIA) &&
+ (cs->subtyp == ELSA_QS1000PCI))
+ return;
+ del_timer(&cs->hw.elsa.tl);
+ if (cs->hw.elsa.status & ELSA_ASSIGN)
+ cs->hw.elsa.ctrl_reg |= ELSA_STAT_LED;
+ else if (cs->hw.elsa.status & ELSA_BAD_PWR)
+ cs->hw.elsa.ctrl_reg &= ~ELSA_STAT_LED;
+ else {
+ cs->hw.elsa.ctrl_reg ^= ELSA_STAT_LED;
+ blink = 250;
+ }
+ if (cs->hw.elsa.status & 0xf000)
+ cs->hw.elsa.ctrl_reg |= ELSA_LINE_LED;
+ else if (cs->hw.elsa.status & 0x0f00) {
+ cs->hw.elsa.ctrl_reg ^= ELSA_LINE_LED;
+ blink = 500;
+ } else
+ cs->hw.elsa.ctrl_reg &= ~ELSA_LINE_LED;
+
+ byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
+ if (blink) {
+ init_timer(&cs->hw.elsa.tl);
+ cs->hw.elsa.tl.expires = jiffies + ((blink * HZ) / 1000);
+ add_timer(&cs->hw.elsa.tl);
+ }
+}
+
+static int
+Elsa_card_msg(struct IsdnCardState *cs, int mt, void *arg)
+{
+ int pwr, ret = 0;
+ long flags;
+
+ switch (mt) {
+ case CARD_RESET:
+ reset_elsa(cs);
+ return(0);
+ case CARD_RELEASE:
+ release_io_elsa(cs);
+ return(0);
+ case CARD_SETIRQ:
+ if (cs->subtyp == ELSA_QS1000PCI)
+ ret = request_irq(cs->irq, &elsa_interrupt_ipac,
+ I4L_IRQ_FLAG, "HiSax", cs);
+ else
+ ret = request_irq(cs->irq, &elsa_interrupt,
+ I4L_IRQ_FLAG, "HiSax", cs);
+ return(ret);
+ case CARD_INIT:
+ if (cs->hw.elsa.trig)
+ byteout(cs->hw.elsa.trig, 0xff);
+ clear_pending_isac_ints(cs);
+ clear_pending_hscx_ints(cs);
+ initisac(cs);
+ inithscx(cs);
+ if (cs->subtyp == ELSA_QS1000) {
+ byteout(cs->hw.elsa.timer, 0);
+ byteout(cs->hw.elsa.trig, 0xff);
+ }
+ return(0);
+ case CARD_TEST:
+ if ((cs->subtyp != ELSA_PCMCIA) &&
+ (cs->subtyp != ELSA_QS1000PCI)) {
+ save_flags(flags);
+ cs->hw.elsa.counter = 0;
+ sti();
+ cs->hw.elsa.ctrl_reg |= ELSA_ENA_TIMER_INT;
+ cs->hw.elsa.status |= ELSA_TIMER_AKTIV;
+ byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
+ byteout(cs->hw.elsa.timer, 0);
+ } else
+ return(0);
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + (110 * HZ) / 1000; /* Timeout 110ms */
+ schedule();
+ restore_flags(flags);
+ cs->hw.elsa.ctrl_reg &= ~ELSA_ENA_TIMER_INT;
+ byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
+ cs->hw.elsa.status &= ~ELSA_TIMER_AKTIV;
+ printk(KERN_INFO "Elsa: %d timer tics in 110 msek\n",
+ cs->hw.elsa.counter);
+ if (abs(cs->hw.elsa.counter - 13) < 3) {
+ printk(KERN_INFO "Elsa: timer and irq OK\n");
+ ret = 0;
} else {
- reset_elsa(sp);
- cnt--;
+ printk(KERN_WARNING
+ "Elsa: timer tic problem (%d/12) maybe an IRQ(%d) conflict\n",
+ cs->hw.elsa.counter, cs->irq);
+ ret = 1;
}
- } else {
- check_arcofi(sp);
- cnt = 0;
- }
+ check_arcofi(cs);
+ elsa_led_handler(cs);
+ return(ret);
+ case MDL_REMOVE_REQ:
+ cs->hw.elsa.status &= 0;
+ break;
+ case MDL_ASSIGN_REQ:
+ cs->hw.elsa.status |= ELSA_ASSIGN;
+ break;
+ case MDL_INFO_SETUP:
+ if ((int) arg)
+ cs->hw.elsa.status |= 0x0200;
+ else
+ cs->hw.elsa.status |= 0x0100;
+ break;
+ case MDL_INFO_CONN:
+ if ((int) arg)
+ cs->hw.elsa.status |= 0x2000;
+ else
+ cs->hw.elsa.status |= 0x1000;
+ break;
+ case MDL_INFO_REL:
+ if ((int) arg) {
+ cs->hw.elsa.status &= ~0x2000;
+ cs->hw.elsa.status &= ~0x0200;
+ } else {
+ cs->hw.elsa.status &= ~0x1000;
+ cs->hw.elsa.status &= ~0x0100;
+ }
+ break;
+ case CARD_AUX_IND:
+ break;
}
- sp->counter = 0;
- return (ret);
+ pwr = bytein(cs->hw.elsa.ale);
+ if (pwr & 0x08)
+ cs->hw.elsa.status |= ELSA_BAD_PWR;
+ else
+ cs->hw.elsa.status &= ~ELSA_BAD_PWR;
+ elsa_led_handler(cs);
+ return(ret);
}
-#ifdef CONFIG_HISAX_ELSA_PCC
static unsigned char
-probe_elsa_adr(unsigned int adr)
+probe_elsa_adr(unsigned int adr, int typ)
{
int i, in1, in2, p16_1 = 0, p16_2 = 0, p8_1 = 0, p8_2 = 0, pc_1 = 0,
pc_2 = 0, pfp_1 = 0, pfp_2 = 0;
long flags;
- if (check_region(adr, 8)) {
+ /* In case of the elsa pcmcia card, this region is in use,
+ reserved for us by the card manager. So we do not check it
+ here, it would fail. */
+ if (typ != ISDN_CTYPE_ELSA_PCMCIA && check_region(adr, 8)) {
printk(KERN_WARNING
"Elsa: Probing Port 0x%x: already in use\n",
adr);
@@ -1251,8 +736,8 @@ probe_elsa_adr(unsigned int adr)
save_flags(flags);
cli();
for (i = 0; i < 16; i++) {
- in1 = inb(adr + CARD_CONFIG); /* 'toggelt' bei */
- in2 = inb(adr + CARD_CONFIG); /* jedem Zugriff */
+ in1 = inb(adr + ELSA_CONFIG); /* 'toggelt' bei */
+ in2 = inb(adr + ELSA_CONFIG); /* jedem Zugriff */
p16_1 += 0x04 & in1;
p16_2 += 0x04 & in2;
p8_1 += 0x02 & in1;
@@ -1283,205 +768,295 @@ probe_elsa_adr(unsigned int adr)
}
static unsigned int
-probe_elsa(struct IsdnCardState *sp)
+probe_elsa(struct IsdnCardState *cs)
{
int i;
unsigned int CARD_portlist[] =
{0x160, 0x170, 0x260, 0x360, 0};
for (i = 0; CARD_portlist[i]; i++) {
- if ((sp->subtyp = probe_elsa_adr(CARD_portlist[i])))
+ if ((cs->subtyp = probe_elsa_adr(CARD_portlist[i], cs->typ)))
break;
}
return (CARD_portlist[i]);
}
-#endif
+
+static int pci_index __initdata = 0;
int
setup_elsa(struct IsdnCard *card)
{
-#ifdef CONFIG_HISAX_ELSA_PCC
long flags;
-#endif
int bytecnt;
- u_char val, verA, verB;
- struct IsdnCardState *sp = card->sp;
+ u_char val;
+ struct IsdnCardState *cs = card->cs;
char tmp[64];
strcpy(tmp, Elsa_revision);
- printk(KERN_NOTICE "HiSax: Elsa driver Rev. %s\n", HiSax_getrev(tmp));
-#ifdef CONFIG_HISAX_ELSA_PCC
- if (sp->typ == ISDN_CTYPE_ELSA) {
- sp->cfg_reg = card->para[0];
+ printk(KERN_INFO "HiSax: Elsa driver Rev. %s\n", HiSax_getrev(tmp));
+ cs->hw.elsa.ctrl_reg = 0;
+ cs->hw.elsa.status = 0;
+ if (cs->typ == ISDN_CTYPE_ELSA) {
+ cs->hw.elsa.base = card->para[0];
printk(KERN_INFO "Elsa: Microlink IO probing\n");
- if (sp->cfg_reg) {
- if (!(sp->subtyp = probe_elsa_adr(sp->cfg_reg))) {
+ if (cs->hw.elsa.base) {
+ if (!(cs->subtyp = probe_elsa_adr(cs->hw.elsa.base,
+ cs->typ))) {
printk(KERN_WARNING
"Elsa: no Elsa Microlink at 0x%x\n",
- sp->cfg_reg);
+ cs->hw.elsa.base);
return (0);
}
} else
- sp->cfg_reg = probe_elsa(sp);
- if (sp->cfg_reg) {
- val = bytein(sp->cfg_reg + CARD_CONFIG);
- if (sp->subtyp == ELSA_PC) {
+ cs->hw.elsa.base = probe_elsa(cs);
+ if (cs->hw.elsa.base) {
+ cs->hw.elsa.cfg = cs->hw.elsa.base + ELSA_CONFIG;
+ cs->hw.elsa.ctrl = cs->hw.elsa.base + ELSA_CONTROL;
+ cs->hw.elsa.ale = cs->hw.elsa.base + ELSA_ALE;
+ cs->hw.elsa.isac = cs->hw.elsa.base + ELSA_ISAC;
+ cs->hw.elsa.itac = cs->hw.elsa.base + ELSA_ITAC;
+ cs->hw.elsa.hscx = cs->hw.elsa.base + ELSA_HSCX;
+ cs->hw.elsa.trig = cs->hw.elsa.base + ELSA_TRIG_IRQ;
+ cs->hw.elsa.timer = cs->hw.elsa.base + ELSA_START_TIMER;
+ val = bytein(cs->hw.elsa.cfg);
+ if (cs->subtyp == ELSA_PC) {
const u_char CARD_IrqTab[8] =
{7, 3, 5, 9, 0, 0, 0, 0};
- sp->irq = CARD_IrqTab[(val & IRQ_INDEX_PC) >> 2];
- } else if (sp->subtyp == ELSA_PCC8) {
+ cs->irq = CARD_IrqTab[(val & ELSA_IRQ_IDX_PC) >> 2];
+ } else if (cs->subtyp == ELSA_PCC8) {
const u_char CARD_IrqTab[8] =
{7, 3, 5, 9, 0, 0, 0, 0};
- sp->irq = CARD_IrqTab[(val & IRQ_INDEX_PCC8) >> 4];
+ cs->irq = CARD_IrqTab[(val & ELSA_IRQ_IDX_PCC8) >> 4];
} else {
const u_char CARD_IrqTab[8] =
{15, 10, 15, 3, 11, 5, 11, 9};
- sp->irq = CARD_IrqTab[(val & IRQ_INDEX) >> 3];
+ cs->irq = CARD_IrqTab[(val & ELSA_IRQ_IDX) >> 3];
}
- val = bytein(sp->cfg_reg + CARD_ALE) & 0x7;
+ val = bytein(cs->hw.elsa.ale) & ELSA_HW_RELEASE;
if (val < 3)
val |= 8;
val += 'A' - 3;
if (val == 'B' || val == 'C')
val ^= 1;
- if ((sp->subtyp == ELSA_PCFPRO) && (val = 'G'))
+ if ((cs->subtyp == ELSA_PCFPRO) && (val = 'G'))
val = 'C';
printk(KERN_INFO
"Elsa: %s found at 0x%x Rev.:%c IRQ %d\n",
- Elsa_Types[sp->subtyp],
- sp->cfg_reg,
- val, sp->irq);
- val = bytein(sp->cfg_reg + CARD_ALE) & 0x08;
- if (val)
+ Elsa_Types[cs->subtyp],
+ cs->hw.elsa.base,
+ val, cs->irq);
+ val = bytein(cs->hw.elsa.ale) & ELSA_S0_POWER_BAD;
+ if (val) {
printk(KERN_WARNING
"Elsa: Microlink S0 bus power bad\n");
+ cs->hw.elsa.status |= ELSA_BAD_PWR;
+ }
} else {
printk(KERN_WARNING
"No Elsa Microlink found\n");
return (0);
}
- } else if (sp->typ == ISDN_CTYPE_ELSA_QS1000) {
- sp->cfg_reg = card->para[1];
- sp->irq = card->para[0];
- sp->subtyp = ELSA_QS1000;
+ } else if (cs->typ == ISDN_CTYPE_ELSA_PNP) {
+ cs->hw.elsa.base = card->para[1];
+ cs->irq = card->para[0];
+ cs->subtyp = ELSA_QS1000;
+ cs->hw.elsa.cfg = cs->hw.elsa.base + ELSA_CONFIG;
+ cs->hw.elsa.ale = cs->hw.elsa.base + ELSA_ALE;
+ cs->hw.elsa.isac = cs->hw.elsa.base + ELSA_ISAC;
+ cs->hw.elsa.hscx = cs->hw.elsa.base + ELSA_HSCX;
+ cs->hw.elsa.trig = cs->hw.elsa.base + ELSA_TRIG_IRQ;
+ cs->hw.elsa.timer = cs->hw.elsa.base + ELSA_START_TIMER;
+ cs->hw.elsa.ctrl = cs->hw.elsa.base + ELSA_CONTROL;
printk(KERN_INFO
- "Elsa: %s found at 0x%x IRQ %d\n",
- Elsa_Types[sp->subtyp],
- sp->cfg_reg,
- sp->irq);
- } else
- return (0);
-#endif
-#ifdef CONFIG_HISAX_ELSA_PCMCIA
- if (sp->typ == ISDN_CTYPE_ELSA_QS1000) {
- sp->cfg_reg = card->para[1];
- sp->irq = card->para[0];
- sp->subtyp = ELSA_PCMCIA;
+ "Elsa: %s defined at 0x%x IRQ %d\n",
+ Elsa_Types[cs->subtyp],
+ cs->hw.elsa.base,
+ cs->irq);
+ } else if (cs->typ == ISDN_CTYPE_ELSA_PCMCIA) {
+ cs->hw.elsa.base = card->para[1];
+ cs->irq = card->para[0];
+ cs->subtyp = ELSA_PCMCIA;
+ cs->hw.elsa.ale = cs->hw.elsa.base + ELSA_ALE_PCM;
+ cs->hw.elsa.isac = cs->hw.elsa.base + ELSA_ISAC_PCM;
+ cs->hw.elsa.hscx = cs->hw.elsa.base + ELSA_HSCX;
+ cs->hw.elsa.timer = 0;
+ cs->hw.elsa.trig = 0;
+ cs->hw.elsa.ctrl = 0;
printk(KERN_INFO
- "Elsa: %s found at 0x%x IRQ %d\n",
- Elsa_Types[sp->subtyp],
- sp->cfg_reg,
- sp->irq);
- } else
+ "Elsa: %s defined at 0x%x IRQ %d\n",
+ Elsa_Types[cs->subtyp],
+ cs->hw.elsa.base,
+ cs->irq);
+ } else if (cs->typ == ISDN_CTYPE_ELSA_PCI) {
+#if CONFIG_PCI
+ u_char pci_bus, pci_device_fn, pci_irq;
+ u_int pci_ioaddr;
+
+ cs->subtyp = 0;
+ for (; pci_index < 0xff; pci_index++) {
+ if (pcibios_find_device(PCI_VENDOR_ELSA,
+ PCI_QS1000_ID, pci_index, &pci_bus, &pci_device_fn)
+ == PCIBIOS_SUCCESSFUL)
+ cs->subtyp = ELSA_QS1000PCI;
+ else
+ break;
+ /* get IRQ */
+ pcibios_read_config_byte(pci_bus, pci_device_fn,
+ PCI_INTERRUPT_LINE, &pci_irq);
+
+ /* get IO address */
+ pcibios_read_config_dword(pci_bus, pci_device_fn,
+ PCI_BASE_ADDRESS_1, &pci_ioaddr);
+ pci_ioaddr &= ~3; /* remove io/mem flag */
+ cs->hw.elsa.cfg = pci_ioaddr;
+ pcibios_read_config_dword(pci_bus, pci_device_fn,
+ PCI_BASE_ADDRESS_3, &pci_ioaddr);
+ if (cs->subtyp)
+ break;
+ }
+ if (!cs->subtyp) {
+ printk(KERN_WARNING "Elsa: No PCI card found\n");
+ return(0);
+ }
+ if (!pci_irq) {
+ printk(KERN_WARNING "Elsa: No IRQ for PCI card found\n");
+ return(0);
+ }
+
+ if (!pci_ioaddr) {
+ printk(KERN_WARNING "Elsa: No IO-Adr for PCI card found\n");
+ return(0);
+ }
+ pci_ioaddr &= ~3; /* remove io/mem flag */
+ cs->hw.elsa.base = pci_ioaddr;
+ cs->hw.elsa.ale = pci_ioaddr;
+ cs->hw.elsa.isac = pci_ioaddr +1;
+ cs->hw.elsa.hscx = pci_ioaddr +1;
+ cs->irq = pci_irq;
+ test_and_set_bit(HW_IPAC, &cs->HW_Flags);
+ cs->hw.elsa.timer = 0;
+ cs->hw.elsa.trig = 0;
+ printk(KERN_INFO
+ "Elsa: %s defined at 0x%x/0x%x IRQ %d\n",
+ Elsa_Types[cs->subtyp],
+ cs->hw.elsa.base,
+ cs->hw.elsa.cfg,
+ cs->irq);
+#else
+ printk(KERN_WARNING "Elsa: Elsa PCI and NO_PCI_BIOS\n");
+ printk(KERN_WARNING "Elsa: unable to config Elsa PCI\n");
+ return (0);
+#endif /* CONFIG_PCI */
+ } else
return (0);
-#endif
- switch (sp->subtyp) {
+ switch (cs->subtyp) {
case ELSA_PC:
- bytecnt = 8;
- break;
case ELSA_PCC8:
- bytecnt = 8;
- break;
- case ELSA_PCFPRO:
- bytecnt = 16;
- break;
case ELSA_PCC16:
+ case ELSA_QS1000:
+ case ELSA_PCMCIA:
bytecnt = 8;
break;
+ case ELSA_PCFPRO:
case ELSA_PCF:
bytecnt = 16;
break;
- case ELSA_QS1000:
- bytecnt = 8;
- break;
- case ELSA_PCMCIA:
- bytecnt = 8;
+ case ELSA_QS1000PCI:
+ bytecnt = 2;
break;
default:
printk(KERN_WARNING
- "Unknown ELSA subtype %d\n", sp->subtyp);
+ "Unknown ELSA subtype %d\n", cs->subtyp);
return (0);
}
-
- if (check_region((sp->cfg_reg), bytecnt)) {
+ /* In case of the elsa pcmcia card, this region is in use,
+ reserved for us by the card manager. So we do not check it
+ here, it would fail. */
+ if (cs->typ != ISDN_CTYPE_ELSA_PCMCIA && check_region(cs->hw.elsa.base, bytecnt)) {
printk(KERN_WARNING
"HiSax: %s config port %x-%x already in use\n",
CardType[card->typ],
- sp->cfg_reg,
- sp->cfg_reg + bytecnt);
+ cs->hw.elsa.base,
+ cs->hw.elsa.base + bytecnt);
return (0);
} else {
- request_region(sp->cfg_reg, bytecnt, "elsa isdn");
+ request_region(cs->hw.elsa.base, bytecnt, "elsa isdn");
}
-
- /* Teste Timer */
-#ifdef CONFIG_HISAX_ELSA_PCC
- byteout(sp->cfg_reg + CARD_TRIG_IRQ, 0xff);
- byteout(sp->cfg_reg + CARD_START_TIMER, 0);
- if (!TimerRun(sp)) {
- byteout(sp->cfg_reg + CARD_START_TIMER, 0); /* 2. Versuch */
- if (!TimerRun(sp)) {
+ if (cs->subtyp == ELSA_QS1000PCI) {
+ if (check_region(cs->hw.elsa.cfg, 0x80)) {
printk(KERN_WARNING
- "Elsa: timer do not start\n");
- release_io_elsa(card);
+ "HiSax: %s pci port %x-%x already in use\n",
+ CardType[card->typ],
+ cs->hw.elsa.cfg,
+ cs->hw.elsa.cfg + 0x80);
+ release_region(cs->hw.elsa.base, bytecnt);
return (0);
+ } else {
+ request_region(cs->hw.elsa.cfg, 0x80, "elsa isdn pci");
}
}
- save_flags(flags);
- sti();
- HZDELAY(1); /* wait >=10 ms */
- restore_flags(flags);
- if (TimerRun(sp)) {
- printk(KERN_WARNING "Elsa: timer do not run down\n");
- release_io_elsa(card);
- return (0);
+ cs->hw.elsa.tl.function = (void *) elsa_led_handler;
+ cs->hw.elsa.tl.data = (long) cs;
+ init_timer(&cs->hw.elsa.tl);
+ /* Teste Timer */
+ if (cs->hw.elsa.timer) {
+ byteout(cs->hw.elsa.trig, 0xff);
+ byteout(cs->hw.elsa.timer, 0);
+ if (!TimerRun(cs)) {
+ byteout(cs->hw.elsa.timer, 0); /* 2. Versuch */
+ if (!TimerRun(cs)) {
+ printk(KERN_WARNING
+ "Elsa: timer do not start\n");
+ release_io_elsa(cs);
+ return (0);
+ }
+ }
+ save_flags(flags);
+ sti();
+ HZDELAY(1); /* wait >=10 ms */
+ restore_flags(flags);
+ if (TimerRun(cs)) {
+ printk(KERN_WARNING "Elsa: timer do not run down\n");
+ release_io_elsa(cs);
+ return (0);
+ }
+ printk(KERN_INFO "Elsa: timer OK; resetting card\n");
}
- printk(KERN_INFO "Elsa: timer OK; resetting card\n");
- reset_elsa(sp);
-#endif
- verA = readhscx(sp->cfg_reg, 0, HSCX_VSTR) & 0xf;
- verB = readhscx(sp->cfg_reg, 1, HSCX_VSTR) & 0xf;
- printk(KERN_INFO "Elsa: HSCX version A: %s B: %s\n",
- HscxVersion(verA), HscxVersion(verB));
- val = readisac(sp->cfg_reg, ISAC_RBCH);
- printk(KERN_INFO "Elsa: ISAC %s\n",
- ISACVersion(val));
-
-#ifdef CONFIG_HISAX_ELSA_PCMCIA
- if ((verA == 0) | (verA == 0xf) | (verB == 0) | (verB == 0xf)) {
- printk(KERN_WARNING
- "Elsa: wrong HSCX versions check IO address\n");
- release_io_elsa(card);
- return (0);
+ reset_elsa(cs);
+ cs->BC_Read_Reg = &ReadHSCX;
+ cs->BC_Write_Reg = &WriteHSCX;
+ cs->BC_Send_Data = &hscx_fill_fifo;
+ cs->cardmsg = &Elsa_card_msg;
+ if (cs->subtyp == ELSA_QS1000PCI) {
+ cs->readisac = &ReadISAC_IPAC;
+ cs->writeisac = &WriteISAC_IPAC;
+ cs->readisacfifo = &ReadISACfifo_IPAC;
+ cs->writeisacfifo = &WriteISACfifo_IPAC;
+ val = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ID);
+ printk(KERN_INFO "Elsa: IPAC version %x\n", val);
+ } else {
+ cs->readisac = &ReadISAC;
+ cs->writeisac = &WriteISAC;
+ cs->readisacfifo = &ReadISACfifo;
+ cs->writeisacfifo = &WriteISACfifo;
+ ISACVersion(cs, "Elsa:");
+ if (HscxVersion(cs, "Elsa:")) {
+ printk(KERN_WARNING
+ "Elsa: wrong HSCX versions check IO address\n");
+ release_io_elsa(cs);
+ return (0);
+ }
}
-#endif
-
-#ifdef CONFIG_HISAX_ELSA_PCC
- if (sp->subtyp == ELSA_PC) {
- val = readitac(sp->cfg_reg, ITAC_SYS);
+ if (cs->subtyp == ELSA_PC) {
+ val = readitac(cs, ITAC_SYS);
printk(KERN_INFO "Elsa: ITAC version %s\n", ITACVer[val & 7]);
- writeitac(sp->cfg_reg, ITAC_ISEN, 0);
- writeitac(sp->cfg_reg, ITAC_RFIE, 0);
- writeitac(sp->cfg_reg, ITAC_XFIE, 0);
- writeitac(sp->cfg_reg, ITAC_SCIE, 0);
- writeitac(sp->cfg_reg, ITAC_STIE, 0);
+ writeitac(cs, ITAC_ISEN, 0);
+ writeitac(cs, ITAC_RFIE, 0);
+ writeitac(cs, ITAC_XFIE, 0);
+ writeitac(cs, ITAC_SCIE, 0);
+ writeitac(cs, ITAC_STIE, 0);
}
-#endif
- sp->modehscx = &modehscx;
- sp->ph_command = &ph_command;
- sp->hscx_fill_fifo = &hscx_fill_fifo;
- sp->isac_fill_fifo = &isac_fill_fifo;
-
return (1);
}
+
diff --git a/drivers/isdn/hisax/fsm.c b/drivers/isdn/hisax/fsm.c
index d0bb2f14f..ae0662f3f 100644
--- a/drivers/isdn/hisax/fsm.c
+++ b/drivers/isdn/hisax/fsm.c
@@ -1,4 +1,4 @@
-/* $Id: fsm.c,v 1.4 1997/04/06 22:56:42 keil Exp $
+/* $Id: fsm.c,v 1.7 1997/11/06 17:09:13 keil Exp $
* Author Karsten Keil (keil@temic-ech.spacenet.de)
* based on the teles driver from Jan den Ouden
@@ -7,6 +7,15 @@
* Fritz Elfert
*
* $Log: fsm.c,v $
+ * Revision 1.7 1997/11/06 17:09:13 keil
+ * New 2.1 init code
+ *
+ * Revision 1.6 1997/07/27 21:42:25 keil
+ * proof Fsm routines
+ *
+ * Revision 1.5 1997/06/26 11:10:05 keil
+ * Restart timer function added
+ *
* Revision 1.4 1997/04/06 22:56:42 keil
* Some cosmetic changes
*
@@ -26,9 +35,9 @@
#define FSM_TIMER_DEBUG 0
-void
+HISAX_INITFUNC(void
FsmNew(struct Fsm *fsm,
- struct FsmNode *fnlist, int fncount)
+ struct FsmNode *fnlist, int fncount))
{
int i;
@@ -36,9 +45,14 @@ FsmNew(struct Fsm *fsm,
kmalloc(4L * fsm->state_count * fsm->event_count, GFP_KERNEL);
memset(fsm->jumpmatrix, 0, 4L * fsm->state_count * fsm->event_count);
- for (i = 0; i < fncount; i++)
- fsm->jumpmatrix[fsm->state_count * fnlist[i].event +
- fnlist[i].state] = (int) fnlist[i].routine;
+ for (i = 0; i < fncount; i++)
+ if ((fnlist[i].state>=fsm->state_count) || (fnlist[i].event>=fsm->event_count)) {
+ printk(KERN_ERR "FsmNew Error line %d st(%d/%d) ev(%d/%d)\n",
+ i,fnlist[i].state,fsm->state_count,
+ fnlist[i].event,fsm->event_count);
+ } else
+ fsm->jumpmatrix[fsm->state_count * fnlist[i].event +
+ fnlist[i].state] = (int) fnlist[i].routine;
}
void
@@ -53,6 +67,11 @@ FsmEvent(struct FsmInst *fi, int event, void *arg)
void (*r) (struct FsmInst *, int, void *);
char str[80];
+ if ((fi->state>=fi->fsm->state_count) || (event >= fi->fsm->event_count)) {
+ printk(KERN_ERR "FsmEvent Error st(%d/%d) ev(%d/%d)\n",
+ fi->state,fi->fsm->state_count,event,fi->fsm->event_count);
+ return(1);
+ }
r = (void (*)) fi->fsm->jumpmatrix[fi->fsm->state_count * event + fi->state];
if (r) {
if (fi->debug) {
@@ -155,10 +174,26 @@ FsmAddTimer(struct FsmTimer *ft,
return 0;
}
-int
-FsmTimerRunning(struct FsmTimer *ft)
+void
+FsmRestartTimer(struct FsmTimer *ft,
+ int millisec, int event, void *arg, int where)
{
- return (ft->tl.next != NULL);
+
+#if FSM_TIMER_DEBUG
+ if (ft->fi->debug) {
+ char str[40];
+ sprintf(str, "FsmRestartTimer %lx %d %d", (long) ft, millisec, where);
+ ft->fi->printdebug(ft->fi, str);
+ }
+#endif
+
+ if (ft->tl.next || ft->tl.prev)
+ del_timer(&ft->tl);
+ init_timer(&ft->tl);
+ ft->event = event;
+ ft->arg = arg;
+ ft->tl.expires = jiffies + (millisec * HZ) / 1000;
+ add_timer(&ft->tl);
}
void
diff --git a/drivers/isdn/hisax/hfc_2bds0.c b/drivers/isdn/hisax/hfc_2bds0.c
new file mode 100644
index 000000000..734ec8bd3
--- /dev/null
+++ b/drivers/isdn/hisax/hfc_2bds0.c
@@ -0,0 +1,1297 @@
+/* $Id: hfc_2bds0.c,v 1.3 1998/02/12 23:07:22 keil Exp $
+ *
+ * specific routines for CCD's HFC 2BDS0
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ *
+ * $Log: hfc_2bds0.c,v $
+ * Revision 1.3 1998/02/12 23:07:22 keil
+ * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
+ *
+ * Revision 1.2 1998/02/02 13:26:13 keil
+ * New
+ *
+ *
+ *
+ */
+#define __NO_VERSION__
+#include "hisax.h"
+#include "hfc_2bds0.h"
+#include "isdnl1.h"
+#include <linux/interrupt.h>
+/*
+#define KDEBUG_DEF
+#include "kdebug.h"
+*/
+
+#define byteout(addr,val) outb(val,addr)
+#define bytein(addr) inb(addr)
+
+static void
+dummyf(struct IsdnCardState *cs, u_char * data, int size)
+{
+ printk(KERN_WARNING "HiSax: hfcd dummy fifo called\n");
+}
+
+static inline u_char
+ReadReg(struct IsdnCardState *cs, int data, u_char reg)
+{
+ register u_char ret;
+
+ if (data) {
+ if (cs->hw.hfcD.cip != reg) {
+ cs->hw.hfcD.cip = reg;
+ byteout(cs->hw.hfcD.addr | 1, reg);
+ }
+ ret = bytein(cs->hw.hfcD.addr);
+#if HFC_REG_DEBUG
+ if (cs->debug & L1_DEB_HSCX_FIFO && (data != 2)) {
+ char tmp[32];
+ sprintf(tmp, "t3c RD %02x %02x", reg, ret);
+ debugl1(cs, tmp);
+ }
+#endif
+ } else
+ ret = bytein(cs->hw.hfcD.addr | 1);
+ return (ret);
+}
+
+static inline void
+WriteReg(struct IsdnCardState *cs, int data, u_char reg, u_char value)
+{
+ if (cs->hw.hfcD.cip != reg) {
+ cs->hw.hfcD.cip = reg;
+ byteout(cs->hw.hfcD.addr | 1, reg);
+ }
+ if (data)
+ byteout(cs->hw.hfcD.addr, value);
+#if HFC_REG_DEBUG
+ if (cs->debug & L1_DEB_HSCX_FIFO && (data != HFCD_DATA_NODEB)) {
+ char tmp[16];
+ sprintf(tmp, "t3c W%c %02x %02x", data ? 'D' : 'C', reg, value);
+ debugl1(cs, tmp);
+ }
+#endif
+}
+
+/* Interface functions */
+
+static u_char
+readreghfcd(struct IsdnCardState *cs, u_char offset)
+{
+ return(ReadReg(cs, HFCD_DATA, offset));
+}
+
+static void
+writereghfcd(struct IsdnCardState *cs, u_char offset, u_char value)
+{
+ WriteReg(cs, HFCD_DATA, offset, value);
+}
+
+void
+set_cs_func(struct IsdnCardState *cs)
+{
+ cs->readisac = &readreghfcd;
+ cs->writeisac = &writereghfcd;
+ cs->readisacfifo = &dummyf;
+ cs->writeisacfifo = &dummyf;
+ cs->BC_Read_Reg = &ReadReg;
+ cs->BC_Write_Reg = &WriteReg;
+}
+
+static inline int
+WaitForBusy(struct IsdnCardState *cs)
+{
+ int to = 130;
+
+ while (!(ReadReg(cs, HFCD_DATA, HFCD_STAT) & HFCD_BUSY) && to) {
+ udelay(1);
+ to--;
+ }
+ if (!to)
+ printk(KERN_WARNING "HiSax: WaitForBusy timeout\n");
+ return (to);
+}
+
+static inline int
+WaitNoBusy(struct IsdnCardState *cs)
+{
+ long flags;
+ int to = 130;
+
+ while ((ReadReg(cs, HFCD_STATUS, HFCD_STATUS) & HFCD_BUSY) && to) {
+ save_flags(flags);
+ sti();
+ udelay(1);
+ to--;
+ restore_flags(flags);
+ }
+ if (!to)
+ printk(KERN_WARNING "HiSax: WaitNoBusy timeout\n");
+ return (to);
+}
+
+static int
+SelFiFo(struct IsdnCardState *cs, u_char FiFo)
+{
+ u_char cip;
+ long flags;
+
+
+ if (cs->hw.hfcD.fifo == FiFo)
+ return(1);
+ save_flags(flags);
+ cli();
+ switch(FiFo) {
+ case 0: cip = HFCB_FIFO | HFCB_Z1 | HFCB_SEND | HFCB_B1;
+ break;
+ case 1: cip = HFCB_FIFO | HFCB_Z1 | HFCB_REC | HFCB_B1;
+ break;
+ case 2: cip = HFCB_FIFO | HFCB_Z1 | HFCB_SEND | HFCB_B2;
+ break;
+ case 3: cip = HFCB_FIFO | HFCB_Z1 | HFCB_REC | HFCB_B2;
+ break;
+ case 4: cip = HFCD_FIFO | HFCD_Z1 | HFCD_SEND;
+ break;
+ case 5: cip = HFCD_FIFO | HFCD_Z1 | HFCD_REC;
+ break;
+ default:
+ restore_flags(flags);
+ debugl1(cs, "SelFiFo Error");
+ return(0);
+ }
+ cs->hw.hfcD.fifo = FiFo;
+ WaitNoBusy(cs);
+ cs->BC_Write_Reg(cs, HFCD_DATA, cip, 0);
+ sti();
+ WaitForBusy(cs);
+ restore_flags(flags);
+ return(2);
+}
+static int
+GetFreeFifoBytes_B(struct BCState *bcs)
+{
+ int s;
+
+ if (bcs->hw.hfc.f1 == bcs->hw.hfc.f2)
+ return (bcs->cs->hw.hfcD.bfifosize);
+ s = bcs->hw.hfc.send[bcs->hw.hfc.f1] - bcs->hw.hfc.send[bcs->hw.hfc.f2];
+ if (s <= 0)
+ s += bcs->cs->hw.hfcD.bfifosize;
+ s = bcs->cs->hw.hfcD.bfifosize - s;
+ return (s);
+}
+
+static int
+GetFreeFifoBytes_D(struct IsdnCardState *cs)
+{
+ int s;
+
+ if (cs->hw.hfcD.f1 == cs->hw.hfcD.f2)
+ return (cs->hw.hfcD.dfifosize);
+ s = cs->hw.hfcD.send[cs->hw.hfcD.f1] - cs->hw.hfcD.send[cs->hw.hfcD.f2];
+ if (s <= 0)
+ s += cs->hw.hfcD.dfifosize;
+ s = cs->hw.hfcD.dfifosize - s;
+ return (s);
+}
+
+static int
+ReadZReg(struct IsdnCardState *cs, u_char reg)
+{
+ int val;
+
+ WaitNoBusy(cs);
+ val = 256 * ReadReg(cs, HFCD_DATA, reg | HFCB_Z_HIGH);
+ WaitNoBusy(cs);
+ val += ReadReg(cs, HFCD_DATA, reg | HFCB_Z_LOW);
+ return (val);
+}
+
+static void
+hfc_sched_event(struct BCState *bcs, int event)
+{
+ bcs->event |= 1 << event;
+ queue_task(&bcs->tqueue, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+}
+
+static struct sk_buff
+*hfc_empty_fifo(struct BCState *bcs, int count)
+{
+ u_char *ptr;
+ struct sk_buff *skb;
+ struct IsdnCardState *cs = bcs->cs;
+ int idx;
+ int chksum;
+ long flags;
+ u_char stat, cip;
+ char tmp[64];
+
+ if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
+ debugl1(cs, "hfc_empty_fifo");
+ idx = 0;
+ save_flags(flags);
+ if (count > HSCX_BUFMAX + 3) {
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "hfc_empty_fifo: incoming packet too large");
+ cip = HFCB_FIFO | HFCB_FIFO_OUT | HFCB_REC | HFCB_CHANNEL(bcs->channel);
+ while (idx++ < count) {
+ cli();
+ WaitNoBusy(cs);
+ ReadReg(cs, HFCD_DATA_NODEB, cip);
+ sti();
+ }
+ skb = NULL;
+ } else if (count < 4) {
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "hfc_empty_fifo: incoming packet too small");
+ cip = HFCB_FIFO | HFCB_FIFO_OUT | HFCB_REC | HFCB_CHANNEL(bcs->channel);
+ cli();
+ while ((idx++ < count) && WaitNoBusy(cs))
+ ReadReg(cs, HFCD_DATA_NODEB, cip);
+ skb = NULL;
+ } else if (!(skb = dev_alloc_skb(count - 3)))
+ printk(KERN_WARNING "HFC: receive out of memory\n");
+ else {
+ ptr = skb_put(skb, count - 3);
+ idx = 0;
+ cip = HFCB_FIFO | HFCB_FIFO_OUT | HFCB_REC | HFCB_CHANNEL(bcs->channel);
+ cli();
+ while (idx < (count - 3)) {
+ cli();
+ if (!WaitNoBusy(cs))
+ break;
+ *ptr = ReadReg(cs, HFCD_DATA_NODEB, cip);
+ sti();
+ ptr++;
+ idx++;
+ }
+ if (idx != count - 3) {
+ sti();
+ debugl1(cs, "RFIFO BUSY error");
+ printk(KERN_WARNING "HFC FIFO channel %d BUSY Error\n", bcs->channel);
+ dev_kfree_skb(skb);
+ skb = NULL;
+ } else {
+ cli();
+ WaitNoBusy(cs);
+ chksum = (ReadReg(cs, HFCD_DATA, cip) << 8);
+ WaitNoBusy(cs);
+ chksum += ReadReg(cs, HFCD_DATA, cip);
+ WaitNoBusy(cs);
+ stat = ReadReg(cs, HFCD_DATA, cip);
+ sti();
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "hfc_empty_fifo %d chksum %x stat %x",
+ bcs->channel, chksum, stat);
+ debugl1(cs, tmp);
+ }
+ if (stat) {
+ debugl1(cs, "FIFO CRC error");
+ dev_kfree_skb(skb);
+ skb = NULL;
+ }
+ }
+ }
+ sti();
+ WaitForBusy(cs);
+ cli();
+ WaitNoBusy(cs);
+ stat = ReadReg(cs, HFCD_DATA, HFCB_FIFO | HFCB_F2_INC |
+ HFCB_REC | HFCB_CHANNEL(bcs->channel));
+ sti();
+ WaitForBusy(cs);
+ restore_flags(flags);
+ return (skb);
+}
+
+static void
+hfc_fill_fifo(struct BCState *bcs)
+{
+ struct IsdnCardState *cs = bcs->cs;
+ long flags;
+ int idx, fcnt;
+ int count;
+ u_char cip;
+ char tmp[64];
+
+
+ if (!bcs->hw.hfc.tx_skb)
+ return;
+ if (bcs->hw.hfc.tx_skb->len <= 0)
+ return;
+
+ save_flags(flags);
+ cli();
+ SelFiFo(cs, HFCB_SEND | HFCB_CHANNEL(bcs->channel));
+ cip = HFCB_FIFO | HFCB_F1 | HFCB_SEND | HFCB_CHANNEL(bcs->channel);
+ WaitNoBusy(cs);
+ bcs->hw.hfc.f1 = ReadReg(cs, HFCD_DATA, cip);
+ WaitNoBusy(cs);
+ cip = HFCB_FIFO | HFCB_F2 | HFCB_SEND | HFCB_CHANNEL(bcs->channel);
+ WaitNoBusy(cs);
+ bcs->hw.hfc.f2 = ReadReg(cs, HFCD_DATA, cip);
+ bcs->hw.hfc.send[bcs->hw.hfc.f1] = ReadZReg(cs, HFCB_FIFO | HFCB_Z1 | HFCB_SEND | HFCB_CHANNEL(bcs->channel));
+ sti();
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "hfc_fill_fifo %d f1(%d) f2(%d) z1(%x)",
+ bcs->channel, bcs->hw.hfc.f1, bcs->hw.hfc.f2,
+ bcs->hw.hfc.send[bcs->hw.hfc.f1]);
+ debugl1(cs, tmp);
+ }
+ fcnt = bcs->hw.hfc.f1 - bcs->hw.hfc.f2;
+ if (fcnt < 0)
+ fcnt += 32;
+ if (fcnt > 30) {
+ if (cs->debug & L1_DEB_HSCX)
+ debugl1(cs, "hfc_fill_fifo more as 30 frames");
+ restore_flags(flags);
+ return;
+ }
+ count = GetFreeFifoBytes_B(bcs);
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "hfc_fill_fifo %d count(%d/%d),%lx",
+ bcs->channel, bcs->hw.hfc.tx_skb->len,
+ count, current->state);
+ debugl1(cs, tmp);
+ }
+ if (count < bcs->hw.hfc.tx_skb->len) {
+ if (cs->debug & L1_DEB_HSCX)
+ debugl1(cs, "hfc_fill_fifo no fifo mem");
+ restore_flags(flags);
+ return;
+ }
+ cip = HFCB_FIFO | HFCB_FIFO_IN | HFCB_SEND | HFCB_CHANNEL(bcs->channel);
+ idx = 0;
+ cli();
+ WaitForBusy(cs);
+ WaitNoBusy(cs);
+ WriteReg(cs, HFCD_DATA_NODEB, cip, bcs->hw.hfc.tx_skb->data[idx++]);
+ while (idx < bcs->hw.hfc.tx_skb->len) {
+ cli();
+ if (!WaitNoBusy(cs))
+ break;
+ WriteReg(cs, HFCD_DATA_NODEB, cip, bcs->hw.hfc.tx_skb->data[idx]);
+ sti();
+ idx++;
+ }
+ if (idx != bcs->hw.hfc.tx_skb->len) {
+ sti();
+ debugl1(cs, "FIFO Send BUSY error");
+ printk(KERN_WARNING "HFC S FIFO channel %d BUSY Error\n", bcs->channel);
+ } else {
+ bcs->tx_cnt -= bcs->hw.hfc.tx_skb->len;
+ if (bcs->st->lli.l1writewakeup &&
+ (PACKET_NOACK != bcs->hw.hfc.tx_skb->pkt_type))
+ bcs->st->lli.l1writewakeup(bcs->st, bcs->hw.hfc.tx_skb->len);
+ dev_kfree_skb(bcs->hw.hfc.tx_skb);
+ bcs->hw.hfc.tx_skb = NULL;
+ }
+ WaitForBusy(cs);
+ cli();
+ WaitNoBusy(cs);
+ ReadReg(cs, HFCD_DATA, HFCB_FIFO | HFCB_F1_INC | HFCB_SEND | HFCB_CHANNEL(bcs->channel));
+ sti();
+ WaitForBusy(cs);
+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
+ restore_flags(flags);
+ return;
+}
+
+static void
+hfc_send_data(struct BCState *bcs)
+{
+ struct IsdnCardState *cs = bcs->cs;
+ char tmp[32];
+
+ if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
+ hfc_fill_fifo(bcs);
+ test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
+ } else {
+ sprintf(tmp,"send_data %d blocked", bcs->channel);
+ debugl1(cs, tmp);
+ }
+}
+
+void
+main_rec_2bds0(struct BCState *bcs)
+{
+ long flags;
+ struct IsdnCardState *cs = bcs->cs;
+ int z1, z2, rcnt;
+ u_char f1, f2, cip;
+ int receive, count = 5;
+ struct sk_buff *skb;
+ char tmp[64];
+
+ save_flags(flags);
+ Begin:
+ count--;
+ cli();
+ if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
+ sprintf(tmp,"rec_data %d blocked", bcs->channel);
+ debugl1(cs, tmp);
+ restore_flags(flags);
+ return;
+ }
+ SelFiFo(cs, HFCB_REC | HFCB_CHANNEL(bcs->channel));
+ cip = HFCB_FIFO | HFCB_F1 | HFCB_REC | HFCB_CHANNEL(bcs->channel);
+ WaitNoBusy(cs);
+ f1 = ReadReg(cs, HFCD_DATA, cip);
+ cip = HFCB_FIFO | HFCB_F2 | HFCB_REC | HFCB_CHANNEL(bcs->channel);
+ WaitNoBusy(cs);
+ f2 = ReadReg(cs, HFCD_DATA, cip);
+ sti();
+ if (f1 != f2) {
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "hfc rec %d f1(%d) f2(%d)",
+ bcs->channel, f1, f2);
+ debugl1(cs, tmp);
+ }
+ cli();
+ z1 = ReadZReg(cs, HFCB_FIFO | HFCB_Z1 | HFCB_REC | HFCB_CHANNEL(bcs->channel));
+ z2 = ReadZReg(cs, HFCB_FIFO | HFCB_Z2 | HFCB_REC | HFCB_CHANNEL(bcs->channel));
+ sti();
+ rcnt = z1 - z2;
+ if (rcnt < 0)
+ rcnt += cs->hw.hfcD.bfifosize;
+ rcnt++;
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "hfc rec %d z1(%x) z2(%x) cnt(%d)",
+ bcs->channel, z1, z2, rcnt);
+ debugl1(cs, tmp);
+ }
+ if ((skb = hfc_empty_fifo(bcs, rcnt))) {
+ cli();
+ skb_queue_tail(&bcs->rqueue, skb);
+ sti();
+ hfc_sched_event(bcs, B_RCVBUFREADY);
+ }
+ rcnt = f1 -f2;
+ if (rcnt<0)
+ rcnt += 32;
+ if (rcnt>1)
+ receive = 1;
+ else
+ receive = 0;
+ } else
+ receive = 0;
+ test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
+ if (count && receive)
+ goto Begin;
+ restore_flags(flags);
+ return;
+}
+
+void
+mode_2bs0(struct BCState *bcs, int mode, int bc)
+{
+ struct IsdnCardState *cs = bcs->cs;
+
+ if (cs->debug & L1_DEB_HSCX) {
+ char tmp[40];
+ sprintf(tmp, "HFCD bchannel mode %d bchan %d/%d",
+ mode, bc, bcs->channel);
+ debugl1(cs, tmp);
+ }
+ bcs->mode = mode;
+ bcs->channel = bc;
+ switch (mode) {
+ case (L1_MODE_NULL):
+ if (bc) {
+ cs->hw.hfcD.conn |= 0x18;
+ cs->hw.hfcD.sctrl &= ~SCTRL_B2_ENA;
+ } else {
+ cs->hw.hfcD.conn |= 0x3;
+ cs->hw.hfcD.sctrl &= ~SCTRL_B1_ENA;
+ }
+ break;
+ case (L1_MODE_TRANS):
+ if (bc) {
+ cs->hw.hfcD.ctmt |= 2;
+ cs->hw.hfcD.conn &= ~0x18;
+ cs->hw.hfcD.sctrl |= SCTRL_B2_ENA;
+ } else {
+ cs->hw.hfcD.ctmt |= 1;
+ cs->hw.hfcD.conn &= ~0x3;
+ cs->hw.hfcD.sctrl |= SCTRL_B1_ENA;
+ }
+ break;
+ case (L1_MODE_HDLC):
+ if (bc) {
+ cs->hw.hfcD.ctmt &= ~2;
+ cs->hw.hfcD.conn &= ~0x18;
+ cs->hw.hfcD.sctrl |= SCTRL_B2_ENA;
+ } else {
+ cs->hw.hfcD.ctmt &= ~1;
+ cs->hw.hfcD.conn &= ~0x3;
+ cs->hw.hfcD.sctrl |= SCTRL_B1_ENA;
+ }
+ break;
+ }
+ WriteReg(cs, HFCD_DATA, HFCD_SCTRL, cs->hw.hfcD.sctrl);
+ WriteReg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt);
+ WriteReg(cs, HFCD_DATA, HFCD_CONN, cs->hw.hfcD.conn);
+}
+
+static void
+hfc_l2l1(struct PStack *st, int pr, void *arg)
+{
+ struct sk_buff *skb = arg;
+ long flags;
+
+ switch (pr) {
+ case (PH_DATA_REQ):
+ save_flags(flags);
+ cli();
+ if (st->l1.bcs->hw.hfc.tx_skb) {
+ skb_queue_tail(&st->l1.bcs->squeue, skb);
+ restore_flags(flags);
+ } else {
+ st->l1.bcs->hw.hfc.tx_skb = skb;
+/* test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
+*/ st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
+ restore_flags(flags);
+ }
+ break;
+ case (PH_PULL_IND):
+ if (st->l1.bcs->hw.hfc.tx_skb) {
+ printk(KERN_WARNING "hfc_l2l1: this shouldn't happen\n");
+ break;
+ }
+ save_flags(flags);
+ cli();
+/* test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
+*/ st->l1.bcs->hw.hfc.tx_skb = skb;
+ st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
+ restore_flags(flags);
+ break;
+ case (PH_PULL_REQ):
+ if (!st->l1.bcs->hw.hfc.tx_skb) {
+ test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
+ st->l1.l1l2(st, PH_PULL_CNF, NULL);
+ } else
+ test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
+ break;
+ }
+}
+
+void
+close_2bs0(struct BCState *bcs)
+{
+ struct sk_buff *skb;
+
+ mode_2bs0(bcs, 0, 0);
+ if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
+ while ((skb = skb_dequeue(&bcs->rqueue))) {
+ dev_kfree_skb(skb);
+ }
+ while ((skb = skb_dequeue(&bcs->squeue))) {
+ dev_kfree_skb(skb);
+ }
+ if (bcs->hw.hfc.tx_skb) {
+ dev_kfree_skb(bcs->hw.hfc.tx_skb);
+ bcs->hw.hfc.tx_skb = NULL;
+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
+ }
+ }
+}
+
+static int
+open_hfcstate(struct IsdnCardState *cs,
+ int bc)
+{
+ struct BCState *bcs = cs->bcs + bc;
+
+ if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) {
+ skb_queue_head_init(&bcs->rqueue);
+ skb_queue_head_init(&bcs->squeue);
+ }
+ bcs->hw.hfc.tx_skb = NULL;
+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
+ bcs->event = 0;
+ bcs->tx_cnt = 0;
+ return (0);
+}
+
+static void
+hfc_manl1(struct PStack *st, int pr,
+ void *arg)
+{
+ switch (pr) {
+ case (PH_ACTIVATE_REQ):
+ test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
+ mode_2bs0(st->l1.bcs, st->l1.mode, st->l1.bc);
+ st->l1.l1man(st, PH_ACTIVATE_CNF, NULL);
+ break;
+ case (PH_DEACTIVATE_REQ):
+ if (!test_bit(BC_FLG_BUSY, &st->l1.bcs->Flag))
+ mode_2bs0(st->l1.bcs, 0, 0);
+ test_and_clear_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
+ break;
+ }
+}
+
+int
+setstack_2b(struct PStack *st, struct BCState *bcs)
+{
+ if (open_hfcstate(st->l1.hardware, bcs->channel))
+ return (-1);
+ st->l1.bcs = bcs;
+ st->l2.l2l1 = hfc_l2l1;
+ st->ma.manl1 = hfc_manl1;
+ setstack_manager(st);
+ bcs->st = st;
+ return (0);
+}
+
+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
+hfcd_bh(struct IsdnCardState *cs)
+{
+/* struct PStack *stptr;
+*/
+ if (!cs)
+ return;
+#if 0
+ 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 = stptr->next;
+ }
+ }
+#endif
+ if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) {
+ switch (cs->ph_state) {
+ case (0):
+ manl1_msg(cs, PH_RESET_IND, NULL);
+ break;
+ case (3):
+ manl1_msg(cs, PH_DEACT_IND, NULL);
+ break;
+ case (8):
+ manl1_msg(cs, PH_RSYNC_IND, NULL);
+ break;
+ case (6):
+ manl1_msg(cs, PH_INFO2_IND, NULL);
+ break;
+ case (7):
+ manl1_msg(cs, PH_I4_P8_IND, NULL);
+ break;
+ default:
+ break;
+ }
+ }
+ if (test_and_clear_bit(D_RCVBUFREADY, &cs->event))
+ DChannel_proc_rcv(cs);
+ if (test_and_clear_bit(D_XMTBUFREADY, &cs->event))
+ DChannel_proc_xmt(cs);
+}
+
+void
+sched_event_D(struct IsdnCardState *cs, int event)
+{
+ test_and_set_bit(event, &cs->event);
+ queue_task(&cs->tqueue, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+}
+
+static
+int receive_dmsg(struct IsdnCardState *cs)
+{
+ struct sk_buff *skb;
+ long flags;
+ int idx;
+ int rcnt, z1, z2;
+ u_char stat, cip, f1, f2;
+ int chksum;
+ int count=5;
+ u_char *ptr;
+ char tmp[64];
+
+ save_flags(flags);
+ cli();
+ if (test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
+ debugl1(cs, "rec_dmsg blocked");
+ restore_flags(flags);
+ return(1);
+ }
+ SelFiFo(cs, 4 | HFCD_REC);
+ cip = HFCD_FIFO | HFCD_F1 | HFCD_REC;
+ WaitNoBusy(cs);
+ f1 = cs->readisac(cs, cip) & 0xf;
+ cip = HFCD_FIFO | HFCD_F2 | HFCD_REC;
+ WaitNoBusy(cs);
+ f2 = cs->readisac(cs, cip) & 0xf;
+ while ((f1 != f2) && count--) {
+ z1 = ReadZReg(cs, HFCD_FIFO | HFCD_Z1 | HFCD_REC);
+ z2 = ReadZReg(cs, HFCD_FIFO | HFCD_Z2 | HFCD_REC);
+ rcnt = z1 - z2;
+ if (rcnt < 0)
+ rcnt += cs->hw.hfcD.dfifosize;
+ rcnt++;
+ if (cs->debug & L1_DEB_ISAC) {
+ sprintf(tmp, "hfcd recd f1(%d) f2(%d) z1(%x) z2(%x) cnt(%d)",
+ f1, f2, z1, z2, rcnt);
+ debugl1(cs, tmp);
+ }
+ sti();
+ idx = 0;
+ cip = HFCD_FIFO | HFCD_FIFO_OUT | HFCD_REC;
+ if (rcnt > MAX_DFRAME_LEN + 3) {
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "empty_fifo d: incoming packet too large");
+ while (idx < rcnt) {
+ cli();
+ if (!(WaitNoBusy(cs)))
+ break;
+ ReadReg(cs, HFCD_DATA_NODEB, cip);
+ sti();
+ idx++;
+ }
+ } else if (rcnt < 4) {
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "empty_fifo d: incoming packet too small");
+ cli();
+ while ((idx++ < rcnt) && WaitNoBusy(cs))
+ ReadReg(cs, HFCD_DATA_NODEB, cip);
+ } else if ((skb = dev_alloc_skb(rcnt - 3))) {
+ ptr = skb_put(skb, rcnt - 3);
+ while (idx < (rcnt - 3)) {
+ cli();
+ if (!(WaitNoBusy(cs)))
+ break;
+ *ptr = ReadReg(cs, HFCD_DATA_NODEB, cip);
+ sti();
+ idx++;
+ ptr++;
+ }
+ if (idx != (rcnt - 3)) {
+ sti();
+ debugl1(cs, "RFIFO D BUSY error");
+ printk(KERN_WARNING "HFC DFIFO channel BUSY Error\n");
+ dev_kfree_skb(skb);
+ skb = NULL;
+ } else {
+ cli();
+ WaitNoBusy(cs);
+ chksum = (ReadReg(cs, HFCD_DATA, cip) << 8);
+ WaitNoBusy(cs);
+ chksum += ReadReg(cs, HFCD_DATA, cip);
+ WaitNoBusy(cs);
+ stat = ReadReg(cs, HFCD_DATA, cip);
+ sti();
+ if (cs->debug & L1_DEB_ISAC) {
+ sprintf(tmp, "empty_dfifo chksum %x stat %x",
+ chksum, stat);
+ debugl1(cs, tmp);
+ }
+ if (stat) {
+ debugl1(cs, "FIFO CRC error");
+ dev_kfree_skb(skb);
+ skb = NULL;
+ } else {
+ skb_queue_tail(&cs->rq, skb);
+ sched_event_D(cs, D_RCVBUFREADY);
+ }
+ }
+ } else
+ printk(KERN_WARNING "HFC: D receive out of memory\n");
+ sti();
+ WaitForBusy(cs);
+ cip = HFCD_FIFO | HFCD_F2_INC | HFCD_REC;
+ cli();
+ WaitNoBusy(cs);
+ stat = ReadReg(cs, HFCD_DATA, cip);
+ sti();
+ WaitForBusy(cs);
+ cip = HFCD_FIFO | HFCD_F2 | HFCD_REC;
+ cli();
+ WaitNoBusy(cs);
+ f2 = cs->readisac(cs, cip) & 0xf;
+ }
+ test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
+ restore_flags(flags);
+ return(1);
+}
+
+static void
+hfc_fill_dfifo(struct IsdnCardState *cs)
+{
+ long flags;
+ int idx, fcnt;
+ int count;
+ u_char cip;
+ char tmp[64];
+
+ if (!cs->tx_skb)
+ return;
+ if (cs->tx_skb->len <= 0)
+ return;
+
+ save_flags(flags);
+ cli();
+ SelFiFo(cs, 4 | HFCD_SEND);
+ cip = HFCD_FIFO | HFCD_F1 | HFCD_SEND;
+ WaitNoBusy(cs);
+ cs->hw.hfcD.f1 = ReadReg(cs, HFCD_DATA, cip) & 0xf;
+ WaitNoBusy(cs);
+ cip = HFCD_FIFO | HFCD_F2 | HFCD_SEND;
+ cs->hw.hfcD.f2 = ReadReg(cs, HFCD_DATA, cip) & 0xf;
+ cs->hw.hfcD.send[cs->hw.hfcD.f1] = ReadZReg(cs, HFCD_FIFO | HFCD_Z1 | HFCD_SEND);
+ sti();
+ if (cs->debug & L1_DEB_ISAC) {
+ sprintf(tmp, "hfc_fill_Dfifo f1(%d) f2(%d) z1(%x)",
+ cs->hw.hfcD.f1, cs->hw.hfcD.f2,
+ cs->hw.hfcD.send[cs->hw.hfcD.f1]);
+ debugl1(cs, tmp);
+ }
+ fcnt = cs->hw.hfcD.f1 - cs->hw.hfcD.f2;
+ if (fcnt < 0)
+ fcnt += 16;
+ if (fcnt > 14) {
+ if (cs->debug & L1_DEB_HSCX)
+ debugl1(cs, "hfc_fill_Dfifo more as 14 frames");
+ restore_flags(flags);
+ return;
+ }
+ count = GetFreeFifoBytes_D(cs);
+ if (cs->debug & L1_DEB_ISAC) {
+ sprintf(tmp, "hfc_fill_Dfifo count(%d/%d)",
+ cs->tx_skb->len, count);
+ debugl1(cs, tmp);
+ }
+ if (count < cs->tx_skb->len) {
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "hfc_fill_Dfifo no fifo mem");
+ restore_flags(flags);
+ return;
+ }
+ cip = HFCD_FIFO | HFCD_FIFO_IN | HFCD_SEND;
+ idx = 0;
+ cli();
+ WaitForBusy(cs);
+ WaitNoBusy(cs);
+ WriteReg(cs, HFCD_DATA_NODEB, cip, cs->tx_skb->data[idx++]);
+ while (idx < cs->tx_skb->len) {
+ cli();
+ if (!(WaitNoBusy(cs)))
+ break;
+ WriteReg(cs, HFCD_DATA_NODEB, cip, cs->tx_skb->data[idx]);
+ sti();
+ idx++;
+ }
+ if (idx != cs->tx_skb->len) {
+ sti();
+ debugl1(cs, "DFIFO Send BUSY error");
+ printk(KERN_WARNING "HFC S DFIFO channel BUSY Error\n");
+ }
+ WaitForBusy(cs);
+ cli();
+ WaitNoBusy(cs);
+ ReadReg(cs, HFCD_DATA, HFCD_FIFO | HFCD_F1_INC | HFCD_SEND);
+ dev_kfree_skb(cs->tx_skb);
+ cs->tx_skb = NULL;
+ sti();
+ WaitForBusy(cs);
+ restore_flags(flags);
+ return;
+}
+
+static
+struct BCState *Sel_BCS(struct IsdnCardState *cs, int channel)
+{
+ if (cs->bcs[0].mode && (cs->bcs[0].channel == channel))
+ return(&cs->bcs[0]);
+ else if (cs->bcs[1].mode && (cs->bcs[1].channel == channel))
+ return(&cs->bcs[1]);
+ else
+ return(NULL);
+}
+
+void
+hfc2bds0_interrupt(struct IsdnCardState *cs, u_char val)
+{
+ u_char exval;
+ struct BCState *bcs;
+ char tmp[32];
+ int count=15;
+ long flags;
+
+ if (cs->debug & L1_DEB_ISAC) {
+ sprintf(tmp, "HFCD irq %x %s", val,
+ test_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags) ?
+ "locked" : "unlocked");
+ debugl1(cs, tmp);
+ }
+ val &= cs->hw.hfcD.int_m1;
+ if (val & 0x40) { /* TE state machine irq */
+ exval = cs->readisac(cs, HFCD_STATES) & 0xf;
+ if (cs->debug & L1_DEB_ISAC) {
+ sprintf(tmp, "ph_state chg %d->%d", cs->ph_state,
+ exval);
+ debugl1(cs, tmp);
+ }
+ cs->ph_state = exval;
+ sched_event_D(cs, D_L1STATECHANGE);
+ val &= ~0x40;
+ }
+ while (val) {
+ save_flags(flags);
+ cli();
+ if (test_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
+ cs->hw.hfcD.int_s1 |= val;
+ restore_flags(flags);
+ return;
+ }
+ if (cs->hw.hfcD.int_s1 & 0x18) {
+ exval = val;
+ val = cs->hw.hfcD.int_s1;
+ cs->hw.hfcD.int_s1 = exval;
+ }
+ if (val & 0x08) {
+ if (!(bcs=Sel_BCS(cs, 0))) {
+ if (cs->debug)
+ debugl1(cs, "hfcd spurious 0x08 IRQ");
+ } else
+ main_rec_2bds0(bcs);
+ }
+ if (val & 0x10) {
+ if (!(bcs=Sel_BCS(cs, 1))) {
+ if (cs->debug)
+ debugl1(cs, "hfcd spurious 0x10 IRQ");
+ } else
+ main_rec_2bds0(bcs);
+ }
+ if (val & 0x01) {
+ if (!(bcs=Sel_BCS(cs, 0))) {
+ if (cs->debug)
+ debugl1(cs, "hfcd spurious 0x01 IRQ");
+ } else {
+ if (bcs->hw.hfc.tx_skb) {
+ if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
+ hfc_fill_fifo(bcs);
+ test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
+ } else {
+ sprintf(tmp,"fill_data %d blocked", bcs->channel);
+ debugl1(cs, tmp);
+ }
+ } else {
+ if ((bcs->hw.hfc.tx_skb = skb_dequeue(&bcs->squeue))) {
+ if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
+ hfc_fill_fifo(bcs);
+ test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
+ } else {
+ sprintf(tmp,"fill_data %d blocked", bcs->channel);
+ debugl1(cs, tmp);
+ }
+ } else {
+ hfc_sched_event(bcs, B_XMTBUFREADY);
+ }
+ }
+ }
+ }
+ if (val & 0x02) {
+ if (!(bcs=Sel_BCS(cs, 1))) {
+ if (cs->debug)
+ debugl1(cs, "hfcd spurious 0x02 IRQ");
+ } else {
+ if (bcs->hw.hfc.tx_skb) {
+ if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
+ hfc_fill_fifo(bcs);
+ test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
+ } else {
+ sprintf(tmp,"fill_data %d blocked", bcs->channel);
+ debugl1(cs, tmp);
+ }
+ } else {
+ if ((bcs->hw.hfc.tx_skb = skb_dequeue(&bcs->squeue))) {
+ if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
+ hfc_fill_fifo(bcs);
+ test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
+ } else {
+ sprintf(tmp,"fill_data %d blocked", bcs->channel);
+ debugl1(cs, tmp);
+ }
+ } else {
+ hfc_sched_event(bcs, B_XMTBUFREADY);
+ }
+ }
+ }
+ }
+ if (val & 0x20) { /* receive dframe */
+ receive_dmsg(cs);
+ }
+ if (val & 0x04) { /* dframe transmitted */
+ 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))
+ sched_event_D(cs, D_CLEARBUSY);
+ if (cs->tx_skb)
+ if (cs->tx_skb->len) {
+ if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
+ hfc_fill_dfifo(cs);
+ test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
+ } else {
+ debugl1(cs, "hfc_fill_dfifo irq blocked");
+ }
+ goto afterXPR;
+ } else {
+ dev_kfree_skb(cs->tx_skb);
+ cs->tx_cnt = 0;
+ cs->tx_skb = NULL;
+ }
+ if ((cs->tx_skb = skb_dequeue(&cs->sq))) {
+ cs->tx_cnt = 0;
+ if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
+ hfc_fill_dfifo(cs);
+ test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
+ } else {
+ debugl1(cs, "hfc_fill_dfifo irq blocked");
+ }
+ } else
+ sched_event_D(cs, D_XMTBUFREADY);
+ }
+ afterXPR:
+ if (cs->hw.hfcD.int_s1 && count--) {
+ val = cs->hw.hfcD.int_s1;
+ cs->hw.hfcD.int_s1 = 0;
+ if (cs->debug & L1_DEB_ISAC) {
+ sprintf(tmp, "HFCD irq %x loop %d", val, 15-count);
+ debugl1(cs, tmp);
+ }
+ } else
+ val = 0;
+ restore_flags(flags);
+ }
+}
+
+static void
+HFCD_l2l1(struct PStack *st, int pr, void *arg)
+{
+ struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware;
+ struct sk_buff *skb = arg;
+ char str[64];
+ switch (pr) {
+ case (PH_DATA_REQ):
+ if (cs->tx_skb) {
+ skb_queue_tail(&cs->sq, skb);
+#ifdef L2FRAME_DEBUG /* psa */
+ if (cs->debug & L1_DEB_LAPD)
+ 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 */
+ if (cs->debug & L1_DEB_LAPD)
+ Logl2Frame(cs, skb, "PH_DATA", 0);
+#endif
+ if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
+ hfc_fill_dfifo(cs);
+ test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
+ } else
+ debugl1(cs, "hfc_fill_dfifo blocked");
+
+ }
+ break;
+ case (PH_PULL_IND):
+ 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 */
+ 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 */
+ if (cs->debug & L1_DEB_LAPD)
+ Logl2Frame(cs, skb, "PH_DATA_PULLED", 0);
+#endif
+ if (!test_and_set_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags)) {
+ hfc_fill_dfifo(cs);
+ test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
+ } else
+ debugl1(cs, "hfc_fill_dfifo blocked");
+ break;
+ case (PH_PULL_REQ):
+#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);
+ } else
+ test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
+ break;
+ }
+}
+
+void
+hfcd_l1cmd(struct IsdnCardState *cs, int msg, void *arg)
+{
+ char tmp[32];
+ switch(msg) {
+ case PH_RESET_REQ:
+ cs->writeisac(cs, HFCD_STATES, HFCD_LOAD_STATE | 3); /* HFC ST 3 */
+ udelay(6);
+ cs->writeisac(cs, HFCD_STATES, 3); /* HFC ST 2 */
+ cs->hw.hfcD.mst_m |= HFCD_MASTER;
+ cs->writeisac(cs, HFCD_MST_MODE, cs->hw.hfcD.mst_m);
+ cs->writeisac(cs, HFCD_STATES, HFCD_ACTIVATE | HFCD_DO_ACTION);
+ manl1_msg(cs, PH_POWERUP_CNF, NULL);
+ break;
+ case PH_ENABLE_REQ:
+ cs->writeisac(cs, HFCD_STATES, HFCD_ACTIVATE | HFCD_DO_ACTION);
+ break;
+ case PH_DEACT_ACK:
+ cs->hw.hfcD.mst_m &= ~HFCD_MASTER;
+ cs->writeisac(cs, HFCD_MST_MODE, cs->hw.hfcD.mst_m);
+ break;
+ case PH_INFO3_REQ:
+ cs->hw.hfcD.mst_m |= HFCD_MASTER;
+ cs->writeisac(cs, HFCD_MST_MODE, cs->hw.hfcD.mst_m);
+ break;
+#if 0
+ case PH_TESTLOOP_REQ:
+ u_char val = 0;
+ if (1 & (int) arg)
+ val |= 0x0c;
+ if (2 & (int) arg)
+ val |= 0x3;
+ if (test_bit(HW_IOM1, &cs->HW_Flags)) {
+ /* IOM 1 Mode */
+ if (!val) {
+ cs->writeisac(cs, ISAC_SPCR, 0xa);
+ cs->writeisac(cs, ISAC_ADF1, 0x2);
+ } else {
+ cs->writeisac(cs, ISAC_SPCR, val);
+ cs->writeisac(cs, ISAC_ADF1, 0xa);
+ }
+ } else {
+ /* IOM 2 Mode */
+ cs->writeisac(cs, ISAC_SPCR, val);
+ if (val)
+ cs->writeisac(cs, ISAC_ADF1, 0x8);
+ else
+ cs->writeisac(cs, ISAC_ADF1, 0x0);
+ }
+ break;
+#endif
+ default:
+ if (cs->debug & L1_DEB_WARN) {
+ sprintf(tmp, "hfcd_l1cmd unknown %4x", msg);
+ debugl1(cs, tmp);
+ }
+ break;
+ }
+}
+
+void
+setstack_hfcd(struct PStack *st, struct IsdnCardState *cs)
+{
+ st->l2.l2l1 = HFCD_l2l1;
+}
+
+static void
+hfc_dbusy_timer(struct IsdnCardState *cs)
+{
+#if 0
+ struct PStack *stptr;
+ 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;
+ }
+ }
+#endif
+}
+
+__initfunc(unsigned int
+*init_send_hfcd(int cnt))
+{
+ int i, *send;
+
+ if (!(send = kmalloc(cnt * sizeof(unsigned int), GFP_ATOMIC))) {
+ printk(KERN_WARNING
+ "HiSax: No memory for hfcd.send\n");
+ return(NULL);
+ }
+ for (i = 0; i < cnt; i++)
+ send[i] = 0x1fff;
+ return(send);
+}
+
+__initfunc(void
+init2bds0(struct IsdnCardState *cs))
+{
+ cs->setstack_d = setstack_hfcd;
+ cs->l1cmd = hfcd_l1cmd;
+ cs->dbusytimer.function = (void *) hfc_dbusy_timer;
+ cs->dbusytimer.data = (long) cs;
+ init_timer(&cs->dbusytimer);
+ cs->tqueue.routine = (void *) (void *) hfcd_bh;
+ if (!cs->hw.hfcD.send)
+ cs->hw.hfcD.send = init_send_hfcd(16);
+ if (!cs->bcs[0].hw.hfc.send)
+ cs->bcs[0].hw.hfc.send = init_send_hfcd(32);
+ if (!cs->bcs[1].hw.hfc.send)
+ cs->bcs[1].hw.hfc.send = init_send_hfcd(32);
+ cs->BC_Send_Data = &hfc_send_data;
+ cs->bcs[0].BC_SetStack = setstack_2b;
+ cs->bcs[1].BC_SetStack = setstack_2b;
+ cs->bcs[0].BC_Close = close_2bs0;
+ cs->bcs[1].BC_Close = close_2bs0;
+ mode_2bs0(cs->bcs, 0, 0);
+ mode_2bs0(cs->bcs + 1, 0, 1);
+}
+
+void
+release2bds0(struct IsdnCardState *cs)
+{
+ if (cs->bcs[0].hw.hfc.send) {
+ kfree(cs->bcs[0].hw.hfc.send);
+ cs->bcs[0].hw.hfc.send = NULL;
+ }
+ if (cs->bcs[1].hw.hfc.send) {
+ kfree(cs->bcs[1].hw.hfc.send);
+ cs->bcs[1].hw.hfc.send = NULL;
+ }
+ if (cs->hw.hfcD.send) {
+ kfree(cs->hw.hfcD.send);
+ cs->hw.hfcD.send = NULL;
+ }
+}
diff --git a/drivers/isdn/hisax/hfc_2bds0.h b/drivers/isdn/hisax/hfc_2bds0.h
new file mode 100644
index 000000000..d11e8b503
--- /dev/null
+++ b/drivers/isdn/hisax/hfc_2bds0.h
@@ -0,0 +1,131 @@
+/* $Id: hfc_2bds0.h,v 1.2 1998/02/02 13:26:15 keil Exp $
+
+ * specific defines for CCD's HFC 2BDS0
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ *
+ * $Log: hfc_2bds0.h,v $
+ * Revision 1.2 1998/02/02 13:26:15 keil
+ * New
+ *
+ *
+ *
+ */
+
+#define HFCD_CIRM 0x18
+#define HFCD_CTMT 0x19
+#define HFCD_INT_M1 0x1A
+#define HFCD_INT_M2 0x1B
+#define HFCD_INT_S1 0x1E
+#define HFCD_STAT 0x1C
+#define HFCD_STAT_DISB 0x1D
+#define HFCD_STATES 0x30
+#define HFCD_SCTRL 0x31
+#define HFCD_TEST 0x32
+#define HFCD_SQ 0x34
+#define HFCD_CLKDEL 0x37
+#define HFCD_MST_MODE 0x2E
+#define HFCD_CONN 0x2F
+
+#define HFCD_FIFO 0x80
+#define HFCD_Z1 0x10
+#define HFCD_Z2 0x18
+#define HFCD_Z_LOW 0x00
+#define HFCD_Z_HIGH 0x04
+#define HFCD_F1_INC 0x12
+#define HFCD_FIFO_IN 0x16
+#define HFCD_F1 0x1a
+#define HFCD_F2 0x1e
+#define HFCD_F2_INC 0x22
+#define HFCD_FIFO_OUT 0x26
+#define HFCD_REC 0x01
+#define HFCD_SEND 0x00
+
+#define HFCB_FIFO 0x80
+#define HFCB_Z1 0x00
+#define HFCB_Z2 0x08
+#define HFCB_Z_LOW 0x00
+#define HFCB_Z_HIGH 0x04
+#define HFCB_F1_INC 0x28
+#define HFCB_FIFO_IN 0x2c
+#define HFCB_F1 0x30
+#define HFCB_F2 0x34
+#define HFCB_F2_INC 0x38
+#define HFCB_FIFO_OUT 0x3c
+#define HFCB_REC 0x01
+#define HFCB_SEND 0x00
+#define HFCB_B1 0x00
+#define HFCB_B2 0x02
+#define HFCB_CHANNEL(ch) (ch ? HFCB_B2 : HFCB_B1)
+
+#define HFCD_STATUS 0
+#define HFCD_DATA 1
+#define HFCD_DATA_NODEB 2
+
+/* Status (READ) */
+#define HFCD_BUSY 0x01
+#define HFCD_BUSY_NBUSY 0x04
+#define HFCD_TIMER_ELAP 0x10
+#define HFCD_STATINT 0x20
+#define HFCD_FRAMEINT 0x40
+#define HFCD_ANYINT 0x80
+
+/* CTMT (Write) */
+#define HFCD_CLTIMER 0x80
+#define HFCD_TIM25 0x00
+#define HFCD_TIM50 0x08
+#define HFCD_TIM400 0x10
+#define HFCD_TIM800 0x18
+#define HFCD_AUTO_TIMER 0x20
+#define HFCD_TRANSB2 0x02
+#define HFCD_TRANSB1 0x01
+
+/* CIRM (Write) */
+#define HFCD_RESET 0x08
+#define HFCD_MEM8K 0x10
+#define HFCD_INTA 0x01
+#define HFCD_INTB 0x02
+#define HFCD_INTC 0x03
+#define HFCD_INTD 0x04
+#define HFCD_INTE 0x05
+#define HFCD_INTF 0x06
+
+/* INT_M1;INT_S1 */
+#define HFCD_INTS_B1TRANS 0x01
+#define HFCD_INTS_B2TRANS 0x02
+#define HFCD_INTS_DTRANS 0x04
+#define HFCD_INTS_B1REC 0x08
+#define HFCD_INTS_B2REC 0x10
+#define HFCD_INTS_DREC 0x20
+#define HFCD_INTS_L1STATE 0x40
+#define HFCD_INTS_TIMER 0x80
+
+/* INT_M2 */
+#define HFCD_IRQ_ENABLE 0x08
+
+/* STATES */
+#define HFCD_LOAD_STATE 0x10
+#define HFCD_ACTIVATE 0x20
+#define HFCD_DO_ACTION 0x40
+
+/* HFCD_MST_MODE */
+#define HFCD_MASTER 0x01
+
+/* HFCD_SCTRL */
+#define SCTRL_B1_ENA 0x01
+#define SCTRL_B2_ENA 0x02
+#define SCTRL_LOW_PRIO 0x08
+#define SCTRL_SQ_ENA 0x10
+#define SCTRL_TEST 0x20
+#define SCTRL_NONE_CAP 0x40
+#define SCTRL_PWR_DOWN 0x80
+
+/* HFCD_TEST */
+#define HFCD_AUTO_AWAKE 0x01
+
+extern void main_irq_2bds0(struct BCState *bcs);
+extern void init2bds0(struct IsdnCardState *cs);
+extern void release2bds0(struct IsdnCardState *cs);
+extern void hfc2bds0_interrupt(struct IsdnCardState *cs, u_char val);
+extern void set_cs_func(struct IsdnCardState *cs);
diff --git a/drivers/isdn/hisax/hfc_2bs0.c b/drivers/isdn/hisax/hfc_2bs0.c
new file mode 100644
index 000000000..2d9ce5bd5
--- /dev/null
+++ b/drivers/isdn/hisax/hfc_2bs0.c
@@ -0,0 +1,615 @@
+/* $Id: hfc_2bs0.c,v 1.4 1998/02/12 23:07:29 keil Exp $
+
+ * specific routines for CCD's HFC 2BS0
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ *
+ * $Log: hfc_2bs0.c,v $
+ * Revision 1.4 1998/02/12 23:07:29 keil
+ * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
+ *
+ * Revision 1.3 1997/11/06 17:13:35 keil
+ * New 2.1 init code
+ *
+ * Revision 1.2 1997/10/29 19:04:47 keil
+ * changes for 2.1
+ *
+ * Revision 1.1 1997/09/11 17:31:33 keil
+ * Common part for HFC 2BS0 based cards
+ *
+ *
+ */
+
+#define __NO_VERSION__
+#include "hisax.h"
+#include "hfc_2bs0.h"
+#include "isac.h"
+#include "isdnl1.h"
+#include <linux/interrupt.h>
+
+static inline int
+WaitForBusy(struct IsdnCardState *cs)
+{
+ int to = 130;
+ long flags;
+ u_char val;
+
+ save_flags(flags);
+ cli();
+ while (!(cs->BC_Read_Reg(cs, HFC_STATUS, 0) & HFC_BUSY) && to) {
+ val = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2 |
+ (cs->hw.hfc.cip & 3));
+ udelay(1);
+ to--;
+ }
+ restore_flags(flags);
+ if (!to) {
+ printk(KERN_WARNING "HiSax: waitforBusy timeout\n");
+ return (0);
+ } else
+ return (to);
+}
+
+static inline int
+WaitNoBusy(struct IsdnCardState *cs)
+{
+ int to = 125;
+
+ while ((cs->BC_Read_Reg(cs, HFC_STATUS, 0) & HFC_BUSY) && to) {
+ udelay(1);
+ to--;
+ }
+ if (!to) {
+ printk(KERN_WARNING "HiSax: waitforBusy timeout\n");
+ return (0);
+ } else
+ return (to);
+}
+
+int
+GetFreeFifoBytes(struct BCState *bcs)
+{
+ int s;
+
+ if (bcs->hw.hfc.f1 == bcs->hw.hfc.f2)
+ return (bcs->cs->hw.hfc.fifosize);
+ s = bcs->hw.hfc.send[bcs->hw.hfc.f1] - bcs->hw.hfc.send[bcs->hw.hfc.f2];
+ if (s <= 0)
+ s += bcs->cs->hw.hfc.fifosize;
+ s = bcs->cs->hw.hfc.fifosize - s;
+ return (s);
+}
+
+int
+ReadZReg(struct BCState *bcs, u_char reg)
+{
+ int val;
+
+ WaitNoBusy(bcs->cs);
+ val = 256 * bcs->cs->BC_Read_Reg(bcs->cs, HFC_DATA, reg | HFC_CIP | HFC_Z_HIGH);
+ WaitNoBusy(bcs->cs);
+ val += bcs->cs->BC_Read_Reg(bcs->cs, HFC_DATA, reg | HFC_CIP | HFC_Z_LOW);
+ return (val);
+}
+
+void
+hfc_sched_event(struct BCState *bcs, int event)
+{
+ bcs->event |= 1 << event;
+ queue_task(&bcs->tqueue, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+}
+
+static void
+hfc_clear_fifo(struct BCState *bcs)
+{
+ struct IsdnCardState *cs = bcs->cs;
+ long flags;
+ int idx, cnt;
+ int rcnt, z1, z2;
+ u_char cip, f1, f2;
+ char tmp[64];
+
+ if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
+ debugl1(cs, "hfc_clear_fifo");
+ save_flags(flags);
+ cli();
+ cip = HFC_CIP | HFC_F1 | HFC_REC | HFC_CHANNEL(bcs->channel);
+ if ((cip & 0xc3) != (cs->hw.hfc.cip & 0xc3)) {
+ cs->BC_Write_Reg(cs, HFC_STATUS, cip, cip);
+ WaitForBusy(cs);
+ }
+ WaitNoBusy(cs);
+ f1 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
+ cip = HFC_CIP | HFC_F2 | HFC_REC | HFC_CHANNEL(bcs->channel);
+ WaitNoBusy(cs);
+ f2 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
+ z1 = ReadZReg(bcs, HFC_Z1 | HFC_REC | HFC_CHANNEL(bcs->channel));
+ z2 = ReadZReg(bcs, HFC_Z2 | HFC_REC | HFC_CHANNEL(bcs->channel));
+ cnt = 32;
+ while (((f1 != f2) || (z1 != z2)) && cnt--) {
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "hfc clear %d f1(%d) f2(%d)",
+ bcs->channel, f1, f2);
+ debugl1(cs, tmp);
+ }
+ rcnt = z1 - z2;
+ if (rcnt < 0)
+ rcnt += cs->hw.hfc.fifosize;
+ if (rcnt)
+ rcnt++;
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "hfc clear %d z1(%x) z2(%x) cnt(%d)",
+ bcs->channel, z1, z2, rcnt);
+ debugl1(cs, tmp);
+ }
+ cip = HFC_CIP | HFC_FIFO_OUT | HFC_REC | HFC_CHANNEL(bcs->channel);
+ idx = 0;
+ while ((idx < rcnt) && WaitNoBusy(cs)) {
+ cs->BC_Read_Reg(cs, HFC_DATA_NODEB, cip);
+ idx++;
+ }
+ if (f1 != f2) {
+ WaitNoBusy(cs);
+ cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
+ HFC_CHANNEL(bcs->channel));
+ WaitForBusy(cs);
+ }
+ cip = HFC_CIP | HFC_F1 | HFC_REC | HFC_CHANNEL(bcs->channel);
+ WaitNoBusy(cs);
+ f1 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
+ cip = HFC_CIP | HFC_F2 | HFC_REC | HFC_CHANNEL(bcs->channel);
+ WaitNoBusy(cs);
+ f2 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
+ z1 = ReadZReg(bcs, HFC_Z1 | HFC_REC | HFC_CHANNEL(bcs->channel));
+ z2 = ReadZReg(bcs, HFC_Z2 | HFC_REC | HFC_CHANNEL(bcs->channel));
+ }
+ restore_flags(flags);
+ return;
+}
+
+
+static struct sk_buff
+*
+hfc_empty_fifo(struct BCState *bcs, int count)
+{
+ u_char *ptr;
+ struct sk_buff *skb;
+ struct IsdnCardState *cs = bcs->cs;
+ int idx;
+ int chksum;
+ u_char stat, cip;
+ char tmp[64];
+
+ if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
+ debugl1(cs, "hfc_empty_fifo");
+ idx = 0;
+ if (count > HSCX_BUFMAX + 3) {
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "hfc_empty_fifo: incoming packet too large");
+ cip = HFC_CIP | HFC_FIFO_OUT | HFC_REC | HFC_CHANNEL(bcs->channel);
+ while ((idx++ < count) && WaitNoBusy(cs))
+ cs->BC_Read_Reg(cs, HFC_DATA_NODEB, cip);
+ WaitNoBusy(cs);
+ stat = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
+ HFC_CHANNEL(bcs->channel));
+ WaitForBusy(cs);
+ return (NULL);
+ }
+ if (count < 4) {
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "hfc_empty_fifo: incoming packet too small");
+ cip = HFC_CIP | HFC_FIFO_OUT | HFC_REC | HFC_CHANNEL(bcs->channel);
+ while ((idx++ < count) && WaitNoBusy(cs))
+ cs->BC_Read_Reg(cs, HFC_DATA_NODEB, cip);
+ WaitNoBusy(cs);
+ stat = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
+ HFC_CHANNEL(bcs->channel));
+ WaitForBusy(cs);
+ return (NULL);
+ }
+ if (!(skb = dev_alloc_skb(count - 3)))
+ printk(KERN_WARNING "HFC: receive out of memory\n");
+ else {
+ ptr = skb_put(skb, count - 3);
+ idx = 0;
+ cip = HFC_CIP | HFC_FIFO_OUT | HFC_REC | HFC_CHANNEL(bcs->channel);
+ while ((idx < count - 3) && WaitNoBusy(cs)) {
+ *ptr++ = cs->BC_Read_Reg(cs, HFC_DATA_NODEB, cip);
+ idx++;
+ }
+ if (idx != count - 3) {
+ debugl1(cs, "RFIFO BUSY error");
+ printk(KERN_WARNING "HFC FIFO channel %d BUSY Error\n", bcs->channel);
+ dev_kfree_skb(skb);
+ WaitNoBusy(cs);
+ stat = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
+ HFC_CHANNEL(bcs->channel));
+ WaitForBusy(cs);
+ return (NULL);
+ }
+ WaitNoBusy(cs);
+ chksum = (cs->BC_Read_Reg(cs, HFC_DATA, cip) << 8);
+ WaitNoBusy(cs);
+ chksum += cs->BC_Read_Reg(cs, HFC_DATA, cip);
+ WaitNoBusy(cs);
+ stat = cs->BC_Read_Reg(cs, HFC_DATA, cip);
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "hfc_empty_fifo %d chksum %x stat %x",
+ bcs->channel, chksum, stat);
+ debugl1(cs, tmp);
+ }
+ if (stat) {
+ debugl1(cs, "FIFO CRC error");
+ dev_kfree_skb(skb);
+ skb = NULL;
+ }
+ WaitNoBusy(cs);
+ stat = cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F2_INC | HFC_REC |
+ HFC_CHANNEL(bcs->channel));
+ WaitForBusy(cs);
+ }
+ return (skb);
+}
+
+static void
+hfc_fill_fifo(struct BCState *bcs)
+{
+ struct IsdnCardState *cs = bcs->cs;
+ long flags;
+ int idx, fcnt;
+ int count;
+ u_char cip;
+ char tmp[64];
+
+ if (!bcs->hw.hfc.tx_skb)
+ return;
+ if (bcs->hw.hfc.tx_skb->len <= 0)
+ return;
+
+ save_flags(flags);
+ cli();
+ cip = HFC_CIP | HFC_F1 | HFC_SEND | HFC_CHANNEL(bcs->channel);
+ if ((cip & 0xc3) != (cs->hw.hfc.cip & 0xc3)) {
+ cs->BC_Write_Reg(cs, HFC_STATUS, cip, cip);
+ WaitForBusy(cs);
+ }
+ WaitNoBusy(cs);
+ bcs->hw.hfc.f1 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
+ cip = HFC_CIP | HFC_F2 | HFC_SEND | HFC_CHANNEL(bcs->channel);
+ WaitNoBusy(cs);
+ bcs->hw.hfc.f2 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
+ bcs->hw.hfc.send[bcs->hw.hfc.f1] = ReadZReg(bcs, HFC_Z1 | HFC_SEND | HFC_CHANNEL(bcs->channel));
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "hfc_fill_fifo %d f1(%d) f2(%d) z1(%x)",
+ bcs->channel, bcs->hw.hfc.f1, bcs->hw.hfc.f2,
+ bcs->hw.hfc.send[bcs->hw.hfc.f1]);
+ debugl1(cs, tmp);
+ }
+ fcnt = bcs->hw.hfc.f1 - bcs->hw.hfc.f2;
+ if (fcnt < 0)
+ fcnt += 32;
+ if (fcnt > 30) {
+ if (cs->debug & L1_DEB_HSCX)
+ debugl1(cs, "hfc_fill_fifo more as 30 frames");
+ restore_flags(flags);
+ return;
+ }
+ count = GetFreeFifoBytes(bcs);
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "hfc_fill_fifo %d count(%d/%d)",
+ bcs->channel, bcs->hw.hfc.tx_skb->len,
+ count);
+ debugl1(cs, tmp);
+ }
+ if (count < bcs->hw.hfc.tx_skb->len) {
+ if (cs->debug & L1_DEB_HSCX)
+ debugl1(cs, "hfc_fill_fifo no fifo mem");
+ restore_flags(flags);
+ return;
+ }
+ cip = HFC_CIP | HFC_FIFO_IN | HFC_SEND | HFC_CHANNEL(bcs->channel);
+ idx = 0;
+ while ((idx < bcs->hw.hfc.tx_skb->len) && WaitNoBusy(cs))
+ cs->BC_Write_Reg(cs, HFC_DATA_NODEB, cip, bcs->hw.hfc.tx_skb->data[idx++]);
+ if (idx != bcs->hw.hfc.tx_skb->len) {
+ debugl1(cs, "FIFO Send BUSY error");
+ printk(KERN_WARNING "HFC S FIFO channel %d BUSY Error\n", bcs->channel);
+ } else {
+ count = bcs->hw.hfc.tx_skb->len;
+ bcs->tx_cnt -= count;
+ if (PACKET_NOACK == bcs->hw.hfc.tx_skb->pkt_type)
+ count = -1;
+ dev_kfree_skb(bcs->hw.hfc.tx_skb);
+ bcs->hw.hfc.tx_skb = NULL;
+ WaitForBusy(cs);
+ WaitNoBusy(cs);
+ cs->BC_Read_Reg(cs, HFC_DATA, HFC_CIP | HFC_F1_INC | HFC_SEND | HFC_CHANNEL(bcs->channel));
+ if (bcs->st->lli.l1writewakeup && (count >= 0))
+ bcs->st->lli.l1writewakeup(bcs->st, count);
+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
+ }
+ restore_flags(flags);
+ return;
+}
+
+void
+main_irq_hfc(struct BCState *bcs)
+{
+ long flags;
+ struct IsdnCardState *cs = bcs->cs;
+ int z1, z2, rcnt;
+ u_char f1, f2, cip;
+ int receive, transmit, count = 5;
+ struct sk_buff *skb;
+ char tmp[64];
+
+ save_flags(flags);
+ Begin:
+ cli();
+ count--;
+ cip = HFC_CIP | HFC_F1 | HFC_REC | HFC_CHANNEL(bcs->channel);
+ if ((cip & 0xc3) != (cs->hw.hfc.cip & 0xc3)) {
+ cs->BC_Write_Reg(cs, HFC_STATUS, cip, cip);
+ WaitForBusy(cs);
+ }
+ WaitNoBusy(cs);
+ f1 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
+ cip = HFC_CIP | HFC_F2 | HFC_REC | HFC_CHANNEL(bcs->channel);
+ WaitNoBusy(cs);
+ f2 = cs->BC_Read_Reg(cs, HFC_DATA, cip);
+ if (f1 != f2) {
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "hfc rec %d f1(%d) f2(%d)",
+ bcs->channel, f1, f2);
+ debugl1(cs, tmp);
+ }
+ WaitForBusy(cs);
+ z1 = ReadZReg(bcs, HFC_Z1 | HFC_REC | HFC_CHANNEL(bcs->channel));
+ z2 = ReadZReg(bcs, HFC_Z2 | HFC_REC | HFC_CHANNEL(bcs->channel));
+ rcnt = z1 - z2;
+ if (rcnt < 0)
+ rcnt += cs->hw.hfc.fifosize;
+ rcnt++;
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "hfc rec %d z1(%x) z2(%x) cnt(%d)",
+ bcs->channel, z1, z2, rcnt);
+ debugl1(cs, tmp);
+ }
+/* sti(); */
+ if ((skb = hfc_empty_fifo(bcs, rcnt))) {
+ skb_queue_tail(&bcs->rqueue, skb);
+ hfc_sched_event(bcs, B_RCVBUFREADY);
+ }
+ receive = 1;
+ } else
+ receive = 0;
+ restore_flags(flags);
+ udelay(1);
+ cli();
+ if (bcs->hw.hfc.tx_skb) {
+ transmit = 1;
+ test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
+ hfc_fill_fifo(bcs);
+ if (test_bit(BC_FLG_BUSY, &bcs->Flag))
+ transmit = 0;
+ } else {
+ if ((bcs->hw.hfc.tx_skb = skb_dequeue(&bcs->squeue))) {
+ transmit = 1;
+ test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
+ hfc_fill_fifo(bcs);
+ if (test_bit(BC_FLG_BUSY, &bcs->Flag))
+ transmit = 0;
+ } else {
+ transmit = 0;
+ hfc_sched_event(bcs, B_XMTBUFREADY);
+ }
+ }
+ restore_flags(flags);
+ if ((receive || transmit) && count)
+ goto Begin;
+ return;
+}
+
+void
+mode_hfc(struct BCState *bcs, int mode, int bc)
+{
+ struct IsdnCardState *cs = bcs->cs;
+
+ if (cs->debug & L1_DEB_HSCX) {
+ char tmp[40];
+ sprintf(tmp, "HFC 2BS0 mode %d bchan %d/%d",
+ mode, bc, bcs->channel);
+ debugl1(cs, tmp);
+ }
+ bcs->mode = mode;
+
+ switch (mode) {
+ case (L1_MODE_NULL):
+ if (bc)
+ cs->hw.hfc.isac_spcr &= ~0x03;
+ else
+ cs->hw.hfc.isac_spcr &= ~0x0c;
+ break;
+ case (L1_MODE_TRANS):
+ if (bc) {
+ cs->hw.hfc.ctmt |= 1;
+ cs->hw.hfc.isac_spcr &= ~0x03;
+ cs->hw.hfc.isac_spcr |= 0x02;
+ } else {
+ cs->hw.hfc.ctmt |= 2;
+ cs->hw.hfc.isac_spcr &= ~0x0c;
+ cs->hw.hfc.isac_spcr |= 0x08;
+ }
+ break;
+ case (L1_MODE_HDLC):
+ if (bc) {
+ cs->hw.hfc.ctmt &= ~1;
+ cs->hw.hfc.isac_spcr &= ~0x03;
+ cs->hw.hfc.isac_spcr |= 0x02;
+ } else {
+ cs->hw.hfc.ctmt &= ~2;
+ cs->hw.hfc.isac_spcr &= ~0x0c;
+ cs->hw.hfc.isac_spcr |= 0x08;
+ }
+ break;
+ }
+ cs->BC_Write_Reg(cs, HFC_STATUS, cs->hw.hfc.ctmt, cs->hw.hfc.ctmt);
+ cs->writeisac(cs, ISAC_SPCR, cs->hw.hfc.isac_spcr);
+ if (mode)
+ hfc_clear_fifo(bcs);
+}
+
+static void
+hfc_l2l1(struct PStack *st, int pr, void *arg)
+{
+ struct sk_buff *skb = arg;
+ long flags;
+
+ switch (pr) {
+ case (PH_DATA_REQ):
+ save_flags(flags);
+ cli();
+ if (st->l1.bcs->hw.hfc.tx_skb) {
+ skb_queue_tail(&st->l1.bcs->squeue, skb);
+ restore_flags(flags);
+ } else {
+ st->l1.bcs->hw.hfc.tx_skb = skb;
+ test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
+ st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
+ restore_flags(flags);
+ }
+ break;
+ case (PH_PULL_IND):
+ if (st->l1.bcs->hw.hfc.tx_skb) {
+ printk(KERN_WARNING "hfc_l2l1: this shouldn't happen\n");
+ break;
+ }
+ save_flags(flags);
+ cli();
+ test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
+ st->l1.bcs->hw.hfc.tx_skb = skb;
+ st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
+ restore_flags(flags);
+ break;
+ case (PH_PULL_REQ):
+ if (!st->l1.bcs->hw.hfc.tx_skb) {
+ test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
+ st->l1.l1l2(st, PH_PULL_CNF, NULL);
+ } else
+ test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
+ break;
+ }
+}
+
+void
+close_hfcstate(struct BCState *bcs)
+{
+ struct sk_buff *skb;
+
+ mode_hfc(bcs, 0, 0);
+ if (test_bit(BC_FLG_INIT, &bcs->Flag)) {
+ while ((skb = skb_dequeue(&bcs->rqueue))) {
+ dev_kfree_skb(skb);
+ }
+ while ((skb = skb_dequeue(&bcs->squeue))) {
+ dev_kfree_skb(skb);
+ }
+ if (bcs->hw.hfc.tx_skb) {
+ dev_kfree_skb(bcs->hw.hfc.tx_skb);
+ bcs->hw.hfc.tx_skb = NULL;
+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
+ }
+ }
+ test_and_clear_bit(BC_FLG_INIT, &bcs->Flag);
+}
+
+static int
+open_hfcstate(struct IsdnCardState *cs,
+ int bc)
+{
+ struct BCState *bcs = cs->bcs + bc;
+
+ if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) {
+ skb_queue_head_init(&bcs->rqueue);
+ skb_queue_head_init(&bcs->squeue);
+ }
+ bcs->hw.hfc.tx_skb = NULL;
+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
+ bcs->event = 0;
+ bcs->tx_cnt = 0;
+ return (0);
+}
+
+static void
+hfc_manl1(struct PStack *st, int pr,
+ void *arg)
+{
+ switch (pr) {
+ case (PH_ACTIVATE_REQ):
+ test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
+ mode_hfc(st->l1.bcs, st->l1.mode, st->l1.bc);
+ st->l1.l1man(st, PH_ACTIVATE_CNF, NULL);
+ break;
+ case (PH_DEACTIVATE_REQ):
+ if (!test_bit(BC_FLG_BUSY, &st->l1.bcs->Flag))
+ mode_hfc(st->l1.bcs, 0, 0);
+ test_and_clear_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
+ break;
+ }
+}
+
+int
+setstack_hfc(struct PStack *st, struct BCState *bcs)
+{
+ if (open_hfcstate(st->l1.hardware, bcs->channel))
+ return (-1);
+ st->l1.bcs = bcs;
+ st->l2.l2l1 = hfc_l2l1;
+ st->ma.manl1 = hfc_manl1;
+ setstack_manager(st);
+ bcs->st = st;
+ return (0);
+}
+
+__initfunc(void
+init_send(struct BCState *bcs))
+{
+ int i;
+
+ if (!(bcs->hw.hfc.send = kmalloc(32 * sizeof(unsigned int), GFP_ATOMIC))) {
+ printk(KERN_WARNING
+ "HiSax: No memory for hfc.send\n");
+ return;
+ }
+ for (i = 0; i < 32; i++)
+ bcs->hw.hfc.send[i] = 0x1fff;
+}
+
+__initfunc(void
+inithfc(struct IsdnCardState *cs))
+{
+ init_send(&cs->bcs[0]);
+ init_send(&cs->bcs[1]);
+ cs->BC_Send_Data = &hfc_fill_fifo;
+ cs->bcs[0].BC_SetStack = setstack_hfc;
+ cs->bcs[1].BC_SetStack = setstack_hfc;
+ cs->bcs[0].BC_Close = close_hfcstate;
+ cs->bcs[1].BC_Close = close_hfcstate;
+ mode_hfc(cs->bcs, 0, 0);
+ mode_hfc(cs->bcs + 1, 0, 0);
+}
+
+void
+releasehfc(struct IsdnCardState *cs)
+{
+ if (cs->bcs[0].hw.hfc.send) {
+ kfree(cs->bcs[0].hw.hfc.send);
+ cs->bcs[0].hw.hfc.send = NULL;
+ }
+ if (cs->bcs[1].hw.hfc.send) {
+ kfree(cs->bcs[1].hw.hfc.send);
+ cs->bcs[1].hw.hfc.send = NULL;
+ }
+}
diff --git a/drivers/isdn/hisax/hfc_2bs0.h b/drivers/isdn/hisax/hfc_2bs0.h
new file mode 100644
index 000000000..cce8e4a35
--- /dev/null
+++ b/drivers/isdn/hisax/hfc_2bs0.h
@@ -0,0 +1,62 @@
+/* $Id: hfc_2bs0.h,v 1.1 1997/09/11 17:31:34 keil Exp $
+
+ * specific defines for CCD's HFC 2BS0
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ *
+ * $Log: hfc_2bs0.h,v $
+ * Revision 1.1 1997/09/11 17:31:34 keil
+ * Common part for HFC 2BS0 based cards
+ *
+ *
+ */
+
+#define HFC_CTMT 0xe0
+#define HFC_CIRM 0xc0
+#define HFC_CIP 0x80
+#define HFC_Z1 0x00
+#define HFC_Z2 0x08
+#define HFC_Z_LOW 0x00
+#define HFC_Z_HIGH 0x04
+#define HFC_F1_INC 0x28
+#define HFC_FIFO_IN 0x2c
+#define HFC_F1 0x30
+#define HFC_F2 0x34
+#define HFC_F2_INC 0x38
+#define HFC_FIFO_OUT 0x3c
+#define HFC_B1 0x00
+#define HFC_B2 0x02
+#define HFC_REC 0x01
+#define HFC_SEND 0x00
+#define HFC_CHANNEL(ch) (ch ? HFC_B2 : HFC_B1)
+
+#define HFC_STATUS 0
+#define HFC_DATA 1
+#define HFC_DATA_NODEB 2
+
+/* Status (READ) */
+#define HFC_BUSY 0x01
+#define HFC_TIMINT 0x02
+#define HFC_EXTINT 0x04
+
+/* CTMT (Write) */
+#define HFC_CLTIMER 0x10
+#define HFC_TIM50MS 0x08
+#define HFC_TIMIRQE 0x04
+#define HFC_TRANSB2 0x02
+#define HFC_TRANSB1 0x01
+
+/* CIRM (Write) */
+#define HFC_RESET 0x08
+#define HFC_MEM8K 0x10
+#define HFC_INTA 0x01
+#define HFC_INTB 0x02
+#define HFC_INTC 0x03
+#define HFC_INTD 0x04
+#define HFC_INTE 0x05
+#define HFC_INTF 0x06
+
+extern void main_irq_hfc(struct BCState *bcs);
+extern void inithfc(struct IsdnCardState *cs);
+extern void releasehfc(struct IsdnCardState *cs);
diff --git a/drivers/isdn/hisax/hisax.h b/drivers/isdn/hisax/hisax.h
index efe7d5329..f5b15e2bf 100644
--- a/drivers/isdn/hisax/hisax.h
+++ b/drivers/isdn/hisax/hisax.h
@@ -1,52 +1,59 @@
-/* $Id: hisax.h,v 1.13 1997/04/06 22:54:12 keil Exp $
+/* $Id: hisax.h,v 2.14 1998/02/11 17:28:04 keil Exp $
* Basic declarations, defines and prototypes
*
* $Log: hisax.h,v $
- * Revision 1.13 1997/04/06 22:54:12 keil
- * Using SKB's
+ * Revision 2.14 1998/02/11 17:28:04 keil
+ * Niccy PnP/PCI support
*
- * Revision 1.12 1997/03/23 21:45:45 keil
- * Add support for ELSA PCMCIA
+ * Revision 2.13 1998/02/09 18:46:02 keil
+ * Support for Sedlbauer PCMCIA (Marcus Niemann)
*
- * Revision 1.11 1997/02/11 01:36:02 keil
- * New Param structure
+ * Revision 2.12 1998/02/03 23:31:30 keil
+ * add AMD7930 support
*
- * Revision 1.10 1997/02/09 00:23:52 keil
- * new interface handling, one interface per card
+ * Revision 2.11 1998/02/02 13:33:00 keil
+ * New card support
*
- * Revision 1.9 1997/01/27 23:18:44 keil
- * prototype for releasestack_isdnl3
+ * Revision 2.10 1997/11/08 21:37:52 keil
+ * new l1 init;new Compaq card
*
- * Revision 1.8 1997/01/27 16:02:37 keil
- * new cards, callc timers, HZDELAY macro, HiSax_getrev prototype
+ * Revision 2.9 1997/11/06 17:09:09 keil
+ * New 2.1 init code
*
- * Revision 1.7 1997/01/21 22:22:14 keil
- * changes for 2.0; Elsa Quickstep support
+ * Revision 2.8 1997/10/29 19:04:13 keil
+ * new L1; changes for 2.1
*
- * Revision 1.6 1997/01/04 13:48:28 keil
- * primitiv for MDL_REMOVE added
+ * Revision 2.7 1997/10/10 20:56:47 fritz
+ * New HL interface.
*
- * Revision 1.5 1996/12/08 19:49:19 keil
- * Monitor channel support
+ * Revision 2.6 1997/09/11 17:25:51 keil
+ * Add new cards
*
- * Revision 1.4 1996/11/18 15:35:39 keil
- * some changes for ELSA cards
+ * Revision 2.5 1997/08/03 14:36:31 keil
+ * Implement RESTART procedure
*
- * Revision 1.3 1996/11/05 19:37:23 keil
- * using config.h
+ * Revision 2.4 1997/07/31 19:25:20 keil
+ * PTP_DATA_LINK support
*
- * Revision 1.2 1996/10/27 22:21:52 keil
- * CallFlags for broadcast messages
+ * Revision 2.3 1997/07/31 11:50:17 keil
+ * ONE TEI and FIXED TEI handling
*
- * Revision 1.1 1996/10/13 20:03:46 keil
- * Initial revision
+ * Revision 2.2 1997/07/30 17:13:02 keil
+ * more changes for 'One TEI per card'
*
+ * Revision 2.1 1997/07/27 21:45:13 keil
+ * new main structures
*
+ * Revision 2.0 1997/06/26 11:06:27 keil
+ * New card and L1 interface.
+ * Eicon.Diehl Diva and Dynalink IS64PH support
+ *
+ * old changes removed KKe
*
*/
-#include <linux/module.h>
#include <linux/config.h>
+#include <linux/module.h>
#include <linux/version.h>
#include <linux/errno.h>
#include <linux/fs.h>
@@ -64,140 +71,136 @@
#include <linux/wait.h>
#include <linux/isdnif.h>
#include <linux/tty.h>
-
-#define PH_ACTIVATE 1
-#define PH_DATA 2
-#define PH_DEACTIVATE 3
-
-#define MDL_ASSIGN 4
-#define DL_UNIT_DATA 5
-#define SC_STARTUP 6
-#define CC_ESTABLISH 7
-#define DL_ESTABLISH 8
-#define DL_DATA 9
-#define CC_S_STATUS_ENQ 10
-
-#define CC_CONNECT 15
-#define CC_CONNECT_ACKNOWLEDGE 16
-#define CO_EOF 17
-#define SC_DISCONNECT 18
-#define CO_DTMF 19
-#define DL_RELEASE 20
-#define DL_FLUSH 21
-
-#define CO_ALARM 22
-#define CC_REJECT 23
-
-#define CC_SETUP_REQ 24
-#define CC_SETUP_CNF 25
-#define CC_SETUP_IND 26
-#define CC_SETUP_RSP 27
-#define CC_SETUP_COMPLETE_IND 28
-
-#define CC_DISCONNECT_REQ 29
-#define CC_DISCONNECT_IND 30
-
-#define CC_RELEASE_CNF 31
-#define CC_RELEASE_IND 32
-#define CC_RELEASE_REQ 33
-
-#define CC_REJECT_REQ 34
-
-#define CC_PROCEEDING_IND 35
-
-#define CC_DLRL 36
-#define CC_DLEST 37
-
-#define CC_ALERTING_REQ 38
-#define CC_ALERTING_IND 39
-
-#define DL_STOP 40
-#define DL_START 41
-
-#define MDL_NOTEIPROC 46
-
-#define LC_ESTABLISH 47
-#define LC_RELEASE 48
-
-#define PH_REQUEST_PULL 49
-#define PH_PULL_ACK 50
-#define PH_DATA_PULLED 51
-#define CC_INFO_CHARGE 52
-
-#define CC_MORE_INFO 53
-#define CC_IGNORE 54
-
-#define MDL_REMOVE 56
-#define MDL_VERIFY 57
-
-#define CC_T303 60
-#define CC_T304 61
-#define CC_T305 62
-#define CC_T308_1 64
-#define CC_T308_2 65
-#define CC_T310 66
-#define CC_T313 67
-#define CC_T318 68
-#define CC_T319 69
-
-#define CC_NOSETUP_RSP_ERR 70
-#define CC_SETUP_ERR 71
-#define CC_CONNECT_ERR 72
-#define CC_RELEASE_ERR 73
-
-/*
- * Message-Types
- */
-
-#define MT_ALERTING 0x01
-#define MT_CALL_PROCEEDING 0x02
-#define MT_CONNECT 0x07
-#define MT_CONNECT_ACKNOWLEDGE 0x0f
-#define MT_PROGRESS 0x03
-#define MT_SETUP 0x05
-#define MT_SETUP_ACKNOWLEDGE 0x0d
-#define MT_RESUME 0x26
-#define MT_RESUME_ACKNOWLEDGE 0x2e
-#define MT_RESUME_REJECT 0x22
-#define MT_SUSPEND 0x25
-#define MT_SUSPEND_ACKNOWLEDGE 0x2d
-#define MT_SUSPEND_REJECT 0x21
-#define MT_USER_INFORMATION 0x20
-#define MT_DISCONNECT 0x45
-#define MT_RELEASE 0x4d
-#define MT_RELEASE_COMPLETE 0x5a
-#define MT_RESTART 0x46
-#define MT_RESTART_ACKNOWLEDGE 0x4e
-#define MT_SEGMENT 0x60
-#define MT_CONGESTION_CONTROL 0x79
-#define MT_INFORMATION 0x7b
-#define MT_FACILITY 0x62
-#define MT_NOTIFY 0x6e
-#define MT_STATUS 0x7d
-#define MT_STATUS_ENQUIRY 0x75
-
-#define IE_CAUSE 0x08
-
-struct HscxIoctlArg {
- int channel;
- int mode;
- int transbufsize;
-};
+#include <linux/init.h>
+
+#define PH_ACTIVATE_REQ 0x0010
+#define PH_ACTIVATE_CNF 0x0011
+#define PH_ACTIVATE_IND 0x0012
+#define PH_DEACTIVATE_REQ 0x0020
+#define PH_DEACTIVATE_CNF 0x0021
+#define PH_DEACTIVATE_IND 0x0022
+#define PH_DEACT_REQ 0x0024
+#define PH_DEACT_CNF 0x0025
+#define PH_DEACT_IND 0x0026
+#define PH_DEACT_ACK 0x0027
+#define PH_TESTLOOP_REQ 0x0030
+#define PH_PAUSE_CNF 0x0035
+#define PH_PAUSE_IND 0x0036
+#define PH_PULL_REQ 0x0038
+#define PH_PULL_CNF 0x0039
+#define PH_PULL_IND 0x003A
+#define PH_DATA_REQ 0x0040
+#define PH_DATA_IND 0x0042
+
+#define PH_INFO3_REQ 0x0008
+#define PH_INFO2_IND 0x000A
+#define PH_ENABLE_REQ 0x0004
+#define PH_RSYNC_IND 0x0006
+#define PH_RESET_REQ 0x0000
+#define PH_RESET_IND 0x0002
+#define PH_POWERUP_CNF 0x0003
+#define PH_ACTIV_REQ 0x000C
+#define PH_I4_P8_IND 0x000D
+#define PH_I4_P10_IND 0x000F
+
+#define MDL_ASSIGN_REQ 0x0050
+#define MDL_ASSIGN_IND 0x0052
+#define MDL_REMOVE_REQ 0x0054
+#define MDL_ERROR_REQ 0x0058
+#define MDL_ERROR_IND 0x005A
+#define CARD_AUX_IND 0x005E
+
+#define DL_UNIT_DATA 6
+#define CC_ESTABLISH 7
+#define DL_ESTABLISH 8
+#define DL_DATA 9
+
+#define CC_CONNECT 15
+#define DL_RELEASE 20
+#define DL_FLUSH 21
+
+#define CC_REJECT 23
+
+#define CC_SETUP_REQ 24
+#define CC_SETUP_CNF 25
+#define CC_SETUP_IND 26
+#define CC_SETUP_RSP 27
+#define CC_SETUP_COMPLETE_IND 28
+
+#define CC_DISCONNECT_REQ 29
+#define CC_DISCONNECT_IND 30
+
+#define CC_RELEASE_CNF 31
+#define CC_RELEASE_IND 32
+#define CC_RELEASE_REQ 33
+
+#define CC_REJECT_REQ 34
+
+#define CC_PROCEEDING_IND 35
+
+#define CC_DLRL 36
+#define CC_DLEST 37
+
+#define CC_ALERTING_REQ 38
+#define CC_ALERTING_IND 39
+
+#define DL_STOP 40
+#define DL_START 41
+
+#define MDL_INFO_SETUP 42
+#define MDL_INFO_CONN 43
+#define MDL_INFO_REL 44
+#define MDL_NOTEIPROC 46
+
+#define LC_ESTABLISH 47
+#define LC_RELEASE 48
+
+#define CC_INFO_CHARGE 52
+
+#define CC_MORE_INFO 53
+#define CC_IGNORE 54
+#define CC_RESTART 55
+
+
+#define CC_T303 60
+#define CC_T304 61
+#define CC_T305 62
+#define CC_T308_1 64
+#define CC_T308_2 65
+#define CC_T310 66
+#define CC_T313 67
+#define CC_T318 68
+#define CC_T319 69
+
+#define CC_NOSETUP_RSP_ERR 70
+#define CC_SETUP_ERR 71
+#define CC_CONNECT_ERR 72
+#define CC_RELEASE_ERR 73
+
+#define CARD_RESET 0x1001
+#define CARD_SETIRQ 0x1002
+#define CARD_INIT 0x1003
+#define CARD_RELEASE 0x1004
+#define CARD_TEST 0x1005
#ifdef __KERNEL__
-#undef DEBUG_MAGIC
-
-#define MAX_DFRAME_LEN 3072
+#define MAX_DFRAME_LEN 260
#define HSCX_BUFMAX 4096
#define MAX_DATA_SIZE (HSCX_BUFMAX - 4)
-#define MAX_DATA_MEM (HSCX_BUFMAX * 2)
+#define MAX_DATA_MEM (HSCX_BUFMAX + 64)
+#define RAW_BUFMAX (((HSCX_BUFMAX*6)/5) + 5)
#define MAX_HEADER_LEN 4
#define MAX_WINDOW 8
+#define MAX_MON_FRAME 32
+
+/* #define I4L_IRQ_FLAG SA_INTERRUPT */
+#define I4L_IRQ_FLAG 0
/*
* Statemachine
*/
+
struct Fsm {
int *jumpmatrix;
int state_count, event_count;
@@ -226,73 +229,107 @@ struct FsmTimer {
};
struct L3Timer {
- struct PStack *st;
+ struct l3_process *pc;
struct timer_list tl;
int event;
};
+#define FLG_L1_ACTIVATING 1
+#define FLG_L1_ACTIVATED 2
+#define FLG_L1_DEACTTIMER 3
+#define FLG_L1_ACTTIMER 4
+#define FLG_L1_T3RUN 5
+#define FLG_L1_PULL_REQ 6
+
struct Layer1 {
void *hardware;
- int hscx;
+ struct BCState *bcs;
struct PStack **stlistp;
- int act_state;
+ int Flags;
+ struct FsmInst l1m;
+ struct FsmTimer timer;
void (*l1l2) (struct PStack *, int, void *);
void (*l1man) (struct PStack *, int, void *);
- int hscxmode, hscxchannel, requestpull;
+ void (*l1tei) (struct PStack *, int, void *);
+ int mode, bc;
};
+#define GROUP_TEI 127
+#define TEI_SAPI 63
+#define CTRL_SAPI 0
+#define PACKET_NOACK 250
+
+/* Layer2 Flags */
+
+#define FLG_LAPB 0
+#define FLG_LAPD 1
+#define FLG_ORIG 2
+#define FLG_MOD128 3
+#define FLG_PEND_REL 4
+#define FLG_L3_INIT 5
+#define FLG_T200_RUN 6
+#define FLG_ACK_PEND 7
+#define FLG_REJEXC 8
+#define FLG_OWN_BUSY 9
+#define FLG_PEER_BUSY 10
+#define FLG_DCHAN_BUSY 11
+
struct Layer2 {
- int sap, tei, ces;
- int extended, laptype;
- int uihsize, ihsize;
+ int tei;
+ int tei_wanted;
+ int sap;
+ int maxlen;
+ unsigned int flag;
int vs, va, vr;
- struct sk_buff_head i_queue;
- int window, orig;
- int rejexp;
- int debug;
- struct sk_buff *windowar[MAX_WINDOW];
+ int rc;
+ int window;
int sow;
- struct FsmInst l2m;
+ struct sk_buff *windowar[MAX_WINDOW];
+ struct sk_buff_head i_queue;
+ struct sk_buff_head ui_queue;
void (*l2l1) (struct PStack *, int, void *);
- void (*l2l1discardq) (struct PStack *, int, void *, int);
void (*l2man) (struct PStack *, int, void *);
void (*l2l3) (struct PStack *, int, void *);
void (*l2tei) (struct PStack *, int, void *);
- struct FsmTimer t200_timer, t203_timer;
- int t200, n200, t203;
- int rc, t200_running;
+ struct FsmInst l2m;
+ struct FsmTimer t200, t203;
+ int T200, N200, T203;
+ int debug;
char debug_id[32];
};
struct Layer3 {
- void (*l3l4) (struct PStack *, int, void *);
+ void (*l3l4) (struct l3_process *, int, void *);
void (*l3l2) (struct PStack *, int, void *);
- int state, callref;
- struct L3Timer timer;
- int t303, t304, t305, t308, t310, t313, t318, t319;
- int n_t303;
+ struct l3_process *proc;
+ struct l3_process *global;
+ int N303;
int debug;
- int channr;
};
-struct Layer4 {
+struct LLInterface {
void (*l4l3) (struct PStack *, int, void *);
void *userdata;
- void (*l1writewakeup) (struct PStack *);
- void (*l2writewakeup) (struct PStack *);
+ void (*l1writewakeup) (struct PStack *, int);
+ void (*l2writewakeup) (struct PStack *, int);
};
+
struct Management {
+ int ri;
+ struct FsmInst tei_m;
+ struct FsmTimer t202;
+ int T202, N202, debug;
+ void (*layer) (struct PStack *, int, void *);
void (*manl1) (struct PStack *, int, void *);
void (*manl2) (struct PStack *, int, void *);
- void (*teil2) (struct PStack *, int, void *);
};
+
struct Param {
int cause;
int loc;
int bchannel;
- int callref; /* Callreferenz Number */
setup_parm setup; /* from isdnif.h numbers and Serviceindicator */
int chargeinfo; /* Charge Info - only for 1tr6 in
* the moment
@@ -300,39 +337,114 @@ struct Param {
int spv; /* SPV Flag */
};
+
struct PStack {
struct PStack *next;
struct Layer1 l1;
struct Layer2 l2;
struct Layer3 l3;
- struct Layer4 l4;
+ struct LLInterface lli;
struct Management ma;
- struct Param *pa;
int protocol; /* EDSS1 or 1TR6 */
};
-struct HscxState {
- int inuse, init, active;
- struct IsdnCardState *sp;
- int hscx, mode;
- u_char *rcvbuf; /* B-Channel receive Buffer */
- int rcvidx; /* B-Channel receive Buffer Index */
- struct sk_buff *tx_skb; /* B-Channel transmit Buffer */
+struct l3_process {
+ int callref;
+ int state;
+ struct L3Timer timer;
+ int N303;
+ int debug;
+ struct Param para;
+ struct Channel *chan;
+ struct PStack *st;
+ struct l3_process *next;
+};
+
+struct hscx_hw {
+ int rcvidx;
+ int count; /* Current skb sent count */
+ u_char *rcvbuf; /* B-Channel receive Buffer */
+ struct sk_buff *tx_skb; /* B-Channel transmit Buffer */
+};
+
+struct hfcB_hw {
+ unsigned int *send;
+ int f1;
+ int f2;
+ struct sk_buff *tx_skb; /* B-Channel transmit Buffer */
+};
+
+struct tiger_hw {
+ struct sk_buff *tx_skb; /* B-Channel transmit Buffer */
+ u_int *send;
+ u_int *s_irq;
+ u_int *s_end;
+ u_int *sendp;
+ u_int *rec;
+ int free;
+ u_char *rcvbuf;
+ u_char *sendbuf;
+ u_char *sp;
+ int sendcnt;
+ u_int s_tot;
+ u_int r_bitcnt;
+ u_int r_tot;
+ u_int r_err;
+ u_int r_fcs;
+ u_char r_state;
+ u_char r_one;
+ u_char r_val;
+ u_char s_state;
+};
+
+struct amd7930_hw {
+ u_char *tx_buff;
+ u_char *rv_buff;
+ int rv_buff_in;
+ int rv_buff_out;
+ struct sk_buff *rv_skb;
+ struct hdlc_state *hdlc_state;
+ struct tq_struct tq_rcv;
+ struct tq_struct tq_xmt;
+ struct sk_buff *tx_skb; /* B-Channel transmit Buffer */
+};
+
+#define BC_FLG_INIT 1
+#define BC_FLG_ACTIV 2
+#define BC_FLG_BUSY 3
+#define BC_FLG_NOFRAME 4
+#define BC_FLG_HALF 5
+#define BC_FLG_EMPTY 6
+
+#define L1_MODE_NULL 0
+#define L1_MODE_TRANS 1
+#define L1_MODE_HDLC 2
+
+struct BCState {
+ int channel;
+ int mode;
+ int Flag;
+ struct IsdnCardState *cs;
int tx_cnt; /* B-Channel transmit counter */
- int count; /* Current skb sent count */
struct sk_buff_head rqueue; /* B-Channel receive Queue */
- struct sk_buff_head squeue; /* B-Channel receive Queue */
+ struct sk_buff_head squeue; /* B-Channel send Queue */
struct PStack *st;
struct tq_struct tqueue;
int event;
-#ifdef DEBUG_MAGIC
- int magic; /* 301270 */
-#endif
+ int (*BC_SetStack) (struct PStack *, struct BCState *);
+ void (*BC_Close) (struct BCState *);
+ union {
+ struct hscx_hw hscx;
+ struct hfcB_hw hfc;
+ struct tiger_hw tiger;
+ struct amd7930_hw amd7930;
+ } hw;
};
struct LcFsm {
- struct FsmInst lcfi;
int type;
+ int delay;
+ struct FsmInst lcfi;
struct Channel *ch;
void (*lccall) (struct LcFsm *, int, void *);
struct PStack *st;
@@ -343,52 +455,209 @@ struct LcFsm {
};
struct Channel {
- struct PStack ds, is;
- struct IsdnCardState *sp;
- int hscx;
+ struct PStack *b_st, *d_st;
+ struct IsdnCardState *cs;
+ struct BCState *bcs;
int chan;
int incoming;
struct FsmInst fi;
- struct LcFsm lc_d, lc_b;
- struct Param para;
+ struct LcFsm *lc_d;
+ struct LcFsm *lc_b;
struct FsmTimer drel_timer, dial_timer;
int debug;
-#ifdef DEBUG_MAGIC
- int magic; /* 301272 */
-#endif
int l2_protocol, l2_active_protocol;
- int l2_primitive, l2_headersize;
int data_open;
- int outcallref;
- int impair;
+ struct l3_process *proc;
+ setup_parm setup; /* from isdnif.h numbers and Serviceindicator */
int Flags; /* for remembering action done in l4 */
int leased;
};
-struct IsdnCardState {
-#ifdef DEBUG_MAGIC
- int magic;
-#endif
- unsigned char typ;
- unsigned char subtyp;
- int protocol;
- unsigned int irq;
+struct elsa_hw {
+ unsigned int base;
+ unsigned int cfg;
+ unsigned int ctrl;
+ unsigned int ale;
+ unsigned int isac;
+ unsigned int itac;
+ unsigned int hscx;
+ unsigned int trig;
+ unsigned int timer;
+ unsigned int counter;
+ unsigned int status;
+ struct timer_list tl;
+ u_char ctrl_reg;
+};
+
+struct teles3_hw {
+ unsigned int cfg_reg;
+ unsigned int isac;
+ unsigned int hscx[2];
+ unsigned int isacfifo;
+ unsigned int hscxfifo[2];
+};
+
+struct teles0_hw {
unsigned int cfg_reg;
unsigned int membase;
+};
+
+struct avm_hw {
+ unsigned int cfg_reg;
unsigned int isac;
unsigned int hscx[2];
+ unsigned int isacfifo;
+ unsigned int hscxfifo[2];
unsigned int counter;
+};
+
+struct ix1_hw {
+ unsigned int cfg_reg;
+ unsigned int isac_ale;
+ unsigned int isac;
+ unsigned int hscx_ale;
+ unsigned int hscx;
+};
+
+struct diva_hw {
+ unsigned int cfg_reg;
+ unsigned int ctrl;
+ unsigned int isac_adr;
+ unsigned int isac;
+ unsigned int hscx_adr;
+ unsigned int hscx;
+ unsigned int status;
+ struct timer_list tl;
+ u_char ctrl_reg;
+};
+
+struct asus_hw {
+ unsigned int cfg_reg;
+ unsigned int adr;
+ unsigned int isac;
+ unsigned int hscx;
+ unsigned int u7;
+ unsigned int pots;
+};
+
+
+struct hfc_hw {
+ unsigned int addr;
+ unsigned int fifosize;
+ unsigned char cirm;
+ unsigned char ctmt;
+ unsigned char cip;
+ u_char isac_spcr;
+ struct timer_list timer;
+};
+
+struct sedl_hw {
+ unsigned int cfg_reg;
+ unsigned int adr;
+ unsigned int isac;
+ unsigned int hscx;
+ unsigned int reset_on;
+ unsigned int reset_off;
+};
+
+struct spt_hw {
+ unsigned int cfg_reg;
+ unsigned int isac;
+ unsigned int hscx[2];
+ unsigned char res_irq;
+};
+
+struct mic_hw {
+ unsigned int cfg_reg;
+ unsigned int adr;
+ unsigned int isac;
+ unsigned int hscx;
+};
+
+struct njet_hw {
+ unsigned int base;
+ unsigned int isac;
+ unsigned int auxa;
+ unsigned char auxd;
+ unsigned char dmactrl;
+ unsigned char ctrl_reg;
+ unsigned char irqmask0;
+ unsigned char irqstat0;
+ unsigned char last_is0;
+};
+
+struct hfcD_hw {
+ unsigned int addr;
+ unsigned int bfifosize;
+ unsigned int dfifosize;
+ unsigned char cirm;
+ unsigned char ctmt;
+ unsigned char cip;
+ unsigned char conn;
+ unsigned char mst_m;
+ unsigned char int_m1;
+ unsigned char int_m2;
+ unsigned char int_s1;
+ unsigned char sctrl;
+ unsigned char stat;
+ unsigned char fifo;
+ unsigned char f1;
+ unsigned char f2;
+ unsigned int *send;
+ struct timer_list timer;
+};
+
+#define HW_IOM1 0
+#define HW_IPAC 1
+#define FLG_TWO_DCHAN 4
+#define FLG_L1_DBUSY 5
+#define FLG_DBUSY_TIMER 6
+#define FLG_LOCK_ATOMIC 7
+#define HW_MON0_RX_END 8
+#define HW_MON1_RX_END 9
+#define HW_MON0_TX_END 10
+#define HW_MON1_TX_END 11
+
+struct IsdnCardState {
+ unsigned char typ;
+ unsigned char subtyp;
+ int protocol;
+ unsigned int irq;
+ int HW_Flags;
+ int *busy_flag;
+ union {
+ struct elsa_hw elsa;
+ struct teles0_hw teles0;
+ struct teles3_hw teles3;
+ struct avm_hw avm;
+ struct ix1_hw ix1;
+ struct diva_hw diva;
+ struct asus_hw asus;
+ struct hfc_hw hfc;
+ struct sedl_hw sedl;
+ struct spt_hw spt;
+ struct mic_hw mic;
+ struct njet_hw njet;
+ struct hfcD_hw hfcD;
+ struct ix1_hw niccy;
+ } hw;
int myid;
isdn_if iif;
u_char *status_buf;
u_char *status_read;
u_char *status_write;
u_char *status_end;
- void (*ph_command) (struct IsdnCardState *, unsigned int);
- void (*modehscx) (struct HscxState *, int, int);
- void (*hscx_fill_fifo) (struct HscxState *);
- void (*isac_fill_fifo) (struct IsdnCardState *);
+ u_char (*readisac) (struct IsdnCardState *, u_char);
+ void (*writeisac) (struct IsdnCardState *, u_char, u_char);
+ void (*readisacfifo) (struct IsdnCardState *, u_char *, int);
+ void (*writeisacfifo) (struct IsdnCardState *, u_char *, int);
+ u_char (*BC_Read_Reg) (struct IsdnCardState *, int, u_char);
+ void (*BC_Write_Reg) (struct IsdnCardState *, int, u_char, u_char);
+ void (*BC_Send_Data) (struct BCState *);
+ int (*cardmsg) (struct IsdnCardState *, int, void *);
+ void (*l1cmd) (struct IsdnCardState *, int, void *);
struct Channel channel[2];
+ struct BCState bcs[2];
struct PStack *stlist;
u_char *rcvbuf;
int rcvidx;
@@ -396,16 +665,20 @@ struct IsdnCardState {
int tx_cnt;
int event;
struct tq_struct tqueue;
- int ph_active;
+ struct timer_list dbusytimer;
struct sk_buff_head rq, sq; /* D-channel queues */
- int cardnr;
int ph_state;
- struct PStack *teistack;
- struct HscxState hs[2];
+ int cardnr;
int dlogflag;
char *dlogspace;
int debug;
- unsigned int CallFlags;
+ u_char *mon_tx;
+ u_char *mon_rx;
+ int mon_txp;
+ int mon_txc;
+ int mon_rxp;
+ u_char mocr;
+ void (*setstack_d) (struct PStack *, struct IsdnCardState *);
};
#define MON0_RX 1
@@ -419,99 +692,246 @@ struct IsdnCardState {
#define ISDN_CTYPE_PNP 4
#define ISDN_CTYPE_A1 5
#define ISDN_CTYPE_ELSA 6
-#define ISDN_CTYPE_ELSA_QS1000 7
+#define ISDN_CTYPE_ELSA_PNP 7
#define ISDN_CTYPE_TELESPCMCIA 8
#define ISDN_CTYPE_IX1MICROR2 9
+#define ISDN_CTYPE_ELSA_PCMCIA 10
+#define ISDN_CTYPE_DIEHLDIVA 11
+#define ISDN_CTYPE_ASUSCOM 12
+#define ISDN_CTYPE_TELEINT 13
+#define ISDN_CTYPE_TELES3C 14
+#define ISDN_CTYPE_SEDLBAUER 15
+#define ISDN_CTYPE_SPORTSTER 16
+#define ISDN_CTYPE_MIC 17
+#define ISDN_CTYPE_ELSA_PCI 18
+#define ISDN_CTYPE_COMPAQ_ISA 19
+#define ISDN_CTYPE_NETJET 20
+#define ISDN_CTYPE_TELESPCI 21
+#define ISDN_CTYPE_SEDLBAUER_PCMCIA 22
+#define ISDN_CTYPE_AMD7930 23
+#define ISDN_CTYPE_NICCY 24
+
+#define ISDN_CTYPE_COUNT 24
+
+#ifdef ISDN_CHIP_ISAC
+#undef ISDN_CHIP_ISAC
+#endif
-#define ISDN_CTYPE_COUNT 9
+#define HISAX_INITFUNC(__arginit) __initfunc(__arginit)
+#define HISAX_INITDATA __initdata
#ifdef CONFIG_HISAX_16_0
#define CARD_TELES0 (1<< ISDN_CTYPE_16_0) | (1<< ISDN_CTYPE_8_0)
+#ifndef ISDN_CHIP_ISAC
+#define ISDN_CHIP_ISAC 1
+#endif
#else
#define CARD_TELES0 0
#endif
#ifdef CONFIG_HISAX_16_3
#define CARD_TELES3 (1<< ISDN_CTYPE_16_3) | (1<< ISDN_CTYPE_PNP) | \
- (1<< ISDN_CTYPE_TELESPCMCIA)
+ (1<< ISDN_CTYPE_TELESPCMCIA) | (1<< ISDN_CTYPE_COMPAQ_ISA)
+#ifndef ISDN_CHIP_ISAC
+#define ISDN_CHIP_ISAC 1
+#endif
#else
#define CARD_TELES3 0
#endif
#ifdef CONFIG_HISAX_AVM_A1
#define CARD_AVM_A1 (1<< ISDN_CTYPE_A1)
+#ifndef ISDN_CHIP_ISAC
+#define ISDN_CHIP_ISAC 1
+#endif
#else
#define CARD_AVM_A1 0
#endif
-#ifdef CONFIG_HISAX_ELSA_PCC
-#define CARD_ELSA (1<< ISDN_CTYPE_ELSA) | (1<< ISDN_CTYPE_ELSA_QS1000)
+#ifdef CONFIG_HISAX_ELSA
+#define CARD_ELSA (1<< ISDN_CTYPE_ELSA) | (1<< ISDN_CTYPE_ELSA_PNP) | \
+ (1<< ISDN_CTYPE_ELSA_PCMCIA) | (1<< ISDN_CTYPE_ELSA_PCI)
+#ifndef ISDN_CHIP_ISAC
+#define ISDN_CHIP_ISAC 1
+#endif
+#undef HISAX_INITFUNC
+#define HISAX_INITFUNC(__arginit) __arginit
+#undef HISAX_INITDATA
+#define HISAX_INITDATA
#else
#define CARD_ELSA 0
#endif
-#ifdef CONFIG_HISAX_ELSA_PCMCIA
-#if CARD_ELSA
-#error "You can't use a ELSA ISA card and a ELSA PCMCIA card with the same driver"
-#else
-#undef CARD_ELSA
-#define CARD_ELSA (1<< ISDN_CTYPE_ELSA_QS1000)
-#endif
-#endif
#ifdef CONFIG_HISAX_IX1MICROR2
#define CARD_IX1MICROR2 (1 << ISDN_CTYPE_IX1MICROR2)
+#ifndef ISDN_CHIP_ISAC
+#define ISDN_CHIP_ISAC 1
+#endif
#else
#define CARD_IX1MICROR2 0
#endif
+#ifdef CONFIG_HISAX_DIEHLDIVA
+#define CARD_DIEHLDIVA (1 << ISDN_CTYPE_DIEHLDIVA)
+#ifndef ISDN_CHIP_ISAC
+#define ISDN_CHIP_ISAC 1
+#endif
+#else
+#define CARD_DIEHLDIVA 0
+#endif
+
+#ifdef CONFIG_HISAX_ASUSCOM
+#define CARD_ASUSCOM (1 << ISDN_CTYPE_ASUSCOM)
+#ifndef ISDN_CHIP_ISAC
+#define ISDN_CHIP_ISAC 1
+#endif
+#else
+#define CARD_ASUSCOM 0
+#endif
+
+#ifdef CONFIG_HISAX_TELEINT
+#define CARD_TELEINT (1 << ISDN_CTYPE_TELEINT)
+#ifndef ISDN_CHIP_ISAC
+#define ISDN_CHIP_ISAC 1
+#endif
+#else
+#define CARD_TELEINT 0
+#endif
+
+#ifdef CONFIG_HISAX_SEDLBAUER
+#define CARD_SEDLBAUER (1 << ISDN_CTYPE_SEDLBAUER) | (1 << ISDN_CTYPE_SEDLBAUER_PCMCIA)
+#ifndef ISDN_CHIP_ISAC
+#define ISDN_CHIP_ISAC 1
+#endif
+#else
+#define CARD_SEDLBAUER 0
+#endif
+
+#ifdef CONFIG_HISAX_SPORTSTER
+#define CARD_SPORTSTER (1 << ISDN_CTYPE_SPORTSTER)
+#ifndef ISDN_CHIP_ISAC
+#define ISDN_CHIP_ISAC 1
+#endif
+#else
+#define CARD_SPORTSTER 0
+#endif
+
+#ifdef CONFIG_HISAX_MIC
+#define CARD_MIC (1 << ISDN_CTYPE_MIC)
+#ifndef ISDN_CHIP_ISAC
+#define ISDN_CHIP_ISAC 1
+#endif
+#else
+#define CARD_MIC 0
+#endif
+
+#ifdef CONFIG_HISAX_NETJET
+#define CARD_NETJET (1 << ISDN_CTYPE_NETJET)
+#ifndef ISDN_CHIP_ISAC
+#define ISDN_CHIP_ISAC 1
+#endif
+#else
+#define CARD_NETJET 0
+#endif
+
+#ifdef CONFIG_HISAX_TELES3C
+#define CARD_TELES3C (1<< ISDN_CTYPE_TELES3C)
+#else
+#define CARD_TELES3C 0
+#endif
+
+#ifdef CONFIG_HISAX_AMD7930
+#define CARD_AMD7930 (1 << ISDN_CTYPE_AMD7930)
+#else
+#define CARD_AMD7930 0
+#endif
+
+#ifdef CONFIG_HISAX_NICCY
+#define CARD_NICCY (1 << ISDN_CTYPE_NICCY)
+#ifndef ISDN_CHIP_ISAC
+#define ISDN_CHIP_ISAC 1
+#endif
+#else
+#define CARD_NICCY 0
+#endif
+
+
#define SUPORTED_CARDS (CARD_TELES0 | CARD_TELES3 | CARD_AVM_A1 | CARD_ELSA \
- | CARD_IX1MICROR2)
+ | CARD_IX1MICROR2 | CARD_DIEHLDIVA | CARD_ASUSCOM \
+ | CARD_TELEINT | CARD_SEDLBAUER | CARD_SPORTSTER \
+ | CARD_MIC | CARD_NETJET | CARD_TELES3C | CARD_AMD7930 \
+ | CARD_NICCY)
+
+#define TEI_PER_CARD 0
+
+#ifdef CONFIG_HISAX_1TR6
+#undef TEI_PER_CARD
+#define TEI_PER_CARD 1
+#endif
+
+#ifdef CONFIG_HISAX_EURO
+#undef TEI_PER_CARD
+#define TEI_PER_CARD 1
+#define HISAX_EURO_SENDCOMPLETE 1
+#ifdef CONFIG_HISAX_ML
+#undef HISAX_EURO_SENDCOMPLETE
+#endif
+#undef HISAX_DE_AOC
+#ifdef CONFIG_DE_AOC
+#define HISAX_DE_AOC 1
+#endif
+#endif
+
+#if TEI_PER_CARD
+#undef TEI_FIXED
+#endif
+
+#undef PTP_DATA_LINK
+
+#ifdef PTP_DATA_LINK
+#undef TEI_FIXED
+#define TEI_FIXED 0
+#define LAYER2_WATCHING
+#endif
struct IsdnCard {
int typ;
int protocol; /* EDSS1 or 1TR6 */
- unsigned int para[3];
- struct IsdnCardState *sp;
+ unsigned int para[4];
+ struct IsdnCardState *cs;
};
-
-#define LAPD 0
-#define LAPB 1
-
-void l2down(struct PStack *st, u_char pr, struct sk_buff *skb);
-void l2up(struct PStack *st, u_char pr, struct sk_buff *skb);
-void acceptph(struct PStack *st, struct sk_buff *skb);
void setstack_isdnl2(struct PStack *st, char *debug_id);
-int HiSax_inithardware(void);
+int HiSax_inithardware(int *);
void HiSax_closehardware(void);
-void setstack_HiSax(struct PStack *st, struct IsdnCardState *sp);
-unsigned int randomces(void);
+void setstack_HiSax(struct PStack *st, struct IsdnCardState *cs);
+unsigned int random_ri(void);
void setstack_isdnl3(struct PStack *st, struct Channel *chanp);
void HiSax_addlist(struct IsdnCardState *sp, struct PStack *st);
void releasestack_isdnl2(struct PStack *st);
void releasestack_isdnl3(struct PStack *st);
void HiSax_rmlist(struct IsdnCardState *sp, struct PStack *st);
-void newcallref(struct PStack *st);
-int setstack_hscx(struct PStack *st, struct HscxState *hs);
u_char *findie(u_char * p, int size, u_char ie, int wanted_set);
int getcallref(u_char * p);
+int newcallref(void);
void FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount);
void FsmFree(struct Fsm *fsm);
int FsmEvent(struct FsmInst *fi, int event, void *arg);
void FsmChangeState(struct FsmInst *fi, int newstate);
void FsmInitTimer(struct FsmInst *fi, struct FsmTimer *ft);
-int FsmAddTimer(struct FsmTimer *ft, int millisec,
- int event, void *arg, int where);
+int FsmAddTimer(struct FsmTimer *ft, int millisec, int event,
+ void *arg, int where);
+void FsmRestartTimer(struct FsmTimer *ft, int millisec, int event,
+ void *arg, int where);
void FsmDelTimer(struct FsmTimer *ft, int where);
-int FsmTimerRunning(struct FsmTimer *ft);
void jiftime(char *s, long mark);
int HiSax_command(isdn_ctrl * ic);
-int HiSax_writebuf_skb(int id, int chan, struct sk_buff *skb);
+int HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb);
void HiSax_putstatus(struct IsdnCardState *csta, char *buf);
void HiSax_reportcard(int cardnr);
int QuickHex(char *txt, u_char * p, int cnt);
@@ -520,10 +940,12 @@ void dlogframe(struct IsdnCardState *sp, u_char * p, int size, char *comment);
void iecpy(u_char * dest, u_char * iestart, int ieoffset);
void setstack_transl2(struct PStack *st);
void releasestack_transl2(struct PStack *st);
-void close_hscxstate(struct HscxState *);
void setstack_tei(struct PStack *st);
-
-#endif /* __KERNEL__ */
+void setstack_manager(struct PStack *st);
+#ifdef ISDN_CHIP_ISAC
+void setstack_isac(struct PStack *st, struct IsdnCardState *cs);
+#endif /* ISDN_CHIP_ISAC */
+#endif /* __KERNEL__ */
#define HZDELAY(jiffs) {int tout = jiffs; while (tout--) udelay(1000000/HZ);}
@@ -533,8 +955,12 @@ void CallcNew(void);
void CallcFree(void);
int CallcNewChan(struct IsdnCardState *csta);
void CallcFreeChan(struct IsdnCardState *csta);
+void Isdnl1New(void);
+void Isdnl1Free(void);
void Isdnl2New(void);
void Isdnl2Free(void);
void init_tei(struct IsdnCardState *sp, int protocol);
void release_tei(struct IsdnCardState *sp);
char *HiSax_getrev(const char *revision);
+void TeiNew(void);
+void TeiFree(void);
diff --git a/drivers/isdn/hisax/hscx.c b/drivers/isdn/hisax/hscx.c
new file mode 100644
index 000000000..c44cc54df
--- /dev/null
+++ b/drivers/isdn/hisax/hscx.c
@@ -0,0 +1,280 @@
+/* $Id: hscx.c,v 1.7 1998/02/12 23:07:36 keil Exp $
+
+ * hscx.c HSCX specific routines
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ *
+ * $Log: hscx.c,v $
+ * Revision 1.7 1998/02/12 23:07:36 keil
+ * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
+ *
+ * Revision 1.6 1998/02/02 13:41:12 keil
+ * new init
+ *
+ * Revision 1.5 1997/11/06 17:09:34 keil
+ * New 2.1 init code
+ *
+ * Revision 1.4 1997/10/29 19:01:06 keil
+ * changes for 2.1
+ *
+ * Revision 1.3 1997/07/27 21:38:34 keil
+ * new B-channel interface
+ *
+ * Revision 1.2 1997/06/26 11:16:17 keil
+ * first version
+ *
+ *
+ */
+
+#define __NO_VERSION__
+#include "hisax.h"
+#include "hscx.h"
+#include "isdnl1.h"
+#include <linux/interrupt.h>
+
+static char *HSCXVer[] HISAX_INITDATA =
+{"A1", "?1", "A2", "?3", "A3", "V2.1", "?6", "?7",
+ "?8", "?9", "?10", "?11", "?12", "?13", "?14", "???"};
+
+HISAX_INITFUNC(int
+HscxVersion(struct IsdnCardState *cs, char *s))
+{
+ int verA, verB;
+
+ verA = cs->BC_Read_Reg(cs, 0, HSCX_VSTR) & 0xf;
+ verB = cs->BC_Read_Reg(cs, 1, HSCX_VSTR) & 0xf;
+ printk(KERN_INFO "%s HSCX version A: %s B: %s\n", s,
+ HSCXVer[verA], HSCXVer[verB]);
+ if ((verA == 0) | (verA == 0xf) | (verB == 0) | (verB == 0xf))
+ return (1);
+ else
+ return (0);
+}
+
+void
+modehscx(struct BCState *bcs, int mode, int bc)
+{
+ struct IsdnCardState *cs = bcs->cs;
+ int hscx = bcs->channel;
+
+ if (cs->debug & L1_DEB_HSCX) {
+ char tmp[40];
+ sprintf(tmp, "hscx %c mode %d ichan %d",
+ 'A' + hscx, mode, bc);
+ debugl1(cs, tmp);
+ }
+ bcs->mode = mode;
+ cs->BC_Write_Reg(cs, hscx, HSCX_CCR1, 0x85);
+ cs->BC_Write_Reg(cs, hscx, HSCX_XAD1, 0xFF);
+ cs->BC_Write_Reg(cs, hscx, HSCX_XAD2, 0xFF);
+ cs->BC_Write_Reg(cs, hscx, HSCX_RAH2, 0xFF);
+ cs->BC_Write_Reg(cs, hscx, HSCX_XBCH, 0x0);
+ cs->BC_Write_Reg(cs, hscx, HSCX_RLCR, 0x0);
+ cs->BC_Write_Reg(cs, hscx, HSCX_CCR2, 0x30);
+ cs->BC_Write_Reg(cs, hscx, HSCX_XCCR, 7);
+ cs->BC_Write_Reg(cs, hscx, HSCX_RCCR, 7);
+
+ /* Switch IOM 1 SSI */
+ if (test_bit(HW_IOM1, &cs->HW_Flags) && (hscx == 0))
+ bc = 1 - bc;
+
+ if (bc == 0) {
+ cs->BC_Write_Reg(cs, hscx, HSCX_TSAX,
+ test_bit(HW_IOM1, &cs->HW_Flags) ? 0x7 : 0x2f);
+ cs->BC_Write_Reg(cs, hscx, HSCX_TSAR,
+ test_bit(HW_IOM1, &cs->HW_Flags) ? 0x7 : 0x2f);
+ } else {
+ cs->BC_Write_Reg(cs, hscx, HSCX_TSAX, 0x3);
+ cs->BC_Write_Reg(cs, hscx, HSCX_TSAR, 0x3);
+ }
+ switch (mode) {
+ case (L1_MODE_NULL):
+ cs->BC_Write_Reg(cs, hscx, HSCX_TSAX, 0xff);
+ cs->BC_Write_Reg(cs, hscx, HSCX_TSAR, 0xff);
+ cs->BC_Write_Reg(cs, hscx, HSCX_MODE, 0x84);
+ break;
+ case (L1_MODE_TRANS):
+ cs->BC_Write_Reg(cs, hscx, HSCX_MODE, 0xe4);
+ break;
+ case (L1_MODE_HDLC):
+ cs->BC_Write_Reg(cs, hscx, HSCX_MODE, 0x8c);
+ break;
+ }
+ if (mode)
+ cs->BC_Write_Reg(cs, hscx, HSCX_CMDR, 0x41);
+ cs->BC_Write_Reg(cs, hscx, HSCX_ISTA, 0x00);
+}
+
+void
+hscx_sched_event(struct BCState *bcs, int event)
+{
+ bcs->event |= 1 << event;
+ queue_task(&bcs->tqueue, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+}
+
+static void
+hscx_l2l1(struct PStack *st, int pr, void *arg)
+{
+ struct sk_buff *skb = arg;
+ long flags;
+
+ switch (pr) {
+ case (PH_DATA_REQ):
+ save_flags(flags);
+ cli();
+ if (st->l1.bcs->hw.hscx.tx_skb) {
+ skb_queue_tail(&st->l1.bcs->squeue, skb);
+ restore_flags(flags);
+ } else {
+ st->l1.bcs->hw.hscx.tx_skb = skb;
+ test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
+ st->l1.bcs->hw.hscx.count = 0;
+ restore_flags(flags);
+ st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
+ }
+ break;
+ case (PH_PULL_IND):
+ if (st->l1.bcs->hw.hscx.tx_skb) {
+ printk(KERN_WARNING "hscx_l2l1: this shouldn't happen\n");
+ break;
+ }
+ test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
+ st->l1.bcs->hw.hscx.tx_skb = skb;
+ st->l1.bcs->hw.hscx.count = 0;
+ st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
+ break;
+ case (PH_PULL_REQ):
+ if (!st->l1.bcs->hw.hscx.tx_skb) {
+ test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
+ st->l1.l1l2(st, PH_PULL_CNF, NULL);
+ } else
+ test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
+ break;
+ }
+
+}
+
+void
+close_hscxstate(struct BCState *bcs)
+{
+ struct sk_buff *skb;
+
+ modehscx(bcs, 0, 0);
+ if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
+ if (bcs->hw.hscx.rcvbuf) {
+ kfree(bcs->hw.hscx.rcvbuf);
+ bcs->hw.hscx.rcvbuf = NULL;
+ }
+ while ((skb = skb_dequeue(&bcs->rqueue))) {
+ dev_kfree_skb(skb);
+ }
+ while ((skb = skb_dequeue(&bcs->squeue))) {
+ dev_kfree_skb(skb);
+ }
+ if (bcs->hw.hscx.tx_skb) {
+ dev_kfree_skb(bcs->hw.hscx.tx_skb);
+ bcs->hw.hscx.tx_skb = NULL;
+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
+ }
+ }
+}
+
+static int
+open_hscxstate(struct IsdnCardState *cs,
+ int bc)
+{
+ struct BCState *bcs = cs->bcs + bc;
+
+ if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) {
+ if (!(bcs->hw.hscx.rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) {
+ printk(KERN_WARNING
+ "HiSax: No memory for hscx.rcvbuf\n");
+ return (1);
+ }
+ skb_queue_head_init(&bcs->rqueue);
+ skb_queue_head_init(&bcs->squeue);
+ }
+ bcs->hw.hscx.tx_skb = NULL;
+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
+ bcs->event = 0;
+ bcs->hw.hscx.rcvidx = 0;
+ bcs->tx_cnt = 0;
+ return (0);
+}
+
+static void
+hscx_manl1(struct PStack *st, int pr,
+ void *arg)
+{
+ switch (pr) {
+ case (PH_ACTIVATE_REQ):
+ test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
+ modehscx(st->l1.bcs, st->l1.mode, st->l1.bc);
+ st->l1.l1man(st, PH_ACTIVATE_CNF, NULL);
+ break;
+ case (PH_DEACTIVATE_REQ):
+ if (!test_bit(BC_FLG_BUSY, &st->l1.bcs->Flag))
+ modehscx(st->l1.bcs, 0, 0);
+ test_and_clear_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
+ break;
+ }
+}
+
+int
+setstack_hscx(struct PStack *st, struct BCState *bcs)
+{
+ if (open_hscxstate(st->l1.hardware, bcs->channel))
+ return (-1);
+ st->l1.bcs = bcs;
+ st->l2.l2l1 = hscx_l2l1;
+ st->ma.manl1 = hscx_manl1;
+ setstack_manager(st);
+ bcs->st = st;
+ return (0);
+}
+
+HISAX_INITFUNC(void
+clear_pending_hscx_ints(struct IsdnCardState *cs))
+{
+ int val;
+ char tmp[64];
+
+ val = cs->BC_Read_Reg(cs, 1, HSCX_ISTA);
+ sprintf(tmp, "HSCX B ISTA %x", val);
+ debugl1(cs, tmp);
+ if (val & 0x01) {
+ val = cs->BC_Read_Reg(cs, 1, HSCX_EXIR);
+ sprintf(tmp, "HSCX B EXIR %x", val);
+ debugl1(cs, tmp);
+ } else if (val & 0x02) {
+ val = cs->BC_Read_Reg(cs, 0, HSCX_EXIR);
+ sprintf(tmp, "HSCX A EXIR %x", val);
+ debugl1(cs, tmp);
+ }
+ val = cs->BC_Read_Reg(cs, 0, HSCX_ISTA);
+ sprintf(tmp, "HSCX A ISTA %x", val);
+ debugl1(cs, tmp);
+ val = cs->BC_Read_Reg(cs, 1, HSCX_STAR);
+ sprintf(tmp, "HSCX B STAR %x", val);
+ debugl1(cs, tmp);
+ val = cs->BC_Read_Reg(cs, 0, HSCX_STAR);
+ sprintf(tmp, "HSCX A STAR %x", val);
+ debugl1(cs, tmp);
+ cs->BC_Write_Reg(cs, 0, HSCX_MASK, 0xFF);
+ cs->BC_Write_Reg(cs, 1, HSCX_MASK, 0xFF);
+ cs->BC_Write_Reg(cs, 0, HSCX_MASK, 0);
+ cs->BC_Write_Reg(cs, 1, HSCX_MASK, 0);
+}
+
+HISAX_INITFUNC(void
+inithscx(struct IsdnCardState *cs))
+{
+ cs->bcs[0].BC_SetStack = setstack_hscx;
+ cs->bcs[1].BC_SetStack = setstack_hscx;
+ cs->bcs[0].BC_Close = close_hscxstate;
+ cs->bcs[1].BC_Close = close_hscxstate;
+ modehscx(cs->bcs, 0, 0);
+ modehscx(cs->bcs + 1, 0, 0);
+}
diff --git a/drivers/isdn/hisax/hscx.h b/drivers/isdn/hisax/hscx.h
new file mode 100644
index 000000000..ac2d38086
--- /dev/null
+++ b/drivers/isdn/hisax/hscx.h
@@ -0,0 +1,46 @@
+/* $Id: hscx.h,v 1.3 1997/07/27 21:38:35 keil Exp $
+
+ * hscx.h HSCX specific defines
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ *
+ * $Log: hscx.h,v $
+ * Revision 1.3 1997/07/27 21:38:35 keil
+ * new B-channel interface
+ *
+ * Revision 1.2 1997/06/26 11:16:18 keil
+ * first version
+ *
+ *
+ */
+
+/* All Registers original Siemens Spec */
+
+#define HSCX_ISTA 0x20
+#define HSCX_CCR1 0x2f
+#define HSCX_CCR2 0x2c
+#define HSCX_TSAR 0x31
+#define HSCX_TSAX 0x30
+#define HSCX_XCCR 0x32
+#define HSCX_RCCR 0x33
+#define HSCX_MODE 0x22
+#define HSCX_CMDR 0x21
+#define HSCX_EXIR 0x24
+#define HSCX_XAD1 0x24
+#define HSCX_XAD2 0x25
+#define HSCX_RAH2 0x27
+#define HSCX_RSTA 0x27
+#define HSCX_TIMR 0x23
+#define HSCX_STAR 0x21
+#define HSCX_RBCL 0x25
+#define HSCX_XBCH 0x2d
+#define HSCX_VSTR 0x2e
+#define HSCX_RLCR 0x2e
+#define HSCX_MASK 0x20
+
+extern int HscxVersion(struct IsdnCardState *cs, char *s);
+extern void hscx_sched_event(struct BCState *bcs, int event);
+extern void modehscx(struct BCState *bcs, int mode, int bc);
+extern void clear_pending_hscx_ints(struct IsdnCardState *cs);
+extern void inithscx(struct IsdnCardState *cs);
diff --git a/drivers/isdn/hisax/hscx_irq.c b/drivers/isdn/hisax/hscx_irq.c
new file mode 100644
index 000000000..64e80e7b2
--- /dev/null
+++ b/drivers/isdn/hisax/hscx_irq.c
@@ -0,0 +1,320 @@
+/* $Id: hscx_irq.c,v 1.7 1998/02/12 23:07:37 keil Exp $
+
+ * hscx_irq.c low level b-channel stuff for Siemens HSCX
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ * This is an include file for fast inline IRQ stuff
+ *
+ * $Log: hscx_irq.c,v $
+ * Revision 1.7 1998/02/12 23:07:37 keil
+ * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
+ *
+ * Revision 1.6 1997/10/29 19:01:07 keil
+ * changes for 2.1
+ *
+ * Revision 1.5 1997/10/01 09:21:35 fritz
+ * Removed old compatibility stuff for 2.0.X kernels.
+ * From now on, this code is for 2.1.X ONLY!
+ * Old stuff is still in the separate branch.
+ *
+ * Revision 1.4 1997/08/15 17:48:02 keil
+ * cosmetic
+ *
+ * Revision 1.3 1997/07/27 21:38:36 keil
+ * new B-channel interface
+ *
+ * Revision 1.2 1997/06/26 11:16:19 keil
+ * first version
+ *
+ *
+ */
+
+
+static inline void
+waitforCEC(struct IsdnCardState *cs, int hscx)
+{
+ int to = 50;
+
+ while ((READHSCX(cs, hscx, HSCX_STAR) & 0x04) && to) {
+ udelay(1);
+ to--;
+ }
+ if (!to)
+ printk(KERN_WARNING "HiSax: waitforCEC timeout\n");
+}
+
+
+static inline void
+waitforXFW(struct IsdnCardState *cs, int hscx)
+{
+ int to = 50;
+
+ while ((!(READHSCX(cs, hscx, HSCX_STAR) & 0x44) == 0x40) && to) {
+ udelay(1);
+ to--;
+ }
+ if (!to)
+ printk(KERN_WARNING "HiSax: waitforXFW timeout\n");
+}
+
+static inline void
+WriteHSCXCMDR(struct IsdnCardState *cs, int hscx, u_char data)
+{
+ long flags;
+
+ save_flags(flags);
+ cli();
+ waitforCEC(cs, hscx);
+ WRITEHSCX(cs, hscx, HSCX_CMDR, data);
+ restore_flags(flags);
+}
+
+
+
+static void
+hscx_empty_fifo(struct BCState *bcs, int count)
+{
+ u_char *ptr;
+ struct IsdnCardState *cs = bcs->cs;
+ long flags;
+
+ if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
+ debugl1(cs, "hscx_empty_fifo");
+
+ if (bcs->hw.hscx.rcvidx + count > HSCX_BUFMAX) {
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "hscx_empty_fifo: incoming packet too large");
+ WriteHSCXCMDR(cs, bcs->channel, 0x80);
+ bcs->hw.hscx.rcvidx = 0;
+ return;
+ }
+ ptr = bcs->hw.hscx.rcvbuf + bcs->hw.hscx.rcvidx;
+ bcs->hw.hscx.rcvidx += count;
+ save_flags(flags);
+ cli();
+ READHSCXFIFO(cs, bcs->channel, ptr, count);
+ WriteHSCXCMDR(cs, bcs->channel, 0x80);
+ restore_flags(flags);
+ if (cs->debug & L1_DEB_HSCX_FIFO) {
+ char tmp[256];
+ char *t = tmp;
+
+ t += sprintf(t, "hscx_empty_fifo %c cnt %d",
+ bcs->channel ? 'B' : 'A', count);
+ QuickHex(t, ptr, count);
+ debugl1(cs, tmp);
+ }
+}
+
+static void
+hscx_fill_fifo(struct BCState *bcs)
+{
+ struct IsdnCardState *cs = bcs->cs;
+ int more, count;
+ int fifo_size = test_bit(HW_IPAC, &cs->HW_Flags)? 64: 32;
+ u_char *ptr;
+ long flags;
+
+
+ if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
+ debugl1(cs, "hscx_fill_fifo");
+
+ if (!bcs->hw.hscx.tx_skb)
+ return;
+ if (bcs->hw.hscx.tx_skb->len <= 0)
+ return;
+
+ more = (bcs->mode == L1_MODE_TRANS) ? 1 : 0;
+ if (bcs->hw.hscx.tx_skb->len > fifo_size) {
+ more = !0;
+ count = fifo_size;
+ } else
+ count = bcs->hw.hscx.tx_skb->len;
+
+ waitforXFW(cs, bcs->channel);
+ save_flags(flags);
+ cli();
+ ptr = bcs->hw.hscx.tx_skb->data;
+ skb_pull(bcs->hw.hscx.tx_skb, count);
+ bcs->tx_cnt -= count;
+ bcs->hw.hscx.count += count;
+ WRITEHSCXFIFO(cs, bcs->channel, ptr, count);
+ WriteHSCXCMDR(cs, bcs->channel, more ? 0x8 : 0xa);
+ restore_flags(flags);
+ if (cs->debug & L1_DEB_HSCX_FIFO) {
+ char tmp[256];
+ char *t = tmp;
+
+ t += sprintf(t, "hscx_fill_fifo %c cnt %d",
+ bcs->channel ? 'B' : 'A', count);
+ QuickHex(t, ptr, count);
+ debugl1(cs, tmp);
+ }
+}
+
+static inline void
+hscx_interrupt(struct IsdnCardState *cs, u_char val, u_char hscx)
+{
+ u_char r;
+ struct BCState *bcs = cs->bcs + hscx;
+ struct sk_buff *skb;
+ int fifo_size = test_bit(HW_IPAC, &cs->HW_Flags)? 64: 32;
+ int count;
+ char tmp[32];
+
+ if (!test_bit(BC_FLG_INIT, &bcs->Flag))
+ return;
+
+ if (val & 0x80) { /* RME */
+ r = READHSCX(cs, hscx, HSCX_RSTA);
+ if ((r & 0xf0) != 0xa0) {
+ if (!(r & 0x80))
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "HSCX invalid frame");
+ if ((r & 0x40) && bcs->mode)
+ if (cs->debug & L1_DEB_WARN) {
+ sprintf(tmp, "HSCX RDO mode=%d",
+ bcs->mode);
+ debugl1(cs, tmp);
+ }
+ if (!(r & 0x20))
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "HSCX CRC error");
+ WriteHSCXCMDR(cs, hscx, 0x80);
+ } else {
+ count = READHSCX(cs, hscx, HSCX_RBCL) & (
+ test_bit(HW_IPAC, &cs->HW_Flags)? 0x3f: 0x1f);
+ if (count == 0)
+ count = fifo_size;
+ hscx_empty_fifo(bcs, count);
+ if ((count = bcs->hw.hscx.rcvidx - 1) > 0) {
+ if (cs->debug & L1_DEB_HSCX_FIFO) {
+ sprintf(tmp, "HX Frame %d", count);
+ debugl1(cs, tmp);
+ }
+ if (!(skb = dev_alloc_skb(count)))
+ printk(KERN_WARNING "HSCX: receive out of memory\n");
+ else {
+ memcpy(skb_put(skb, count), bcs->hw.hscx.rcvbuf, count);
+ skb_queue_tail(&bcs->rqueue, skb);
+ }
+ }
+ }
+ bcs->hw.hscx.rcvidx = 0;
+ hscx_sched_event(bcs, B_RCVBUFREADY);
+ }
+ if (val & 0x40) { /* RPF */
+ hscx_empty_fifo(bcs, fifo_size);
+ if (bcs->mode == L1_MODE_TRANS) {
+ /* receive audio data */
+ if (!(skb = dev_alloc_skb(fifo_size)))
+ printk(KERN_WARNING "HiSax: receive out of memory\n");
+ else {
+ memcpy(skb_put(skb, fifo_size), bcs->hw.hscx.rcvbuf, fifo_size);
+ skb_queue_tail(&bcs->rqueue, skb);
+ }
+ bcs->hw.hscx.rcvidx = 0;
+ hscx_sched_event(bcs, B_RCVBUFREADY);
+ }
+ }
+ if (val & 0x10) { /* XPR */
+ if (bcs->hw.hscx.tx_skb)
+ if (bcs->hw.hscx.tx_skb->len) {
+ hscx_fill_fifo(bcs);
+ return;
+ } else {
+ if (bcs->st->lli.l1writewakeup &&
+ (PACKET_NOACK != bcs->hw.hscx.tx_skb->pkt_type))
+ bcs->st->lli.l1writewakeup(bcs->st, bcs->hw.hscx.count);
+ dev_kfree_skb(bcs->hw.hscx.tx_skb);
+ bcs->hw.hscx.count = 0;
+ bcs->hw.hscx.tx_skb = NULL;
+ }
+ if ((bcs->hw.hscx.tx_skb = skb_dequeue(&bcs->squeue))) {
+ bcs->hw.hscx.count = 0;
+ test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
+ hscx_fill_fifo(bcs);
+ } else {
+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
+ hscx_sched_event(bcs, B_XMTBUFREADY);
+ }
+ }
+}
+
+static inline void
+hscx_int_main(struct IsdnCardState *cs, u_char val)
+{
+
+ u_char exval;
+ struct BCState *bcs;
+ char tmp[32];
+
+ if (val & 0x01) {
+ bcs = cs->bcs + 1;
+ exval = READHSCX(cs, 1, HSCX_EXIR);
+ if (exval == 0x40) {
+ if (bcs->mode == 1)
+ hscx_fill_fifo(bcs);
+ else {
+ /* Here we lost an TX interrupt, so
+ * restart transmitting the whole frame.
+ */
+ if (bcs->hw.hscx.tx_skb) {
+ skb_push(bcs->hw.hscx.tx_skb, bcs->hw.hscx.count);
+ bcs->tx_cnt += bcs->hw.hscx.count;
+ bcs->hw.hscx.count = 0;
+ }
+ WriteHSCXCMDR(cs, bcs->channel, 0x01);
+ if (cs->debug & L1_DEB_WARN) {
+ sprintf(tmp, "HSCX B EXIR %x Lost TX", exval);
+ debugl1(cs, tmp);
+ }
+ }
+ } else if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "HSCX B EXIR %x", exval);
+ debugl1(cs, tmp);
+ }
+ }
+ if (val & 0xf8) {
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "HSCX B interrupt %x", val);
+ debugl1(cs, tmp);
+ }
+ hscx_interrupt(cs, val, 1);
+ }
+ if (val & 0x02) {
+ bcs = cs->bcs;
+ exval = READHSCX(cs, 0, HSCX_EXIR);
+ if (exval == 0x40) {
+ if (bcs->mode == L1_MODE_TRANS)
+ hscx_fill_fifo(bcs);
+ else {
+ /* Here we lost an TX interrupt, so
+ * restart transmitting the whole frame.
+ */
+ if (bcs->hw.hscx.tx_skb) {
+ skb_push(bcs->hw.hscx.tx_skb, bcs->hw.hscx.count);
+ bcs->tx_cnt += bcs->hw.hscx.count;
+ bcs->hw.hscx.count = 0;
+ }
+ WriteHSCXCMDR(cs, bcs->channel, 0x01);
+ if (cs->debug & L1_DEB_WARN) {
+ sprintf(tmp, "HSCX A EXIR %x Lost TX", exval);
+ debugl1(cs, tmp);
+ }
+ }
+ } else if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "HSCX A EXIR %x", exval);
+ debugl1(cs, tmp);
+ }
+ }
+ if (val & 0x04) {
+ exval = READHSCX(cs, 0, HSCX_ISTA);
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "HSCX A interrupt %x", exval);
+ debugl1(cs, tmp);
+ }
+ hscx_interrupt(cs, exval, 0);
+ }
+}
diff --git a/drivers/isdn/hisax/ipac.h b/drivers/isdn/hisax/ipac.h
new file mode 100644
index 000000000..6d856ec6c
--- /dev/null
+++ b/drivers/isdn/hisax/ipac.h
@@ -0,0 +1,35 @@
+/* $Id: ipac.h,v 1.2 1997/10/29 18:51:21 keil Exp $
+
+ * ipac.h IPAC specific defines
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ *
+ * $Log: ipac.h,v $
+ * Revision 1.2 1997/10/29 18:51:21 keil
+ * New files
+ *
+ * Revision 1.1.2.1 1997/10/17 22:10:48 keil
+ * new files on 2.0
+ *
+ *
+ *
+ */
+
+
+/* All Registers original Siemens Spec */
+
+#define IPAC_CONF 0xC0
+#define IPAC_MASK 0xC1
+#define IPAC_ISTA 0xC1
+#define IPAC_ID 0xC2
+#define IPAC_ACFG 0xC3
+#define IPAC_AOE 0xC4
+#define IPAC_ARX 0xC5
+#define IPAC_PITA1 0xC6
+#define IPAC_PITA2 0xC7
+#define IPAC_POTA1 0xC8
+#define IPAC_POTA2 0xC9
+#define IPAC_PCFG 0xCA
+#define IPAC_SCFG 0xCB
+#define IPAC_TIMR2 0xCC
diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
new file mode 100644
index 000000000..9a2624ef4
--- /dev/null
+++ b/drivers/isdn/hisax/isac.c
@@ -0,0 +1,679 @@
+/* $Id: isac.c,v 1.12 1998/02/12 23:07:40 keil Exp $
+
+ * isac.c ISAC specific routines
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ *
+ * $Log: isac.c,v $
+ * Revision 1.12 1998/02/12 23:07:40 keil
+ * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
+ *
+ * Revision 1.11 1998/02/09 10:54:49 keil
+ * fixes for leased mode
+ *
+ * Revision 1.10 1998/02/02 13:37:37 keil
+ * new init
+ *
+ * Revision 1.9 1997/11/06 17:09:07 keil
+ * New 2.1 init code
+ *
+ * Revision 1.8 1997/10/29 19:00:03 keil
+ * new layer1,changes for 2.1
+ *
+ * Revision 1.7 1997/10/01 09:21:37 fritz
+ * Removed old compatibility stuff for 2.0.X kernels.
+ * From now on, this code is for 2.1.X ONLY!
+ * Old stuff is still in the separate branch.
+ *
+ * Revision 1.6 1997/08/15 17:47:08 keil
+ * avoid oops because a uninitialised timer
+ *
+ * Revision 1.5 1997/08/07 17:48:49 keil
+ * fix wrong parenthesis
+ *
+ * Revision 1.4 1997/07/30 17:11:59 keil
+ * fixed Timer3
+ *
+ * Revision 1.3 1997/07/27 21:37:40 keil
+ * T3 implemented; supervisor l1timer; B-channel TEST_LOOP
+ *
+ * Revision 1.2 1997/06/26 11:16:15 keil
+ * first version
+ *
+ *
+ */
+
+#define __NO_VERSION__
+#include "hisax.h"
+#include "isac.h"
+#include "isdnl1.h"
+#include <linux/interrupt.h>
+
+#define DBUSY_TIMER_VALUE 80
+#define ARCOFI_USE 1
+
+static char *ISACVer[] HISAX_INITDATA =
+{"2086/2186 V1.1", "2085 B1", "2085 B2",
+ "2085 V2.3"};
+
+void
+ISACVersion(struct IsdnCardState *cs, char *s)
+{
+ int val;
+
+ val = cs->readisac(cs, ISAC_RBCH);
+ printk(KERN_INFO "%s ISAC version : %s\n", s, 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);
+ }
+ 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) {
+ case (ISAC_IND_RS):
+ case (ISAC_IND_EI):
+ ph_command(cs, ISAC_CMD_DUI);
+ manl1_msg(cs, PH_RESET_IND, NULL);
+ break;
+ case (ISAC_IND_DID):
+ manl1_msg(cs, PH_DEACT_CNF, NULL);
+ break;
+ case (ISAC_IND_DR):
+ manl1_msg(cs, PH_DEACT_IND, NULL);
+ break;
+ case (ISAC_IND_PU):
+ manl1_msg(cs, PH_POWERUP_CNF, NULL);
+ break;
+ case (ISAC_IND_RSY):
+ manl1_msg(cs, PH_RSYNC_IND, NULL);
+ break;
+ case (ISAC_IND_ARD):
+ manl1_msg(cs, PH_INFO2_IND, NULL);
+ break;
+ case (ISAC_IND_AI8):
+ manl1_msg(cs, PH_I4_P8_IND, NULL);
+ break;
+ case (ISAC_IND_AI10):
+ manl1_msg(cs, PH_I4_P10_IND, NULL);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+isac_bh(struct IsdnCardState *cs)
+{
+ struct PStack *stptr;
+
+ 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 = stptr->next;
+ }
+ }
+ if (test_and_clear_bit(D_L1STATECHANGE, &cs->event))
+ isac_new_ph(cs);
+ if (test_and_clear_bit(D_RCVBUFREADY, &cs->event))
+ 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);
+ if (test_and_clear_bit(D_TX_MON1, &cs->event))
+ test_and_set_bit(HW_MON1_RX_END, &cs->HW_Flags);
+}
+
+void
+isac_empty_fifo(struct IsdnCardState *cs, int count)
+{
+ u_char *ptr;
+ long flags;
+
+ 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",
+ cs->rcvidx + count);
+ debugl1(cs, tmp);
+ }
+ cs->writeisac(cs, ISAC_CMDR, 0x80);
+ cs->rcvidx = 0;
+ return;
+ }
+ ptr = cs->rcvbuf + cs->rcvidx;
+ cs->rcvidx += count;
+ save_flags(flags);
+ cli();
+ cs->readisacfifo(cs, ptr, count);
+ cs->writeisac(cs, ISAC_CMDR, 0x80);
+ restore_flags(flags);
+ if (cs->debug & L1_DEB_ISAC_FIFO) {
+ char tmp[128];
+ char *t = tmp;
+
+ t += sprintf(t, "isac_empty_fifo cnt %d", count);
+ QuickHex(t, ptr, count);
+ debugl1(cs, tmp);
+ }
+}
+
+static void
+isac_fill_fifo(struct IsdnCardState *cs)
+{
+ int count, more;
+ u_char *ptr;
+ long flags;
+
+ if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO))
+ debugl1(cs, "isac_fill_fifo");
+
+ if (!cs->tx_skb)
+ return;
+
+ count = cs->tx_skb->len;
+ if (count <= 0)
+ return;
+
+ more = 0;
+ if (count > 32) {
+ more = !0;
+ count = 32;
+ }
+ save_flags(flags);
+ cli();
+ ptr = cs->tx_skb->data;
+ skb_pull(cs->tx_skb, count);
+ cs->tx_cnt += count;
+ cs->writeisacfifo(cs, ptr, count);
+ cs->writeisac(cs, ISAC_CMDR, more ? 0x8 : 0xa);
+ restore_flags(flags);
+ if (test_and_set_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) {
+ debugl1(cs, "isac_fill_fifo dbusytimer running");
+ del_timer(&cs->dbusytimer);
+ }
+ init_timer(&cs->dbusytimer);
+ 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;
+
+ t += sprintf(t, "isac_fill_fifo cnt %d", count);
+ QuickHex(t, ptr, count);
+ debugl1(cs, tmp);
+ }
+}
+
+void
+isac_sched_event(struct IsdnCardState *cs, int event)
+{
+ test_and_set_bit(event, &cs->event);
+ queue_task(&cs->tqueue, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+}
+
+void
+isac_interrupt(struct IsdnCardState *cs, u_char val)
+{
+ u_char exval, v1;
+ 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 (val & 0x80) { /* RME */
+ exval = cs->readisac(cs, ISAC_RSTA);
+ if ((exval & 0x70) != 0x20) {
+ if (exval & 0x40)
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "ISAC RDO");
+ if (!(exval & 0x20))
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "ISAC CRC error");
+ cs->writeisac(cs, ISAC_CMDR, 0x80);
+ } else {
+ count = cs->readisac(cs, ISAC_RBCL) & 0x1f;
+ if (count == 0)
+ count = 32;
+ isac_empty_fifo(cs, count);
+ save_flags(flags);
+ cli();
+ if ((count = cs->rcvidx) > 0) {
+ cs->rcvidx = 0;
+ if (!(skb = alloc_skb(count, GFP_ATOMIC)))
+ printk(KERN_WARNING "HiSax: D receive out of memory\n");
+ else {
+ memcpy(skb_put(skb, count), cs->rcvbuf, count);
+ skb_queue_tail(&cs->rq, skb);
+ }
+ }
+ restore_flags(flags);
+ }
+ cs->rcvidx = 0;
+ isac_sched_event(cs, D_RCVBUFREADY);
+ }
+ if (val & 0x40) { /* RPF */
+ isac_empty_fifo(cs, 32);
+ }
+ if (val & 0x20) { /* RSC */
+ /* never */
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "ISAC RSC interrupt");
+ }
+ if (val & 0x10) { /* XPR */
+ 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)
+ if (cs->tx_skb->len) {
+ isac_fill_fifo(cs);
+ goto afterXPR;
+ } else {
+ dev_kfree_skb(cs->tx_skb);
+ cs->tx_cnt = 0;
+ cs->tx_skb = NULL;
+ }
+ if ((cs->tx_skb = skb_dequeue(&cs->sq))) {
+ cs->tx_cnt = 0;
+ isac_fill_fifo(cs);
+ } else
+ isac_sched_event(cs, D_XMTBUFREADY);
+ }
+ 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);
+ }
+ isac_sched_event(cs, D_L1STATECHANGE);
+ }
+ if (val & 0x02) { /* SIN */
+ /* never */
+ if (cs->debug & L1_DEB_WARN)
+ debugl1(cs, "ISAC SIN interrupt");
+ }
+ 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 (exval & 0x04) {
+ v1 = cs->readisac(cs, ISAC_MOSR);
+ if (cs->debug & L1_DEB_WARN) {
+ sprintf(tmp, "ISAC MOSR %02x", v1);
+ debugl1(cs, tmp);
+ }
+#if ARCOFI_USE
+ if (v1 & 0x08) {
+ if (!cs->mon_rx)
+ if (!(cs->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);
+ goto afterMONR0;
+ } else
+ cs->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->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);
+ }
+ }
+ afterMONR0:
+ if (v1 & 0x80) {
+ if (!cs->mon_rx)
+ if (!(cs->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);
+ goto afterMONR1;
+ } else
+ cs->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->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);
+ }
+ }
+ afterMONR1:
+ if (v1 & 0x04) {
+ cs->mocr &= 0xf0;
+ cs->mocr |= 0x0a;
+ cs->writeisac(cs, ISAC_MOCR, cs->mocr);
+ isac_sched_event(cs, D_RX_MON0);
+ }
+ if (v1 & 0x40) {
+ cs->mocr &= 0x0f;
+ cs->mocr |= 0xa0;
+ cs->writeisac(cs, ISAC_MOCR, cs->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);
+ goto AfterMOX0;
+ }
+ if (cs->mon_txp >= cs->mon_txc) {
+ if (cs->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);
+ }
+ }
+ AfterMOX0:
+ if (v1 & 0x20) {
+ if (!cs->mon_tx) {
+ cs->mocr &= 0x0f;
+ cs->mocr |= 0xa0;
+ cs->writeisac(cs, ISAC_MOCR, cs->mocr);
+ goto AfterMOX1;
+ }
+ if (cs->mon_txp >= cs->mon_txc) {
+ if (cs->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);
+ }
+ }
+ AfterMOX1:
+#endif
+ }
+ }
+}
+
+static void
+ISAC_l2l1(struct PStack *st, int pr, void *arg)
+{
+ struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware;
+ struct sk_buff *skb = arg;
+ char str[64];
+
+ switch (pr) {
+ case (PH_DATA_REQ):
+ if (cs->tx_skb) {
+ skb_queue_tail(&cs->sq, skb);
+#ifdef L2FRAME_DEBUG /* psa */
+ if (cs->debug & L1_DEB_LAPD)
+ 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 */
+ if (cs->debug & L1_DEB_LAPD)
+ Logl2Frame(cs, skb, "PH_DATA", 0);
+#endif
+ isac_fill_fifo(cs);
+ }
+ break;
+ case (PH_PULL_IND):
+ 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 */
+ 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 */
+ if (cs->debug & L1_DEB_LAPD)
+ Logl2Frame(cs, skb, "PH_DATA_PULLED", 0);
+#endif
+ isac_fill_fifo(cs);
+ break;
+ case (PH_PULL_REQ):
+#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);
+ } 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))
+ ph_command(cs, ISAC_CMD_TIM);
+ else
+ ph_command(cs, ISAC_CMD_RS);
+ break;
+ case PH_ENABLE_REQ:
+ ph_command(cs, ISAC_CMD_TIM);
+ break;
+ case PH_INFO3_REQ:
+ ph_command(cs, ISAC_CMD_AR8);
+ break;
+ case PH_TESTLOOP_REQ:
+ val = 0;
+ if (1 & (int) arg)
+ val |= 0x0c;
+ if (2 & (int) arg)
+ val |= 0x3;
+ if (test_bit(HW_IOM1, &cs->HW_Flags)) {
+ /* IOM 1 Mode */
+ if (!val) {
+ cs->writeisac(cs, ISAC_SPCR, 0xa);
+ cs->writeisac(cs, ISAC_ADF1, 0x2);
+ } else {
+ cs->writeisac(cs, ISAC_SPCR, val);
+ cs->writeisac(cs, ISAC_ADF1, 0xa);
+ }
+ } else {
+ /* IOM 2 Mode */
+ cs->writeisac(cs, ISAC_SPCR, val);
+ if (val)
+ cs->writeisac(cs, ISAC_ADF1, 0x8);
+ else
+ cs->writeisac(cs, ISAC_ADF1, 0x0);
+ }
+ break;
+ default:
+ if (cs->debug & L1_DEB_WARN) {
+ sprintf(tmp, "isac_l1cmd unknown %4x", msg);
+ debugl1(cs, tmp);
+ }
+ break;
+ }
+}
+
+void
+setstack_isac(struct PStack *st, struct IsdnCardState *cs)
+{
+ st->l2.l2l1 = ISAC_l2l1;
+}
+
+static void
+dbusy_timer_handler(struct IsdnCardState *cs)
+{
+ struct PStack *stptr;
+
+ 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;
+ }
+ }
+}
+
+HISAX_INITFUNC(void
+initisac(struct IsdnCardState *cs))
+{
+ cs->tqueue.routine = (void *) (void *) isac_bh;
+ cs->l1cmd = isac_l1cmd;
+ cs->setstack_d = setstack_isac;
+ 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;
+ if (test_bit(HW_IOM1, &cs->HW_Flags)) {
+ /* IOM 1 Mode */
+ cs->writeisac(cs, ISAC_ADF2, 0x0);
+ cs->writeisac(cs, ISAC_SPCR, 0xa);
+ cs->writeisac(cs, ISAC_ADF1, 0x2);
+ cs->writeisac(cs, ISAC_STCR, 0x70);
+ cs->writeisac(cs, ISAC_MODE, 0xc9);
+ } else {
+ /* IOM 2 Mode */
+ cs->writeisac(cs, ISAC_ADF2, 0x80);
+ cs->writeisac(cs, ISAC_SQXR, 0x2f);
+ cs->writeisac(cs, ISAC_SPCR, 0x00);
+ cs->writeisac(cs, ISAC_STCR, 0x70);
+ cs->writeisac(cs, ISAC_MODE, 0xc9);
+ cs->writeisac(cs, ISAC_TIMR, 0x00);
+ cs->writeisac(cs, ISAC_ADF1, 0x00);
+ }
+ ph_command(cs, ISAC_CMD_RS);
+ cs->writeisac(cs, ISAC_MASK, 0x0);
+}
+
+HISAX_INITFUNC(void
+clear_pending_isac_ints(struct IsdnCardState *cs))
+{
+ int val;
+ char tmp[64];
+
+ val = cs->readisac(cs, ISAC_STAR);
+ sprintf(tmp, "ISAC STAR %x", val);
+ debugl1(cs, tmp);
+ val = cs->readisac(cs, ISAC_MODE);
+ sprintf(tmp, "ISAC MODE %x", val);
+ debugl1(cs, tmp);
+ val = cs->readisac(cs, ISAC_ADF2);
+ sprintf(tmp, "ISAC ADF2 %x", val);
+ debugl1(cs, tmp);
+ val = cs->readisac(cs, ISAC_ISTA);
+ sprintf(tmp, "ISAC ISTA %x", val);
+ debugl1(cs, tmp);
+ 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;
+ }
+ isac_sched_event(cs, D_L1STATECHANGE);
+ cs->writeisac(cs, ISAC_MASK, 0xFF);
+ cs->writeisac(cs, ISAC_MASK, 0);
+ cs->writeisac(cs, ISAC_CMDR, 0x41);
+}
diff --git a/drivers/isdn/hisax/isac.h b/drivers/isdn/hisax/isac.h
new file mode 100644
index 000000000..ac4d55647
--- /dev/null
+++ b/drivers/isdn/hisax/isac.h
@@ -0,0 +1,74 @@
+/* $Id: isac.h,v 1.4 1997/10/29 19:09:34 keil Exp $
+
+ * isac.h ISAC specific defines
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ *
+ * $Log: isac.h,v $
+ * Revision 1.4 1997/10/29 19:09:34 keil
+ * new L1
+ *
+ * Revision 1.3 1997/07/27 21:37:41 keil
+ * T3 implemented; supervisor l1timer; B-channel TEST_LOOP
+ *
+ * Revision 1.2 1997/06/26 11:16:16 keil
+ * first version
+ *
+ *
+ */
+
+
+/* All Registers original Siemens Spec */
+
+#define ISAC_MASK 0x20
+#define ISAC_ISTA 0x20
+#define ISAC_STAR 0x21
+#define ISAC_CMDR 0x21
+#define ISAC_EXIR 0x24
+#define ISAC_RBCH 0x2a
+#define ISAC_ADF2 0x39
+#define ISAC_SPCR 0x30
+#define ISAC_ADF1 0x38
+#define ISAC_CIR0 0x31
+#define ISAC_CIX0 0x31
+#define ISAC_STCR 0x37
+#define ISAC_MODE 0x22
+#define ISAC_RSTA 0x27
+#define ISAC_RBCL 0x25
+#define ISAC_TIMR 0x23
+#define ISAC_SQXR 0x3b
+#define ISAC_MOSR 0x3a
+#define ISAC_MOCR 0x3a
+#define ISAC_MOR0 0x32
+#define ISAC_MOX0 0x32
+#define ISAC_MOR1 0x34
+#define ISAC_MOX1 0x34
+
+#define ISAC_CMD_TIM 0x0
+#define ISAC_CMD_RS 0x1
+#define ISAC_CMD_SCZ 0x4
+#define ISAC_CMD_SSZ 0x2
+#define ISAC_CMD_AR8 0x8
+#define ISAC_CMD_AR10 0x9
+#define ISAC_CMD_ARL 0xA
+#define ISAC_CMD_DUI 0xF
+
+#define ISAC_IND_RS 0x1
+#define ISAC_IND_PU 0x7
+#define ISAC_IND_DR 0x0
+#define ISAC_IND_SD 0x2
+#define ISAC_IND_DIS 0x3
+#define ISAC_IND_EI 0x6
+#define ISAC_IND_RSY 0x4
+#define ISAC_IND_ARD 0x8
+#define ISAC_IND_TI 0xA
+#define ISAC_IND_ATI 0xB
+#define ISAC_IND_AI8 0xC
+#define ISAC_IND_AI10 0xD
+#define ISAC_IND_DID 0xF
+
+extern void ISACVersion(struct IsdnCardState *cs, char *s);
+extern void initisac(struct IsdnCardState *cs);
+extern void isac_interrupt(struct IsdnCardState *cs, u_char val);
+extern void clear_pending_isac_ints(struct IsdnCardState *cs);
diff --git a/drivers/isdn/hisax/isdnl1.c b/drivers/isdn/hisax/isdnl1.c
index 655e6a417..8c4431b04 100644
--- a/drivers/isdn/hisax/isdnl1.c
+++ b/drivers/isdn/hisax/isdnl1.c
@@ -1,4 +1,4 @@
-/* $Id: isdnl1.c,v 1.15 1997/05/27 15:17:55 fritz Exp $
+/* $Id: isdnl1.c,v 2.18 1998/02/12 23:07:42 keil Exp $
* isdnl1.c common low level stuff for Siemens Chipsetbased isdn cards
* based on the teles driver from Jan den Ouden
@@ -11,131 +11,239 @@
*
*
* $Log: isdnl1.c,v $
- * Revision 1.15 1997/05/27 15:17:55 fritz
- * Added changes for recent 2.1.x kernels:
- * changed return type of isdn_close
- * queue_task_* -> queue_task
- * clear/set_bit -> test_and_... where apropriate.
- * changed type of hard_header_cache parameter.
+ * Revision 2.18 1998/02/12 23:07:42 keil
+ * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
+ *
+ * Revision 2.17 1998/02/11 17:28:07 keil
+ * Niccy PnP/PCI support
+ *
+ * Revision 2.16 1998/02/09 18:46:08 keil
+ * Support for Sedlbauer PCMCIA (Marcus Niemann)
*
- * Revision 1.14 1997/04/07 23:00:08 keil
- * GFP_KERNEL ---> GFP_ATOMIC
+ * Revision 2.15 1998/02/09 10:54:51 keil
+ * fixes for leased mode
*
- * Revision 1.13 1997/04/06 22:55:50 keil
- * Using SKB's
+ * Revision 2.14 1998/02/03 23:31:31 keil
+ * add AMD7930 support
*
- * Revision 1.12 1997/03/26 13:43:57 keil
- * small cosmetics
+ * Revision 2.13 1998/02/02 13:33:02 keil
+ * New card support
*
- * Revision 1.11 1997/03/25 23:11:23 keil
- * US NI-1 protocol
+ * Revision 2.12 1998/01/31 21:41:48 keil
+ * changes for newer 2.1 kernels
*
- * Revision 1.10 1997/03/13 14:45:05 keil
- * using IRQ proof queue_task
+ * Revision 2.11 1997/11/12 15:01:23 keil
+ * COMPAQ_ISA changes
*
- * Revision 1.9 1997/03/12 21:44:21 keil
- * change Interrupt routine from atomic quick to normal
+ * Revision 2.10 1997/11/08 21:35:48 keil
+ * new l1 init
*
- * Revision 1.8 1997/02/09 00:24:31 keil
- * new interface handling, one interface per card
+ * Revision 2.9 1997/11/06 17:09:18 keil
+ * New 2.1 init code
*
- * Revision 1.7 1997/01/27 15:56:03 keil
- * PCMCIA Teles card and ITK ix1 micro added
+ * Revision 2.8 1997/10/29 19:00:05 keil
+ * new layer1,changes for 2.1
*
- * Revision 1.6 1997/01/21 22:20:00 keil
- * changes for D-channel log; Elsa Quickstep support
+ * Revision 2.7 1997/10/10 20:56:50 fritz
+ * New HL interface.
*
- * Revision 1.5 1997/01/10 12:51:19 keil
- * cleanup; set newversion
+ * Revision 2.6 1997/09/12 10:05:16 keil
+ * ISDN_CTRL_DEBUG define
*
- * Revision 1.4 1996/12/08 19:44:53 keil
- * L2FRAME_DEBUG and other changes from Pekka Sarnila
+ * Revision 2.5 1997/09/11 17:24:45 keil
+ * Add new cards
*
- * Revision 1.3 1996/11/18 15:34:47 keil
- * fix HSCX version code
+ * Revision 2.4 1997/08/15 17:47:09 keil
+ * avoid oops because a uninitialised timer
*
- * Revision 1.2 1996/10/27 22:16:54 keil
- * ISAC/HSCX version lookup
+ * Revision 2.3 1997/08/01 11:16:40 keil
+ * cosmetics
*
- * Revision 1.1 1996/10/13 20:04:53 keil
- * Initial revision
+ * Revision 2.2 1997/07/30 17:11:08 keil
+ * L1deactivated exported
*
+ * Revision 2.1 1997/07/27 21:35:38 keil
+ * new layer1 interface
+ *
+ * Revision 2.0 1997/06/26 11:02:53 keil
+ * New Layer and card interface
+ *
+ * Revision 1.15 1997/05/27 15:17:55 fritz
+ * Added changes for recent 2.1.x kernels:
+ * changed return type of isdn_close
+ * queue_task_* -> queue_task
+ * clear/set_bit -> test_and_... where apropriate.
+ * changed type of hard_header_cache parameter.
*
+ * old changes removed KKe
*
*/
-const char *l1_revision = "$Revision: 1.15 $";
+const char *l1_revision = "$Revision: 2.18 $";
#define __NO_VERSION__
#include <linux/config.h>
#include "hisax.h"
#include "isdnl1.h"
+#include <linux/kernel_stat.h>
+#if (LINUX_VERSION_CODE < 0x020150) /* 2.1.80 */
+#define kstat_irqs( PAR ) kstat.interrupts( (PAR) )
+#endif
+
+
#if CARD_TELES0
-#include "teles0.h"
+extern int setup_teles0(struct IsdnCard *card);
#endif
#if CARD_TELES3
-#include "teles3.h"
+extern int setup_teles3(struct IsdnCard *card);
#endif
#if CARD_AVM_A1
-#include "avm_a1.h"
+extern int setup_avm_a1(struct IsdnCard *card);
#endif
#if CARD_ELSA
-#include "elsa.h"
+extern int setup_elsa(struct IsdnCard *card);
#endif
#if CARD_IX1MICROR2
-#include "ix1_micro.h"
+extern int setup_ix1micro(struct IsdnCard *card);
#endif
-/* #define I4L_IRQ_FLAG SA_INTERRUPT */
-#define I4L_IRQ_FLAG 0
+#if CARD_DIEHLDIVA
+extern int setup_diva(struct IsdnCard *card);
+#endif
-#define HISAX_STATUS_BUFSIZE 4096
+#if CARD_ASUSCOM
+extern int setup_asuscom(struct IsdnCard *card);
+#endif
-#define INCLUDE_INLINE_FUNCS
-#include <linux/tqueue.h>
-#include <linux/interrupt.h>
+#if CARD_TELEINT
+extern int setup_TeleInt(struct IsdnCard *card);
+#endif
-const char *CardType[] =
-{"No Card", "Teles 16.0", "Teles 8.0", "Teles 16.3",
- "Creatix/Teles PnP", "AVM A1", "Elsa ML",
-#ifdef CONFIG_HISAX_ELSA_PCMCIA
- "Elsa PCMCIA",
-#else
- "Elsa Quickstep",
+#if CARD_SEDLBAUER
+extern int setup_sedlbauer(struct IsdnCard *card);
+#endif
+
+#if CARD_SPORTSTER
+extern int setup_sportster(struct IsdnCard *card);
+#endif
+
+#if CARD_MIC
+extern int setup_mic(struct IsdnCard *card);
#endif
- "Teles PCMCIA", "ITK ix1-micro Rev.2"};
-static char *HSCXVer[] =
-{"A1", "?1", "A2", "?3", "A3", "V2.1", "?6", "?7",
- "?8", "?9", "?10", "?11", "?12", "?13", "?14", "???"};
+#if CARD_NETJET
+extern int setup_netjet(struct IsdnCard *card);
+#endif
+
+#if CARD_TELES3C
+extern int setup_t163c(struct IsdnCard *card);
+#endif
+
+#if CARD_AMD7930
+extern int setup_amd7930(struct IsdnCard *card);
+#endif
+
+#if CARD_NICCY
+extern int setup_niccy(struct IsdnCard *card);
+#endif
-static char *ISACVer[] =
-{"2086/2186 V1.1", "2085 B1", "2085 B2",
- "2085 V2.3"};
+#define HISAX_STATUS_BUFSIZE 4096
+#define ISDN_CTRL_DEBUG 1
+#define INCLUDE_INLINE_FUNCS
+#include <linux/tqueue.h>
+#include <linux/interrupt.h>
+const char *CardType[] =
+{"No Card", "Teles 16.0", "Teles 8.0", "Teles 16.3", "Creatix/Teles PnP",
+ "AVM A1", "Elsa ML", "Elsa Quickstep", "Teles PCMCIA", "ITK ix1-micro Rev.2",
+ "Elsa PCMCIA", "Eicon.Diehl Diva", "ISDNLink", "TeleInt", "Teles 16.3c",
+ "Sedlbauer Speed Card", "USR Sportster", "ith mic Linux", "Elsa PCI",
+ "Compaq ISA", "NETjet", "Teles PCI", "Sedlbauer Speed Star (PCMCIA)",
+ "AMD 7930", "NICCY"
+};
extern struct IsdnCard cards[];
extern int nrcards;
extern char *HiSax_id;
+extern struct IsdnBuffers *tracebuf;
+
+#define TIMER3_VALUE 7
+
+static
+struct Fsm l1fsm =
+{NULL, 0, 0, NULL, NULL};
+
+enum {
+ ST_L1_F2,
+ ST_L1_F3,
+ ST_L1_F4,
+ ST_L1_F5,
+ ST_L1_F6,
+ ST_L1_F7,
+ ST_L1_F8,
+};
+
+#define L1_STATE_COUNT (ST_L1_F8+1)
+
+static char *strL1State[] =
+{
+ "ST_L1_F2",
+ "ST_L1_F3",
+ "ST_L1_F4",
+ "ST_L1_F5",
+ "ST_L1_F6",
+ "ST_L1_F7",
+ "ST_L1_F8",
+};
+
+enum {
+ EV_PH_ACTIVATE,
+ EV_RESET_IND,
+ EV_DEACT_CNF,
+ EV_DEACT_IND,
+ EV_POWER_UP,
+ EV_RSYNC_IND,
+ EV_INFO2_IND,
+ EV_INFO4_IND,
+ EV_TIMER_DEACT,
+ EV_TIMER_ACT,
+ EV_TIMER3,
+};
+
+#define L1_EVENT_COUNT (EV_TIMER3 + 1)
+
+static char *strL1Event[] =
+{
+ "EV_PH_ACTIVATE",
+ "EV_RESET_IND",
+ "EV_DEACT_CNF",
+ "EV_DEACT_IND",
+ "EV_POWER_UP",
+ "EV_RSYNC_IND",
+ "EV_INFO2_IND",
+ "EV_INFO4_IND",
+ "EV_TIMER_DEACT",
+ "EV_TIMER_ACT",
+ "EV_TIMER3",
+};
/*
* Find card with given driverId
*/
static inline struct IsdnCardState
-*
-hisax_findcard(int driverid)
+*hisax_findcard(int driverid)
{
int i;
for (i = 0; i < nrcards; i++)
- if (cards[i].sp)
- if (cards[i].sp->myid == driverid)
- return (cards[i].sp);
- return (struct IsdnCardState *) 0;
+ if (cards[i].cs)
+ if (cards[i].cs->myid == driverid)
+ return (cards[i].cs);
+ return (NULL);
}
int
@@ -162,6 +270,7 @@ HiSax_readstatus(u_char * buf, int len, int user, int id, int channel)
}
}
+#if ISDN_CTRL_DEBUG
void
HiSax_putstatus(struct IsdnCardState *csta, char *buf)
{
@@ -194,6 +303,23 @@ HiSax_putstatus(struct IsdnCardState *csta, char *buf)
csta->iif.statcallb(&ic);
}
}
+#else
+#define KDEBUG_DEF
+#include "../kdebug.h"
+
+static int DbgLineNr=0,DbgSequenzNr=1;
+
+void
+HiSax_putstatus(struct IsdnCardState *csta, char *buf)
+{
+ char tmp[512];
+
+ if (DbgLineNr==23)
+ DbgLineNr=0;
+ sprintf(tmp, "%5d %s",DbgSequenzNr++,buf);
+ gput_str(tmp,0,DbgLineNr++);
+}
+#endif
int
ll_run(struct IsdnCardState *csta)
@@ -238,228 +364,119 @@ ll_unload(struct IsdnCardState *csta)
}
void
-debugl1(struct IsdnCardState *sp, char *msg)
+debugl1(struct IsdnCardState *cs, char *msg)
{
char tmp[256], tm[32];
jiftime(tm, jiffies);
- sprintf(tmp, "%s Card %d %s\n", tm, sp->cardnr + 1, msg);
- HiSax_putstatus(sp, tmp);
-}
-
-/*
- * HSCX stuff goes here
- */
-
-
-char *
-HscxVersion(u_char v)
-{
- return (HSCXVer[v & 0xf]);
-}
-
-void
-hscx_sched_event(struct HscxState *hsp, int event)
-{
- hsp->event |= 1 << event;
- queue_task(&hsp->tqueue, &tq_immediate);
- mark_bh(IMMEDIATE_BH);
+ sprintf(tmp, "%s Card %d %s\n", tm, cs->cardnr + 1, msg);
+ HiSax_putstatus(cs, tmp);
}
-/*
- * ISAC stuff goes here
- */
-
-char *
-ISACVersion(u_char v)
+static void
+l1m_debug(struct FsmInst *fi, char *s)
{
- return (ISACVer[(v >> 5) & 3]);
+ struct PStack *st = fi->userdata;
+
+ debugl1(st->l1.hardware, s);
}
void
-isac_sched_event(struct IsdnCardState *sp, int event)
-{
- sp->event |= 1 << event;
- queue_task(&sp->tqueue, &tq_immediate);
- mark_bh(IMMEDIATE_BH);
-}
-
-int
-act_wanted(struct IsdnCardState *sp)
+L1activated(struct IsdnCardState *cs)
{
struct PStack *st;
- st = sp->stlist;
- while (st)
- if (st->l1.act_state)
- return (!0);
+ st = cs->stlist;
+ while (st) {
+ if (test_and_clear_bit(FLG_L1_ACTIVATING, &st->l1.Flags))
+ st->l1.l1man(st, PH_ACTIVATE_CNF, NULL);
else
- st = st->next;
- return (0);
-}
-
-void
-isac_new_ph(struct IsdnCardState *sp)
-{
- int enq;
-
- enq = act_wanted(sp);
-
- switch (sp->ph_state) {
- case (6):
- sp->ph_active = 0;
- sp->ph_command(sp, 15);
- break;
- case (15):
- sp->ph_active = 0;
- if (enq)
- sp->ph_command(sp, 0);
- break;
- case (0):
- sp->ph_active = 0;
- if (enq)
- sp->ph_command(sp, 0);
-#if 0
- else
- sp->ph_command(sp, 15);
-#endif
- break;
- case (7):
- sp->ph_active = 0;
- if (enq)
- sp->ph_command(sp, 9);
- break;
- case (12):
- sp->ph_command(sp, 8);
- sp->ph_active = 5;
- isac_sched_event(sp, ISAC_PHCHANGE);
- if (!sp->tx_skb)
- sp->tx_skb = skb_dequeue(&sp->sq);
- if (sp->tx_skb) {
- sp->tx_cnt = 0;
- sp->isac_fill_fifo(sp);
- }
- break;
- case (13):
- sp->ph_command(sp, 9);
- sp->ph_active = 5;
- isac_sched_event(sp, ISAC_PHCHANGE);
- if (!sp->tx_skb)
- sp->tx_skb = skb_dequeue(&sp->sq);
- if (sp->tx_skb) {
- sp->tx_cnt = 0;
- sp->isac_fill_fifo(sp);
- }
- break;
- case (4):
- case (8):
- sp->ph_active = 0;
- break;
- default:
- sp->ph_active = 0;
- break;
- }
-}
-
-static void
-restart_ph(struct IsdnCardState *sp)
-{
- if (!sp->ph_active) {
- if ((sp->ph_state == 6) || (sp->ph_state == 0)) {
- sp->ph_command(sp, 0);
- sp->ph_active = 2;
- } else {
- sp->ph_command(sp, 1);
- sp->ph_active = 1;
- }
- } else if (sp->ph_active == 2) {
- sp->ph_command(sp, 1);
- sp->ph_active = 1;
+ st->l1.l1man(st, PH_ACTIVATE_IND, NULL);
+ st = st->next;
}
}
-
-static void
-act_ivated(struct IsdnCardState *sp)
+void
+L1deactivated(struct IsdnCardState *cs)
{
struct PStack *st;
- st = sp->stlist;
+ st = cs->stlist;
while (st) {
- if (st->l1.act_state == 1) {
- st->l1.act_state = 2;
- st->l1.l1man(st, PH_ACTIVATE, NULL);
- }
+ if (test_bit(FLG_L1_DBUSY, &cs->HW_Flags))
+ st->l1.l1l2(st, PH_PAUSE_CNF, NULL);
+ st->l1.l1man(st, PH_DEACTIVATE_IND, NULL);
st = st->next;
}
+ test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags);
}
-static void
-process_new_ph(struct IsdnCardState *sp)
-{
- if (sp->ph_active == 5)
- act_ivated(sp);
-}
-
-static void
-process_xmt(struct IsdnCardState *sp)
+void
+DChannel_proc_xmt(struct IsdnCardState *cs)
{
struct PStack *stptr;
- if (sp->tx_skb)
+ if (cs->tx_skb)
return;
- stptr = sp->stlist;
+ stptr = cs->stlist;
while (stptr != NULL)
- if (stptr->l1.requestpull) {
- stptr->l1.requestpull = 0;
- stptr->l1.l1l2(stptr, PH_PULL_ACK, NULL);
+ if (test_and_clear_bit(FLG_L1_PULL_REQ, &stptr->l1.Flags)) {
+ stptr->l1.l1l2(stptr, PH_PULL_CNF, NULL);
break;
} else
stptr = stptr->next;
}
-static void
-process_rcv(struct IsdnCardState *sp)
+void
+DChannel_proc_rcv(struct IsdnCardState *cs)
{
struct sk_buff *skb, *nskb;
- struct PStack *stptr;
- int found, broadc;
+ struct PStack *stptr = cs->stlist;
+ int found, tei, sapi;
char tmp[64];
- while ((skb = skb_dequeue(&sp->rq))) {
+ if (stptr)
+ if (test_bit(FLG_L1_ACTTIMER, &stptr->l1.Flags))
+ FsmEvent(&stptr->l1.l1m, EV_TIMER_ACT, NULL);
+ while ((skb = skb_dequeue(&cs->rq))) {
#ifdef L2FRAME_DEBUG /* psa */
- if (sp->debug & L1_DEB_LAPD)
- Logl2Frame(sp, skb, "PH_DATA", 1);
+ if (cs->debug & L1_DEB_LAPD)
+ Logl2Frame(cs, skb, "PH_DATA", 1);
#endif
- stptr = sp->stlist;
- broadc = (skb->data[1] >> 1) == 127;
-
- if (broadc) {
- if (!(skb->data[0] >> 2)) { /* sapi 0 */
- sp->CallFlags = 3;
- if (sp->dlogflag) {
- LogFrame(sp, skb->data, skb->len);
- dlogframe(sp, skb->data + 3, skb->len - 3,
+ stptr = cs->stlist;
+ sapi = skb->data[0] >> 2;
+ tei = skb->data[1] >> 1;
+
+ if (tei == GROUP_TEI) {
+ if (sapi == CTRL_SAPI) { /* sapi 0 */
+ if (cs->dlogflag) {
+ LogFrame(cs, skb->data, skb->len);
+ dlogframe(cs, skb->data + 3, skb->len - 3,
"Q.931 frame network->user broadcast");
}
- }
- while (stptr != NULL) {
- if ((skb->data[0] >> 2) == stptr->l2.sap)
+ while (stptr != NULL) {
if ((nskb = skb_clone(skb, GFP_ATOMIC)))
- stptr->l1.l1l2(stptr, PH_DATA, nskb);
+ stptr->l1.l1l2(stptr, PH_DATA_IND, nskb);
else
printk(KERN_WARNING "HiSax: isdn broadcast buffer shortage\n");
- stptr = stptr->next;
+ stptr = stptr->next;
+ }
+ } else if (sapi == TEI_SAPI) {
+ while (stptr != NULL) {
+ if ((nskb = skb_clone(skb, GFP_ATOMIC)))
+ stptr->l1.l1tei(stptr, PH_DATA_IND, nskb);
+ else
+ printk(KERN_WARNING "HiSax: tei broadcast buffer shortage\n");
+ stptr = stptr->next;
+ }
}
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
- } else {
+ } else if (sapi == CTRL_SAPI) {
found = 0;
while (stptr != NULL)
- if (((skb->data[0] >> 2) == stptr->l2.sap) &&
- ((skb->data[1] >> 1) == stptr->l2.tei)) {
- stptr->l1.l1l2(stptr, PH_DATA, skb);
+ if (tei == stptr->l2.tei) {
+ stptr->l1.l1l2(stptr, PH_DATA_IND, skb);
found = !0;
break;
} else
@@ -474,167 +491,70 @@ process_rcv(struct IsdnCardState *sp)
sprintf(tmp,
"Q.931 frame network->user with tei %d (not for us)",
skb->data[1] >> 1);
- LogFrame(sp, skb->data, skb->len);
- dlogframe(sp, skb->data + 4, skb->len - 4, tmp);
+ LogFrame(cs, skb->data, skb->len);
+ dlogframe(cs, skb->data + 4, skb->len - 4, tmp);
}
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
}
}
-
- }
-
-}
-
-static void
-isac_bh(struct IsdnCardState *sp)
-{
- if (!sp)
- return;
-
- if (test_and_clear_bit(ISAC_PHCHANGE, &sp->event))
- process_new_ph(sp);
- if (test_and_clear_bit(ISAC_RCVBUFREADY, &sp->event))
- process_rcv(sp);
- if (test_and_clear_bit(ISAC_XMTBUFREADY, &sp->event))
- process_xmt(sp);
-}
-
-static void
-l2l1(struct PStack *st, int pr, void *arg)
-{
- struct IsdnCardState *sp = (struct IsdnCardState *) st->l1.hardware;
- struct sk_buff *skb = arg;
- char str[64];
-
- switch (pr) {
- case (PH_DATA):
- if (sp->tx_skb) {
- skb_queue_tail(&sp->sq, skb);
-#ifdef L2FRAME_DEBUG /* psa */
- if (sp->debug & L1_DEB_LAPD)
- Logl2Frame(sp, skb, "PH_DATA Queued", 0);
-#endif
- } else {
- if ((sp->dlogflag) && (!(skb->data[2] & 1))) { /* I-FRAME */
- LogFrame(sp, skb->data, skb->len);
- sprintf(str, "Q.931 frame user->network tei %d", st->l2.tei);
- dlogframe(sp, skb->data + st->l2.ihsize, skb->len - st->l2.ihsize,
- str);
- }
- sp->tx_skb = skb;
- sp->tx_cnt = 0;
-#ifdef L2FRAME_DEBUG /* psa */
- if (sp->debug & L1_DEB_LAPD)
- Logl2Frame(sp, skb, "PH_DATA", 0);
-#endif
- sp->isac_fill_fifo(sp);
- }
- break;
- case (PH_DATA_PULLED):
- if (sp->tx_skb) {
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, " l2l1 tx_skb exist this shouldn't happen");
- break;
- }
- if ((sp->dlogflag) && (!(skb->data[2] & 1))) { /* I-FRAME */
- LogFrame(sp, skb->data, skb->len);
- sprintf(str, "Q.931 frame user->network tei %d", st->l2.tei);
- dlogframe(sp, skb->data + st->l2.ihsize, skb->len - st->l2.ihsize,
- str);
- }
- sp->tx_skb = skb;
- sp->tx_cnt = 0;
-#ifdef L2FRAME_DEBUG /* psa */
- if (sp->debug & L1_DEB_LAPD)
- Logl2Frame(sp, skb, "PH_DATA_PULLED", 0);
-#endif
- sp->isac_fill_fifo(sp);
- break;
- case (PH_REQUEST_PULL):
-#ifdef L2FRAME_DEBUG /* psa */
- if (sp->debug & L1_DEB_LAPD)
- debugl1(sp, "-> PH_REQUEST_PULL");
-#endif
- if (!sp->tx_skb) {
- st->l1.requestpull = 0;
- st->l1.l1l2(st, PH_PULL_ACK, NULL);
- } else
- st->l1.requestpull = !0;
- break;
}
}
-
static void
-hscx_process_xmt(struct HscxState *hsp)
+BChannel_proc_xmt(struct BCState *bcs)
{
- struct PStack *st = hsp->st;
+ struct PStack *st = bcs->st;
- if (hsp->tx_skb)
+ if (test_bit(BC_FLG_BUSY, &bcs->Flag))
return;
- if (st->l1.requestpull) {
- st->l1.requestpull = 0;
- st->l1.l1l2(st, PH_PULL_ACK, NULL);
- }
- if (!hsp->active)
- if ((!hsp->tx_skb) && (!skb_queue_len(&hsp->squeue)))
- hsp->sp->modehscx(hsp, 0, 0);
+ if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags))
+ st->l1.l1l2(st, PH_PULL_CNF, NULL);
+ if (!test_bit(BC_FLG_ACTIV, &bcs->Flag))
+ if (!test_bit(BC_FLG_BUSY, &bcs->Flag) && (!skb_queue_len(&bcs->squeue)))
+ st->ma.manl1(st, PH_DEACTIVATE_CNF, 0);
}
static void
-hscx_process_rcv(struct HscxState *hsp)
+BChannel_proc_rcv(struct BCState *bcs)
{
struct sk_buff *skb;
-#ifdef DEBUG_MAGIC
- if (hsp->magic != 301270) {
- printk(KERN_DEBUG "hscx_process_rcv magic not 301270\n");
- return;
- }
-#endif
- while ((skb = skb_dequeue(&hsp->rqueue))) {
- hsp->st->l1.l1l2(hsp->st, PH_DATA, skb);
+ while ((skb = skb_dequeue(&bcs->rqueue))) {
+ bcs->st->l1.l1l2(bcs->st, PH_DATA_IND, skb);
}
}
static void
-hscx_bh(struct HscxState *hsp)
+BChannel_bh(struct BCState *bcs)
{
-
- if (!hsp)
+ if (!bcs)
return;
-
- if (test_and_clear_bit(HSCX_RCVBUFREADY, &hsp->event))
- hscx_process_rcv(hsp);
- if (test_and_clear_bit(HSCX_XMTBUFREADY, &hsp->event))
- hscx_process_xmt(hsp);
-
+ if (test_and_clear_bit(B_RCVBUFREADY, &bcs->event))
+ BChannel_proc_rcv(bcs);
+ if (test_and_clear_bit(B_XMTBUFREADY, &bcs->event))
+ BChannel_proc_xmt(bcs);
}
-/*
- * interrupt stuff ends here
- */
-
void
-HiSax_addlist(struct IsdnCardState *sp,
+HiSax_addlist(struct IsdnCardState *cs,
struct PStack *st)
{
- st->next = sp->stlist;
- sp->stlist = st;
+ st->next = cs->stlist;
+ cs->stlist = st;
}
void
-HiSax_rmlist(struct IsdnCardState *sp,
+HiSax_rmlist(struct IsdnCardState *cs,
struct PStack *st)
{
struct PStack *p;
- if (sp->stlist == st)
- sp->stlist = st->next;
+ FsmDelTimer(&st->l1.timer, 0);
+ if (cs->stlist == st)
+ cs->stlist = st->next;
else {
- p = sp->stlist;
+ p = cs->stlist;
while (p)
if (p->next == st) {
p->next = st->next;
@@ -644,248 +564,117 @@ HiSax_rmlist(struct IsdnCardState *sp,
}
}
-static void
-check_ph_act(struct IsdnCardState *sp)
-{
- struct PStack *st = sp->stlist;
-
- while (st) {
- if (st->l1.act_state)
- return;
- st = st->next;
- }
- if (sp->ph_active == 5)
- sp->ph_active = 4;
-}
-
-static void
-HiSax_manl1(struct PStack *st, int pr,
- void *arg)
-{
- struct IsdnCardState *sp = (struct IsdnCardState *)
- st->l1.hardware;
- long flags;
- char tmp[32];
-
- switch (pr) {
- case (PH_ACTIVATE):
- if (sp->debug) {
- sprintf(tmp, "PH_ACT ph_active %d", sp->ph_active);
- debugl1(sp, tmp);
- }
- save_flags(flags);
- cli();
- if (sp->ph_active & 4) {
- sp->ph_active = 5;
- st->l1.act_state = 2;
- restore_flags(flags);
- st->l1.l1man(st, PH_ACTIVATE, NULL);
- } else {
- st->l1.act_state = 1;
- if (sp->ph_active == 0)
- restart_ph(sp);
- restore_flags(flags);
- }
- break;
- case (PH_DEACTIVATE):
- st->l1.act_state = 0;
- if (sp->debug) {
- sprintf(tmp, "PH_DEACT ph_active %d", sp->ph_active);
- debugl1(sp, tmp);
- }
- check_ph_act(sp);
- break;
- }
-}
-
-static void
-HiSax_l2l1discardq(struct PStack *st, int pr,
- void *heldby, int releasetoo)
-{
- struct IsdnCardState *sp = (struct IsdnCardState *) st->l1.hardware;
- struct sk_buff *skb;
-
-#ifdef DEBUG_MAGIC
- if (sp->magic != 301271) {
- printk(KERN_DEBUG "isac_discardq magic not 301271\n");
- return;
- }
-#endif
-
- while ((skb = skb_dequeue(&sp->sq))) {
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
- }
-}
-
void
-setstack_HiSax(struct PStack *st, struct IsdnCardState *sp)
+init_bcstate(struct IsdnCardState *cs,
+ int bc)
{
- st->l1.hardware = sp;
- st->protocol = sp->protocol;
-
- setstack_tei(st);
-
- st->l1.stlistp = &(sp->stlist);
- st->l1.act_state = 0;
- st->l2.l2l1 = l2l1;
- st->l2.l2l1discardq = HiSax_l2l1discardq;
- st->ma.manl1 = HiSax_manl1;
- st->l1.requestpull = 0;
-}
-
-void
-init_hscxstate(struct IsdnCardState *sp,
- int hscx)
-{
- struct HscxState *hsp = sp->hs + hscx;
-
- hsp->sp = sp;
- hsp->hscx = hscx;
-
- hsp->tqueue.next = 0;
- hsp->tqueue.sync = 0;
- hsp->tqueue.routine = (void *) (void *) hscx_bh;
- hsp->tqueue.data = hsp;
-
- hsp->inuse = 0;
- hsp->init = 0;
- hsp->active = 0;
-
-#ifdef DEBUG_MAGIC
- hsp->magic = 301270;
-#endif
-}
-
-int
-get_irq(int cardnr, void *routine)
-{
- struct IsdnCard *card = cards + cardnr;
- long flags;
-
- save_flags(flags);
- cli();
- if (request_irq(card->sp->irq, routine,
- I4L_IRQ_FLAG, "HiSax", card->sp)) {
- printk(KERN_WARNING "HiSax: couldn't get interrupt %d\n",
- card->sp->irq);
- restore_flags(flags);
- return (0);
- }
- restore_flags(flags);
- return (1);
-}
-
-static void
-release_irq(int cardnr)
-{
- struct IsdnCard *card = cards + cardnr;
-
- free_irq(card->sp->irq, card->sp);
-}
-
-void
-close_hscxstate(struct HscxState *hs)
-{
- struct sk_buff *skb;
-
- hs->sp->modehscx(hs, 0, 0);
- hs->inuse = 0;
- if (hs->init) {
- if (hs->rcvbuf) {
- kfree(hs->rcvbuf);
- hs->rcvbuf = NULL;
- }
- while ((skb = skb_dequeue(&hs->rqueue))) {
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
- }
- while ((skb = skb_dequeue(&hs->squeue))) {
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
- }
- if (hs->tx_skb) {
- SET_SKB_FREE(hs->tx_skb);
- dev_kfree_skb(hs->tx_skb);
- hs->tx_skb = NULL;
- }
- }
- hs->init = 0;
+ struct BCState *bcs = cs->bcs + bc;
+
+ bcs->cs = cs;
+ bcs->channel = bc;
+ bcs->tqueue.next = 0;
+ bcs->tqueue.sync = 0;
+ bcs->tqueue.routine = (void *) (void *) BChannel_bh;
+ bcs->tqueue.data = bcs;
+ bcs->BC_SetStack = NULL;
+ bcs->BC_Close = NULL;
+ bcs->Flag = 0;
}
static void
closecard(int cardnr)
{
- struct IsdnCardState *csta = cards[cardnr].sp;
+ struct IsdnCardState *csta = cards[cardnr].cs;
struct sk_buff *skb;
-
- close_hscxstate(csta->hs + 1);
- close_hscxstate(csta->hs);
+
+ if (csta->bcs->BC_Close != NULL) {
+ csta->bcs->BC_Close(csta->bcs + 1);
+ csta->bcs->BC_Close(csta->bcs);
+ }
if (csta->rcvbuf) {
kfree(csta->rcvbuf);
csta->rcvbuf = NULL;
}
while ((skb = skb_dequeue(&csta->rq))) {
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
}
while ((skb = skb_dequeue(&csta->sq))) {
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
}
if (csta->tx_skb) {
- SET_SKB_FREE(csta->tx_skb);
dev_kfree_skb(csta->tx_skb);
csta->tx_skb = NULL;
}
- switch (csta->typ) {
-#if CARD_TELES0
- case ISDN_CTYPE_16_0:
- case ISDN_CTYPE_8_0:
- release_io_teles0(cards + cardnr);
- break;
-#endif
-#if CARD_TELES3
- case ISDN_CTYPE_PNP:
- case ISDN_CTYPE_16_3:
- case ISDN_CTYPE_TELESPCMCIA:
- release_io_teles3(cards + cardnr);
- break;
-#endif
-#if CARD_AVM_A1
- case ISDN_CTYPE_A1:
- release_io_avm_a1(cards + cardnr);
- break;
-#endif
-#if CARD_ELSA
- case ISDN_CTYPE_ELSA:
- case ISDN_CTYPE_ELSA_QS1000:
- release_io_elsa(cards + cardnr);
- break;
-#endif
-#if CARD_IX1MICROR2
- case ISDN_CTYPE_IX1MICROR2:
- release_io_ix1micro(cards + cardnr);
- break;
-#endif
- default:
- break;
+ if (csta->mon_rx) {
+ kfree(csta->mon_rx);
+ csta->mon_rx = NULL;
}
+ if (csta->mon_tx) {
+ kfree(csta->mon_tx);
+ csta->mon_tx = NULL;
+ }
+ csta->cardmsg(csta, CARD_RELEASE, NULL);
+ del_timer(&csta->dbusytimer);
ll_unload(csta);
}
-static int
-checkcard(int cardnr, char *id)
+HISAX_INITFUNC(static int init_card(struct IsdnCardState *cs))
+{
+ int irq_cnt, cnt = 3;
+ long flags;
+
+ save_flags(flags);
+ cli();
+ irq_cnt = kstat_irqs(cs->irq);
+ printk(KERN_INFO "%s: IRQ %d count %d\n", CardType[cs->typ], cs->irq,
+ irq_cnt);
+ if (cs->cardmsg(cs, CARD_SETIRQ, NULL)) {
+ printk(KERN_WARNING "HiSax: couldn't get interrupt %d\n",
+ cs->irq);
+ return(1);
+ }
+ while (cnt) {
+ cs->cardmsg(cs, CARD_INIT, NULL);
+ sti();
+ current->state = TASK_INTERRUPTIBLE;
+ /* Timeout 10ms */
+ current->timeout = jiffies + (10 * HZ) / 1000;
+ schedule();
+ restore_flags(flags);
+ printk(KERN_INFO "%s: IRQ %d count %d\n", CardType[cs->typ],
+ cs->irq, kstat_irqs(cs->irq));
+ if (kstat_irqs(cs->irq) == irq_cnt) {
+ printk(KERN_WARNING
+ "%s: IRQ(%d) getting no interrupts during init %d\n",
+ CardType[cs->typ], cs->irq, 4 - cnt);
+ if (cnt == 1) {
+ free_irq(cs->irq, cs);
+ return (2);
+ } else {
+ cs->cardmsg(cs, CARD_RESET, NULL);
+ cnt--;
+ }
+ } else {
+ cs->cardmsg(cs, CARD_TEST, NULL);
+ return(0);
+ }
+ }
+ restore_flags(flags);
+ return(3);
+}
+
+HISAX_INITFUNC(static int
+checkcard(int cardnr, char *id, int *busy_flag))
{
long flags;
int ret = 0;
struct IsdnCard *card = cards + cardnr;
- struct IsdnCardState *sp;
+ struct IsdnCardState *cs;
save_flags(flags);
cli();
- if (!(sp = (struct IsdnCardState *)
+ if (!(cs = (struct IsdnCardState *)
kmalloc(sizeof(struct IsdnCardState), GFP_ATOMIC))) {
printk(KERN_WARNING
"HiSax: No memory for IsdnCardState(card %d)\n",
@@ -893,10 +682,16 @@ checkcard(int cardnr, char *id)
restore_flags(flags);
return (0);
}
- card->sp = sp;
- sp->cardnr = cardnr;
- sp->cfg_reg = 0;
- sp->protocol = card->protocol;
+ card->cs = cs;
+ cs->cardnr = cardnr;
+ cs->debug = L1_DEB_WARN;
+ cs->HW_Flags = 0;
+ cs->busy_flag = busy_flag;
+#if TEI_PER_CARD
+#else
+ test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
+#endif
+ cs->protocol = card->protocol;
if ((card->typ > 0) && (card->typ < 31)) {
if (!((1 << card->typ) & SUPORTED_CARDS)) {
@@ -913,31 +708,34 @@ checkcard(int cardnr, char *id)
restore_flags(flags);
return (0);
}
- if (!(sp->dlogspace = kmalloc(4096, GFP_ATOMIC))) {
+ if (!(cs->dlogspace = kmalloc(4096, GFP_ATOMIC))) {
printk(KERN_WARNING
"HiSax: No memory for dlogspace(card %d)\n",
cardnr + 1);
restore_flags(flags);
return (0);
}
- if (!(sp->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) {
+ if (!(cs->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) {
printk(KERN_WARNING
"HiSax: No memory for status_buf(card %d)\n",
cardnr + 1);
- kfree(sp->dlogspace);
+ kfree(cs->dlogspace);
restore_flags(flags);
return (0);
}
- sp->status_read = sp->status_buf;
- sp->status_write = sp->status_buf;
- sp->status_end = sp->status_buf + HISAX_STATUS_BUFSIZE - 1;
- sp->typ = card->typ;
- sp->CallFlags = 0;
- strcpy(sp->iif.id, id);
- sp->iif.channels = 2;
- sp->iif.maxbufsize = MAX_DATA_SIZE;
- sp->iif.hl_hdrlen = MAX_HEADER_LEN;
- sp->iif.features =
+ cs->stlist = NULL;
+ cs->dlogflag = 0;
+ cs->mon_tx = NULL;
+ cs->mon_rx = NULL;
+ cs->status_read = cs->status_buf;
+ cs->status_write = cs->status_buf;
+ cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1;
+ cs->typ = card->typ;
+ strcpy(cs->iif.id, id);
+ cs->iif.channels = 2;
+ cs->iif.maxbufsize = MAX_DATA_SIZE;
+ cs->iif.hl_hdrlen = MAX_HEADER_LEN;
+ cs->iif.features =
ISDN_FEATURE_L2_X75I |
ISDN_FEATURE_L2_HDLC |
ISDN_FEATURE_L2_TRANS |
@@ -953,21 +751,19 @@ checkcard(int cardnr, char *id)
#endif
0;
- sp->iif.command = HiSax_command;
- sp->iif.writebuf = NULL;
- sp->iif.writecmd = NULL;
- sp->iif.writebuf_skb = HiSax_writebuf_skb;
- sp->iif.readstat = HiSax_readstatus;
- register_isdn(&sp->iif);
- sp->myid = sp->iif.channels;
- restore_flags(flags);
- printk(KERN_NOTICE
+ cs->iif.command = HiSax_command;
+ cs->iif.writecmd = NULL;
+ cs->iif.writebuf_skb = HiSax_writebuf_skb;
+ cs->iif.readstat = HiSax_readstatus;
+ register_isdn(&cs->iif);
+ cs->myid = cs->iif.channels;
+ printk(KERN_INFO
"HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1,
(card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :
(card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :
(card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :
(card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
- "NONE", sp->iif.id, sp->myid);
+ "NONE", cs->iif.id, cs->myid);
switch (card->typ) {
#if CARD_TELES0
case ISDN_CTYPE_16_0:
@@ -979,6 +775,7 @@ checkcard(int cardnr, char *id)
case ISDN_CTYPE_16_3:
case ISDN_CTYPE_PNP:
case ISDN_CTYPE_TELESPCMCIA:
+ case ISDN_CTYPE_COMPAQ_ISA:
ret = setup_teles3(card);
break;
#endif
@@ -989,7 +786,9 @@ checkcard(int cardnr, char *id)
#endif
#if CARD_ELSA
case ISDN_CTYPE_ELSA:
- case ISDN_CTYPE_ELSA_QS1000:
+ case ISDN_CTYPE_ELSA_PNP:
+ case ISDN_CTYPE_ELSA_PCMCIA:
+ case ISDN_CTYPE_ELSA_PCI:
ret = setup_elsa(card);
break;
#endif
@@ -998,90 +797,103 @@ checkcard(int cardnr, char *id)
ret = setup_ix1micro(card);
break;
#endif
- default:
- printk(KERN_WARNING "HiSax: Unknown Card Typ %d\n",
- card->typ);
- ll_unload(sp);
- return (0);
- }
- if (!ret) {
- ll_unload(sp);
- return (0);
- }
- if (!(sp->rcvbuf = kmalloc(MAX_DFRAME_LEN, GFP_ATOMIC))) {
- printk(KERN_WARNING
- "HiSax: No memory for isac rcvbuf\n");
- return (1);
- }
- sp->rcvidx = 0;
- sp->tx_skb = NULL;
- sp->tx_cnt = 0;
- sp->event = 0;
- sp->tqueue.next = 0;
- sp->tqueue.sync = 0;
- sp->tqueue.routine = (void *) (void *) isac_bh;
- sp->tqueue.data = sp;
-
- skb_queue_head_init(&sp->rq);
- skb_queue_head_init(&sp->sq);
-
- sp->stlist = NULL;
- sp->ph_active = 0;
- sp->dlogflag = 0;
- sp->debug = L1_DEB_WARN;
-#ifdef DEBUG_MAGIC
- sp->magic = 301271;
+#if CARD_DIEHLDIVA
+ case ISDN_CTYPE_DIEHLDIVA:
+ ret = setup_diva(card);
+ break;
#endif
-
- init_hscxstate(sp, 0);
- init_hscxstate(sp, 1);
-
- switch (card->typ) {
-#if CARD_TELES0
- case ISDN_CTYPE_16_0:
- case ISDN_CTYPE_8_0:
- ret = initteles0(sp);
+#if CARD_ASUSCOM
+ case ISDN_CTYPE_ASUSCOM:
+ ret = setup_asuscom(card);
break;
#endif
-#if CARD_TELES3
- case ISDN_CTYPE_16_3:
- case ISDN_CTYPE_PNP:
- case ISDN_CTYPE_TELESPCMCIA:
- ret = initteles3(sp);
+#if CARD_TELEINT
+ case ISDN_CTYPE_TELEINT:
+ ret = setup_TeleInt(card);
break;
#endif
-#if CARD_AVM_A1
- case ISDN_CTYPE_A1:
- ret = initavm_a1(sp);
+#if CARD_SEDLBAUER
+ case ISDN_CTYPE_SEDLBAUER:
+ case ISDN_CTYPE_SEDLBAUER_PCMCIA:
+ ret = setup_sedlbauer(card);
break;
#endif
-#if CARD_ELSA
- case ISDN_CTYPE_ELSA:
- case ISDN_CTYPE_ELSA_QS1000:
- ret = initelsa(sp);
+#if CARD_SPORTSTER
+ case ISDN_CTYPE_SPORTSTER:
+ ret = setup_sportster(card);
break;
#endif
-#if CARD_IX1MICROR2
- case ISDN_CTYPE_IX1MICROR2:
- ret = initix1micro(sp);
+#if CARD_MIC
+ case ISDN_CTYPE_MIC:
+ ret = setup_mic(card);
break;
#endif
- default:
- ret = 0;
+#if CARD_NETJET
+ case ISDN_CTYPE_NETJET:
+ ret = setup_netjet(card);
+ break;
+#endif
+#if CARD_TELES3C
+ case ISDN_CTYPE_TELES3C:
+ ret = setup_t163c(card);
+ break;
+#endif
+#if CARD_NICCY
+ case ISDN_CTYPE_NICCY:
+ ret = setup_niccy(card);
+ break;
+#endif
+#if CARD_AMD7930
+ case ISDN_CTYPE_AMD7930:
+ ret = setup_amd7930(card);
break;
+#endif
+ default:
+ printk(KERN_WARNING "HiSax: Unknown Card Typ %d\n",
+ card->typ);
+ ll_unload(cs);
+ restore_flags(flags);
+ return (0);
}
if (!ret) {
+ ll_unload(cs);
+ restore_flags(flags);
+ return (0);
+ }
+ if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN, GFP_ATOMIC))) {
+ printk(KERN_WARNING
+ "HiSax: No memory for isac rcvbuf\n");
+ return (1);
+ }
+ cs->rcvidx = 0;
+ cs->tx_skb = NULL;
+ cs->tx_cnt = 0;
+ cs->event = 0;
+ cs->tqueue.next = 0;
+ cs->tqueue.sync = 0;
+ cs->tqueue.data = cs;
+
+ skb_queue_head_init(&cs->rq);
+ skb_queue_head_init(&cs->sq);
+
+ init_bcstate(cs, 0);
+ init_bcstate(cs, 1);
+ ret = init_card(cs);
+ if (ret) {
closecard(cardnr);
+ restore_flags(flags);
return (0);
}
- init_tei(sp, sp->protocol);
- CallcNewChan(sp);
- ll_run(sp);
+ init_tei(cs, cs->protocol);
+ CallcNewChan(cs);
+ ll_run(cs);
+ cs->l1cmd(cs, PH_RESET_REQ, NULL);
+ restore_flags(flags);
return (1);
}
-void
-HiSax_shiftcards(int idx)
+HISAX_INITFUNC(void
+HiSax_shiftcards(int idx))
{
int i;
@@ -1089,8 +901,8 @@ HiSax_shiftcards(int idx)
memcpy(&cards[i], &cards[i + 1], sizeof(cards[i]));
}
-int
-HiSax_inithardware(void)
+HISAX_INITFUNC(int
+HiSax_inithardware(int *busy_flag))
{
int foundcards = 0;
int i = 0;
@@ -1120,15 +932,15 @@ HiSax_inithardware(void)
else
sprintf(ids, "%s%d", id, i);
}
- if (checkcard(i, ids)) {
+ if (checkcard(i, ids, busy_flag)) {
foundcards++;
i++;
} else {
printk(KERN_WARNING "HiSax: Card %s not installed !\n",
CardType[cards[i].typ]);
- if (cards[i].sp)
- kfree((void *) cards[i].sp);
- cards[i].sp = NULL;
+ if (cards[i].cs)
+ kfree((void *) cards[i].cs);
+ cards[i].cs = NULL;
HiSax_shiftcards(i);
}
}
@@ -1144,159 +956,66 @@ HiSax_closehardware(void)
save_flags(flags);
cli();
for (i = 0; i < nrcards; i++)
- if (cards[i].sp) {
- ll_stop(cards[i].sp);
- CallcFreeChan(cards[i].sp);
- release_tei(cards[i].sp);
- release_irq(i);
+ if (cards[i].cs) {
+ ll_stop(cards[i].cs);
+ release_tei(cards[i].cs);
closecard(i);
- kfree((void *) cards[i].sp);
- cards[i].sp = NULL;
+ free_irq(cards[i].cs->irq, cards[i].cs);
+ kfree((void *) cards[i].cs);
+ cards[i].cs = NULL;
}
+ Isdnl1Free();
+ TeiFree();
Isdnl2Free();
CallcFree();
restore_flags(flags);
}
-static void
-hscx_l2l1(struct PStack *st, int pr, void *arg)
-{
- struct sk_buff *skb = arg;
- struct IsdnCardState *sp = (struct IsdnCardState *) st->l1.hardware;
- struct HscxState *hsp = sp->hs + st->l1.hscx;
- long flags;
-
- switch (pr) {
- case (PH_DATA):
- save_flags(flags);
- cli();
- if (hsp->tx_skb) {
- skb_queue_tail(&hsp->squeue, skb);
- restore_flags(flags);
- } else {
- restore_flags(flags);
- hsp->tx_skb = skb;
- hsp->count = 0;
- sp->hscx_fill_fifo(hsp);
- }
- break;
- case (PH_DATA_PULLED):
- if (hsp->tx_skb) {
- printk(KERN_WARNING "hscx_l2l1: this shouldn't happen\n");
- break;
- }
- hsp->tx_skb = skb;
- hsp->count = 0;
- sp->hscx_fill_fifo(hsp);
- break;
- case (PH_REQUEST_PULL):
- if (!hsp->tx_skb) {
- st->l1.requestpull = 0;
- st->l1.l1l2(st, PH_PULL_ACK, NULL);
- } else
- st->l1.requestpull = !0;
- break;
- }
-
-}
-extern struct IsdnBuffers *tracebuf;
-
-static void
-hscx_l2l1discardq(struct PStack *st, int pr, void *heldby,
- int releasetoo)
-{
- struct IsdnCardState *sp = (struct IsdnCardState *)
- st->l1.hardware;
- struct HscxState *hsp = sp->hs + st->l1.hscx;
- struct sk_buff *skb;
-
-#ifdef DEBUG_MAGIC
- if (hsp->magic != 301270) {
- printk(KERN_DEBUG "hscx_discardq magic not 301270\n");
- return;
- }
-#endif
-
- while ((skb = skb_dequeue(&hsp->squeue))) {
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
- }
-}
-
-static int
-open_hscxstate(struct IsdnCardState *sp,
- int hscx)
-{
- struct HscxState *hsp = sp->hs + hscx;
-
- if (!hsp->init) {
- if (!(hsp->rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) {
- printk(KERN_WARNING
- "HiSax: No memory for hscx_rcvbuf\n");
- return (1);
- }
- skb_queue_head_init(&hsp->rqueue);
- skb_queue_head_init(&hsp->squeue);
- }
- hsp->init = !0;
-
- hsp->tx_skb = NULL;
- hsp->event = 0;
- hsp->rcvidx = 0;
- hsp->tx_cnt = 0;
- return (0);
-}
-
-static void
-hscx_manl1(struct PStack *st, int pr,
- void *arg)
-{
- struct IsdnCardState *sp = (struct IsdnCardState *) st->l1.hardware;
- struct HscxState *hsp = sp->hs + st->l1.hscx;
-
- switch (pr) {
- case (PH_ACTIVATE):
- hsp->active = !0;
- sp->modehscx(hsp, st->l1.hscxmode, st->l1.hscxchannel);
- st->l1.l1man(st, PH_ACTIVATE, NULL);
- break;
- case (PH_DEACTIVATE):
- if (!hsp->tx_skb)
- sp->modehscx(hsp, 0, 0);
-
- hsp->active = 0;
- break;
- }
-}
-
-int
-setstack_hscx(struct PStack *st, struct HscxState *hs)
-{
- if (open_hscxstate(st->l1.hardware, hs->hscx))
- return (-1);
-
- st->l1.hscx = hs->hscx;
- st->l2.l2l1 = hscx_l2l1;
- st->ma.manl1 = hscx_manl1;
- st->l2.l2l1discardq = hscx_l2l1discardq;
-
- st->l1.act_state = 0;
- st->l1.requestpull = 0;
-
- hs->st = st;
- return (0);
-}
-
void
HiSax_reportcard(int cardnr)
{
- struct IsdnCardState *sp = cards[cardnr].sp;
+ struct IsdnCardState *cs = cards[cardnr].cs;
+ struct PStack *stptr;
+ struct l3_process *pc;
+ int j, i = 1;
printk(KERN_DEBUG "HiSax: reportcard No %d\n", cardnr + 1);
- printk(KERN_DEBUG "HiSax: Type %s\n", CardType[sp->typ]);
- printk(KERN_DEBUG "HiSax: debuglevel %x\n", sp->debug);
+ printk(KERN_DEBUG "HiSax: Type %s\n", CardType[cs->typ]);
+ printk(KERN_DEBUG "HiSax: debuglevel %x\n", cs->debug);
printk(KERN_DEBUG "HiSax: HiSax_reportcard address 0x%lX\n",
(ulong) & HiSax_reportcard);
+ printk(KERN_DEBUG "HiSax: cs 0x%lX\n", (ulong) cs);
+ printk(KERN_DEBUG "HiSax: cs stl 0x%lX\n", (ulong) & (cs->stlist));
+ stptr = cs->stlist;
+ while (stptr != NULL) {
+ printk(KERN_DEBUG "HiSax: dst%d 0x%lX\n", i, (ulong) stptr);
+ printk(KERN_DEBUG "HiSax: dst%d stp 0x%lX\n", i, (ulong) stptr->l1.stlistp);
+ printk(KERN_DEBUG "HiSax: tei %d sapi %d\n",
+ stptr->l2.tei, stptr->l2.sap);
+ printk(KERN_DEBUG "HiSax: man 0x%lX\n", (ulong) stptr->ma.layer);
+ pc = stptr->l3.proc;
+ while (pc) {
+ printk(KERN_DEBUG "HiSax: l3proc %x 0x%lX\n", pc->callref,
+ (ulong) pc);
+ printk(KERN_DEBUG "HiSax: state %d st 0x%lX chan 0x%lX\n",
+ pc->state, (ulong) pc->st, (ulong) pc->chan);
+ pc = pc->next;
+ }
+ stptr = stptr->next;
+ i++;
+ }
+ for (j = 0; j < 2; j++) {
+ printk(KERN_DEBUG "HiSax: ch%d 0x%lX\n", j,
+ (ulong) & cs->channel[j]);
+ stptr = cs->channel[j].b_st;
+ i = 1;
+ while (stptr != NULL) {
+ printk(KERN_DEBUG "HiSax: b_st%d 0x%lX\n", i, (ulong) stptr);
+ printk(KERN_DEBUG "HiSax: man 0x%lX\n", (ulong) stptr->ma.layer);
+ stptr = stptr->next;
+ i++;
+ }
+ }
}
#ifdef L2FRAME_DEBUG /* psa */
@@ -1366,7 +1085,7 @@ l2frames(u_char * ptr)
}
void
-Logl2Frame(struct IsdnCardState *sp, struct sk_buff *skb, char *buf, int dir)
+Logl2Frame(struct IsdnCardState *cs, struct sk_buff *skb, char *buf, int dir)
{
char tmp[132];
u_char *ptr;
@@ -1374,13 +1093,293 @@ Logl2Frame(struct IsdnCardState *sp, struct sk_buff *skb, char *buf, int dir)
ptr = skb->data;
if (ptr[0] & 1 || !(ptr[1] & 1))
- debugl1(sp, "Addres not LAPD");
+ debugl1(cs, "Addres not LAPD");
else {
sprintf(tmp, "%s %s: %s%c (sapi %d, tei %d)",
(dir ? "<-" : "->"), buf, l2frames(ptr),
((ptr[0] & 2) >> 1) == dir ? 'C' : 'R', ptr[0] >> 2, ptr[1] >> 1);
- debugl1(sp, tmp);
+ debugl1(cs, tmp);
}
}
-
#endif
+
+static void
+l1_reset(struct FsmInst *fi, int event, void *arg)
+{
+ FsmChangeState(fi, ST_L1_F3);
+}
+
+static void
+l1_deact_cnf(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ struct IsdnCardState *cs = st->l1.hardware;
+
+ FsmChangeState(fi, ST_L1_F3);
+ if (test_bit(FLG_L1_ACTIVATING, &st->l1.Flags))
+ cs->l1cmd(cs, PH_ENABLE_REQ, NULL);
+}
+
+static void
+l1_deact_req(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+
+ FsmChangeState(fi, ST_L1_F3);
+ if (!test_bit(FLG_L1_T3RUN, &st->l1.Flags)) {
+ FsmDelTimer(&st->l1.timer, 1);
+ FsmAddTimer(&st->l1.timer, 550, EV_TIMER_DEACT, NULL, 2);
+ test_and_set_bit(FLG_L1_DEACTTIMER, &st->l1.Flags);
+ }
+}
+
+static void
+l1_power_up(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ struct IsdnCardState *cs = st->l1.hardware;
+
+ if (test_bit(FLG_L1_ACTIVATING, &st->l1.Flags)) {
+ FsmChangeState(fi, ST_L1_F4);
+ cs->l1cmd(cs, PH_INFO3_REQ, NULL);
+ FsmDelTimer(&st->l1.timer, 1);
+ FsmAddTimer(&st->l1.timer, TIMER3_VALUE * HZ, EV_TIMER3, NULL, 2);
+ test_and_set_bit(FLG_L1_T3RUN, &st->l1.Flags);
+ } else
+ FsmChangeState(fi, ST_L1_F3);
+}
+
+static void
+l1_go_F5(struct FsmInst *fi, int event, void *arg)
+{
+ FsmChangeState(fi, ST_L1_F5);
+}
+
+static void
+l1_go_F8(struct FsmInst *fi, int event, void *arg)
+{
+ FsmChangeState(fi, ST_L1_F8);
+}
+
+static void
+l1_info2_ind(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ struct IsdnCardState *cs = st->l1.hardware;
+
+ FsmChangeState(fi, ST_L1_F6);
+ cs->l1cmd(cs, PH_INFO3_REQ, NULL);
+}
+
+static void
+l1_info4_ind(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ struct IsdnCardState *cs = st->l1.hardware;
+
+ FsmChangeState(fi, ST_L1_F7);
+ cs->l1cmd(cs, PH_INFO3_REQ, NULL);
+ if (test_and_clear_bit(FLG_L1_DEACTTIMER, &st->l1.Flags))
+ FsmDelTimer(&st->l1.timer, 4);
+ if (!test_bit(FLG_L1_ACTIVATED, &st->l1.Flags)) {
+ if (test_and_clear_bit(FLG_L1_T3RUN, &st->l1.Flags))
+ FsmDelTimer(&st->l1.timer, 3);
+ FsmAddTimer(&st->l1.timer, 110, EV_TIMER_ACT, NULL, 2);
+ test_and_set_bit(FLG_L1_ACTTIMER, &st->l1.Flags);
+ }
+}
+
+static void
+l1_timer3(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ struct IsdnCardState *cs = st->l1.hardware;
+
+ test_and_clear_bit(FLG_L1_T3RUN, &st->l1.Flags);
+ if (test_and_clear_bit(FLG_L1_ACTIVATING, &st->l1.Flags))
+ L1deactivated(cs);
+ if (st->l1.l1m.state != ST_L1_F6)
+ FsmChangeState(fi, ST_L1_F3);
+}
+
+static void
+l1_timer_act(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ struct IsdnCardState *cs = st->l1.hardware;
+
+ test_and_clear_bit(FLG_L1_ACTTIMER, &st->l1.Flags);
+ test_and_set_bit(FLG_L1_ACTIVATED, &st->l1.Flags);
+ L1activated(cs);
+}
+
+static void
+l1_timer_deact(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ struct IsdnCardState *cs = st->l1.hardware;
+
+ test_and_clear_bit(FLG_L1_DEACTTIMER, &st->l1.Flags);
+ test_and_clear_bit(FLG_L1_ACTIVATED, &st->l1.Flags);
+ L1deactivated(cs);
+ cs->l1cmd(cs, PH_DEACT_ACK, NULL);
+}
+
+static void
+l1_activate(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ struct IsdnCardState *cs = st->l1.hardware;
+
+ cs->l1cmd(cs, PH_RESET_REQ, NULL);
+}
+
+static struct FsmNode L1FnList[] HISAX_INITDATA =
+{
+ {ST_L1_F3, EV_PH_ACTIVATE, l1_activate},
+ {ST_L1_F3, EV_RESET_IND, l1_reset},
+ {ST_L1_F4, EV_RESET_IND, l1_reset},
+ {ST_L1_F5, EV_RESET_IND, l1_reset},
+ {ST_L1_F6, EV_RESET_IND, l1_reset},
+ {ST_L1_F7, EV_RESET_IND, l1_reset},
+ {ST_L1_F8, EV_RESET_IND, l1_reset},
+ {ST_L1_F3, EV_DEACT_CNF, l1_deact_cnf},
+ {ST_L1_F4, EV_DEACT_CNF, l1_deact_cnf},
+ {ST_L1_F5, EV_DEACT_CNF, l1_deact_cnf},
+ {ST_L1_F6, EV_DEACT_CNF, l1_deact_cnf},
+ {ST_L1_F7, EV_DEACT_CNF, l1_deact_cnf},
+ {ST_L1_F8, EV_DEACT_CNF, l1_deact_cnf},
+ {ST_L1_F6, EV_DEACT_IND, l1_deact_req},
+ {ST_L1_F7, EV_DEACT_IND, l1_deact_req},
+ {ST_L1_F8, EV_DEACT_IND, l1_deact_req},
+ {ST_L1_F3, EV_POWER_UP, l1_power_up},
+ {ST_L1_F4, EV_RSYNC_IND, l1_go_F5},
+ {ST_L1_F6, EV_RSYNC_IND, l1_go_F8},
+ {ST_L1_F7, EV_RSYNC_IND, l1_go_F8},
+ {ST_L1_F3, EV_INFO2_IND, l1_info2_ind},
+ {ST_L1_F4, EV_INFO2_IND, l1_info2_ind},
+ {ST_L1_F5, EV_INFO2_IND, l1_info2_ind},
+ {ST_L1_F7, EV_INFO2_IND, l1_info2_ind},
+ {ST_L1_F8, EV_INFO2_IND, l1_info2_ind},
+ {ST_L1_F3, EV_INFO4_IND, l1_info4_ind},
+ {ST_L1_F4, EV_INFO4_IND, l1_info4_ind},
+ {ST_L1_F5, EV_INFO4_IND, l1_info4_ind},
+ {ST_L1_F6, EV_INFO4_IND, l1_info4_ind},
+ {ST_L1_F8, EV_INFO4_IND, l1_info4_ind},
+ {ST_L1_F3, EV_TIMER3, l1_timer3},
+ {ST_L1_F4, EV_TIMER3, l1_timer3},
+ {ST_L1_F5, EV_TIMER3, l1_timer3},
+ {ST_L1_F6, EV_TIMER3, l1_timer3},
+ {ST_L1_F8, EV_TIMER3, l1_timer3},
+ {ST_L1_F7, EV_TIMER_ACT, l1_timer_act},
+ {ST_L1_F3, EV_TIMER_DEACT, l1_timer_deact},
+ {ST_L1_F4, EV_TIMER_DEACT, l1_timer_deact},
+ {ST_L1_F5, EV_TIMER_DEACT, l1_timer_deact},
+ {ST_L1_F6, EV_TIMER_DEACT, l1_timer_deact},
+ {ST_L1_F7, EV_TIMER_DEACT, l1_timer_deact},
+ {ST_L1_F8, EV_TIMER_DEACT, l1_timer_deact},
+};
+
+#define L1_FN_COUNT (sizeof(L1FnList)/sizeof(struct FsmNode))
+
+HISAX_INITFUNC(void Isdnl1New(void))
+{
+ l1fsm.state_count = L1_STATE_COUNT;
+ l1fsm.event_count = L1_EVENT_COUNT;
+ l1fsm.strEvent = strL1Event;
+ l1fsm.strState = strL1State;
+ FsmNew(&l1fsm, L1FnList, L1_FN_COUNT);
+}
+
+void Isdnl1Free(void)
+{
+ FsmFree(&l1fsm);
+}
+
+static void
+dch_manl1(struct PStack *st, int pr,
+ void *arg)
+{
+ struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware;
+ char tmp[32];
+
+ switch (pr) {
+ case PH_ACTIVATE_REQ:
+ if (cs->debug) {
+ sprintf(tmp, "PH_ACTIVATE_REQ %s",
+ strL1State[st->l1.l1m.state]);
+ debugl1(cs, tmp);
+ }
+ if (test_bit(FLG_L1_ACTIVATED, &st->l1.Flags))
+ st->l1.l1man(st, PH_ACTIVATE_CNF, NULL);
+ else {
+ test_and_set_bit(FLG_L1_ACTIVATING, &st->l1.Flags);
+ FsmEvent(&st->l1.l1m, EV_PH_ACTIVATE, arg);
+ }
+ break;
+ case PH_DEACTIVATE_REQ:
+ if (cs->debug) {
+ sprintf(tmp, "PH_DEACTIVATE_REQ %s",
+ strL1State[st->l1.l1m.state]);
+ debugl1(cs, tmp);
+ }
+ break;
+ case PH_TESTLOOP_REQ:
+ if (1 & (int) arg)
+ debugl1(cs, "PH_TEST_LOOP B1");
+ if (2 & (int) arg)
+ debugl1(cs, "PH_TEST_LOOP B2");
+ if (!(3 & (int) arg))
+ debugl1(cs, "PH_TEST_LOOP DISABLED");
+ cs->l1cmd(cs, PH_TESTLOOP_REQ, arg);
+ break;
+ case PH_RESET_IND:
+ FsmEvent(&st->l1.l1m, EV_RESET_IND, arg);
+ break;
+ case PH_DEACT_CNF:
+ FsmEvent(&st->l1.l1m, EV_DEACT_CNF, arg);
+ break;
+ case PH_DEACT_IND:
+ FsmEvent(&st->l1.l1m, EV_DEACT_IND, arg);
+ break;
+ case PH_POWERUP_CNF:
+ FsmEvent(&st->l1.l1m, EV_POWER_UP, arg);
+ break;
+ case PH_RSYNC_IND:
+ FsmEvent(&st->l1.l1m, EV_RSYNC_IND, arg);
+ break;
+ case PH_INFO2_IND:
+ FsmEvent(&st->l1.l1m, EV_INFO2_IND, arg);
+ break;
+ case PH_I4_P8_IND:
+ case PH_I4_P10_IND:
+ FsmEvent(&st->l1.l1m, EV_INFO4_IND, arg);
+ break;
+ default:
+ if (cs->debug) {
+ sprintf(tmp, "dch_manl1 msg %04X unhandled", pr);
+ debugl1(cs, tmp);
+ }
+ break;
+ }
+}
+
+void
+setstack_HiSax(struct PStack *st, struct IsdnCardState *cs)
+{
+ st->l1.hardware = cs;
+ st->protocol = cs->protocol;
+ st->l1.l1m.fsm = &l1fsm;
+ st->l1.l1m.state = ST_L1_F3;
+ st->l1.l1m.debug = cs->debug;
+ st->l1.l1m.userdata = st;
+ st->l1.l1m.userint = 0;
+ st->l1.l1m.printdebug = l1m_debug;
+ FsmInitTimer(&st->l1.l1m, &st->l1.timer);
+ setstack_tei(st);
+ setstack_manager(st);
+ st->l1.stlistp = &(cs->stlist);
+ st->ma.manl1 = dch_manl1;
+ st->l1.Flags = 0;
+ cs->setstack_d(st, cs);
+}
diff --git a/drivers/isdn/hisax/isdnl1.h b/drivers/isdn/hisax/isdnl1.h
index d01d70123..71f081a07 100644
--- a/drivers/isdn/hisax/isdnl1.h
+++ b/drivers/isdn/hisax/isdnl1.h
@@ -1,18 +1,23 @@
-/* $Id: isdnl1.h,v 1.4 1997/04/06 22:55:52 keil Exp $
- *
+/* $Id: isdnl1.h,v 2.5 1998/02/02 13:36:58 keil Exp $
+
* $Log: isdnl1.h,v $
- * Revision 1.4 1997/04/06 22:55:52 keil
- * Using SKB's
+ * Revision 2.5 1998/02/02 13:36:58 keil
+ * more debug
+ *
+ * Revision 2.4 1997/11/08 21:35:49 keil
+ * new l1 init
*
- * Revision 1.3 1996/12/08 19:41:55 keil
- * L2FRAME_DEBUG
+ * Revision 2.3 1997/10/29 19:07:53 keil
+ * changes for 2.1
*
- * Revision 1.2 1996/10/27 22:26:27 keil
- * ISAC/HSCX version functions
+ * Revision 2.2 1997/07/30 17:11:09 keil
+ * L1deactivated exported
*
- * Revision 1.1 1996/10/13 20:03:47 keil
- * Initial revision
+ * Revision 2.1 1997/07/27 21:43:58 keil
+ * new l1 interface
*
+ * Revision 2.0 1997/06/26 11:02:55 keil
+ * New Layer and card interface
*
*
*/
@@ -29,22 +34,25 @@
#define L1_DEB_HSCX 0x10
#define L1_DEB_HSCX_FIFO 0x20
#define L1_DEB_LAPD 0x40
+#define L1_DEB_IPAC 0x80
+#define L1_DEB_RECEIVE_FRAME 0x100
+#define D_RCVBUFREADY 0
+#define D_XMTBUFREADY 1
+#define D_L1STATECHANGE 2
+#define D_CLEARBUSY 3
+#define D_RX_MON0 4
+#define D_RX_MON1 5
+#define D_TX_MON0 6
+#define D_TX_MON1 7
-#define ISAC_RCVBUFREADY 0
-#define ISAC_XMTBUFREADY 1
-#define ISAC_PHCHANGE 2
-
-#define HSCX_RCVBUFREADY 0
-#define HSCX_XMTBUFREADY 1
+#define B_RCVBUFREADY 0
+#define B_XMTBUFREADY 1
extern void debugl1(struct IsdnCardState *sp, char *msg);
-extern char *HscxVersion(u_char v);
-extern char *ISACVersion(u_char v);
-extern void hscx_sched_event(struct HscxState *hsp, int event);
-extern void isac_sched_event(struct IsdnCardState *sp, int event);
-extern void isac_new_ph(struct IsdnCardState *sp);
-extern int get_irq(int cardnr, void *routine);
+extern void DChannel_proc_xmt(struct IsdnCardState *cs);
+extern void DChannel_proc_rcv(struct IsdnCardState *cs);
+
#ifdef L2FRAME_DEBUG
extern void Logl2Frame(struct IsdnCardState *sp, struct sk_buff *skb, char *buf, int dir);
diff --git a/drivers/isdn/hisax/isdnl2.c b/drivers/isdn/hisax/isdnl2.c
index 9c58eef90..eadfa4c8a 100644
--- a/drivers/isdn/hisax/isdnl2.c
+++ b/drivers/isdn/hisax/isdnl2.c
@@ -1,4 +1,4 @@
-/* $Id: isdnl2.c,v 1.10 1997/05/06 09:38:13 keil Exp $
+/* $Id: isdnl2.c,v 2.7 1998/02/12 23:07:47 keil Exp $
* Author Karsten Keil (keil@temic-ech.spacenet.de)
* based on the teles driver from Jan den Ouden
@@ -7,56 +7,51 @@
* Fritz Elfert
*
* $Log: isdnl2.c,v $
- * Revision 1.10 1997/05/06 09:38:13 keil
- * Bugfixes: - clear ack queue entries after resend
- * - acknowlege each frame to linklevel
- * - UA for SABM is Response, not command
- * - only RR was send as supervisor frame (X.75 hangs after a
- * sequence error)
+ * Revision 2.7 1998/02/12 23:07:47 keil
+ * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
*
- * Revision 1.9 1997/04/07 23:02:11 keil
- * missing braces
+ * Revision 2.6 1998/02/02 13:36:15 keil
+ * bugfix X.75 win calculation
*
- * Revision 1.8 1997/04/06 22:59:59 keil
- * Using SKB's; changing function names; some minor changes
+ * Revision 2.5 1997/11/06 17:09:22 keil
+ * New 2.1 init code
*
- * Revision 1.7 1997/02/09 00:25:44 keil
- * new interface handling, one interface per card
+ * Revision 2.4 1997/10/29 19:02:01 keil
+ * new LL interface
*
- * Revision 1.6 1997/01/21 22:23:42 keil
- * D-channel log changed
+ * Revision 2.3 1997/10/01 09:21:39 fritz
+ * Removed old compatibility stuff for 2.0.X kernels.
+ * From now on, this code is for 2.1.X ONLY!
+ * Old stuff is still in the separate branch.
*
- * Revision 1.5 1997/01/04 13:47:06 keil
- * handling of MDL_REMOVE added (Thanks to Sim Yskes)
+ * Revision 2.2 1997/07/31 11:49:05 keil
+ * Eroor handling for no TEI assign
*
- * Revision 1.4 1996/12/08 19:51:51 keil
- * many fixes from Pekka Sarnila
+ * Revision 2.1 1997/07/27 21:34:38 keil
+ * cosmetics
*
- * Revision 1.3 1996/11/05 19:39:12 keil
- * X.75 bugfixes Thank to Martin Maurer
- *
- * Revision 1.2 1996/10/30 10:20:58 keil
- * X.75 answer of SABMX fixed to response address (AVM X.75 problem)
- *
- * Revision 1.1 1996/10/13 20:04:54 keil
- * Initial revision
+ * Revision 2.0 1997/06/26 11:07:29 keil
+ * New q.921 and X.75 Layer2
*
*
+ * Old log removed KKe
*
*/
#define __NO_VERSION__
#include "hisax.h"
#include "isdnl2.h"
-const char *l2_revision = "$Revision: 1.10 $";
+const char *l2_revision = "$Revision: 2.7 $";
static void l2m_debug(struct FsmInst *fi, char *s);
+static
struct Fsm l2fsm =
{NULL, 0, 0, NULL, NULL};
enum {
ST_L2_1,
+ ST_L2_2,
ST_L2_3,
ST_L2_4,
ST_L2_5,
@@ -70,6 +65,7 @@ enum {
static char *strL2State[] =
{
"ST_L2_1",
+ "ST_L2_2",
"ST_L2_3",
"ST_L2_4",
"ST_L2_5",
@@ -81,53 +77,53 @@ static char *strL2State[] =
enum {
EV_L2_UI,
EV_L2_SABMX,
- EV_L2_UA,
EV_L2_DISC,
- EV_L2_I,
- EV_L2_RR,
- EV_L2_REJ,
+ EV_L2_DM,
+ EV_L2_UA,
EV_L2_FRMR,
+ EV_L2_SUPER,
+ EV_L2_I,
EV_L2_DL_DATA,
+ EV_L2_ACK_PULL,
+ EV_L2_DL_UNIT_DATA,
EV_L2_DL_ESTABLISH,
+ EV_L2_DL_RELEASE,
EV_L2_MDL_ASSIGN,
EV_L2_MDL_REMOVE,
- EV_L2_DL_UNIT_DATA,
- EV_L2_DL_RELEASE,
+ EV_L2_MDL_ERROR,
EV_L2_MDL_NOTEIPROC,
+ EV_L1_DEACTIVATE,
EV_L2_T200,
- EV_L2_ACK_PULL,
EV_L2_T203,
- EV_L2_RNR,
};
-#define L2_EVENT_COUNT (EV_L2_RNR+1)
+#define L2_EVENT_COUNT (EV_L2_T203+1)
static char *strL2Event[] =
{
"EV_L2_UI",
"EV_L2_SABMX",
- "EV_L2_UA",
"EV_L2_DISC",
- "EV_L2_I",
- "EV_L2_RR",
- "EV_L2_REJ",
+ "EV_L2_DM",
+ "EV_L2_UA",
"EV_L2_FRMR",
+ "EV_L2_SUPER",
+ "EV_L2_I",
"EV_L2_DL_DATA",
+ "EV_L2_ACK_PULL",
+ "EV_L2_DL_UNIT_DATA",
"EV_L2_DL_ESTABLISH",
+ "EV_L2_DL_RELEASE",
"EV_L2_MDL_ASSIGN",
"EV_L2_MDL_REMOVE",
- "EV_L2_DL_UNIT_DATA",
- "EV_L2_DL_RELEASE",
+ "EV_L2_MDL_ERROR",
"EV_L2_MDL_NOTEIPROC",
+ "EV_L1_DEACTIVATE",
"EV_L2_T200",
- "EV_L2_ACK_PULL",
"EV_L2_T203",
- "EV_L2_RNR",
};
-int errcount = 0;
-
-static int l2addrsize(struct Layer2 *tsp);
+static int l2addrsize(struct Layer2 *l2);
static void
InitWin(struct Layer2 *l2)
@@ -143,11 +139,9 @@ ReleaseWin(struct Layer2 *l2)
{
int i, cnt = 0;
-
for (i = 0; i < MAX_WINDOW; i++) {
if (l2->windowar[i]) {
cnt++;
- SET_SKB_FREE(l2->windowar[i]);
dev_kfree_skb(l2->windowar[i]);
l2->windowar[i] = NULL;
}
@@ -156,13 +150,15 @@ ReleaseWin(struct Layer2 *l2)
printk(KERN_WARNING "isdl2 freed %d skbuffs in release\n", cnt);
}
-static int
+inline int
cansend(struct PStack *st)
{
int p1;
- p1 = (st->l2.va + st->l2.window) % (st->l2.extended ? 128 : 8);
- return (st->l2.vs != p1);
+ p1 = st->l2.vs - st->l2.va;
+ if (p1 < 0)
+ p1 += (test_bit(FLG_MOD128, &st->l2.flag) ? 128 : 8);
+ return ((p1 < st->l2.window) && !test_bit(FLG_PEER_BUSY, &st->l2.flag));
}
static void
@@ -171,40 +167,54 @@ discard_i_queue(struct PStack *st)
struct sk_buff *skb;
while ((skb = skb_dequeue(&st->l2.i_queue))) {
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
}
}
-int
-l2headersize(struct Layer2 *tsp, int ui)
+static void
+discard_ui_queue(struct PStack *st)
+{
+ struct sk_buff *skb;
+
+ while ((skb = skb_dequeue(&st->l2.ui_queue))) {
+ dev_kfree_skb(skb);
+ }
+}
+
+inline void
+clear_exception(struct Layer2 *l2)
{
- return ((tsp->extended && (!ui) ? 2 : 1) + (tsp->laptype == LAPD ? 2 : 1));
+ test_and_clear_bit(FLG_ACK_PEND, &l2->flag);
+ test_and_clear_bit(FLG_REJEXC, &l2->flag);
+ test_and_clear_bit(FLG_OWN_BUSY, &l2->flag);
+ test_and_clear_bit(FLG_PEER_BUSY, &l2->flag);
}
-int
-l2addrsize(struct Layer2 *tsp)
+inline int
+l2headersize(struct Layer2 *l2, int ui)
{
- return (tsp->laptype == LAPD ? 2 : 1);
+ return (((test_bit(FLG_MOD128, &l2->flag) && (!ui)) ? 2 : 1) +
+ (test_bit(FLG_LAPD, &l2->flag) ? 2 : 1));
+}
+
+inline int
+l2addrsize(struct Layer2 *l2)
+{
+ return (test_bit(FLG_LAPD, &l2->flag) ? 2 : 1);
}
static int
-sethdraddr(struct Layer2 *tsp,
- u_char * header, int rsp)
+sethdraddr(struct Layer2 *l2, u_char * header, int rsp)
{
u_char *ptr = header;
- int crbit;
+ int crbit = rsp;
- if (tsp->laptype == LAPD) {
- crbit = rsp;
- if (!tsp->orig)
- crbit = !crbit;
- *ptr++ = (tsp->sap << 2) | (crbit ? 2 : 0);
- *ptr++ = (tsp->tei << 1) | 1;
+ if (test_bit(FLG_LAPD, &l2->flag)) {
+ *ptr++ = (l2->sap << 2) | (rsp ? 2 : 0);
+ *ptr++ = (l2->tei << 1) | 1;
return (2);
} else {
- crbit = rsp;
- if (tsp->orig)
+ if (test_bit(FLG_ORIG, &l2->flag))
crbit = !crbit;
if (crbit)
*ptr++ = 1;
@@ -218,79 +228,107 @@ static void
enqueue_ui(struct PStack *st,
struct sk_buff *skb)
{
- st->l2.l2l1(st, PH_DATA, skb);
+ st->l2.l2l1(st, PH_DATA_REQ, skb);
}
static void
enqueue_super(struct PStack *st,
struct sk_buff *skb)
{
- st->l2.l2l1(st, PH_DATA, skb);
+ st->l2.l2l1(st, PH_DATA_REQ, skb);
}
-static int
-legalnr(struct PStack *st, int nr)
+inline int
+IsUI(u_char * data, int ext)
{
- struct Layer2 *l2 = &st->l2;
- int lnr, lvs;
+ return ((data[0] & 0xef) == UI);
+}
- lvs = (l2->vs >= l2->va) ? l2->vs : (l2->vs + l2->extended ? 128 : 8);
- lnr = (nr >= l2->va) ? nr : (nr + l2->extended ? 128 : 8);
- return (lnr <= lvs);
+inline int
+IsUA(u_char * data, int ext)
+{
+ return ((data[0] & 0xef) == UA);
}
-static void
-setva(struct PStack *st, int nr)
+inline int
+IsDM(u_char * data, int ext)
{
- struct Layer2 *l2 = &st->l2;
+ return ((data[0] & 0xef) == DM);
+}
- if (l2->va != nr) {
- while (l2->va != nr) {
- l2->va = (l2->va + 1) % (l2->extended ? 128 : 8);
- SET_SKB_FREE(l2->windowar[l2->sow]);
- dev_kfree_skb(l2->windowar[l2->sow]);
- l2->windowar[l2->sow] = NULL;
- l2->sow = (l2->sow + 1) % l2->window;
- if (st->l4.l2writewakeup)
- st->l4.l2writewakeup(st);
- }
- }
+inline int
+IsDISC(u_char * data, int ext)
+{
+ return ((data[0] & 0xef) == DISC);
}
-static void
-l2s1(struct FsmInst *fi, int event, void *arg)
+inline int
+IsRR(u_char * data, int ext)
{
- struct PStack *st = fi->userdata;
+ if (ext)
+ return (data[0] == RR);
+ else
+ return ((data[0] & 0xf) == 1);
+}
- st->l2.l2tei(st, MDL_ASSIGN, (void *) st->l2.ces);
- FsmChangeState(fi, ST_L2_3);
+inline int
+IsSABMX(u_char * data, int ext)
+{
+ u_char d = data[0] & ~0x10;
+
+ return (ext ? d == SABME : d == SABM);
}
-static void
-l2_send_ui(struct FsmInst *fi, int event, void *arg)
+inline int
+IsREJ(u_char * data, int ext)
{
- struct PStack *st = fi->userdata;
- struct sk_buff *skb = arg;
- u_char header[MAX_HEADER_LEN];
- int i;
+ return (ext ? data[0] == REJ : (data[0] & 0xf) == REJ);
+}
- i = sethdraddr(&(st->l2), header, CMD);
- header[i++] = UI;
- memcpy(skb_push(skb, i), header, i);
- enqueue_ui(st, skb);
+inline int
+IsFRMR(u_char * data, int ext)
+{
+ return ((data[0] & 0xef) == FRMR);
}
-static void
-l2_receive_ui(struct FsmInst *fi, int event, void *arg)
+inline int
+IsRNR(u_char * data, int ext)
{
- struct PStack *st = fi->userdata;
- struct sk_buff *skb = arg;
+ return (ext ? data[0] == RNR : (data[0] & 0xf) == RNR);
+}
- skb_pull(skb, l2headersize(&st->l2, 1));
- st->l2.l2l3(st, DL_UNIT_DATA, skb);
+static int
+legalnr(struct PStack *st, int nr)
+{
+ struct Layer2 *l2 = &st->l2;
+ int lnr, lvs;
+
+ lvs = (l2->vs >= l2->va) ? l2->vs :
+ (l2->vs + (test_bit(FLG_MOD128, &l2->flag) ? 128 : 8));
+ lnr = (nr >= l2->va) ? nr : (test_bit(FLG_MOD128, &l2->flag) ? 128 : 8);
+ return (lnr <= lvs);
}
-inline void
+static void
+setva(struct PStack *st, int nr)
+{
+ struct Layer2 *l2 = &st->l2;
+ int len;
+
+ while (l2->va != nr) {
+ l2->va = (l2->va + 1) % (test_bit(FLG_MOD128, &l2->flag) ? 128 : 8);
+ len = l2->windowar[l2->sow]->len;
+ if (PACKET_NOACK == l2->windowar[l2->sow]->pkt_type)
+ len = -1;
+ dev_kfree_skb(l2->windowar[l2->sow]);
+ l2->windowar[l2->sow] = NULL;
+ l2->sow = (l2->sow + 1) % l2->window;
+ if (st->lli.l2writewakeup && (len >=0))
+ st->lli.l2writewakeup(st, len);
+ }
+}
+
+static void
send_uframe(struct PStack *st, u_char cmd, u_char cr)
{
struct sk_buff *skb;
@@ -307,53 +345,156 @@ send_uframe(struct PStack *st, u_char cmd, u_char cr)
enqueue_super(st, skb);
}
+inline u_char
+get_PollFlag(struct PStack * st, struct sk_buff * skb)
+{
+ return (skb->data[l2addrsize(&(st->l2))] & 0x10);
+}
+
+inline void
+FreeSkb(struct sk_buff *skb)
+{
+ dev_kfree_skb(skb);
+}
+
+
+inline u_char
+get_PollFlagFree(struct PStack *st, struct sk_buff *skb)
+{
+ u_char PF;
+
+ PF = get_PollFlag(st, skb);
+ FreeSkb(skb);
+ return (PF);
+}
+
static void
establishlink(struct FsmInst *fi)
{
struct PStack *st = fi->userdata;
u_char cmd;
- FsmChangeState(fi, ST_L2_5);
+ clear_exception(&st->l2);
st->l2.rc = 0;
+ cmd = (test_bit(FLG_MOD128, &st->l2.flag) ? SABME : SABM) | 0x10;
+ send_uframe(st, cmd, CMD);
+ FsmDelTimer(&st->l2.t203, 1);
+ FsmRestartTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 1);
+ test_and_set_bit(FLG_T200_RUN, &st->l2.flag);
+ FsmChangeState(fi, ST_L2_5);
+}
- if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 1))
- if (st->l2.l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 1");
+static void
+l2_mdl_error(struct FsmInst *fi, int event, void *arg)
+{
+ struct sk_buff *skb = arg;
+ struct PStack *st = fi->userdata;
+ switch (event) {
+ case EV_L2_UA:
+ if (get_PollFlagFree(st, skb))
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'C');
+ else
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'D');
+ break;
+ case EV_L2_DM:
+ if (get_PollFlagFree(st, skb))
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'B');
+ else {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'E');
+ establishlink(fi);
+ test_and_clear_bit(FLG_L3_INIT, &st->l2.flag);
+ }
+ break;
+ }
+}
- cmd = (st->l2.extended ? SABME : SABM) | 0x10;
- send_uframe(st, cmd, CMD);
+static void
+l2_dl_establish(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ int state = fi->state;
+
+ FsmChangeState(fi, ST_L2_3);
+ if (state == ST_L2_1)
+ st->l2.l2tei(st, MDL_ASSIGN_IND, NULL);
}
static void
-l2_establish(struct FsmInst *fi, int event, void *arg)
+l2_send_ui(struct PStack *st)
{
- establishlink(fi);
+ struct sk_buff *skb;
+ u_char header[MAX_HEADER_LEN];
+ int i;
+
+ i = sethdraddr(&(st->l2), header, CMD);
+ header[i++] = UI;
+ while ((skb = skb_dequeue(&st->l2.ui_queue))) {
+ memcpy(skb_push(skb, i), header, i);
+ enqueue_ui(st, skb);
+ }
}
static void
-l2_send_disconn(struct FsmInst *fi, int event, void *arg)
+l2_put_ui(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct Channel *chanp = st->l4.userdata;
-
- FsmChangeState(fi, ST_L2_6);
+ struct sk_buff *skb = arg;
- FsmDelTimer(&st->l2.t203_timer, 1);
- if (st->l2.t200_running) {
- FsmDelTimer(&st->l2.t200_timer, 2);
- st->l2.t200_running = 0;
+ skb_queue_tail(&st->l2.ui_queue, skb);
+ if (fi->state == ST_L2_1) {
+ FsmChangeState(fi, ST_L2_2);
+ st->l2.l2tei(st, MDL_ASSIGN_IND, NULL);
}
- st->l2.rc = 0;
- if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 2))
- if (st->l2.l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 2");
+ if (fi->state > ST_L2_3)
+ l2_send_ui(st);
+}
+static void
+l2_got_ui(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ struct sk_buff *skb = arg;
- if (!((chanp->impair == 2) && (st->l2.laptype == LAPB)))
- send_uframe(st, DISC | 0x10, CMD);
+ skb_pull(skb, l2headersize(&st->l2, 1));
+ if (skb->len > st->l2.maxlen) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'O');
+ FreeSkb(skb);
+ } else
+ st->l2.l2l3(st, DL_UNIT_DATA, skb);
+}
+
+static void
+l2_establish(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ if (fi->state != ST_L2_4)
+ discard_i_queue(st);
+ if (fi->state != ST_L2_5)
+ establishlink(fi);
+ test_and_set_bit(FLG_L3_INIT, &st->l2.flag);
+}
+
+static void
+l2_dl_release(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+
+ if (fi->state == ST_L2_4) {
+ st->l2.l2man(st, DL_RELEASE, NULL);
+ return;
+ } else if (fi->state == ST_L2_5) {
+ test_and_set_bit(FLG_PEND_REL, &st->l2.flag);
+ return;
+ }
discard_i_queue(st);
+ FsmChangeState(fi, ST_L2_6);
+ st->l2.rc = 0;
+ send_uframe(st, DISC | 0x10, CMD);
+ FsmDelTimer(&st->l2.t203, 1);
+ FsmRestartTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 2);
+ test_and_set_bit(FLG_T200_RUN, &st->l2.flag);
}
static void
@@ -361,46 +502,59 @@ l2_got_SABMX(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
struct sk_buff *skb = arg;
- int est = 1, state;
+ int est = 1, state, rsp;
u_char PollFlag;
state = fi->state;
-
- skb_pull(skb, l2addrsize(&(st->l2)));
- PollFlag = *skb->data & 0x10;
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
-
- if (ST_L2_4 != state)
+ rsp = *skb->data & 0x2;
+ if (test_bit(FLG_ORIG, &st->l2.flag))
+ rsp = !rsp;
+ if (rsp) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'L');
+ FreeSkb(skb);
+ if ((state == ST_L2_7) || (state == ST_L2_8))
+ establishlink(fi);
+ return;
+ }
+ if (skb->len != (l2addrsize(&st->l2) + 1)) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'N');
+ FreeSkb(skb);
+ if ((state == ST_L2_7) || (state == ST_L2_8))
+ establishlink(fi);
+ return;
+ }
+ PollFlag = get_PollFlagFree(st, skb);
+ if (ST_L2_6 == state) {
+ send_uframe(st, DM | PollFlag, RSP);
+ return;
+ } else
+ send_uframe(st, UA | PollFlag, RSP);
+ if (ST_L2_5 == state)
+ return;
+ if (ST_L2_4 != state) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'F');
if (st->l2.vs != st->l2.va) {
discard_i_queue(st);
est = 1;
} else
est = 0;
-
+ }
+ clear_exception(&st->l2);
st->l2.vs = 0;
st->l2.va = 0;
st->l2.vr = 0;
st->l2.sow = 0;
- if (ST_L2_7 != state)
- FsmChangeState(fi, ST_L2_7);
-
- send_uframe(st, UA | PollFlag, RSP);
-
- if (st->l2.t200_running) {
- FsmDelTimer(&st->l2.t200_timer, 15);
- st->l2.t200_running = 0;
- }
- if (FsmAddTimer(&st->l2.t203_timer, st->l2.t203, EV_L2_T203, NULL, 3))
- if (st->l2.l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 3");
+ FsmChangeState(fi, ST_L2_7);
+ if (test_and_clear_bit(FLG_T200_RUN, &st->l2.flag))
+ FsmDelTimer(&st->l2.t200, 2);
+ FsmAddTimer(&st->l2.t203, st->l2.T203, EV_L2_T203, NULL, 3);
if (est)
st->l2.l2man(st, DL_ESTABLISH, NULL);
if (ST_L2_8 == state)
if (skb_queue_len(&st->l2.i_queue) && cansend(st))
- st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
+ st->l2.l2l1(st, PH_PULL_REQ, NULL);
}
static void
@@ -408,87 +562,152 @@ l2_got_disconn(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
struct sk_buff *skb = arg;
- struct Channel *chanp = st->l4.userdata;
- u_char PollFlag;
-
- skb_pull(skb, l2addrsize(&(st->l2)));
- PollFlag = *skb->data & 0x10;
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
+ u_char PollFlag, cmd = UA;
+ int state, rel = 1, cst = 1, rsp;
- FsmChangeState(fi, ST_L2_4);
+ state = fi->state;
+ rsp = *skb->data & 0x2;
+ if (test_bit(FLG_ORIG, &st->l2.flag))
+ rsp = !rsp;
- FsmDelTimer(&st->l2.t203_timer, 3);
- if (st->l2.t200_running) {
- FsmDelTimer(&st->l2.t200_timer, 4);
- st->l2.t200_running = 0;
+ if (rsp) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'L');
+ FreeSkb(skb);
+ if ((state == ST_L2_7) || (state == ST_L2_8))
+ establishlink(fi);
+ return;
+ }
+ if (skb->len != (l2addrsize(&st->l2) + 1)) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'N');
+ FreeSkb(skb);
+ if ((state == ST_L2_7) || (state == ST_L2_8))
+ establishlink(fi);
+ return;
}
- if (!((chanp->impair == 1) && (st->l2.laptype == LAPB)))
- send_uframe(st, UA | PollFlag, RSP);
-
- st->l2.l2man(st, DL_RELEASE, NULL);
+ PollFlag = get_PollFlagFree(st, skb);
+ if ((state == ST_L2_4) || (state == ST_L2_5)) {
+ rel = 0;
+ cst = 0;
+ cmd = DM;
+ } else if (state == ST_L2_6) {
+ rel = 0;
+ cst = 0;
+ }
+ if (cst) {
+ FsmChangeState(fi, ST_L2_4);
+ FsmDelTimer(&st->l2.t203, 3);
+ if (test_and_clear_bit(FLG_T200_RUN, &st->l2.flag))
+ FsmDelTimer(&st->l2.t200, 2);
+ }
+ send_uframe(st, cmd | PollFlag, RSP);
+ if (rel)
+ st->l2.l2man(st, DL_RELEASE, NULL);
}
+
static void
-l2_got_st4_disc(struct FsmInst *fi, int event, void *arg)
+l2_got_ua(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
struct sk_buff *skb = arg;
- struct Channel *chanp = st->l4.userdata;
- u_char PollFlag;
+ u_char PollFlag, est = 1;
+ int state,rsp;
- skb_pull(skb, l2addrsize(&(st->l2)));
- PollFlag = *skb->data & 0x10;
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
+ state = fi->state;
+ rsp = *skb->data & 0x2;
+ if (test_bit(FLG_ORIG, &st->l2.flag))
+ rsp = !rsp;
- if (!((chanp->impair == 1) && (st->l2.laptype == LAPB)))
- send_uframe(st, DM | (PollFlag ? 0x10 : 0x0), RSP);
+ if (!rsp) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'L');
+ FreeSkb(skb);
+ if ((state == ST_L2_7) || (state == ST_L2_8))
+ establishlink(fi);
+ return;
+ }
+ if (skb->len != (l2addrsize(&st->l2) + 1)) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'N');
+ FreeSkb(skb);
+ if ((fi->state == ST_L2_7) || (fi->state == ST_L2_8))
+ establishlink(fi);
+ return;
+ }
+ PollFlag = get_PollFlag(st, skb);
+ if (!PollFlag) {
+ l2_mdl_error(fi, event, arg);
+ return;
+ }
+ FreeSkb(skb);
+ if (test_and_clear_bit(FLG_T200_RUN, &st->l2.flag))
+ FsmDelTimer(&st->l2.t200, 2);
+ if (fi->state == ST_L2_5) {
+ if (test_and_clear_bit(FLG_PEND_REL, &st->l2.flag)) {
+ discard_i_queue(st);
+ st->l2.rc = 0;
+ send_uframe(st, DISC | 0x10, CMD);
+ FsmChangeState(fi, ST_L2_6);
+ FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 4);
+ test_and_set_bit(FLG_T200_RUN, &st->l2.flag);
+ } else {
+ if (!test_and_clear_bit(FLG_L3_INIT, &st->l2.flag))
+ if (st->l2.vs != st->l2.va)
+ discard_i_queue(st);
+ else
+ est = 0;
+ st->l2.vs = 0;
+ st->l2.va = 0;
+ st->l2.vr = 0;
+ st->l2.sow = 0;
+ FsmChangeState(fi, ST_L2_7);
+ FsmAddTimer(&st->l2.t203, st->l2.T203, EV_L2_T203, NULL, 4);
+ if (est)
+ st->l2.l2man(st, DL_ESTABLISH, NULL);
+ }
+ } else { /* ST_L2_6 */
+ st->l2.l2man(st, DL_RELEASE, NULL);
+ FsmChangeState(fi, ST_L2_4);
+ }
}
static void
-l2_got_ua_establish(struct FsmInst *fi, int event, void *arg)
+l2_got_dm(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
struct sk_buff *skb = arg;
- u_char f;
+ u_char PollFlag;
+ int state,rsp;
- skb_pull(skb, l2addrsize(&(st->l2)));
- f = *skb->data & 0x10;
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
- if (f) {
- st->l2.vs = 0;
- st->l2.va = 0;
- st->l2.vr = 0;
- st->l2.sow = 0;
- FsmChangeState(fi, ST_L2_7);
-
- FsmDelTimer(&st->l2.t200_timer, 5);
- if (FsmAddTimer(&st->l2.t203_timer, st->l2.t203, EV_L2_T203, NULL, 4))
- if (st->l2.l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 4");
+ state = fi->state;
+ rsp = *skb->data & 0x2;
+ if (test_bit(FLG_ORIG, &st->l2.flag))
+ rsp = !rsp;
- st->l2.l2man(st, DL_ESTABLISH, NULL);
+ if (!rsp) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'L');
+ FreeSkb(skb);
+ if ((state == ST_L2_7) || (state == ST_L2_8))
+ establishlink(fi);
+ return;
+ }
+ if (skb->len != (l2addrsize(&st->l2) + 1)) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'N');
+ FreeSkb(skb);
+ if ((fi->state == ST_L2_7) || (fi->state == ST_L2_8))
+ establishlink(fi);
+ return;
}
-}
-
-static void
-l2_got_ua_disconn(struct FsmInst *fi, int event, void *arg)
-{
- struct PStack *st = fi->userdata;
- struct sk_buff *skb = arg;
- u_char f;
-
- skb_pull(skb, l2addrsize(&(st->l2)));
- f = *skb->data & 0x10;
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
- if (f) {
- FsmDelTimer(&st->l2.t200_timer, 6);
- FsmChangeState(fi, ST_L2_4);
+ PollFlag = get_PollFlagFree(st, skb);
+ if (!PollFlag) {
+ establishlink(fi);
+ test_and_clear_bit(FLG_L3_INIT, &st->l2.flag);
+ } else {
+ if (test_and_clear_bit(FLG_T200_RUN, &st->l2.flag))
+ FsmDelTimer(&st->l2.t200, 2);
+ if (fi->state == ST_L2_5 && !test_bit(FLG_L3_INIT, &st->l2.flag))
+ discard_i_queue(st);
st->l2.l2man(st, DL_RELEASE, NULL);
+ FsmChangeState(fi, ST_L2_4);
}
}
@@ -502,7 +721,7 @@ enquiry_cr(struct PStack *st, u_char typ, u_char cr, u_char pf)
l2 = &st->l2;
i = sethdraddr(l2, tmp, cr);
- if (l2->extended) {
+ if (test_bit(FLG_MOD128, &l2->flag)) {
tmp[i++] = typ;
tmp[i++] = (l2->vr << 1) | (pf ? 1 : 0);
} else
@@ -516,77 +735,133 @@ enquiry_cr(struct PStack *st, u_char typ, u_char cr, u_char pf)
}
inline void
-enquiry_response(struct PStack *st, u_char typ, u_char final)
+enquiry_response(struct PStack *st)
{
- enquiry_cr(st, typ, RSP, final);
+ if (test_bit(FLG_OWN_BUSY, &st->l2.flag))
+ enquiry_cr(st, RNR, RSP, 1);
+ else
+ enquiry_cr(st, RR, RSP, 1);
+ test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag);
}
inline void
-enquiry_command(struct PStack *st, u_char typ, u_char poll)
+transmit_enquiry(struct PStack *st)
{
- enquiry_cr(st, typ, CMD, poll);
+ if (test_bit(FLG_OWN_BUSY, &st->l2.flag))
+ enquiry_cr(st, RNR, CMD, 1);
+ else
+ enquiry_cr(st, RR, CMD, 1);
+ test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag);
+ FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 12);
+ test_and_set_bit(FLG_T200_RUN, &st->l2.flag);
}
+
static void
nrerrorrecovery(struct FsmInst *fi)
{
- /* should log error here */
+ struct PStack *st = fi->userdata;
+
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'J');
establishlink(fi);
}
static void
-l2_got_st7_RR(struct FsmInst *fi, int event, void *arg)
+invoke_retransmission(struct PStack *st, int nr)
+{
+ struct Layer2 *l2 = &st->l2;
+ int p1;
+ long flags;
+
+ if (l2->vs != nr) {
+ save_flags(flags);
+ cli();
+ while (l2->vs != nr) {
+ l2->vs = l2->vs - 1;
+ if (l2->vs < 0)
+ l2->vs += (test_bit(FLG_MOD128, &l2->flag) ? 128 : 8);
+ p1 = l2->vs - l2->va;
+ if (p1 < 0)
+ p1 += (test_bit(FLG_MOD128, &l2->flag) ? 128 : 8);
+ p1 = (p1 + l2->sow) % l2->window;
+ skb_queue_head(&l2->i_queue, l2->windowar[p1]);
+ l2->windowar[p1] = NULL;
+ }
+ restore_flags(flags);
+ st->l2.l2l1(st, PH_PULL_REQ, NULL);
+ }
+}
+
+static void
+l2_got_st7_super(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct Channel *chanp = st->l4.userdata;
struct sk_buff *skb = arg;
- int PollFlag, seq, rsp;
- struct Layer2 *l2;
+ int PollFlag, nr, rsp, typ = RR;
+ struct Layer2 *l2 = &st->l2;
- l2 = &st->l2;
- if (l2->laptype == LAPD)
- rsp = *skb->data & 0x2;
- else
- rsp = *skb->data == 0x3;
- if (l2->orig)
+ rsp = *skb->data & 0x2;
+ if (test_bit(FLG_ORIG, &l2->flag))
rsp = !rsp;
skb_pull(skb, l2addrsize(l2));
- if (l2->extended) {
- PollFlag = (skb->data[1] & 0x1) == 0x1;
- seq = skb->data[1] >> 1;
+ if (IsRNR(skb->data, test_bit(FLG_MOD128, &l2->flag))) {
+ test_and_set_bit(FLG_PEER_BUSY, &l2->flag);
+ typ = RNR;
+ } else
+ test_and_clear_bit(FLG_PEER_BUSY, &l2->flag);
+ if (IsREJ(skb->data, test_bit(FLG_MOD128, &l2->flag)))
+ typ = REJ;
+ if (test_bit(FLG_MOD128, &l2->flag)) {
+ if (skb->len == 2) {
+ PollFlag = (skb->data[1] & 0x1) == 0x1;
+ nr = skb->data[1] >> 1;
+ } else {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'N');
+ FreeSkb(skb);
+ establishlink(fi);
+ return;
+ }
} else {
- PollFlag = (skb->data[0] & 0x10);
- seq = (skb->data[0] >> 5) & 0x7;
+ if (skb->len == 1) {
+ PollFlag = (skb->data[0] & 0x10);
+ nr = (skb->data[0] >> 5) & 0x7;
+ } else {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'N');
+ FreeSkb(skb);
+ establishlink(fi);
+ return;
+ }
}
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
+ FreeSkb(skb);
- if (!((chanp->impair == 4) && (st->l2.laptype == LAPB)))
- if ((!rsp) && PollFlag)
- enquiry_response(st, RR, PollFlag);
-
- if (legalnr(st, seq)) {
- if (seq == l2->vs) {
- setva(st, seq);
- FsmDelTimer(&l2->t200_timer, 7);
- l2->t200_running = 0;
- FsmDelTimer(&l2->t203_timer, 8);
- if (FsmAddTimer(&l2->t203_timer, l2->t203, EV_L2_T203, NULL, 5))
- if (l2->l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 5");
-
- if (skb_queue_len(&st->l2.i_queue))
- st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
- } else if (l2->va != seq) {
- setva(st, seq);
- FsmDelTimer(&st->l2.t200_timer, 9);
- if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 6))
- if (st->l2.l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 6");
- if (skb_queue_len(&st->l2.i_queue))
- st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
+ if ((!rsp) && PollFlag)
+ enquiry_response(st);
+ if (rsp && PollFlag)
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'A');
+ if (legalnr(st, nr)) {
+ if (typ == REJ) {
+ setva(st, nr);
+ invoke_retransmission(st, nr);
+ if (test_and_clear_bit(FLG_T200_RUN, &st->l2.flag))
+ FsmDelTimer(&st->l2.t200, 9);
+ if (FsmAddTimer(&st->l2.t203, st->l2.T203,
+ EV_L2_T203, NULL, 6))
+ l2m_debug(&st->l2.l2m, "Restart T203 ST7 REJ");
+ } else if ((nr == l2->vs) && (typ == RR)) {
+ setva(st, nr);
+ if (test_and_clear_bit(FLG_T200_RUN, &st->l2.flag))
+ FsmDelTimer(&st->l2.t200, 9);
+ FsmRestartTimer(&st->l2.t203, st->l2.T203,
+ EV_L2_T203, NULL, 7);
+ } else if ((l2->va != nr) || (typ == RNR)) {
+ setva(st, nr);
+ FsmDelTimer(&st->l2.t203, 9);
+ FsmRestartTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 6);
+ test_and_set_bit(FLG_T200_RUN, &st->l2.flag);
}
+ if (skb_queue_len(&st->l2.i_queue) && (typ == RR))
+ st->l2.l2l1(st, PH_PULL_REQ, NULL);
} else
nrerrorrecovery(fi);
@@ -602,122 +877,121 @@ l2_feed_iqueue(struct FsmInst *fi, int event, void *arg)
struct PStack *st = fi->userdata;
struct sk_buff *skb = arg;
- skb_queue_tail(&st->l2.i_queue, skb);
- st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
+ if (test_bit(FLG_LAPB, &st->l2.flag))
+ st->l1.bcs->tx_cnt += skb->len + l2headersize(&st->l2, 0);
+ if (!((fi->state == ST_L2_5) && test_bit(FLG_L3_INIT, &st->l2.flag)))
+ skb_queue_tail(&st->l2.i_queue, skb);
+ if (fi->state == ST_L2_7)
+ st->l2.l2l1(st, PH_PULL_REQ, NULL);
}
-static int
-icommandreceived(struct FsmInst *fi, int event, void *arg, int *nr)
+static void
+l2_got_iframe(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct Channel *chanp = st->l4.userdata;
struct sk_buff *skb = arg;
struct IsdnCardState *sp = st->l1.hardware;
struct Layer2 *l2 = &(st->l2);
- int i, p, seq, wasok;
+ int PollFlag, ns, nr, i, hs, rsp;
char str[64];
+ rsp = *skb->data & 0x2;
+ if (test_bit(FLG_ORIG, &l2->flag))
+ rsp = !rsp;
+
+ if (rsp) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'L');
+ FreeSkb(skb);
+ establishlink(fi);
+ return;
+ }
i = l2addrsize(l2);
- if (l2->extended) {
- p = (skb->data[i + 1] & 0x1) == 0x1;
- seq = skb->data[i] >> 1;
- *nr = (skb->data[i + 1] >> 1) & 0x7f;
+ if (test_bit(FLG_MOD128, &l2->flag)) {
+ if (skb->len <= (i + 1)) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'N');
+ FreeSkb(skb);
+ establishlink(fi);
+ return;
+ } else if ((skb->len - i - 1) > l2->maxlen) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'O');
+ FreeSkb(skb);
+ establishlink(fi);
+ return;
+ }
+ PollFlag = ((skb->data[i + 1] & 0x1) == 0x1);
+ ns = skb->data[i] >> 1;
+ nr = (skb->data[i + 1] >> 1) & 0x7f;
} else {
- p = (skb->data[i] & 0x10);
- seq = (skb->data[i] >> 1) & 0x7;
- *nr = (skb->data[i] >> 5) & 0x7;
+ if (skb->len <= i) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'N');
+ FreeSkb(skb);
+ establishlink(fi);
+ return;
+ } else if ((skb->len - i) > l2->maxlen) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'O');
+ FreeSkb(skb);
+ establishlink(fi);
+ return;
+ }
+ PollFlag = (skb->data[i] & 0x10);
+ ns = (skb->data[i] >> 1) & 0x7;
+ nr = (skb->data[i] >> 5) & 0x7;
}
-
- if (l2->vr == seq) {
- wasok = !0;
-
- l2->vr = (l2->vr + 1) % (l2->extended ? 128 : 8);
- l2->rejexp = 0;
-
- if (st->l2.laptype == LAPD)
+ if (test_bit(FLG_OWN_BUSY, &l2->flag)) {
+ FreeSkb(skb);
+ enquiry_response(st);
+ } else if (l2->vr == ns) {
+ l2->vr = (l2->vr + 1) % (test_bit(FLG_MOD128, &l2->flag) ? 128 : 8);
+ test_and_clear_bit(FLG_REJEXC, &l2->flag);
+ if (test_bit(FLG_LAPD, &l2->flag))
if (sp->dlogflag) {
+ hs = l2headersize(l2, 0);
LogFrame(st->l1.hardware, skb->data, skb->len);
sprintf(str, "Q.931 frame network->user tei %d", st->l2.tei);
- dlogframe(st->l1.hardware, skb->data + l2->ihsize,
- skb->len - l2->ihsize, str);
+ dlogframe(st->l1.hardware, skb->data + hs,
+ skb->len - hs, str);
}
- if (!((chanp->impair == 3) && (st->l2.laptype == LAPB)))
- if (p || (!skb_queue_len(&st->l2.i_queue)))
- enquiry_response(st, RR, p);
+ if (PollFlag)
+ enquiry_response(st);
+ else
+ test_and_set_bit(FLG_ACK_PEND, &l2->flag);
skb_pull(skb, l2headersize(l2, 0));
+ st->l2.l2l3(st, DL_DATA, skb);
} else {
/* n(s)!=v(r) */
- wasok = 0;
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
- if (st->l2.rejexp) {
- if (p)
- if (!((chanp->impair == 3) && (st->l2.laptype == LAPB)))
- enquiry_response(st, RR, p);
+ FreeSkb(skb);
+ if (test_and_set_bit(FLG_REJEXC, &l2->flag)) {
+ if (PollFlag)
+ enquiry_response(st);
} else {
- st->l2.rejexp = !0;
- enquiry_command(st, REJ, 1);
+ enquiry_cr(st, REJ, RSP, PollFlag);
+ test_and_clear_bit(FLG_ACK_PEND, &l2->flag);
}
}
- return wasok;
-}
-
-static void
-l2_got_st7_data(struct FsmInst *fi, int event, void *arg)
-{
- struct PStack *st = fi->userdata;
- struct sk_buff *skb = arg;
- int nr, wasok;
-
- wasok = icommandreceived(fi, event, arg, &nr);
-
- if (legalnr(st, nr)) {
- if (nr == st->l2.vs) {
- setva(st, nr);
- FsmDelTimer(&st->l2.t200_timer, 10);
- st->l2.t200_running = 0;
- FsmDelTimer(&st->l2.t203_timer, 11);
- if (FsmAddTimer(&st->l2.t203_timer, st->l2.t203, EV_L2_T203, NULL, 7))
- if (st->l2.l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 5");
-
- if (skb_queue_len(&st->l2.i_queue))
- st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
- } else if (nr != st->l2.va) {
- setva(st, nr);
- FsmDelTimer(&st->l2.t200_timer, 12);
- if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 8))
- if (st->l2.l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 6");
-
- if (skb_queue_len(&st->l2.i_queue))
- st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
- }
- } else
- nrerrorrecovery(fi);
-
- if (wasok)
- st->l2.l2l3(st, DL_DATA, skb);
-}
-
-static void
-l2_got_st8_data(struct FsmInst *fi, int event, void *arg)
-{
- struct PStack *st = fi->userdata;
- struct sk_buff *skb = arg;
- int nr, wasok;
-
- wasok = icommandreceived(fi, event, arg, &nr);
if (legalnr(st, nr)) {
setva(st, nr);
- if (skb_queue_len(&st->l2.i_queue))
- st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
- } else
+ if (!test_bit(FLG_PEER_BUSY, &st->l2.flag) && (fi->state == ST_L2_7)) {
+ if (nr == st->l2.vs) {
+ if (test_and_clear_bit(FLG_T200_RUN, &st->l2.flag))
+ FsmDelTimer(&st->l2.t200, 10);
+ FsmRestartTimer(&st->l2.t203, st->l2.T203,
+ EV_L2_T203, NULL, 7);
+ } else if (nr != st->l2.va) {
+ FsmRestartTimer(&st->l2.t200, st->l2.T200, EV_L2_T200,
+ NULL, 8);
+ test_and_set_bit(FLG_T200_RUN, &st->l2.flag);
+ }
+ }
+ } else {
nrerrorrecovery(fi);
+ return;
+ }
- if (wasok)
- st->l2.l2l3(st, DL_DATA, skb);
+ if (skb_queue_len(&st->l2.i_queue) && (fi->state == ST_L2_7))
+ st->l2.l2l1(st, PH_PULL_REQ, NULL);
+ if (test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag))
+ enquiry_cr(st, RR, RSP, 0);
}
static void
@@ -726,69 +1000,14 @@ l2_got_tei(struct FsmInst *fi, int event, void *arg)
struct PStack *st = fi->userdata;
st->l2.tei = (int) arg;
- establishlink(fi);
-}
-
-static void
-invoke_retransmission(struct PStack *st, int nr)
-{
- struct Layer2 *l2 = &st->l2;
- int p1;
-
- if (l2->vs != nr) {
- while (l2->vs != nr) {
-
- l2->vs = l2->vs - 1;
- if (l2->vs < 0)
- l2->vs += l2->extended ? 128 : 8;
- p1 = l2->vs - l2->va;
- if (p1 < 0)
- p1 += l2->extended ? 128 : 8;
- p1 = (p1 + l2->sow) % l2->window;
-
- skb_queue_head(&l2->i_queue, l2->windowar[p1]);
- l2->windowar[p1] = NULL;
- }
- st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
- }
-}
-
-static void
-l2_got_st7_rej(struct FsmInst *fi, int event, void *arg)
-{
- struct PStack *st = fi->userdata;
- struct sk_buff *skb = arg;
- int PollFlag, seq, rsp;
- struct Layer2 *l2;
-
- l2 = &st->l2;
- if (l2->laptype == LAPD)
- rsp = *skb->data & 0x2;
- else
- rsp = *skb->data == 0x3;
- if (l2->orig)
- rsp = !rsp;
-
- skb_pull(skb, l2addrsize(l2));
- if (l2->extended) {
- PollFlag = (skb->data[1] & 0x1) == 0x1;
- seq = skb->data[1] >> 1;
- } else {
- PollFlag = (skb->data[0] & 0x10);
- seq = (skb->data[0] >> 5) & 0x7;
- }
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
-
- if ((!rsp) && PollFlag)
- enquiry_response(st, RR, PollFlag);
-
- if (!legalnr(st, seq))
- return;
-
- setva(st, seq);
- invoke_retransmission(st, seq);
+ if (fi->state == ST_L2_3) {
+ establishlink(fi);
+ test_and_set_bit(FLG_L3_INIT, &st->l2.flag);
+ } else
+ FsmChangeState(fi, ST_L2_4);
+ if (skb_queue_len(&st->l2.ui_queue))
+ l2_send_ui(st);
}
static void
@@ -801,21 +1020,21 @@ static void
l2_st5_tout_200(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- u_char cmd;
- if (st->l2.rc == st->l2.n200) {
+ if (test_bit(FLG_LAPD, &st->l2.flag) &&
+ test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) {
+ FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 9);
+ } else if (st->l2.rc == st->l2.N200) {
FsmChangeState(fi, ST_L2_4);
- st->l2.l2tei(st, MDL_VERIFY, (void *) st->l2.tei);
+ test_and_clear_bit(FLG_T200_RUN, &st->l2.flag);
+ discard_i_queue(st);
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'G');
st->l2.l2man(st, DL_RELEASE, NULL);
} else {
st->l2.rc++;
-
- if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 9))
- if (st->l2.l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 7");
-
- cmd = (st->l2.extended ? SABME : SABM) | 0x10;
- send_uframe(st, cmd, CMD);
+ FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 9);
+ send_uframe(st, (test_bit(FLG_MOD128, &st->l2.flag) ? SABME : SABM)
+ | 0x10, CMD);
}
}
@@ -823,30 +1042,65 @@ static void
l2_st6_tout_200(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct Channel *chanp = st->l4.userdata;
- if (st->l2.rc == st->l2.n200) {
+ if (test_bit(FLG_LAPD, &st->l2.flag) &&
+ test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) {
+ FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 9);
+ } else if (st->l2.rc == st->l2.N200) {
FsmChangeState(fi, ST_L2_4);
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'H');
st->l2.l2man(st, DL_RELEASE, NULL);
} else {
st->l2.rc++;
+ FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200,
+ NULL, 9);
+ send_uframe(st, DISC | 0x10, CMD);
+ }
+}
- if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 10))
- if (st->l2.l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 8");
+static void
+l2_st78_tout_200(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ if (test_bit(FLG_LAPD, &st->l2.flag) &&
+ test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) {
+ FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 9);
+ return;
+ }
+ test_and_clear_bit(FLG_T200_RUN, &st->l2.flag);
+ if (fi->state == ST_L2_7) {
+ st->l2.rc = 0;
+ FsmChangeState(fi, ST_L2_8);
+ }
+ if (st->l2.rc == st->l2.N200) {
+ establishlink(fi);
+ } else {
+ transmit_enquiry(st);
+ st->l2.rc++;
+ }
+}
- if (!((chanp->impair == 2) && (st->l2.laptype == LAPB)))
- send_uframe(st, DISC | 0x10, CMD);
+static void
+l2_st7_tout_203(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ if (test_bit(FLG_LAPD, &st->l2.flag) &&
+ test_bit(FLG_DCHAN_BUSY, &st->l2.flag)) {
+ FsmAddTimer(&st->l2.t203, st->l2.T203, EV_L2_T203, NULL, 9);
+ return;
}
+ FsmChangeState(fi, ST_L2_8);
+ transmit_enquiry(st);
+ st->l2.rc = 0;
}
static void
l2_pull_iqueue(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
- struct sk_buff *skb;
+ struct sk_buff *skb, *oskb;
struct Layer2 *l2 = &st->l2;
u_char header[MAX_HEADER_LEN];
int p1, i;
@@ -860,19 +1114,18 @@ l2_pull_iqueue(struct FsmInst *fi, int event, void *arg)
p1 = l2->vs - l2->va;
if (p1 < 0)
- p1 += l2->extended ? 128 : 8;
+ p1 += test_bit(FLG_MOD128, &l2->flag) ? 128 : 8;
p1 = (p1 + l2->sow) % l2->window;
if (l2->windowar[p1]) {
printk(KERN_WARNING "isdnl2 try overwrite ack queue entry %d\n",
p1);
- SET_SKB_FREE(l2->windowar[p1]);
dev_kfree_skb(l2->windowar[p1]);
}
l2->windowar[p1] = skb_clone(skb, GFP_ATOMIC);
i = sethdraddr(&st->l2, header, CMD);
- if (l2->extended) {
+ if (test_bit(FLG_MOD128, &l2->flag)) {
header[i++] = l2->vs << 1;
header[i++] = l2->vr << 1;
l2->vs = (l2->vs + 1) % 128;
@@ -880,88 +1133,86 @@ l2_pull_iqueue(struct FsmInst *fi, int event, void *arg)
header[i++] = (l2->vr << 5) | (l2->vs << 1);
l2->vs = (l2->vs + 1) % 8;
}
-
- memcpy(skb_push(skb, i), header, i);
- st->l2.l2l1(st, PH_DATA_PULLED, skb);
- if (!st->l2.t200_running) {
- FsmDelTimer(&st->l2.t203_timer, 13);
- if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 11))
- if (st->l2.l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 9");
-
- st->l2.t200_running = !0;
+ p1 = skb->data - skb->head;
+ if (p1 >= i)
+ memcpy(skb_push(skb, i), header, i);
+ else {
+ printk(KERN_WARNING
+ "isdl2 pull_iqueue skb header(%d/%d) too short\n", i, p1);
+ oskb = skb;
+ skb = alloc_skb(oskb->len + i, GFP_ATOMIC);
+ memcpy(skb_put(skb, i), header, i);
+ memcpy(skb_put(skb, oskb->len), oskb->data, oskb->len);
+ FreeSkb(oskb);
+ }
+ st->l2.l2l1(st, PH_PULL_IND, skb);
+ test_and_clear_bit(FLG_ACK_PEND, &st->l2.flag);
+ if (!test_and_set_bit(FLG_T200_RUN, &st->l2.flag)) {
+ FsmDelTimer(&st->l2.t203, 13);
+ FsmAddTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, 11);
}
if (skb_queue_len(&l2->i_queue) && cansend(st))
- st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
-}
-
-static void
-transmit_enquiry(struct PStack *st)
-{
-
- enquiry_command(st, RR, 1);
- if (FsmAddTimer(&st->l2.t200_timer, st->l2.t200, EV_L2_T200, NULL, 12))
- if (st->l2.l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 10");
-
- st->l2.t200_running = !0;
-}
-
-static void
-l2_st7_tout_200(struct FsmInst *fi, int event, void *arg)
-{
- struct PStack *st = fi->userdata;
-
- st->l2.t200_running = 0;
-
- st->l2.rc = 1;
- FsmChangeState(fi, ST_L2_8);
- transmit_enquiry(st);
+ st->l2.l2l1(st, PH_PULL_REQ, NULL);
}
static void
-l2_got_st8_rr_rej(struct FsmInst *fi, int event, void *arg)
+l2_got_st8_super(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
struct sk_buff *skb = arg;
- int PollFlag, seq, rsp;
- struct Layer2 *l2;
+ int PollFlag, nr, rsp, rnr = 0;
+ struct Layer2 *l2 = &st->l2;
- l2 = &st->l2;
- if (l2->laptype == LAPD)
- rsp = *skb->data & 0x2;
- else
- rsp = *skb->data == 0x3;
- if (l2->orig)
+ rsp = *skb->data & 0x2;
+ if (test_bit(FLG_ORIG, &l2->flag))
rsp = !rsp;
-
skb_pull(skb, l2addrsize(l2));
- if (l2->extended) {
- PollFlag = (skb->data[1] & 0x1) == 0x1;
- seq = skb->data[1] >> 1;
+
+ if (IsRNR(skb->data, test_bit(FLG_MOD128, &l2->flag))) {
+ test_and_set_bit(FLG_PEER_BUSY, &l2->flag);
+ rnr = 1;
+ } else
+ test_and_clear_bit(FLG_PEER_BUSY, &l2->flag);
+ if (test_bit(FLG_MOD128, &l2->flag)) {
+ if (skb->len == 2) {
+ PollFlag = (skb->data[1] & 0x1) == 0x1;
+ nr = skb->data[1] >> 1;
+ } else {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'N');
+ FreeSkb(skb);
+ establishlink(fi);
+ return;
+ }
} else {
- PollFlag = (skb->data[0] & 0x10);
- seq = (skb->data[0] >> 5) & 0x7;
+ if (skb->len == 1) {
+ PollFlag = (skb->data[0] & 0x10);
+ nr = (skb->data[0] >> 5) & 0x7;
+ } else {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'N');
+ FreeSkb(skb);
+ establishlink(fi);
+ return;
+ }
}
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
+ FreeSkb(skb);
if (rsp && PollFlag) {
- if (legalnr(st, seq)) {
+ if (legalnr(st, nr)) {
+ setva(st, nr);
+ if (test_and_clear_bit(FLG_T200_RUN, &st->l2.flag))
+ FsmDelTimer(&st->l2.t200, 7);
+ FsmDelTimer(&l2->t203, 8);
+ if (rnr) {
+ FsmRestartTimer(&l2->t200, l2->T200,
+ EV_L2_T200, NULL, 14);
+ test_and_set_bit(FLG_T200_RUN, &st->l2.flag);
+ } else
+ FsmAddTimer(&l2->t203, l2->T203,
+ EV_L2_T203, NULL, 5);
+ invoke_retransmission(st, nr);
FsmChangeState(fi, ST_L2_7);
- setva(st, seq);
- if (st->l2.t200_running) {
- FsmDelTimer(&st->l2.t200_timer, 14);
- st->l2.t200_running = 0;
- }
- if (FsmAddTimer(&st->l2.t203_timer, st->l2.t203, EV_L2_T203, NULL, 13))
- if (st->l2.l2m.debug)
- l2m_debug(&st->l2.l2m, "FAT 11");
-
- invoke_retransmission(st, seq);
-
if (skb_queue_len(&l2->i_queue) && cansend(st))
- st->l2.l2l1(st, PH_REQUEST_PULL, NULL);
+ st->l2.l2l1(st, PH_PULL_REQ, NULL);
else if (fi->userint & LC_FLUSH_WAIT) {
fi->userint &= ~LC_FLUSH_WAIT;
st->l2.l2man(st, DL_FLUSH, NULL);
@@ -969,57 +1220,46 @@ l2_got_st8_rr_rej(struct FsmInst *fi, int event, void *arg)
}
} else {
if (!rsp && PollFlag)
- enquiry_response(st, RR, PollFlag);
- if (legalnr(st, seq)) {
- setva(st, seq);
+ enquiry_response(st);
+ if (legalnr(st, nr)) {
+ setva(st, nr);
}
}
}
static void
-l2_st7_tout_203(struct FsmInst *fi, int event, void *arg)
-{
- struct PStack *st = fi->userdata;
-
- st->l2.rc = 0;
- FsmChangeState(fi, ST_L2_8);
- transmit_enquiry(st);
-}
-
-static void
-l2_st8_tout_200(struct FsmInst *fi, int event, void *arg)
-{
- struct PStack *st = fi->userdata;
-
- if (st->l2.rc == st->l2.n200) {
- establishlink(fi);
- } else {
- st->l2.rc++;
- transmit_enquiry(st);
- }
-}
-
-static void
l2_got_FRMR(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
struct sk_buff *skb = arg;
char tmp[64];
- skb_pull(skb, l2addrsize(&st->l2));
- if (st->l2.l2m.debug) {
- if (st->l2.extended)
+ skb_pull(skb, l2addrsize(&st->l2) + 1);
+ if (test_bit(FLG_MOD128, &st->l2.flag)) {
+ if (skb->len < 5)
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'N');
+ else {
sprintf(tmp, "FRMR information %2x %2x %2x %2x %2x",
skb->data[0], skb->data[1], skb->data[2],
skb->data[3], skb->data[4]);
- else
+ l2m_debug(&st->l2.l2m, tmp);
+ }
+ } else {
+ if (skb->len < 3)
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'N');
+ else {
sprintf(tmp, "FRMR information %2x %2x %2x",
skb->data[0], skb->data[1], skb->data[2]);
-
- l2m_debug(&st->l2.l2m, tmp);
+ l2m_debug(&st->l2.l2m, tmp);
+ }
}
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
+ if (!(skb->data[0] & 1) || ((skb->data[0] & 3) == 1) || /* I or S */
+ (IsUA(skb->data, 0) && (fi->state == ST_L2_7))) {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'K');
+ establishlink(fi);
+ test_and_clear_bit(FLG_L3_INIT, &st->l2.flag);
+ }
+ FreeSkb(skb);
}
static void
@@ -1027,135 +1267,126 @@ l2_tei_remove(struct FsmInst *fi, int event, void *arg)
{
struct PStack *st = fi->userdata;
-/*TODO
- if( DL_RELEASE.req outstanding ) {
- ... issue DL_RELEASE.confirm
- } else {
- if( fi->state != ST_L2_4 ) {
- ... issue DL_RELEASE.indication
- }
- }
- TODO */
- discard_i_queue(st); /* There is no UI queue in layer 2 */
- st->l2.tei = 255;
- if (st->l2.t200_running) {
- FsmDelTimer(&st->l2.t200_timer, 18);
- st->l2.t200_running = 0;
- }
- FsmDelTimer(&st->l2.t203_timer, 19);
- st->l2.l2man(st, DL_RELEASE, NULL); /* TEMP */
+ discard_i_queue(st);
+ discard_ui_queue(st);
+ st->l2.tei = -1;
+ if (test_and_clear_bit(FLG_T200_RUN, &st->l2.flag))
+ FsmDelTimer(&st->l2.t200, 18);
+ FsmDelTimer(&st->l2.t203, 19);
+ if (fi->state != ST_L2_4)
+ st->l2.l2man(st, DL_RELEASE, NULL);
FsmChangeState(fi, ST_L2_1);
}
-inline int
-IsUI(u_char * data, int ext)
-{
- return ((data[0] & 0xef) == UI);
-}
-
-inline int
-IsUA(u_char * data, int ext)
-{
- return ((data[0] & 0xef) == UA);
-}
-
-inline int
-IsDISC(u_char * data, int ext)
-{
- return ((data[0] & 0xef) == DISC);
-}
-
-inline int
-IsRR(u_char * data, int ext)
-{
- if (ext)
- return (data[0] == RR);
- else
- return ((data[0] & 0xf) == 1);
-}
-
-inline int
-IsI(u_char * data, int ext)
-{
- return ((data[0] & 0x1) == 0x0);
-}
-
-inline int
-IsSABMX(u_char * data, int ext)
+static void
+l2_persistant_da(struct FsmInst *fi, int event, void *arg)
{
- u_char d = data[0] & ~0x10;
+ struct PStack *st = fi->userdata;
- return (ext ? d == SABME : d == SABM);
-}
-
-inline int
-IsREJ(u_char * data, int ext)
-{
- return (ext ? data[0] == REJ : (data[0] & 0xf) == 0x9);
-}
-
-inline int
-IsFRMR(u_char * data, int ext)
-{
- return ((data[0] & 0xef) == FRMR);
-}
-
-inline int
-IsRNR(u_char * data, int ext)
-{
- if (ext)
- return (data[0] == RNR);
- else
- return ((data[0] & 0xf) == 5);
+ discard_i_queue(st);
+ discard_ui_queue(st);
+ if (test_and_clear_bit(FLG_T200_RUN, &st->l2.flag))
+ FsmDelTimer(&st->l2.t200, 18);
+ FsmDelTimer(&st->l2.t203, 19);
+ test_and_clear_bit(FLG_PEND_REL, &st->l2.flag);
+ clear_exception(&st->l2);
+ switch (fi->state) {
+ case ST_L2_3:
+ st->l2.l2man(st, DL_RELEASE, NULL);
+ case ST_L2_2:
+ FsmChangeState(fi, ST_L2_1);
+ break;
+ case ST_L2_5:
+ case ST_L2_6:
+ case ST_L2_7:
+ case ST_L2_8:
+ st->l2.l2man(st, DL_RELEASE, NULL);
+ FsmChangeState(fi, ST_L2_4);
+ break;
+ }
}
-static struct FsmNode L2FnList[] =
+static struct FsmNode L2FnList[] HISAX_INITDATA =
{
- {ST_L2_1, EV_L2_DL_ESTABLISH, l2s1},
{ST_L2_1, EV_L2_MDL_NOTEIPROC, l2_no_tei},
- {ST_L2_3, EV_L2_MDL_ASSIGN, l2_got_tei},
- {ST_L2_4, EV_L2_DL_UNIT_DATA, l2_send_ui},
+ {ST_L2_1, EV_L2_DL_ESTABLISH, l2_dl_establish},
+ {ST_L2_2, EV_L2_DL_ESTABLISH, l2_dl_establish},
{ST_L2_4, EV_L2_DL_ESTABLISH, l2_establish},
- {ST_L2_7, EV_L2_DL_UNIT_DATA, l2_send_ui},
+ {ST_L2_5, EV_L2_DL_ESTABLISH, l2_establish},
+ {ST_L2_7, EV_L2_DL_ESTABLISH, l2_establish},
+ {ST_L2_8, EV_L2_DL_ESTABLISH, l2_establish},
+ {ST_L2_4, EV_L2_DL_RELEASE, l2_dl_release},
+ {ST_L2_5, EV_L2_DL_RELEASE, l2_dl_release},
+ {ST_L2_7, EV_L2_DL_RELEASE, l2_dl_release},
+ {ST_L2_8, EV_L2_DL_RELEASE, l2_dl_release},
+ {ST_L2_5, EV_L2_DL_DATA, l2_feed_iqueue},
{ST_L2_7, EV_L2_DL_DATA, l2_feed_iqueue},
- {ST_L2_7, EV_L2_DL_RELEASE, l2_send_disconn},
- {ST_L2_7, EV_L2_ACK_PULL, l2_pull_iqueue},
{ST_L2_8, EV_L2_DL_DATA, l2_feed_iqueue},
- {ST_L2_8, EV_L2_DL_RELEASE, l2_send_disconn},
-
- {ST_L2_1, EV_L2_UI, l2_receive_ui},
- {ST_L2_4, EV_L2_UI, l2_receive_ui},
+ {ST_L2_1, EV_L2_DL_UNIT_DATA, l2_put_ui},
+ {ST_L2_2, EV_L2_DL_UNIT_DATA, l2_put_ui},
+ {ST_L2_3, EV_L2_DL_UNIT_DATA, l2_put_ui},
+ {ST_L2_4, EV_L2_DL_UNIT_DATA, l2_put_ui},
+ {ST_L2_5, EV_L2_DL_UNIT_DATA, l2_put_ui},
+ {ST_L2_6, EV_L2_DL_UNIT_DATA, l2_put_ui},
+ {ST_L2_7, EV_L2_DL_UNIT_DATA, l2_put_ui},
+ {ST_L2_8, EV_L2_DL_UNIT_DATA, l2_put_ui},
+ {ST_L2_1, EV_L2_MDL_ASSIGN, l2_got_tei},
+ {ST_L2_2, EV_L2_MDL_ASSIGN, l2_got_tei},
+ {ST_L2_3, EV_L2_MDL_ASSIGN, l2_got_tei},
+ {ST_L2_2, EV_L2_MDL_ERROR, l2_tei_remove},
+ {ST_L2_3, EV_L2_MDL_ERROR, l2_tei_remove},
+ {ST_L2_4, EV_L2_MDL_REMOVE, l2_tei_remove},
+ {ST_L2_5, EV_L2_MDL_REMOVE, l2_tei_remove},
+ {ST_L2_6, EV_L2_MDL_REMOVE, l2_tei_remove},
+ {ST_L2_7, EV_L2_MDL_REMOVE, l2_tei_remove},
+ {ST_L2_8, EV_L2_MDL_REMOVE, l2_tei_remove},
{ST_L2_4, EV_L2_SABMX, l2_got_SABMX},
- {ST_L2_4, EV_L2_DISC, l2_got_st4_disc},
- {ST_L2_5, EV_L2_UA, l2_got_ua_establish},
- {ST_L2_6, EV_L2_UA, l2_got_ua_disconn},
- {ST_L2_7, EV_L2_UI, l2_receive_ui},
- {ST_L2_7, EV_L2_DISC, l2_got_disconn},
- {ST_L2_7, EV_L2_I, l2_got_st7_data},
- {ST_L2_7, EV_L2_RR, l2_got_st7_RR},
- {ST_L2_7, EV_L2_REJ, l2_got_st7_rej},
+ {ST_L2_5, EV_L2_SABMX, l2_got_SABMX},
+ {ST_L2_6, EV_L2_SABMX, l2_got_SABMX},
{ST_L2_7, EV_L2_SABMX, l2_got_SABMX},
- {ST_L2_7, EV_L2_FRMR, l2_got_FRMR},
- {ST_L2_8, EV_L2_RR, l2_got_st8_rr_rej},
- {ST_L2_8, EV_L2_REJ, l2_got_st8_rr_rej},
{ST_L2_8, EV_L2_SABMX, l2_got_SABMX},
+ {ST_L2_4, EV_L2_DISC, l2_got_disconn},
+ {ST_L2_5, EV_L2_DISC, l2_got_disconn},
+ {ST_L2_6, EV_L2_DISC, l2_got_disconn},
+ {ST_L2_7, EV_L2_DISC, l2_got_disconn},
{ST_L2_8, EV_L2_DISC, l2_got_disconn},
+ {ST_L2_4, EV_L2_UA, l2_mdl_error},
+ {ST_L2_5, EV_L2_UA, l2_got_ua},
+ {ST_L2_6, EV_L2_UA, l2_got_ua},
+ {ST_L2_7, EV_L2_UA, l2_mdl_error},
+ {ST_L2_8, EV_L2_UA, l2_mdl_error},
+ {ST_L2_4, EV_L2_DM, l2_got_dm},
+ {ST_L2_5, EV_L2_DM, l2_got_dm},
+ {ST_L2_6, EV_L2_DM, l2_got_dm},
+ {ST_L2_7, EV_L2_DM, l2_mdl_error},
+ {ST_L2_8, EV_L2_DM, l2_mdl_error},
+ {ST_L2_1, EV_L2_UI, l2_got_ui},
+ {ST_L2_2, EV_L2_UI, l2_got_ui},
+ {ST_L2_3, EV_L2_UI, l2_got_ui},
+ {ST_L2_4, EV_L2_UI, l2_got_ui},
+ {ST_L2_5, EV_L2_UI, l2_got_ui},
+ {ST_L2_6, EV_L2_UI, l2_got_ui},
+ {ST_L2_7, EV_L2_UI, l2_got_ui},
+ {ST_L2_8, EV_L2_UI, l2_got_ui},
+ {ST_L2_7, EV_L2_FRMR, l2_got_FRMR},
{ST_L2_8, EV_L2_FRMR, l2_got_FRMR},
- {ST_L2_8, EV_L2_I, l2_got_st8_data},
-
+ {ST_L2_7, EV_L2_SUPER, l2_got_st7_super},
+ {ST_L2_8, EV_L2_SUPER, l2_got_st8_super},
+ {ST_L2_7, EV_L2_I, l2_got_iframe},
+ {ST_L2_8, EV_L2_I, l2_got_iframe},
{ST_L2_5, EV_L2_T200, l2_st5_tout_200},
{ST_L2_6, EV_L2_T200, l2_st6_tout_200},
- {ST_L2_7, EV_L2_T200, l2_st7_tout_200},
+ {ST_L2_7, EV_L2_T200, l2_st78_tout_200},
+ {ST_L2_8, EV_L2_T200, l2_st78_tout_200},
{ST_L2_7, EV_L2_T203, l2_st7_tout_203},
- {ST_L2_8, EV_L2_T200, l2_st8_tout_200},
-
- {ST_L2_1, EV_L2_MDL_REMOVE, l2_tei_remove},
- {ST_L2_3, EV_L2_MDL_REMOVE, l2_tei_remove},
- {ST_L2_4, EV_L2_MDL_REMOVE, l2_tei_remove},
- {ST_L2_5, EV_L2_MDL_REMOVE, l2_tei_remove},
- {ST_L2_6, EV_L2_MDL_REMOVE, l2_tei_remove},
- {ST_L2_7, EV_L2_MDL_REMOVE, l2_tei_remove},
- {ST_L2_8, EV_L2_MDL_REMOVE, l2_tei_remove},
+ {ST_L2_7, EV_L2_ACK_PULL, l2_pull_iqueue},
+ {ST_L2_2, EV_L1_DEACTIVATE, l2_persistant_da},
+ {ST_L2_3, EV_L1_DEACTIVATE, l2_persistant_da},
+ {ST_L2_4, EV_L1_DEACTIVATE, l2_persistant_da},
+ {ST_L2_5, EV_L1_DEACTIVATE, l2_persistant_da},
+ {ST_L2_6, EV_L1_DEACTIVATE, l2_persistant_da},
+ {ST_L2_7, EV_L1_DEACTIVATE, l2_persistant_da},
+ {ST_L2_8, EV_L1_DEACTIVATE, l2_persistant_da},
};
#define L2_FN_COUNT (sizeof(L2FnList)/sizeof(struct FsmNode))
@@ -1165,40 +1396,53 @@ isdnl2_l1l2(struct PStack *st, int pr, void *arg)
{
struct sk_buff *skb = arg;
u_char *datap;
- int ret = !0;
+ int ret = 1, len;
switch (pr) {
- case (PH_DATA):
+ case (PH_DATA_IND):
datap = skb->data;
- datap += l2addrsize(&st->l2);
-
- if (IsI(datap, st->l2.extended))
+ len = l2addrsize(&st->l2);
+ if (skb->len > len)
+ datap += len;
+ else {
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'N');
+ FreeSkb(skb);
+ return;
+ }
+ if (!(*datap & 1)) /* I-Frame */
ret = FsmEvent(&st->l2.l2m, EV_L2_I, skb);
- else if (IsRR(datap, st->l2.extended))
- ret = FsmEvent(&st->l2.l2m, EV_L2_RR, skb);
- else if (IsUI(datap, st->l2.extended))
+ else if ((*datap & 3) == 1) /* S-Frame */
+ ret = FsmEvent(&st->l2.l2m, EV_L2_SUPER, skb);
+ else if (IsUI(datap, test_bit(FLG_MOD128, &st->l2.flag)))
ret = FsmEvent(&st->l2.l2m, EV_L2_UI, skb);
- else if (IsSABMX(datap, st->l2.extended))
+ else if (IsSABMX(datap, test_bit(FLG_MOD128, &st->l2.flag)))
ret = FsmEvent(&st->l2.l2m, EV_L2_SABMX, skb);
- else if (IsUA(datap, st->l2.extended))
+ else if (IsUA(datap, test_bit(FLG_MOD128, &st->l2.flag)))
ret = FsmEvent(&st->l2.l2m, EV_L2_UA, skb);
- else if (IsDISC(datap, st->l2.extended))
+ else if (IsDISC(datap, test_bit(FLG_MOD128, &st->l2.flag)))
ret = FsmEvent(&st->l2.l2m, EV_L2_DISC, skb);
- else if (IsREJ(datap, st->l2.extended))
- ret = FsmEvent(&st->l2.l2m, EV_L2_REJ, skb);
- else if (IsFRMR(datap, st->l2.extended))
+ else if (IsDM(datap, test_bit(FLG_MOD128, &st->l2.flag)))
+ ret = FsmEvent(&st->l2.l2m, EV_L2_DM, skb);
+ else if (IsFRMR(datap, test_bit(FLG_MOD128, &st->l2.flag)))
ret = FsmEvent(&st->l2.l2m, EV_L2_FRMR, skb);
- else if (IsRNR(datap, st->l2.extended))
- ret = FsmEvent(&st->l2.l2m, EV_L2_RNR, skb);
-
+ else {
+ ret = 0;
+ st->ma.layer(st, MDL_ERROR_IND, (void *) 'L');
+ FreeSkb(skb);
+ }
if (ret) {
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
+ FreeSkb(skb);
}
break;
- case (PH_PULL_ACK):
+ case (PH_PULL_CNF):
FsmEvent(&st->l2.l2m, EV_L2_ACK_PULL, arg);
break;
+ case (PH_PAUSE_IND):
+ test_and_set_bit(FLG_DCHAN_BUSY, &st->l2.flag);
+ break;
+ case (PH_PAUSE_CNF):
+ test_and_clear_bit(FLG_DCHAN_BUSY, &st->l2.flag);
+ break;
}
}
@@ -1208,13 +1452,11 @@ isdnl2_l3l2(struct PStack *st, int pr, void *arg)
switch (pr) {
case (DL_DATA):
if (FsmEvent(&st->l2.l2m, EV_L2_DL_DATA, arg)) {
- SET_SKB_FREE(((struct sk_buff *) arg));
dev_kfree_skb((struct sk_buff *) arg);
}
break;
case (DL_UNIT_DATA):
if (FsmEvent(&st->l2.l2m, EV_L2_DL_UNIT_DATA, arg)) {
- SET_SKB_FREE(((struct sk_buff *) arg));
dev_kfree_skb((struct sk_buff *) arg);
}
break;
@@ -1237,28 +1479,28 @@ isdnl2_manl2(struct PStack *st, int pr, void *arg)
case (DL_FLUSH):
(&st->l2.l2m)->userint |= LC_FLUSH_WAIT;
break;
- }
-}
-
-static void
-isdnl2_teil2(struct PStack *st, int pr, void *arg)
-{
- switch (pr) {
- case (MDL_ASSIGN):
+ case (PH_DEACTIVATE_IND):
+ FsmEvent(&st->l2.l2m, EV_L1_DEACTIVATE, arg);
+ break;
+ case (MDL_ASSIGN_REQ):
FsmEvent(&st->l2.l2m, EV_L2_MDL_ASSIGN, arg);
break;
- case (MDL_REMOVE):
+ case (MDL_REMOVE_REQ):
FsmEvent(&st->l2.l2m, EV_L2_MDL_REMOVE, arg);
break;
+ case (MDL_ERROR_REQ):
+ FsmEvent(&st->l2.l2m, EV_L2_MDL_ERROR, arg);
+ break;
}
}
void
releasestack_isdnl2(struct PStack *st)
{
- FsmDelTimer(&st->l2.t200_timer, 15);
- FsmDelTimer(&st->l2.t203_timer, 16);
+ FsmDelTimer(&st->l2.t200, 15);
+ FsmDelTimer(&st->l2.t203, 16);
discard_i_queue(st);
+ discard_ui_queue(st);
ReleaseWin(&st->l2);
}
@@ -1279,13 +1521,10 @@ setstack_isdnl2(struct PStack *st, char *debug_id)
st->l1.l1l2 = isdnl2_l1l2;
st->l3.l3l2 = isdnl2_l3l2;
st->ma.manl2 = isdnl2_manl2;
- st->ma.teil2 = isdnl2_teil2;
- st->l2.uihsize = l2headersize(&st->l2, !0);
- st->l2.ihsize = l2headersize(&st->l2, 0);
skb_queue_head_init(&st->l2.i_queue);
+ skb_queue_head_init(&st->l2.ui_queue);
InitWin(&st->l2);
- st->l2.rejexp = 0;
st->l2.debug = 0;
st->l2.l2m.fsm = &l2fsm;
@@ -1296,9 +1535,8 @@ setstack_isdnl2(struct PStack *st, char *debug_id)
st->l2.l2m.printdebug = l2m_debug;
strcpy(st->l2.debug_id, debug_id);
- FsmInitTimer(&st->l2.l2m, &st->l2.t200_timer);
- FsmInitTimer(&st->l2.l2m, &st->l2.t203_timer);
- st->l2.t200_running = 0;
+ FsmInitTimer(&st->l2.l2m, &st->l2.t200);
+ FsmInitTimer(&st->l2.l2m, &st->l2.t203);
}
void
@@ -1311,8 +1549,8 @@ releasestack_transl2(struct PStack *st)
{
}
-void
-Isdnl2New(void)
+HISAX_INITFUNC(void
+Isdnl2New(void))
{
l2fsm.state_count = L2_STATE_COUNT;
l2fsm.event_count = L2_EVENT_COUNT;
diff --git a/drivers/isdn/hisax/isdnl3.c b/drivers/isdn/hisax/isdnl3.c
index 73b66c73b..026d8eb76 100644
--- a/drivers/isdn/hisax/isdnl3.c
+++ b/drivers/isdn/hisax/isdnl3.c
@@ -1,4 +1,4 @@
-/* $Id: isdnl3.c,v 1.10 1997/04/06 22:54:16 keil Exp $
+/* $Id: isdnl3.c,v 2.5 1998/02/12 23:07:52 keil Exp $
* Author Karsten Keil (keil@temic-ech.spacenet.de)
* based on the teles driver from Jan den Ouden
@@ -7,38 +7,39 @@
* Fritz Elfert
*
* $Log: isdnl3.c,v $
- * Revision 1.10 1997/04/06 22:54:16 keil
- * Using SKB's
- *
- * Revision 1.9 1997/03/25 23:11:25 keil
- * US NI-1 protocol
+ * Revision 2.5 1998/02/12 23:07:52 keil
+ * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
*
- * Revision 1.8 1997/03/21 18:53:44 keil
- * Report no protocol error to syslog too
+ * Revision 2.4 1997/11/06 17:09:25 keil
+ * New 2.1 init code
*
- * Revision 1.7 1997/03/17 18:34:38 keil
- * fixed oops if no protocol selected during config
+ * Revision 2.3 1997/10/29 19:07:53 keil
+ * changes for 2.1
*
- * Revision 1.6 1997/02/16 01:04:08 fritz
- * Bugfix: Changed timer handling caused hang with 2.1.X
+ * Revision 2.2 1997/10/01 09:21:41 fritz
+ * Removed old compatibility stuff for 2.0.X kernels.
+ * From now on, this code is for 2.1.X ONLY!
+ * Old stuff is still in the separate branch.
*
- * Revision 1.5 1997/02/09 00:26:27 keil
- * new interface handling, one interface per card
- * leased line changes
+ * Revision 2.1 1997/08/03 14:36:32 keil
+ * Implement RESTART procedure
*
- * Revision 1.4 1997/01/27 23:17:44 keil
- * delete timers while unloading
+ * Revision 2.0 1997/07/27 21:15:42 keil
+ * New Callref based layer3
*
- * Revision 1.3 1997/01/21 22:31:12 keil
- * new statemachine; L3 timers
+ * Revision 1.11 1997/06/26 11:11:44 keil
+ * SET_SKBFREE now on creation of a SKB
*
- * Revision 1.2 1996/11/05 19:42:04 keil
- * using config.h
+ * Revision 1.10 1997/04/06 22:54:16 keil
+ * Using SKB's
*
- * Revision 1.1 1996/10/13 20:04:54 keil
- * Initial revision
+ * Revision 1.9 1997/03/25 23:11:25 keil
+ * US NI-1 protocol
*
+ * Revision 1.8 1997/03/21 18:53:44 keil
+ * Report no protocol error to syslog too
*
+ * Remove old logs /KKe
*
*/
#define __NO_VERSION__
@@ -46,7 +47,72 @@
#include "isdnl3.h"
#include <linux/config.h>
-const char *l3_revision = "$Revision: 1.10 $";
+const char *l3_revision = "$Revision: 2.5 $";
+
+u_char *
+findie(u_char * p, int size, u_char ie, int wanted_set)
+{
+ int l, codeset, maincodeset;
+ u_char *pend = p + size;
+
+ /* skip protocol discriminator, callref and message type */
+ p++;
+ l = (*p++) & 0xf;
+ p += l;
+ p++;
+ codeset = 0;
+ maincodeset = 0;
+ /* while there are bytes left... */
+ while (p < pend) {
+ if ((*p & 0xf0) == 0x90) {
+ codeset = *p & 0x07;
+ if (!(*p & 0x08))
+ maincodeset = codeset;
+ }
+ if (*p & 0x80)
+ p++;
+ else {
+ if (codeset == wanted_set) {
+ if (*p == ie)
+ return (p);
+ if (*p > ie)
+ return (NULL);
+ }
+ p++;
+ l = *p++;
+ p += l;
+ codeset = maincodeset;
+ }
+ }
+ return (NULL);
+}
+
+int
+getcallref(u_char * p)
+{
+ int l, m = 1, cr = 0;
+ p++; /* prot discr */
+ l = 0xf & *p++; /* callref length */
+ if (!l) /* dummy CallRef */
+ return(-1);
+ while (l--) {
+ cr += m * (*p++);
+ m *= 8;
+ }
+ return (cr);
+}
+
+static int OrigCallRef = 0;
+
+int
+newcallref(void)
+{
+ if (OrigCallRef == 127)
+ OrigCallRef = 1;
+ else
+ OrigCallRef++;
+ return (OrigCallRef);
+}
void
l3_debug(struct PStack *st, char *s)
@@ -54,34 +120,33 @@ l3_debug(struct PStack *st, char *s)
char str[256], tm[32];
jiftime(tm, jiffies);
- sprintf(str, "%s Channel %d l3 %s\n", tm, st->l3.channr, s);
+ sprintf(str, "%s l3 %s\n", tm, s);
HiSax_putstatus(st->l1.hardware, str);
}
-
-
void
-newl3state(struct PStack *st, int state)
+newl3state(struct l3_process *pc, int state)
{
char tmp[80];
- if (st->l3.debug & L3_DEB_STATE) {
- sprintf(tmp, "newstate %d --> %d", st->l3.state, state);
- l3_debug(st, tmp);
+ if (pc->debug & L3_DEB_STATE) {
+ sprintf(tmp, "newstate cr %d %d --> %d", pc->callref,
+ pc->state, state);
+ l3_debug(pc->st, tmp);
}
- st->l3.state = state;
+ pc->state = state;
}
static void
L3ExpireTimer(struct L3Timer *t)
{
- t->st->l4.l4l3(t->st, t->event, NULL);
+ t->pc->st->lli.l4l3(t->pc->st, t->event, t->pc);
}
void
-L3InitTimer(struct PStack *st, struct L3Timer *t)
+L3InitTimer(struct l3_process *pc, struct L3Timer *t)
{
- t->st = st;
+ t->pc = pc;
t->tl.function = (void *) L3ExpireTimer;
t->tl.data = (long) t;
init_timer(&t->tl);
@@ -109,9 +174,9 @@ L3AddTimer(struct L3Timer *t,
}
void
-StopAllL3Timer(struct PStack *st)
+StopAllL3Timer(struct l3_process *pc)
{
- L3DelTimer(&st->l3.timer);
+ L3DelTimer(&pc->timer);
}
struct sk_buff *
@@ -132,9 +197,8 @@ no_l3_proto(struct PStack *st, int pr, void *arg)
{
struct sk_buff *skb = arg;
- l3_debug(st, "no protocol");
+ HiSax_putstatus(st->l1.hardware, "L3 no D protocol\n");
if (skb) {
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
}
}
@@ -151,14 +215,78 @@ extern void setstack_ni1(struct PStack *st);
extern void setstack_1tr6(struct PStack *st);
#endif
+struct l3_process
+*getl3proc(struct PStack *st, int cr)
+{
+ struct l3_process *p = st->l3.proc;
+
+ while (p)
+ if (p->callref == cr)
+ return (p);
+ else
+ p = p->next;
+ return (NULL);
+}
+
+struct l3_process
+*new_l3_process(struct PStack *st, int cr)
+{
+ struct l3_process *p, *np;
+
+ if (!(p = kmalloc(sizeof(struct l3_process), GFP_ATOMIC))) {
+ printk(KERN_ERR "HiSax can't get memory for cr %d\n", cr);
+ return (NULL);
+ }
+ if (!st->l3.proc)
+ st->l3.proc = p;
+ else {
+ np = st->l3.proc;
+ while (np->next)
+ np = np->next;
+ np->next = p;
+ }
+ p->next = NULL;
+ p->debug = L3_DEB_WARN;
+ p->callref = cr;
+ p->state = 0;
+ p->chan = NULL;
+ p->st = st;
+ p->N303 = st->l3.N303;
+ L3InitTimer(p, &p->timer);
+ return (p);
+};
+
+void
+release_l3_process(struct l3_process *p)
+{
+ struct l3_process *np, *pp = NULL;
+
+ if (!p)
+ return;
+ np = p->st->l3.proc;
+ while (np) {
+ if (np == p) {
+ StopAllL3Timer(p);
+ if (pp)
+ pp->next = np->next;
+ else
+ p->st->l3.proc = np->next;
+ kfree(p);
+ return;
+ }
+ pp = np;
+ np = np->next;
+ }
+ printk(KERN_ERR "HiSax internal L3 error CR not in list\n");
+};
+
void
setstack_isdnl3(struct PStack *st, struct Channel *chanp)
{
char tmp[64];
- st->l3.debug = L3_DEB_WARN;
- st->l3.channr = chanp->chan;
- L3InitTimer(st, &st->l3.timer);
+ st->l3.proc = NULL;
+ st->l3.global = NULL;
#ifdef CONFIG_HISAX_EURO
if (st->protocol == ISDN_PTYPE_EURO) {
@@ -176,11 +304,11 @@ setstack_isdnl3(struct PStack *st, struct Channel *chanp)
} else
#endif
if (st->protocol == ISDN_PTYPE_LEASED) {
- st->l4.l4l3 = no_l3_proto;
+ st->lli.l4l3 = no_l3_proto;
st->l2.l2l3 = no_l3_proto;
- printk(KERN_NOTICE "HiSax: Leased line mode\n");
+ printk(KERN_INFO "HiSax: Leased line mode\n");
} else {
- st->l4.l4l3 = no_l3_proto;
+ st->lli.l4l3 = no_l3_proto;
st->l2.l2l3 = no_l3_proto;
sprintf(tmp, "protocol %s not supported",
(st->protocol == ISDN_PTYPE_1TR6) ? "1tr6" :
@@ -188,15 +316,18 @@ setstack_isdnl3(struct PStack *st, struct Channel *chanp)
(st->protocol == ISDN_PTYPE_NI1) ? "ni1" :
"unknown");
printk(KERN_WARNING "HiSax: %s\n", tmp);
- l3_debug(st, tmp);
st->protocol = -1;
}
- st->l3.state = 0;
- st->l3.callref = 0;
}
void
releasestack_isdnl3(struct PStack *st)
{
- StopAllL3Timer(st);
+ while (st->l3.proc)
+ release_l3_process(st->l3.proc);
+ if (st->l3.global) {
+ StopAllL3Timer(st->l3.global);
+ kfree(st->l3.global);
+ st->l3.global = NULL;
+ }
}
diff --git a/drivers/isdn/hisax/isdnl3.h b/drivers/isdn/hisax/isdnl3.h
index bed989a18..2ff582b4a 100644
--- a/drivers/isdn/hisax/isdnl3.h
+++ b/drivers/isdn/hisax/isdnl3.h
@@ -1,6 +1,12 @@
-/* $Id: isdnl3.h,v 1.3 1997/04/06 22:54:17 keil Exp $
- *
+/* $Id: isdnl3.h,v 2.0 1997/07/27 21:15:42 keil Exp $
+
* $Log: isdnl3.h,v $
+ * Revision 2.0 1997/07/27 21:15:42 keil
+ * New Callref based layer3
+ *
+ * Revision 1.4 1997/06/26 11:20:57 keil
+ * ?
+ *
* Revision 1.3 1997/04/06 22:54:17 keil
* Using SKB's
*
@@ -24,15 +30,18 @@
#define L3_DEB_CHARGE 0x08
struct stateentry {
- int state;
- u_char primitive;
- void (*rout) (struct PStack *, u_char, void *);
+ int state;
+ u_char primitive;
+ void (*rout) (struct l3_process *, u_char, void *);
};
extern void l3_debug(struct PStack *st, char *s);
-extern void newl3state(struct PStack *st, int state);
-extern void L3InitTimer(struct PStack *st, struct L3Timer *t);
+extern void newl3state(struct l3_process *pc, int state);
+extern void L3InitTimer(struct l3_process *pc, struct L3Timer *t);
extern void L3DelTimer(struct L3Timer *t);
-extern int L3AddTimer(struct L3Timer *t, int millisec, int event);
-extern void StopAllL3Timer(struct PStack *st);
+extern int L3AddTimer(struct L3Timer *t, int millisec, int event);
+extern void StopAllL3Timer(struct l3_process *pc);
extern struct sk_buff *l3_alloc_skb(int len);
+extern struct l3_process *new_l3_process(struct PStack *st, int cr);
+extern void release_l3_process(struct l3_process *p);
+extern struct l3_process *getl3proc(struct PStack *st, int cr);
diff --git a/drivers/isdn/hisax/ix1_micro.c b/drivers/isdn/hisax/ix1_micro.c
index f5f5e857a..0c075546b 100644
--- a/drivers/isdn/hisax/ix1_micro.c
+++ b/drivers/isdn/hisax/ix1_micro.c
@@ -1,4 +1,4 @@
-/* $Id: ix1_micro.c,v 1.3 1997/04/13 19:54:02 keil Exp $
+/* $Id: ix1_micro.c,v 2.6 1998/02/11 17:28:09 keil Exp $
* ix1_micro.c low level stuff for ITK ix1-micro Rev.2 isdn cards
* derived from the original file teles3.c from Karsten Keil
@@ -11,6 +11,27 @@
* Beat Doebeli
*
* $Log: ix1_micro.c,v $
+ * Revision 2.6 1998/02/11 17:28:09 keil
+ * Niccy PnP/PCI support
+ *
+ * Revision 2.5 1998/02/02 13:29:42 keil
+ * fast io
+ *
+ * Revision 2.4 1997/11/08 21:35:50 keil
+ * new l1 init
+ *
+ * Revision 2.3 1997/11/06 17:09:35 keil
+ * New 2.1 init code
+ *
+ * Revision 2.2 1997/10/29 18:55:51 keil
+ * changes for 2.1.60 (irq2dev_map)
+ *
+ * Revision 2.1 1997/07/27 21:47:09 keil
+ * new interface structures
+ *
+ * Revision 2.0 1997/06/26 11:02:50 keil
+ * New Layer and card interface
+ *
* Revision 1.3 1997/04/13 19:54:02 keil
* Change in IRQ check delay for SMP
*
@@ -54,17 +75,16 @@
#define __NO_VERSION__
-#include "siemens.h"
#include "hisax.h"
-#include "teles3.h"
+#include "isac.h"
+#include "hscx.h"
#include "isdnl1.h"
-#include <linux/kernel_stat.h>
extern const char *CardType[];
-const char *ix1_revision = "$Revision: 1.3 $";
+const char *ix1_revision = "$Revision: 2.6 $";
-#define byteout(addr,val) outb_p(val,addr)
-#define bytein(addr) inb_p(addr)
+#define byteout(addr,val) outb(val,addr)
+#define bytein(addr) inb(addr)
#define SPECIAL_PORT_OFFSET 3
@@ -73,865 +93,250 @@ const char *ix1_revision = "$Revision: 1.3 $";
#define HSCX_COMMAND_OFFSET 2
#define HSCX_DATA_OFFSET 1
-#define ISAC_FIFOSIZE 16
-#define HSCX_FIFOSIZE 16
-
#define TIMEOUT 50
static inline u_char
-IsacReadReg(unsigned int adr, u_char off)
-{
- byteout(adr + ISAC_COMMAND_OFFSET, off + 0x20);
- return bytein(adr + ISAC_DATA_OFFSET);
-}
-
-static inline void
-IsacWriteReg(unsigned int adr, u_char off, u_char data)
-{
- byteout(adr + ISAC_COMMAND_OFFSET, off + 0x20);
- byteout(adr + ISAC_DATA_OFFSET, data);
-}
-
-#define HSCX_OFFSET(WhichHscx,offset) \
-( (WhichHscx) ? (offset+0x60) : (offset+0x20) )
-
-static inline u_char
-HscxReadReg(unsigned int adr, int WhichHscx, u_char off)
+readreg(unsigned int ale, unsigned int adr, u_char off)
{
- byteout(adr + HSCX_COMMAND_OFFSET, HSCX_OFFSET(WhichHscx, off));
- return bytein(adr + HSCX_DATA_OFFSET);
-}
-
-static inline void
-HscxWriteReg(unsigned int adr, int WhichHscx, u_char off, u_char data)
-{
- byteout(adr + HSCX_COMMAND_OFFSET, HSCX_OFFSET(WhichHscx, off));
- byteout(adr + HSCX_DATA_OFFSET, data);
-}
-
-
-static inline void
-IsacReadFifo(unsigned int adr, u_char * data, int size)
-{
- byteout(adr + ISAC_COMMAND_OFFSET, 0);
- while (size--)
- *data++ = bytein(adr + ISAC_DATA_OFFSET);
-}
-
-static void
-IsacWriteFifo(unsigned int adr, u_char * data, int size)
-{
- byteout(adr + ISAC_COMMAND_OFFSET, 0);
- while (size--) {
- byteout(adr + ISAC_DATA_OFFSET, *data);
- data++;
- }
-}
-
-static inline void
-HscxReadFifo(unsigned int adr, int WhichHscx, u_char * data, int size)
-{
- byteout(adr + HSCX_COMMAND_OFFSET, (WhichHscx) ? 0x40 : 0x00);
- while (size--)
- *data++ = bytein(adr + HSCX_DATA_OFFSET);
-}
+ register u_char ret;
+ long flags;
-static void
-HscxWriteFifo(unsigned int adr, int WhichHscx, u_char * data, int size)
-{
- byteout(adr + HSCX_COMMAND_OFFSET, (WhichHscx) ? 0x40 : 0x00);
- while (size--) {
- byteout(adr + HSCX_DATA_OFFSET, *data);
- data++;
- }
+ save_flags(flags);
+ cli();
+ byteout(ale, off);
+ ret = bytein(adr);
+ restore_flags(flags);
+ return (ret);
}
static inline void
-waitforCEC(int adr, int WhichHscx)
+readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
{
- int to = TIMEOUT;
+ /* fifo read without cli because it's allready done */
- while ((HscxReadReg(adr, WhichHscx, HSCX_STAR) & 0x04) && to) {
- udelay(1);
- to--;
- }
- if (!to)
- printk(KERN_WARNING "ix1-Micro: waitforCEC timeout\n");
+ byteout(ale, off);
+ insb(adr, data, size);
}
static inline void
-waitforXFW(int adr, int WhichHscx)
-{
- int to = TIMEOUT;
-
- while ((!(HscxReadReg(adr, WhichHscx, HSCX_STAR) & 0x44) == 0x40) && to) {
- udelay(1);
- to--;
- }
- if (!to)
- printk(KERN_WARNING "ix1-Micro: waitforXFW timeout\n");
-}
-
-static inline void
-writehscxCMDR(int adr, int WhichHscx, u_char data)
+writereg(unsigned int ale, unsigned int adr, u_char off, u_char data)
{
long flags;
save_flags(flags);
cli();
- waitforCEC(adr, WhichHscx);
- HscxWriteReg(adr, WhichHscx, HSCX_CMDR, data);
+ byteout(ale, off);
+ byteout(adr, data);
restore_flags(flags);
}
-/*
- * fast interrupt here
- */
-
-static void
-hscxreport(struct IsdnCardState *sp, int hscx)
-{
- printk(KERN_DEBUG "HSCX %d\n", hscx);
- printk(KERN_DEBUG "ISTA %x\n", HscxReadReg(sp->hscx[hscx], hscx, HSCX_ISTA));
- printk(KERN_DEBUG "STAR %x\n", HscxReadReg(sp->hscx[hscx], hscx, HSCX_STAR));
- printk(KERN_DEBUG "EXIR %x\n", HscxReadReg(sp->hscx[hscx], hscx, HSCX_EXIR));
-}
-
-void
-ix1micro_report(struct IsdnCardState *sp)
+static inline void
+writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
{
- printk(KERN_DEBUG "ISAC\n");
- printk(KERN_DEBUG "ISTA %x\n", IsacReadReg(sp->isac, ISAC_ISTA));
- printk(KERN_DEBUG "STAR %x\n", IsacReadReg(sp->isac, ISAC_STAR));
- printk(KERN_DEBUG "EXIR %x\n", IsacReadReg(sp->isac, ISAC_EXIR));
- hscxreport(sp, 0);
- hscxreport(sp, 1);
+ /* fifo write without cli because it's allready done */
+ byteout(ale, off);
+ outsb(adr, data, size);
}
-/*
- * HSCX stuff goes here
- */
+/* Interface functions */
-static void
-hscx_empty_fifo(struct HscxState *hsp, int count)
+static u_char
+ReadISAC(struct IsdnCardState *cs, u_char offset)
{
- u_char *ptr;
- struct IsdnCardState *sp = hsp->sp;
- long flags;
-
- if ((sp->debug & L1_DEB_HSCX) && !(sp->debug & L1_DEB_HSCX_FIFO))
- debugl1(sp, "hscx_empty_fifo");
-
- if (hsp->rcvidx + count > HSCX_BUFMAX) {
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "hscx_empty_fifo: incoming packet too large");
- writehscxCMDR(sp->hscx[hsp->hscx], hsp->hscx, 0x80);
- hsp->rcvidx = 0;
- return;
- }
- ptr = hsp->rcvbuf + hsp->rcvidx;
- hsp->rcvidx += count;
- save_flags(flags);
- cli();
- HscxReadFifo(sp->hscx[hsp->hscx], hsp->hscx, ptr, count);
- writehscxCMDR(sp->hscx[hsp->hscx], hsp->hscx, 0x80);
- restore_flags(flags);
- if (sp->debug & L1_DEB_HSCX_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "hscx_empty_fifo %c cnt %d",
- hsp->hscx ? 'B' : 'A', count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ return (readreg(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, offset));
}
static void
-hscx_fill_fifo(struct HscxState *hsp)
+WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
{
- struct IsdnCardState *sp = hsp->sp;
- int more, count;
- u_char *ptr;
- long flags;
-
- if ((sp->debug & L1_DEB_HSCX) && !(sp->debug & L1_DEB_HSCX_FIFO))
- debugl1(sp, "hscx_fill_fifo");
-
- if (!hsp->tx_skb)
- return;
- if (hsp->tx_skb->len <= 0)
- return;
-
- more = (hsp->mode == 1) ? 1 : 0;
- if (hsp->tx_skb->len > 32) {
- more = !0;
- count = 32;
- } else
- count = hsp->tx_skb->len;
-
- waitforXFW(sp->hscx[hsp->hscx], hsp->hscx);
- save_flags(flags);
- cli();
- ptr = hsp->tx_skb->data;
- skb_pull(hsp->tx_skb, count);
- hsp->tx_cnt -= count;
- hsp->count += count;
- HscxWriteFifo(sp->hscx[hsp->hscx], hsp->hscx, ptr, count);
- writehscxCMDR(sp->hscx[hsp->hscx], hsp->hscx, more ? 0x8 : 0xa);
- restore_flags(flags);
- if (sp->debug & L1_DEB_HSCX_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "hscx_fill_fifo %c cnt %d",
- hsp->hscx ? 'B' : 'A', count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ writereg(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, offset, value);
}
-static inline void
-hscx_interrupt(struct IsdnCardState *sp, u_char val, u_char hscx)
+static void
+ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
{
- u_char r;
- struct HscxState *hsp = sp->hs + hscx;
- struct sk_buff *skb;
- int count;
- char tmp[32];
-
- if (!hsp->init)
- return;
-
- if (val & 0x80) { /* RME */
-
- r = HscxReadReg(sp->hscx[hsp->hscx], hscx, HSCX_RSTA);
- if ((r & 0xf0) != 0xa0) {
- if (!r & 0x80)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "HSCX invalid frame");
- if ((r & 0x40) && hsp->mode)
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX RDO mode=%d",
- hsp->mode);
- debugl1(sp, tmp);
- }
- if (!r & 0x20)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "HSCX CRC error");
- writehscxCMDR(sp->hscx[hsp->hscx], hsp->hscx, 0x80);
- } else {
- count = HscxReadReg(sp->hscx[hsp->hscx], hscx, HSCX_RBCL) & 0x1f;
- if (count == 0)
- count = 32;
- hscx_empty_fifo(hsp, count);
- if ((count = hsp->rcvidx - 1) > 0) {
- if (sp->debug & L1_DEB_HSCX_FIFO) {
- sprintf(tmp, "HX Frame %d", count);
- debugl1(sp, tmp);
- }
- if (!(skb = dev_alloc_skb(count)))
- printk(KERN_WARNING "IX1: receive out of memory\n");
- else {
- memcpy(skb_put(skb, count), hsp->rcvbuf, count);
- skb_queue_tail(&hsp->rqueue, skb);
- }
- }
- }
- hsp->rcvidx = 0;
- hscx_sched_event(hsp, HSCX_RCVBUFREADY);
- }
- if (val & 0x40) { /* RPF */
- hscx_empty_fifo(hsp, 32);
- if (hsp->mode == 1) {
- /* receive audio data */
- if (!(skb = dev_alloc_skb(32)))
- printk(KERN_WARNING "IX1: receive out of memory\n");
- else {
- memcpy(skb_put(skb, 32), hsp->rcvbuf, 32);
- skb_queue_tail(&hsp->rqueue, skb);
- }
- hsp->rcvidx = 0;
- hscx_sched_event(hsp, HSCX_RCVBUFREADY);
- }
- }
- if (val & 0x10) { /* XPR */
- if (hsp->tx_skb)
- if (hsp->tx_skb->len) {
- hscx_fill_fifo(hsp);
- return;
- } else {
- SET_SKB_FREE(hsp->tx_skb);
- dev_kfree_skb(hsp->tx_skb);
- hsp->count = 0;
- if (hsp->st->l4.l1writewakeup)
- hsp->st->l4.l1writewakeup(hsp->st);
- hsp->tx_skb = NULL;
- }
- if ((hsp->tx_skb = skb_dequeue(&hsp->squeue))) {
- hsp->count = 0;
- hscx_fill_fifo(hsp);
- } else
- hscx_sched_event(hsp, HSCX_XMTBUFREADY);
- }
+ readfifo(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, 0, data, size);
}
-/*
- * ISAC stuff goes here
- */
-
static void
-isac_empty_fifo(struct IsdnCardState *sp, int count)
+WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
{
- u_char *ptr;
- long flags;
-
- if ((sp->debug & L1_DEB_ISAC) && !(sp->debug & L1_DEB_ISAC_FIFO))
- if (sp->debug & L1_DEB_ISAC)
- debugl1(sp, "isac_empty_fifo");
-
- if ((sp->rcvidx + count) >= MAX_DFRAME_LEN) {
- if (sp->debug & L1_DEB_WARN) {
- char tmp[40];
- sprintf(tmp, "isac_empty_fifo overrun %d",
- sp->rcvidx + count);
- debugl1(sp, tmp);
- }
- IsacWriteReg(sp->isac, ISAC_CMDR, 0x80);
- sp->rcvidx = 0;
- return;
- }
- ptr = sp->rcvbuf + sp->rcvidx;
- sp->rcvidx += count;
- save_flags(flags);
- cli();
- IsacReadFifo(sp->isac, ptr, count);
- IsacWriteReg(sp->isac, ISAC_CMDR, 0x80);
- restore_flags(flags);
- if (sp->debug & L1_DEB_ISAC_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "isac_empty_fifo cnt %d", count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ writefifo(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, 0, data, size);
}
-static void
-isac_fill_fifo(struct IsdnCardState *sp)
+static u_char
+ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
{
- int count, more;
- u_char *ptr;
- long flags;
-
- if ((sp->debug & L1_DEB_ISAC) && !(sp->debug & L1_DEB_ISAC_FIFO))
- debugl1(sp, "isac_fill_fifo");
-
- if (!sp->tx_skb)
- return;
-
- count = sp->tx_skb->len;
- if (count <= 0)
- return;
-
- more = 0;
- if (count > 32) {
- more = !0;
- count = 32;
- }
- save_flags(flags);
- cli();
- ptr = sp->tx_skb->data;
- skb_pull(sp->tx_skb, count);
- sp->tx_cnt += count;
- IsacWriteFifo(sp->isac, ptr, count);
- IsacWriteReg(sp->isac, ISAC_CMDR, more ? 0x8 : 0xa);
- restore_flags(flags);
- if (sp->debug & L1_DEB_ISAC_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "isac_fill_fifo cnt %d", count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ return (readreg(cs->hw.ix1.hscx_ale,
+ cs->hw.ix1.hscx, offset + (hscx ? 0x40 : 0)));
}
static void
-ph_command(struct IsdnCardState *sp, unsigned int command)
+WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
{
- if (sp->debug & L1_DEB_ISAC) {
- char tmp[32];
- sprintf(tmp, "ph_command %d", command);
- debugl1(sp, tmp);
- }
- IsacWriteReg(sp->isac, ISAC_CIX0, (command << 2) | 3);
+ writereg(cs->hw.ix1.hscx_ale,
+ cs->hw.ix1.hscx, offset + (hscx ? 0x40 : 0), value);
}
+#define READHSCX(cs, nr, reg) readreg(cs->hw.ix1.hscx_ale, \
+ cs->hw.ix1.hscx, reg + (nr ? 0x40 : 0))
+#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.ix1.hscx_ale, \
+ cs->hw.ix1.hscx, reg + (nr ? 0x40 : 0), data)
-static inline void
-isac_interrupt(struct IsdnCardState *sp, u_char val)
-{
- u_char exval;
- struct sk_buff *skb;
- unsigned int count;
- char tmp[32];
-
- if (sp->debug & L1_DEB_ISAC) {
- sprintf(tmp, "ISAC interrupt %x", val);
- debugl1(sp, tmp);
- }
- if (val & 0x80) { /* RME */
- exval = IsacReadReg(sp->isac, ISAC_RSTA);
- if ((exval & 0x70) != 0x20) {
- if (exval & 0x40)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC RDO");
- if (!exval & 0x20)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC CRC error");
- IsacWriteReg(sp->isac, ISAC_CMDR, 0x80);
- } else {
- count = IsacReadReg(sp->isac, ISAC_RBCL) & 0x1f;
- if (count == 0)
- count = 32;
- isac_empty_fifo(sp, count);
- if ((count = sp->rcvidx) > 0) {
- sp->rcvidx = 0;
- if (!(skb = alloc_skb(count, GFP_ATOMIC)))
- printk(KERN_WARNING "IX1: D receive out of memory\n");
- else {
- memcpy(skb_put(skb, count), sp->rcvbuf, count);
- skb_queue_tail(&sp->rq, skb);
- }
- }
- }
- sp->rcvidx = 0;
- isac_sched_event(sp, ISAC_RCVBUFREADY);
- }
- if (val & 0x40) { /* RPF */
- isac_empty_fifo(sp, 32);
- }
- if (val & 0x20) { /* RSC */
- /* never */
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC RSC interrupt");
- }
- if (val & 0x10) { /* XPR */
- if (sp->tx_skb)
- if (sp->tx_skb->len) {
- isac_fill_fifo(sp);
- goto afterXPR;
- } else {
- SET_SKB_FREE(sp->tx_skb);
- dev_kfree_skb(sp->tx_skb);
- sp->tx_cnt = 0;
- sp->tx_skb = NULL;
- }
- if ((sp->tx_skb = skb_dequeue(&sp->sq))) {
- sp->tx_cnt = 0;
- isac_fill_fifo(sp);
- } else
- isac_sched_event(sp, ISAC_XMTBUFREADY);
- }
- afterXPR:
- if (val & 0x04) { /* CISQ */
- sp->ph_state = (IsacReadReg(sp->isac, ISAC_CIX0) >> 2)
- & 0xf;
- if (sp->debug & L1_DEB_ISAC) {
- sprintf(tmp, "l1state %d", sp->ph_state);
- debugl1(sp, tmp);
- }
- isac_new_ph(sp);
- }
- if (val & 0x02) { /* SIN */
- /* never */
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC SIN interrupt");
- }
- if (val & 0x01) { /* EXI */
- exval = IsacReadReg(sp->isac, ISAC_EXIR);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "ISAC EXIR %02x", exval);
- debugl1(sp, tmp);
- }
- }
-}
+#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.ix1.hscx_ale, \
+ cs->hw.ix1.hscx, (nr ? 0x40 : 0), ptr, cnt)
-static inline void
-hscx_int_main(struct IsdnCardState *sp, u_char val)
-{
+#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.ix1.hscx_ale, \
+ cs->hw.ix1.hscx, (nr ? 0x40 : 0), ptr, cnt)
- u_char exval;
- struct HscxState *hsp;
- char tmp[32];
-
-
- if (val & 0x01) {
- hsp = sp->hs + 1;
- exval = HscxReadReg(sp->hscx[1], 1, HSCX_EXIR);
- if (exval == 0x40) {
- if (hsp->mode == 1)
- hscx_fill_fifo(hsp);
- else {
- /* Here we lost an TX interrupt, so
- * restart transmitting the whole frame.
- */
- if (hsp->tx_skb) {
- skb_push(hsp->tx_skb, hsp->count);
- hsp->tx_cnt += hsp->count;
- hsp->count = 0;
- }
- writehscxCMDR(sp->hscx[hsp->hscx], hsp->hscx, 0x01);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX B EXIR %x Lost TX", exval);
- debugl1(sp, tmp);
- }
- }
- } else if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX B EXIR %x", exval);
- debugl1(sp, tmp);
- }
- }
- if (val & 0xf8) {
- if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX B interrupt %x", val);
- debugl1(sp, tmp);
- }
- hscx_interrupt(sp, val, 1);
- }
- if (val & 0x02) {
- hsp = sp->hs;
- exval = HscxReadReg(sp->hscx[0], 0, HSCX_EXIR);
- if (exval == 0x40) {
- if (hsp->mode == 1)
- hscx_fill_fifo(hsp);
- else {
- /* Here we lost an TX interrupt, so
- * restart transmitting the whole frame.
- */
- if (hsp->tx_skb) {
- skb_push(hsp->tx_skb, hsp->count);
- hsp->tx_cnt += hsp->count;
- hsp->count = 0;
- }
- writehscxCMDR(sp->hscx[hsp->hscx], hsp->hscx, 0x01);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX A EXIR %x Lost TX", exval);
- debugl1(sp, tmp);
- }
- }
- } else if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX A EXIR %x", exval);
- debugl1(sp, tmp);
- }
- }
- if (val & 0x04) {
- exval = HscxReadReg(sp->hscx[0], 0, HSCX_ISTA);
- if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX A interrupt %x", exval);
- debugl1(sp, tmp);
- }
- hscx_interrupt(sp, exval, 0);
- }
-}
+#include "hscx_irq.c"
static void
ix1micro_interrupt(int intno, void *dev_id, struct pt_regs *regs)
{
- struct IsdnCardState *sp;
+ struct IsdnCardState *cs = dev_id;
u_char val, stat = 0;
- sp = (struct IsdnCardState *) dev_id;
-
- if (!sp) {
- printk(KERN_WARNING "Teles: Spurious interrupt!\n");
+ if (!cs) {
+ printk(KERN_WARNING "IX1: Spurious interrupt!\n");
return;
}
- val = HscxReadReg(sp->hscx[1], 1, HSCX_ISTA);
+ val = readreg(cs->hw.ix1.hscx_ale, cs->hw.ix1.hscx, HSCX_ISTA + 0x40);
Start_HSCX:
if (val) {
- hscx_int_main(sp, val);
+ hscx_int_main(cs, val);
stat |= 1;
}
- val = IsacReadReg(sp->isac, ISAC_ISTA);
+ val = readreg(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, ISAC_ISTA);
Start_ISAC:
if (val) {
- isac_interrupt(sp, val);
+ isac_interrupt(cs, val);
stat |= 2;
}
- val = HscxReadReg(sp->hscx[1], 1, HSCX_ISTA);
+ val = readreg(cs->hw.ix1.hscx_ale, cs->hw.ix1.hscx, HSCX_ISTA + 0x40);
if (val) {
- if (sp->debug & L1_DEB_HSCX)
- debugl1(sp, "HSCX IntStat after IntRoutine");
+ if (cs->debug & L1_DEB_HSCX)
+ debugl1(cs, "HSCX IntStat after IntRoutine");
goto Start_HSCX;
}
- val = IsacReadReg(sp->isac, ISAC_ISTA);
+ val = readreg(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, ISAC_ISTA);
if (val) {
- if (sp->debug & L1_DEB_ISAC)
- debugl1(sp, "ISAC IntStat after IntRoutine");
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ISAC IntStat after IntRoutine");
goto Start_ISAC;
}
if (stat & 1) {
- HscxWriteReg(sp->hscx[0], 0, HSCX_MASK, 0xFF);
- HscxWriteReg(sp->hscx[1], 1, HSCX_MASK, 0xFF);
- HscxWriteReg(sp->hscx[0], 0, HSCX_MASK, 0x0);
- HscxWriteReg(sp->hscx[1], 1, HSCX_MASK, 0x0);
+ writereg(cs->hw.ix1.hscx_ale, cs->hw.ix1.hscx, HSCX_MASK, 0xFF);
+ writereg(cs->hw.ix1.hscx_ale, cs->hw.ix1.hscx, HSCX_MASK + 0x40, 0xFF);
+ writereg(cs->hw.ix1.hscx_ale, cs->hw.ix1.hscx, HSCX_MASK, 0);
+ writereg(cs->hw.ix1.hscx_ale, cs->hw.ix1.hscx, HSCX_MASK + 0x40, 0);
}
if (stat & 2) {
- IsacWriteReg(sp->isac, ISAC_MASK, 0xFF);
- IsacWriteReg(sp->isac, ISAC_MASK, 0x0);
- }
-}
-
-
-static void
-initisac(struct IsdnCardState *sp)
-{
- unsigned int adr = sp->isac;
-
- /* 16.3 IOM 2 Mode */
- IsacWriteReg(adr, ISAC_MASK, 0xff);
- IsacWriteReg(adr, ISAC_ADF2, 0x80);
- IsacWriteReg(adr, ISAC_SQXR, 0x2f);
- IsacWriteReg(adr, ISAC_SPCR, 0x0);
- IsacWriteReg(adr, ISAC_ADF1, 0x2);
- IsacWriteReg(adr, ISAC_STCR, 0x70);
- IsacWriteReg(adr, ISAC_MODE, 0xc9);
- IsacWriteReg(adr, ISAC_TIMR, 0x0);
- IsacWriteReg(adr, ISAC_ADF1, 0x0);
- IsacWriteReg(adr, ISAC_CMDR, 0x41);
- IsacWriteReg(adr, ISAC_CIX0, (1 << 2) | 3);
- IsacWriteReg(adr, ISAC_MASK, 0xff);
- IsacWriteReg(adr, ISAC_MASK, 0x0);
-}
-
-static void
-modehscx(struct HscxState *hs, int mode, int ichan)
-{
- struct IsdnCardState *sp = hs->sp;
- int hscx = hs->hscx;
-
- if (sp->debug & L1_DEB_HSCX) {
- char tmp[40];
- sprintf(tmp, "hscx %c mode %d ichan %d",
- 'A' + hscx, mode, ichan);
- debugl1(sp, tmp);
+ writereg(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, ISAC_MASK, 0xFF);
+ writereg(cs->hw.ix1.isac_ale, cs->hw.ix1.isac, ISAC_MASK, 0);
}
- hs->mode = mode;
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_CCR1, 0x85);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_XAD1, 0xFF);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_XAD2, 0xFF);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_RAH2, 0xFF);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_XBCH, 0x0);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_RLCR, 0x0);
-
- switch (mode) {
- case 0:
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_CCR2, 0x30);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_TSAX, 0xff);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_TSAR, 0xff);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_XCCR, 7);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_RCCR, 7);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_MODE, 0x84);
- break;
- case 1:
- if (ichan == 0) {
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_CCR2, 0x30);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_TSAX, 0x2f);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_TSAR, 0x2f);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_XCCR, 7);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_RCCR, 7);
- } else {
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_CCR2, 0x30);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_TSAX, 0x3);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_TSAR, 0x3);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_XCCR, 7);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_RCCR, 7);
- }
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_MODE, 0xe4);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_CMDR, 0x41);
- break;
- case 2:
- if (ichan == 0) {
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_CCR2, 0x30);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_TSAX, 0x2f);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_TSAR, 0x2f);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_XCCR, 7);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_RCCR, 7);
- } else {
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_CCR2, 0x30);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_TSAX, 0x3);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_TSAR, 0x3);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_XCCR, 7);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_RCCR, 7);
- }
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_MODE, 0x8c);
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_CMDR, 0x41);
- break;
- }
- HscxWriteReg(sp->hscx[hscx], hscx, HSCX_ISTA, 0x00);
}
void
-release_io_ix1micro(struct IsdnCard *card)
+release_io_ix1micro(struct IsdnCardState *cs)
{
- if (card->sp->cfg_reg)
- release_region(card->sp->cfg_reg, 4);
+ if (cs->hw.ix1.cfg_reg)
+ release_region(cs->hw.ix1.cfg_reg, 4);
}
static void
-clear_pending_ints(struct IsdnCardState *sp)
+ix1_reset(struct IsdnCardState *cs)
{
- int val;
- char tmp[64];
+ long flags;
+ int cnt;
- val = HscxReadReg(sp->hscx[1], 1, HSCX_ISTA);
- sprintf(tmp, "HSCX B ISTA %x", val);
- debugl1(sp, tmp);
- if (val & 0x01) {
- val = HscxReadReg(sp->hscx[1], 1, HSCX_EXIR);
- sprintf(tmp, "HSCX B EXIR %x", val);
- debugl1(sp, tmp);
- } else if (val & 0x02) {
- val = HscxReadReg(sp->hscx[0], 0, HSCX_EXIR);
- sprintf(tmp, "HSCX A EXIR %x", val);
- debugl1(sp, tmp);
- }
- val = HscxReadReg(sp->hscx[0], 0, HSCX_ISTA);
- sprintf(tmp, "HSCX A ISTA %x", val);
- debugl1(sp, tmp);
- val = HscxReadReg(sp->hscx[1], 1, HSCX_STAR);
- sprintf(tmp, "HSCX B STAR %x", val);
- debugl1(sp, tmp);
- val = HscxReadReg(sp->hscx[0], 0, HSCX_STAR);
- sprintf(tmp, "HSCX A STAR %x", val);
- debugl1(sp, tmp);
- val = IsacReadReg(sp->isac, ISAC_STAR);
- sprintf(tmp, "ISAC STAR %x", val);
- debugl1(sp, tmp);
- val = IsacReadReg(sp->isac, ISAC_MODE);
- sprintf(tmp, "ISAC MODE %x", val);
- debugl1(sp, tmp);
- val = IsacReadReg(sp->isac, ISAC_ADF2);
- sprintf(tmp, "ISAC ADF2 %x", val);
- debugl1(sp, tmp);
- val = IsacReadReg(sp->isac, ISAC_ISTA);
- sprintf(tmp, "ISAC ISTA %x", val);
- debugl1(sp, tmp);
- if (val & 0x01) {
- val = IsacReadReg(sp->isac, ISAC_EXIR);
- sprintf(tmp, "ISAC EXIR %x", val);
- debugl1(sp, tmp);
- } else if (val & 0x04) {
- val = IsacReadReg(sp->isac, ISAC_CIR0);
- sprintf(tmp, "ISAC CIR0 %x", val);
- debugl1(sp, tmp);
+ /* reset isac */
+ save_flags(flags);
+ cnt = 3 * (HZ / 10) + 1;
+ sti();
+ while (cnt--) {
+ byteout(cs->hw.ix1.cfg_reg + SPECIAL_PORT_OFFSET, 1);
+ HZDELAY(1); /* wait >=10 ms */
}
- IsacWriteReg(sp->isac, ISAC_MASK, 0);
- IsacWriteReg(sp->isac, ISAC_CMDR, 0x41);
+ byteout(cs->hw.ix1.cfg_reg + SPECIAL_PORT_OFFSET, 0);
+ restore_flags(flags);
}
-int
-initix1micro(struct IsdnCardState *sp)
+static int
+ix1_card_msg(struct IsdnCardState *cs, int mt, void *arg)
{
- int ret;
- int loop = 0;
- char tmp[40];
-
- sp->counter = kstat_irqs(sp->irq);
- sprintf(tmp, "IRQ %d count %d", sp->irq, sp->counter);
- debugl1(sp, tmp);
- clear_pending_ints(sp);
- ret = get_irq(sp->cardnr, &ix1micro_interrupt);
- if (ret) {
- initisac(sp);
- sp->modehscx(sp->hs, 0, 0);
- sp->modehscx(sp->hs + 1, 0, 0);
- while (loop++ < 10) {
- /* At least 1-3 irqs must happen
- * (one from HSCX A, one from HSCX B, 3rd from ISAC)
- */
- if (kstat_irqs(sp->irq) > sp->counter)
- break;
- current->state = TASK_INTERRUPTIBLE;
- current->timeout = jiffies + 1;
- schedule();
- }
- sprintf(tmp, "IRQ %d count %d", sp->irq,
- kstat_irqs(sp->irq));
- debugl1(sp, tmp);
- if (kstat_irqs(sp->irq) == sp->counter) {
- printk(KERN_WARNING
- "ix1-Micro: IRQ(%d) getting no interrupts during init\n",
- sp->irq);
- free_irq(sp->irq, sp);
- return (0);
- }
- }
- return (ret);
+ switch (mt) {
+ case CARD_RESET:
+ ix1_reset(cs);
+ return(0);
+ case CARD_RELEASE:
+ release_io_ix1micro(cs);
+ return(0);
+ case CARD_SETIRQ:
+ return(request_irq(cs->irq, &ix1micro_interrupt,
+ I4L_IRQ_FLAG, "HiSax", cs));
+ case CARD_INIT:
+ clear_pending_isac_ints(cs);
+ clear_pending_hscx_ints(cs);
+ initisac(cs);
+ inithscx(cs);
+ return(0);
+ case CARD_TEST:
+ return(0);
+ }
+ return(0);
}
-int
-setup_ix1micro(struct IsdnCard *card)
+
+__initfunc(int
+setup_ix1micro(struct IsdnCard *card))
{
- u_char val, verA, verB;
- struct IsdnCardState *sp = card->sp;
- long flags;
+ struct IsdnCardState *cs = card->cs;
char tmp[64];
strcpy(tmp, ix1_revision);
- printk(KERN_NOTICE "HiSax: ITK IX1 driver Rev. %s\n", HiSax_getrev(tmp));
- if (sp->typ != ISDN_CTYPE_IX1MICROR2)
+ printk(KERN_INFO "HiSax: ITK IX1 driver Rev. %s\n", HiSax_getrev(tmp));
+ if (cs->typ != ISDN_CTYPE_IX1MICROR2)
return (0);
/* IO-Ports */
- sp->isac = sp->hscx[0] = sp->hscx[1] = sp->cfg_reg = card->para[1];
- sp->irq = card->para[0];
- if (sp->cfg_reg) {
- if (check_region((sp->cfg_reg), 4)) {
+ cs->hw.ix1.isac_ale = card->para[1] + ISAC_COMMAND_OFFSET;
+ cs->hw.ix1.hscx_ale = card->para[1] + HSCX_COMMAND_OFFSET;
+ cs->hw.ix1.isac = card->para[1] + ISAC_DATA_OFFSET;
+ cs->hw.ix1.hscx = card->para[1] + HSCX_DATA_OFFSET;
+ cs->hw.ix1.cfg_reg = card->para[1];
+ cs->irq = card->para[0];
+ if (cs->hw.ix1.cfg_reg) {
+ if (check_region((cs->hw.ix1.cfg_reg), 4)) {
printk(KERN_WARNING
"HiSax: %s config port %x-%x already in use\n",
CardType[card->typ],
- sp->cfg_reg,
- sp->cfg_reg + 4);
+ cs->hw.ix1.cfg_reg,
+ cs->hw.ix1.cfg_reg + 4);
return (0);
} else
- request_region(sp->cfg_reg, 4, "ix1micro cfg");
- }
- /* reset isac */
- save_flags(flags);
- val = 3 * (HZ / 10) + 1;
- sti();
- while (val--) {
- byteout(sp->cfg_reg + SPECIAL_PORT_OFFSET, 1);
- HZDELAY(1); /* wait >=10 ms */
- }
- byteout(sp->cfg_reg + SPECIAL_PORT_OFFSET, 0);
- restore_flags(flags);
-
- printk(KERN_NOTICE
- "HiSax: %s config irq:%d io:0x%x\n",
- CardType[sp->typ], sp->irq,
- sp->cfg_reg);
- verA = HscxReadReg(sp->hscx[0], 0, HSCX_VSTR) & 0xf;
- verB = HscxReadReg(sp->hscx[1], 1, HSCX_VSTR) & 0xf;
- printk(KERN_INFO "ix1-Micro: HSCX version A: %s B: %s\n",
- HscxVersion(verA), HscxVersion(verB));
- val = IsacReadReg(sp->isac, ISAC_RBCH);
- printk(KERN_INFO "ix1-Micro: ISAC %s\n",
- ISACVersion(val));
- if ((verA == 0) | (verA == 0xf) | (verB == 0) | (verB == 0xf)) {
+ request_region(cs->hw.ix1.cfg_reg, 4, "ix1micro cfg");
+ }
+ printk(KERN_INFO
+ "HiSax: %s config irq:%d io:0x%X\n",
+ CardType[cs->typ], cs->irq,
+ cs->hw.ix1.cfg_reg);
+ ix1_reset(cs);
+ cs->readisac = &ReadISAC;
+ cs->writeisac = &WriteISAC;
+ cs->readisacfifo = &ReadISACfifo;
+ cs->writeisacfifo = &WriteISACfifo;
+ cs->BC_Read_Reg = &ReadHSCX;
+ cs->BC_Write_Reg = &WriteHSCX;
+ cs->BC_Send_Data = &hscx_fill_fifo;
+ cs->cardmsg = &ix1_card_msg;
+ ISACVersion(cs, "ix1-Micro:");
+ if (HscxVersion(cs, "ix1-Micro:")) {
printk(KERN_WARNING
"ix1-Micro: wrong HSCX versions check IO address\n");
- release_io_ix1micro(card);
+ release_io_ix1micro(cs);
return (0);
}
- sp->modehscx = &modehscx;
- sp->ph_command = &ph_command;
- sp->hscx_fill_fifo = &hscx_fill_fifo;
- sp->isac_fill_fifo = &isac_fill_fifo;
return (1);
}
diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c
index c3ee6a73f..d60a5da66 100644
--- a/drivers/isdn/hisax/l3_1tr6.c
+++ b/drivers/isdn/hisax/l3_1tr6.c
@@ -1,4 +1,4 @@
-/* $Id: l3_1tr6.c,v 1.11 1997/04/06 22:54:18 keil Exp $
+/* $Id: l3_1tr6.c,v 2.4 1998/02/12 23:07:57 keil Exp $
* German 1TR6 D-channel protocol
*
@@ -6,39 +6,28 @@
*
*
* $Log: l3_1tr6.c,v $
- * Revision 1.11 1997/04/06 22:54:18 keil
- * Using SKB's
- *
- * Revision 1.10 1997/03/13 20:37:58 keil
- * channel request added
- *
- * Revision 1.9 1997/02/11 01:37:40 keil
- * Changed setup-interface (incoming and outgoing)
- *
- * Revision 1.8 1997/01/27 23:20:21 keil
- * report revision only ones
- *
- * Revision 1.7 1997/01/21 22:30:07 keil
- * new statemachine; L3 timers
+ * Revision 2.4 1998/02/12 23:07:57 keil
+ * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
*
- * Revision 1.6 1996/12/14 21:07:20 keil
- * additional states for CC_REJECT
+ * Revision 2.3 1997/11/06 17:12:24 keil
+ * KERN_NOTICE --> KERN_INFO
*
- * Revision 1.5 1996/12/08 19:55:17 keil
- * change CC_REJECT_REQ routine
+ * Revision 2.2 1997/10/29 19:03:00 keil
+ * changes for 2.1
*
- * Revision 1.4 1996/10/30 10:18:01 keil
- * bugfixes in debugging output
+ * Revision 2.1 1997/08/03 15:28:09 keil
+ * release L3 empty processes
*
- * Revision 1.3 1996/10/27 22:15:37 keil
- * bugfix reject handling
+ * Revision 2.0 1997/07/27 21:15:45 keil
+ * New Callref based layer3
*
- * Revision 1.2 1996/10/13 23:08:56 keil
- * added missing state for callback reject
+ * Revision 1.12 1997/06/26 11:11:45 keil
+ * SET_SKBFREE now on creation of a SKB
*
- * Revision 1.1 1996/10/13 20:04:55 keil
- * Initial revision
+ * Revision 1.11 1997/04/06 22:54:18 keil
+ * Using SKB's
*
+ * Old Log removed /KKe
*
*/
@@ -49,16 +38,16 @@
#include <linux/ctype.h>
extern char *HiSax_getrev(const char *revision);
-const char *l3_1tr6_revision = "$Revision: 1.11 $";
+const char *l3_1tr6_revision = "$Revision: 2.4 $";
#define MsgHead(ptr, cref, mty, dis) \
*ptr++ = dis; \
*ptr++ = 0x1; \
- *ptr++ = cref; \
+ *ptr++ = cref ^ 0x80; \
*ptr++ = mty
static void
-l3_1TR6_message(struct PStack *st, u_char mt, u_char pd)
+l3_1TR6_message(struct l3_process *pc, u_char mt, u_char pd)
{
struct sk_buff *skb;
u_char *p;
@@ -66,12 +55,71 @@ l3_1TR6_message(struct PStack *st, u_char mt, u_char pd)
if (!(skb = l3_alloc_skb(4)))
return;
p = skb_put(skb, 4);
- MsgHead(p, st->l3.callref, mt, pd);
- st->l3.l3l2(st, DL_DATA, skb);
+ MsgHead(p, pc->callref, mt, pd);
+ pc->st->l3.l3l2(pc->st, DL_DATA, skb);
+}
+
+static int
+l31tr6_check_messagetype_validity(int mt, int pd) {
+/* verify if a message type exists */
+
+ if (pd == PROTO_DIS_N0)
+ switch(mt) {
+ case MT_N0_REG_IND:
+ case MT_N0_CANC_IND:
+ case MT_N0_FAC_STA:
+ case MT_N0_STA_ACK:
+ case MT_N0_STA_REJ:
+ case MT_N0_FAC_INF:
+ case MT_N0_INF_ACK:
+ case MT_N0_INF_REJ:
+ case MT_N0_CLOSE:
+ case MT_N0_CLO_ACK:
+ return(1);
+ default:
+ return(0);
+ }
+ else if (pd == PROTO_DIS_N1)
+ switch(mt) {
+ case MT_N1_ESC:
+ case MT_N1_ALERT:
+ case MT_N1_CALL_SENT:
+ case MT_N1_CONN:
+ case MT_N1_CONN_ACK:
+ case MT_N1_SETUP:
+ case MT_N1_SETUP_ACK:
+ case MT_N1_RES:
+ case MT_N1_RES_ACK:
+ case MT_N1_RES_REJ:
+ case MT_N1_SUSP:
+ case MT_N1_SUSP_ACK:
+ case MT_N1_SUSP_REJ:
+ case MT_N1_USER_INFO:
+ case MT_N1_DET:
+ case MT_N1_DISC:
+ case MT_N1_REL:
+ case MT_N1_REL_ACK:
+ case MT_N1_CANC_ACK:
+ case MT_N1_CANC_REJ:
+ case MT_N1_CON_CON:
+ case MT_N1_FAC:
+ case MT_N1_FAC_ACK:
+ case MT_N1_FAC_CAN:
+ case MT_N1_FAC_REG:
+ case MT_N1_FAC_REJ:
+ case MT_N1_INFO:
+ case MT_N1_REG_ACK:
+ case MT_N1_REG_REJ:
+ case MT_N1_STAT:
+ return (1);
+ default:
+ return(0);
+ }
+ return(0);
}
static void
-l3_1tr6_setup_req(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_setup_req(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb;
u_char tmp[128];
@@ -81,16 +129,13 @@ l3_1tr6_setup_req(struct PStack *st, u_char pr, void *arg)
u_char channel = 0;
int l;
-
- st->l3.callref = st->pa->callref;
- MsgHead(p, st->l3.callref, MT_N1_SETUP, PROTO_DIS_N1);
-
- teln = st->pa->setup.phone;
- st->pa->spv = 0;
+ MsgHead(p, pc->callref, MT_N1_SETUP, PROTO_DIS_N1);
+ teln = pc->para.setup.phone;
+ pc->para.spv = 0;
if (!isdigit(*teln)) {
switch (0x5f & *teln) {
case 'S':
- st->pa->spv = 1;
+ pc->para.spv = 1;
break;
case 'C':
channel = 0x08;
@@ -103,8 +148,8 @@ l3_1tr6_setup_req(struct PStack *st, u_char pr, void *arg)
channel |= 0x02;
break;
default:
- if (st->l3.debug & L3_DEB_WARN)
- l3_debug(st, "Wrong MSN Code");
+ if (pc->st->l3.debug & L3_DEB_WARN)
+ l3_debug(pc->st, "Wrong MSN Code");
break;
}
teln++;
@@ -114,22 +159,22 @@ l3_1tr6_setup_req(struct PStack *st, u_char pr, void *arg)
*p++ = 1;
*p++ = channel;
}
- if (st->pa->spv) { /* SPV ? */
+ if (pc->para.spv) { /* SPV ? */
/* NSF SPV */
*p++ = WE0_netSpecFac;
*p++ = 4; /* Laenge */
*p++ = 0;
*p++ = FAC_SPV; /* SPV */
- *p++ = st->pa->setup.si1; /* 0 for all Services */
- *p++ = st->pa->setup.si2; /* 0 for all Services */
+ *p++ = pc->para.setup.si1; /* 0 for all Services */
+ *p++ = pc->para.setup.si2; /* 0 for all Services */
*p++ = WE0_netSpecFac;
*p++ = 4; /* Laenge */
*p++ = 0;
*p++ = FAC_Activate; /* aktiviere SPV (default) */
- *p++ = st->pa->setup.si1; /* 0 for all Services */
- *p++ = st->pa->setup.si2; /* 0 for all Services */
+ *p++ = pc->para.setup.si1; /* 0 for all Services */
+ *p++ = pc->para.setup.si2; /* 0 for all Services */
}
- eaz = st->pa->setup.eazmsn;
+ eaz = pc->para.setup.eazmsn;
if (*eaz) {
*p++ = WE0_origAddr;
*p++ = strlen(eaz) + 1;
@@ -149,22 +194,21 @@ l3_1tr6_setup_req(struct PStack *st, u_char pr, void *arg)
/* Codesatz 6 fuer Service */
*p++ = WE6_serviceInd;
*p++ = 2; /* len=2 info,info2 */
- *p++ = st->pa->setup.si1;
- *p++ = st->pa->setup.si2;
+ *p++ = pc->para.setup.si1;
+ *p++ = pc->para.setup.si2;
l = p - tmp;
if (!(skb = l3_alloc_skb(l)))
return;
memcpy(skb_put(skb, l), tmp, l);
- L3DelTimer(&st->l3.timer);
- L3AddTimer(&st->l3.timer, st->l3.t303, CC_T303);
- newl3state(st, 1);
- st->l3.l3l2(st, DL_DATA, skb);
-
+ L3DelTimer(&pc->timer);
+ L3AddTimer(&pc->timer, T303, CC_T303);
+ newl3state(pc, 1);
+ pc->st->l3.l3l2(pc->st, DL_DATA, skb);
}
static void
-l3_1tr6_setup(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
{
u_char *p;
int bcfound = 0;
@@ -172,110 +216,105 @@ l3_1tr6_setup(struct PStack *st, u_char pr, void *arg)
struct sk_buff *skb = arg;
p = skb->data;
- st->pa->callref = getcallref(p);
- st->l3.callref = 0x80 + st->pa->callref;
/* Channel Identification */
p = skb->data;
if ((p = findie(p, skb->len, WE0_chanID, 0))) {
- st->pa->bchannel = p[2] & 0x3;
+ pc->para.bchannel = p[2] & 0x3;
bcfound++;
- } else if (st->l3.debug & L3_DEB_WARN)
- l3_debug(st, "setup without bchannel");
+ } else if (pc->st->l3.debug & L3_DEB_WARN)
+ l3_debug(pc->st, "setup without bchannel");
p = skb->data;
if ((p = findie(p, skb->len, WE6_serviceInd, 6))) {
- st->pa->setup.si1 = p[2];
- st->pa->setup.si2 = p[3];
- } else if (st->l3.debug & L3_DEB_WARN)
- l3_debug(st, "setup without service indicator");
+ pc->para.setup.si1 = p[2];
+ pc->para.setup.si2 = p[3];
+ } else if (pc->st->l3.debug & L3_DEB_WARN)
+ l3_debug(pc->st, "setup without service indicator");
p = skb->data;
if ((p = findie(p, skb->len, WE0_destAddr, 0)))
- iecpy(st->pa->setup.eazmsn, p, 1);
+ iecpy(pc->para.setup.eazmsn, p, 1);
else
- st->pa->setup.eazmsn[0] = 0;
+ pc->para.setup.eazmsn[0] = 0;
p = skb->data;
if ((p = findie(p, skb->len, WE0_origAddr, 0))) {
- iecpy(st->pa->setup.phone, p, 1);
+ iecpy(pc->para.setup.phone, p, 1);
} else
- st->pa->setup.phone[0] = 0;
+ pc->para.setup.phone[0] = 0;
p = skb->data;
- st->pa->spv = 0;
+ pc->para.spv = 0;
if ((p = findie(p, skb->len, WE0_netSpecFac, 0))) {
if ((FAC_SPV == p[3]) || (FAC_Activate == p[3]))
- st->pa->spv = 1;
+ pc->para.spv = 1;
}
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
/* Signal all services, linklevel takes care of Service-Indicator */
if (bcfound) {
- if ((st->pa->setup.si1 != 7) && (st->l3.debug & L3_DEB_WARN)) {
+ if ((pc->para.setup.si1 != 7) && (pc->st->l3.debug & L3_DEB_WARN)) {
sprintf(tmp, "non-digital call: %s -> %s",
- st->pa->setup.phone,
- st->pa->setup.eazmsn);
- l3_debug(st, tmp);
+ pc->para.setup.phone,
+ pc->para.setup.eazmsn);
+ l3_debug(pc->st, tmp);
}
- newl3state(st, 6);
- st->l3.l3l4(st, CC_SETUP_IND, NULL);
- }
+ newl3state(pc, 6);
+ pc->st->l3.l3l4(pc, CC_SETUP_IND, NULL);
+ } else
+ release_l3_process(pc);
}
static void
-l3_1tr6_setup_ack(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_setup_ack(struct l3_process *pc, u_char pr, void *arg)
{
u_char *p;
struct sk_buff *skb = arg;
- L3DelTimer(&st->l3.timer);
+ L3DelTimer(&pc->timer);
p = skb->data;
- newl3state(st, 2);
+ newl3state(pc, 2);
if ((p = findie(p, skb->len, WE0_chanID, 0))) {
- st->pa->bchannel = p[2] & 0x3;
- } else if (st->l3.debug & L3_DEB_WARN)
- l3_debug(st, "setup answer without bchannel");
- SET_SKB_FREE(skb);
+ pc->para.bchannel = p[2] & 0x3;
+ } else if (pc->st->l3.debug & L3_DEB_WARN)
+ l3_debug(pc->st, "setup answer without bchannel");
dev_kfree_skb(skb);
- L3AddTimer(&st->l3.timer, st->l3.t304, CC_T304);
- st->l3.l3l4(st, CC_MORE_INFO, NULL);
+ L3AddTimer(&pc->timer, T304, CC_T304);
+ pc->st->l3.l3l4(pc, CC_MORE_INFO, NULL);
}
static void
-l3_1tr6_call_sent(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_call_sent(struct l3_process *pc, u_char pr, void *arg)
{
u_char *p;
struct sk_buff *skb = arg;
- L3DelTimer(&st->l3.timer);
+ L3DelTimer(&pc->timer);
p = skb->data;
if ((p = findie(p, skb->len, WE0_chanID, 0))) {
- st->pa->bchannel = p[2] & 0x3;
- } else if (st->l3.debug & L3_DEB_WARN)
- l3_debug(st, "setup answer without bchannel");
- SET_SKB_FREE(skb);
+ pc->para.bchannel = p[2] & 0x3;
+ } else if (pc->st->l3.debug & L3_DEB_WARN)
+ l3_debug(pc->st, "setup answer without bchannel");
dev_kfree_skb(skb);
- L3AddTimer(&st->l3.timer, st->l3.t310, CC_T310);
- newl3state(st, 3);
- st->l3.l3l4(st, CC_PROCEEDING_IND, NULL);
+ L3AddTimer(&pc->timer, T310, CC_T310);
+ newl3state(pc, 3);
+ pc->st->l3.l3l4(pc, CC_PROCEEDING_IND, NULL);
}
static void
-l3_1tr6_alert(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_alert(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb = arg;
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
- L3DelTimer(&st->l3.timer); /* T304 */
- newl3state(st, 4);
- st->l3.l3l4(st, CC_ALERTING_IND, NULL);
+ L3DelTimer(&pc->timer); /* T304 */
+ newl3state(pc, 4);
+ pc->st->l3.l3l4(pc, CC_ALERTING_IND, NULL);
}
static void
-l3_1tr6_info(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
{
u_char *p;
int i, tmpcharge = 0;
@@ -289,45 +328,42 @@ l3_1tr6_info(struct PStack *st, u_char pr, void *arg)
tmpcharge *= 10;
tmpcharge += a_charge[i] & 0xf;
}
- if (tmpcharge > st->pa->chargeinfo) {
- st->pa->chargeinfo = tmpcharge;
- st->l3.l3l4(st, CC_INFO_CHARGE, NULL);
+ if (tmpcharge > pc->para.chargeinfo) {
+ pc->para.chargeinfo = tmpcharge;
+ pc->st->l3.l3l4(pc, CC_INFO_CHARGE, NULL);
}
- if (st->l3.debug & L3_DEB_CHARGE) {
- sprintf(tmp, "charging info %d", st->pa->chargeinfo);
- l3_debug(st, tmp);
+ if (pc->st->l3.debug & L3_DEB_CHARGE) {
+ sprintf(tmp, "charging info %d", pc->para.chargeinfo);
+ l3_debug(pc->st, tmp);
}
- } else if (st->l3.debug & L3_DEB_CHARGE)
- l3_debug(st, "charging info not found");
- SET_SKB_FREE(skb);
+ } else if (pc->st->l3.debug & L3_DEB_CHARGE)
+ l3_debug(pc->st, "charging info not found");
dev_kfree_skb(skb);
}
static void
-l3_1tr6_info_s2(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_info_s2(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb = arg;
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
}
static void
-l3_1tr6_connect(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_connect(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb = arg;
- L3DelTimer(&st->l3.timer); /* T310 */
- newl3state(st, 10);
- SET_SKB_FREE(skb);
+ L3DelTimer(&pc->timer); /* T310 */
+ newl3state(pc, 10);
dev_kfree_skb(skb);
- st->pa->chargeinfo = 0;
- st->l3.l3l4(st, CC_SETUP_CNF, NULL);
+ pc->para.chargeinfo = 0;
+ pc->st->l3.l3l4(pc, CC_SETUP_CNF, NULL);
}
static void
-l3_1tr6_rel(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_rel(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb = arg;
u_char *p;
@@ -335,47 +371,47 @@ l3_1tr6_rel(struct PStack *st, u_char pr, void *arg)
p = skb->data;
if ((p = findie(p, skb->len, WE0_cause, 0))) {
if (p[1] > 0) {
- st->pa->cause = p[2];
+ pc->para.cause = p[2];
if (p[1] > 1)
- st->pa->loc = p[3];
+ pc->para.loc = p[3];
else
- st->pa->loc = 0;
+ pc->para.loc = 0;
} else {
- st->pa->cause = 0;
- st->pa->loc = 0;
+ pc->para.cause = 0;
+ pc->para.loc = 0;
}
} else
- st->pa->cause = -1;
- SET_SKB_FREE(skb);
+ pc->para.cause = -1;
dev_kfree_skb(skb);
- StopAllL3Timer(st);
- newl3state(st, 0);
- l3_1TR6_message(st, MT_N1_REL_ACK, PROTO_DIS_N1);
- st->l3.l3l4(st, CC_RELEASE_IND, NULL);
+ StopAllL3Timer(pc);
+ newl3state(pc, 0);
+ l3_1TR6_message(pc, MT_N1_REL_ACK, PROTO_DIS_N1);
+ pc->st->l3.l3l4(pc, CC_RELEASE_IND, NULL);
+ release_l3_process(pc);
}
static void
-l3_1tr6_rel_ack(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_rel_ack(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb = arg;
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
- StopAllL3Timer(st);
- newl3state(st, 0);
- st->pa->cause = -1;
- st->l3.l3l4(st, CC_RELEASE_CNF, NULL);
+ StopAllL3Timer(pc);
+ newl3state(pc, 0);
+ pc->para.cause = -1;
+ pc->st->l3.l3l4(pc, CC_RELEASE_CNF, NULL);
+ release_l3_process(pc);
}
static void
-l3_1tr6_disc(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb = arg;
u_char *p;
int i, tmpcharge = 0;
char a_charge[8], tmp[32];
- StopAllL3Timer(st);
+ StopAllL3Timer(pc);
p = skb->data;
if ((p = findie(p, skb->len, WE6_chargingInfo, 6))) {
iecpy(a_charge, p, 1);
@@ -383,104 +419,102 @@ l3_1tr6_disc(struct PStack *st, u_char pr, void *arg)
tmpcharge *= 10;
tmpcharge += a_charge[i] & 0xf;
}
- if (tmpcharge > st->pa->chargeinfo) {
- st->pa->chargeinfo = tmpcharge;
- st->l3.l3l4(st, CC_INFO_CHARGE, NULL);
+ if (tmpcharge > pc->para.chargeinfo) {
+ pc->para.chargeinfo = tmpcharge;
+ pc->st->l3.l3l4(pc, CC_INFO_CHARGE, NULL);
}
- if (st->l3.debug & L3_DEB_CHARGE) {
- sprintf(tmp, "charging info %d", st->pa->chargeinfo);
- l3_debug(st, tmp);
+ if (pc->st->l3.debug & L3_DEB_CHARGE) {
+ sprintf(tmp, "charging info %d", pc->para.chargeinfo);
+ l3_debug(pc->st, tmp);
}
- } else if (st->l3.debug & L3_DEB_CHARGE)
- l3_debug(st, "charging info not found");
+ } else if (pc->st->l3.debug & L3_DEB_CHARGE)
+ l3_debug(pc->st, "charging info not found");
p = skb->data;
if ((p = findie(p, skb->len, WE0_cause, 0))) {
if (p[1] > 0) {
- st->pa->cause = p[2];
+ pc->para.cause = p[2];
if (p[1] > 1)
- st->pa->loc = p[3];
+ pc->para.loc = p[3];
else
- st->pa->loc = 0;
+ pc->para.loc = 0;
} else {
- st->pa->cause = 0;
- st->pa->loc = 0;
+ pc->para.cause = 0;
+ pc->para.loc = 0;
}
} else {
- if (st->l3.debug & L3_DEB_WARN)
- l3_debug(st, "cause not found");
- st->pa->cause = -1;
+ if (pc->st->l3.debug & L3_DEB_WARN)
+ l3_debug(pc->st, "cause not found");
+ pc->para.cause = -1;
}
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
- newl3state(st, 12);
- st->l3.l3l4(st, CC_DISCONNECT_IND, NULL);
+ newl3state(pc, 12);
+ pc->st->l3.l3l4(pc, CC_DISCONNECT_IND, NULL);
}
static void
-l3_1tr6_connect_ack(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_connect_ack(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb = arg;
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
- newl3state(st, 10);
- st->pa->chargeinfo = 0;
- L3DelTimer(&st->l3.timer);
- st->l3.l3l4(st, CC_SETUP_COMPLETE_IND, NULL);
+ newl3state(pc, 10);
+ pc->para.chargeinfo = 0;
+ L3DelTimer(&pc->timer);
+ pc->st->l3.l3l4(pc, CC_SETUP_COMPLETE_IND, NULL);
}
static void
-l3_1tr6_alert_req(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_alert_req(struct l3_process *pc, u_char pr, void *arg)
{
- newl3state(st, 7);
- l3_1TR6_message(st, MT_N1_ALERT, PROTO_DIS_N1);
+ newl3state(pc, 7);
+ l3_1TR6_message(pc, MT_N1_ALERT, PROTO_DIS_N1);
}
static void
-l3_1tr6_setup_rsp(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_setup_rsp(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb;
u_char tmp[24];
u_char *p = tmp;
int l;
- MsgHead(p, st->l3.callref, MT_N1_CONN, PROTO_DIS_N1);
- if (st->pa->spv) { /* SPV ? */
+ MsgHead(p, pc->callref, MT_N1_CONN, PROTO_DIS_N1);
+ if (pc->para.spv) { /* SPV ? */
/* NSF SPV */
*p++ = WE0_netSpecFac;
*p++ = 4; /* Laenge */
*p++ = 0;
*p++ = FAC_SPV; /* SPV */
- *p++ = st->pa->setup.si1;
- *p++ = st->pa->setup.si2;
+ *p++ = pc->para.setup.si1;
+ *p++ = pc->para.setup.si2;
*p++ = WE0_netSpecFac;
*p++ = 4; /* Laenge */
*p++ = 0;
*p++ = FAC_Activate; /* aktiviere SPV */
- *p++ = st->pa->setup.si1;
- *p++ = st->pa->setup.si2;
+ *p++ = pc->para.setup.si1;
+ *p++ = pc->para.setup.si2;
}
- newl3state(st, 8);
+ newl3state(pc, 8);
l = p - tmp;
if (!(skb = l3_alloc_skb(l)))
return;
memcpy(skb_put(skb, l), tmp, l);
- st->l3.l3l2(st, DL_DATA, skb);
- L3DelTimer(&st->l3.timer);
- L3AddTimer(&st->l3.timer, st->l3.t313, CC_T313);
+ pc->st->l3.l3l2(pc->st, DL_DATA, skb);
+ L3DelTimer(&pc->timer);
+ L3AddTimer(&pc->timer, T313, CC_T313);
}
static void
-l3_1tr6_reset(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_reset(struct l3_process *pc, u_char pr, void *arg)
{
- newl3state(st, 0);
+ release_l3_process(pc);
}
static void
-l3_1tr6_disconnect_req(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_disconnect_req(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb;
u_char tmp[16];
@@ -489,8 +523,8 @@ l3_1tr6_disconnect_req(struct PStack *st, u_char pr, void *arg)
u_char cause = 0x10;
u_char clen = 1;
- if (st->pa->cause > 0)
- cause = st->pa->cause;
+ if (pc->para.cause > 0)
+ cause = pc->para.cause;
/* Map DSS1 causes */
switch (cause & 0x7f) {
case 0x10:
@@ -500,57 +534,55 @@ l3_1tr6_disconnect_req(struct PStack *st, u_char pr, void *arg)
cause = CAUSE_CallRejected;
break;
}
- StopAllL3Timer(st);
- MsgHead(p, st->l3.callref, MT_N1_DISC, PROTO_DIS_N1);
+ StopAllL3Timer(pc);
+ MsgHead(p, pc->callref, MT_N1_DISC, PROTO_DIS_N1);
*p++ = WE0_cause;
*p++ = clen; /* Laenge */
if (clen)
*p++ = cause | 0x80;
- newl3state(st, 11);
+ newl3state(pc, 11);
l = p - tmp;
if (!(skb = l3_alloc_skb(l)))
return;
memcpy(skb_put(skb, l), tmp, l);
- st->l3.l3l2(st, DL_DATA, skb);
- L3AddTimer(&st->l3.timer, st->l3.t305, CC_T305);
+ pc->st->l3.l3l2(pc->st, DL_DATA, skb);
+ L3AddTimer(&pc->timer, T305, CC_T305);
}
static void
-l3_1tr6_release_req(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_release_req(struct l3_process *pc, u_char pr, void *arg)
{
- StopAllL3Timer(st);
- newl3state(st, 19);
- l3_1TR6_message(st, MT_N1_REL, PROTO_DIS_N1);
- L3AddTimer(&st->l3.timer, st->l3.t308, CC_T308_1);
+ StopAllL3Timer(pc);
+ newl3state(pc, 19);
+ l3_1TR6_message(pc, MT_N1_REL, PROTO_DIS_N1);
+ L3AddTimer(&pc->timer, T308, CC_T308_1);
}
static void
-l3_1tr6_t303(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_t303(struct l3_process *pc, u_char pr, void *arg)
{
- if (st->l3.n_t303 > 0) {
- st->l3.n_t303--;
- L3DelTimer(&st->l3.timer);
- l3_1tr6_setup_req(st, pr, arg);
+ if (pc->N303 > 0) {
+ pc->N303--;
+ L3DelTimer(&pc->timer);
+ l3_1tr6_setup_req(pc, pr, arg);
} else {
- L3DelTimer(&st->l3.timer);
- st->l3.l3l4(st, CC_NOSETUP_RSP_ERR, NULL);
- st->l3.n_t303 = 1;
- newl3state(st, 0);
+ L3DelTimer(&pc->timer);
+ pc->st->l3.l3l4(pc, CC_NOSETUP_RSP_ERR, NULL);
+ release_l3_process(pc);
}
}
static void
-l3_1tr6_t304(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_t304(struct l3_process *pc, u_char pr, void *arg)
{
- L3DelTimer(&st->l3.timer);
- st->pa->cause = 0xE6;
- l3_1tr6_disconnect_req(st, pr, NULL);
- st->l3.l3l4(st, CC_SETUP_ERR, NULL);
-
+ L3DelTimer(&pc->timer);
+ pc->para.cause = 0xE6;
+ l3_1tr6_disconnect_req(pc, pr, NULL);
+ pc->st->l3.l3l4(pc, CC_SETUP_ERR, NULL);
}
static void
-l3_1tr6_t305(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_t305(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb;
u_char tmp[16];
@@ -559,9 +591,9 @@ l3_1tr6_t305(struct PStack *st, u_char pr, void *arg)
u_char cause = 0x90;
u_char clen = 1;
- L3DelTimer(&st->l3.timer);
- if (st->pa->cause > 0)
- cause = st->pa->cause;
+ L3DelTimer(&pc->timer);
+ if (pc->para.cause > 0)
+ cause = pc->para.cause;
/* Map DSS1 causes */
switch (cause & 0x7f) {
case 0x10:
@@ -571,53 +603,53 @@ l3_1tr6_t305(struct PStack *st, u_char pr, void *arg)
cause = CAUSE_CallRejected;
break;
}
- MsgHead(p, st->l3.callref, MT_N1_REL, PROTO_DIS_N1);
+ MsgHead(p, pc->callref, MT_N1_REL, PROTO_DIS_N1);
*p++ = WE0_cause;
*p++ = clen; /* Laenge */
if (clen)
*p++ = cause;
- newl3state(st, 19);
+ newl3state(pc, 19);
l = p - tmp;
if (!(skb = l3_alloc_skb(l)))
return;
memcpy(skb_put(skb, l), tmp, l);
- st->l3.l3l2(st, DL_DATA, skb);
- L3AddTimer(&st->l3.timer, st->l3.t308, CC_T308_1);
+ pc->st->l3.l3l2(pc->st, DL_DATA, skb);
+ L3AddTimer(&pc->timer, T308, CC_T308_1);
}
static void
-l3_1tr6_t310(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_t310(struct l3_process *pc, u_char pr, void *arg)
{
- L3DelTimer(&st->l3.timer);
- st->pa->cause = 0xE6;
- l3_1tr6_disconnect_req(st, pr, NULL);
- st->l3.l3l4(st, CC_SETUP_ERR, NULL);
+ L3DelTimer(&pc->timer);
+ pc->para.cause = 0xE6;
+ l3_1tr6_disconnect_req(pc, pr, NULL);
+ pc->st->l3.l3l4(pc, CC_SETUP_ERR, NULL);
}
static void
-l3_1tr6_t313(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_t313(struct l3_process *pc, u_char pr, void *arg)
{
- L3DelTimer(&st->l3.timer);
- st->pa->cause = 0xE6;
- l3_1tr6_disconnect_req(st, pr, NULL);
- st->l3.l3l4(st, CC_CONNECT_ERR, NULL);
+ L3DelTimer(&pc->timer);
+ pc->para.cause = 0xE6;
+ l3_1tr6_disconnect_req(pc, pr, NULL);
+ pc->st->l3.l3l4(pc, CC_CONNECT_ERR, NULL);
}
static void
-l3_1tr6_t308_1(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_t308_1(struct l3_process *pc, u_char pr, void *arg)
{
- L3DelTimer(&st->l3.timer);
- l3_1TR6_message(st, MT_N1_REL, PROTO_DIS_N1);
- L3AddTimer(&st->l3.timer, st->l3.t308, CC_T308_2);
- newl3state(st, 19);
+ L3DelTimer(&pc->timer);
+ l3_1TR6_message(pc, MT_N1_REL, PROTO_DIS_N1);
+ L3AddTimer(&pc->timer, T308, CC_T308_2);
+ newl3state(pc, 19);
}
static void
-l3_1tr6_t308_2(struct PStack *st, u_char pr, void *arg)
+l3_1tr6_t308_2(struct l3_process *pc, u_char pr, void *arg)
{
- L3DelTimer(&st->l3.timer);
- st->l3.l3l4(st, CC_RELEASE_ERR, NULL);
- newl3state(st, 0);
+ L3DelTimer(&pc->timer);
+ pc->st->l3.l3l4(pc, CC_RELEASE_ERR, NULL);
+ release_l3_process(pc);
}
/* *INDENT-OFF* */
static struct stateentry downstl[] =
@@ -688,49 +720,79 @@ static struct stateentry datastln1[] =
+
static int datastln1_len = sizeof(datastln1) /
sizeof(struct stateentry);
static void
up1tr6(struct PStack *st, int pr, void *arg)
{
- int i, mt;
+ int i, mt, cr;
+ struct l3_process *proc;
struct sk_buff *skb = arg;
char tmp[80];
+ if (skb->len < 4) {
+ if (st->l3.debug & L3_DEB_PROTERR) {
+ sprintf(tmp, "up1tr6 len only %d", skb->len);
+ l3_debug(st, tmp);
+ }
+ dev_kfree_skb(skb);
+ return;
+ }
if ((skb->data[0] & 0xfe) != PROTO_DIS_N0) {
if (st->l3.debug & L3_DEB_PROTERR) {
- sprintf(tmp, "up1tr6%sunexpected discriminator %x message len %d state %d",
+ sprintf(tmp, "up1tr6%sunexpected discriminator %x message len %d",
(pr == DL_DATA) ? " " : "(broadcast) ",
- skb->data[0], skb->len, st->l3.state);
+ skb->data[0], skb->len);
+ l3_debug(st, tmp);
+ }
+ dev_kfree_skb(skb);
+ return;
+ }
+ if (skb->data[1] != 1) {
+ if (st->l3.debug & L3_DEB_PROTERR) {
+ sprintf(tmp, "up1tr6 CR len not 1");
l3_debug(st, tmp);
}
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
return;
}
- mt = skb->data[skb->data[1] + 2];
+ cr = skb->data[2];
+ mt = skb->data[3];
if (skb->data[0] == PROTO_DIS_N0) {
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
if (st->l3.debug & L3_DEB_STATE) {
- sprintf(tmp, "up1tr6%s N0 state %d mt %x unhandled",
- (pr == DL_DATA) ? " " : "(broadcast) ",
- st->l3.state, mt);
+ sprintf(tmp, "up1tr6%s N0 mt %x unhandled",
+ (pr == DL_DATA) ? " " : "(broadcast) ", mt);
l3_debug(st, tmp);
}
} else if (skb->data[0] == PROTO_DIS_N1) {
+ if (!(proc = getl3proc(st, cr))) {
+ if ((mt == MT_N1_SETUP) && (cr < 128)) {
+ if (!(proc = new_l3_process(st, cr))) {
+ if (st->l3.debug & L3_DEB_PROTERR) {
+ sprintf(tmp, "up1tr6 no roc mem");
+ l3_debug(st, tmp);
+ }
+ dev_kfree_skb(skb);
+ return;
+ }
+ } else {
+ dev_kfree_skb(skb);
+ return;
+ }
+ }
for (i = 0; i < datastln1_len; i++)
if ((mt == datastln1[i].primitive) &&
- ((1 << st->l3.state) & datastln1[i].state))
+ ((1 << proc->state) & datastln1[i].state))
break;
if (i == datastln1_len) {
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
if (st->l3.debug & L3_DEB_STATE) {
sprintf(tmp, "up1tr6%sstate %d mt %x unhandled",
(pr == DL_DATA) ? " " : "(broadcast) ",
- st->l3.state, mt);
+ proc->state, mt);
l3_debug(st, tmp);
}
return;
@@ -738,10 +800,10 @@ up1tr6(struct PStack *st, int pr, void *arg)
if (st->l3.debug & L3_DEB_STATE) {
sprintf(tmp, "up1tr6%sstate %d mt %x",
(pr == DL_DATA) ? " " : "(broadcast) ",
- st->l3.state, mt);
+ proc->state, mt);
l3_debug(st, tmp);
}
- datastln1[i].rout(st, pr, skb);
+ datastln1[i].rout(proc, pr, skb);
}
}
}
@@ -749,26 +811,44 @@ up1tr6(struct PStack *st, int pr, void *arg)
static void
down1tr6(struct PStack *st, int pr, void *arg)
{
- int i;
+ int i, cr;
+ struct l3_process *proc;
+ struct Channel *chan;
char tmp[80];
+ if (CC_SETUP_REQ == pr) {
+ chan = arg;
+ cr = newcallref();
+ cr |= 0x80;
+ if (!(proc = new_l3_process(st, cr))) {
+ return;
+ } else {
+ proc->chan = chan;
+ chan->proc = proc;
+ proc->para.setup = chan->setup;
+ proc->callref = cr;
+ }
+ } else {
+ proc = arg;
+ }
+
for (i = 0; i < downstl_len; i++)
if ((pr == downstl[i].primitive) &&
- ((1 << st->l3.state) & downstl[i].state))
+ ((1 << proc->state) & downstl[i].state))
break;
if (i == downstl_len) {
if (st->l3.debug & L3_DEB_STATE) {
sprintf(tmp, "down1tr6 state %d prim %d unhandled",
- st->l3.state, pr);
+ proc->state, pr);
l3_debug(st, tmp);
}
} else {
if (st->l3.debug & L3_DEB_STATE) {
sprintf(tmp, "down1tr6 state %d prim %d",
- st->l3.state, pr);
+ proc->state, pr);
l3_debug(st, tmp);
}
- downstl[i].rout(st, pr, arg);
+ downstl[i].rout(proc, pr, arg);
}
}
@@ -777,20 +857,10 @@ setstack_1tr6(struct PStack *st)
{
char tmp[64];
- st->l4.l4l3 = down1tr6;
+ st->lli.l4l3 = down1tr6;
st->l2.l2l3 = up1tr6;
- st->l3.t303 = 4000;
- st->l3.t304 = 20000;
- st->l3.t305 = 4000;
- st->l3.t308 = 4000;
- st->l3.t310 = 120000;
- st->l3.t313 = 4000;
- st->l3.t318 = 4000;
- st->l3.t319 = 4000;
- st->l3.n_t303 = 0;
-
- if (st->l3.channr & 1) {
- strcpy(tmp, l3_1tr6_revision);
- printk(KERN_NOTICE "HiSax: 1TR6 Rev. %s\n", HiSax_getrev(tmp));
- }
+ st->l3.N303 = 0;
+
+ strcpy(tmp, l3_1tr6_revision);
+ printk(KERN_INFO "HiSax: 1TR6 Rev. %s\n", HiSax_getrev(tmp));
}
diff --git a/drivers/isdn/hisax/l3_1tr6.h b/drivers/isdn/hisax/l3_1tr6.h
index 6e2fee72f..90d08793e 100644
--- a/drivers/isdn/hisax/l3_1tr6.h
+++ b/drivers/isdn/hisax/l3_1tr6.h
@@ -1,13 +1,14 @@
-/* $Id: l3_1tr6.h,v 1.1 1996/10/13 20:03:48 keil Exp $
+/* $Id: l3_1tr6.h,v 2.0 1997/07/27 21:15:47 keil Exp $
*
* German 1TR6 D-channel protocol defines
*
* $Log: l3_1tr6.h,v $
+ * Revision 2.0 1997/07/27 21:15:47 keil
+ * New Callref based layer3
+ *
* Revision 1.1 1996/10/13 20:03:48 keil
* Initial revision
*
- *
- *
*/
#ifndef l3_1tr6
#define l3_1tr6
@@ -29,7 +30,6 @@
#define MT_N0_CLOSE 0x75
#define MT_N0_CLO_ACK 0x77
-
/*
* MsgType N1
*/
@@ -65,8 +65,6 @@
#define MT_N1_REG_REJ 0x6F
#define MT_N1_STAT 0x63
-
-
/*
* W Elemente
*/
@@ -156,5 +154,13 @@
#define CAUSE_RemoteUserResumed 0x73
#define CAUSE_UserInfoDiscarded 0x7F
+#define T303 4000
+#define T304 20000
+#define T305 4000
+#define T308 4000
+#define T310 120000
+#define T313 4000
+#define T318 4000
+#define T319 4000
#endif
diff --git a/drivers/isdn/hisax/l3dss1.c b/drivers/isdn/hisax/l3dss1.c
index d60898734..f8b97fd73 100644
--- a/drivers/isdn/hisax/l3dss1.c
+++ b/drivers/isdn/hisax/l3dss1.c
@@ -1,4 +1,4 @@
-/* $Id: l3dss1.c,v 1.15 1997/04/17 11:50:48 keil Exp $
+/* $Id: l3dss1.c,v 2.7 1998/02/12 23:08:01 keil Exp $
* EURO/DSS1 D-channel protocol
*
@@ -9,71 +9,272 @@
* Fritz Elfert
*
* $Log: l3dss1.c,v $
- * Revision 1.15 1997/04/17 11:50:48 keil
- * pa->loc was undefined, if it was not send by the exchange
- *
- * Revision 1.14 1997/04/06 22:54:20 keil
- * Using SKB's
- *
- * Revision 1.13 1997/03/13 20:37:28 keil
- * CLIR and channel request added
- *
- * Revision 1.12 1997/02/17 00:34:26 keil
- * Bugfix: Wrong cause delivered
- *
- * Revision 1.11 1997/02/16 12:12:47 fritz
- * Bugfix: SI2 was nont initialized on incoming calls.
- *
- * Revision 1.10 1997/02/11 01:37:24 keil
- * Changed setup-interface (incoming and outgoing)
- *
- * Revision 1.9 1997/01/27 23:20:52 keil
- * report revision only ones
+ * Revision 2.7 1998/02/12 23:08:01 keil
+ * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
*
- * Revision 1.8 1997/01/21 22:29:41 keil
- * new statemachine; L3 timers
+ * Revision 2.6 1998/02/03 23:26:35 keil
+ * V110 extensions from Thomas Pfeiffer
*
- * Revision 1.7 1996/12/14 21:06:59 keil
- * additional states for CC_REJECT
+ * Revision 2.5 1998/02/02 13:34:28 keil
+ * Support australian Microlink net and german AOCD
*
- * Revision 1.6 1996/12/08 22:59:16 keil
- * fixed calling party number without octet 3a
+ * Revision 2.4 1997/11/06 17:12:25 keil
+ * KERN_NOTICE --> KERN_INFO
*
- * Revision 1.5 1996/12/08 19:53:31 keil
- * fixes from Pekka Sarnila
+ * Revision 2.3 1997/10/29 19:03:01 keil
+ * changes for 2.1
*
- * Revision 1.4 1996/11/05 19:44:36 keil
- * some fixes from Henner Eisen
+ * Revision 2.2 1997/08/07 17:44:36 keil
+ * Fix RESTART
*
- * Revision 1.3 1996/10/30 10:18:01 keil
- * bugfixes in debugging output
+ * Revision 2.1 1997/08/03 14:36:33 keil
+ * Implement RESTART procedure
*
- * Revision 1.2 1996/10/27 22:15:16 keil
- * bugfix reject handling
+ * Revision 2.0 1997/07/27 21:15:43 keil
+ * New Callref based layer3
*
- * Revision 1.1 1996/10/13 20:04:55 keil
- * Initial revision
+ * Revision 1.17 1997/06/26 11:11:46 keil
+ * SET_SKBFREE now on creation of a SKB
*
+ * Revision 1.15 1997/04/17 11:50:48 keil
+ * pa->loc was undefined, if it was not send by the exchange
*
+ * Old log removed /KKe
*
*/
#define __NO_VERSION__
#include "hisax.h"
#include "isdnl3.h"
+#include "l3dss1.h"
#include <linux/ctype.h>
extern char *HiSax_getrev(const char *revision);
-const char *dss1_revision = "$Revision: 1.15 $";
+const char *dss1_revision = "$Revision: 2.7 $";
+
+#define EXT_BEARER_CAPS 1
#define MsgHead(ptr, cref, mty) \
*ptr++ = 0x8; \
*ptr++ = 0x1; \
- *ptr++ = cref; \
+ *ptr++ = cref^0x80; \
*ptr++ = mty
+
+#ifdef HISAX_DE_AOC
static void
-l3dss1_message(struct PStack *st, u_char mt)
+l3dss1_parse_facility(struct l3_process *pc, u_char *p)
+{
+ int qd_len = 0;
+ char tmp[32];
+
+ p++;
+ qd_len = *p++;
+ if (qd_len == 0) {
+ l3_debug(pc->st, "qd_len == 0");
+ return;
+ }
+ if((*p & 0x1F) != 0x11) { /* Service discriminator, supplementary service */
+ l3_debug(pc->st, "supplementary service != 0x11");
+ return;
+ }
+ while(qd_len > 0 && !(*p & 0x80)) { /* extension ? */
+ p++; qd_len--;
+ }
+ if(qd_len < 2) {
+ l3_debug(pc->st, "qd_len < 2");
+ return;
+ }
+ p++; qd_len--;
+ if((*p & 0xE0) != 0xA0) { /* class and form */
+ l3_debug(pc->st, "class and form != 0xA0");
+ return;
+ }
+ switch(*p & 0x1F) { /* component tag */
+ case 1: /* invoke */
+ {
+ unsigned char nlen, ilen;
+ int ident;
+
+ p++; qd_len--;
+ if(qd_len < 1) {
+ l3_debug(pc->st, "qd_len < 1");
+ break;
+ }
+ if(*p & 0x80) { /* length format */
+ l3_debug(pc->st, "*p & 0x80 length format");
+ break;
+ }
+ nlen = *p++; qd_len--;
+ if(qd_len < nlen) {
+ l3_debug(pc->st, "qd_len < nlen");
+ return;
+ }
+ qd_len -= nlen;
+
+ if(nlen < 2) {
+ l3_debug(pc->st, "nlen < 2");
+ return;
+ }
+ if(*p != 0x02) { /* invoke identifier tag */
+ l3_debug(pc->st, "invoke identifier tag !=0x02");
+ return;
+ }
+ p++; nlen--;
+ if(*p & 0x80) { /* length format */
+ l3_debug(pc->st, "*p & 0x80 length format 2");
+ break;
+ }
+ ilen = *p++; nlen--;
+ if(ilen > nlen || ilen == 0) {
+ l3_debug(pc->st, "ilen > nlen || ilen == 0");
+ return;
+ }
+ nlen -= ilen;
+ ident = 0;
+ while(ilen > 0) {
+ ident = (ident << 8) | (*p++ & 0xFF); /* invoke identifier */
+ ilen--;
+ }
+
+ if(nlen < 2) {
+ l3_debug(pc->st, "nlen < 2 22");
+ return;
+ }
+ if(*p != 0x02) { /* operation value */
+ l3_debug(pc->st, "operation value !=0x02");
+ return;
+ }
+ p++; nlen--;
+ ilen = *p++; nlen--;
+ if(ilen > nlen || ilen == 0) {
+ l3_debug(pc->st, "ilen > nlen || ilen == 0 22");
+ return;
+ }
+ nlen -= ilen;
+ ident = 0;
+ while(ilen > 0) {
+ ident = (ident << 8) | (*p++ & 0xFF);
+ ilen--;
+ }
+
+ #define FOO1(s,a,b) \
+ while(nlen > 1) { \
+ int ilen = p[1]; \
+ if(nlen < ilen+2) { \
+ l3_debug(pc->st, "FOO1 nlen < ilen+2"); \
+ return; \
+ } \
+ nlen -= ilen+2; \
+ if((*p & 0xFF) == (a)) { \
+ int nlen = ilen; \
+ p += 2; \
+ b; \
+ } else { \
+ p += ilen+2; \
+ } \
+ }
+
+ switch(ident) {
+ default:
+ break;
+ case 0x22: /* during */
+ FOO1("1A",0x30,FOO1("1C",0xA1,FOO1("1D",0x30,FOO1("1E",0x02,({
+ ident = 0;
+ while(ilen > 0) {
+ ident = (ident<<8) | *p++;
+ ilen--;
+ }
+ if (ident > pc->para.chargeinfo) {
+ pc->para.chargeinfo = ident;
+ pc->st->l3.l3l4(pc, CC_INFO_CHARGE, NULL);
+ }
+ if (pc->st->l3.debug & L3_DEB_CHARGE) {
+ if (*(p+2) == 0) {
+ sprintf(tmp, "charging info during %d", pc->para.chargeinfo);
+ l3_debug(pc->st, tmp);
+ }
+ else {
+ sprintf(tmp, "charging info final %d", pc->para.chargeinfo);
+ l3_debug(pc->st, tmp);
+ }
+ }
+ })))))
+ break;
+ case 0x24: /* final */
+ FOO1("2A",0x30,FOO1("2B",0x30,FOO1("2C",0xA1,FOO1("2D",0x30,FOO1("2E",0x02,({
+ ident = 0;
+ while(ilen > 0) {
+ ident = (ident<<8) | *p++;
+ ilen--;
+ }
+ if (ident > pc->para.chargeinfo) {
+ pc->para.chargeinfo = ident;
+ pc->st->l3.l3l4(pc, CC_INFO_CHARGE, NULL);
+ }
+ if (pc->st->l3.debug & L3_DEB_CHARGE) {
+ sprintf(tmp, "charging info final %d", pc->para.chargeinfo);
+ l3_debug(pc->st, tmp);
+ }
+ }))))))
+ break;
+ }
+ #undef FOO1
+
+ }
+ break;
+ case 2: /* return result */
+ l3_debug(pc->st, "return result break");
+ break;
+ case 3: /* return error */
+ l3_debug(pc->st, "return error break");
+ break;
+ default:
+ l3_debug(pc->st, "default break");
+ break;
+ }
+}
+#endif
+
+static int
+l3dss1_check_messagetype_validity(int mt) {
+/* verify if a message type exists */
+ switch(mt) {
+ case MT_ALERTING:
+ case MT_CALL_PROCEEDING:
+ case MT_CONNECT:
+ case MT_CONNECT_ACKNOWLEDGE:
+ case MT_PROGRESS:
+ case MT_SETUP:
+ case MT_SETUP_ACKNOWLEDGE:
+ case MT_RESUME:
+ case MT_RESUME_ACKNOWLEDGE:
+ case MT_RESUME_REJECT:
+ case MT_SUSPEND:
+ case MT_SUSPEND_ACKNOWLEDGE:
+ case MT_SUSPEND_REJECT:
+ case MT_USER_INFORMATION:
+ case MT_DISCONNECT:
+ case MT_RELEASE:
+ case MT_RELEASE_COMPLETE:
+ case MT_RESTART:
+ case MT_RESTART_ACKNOWLEDGE:
+ case MT_SEGMENT:
+ case MT_CONGESTION_CONTROL:
+ case MT_INFORMATION:
+ case MT_FACILITY:
+ case MT_NOTIFY:
+ case MT_STATUS:
+ case MT_STATUS_ENQUIRY:
+ return(1);
+ default:
+ return(0);
+ }
+ return(0);
+}
+
+static void
+l3dss1_message(struct l3_process *pc, u_char mt)
{
struct sk_buff *skb;
u_char *p;
@@ -81,63 +282,226 @@ l3dss1_message(struct PStack *st, u_char mt)
if (!(skb = l3_alloc_skb(4)))
return;
p = skb_put(skb, 4);
- MsgHead(p, st->l3.callref, mt);
- st->l3.l3l2(st, DL_DATA, skb);
+ MsgHead(p, pc->callref, mt);
+ pc->st->l3.l3l2(pc->st, DL_DATA, skb);
}
static void
-l3dss1_release_req(struct PStack *st, u_char pr, void *arg)
+l3dss1_release_req(struct l3_process *pc, u_char pr, void *arg)
{
- StopAllL3Timer(st);
- newl3state(st, 19);
- l3dss1_message(st, MT_RELEASE);
- L3AddTimer(&st->l3.timer, st->l3.t308, CC_T308_1);
+ StopAllL3Timer(pc);
+ newl3state(pc, 19);
+ l3dss1_message(pc, MT_RELEASE);
+ L3AddTimer(&pc->timer, T308, CC_T308_1);
}
static void
-l3dss1_release_cmpl(struct PStack *st, u_char pr, void *arg)
+l3dss1_release_cmpl(struct l3_process *pc, u_char pr, void *arg)
{
u_char *p;
struct sk_buff *skb = arg;
int cause = -1;
p = skb->data;
- st->pa->loc = 0;
+ pc->para.loc = 0;
if ((p = findie(p, skb->len, IE_CAUSE, 0))) {
p++;
if (*p++ == 2)
- st->pa->loc = *p++;
+ pc->para.loc = *p++;
cause = *p & 0x7f;
}
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
- StopAllL3Timer(st);
- st->pa->cause = cause;
- newl3state(st, 0);
- st->l3.l3l4(st, CC_RELEASE_CNF, NULL);
+ StopAllL3Timer(pc);
+ pc->para.cause = cause;
+ newl3state(pc, 0);
+ pc->st->l3.l3l4(pc, CC_RELEASE_CNF, NULL);
+ release_l3_process(pc);
+}
+
+#ifdef EXT_BEARER_CAPS
+
+u_char *EncodeASyncParams(u_char *p, u_char si2)
+{ // 7c 06 88 90 21 42 00 bb
+
+ p[0] = p[1] = 0; p[2] = 0x80;
+ if (si2 & 32) // 7 data bits
+ p[2] += 16;
+ else // 8 data bits
+ p[2] +=24;
+
+ if (si2 & 16) // 2 stop bits
+ p[2] += 96;
+ else // 1 stop bit
+ p[2] = 32;
+
+ if (si2 & 8) // even parity
+ p[2] += 2;
+ else // no parity
+ p[2] += 3;
+
+ switch (si2 & 0x07)
+ {
+ case 0: p[0] = 66; // 1200 bit/s
+ break;
+ case 1: p[0] = 88; // 1200/75 bit/s
+ break;
+ case 2: p[0] = 87; // 75/1200 bit/s
+ break;
+ case 3: p[0] = 67; // 2400 bit/s
+ break;
+ case 4: p[0] = 69; // 4800 bit/s
+ break;
+ case 5: p[0] = 72; // 9600 bit/s
+ break;
+ case 6: p[0] = 73; // 14400 bit/s
+ break;
+ case 7: p[0] = 75; // 19200 bit/s
+ break;
+ }
+ return p+3;
+}
+
+u_char EncodeSyncParams(u_char si2, u_char ai)
+{
+
+ switch (si2)
+ {
+ case 0: return ai + 2; // 1200 bit/s
+ case 1: return ai + 24; // 1200/75 bit/s
+ case 2: return ai + 23; // 75/1200 bit/s
+ case 3: return ai + 3; // 2400 bit/s
+ case 4: return ai + 5; // 4800 bit/s
+ case 5: return ai + 8; // 9600 bit/s
+ case 6: return ai + 9; // 14400 bit/s
+ case 7: return ai + 11; // 19200 bit/s
+ case 8: return ai + 14; // 48000 bit/s
+ case 9: return ai + 15; // 56000 bit/s
+ case 15: return ai + 40; // negotiate bit/s
+ default: break;
+ }
+ return ai;
+}
+
+
+static u_char DecodeASyncParams(u_char si2, u_char *p)
+{ u_char info;
+
+ switch (p[5])
+ {
+ case 66: // 1200 bit/s
+ break; // si2 bleibt gleich
+ case 88: // 1200/75 bit/s
+ si2 += 1;
+ break;
+ case 87: // 75/1200 bit/s
+ si2 += 2;
+ break;
+ case 67: // 2400 bit/s
+ si2 += 3;
+ break;
+ case 69: // 4800 bit/s
+ si2 += 4;
+ break;
+ case 72: // 9600 bit/s
+ si2 += 5;
+ break;
+ case 73: // 14400 bit/s
+ si2 += 6;
+ break;
+ case 75: // 19200 bit/s
+ si2 += 7;
+ break;
+ }
+
+ info = p[7] & 0x7f;
+ if ((info & 16) && (!(info & 8))) // 7 data bits
+ si2 += 32; // else 8 data bits
+ if ((info & 96) == 96) // 2 stop bits
+ si2 += 16; // else 1 stop bit
+ if ((info & 2) && (!(info & 1))) // even parity
+ si2 += 8; // else no parity
+
+ return si2;
+}
+
+
+static u_char DecodeSyncParams(u_char si2, u_char info)
+{
+ info &= 0x7f;
+ switch (info)
+ {
+ case 40: // bit/s aushandeln --- hat nicht geklappt, ai wird 165 statt 175!
+ return si2 + 15;
+ case 15: // 56000 bit/s --- hat nicht geklappt, ai wird 0 statt 169 !
+ return si2 + 9;
+ case 14: // 48000 bit/s
+ return si2 + 8;
+ case 11: // 19200 bit/s
+ return si2 + 7;
+ case 9: // 14400 bit/s
+ return si2 + 6;
+ case 8: // 9600 bit/s
+ return si2 + 5;
+ case 5: // 4800 bit/s
+ return si2 + 4;
+ case 3: // 2400 bit/s
+ return si2 + 3;
+ case 23: // 75/1200 bit/s
+ return si2 + 2;
+ case 24: // 1200/75 bit/s
+ return si2 + 1;
+ default: // 1200 bit/s
+ return si2;
+ }
}
+static u_char DecodeSI2(struct sk_buff *skb)
+{ u_char *p; //, *pend=skb->data + skb->len;
+
+ if ((p = findie(skb->data, skb->len, 0x7c, 0)))
+ {
+ switch (p[4] & 0x0f)
+ {
+ case 0x01: if (p[1] == 0x04) // sync. Bitratenadaption
+ return DecodeSyncParams(160, p[5]); // V.110/X.30
+ else if (p[1] == 0x06) // async. Bitratenadaption
+ return DecodeASyncParams(192, p); // V.110/X.30
+ break;
+ case 0x08: // if (p[5] == 0x02) // sync. Bitratenadaption
+ return DecodeSyncParams(176, p[5]); // V.120
+ break;
+ }
+ }
+ return 0;
+}
+
+#endif
+
+
static void
-l3dss1_setup_req(struct PStack *st, u_char pr,
+l3dss1_setup_req(struct l3_process *pc, u_char pr,
void *arg)
{
struct sk_buff *skb;
u_char tmp[128];
u_char *p = tmp;
u_char channel = 0;
- u_char screen = 0;
+ u_char screen = 0x80;
u_char *teln;
u_char *msn;
+ u_char *sub;
+ u_char *sp;
int l;
- st->l3.callref = st->pa->callref;
- MsgHead(p, st->l3.callref, MT_SETUP);
+ MsgHead(p, pc->callref, MT_SETUP);
/*
* Set Bearer Capability, Map info from 1TR6-convention to EDSS1
*/
+#ifdef HISAX_EURO_SENDCOMPLETE
*p++ = 0xa1; /* complete indicator */
- switch (st->pa->setup.si1) {
+#endif
+ switch (pc->para.setup.si1) {
case 1: /* Telephony */
*p++ = 0x4; /* BC-IE-code */
*p++ = 0x3; /* Length */
@@ -157,7 +521,7 @@ l3dss1_setup_req(struct PStack *st, u_char pr,
/*
* What about info2? Mapping to High-Layer-Compatibility?
*/
- teln = st->pa->setup.phone;
+ teln = pc->para.setup.phone;
if (*teln) {
/* parse number for special things */
if (!isdigit(*teln)) {
@@ -179,19 +543,28 @@ l3dss1_setup_req(struct PStack *st, u_char pr,
screen = 0x80;
break;
default:
- if (st->l3.debug & L3_DEB_WARN)
- l3_debug(st, "Wrong MSN Code");
+ if (pc->debug & L3_DEB_WARN)
+ l3_debug(pc->st, "Wrong MSN Code");
break;
}
teln++;
}
}
if (channel) {
- *p++ = 0x18; /* channel indicator */
+ *p++ = IE_CHANNEL_ID;
*p++ = 1;
*p++ = channel;
}
- msn = st->pa->setup.eazmsn;
+ msn = pc->para.setup.eazmsn;
+ sub = NULL;
+ sp = msn;
+ while (*sp) {
+ if ('.' == *sp) {
+ sub = sp;
+ *sp = 0;
+ } else
+ sp++;
+ }
if (*msn) {
*p++ = 0x6c;
*p++ = strlen(msn) + (screen ? 2 : 1);
@@ -204,241 +577,372 @@ l3dss1_setup_req(struct PStack *st, u_char pr,
while (*msn)
*p++ = *msn++ & 0x7f;
}
+ if (sub) {
+ *sub++ = '.';
+ *p++ = 0x6d; /* Calling party subaddress */
+ *p++ = strlen(sub) + 2;
+ *p++ = 0x80; /* NSAP coded */
+ *p++ = 0x50; /* local IDI format */
+ while (*sub)
+ *p++ = *sub++ & 0x7f;
+ }
+ sub = NULL;
+ sp = teln;
+ while (*sp) {
+ if ('.' == *sp) {
+ sub = sp;
+ *sp = 0;
+ } else
+ sp++;
+ }
*p++ = 0x70;
*p++ = strlen(teln) + 1;
/* Classify as AnyPref. */
*p++ = 0x81; /* Ext = '1'B, Type = '000'B, Plan = '0001'B. */
-
while (*teln)
*p++ = *teln++ & 0x7f;
+ if (sub) {
+ *sub++ = '.';
+ *p++ = 0x71; /* Called party subaddress */
+ *p++ = strlen(sub) + 2;
+ *p++ = 0x80; /* NSAP coded */
+ *p++ = 0x50; /* local IDI format */
+ while (*sub)
+ *p++ = *sub++ & 0x7f;
+ }
+
+#ifdef EXT_BEARER_CAPS
+ if ((pc->para.setup.si2 >= 160) && (pc->para.setup.si2 <= 175))
+ { // sync. Bitratenadaption, V.110/X.30
+ *p++ = 0x7c; *p++ = 0x04; *p++ = 0x88; *p++ = 0x90; *p++ = 0x21;
+ *p++ = EncodeSyncParams(pc->para.setup.si2 - 160, 0x80);
+ }
+ else if ((pc->para.setup.si2 >= 176) && (pc->para.setup.si2 <= 191))
+ { // sync. Bitratenadaption, V.120
+ *p++ = 0x7c; *p++ = 0x05; *p++ = 0x88; *p++ = 0x90; *p++ = 0x28;
+ *p++ = EncodeSyncParams(pc->para.setup.si2 - 176, 0);
+ *p++ = 0x82;
+ }
+ else if (pc->para.setup.si2 >= 192)
+ { // async. Bitratenadaption, V.110/X.30
+ *p++ = 0x7c; *p++ = 0x06; *p++ = 0x88; *p++ = 0x90; *p++ = 0x21;
+ p = EncodeASyncParams(p, pc->para.setup.si2 - 192);
+ }
+#endif
l = p - tmp;
if (!(skb = l3_alloc_skb(l)))
return;
memcpy(skb_put(skb, l), tmp, l);
- L3DelTimer(&st->l3.timer);
- L3AddTimer(&st->l3.timer, st->l3.t303, CC_T303);
- newl3state(st, 1);
- st->l3.l3l2(st, DL_DATA, skb);
-
+ L3DelTimer(&pc->timer);
+ L3AddTimer(&pc->timer, T303, CC_T303);
+ newl3state(pc, 1);
+ pc->st->l3.l3l2(pc->st, DL_DATA, skb);
}
static void
-l3dss1_call_proc(struct PStack *st, u_char pr, void *arg)
+l3dss1_call_proc(struct l3_process *pc, u_char pr, void *arg)
{
u_char *p;
struct sk_buff *skb = arg;
- L3DelTimer(&st->l3.timer);
+ L3DelTimer(&pc->timer);
p = skb->data;
- if ((p = findie(p, skb->len, 0x18, 0))) {
- st->pa->bchannel = p[2] & 0x3;
- if ((!st->pa->bchannel) && (st->l3.debug & L3_DEB_WARN))
- l3_debug(st, "setup answer without bchannel");
- } else if (st->l3.debug & L3_DEB_WARN)
- l3_debug(st, "setup answer without bchannel");
- SET_SKB_FREE(skb);
+ if ((p = findie(p, skb->len, IE_CHANNEL_ID, 0))) {
+ pc->para.bchannel = p[2] & 0x3;
+ if ((!pc->para.bchannel) && (pc->debug & L3_DEB_WARN))
+ l3_debug(pc->st, "setup answer without bchannel");
+ } else if (pc->debug & L3_DEB_WARN)
+ l3_debug(pc->st, "setup answer without bchannel");
dev_kfree_skb(skb);
- newl3state(st, 3);
- L3AddTimer(&st->l3.timer, st->l3.t310, CC_T310);
- st->l3.l3l4(st, CC_PROCEEDING_IND, NULL);
+ newl3state(pc, 3);
+ L3AddTimer(&pc->timer, T310, CC_T310);
+ pc->st->l3.l3l4(pc, CC_PROCEEDING_IND, NULL);
}
static void
-l3dss1_setup_ack(struct PStack *st, u_char pr, void *arg)
+l3dss1_setup_ack(struct l3_process *pc, u_char pr, void *arg)
{
u_char *p;
struct sk_buff *skb = arg;
- L3DelTimer(&st->l3.timer);
+ L3DelTimer(&pc->timer);
p = skb->data;
- if ((p = findie(p, skb->len, 0x18, 0))) {
- st->pa->bchannel = p[2] & 0x3;
- if ((!st->pa->bchannel) && (st->l3.debug & L3_DEB_WARN))
- l3_debug(st, "setup answer without bchannel");
- } else if (st->l3.debug & L3_DEB_WARN)
- l3_debug(st, "setup answer without bchannel");
- SET_SKB_FREE(skb);
+ if ((p = findie(p, skb->len, IE_CHANNEL_ID, 0))) {
+ pc->para.bchannel = p[2] & 0x3;
+ if ((!pc->para.bchannel) && (pc->debug & L3_DEB_WARN))
+ l3_debug(pc->st, "setup answer without bchannel");
+ } else if (pc->debug & L3_DEB_WARN)
+ l3_debug(pc->st, "setup answer without bchannel");
dev_kfree_skb(skb);
- newl3state(st, 2);
- L3AddTimer(&st->l3.timer, st->l3.t304, CC_T304);
- st->l3.l3l4(st, CC_MORE_INFO, NULL);
+ newl3state(pc, 2);
+ L3AddTimer(&pc->timer, T304, CC_T304);
+ pc->st->l3.l3l4(pc, CC_MORE_INFO, NULL);
}
static void
-l3dss1_disconnect(struct PStack *st, u_char pr, void *arg)
+l3dss1_disconnect(struct l3_process *pc, u_char pr, void *arg)
{
u_char *p;
struct sk_buff *skb = arg;
int cause = -1;
- StopAllL3Timer(st);
+ StopAllL3Timer(pc);
p = skb->data;
- st->pa->loc = 0;
+ pc->para.loc = 0;
if ((p = findie(p, skb->len, IE_CAUSE, 0))) {
p++;
if (*p++ == 2)
- st->pa->loc = *p++;
+ pc->para.loc = *p++;
cause = *p & 0x7f;
}
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
- newl3state(st, 12);
- st->pa->cause = cause;
- st->l3.l3l4(st, CC_DISCONNECT_IND, NULL);
+ newl3state(pc, 12);
+ pc->para.cause = cause;
+ pc->st->l3.l3l4(pc, CC_DISCONNECT_IND, NULL);
}
static void
-l3dss1_connect(struct PStack *st, u_char pr, void *arg)
+l3dss1_connect(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb = arg;
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
- L3DelTimer(&st->l3.timer); /* T310 */
- newl3state(st, 10);
- st->l3.l3l4(st, CC_SETUP_CNF, NULL);
+ L3DelTimer(&pc->timer); /* T310 */
+ newl3state(pc, 10);
+ pc->para.chargeinfo = 0;
+ pc->st->l3.l3l4(pc, CC_SETUP_CNF, NULL);
}
static void
-l3dss1_alerting(struct PStack *st, u_char pr, void *arg)
+l3dss1_alerting(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb = arg;
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
- L3DelTimer(&st->l3.timer); /* T304 */
- newl3state(st, 4);
- st->l3.l3l4(st, CC_ALERTING_IND, NULL);
+ L3DelTimer(&pc->timer); /* T304 */
+ newl3state(pc, 4);
+ pc->st->l3.l3l4(pc, CC_ALERTING_IND, NULL);
}
static void
-l3dss1_setup(struct PStack *st, u_char pr, void *arg)
+l3dss1_msg_without_setup(struct l3_process *pc, u_char pr, void *arg)
{
- u_char *p;
+ /* This routine is called if here was no SETUP made (checks in dss1up and in
+ * l3dss1_setup) and a RELEASE_COMPLETE have to be sent with an error code
+ * It is called after it is veryfied that Layer2 is up.
+ * The cause value is allready in pc->para.cause
+ * MT_STATUS_ENQUIRE in the NULL state is handled too
+ */
+ u_char tmp[16];
+ u_char *p=tmp;
+ int l;
+ struct sk_buff *skb;
+
+ switch (pc->para.cause) {
+ case 81: /* 0x51 invalid callreference */
+ case 96: /* 0x60 mandory IE missing */
+ case 101: /* 0x65 incompatible Callstate */
+ MsgHead(p, pc->callref, MT_RELEASE_COMPLETE);
+ *p++ = IE_CAUSE;
+ *p++ = 0x2;
+ *p++ = 0x80;
+ *p++ = pc->para.cause | 0x80;
+ break;
+ default:
+ printk(KERN_ERR "HiSax internal error l3dss1_msg_without_setup\n");
+ return;
+ }
+ l = p - tmp;
+ if (!(skb = l3_alloc_skb(l)))
+ return;
+ memcpy(skb_put(skb, l), tmp, l);
+ pc->st->l3.l3l2(pc->st, DL_DATA, skb);
+ release_l3_process(pc);
+}
+
+static void
+l3dss1_setup(struct l3_process *pc, u_char pr, void *arg)
+{
+ u_char *p, *ptmp[8];
+ int i;
int bcfound = 0;
char tmp[80];
struct sk_buff *skb = arg;
+ /* ETS 300-104 1.3.4 and 1.3.5
+ * we need to detect unknown inform. element from 0 to 7
+ */
p = skb->data;
- st->pa->callref = getcallref(p);
- st->l3.callref = 0x80 + st->pa->callref;
+ for(i = 0; i < 8; i++)
+ ptmp[i] = skb->data;
+ if (findie(ptmp[1], skb->len, 0x01, 0)
+ || findie(ptmp[2], skb->len, 0x02, 0)
+ || findie(ptmp[3], skb->len, 0x03, 0)
+ || findie(ptmp[5], skb->len, 0x05, 0)
+ || findie(ptmp[6], skb->len, 0x06, 0)
+ || findie(ptmp[7], skb->len, 0x07, 0)) {
+ /* if ie is < 8 and not 0 nor 4, send RELEASE_COMPLETE
+ * cause 0x60
+ */
+ pc->para.cause = 0x60;
+ dev_kfree_skb(skb);
+ if (pc->state == 0)
+ pc->st->l3.l3l4(pc, CC_ESTABLISH, NULL);
+ else
+ l3dss1_msg_without_setup(pc, pr, NULL);
+ return;
+ }
/*
* Channel Identification
*/
p = skb->data;
- if ((p = findie(p, skb->len, 0x18, 0))) {
- st->pa->bchannel = p[2] & 0x3;
- if (st->pa->bchannel)
+ if ((p = findie(p, skb->len, IE_CHANNEL_ID, 0))) {
+ pc->para.bchannel = p[2] & 0x3;
+ if (pc->para.bchannel)
bcfound++;
- else if (st->l3.debug & L3_DEB_WARN)
- l3_debug(st, "setup without bchannel");
- } else if (st->l3.debug & L3_DEB_WARN)
- l3_debug(st, "setup without bchannel");
+ else if (pc->debug & L3_DEB_WARN)
+ l3_debug(pc->st, "setup without bchannel");
+ } else if (pc->debug & L3_DEB_WARN)
+ l3_debug(pc->st, "setup without bchannel");
/*
* Bearer Capabilities
*/
p = skb->data;
if ((p = findie(p, skb->len, 0x04, 0))) {
- st->pa->setup.si2 = 0;
+ pc->para.setup.si2 = 0;
switch (p[2] & 0x1f) {
case 0x00:
/* Speech */
case 0x10:
/* 3.1 Khz audio */
- st->pa->setup.si1 = 1;
+ pc->para.setup.si1 = 1;
break;
case 0x08:
/* Unrestricted digital information */
- st->pa->setup.si1 = 7;
+ pc->para.setup.si1 = 7;
+/* JIM, 05.11.97 I wanna set service indicator 2 */
+#ifdef EXT_BEARER_CAPS
+ pc->para.setup.si2 = DecodeSI2(skb);
+ printk(KERN_DEBUG "HiSax: SI=%d, AI=%d\n",
+ pc->para.setup.si1, pc->para.setup.si2);
+#endif
break;
case 0x09:
/* Restricted digital information */
- st->pa->setup.si1 = 2;
+ pc->para.setup.si1 = 2;
break;
case 0x11:
/* Unrestr. digital information with tones/announcements */
- st->pa->setup.si1 = 3;
+ pc->para.setup.si1 = 3;
break;
case 0x18:
/* Video */
- st->pa->setup.si1 = 4;
+ pc->para.setup.si1 = 4;
break;
default:
- st->pa->setup.si1 = 0;
+ pc->para.setup.si1 = 0;
}
- } else if (st->l3.debug & L3_DEB_WARN)
- l3_debug(st, "setup without bearer capabilities");
+ } else {
+ if (pc->debug & L3_DEB_WARN)
+ l3_debug(pc->st, "setup without bearer capabilities");
+ /* ETS 300-104 1.3.3 */
+ pc->para.cause = 0x60;
+ dev_kfree_skb(skb);
+ if (pc->state == 0)
+ pc->st->l3.l3l4(pc, CC_ESTABLISH, NULL);
+ else
+ l3dss1_msg_without_setup(pc, pr, NULL);
+ return;
+ }
p = skb->data;
if ((p = findie(p, skb->len, 0x70, 0)))
- iecpy(st->pa->setup.eazmsn, p, 1);
+ iecpy(pc->para.setup.eazmsn, p, 1);
else
- st->pa->setup.eazmsn[0] = 0;
+ pc->para.setup.eazmsn[0] = 0;
p = skb->data;
+ if ((p = findie(p, skb->len, 0x71, 0))) {
+ /* Called party subaddress */
+ if ((p[1]>=2) && (p[2]==0x80) && (p[3]==0x50)) {
+ tmp[0]='.';
+ iecpy(&tmp[1], p, 2);
+ strcat(pc->para.setup.eazmsn, tmp);
+ } else if (pc->debug & L3_DEB_WARN)
+ l3_debug(pc->st, "wrong called subaddress");
+ }
+ p = skb->data;
if ((p = findie(p, skb->len, 0x6c, 0))) {
- st->pa->setup.plan = p[2];
+ pc->para.setup.plan = p[2];
if (p[2] & 0x80) {
- iecpy(st->pa->setup.phone, p, 1);
- st->pa->setup.screen = 0;
+ iecpy(pc->para.setup.phone, p, 1);
+ pc->para.setup.screen = 0;
} else {
- iecpy(st->pa->setup.phone, p, 2);
- st->pa->setup.screen = p[3];
+ iecpy(pc->para.setup.phone, p, 2);
+ pc->para.setup.screen = p[3];
}
} else {
- st->pa->setup.phone[0] = 0;
- st->pa->setup.plan = 0;
- st->pa->setup.screen = 0;
+ pc->para.setup.phone[0] = 0;
+ pc->para.setup.plan = 0;
+ pc->para.setup.screen = 0;
+ }
+ p = skb->data;
+ if ((p = findie(p, skb->len, 0x6d, 0))) {
+ /* Calling party subaddress */
+ if ((p[1]>=2) && (p[2]==0x80) && (p[3]==0x50)) {
+ tmp[0]='.';
+ iecpy(&tmp[1], p, 2);
+ strcat(pc->para.setup.phone, tmp);
+ } else if (pc->debug & L3_DEB_WARN)
+ l3_debug(pc->st, "wrong calling subaddress");
}
- SET_SKB_FREE(skb);
+
dev_kfree_skb(skb);
if (bcfound) {
- if ((st->pa->setup.si1 != 7) && (st->l3.debug & L3_DEB_WARN)) {
+ if ((pc->para.setup.si1 != 7) && (pc->debug & L3_DEB_WARN)) {
sprintf(tmp, "non-digital call: %s -> %s",
- st->pa->setup.phone,
- st->pa->setup.eazmsn);
- l3_debug(st, tmp);
+ pc->para.setup.phone, pc->para.setup.eazmsn);
+ l3_debug(pc->st, tmp);
}
- newl3state(st, 6);
- st->l3.l3l4(st, CC_SETUP_IND, NULL);
- }
+ newl3state(pc, 6);
+ pc->st->l3.l3l4(pc, CC_SETUP_IND, NULL);
+ } else
+ release_l3_process(pc);
}
static void
-l3dss1_reset(struct PStack *st, u_char pr, void *arg)
+l3dss1_reset(struct l3_process *pc, u_char pr, void *arg)
{
- StopAllL3Timer(st);
- newl3state(st, 0);
+ release_l3_process(pc);
}
static void
-l3dss1_setup_rsp(struct PStack *st, u_char pr,
+l3dss1_setup_rsp(struct l3_process *pc, u_char pr,
void *arg)
{
- newl3state(st, 8);
- l3dss1_message(st, MT_CONNECT);
- L3DelTimer(&st->l3.timer);
- L3AddTimer(&st->l3.timer, st->l3.t313, CC_T313);
+ newl3state(pc, 8);
+ l3dss1_message(pc, MT_CONNECT);
+ L3DelTimer(&pc->timer);
+ L3AddTimer(&pc->timer, T313, CC_T313);
}
static void
-l3dss1_connect_ack(struct PStack *st, u_char pr, void *arg)
+l3dss1_connect_ack(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb = arg;
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
- newl3state(st, 10);
- L3DelTimer(&st->l3.timer);
- st->l3.l3l4(st, CC_SETUP_COMPLETE_IND, NULL);
+ newl3state(pc, 10);
+ L3DelTimer(&pc->timer);
+ pc->st->l3.l3l4(pc, CC_SETUP_COMPLETE_IND, NULL);
}
static void
-l3dss1_disconnect_req(struct PStack *st, u_char pr, void *arg)
+l3dss1_disconnect_req(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb;
u_char tmp[16];
@@ -446,12 +950,12 @@ l3dss1_disconnect_req(struct PStack *st, u_char pr, void *arg)
int l;
u_char cause = 0x10;
- if (st->pa->cause > 0)
- cause = st->pa->cause;
+ if (pc->para.cause > 0)
+ cause = pc->para.cause;
- StopAllL3Timer(st);
+ StopAllL3Timer(pc);
- MsgHead(p, st->l3.callref, MT_DISCONNECT);
+ MsgHead(p, pc->callref, MT_DISCONNECT);
*p++ = IE_CAUSE;
*p++ = 0x2;
@@ -462,13 +966,13 @@ l3dss1_disconnect_req(struct PStack *st, u_char pr, void *arg)
if (!(skb = l3_alloc_skb(l)))
return;
memcpy(skb_put(skb, l), tmp, l);
- newl3state(st, 11);
- st->l3.l3l2(st, DL_DATA, skb);
- L3AddTimer(&st->l3.timer, st->l3.t305, CC_T305);
+ newl3state(pc, 11);
+ pc->st->l3.l3l2(pc->st, DL_DATA, skb);
+ L3AddTimer(&pc->timer, T305, CC_T305);
}
static void
-l3dss1_reject_req(struct PStack *st, u_char pr, void *arg)
+l3dss1_reject_req(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb;
u_char tmp[16];
@@ -476,10 +980,10 @@ l3dss1_reject_req(struct PStack *st, u_char pr, void *arg)
int l;
u_char cause = 0x95;
- if (st->pa->cause > 0)
- cause = st->pa->cause;
+ if (pc->para.cause > 0)
+ cause = pc->para.cause;
- MsgHead(p, st->l3.callref, MT_RELEASE_COMPLETE);
+ MsgHead(p, pc->callref, MT_RELEASE_COMPLETE);
*p++ = IE_CAUSE;
*p++ = 0x2;
@@ -490,13 +994,14 @@ l3dss1_reject_req(struct PStack *st, u_char pr, void *arg)
if (!(skb = l3_alloc_skb(l)))
return;
memcpy(skb_put(skb, l), tmp, l);
- newl3state(st, 0);
- st->l3.l3l2(st, DL_DATA, skb);
- st->l3.l3l4(st, CC_RELEASE_IND, NULL);
+ pc->st->l3.l3l2(pc->st, DL_DATA, skb);
+ pc->st->l3.l3l4(pc, CC_RELEASE_IND, NULL);
+ newl3state(pc, 0);
+ release_l3_process(pc);
}
static void
-l3dss1_release(struct PStack *st, u_char pr, void *arg)
+l3dss1_release(struct l3_process *pc, u_char pr, void *arg)
{
u_char *p;
struct sk_buff *skb = arg;
@@ -506,38 +1011,45 @@ l3dss1_release(struct PStack *st, u_char pr, void *arg)
if ((p = findie(p, skb->len, IE_CAUSE, 0))) {
p++;
if (*p++ == 2)
- st->pa->loc = *p++;
+ pc->para.loc = *p++;
cause = *p & 0x7f;
}
- SET_SKB_FREE(skb);
+ p = skb->data;
+ if ((p = findie(p, skb->len, IE_FACILITY, 0))) {
+#ifdef HISAX_DE_AOC
+ l3dss1_parse_facility(pc,p);
+#else
+ p = NULL;
+#endif
+ }
dev_kfree_skb(skb);
- StopAllL3Timer(st);
- st->pa->cause = cause;
- newl3state(st, 0);
- l3dss1_message(st, MT_RELEASE_COMPLETE);
- st->l3.l3l4(st, CC_RELEASE_IND, NULL);
+ StopAllL3Timer(pc);
+ pc->para.cause = cause;
+ l3dss1_message(pc, MT_RELEASE_COMPLETE);
+ pc->st->l3.l3l4(pc, CC_RELEASE_IND, NULL);
+ newl3state(pc, 0);
+ release_l3_process(pc);
}
static void
-l3dss1_alert_req(struct PStack *st, u_char pr,
+l3dss1_alert_req(struct l3_process *pc, u_char pr,
void *arg)
{
- newl3state(st, 7);
- l3dss1_message(st, MT_ALERTING);
+ newl3state(pc, 7);
+ l3dss1_message(pc, MT_ALERTING);
}
static void
-l3dss1_status_enq(struct PStack *st, u_char pr, void *arg)
+l3dss1_status_enq(struct l3_process *pc, u_char pr, void *arg)
{
u_char tmp[16];
u_char *p = tmp;
int l;
struct sk_buff *skb = arg;
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
- MsgHead(p, st->l3.callref, MT_STATUS);
+ MsgHead(p, pc->callref, MT_STATUS);
*p++ = IE_CAUSE;
*p++ = 0x2;
@@ -546,42 +1058,96 @@ l3dss1_status_enq(struct PStack *st, u_char pr, void *arg)
*p++ = 0x14; /* CallState */
*p++ = 0x1;
- *p++ = st->l3.state & 0x3f;
+ *p++ = pc->state & 0x3f;
+
+ l = p - tmp;
+ if (!(skb = l3_alloc_skb(l)))
+ return;
+ memcpy(skb_put(skb, l), tmp, l);
+ pc->st->l3.l3l2(pc->st, DL_DATA, skb);
+}
+
+static void
+l3dss1_status_req(struct l3_process *pc, u_char pr, void *arg)
+{
+ /* ETS 300-104 7.4.1, 8.4.1, 10.3.1, 11.4.1, 12.4.1, 13.4.1, 14.4.1...
+ if setup has been made and a non expected message type is received, we must send MT_STATUS cause 0x62 */
+ u_char tmp[16];
+ u_char *p = tmp;
+ int l;
+ struct sk_buff *skb = arg;
+
+ dev_kfree_skb(skb);
+
+ MsgHead(p, pc->callref, MT_STATUS);
+
+ *p++ = IE_CAUSE;
+ *p++ = 0x2;
+ *p++ = 0x80;
+ *p++ = 0x62 | 0x80; /* status sending */
+
+ *p++ = 0x14; /* CallState */
+ *p++ = 0x1;
+ *p++ = pc->state & 0x3f;
l = p - tmp;
if (!(skb = l3_alloc_skb(l)))
return;
memcpy(skb_put(skb, l), tmp, l);
- st->l3.l3l2(st, DL_DATA, skb);
+ pc->st->l3.l3l2(pc->st, DL_DATA, skb);
}
static void
-l3dss1_t303(struct PStack *st, u_char pr, void *arg)
+l3dss1_release_ind(struct l3_process *pc, u_char pr, void *arg)
{
- if (st->l3.n_t303 > 0) {
- st->l3.n_t303--;
- L3DelTimer(&st->l3.timer);
- l3dss1_setup_req(st, pr, arg);
+ u_char *p;
+ struct sk_buff *skb = arg;
+ int callState = 0;
+ p = skb->data;
+
+ if ((p = findie(p, skb->len, IE_CALL_STATE, 0))) {
+ p++;
+ if (1== *p++)
+ callState = *p;
+ }
+ if(callState == 0) {
+ /* ETS 300-104 7.6.1, 8.6.1, 10.6.1... and 16.1
+ * set down layer 3 without sending any message
+ */
+ pc->st->l3.l3l4(pc, CC_RELEASE_IND, NULL);
+ newl3state(pc, 0);
+ release_l3_process(pc);
} else {
- newl3state(st, 0);
- L3DelTimer(&st->l3.timer);
- st->l3.l3l4(st, CC_NOSETUP_RSP_ERR, NULL);
- st->l3.n_t303 = 1;
+ pc->st->l3.l3l4(pc, CC_IGNORE, NULL);
}
}
static void
-l3dss1_t304(struct PStack *st, u_char pr, void *arg)
+l3dss1_t303(struct l3_process *pc, u_char pr, void *arg)
{
- L3DelTimer(&st->l3.timer);
- st->pa->cause = 0xE6;
- l3dss1_disconnect_req(st, pr, NULL);
- st->l3.l3l4(st, CC_SETUP_ERR, NULL);
+ if (pc->N303 > 0) {
+ pc->N303--;
+ L3DelTimer(&pc->timer);
+ l3dss1_setup_req(pc, pr, arg);
+ } else {
+ L3DelTimer(&pc->timer);
+ pc->st->l3.l3l4(pc, CC_NOSETUP_RSP_ERR, NULL);
+ release_l3_process(pc);
+ }
+}
+
+static void
+l3dss1_t304(struct l3_process *pc, u_char pr, void *arg)
+{
+ L3DelTimer(&pc->timer);
+ pc->para.cause = 0xE6;
+ l3dss1_disconnect_req(pc, pr, NULL);
+ pc->st->l3.l3l4(pc, CC_SETUP_ERR, NULL);
}
static void
-l3dss1_t305(struct PStack *st, u_char pr, void *arg)
+l3dss1_t305(struct l3_process *pc, u_char pr, void *arg)
{
u_char tmp[16];
u_char *p = tmp;
@@ -589,11 +1155,11 @@ l3dss1_t305(struct PStack *st, u_char pr, void *arg)
struct sk_buff *skb;
u_char cause = 0x90;
- L3DelTimer(&st->l3.timer);
- if (st->pa->cause > 0)
- cause = st->pa->cause;
+ L3DelTimer(&pc->timer);
+ if (pc->para.cause > 0)
+ cause = pc->para.cause | 0x80;
- MsgHead(p, st->l3.callref, MT_RELEASE);
+ MsgHead(p, pc->callref, MT_RELEASE);
*p++ = IE_CAUSE;
*p++ = 0x2;
@@ -604,49 +1170,180 @@ l3dss1_t305(struct PStack *st, u_char pr, void *arg)
if (!(skb = l3_alloc_skb(l)))
return;
memcpy(skb_put(skb, l), tmp, l);
- newl3state(st, 19);
- st->l3.l3l2(st, DL_DATA, skb);
- L3AddTimer(&st->l3.timer, st->l3.t308, CC_T308_1);
+ newl3state(pc, 19);
+ pc->st->l3.l3l2(pc->st, DL_DATA, skb);
+ L3AddTimer(&pc->timer, T308, CC_T308_1);
+}
+
+static void
+l3dss1_t310(struct l3_process *pc, u_char pr, void *arg)
+{
+ L3DelTimer(&pc->timer);
+ pc->para.cause = 0xE6;
+ l3dss1_disconnect_req(pc, pr, NULL);
+ pc->st->l3.l3l4(pc, CC_SETUP_ERR, NULL);
+}
+
+static void
+l3dss1_t313(struct l3_process *pc, u_char pr, void *arg)
+{
+ L3DelTimer(&pc->timer);
+ pc->para.cause = 0xE6;
+ l3dss1_disconnect_req(pc, pr, NULL);
+ pc->st->l3.l3l4(pc, CC_CONNECT_ERR, NULL);
+}
+
+static void
+l3dss1_t308_1(struct l3_process *pc, u_char pr, void *arg)
+{
+ newl3state(pc, 19);
+ L3DelTimer(&pc->timer);
+ l3dss1_message(pc, MT_RELEASE);
+ L3AddTimer(&pc->timer, T308, CC_T308_2);
+}
+
+static void
+l3dss1_t308_2(struct l3_process *pc, u_char pr, void *arg)
+{
+ L3DelTimer(&pc->timer);
+ pc->st->l3.l3l4(pc, CC_RELEASE_ERR, NULL);
+ release_l3_process(pc);
}
static void
-l3dss1_t310(struct PStack *st, u_char pr, void *arg)
+l3dss1_restart(struct l3_process *pc, u_char pr, void *arg)
{
- L3DelTimer(&st->l3.timer);
- st->pa->cause = 0xE6;
- l3dss1_disconnect_req(st, pr, NULL);
- st->l3.l3l4(st, CC_SETUP_ERR, NULL);
+ L3DelTimer(&pc->timer);
+ pc->st->l3.l3l4(pc, CC_DLRL, NULL);
+ release_l3_process(pc);
}
static void
-l3dss1_t313(struct PStack *st, u_char pr, void *arg)
+l3dss1_status(struct l3_process *pc, u_char pr, void *arg)
{
- L3DelTimer(&st->l3.timer);
- st->pa->cause = 0xE6;
- l3dss1_disconnect_req(st, pr, NULL);
- st->l3.l3l4(st, CC_CONNECT_ERR, NULL);
+ u_char *p;
+ char tmp[64], *t;
+ int l;
+ struct sk_buff *skb = arg;
+ int cause, callState;
+
+ cause = callState = -1;
+ p = skb->data;
+ t = tmp;
+ if ((p = findie(p, skb->len, IE_CAUSE, 0))) {
+ p++;
+ l = *p++;
+ t += sprintf(t,"Status CR %x Cause:", pc->callref);
+ while (l--) {
+ cause = *p;
+ t += sprintf(t," %2x",*p++);
+ }
+ } else
+ sprintf(t,"Status CR %x no Cause", pc->callref);
+ l3_debug(pc->st, tmp);
+ p = skb->data;
+ t = tmp;
+ t += sprintf(t,"Status state %x ", pc->state);
+ if ((p = findie(p, skb->len, IE_CALL_STATE, 0))) {
+ p++;
+ if (1== *p++) {
+ callState = *p;
+ t += sprintf(t,"peer state %x" , *p);
+ }
+ else
+ t += sprintf(t,"peer state len error");
+ } else
+ sprintf(t,"no peer state");
+ l3_debug(pc->st, tmp);
+ if(((cause & 0x7f) == 0x6f) && (callState == 0)) {
+ /* ETS 300-104 7.6.1, 8.6.1, 10.6.1...
+ * if received MT_STATUS with cause == 0x6f and call
+ * state == 0, then we must set down layer 3
+ */
+ l3dss1_release_ind(pc, pr, arg);
+ } else
+ dev_kfree_skb(skb);
}
static void
-l3dss1_t308_1(struct PStack *st, u_char pr, void *arg)
+l3dss1_facility(struct l3_process *pc, u_char pr, void *arg)
{
- newl3state(st, 19);
- L3DelTimer(&st->l3.timer);
- l3dss1_message(st, MT_RELEASE);
- L3AddTimer(&st->l3.timer, st->l3.t308, CC_T308_2);
+ u_char *p;
+ struct sk_buff *skb = arg;
+
+ p = skb->data;
+ if ((p = findie(p, skb->len, IE_FACILITY, 0))) {
+#ifdef HISAX_DE_AOC
+ l3dss1_parse_facility(pc,p);
+#else
+ p = NULL;
+#endif
+ }
}
+
+
static void
-l3dss1_t308_2(struct PStack *st, u_char pr, void *arg)
+l3dss1_global_restart(struct l3_process *pc, u_char pr, void *arg)
{
- newl3state(st, 0);
- L3DelTimer(&st->l3.timer);
- st->l3.l3l4(st, CC_RELEASE_ERR, NULL);
+ u_char tmp[32];
+ u_char *p;
+ u_char ri, chan=0;
+ int l;
+ struct sk_buff *skb = arg;
+ struct l3_process *up;
+
+ newl3state(pc, 2);
+ L3DelTimer(&pc->timer);
+ p = skb->data;
+ if ((p = findie(p, skb->len, IE_RESTART_IND, 0))) {
+ ri = p[2];
+ sprintf(tmp, "Restart %x", ri);
+ } else {
+ sprintf(tmp, "Restart without restart IE");
+ ri = 0x86;
+ }
+ l3_debug(pc->st, tmp);
+ p = skb->data;
+ if ((p = findie(p, skb->len, IE_CHANNEL_ID, 0))) {
+ chan = p[2] & 3;
+ sprintf(tmp, "Restart for channel %d", chan);
+ l3_debug(pc->st, tmp);
+ }
+ dev_kfree_skb(skb);
+ newl3state(pc, 2);
+ up = pc->st->l3.proc;
+ while (up) {
+ if ((ri & 7)==7)
+ up->st->lli.l4l3(up->st, CC_RESTART, up);
+ else if (up->para.bchannel == chan)
+ up->st->lli.l4l3(up->st, CC_RESTART, up);
+ up = up->next;
+ }
+ p = tmp;
+ MsgHead(p, pc->callref, MT_RESTART_ACKNOWLEDGE);
+ if (chan) {
+ *p++ = IE_CHANNEL_ID;
+ *p++ = 1;
+ *p++ = chan | 0x80;
+ }
+ *p++ = 0x79; /* RESTART Ind */
+ *p++ = 1;
+ *p++ = ri;
+ l = p - tmp;
+ if (!(skb = l3_alloc_skb(l)))
+ return;
+ memcpy(skb_put(skb, l), tmp, l);
+ newl3state(pc, 0);
+ pc->st->l3.l3l2(pc->st, DL_DATA, skb);
}
+
/* *INDENT-OFF* */
static struct stateentry downstatelist[] =
{
{SBIT(0),
+ CC_ESTABLISH, l3dss1_msg_without_setup},
+ {SBIT(0),
CC_SETUP_REQ, l3dss1_setup_req},
{SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(6) | SBIT(7) | SBIT(8) | SBIT(10),
CC_DISCONNECT_REQ, l3dss1_disconnect_req},
@@ -654,6 +1351,8 @@ static struct stateentry downstatelist[] =
CC_RELEASE_REQ, l3dss1_release_req},
{ALL_STATES,
CC_DLRL, l3dss1_reset},
+ {ALL_STATES,
+ CC_RESTART, l3dss1_restart},
{SBIT(6),
CC_IGNORE, l3dss1_reset},
{SBIT(6),
@@ -685,63 +1384,216 @@ static struct stateentry datastatelist[] =
{
{ALL_STATES,
MT_STATUS_ENQUIRY, l3dss1_status_enq},
+ {ALL_STATES,
+ MT_FACILITY, l3dss1_facility},
+ {SBIT(19),
+ MT_STATUS, l3dss1_release_ind},
+ {ALL_STATES,
+ MT_STATUS, l3dss1_status},
{SBIT(0) | SBIT(6),
MT_SETUP, l3dss1_setup},
{SBIT(1) | SBIT(2),
MT_CALL_PROCEEDING, l3dss1_call_proc},
+ {SBIT(3) | SBIT(4) | SBIT(8) | SBIT(10) | SBIT(11) | SBIT(19),
+ MT_CALL_PROCEEDING, l3dss1_status_req},
{SBIT(1),
MT_SETUP_ACKNOWLEDGE, l3dss1_setup_ack},
+ {SBIT(2) | SBIT(3) | SBIT(4) | SBIT(8) | SBIT(10) | SBIT(11) | SBIT(19),
+ MT_SETUP_ACKNOWLEDGE, l3dss1_status_req},
{SBIT(1) | SBIT(2) | SBIT(3),
MT_ALERTING, l3dss1_alerting},
+ {SBIT(4) | SBIT(8) | SBIT(10) | SBIT(11) | SBIT(19),
+ MT_ALERTING, l3dss1_status_req},
{SBIT(0) | SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(10) |
SBIT(11) | SBIT(12) | SBIT(15) | SBIT(17) | SBIT(19),
MT_RELEASE_COMPLETE, l3dss1_release_cmpl},
- {SBIT(0) | SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(10) |
- SBIT(11) | SBIT(12) | SBIT(15) | SBIT(17) | SBIT(19),
+ {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(10) |
+ SBIT(11) | SBIT(12) | SBIT(15) | SBIT(17) /*| SBIT(19)*/,
MT_RELEASE, l3dss1_release},
+ {SBIT(19), MT_RELEASE, l3dss1_release_ind},
{SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(7) | SBIT(8) | SBIT(10),
MT_DISCONNECT, l3dss1_disconnect},
+ {SBIT(11),
+ MT_DISCONNECT, l3dss1_release_req},
{SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4),
MT_CONNECT, l3dss1_connect},
+ {SBIT(8) | SBIT(10) | SBIT(11) | SBIT(19),
+ MT_CONNECT, l3dss1_status_req},
+ {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(11) | SBIT(19),
+ MT_CONNECT_ACKNOWLEDGE, l3dss1_status_req},
{SBIT(8),
MT_CONNECT_ACKNOWLEDGE, l3dss1_connect_ack},
+ {SBIT(1) | SBIT(2) | SBIT(3) | SBIT(4) | SBIT(8) | SBIT(10) | SBIT(11) | SBIT(19),
+ MT_INVALID, l3dss1_status_req},
};
-/* *INDENT-ON* */
+static int datasllen = sizeof(datastatelist) / sizeof(struct stateentry);
-static int datasllen = sizeof(datastatelist) /
-sizeof(struct stateentry);
+static struct stateentry globalmes_list[] =
+{
+ {ALL_STATES,
+ MT_STATUS, l3dss1_status},
+ {SBIT(0),
+ MT_RESTART, l3dss1_global_restart},
+/* {SBIT(1),
+ MT_RESTART_ACKNOWLEDGE, l3dss1_restart_ack},
+*/
+};
+static int globalm_len = sizeof(globalmes_list) / sizeof(struct stateentry);
+
+#if 0
+static struct stateentry globalcmd_list[] =
+{
+ {ALL_STATES,
+ CC_STATUS, l3dss1_status_req},
+ {SBIT(0),
+ CC_RESTART, l3dss1_restart_req},
+};
+
+static int globalc_len = sizeof(globalcmd_list) / sizeof(struct stateentry);
+#endif
+/* *INDENT-ON* */
+
+static void
+global_handler(struct PStack *st, int mt, struct sk_buff *skb)
+{
+ int i;
+ char tmp[64];
+ struct l3_process *proc = st->l3.global;
+
+ for (i = 0; i < globalm_len; i++)
+ if ((mt == globalmes_list[i].primitive) &&
+ ((1 << proc->state) & globalmes_list[i].state))
+ break;
+ if (i == globalm_len) {
+ dev_kfree_skb(skb);
+ if (st->l3.debug & L3_DEB_STATE) {
+ sprintf(tmp, "dss1 global state %d mt %x unhandled",
+ proc->state, mt);
+ l3_debug(st, tmp);
+ }
+ return;
+ } else {
+ if (st->l3.debug & L3_DEB_STATE) {
+ sprintf(tmp, "dss1 global %d mt %x",
+ proc->state, mt);
+ l3_debug(st, tmp);
+ }
+ globalmes_list[i].rout(proc, mt, skb);
+ }
+}
static void
dss1up(struct PStack *st, int pr, void *arg)
{
- int i, mt;
+ int i, mt, cr, cause, callState;
+ char *ptr;
struct sk_buff *skb = arg;
+ struct l3_process *proc;
char tmp[80];
if (skb->data[0] != PROTO_DIS_EURO) {
if (st->l3.debug & L3_DEB_PROTERR) {
- sprintf(tmp, "dss1up%sunexpected discriminator %x message len %d state %d",
+ sprintf(tmp, "dss1up%sunexpected discriminator %x message len %d",
(pr == DL_DATA) ? " " : "(broadcast) ",
- skb->data[0], skb->len, st->l3.state);
+ skb->data[0], skb->len);
l3_debug(st, tmp);
}
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
return;
}
+ cr = getcallref(skb->data);
mt = skb->data[skb->data[1] + 2];
+ if (!cr) { /* Global CallRef */
+ global_handler(st, mt, skb);
+ return;
+ } else if (cr == -1) { /* Dummy Callref */
+ dev_kfree_skb(skb);
+ return;
+ } else if (!(proc = getl3proc(st, cr))) {
+ /* No transaction process exist, that means no call with
+ * this callreference is active
+ */
+ if (mt == MT_SETUP) {
+ /* Setup creates a new transaction process */
+ if (!(proc = new_l3_process(st, cr))) {
+ /* May be to answer with RELEASE_COMPLETE and
+ * CAUSE 0x2f "Resource unavailable", but this
+ * need a new_l3_process too ... arghh
+ */
+ dev_kfree_skb(skb);
+ return;
+ }
+ } else if (mt == MT_STATUS) {
+ cause = 0;
+ if((ptr = findie(skb->data, skb->len, IE_CAUSE, 0)) != NULL) {
+ ptr++;
+ if (*ptr++ == 2)
+ ptr++;
+ cause = *ptr & 0x7f;
+ }
+ callState = 0;
+ if((ptr = findie(skb->data, skb->len, IE_CALL_STATE, 0)) != NULL) {
+ ptr++;
+ if (*ptr++ == 2)
+ ptr++;
+ callState = *ptr;
+ }
+ if (callState == 0) {
+ /* ETS 300-104 part 2.4.1
+ * if setup has not been made and a message type
+ * MT_STATUS is received with call state == 0,
+ * we must send nothing
+ */
+ dev_kfree_skb(skb);
+ return;
+ } else {
+ /* ETS 300-104 part 2.4.2
+ * if setup has not been made and a message type
+ * MT_STATUS is received with call state != 0,
+ * we must send MT_RELEASE_COMPLETE cause 101
+ */
+ dev_kfree_skb(skb);
+ if ((proc = new_l3_process(st, cr))) {
+ proc->para.cause = 0x65; /* 101 */
+ proc->st->l3.l3l4(proc, CC_ESTABLISH, NULL);
+ }
+ return;
+ }
+ } else if (mt == MT_RELEASE_COMPLETE){
+ dev_kfree_skb(skb);
+ return;
+ } else {
+ /* ETS 300-104 part 2
+ * if setup has not been made and a message type
+ * (except MT_SETUP and RELEASE_COMPLETE) is received,
+ * we must send MT_RELEASE_COMPLETE cause 81 */
+ dev_kfree_skb(skb);
+ if ((proc = new_l3_process(st, cr))) {
+ proc->para.cause = 0x51; /* 81 */
+ proc->st->l3.l3l4(proc, CC_ESTABLISH, NULL);
+ }
+ return;
+ }
+ } else if (!l3dss1_check_messagetype_validity(mt)) {
+ /* ETS 300-104 7.4.2, 8.4.2, 10.3.2, 11.4.2, 12.4.2, 13.4.2,
+ * 14.4.2...
+ * if setup has been made and invalid message type is received,
+ * we must send MT_STATUS cause 0x62
+ */
+ mt = MT_INVALID; /* sorry, not clean, but do the right thing ;-) */
+ }
+
for (i = 0; i < datasllen; i++)
if ((mt == datastatelist[i].primitive) &&
- ((1 << st->l3.state) & datastatelist[i].state))
+ ((1 << proc->state) & datastatelist[i].state))
break;
if (i == datasllen) {
- SET_SKB_FREE(skb);
dev_kfree_skb(skb);
if (st->l3.debug & L3_DEB_STATE) {
sprintf(tmp, "dss1up%sstate %d mt %x unhandled",
(pr == DL_DATA) ? " " : "(broadcast) ",
- st->l3.state, mt);
+ proc->state, mt);
l3_debug(st, tmp);
}
return;
@@ -749,36 +1601,55 @@ dss1up(struct PStack *st, int pr, void *arg)
if (st->l3.debug & L3_DEB_STATE) {
sprintf(tmp, "dss1up%sstate %d mt %x",
(pr == DL_DATA) ? " " : "(broadcast) ",
- st->l3.state, mt);
+ proc->state, mt);
l3_debug(st, tmp);
}
- datastatelist[i].rout(st, pr, skb);
+ datastatelist[i].rout(proc, pr, skb);
}
}
static void
dss1down(struct PStack *st, int pr, void *arg)
{
- int i;
+ int i, cr;
+ struct l3_process *proc;
+ struct Channel *chan;
char tmp[80];
+ if (CC_SETUP_REQ == pr) {
+ chan = arg;
+ cr = newcallref();
+ cr |= 0x80;
+ if ((proc = new_l3_process(st, cr))) {
+ proc->chan = chan;
+ chan->proc = proc;
+ proc->para.setup = chan->setup;
+ proc->callref = cr;
+ }
+ } else {
+ proc = arg;
+ }
+ if (!proc) {
+ printk(KERN_ERR "HiSax internal error dss1down without proc\n");
+ return;
+ }
for (i = 0; i < downsllen; i++)
if ((pr == downstatelist[i].primitive) &&
- ((1 << st->l3.state) & downstatelist[i].state))
+ ((1 << proc->state) & downstatelist[i].state))
break;
if (i == downsllen) {
if (st->l3.debug & L3_DEB_STATE) {
sprintf(tmp, "dss1down state %d prim %d unhandled",
- st->l3.state, pr);
+ proc->state, pr);
l3_debug(st, tmp);
}
} else {
if (st->l3.debug & L3_DEB_STATE) {
sprintf(tmp, "dss1down state %d prim %d",
- st->l3.state, pr);
+ proc->state, pr);
l3_debug(st, tmp);
}
- downstatelist[i].rout(st, pr, arg);
+ downstatelist[i].rout(proc, pr, arg);
}
}
@@ -787,20 +1658,20 @@ setstack_dss1(struct PStack *st)
{
char tmp[64];
- st->l4.l4l3 = dss1down;
+ st->lli.l4l3 = dss1down;
st->l2.l2l3 = dss1up;
- st->l3.t303 = 4000;
- st->l3.t304 = 30000;
- st->l3.t305 = 30000;
- st->l3.t308 = 4000;
- st->l3.t310 = 30000;
- st->l3.t313 = 4000;
- st->l3.t318 = 4000;
- st->l3.t319 = 4000;
- st->l3.n_t303 = 1;
-
- if (st->l3.channr & 1) {
- strcpy(tmp, dss1_revision);
- printk(KERN_NOTICE "HiSax: DSS1 Rev. %s\n", HiSax_getrev(tmp));
+ st->l3.N303 = 1;
+ if (!(st->l3.global = kmalloc(sizeof(struct l3_process), GFP_ATOMIC))) {
+ printk(KERN_ERR "HiSax can't get memory for dss1 global CR\n");
+ } else {
+ st->l3.global->state = 0;
+ st->l3.global->callref = 0;
+ st->l3.global->next = NULL;
+ st->l3.global->debug = L3_DEB_WARN;
+ st->l3.global->st = st;
+ st->l3.global->N303 = 1;
+ L3InitTimer(st->l3.global, &st->l3.global->timer);
}
+ strcpy(tmp, dss1_revision);
+ printk(KERN_INFO "HiSax: DSS1 Rev. %s\n", HiSax_getrev(tmp));
}
diff --git a/drivers/isdn/hisax/l3dss1.h b/drivers/isdn/hisax/l3dss1.h
new file mode 100644
index 000000000..8508c3109
--- /dev/null
+++ b/drivers/isdn/hisax/l3dss1.h
@@ -0,0 +1,71 @@
+/* $Id: l3dss1.h,v 1.5 1998/02/02 13:34:30 keil Exp $
+ *
+ * DSS1 (Euro) D-channel protocol defines
+ *
+ * $Log: l3dss1.h,v $
+ * Revision 1.5 1998/02/02 13:34:30 keil
+ * Support australian Microlink net and german AOCD
+ *
+ * Revision 1.4 1997/10/29 19:07:54 keil
+ * changes for 2.1
+ *
+ * Revision 1.3 1997/08/07 17:44:37 keil
+ * Fix RESTART
+ *
+ * Revision 1.2 1997/08/03 14:36:34 keil
+ * Implement RESTART procedure
+ *
+ * Revision 1.1 1997/07/27 21:08:38 keil
+ * new
+ *
+ *
+ *
+ */
+#define T303 4000
+#define T304 30000
+#define T305 30000
+#define T308 4000
+#define T310 30000
+#define T313 4000
+#define T318 4000
+#define T319 4000
+
+/*
+ * Message-Types
+ */
+
+#define MT_ALERTING 0x01
+#define MT_CALL_PROCEEDING 0x02
+#define MT_CONNECT 0x07
+#define MT_CONNECT_ACKNOWLEDGE 0x0f
+#define MT_PROGRESS 0x03
+#define MT_SETUP 0x05
+#define MT_SETUP_ACKNOWLEDGE 0x0d
+#define MT_RESUME 0x26
+#define MT_RESUME_ACKNOWLEDGE 0x2e
+#define MT_RESUME_REJECT 0x22
+#define MT_SUSPEND 0x25
+#define MT_SUSPEND_ACKNOWLEDGE 0x2d
+#define MT_SUSPEND_REJECT 0x21
+#define MT_USER_INFORMATION 0x20
+#define MT_DISCONNECT 0x45
+#define MT_RELEASE 0x4d
+#define MT_RELEASE_COMPLETE 0x5a
+#define MT_RESTART 0x46
+#define MT_RESTART_ACKNOWLEDGE 0x4e
+#define MT_SEGMENT 0x60
+#define MT_CONGESTION_CONTROL 0x79
+#define MT_INFORMATION 0x7b
+#define MT_FACILITY 0x62
+#define MT_NOTIFY 0x6e
+#define MT_STATUS 0x7d
+#define MT_STATUS_ENQUIRY 0x75
+
+#define MT_INVALID 0xff
+
+#define IE_CAUSE 0x08
+#define IE_BEARER 0x04
+#define IE_FACILITY 0x1c
+#define IE_CALL_STATE 0x14
+#define IE_CHANNEL_ID 0x18
+#define IE_RESTART_IND 0x79
diff --git a/drivers/isdn/hisax/lmgr.c b/drivers/isdn/hisax/lmgr.c
new file mode 100644
index 000000000..b3e9819b2
--- /dev/null
+++ b/drivers/isdn/hisax/lmgr.c
@@ -0,0 +1,58 @@
+/* $Id: lmgr.c,v 1.2 1997/10/29 19:09:34 keil Exp $
+
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ *
+ * Layermanagement module
+ *
+ * $Log: lmgr.c,v $
+ * Revision 1.2 1997/10/29 19:09:34 keil
+ * new L1
+ *
+ * Revision 1.1 1997/06/26 11:17:25 keil
+ * first version
+ *
+ *
+ */
+
+#define __NO_VERSION__
+#include "hisax.h"
+
+static void
+error_handling_dchan(struct PStack *st, int Error)
+{
+ switch (Error) {
+ case 'C':
+ case 'D':
+ case 'G':
+ case 'H':
+ st->l2.l2tei(st, MDL_ERROR_REQ, NULL);
+ break;
+ }
+}
+
+static void
+hisax_manager(struct PStack *st, int pr, void *arg)
+{
+ char tm[32], str[256];
+ int Code;
+
+ switch (pr) {
+ case MDL_ERROR_IND:
+ Code = (int) arg;
+ jiftime(tm, jiffies);
+ sprintf(str, "%s manager: MDL_ERROR %c %s\n", tm,
+ Code, test_bit(FLG_LAPD, &st->l2.flag) ?
+ "D-channel" : "B-channel");
+ HiSax_putstatus(st->l1.hardware, str);
+ if (test_bit(FLG_LAPD, &st->l2.flag))
+ error_handling_dchan(st, Code);
+ break;
+ }
+}
+
+void
+setstack_manager(struct PStack *st)
+{
+ st->ma.layer = hisax_manager;
+}
diff --git a/drivers/isdn/hisax/mic.c b/drivers/isdn/hisax/mic.c
new file mode 100644
index 000000000..8bf4757c9
--- /dev/null
+++ b/drivers/isdn/hisax/mic.c
@@ -0,0 +1,284 @@
+/* $Id: mic.c,v 1.6 1998/02/17 15:39:57 keil Exp $
+
+ * mic.c low level stuff for mic cards
+ *
+ * Copyright (C) 1997
+ *
+ * Author Stephan von Krawczynski <skraw@ithnet.com>
+ *
+ *
+ * $Log: mic.c,v $
+ * Revision 1.6 1998/02/17 15:39:57 keil
+ * fix reset problem
+ *
+ * Revision 1.5 1998/02/02 13:29:43 keil
+ * fast io
+ *
+ * Revision 1.4 1997/11/08 21:35:51 keil
+ * new l1 init
+ *
+ * Revision 1.3 1997/11/06 17:09:11 keil
+ * New 2.1 init code
+ *
+ * Revision 1.2 1997/10/29 18:51:17 keil
+ * New files
+ *
+ * Revision 1.1.2.1 1997/10/17 22:10:54 keil
+ * new files on 2.0
+ *
+ *
+ */
+
+#define __NO_VERSION__
+#include "hisax.h"
+#include "isac.h"
+#include "hscx.h"
+#include "isdnl1.h"
+
+extern const char *CardType[];
+
+const char *mic_revision = "$Revision: 1.6 $";
+
+#define byteout(addr,val) outb(val,addr)
+#define bytein(addr) inb(addr)
+
+#define MIC_ISAC 2
+#define MIC_HSCX 1
+#define MIC_ADR 7
+
+/* CARD_ADR (Write) */
+#define MIC_RESET 0x3 /* same as DOS driver */
+
+static inline u_char
+readreg(unsigned int ale, unsigned int adr, u_char off)
+{
+ register u_char ret;
+ long flags;
+
+ save_flags(flags);
+ cli();
+ byteout(ale, off);
+ ret = bytein(adr);
+ restore_flags(flags);
+
+ return (ret);
+}
+
+static inline void
+readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
+{
+ /* fifo read without cli because it's allready done */
+
+ byteout(ale, off);
+ insb(adr, data, size);
+}
+
+
+static inline void
+writereg(unsigned int ale, unsigned int adr, u_char off, u_char data)
+{
+ long flags;
+
+ save_flags(flags);
+ cli();
+ byteout(ale, off);
+ byteout(adr, data);
+ restore_flags(flags);
+}
+
+static inline void
+writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
+{
+ /* fifo write without cli because it's allready done */
+ byteout(ale, off);
+ outsb(adr, data, size);
+}
+
+/* Interface functions */
+
+static u_char
+ReadISAC(struct IsdnCardState *cs, u_char offset)
+{
+ return (readreg(cs->hw.mic.adr, cs->hw.mic.isac, offset));
+}
+
+static void
+WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
+{
+ writereg(cs->hw.mic.adr, cs->hw.mic.isac, offset, value);
+}
+
+static void
+ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
+{
+ readfifo(cs->hw.mic.adr, cs->hw.mic.isac, 0, data, size);
+}
+
+static void
+WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
+{
+ writefifo(cs->hw.mic.adr, cs->hw.mic.isac, 0, data, size);
+}
+
+static u_char
+ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
+{
+ return (readreg(cs->hw.mic.adr,
+ cs->hw.mic.hscx, offset + (hscx ? 0x40 : 0)));
+}
+
+static void
+WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
+{
+ writereg(cs->hw.mic.adr,
+ cs->hw.mic.hscx, offset + (hscx ? 0x40 : 0), value);
+}
+
+/*
+ * fast interrupt HSCX stuff goes here
+ */
+
+#define READHSCX(cs, nr, reg) readreg(cs->hw.mic.adr, \
+ cs->hw.mic.hscx, reg + (nr ? 0x40 : 0))
+#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.mic.adr, \
+ cs->hw.mic.hscx, reg + (nr ? 0x40 : 0), data)
+
+#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.mic.adr, \
+ cs->hw.mic.hscx, (nr ? 0x40 : 0), ptr, cnt)
+
+#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.mic.adr, \
+ cs->hw.mic.hscx, (nr ? 0x40 : 0), ptr, cnt)
+
+#include "hscx_irq.c"
+
+static void
+mic_interrupt(int intno, void *dev_id, struct pt_regs *regs)
+{
+ struct IsdnCardState *cs = dev_id;
+ u_char val, stat = 0;
+
+ if (!cs) {
+ printk(KERN_WARNING "mic: Spurious interrupt!\n");
+ return;
+ }
+ val = readreg(cs->hw.mic.adr, cs->hw.mic.hscx, HSCX_ISTA + 0x40);
+ Start_HSCX:
+ if (val) {
+ hscx_int_main(cs, val);
+ stat |= 1;
+ }
+ val = readreg(cs->hw.mic.adr, cs->hw.mic.isac, ISAC_ISTA);
+ Start_ISAC:
+ if (val) {
+ isac_interrupt(cs, val);
+ stat |= 2;
+ }
+ val = readreg(cs->hw.mic.adr, cs->hw.mic.hscx, HSCX_ISTA + 0x40);
+ if (val) {
+ if (cs->debug & L1_DEB_HSCX)
+ debugl1(cs, "HSCX IntStat after IntRoutine");
+ goto Start_HSCX;
+ }
+ val = readreg(cs->hw.mic.adr, cs->hw.mic.isac, ISAC_ISTA);
+ if (val) {
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ISAC IntStat after IntRoutine");
+ goto Start_ISAC;
+ }
+ if (stat & 1) {
+ writereg(cs->hw.mic.adr, cs->hw.mic.hscx, HSCX_MASK, 0xFF);
+ writereg(cs->hw.mic.adr, cs->hw.mic.hscx, HSCX_MASK + 0x40, 0xFF);
+ writereg(cs->hw.mic.adr, cs->hw.mic.hscx, HSCX_MASK, 0x0);
+ writereg(cs->hw.mic.adr, cs->hw.mic.hscx, HSCX_MASK + 0x40, 0x0);
+ }
+ if (stat & 2) {
+ writereg(cs->hw.mic.adr, cs->hw.mic.isac, ISAC_MASK, 0xFF);
+ writereg(cs->hw.mic.adr, cs->hw.mic.isac, ISAC_MASK, 0x0);
+ }
+}
+
+void
+release_io_mic(struct IsdnCardState *cs)
+{
+ int bytecnt = 8;
+
+ if (cs->hw.mic.cfg_reg)
+ release_region(cs->hw.mic.cfg_reg, bytecnt);
+}
+
+static int
+mic_card_msg(struct IsdnCardState *cs, int mt, void *arg)
+{
+ switch (mt) {
+ case CARD_RESET:
+ return(0);
+ case CARD_RELEASE:
+ release_io_mic(cs);
+ return(0);
+ case CARD_SETIRQ:
+ return(request_irq(cs->irq, &mic_interrupt,
+ I4L_IRQ_FLAG, "HiSax", cs));
+ case CARD_INIT:
+ inithscx(cs); /* /RTSA := ISAC RST */
+ clear_pending_isac_ints(cs);
+ clear_pending_hscx_ints(cs);
+ initisac(cs);
+ inithscx(cs);
+ return(0);
+ case CARD_TEST:
+ return(0);
+ }
+ return(0);
+}
+
+__initfunc(int
+setup_mic(struct IsdnCard *card))
+{
+ int bytecnt;
+ struct IsdnCardState *cs = card->cs;
+ char tmp[64];
+
+ strcpy(tmp, mic_revision);
+ printk(KERN_INFO "HiSax: mic driver Rev. %s\n", HiSax_getrev(tmp));
+ if (cs->typ != ISDN_CTYPE_MIC)
+ return (0);
+
+ bytecnt = 8;
+ cs->hw.mic.cfg_reg = card->para[1];
+ cs->irq = card->para[0];
+ cs->hw.mic.adr = cs->hw.mic.cfg_reg + MIC_ADR;
+ cs->hw.mic.isac = cs->hw.mic.cfg_reg + MIC_ISAC;
+ cs->hw.mic.hscx = cs->hw.mic.cfg_reg + MIC_HSCX;
+
+ if (check_region((cs->hw.mic.cfg_reg), bytecnt)) {
+ printk(KERN_WARNING
+ "HiSax: %s config port %x-%x already in use\n",
+ CardType[card->typ],
+ cs->hw.mic.cfg_reg,
+ cs->hw.mic.cfg_reg + bytecnt);
+ return (0);
+ } else {
+ request_region(cs->hw.mic.cfg_reg, bytecnt, "mic isdn");
+ }
+
+ printk(KERN_INFO
+ "mic: defined at 0x%x IRQ %d\n",
+ cs->hw.mic.cfg_reg,
+ cs->irq);
+ cs->readisac = &ReadISAC;
+ cs->writeisac = &WriteISAC;
+ cs->readisacfifo = &ReadISACfifo;
+ cs->writeisacfifo = &WriteISACfifo;
+ cs->BC_Read_Reg = &ReadHSCX;
+ cs->BC_Write_Reg = &WriteHSCX;
+ cs->BC_Send_Data = &hscx_fill_fifo;
+ cs->cardmsg = &mic_card_msg;
+ ISACVersion(cs, "mic:");
+ if (HscxVersion(cs, "mic:")) {
+ printk(KERN_WARNING
+ "mic: wrong HSCX versions check IO address\n");
+ release_io_mic(cs);
+ return (0);
+ }
+ return (1);
+}
diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
new file mode 100644
index 000000000..0686598e2
--- /dev/null
+++ b/drivers/isdn/hisax/netjet.c
@@ -0,0 +1,1108 @@
+/* $Id: netjet.c,v 1.3 1998/02/12 23:08:05 keil Exp $
+
+ * netjet.c low level stuff for Traverse Technologie NETJet ISDN cards
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ * Thanks to Traverse Technologie Australia for documents and informations
+ *
+ *
+ * $Log: netjet.c,v $
+ * Revision 1.3 1998/02/12 23:08:05 keil
+ * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
+ *
+ * Revision 1.2 1998/02/02 13:32:06 keil
+ * New
+ *
+ *
+ *
+ */
+
+#define __NO_VERSION__
+#include <linux/config.h>
+#include "hisax.h"
+#include "isac.h"
+#include "hscx.h"
+#include "isdnl1.h"
+#include <linux/pci.h>
+#include <linux/bios32.h>
+#include <linux/interrupt.h>
+#define fcstab ppp_crc16_table
+#include <linux/ppp_defs.h>
+extern __u16 ppp_crc16_table[256]; /* from ppp code */
+
+extern const char *CardType[];
+
+const char *NETjet_revision = "$Revision: 1.3 $";
+
+#define byteout(addr,val) outb(val,addr)
+#define bytein(addr) inb(addr)
+
+/* PCI stuff */
+#define PCI_VENDOR_TRAVERSE_TECH 0xe159
+#define PCI_NETJET_ID 0x0001
+
+#define NETJET_CTRL 0x00
+#define NETJET_DMACTRL 0x01
+#define NETJET_AUXCTRL 0x02
+#define NETJET_AUXDATA 0x03
+#define NETJET_IRQMASK0 0x04
+#define NETJET_IRQMASK1 0x05
+#define NETJET_IRQSTAT0 0x06
+#define NETJET_IRQSTAT1 0x07
+#define NETJET_DMA_READ_START 0x08
+#define NETJET_DMA_READ_IRQ 0x0c
+#define NETJET_DMA_READ_END 0x10
+#define NETJET_DMA_READ_ADR 0x14
+#define NETJET_DMA_WRITE_START 0x18
+#define NETJET_DMA_WRITE_IRQ 0x1c
+#define NETJET_DMA_WRITE_END 0x20
+#define NETJET_DMA_WRITE_ADR 0x24
+#define NETJET_PULSE_CNT 0x28
+
+#define NETJET_ISAC_OFF 0xc0
+#define NETJET_ISACIRQ 0x10
+
+#define NETJET_DMA_SIZE 512
+
+#define HDLC_ZERO_SEARCH 0
+#define HDLC_FLAG_SEARCH 1
+#define HDLC_FLAG_FOUND 2
+#define HDLC_FRAME_FOUND 3
+#define HDLC_NULL 4
+#define HDLC_PART 5
+#define HDLC_FULL 6
+
+#define HDLC_FLAG_VALUE 0x7e
+
+/* Interface functions */
+
+static u_char
+ReadISAC(struct IsdnCardState *cs, u_char offset)
+{
+ long flags;
+ u_char ret;
+
+ save_flags(flags);
+ cli();
+ cs->hw.njet.auxd &= 0xfc;
+ cs->hw.njet.auxd |= (offset>>4) & 3;
+ byteout(cs->hw.njet.auxa, cs->hw.njet.auxd);
+ ret = bytein(cs->hw.njet.isac + ((offset & 0xf)<<2));
+ restore_flags(flags);
+ return(ret);
+}
+
+static void
+WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
+{
+ long flags;
+
+ save_flags(flags);
+ cli();
+ cs->hw.njet.auxd &= 0xfc;
+ cs->hw.njet.auxd |= (offset>>4) & 3;
+ byteout(cs->hw.njet.auxa, cs->hw.njet.auxd);
+ byteout(cs->hw.njet.isac + ((offset & 0xf)<<2), value);
+ restore_flags(flags);
+}
+
+static void
+ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size)
+{
+ cs->hw.njet.auxd &= 0xfc;
+ byteout(cs->hw.njet.auxa, cs->hw.njet.auxd);
+ insb(cs->hw.njet.isac, data, size);
+}
+
+static void
+WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size)
+{
+ cs->hw.njet.auxd &= 0xfc;
+ byteout(cs->hw.njet.auxa, cs->hw.njet.auxd);
+ outsb(cs->hw.njet.isac, data, size);
+}
+
+void fill_mem(struct BCState *bcs, u_int *pos, u_int cnt, int chan, u_char fill)
+{
+ u_int mask=0x000000ff, val = 0, *p=pos;
+ u_int i;
+
+ val |= fill;
+ if (chan) {
+ val <<= 8;
+ mask <<= 8;
+ }
+ mask ^= 0xffffffff;
+ for (i=0; i<cnt; i++) {
+ *p &= mask;
+ *p++ |= val;
+ if (p > bcs->hw.tiger.s_end)
+ p = bcs->hw.tiger.send;
+ }
+}
+
+void
+mode_tiger(struct BCState *bcs, int mode, int bc)
+{
+ struct IsdnCardState *cs = bcs->cs;
+ char tmp[64];
+
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "Tiger mode %d bchan %d/%d",
+ mode, bc, bcs->channel);
+ debugl1(cs, tmp);
+ }
+ bcs->mode = mode;
+ bcs->channel = bc;
+ switch (mode) {
+ case (L1_MODE_NULL):
+ fill_mem(bcs, bcs->hw.tiger.send,
+ NETJET_DMA_SIZE, bc, 0xff);
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "Tiger stat rec %d/%d send %d",
+ bcs->hw.tiger.r_tot, bcs->hw.tiger.r_err,
+ bcs->hw.tiger.s_tot);
+ debugl1(cs, tmp);
+ }
+ if ((cs->bcs[0].mode == L1_MODE_NULL) &&
+ (cs->bcs[1].mode == L1_MODE_NULL)) {
+ cs->hw.njet.dmactrl = 0;
+ byteout(cs->hw.njet.base + NETJET_DMACTRL,
+ cs->hw.njet.dmactrl);
+ byteout(cs->hw.njet.base + NETJET_IRQMASK0, 0);
+ }
+ break;
+ case (L1_MODE_TRANS):
+ break;
+ case (L1_MODE_HDLC):
+ fill_mem(bcs, bcs->hw.tiger.send,
+ NETJET_DMA_SIZE, bc, 0xff);
+ bcs->hw.tiger.r_state = HDLC_ZERO_SEARCH;
+ bcs->hw.tiger.r_tot = 0;
+ bcs->hw.tiger.r_bitcnt = 0;
+ bcs->hw.tiger.r_one = 0;
+ bcs->hw.tiger.r_err = 0;
+ bcs->hw.tiger.s_tot = 0;
+ if (! cs->hw.njet.dmactrl) {
+ fill_mem(bcs, bcs->hw.tiger.send,
+ NETJET_DMA_SIZE, !bc, 0xff);
+ cs->hw.njet.dmactrl = 1;
+ byteout(cs->hw.njet.base + NETJET_DMACTRL,
+ cs->hw.njet.dmactrl);
+ byteout(cs->hw.njet.base + NETJET_IRQMASK0, 0x3f);
+ }
+ bcs->hw.tiger.sendp = bcs->hw.tiger.send;
+ bcs->hw.tiger.free = NETJET_DMA_SIZE;
+ test_and_set_bit(BC_FLG_EMPTY, &bcs->Flag);
+ break;
+ }
+ if (cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "tiger: set %x %x %x %x/%x pulse=%d",
+ bytein(cs->hw.njet.base + NETJET_DMACTRL),
+ bytein(cs->hw.njet.base + NETJET_IRQMASK0),
+ bytein(cs->hw.njet.base + NETJET_IRQSTAT0),
+ inl(cs->hw.njet.base + NETJET_DMA_READ_ADR),
+ inl(cs->hw.njet.base + NETJET_DMA_WRITE_ADR),
+ bytein(cs->hw.njet.base + NETJET_PULSE_CNT));
+ debugl1(cs, tmp);
+ }
+}
+
+static u_char dummyrr(struct IsdnCardState *cs, int chan, u_char off)
+{
+ return(5);
+}
+
+static void dummywr(struct IsdnCardState *cs, int chan, u_char off, u_char value)
+{
+}
+
+static void printframe(struct IsdnCardState *cs, u_char *buf, int count, char *s) {
+ char tmp[128];
+ char *t = tmp;
+ int i=count,j;
+ u_char *p = buf;
+
+ t += sprintf(t, "tiger %s(%4d)", s, count);
+ while (i>0) {
+ if (i>16)
+ j=16;
+ else
+ j=i;
+ QuickHex(t, p, j);
+ debugl1(cs, tmp);
+ p += j;
+ i -= j;
+ t = tmp;
+ t += sprintf(t, "tiger %s ", s);
+ }
+}
+
+#define MAKE_RAW_BYTE for (j=0; j<8; j++) { \
+ bitcnt++;\
+ s_val >>= 1;\
+ if (val & 1) {\
+ s_one++;\
+ s_val |= 0x80;\
+ } else {\
+ s_one = 0;\
+ s_val &= 0x7f;\
+ }\
+ if (bitcnt==8) {\
+ bcs->hw.tiger.sendbuf[s_cnt++] = s_val;\
+ bitcnt = 0;\
+ }\
+ if (s_one == 5) {\
+ s_val >>= 1;\
+ s_val &= 0x7f;\
+ bitcnt++;\
+ s_one = 0;\
+ }\
+ if (bitcnt==8) {\
+ bcs->hw.tiger.sendbuf[s_cnt++] = s_val;\
+ bitcnt = 0;\
+ }\
+ val >>= 1;\
+ }
+
+static void make_raw_data(struct BCState *bcs) {
+ register u_int i,s_cnt=0;
+ register u_char j;
+ register u_char val;
+ register u_char s_one = 0;
+ register u_char s_val = 0;
+ register u_char bitcnt = 0;
+ u_int fcs;
+ char tmp[64];
+
+
+ bcs->hw.tiger.sendbuf[s_cnt++] = HDLC_FLAG_VALUE;
+ fcs = PPP_INITFCS;
+ for (i=0; i<bcs->hw.tiger.tx_skb->len; i++) {
+ val = bcs->hw.tiger.tx_skb->data[i];
+ fcs = PPP_FCS (fcs, val);
+ MAKE_RAW_BYTE;
+ }
+ fcs ^= 0xffff;
+ val = fcs & 0xff;
+ MAKE_RAW_BYTE;
+ val = (fcs>>8) & 0xff;
+ MAKE_RAW_BYTE;
+ val = HDLC_FLAG_VALUE;
+ for (j=0; j<8; j++) {
+ bitcnt++;
+ s_val >>= 1;
+ if (val & 1)
+ s_val |= 0x80;
+ else
+ s_val &= 0x7f;
+ if (bitcnt==8) {
+ bcs->hw.tiger.sendbuf[s_cnt++] = s_val;
+ bitcnt = 0;
+ }
+ val >>= 1;
+ }
+ if (bcs->cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp,"tiger make_raw: in %d out %d.%d",
+ bcs->hw.tiger.tx_skb->len, s_cnt, bitcnt);
+ debugl1(bcs->cs,tmp);
+ }
+ if (bitcnt) {
+ while (8>bitcnt++) {
+ s_val >>= 1;
+ s_val |= 0x80;
+ }
+ bcs->hw.tiger.sendbuf[s_cnt++] = s_val;
+ }
+ bcs->hw.tiger.sendcnt = s_cnt;
+ bcs->tx_cnt -= bcs->hw.tiger.tx_skb->len;
+ bcs->hw.tiger.sp = bcs->hw.tiger.sendbuf;
+}
+
+static void got_frame(struct BCState *bcs, int count) {
+ struct sk_buff *skb;
+
+ if (!(skb = dev_alloc_skb(count)))
+ printk(KERN_WARNING "TIGER: receive out of memory\n");
+ else {
+ memcpy(skb_put(skb, count), bcs->hw.tiger.rcvbuf, count);
+ skb_queue_tail(&bcs->rqueue, skb);
+ }
+ bcs->event |= 1 << B_RCVBUFREADY;
+ queue_task(&bcs->tqueue, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+
+ if (bcs->cs->debug & L1_DEB_RECEIVE_FRAME)
+ printframe(bcs->cs, bcs->hw.tiger.rcvbuf, count, "rec");
+}
+
+
+
+static void read_raw(struct BCState *bcs, u_int *buf, int cnt){
+ int i;
+ register u_char j;
+ register u_char val;
+ u_int *pend = bcs->hw.tiger.rec +NETJET_DMA_SIZE -1;
+ register u_char state = bcs->hw.tiger.r_state;
+ register u_char r_one = bcs->hw.tiger.r_one;
+ register u_char r_val = bcs->hw.tiger.r_val;
+ register u_int bitcnt = bcs->hw.tiger.r_bitcnt;
+ u_int *p = buf;
+ char tmp[64];
+
+ for (i=0;i<cnt;i++) {
+ val = bcs->channel ? ((*p>>8) & 0xff) : (*p & 0xff);
+ p++;
+ if (p > pend)
+ p = bcs->hw.tiger.rec;
+ if (val == 0xff) {
+ state = HDLC_ZERO_SEARCH;
+ bcs->hw.tiger.r_tot++;
+ bitcnt = 0;
+ r_one = 0;
+ continue;
+ }
+ for (j=0;j<8;j++) {
+ if (state == HDLC_ZERO_SEARCH) {
+ if (val & 1) {
+ r_one++;
+ } else {
+ r_one=0;
+ state= HDLC_FLAG_SEARCH;
+ if (bcs->cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp,"tiger read_raw: zBit(%d,%d,%d) %x",
+ bcs->hw.tiger.r_tot,i,j,val);
+ debugl1(bcs->cs,tmp);
+ }
+ }
+ } else if (state == HDLC_FLAG_SEARCH) {
+ if (val & 1) {
+ r_one++;
+ if (r_one>6) {
+ state=HDLC_ZERO_SEARCH;
+ }
+ } else {
+ if (r_one==6) {
+ bitcnt=0;
+ r_val=0;
+ state=HDLC_FLAG_FOUND;
+ if (bcs->cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp,"tiger read_raw: flag(%d,%d,%d) %x",
+ bcs->hw.tiger.r_tot,i,j,val);
+ debugl1(bcs->cs,tmp);
+ }
+ }
+ r_one=0;
+ }
+ } else if (state == HDLC_FLAG_FOUND) {
+ if (val & 1) {
+ r_one++;
+ if (r_one>6) {
+ state=HDLC_ZERO_SEARCH;
+ } else {
+ r_val >>= 1;
+ r_val |= 0x80;
+ bitcnt++;
+ }
+ } else {
+ if (r_one==6) {
+ bitcnt=0;
+ r_val=0;
+ r_one=0;
+ val >>= 1;
+ continue;
+ } else if (r_one!=5) {
+ r_val >>= 1;
+ r_val &= 0x7f;
+ bitcnt++;
+ }
+ r_one=0;
+ }
+ if ((state != HDLC_ZERO_SEARCH) &&
+ !(bitcnt & 7)) {
+ state=HDLC_FRAME_FOUND;
+ bcs->hw.tiger.r_fcs = PPP_INITFCS;
+ bcs->hw.tiger.rcvbuf[0] = r_val;
+ bcs->hw.tiger.r_fcs = PPP_FCS (bcs->hw.tiger.r_fcs, r_val);
+ if (bcs->cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp,"tiger read_raw: byte1(%d,%d,%d) rval %x val %x i %x",
+ bcs->hw.tiger.r_tot,i,j,r_val,val,
+ bcs->cs->hw.njet.irqstat0);
+ debugl1(bcs->cs,tmp);
+ }
+ }
+ } else if (state == HDLC_FRAME_FOUND) {
+ if (val & 1) {
+ r_one++;
+ if (r_one>6) {
+ state=HDLC_ZERO_SEARCH;
+ bitcnt=0;
+ } else {
+ r_val >>= 1;
+ r_val |= 0x80;
+ bitcnt++;
+ }
+ } else {
+ if (r_one==6) {
+ r_val=0;
+ r_one=0;
+ bitcnt++;
+ if (bitcnt & 7) {
+ debugl1(bcs->cs, "tiger: frame not byte aligned");
+ state=HDLC_FLAG_SEARCH;
+ bcs->hw.tiger.r_err++;
+ } else {
+ if (bcs->cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp,"tiger frame end(%d,%d): fcs(%x) i %x",
+ i,j,bcs->hw.tiger.r_fcs, bcs->cs->hw.njet.irqstat0);
+ debugl1(bcs->cs, tmp);
+ }
+ if (bcs->hw.tiger.r_fcs == PPP_GOODFCS) {
+ got_frame(bcs, (bitcnt>>3)-3);
+ } else
+ if (bcs->cs->debug) {
+ debugl1(bcs->cs, "tiger FCS error");
+ printframe(bcs->cs, bcs->hw.tiger.rcvbuf,
+ (bitcnt>>3)-1, "rec");
+ bcs->hw.tiger.r_err++;
+ }
+ state=HDLC_FLAG_FOUND;
+ }
+ bitcnt=0;
+ } else if (r_one==5) {
+ val >>= 1;
+ r_one=0;
+ continue;
+ } else {
+ r_val >>= 1;
+ r_val &= 0x7f;
+ bitcnt++;
+ }
+ r_one=0;
+ }
+ if ((state == HDLC_FRAME_FOUND) &&
+ !(bitcnt & 7)) {
+ if ((bitcnt>>3)>=HSCX_BUFMAX) {
+ debugl1(bcs->cs, "tiger: frame to big");
+ r_val=0;
+ state=HDLC_FLAG_SEARCH;
+ bcs->hw.tiger.r_err++;
+ } else {
+ bcs->hw.tiger.rcvbuf[(bitcnt>>3)-1] = r_val;
+ bcs->hw.tiger.r_fcs =
+ PPP_FCS (bcs->hw.tiger.r_fcs, r_val);
+ }
+ }
+ }
+ val >>= 1;
+ }
+ bcs->hw.tiger.r_tot++;
+ }
+ bcs->hw.tiger.r_state = state;
+ bcs->hw.tiger.r_one = r_one;
+ bcs->hw.tiger.r_val = r_val;
+ bcs->hw.tiger.r_bitcnt = bitcnt;
+}
+
+static void read_tiger(struct IsdnCardState *cs) {
+ u_int *p;
+ int cnt = NETJET_DMA_SIZE/2;
+
+ if (cs->hw.njet.irqstat0 & 4)
+ p = cs->bcs[0].hw.tiger.rec + NETJET_DMA_SIZE - 1;
+ else
+ p = cs->bcs[0].hw.tiger.rec + cnt - 1;
+ if (cs->bcs[0].mode == L1_MODE_HDLC)
+ read_raw(cs->bcs, p, cnt);
+ if (cs->bcs[1].mode == L1_MODE_HDLC)
+ read_raw(cs->bcs + 1, p, cnt);
+ cs->hw.njet.irqstat0 &= 0xf3;
+}
+
+static void write_raw(struct BCState *bcs, u_int *buf, int cnt);
+
+static void fill_dma(struct BCState *bcs)
+{
+ char tmp[64];
+ register u_int *p, *sp;
+ register int cnt;
+
+ if (!bcs->hw.tiger.tx_skb)
+ return;
+ if (bcs->cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp,"tiger fill_dma1: c%d %4x", bcs->channel,
+ bcs->Flag);
+ debugl1(bcs->cs,tmp);
+ }
+ if (test_and_set_bit(BC_FLG_BUSY, &bcs->Flag))
+ return;
+ make_raw_data(bcs);
+ if (bcs->cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp,"tiger fill_dma2: c%d %4x", bcs->channel,
+ bcs->Flag);
+ debugl1(bcs->cs,tmp);
+ }
+ if (test_and_clear_bit(BC_FLG_NOFRAME, &bcs->Flag)) {
+ write_raw(bcs, bcs->hw.tiger.sendp, bcs->hw.tiger.free);
+ } else if (test_and_clear_bit(BC_FLG_HALF, &bcs->Flag)) {
+ p = bus_to_virt(inl(bcs->cs->hw.njet.base + NETJET_DMA_READ_ADR));
+ sp = bcs->hw.tiger.sendp;
+ if (p == bcs->hw.tiger.s_end)
+ p = bcs->hw.tiger.send -1;
+ if (sp == bcs->hw.tiger.s_end)
+ sp = bcs->hw.tiger.send -1;
+ cnt = p - sp;
+ if (cnt <0) {
+ write_raw(bcs, bcs->hw.tiger.sendp, bcs->hw.tiger.free);
+ } else {
+ p++;
+ cnt++;
+ if (p > bcs->hw.tiger.s_end)
+ p = bcs->hw.tiger.send;
+ p++;
+ cnt++;
+ if (p > bcs->hw.tiger.s_end)
+ p = bcs->hw.tiger.send;
+ write_raw(bcs, p, bcs->hw.tiger.free - cnt);
+ }
+ } else if (test_and_clear_bit(BC_FLG_EMPTY, &bcs->Flag)) {
+ p = bus_to_virt(inl(bcs->cs->hw.njet.base + NETJET_DMA_READ_ADR));
+ cnt = bcs->hw.tiger.s_end - p;
+ if (cnt < 2) {
+ p = bcs->hw.tiger.send + 1;
+ cnt = NETJET_DMA_SIZE/2 - 2;
+ } else {
+ p++;
+ p++;
+ if (cnt <= (NETJET_DMA_SIZE/2))
+ cnt += NETJET_DMA_SIZE/2;
+ cnt--;
+ cnt--;
+ }
+ write_raw(bcs, p, cnt);
+ }
+ if (bcs->cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp,"tiger fill_dma3: c%d %4x", bcs->channel,
+ bcs->Flag);
+ debugl1(bcs->cs,tmp);
+ }
+}
+
+static void write_raw(struct BCState *bcs, u_int *buf, int cnt) {
+ u_int mask, val, *p=buf;
+ u_int i, s_cnt;
+ char tmp[64];
+
+ if (cnt <= 0)
+ return;
+ if (test_bit(BC_FLG_BUSY, &bcs->Flag)) {
+ if (bcs->hw.tiger.sendcnt> cnt) {
+ s_cnt = cnt;
+ bcs->hw.tiger.sendcnt -= cnt;
+ } else {
+ s_cnt = bcs->hw.tiger.sendcnt;
+ bcs->hw.tiger.sendcnt = 0;
+ }
+ if (bcs->channel)
+ mask = 0xffff00ff;
+ else
+ mask = 0xffffff00;
+ for (i=0; i<s_cnt; i++) {
+ val = bcs->channel ? ((bcs->hw.tiger.sp[i] <<8) & 0xff00) :
+ (bcs->hw.tiger.sp[i]);
+ *p &= mask;
+ *p++ |= val;
+ if (p>bcs->hw.tiger.s_end)
+ p = bcs->hw.tiger.send;
+ }
+ bcs->hw.tiger.s_tot += s_cnt;
+ if (bcs->cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp,"tiger write_raw: c%d %x-%x %d/%d %d %x", bcs->channel,
+ (u_int)buf, (u_int)p, s_cnt, cnt, bcs->hw.tiger.sendcnt,
+ bcs->cs->hw.njet.irqstat0);
+ debugl1(bcs->cs,tmp);
+ }
+ if (bcs->cs->debug & L1_DEB_HSCX_FIFO)
+ printframe(bcs->cs, bcs->hw.tiger.sp, s_cnt, "snd");
+ bcs->hw.tiger.sp += s_cnt;
+ bcs->hw.tiger.sendp = p;
+ if (!bcs->hw.tiger.sendcnt) {
+ if (!bcs->hw.tiger.tx_skb) {
+ sprintf(tmp,"tiger write_raw: NULL skb s_cnt %d", s_cnt);
+ debugl1(bcs->cs, tmp);
+ } else {
+ if (bcs->st->lli.l1writewakeup &&
+ (PACKET_NOACK != bcs->hw.tiger.tx_skb->pkt_type))
+ bcs->st->lli.l1writewakeup(bcs->st, bcs->hw.tiger.tx_skb->len);
+ dev_kfree_skb(bcs->hw.tiger.tx_skb);
+ bcs->hw.tiger.tx_skb = NULL;
+ }
+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
+ bcs->hw.tiger.free = cnt - s_cnt;
+ if (bcs->hw.tiger.free > (NETJET_DMA_SIZE/2))
+ test_and_set_bit(BC_FLG_HALF, &bcs->Flag);
+ else {
+ test_and_clear_bit(BC_FLG_HALF, &bcs->Flag);
+ test_and_set_bit(BC_FLG_NOFRAME, &bcs->Flag);
+ }
+ if ((bcs->hw.tiger.tx_skb = skb_dequeue(&bcs->squeue))) {
+ fill_dma(bcs);
+ } else {
+ mask ^= 0xffffffff;
+ if (s_cnt < cnt) {
+ for (i=s_cnt; i<cnt;i++) {
+ *p++ |= mask;
+ if (p>bcs->hw.tiger.s_end)
+ p = bcs->hw.tiger.send;
+ }
+ if (bcs->cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp, "tiger write_raw: fill rest %d",
+ cnt - s_cnt);
+ debugl1(bcs->cs,tmp);
+ }
+ }
+ bcs->event |= 1 << B_XMTBUFREADY;
+ queue_task(&bcs->tqueue, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+ }
+ }
+ } else if (test_and_clear_bit(BC_FLG_NOFRAME, &bcs->Flag)) {
+ test_and_set_bit(BC_FLG_HALF, &bcs->Flag);
+ fill_mem(bcs, buf, cnt, bcs->channel, 0xff);
+ bcs->hw.tiger.free += cnt;
+ if (bcs->cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp,"tiger write_raw: fill half");
+ debugl1(bcs->cs,tmp);
+ }
+ } else if (test_and_clear_bit(BC_FLG_HALF, &bcs->Flag)) {
+ test_and_set_bit(BC_FLG_EMPTY, &bcs->Flag);
+ fill_mem(bcs, buf, cnt, bcs->channel, 0xff);
+ if (bcs->cs->debug & L1_DEB_HSCX) {
+ sprintf(tmp,"tiger write_raw: fill full");
+ debugl1(bcs->cs,tmp);
+ }
+ }
+}
+
+static void write_tiger(struct IsdnCardState *cs) {
+ u_int *p, cnt = NETJET_DMA_SIZE/2;
+
+ if (cs->hw.njet.irqstat0 & 1)
+ p = cs->bcs[0].hw.tiger.send + NETJET_DMA_SIZE - 1;
+ else
+ p = cs->bcs[0].hw.tiger.send + cnt - 1;
+ if (cs->bcs[0].mode == L1_MODE_HDLC)
+ write_raw(cs->bcs, p, cnt);
+ if (cs->bcs[1].mode == L1_MODE_HDLC)
+ write_raw(cs->bcs + 1, p, cnt);
+ cs->hw.njet.irqstat0 &= 0xfc;
+}
+
+static void
+tiger_l2l1(struct PStack *st, int pr, void *arg)
+{
+ struct sk_buff *skb = arg;
+ long flags;
+
+ switch (pr) {
+ case (PH_DATA_REQ):
+ save_flags(flags);
+ cli();
+ if (st->l1.bcs->hw.tiger.tx_skb) {
+ skb_queue_tail(&st->l1.bcs->squeue, skb);
+ restore_flags(flags);
+ } else {
+ st->l1.bcs->hw.tiger.tx_skb = skb;
+ st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
+ restore_flags(flags);
+ }
+ break;
+ case (PH_PULL_IND):
+ if (st->l1.bcs->hw.tiger.tx_skb) {
+ printk(KERN_WARNING "tiger_l2l1: this shouldn't happen\n");
+ break;
+ }
+ save_flags(flags);
+ cli();
+ st->l1.bcs->hw.tiger.tx_skb = skb;
+ st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
+ restore_flags(flags);
+ break;
+ case (PH_PULL_REQ):
+ if (!st->l1.bcs->hw.tiger.tx_skb) {
+ test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
+ st->l1.l1l2(st, PH_PULL_CNF, NULL);
+ } else
+ test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
+ break;
+ }
+}
+
+void
+close_tigerstate(struct BCState *bcs)
+{
+ struct sk_buff *skb;
+
+ mode_tiger(bcs, 0, 0);
+ if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
+ if (bcs->hw.tiger.rcvbuf) {
+ kfree(bcs->hw.tiger.rcvbuf);
+ bcs->hw.tiger.rcvbuf = NULL;
+ }
+ if (bcs->hw.tiger.sendbuf) {
+ kfree(bcs->hw.tiger.sendbuf);
+ bcs->hw.tiger.sendbuf = NULL;
+ }
+ while ((skb = skb_dequeue(&bcs->rqueue))) {
+ dev_kfree_skb(skb);
+ }
+ while ((skb = skb_dequeue(&bcs->squeue))) {
+ dev_kfree_skb(skb);
+ }
+ if (bcs->hw.tiger.tx_skb) {
+ dev_kfree_skb(bcs->hw.tiger.tx_skb);
+ bcs->hw.tiger.tx_skb = NULL;
+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
+ }
+ }
+}
+
+static int
+open_tigerstate(struct IsdnCardState *cs, int bc)
+{
+ struct BCState *bcs = cs->bcs + bc;
+
+ if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) {
+ if (!(bcs->hw.tiger.rcvbuf = kmalloc(HSCX_BUFMAX, GFP_KERNEL))) {
+ printk(KERN_WARNING
+ "HiSax: No memory for tiger.rcvbuf\n");
+ return (1);
+ }
+ if (!(bcs->hw.tiger.sendbuf = kmalloc(RAW_BUFMAX, GFP_KERNEL))) {
+ printk(KERN_WARNING
+ "HiSax: No memory for tiger.sendbuf\n");
+ return (1);
+ }
+ skb_queue_head_init(&bcs->rqueue);
+ skb_queue_head_init(&bcs->squeue);
+ }
+ bcs->hw.tiger.tx_skb = NULL;
+ bcs->hw.tiger.sendcnt = 0;
+ test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
+ bcs->event = 0;
+ bcs->tx_cnt = 0;
+ return (0);
+}
+
+static void
+tiger_manl1(struct PStack *st, int pr,
+ void *arg)
+{
+ switch (pr) {
+ case (PH_ACTIVATE_REQ):
+ test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
+ mode_tiger(st->l1.bcs, st->l1.mode, st->l1.bc);
+ st->l1.l1man(st, PH_ACTIVATE_CNF, NULL);
+ break;
+ case (PH_DEACTIVATE_REQ):
+ if (!test_bit(BC_FLG_BUSY, &st->l1.bcs->Flag))
+ mode_tiger(st->l1.bcs, 0, 0);
+ test_and_clear_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
+ break;
+ }
+}
+
+int
+setstack_tiger(struct PStack *st, struct BCState *bcs)
+{
+ if (open_tigerstate(st->l1.hardware, bcs->channel))
+ return (-1);
+ st->l1.bcs = bcs;
+ st->l2.l2l1 = tiger_l2l1;
+ st->ma.manl1 = tiger_manl1;
+ setstack_manager(st);
+ bcs->st = st;
+ return (0);
+}
+
+
+__initfunc(void
+inittiger(struct IsdnCardState *cs))
+{
+ char tmp[128];
+
+ if (!(cs->bcs[0].hw.tiger.send = kmalloc(NETJET_DMA_SIZE * sizeof(unsigned int),
+ GFP_KERNEL | GFP_DMA))) {
+ printk(KERN_WARNING
+ "HiSax: No memory for tiger.send\n");
+ return;
+ }
+ cs->bcs[0].hw.tiger.s_irq = cs->bcs[0].hw.tiger.send + NETJET_DMA_SIZE/2 - 1;
+ cs->bcs[0].hw.tiger.s_end = cs->bcs[0].hw.tiger.send + NETJET_DMA_SIZE - 1;
+ cs->bcs[1].hw.tiger.send = cs->bcs[0].hw.tiger.send;
+ cs->bcs[1].hw.tiger.s_irq = cs->bcs[0].hw.tiger.s_irq;
+ cs->bcs[1].hw.tiger.s_end = cs->bcs[0].hw.tiger.s_end;
+
+ memset(cs->bcs[0].hw.tiger.send, 0xff, NETJET_DMA_SIZE * sizeof(unsigned int));
+ sprintf(tmp, "tiger: send buf %x - %x", (u_int)cs->bcs[0].hw.tiger.send,
+ (u_int)(cs->bcs[0].hw.tiger.send + NETJET_DMA_SIZE - 1));
+ debugl1(cs, tmp);
+ outl(virt_to_bus(cs->bcs[0].hw.tiger.send),
+ cs->hw.njet.base + NETJET_DMA_READ_START);
+ outl(virt_to_bus(cs->bcs[0].hw.tiger.s_irq),
+ cs->hw.njet.base + NETJET_DMA_READ_IRQ);
+ outl(virt_to_bus(cs->bcs[0].hw.tiger.s_end),
+ cs->hw.njet.base + NETJET_DMA_READ_END);
+ if (!(cs->bcs[0].hw.tiger.rec = kmalloc(NETJET_DMA_SIZE * sizeof(unsigned int),
+ GFP_KERNEL | GFP_DMA))) {
+ printk(KERN_WARNING
+ "HiSax: No memory for tiger.rec\n");
+ return;
+ }
+ sprintf(tmp, "tiger: rec buf %x - %x", (u_int)cs->bcs[0].hw.tiger.rec,
+ (u_int)(cs->bcs[0].hw.tiger.rec + NETJET_DMA_SIZE - 1));
+ debugl1(cs, tmp);
+ cs->bcs[1].hw.tiger.rec = cs->bcs[0].hw.tiger.rec;
+ memset(cs->bcs[0].hw.tiger.rec, 0xff, NETJET_DMA_SIZE * sizeof(unsigned int));
+ outl(virt_to_bus(cs->bcs[0].hw.tiger.rec),
+ cs->hw.njet.base + NETJET_DMA_WRITE_START);
+ outl(virt_to_bus(cs->bcs[0].hw.tiger.rec + NETJET_DMA_SIZE/2 - 1),
+ cs->hw.njet.base + NETJET_DMA_WRITE_IRQ);
+ outl(virt_to_bus(cs->bcs[0].hw.tiger.rec + NETJET_DMA_SIZE - 1),
+ cs->hw.njet.base + NETJET_DMA_WRITE_END);
+ sprintf(tmp, "tiger: dmacfg %x/%x pulse=%d",
+ inl(cs->hw.njet.base + NETJET_DMA_WRITE_ADR),
+ inl(cs->hw.njet.base + NETJET_DMA_READ_ADR),
+ bytein(cs->hw.njet.base + NETJET_PULSE_CNT));
+ debugl1(cs, tmp);
+ cs->hw.njet.last_is0 = 0;
+ cs->bcs[0].BC_SetStack = setstack_tiger;
+ cs->bcs[1].BC_SetStack = setstack_tiger;
+ cs->bcs[0].BC_Close = close_tigerstate;
+ cs->bcs[1].BC_Close = close_tigerstate;
+}
+
+void
+releasetiger(struct IsdnCardState *cs)
+{
+ if (cs->bcs[0].hw.tiger.send) {
+ kfree(cs->bcs[0].hw.tiger.send);
+ cs->bcs[0].hw.tiger.send = NULL;
+ }
+ if (cs->bcs[1].hw.tiger.send) {
+ cs->bcs[1].hw.tiger.send = NULL;
+ }
+ if (cs->bcs[0].hw.tiger.rec) {
+ kfree(cs->bcs[0].hw.tiger.rec);
+ cs->bcs[0].hw.tiger.rec = NULL;
+ }
+ if (cs->bcs[1].hw.tiger.rec) {
+ cs->bcs[1].hw.tiger.rec = NULL;
+ }
+}
+
+static void
+netjet_interrupt(int intno, void *dev_id, struct pt_regs *regs)
+{
+ struct IsdnCardState *cs = dev_id;
+ u_char val, sval, stat = 1;
+ char tmp[128];
+
+ if (!cs) {
+ printk(KERN_WARNING "NETjet: Spurious interrupt!\n");
+ return;
+ }
+ if (!((sval = bytein(cs->hw.njet.base + NETJET_IRQSTAT1)) &
+ NETJET_ISACIRQ)) {
+ val = ReadISAC(cs, ISAC_ISTA);
+ if (cs->debug & L1_DEB_ISAC) {
+ sprintf(tmp, "tiger: i1 %x %x", sval, val);
+ debugl1(cs, tmp);
+ }
+ if (val) {
+ isac_interrupt(cs, val);
+ stat |= 2;
+ }
+ }
+ if ((cs->hw.njet.irqstat0 = bytein(cs->hw.njet.base + NETJET_IRQSTAT0))) {
+/* sprintf(tmp, "tiger: ist0 %x %x %x %x/%x pulse=%d",
+ sval,
+ bytein(cs->hw.njet.base + NETJET_DMACTRL),
+ bytein(cs->hw.njet.base + NETJET_IRQMASK0),
+ inl(cs->hw.njet.base + NETJET_DMA_READ_ADR),
+ inl(cs->hw.njet.base + NETJET_DMA_WRITE_ADR),
+ bytein(cs->hw.njet.base + NETJET_PULSE_CNT));
+ debugl1(cs, tmp);
+*/
+ if (cs->hw.njet.last_is0 & cs->hw.njet.irqstat0 & 0xf) {
+ sprintf(tmp, "tiger: ist0 %x->%x irq lost",
+ cs->hw.njet.last_is0, cs->hw.njet.irqstat0);
+ debugl1(cs, tmp);
+ }
+ cs->hw.njet.last_is0 = cs->hw.njet.irqstat0;
+/* cs->hw.njet.irqmask0 = ((0x0f & cs->hw.njet.irqstat0) ^ 0x0f) | 0x30;
+*/ byteout(cs->hw.njet.base + NETJET_IRQSTAT0, cs->hw.njet.irqstat0);
+/* byteout(cs->hw.njet.base + NETJET_IRQMASK0, cs->hw.njet.irqmask0);
+*/ if (cs->hw.njet.irqstat0 & 0x0c)
+ read_tiger(cs);
+ if (cs->hw.njet.irqstat0 & 0x03)
+ write_tiger(cs);
+ }
+/* if (!testcnt--) {
+ cs->hw.njet.dmactrl = 0;
+ byteout(cs->hw.njet.base + NETJET_DMACTRL,
+ cs->hw.njet.dmactrl);
+ byteout(cs->hw.njet.base + NETJET_IRQMASK0, 0);
+ }
+*/ if (stat & 2) {
+ WriteISAC(cs, ISAC_MASK, 0xFF);
+ WriteISAC(cs, ISAC_MASK, 0x0);
+ }
+}
+
+static void
+reset_netjet(struct IsdnCardState *cs)
+{
+ long flags;
+
+ save_flags(flags);
+ sti();
+ cs->hw.njet.ctrl_reg = 0xff; /* Reset On */
+ byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + (10 * HZ) / 1000; /* Timeout 10ms */
+ schedule();
+ cs->hw.njet.ctrl_reg = 0x00; /* Reset Off and status read clear */
+ byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + (10 * HZ) / 1000; /* Timeout 10ms */
+ schedule();
+ restore_flags(flags);
+ cs->hw.njet.auxd = 0;
+ cs->hw.njet.dmactrl = 0;
+ byteout(cs->hw.njet.base + NETJET_AUXCTRL, ~NETJET_ISACIRQ);
+ byteout(cs->hw.njet.base + NETJET_IRQMASK1, NETJET_ISACIRQ);
+ byteout(cs->hw.njet.auxa, cs->hw.njet.auxd);
+}
+
+void
+release_io_netjet(struct IsdnCardState *cs)
+{
+ byteout(cs->hw.njet.base + NETJET_IRQMASK0, 0);
+ byteout(cs->hw.njet.base + NETJET_IRQMASK1, 0);
+ releasetiger(cs);
+ release_region(cs->hw.njet.base, 256);
+}
+
+
+static int
+NETjet_card_msg(struct IsdnCardState *cs, int mt, void *arg)
+{
+ switch (mt) {
+ case CARD_RESET:
+ reset_netjet(cs);
+ return(0);
+ case CARD_RELEASE:
+ release_io_netjet(cs);
+ return(0);
+ case CARD_SETIRQ:
+ return(request_irq(cs->irq, &netjet_interrupt,
+ I4L_IRQ_FLAG, "HiSax", cs));
+ case CARD_INIT:
+ inittiger(cs);
+ clear_pending_isac_ints(cs);
+ initisac(cs);
+ return(0);
+ case CARD_TEST:
+ return(0);
+ }
+ return(0);
+}
+
+
+
+static int pci_index __initdata = 0;
+
+__initfunc(int
+setup_netjet(struct IsdnCard *card))
+{
+ int bytecnt;
+ struct IsdnCardState *cs = card->cs;
+ char tmp[64];
+#if CONFIG_PCI
+ u_char pci_bus, pci_device_fn, pci_irq;
+ u_int pci_ioaddr, found;
+#endif
+
+ strcpy(tmp, NETjet_revision);
+ printk(KERN_INFO "HiSax: Traverse Tech. NETjet driver Rev. %s\n", HiSax_getrev(tmp));
+ if (cs->typ != ISDN_CTYPE_NETJET)
+ return(0);
+#if CONFIG_PCI
+ found = 0;
+ for (; pci_index < 0xff; pci_index++) {
+ if (pcibios_find_device(PCI_VENDOR_TRAVERSE_TECH,
+ PCI_NETJET_ID, pci_index, &pci_bus, &pci_device_fn)
+ == PCIBIOS_SUCCESSFUL)
+ found = 1;
+ else
+ break;
+ /* get IRQ */
+ pcibios_read_config_byte(pci_bus, pci_device_fn,
+ PCI_INTERRUPT_LINE, &pci_irq);
+
+ /* get IO address */
+ pcibios_read_config_dword(pci_bus, pci_device_fn,
+ PCI_BASE_ADDRESS_0, &pci_ioaddr);
+ if (found)
+ break;
+ }
+ if (!found) {
+ printk(KERN_WARNING "NETjet: No PCI card found\n");
+ return(0);
+ }
+ if (!pci_irq) {
+ printk(KERN_WARNING "NETjet: No IRQ for PCI card found\n");
+ return(0);
+ }
+ if (!pci_ioaddr) {
+ printk(KERN_WARNING "NETjet: No IO-Adr for PCI card found\n");
+ return(0);
+ }
+ pci_ioaddr &= ~3; /* remove io/mem flag */
+ cs->hw.njet.base = pci_ioaddr;
+ cs->hw.njet.auxa = pci_ioaddr + NETJET_AUXDATA;
+ cs->hw.njet.isac = pci_ioaddr | NETJET_ISAC_OFF;
+ cs->irq = pci_irq;
+ bytecnt = 256;
+#else
+ printk(KERN_WARNING "NETjet: NO_PCI_BIOS\n");
+ printk(KERN_WARNING "NETjet: unable to config NETJET PCI\n");
+ return (0);
+#endif /* CONFIG_PCI */
+ printk(KERN_INFO
+ "NETjet: PCI card configured at 0x%x IRQ %d\n",
+ cs->hw.njet.base, cs->irq);
+ if (check_region(cs->hw.njet.base, bytecnt)) {
+ printk(KERN_WARNING
+ "HiSax: %s config port %x-%x already in use\n",
+ CardType[card->typ],
+ cs->hw.njet.base,
+ cs->hw.njet.base + bytecnt);
+ return (0);
+ } else {
+ request_region(cs->hw.njet.base, bytecnt, "netjet isdn");
+ }
+ reset_netjet(cs);
+ cs->readisac = &ReadISAC;
+ cs->writeisac = &WriteISAC;
+ cs->readisacfifo = &ReadISACfifo;
+ cs->writeisacfifo = &WriteISACfifo;
+ cs->BC_Read_Reg = &dummyrr;
+ cs->BC_Write_Reg = &dummywr;
+ cs->BC_Send_Data = &fill_dma;
+ cs->cardmsg = &NETjet_card_msg;
+ ISACVersion(cs, "NETjet:");
+ return (1);
+}
diff --git a/drivers/isdn/hisax/niccy.c b/drivers/isdn/hisax/niccy.c
new file mode 100644
index 000000000..59a8a94e3
--- /dev/null
+++ b/drivers/isdn/hisax/niccy.c
@@ -0,0 +1,354 @@
+/* $Id: niccy.c,v 1.2 1998/02/11 17:31:04 keil Exp $
+
+ * niccy.c low level stuff for Dr. Neuhaus NICCY PnP and NICCY PCI and
+ * compatible (SAGEM cybermodem)
+ *
+ * Author Karsten Keil
+ *
+ * Thanks to Dr. Neuhaus and SAGEM for informations
+ *
+ * $Log: niccy.c,v $
+ * Revision 1.2 1998/02/11 17:31:04 keil
+ * new file
+ *
+ *
+ *
+ */
+
+#include <linux/config.h>
+#define __NO_VERSION__
+#include "hisax.h"
+#include "isac.h"
+#include "hscx.h"
+#include "isdnl1.h"
+#include <linux/pci.h>
+#include <linux/bios32.h>
+
+extern const char *CardType[];
+const char *niccy_revision = "$Revision: 1.2 $";
+
+#define byteout(addr,val) outb(val,addr)
+#define bytein(addr) inb(addr)
+
+#define ISAC_PCI_DATA 0
+#define HSCX_PCI_DATA 1
+#define ISAC_PCI_ADDR 2
+#define HSCX_PCI_ADDR 3
+#define ISAC_PNP 0
+#define HSCX_PNP 1
+
+/* SUB Types */
+#define NICCY_PNP 1
+#define NICCY_PCI 2
+
+/* PCI stuff */
+#define PCI_VENDOR_DR_NEUHAUS 0x1267
+#define PCI_NICCY_ID 0x1016
+
+static inline u_char
+readreg(unsigned int ale, unsigned int adr, u_char off)
+{
+ register u_char ret;
+ long flags;
+
+ save_flags(flags);
+ cli();
+ byteout(ale, off);
+ ret = bytein(adr);
+ restore_flags(flags);
+ return (ret);
+}
+
+static inline void
+readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
+{
+ /* fifo read without cli because it's allready done */
+
+ byteout(ale, off);
+ insb(adr, data, size);
+}
+
+
+static inline void
+writereg(unsigned int ale, unsigned int adr, u_char off, u_char data)
+{
+ long flags;
+
+ save_flags(flags);
+ cli();
+ byteout(ale, off);
+ byteout(adr, data);
+ restore_flags(flags);
+}
+
+static inline void
+writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
+{
+ /* fifo write without cli because it's allready done */
+ byteout(ale, off);
+ outsb(adr, data, size);
+}
+
+/* Interface functions */
+
+static u_char
+ReadISAC(struct IsdnCardState *cs, u_char offset)
+{
+ return (readreg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, offset));
+}
+
+static void
+WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
+{
+ writereg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, offset, value);
+}
+
+static void
+ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
+{
+ readfifo(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, 0, data, size);
+}
+
+static void
+WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
+{
+ writefifo(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, 0, data, size);
+}
+
+static u_char
+ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
+{
+ return (readreg(cs->hw.niccy.hscx_ale,
+ cs->hw.niccy.hscx, offset + (hscx ? 0x40 : 0)));
+}
+
+static void
+WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
+{
+ writereg(cs->hw.niccy.hscx_ale,
+ cs->hw.niccy.hscx, offset + (hscx ? 0x40 : 0), value);
+}
+
+#define READHSCX(cs, nr, reg) readreg(cs->hw.niccy.hscx_ale, \
+ cs->hw.niccy.hscx, reg + (nr ? 0x40 : 0))
+#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.niccy.hscx_ale, \
+ cs->hw.niccy.hscx, reg + (nr ? 0x40 : 0), data)
+
+#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.niccy.hscx_ale, \
+ cs->hw.niccy.hscx, (nr ? 0x40 : 0), ptr, cnt)
+
+#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.niccy.hscx_ale, \
+ cs->hw.niccy.hscx, (nr ? 0x40 : 0), ptr, cnt)
+
+#include "hscx_irq.c"
+
+static void
+niccy_interrupt(int intno, void *dev_id, struct pt_regs *regs)
+{
+ struct IsdnCardState *cs = dev_id;
+ u_char val, stat = 0;
+
+ if (!cs) {
+ printk(KERN_WARNING "Niccy: Spurious interrupt!\n");
+ return;
+ }
+ val = readreg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, HSCX_ISTA + 0x40);
+ Start_HSCX:
+ if (val) {
+ hscx_int_main(cs, val);
+ stat |= 1;
+ }
+ val = readreg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, ISAC_ISTA);
+ Start_ISAC:
+ if (val) {
+ isac_interrupt(cs, val);
+ stat |= 2;
+ }
+ val = readreg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, HSCX_ISTA + 0x40);
+ if (val) {
+ if (cs->debug & L1_DEB_HSCX)
+ debugl1(cs, "HSCX IntStat after IntRoutine");
+ goto Start_HSCX;
+ }
+ val = readreg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, ISAC_ISTA);
+ if (val) {
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ISAC IntStat after IntRoutine");
+ goto Start_ISAC;
+ }
+ if (stat & 1) {
+ writereg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, HSCX_MASK, 0xFF);
+ writereg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, HSCX_MASK + 0x40, 0xFF);
+ writereg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, HSCX_MASK, 0);
+ writereg(cs->hw.niccy.hscx_ale, cs->hw.niccy.hscx, HSCX_MASK + 0x40, 0);
+ }
+ if (stat & 2) {
+ writereg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, ISAC_MASK, 0xFF);
+ writereg(cs->hw.niccy.isac_ale, cs->hw.niccy.isac, ISAC_MASK, 0);
+ }
+}
+
+void
+release_io_niccy(struct IsdnCardState *cs)
+{
+ if (cs->subtyp == NICCY_PCI)
+ release_region(cs->hw.niccy.isac, 4);
+ else {
+ release_region(cs->hw.niccy.isac, 2);
+ release_region(cs->hw.niccy.isac_ale, 2);
+ }
+}
+
+static void
+niccy_reset(struct IsdnCardState *cs)
+{
+ // No reset procedure known
+}
+
+static int
+niccy_card_msg(struct IsdnCardState *cs, int mt, void *arg)
+{
+ switch (mt) {
+ case CARD_RESET:
+ niccy_reset(cs);
+ return(0);
+ case CARD_RELEASE:
+ release_io_niccy(cs);
+ return(0);
+ case CARD_SETIRQ:
+ return(request_irq(cs->irq, &niccy_interrupt,
+ I4L_IRQ_FLAG, "HiSax", cs));
+ case CARD_INIT:
+ clear_pending_isac_ints(cs);
+ clear_pending_hscx_ints(cs);
+ initisac(cs);
+ inithscx(cs);
+ return(0);
+ case CARD_TEST:
+ return(0);
+ }
+ return(0);
+}
+
+static int pci_index __initdata = 0;
+
+__initfunc(int
+setup_niccy(struct IsdnCard *card))
+{
+ struct IsdnCardState *cs = card->cs;
+ char tmp[64];
+
+ strcpy(tmp, niccy_revision);
+ printk(KERN_INFO "HiSax: Niccy driver Rev. %s\n", HiSax_getrev(tmp));
+ if (cs->typ != ISDN_CTYPE_NICCY)
+ return (0);
+
+ if (card->para[1]) {
+ cs->hw.niccy.isac = card->para[1] + ISAC_PNP;
+ cs->hw.niccy.hscx = card->para[1] + HSCX_PNP;
+ cs->hw.niccy.isac_ale = card->para[2] + ISAC_PNP;
+ cs->hw.niccy.hscx_ale = card->para[2] + HSCX_PNP;
+ cs->hw.niccy.cfg_reg = 0;
+ cs->subtyp = NICCY_PNP;
+ cs->irq = card->para[0];
+ if (check_region((cs->hw.niccy.isac), 2)) {
+ printk(KERN_WARNING
+ "HiSax: %s data port %x-%x already in use\n",
+ CardType[card->typ],
+ cs->hw.niccy.isac,
+ cs->hw.niccy.isac + 1);
+ return (0);
+ } else
+ request_region(cs->hw.niccy.isac, 2, "niccy data");
+ if (check_region((cs->hw.niccy.isac_ale), 2)) {
+ printk(KERN_WARNING
+ "HiSax: %s address port %x-%x already in use\n",
+ CardType[card->typ],
+ cs->hw.niccy.isac_ale,
+ cs->hw.niccy.isac_ale + 1);
+ release_region(cs->hw.niccy.isac, 2);
+ return (0);
+ } else
+ request_region(cs->hw.niccy.isac_ale, 2, "niccy addr");
+ } else {
+#if CONFIG_PCI
+ u_char pci_bus, pci_device_fn, pci_irq;
+ u_int pci_ioaddr;
+
+ cs->subtyp = 0;
+ for (; pci_index < 0xff; pci_index++) {
+ if (pcibios_find_device(PCI_VENDOR_DR_NEUHAUS,
+ PCI_NICCY_ID, pci_index, &pci_bus, &pci_device_fn)
+ == PCIBIOS_SUCCESSFUL)
+ cs->subtyp = NICCY_PCI;
+ else
+ break;
+ /* get IRQ */
+ pcibios_read_config_byte(pci_bus, pci_device_fn,
+ PCI_INTERRUPT_LINE, &pci_irq);
+
+ /* get IO address */
+ /* if it won't work try the other PCI addresses
+ * PCI_BASE_ADDRESS_0 ... PCI_BASE_ADDRESS_5
+ */
+ pcibios_read_config_dword(pci_bus, pci_device_fn,
+ PCI_BASE_ADDRESS_2, &pci_ioaddr);
+ if (cs->subtyp)
+ break;
+ }
+ if (!cs->subtyp) {
+ printk(KERN_WARNING "Niccy: No PCI card found\n");
+ return(0);
+ }
+ if (!pci_irq) {
+ printk(KERN_WARNING "Niccy: No IRQ for PCI card found\n");
+ return(0);
+ }
+
+ if (!pci_ioaddr) {
+ printk(KERN_WARNING "Niccy: No IO-Adr for PCI card found\n");
+ return(0);
+ }
+ pci_ioaddr &= ~3; /* remove io/mem flag */
+ cs->hw.niccy.isac = pci_ioaddr + ISAC_PCI_DATA;
+ cs->hw.niccy.isac_ale = pci_ioaddr + ISAC_PCI_ADDR;
+ cs->hw.niccy.hscx = pci_ioaddr + HSCX_PCI_DATA;
+ cs->hw.niccy.hscx_ale = pci_ioaddr + HSCX_PCI_ADDR;
+ cs->irq = pci_irq;
+ if (check_region((cs->hw.niccy.isac), 4)) {
+ printk(KERN_WARNING
+ "HiSax: %s data port %x-%x already in use\n",
+ CardType[card->typ],
+ cs->hw.niccy.isac,
+ cs->hw.niccy.isac + 4);
+ return (0);
+ } else
+ request_region(cs->hw.niccy.isac, 4, "niccy");
+#else
+ printk(KERN_WARNING "Niccy: io0 0 and NO_PCI_BIOS\n");
+ printk(KERN_WARNING "Niccy: unable to config NICCY PCI\n");
+ return (0);
+#endif /* CONFIG_PCI */
+ }
+ printk(KERN_INFO
+ "HiSax: %s %s config irq:%d data:0x%X ale:0x%X\n",
+ CardType[cs->typ], (cs->subtyp==1) ? "PnP":"PCI",
+ cs->irq, cs->hw.niccy.isac, cs->hw.niccy.isac_ale);
+ niccy_reset(cs);
+ cs->readisac = &ReadISAC;
+ cs->writeisac = &WriteISAC;
+ cs->readisacfifo = &ReadISACfifo;
+ cs->writeisacfifo = &WriteISACfifo;
+ cs->BC_Read_Reg = &ReadHSCX;
+ cs->BC_Write_Reg = &WriteHSCX;
+ cs->BC_Send_Data = &hscx_fill_fifo;
+ cs->cardmsg = &niccy_card_msg;
+ ISACVersion(cs, "Niccy:");
+ if (HscxVersion(cs, "Niccy:")) {
+ printk(KERN_WARNING
+ "Niccy: wrong HSCX versions check IO address\n");
+ release_io_niccy(cs);
+ return (0);
+ }
+ return (1);
+}
diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
index 1e1ee4772..a0ba3645a 100644
--- a/drivers/isdn/hisax/q931.c
+++ b/drivers/isdn/hisax/q931.c
@@ -1,4 +1,4 @@
-/* $Id: q931.c,v 1.5 1997/04/06 22:56:43 keil Exp $
+/* $Id: q931.c,v 1.6 1997/07/27 21:09:44 keil Exp $
* q931.c code to decode ITU Q.931 call control messages
*
@@ -14,6 +14,9 @@
*
*
* $Log: q931.c,v $
+ * Revision 1.6 1997/07/27 21:09:44 keil
+ * move functions to isdnl3.c
+ *
* Revision 1.5 1997/04/06 22:56:43 keil
* Some cosmetic changes
*
@@ -37,44 +40,6 @@
#include "hisax.h"
#include "l3_1tr6.h"
-u_char *
-findie(u_char * p, int size, u_char ie, int wanted_set)
-{
- int l, codeset, maincodeset;
- u_char *pend = p + size;
-
- /* skip protocol discriminator, callref and message type */
- p++;
- l = (*p++) & 0xf;
- p += l;
- p++;
- codeset = 0;
- maincodeset = 0;
- /* while there are bytes left... */
- while (p < pend) {
- if ((*p & 0xf0) == 0x90) {
- codeset = *p & 0x07;
- if (!(*p & 0x08))
- maincodeset = codeset;
- }
- if (*p & 0x80)
- p++;
- else {
- if (codeset == wanted_set) {
- if (*p == ie)
- return (p);
- if (*p > ie)
- return (NULL);
- }
- p++;
- l = *p++;
- p += l;
- codeset = maincodeset;
- }
- }
- return (NULL);
-}
-
void
iecpy(u_char * dest, u_char * iestart, int ieoffset)
{
@@ -88,14 +53,6 @@ iecpy(u_char * dest, u_char * iestart, int ieoffset)
*dest++ = '\0';
}
-int
-getcallref(u_char * p)
-{
- p++; /* prot discr */
- p++; /* callref length */
- return (*p); /* assuming one-byte callref */
-}
-
/*
* According to Table 4-2/Q.931
*/
diff --git a/drivers/isdn/hisax/rawhdlc.c b/drivers/isdn/hisax/rawhdlc.c
new file mode 100644
index 000000000..16938bc98
--- /dev/null
+++ b/drivers/isdn/hisax/rawhdlc.c
@@ -0,0 +1,539 @@
+/* $Id: rawhdlc.c,v 1.2 1998/02/09 10:53:51 keil Exp $
+
+ * rawhdlc.c support routines for cards that don't support HDLC
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ * Brent Baccala <baccala@FreeSoft.org>
+ *
+ *
+ * Some passive ISDN cards, such as the Traverse NETJet and the AMD 7930,
+ * don't perform HDLC encapsulation over the B channel. Drivers for
+ * such cards use support routines in this file to perform B channel HDLC.
+ *
+ * Bit-synchronous HDLC encapsulation is a means of encapsulating packets
+ * over a continuously transmitting serial communications link.
+ * It looks like this:
+ *
+ * 11111111101111110...........0111111011111111111
+ * iiiiiiiiiffffffffdddddddddddffffffffiiiiiiiiiii
+ *
+ * i = idle f = flag d = data
+ *
+ * When idle, the channel sends a continuous string of ones (mark
+ * idle; illustrated), or a continuous string of flag characters (flag
+ * idle). The beginning of a data frame is marked by a flag character
+ * (01111110), then comes the actual data, followed by another flag
+ * character, after which another frame may be sent immediately (a
+ * single flag may serve as both the end of one frame and the start of
+ * the next), or the link may return to idle. Obviously, the flag
+ * character can not appear anywhere in the data (or a false
+ * end-of-frame would occur), so the transmitter performs
+ * "bit-stuffing" - inserting a zero bit after every five one bits,
+ * irregardless of the original bit after the five ones. Byte
+ * ordering is irrelevent at this point - the data is treated as a
+ * string of bits, not bytes. Since no more than 5 ones may now occur
+ * in a row, the flag sequence, with its 6 ones, is unique.
+ *
+ * Upon reception, a zero bit that occur after 5 one bits is simply
+ * discarded. A series of 6 one bits is end-of-frame, and a series of
+ * 7 one bits is an abort. Once bit-stuffing has been corrected for,
+ * an integer number of bytes should now be present. The last two
+ * of these bytes form the Frame Check Sequence, a CRC that is verified
+ * and then discarded. Note that bit-stuffing is performed on the FCS
+ * just as if it were regular data.
+ *
+ *
+ *
+ * int make_raw_hdlc_data(u_char *src, u_int slen,
+ * u_char *dst, u_int dsize)
+ *
+ * Used for transmission. Copies slen bytes from src to dst, performing
+ * HDLC encapsulation (flag bytes, bit-stuffing, CRC) in the process.
+ * dsize is size of destination buffer, and should be at least
+ * ((6*slen)/5)+5 bytes to ensure adequate space will be available.
+ * Function returns length (in bytes) of valid destination buffer, or
+ * 0 upon destination overflow.
+ *
+ * void init_hdlc_state(struct hdlc_state *stateptr, int mode)
+ *
+ * Initializes hdlc_state structure before first call to read_raw_hdlc_data
+ *
+ * mode = 0: Sane mode
+ * mode = 1/2:
+ * Insane mode; NETJet use a shared unsigned int memory block (
+ * with busmaster DMA), the bit pattern of every word is
+ * <8 B1> <8 B2> <8 Mon> <2 D> <4 C/I> <MX> <MR>
+ * according to Siemens IOM-2 interface, so we have to handle
+ * the src buffer as unsigned int and have to shift/mask the
+ * B-channel bytes.
+ * mode 1 -> B1 mode 2 -> B2 data is used
+ *
+ * int read_raw_hdlc_data(struct hdlc_state *saved_state,
+ * u_char *src, u_int slen,
+ * u_char *dst, u_int dsize)
+ *
+ * Used for reception. Scans source buffer bit-by-bit looking for
+ * valid HDLC frames, which are copied to destination buffer. HDLC
+ * state information is stored in a structure, which allows this
+ * function to process frames spread across several blocks of raw
+ * HDLC data. Part of the state information is bit offsets into
+ * the source and destination buffers.
+ *
+ * A return value >0 indicates the length of a valid frame, now
+ * stored in the destination buffer. In this case, the source
+ * buffer might not be completely processed, so this function should
+ * be called again with the same source buffer, possibly with a
+ * different destination buffer.
+ *
+ * A return value of zero indicates that the source buffer was
+ * completely processed without finding a valid end-of-packet;
+ * however, we might be in the middle of packet reception, so
+ * the function should be called again with the next block of
+ * raw HDLC data and the same destination buffer. It is NOT
+ * permitted to change the destination buffer in this case,
+ * since data may already have begun to be stored there.
+ *
+ * A return value of -1 indicates some kind of error - destination
+ * buffer overflow, CRC check failed, frame not a multiple of 8
+ * bits. Destination buffer probably contains invalid data, which
+ * should be discarded. Call function again with same source buffer
+ * and a new (or same) destination buffer.
+ *
+ * Suggested calling sequence:
+ *
+ * init_hdlc_state(...);
+ * for (EACH_RAW_DATA_BLOCK) {
+ * while (len = read_raw_hdlc_data(...)) {
+ * if (len == -1) DISCARD_FRAME;
+ * else PROCESS_FRAME;
+ * }
+ * }
+ *
+ *
+ * Test the code in this file as follows:
+ * gcc -DDEBUGME -o rawhdlctest rawhdlc.c
+ * ./rawhdlctest < rawdata
+ *
+ * The file "rawdata" can be easily generated from a HISAX B-channel
+ * hex dump (CF CF CF 02 ...) using the following perl script:
+ *
+ * while(<>) {
+ * @hexlist = split ' ';
+ * while ($hexstr = shift(@hexlist)) {
+ * printf "%c", hex($hexstr);
+ * }
+ * }
+ *
+ */
+
+#ifdef DEBUGME
+#include <stdio.h>
+#endif
+
+#include <linux/types.h>
+#include <linux/ppp_defs.h>
+#include "rawhdlc.h"
+
+/* There's actually an identical copy of this table in the PPP code
+ * (ppp_crc16_table), but I don't want this code dependant on PPP
+ */
+
+// static
+__u16 fcstab[256] =
+{
+ 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
+ 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
+ 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
+ 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
+ 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
+ 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
+ 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
+ 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
+ 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
+ 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
+ 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
+ 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
+ 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
+ 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
+ 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
+ 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
+ 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
+ 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
+ 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
+ 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
+ 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
+ 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
+ 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
+ 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
+ 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
+ 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
+ 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
+ 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
+ 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
+ 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
+ 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
+ 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
+};
+
+#define HDLC_ZERO_SEARCH 0
+#define HDLC_FLAG_SEARCH 1
+#define HDLC_FLAG_FOUND 2
+#define HDLC_FRAME_FOUND 3
+#define HDLC_NULL 4
+#define HDLC_PART 5
+#define HDLC_FULL 6
+
+#define HDLC_FLAG_VALUE 0x7e
+
+
+#define MAKE_RAW_BYTE for (j=0; j<8; j++) { \
+ bitcnt++;\
+ out_val >>= 1;\
+ if (val & 1) {\
+ s_one++;\
+ out_val |= 0x80;\
+ } else {\
+ s_one = 0;\
+ out_val &= 0x7f;\
+ }\
+ if (bitcnt==8) {\
+ if (d_cnt == dsize) return 0;\
+ dst[d_cnt++] = out_val;\
+ bitcnt = 0;\
+ }\
+ if (s_one == 5) {\
+ out_val >>= 1;\
+ out_val &= 0x7f;\
+ bitcnt++;\
+ s_one = 0;\
+ }\
+ if (bitcnt==8) {\
+ if (d_cnt == dsize) return 0;\
+ dst[d_cnt++] = out_val;\
+ bitcnt = 0;\
+ }\
+ val >>= 1;\
+ }
+
+/* Optimization suggestion: If needed, this function could be
+ * dramatically sped up using a state machine. Each state would
+ * correspond to having seen N one bits, and being offset M bits into
+ * the current output byte. N ranges from 0 to 4, M from 0 to 7, so
+ * we need 5*8 = 35 states. Each state would have a table with 256
+ * entries, one for each input character. Each entry would contain
+ * three output characters, an output state, an a byte increment
+ * that's either 1 or 2. All this could fit in four bytes; so we need
+ * 4 bytes * 256 characters = 1 KB for each state (35 KB total). Zero
+ * the output buffer before you start. For each character in your
+ * input, you look it up in the current state's table and get three
+ * bytes to be or'ed into the output at the current byte offset, and
+ * an byte increment to move your pointer forward. A simple Perl
+ * script could generate the tables. Given HDLC semantics, probably
+ * would be better to set output to all 1s, then use ands instead of ors.
+ * A smaller state machine could operate on nibbles instead of bytes.
+ * A state machine for 32-bit architectures could use word offsets
+ * instead of byte offsets, requiring 5*32 = 160 states; probably
+ * best to work on nibbles in such a case.
+ */
+
+
+int make_raw_hdlc_data(u_char *src, u_int slen, u_char *dst, u_int dsize)
+{
+ register u_int i,d_cnt=0;
+ register u_char j;
+ register u_char val;
+ register u_char s_one = 0;
+ register u_char out_val = 0;
+ register u_char bitcnt = 0;
+ u_int fcs;
+
+
+ dst[d_cnt++] = HDLC_FLAG_VALUE;
+ fcs = PPP_INITFCS;
+ for (i=0; i<slen; i++) {
+ val = src[i];
+ fcs = PPP_FCS (fcs, val);
+ MAKE_RAW_BYTE;
+ }
+ fcs ^= 0xffff;
+ val = fcs & 0xff;
+ MAKE_RAW_BYTE;
+ val = (fcs>>8) & 0xff;
+ MAKE_RAW_BYTE;
+ val = HDLC_FLAG_VALUE;
+ for (j=0; j<8; j++) {
+ bitcnt++;
+ out_val >>= 1;
+ if (val & 1)
+ out_val |= 0x80;
+ else
+ out_val &= 0x7f;
+ if (bitcnt==8) {
+ if (d_cnt == dsize) return 0;
+ dst[d_cnt++] = out_val;
+ bitcnt = 0;
+ }
+ val >>= 1;
+ }
+ if (bitcnt) {
+ while (8>bitcnt++) {
+ out_val >>= 1;
+ out_val |= 0x80;
+ }
+ if (d_cnt == dsize) return 0;
+ dst[d_cnt++] = out_val;
+ }
+
+ return d_cnt;
+}
+
+void init_hdlc_state(struct hdlc_state *stateptr, int mode)
+{
+ stateptr->state = HDLC_ZERO_SEARCH;
+ stateptr->r_one = 0;
+ stateptr->r_val = 0;
+ stateptr->o_bitcnt = 0;
+ stateptr->i_bitcnt = 0;
+ stateptr->insane_mode = mode;
+}
+
+/* Optimization suggestion: A similar state machine could surely
+ * be developed for this function as well.
+ */
+
+int read_raw_hdlc_data(struct hdlc_state *saved_state,
+ u_char *src, u_int slen, u_char *dst, u_int dsize)
+{
+ int retval=0;
+ register u_char val;
+ register u_char state = saved_state->state;
+ register u_char r_one = saved_state->r_one;
+ register u_char r_val = saved_state->r_val;
+ register u_int o_bitcnt = saved_state->o_bitcnt;
+ register u_int i_bitcnt = saved_state->i_bitcnt;
+ register u_int fcs = saved_state->fcs;
+ register u_int *isrc = (u_int *) src;
+
+ /* Use i_bitcnt (bit offset into source buffer) to reload "val"
+ * in case we're starting up again partway through a source buffer
+ */
+
+ if ((i_bitcnt >> 3) < slen) {
+ if (saved_state->insane_mode==1) {
+ val = isrc[(i_bitcnt >> 3)] & 0xff;
+ } else if (saved_state->insane_mode==2) {
+ val = (isrc[i_bitcnt >> 3] >>8) & 0xff;
+ } else {
+ val = src[i_bitcnt >> 3];
+ }
+ val >>= i_bitcnt & 7;
+ }
+
+ /* One bit per loop. Keep going until we've got something to
+ * report (retval != 0), or we exhaust the source buffer
+ */
+
+ while ((retval == 0) && ((i_bitcnt >> 3) < slen)) {
+ if ((i_bitcnt & 7) == 0) {
+ if (saved_state->insane_mode==1) {
+ val = isrc[(i_bitcnt >> 3)] & 0xff;
+ } else if (saved_state->insane_mode==2) {
+ val = (isrc[i_bitcnt >> 3] >>8) & 0xff;
+ } else {
+ val = src[i_bitcnt >> 3];
+ }
+#ifdef DEBUGME
+ printf("Input byte %d: 0x%2x\n", i_bitcnt>>3, val);
+#endif
+ if (val == 0xff) {
+ state = HDLC_ZERO_SEARCH;
+ o_bitcnt = 0;
+ r_one = 0;
+ i_bitcnt += 8;
+ continue;
+ }
+ }
+
+#ifdef DEBUGME
+ /* printf("Data bit=%d (%d/%d)\n", val&1, i_bitcnt>>3, i_bitcnt&7);*/
+#endif
+
+ if (state == HDLC_ZERO_SEARCH) {
+ if (val & 1) {
+ r_one++;
+ } else {
+ r_one=0;
+ state= HDLC_FLAG_SEARCH;
+ }
+ } else if (state == HDLC_FLAG_SEARCH) {
+ if (val & 1) {
+ r_one++;
+ if (r_one>6) {
+ state=HDLC_ZERO_SEARCH;
+ }
+ } else {
+ if (r_one==6) {
+ o_bitcnt=0;
+ r_val=0;
+ state=HDLC_FLAG_FOUND;
+ }
+ r_one=0;
+ }
+ } else if (state == HDLC_FLAG_FOUND) {
+ if (val & 1) {
+ r_one++;
+ if (r_one>6) {
+ state=HDLC_ZERO_SEARCH;
+ } else {
+ r_val >>= 1;
+ r_val |= 0x80;
+ o_bitcnt++;
+ }
+ } else {
+ if (r_one==6) {
+ o_bitcnt=0;
+ r_val=0;
+ r_one=0;
+ i_bitcnt++;
+ val >>= 1;
+ continue;
+ } else if (r_one!=5) {
+ r_val >>= 1;
+ r_val &= 0x7f;
+ o_bitcnt++;
+ }
+ r_one=0;
+ }
+ if ((state != HDLC_ZERO_SEARCH) &&
+ !(o_bitcnt & 7)) {
+#ifdef DEBUGME
+ printf("HDLC_FRAME_FOUND at i_bitcnt:%d\n",i_bitcnt);
+#endif
+ state=HDLC_FRAME_FOUND;
+ fcs = PPP_INITFCS;
+ dst[0] = r_val;
+ fcs = PPP_FCS (fcs, r_val);
+ }
+ } else if (state == HDLC_FRAME_FOUND) {
+ if (val & 1) {
+ r_one++;
+ if (r_one>6) {
+ state=HDLC_ZERO_SEARCH;
+ o_bitcnt=0;
+ } else {
+ r_val >>= 1;
+ r_val |= 0x80;
+ o_bitcnt++;
+ }
+ } else {
+ if (r_one==6) {
+ r_val=0;
+ r_one=0;
+ o_bitcnt++;
+ if (o_bitcnt & 7) {
+ /* Alignment error */
+#ifdef DEBUGME
+ printf("Alignment error\n");
+#endif
+ state=HDLC_FLAG_SEARCH;
+ retval = -1;
+ } else if (fcs==PPP_GOODFCS) {
+ /* Valid frame */
+ state=HDLC_FLAG_FOUND;
+ retval = (o_bitcnt>>3)-3;
+ } else {
+ /* CRC error */
+#ifdef DEBUGME
+ printf("CRC error; fcs was 0x%x, should have been 0x%x\n", fcs, PPP_GOODFCS);
+#endif
+ state=HDLC_FLAG_FOUND;
+ retval = -1;
+ }
+ } else if (r_one==5) {
+ r_one=0;
+ i_bitcnt++;
+ val >>= 1;
+ continue;
+ } else {
+ r_val >>= 1;
+ r_val &= 0x7f;
+ o_bitcnt++;
+ }
+ r_one=0;
+ }
+ if ((state == HDLC_FRAME_FOUND) &&
+ !(o_bitcnt & 7)) {
+ if ((o_bitcnt>>3)>=dsize) {
+ /* Buffer overflow error */
+#ifdef DEBUGME
+ printf("Buffer overflow error\n");
+#endif
+ r_val=0;
+ state=HDLC_FLAG_SEARCH;
+ retval = -1;
+ } else {
+ dst[(o_bitcnt>>3)-1] = r_val;
+ fcs = PPP_FCS (fcs, r_val);
+#ifdef DEBUGME
+ printf("Output byte %d: 0x%02x; FCS 0x%04x\n", (o_bitcnt>>3)-1, r_val, fcs);
+#endif
+ }
+ }
+ }
+ i_bitcnt ++;
+ val >>= 1;
+ }
+
+ /* We exhausted the source buffer before anything else happened
+ * (retval==0). Reset i_bitcnt in expectation of a new source
+ * buffer. Other, we either had an error or a valid frame, so
+ * reset o_bitcnt in expectation of a new destination buffer.
+ */
+
+ if (retval == 0) {
+ i_bitcnt = 0;
+ } else {
+ o_bitcnt = 0;
+ }
+
+ saved_state->state = state;
+ saved_state->r_one = r_one;
+ saved_state->r_val = r_val;
+ saved_state->fcs = fcs;
+ saved_state->o_bitcnt = o_bitcnt;
+ saved_state->i_bitcnt = i_bitcnt;
+
+ return (retval);
+}
+
+
+
+#ifdef DEBUGME
+
+char buffer[1024];
+char obuffer[1024];
+
+main()
+{
+ int buflen=0;
+ int len;
+ struct hdlc_state hdlc_state;
+
+ while((buffer[buflen] = getc(stdin)) != EOF && buflen<1024) buflen++;
+
+ printf("buflen = %d\n", buflen);
+
+ init_hdlc_state(&hdlc_state, 0);
+
+ while (len = read_raw_hdlc_data(&hdlc_state,buffer,buflen,obuffer,1024)) {
+ if (len == -1) printf("Error @ byte %d/bit %d\n",
+ hdlc_state.i_bitcnt>>3, hdlc_state.i_bitcnt & 7);
+ else {
+ printf("Frame received: len %d\n", len);
+ }
+ }
+
+ printf("Done\n");
+}
+
+#endif
diff --git a/drivers/isdn/hisax/rawhdlc.h b/drivers/isdn/hisax/rawhdlc.h
new file mode 100644
index 000000000..d946fa0b3
--- /dev/null
+++ b/drivers/isdn/hisax/rawhdlc.h
@@ -0,0 +1,26 @@
+/* $Id: rawhdlc.h,v 1.2 1998/02/09 10:53:53 keil Exp $
+
+ * rawhdlc.h support routines for cards that don't support HDLC
+ *
+ * Author Brent Baccala <baccala@FreeSoft.org>
+ *
+ */
+
+#ifndef RAWHDLC_H
+struct hdlc_state {
+ char insane_mode;
+ u_char state;
+ u_char r_one;
+ u_char r_val;
+ u_int o_bitcnt;
+ u_int i_bitcnt;
+ u_int fcs;
+};
+
+
+int make_raw_hdlc_data(u_char *src, u_int slen, u_char *dst, u_int dsize);
+void init_hdlc_state(struct hdlc_state *stateptr, int mode);
+int read_raw_hdlc_data(struct hdlc_state *saved_state,
+ u_char *src, u_int slen, u_char *dst, u_int dsize);
+#define RAWHDLC_H
+#endif
diff --git a/drivers/isdn/hisax/sedlbauer.c b/drivers/isdn/hisax/sedlbauer.c
new file mode 100644
index 000000000..40dc8e622
--- /dev/null
+++ b/drivers/isdn/hisax/sedlbauer.c
@@ -0,0 +1,356 @@
+/* $Id: sedlbauer.c,v 1.6 1998/02/09 18:46:06 keil Exp $
+
+ * sedlbauer.c low level stuff for Sedlbauer cards
+ * includes Support for the Sedlbauer Speed Star
+ * derived from the original file dynalink.c from Karsten Keil
+ *
+ * Copyright (C) 1997,1998 Marcus Niemann (for the modifications to
+ * the original file dynalink.c)
+ *
+ * Author Marcus Niemann (niemann@www-bib.fh-bielefeld.de)
+ *
+ * Thanks to Karsten Keil
+ * Sedlbauer AG for informations
+ * Edgar Toernig
+ *
+ * $Log: sedlbauer.c,v $
+ * Revision 1.6 1998/02/09 18:46:06 keil
+ * Support for Sedlbauer PCMCIA (Marcus Niemann)
+ *
+ * Revision 1.5 1998/02/02 13:29:45 keil
+ * fast io
+ *
+ * Revision 1.4 1997/11/08 21:35:52 keil
+ * new l1 init
+ *
+ * Revision 1.3 1997/11/06 17:09:28 keil
+ * New 2.1 init code
+ *
+ * Revision 1.2 1997/10/29 18:55:52 keil
+ * changes for 2.1.60 (irq2dev_map)
+ *
+ * Revision 1.1 1997/09/11 17:32:04 keil
+ * new
+ *
+ *
+ */
+
+#define __NO_VERSION__
+#include "hisax.h"
+#include "isac.h"
+#include "hscx.h"
+#include "isdnl1.h"
+
+extern const char *CardType[];
+
+const char *Sedlbauer_revision = "$Revision: 1.6 $";
+
+const char *Sedlbauer_Types[] =
+{"None", "Speed Card", "Speed Win", "Speed Star"};
+
+#define SEDL_SPEED_CARD 1
+#define SEDL_SPEED_WIN 2
+#define SEDL_SPEED_STAR 3
+
+#define byteout(addr,val) outb(val,addr)
+#define bytein(addr) inb(addr)
+
+#define SEDL_RESET_ON 0
+#define SEDL_RESET_OFF 1
+#define SEDL_ISAC 2
+#define SEDL_HSCX 3
+#define SEDL_ADR 4
+
+#define SEDL_PCMCIA_RESET 0
+#define SEDL_PCMCIA_ISAC 1
+#define SEDL_PCMCIA_HSCX 2
+#define SEDL_PCMCIA_ADR 4
+
+#define SEDL_RESET 0x3 /* same as DOS driver */
+
+static inline u_char
+readreg(unsigned int ale, unsigned int adr, u_char off)
+{
+ register u_char ret;
+ long flags;
+
+ save_flags(flags);
+ cli();
+ byteout(ale, off);
+ ret = bytein(adr);
+ restore_flags(flags);
+ return (ret);
+}
+
+static inline void
+readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
+{
+ /* fifo read without cli because it's allready done */
+
+ byteout(ale, off);
+ insb(adr, data, size);
+}
+
+
+static inline void
+writereg(unsigned int ale, unsigned int adr, u_char off, u_char data)
+{
+ long flags;
+
+ save_flags(flags);
+ cli();
+ byteout(ale, off);
+ byteout(adr, data);
+ restore_flags(flags);
+}
+
+static inline void
+writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
+{
+ /* fifo write without cli because it's allready done */
+ byteout(ale, off);
+ outsb(adr, data, size);
+}
+
+/* Interface functions */
+
+static u_char
+ReadISAC(struct IsdnCardState *cs, u_char offset)
+{
+ return (readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset));
+}
+
+static void
+WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
+{
+ writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset, value);
+}
+
+static void
+ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
+{
+ readfifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0, data, size);
+}
+
+static void
+WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
+{
+ writefifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0, data, size);
+}
+
+static u_char
+ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
+{
+ return (readreg(cs->hw.sedl.adr,
+ cs->hw.sedl.hscx, offset + (hscx ? 0x40 : 0)));
+}
+
+static void
+WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
+{
+ writereg(cs->hw.sedl.adr,
+ cs->hw.sedl.hscx, offset + (hscx ? 0x40 : 0), value);
+}
+
+/*
+ * fast interrupt HSCX stuff goes here
+ */
+
+#define READHSCX(cs, nr, reg) readreg(cs->hw.sedl.adr, \
+ cs->hw.sedl.hscx, reg + (nr ? 0x40 : 0))
+#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.sedl.adr, \
+ cs->hw.sedl.hscx, reg + (nr ? 0x40 : 0), data)
+
+#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.sedl.adr, \
+ cs->hw.sedl.hscx, (nr ? 0x40 : 0), ptr, cnt)
+
+#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.sedl.adr, \
+ cs->hw.sedl.hscx, (nr ? 0x40 : 0), ptr, cnt)
+
+#include "hscx_irq.c"
+
+static void
+sedlbauer_interrupt(int intno, void *dev_id, struct pt_regs *regs)
+{
+ struct IsdnCardState *cs = dev_id;
+ u_char val, stat = 0;
+
+ if (!cs) {
+ printk(KERN_WARNING "Sedlbauer: Spurious interrupt!\n");
+ return;
+ }
+
+ if ((cs->typ == ISDN_CTYPE_SEDLBAUER_PCMCIA) && (*cs->busy_flag == 1)) {
+ /* The card tends to generate interrupts while being removed
+ causing us to just crash the kernel. bad. */
+ printk(KERN_WARNING "Sedlbauer: card not available!\n");
+ return;
+ }
+
+ val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_ISTA + 0x40);
+ Start_HSCX:
+ if (val) {
+ hscx_int_main(cs, val);
+ stat |= 1;
+ }
+ val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA);
+ Start_ISAC:
+ if (val) {
+ isac_interrupt(cs, val);
+ stat |= 2;
+ }
+ val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_ISTA + 0x40);
+ if (val) {
+ if (cs->debug & L1_DEB_HSCX)
+ debugl1(cs, "HSCX IntStat after IntRoutine");
+ goto Start_HSCX;
+ }
+ val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA);
+ if (val) {
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ISAC IntStat after IntRoutine");
+ goto Start_ISAC;
+ }
+ if (stat & 1) {
+ writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK, 0xFF);
+ writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK + 0x40, 0xFF);
+ writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK, 0x0);
+ writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK + 0x40, 0x0);
+ }
+ if (stat & 2) {
+ writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_MASK, 0xFF);
+ writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_MASK, 0x0);
+ }
+}
+
+void
+release_io_sedlbauer(struct IsdnCardState *cs)
+{
+ int bytecnt = 8;
+
+ if (cs->hw.sedl.cfg_reg)
+ release_region(cs->hw.sedl.cfg_reg, bytecnt);
+}
+
+static void
+reset_sedlbauer(struct IsdnCardState *cs)
+{
+ long flags;
+
+ if (cs->typ != ISDN_CTYPE_SEDLBAUER_PCMCIA) {
+ byteout(cs->hw.sedl.reset_on, SEDL_RESET); /* Reset On */
+ save_flags(flags);
+ sti();
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + 1;
+ schedule();
+ byteout(cs->hw.sedl.reset_off, 0); /* Reset Off */
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + 1;
+ schedule();
+ restore_flags(flags);
+ }
+}
+
+static int
+Sedl_card_msg(struct IsdnCardState *cs, int mt, void *arg)
+{
+ switch (mt) {
+ case CARD_RESET:
+ reset_sedlbauer(cs);
+ return(0);
+ case CARD_RELEASE:
+ release_io_sedlbauer(cs);
+ return(0);
+ case CARD_SETIRQ:
+ return(request_irq(cs->irq, &sedlbauer_interrupt,
+ I4L_IRQ_FLAG, "HiSax", cs));
+ case CARD_INIT:
+ clear_pending_isac_ints(cs);
+ clear_pending_hscx_ints(cs);
+ initisac(cs);
+ inithscx(cs);
+ return(0);
+ case CARD_TEST:
+ return(0);
+ }
+ return(0);
+}
+
+__initfunc(int
+setup_sedlbauer(struct IsdnCard *card))
+{
+ int bytecnt;
+ struct IsdnCardState *cs = card->cs;
+ char tmp[64];
+
+ strcpy(tmp, Sedlbauer_revision);
+ printk(KERN_INFO "HiSax: Sedlbauer driver Rev. %s\n", HiSax_getrev(tmp));
+ if (cs->typ == ISDN_CTYPE_SEDLBAUER) {
+ cs->subtyp = SEDL_SPEED_CARD;
+ } else if (cs->typ == ISDN_CTYPE_SEDLBAUER_PCMCIA) {
+ cs->subtyp = SEDL_SPEED_STAR;
+ } else
+ return (0);
+
+ bytecnt = 8;
+ cs->hw.sedl.cfg_reg = card->para[1];
+ cs->irq = card->para[0];
+ if (cs->subtyp == SEDL_SPEED_STAR) {
+ cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_PCMCIA_ADR;
+ cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_PCMCIA_ISAC;
+ cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_PCMCIA_HSCX;
+ cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg + SEDL_PCMCIA_RESET;
+ cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg + SEDL_PCMCIA_RESET;
+ } else {
+ cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_ADR;
+ cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_ISAC;
+ cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_HSCX;
+ cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg + SEDL_RESET_ON;
+ cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg + SEDL_RESET_OFF;
+ }
+
+ /* In case of the sedlbauer pcmcia card, this region is in use,
+ reserved for us by the card manager. So we do not check it
+ here, it would fail. */
+ if (cs->typ != ISDN_CTYPE_SEDLBAUER_PCMCIA &&
+ check_region((cs->hw.sedl.cfg_reg), bytecnt)) {
+ printk(KERN_WARNING
+ "HiSax: %s config port %x-%x already in use\n",
+ CardType[card->typ],
+ cs->hw.sedl.cfg_reg,
+ cs->hw.sedl.cfg_reg + bytecnt);
+ return (0);
+ } else {
+ request_region(cs->hw.sedl.cfg_reg, bytecnt, "sedlbauer isdn");
+ }
+
+ printk(KERN_INFO
+ "Sedlbauer: defined at 0x%x IRQ %d\n",
+ cs->hw.sedl.cfg_reg,
+ cs->irq);
+ printk(KERN_WARNING
+ "Sedlbauer %s uses ports 0x%x-0x%x\n",
+ Sedlbauer_Types[cs->subtyp],
+ cs->hw.sedl.cfg_reg,
+ cs->hw.sedl.cfg_reg + bytecnt);
+
+ printk(KERN_INFO "Sedlbauer: resetting card\n");
+ reset_sedlbauer(cs);
+ cs->readisac = &ReadISAC;
+ cs->writeisac = &WriteISAC;
+ cs->readisacfifo = &ReadISACfifo;
+ cs->writeisacfifo = &WriteISACfifo;
+ cs->BC_Read_Reg = &ReadHSCX;
+ cs->BC_Write_Reg = &WriteHSCX;
+ cs->BC_Send_Data = &hscx_fill_fifo;
+ cs->cardmsg = &Sedl_card_msg;
+ ISACVersion(cs, "Sedlbauer:");
+ if (HscxVersion(cs, "Sedlbauer:")) {
+ printk(KERN_WARNING
+ "Sedlbauer: wrong HSCX versions check IO address\n");
+ release_io_sedlbauer(cs);
+ return (0);
+ }
+ return (1);
+}
diff --git a/drivers/isdn/hisax/sportster.c b/drivers/isdn/hisax/sportster.c
new file mode 100644
index 000000000..cb867a13f
--- /dev/null
+++ b/drivers/isdn/hisax/sportster.c
@@ -0,0 +1,291 @@
+/* $Id: sportster.c,v 1.5 1998/02/02 13:29:46 keil Exp $
+
+ * sportster.c low level stuff for USR Sportster internal TA
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ * Thanks to Christian "naddy" Weisgerber (3Com, US Robotics) for documentation
+ *
+ * $Log: sportster.c,v $
+ * Revision 1.5 1998/02/02 13:29:46 keil
+ * fast io
+ *
+ * Revision 1.4 1997/11/08 21:35:52 keil
+ * new l1 init
+ *
+ * Revision 1.3 1997/11/06 17:09:29 keil
+ * New 2.1 init code
+ *
+ * Revision 1.2 1997/10/29 18:51:18 keil
+ * New files
+ *
+ * Revision 1.1.2.1 1997/10/17 22:10:58 keil
+ * new files on 2.0
+ *
+ */
+#define __NO_VERSION__
+#include "hisax.h"
+#include "isac.h"
+#include "hscx.h"
+#include "isdnl1.h"
+
+extern const char *CardType[];
+const char *sportster_revision = "$Revision: 1.5 $";
+
+#define byteout(addr,val) outb(val,addr)
+#define bytein(addr) inb(addr)
+
+#define SPORTSTER_ISAC 0xC000
+#define SPORTSTER_HSCXA 0x0000
+#define SPORTSTER_HSCXB 0x4000
+#define SPORTSTER_RES_IRQ 0x8000
+#define SPORTSTER_RESET 0x80
+#define SPORTSTER_INTE 0x40
+
+static inline int
+calc_off(unsigned int base, unsigned int off)
+{
+ return(base + ((off & 0xfc)<<8) + ((off & 3)<<1));
+}
+
+static inline void
+read_fifo(unsigned int adr, u_char * data, int size)
+{
+ insb(adr, data, size);
+}
+
+static void
+write_fifo(unsigned int adr, u_char * data, int size)
+{
+ outsb(adr, data, size);
+}
+
+/* Interface functions */
+
+static u_char
+ReadISAC(struct IsdnCardState *cs, u_char offset)
+{
+ return (bytein(calc_off(cs->hw.spt.isac, offset)));
+}
+
+static void
+WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
+{
+ byteout(calc_off(cs->hw.spt.isac, offset), value);
+}
+
+static void
+ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
+{
+ read_fifo(cs->hw.spt.isac, data, size);
+}
+
+static void
+WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
+{
+ write_fifo(cs->hw.spt.isac, data, size);
+}
+
+static u_char
+ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
+{
+ return (bytein(calc_off(cs->hw.spt.hscx[hscx], offset)));
+}
+
+static void
+WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
+{
+ byteout(calc_off(cs->hw.spt.hscx[hscx], offset), value);
+}
+
+/*
+ * fast interrupt HSCX stuff goes here
+ */
+
+#define READHSCX(cs, nr, reg) bytein(calc_off(cs->hw.spt.hscx[nr], reg))
+#define WRITEHSCX(cs, nr, reg, data) byteout(calc_off(cs->hw.spt.hscx[nr], reg), data)
+#define READHSCXFIFO(cs, nr, ptr, cnt) read_fifo(cs->hw.spt.hscx[nr], ptr, cnt)
+#define WRITEHSCXFIFO(cs, nr, ptr, cnt) write_fifo(cs->hw.spt.hscx[nr], ptr, cnt)
+
+#include "hscx_irq.c"
+
+static void
+sportster_interrupt(int intno, void *dev_id, struct pt_regs *regs)
+{
+ struct IsdnCardState *cs = dev_id;
+ u_char val;
+
+ if (!cs) {
+ printk(KERN_WARNING "Sportster: Spurious interrupt!\n");
+ return;
+ }
+ val = READHSCX(cs, 1, HSCX_ISTA);
+ Start_HSCX:
+ if (val)
+ hscx_int_main(cs, val);
+ val = ReadISAC(cs, ISAC_ISTA);
+ Start_ISAC:
+ if (val)
+ isac_interrupt(cs, val);
+ val = READHSCX(cs, 1, HSCX_ISTA);
+ if (val) {
+ if (cs->debug & L1_DEB_HSCX)
+ debugl1(cs, "HSCX IntStat after IntRoutine");
+ goto Start_HSCX;
+ }
+ val = ReadISAC(cs, ISAC_ISTA);
+ if (val) {
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ISAC IntStat after IntRoutine");
+ goto Start_ISAC;
+ }
+ /* get a new irq impulse if there any pending */
+ bytein(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ +1);
+}
+
+void
+release_io_sportster(struct IsdnCardState *cs)
+{
+ int i, adr;
+
+ byteout(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ, 0);
+ for (i=0; i<64; i++) {
+ adr = cs->hw.spt.cfg_reg + i *1024;
+ release_region(adr, 8);
+ }
+}
+
+void
+reset_sportster(struct IsdnCardState *cs)
+{
+ long flags;
+
+ cs->hw.spt.res_irq |= SPORTSTER_RESET; /* Reset On */
+ byteout(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ, cs->hw.spt.res_irq);
+ save_flags(flags);
+ sti();
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + 1;
+ schedule();
+ cs->hw.spt.res_irq &= ~SPORTSTER_RESET; /* Reset Off */
+ byteout(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ, cs->hw.spt.res_irq);
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + 1;
+ schedule();
+ restore_flags(flags);
+}
+
+static int
+Sportster_card_msg(struct IsdnCardState *cs, int mt, void *arg)
+{
+ switch (mt) {
+ case CARD_RESET:
+ reset_sportster(cs);
+ return(0);
+ case CARD_RELEASE:
+ release_io_sportster(cs);
+ return(0);
+ case CARD_SETIRQ:
+ return(request_irq(cs->irq, &sportster_interrupt,
+ I4L_IRQ_FLAG, "HiSax", cs));
+ case CARD_INIT:
+ clear_pending_isac_ints(cs);
+ clear_pending_hscx_ints(cs);
+ initisac(cs);
+ inithscx(cs);
+ cs->hw.spt.res_irq |= SPORTSTER_INTE; /* IRQ On */
+ byteout(cs->hw.spt.cfg_reg + SPORTSTER_RES_IRQ, cs->hw.spt.res_irq);
+ return(0);
+ case CARD_TEST:
+ return(0);
+ }
+ return(0);
+}
+
+__initfunc(int
+get_io_range(struct IsdnCardState *cs))
+{
+ int i, j, adr;
+
+ for (i=0;i<64;i++) {
+ adr = cs->hw.spt.cfg_reg + i *1024;
+ if (check_region(adr, 8)) {
+ printk(KERN_WARNING
+ "HiSax: %s config port %x-%x already in use\n",
+ CardType[cs->typ], adr, adr + 8);
+ break;
+ } else
+ request_region(adr, 8, "sportster");
+ }
+ if (i==64)
+ return(1);
+ else {
+ for (j=0; j<i; j++) {
+ adr = cs->hw.spt.cfg_reg + j *1024;
+ release_region(adr, 8);
+ }
+ return(0);
+ }
+}
+
+__initfunc(int
+setup_sportster(struct IsdnCard *card))
+{
+ struct IsdnCardState *cs = card->cs;
+ char tmp[64];
+
+ strcpy(tmp, sportster_revision);
+ printk(KERN_INFO "HiSax: USR Sportster driver Rev. %s\n", HiSax_getrev(tmp));
+ if (cs->typ != ISDN_CTYPE_SPORTSTER)
+ return (0);
+
+ cs->hw.spt.cfg_reg = card->para[1];
+ cs->irq = card->para[0];
+ if (!get_io_range(cs))
+ return (0);
+ cs->hw.spt.isac = cs->hw.spt.cfg_reg + SPORTSTER_ISAC;
+ cs->hw.spt.hscx[0] = cs->hw.spt.cfg_reg + SPORTSTER_HSCXA;
+ cs->hw.spt.hscx[1] = cs->hw.spt.cfg_reg + SPORTSTER_HSCXB;
+
+ switch(cs->irq) {
+ case 5: cs->hw.spt.res_irq = 1;
+ break;
+ case 7: cs->hw.spt.res_irq = 2;
+ break;
+ case 10:cs->hw.spt.res_irq = 3;
+ break;
+ case 11:cs->hw.spt.res_irq = 4;
+ break;
+ case 12:cs->hw.spt.res_irq = 5;
+ break;
+ case 14:cs->hw.spt.res_irq = 6;
+ break;
+ case 15:cs->hw.spt.res_irq = 7;
+ break;
+ default:release_io_sportster(cs);
+ printk(KERN_WARNING "Sportster: wrong IRQ\n");
+ return(0);
+ }
+ reset_sportster(cs);
+ printk(KERN_INFO
+ "HiSax: %s config irq:%d cfg:0x%X\n",
+ CardType[cs->typ], cs->irq,
+ cs->hw.spt.cfg_reg);
+
+ cs->readisac = &ReadISAC;
+ cs->writeisac = &WriteISAC;
+ cs->readisacfifo = &ReadISACfifo;
+ cs->writeisacfifo = &WriteISACfifo;
+ cs->BC_Read_Reg = &ReadHSCX;
+ cs->BC_Write_Reg = &WriteHSCX;
+ cs->BC_Send_Data = &hscx_fill_fifo;
+ cs->cardmsg = &Sportster_card_msg;
+ ISACVersion(cs, "Sportster:");
+ if (HscxVersion(cs, "Sportster:")) {
+ printk(KERN_WARNING
+ "Sportster: wrong HSCX versions check IO address\n");
+ release_io_sportster(cs);
+ return (0);
+ }
+ return (1);
+}
diff --git a/drivers/isdn/hisax/tei.c b/drivers/isdn/hisax/tei.c
index d97595938..a52078746 100644
--- a/drivers/isdn/hisax/tei.c
+++ b/drivers/isdn/hisax/tei.c
@@ -1,4 +1,4 @@
-/* $Id: tei.c,v 1.8 1997/04/07 22:59:08 keil Exp $
+/* $Id: tei.c,v 2.7 1998/02/12 23:08:11 keil Exp $
* Author Karsten Keil (keil@temic-ech.spacenet.de)
* based on the teles driver from Jan den Ouden
@@ -7,52 +7,112 @@
* Fritz Elfert
*
* $Log: tei.c,v $
- * Revision 1.8 1997/04/07 22:59:08 keil
- * GFP_KERNEL --> GFP_ATOMIC
+ * Revision 2.7 1998/02/12 23:08:11 keil
+ * change for 2.1.86 (removing FREE_READ/FREE_WRITE from [dev]_kfree_skb()
*
- * Revision 1.7 1997/04/06 22:54:03 keil
- * Using SKB's
+ * Revision 2.6 1998/02/02 13:41:42 keil
+ * fix MDL_ASSIGN for PtP
*
- * Revision 1.6 1997/02/09 00:25:12 keil
- * new interface handling, one interface per card
+ * Revision 2.5 1997/11/06 17:09:12 keil
+ * New 2.1 init code
*
- * Revision 1.5 1997/01/27 15:57:51 keil
- * cosmetics
+ * Revision 2.4 1997/10/29 19:04:46 keil
+ * changes for 2.1
*
- * Revision 1.4 1997/01/21 22:32:44 keil
- * Tei verify request
+ * Revision 2.3 1997/10/01 09:21:43 fritz
+ * Removed old compatibility stuff for 2.0.X kernels.
+ * From now on, this code is for 2.1.X ONLY!
+ * Old stuff is still in the separate branch.
*
- * Revision 1.3 1997/01/04 13:45:02 keil
- * cleanup,adding remove tei request (thanks to Sim Yskes)
+ * Revision 2.2 1997/07/31 19:24:39 keil
+ * fixed a warning
*
- * Revision 1.2 1996/12/08 19:52:39 keil
- * minor debug fix
+ * Revision 2.1 1997/07/31 11:50:16 keil
+ * ONE TEI and FIXED TEI handling
*
- * Revision 1.1 1996/10/13 20:04:57 keil
- * Initial revision
+ * Revision 2.0 1997/07/27 21:13:30 keil
+ * New TEI managment
*
+ * Revision 1.9 1997/06/26 11:18:02 keil
+ * New managment
*
+ * Revision 1.8 1997/04/07 22:59:08 keil
+ * GFP_KERNEL --> GFP_ATOMIC
+ *
+ * Revision 1.7 1997/04/06 22:54:03 keil
+ * Using SKB's
+ *
+ * Old log removed/ KKe
*
*/
#define __NO_VERSION__
#include "hisax.h"
+#include "isdnl2.h"
+#include <linux/random.h>
-extern struct IsdnCard cards[];
-extern int nrcards;
+const char *tei_revision = "$Revision: 2.7 $";
-const char *tei_revision = "$Revision: 1.8 $";
+#define ID_REQUEST 1
+#define ID_ASSIGNED 2
+#define ID_DENIED 3
+#define ID_CHK_REQ 4
+#define ID_CHK_RES 5
+#define ID_REMOVE 6
+#define ID_VERIFY 7
-static struct PStack *
-findces(struct PStack *st, int ces)
+#define TEI_ENTITY_ID 0xf
+
+static
+struct Fsm teifsm =
+{NULL, 0, 0, NULL, NULL};
+
+void tei_handler(struct PStack *st, u_char pr, struct sk_buff *skb);
+
+enum {
+ ST_TEI_NOP,
+ ST_TEI_IDREQ,
+ ST_TEI_IDVERIFY,
+};
+
+#define TEI_STATE_COUNT (ST_TEI_IDVERIFY+1)
+
+static char *strTeiState[] =
{
- struct PStack *ptr = *(st->l1.stlistp);
+ "ST_TEI_NOP",
+ "ST_TEI_IDREQ",
+ "ST_TEI_IDVERIFY",
+};
- while (ptr)
- if (ptr->l2.ces == ces)
- return (ptr);
- else
- ptr = ptr->next;
- return (NULL);
+enum {
+ EV_IDREQ,
+ EV_ASSIGN,
+ EV_DENIED,
+ EV_CHKREQ,
+ EV_REMOVE,
+ EV_VERIFY,
+ EV_T202,
+};
+
+#define TEI_EVENT_COUNT (EV_T202+1)
+
+static char *strTeiEvent[] =
+{
+ "EV_IDREQ",
+ "EV_ASSIGN",
+ "EV_DENIED",
+ "EV_CHKREQ",
+ "EV_REMOVE",
+ "EV_VERIFY",
+ "EV_T202",
+};
+
+unsigned int
+random_ri(void)
+{
+ unsigned int x;
+
+ get_random_bytes(&x, sizeof(x));
+ return (x & 0xffff);
}
static struct PStack *
@@ -72,246 +132,357 @@ findtei(struct PStack *st, int tei)
}
static void
-mdl_unit_data_res(struct PStack *st, unsigned int ri, u_char mt, u_char ai)
+put_tei_msg(struct PStack *st, u_char m_id, unsigned int ri, u_char tei)
{
struct sk_buff *skb;
u_char *bp;
- if (!(skb = alloc_skb(6 + MAX_HEADER_LEN, GFP_ATOMIC))) {
+ if (!(skb = alloc_skb(8, GFP_ATOMIC))) {
printk(KERN_WARNING "HiSax: No skb for TEI manager\n");
return;
}
- skb_reserve(skb, MAX_HEADER_LEN);
+ bp = skb_put(skb, 3);
+ bp[0] = (TEI_SAPI << 2);
+ bp[1] = (GROUP_TEI << 1) | 0x1;
+ bp[2] = UI;
bp = skb_put(skb, 5);
- bp[0] = 0xf;
+ bp[0] = TEI_ENTITY_ID;
bp[1] = ri >> 8;
bp[2] = ri & 0xff;
- bp[3] = mt;
- bp[4] = (ai << 1) | 1;
- st->l3.l3l2(st, DL_UNIT_DATA, skb);
+ bp[3] = m_id;
+ bp[4] = (tei << 1) | 1;
+ st->l2.l2l1(st, PH_DATA_REQ, skb);
}
static void
-mdl_unit_data_ind(struct PStack *st, unsigned int ri, u_char mt, u_char ai)
+tei_id_request(struct FsmInst *fi, int event, void *arg)
{
- unsigned int tces;
- struct PStack *otsp, *ptr;
+ struct PStack *st = fi->userdata;
char tmp[64];
- switch (mt) {
- case (2):
- tces = ri;
- if (st->l3.debug) {
- sprintf(tmp, "identity assign ces %d ai %d", tces, ai);
- st->l2.l2m.printdebug(&st->l2.l2m, tmp);
- }
- if ((otsp = findces(st, tces))) {
- if (st->l3.debug) {
- sprintf(tmp, "ces %d --> tei %d", tces, ai);
- st->l2.l2m.printdebug(&st->l2.l2m, tmp);
- }
- otsp->ma.teil2(otsp, MDL_ASSIGN, (void *) (int) ai);
- }
- break;
- case (3):
- tces = ri;
- if (st->l3.debug) {
- sprintf(tmp, "identity denied for ces %d ai %d", tces, ai);
- st->l2.l2m.printdebug(&st->l2.l2m, tmp);
- }
- if ((otsp = findces(st, tces))) {
- if (st->l3.debug) {
- sprintf(tmp, "ces %d denied tei %d", tces, ai);
- st->l2.l2m.printdebug(&st->l2.l2m, tmp);
- }
- otsp->l2.tei = 255;
- otsp->l2.ces = randomces();
- otsp->ma.teil2(otsp, MDL_REMOVE, 0);
- }
- break;
- case (4):
- if (st->l3.debug) {
- sprintf(tmp, "checking identity for %d", ai);
- st->l2.l2m.printdebug(&st->l2.l2m, tmp);
- }
- if (ai == 0x7f) {
- ptr = *(st->l1.stlistp);
- while (ptr) {
- if ((ptr->l2.tei & 0x7f) != 0x7f) {
- if (st->l3.debug) {
- sprintf(tmp, "check response for ces %d with tei %d",
- ptr->l2.ces, ptr->l2.tei);
- st->l2.l2m.printdebug(&st->l2.l2m, tmp);
- }
- /* send identity check response (user->network) */
- mdl_unit_data_res(st, ptr->l2.ces, 5, ptr->l2.tei);
- }
- ptr = ptr->next;
- }
- } else {
- otsp = findtei(st, ai);
- if (!otsp)
- break;
- if (st->l3.debug) {
- sprintf(tmp, "check response for ces %d with tei %d",
- otsp->l2.ces, otsp->l2.tei);
- st->l2.l2m.printdebug(&st->l2.l2m, tmp);
- }
- /* send identity check response (user->network) */
- mdl_unit_data_res(st, otsp->l2.ces, 5, otsp->l2.tei);
- }
- break;
- case (6):
- if (st->l3.debug) {
- sprintf(tmp, "removal for %d", ai);
- st->l2.l2m.printdebug(&st->l2.l2m, tmp);
- }
- if (ai == 0x7f) {
- ptr = *(st->l1.stlistp);
- while (ptr) {
- if ((ptr->l2.tei & 0x7f) != 0x7f) {
- if (st->l3.debug) {
- sprintf(tmp, "rem ces %d with tei %d",
- ptr->l2.ces, ptr->l2.tei);
- st->l2.l2m.printdebug(&st->l2.l2m, tmp);
- }
- ptr->ma.teil2(ptr, MDL_REMOVE, 0);
- }
- ptr = ptr->next;
- }
- } else {
- otsp = findtei(st, ai);
- if (!otsp)
- break;
- if (st->l3.debug) {
- sprintf(tmp, "rem ces %d with tei %d",
- otsp->l2.ces, otsp->l2.tei);
- st->l2.l2m.printdebug(&st->l2.l2m, tmp);
- }
- otsp->ma.teil2(otsp, MDL_REMOVE, 0);
- }
- break;
- default:
- if (st->l3.debug) {
- sprintf(tmp, "message unknown %d ai %d", mt, ai);
- st->l2.l2m.printdebug(&st->l2.l2m, tmp);
- }
+ if (st->l2.tei != -1) {
+ sprintf(tmp, "assign request for allready asigned tei %d",
+ st->l2.tei);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ return;
+ }
+ st->ma.ri = random_ri();
+ if (st->ma.debug) {
+ sprintf(tmp, "assign request ri %d", st->ma.ri);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
}
+ put_tei_msg(st, ID_REQUEST, st->ma.ri, 127);
+ FsmChangeState(&st->ma.tei_m, ST_TEI_IDREQ);
+ FsmAddTimer(&st->ma.t202, st->ma.T202, EV_T202, NULL, 1);
+ st->ma.N202 = 3;
}
-void
-tei_handler(struct PStack *st,
- u_char pr, struct sk_buff *skb)
+static void
+tei_id_assign(struct FsmInst *fi, int event, void *arg)
{
- u_char *bp;
- unsigned int data;
- char tmp[32];
+ struct PStack *ost, *st = fi->userdata;
+ struct sk_buff *skb = arg;
+ struct IsdnCardState *cs;
+ int ri, tei;
+ char tmp[64];
- switch (pr) {
- case (MDL_ASSIGN):
- data = (unsigned int) skb;
- if (st->l3.debug) {
- sprintf(tmp, "ces %d assign request", data);
- st->l2.l2m.printdebug(&st->l2.l2m, tmp);
- }
- mdl_unit_data_res(st, data, 1, 127);
- break;
- case (MDL_VERIFY):
- data = (unsigned int) skb;
- if (st->l3.debug) {
- sprintf(tmp, "%d id verify request", data);
- st->l2.l2m.printdebug(&st->l2.l2m, tmp);
- }
- mdl_unit_data_res(st, 0, 7, data);
- break;
- case (DL_UNIT_DATA):
- bp = skb->data;
- if (bp[0] != 0xf) {
- /* wrong management entity identifier, ignore */
- /* shouldn't ibh be released??? */
- printk(KERN_WARNING "tei handler wrong entity id %x\n", bp[0]);
- } else
- mdl_unit_data_ind(st, (bp[1] << 8) | bp[2], bp[3], bp[4] >> 1);
- SET_SKB_FREE(skb);
- dev_kfree_skb(skb);
- break;
- default:
- break;
+ ri = ((unsigned int) skb->data[1] << 8) + skb->data[2];
+ tei = skb->data[4] >> 1;
+ if (st->ma.debug) {
+ sprintf(tmp, "identity assign ri %d tei %d", ri, tei);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ }
+ if ((ost = findtei(st, tei))) { /* same tei is in use */
+ if (ri != ost->ma.ri) {
+ sprintf(tmp, "possible duplicate assignment tei %d", tei);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ ost->l2.l2tei(ost, MDL_ERROR_REQ, NULL);
+ }
+ } else if (ri == st->ma.ri) {
+ FsmDelTimer(&st->ma.t202, 1);
+ FsmChangeState(&st->ma.tei_m, ST_TEI_NOP);
+ st->ma.manl2(st, MDL_ASSIGN_REQ, (void *) (int) tei);
+ cs = (struct IsdnCardState *) st->l1.hardware;
+ cs->cardmsg(cs, MDL_ASSIGN_REQ, NULL);
}
}
-unsigned int
-randomces(void)
+static void
+tei_id_denied(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ struct sk_buff *skb = arg;
+ int ri, tei;
+ char tmp[64];
+
+ ri = ((unsigned int) skb->data[1] << 8) + skb->data[2];
+ tei = skb->data[4] >> 1;
+ if (st->ma.debug) {
+ sprintf(tmp, "identity denied ri %d tei %d", ri, tei);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ }
+}
+
+static void
+tei_id_chk_req(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ struct sk_buff *skb = arg;
+ int tei;
+ char tmp[64];
+
+ tei = skb->data[4] >> 1;
+ if (st->ma.debug) {
+ sprintf(tmp, "identity check req tei %d", tei);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ }
+ if ((st->l2.tei != -1) && ((tei == GROUP_TEI) || (tei == st->l2.tei))) {
+ FsmDelTimer(&st->ma.t202, 4);
+ FsmChangeState(&st->ma.tei_m, ST_TEI_NOP);
+ put_tei_msg(st, ID_CHK_RES, random_ri(), st->l2.tei);
+ }
+}
+
+static void
+tei_id_remove(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ struct sk_buff *skb = arg;
+ struct IsdnCardState *cs;
+ int tei;
+ char tmp[64];
+
+ tei = skb->data[4] >> 1;
+ if (st->ma.debug) {
+ sprintf(tmp, "identity remove tei %d", tei);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ }
+ if ((st->l2.tei != -1) && ((tei == GROUP_TEI) || (tei == st->l2.tei))) {
+ FsmDelTimer(&st->ma.t202, 5);
+ FsmChangeState(&st->ma.tei_m, ST_TEI_NOP);
+ st->ma.manl2(st, MDL_REMOVE_REQ, 0);
+ cs = (struct IsdnCardState *) st->l1.hardware;
+ cs->cardmsg(cs, MDL_REMOVE_REQ, NULL);
+ }
+}
+
+static void
+tei_id_verify(struct FsmInst *fi, int event, void *arg)
{
- int x = jiffies & 0xffff;
+ struct PStack *st = fi->userdata;
+ char tmp[64];
- return (x);
+ if (st->ma.debug) {
+ sprintf(tmp, "id verify request for tei %d", st->l2.tei);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ }
+ put_tei_msg(st, ID_VERIFY, 0, st->l2.tei);
+ FsmChangeState(&st->ma.tei_m, ST_TEI_IDVERIFY);
+ FsmAddTimer(&st->ma.t202, st->ma.T202, EV_T202, NULL, 2);
+ st->ma.N202 = 2;
}
static void
-tei_man(struct PStack *sp, int i, void *v)
+tei_id_req_tout(struct FsmInst *fi, int event, void *arg)
{
+ struct PStack *st = fi->userdata;
+ char tmp[64];
+ struct IsdnCardState *cs;
- printk(KERN_DEBUG "tei_man\n");
+ if (--st->ma.N202) {
+ st->ma.ri = random_ri();
+ if (st->ma.debug) {
+ sprintf(tmp, "assign req(%d) ri %d",
+ 4 - st->ma.N202, st->ma.ri);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ }
+ put_tei_msg(st, ID_REQUEST, st->ma.ri, 127);
+ FsmAddTimer(&st->ma.t202, st->ma.T202, EV_T202, NULL, 3);
+ } else {
+ sprintf(tmp, "assign req failed");
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ st->ma.manl2(st, MDL_ERROR_IND, 0);
+ cs = (struct IsdnCardState *) st->l1.hardware;
+ cs->cardmsg(cs, MDL_REMOVE_REQ, NULL);
+ FsmChangeState(fi, ST_TEI_NOP);
+ }
+}
+
+static void
+tei_id_ver_tout(struct FsmInst *fi, int event, void *arg)
+{
+ struct PStack *st = fi->userdata;
+ char tmp[64];
+ struct IsdnCardState *cs;
+
+ if (--st->ma.N202) {
+ if (st->ma.debug) {
+ sprintf(tmp, "id verify req(%d) for tei %d",
+ 3 - st->ma.N202, st->l2.tei);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ }
+ put_tei_msg(st, ID_VERIFY, 0, st->l2.tei);
+ FsmAddTimer(&st->ma.t202, st->ma.T202, EV_T202, NULL, 4);
+ } else {
+ sprintf(tmp, "verify req for tei %d failed", st->l2.tei);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ st->ma.manl2(st, MDL_REMOVE_REQ, 0);
+ cs = (struct IsdnCardState *) st->l1.hardware;
+ cs->cardmsg(cs, MDL_REMOVE_REQ, NULL);
+ FsmChangeState(fi, ST_TEI_NOP);
+ }
+}
+
+static void
+tei_l1l2(struct PStack *st, int pr, void *arg)
+{
+ struct sk_buff *skb = arg;
+ int mt;
+ char tmp[64];
+
+ if (pr == PH_DATA_IND) {
+ if (skb->len < 3) {
+ sprintf(tmp, "short mgr frame %d/3", skb->len);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ } else if (((skb->data[0] >> 2) != TEI_SAPI) ||
+ ((skb->data[1] >> 1) != GROUP_TEI)) {
+ sprintf(tmp, "wrong mgr sapi/tei %x/%x",
+ skb->data[0], skb->data[1]);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ } else if ((skb->data[2] & 0xef) != UI) {
+ sprintf(tmp, "mgr frame is not ui %x",
+ skb->data[2]);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ } else {
+ skb_pull(skb, 3);
+ if (skb->len < 5) {
+ sprintf(tmp, "short mgr frame %d/5", skb->len);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ } else if (skb->data[0] != TEI_ENTITY_ID) {
+ /* wrong management entity identifier, ignore */
+ sprintf(tmp, "tei handler wrong entity id %x\n",
+ skb->data[0]);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ } else {
+ mt = skb->data[3];
+ if (mt == ID_ASSIGNED)
+ FsmEvent(&st->ma.tei_m, EV_ASSIGN, skb);
+ else if (mt == ID_DENIED)
+ FsmEvent(&st->ma.tei_m, EV_DENIED, skb);
+ else if (mt == ID_CHK_REQ)
+ FsmEvent(&st->ma.tei_m, EV_CHKREQ, skb);
+ else if (mt == ID_REMOVE)
+ FsmEvent(&st->ma.tei_m, EV_REMOVE, skb);
+ else {
+ sprintf(tmp, "tei handler wrong mt %x\n",
+ mt);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ }
+ }
+ }
+ } else {
+ sprintf(tmp, "tei handler wrong pr %x\n", pr);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ }
+ dev_kfree_skb(skb);
}
static void
tei_l2tei(struct PStack *st, int pr, void *arg)
{
- struct IsdnCardState *sp = st->l1.hardware;
+ switch (pr) {
+ case (MDL_ASSIGN_IND):
+#ifdef TEI_FIXED
+ if (st->ma.debug) {
+ char tmp[64];
+ sprintf(tmp, "fixed assign tei %d", TEI_FIXED);
+ st->ma.tei_m.printdebug(&st->ma.tei_m, tmp);
+ }
+ st->ma.manl2(st, MDL_ASSIGN_REQ, (void *) (int) TEI_FIXED);
+#else
+ FsmEvent(&st->ma.tei_m, EV_IDREQ, arg);
+#endif
+ break;
+ case (MDL_ERROR_REQ):
+ FsmEvent(&st->ma.tei_m, EV_VERIFY, arg);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+tei_debug(struct FsmInst *fi, char *s)
+{
+ struct PStack *st = fi->userdata;
+ char tm[32], str[256];
- tei_handler(sp->teistack, pr, arg);
+ jiftime(tm, jiffies);
+ sprintf(str, "%s Tei %s\n", tm, s);
+ HiSax_putstatus(st->l1.hardware, str);
}
void
setstack_tei(struct PStack *st)
{
st->l2.l2tei = tei_l2tei;
+ st->ma.T202 = 2000; /* T202 2000 milliseconds */
+ st->l1.l1tei = tei_l1l2;
+ st->ma.debug = 1;
+ st->ma.tei_m.fsm = &teifsm;
+ st->ma.tei_m.state = ST_TEI_NOP;
+ st->ma.tei_m.debug = 1;
+ st->ma.tei_m.userdata = st;
+ st->ma.tei_m.userint = 0;
+ st->ma.tei_m.printdebug = tei_debug;
+ FsmInitTimer(&st->ma.tei_m, &st->ma.t202);
}
void
init_tei(struct IsdnCardState *sp, int protocol)
{
- struct PStack *st;
- char tmp[128];
-
- st = (struct PStack *) kmalloc(sizeof(struct PStack), GFP_ATOMIC);
- setstack_HiSax(st, sp);
- st->l2.extended = !0;
- st->l2.laptype = LAPD;
- st->l2.window = 1;
- st->l2.orig = !0;
- st->protocol = protocol;
-/*
- * the following is not necessary for tei mng. (broadcast only)
- */
- st->l2.t200 = 500; /* 500 milliseconds */
- st->l2.n200 = 4; /* try 4 times */
- st->l2.sap = 63;
- st->l2.tei = 127;
+}
+
+void
+release_tei(struct IsdnCardState *cs)
+{
+ struct PStack *st = cs->stlist;
- sprintf(tmp, "Card %d tei", sp->cardnr + 1);
- setstack_isdnl2(st, tmp);
- st->l2.debug = 0;
- st->l3.debug = 0;
+ while (st) {
+ FsmDelTimer(&st->ma.t202, 1);
+ st = st->next;
+ }
+}
- st->ma.manl2(st, MDL_NOTEIPROC, NULL);
+static struct FsmNode TeiFnList[] HISAX_INITDATA =
+{
+ {ST_TEI_NOP, EV_IDREQ, tei_id_request},
+ {ST_TEI_NOP, EV_VERIFY, tei_id_verify},
+ {ST_TEI_NOP, EV_REMOVE, tei_id_remove},
+ {ST_TEI_NOP, EV_CHKREQ, tei_id_chk_req},
+ {ST_TEI_IDREQ, EV_T202, tei_id_req_tout},
+ {ST_TEI_IDREQ, EV_ASSIGN, tei_id_assign},
+ {ST_TEI_IDREQ, EV_DENIED, tei_id_denied},
+ {ST_TEI_IDVERIFY, EV_T202, tei_id_ver_tout},
+ {ST_TEI_IDVERIFY, EV_REMOVE, tei_id_remove},
+ {ST_TEI_IDVERIFY, EV_CHKREQ, tei_id_chk_req},
+};
- st->l2.l2l3 = (void *) tei_handler;
- st->l1.l1man = tei_man;
- st->l2.l2man = tei_man;
- st->l4.l2writewakeup = NULL;
+#define TEI_FN_COUNT (sizeof(TeiFnList)/sizeof(struct FsmNode))
- HiSax_addlist(sp, st);
- sp->teistack = st;
+HISAX_INITFUNC(void
+TeiNew(void))
+{
+ teifsm.state_count = TEI_STATE_COUNT;
+ teifsm.event_count = TEI_EVENT_COUNT;
+ teifsm.strEvent = strTeiEvent;
+ teifsm.strState = strTeiState;
+ FsmNew(&teifsm, TeiFnList, TEI_FN_COUNT);
}
void
-release_tei(struct IsdnCardState *sp)
+TeiFree(void)
{
- struct PStack *st = sp->teistack;
-
- HiSax_rmlist(sp, st);
- kfree((void *) st);
+ FsmFree(&teifsm);
}
diff --git a/drivers/isdn/hisax/teleint.c b/drivers/isdn/hisax/teleint.c
new file mode 100644
index 000000000..d86dd79a4
--- /dev/null
+++ b/drivers/isdn/hisax/teleint.c
@@ -0,0 +1,363 @@
+/* $Id: teleint.c,v 1.5 1998/02/02 13:40:47 keil Exp $
+
+ * teleint.c low level stuff for TeleInt isdn cards
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ *
+ * $Log: teleint.c,v $
+ * Revision 1.5 1998/02/02 13:40:47 keil
+ * fast io
+ *
+ * Revision 1.4 1997/11/08 21:35:53 keil
+ * new l1 init
+ *
+ * Revision 1.3 1997/11/06 17:09:30 keil
+ * New 2.1 init code
+ *
+ * Revision 1.2 1997/10/29 18:55:53 keil
+ * changes for 2.1.60 (irq2dev_map)
+ *
+ * Revision 1.1 1997/09/11 17:32:32 keil
+ * new
+ *
+ *
+ */
+
+#define __NO_VERSION__
+#include "hisax.h"
+#include "isac.h"
+#include "hfc_2bs0.h"
+#include "isdnl1.h"
+
+extern const char *CardType[];
+
+const char *TeleInt_revision = "$Revision: 1.5 $";
+
+#define byteout(addr,val) outb(val,addr)
+#define bytein(addr) inb(addr)
+
+static inline u_char
+readreg(unsigned int ale, unsigned int adr, u_char off)
+{
+ register u_char ret;
+ int max_delay = 2000;
+ long flags;
+
+ save_flags(flags);
+ cli();
+ byteout(ale, off);
+ ret = HFC_BUSY & bytein(ale);
+ while (ret && --max_delay)
+ ret = HFC_BUSY & bytein(ale);
+ if (!max_delay) {
+ printk(KERN_WARNING "TeleInt Busy not inaktive\n");
+ restore_flags(flags);
+ return (0);
+ }
+ ret = bytein(adr);
+ restore_flags(flags);
+ return (ret);
+}
+
+static inline void
+readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
+{
+ register u_char ret;
+ int max_delay = 2000;
+ byteout(ale, off);
+
+ ret = HFC_BUSY & bytein(ale);
+ while (ret && --max_delay)
+ ret = HFC_BUSY & bytein(ale);
+ if (!max_delay) {
+ printk(KERN_WARNING "TeleInt Busy not inaktive\n");
+ return;
+ }
+ insb(adr, data, size);
+}
+
+
+static inline void
+writereg(unsigned int ale, unsigned int adr, u_char off, u_char data)
+{
+ register u_char ret;
+ int max_delay = 2000;
+ long flags;
+
+ save_flags(flags);
+ cli();
+ byteout(ale, off);
+ ret = HFC_BUSY & bytein(ale);
+ while (ret && --max_delay)
+ ret = HFC_BUSY & bytein(ale);
+ if (!max_delay) {
+ printk(KERN_WARNING "TeleInt Busy not inaktive\n");
+ restore_flags(flags);
+ return;
+ }
+ byteout(adr, data);
+ restore_flags(flags);
+}
+
+static inline void
+writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
+{
+ register u_char ret;
+ int max_delay = 2000;
+
+ /* fifo write without cli because it's allready done */
+ byteout(ale, off);
+ ret = HFC_BUSY & bytein(ale);
+ while (ret && --max_delay)
+ ret = HFC_BUSY & bytein(ale);
+ if (!max_delay) {
+ printk(KERN_WARNING "TeleInt Busy not inaktive\n");
+ return;
+ }
+ outsb(adr, data, size);
+}
+
+/* Interface functions */
+
+static u_char
+ReadISAC(struct IsdnCardState *cs, u_char offset)
+{
+ cs->hw.hfc.cip = offset;
+ return (readreg(cs->hw.hfc.addr | 1, cs->hw.hfc.addr, offset));
+}
+
+static void
+WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
+{
+ cs->hw.hfc.cip = offset;
+ writereg(cs->hw.hfc.addr | 1, cs->hw.hfc.addr, offset, value);
+}
+
+static void
+ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
+{
+ cs->hw.hfc.cip = 0;
+ readfifo(cs->hw.hfc.addr | 1, cs->hw.hfc.addr, 0, data, size);
+}
+
+static void
+WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
+{
+ cs->hw.hfc.cip = 0;
+ writefifo(cs->hw.hfc.addr | 1, cs->hw.hfc.addr, 0, data, size);
+}
+
+static u_char
+ReadHFC(struct IsdnCardState *cs, int data, u_char reg)
+{
+ register u_char ret;
+
+ if (data) {
+ cs->hw.hfc.cip = reg;
+ byteout(cs->hw.hfc.addr | 1, reg);
+ ret = bytein(cs->hw.hfc.addr);
+ if (cs->debug & L1_DEB_HSCX_FIFO && (data != 2)) {
+ char tmp[32];
+ sprintf(tmp, "hfc RD %02x %02x", reg, ret);
+ debugl1(cs, tmp);
+ }
+ } else
+ ret = bytein(cs->hw.hfc.addr | 1);
+ return (ret);
+}
+
+static void
+WriteHFC(struct IsdnCardState *cs, int data, u_char reg, u_char value)
+{
+ byteout(cs->hw.hfc.addr | 1, reg);
+ cs->hw.hfc.cip = reg;
+ if (data)
+ byteout(cs->hw.hfc.addr, value);
+ if (cs->debug & L1_DEB_HSCX_FIFO && (data != 2)) {
+ char tmp[32];
+ sprintf(tmp, "hfc W%c %02x %02x", data ? 'D' : 'C', reg, value);
+ debugl1(cs, tmp);
+ }
+}
+
+static void
+TeleInt_interrupt(int intno, void *dev_id, struct pt_regs *regs)
+{
+ struct IsdnCardState *cs = dev_id;
+ u_char val, stat = 0;
+
+ if (!cs) {
+ printk(KERN_WARNING "TeleInt: Spurious interrupt!\n");
+ return;
+ }
+ val = readreg(cs->hw.hfc.addr | 1, cs->hw.hfc.addr, ISAC_ISTA);
+ Start_ISAC:
+ if (val) {
+ isac_interrupt(cs, val);
+ stat |= 2;
+ }
+ val = readreg(cs->hw.hfc.addr | 1, cs->hw.hfc.addr, ISAC_ISTA);
+ if (val) {
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ISAC IntStat after IntRoutine");
+ goto Start_ISAC;
+ }
+ if (stat & 2) {
+ writereg(cs->hw.hfc.addr | 1, cs->hw.hfc.addr, ISAC_MASK, 0xFF);
+ writereg(cs->hw.hfc.addr | 1, cs->hw.hfc.addr, ISAC_MASK, 0x0);
+ }
+}
+
+static void
+TeleInt_Timer(struct IsdnCardState *cs)
+{
+ int stat = 0;
+
+ if (cs->bcs[0].mode) {
+ stat |= 1;
+ main_irq_hfc(&cs->bcs[0]);
+ }
+ if (cs->bcs[1].mode) {
+ stat |= 2;
+ main_irq_hfc(&cs->bcs[1]);
+ }
+ cs->hw.hfc.timer.expires = jiffies + 1;
+ add_timer(&cs->hw.hfc.timer);
+}
+
+void
+release_io_TeleInt(struct IsdnCardState *cs)
+{
+ del_timer(&cs->hw.hfc.timer);
+ releasehfc(cs);
+ if (cs->hw.hfc.addr)
+ release_region(cs->hw.hfc.addr, 2);
+}
+
+static void
+reset_TeleInt(struct IsdnCardState *cs)
+{
+ long flags;
+
+ printk(KERN_INFO "TeleInt: resetting card\n");
+ cs->hw.hfc.cirm |= HFC_RESET;
+ byteout(cs->hw.hfc.addr | 1, cs->hw.hfc.cirm); /* Reset On */
+ save_flags(flags);
+ sti();
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + 3;
+ schedule();
+ cs->hw.hfc.cirm &= ~HFC_RESET;
+ byteout(cs->hw.hfc.addr | 1, cs->hw.hfc.cirm); /* Reset Off */
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + 1;
+ schedule();
+ restore_flags(flags);
+}
+
+static int
+TeleInt_card_msg(struct IsdnCardState *cs, int mt, void *arg)
+{
+ switch (mt) {
+ case CARD_RESET:
+ reset_TeleInt(cs);
+ return(0);
+ case CARD_RELEASE:
+ release_io_TeleInt(cs);
+ return(0);
+ case CARD_SETIRQ:
+ return(request_irq(cs->irq, &TeleInt_interrupt,
+ I4L_IRQ_FLAG, "HiSax", cs));
+ case CARD_INIT:
+ inithfc(cs);
+ clear_pending_isac_ints(cs);
+ initisac(cs);
+ cs->hw.hfc.timer.expires = jiffies + 1;
+ add_timer(&cs->hw.hfc.timer);
+ return(0);
+ case CARD_TEST:
+ return(0);
+ }
+ return(0);
+}
+
+__initfunc(int
+setup_TeleInt(struct IsdnCard *card))
+{
+ struct IsdnCardState *cs = card->cs;
+ char tmp[64];
+
+ strcpy(tmp, TeleInt_revision);
+ printk(KERN_INFO "HiSax: TeleInt driver Rev. %s\n", HiSax_getrev(tmp));
+ if (cs->typ != ISDN_CTYPE_TELEINT)
+ return (0);
+
+ cs->hw.hfc.addr = card->para[1] & 0x3fe;
+ cs->irq = card->para[0];
+ cs->hw.hfc.cirm = HFC_CIRM;
+ cs->hw.hfc.isac_spcr = 0x00;
+ cs->hw.hfc.cip = 0;
+ cs->hw.hfc.ctmt = HFC_CTMT | HFC_CLTIMER;
+ cs->bcs[0].hw.hfc.send = NULL;
+ cs->bcs[1].hw.hfc.send = NULL;
+ cs->hw.hfc.fifosize = 7 * 1024 + 512;
+ cs->hw.hfc.timer.function = (void *) TeleInt_Timer;
+ cs->hw.hfc.timer.data = (long) cs;
+ init_timer(&cs->hw.hfc.timer);
+ if (check_region((cs->hw.hfc.addr), 2)) {
+ printk(KERN_WARNING
+ "HiSax: %s config port %x-%x already in use\n",
+ CardType[card->typ],
+ cs->hw.hfc.addr,
+ cs->hw.hfc.addr + 2);
+ return (0);
+ } else {
+ request_region(cs->hw.hfc.addr, 2, "TeleInt isdn");
+ }
+ /* HW IO = IO */
+ byteout(cs->hw.hfc.addr, cs->hw.hfc.addr & 0xff);
+ byteout(cs->hw.hfc.addr | 1, ((cs->hw.hfc.addr & 0x300) >> 8) | 0x54);
+ switch (cs->irq) {
+ case 3:
+ cs->hw.hfc.cirm |= HFC_INTA;
+ break;
+ case 4:
+ cs->hw.hfc.cirm |= HFC_INTB;
+ break;
+ case 5:
+ cs->hw.hfc.cirm |= HFC_INTC;
+ break;
+ case 7:
+ cs->hw.hfc.cirm |= HFC_INTD;
+ break;
+ case 10:
+ cs->hw.hfc.cirm |= HFC_INTE;
+ break;
+ case 11:
+ cs->hw.hfc.cirm |= HFC_INTF;
+ break;
+ default:
+ printk(KERN_WARNING "TeleInt: wrong IRQ\n");
+ release_io_TeleInt(cs);
+ return (0);
+ }
+ byteout(cs->hw.hfc.addr | 1, cs->hw.hfc.cirm);
+ byteout(cs->hw.hfc.addr | 1, cs->hw.hfc.ctmt);
+
+ printk(KERN_INFO
+ "TeleInt: defined at 0x%x IRQ %d\n",
+ cs->hw.hfc.addr,
+ cs->irq);
+
+ reset_TeleInt(cs);
+ cs->readisac = &ReadISAC;
+ cs->writeisac = &WriteISAC;
+ cs->readisacfifo = &ReadISACfifo;
+ cs->writeisacfifo = &WriteISACfifo;
+ cs->BC_Read_Reg = &ReadHFC;
+ cs->BC_Write_Reg = &WriteHFC;
+ cs->cardmsg = &TeleInt_card_msg;
+ ISACVersion(cs, "TeleInt:");
+ return (1);
+}
diff --git a/drivers/isdn/hisax/teles0.c b/drivers/isdn/hisax/teles0.c
index 6aaba70d3..7cd173154 100644
--- a/drivers/isdn/hisax/teles0.c
+++ b/drivers/isdn/hisax/teles0.c
@@ -1,4 +1,4 @@
-/* $Id: teles0.c,v 1.8 1997/04/13 19:54:04 keil Exp $
+/* $Id: teles0.c,v 2.6 1998/02/03 23:27:47 keil Exp $
* teles0.c low level stuff for Teles Memory IO isdn cards
* based on the teles driver from Jan den Ouden
@@ -10,71 +10,73 @@
* Beat Doebeli
*
* $Log: teles0.c,v $
- * Revision 1.8 1997/04/13 19:54:04 keil
- * Change in IRQ check delay for SMP
+ * Revision 2.6 1998/02/03 23:27:47 keil
+ * IRQ 9
*
- * Revision 1.7 1997/04/06 22:54:04 keil
- * Using SKB's
+ * Revision 2.5 1998/02/02 13:29:47 keil
+ * fast io
*
- * Revision 1.6 1997/01/27 15:52:18 keil
- * SMP proof,cosmetics
+ * Revision 2.4 1997/11/08 21:35:54 keil
+ * new l1 init
*
- * Revision 1.5 1997/01/21 22:25:59 keil
- * cleanups
+ * Revision 2.3 1997/11/06 17:09:31 keil
+ * New 2.1 init code
*
- * Revision 1.4 1996/11/05 19:41:27 keil
- * more changes for 2.1
+ * Revision 2.2 1997/10/29 18:55:57 keil
+ * changes for 2.1.60 (irq2dev_map)
*
- * Revision 1.3 1996/10/30 10:22:58 keil
- * Changes for 2.1 kernels
+ * Revision 2.1 1997/07/27 21:47:10 keil
+ * new interface structures
*
- * Revision 1.2 1996/10/27 22:08:34 keil
- * cosmetic changes
+ * Revision 2.0 1997/06/26 11:02:43 keil
+ * New Layer and card interface
*
- * Revision 1.1 1996/10/13 20:04:58 keil
- * Initial revision
+ * Revision 1.8 1997/04/13 19:54:04 keil
+ * Change in IRQ check delay for SMP
*
+ * Revision 1.7 1997/04/06 22:54:04 keil
+ * Using SKB's
*
+ * removed old log info /KKe
*
*/
#define __NO_VERSION__
-#include "siemens.h"
#include "hisax.h"
-#include "teles0.h"
#include "isdnl1.h"
-#include <linux/kernel_stat.h>
+#include "isac.h"
+#include "hscx.h"
extern const char *CardType[];
-const char *teles0_revision = "$Revision: 1.8 $";
+const char *teles0_revision = "$Revision: 2.6 $";
-#define byteout(addr,val) outb_p(val,addr)
-#define bytein(addr) inb_p(addr)
+#define byteout(addr,val) outb(val,addr)
+#define bytein(addr) inb(addr)
static inline u_char
readisac(unsigned int adr, u_char off)
{
- return readb(adr + 0x120 + ((off & 1) ? 0x1ff : 0) + off);
+ return readb(adr + ((off & 1) ? 0x2ff : 0x100) + off);
}
static inline void
writeisac(unsigned int adr, u_char off, u_char data)
{
- writeb(data, adr + 0x120 + ((off & 1) ? 0x1ff : 0) + off);
+ writeb(data, adr + ((off & 1) ? 0x2ff : 0x100) + off);
}
static inline u_char
readhscx(unsigned int adr, int hscx, u_char off)
{
- return readb(adr + (hscx ? 0x1e0 : 0x1a0) +
+ return readb(adr + (hscx ? 0x1c0 : 0x180) +
((off & 1) ? 0x1ff : 0) + off);
}
static inline void
writehscx(unsigned int adr, int hscx, u_char off, u_char data)
{
- writeb(data, adr + (hscx ? 0x1e0 : 0x1a0) +
+ writeb(data, adr + (hscx ? 0x1c0 : 0x180) +
((off & 1) ? 0x1ff : 0) + off);
}
@@ -87,7 +89,7 @@ read_fifo_isac(unsigned int adr, u_char * data, int size)
data[i] = readb(ad);
}
-static void
+static inline void
write_fifo_isac(unsigned int adr, u_char * data, int size)
{
register int i;
@@ -113,745 +115,204 @@ write_fifo_hscx(unsigned int adr, int hscx, u_char * data, int size)
for (i = 0; i < size; i++)
writeb(data[i], ad);
}
-static inline void
-waitforCEC(int adr, int hscx)
-{
- int to = 50;
-
- while ((readhscx(adr, hscx, HSCX_STAR) & 0x04) && to) {
- udelay(1);
- to--;
- }
- if (!to)
- printk(KERN_WARNING "Teles0: waitforCEC timeout\n");
-}
+/* Interface functions */
-static inline void
-waitforXFW(int adr, int hscx)
+static u_char
+ReadISAC(struct IsdnCardState *cs, u_char offset)
{
- int to = 50;
-
- while ((!(readhscx(adr, hscx, HSCX_STAR) & 0x44) == 0x40) && to) {
- udelay(1);
- to--;
- }
- if (!to)
- printk(KERN_WARNING "Teles0: waitforXFW timeout\n");
+ return (readisac(cs->hw.teles0.membase, offset));
}
-static inline void
-writehscxCMDR(int adr, int hscx, u_char data)
-{
- long flags;
-
- save_flags(flags);
- cli();
- waitforCEC(adr, hscx);
- writehscx(adr, hscx, HSCX_CMDR, data);
- restore_flags(flags);
-}
-
-/*
- * fast interrupt here
- */
-
-
static void
-hscxreport(struct IsdnCardState *sp, int hscx)
-{
- printk(KERN_DEBUG "HSCX %d\n", hscx);
- printk(KERN_DEBUG "ISTA %x\n", readhscx(sp->membase, hscx, HSCX_ISTA));
- printk(KERN_DEBUG "STAR %x\n", readhscx(sp->membase, hscx, HSCX_STAR));
- printk(KERN_DEBUG "EXIR %x\n", readhscx(sp->membase, hscx, HSCX_EXIR));
-}
-
-void
-teles0_report(struct IsdnCardState *sp)
+WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
{
- printk(KERN_DEBUG "ISAC\n");
- printk(KERN_DEBUG "ISTA %x\n", readisac(sp->membase, ISAC_ISTA));
- printk(KERN_DEBUG "STAR %x\n", readisac(sp->membase, ISAC_STAR));
- printk(KERN_DEBUG "EXIR %x\n", readisac(sp->membase, ISAC_EXIR));
- hscxreport(sp, 0);
- hscxreport(sp, 1);
+ writeisac(cs->hw.teles0.membase, offset, value);
}
-/*
- * HSCX stuff goes here
- */
-
static void
-hscx_empty_fifo(struct HscxState *hsp, int count)
+ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
{
- u_char *ptr;
- struct IsdnCardState *sp = hsp->sp;
- long flags;
-
- if ((sp->debug & L1_DEB_HSCX) && !(sp->debug & L1_DEB_HSCX_FIFO))
- debugl1(sp, "hscx_empty_fifo");
-
- if (hsp->rcvidx + count > HSCX_BUFMAX) {
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "hscx_empty_fifo: incoming packet too large");
- writehscxCMDR(sp->membase, hsp->hscx, 0x80);
- hsp->rcvidx = 0;
- return;
- }
- ptr = hsp->rcvbuf + hsp->rcvidx;
- hsp->rcvidx += count;
- save_flags(flags);
- cli();
- read_fifo_hscx(sp->membase, hsp->hscx, ptr, count);
- writehscxCMDR(sp->membase, hsp->hscx, 0x80);
- restore_flags(flags);
- if (sp->debug & L1_DEB_HSCX_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "hscx_empty_fifo %c cnt %d",
- hsp->hscx ? 'B' : 'A', count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ read_fifo_isac(cs->hw.teles0.membase, data, size);
}
static void
-hscx_fill_fifo(struct HscxState *hsp)
+WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
{
- struct IsdnCardState *sp = hsp->sp;
- int more, count;
- u_char *ptr;
- long flags;
-
- if ((sp->debug & L1_DEB_HSCX) && !(sp->debug & L1_DEB_HSCX_FIFO))
- debugl1(sp, "hscx_fill_fifo");
-
- if (!hsp->tx_skb)
- return;
- if (hsp->tx_skb->len <= 0)
- return;
-
- more = (hsp->mode == 1) ? 1 : 0;
- if (hsp->tx_skb->len > 32) {
- more = !0;
- count = 32;
- } else
- count = hsp->tx_skb->len;
-
- waitforXFW(sp->membase, hsp->hscx);
- save_flags(flags);
- cli();
- ptr = hsp->tx_skb->data;
- skb_pull(hsp->tx_skb, count);
- hsp->tx_cnt -= count;
- hsp->count += count;
- write_fifo_hscx(sp->membase, hsp->hscx, ptr, count);
- writehscxCMDR(sp->membase, hsp->hscx, more ? 0x8 : 0xa);
- restore_flags(flags);
- if (sp->debug & L1_DEB_HSCX_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "hscx_fill_fifo %c cnt %d",
- hsp->hscx ? 'B' : 'A', count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ write_fifo_isac(cs->hw.teles0.membase, data, size);
}
-static inline void
-hscx_interrupt(struct IsdnCardState *sp, u_char val, u_char hscx)
+static u_char
+ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
{
- u_char r;
- struct HscxState *hsp = sp->hs + hscx;
- struct sk_buff *skb;
- int count;
- char tmp[32];
-
- if (!hsp->init)
- return;
-
- if (val & 0x80) { /* RME */
-
- r = readhscx(sp->membase, hsp->hscx, HSCX_RSTA);
- if ((r & 0xf0) != 0xa0) {
- if (!r & 0x80)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "HSCX invalid frame");
- if ((r & 0x40) && hsp->mode)
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX RDO mode=%d",
- hsp->mode);
- debugl1(sp, tmp);
- }
- if (!r & 0x20)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "HSCX CRC error");
- writehscxCMDR(sp->membase, hsp->hscx, 0x80);
- } else {
- count = readhscx(sp->membase, hsp->hscx, HSCX_RBCL) & 0x1f;
- if (count == 0)
- count = 32;
- hscx_empty_fifo(hsp, count);
- if ((count = hsp->rcvidx - 1) > 0) {
- if (!(skb = dev_alloc_skb(count)))
- printk(KERN_WARNING "AVM: receive out of memory\n");
- else {
- memcpy(skb_put(skb, count), hsp->rcvbuf, count);
- skb_queue_tail(&hsp->rqueue, skb);
- }
- }
- }
- hsp->rcvidx = 0;
- hscx_sched_event(hsp, HSCX_RCVBUFREADY);
- }
- if (val & 0x40) { /* RPF */
- hscx_empty_fifo(hsp, 32);
- if (hsp->mode == 1) {
- /* receive audio data */
- if (!(skb = dev_alloc_skb(32)))
- printk(KERN_WARNING "AVM: receive out of memory\n");
- else {
- memcpy(skb_put(skb, 32), hsp->rcvbuf, 32);
- skb_queue_tail(&hsp->rqueue, skb);
- }
- hsp->rcvidx = 0;
- hscx_sched_event(hsp, HSCX_RCVBUFREADY);
- }
- }
- if (val & 0x10) { /* XPR */
- if (hsp->tx_skb)
- if (hsp->tx_skb->len) {
- hscx_fill_fifo(hsp);
- return;
- } else {
- SET_SKB_FREE(hsp->tx_skb);
- dev_kfree_skb(hsp->tx_skb);
- hsp->count = 0;
- if (hsp->st->l4.l1writewakeup)
- hsp->st->l4.l1writewakeup(hsp->st);
- hsp->tx_skb = NULL;
- }
- if ((hsp->tx_skb = skb_dequeue(&hsp->squeue))) {
- hsp->count = 0;
- hscx_fill_fifo(hsp);
- } else
- hscx_sched_event(hsp, HSCX_XMTBUFREADY);
- }
+ return (readhscx(cs->hw.teles0.membase, hscx, offset));
}
-/*
- * ISAC stuff goes here
- */
-
static void
-isac_empty_fifo(struct IsdnCardState *sp, int count)
+WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
{
- u_char *ptr;
- long flags;
-
- if ((sp->debug & L1_DEB_ISAC) && !(sp->debug & L1_DEB_ISAC_FIFO))
- debugl1(sp, "isac_empty_fifo");
-
- if ((sp->rcvidx + count) >= MAX_DFRAME_LEN) {
- if (sp->debug & L1_DEB_WARN) {
- char tmp[40];
- sprintf(tmp, "isac_empty_fifo overrun %d",
- sp->rcvidx + count);
- debugl1(sp, tmp);
- }
- writeisac(sp->membase, ISAC_CMDR, 0x80);
- sp->rcvidx = 0;
- return;
- }
- ptr = sp->rcvbuf + sp->rcvidx;
- sp->rcvidx += count;
- save_flags(flags);
- cli();
- read_fifo_isac(sp->membase, ptr, count);
- writeisac(sp->membase, ISAC_CMDR, 0x80);
- restore_flags(flags);
- if (sp->debug & L1_DEB_ISAC_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "isac_empty_fifo cnt %d", count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ writehscx(cs->hw.teles0.membase, hscx, offset, value);
}
-static void
-isac_fill_fifo(struct IsdnCardState *sp)
-{
- int count, more;
- u_char *ptr;
- long flags;
-
- if ((sp->debug & L1_DEB_ISAC) && !(sp->debug & L1_DEB_ISAC_FIFO))
- debugl1(sp, "isac_fill_fifo");
-
- if (!sp->tx_skb)
- return;
-
- count = sp->tx_skb->len;
- if (count <= 0)
- return;
-
- more = 0;
- if (count > 32) {
- more = !0;
- count = 32;
- }
- save_flags(flags);
- cli();
- ptr = sp->tx_skb->data;
- skb_pull(sp->tx_skb, count);
- sp->tx_cnt += count;
- write_fifo_isac(sp->membase, ptr, count);
- writeisac(sp->membase, ISAC_CMDR, more ? 0x8 : 0xa);
- restore_flags(flags);
- if (sp->debug & L1_DEB_ISAC_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "isac_fill_fifo cnt %d", count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
-}
-
-static void
-ph_command(struct IsdnCardState *sp, unsigned int command)
-{
- if (sp->debug & L1_DEB_ISAC) {
- char tmp[32];
- sprintf(tmp, "ph_command %d", command);
- debugl1(sp, tmp);
- }
- writeisac(sp->membase, ISAC_CIX0, (command << 2) | 3);
-}
-
-static inline void
-isac_interrupt(struct IsdnCardState *sp, u_char val)
-{
- u_char exval;
- struct sk_buff *skb;
- unsigned int count;
- char tmp[32];
-
- if (sp->debug & L1_DEB_ISAC) {
- sprintf(tmp, "ISAC interrupt %x", val);
- debugl1(sp, tmp);
- }
- if (val & 0x80) { /* RME */
- exval = readisac(sp->membase, ISAC_RSTA);
- if ((exval & 0x70) != 0x20) {
- if (exval & 0x40)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC RDO");
- if (!exval & 0x20)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC CRC error");
- writeisac(sp->membase, ISAC_CMDR, 0x80);
- } else {
- count = readisac(sp->membase, ISAC_RBCL) & 0x1f;
- if (count == 0)
- count = 32;
- isac_empty_fifo(sp, count);
- if ((count = sp->rcvidx) > 0) {
- if (!(skb = alloc_skb(count, GFP_ATOMIC)))
- printk(KERN_WARNING "AVM: D receive out of memory\n");
- else {
- memcpy(skb_put(skb, count), sp->rcvbuf, count);
- skb_queue_tail(&sp->rq, skb);
- }
- }
- }
- sp->rcvidx = 0;
- isac_sched_event(sp, ISAC_RCVBUFREADY);
- }
- if (val & 0x40) { /* RPF */
- isac_empty_fifo(sp, 32);
- }
- if (val & 0x20) { /* RSC */
- /* never */
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC RSC interrupt");
- }
- if (val & 0x10) { /* XPR */
- if (sp->tx_skb)
- if (sp->tx_skb->len) {
- isac_fill_fifo(sp);
- goto afterXPR;
- } else {
- SET_SKB_FREE(sp->tx_skb);
- dev_kfree_skb(sp->tx_skb);
- sp->tx_cnt = 0;
- sp->tx_skb = NULL;
- }
- if ((sp->tx_skb = skb_dequeue(&sp->sq))) {
- sp->tx_cnt = 0;
- isac_fill_fifo(sp);
- } else
- isac_sched_event(sp, ISAC_XMTBUFREADY);
- }
- afterXPR:
- if (val & 0x04) { /* CISQ */
- sp->ph_state = (readisac(sp->membase, ISAC_CIX0) >> 2)
- & 0xf;
- if (sp->debug & L1_DEB_ISAC) {
- sprintf(tmp, "l1state %d", sp->ph_state);
- debugl1(sp, tmp);
- }
- isac_new_ph(sp);
- }
- if (val & 0x02) { /* SIN */
- /* never */
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC SIN interrupt");
- }
- if (val & 0x01) { /* EXI */
- exval = readisac(sp->membase, ISAC_EXIR);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "ISAC EXIR %02x", exval);
- debugl1(sp, tmp);
- }
- }
-}
+/*
+ * fast interrupt HSCX stuff goes here
+ */
-static inline void
-hscx_int_main(struct IsdnCardState *sp, u_char val)
-{
+#define READHSCX(cs, nr, reg) readhscx(cs->hw.teles0.membase, nr, reg)
+#define WRITEHSCX(cs, nr, reg, data) writehscx(cs->hw.teles0.membase, nr, reg, data)
+#define READHSCXFIFO(cs, nr, ptr, cnt) read_fifo_hscx(cs->hw.teles0.membase, nr, ptr, cnt)
+#define WRITEHSCXFIFO(cs, nr, ptr, cnt) write_fifo_hscx(cs->hw.teles0.membase, nr, ptr, cnt)
- u_char exval;
- struct HscxState *hsp;
- char tmp[32];
-
-
- if (val & 0x01) {
- hsp = sp->hs + 1;
- exval = readhscx(sp->membase, 1, HSCX_EXIR);
- if (exval == 0x40) {
- if (hsp->mode == 1)
- hscx_fill_fifo(hsp);
- else {
- /* Here we lost an TX interrupt, so
- * restart transmitting the whole frame.
- */
- if (hsp->tx_skb) {
- skb_push(hsp->tx_skb, hsp->count);
- hsp->tx_cnt += hsp->count;
- hsp->count = 0;
- }
- writehscxCMDR(sp->membase, hsp->hscx, 0x01);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX B EXIR %x Lost TX", exval);
- debugl1(sp, tmp);
- }
- }
- } else if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX B EXIR %x", exval);
- debugl1(sp, tmp);
- }
- }
- if (val & 0xf8) {
- if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX B interrupt %x", val);
- debugl1(sp, tmp);
- }
- hscx_interrupt(sp, val, 1);
- }
- if (val & 0x02) {
- hsp = sp->hs;
- exval = readhscx(sp->membase, 0, HSCX_EXIR);
- if (exval == 0x40) {
- if (hsp->mode == 1)
- hscx_fill_fifo(hsp);
- else {
- /* Here we lost an TX interrupt, so
- * restart transmitting the whole frame.
- */
- if (hsp->tx_skb) {
- skb_push(hsp->tx_skb, hsp->count);
- hsp->tx_cnt += hsp->count;
- hsp->count = 0;
- }
- writehscxCMDR(sp->membase, hsp->hscx, 0x01);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX A EXIR %x Lost TX", exval);
- debugl1(sp, tmp);
- }
- }
- } else if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX A EXIR %x", exval);
- debugl1(sp, tmp);
- }
- }
- if (val & 0x04) {
- exval = readhscx(sp->membase, 0, HSCX_ISTA);
- if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX A interrupt %x", exval);
- debugl1(sp, tmp);
- }
- hscx_interrupt(sp, exval, 0);
- }
-}
+#include "hscx_irq.c"
static void
-telesS0_interrupt(int intno, void *dev_id, struct pt_regs *regs)
+teles0_interrupt(int intno, void *dev_id, struct pt_regs *regs)
{
- struct IsdnCardState *sp;
+ struct IsdnCardState *cs = dev_id;
u_char val, stat = 0;
+ int count = 0;
- sp = (struct IsdnCardState *) dev_id;
-
- if (!sp) {
+ if (!cs) {
printk(KERN_WARNING "Teles0: Spurious interrupt!\n");
return;
}
- val = readhscx(sp->membase, 1, HSCX_ISTA);
+ val = readhscx(cs->hw.teles0.membase, 1, HSCX_ISTA);
Start_HSCX:
if (val) {
- hscx_int_main(sp, val);
+ hscx_int_main(cs, val);
stat |= 1;
}
- val = readisac(sp->membase, ISAC_ISTA);
+ val = readisac(cs->hw.teles0.membase, ISAC_ISTA);
Start_ISAC:
if (val) {
- isac_interrupt(sp, val);
+ isac_interrupt(cs, val);
stat |= 2;
}
- val = readhscx(sp->membase, 1, HSCX_ISTA);
- if (val) {
- if (sp->debug & L1_DEB_HSCX)
- debugl1(sp, "HSCX IntStat after IntRoutine");
+ count++;
+ val = readhscx(cs->hw.teles0.membase, 1, HSCX_ISTA);
+ if (val && count < 20) {
+ if (cs->debug & L1_DEB_HSCX)
+ debugl1(cs, "HSCX IntStat after IntRoutine");
goto Start_HSCX;
}
- val = readisac(sp->membase, ISAC_ISTA);
- if (val) {
- if (sp->debug & L1_DEB_ISAC)
- debugl1(sp, "ISAC IntStat after IntRoutine");
+ val = readisac(cs->hw.teles0.membase, ISAC_ISTA);
+ if (val && count < 20) {
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ISAC IntStat after IntRoutine");
goto Start_ISAC;
}
if (stat & 1) {
- writehscx(sp->membase, 0, HSCX_MASK, 0xFF);
- writehscx(sp->membase, 1, HSCX_MASK, 0xFF);
- writehscx(sp->membase, 0, HSCX_MASK, 0x0);
- writehscx(sp->membase, 1, HSCX_MASK, 0x0);
+ writehscx(cs->hw.teles0.membase, 0, HSCX_MASK, 0xFF);
+ writehscx(cs->hw.teles0.membase, 1, HSCX_MASK, 0xFF);
+ writehscx(cs->hw.teles0.membase, 0, HSCX_MASK, 0x0);
+ writehscx(cs->hw.teles0.membase, 1, HSCX_MASK, 0x0);
}
if (stat & 2) {
- writeisac(sp->membase, ISAC_MASK, 0xFF);
- writeisac(sp->membase, ISAC_MASK, 0x0);
+ writeisac(cs->hw.teles0.membase, ISAC_MASK, 0xFF);
+ writeisac(cs->hw.teles0.membase, ISAC_MASK, 0x0);
}
}
-
-static void
-initisac(struct IsdnCardState *sp)
-{
- unsigned int adr = sp->membase;
-
- /* 16.0 IOM 1 Mode */
- writeisac(adr, ISAC_MASK, 0xff);
- writeisac(adr, ISAC_ADF2, 0x0);
- writeisac(adr, ISAC_SPCR, 0xa);
- writeisac(adr, ISAC_ADF1, 0x2);
- writeisac(adr, ISAC_STCR, 0x70);
- writeisac(adr, ISAC_MODE, 0xc9);
- writeisac(adr, ISAC_CMDR, 0x41);
- writeisac(adr, ISAC_CIX0, (1 << 2) | 3);
- writeisac(adr, ISAC_MASK, 0xff);
- writeisac(adr, ISAC_MASK, 0x0);
-}
-
-static void
-modehscx(struct HscxState *hs, int mode, int ichan)
-{
- struct IsdnCardState *sp = hs->sp;
- int hscx = hs->hscx;
-
- if (sp->debug & L1_DEB_HSCX) {
- char tmp[40];
- sprintf(tmp, "hscx %c mode %d ichan %d",
- 'A' + hscx, mode, ichan);
- debugl1(sp, tmp);
- }
- hs->mode = mode;
- writehscx(sp->membase, hscx, HSCX_CCR1, 0x85);
- writehscx(sp->membase, hscx, HSCX_XAD1, 0xFF);
- writehscx(sp->membase, hscx, HSCX_XAD2, 0xFF);
- writehscx(sp->membase, hscx, HSCX_RAH2, 0xFF);
- writehscx(sp->membase, hscx, HSCX_XBCH, 0x0);
-
- /* Switch IOM 1 SSI */
- if (hscx == 0)
- ichan = 1 - ichan;
-
- switch (mode) {
- case (0):
- writehscx(sp->membase, hscx, HSCX_CCR2, 0x30);
- writehscx(sp->membase, hscx, HSCX_TSAX, 0xff);
- writehscx(sp->membase, hscx, HSCX_TSAR, 0xff);
- writehscx(sp->membase, hscx, HSCX_XCCR, 7);
- writehscx(sp->membase, hscx, HSCX_RCCR, 7);
- writehscx(sp->membase, hscx, HSCX_MODE, 0x84);
- break;
- case (1):
- if (ichan == 0) {
- writehscx(sp->membase, hscx, HSCX_CCR2, 0x30);
- writehscx(sp->membase, hscx, HSCX_TSAX, 0x7);
- writehscx(sp->membase, hscx, HSCX_TSAR, 0x7);
- writehscx(sp->membase, hscx, HSCX_XCCR, 7);
- writehscx(sp->membase, hscx, HSCX_RCCR, 7);
- } else {
- writehscx(sp->membase, hscx, HSCX_CCR2, 0x30);
- writehscx(sp->membase, hscx, HSCX_TSAX, 0x3);
- writehscx(sp->membase, hscx, HSCX_TSAR, 0x3);
- writehscx(sp->membase, hscx, HSCX_XCCR, 7);
- writehscx(sp->membase, hscx, HSCX_RCCR, 7);
- }
- writehscx(sp->membase, hscx, HSCX_MODE, 0xe4);
- writehscx(sp->membase, hscx, HSCX_CMDR, 0x41);
- break;
- case (2):
- if (ichan == 0) {
- writehscx(sp->membase, hscx, HSCX_CCR2, 0x30);
- writehscx(sp->membase, hscx, HSCX_TSAX, 0x7);
- writehscx(sp->membase, hscx, HSCX_TSAR, 0x7);
- writehscx(sp->membase, hscx, HSCX_XCCR, 7);
- writehscx(sp->membase, hscx, HSCX_RCCR, 7);
- } else {
- writehscx(sp->membase, hscx, HSCX_CCR2, 0x30);
- writehscx(sp->membase, hscx, HSCX_TSAX, 0x3);
- writehscx(sp->membase, hscx, HSCX_TSAR, 0x3);
- writehscx(sp->membase, hscx, HSCX_XCCR, 7);
- writehscx(sp->membase, hscx, HSCX_RCCR, 7);
- }
- writehscx(sp->membase, hscx, HSCX_MODE, 0x8c);
- writehscx(sp->membase, hscx, HSCX_CMDR, 0x41);
- break;
- }
- writehscx(sp->membase, hscx, HSCX_ISTA, 0x00);
-}
-
void
-release_io_teles0(struct IsdnCard *card)
+release_io_teles0(struct IsdnCardState *cs)
{
- if (card->sp->cfg_reg)
- release_region(card->sp->cfg_reg, 8);
+ if (cs->hw.teles0.cfg_reg)
+ release_region(cs->hw.teles0.cfg_reg, 8);
}
-static void
-clear_pending_ints(struct IsdnCardState *sp)
+static int
+reset_teles0(struct IsdnCardState *cs)
{
- int val;
- char tmp[64];
+ u_char cfval;
+ long flags;
- val = readhscx(sp->membase, 1, HSCX_ISTA);
- sprintf(tmp, "HSCX B ISTA %x", val);
- debugl1(sp, tmp);
- if (val & 0x01) {
- val = readhscx(sp->membase, 1, HSCX_EXIR);
- sprintf(tmp, "HSCX B EXIR %x", val);
- debugl1(sp, tmp);
- } else if (val & 0x02) {
- val = readhscx(sp->membase, 0, HSCX_EXIR);
- sprintf(tmp, "HSCX A EXIR %x", val);
- debugl1(sp, tmp);
- }
- val = readhscx(sp->membase, 0, HSCX_ISTA);
- sprintf(tmp, "HSCX A ISTA %x", val);
- debugl1(sp, tmp);
- val = readhscx(sp->membase, 1, HSCX_STAR);
- sprintf(tmp, "HSCX B STAR %x", val);
- debugl1(sp, tmp);
- val = readhscx(sp->membase, 0, HSCX_STAR);
- sprintf(tmp, "HSCX A STAR %x", val);
- debugl1(sp, tmp);
- val = readisac(sp->membase, ISAC_STAR);
- sprintf(tmp, "ISAC STAR %x", val);
- debugl1(sp, tmp);
- val = readisac(sp->membase, ISAC_MODE);
- sprintf(tmp, "ISAC MODE %x", val);
- debugl1(sp, tmp);
- val = readisac(sp->membase, ISAC_ADF2);
- sprintf(tmp, "ISAC ADF2 %x", val);
- debugl1(sp, tmp);
- val = readisac(sp->membase, ISAC_ISTA);
- sprintf(tmp, "ISAC ISTA %x", val);
- debugl1(sp, tmp);
- if (val & 0x01) {
- val = readisac(sp->membase, ISAC_EXIR);
- sprintf(tmp, "ISAC EXIR %x", val);
- debugl1(sp, tmp);
- } else if (val & 0x04) {
- val = readisac(sp->membase, ISAC_CIR0);
- sprintf(tmp, "ISAC CIR0 %x", val);
- debugl1(sp, tmp);
+ save_flags(flags);
+ sti();
+ if (cs->hw.teles0.cfg_reg) {
+ switch (cs->irq) {
+ case 2:
+ case 9:
+ cfval = 0x00;
+ break;
+ case 3:
+ cfval = 0x02;
+ break;
+ case 4:
+ cfval = 0x04;
+ break;
+ case 5:
+ cfval = 0x06;
+ break;
+ case 10:
+ cfval = 0x08;
+ break;
+ case 11:
+ cfval = 0x0A;
+ break;
+ case 12:
+ cfval = 0x0C;
+ break;
+ case 15:
+ cfval = 0x0E;
+ break;
+ default:
+ return(1);
+ }
+ cfval |= ((cs->hw.teles0.membase >> 9) & 0xF0);
+ byteout(cs->hw.teles0.cfg_reg + 4, cfval);
+ HZDELAY(HZ / 10 + 1);
+ byteout(cs->hw.teles0.cfg_reg + 4, cfval | 1);
+ HZDELAY(HZ / 10 + 1);
}
- writeisac(sp->membase, ISAC_MASK, 0);
- writeisac(sp->membase, ISAC_CMDR, 0x41);
+ writeb(0, cs->hw.teles0.membase + 0x80);
+ HZDELAY(HZ / 5 + 1);
+ writeb(1, cs->hw.teles0.membase + 0x80);
+ HZDELAY(HZ / 5 + 1);
+ restore_flags(flags);
+ return(0);
}
-int
-initteles0(struct IsdnCardState *sp)
+static int
+Teles_card_msg(struct IsdnCardState *cs, int mt, void *arg)
{
- int ret;
- int loop = 0;
- char tmp[40];
-
- sp->counter = kstat_irqs(sp->irq);
- sprintf(tmp, "IRQ %d count %d", sp->irq, sp->counter);
- debugl1(sp, tmp);
- clear_pending_ints(sp);
- ret = get_irq(sp->cardnr, &telesS0_interrupt);
- if (ret) {
- initisac(sp);
- sp->modehscx(sp->hs, 0, 0);
- sp->modehscx(sp->hs + 1, 0, 0);
- while (loop++ < 10) {
- /* At least 1-3 irqs must happen
- * (one from HSCX A, one from HSCX B, 3rd from ISAC)
- */
- if (kstat_irqs(sp->irq) > sp->counter)
- break;
- current->state = TASK_INTERRUPTIBLE;
- current->timeout = jiffies + 1;
- schedule();
- }
- sprintf(tmp, "IRQ %d count %d", sp->irq,
- kstat_irqs(sp->irq));
- debugl1(sp, tmp);
- if (kstat_irqs(sp->irq) == sp->counter) {
- printk(KERN_WARNING
- "Teles0: IRQ(%d) getting no interrupts during init\n",
- sp->irq);
- free_irq(sp->irq, sp);
- return (0);
- }
- }
- return (ret);
+ switch (mt) {
+ case CARD_RESET:
+ reset_teles0(cs);
+ return(0);
+ case CARD_RELEASE:
+ release_io_teles0(cs);
+ return(0);
+ case CARD_SETIRQ:
+ return(request_irq(cs->irq, &teles0_interrupt,
+ I4L_IRQ_FLAG, "HiSax", cs));
+ case CARD_INIT:
+ clear_pending_isac_ints(cs);
+ clear_pending_hscx_ints(cs);
+ initisac(cs);
+ inithscx(cs);
+ return(0);
+ case CARD_TEST:
+ return(0);
+ }
+ return(0);
}
-int
-setup_teles0(struct IsdnCard *card)
+__initfunc(int
+setup_teles0(struct IsdnCard *card))
{
- u_char cfval, val, verA, verB;
- struct IsdnCardState *sp = card->sp;
- long flags;
+ u_char val;
+ struct IsdnCardState *cs = card->cs;
char tmp[64];
strcpy(tmp, teles0_revision);
- printk(KERN_NOTICE "HiSax: Teles 8.0/16.0 driver Rev. %s\n", HiSax_getrev(tmp));
- if ((sp->typ != ISDN_CTYPE_16_0) && (sp->typ != ISDN_CTYPE_8_0))
+ printk(KERN_INFO "HiSax: Teles 8.0/16.0 driver Rev. %s\n", HiSax_getrev(tmp));
+ if ((cs->typ != ISDN_CTYPE_16_0) && (cs->typ != ISDN_CTYPE_8_0))
return (0);
- if (sp->typ == ISDN_CTYPE_16_0)
- sp->cfg_reg = card->para[2];
+ if (cs->typ == ISDN_CTYPE_16_0)
+ cs->hw.teles0.cfg_reg = card->para[2];
else /* 8.0 */
- sp->cfg_reg = 0;
+ cs->hw.teles0.cfg_reg = 0;
if (card->para[1] < 0x10000) {
card->para[1] <<= 4;
@@ -859,110 +320,69 @@ setup_teles0(struct IsdnCard *card)
"Teles0: membase configured DOSish, assuming 0x%lx\n",
(unsigned long) card->para[1]);
}
- sp->membase = card->para[1];
- sp->irq = card->para[0];
- if (sp->cfg_reg) {
- if (check_region((sp->cfg_reg), 8)) {
+ cs->hw.teles0.membase = card->para[1];
+ cs->irq = card->para[0];
+ if (cs->hw.teles0.cfg_reg) {
+ if (check_region((cs->hw.teles0.cfg_reg), 8)) {
printk(KERN_WARNING
"HiSax: %s config port %x-%x already in use\n",
CardType[card->typ],
- sp->cfg_reg,
- sp->cfg_reg + 8);
+ cs->hw.teles0.cfg_reg,
+ cs->hw.teles0.cfg_reg + 8);
return (0);
} else {
- request_region(sp->cfg_reg, 8, "teles cfg");
+ request_region(cs->hw.teles0.cfg_reg, 8, "teles cfg");
}
}
- switch (sp->irq) {
- case 2:
- cfval = 0x00;
- break;
- case 3:
- cfval = 0x02;
- break;
- case 4:
- cfval = 0x04;
- break;
- case 5:
- cfval = 0x06;
- break;
- case 10:
- cfval = 0x08;
- break;
- case 11:
- cfval = 0x0A;
- break;
- case 12:
- cfval = 0x0C;
- break;
- case 15:
- cfval = 0x0E;
- break;
- default:
- cfval = 0x00;
- break;
- }
- cfval |= ((card->para[1] >> 9) & 0xF0);
- if (sp->cfg_reg) {
- if ((val = bytein(sp->cfg_reg + 0)) != 0x51) {
+ if (cs->hw.teles0.cfg_reg) {
+ if ((val = bytein(cs->hw.teles0.cfg_reg + 0)) != 0x51) {
printk(KERN_WARNING "Teles0: 16.0 Byte at %x is %x\n",
- sp->cfg_reg + 0, val);
- release_region(sp->cfg_reg, 8);
+ cs->hw.teles0.cfg_reg + 0, val);
+ release_region(cs->hw.teles0.cfg_reg, 8);
return (0);
}
- if ((val = bytein(sp->cfg_reg + 1)) != 0x93) {
+ if ((val = bytein(cs->hw.teles0.cfg_reg + 1)) != 0x93) {
printk(KERN_WARNING "Teles0: 16.0 Byte at %x is %x\n",
- sp->cfg_reg + 1, val);
- release_region(sp->cfg_reg, 8);
+ cs->hw.teles0.cfg_reg + 1, val);
+ release_region(cs->hw.teles0.cfg_reg, 8);
return (0);
}
- val = bytein(sp->cfg_reg + 2); /* 0x1e=without AB
- * 0x1f=with AB
- * 0x1c 16.3 ???
- */
+ val = bytein(cs->hw.teles0.cfg_reg + 2); /* 0x1e=without AB
+ * 0x1f=with AB
+ * 0x1c 16.3 ???
+ */
if (val != 0x1e && val != 0x1f) {
printk(KERN_WARNING "Teles0: 16.0 Byte at %x is %x\n",
- sp->cfg_reg + 2, val);
- release_region(sp->cfg_reg, 8);
+ cs->hw.teles0.cfg_reg + 2, val);
+ release_region(cs->hw.teles0.cfg_reg, 8);
return (0);
}
- save_flags(flags);
- byteout(sp->cfg_reg + 4, cfval);
- sti();
- HZDELAY(HZ / 10 + 1);
- byteout(sp->cfg_reg + 4, cfval | 1);
- HZDELAY(HZ / 10 + 1);
- restore_flags(flags);
}
- printk(KERN_NOTICE
- "HiSax: %s config irq:%d mem:%x cfg:%x\n",
- CardType[sp->typ], sp->irq,
- sp->membase, sp->cfg_reg);
- verA = readhscx(sp->membase, 0, HSCX_VSTR) & 0xf;
- verB = readhscx(sp->membase, 1, HSCX_VSTR) & 0xf;
- printk(KERN_INFO "Teles0: HSCX version A: %s B: %s\n",
- HscxVersion(verA), HscxVersion(verB));
- val = readisac(sp->membase, ISAC_RBCH);
- printk(KERN_INFO "Teles0: ISAC %s\n",
- ISACVersion(val));
-
- if ((verA == 0) | (verA == 0xf) | (verB == 0) | (verB == 0xf)) {
+ /* 16.0 and 8.0 designed for IOM1 */
+ test_and_set_bit(HW_IOM1, &cs->HW_Flags);
+ printk(KERN_INFO
+ "HiSax: %s config irq:%d mem:0x%X cfg:0x%X\n",
+ CardType[cs->typ], cs->irq,
+ cs->hw.teles0.membase, cs->hw.teles0.cfg_reg);
+ if (reset_teles0(cs)) {
+ printk(KERN_WARNING "Teles0: wrong IRQ\n");
+ release_io_teles0(cs);
+ return (0);
+ }
+ cs->readisac = &ReadISAC;
+ cs->writeisac = &WriteISAC;
+ cs->readisacfifo = &ReadISACfifo;
+ cs->writeisacfifo = &WriteISACfifo;
+ cs->BC_Read_Reg = &ReadHSCX;
+ cs->BC_Write_Reg = &WriteHSCX;
+ cs->BC_Send_Data = &hscx_fill_fifo;
+ cs->cardmsg = &Teles_card_msg;
+ ISACVersion(cs, "Teles0:");
+ if (HscxVersion(cs, "Teles0:")) {
printk(KERN_WARNING
"Teles0: wrong HSCX versions check IO/MEM addresses\n");
- release_io_teles0(card);
+ release_io_teles0(cs);
return (0);
}
- save_flags(flags);
- writeb(0, sp->membase + 0x80);
- sti();
- HZDELAY(HZ / 5 + 1);
- writeb(1, sp->membase + 0x80);
- HZDELAY(HZ / 5 + 1);
- restore_flags(flags);
-
- sp->modehscx = &modehscx;
- sp->ph_command = &ph_command;
- sp->hscx_fill_fifo = &hscx_fill_fifo;
- sp->isac_fill_fifo = &isac_fill_fifo;
return (1);
}
diff --git a/drivers/isdn/hisax/teles3.c b/drivers/isdn/hisax/teles3.c
index 4b92e5ab7..261d054fb 100644
--- a/drivers/isdn/hisax/teles3.c
+++ b/drivers/isdn/hisax/teles3.c
@@ -1,4 +1,4 @@
-/* $Id: teles3.c,v 1.11 1997/04/13 19:54:05 keil Exp $
+/* $Id: teles3.c,v 2.7 1998/02/02 13:29:48 keil Exp $
* teles3.c low level stuff for Teles 16.3 & PNP isdn cards
*
@@ -11,6 +11,30 @@
* Beat Doebeli
*
* $Log: teles3.c,v $
+ * Revision 2.7 1998/02/02 13:29:48 keil
+ * fast io
+ *
+ * Revision 2.6 1997/11/13 16:22:44 keil
+ * COMPAQ_ISA reset
+ *
+ * Revision 2.5 1997/11/12 15:01:25 keil
+ * COMPAQ_ISA changes
+ *
+ * Revision 2.4 1997/11/08 21:35:56 keil
+ * new l1 init
+ *
+ * Revision 2.3 1997/11/06 17:09:33 keil
+ * New 2.1 init code
+ *
+ * Revision 2.2 1997/10/29 18:55:59 keil
+ * changes for 2.1.60 (irq2dev_map)
+ *
+ * Revision 2.1 1997/07/27 21:47:12 keil
+ * new interface structures
+ *
+ * Revision 2.0 1997/06/26 11:02:46 keil
+ * New Layer and card interface
+ *
* Revision 1.11 1997/04/13 19:54:05 keil
* Change in IRQ check delay for SMP
*
@@ -35,36 +59,20 @@
* Revision 1.6 1997/01/27 15:52:55 keil
* SMP proof,cosmetics, PCMCIA added
*
- * Revision 1.5 1997/01/21 22:28:32 keil
- * cleanups
- *
- * Revision 1.4 1996/12/14 21:05:41 keil
- * Reset for 16.3 PnP
- *
- * Revision 1.3 1996/11/05 19:56:54 keil
- * debug output fixed
- *
- * Revision 1.2 1996/10/27 22:09:15 keil
- * cosmetic changes
- *
- * Revision 1.1 1996/10/13 20:04:59 keil
- * Initial revision
- *
- *
+ * removed old log info /KKe
*
*/
#define __NO_VERSION__
-#include "siemens.h"
#include "hisax.h"
-#include "teles3.h"
+#include "isac.h"
+#include "hscx.h"
#include "isdnl1.h"
-#include <linux/kernel_stat.h>
extern const char *CardType[];
-const char *teles3_revision = "$Revision: 1.11 $";
+const char *teles3_revision = "$Revision: 2.7 $";
-#define byteout(addr,val) outb_p(val,addr)
-#define bytein(addr) inb_p(addr)
+#define byteout(addr,val) outb(val,addr)
+#define bytein(addr) inb(addr)
static inline u_char
readreg(unsigned int adr, u_char off)
@@ -82,953 +90,410 @@ writereg(unsigned int adr, u_char off, u_char data)
static inline void
read_fifo(unsigned int adr, u_char * data, int size)
{
- insb(adr + 0x1e, data, size);
+ insb(adr, data, size);
}
static void
write_fifo(unsigned int adr, u_char * data, int size)
{
- outsb(adr + 0x1e, data, size);
+ outsb(adr, data, size);
}
-static inline void
-waitforCEC(int adr)
-{
- int to = 50;
+/* Interface functions */
- while ((readreg(adr, HSCX_STAR) & 0x04) && to) {
- udelay(1);
- to--;
- }
- if (!to)
- printk(KERN_WARNING "Teles3: waitforCEC timeout\n");
-}
-
-
-static inline void
-waitforXFW(int adr)
+static u_char
+ReadISAC(struct IsdnCardState *cs, u_char offset)
{
- int to = 50;
-
- while ((!(readreg(adr, HSCX_STAR) & 0x44) == 0x40) && to) {
- udelay(1);
- to--;
- }
- if (!to)
- printk(KERN_WARNING "Teles3: waitforXFW timeout\n");
+ return (readreg(cs->hw.teles3.isac, offset));
}
-static inline void
-writehscxCMDR(int adr, u_char data)
-{
- long flags;
-
- save_flags(flags);
- cli();
- waitforCEC(adr);
- writereg(adr, HSCX_CMDR, data);
- restore_flags(flags);
-}
-
-/*
- * fast interrupt here
- */
-
-static void
-hscxreport(struct IsdnCardState *sp, int hscx)
-{
- printk(KERN_DEBUG "HSCX %d\n", hscx);
- printk(KERN_DEBUG "ISTA %x\n", readreg(sp->hscx[hscx], HSCX_ISTA));
- printk(KERN_DEBUG "STAR %x\n", readreg(sp->hscx[hscx], HSCX_STAR));
- printk(KERN_DEBUG "EXIR %x\n", readreg(sp->hscx[hscx], HSCX_EXIR));
-}
-
-void
-teles3_report(struct IsdnCardState *sp)
-{
- printk(KERN_DEBUG "ISAC\n");
- printk(KERN_DEBUG "ISTA %x\n", readreg(sp->isac, ISAC_ISTA));
- printk(KERN_DEBUG "STAR %x\n", readreg(sp->isac, ISAC_STAR));
- printk(KERN_DEBUG "EXIR %x\n", readreg(sp->isac, ISAC_EXIR));
- hscxreport(sp, 0);
- hscxreport(sp, 1);
-}
-
-/*
- * HSCX stuff goes here
- */
static void
-hscx_empty_fifo(struct HscxState *hsp, int count)
+WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
{
- u_char *ptr;
- struct IsdnCardState *sp = hsp->sp;
- long flags;
-
- if ((sp->debug & L1_DEB_HSCX) && !(sp->debug & L1_DEB_HSCX_FIFO))
- debugl1(sp, "hscx_empty_fifo");
-
- if (hsp->rcvidx + count > HSCX_BUFMAX) {
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "hscx_empty_fifo: incoming packet too large");
- writehscxCMDR(sp->hscx[hsp->hscx], 0x80);
- hsp->rcvidx = 0;
- return;
- }
- ptr = hsp->rcvbuf + hsp->rcvidx;
- hsp->rcvidx += count;
- save_flags(flags);
- cli();
- read_fifo(sp->hscx[hsp->hscx], ptr, count);
- writehscxCMDR(sp->hscx[hsp->hscx], 0x80);
- restore_flags(flags);
- if (sp->debug & L1_DEB_HSCX_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "hscx_empty_fifo %c cnt %d",
- hsp->hscx ? 'B' : 'A', count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ writereg(cs->hw.teles3.isac, offset, value);
}
static void
-hscx_fill_fifo(struct HscxState *hsp)
-{
- struct IsdnCardState *sp = hsp->sp;
- int more, count;
- u_char *ptr;
- long flags;
-
- if ((sp->debug & L1_DEB_HSCX) && !(sp->debug & L1_DEB_HSCX_FIFO))
- debugl1(sp, "hscx_fill_fifo");
-
- if (!hsp->tx_skb)
- return;
- if (hsp->tx_skb->len <= 0)
- return;
-
- more = (hsp->mode == 1) ? 1 : 0;
- if (hsp->tx_skb->len > 32) {
- more = !0;
- count = 32;
- } else
- count = hsp->tx_skb->len;
-
- waitforXFW(sp->hscx[hsp->hscx]);
- save_flags(flags);
- cli();
- ptr = hsp->tx_skb->data;
- skb_pull(hsp->tx_skb, count);
- hsp->tx_cnt -= count;
- hsp->count += count;
- write_fifo(sp->hscx[hsp->hscx], ptr, count);
- writehscxCMDR(sp->hscx[hsp->hscx], more ? 0x8 : 0xa);
- restore_flags(flags);
- if (sp->debug & L1_DEB_HSCX_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "hscx_fill_fifo %c cnt %d",
- hsp->hscx ? 'B' : 'A', count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
-}
-
-static inline void
-hscx_interrupt(struct IsdnCardState *sp, u_char val, u_char hscx)
+ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
{
- u_char r;
- struct HscxState *hsp = sp->hs + hscx;
- struct sk_buff *skb;
- int count;
- char tmp[32];
-
- if (!hsp->init)
- return;
-
- if (val & 0x80) { /* RME */
-
- r = readreg(sp->hscx[hsp->hscx], HSCX_RSTA);
- if ((r & 0xf0) != 0xa0) {
- if (!r & 0x80)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "HSCX invalid frame");
- if ((r & 0x40) && hsp->mode)
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX RDO mode=%d",
- hsp->mode);
- debugl1(sp, tmp);
- }
- if (!r & 0x20)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "HSCX CRC error");
- writehscxCMDR(sp->hscx[hsp->hscx], 0x80);
- } else {
- count = readreg(sp->hscx[hsp->hscx], HSCX_RBCL) & 0x1f;
- if (count == 0)
- count = 32;
- hscx_empty_fifo(hsp, count);
- if ((count = hsp->rcvidx - 1) > 0) {
- if (!(skb = dev_alloc_skb(count)))
- printk(KERN_WARNING "AVM: receive out of memory\n");
- else {
- memcpy(skb_put(skb, count), hsp->rcvbuf, count);
- skb_queue_tail(&hsp->rqueue, skb);
- }
- }
- }
- hsp->rcvidx = 0;
- hscx_sched_event(hsp, HSCX_RCVBUFREADY);
- }
- if (val & 0x40) { /* RPF */
- hscx_empty_fifo(hsp, 32);
- if (hsp->mode == 1) {
- /* receive audio data */
- if (!(skb = dev_alloc_skb(32)))
- printk(KERN_WARNING "AVM: receive out of memory\n");
- else {
- memcpy(skb_put(skb, 32), hsp->rcvbuf, 32);
- skb_queue_tail(&hsp->rqueue, skb);
- }
- hsp->rcvidx = 0;
- hscx_sched_event(hsp, HSCX_RCVBUFREADY);
- }
- }
- if (val & 0x10) { /* XPR */
- if (hsp->tx_skb)
- if (hsp->tx_skb->len) {
- hscx_fill_fifo(hsp);
- return;
- } else {
- SET_SKB_FREE(hsp->tx_skb);
- dev_kfree_skb(hsp->tx_skb);
- hsp->count = 0;
- if (hsp->st->l4.l1writewakeup)
- hsp->st->l4.l1writewakeup(hsp->st);
- hsp->tx_skb = NULL;
- }
- if ((hsp->tx_skb = skb_dequeue(&hsp->squeue))) {
- hsp->count = 0;
- hscx_fill_fifo(hsp);
- } else
- hscx_sched_event(hsp, HSCX_XMTBUFREADY);
- }
+ read_fifo(cs->hw.teles3.isacfifo, data, size);
}
-/*
- * ISAC stuff goes here
- */
-
static void
-isac_empty_fifo(struct IsdnCardState *sp, int count)
+WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
{
- u_char *ptr;
- long flags;
-
- if ((sp->debug & L1_DEB_ISAC) && !(sp->debug & L1_DEB_ISAC_FIFO))
- if (sp->debug & L1_DEB_ISAC)
- debugl1(sp, "isac_empty_fifo");
-
- if ((sp->rcvidx + count) >= MAX_DFRAME_LEN) {
- if (sp->debug & L1_DEB_WARN) {
- char tmp[40];
- sprintf(tmp, "isac_empty_fifo overrun %d",
- sp->rcvidx + count);
- debugl1(sp, tmp);
- }
- writereg(sp->isac, ISAC_CMDR, 0x80);
- sp->rcvidx = 0;
- return;
- }
- ptr = sp->rcvbuf + sp->rcvidx;
- sp->rcvidx += count;
- save_flags(flags);
- cli();
- read_fifo(sp->isac, ptr, count);
- writereg(sp->isac, ISAC_CMDR, 0x80);
- restore_flags(flags);
- if (sp->debug & L1_DEB_ISAC_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "isac_empty_fifo cnt %d", count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ write_fifo(cs->hw.teles3.isacfifo, data, size);
}
-static void
-isac_fill_fifo(struct IsdnCardState *sp)
+static u_char
+ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
{
- int count, more;
- u_char *ptr;
- long flags;
-
- if ((sp->debug & L1_DEB_ISAC) && !(sp->debug & L1_DEB_ISAC_FIFO))
- debugl1(sp, "isac_fill_fifo");
-
- if (!sp->tx_skb)
- return;
-
- count = sp->tx_skb->len;
- if (count <= 0)
- return;
-
- more = 0;
- if (count > 32) {
- more = !0;
- count = 32;
- }
- save_flags(flags);
- cli();
- ptr = sp->tx_skb->data;
- skb_pull(sp->tx_skb, count);
- sp->tx_cnt += count;
- write_fifo(sp->isac, ptr, count);
- writereg(sp->isac, ISAC_CMDR, more ? 0x8 : 0xa);
- restore_flags(flags);
- if (sp->debug & L1_DEB_ISAC_FIFO) {
- char tmp[128];
- char *t = tmp;
-
- t += sprintf(t, "isac_fill_fifo cnt %d", count);
- QuickHex(t, ptr, count);
- debugl1(sp, tmp);
- }
+ return (readreg(cs->hw.teles3.hscx[hscx], offset));
}
static void
-ph_command(struct IsdnCardState *sp, unsigned int command)
+WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
{
- if (sp->debug & L1_DEB_ISAC) {
- char tmp[32];
- sprintf(tmp, "ph_command %d", command);
- debugl1(sp, tmp);
- }
- writereg(sp->isac, ISAC_CIX0, (command << 2) | 3);
+ writereg(cs->hw.teles3.hscx[hscx], offset, value);
}
+/*
+ * fast interrupt HSCX stuff goes here
+ */
-static inline void
-isac_interrupt(struct IsdnCardState *sp, u_char val)
-{
- u_char exval;
- struct sk_buff *skb;
- unsigned int count;
- char tmp[32];
-
- if (sp->debug & L1_DEB_ISAC) {
- sprintf(tmp, "ISAC interrupt %x", val);
- debugl1(sp, tmp);
- }
- if (val & 0x80) { /* RME */
- exval = readreg(sp->isac, ISAC_RSTA);
- if ((exval & 0x70) != 0x20) {
- if (exval & 0x40)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC RDO");
- if (!exval & 0x20)
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC CRC error");
- writereg(sp->isac, ISAC_CMDR, 0x80);
- } else {
- count = readreg(sp->isac, ISAC_RBCL) & 0x1f;
- if (count == 0)
- count = 32;
- isac_empty_fifo(sp, count);
- if ((count = sp->rcvidx) > 0) {
- if (!(skb = alloc_skb(count, GFP_ATOMIC)))
- printk(KERN_WARNING "AVM: D receive out of memory\n");
- else {
- memcpy(skb_put(skb, count), sp->rcvbuf, count);
- skb_queue_tail(&sp->rq, skb);
- }
- }
- }
- sp->rcvidx = 0;
- isac_sched_event(sp, ISAC_RCVBUFREADY);
- }
- if (val & 0x40) { /* RPF */
- isac_empty_fifo(sp, 32);
- }
- if (val & 0x20) { /* RSC */
- /* never */
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC RSC interrupt");
- }
- if (val & 0x10) { /* XPR */
- if (sp->tx_skb)
- if (sp->tx_skb->len) {
- isac_fill_fifo(sp);
- goto afterXPR;
- } else {
- SET_SKB_FREE(sp->tx_skb);
- dev_kfree_skb(sp->tx_skb);
- sp->tx_cnt = 0;
- sp->tx_skb = NULL;
- }
- if ((sp->tx_skb = skb_dequeue(&sp->sq))) {
- sp->tx_cnt = 0;
- isac_fill_fifo(sp);
- } else
- isac_sched_event(sp, ISAC_XMTBUFREADY);
- }
- afterXPR:
- if (val & 0x04) { /* CISQ */
- sp->ph_state = (readreg(sp->isac, ISAC_CIX0) >> 2)
- & 0xf;
- if (sp->debug & L1_DEB_ISAC) {
- sprintf(tmp, "l1state %d", sp->ph_state);
- debugl1(sp, tmp);
- }
- isac_new_ph(sp);
- }
- if (val & 0x02) { /* SIN */
- /* never */
- if (sp->debug & L1_DEB_WARN)
- debugl1(sp, "ISAC SIN interrupt");
- }
- if (val & 0x01) { /* EXI */
- exval = readreg(sp->isac, ISAC_EXIR);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "ISAC EXIR %02x", exval);
- debugl1(sp, tmp);
- }
- }
-}
-
-static inline void
-hscx_int_main(struct IsdnCardState *sp, u_char val)
-{
-
- u_char exval;
- struct HscxState *hsp;
- char tmp[32];
+#define READHSCX(cs, nr, reg) readreg(cs->hw.teles3.hscx[nr], reg)
+#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.teles3.hscx[nr], reg, data)
+#define READHSCXFIFO(cs, nr, ptr, cnt) read_fifo(cs->hw.teles3.hscxfifo[nr], ptr, cnt)
+#define WRITEHSCXFIFO(cs, nr, ptr, cnt) write_fifo(cs->hw.teles3.hscxfifo[nr], ptr, cnt)
-
- if (val & 0x01) {
- hsp = sp->hs + 1;
- exval = readreg(sp->hscx[1], HSCX_EXIR);
- if (exval == 0x40) {
- if (hsp->mode == 1)
- hscx_fill_fifo(hsp);
- else {
- /* Here we lost an TX interrupt, so
- * restart transmitting the whole frame.
- */
- if (hsp->tx_skb) {
- skb_push(hsp->tx_skb, hsp->count);
- hsp->tx_cnt += hsp->count;
- hsp->count = 0;
- }
- writehscxCMDR(sp->hscx[hsp->hscx], 0x01);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX B EXIR %x Lost TX", exval);
- debugl1(sp, tmp);
- }
- }
- } else if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX B EXIR %x", exval);
- debugl1(sp, tmp);
- }
- }
- if (val & 0xf8) {
- if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX B interrupt %x", val);
- debugl1(sp, tmp);
- }
- hscx_interrupt(sp, val, 1);
- }
- if (val & 0x02) {
- hsp = sp->hs;
- exval = readreg(sp->hscx[0], HSCX_EXIR);
- if (exval == 0x40) {
- if (hsp->mode == 1)
- hscx_fill_fifo(hsp);
- else {
- /* Here we lost an TX interrupt, so
- * restart transmitting the whole frame.
- */
- if (hsp->tx_skb) {
- skb_push(hsp->tx_skb, hsp->count);
- hsp->tx_cnt += hsp->count;
- hsp->count = 0;
- }
- writehscxCMDR(sp->hscx[hsp->hscx], 0x01);
- if (sp->debug & L1_DEB_WARN) {
- sprintf(tmp, "HSCX A EXIR %x Lost TX", exval);
- debugl1(sp, tmp);
- }
- }
- } else if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX A EXIR %x", exval);
- debugl1(sp, tmp);
- }
- }
- if (val & 0x04) {
- exval = readreg(sp->hscx[0], HSCX_ISTA);
- if (sp->debug & L1_DEB_HSCX) {
- sprintf(tmp, "HSCX A interrupt %x", exval);
- debugl1(sp, tmp);
- }
- hscx_interrupt(sp, exval, 0);
- }
-}
+#include "hscx_irq.c"
static void
teles3_interrupt(int intno, void *dev_id, struct pt_regs *regs)
{
#define MAXCOUNT 20
- struct IsdnCardState *sp;
+ struct IsdnCardState *cs = dev_id;
u_char val, stat = 0;
int count = 0;
- sp = (struct IsdnCardState *) dev_id;
-
- if (!sp) {
+ if (!cs) {
printk(KERN_WARNING "Teles: Spurious interrupt!\n");
return;
}
- val = readreg(sp->hscx[1], HSCX_ISTA);
+ val = readreg(cs->hw.teles3.hscx[1], HSCX_ISTA);
Start_HSCX:
if (val) {
- hscx_int_main(sp, val);
+ hscx_int_main(cs, val);
stat |= 1;
}
- val = readreg(sp->isac, ISAC_ISTA);
+ val = readreg(cs->hw.teles3.isac, ISAC_ISTA);
Start_ISAC:
if (val) {
- isac_interrupt(sp, val);
+ isac_interrupt(cs, val);
stat |= 2;
}
count++;
- val = readreg(sp->hscx[1], HSCX_ISTA);
+ val = readreg(cs->hw.teles3.hscx[1], HSCX_ISTA);
if (val && count < MAXCOUNT) {
- if (sp->debug & L1_DEB_HSCX)
- debugl1(sp, "HSCX IntStat after IntRoutine");
+ if (cs->debug & L1_DEB_HSCX)
+ debugl1(cs, "HSCX IntStat after IntRoutine");
goto Start_HSCX;
}
- val = readreg(sp->isac, ISAC_ISTA);
+ val = readreg(cs->hw.teles3.isac, ISAC_ISTA);
if (val && count < MAXCOUNT) {
- if (sp->debug & L1_DEB_ISAC)
- debugl1(sp, "ISAC IntStat after IntRoutine");
+ if (cs->debug & L1_DEB_ISAC)
+ debugl1(cs, "ISAC IntStat after IntRoutine");
goto Start_ISAC;
}
if (count >= MAXCOUNT)
printk(KERN_WARNING "Teles3: more than %d loops in teles3_interrupt\n", count);
if (stat & 1) {
- writereg(sp->hscx[0], HSCX_MASK, 0xFF);
- writereg(sp->hscx[1], HSCX_MASK, 0xFF);
- writereg(sp->hscx[0], HSCX_MASK, 0x0);
- writereg(sp->hscx[1], HSCX_MASK, 0x0);
+ writereg(cs->hw.teles3.hscx[0], HSCX_MASK, 0xFF);
+ writereg(cs->hw.teles3.hscx[1], HSCX_MASK, 0xFF);
+ writereg(cs->hw.teles3.hscx[0], HSCX_MASK, 0x0);
+ writereg(cs->hw.teles3.hscx[1], HSCX_MASK, 0x0);
}
if (stat & 2) {
- writereg(sp->isac, ISAC_MASK, 0xFF);
- writereg(sp->isac, ISAC_MASK, 0x0);
+ writereg(cs->hw.teles3.isac, ISAC_MASK, 0xFF);
+ writereg(cs->hw.teles3.isac, ISAC_MASK, 0x0);
}
}
-
-static void
-initisac(struct IsdnCardState *sp)
-{
- unsigned int adr = sp->isac;
-
- /* 16.3 IOM 2 Mode */
- writereg(adr, ISAC_MASK, 0xff);
- writereg(adr, ISAC_ADF2, 0x80);
- writereg(adr, ISAC_SQXR, 0x2f);
- writereg(adr, ISAC_SPCR, 0x0);
- writereg(adr, ISAC_ADF1, 0x2);
- writereg(adr, ISAC_STCR, 0x70);
- writereg(adr, ISAC_MODE, 0xc9);
- writereg(adr, ISAC_TIMR, 0x0);
- writereg(adr, ISAC_ADF1, 0x0);
- writereg(adr, ISAC_CMDR, 0x41);
- writereg(adr, ISAC_CIX0, (1 << 2) | 3);
- writereg(adr, ISAC_MASK, 0xff);
- writereg(adr, ISAC_MASK, 0x0);
-}
-
-static void
-modehscx(struct HscxState *hs, int mode, int ichan)
-{
- struct IsdnCardState *sp = hs->sp;
- int hscx = hs->hscx;
-
- if (sp->debug & L1_DEB_HSCX) {
- char tmp[40];
- sprintf(tmp, "hscx %c mode %d ichan %d",
- 'A' + hscx, mode, ichan);
- debugl1(sp, tmp);
- }
- hs->mode = mode;
- writereg(sp->hscx[hscx], HSCX_CCR1, 0x85);
- writereg(sp->hscx[hscx], HSCX_XAD1, 0xFF);
- writereg(sp->hscx[hscx], HSCX_XAD2, 0xFF);
- writereg(sp->hscx[hscx], HSCX_RAH2, 0xFF);
- writereg(sp->hscx[hscx], HSCX_XBCH, 0x0);
- writereg(sp->hscx[hscx], HSCX_RLCR, 0x0);
-
- switch (mode) {
- case (0):
- writereg(sp->hscx[hscx], HSCX_CCR2, 0x30);
- writereg(sp->hscx[hscx], HSCX_TSAX, 0xff);
- writereg(sp->hscx[hscx], HSCX_TSAR, 0xff);
- writereg(sp->hscx[hscx], HSCX_XCCR, 7);
- writereg(sp->hscx[hscx], HSCX_RCCR, 7);
- writereg(sp->hscx[hscx], HSCX_MODE, 0x84);
- break;
- case (1):
- if (ichan == 0) {
- writereg(sp->hscx[hscx], HSCX_CCR2, 0x30);
- writereg(sp->hscx[hscx], HSCX_TSAX, 0x2f);
- writereg(sp->hscx[hscx], HSCX_TSAR, 0x2f);
- writereg(sp->hscx[hscx], HSCX_XCCR, 7);
- writereg(sp->hscx[hscx], HSCX_RCCR, 7);
- } else {
- writereg(sp->hscx[hscx], HSCX_CCR2, 0x30);
- writereg(sp->hscx[hscx], HSCX_TSAX, 0x3);
- writereg(sp->hscx[hscx], HSCX_TSAR, 0x3);
- writereg(sp->hscx[hscx], HSCX_XCCR, 7);
- writereg(sp->hscx[hscx], HSCX_RCCR, 7);
- }
- writereg(sp->hscx[hscx], HSCX_MODE, 0xe4);
- writereg(sp->hscx[hscx], HSCX_CMDR, 0x41);
- break;
- case (2):
- if (ichan == 0) {
- writereg(sp->hscx[hscx], HSCX_CCR2, 0x30);
- writereg(sp->hscx[hscx], HSCX_TSAX, 0x2f);
- writereg(sp->hscx[hscx], HSCX_TSAR, 0x2f);
- writereg(sp->hscx[hscx], HSCX_XCCR, 7);
- writereg(sp->hscx[hscx], HSCX_RCCR, 7);
- } else {
- writereg(sp->hscx[hscx], HSCX_CCR2, 0x30);
- writereg(sp->hscx[hscx], HSCX_TSAX, 0x3);
- writereg(sp->hscx[hscx], HSCX_TSAR, 0x3);
- writereg(sp->hscx[hscx], HSCX_XCCR, 7);
- writereg(sp->hscx[hscx], HSCX_RCCR, 7);
- }
- writereg(sp->hscx[hscx], HSCX_MODE, 0x8c);
- writereg(sp->hscx[hscx], HSCX_CMDR, 0x41);
- break;
- }
- writereg(sp->hscx[hscx], HSCX_ISTA, 0x00);
-}
-
inline static void
-release_ioregs(struct IsdnCard *card, int mask)
+release_ioregs(struct IsdnCardState *cs, int mask)
{
if (mask & 1)
- release_region(card->sp->isac, 32);
+ release_region(cs->hw.teles3.isac + 32, 32);
if (mask & 2)
- release_region(card->sp->hscx[0], 32);
+ release_region(cs->hw.teles3.hscx[0] + 32, 32);
if (mask & 4)
- release_region(card->sp->hscx[1], 32);
+ release_region(cs->hw.teles3.hscx[1] + 32, 32);
}
void
-release_io_teles3(struct IsdnCard *card)
+release_io_teles3(struct IsdnCardState *cs)
{
- if (card->sp->typ == ISDN_CTYPE_TELESPCMCIA)
- release_region(card->sp->hscx[0], 97);
+ if (cs->typ == ISDN_CTYPE_TELESPCMCIA)
+ release_region(cs->hw.teles3.cfg_reg, 97);
else {
- if (card->sp->cfg_reg)
- release_region(card->sp->cfg_reg, 8);
- release_ioregs(card, 0x7);
+ if (cs->hw.teles3.cfg_reg)
+ if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) {
+ release_region(cs->hw.teles3.cfg_reg, 1);
+ } else {
+ release_region(cs->hw.teles3.cfg_reg, 8);
+ }
+ release_ioregs(cs, 0x7);
}
}
-static void
-clear_pending_ints(struct IsdnCardState *sp)
+static int
+reset_teles3(struct IsdnCardState *cs)
{
- int val;
- char tmp[64];
-
- val = readreg(sp->hscx[1], HSCX_ISTA);
- sprintf(tmp, "HSCX B ISTA %x", val);
- debugl1(sp, tmp);
- if (val & 0x01) {
- val = readreg(sp->hscx[1], HSCX_EXIR);
- sprintf(tmp, "HSCX B EXIR %x", val);
- debugl1(sp, tmp);
- } else if (val & 0x02) {
- val = readreg(sp->hscx[0], HSCX_EXIR);
- sprintf(tmp, "HSCX A EXIR %x", val);
- debugl1(sp, tmp);
- }
- val = readreg(sp->hscx[0], HSCX_ISTA);
- sprintf(tmp, "HSCX A ISTA %x", val);
- debugl1(sp, tmp);
- val = readreg(sp->hscx[1], HSCX_STAR);
- sprintf(tmp, "HSCX B STAR %x", val);
- debugl1(sp, tmp);
- val = readreg(sp->hscx[0], HSCX_STAR);
- sprintf(tmp, "HSCX A STAR %x", val);
- debugl1(sp, tmp);
- val = readreg(sp->isac, ISAC_STAR);
- sprintf(tmp, "ISAC STAR %x", val);
- debugl1(sp, tmp);
- val = readreg(sp->isac, ISAC_MODE);
- sprintf(tmp, "ISAC MODE %x", val);
- debugl1(sp, tmp);
- val = readreg(sp->isac, ISAC_ADF2);
- sprintf(tmp, "ISAC ADF2 %x", val);
- debugl1(sp, tmp);
- val = readreg(sp->isac, ISAC_ISTA);
- sprintf(tmp, "ISAC ISTA %x", val);
- debugl1(sp, tmp);
- if (val & 0x01) {
- val = readreg(sp->isac, ISAC_EXIR);
- sprintf(tmp, "ISAC EXIR %x", val);
- debugl1(sp, tmp);
- } else if (val & 0x04) {
- val = readreg(sp->isac, ISAC_CIR0);
- sprintf(tmp, "ISAC CIR0 %x", val);
- debugl1(sp, tmp);
+ long flags;
+ u_char irqcfg;
+
+ if (cs->typ != ISDN_CTYPE_TELESPCMCIA) {
+ if ((cs->hw.teles3.cfg_reg) && (cs->typ != ISDN_CTYPE_COMPAQ_ISA)) {
+ switch (cs->irq) {
+ case 2:
+ case 9:
+ irqcfg = 0x00;
+ break;
+ case 3:
+ irqcfg = 0x02;
+ break;
+ case 4:
+ irqcfg = 0x04;
+ break;
+ case 5:
+ irqcfg = 0x06;
+ break;
+ case 10:
+ irqcfg = 0x08;
+ break;
+ case 11:
+ irqcfg = 0x0A;
+ break;
+ case 12:
+ irqcfg = 0x0C;
+ break;
+ case 15:
+ irqcfg = 0x0E;
+ break;
+ default:
+ return(1);
+ }
+ save_flags(flags);
+ byteout(cs->hw.teles3.cfg_reg + 4, irqcfg);
+ sti();
+ HZDELAY(HZ / 10 + 1);
+ byteout(cs->hw.teles3.cfg_reg + 4, irqcfg | 1);
+ HZDELAY(HZ / 10 + 1);
+ restore_flags(flags);
+ } else if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) {
+ save_flags(flags);
+ byteout(cs->hw.teles3.cfg_reg, 0xff);
+ HZDELAY(2);
+ byteout(cs->hw.teles3.cfg_reg, 0x00);
+ HZDELAY(2);
+ restore_flags(flags);
+ } else {
+ /* Reset off for 16.3 PnP , thanks to Georg Acher */
+ save_flags(flags);
+ byteout(cs->hw.teles3.isac + 0x3c, 0);
+ HZDELAY(2);
+ byteout(cs->hw.teles3.isac + 0x3c, 1);
+ HZDELAY(2);
+ restore_flags(flags);
+ }
}
- writereg(sp->isac, ISAC_MASK, 0);
- writereg(sp->isac, ISAC_CMDR, 0x41);
+ return(0);
}
-int
-initteles3(struct IsdnCardState *sp)
+static int
+Teles_card_msg(struct IsdnCardState *cs, int mt, void *arg)
{
- int ret;
- int loop = 0;
- char tmp[40];
-
- sp->counter = kstat_irqs(sp->irq);
- sprintf(tmp, "IRQ %d count %d", sp->irq, sp->counter);
- debugl1(sp, tmp);
- clear_pending_ints(sp);
- ret = get_irq(sp->cardnr, &teles3_interrupt);
- if (ret) {
- initisac(sp);
- sp->modehscx(sp->hs, 0, 0);
- writereg(sp->hscx[sp->hs->hscx], HSCX_CMDR, 0x01);
- sp->modehscx(sp->hs + 1, 0, 0);
- writereg(sp->hscx[(sp->hs + 1)->hscx], HSCX_CMDR, 0x01);
- while (loop++ < 10) {
- /* At least 1-3 irqs must happen
- * (one from HSCX A, one from HSCX B, 3rd from ISAC)
- */
- if (kstat_irqs(sp->irq) > sp->counter)
- break;
- current->state = TASK_INTERRUPTIBLE;
- current->timeout = jiffies + 1;
- schedule();
- }
- sprintf(tmp, "IRQ %d count %d loop %d", sp->irq,
- kstat_irqs(sp->irq), loop);
- debugl1(sp, tmp);
- if (kstat_irqs(sp->irq) <= sp->counter) {
- printk(KERN_WARNING
- "Teles3: IRQ(%d) getting no interrupts during init\n",
- sp->irq);
- free_irq(sp->irq, sp);
- return (0);
- }
- }
- return (ret);
+ switch (mt) {
+ case CARD_RESET:
+ reset_teles3(cs);
+ return(0);
+ case CARD_RELEASE:
+ release_io_teles3(cs);
+ return(0);
+ case CARD_SETIRQ:
+ return(request_irq(cs->irq, &teles3_interrupt,
+ I4L_IRQ_FLAG, "HiSax", cs));
+ case CARD_INIT:
+ clear_pending_isac_ints(cs);
+ clear_pending_hscx_ints(cs);
+ initisac(cs);
+ inithscx(cs);
+ return(0);
+ case CARD_TEST:
+ return(0);
+ }
+ return(0);
}
-int
-setup_teles3(struct IsdnCard *card)
+__initfunc(int
+setup_teles3(struct IsdnCard *card))
{
- u_char cfval = 0, val, verA, verB;
- struct IsdnCardState *sp = card->sp;
- long flags;
+ u_char val;
+ struct IsdnCardState *cs = card->cs;
char tmp[64];
strcpy(tmp, teles3_revision);
- printk(KERN_NOTICE "HiSax: Teles IO driver Rev. %s\n", HiSax_getrev(tmp));
- if ((sp->typ != ISDN_CTYPE_16_3) && (sp->typ != ISDN_CTYPE_PNP)
- && (sp->typ != ISDN_CTYPE_TELESPCMCIA))
+ printk(KERN_INFO "HiSax: Teles IO driver Rev. %s\n", HiSax_getrev(tmp));
+ if ((cs->typ != ISDN_CTYPE_16_3) && (cs->typ != ISDN_CTYPE_PNP)
+ && (cs->typ != ISDN_CTYPE_TELESPCMCIA) && (cs->typ != ISDN_CTYPE_COMPAQ_ISA))
return (0);
- if (sp->typ == ISDN_CTYPE_16_3) {
- sp->cfg_reg = card->para[1];
- switch (sp->cfg_reg) {
+ if (cs->typ == ISDN_CTYPE_16_3) {
+ cs->hw.teles3.cfg_reg = card->para[1];
+ switch (cs->hw.teles3.cfg_reg) {
case 0x180:
case 0x280:
case 0x380:
- sp->cfg_reg |= 0xc00;
+ cs->hw.teles3.cfg_reg |= 0xc00;
break;
}
- sp->isac = sp->cfg_reg - 0x400;
- sp->hscx[0] = sp->cfg_reg - 0xc00;
- sp->hscx[1] = sp->cfg_reg - 0x800;
- } else if (sp->typ == ISDN_CTYPE_TELESPCMCIA) {
- sp->cfg_reg = 0;
- sp->hscx[0] = card->para[1];
- sp->hscx[1] = card->para[1] + 0x20;
- sp->isac = card->para[1] + 0x40;
- } else { /* PNP */
- sp->cfg_reg = 0;
- sp->isac = card->para[1];
- sp->hscx[0] = card->para[2];
- sp->hscx[1] = card->para[2] + 0x20;
- }
- sp->irq = card->para[0];
- if (sp->typ == ISDN_CTYPE_TELESPCMCIA) {
- if (check_region((sp->hscx[0]), 97)) {
+ cs->hw.teles3.isac = cs->hw.teles3.cfg_reg - 0x420;
+ cs->hw.teles3.hscx[0] = cs->hw.teles3.cfg_reg - 0xc20;
+ cs->hw.teles3.hscx[1] = cs->hw.teles3.cfg_reg - 0x820;
+ } else if (cs->typ == ISDN_CTYPE_TELESPCMCIA) {
+ cs->hw.teles3.cfg_reg = card->para[1];
+ cs->hw.teles3.hscx[0] = card->para[1] - 0x20;
+ cs->hw.teles3.hscx[1] = card->para[1];
+ cs->hw.teles3.isac = card->para[1] + 0x20;
+ } else if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) {
+ cs->hw.teles3.cfg_reg = card->para[3];
+ cs->hw.teles3.isac = card->para[2] - 32;
+ cs->hw.teles3.hscx[0] = card->para[1] - 32;
+ cs->hw.teles3.hscx[1] = card->para[1];
+ } else { /* PNP */
+ cs->hw.teles3.cfg_reg = 0;
+ cs->hw.teles3.isac = card->para[1] - 32;
+ cs->hw.teles3.hscx[0] = card->para[2] - 32;
+ cs->hw.teles3.hscx[1] = card->para[2];
+ }
+ cs->irq = card->para[0];
+ cs->hw.teles3.isacfifo = cs->hw.teles3.isac + 0x3e;
+ cs->hw.teles3.hscxfifo[0] = cs->hw.teles3.hscx[0] + 0x3e;
+ cs->hw.teles3.hscxfifo[1] = cs->hw.teles3.hscx[1] + 0x3e;
+ if (cs->typ == ISDN_CTYPE_TELESPCMCIA) {
+ if (check_region((cs->hw.teles3.cfg_reg), 97)) {
printk(KERN_WARNING
"HiSax: %s ports %x-%x already in use\n",
- CardType[sp->typ],
- sp->hscx[0],
- sp->hscx[0] + 96);
+ CardType[cs->typ],
+ cs->hw.teles3.cfg_reg,
+ cs->hw.teles3.cfg_reg + 96);
return (0);
} else
- request_region(sp->hscx[0], 97, "HiSax Teles PCMCIA");
+ request_region(cs->hw.teles3.hscx[0], 97, "HiSax Teles PCMCIA");
} else {
- if (sp->cfg_reg) {
- if (check_region((sp->cfg_reg), 8)) {
- printk(KERN_WARNING
- "HiSax: %s config port %x-%x already in use\n",
- CardType[card->typ],
- sp->cfg_reg,
- sp->cfg_reg + 8);
- return (0);
+ if (cs->hw.teles3.cfg_reg) {
+ if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) {
+ if (check_region((cs->hw.teles3.cfg_reg), 1)) {
+ printk(KERN_WARNING
+ "HiSax: %s config port %x already in use\n",
+ CardType[card->typ],
+ cs->hw.teles3.cfg_reg);
+ return (0);
+ } else
+ request_region(cs->hw.teles3.cfg_reg, 1, "teles3 cfg");
} else {
- request_region(sp->cfg_reg, 8, "teles3 cfg");
+ if (check_region((cs->hw.teles3.cfg_reg), 8)) {
+ printk(KERN_WARNING
+ "HiSax: %s config port %x-%x already in use\n",
+ CardType[card->typ],
+ cs->hw.teles3.cfg_reg,
+ cs->hw.teles3.cfg_reg + 8);
+ return (0);
+ } else
+ request_region(cs->hw.teles3.cfg_reg, 8, "teles3 cfg");
}
}
- if (check_region((sp->isac), 32)) {
+ if (check_region((cs->hw.teles3.isac + 32), 32)) {
printk(KERN_WARNING
"HiSax: %s isac ports %x-%x already in use\n",
- CardType[sp->typ],
- sp->isac,
- sp->isac + 32);
- if (sp->cfg_reg) {
- release_region(sp->cfg_reg, 8);
- }
+ CardType[cs->typ],
+ cs->hw.teles3.isac + 32,
+ cs->hw.teles3.isac + 64);
+ if (cs->hw.teles3.cfg_reg)
+ if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) {
+ release_region(cs->hw.teles3.cfg_reg, 1);
+ } else {
+ release_region(cs->hw.teles3.cfg_reg, 8);
+ }
return (0);
- } else {
- request_region(sp->isac, 32, "HiSax isac");
- }
- if (check_region((sp->hscx[0]), 32)) {
+ } else
+ request_region(cs->hw.teles3.isac + 32, 32, "HiSax isac");
+ if (check_region((cs->hw.teles3.hscx[0] + 32), 32)) {
printk(KERN_WARNING
"HiSax: %s hscx A ports %x-%x already in use\n",
- CardType[sp->typ],
- sp->hscx[0],
- sp->hscx[0] + 32);
- if (sp->cfg_reg) {
- release_region(sp->cfg_reg, 8);
- }
- release_ioregs(card, 1);
+ CardType[cs->typ],
+ cs->hw.teles3.hscx[0] + 32,
+ cs->hw.teles3.hscx[0] + 64);
+ if (cs->hw.teles3.cfg_reg)
+ if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) {
+ release_region(cs->hw.teles3.cfg_reg, 1);
+ } else {
+ release_region(cs->hw.teles3.cfg_reg, 8);
+ }
+ release_ioregs(cs, 1);
return (0);
- } else {
- request_region(sp->hscx[0], 32, "HiSax hscx A");
- }
- if (check_region((sp->hscx[1]), 32)) {
+ } else
+ request_region(cs->hw.teles3.hscx[0] + 32, 32, "HiSax hscx A");
+ if (check_region((cs->hw.teles3.hscx[1] + 32), 32)) {
printk(KERN_WARNING
"HiSax: %s hscx B ports %x-%x already in use\n",
- CardType[sp->typ],
- sp->hscx[1],
- sp->hscx[1] + 32);
- if (sp->cfg_reg) {
- release_region(sp->cfg_reg, 8);
- }
- release_ioregs(card, 3);
+ CardType[cs->typ],
+ cs->hw.teles3.hscx[1] + 32,
+ cs->hw.teles3.hscx[1] + 64);
+ if (cs->hw.teles3.cfg_reg)
+ if (cs->typ == ISDN_CTYPE_COMPAQ_ISA) {
+ release_region(cs->hw.teles3.cfg_reg, 1);
+ } else {
+ release_region(cs->hw.teles3.cfg_reg, 8);
+ }
+ release_ioregs(cs, 3);
return (0);
- } else {
- request_region(sp->hscx[1], 32, "HiSax hscx B");
- }
- switch (sp->irq) {
- case 2:
- cfval = 0x00;
- break;
- case 3:
- cfval = 0x02;
- break;
- case 4:
- cfval = 0x04;
- break;
- case 5:
- cfval = 0x06;
- break;
- case 10:
- cfval = 0x08;
- break;
- case 11:
- cfval = 0x0A;
- break;
- case 12:
- cfval = 0x0C;
- break;
- case 15:
- cfval = 0x0E;
- break;
- default:
- cfval = 0x00;
- break;
- }
+ } else
+ request_region(cs->hw.teles3.hscx[1] + 32, 32, "HiSax hscx B");
}
- if (sp->cfg_reg) {
- if ((val = bytein(sp->cfg_reg + 0)) != 0x51) {
+ if ((cs->hw.teles3.cfg_reg) && (cs->typ != ISDN_CTYPE_COMPAQ_ISA)) {
+ if ((val = bytein(cs->hw.teles3.cfg_reg + 0)) != 0x51) {
printk(KERN_WARNING "Teles: 16.3 Byte at %x is %x\n",
- sp->cfg_reg + 0, val);
- release_io_teles3(card);
+ cs->hw.teles3.cfg_reg + 0, val);
+ release_io_teles3(cs);
return (0);
}
- if ((val = bytein(sp->cfg_reg + 1)) != 0x93) {
+ if ((val = bytein(cs->hw.teles3.cfg_reg + 1)) != 0x93) {
printk(KERN_WARNING "Teles: 16.3 Byte at %x is %x\n",
- sp->cfg_reg + 1, val);
- release_io_teles3(card);
+ cs->hw.teles3.cfg_reg + 1, val);
+ release_io_teles3(cs);
return (0);
}
- val = bytein(sp->cfg_reg + 2); /* 0x1e=without AB
- * 0x1f=with AB
- * 0x1c 16.3 ???
- * 0x46 16.3 with AB + Video (Teles-Vision)
- */
- if (val != 0x46 && val != 0x1c && val != 0x1e && val != 0x1f) {
+ val = bytein(cs->hw.teles3.cfg_reg + 2);/* 0x1e=without AB
+ * 0x1f=with AB
+ * 0x1c 16.3 ???
+ * 0x39 16.3 1.1
+ * 0x46 16.3 with AB + Video (Teles-Vision)
+ */
+ if (val != 0x46 && val != 0x39 && val != 0x1c && val != 0x1e && val != 0x1f) {
printk(KERN_WARNING "Teles: 16.3 Byte at %x is %x\n",
- sp->cfg_reg + 2, val);
- release_io_teles3(card);
+ cs->hw.teles3.cfg_reg + 2, val);
+ release_io_teles3(cs);
return (0);
}
- save_flags(flags);
- byteout(sp->cfg_reg + 4, cfval);
- sti();
- HZDELAY(HZ / 10 + 1);
- byteout(sp->cfg_reg + 4, cfval | 1);
- HZDELAY(HZ / 10 + 1);
- restore_flags(flags);
- } else {
- /* Reset off for 16.3 PnP , thanks to Georg Acher */
- save_flags(flags);
- byteout(sp->isac + 0x1c, 1);
- HZDELAY(2);
- restore_flags(flags);
}
- printk(KERN_NOTICE
- "HiSax: %s config irq:%d isac:%x cfg:%x\n",
- CardType[sp->typ], sp->irq,
- sp->isac, sp->cfg_reg);
- printk(KERN_NOTICE
- "HiSax: hscx A:%x hscx B:%x\n",
- sp->hscx[0], sp->hscx[1]);
- verA = readreg(sp->hscx[0], HSCX_VSTR) & 0xf;
- verB = readreg(sp->hscx[1], HSCX_VSTR) & 0xf;
- printk(KERN_INFO "Teles3: HSCX version A: %s B: %s\n",
- HscxVersion(verA), HscxVersion(verB));
- val = readreg(sp->isac, ISAC_RBCH);
- printk(KERN_INFO "Teles3: ISAC %s\n",
- ISACVersion(val));
- if ((verA == 0) | (verA == 0xf) | (verB == 0) | (verB == 0xf)) {
+ printk(KERN_INFO
+ "HiSax: %s config irq:%d isac:0x%X cfg:0x%X\n",
+ CardType[cs->typ], cs->irq,
+ cs->hw.teles3.isac + 32, cs->hw.teles3.cfg_reg);
+ printk(KERN_INFO
+ "HiSax: hscx A:0x%X hscx B:0x%X\n",
+ cs->hw.teles3.hscx[0] + 32, cs->hw.teles3.hscx[1] + 32);
+
+ if (reset_teles3(cs)) {
+ printk(KERN_WARNING "Teles3: wrong IRQ\n");
+ release_io_teles3(cs);
+ return (0);
+ }
+ cs->readisac = &ReadISAC;
+ cs->writeisac = &WriteISAC;
+ cs->readisacfifo = &ReadISACfifo;
+ cs->writeisacfifo = &WriteISACfifo;
+ cs->BC_Read_Reg = &ReadHSCX;
+ cs->BC_Write_Reg = &WriteHSCX;
+ cs->BC_Send_Data = &hscx_fill_fifo;
+ cs->cardmsg = &Teles_card_msg;
+ ISACVersion(cs, "Teles3:");
+ if (HscxVersion(cs, "Teles3:")) {
printk(KERN_WARNING
"Teles3: wrong HSCX versions check IO address\n");
- release_io_teles3(card);
+ release_io_teles3(cs);
return (0);
}
- sp->modehscx = &modehscx;
- sp->ph_command = &ph_command;
- sp->hscx_fill_fifo = &hscx_fill_fifo;
- sp->isac_fill_fifo = &isac_fill_fifo;
return (1);
}
diff --git a/drivers/isdn/hisax/teles3c.c b/drivers/isdn/hisax/teles3c.c
new file mode 100644
index 000000000..848c46be9
--- /dev/null
+++ b/drivers/isdn/hisax/teles3c.c
@@ -0,0 +1,199 @@
+/* $Id: teles3c.c,v 1.2 1998/02/02 13:27:07 keil Exp $
+
+ * teles3c.c low level stuff for teles 16.3c
+ *
+ * Author Karsten Keil (keil@temic-ech.spacenet.de)
+ *
+ *
+ * $Log: teles3c.c,v $
+ * Revision 1.2 1998/02/02 13:27:07 keil
+ * New
+ *
+ *
+ *
+ */
+
+#define __NO_VERSION__
+#include "hisax.h"
+#include "hfc_2bds0.h"
+#include "isdnl1.h"
+
+extern const char *CardType[];
+
+const char *teles163c_revision = "$Revision: 1.2 $";
+
+static void
+t163c_interrupt(int intno, void *dev_id, struct pt_regs *regs)
+{
+ struct IsdnCardState *cs = dev_id;
+ u_char val, stat;
+ char tmp[32];
+
+ if (!cs) {
+ printk(KERN_WARNING "teles3c: Spurious interrupt!\n");
+ return;
+ }
+ if ((HFCD_ANYINT | HFCD_BUSY_NBUSY) &
+ (stat = cs->BC_Read_Reg(cs, HFCD_DATA, HFCD_STAT))) {
+ val = cs->BC_Read_Reg(cs, HFCD_DATA, HFCD_INT_S1);
+ if (cs->debug & L1_DEB_ISAC) {
+ sprintf(tmp, "teles3c: stat(%02x) s1(%02x)", stat, val);
+ debugl1(cs, tmp);
+ }
+ hfc2bds0_interrupt(cs, val);
+ } else {
+ if (cs->debug & L1_DEB_ISAC) {
+ sprintf(tmp, "teles3c: irq_no_irq stat(%02x)", stat);
+ debugl1(cs, tmp);
+ }
+ }
+}
+
+static void
+t163c_Timer(struct IsdnCardState *cs)
+{
+ cs->hw.hfcD.timer.expires = jiffies + 75;
+ /* WD RESET */
+/* WriteReg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt | 0x80);
+ add_timer(&cs->hw.hfcD.timer);
+*/
+}
+
+void
+release_io_t163c(struct IsdnCardState *cs)
+{
+ release2bds0(cs);
+ del_timer(&cs->hw.hfcD.timer);
+ if (cs->hw.hfcD.addr)
+ release_region(cs->hw.hfcD.addr, 2);
+}
+
+static void
+reset_t163c(struct IsdnCardState *cs)
+{
+ long flags;
+
+ printk(KERN_INFO "teles3c: resetting card\n");
+ cs->hw.hfcD.cirm = HFCD_RESET | HFCD_MEM8K;
+ cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm); /* Reset On */
+ save_flags(flags);
+ sti();
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + 3;
+ schedule();
+ cs->hw.hfcD.cirm = HFCD_MEM8K;
+ cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm); /* Reset Off */
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + 1;
+ schedule();
+ cs->hw.hfcD.cirm |= HFCD_INTB;
+ cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CIRM, cs->hw.hfcD.cirm); /* INT B */
+ cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CLKDEL, 0x0e);
+ cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_TEST, HFCD_AUTO_AWAKE); /* S/T Auto awake */
+ cs->hw.hfcD.ctmt = HFCD_TIM25 | HFCD_AUTO_TIMER;
+ cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt);
+ cs->hw.hfcD.int_m2 = HFCD_IRQ_ENABLE;
+ cs->hw.hfcD.int_m1 = HFCD_INTS_B1TRANS | HFCD_INTS_B2TRANS |
+ HFCD_INTS_DTRANS | HFCD_INTS_B1REC | HFCD_INTS_B2REC |
+ HFCD_INTS_DREC | HFCD_INTS_L1STATE;
+ cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_INT_M1, cs->hw.hfcD.int_m1);
+ cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_INT_M2, cs->hw.hfcD.int_m2);
+ cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_STATES, HFCD_LOAD_STATE | 2); /* HFC ST 2 */
+ udelay(10);
+ cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_STATES, 2); /* HFC ST 2 */
+ cs->hw.hfcD.mst_m = 0;
+ cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_MST_MODE, HFCD_MASTER); /* HFC Master */
+ cs->hw.hfcD.sctrl = 0;
+ cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_SCTRL, cs->hw.hfcD.sctrl);
+ restore_flags(flags);
+}
+
+static int
+t163c_card_msg(struct IsdnCardState *cs, int mt, void *arg)
+{
+ long flags;
+ char tmp[32];
+
+ if (cs->debug & L1_DEB_ISAC) {
+
+ sprintf(tmp, "teles3c: card_msg %x", mt);
+ debugl1(cs, tmp);
+ }
+ switch (mt) {
+ case CARD_RESET:
+ reset_t163c(cs);
+ return(0);
+ case CARD_RELEASE:
+ release_io_t163c(cs);
+ return(0);
+ case CARD_SETIRQ:
+ cs->hw.hfcD.timer.expires = jiffies + 75;
+ add_timer(&cs->hw.hfcD.timer);
+ return(request_irq(cs->irq, &t163c_interrupt,
+ I4L_IRQ_FLAG, "HiSax", cs));
+ case CARD_INIT:
+ init2bds0(cs);
+ save_flags(flags);
+ sti();
+ current->state = TASK_INTERRUPTIBLE;
+ current->timeout = jiffies + (80*HZ)/1000;
+ schedule();
+ cs->hw.hfcD.ctmt |= HFCD_TIM800;
+ cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_CTMT, cs->hw.hfcD.ctmt);
+ cs->BC_Write_Reg(cs, HFCD_DATA, HFCD_MST_MODE, cs->hw.hfcD.mst_m);
+ restore_flags(flags);
+ return(0);
+ case CARD_TEST:
+ return(0);
+ }
+ return(0);
+}
+
+__initfunc(int
+setup_t163c(struct IsdnCard *card))
+{
+ struct IsdnCardState *cs = card->cs;
+ char tmp[64];
+
+ strcpy(tmp, teles163c_revision);
+ printk(KERN_INFO "HiSax: Teles 16.3c driver Rev. %s\n", HiSax_getrev(tmp));
+ if (cs->typ != ISDN_CTYPE_TELES3C)
+ return (0);
+ cs->debug = 0xff;
+ cs->hw.hfcD.addr = card->para[1] & 0xfffe;
+ cs->irq = card->para[0];
+ cs->hw.hfcD.cip = 0;
+ cs->hw.hfcD.int_s1 = 0;
+ cs->hw.hfcD.send = NULL;
+ cs->bcs[0].hw.hfc.send = NULL;
+ cs->bcs[1].hw.hfc.send = NULL;
+ cs->hw.hfcD.bfifosize = 1024 + 512;
+ cs->hw.hfcD.dfifosize = 512;
+ cs->ph_state = 0;
+ cs->hw.hfcD.fifo = 255;
+ if (check_region((cs->hw.hfcD.addr), 2)) {
+ printk(KERN_WARNING
+ "HiSax: %s config port %x-%x already in use\n",
+ CardType[card->typ],
+ cs->hw.hfcD.addr,
+ cs->hw.hfcD.addr + 2);
+ return (0);
+ } else {
+ request_region(cs->hw.hfcD.addr, 2, "teles3c isdn");
+ }
+ /* Teles 16.3c IO ADR is 0x200 | YY0U (YY Bit 15/14 address) */
+ outb(0x00, cs->hw.hfcD.addr);
+ outb(0x56, cs->hw.hfcD.addr | 1);
+ printk(KERN_INFO
+ "teles3c: defined at 0x%x IRQ %d HZ %d\n",
+ cs->hw.hfcD.addr,
+ cs->irq, HZ);
+
+ set_cs_func(cs);
+ cs->hw.hfcD.timer.function = (void *) t163c_Timer;
+ cs->hw.hfcD.timer.data = (long) cs;
+ init_timer(&cs->hw.hfcD.timer);
+ reset_t163c(cs);
+ cs->cardmsg = &t163c_card_msg;
+ return (1);
+}