1 /* $Id: act2000.h,v 1.8.6.3 2001/09/23 22:24:32 kai Exp $
3 * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000.
6 * Copyright by Fritz Elfert <fritz@isdn4linux.de>
8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference.
11 * Thanks to Friedemann Baitinger and IBM Germany
18 #define ACT2000_IOCTL_SETPORT 1
19 #define ACT2000_IOCTL_GETPORT 2
20 #define ACT2000_IOCTL_SETIRQ 3
21 #define ACT2000_IOCTL_GETIRQ 4
22 #define ACT2000_IOCTL_SETBUS 5
23 #define ACT2000_IOCTL_GETBUS 6
24 #define ACT2000_IOCTL_SETPROTO 7
25 #define ACT2000_IOCTL_GETPROTO 8
26 #define ACT2000_IOCTL_SETMSN 9
27 #define ACT2000_IOCTL_GETMSN 10
28 #define ACT2000_IOCTL_LOADBOOT 11
29 #define ACT2000_IOCTL_ADDCARD 12
31 #define ACT2000_IOCTL_TEST 98
32 #define ACT2000_IOCTL_DEBUGVAR 99
34 #define ACT2000_BUS_ISA 1
35 #define ACT2000_BUS_MCA 2
36 #define ACT2000_BUS_PCMCIA 3
38 /* Struct for adding new cards */
39 typedef struct act2000_cdef {
46 /* Struct for downloading firmware */
47 typedef struct act2000_ddef {
48 int length; /* Length of code */
49 char *buffer; /* Ptr. to code */
52 typedef struct act2000_fwid {
58 #if defined(__KERNEL__) || defined(__DEBUGVAR__)
63 #include <linux/sched.h>
64 #include <linux/string.h>
65 #include <linux/workqueue.h>
66 #include <linux/interrupt.h>
67 #include <linux/skbuff.h>
68 #include <linux/errno.h>
70 #include <linux/major.h>
72 #include <linux/kernel.h>
73 #include <linux/signal.h>
74 #include <linux/slab.h>
76 #include <linux/mman.h>
77 #include <linux/ioport.h>
78 #include <linux/timer.h>
79 #include <linux/wait.h>
80 #include <linux/delay.h>
81 #include <linux/ctype.h>
82 #include <linux/isdnif.h>
84 #endif /* __KERNEL__ */
86 #define ACT2000_PORTLEN 8
88 #define ACT2000_FLAGS_RUNNING 1 /* Cards driver activated */
89 #define ACT2000_FLAGS_PVALID 2 /* Cards port is valid */
90 #define ACT2000_FLAGS_IVALID 4 /* Cards irq is valid */
91 #define ACT2000_FLAGS_LOADED 8 /* Firmware loaded */
93 #define ACT2000_BCH 2 /* # of channels per card */
95 /* D-Channel states */
96 #define ACT2000_STATE_NULL 0
97 #define ACT2000_STATE_ICALL 1
98 #define ACT2000_STATE_OCALL 2
99 #define ACT2000_STATE_IWAIT 3
100 #define ACT2000_STATE_OWAIT 4
101 #define ACT2000_STATE_IBWAIT 5
102 #define ACT2000_STATE_OBWAIT 6
103 #define ACT2000_STATE_BWAIT 7
104 #define ACT2000_STATE_BHWAIT 8
105 #define ACT2000_STATE_BHWAIT2 9
106 #define ACT2000_STATE_DHWAIT 10
107 #define ACT2000_STATE_DHWAIT2 11
108 #define ACT2000_STATE_BSETUP 12
109 #define ACT2000_STATE_ACTIVE 13
111 #define ACT2000_MAX_QUEUED 8000 /* 2 * maxbuff */
113 #define ACT2000_LOCK_TX 0
114 #define ACT2000_LOCK_RX 1
116 typedef struct act2000_chan {
117 unsigned short callref; /* Call Reference */
118 unsigned short fsm_state; /* Current D-Channel state */
119 unsigned short eazmask; /* EAZ-Mask for this Channel */
120 short queued; /* User-Data Bytes in TX queue */
123 unsigned char l2prot; /* Layer 2 protocol */
124 unsigned char l3prot; /* Layer 3 protocol */
127 typedef struct msn_entry {
130 struct msn_entry * next;
133 typedef struct irq_data_isa {
137 struct sk_buff *rcvskb;
142 typedef union irq_data {
147 * Per card driver data
149 typedef struct act2000_card {
150 unsigned short port; /* Base-port-address */
151 unsigned short irq; /* Interrupt */
152 u_char ptype; /* Protocol type (1TR6 or Euro) */
153 u_char bus; /* Cardtype (ISA, MCA, PCMCIA) */
154 struct act2000_card *next; /* Pointer to next device struct */
155 spinlock_t lock; /* protect critical operations */
156 int myid; /* Driver-Nr. assigned by linklevel */
157 unsigned long flags; /* Statusflags */
158 unsigned long ilock; /* Semaphores for IRQ-Routines */
159 struct sk_buff_head rcvq; /* Receive-Message queue */
160 struct sk_buff_head sndq; /* Send-Message queue */
161 struct sk_buff_head ackq; /* Data-Ack-Message queue */
162 u_char *ack_msg; /* Ptr to User Data in User skb */
163 __u16 need_b3ack; /* Flag: Need ACK for current skb */
164 struct sk_buff *sbuf; /* skb which is currently sent */
165 struct timer_list ptimer; /* Poll timer */
166 struct work_struct snd_tq; /* Task struct for xmit bh */
167 struct work_struct rcv_tq; /* Task struct for rcv bh */
168 struct work_struct poll_tq; /* Task struct for polled rcv bh */
170 unsigned short msgnum; /* Message number for sending */
171 spinlock_t mnlock; /* lock for msgnum */
172 act2000_chan bch[ACT2000_BCH]; /* B-Channel status/control */
173 char status_buf[256]; /* Buffer for status messages */
174 char *status_buf_read;
175 char *status_buf_write;
176 char *status_buf_end;
177 irq_data idat; /* Data used for IRQ handler */
178 isdn_if interface; /* Interface to upper layer */
179 char regname[35]; /* Name used for request_region */
182 extern __inline__ void act2000_schedule_tx(act2000_card *card)
184 schedule_work(&card->snd_tq);
187 extern __inline__ void act2000_schedule_rx(act2000_card *card)
189 schedule_work(&card->rcv_tq);
192 extern __inline__ void act2000_schedule_poll(act2000_card *card)
194 schedule_work(&card->poll_tq);
197 extern char *act2000_find_eaz(act2000_card *, char);
199 #endif /* defined(__KERNEL__) || defined(__DEBUGVAR__) */
200 #endif /* act2000_h */