Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
act2000.h
Go to the documentation of this file.
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 <[email protected]>
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 #include <linux/compiler.h>
19 
20 #define ACT2000_IOCTL_SETPORT 1
21 #define ACT2000_IOCTL_GETPORT 2
22 #define ACT2000_IOCTL_SETIRQ 3
23 #define ACT2000_IOCTL_GETIRQ 4
24 #define ACT2000_IOCTL_SETBUS 5
25 #define ACT2000_IOCTL_GETBUS 6
26 #define ACT2000_IOCTL_SETPROTO 7
27 #define ACT2000_IOCTL_GETPROTO 8
28 #define ACT2000_IOCTL_SETMSN 9
29 #define ACT2000_IOCTL_GETMSN 10
30 #define ACT2000_IOCTL_LOADBOOT 11
31 #define ACT2000_IOCTL_ADDCARD 12
32 
33 #define ACT2000_IOCTL_TEST 98
34 #define ACT2000_IOCTL_DEBUGVAR 99
35 
36 #define ACT2000_BUS_ISA 1
37 #define ACT2000_BUS_MCA 2
38 #define ACT2000_BUS_PCMCIA 3
39 
40 /* Struct for adding new cards */
41 typedef struct act2000_cdef {
42  int bus;
43  int port;
44  int irq;
45  char id[10];
46 } act2000_cdef;
47 
48 /* Struct for downloading firmware */
49 typedef struct act2000_ddef {
50  int length; /* Length of code */
51  char __user *buffer; /* Ptr. to code */
52 } act2000_ddef;
53 
54 typedef struct act2000_fwid {
55  char isdn[4];
56  char revlen[2];
57  char revision[504];
58 } act2000_fwid;
59 
60 #if defined(__KERNEL__) || defined(__DEBUGVAR__)
61 
62 #ifdef __KERNEL__
63 /* Kernel includes */
64 
65 #include <linux/sched.h>
66 #include <linux/string.h>
67 #include <linux/workqueue.h>
68 #include <linux/interrupt.h>
69 #include <linux/skbuff.h>
70 #include <linux/errno.h>
71 #include <linux/fs.h>
72 #include <linux/major.h>
73 #include <asm/io.h>
74 #include <linux/kernel.h>
75 #include <linux/signal.h>
76 #include <linux/slab.h>
77 #include <linux/mm.h>
78 #include <linux/mman.h>
79 #include <linux/ioport.h>
80 #include <linux/timer.h>
81 #include <linux/wait.h>
82 #include <linux/delay.h>
83 #include <linux/ctype.h>
84 #include <linux/isdnif.h>
85 
86 #endif /* __KERNEL__ */
87 
88 #define ACT2000_PORTLEN 8
89 
90 #define ACT2000_FLAGS_RUNNING 1 /* Cards driver activated */
91 #define ACT2000_FLAGS_PVALID 2 /* Cards port is valid */
92 #define ACT2000_FLAGS_IVALID 4 /* Cards irq is valid */
93 #define ACT2000_FLAGS_LOADED 8 /* Firmware loaded */
94 
95 #define ACT2000_BCH 2 /* # of channels per card */
96 
97 /* D-Channel states */
98 #define ACT2000_STATE_NULL 0
99 #define ACT2000_STATE_ICALL 1
100 #define ACT2000_STATE_OCALL 2
101 #define ACT2000_STATE_IWAIT 3
102 #define ACT2000_STATE_OWAIT 4
103 #define ACT2000_STATE_IBWAIT 5
104 #define ACT2000_STATE_OBWAIT 6
105 #define ACT2000_STATE_BWAIT 7
106 #define ACT2000_STATE_BHWAIT 8
107 #define ACT2000_STATE_BHWAIT2 9
108 #define ACT2000_STATE_DHWAIT 10
109 #define ACT2000_STATE_DHWAIT2 11
110 #define ACT2000_STATE_BSETUP 12
111 #define ACT2000_STATE_ACTIVE 13
112 
113 #define ACT2000_MAX_QUEUED 8000 /* 2 * maxbuff */
114 
115 #define ACT2000_LOCK_TX 0
116 #define ACT2000_LOCK_RX 1
117 
118 typedef struct act2000_chan {
119  unsigned short callref; /* Call Reference */
120  unsigned short fsm_state; /* Current D-Channel state */
121  unsigned short eazmask; /* EAZ-Mask for this Channel */
122  short queued; /* User-Data Bytes in TX queue */
123  unsigned short plci;
124  unsigned short ncci;
125  unsigned char l2prot; /* Layer 2 protocol */
126  unsigned char l3prot; /* Layer 3 protocol */
127 } act2000_chan;
128 
129 typedef struct msn_entry {
130  char eaz;
131  char msn[16];
132  struct msn_entry *next;
133 } msn_entry;
134 
135 typedef struct irq_data_isa {
136  __u8 *rcvptr;
137  __u16 rcvidx;
138  __u16 rcvlen;
139  struct sk_buff *rcvskb;
140  __u8 rcvignore;
141  __u8 rcvhdr[8];
142 } irq_data_isa;
143 
144 typedef union act2000_irq_data {
145  irq_data_isa isa;
146 } act2000_irq_data;
147 
148 /*
149  * Per card driver data
150  */
151 typedef struct act2000_card {
152  unsigned short port; /* Base-port-address */
153  unsigned short irq; /* Interrupt */
154  u_char ptype; /* Protocol type (1TR6 or Euro) */
155  u_char bus; /* Cardtype (ISA, MCA, PCMCIA) */
156  struct act2000_card *next; /* Pointer to next device struct */
157  spinlock_t lock; /* protect critical operations */
158  int myid; /* Driver-Nr. assigned by linklevel */
159  unsigned long flags; /* Statusflags */
160  unsigned long ilock; /* Semaphores for IRQ-Routines */
161  struct sk_buff_head rcvq; /* Receive-Message queue */
162  struct sk_buff_head sndq; /* Send-Message queue */
163  struct sk_buff_head ackq; /* Data-Ack-Message queue */
164  u_char *ack_msg; /* Ptr to User Data in User skb */
165  __u16 need_b3ack; /* Flag: Need ACK for current skb */
166  struct sk_buff *sbuf; /* skb which is currently sent */
167  struct timer_list ptimer; /* Poll timer */
168  struct work_struct snd_tq; /* Task struct for xmit bh */
169  struct work_struct rcv_tq; /* Task struct for rcv bh */
170  struct work_struct poll_tq; /* Task struct for polled rcv bh */
171  msn_entry *msn_list;
172  unsigned short msgnum; /* Message number for sending */
173  spinlock_t mnlock; /* lock for msgnum */
174  act2000_chan bch[ACT2000_BCH]; /* B-Channel status/control */
175  char status_buf[256]; /* Buffer for status messages */
176  char *status_buf_read;
177  char *status_buf_write;
178  char *status_buf_end;
179  act2000_irq_data idat; /* Data used for IRQ handler */
180  isdn_if interface; /* Interface to upper layer */
181  char regname[35]; /* Name used for request_region */
182 } act2000_card;
183 
184 static inline void act2000_schedule_tx(act2000_card *card)
185 {
186  schedule_work(&card->snd_tq);
187 }
188 
189 static inline void act2000_schedule_rx(act2000_card *card)
190 {
191  schedule_work(&card->rcv_tq);
192 }
193 
194 static inline void act2000_schedule_poll(act2000_card *card)
195 {
196  schedule_work(&card->poll_tq);
197 }
198 
199 extern char *act2000_find_eaz(act2000_card *, char);
200 
201 #endif /* defined(__KERNEL__) || defined(__DEBUGVAR__) */
202 #endif /* act2000_h */