ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / drivers / isdn / act2000 / act2000.h
1 /* $Id: act2000.h,v 1.8.6.3 2001/09/23 22:24:32 kai Exp $
2  *
3  * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000.
4  *
5  * Author       Fritz Elfert
6  * Copyright    by Fritz Elfert      <fritz@isdn4linux.de>
7  * 
8  * This software may be used and distributed according to the terms
9  * of the GNU General Public License, incorporated herein by reference.
10  *
11  * Thanks to Friedemann Baitinger and IBM Germany
12  *
13  */
14
15 #ifndef act2000_h
16 #define act2000_h
17
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
30
31 #define ACT2000_IOCTL_TEST      98
32 #define ACT2000_IOCTL_DEBUGVAR  99
33
34 #define ACT2000_BUS_ISA          1
35 #define ACT2000_BUS_MCA          2
36 #define ACT2000_BUS_PCMCIA       3
37
38 /* Struct for adding new cards */
39 typedef struct act2000_cdef {
40         int bus;
41         int port;
42         int irq;
43         char id[10];
44 } act2000_cdef;
45
46 /* Struct for downloading firmware */
47 typedef struct act2000_ddef {
48         int length;             /* Length of code */
49         char *buffer;           /* Ptr. to code   */
50 } act2000_ddef;
51
52 typedef struct act2000_fwid {
53         char isdn[4];
54         char revlen[2];
55         char revision[504];
56 } act2000_fwid;
57
58 #if defined(__KERNEL__) || defined(__DEBUGVAR__)
59
60 #ifdef __KERNEL__
61 /* Kernel includes */
62
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>
69 #include <linux/fs.h>
70 #include <linux/major.h>
71 #include <asm/io.h>
72 #include <linux/kernel.h>
73 #include <linux/signal.h>
74 #include <linux/slab.h>
75 #include <linux/mm.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>
83
84 #endif                           /* __KERNEL__ */
85
86 #define ACT2000_PORTLEN        8
87
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        */
92
93 #define ACT2000_BCH            2 /* # of channels per card */
94
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
110
111 #define ACT2000_MAX_QUEUED  8000 /* 2 * maxbuff */
112
113 #define ACT2000_LOCK_TX 0
114 #define ACT2000_LOCK_RX 1
115
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 */
121         unsigned short plci;
122         unsigned short ncci;
123         unsigned char  l2prot;           /* Layer 2 protocol            */
124         unsigned char  l3prot;           /* Layer 3 protocol            */
125 } act2000_chan;
126
127 typedef struct msn_entry {
128         char eaz;
129         char msn[16];
130         struct msn_entry * next;
131 } msn_entry;
132
133 typedef struct irq_data_isa {
134         __u8           *rcvptr;
135         __u16           rcvidx;
136         __u16           rcvlen;
137         struct sk_buff *rcvskb;
138         __u8            rcvignore;
139         __u8            rcvhdr[8];
140 } irq_data_isa;
141
142 typedef union irq_data {
143         irq_data_isa isa;
144 } irq_data;
145
146 /*
147  * Per card driver data
148  */
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    */
169         msn_entry *msn_list;
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     */
180 } act2000_card;
181
182 extern __inline__ void act2000_schedule_tx(act2000_card *card)
183 {
184         schedule_work(&card->snd_tq);
185 }
186
187 extern __inline__ void act2000_schedule_rx(act2000_card *card)
188 {
189         schedule_work(&card->rcv_tq);
190 }
191
192 extern __inline__ void act2000_schedule_poll(act2000_card *card)
193 {
194         schedule_work(&card->poll_tq);
195 }
196
197 extern char *act2000_find_eaz(act2000_card *, char);
198
199 #endif                          /* defined(__KERNEL__) || defined(__DEBUGVAR__) */
200 #endif                          /* act2000_h */