diff options
Diffstat (limited to 'drivers/isdn/gigaset/gigaset.h')
-rw-r--r-- | drivers/isdn/gigaset/gigaset.h | 600 |
1 files changed, 284 insertions, 316 deletions
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h index 729edcdb6dac..9d21ba8757b0 100644 --- a/drivers/isdn/gigaset/gigaset.h +++ b/drivers/isdn/gigaset/gigaset.h | |||
@@ -1,11 +1,16 @@ | |||
1 | /* Siemens Gigaset 307x driver | 1 | /* |
2 | * Siemens Gigaset 307x driver | ||
2 | * Common header file for all connection variants | 3 | * Common header file for all connection variants |
3 | * | 4 | * |
4 | * Written by Stefan Eilers <Eilers.Stefan@epost.de> | 5 | * Written by Stefan Eilers |
5 | * and Hansjoerg Lipp <hjlipp@web.de> | 6 | * and Hansjoerg Lipp <hjlipp@web.de> |
6 | * | 7 | * |
7 | * Version: $Id: gigaset.h,v 1.97.4.26 2006/02/04 18:28:16 hjlipp Exp $ | 8 | * ===================================================================== |
8 | * =========================================================================== | 9 | * This program is free software; you can redistribute it and/or |
10 | * modify it under the terms of the GNU General Public License as | ||
11 | * published by the Free Software Foundation; either version 2 of | ||
12 | * the License, or (at your option) any later version. | ||
13 | * ===================================================================== | ||
9 | */ | 14 | */ |
10 | 15 | ||
11 | #ifndef GIGASET_H | 16 | #ifndef GIGASET_H |
@@ -15,7 +20,6 @@ | |||
15 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
16 | #include <linux/compiler.h> | 21 | #include <linux/compiler.h> |
17 | #include <linux/types.h> | 22 | #include <linux/types.h> |
18 | #include <asm/atomic.h> | ||
19 | #include <linux/spinlock.h> | 23 | #include <linux/spinlock.h> |
20 | #include <linux/isdnif.h> | 24 | #include <linux/isdnif.h> |
21 | #include <linux/usb.h> | 25 | #include <linux/usb.h> |
@@ -27,21 +31,22 @@ | |||
27 | #include <linux/tty.h> | 31 | #include <linux/tty.h> |
28 | #include <linux/tty_driver.h> | 32 | #include <linux/tty_driver.h> |
29 | #include <linux/list.h> | 33 | #include <linux/list.h> |
34 | #include <asm/atomic.h> | ||
30 | 35 | ||
31 | #define GIG_VERSION {0,5,0,0} | 36 | #define GIG_VERSION {0,5,0,0} |
32 | #define GIG_COMPAT {0,4,0,0} | 37 | #define GIG_COMPAT {0,4,0,0} |
33 | 38 | ||
34 | #define MAX_REC_PARAMS 10 /* Max. number of params in response string */ | 39 | #define MAX_REC_PARAMS 10 /* Max. number of params in response string */ |
35 | #define MAX_RESP_SIZE 512 /* Max. size of a response string */ | 40 | #define MAX_RESP_SIZE 512 /* Max. size of a response string */ |
36 | #define HW_HDR_LEN 2 /* Header size used to store ack info */ | 41 | #define HW_HDR_LEN 2 /* Header size used to store ack info */ |
37 | 42 | ||
38 | #define MAX_EVENTS 64 /* size of event queue */ | 43 | #define MAX_EVENTS 64 /* size of event queue */ |
39 | 44 | ||
40 | #define RBUFSIZE 8192 | 45 | #define RBUFSIZE 8192 |
41 | #define SBUFSIZE 4096 /* sk_buff payload size */ | 46 | #define SBUFSIZE 4096 /* sk_buff payload size */ |
42 | 47 | ||
43 | #define MAX_BUF_SIZE (SBUFSIZE - 2) /* Max. size of a data packet from LL */ | 48 | #define TRANSBUFSIZE 768 /* bytes per skb for transparent receive */ |
44 | #define TRANSBUFSIZE 768 /* bytes per skb for transparent receive */ | 49 | #define MAX_BUF_SIZE (SBUFSIZE - 2) /* Max. size of a data packet from LL */ |
45 | 50 | ||
46 | /* compile time options */ | 51 | /* compile time options */ |
47 | #define GIG_MAJOR 0 | 52 | #define GIG_MAJOR 0 |
@@ -50,10 +55,7 @@ | |||
50 | #define GIG_RETRYCID | 55 | #define GIG_RETRYCID |
51 | #define GIG_X75 | 56 | #define GIG_X75 |
52 | 57 | ||
53 | #define MAX_TIMER_INDEX 1000 | 58 | #define GIG_TICK 100 /* in milliseconds */ |
54 | #define MAX_SEQ_INDEX 1000 | ||
55 | |||
56 | #define GIG_TICK (HZ / 10) | ||
57 | 59 | ||
58 | /* timeout values (unit: 1 sec) */ | 60 | /* timeout values (unit: 1 sec) */ |
59 | #define INIT_TIMEOUT 1 | 61 | #define INIT_TIMEOUT 1 |
@@ -67,74 +69,89 @@ | |||
67 | 69 | ||
68 | #define MAXACT 3 | 70 | #define MAXACT 3 |
69 | 71 | ||
70 | #define IFNULL(a) if (unlikely(!(a))) | ||
71 | #define IFNULLRET(a) if (unlikely(!(a))) {err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); return; } | ||
72 | #define IFNULLRETVAL(a,b) if (unlikely(!(a))) {err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); return (b); } | ||
73 | #define IFNULLCONT(a) if (unlikely(!(a))) {err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); continue; } | ||
74 | #define IFNULLGOTO(a,b) if (unlikely(!(a))) {err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); goto b; } | ||
75 | |||
76 | extern int gigaset_debuglevel; /* "needs" cast to (enum debuglevel) */ | 72 | extern int gigaset_debuglevel; /* "needs" cast to (enum debuglevel) */ |
77 | 73 | ||
78 | /* any combination of these can be given with the 'debug=' parameter to insmod, e.g. | 74 | /* any combination of these can be given with the 'debug=' parameter to insmod, |
79 | * 'insmod usb_gigaset.o debug=0x2c' will set DEBUG_OPEN, DEBUG_CMD and DEBUG_INTR. */ | 75 | * e.g. 'insmod usb_gigaset.o debug=0x2c' will set DEBUG_OPEN, DEBUG_CMD and |
76 | * DEBUG_INTR. | ||
77 | */ | ||
80 | enum debuglevel { /* up to 24 bits (atomic_t) */ | 78 | enum debuglevel { /* up to 24 bits (atomic_t) */ |
81 | DEBUG_REG = 0x0002, /* serial port I/O register operations */ | 79 | DEBUG_REG = 0x0002, /* serial port I/O register operations */ |
82 | DEBUG_OPEN = 0x0004, /* open/close serial port */ | 80 | DEBUG_OPEN = 0x0004, /* open/close serial port */ |
83 | DEBUG_INTR = 0x0008, /* interrupt processing */ | 81 | DEBUG_INTR = 0x0008, /* interrupt processing */ |
84 | DEBUG_INTR_DUMP = 0x0010, /* Activating hexdump debug output on interrupt | 82 | DEBUG_INTR_DUMP = 0x0010, /* Activating hexdump debug output on |
85 | requests, not available as run-time option */ | 83 | interrupt requests, not available as |
84 | run-time option */ | ||
86 | DEBUG_CMD = 0x00020, /* sent/received LL commands */ | 85 | DEBUG_CMD = 0x00020, /* sent/received LL commands */ |
87 | DEBUG_STREAM = 0x00040, /* application data stream I/O events */ | 86 | DEBUG_STREAM = 0x00040, /* application data stream I/O events */ |
88 | DEBUG_STREAM_DUMP = 0x00080, /* application data stream content */ | 87 | DEBUG_STREAM_DUMP = 0x00080, /* application data stream content */ |
89 | DEBUG_LLDATA = 0x00100, /* sent/received LL data */ | 88 | DEBUG_LLDATA = 0x00100, /* sent/received LL data */ |
90 | DEBUG_INTR_0 = 0x00200, /* serial port output interrupt processing */ | 89 | DEBUG_INTR_0 = 0x00200, /* serial port interrupt processing */ |
91 | DEBUG_DRIVER = 0x00400, /* driver structure */ | 90 | DEBUG_DRIVER = 0x00400, /* driver structure */ |
92 | DEBUG_HDLC = 0x00800, /* M10x HDLC processing */ | 91 | DEBUG_HDLC = 0x00800, /* M10x HDLC processing */ |
93 | DEBUG_WRITE = 0x01000, /* M105 data write */ | 92 | DEBUG_WRITE = 0x01000, /* M105 data write */ |
94 | DEBUG_TRANSCMD = 0x02000, /*AT-COMMANDS+RESPONSES*/ | 93 | DEBUG_TRANSCMD = 0x02000, /* AT-COMMANDS+RESPONSES */ |
95 | DEBUG_MCMD = 0x04000, /*COMMANDS THAT ARE SENT VERY OFTEN*/ | 94 | DEBUG_MCMD = 0x04000, /* COMMANDS THAT ARE SENT VERY OFTEN */ |
96 | DEBUG_INIT = 0x08000, /* (de)allocation+initialization of data structures */ | 95 | DEBUG_INIT = 0x08000, /* (de)allocation+initialization of data |
96 | structures */ | ||
97 | DEBUG_LOCK = 0x10000, /* semaphore operations */ | 97 | DEBUG_LOCK = 0x10000, /* semaphore operations */ |
98 | DEBUG_OUTPUT = 0x20000, /* output to device */ | 98 | DEBUG_OUTPUT = 0x20000, /* output to device */ |
99 | DEBUG_ISO = 0x40000, /* isochronous transfers */ | 99 | DEBUG_ISO = 0x40000, /* isochronous transfers */ |
100 | DEBUG_IF = 0x80000, /* character device operations */ | 100 | DEBUG_IF = 0x80000, /* character device operations */ |
101 | DEBUG_USBREQ = 0x100000, /* USB communication (except payload data) */ | 101 | DEBUG_USBREQ = 0x100000, /* USB communication (except payload |
102 | DEBUG_LOCKCMD = 0x200000, /* AT commands and responses when MS_LOCKED */ | 102 | data) */ |
103 | DEBUG_LOCKCMD = 0x200000, /* AT commands and responses when | ||
104 | MS_LOCKED */ | ||
103 | 105 | ||
104 | DEBUG_ANY = 0x3fffff, /* print message if any of the others is activated */ | 106 | DEBUG_ANY = 0x3fffff, /* print message if any of the others is |
107 | activated */ | ||
105 | }; | 108 | }; |
106 | 109 | ||
107 | #ifdef CONFIG_GIGASET_DEBUG | 110 | /* missing from linux/device.h ... */ |
108 | #define DEBUG_DEFAULT (DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ) | 111 | #ifndef dev_notice |
109 | //#define DEBUG_DEFAULT (DEBUG_LOCK | DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUF_IF | DEBUG_DRIVER | DEBUG_OUTPUT | DEBUG_INTR) | 112 | #define dev_notice(dev, format, arg...) \ |
110 | #else | 113 | dev_printk(KERN_NOTICE , dev , format , ## arg) |
111 | #define DEBUG_DEFAULT 0 | ||
112 | #endif | 114 | #endif |
113 | 115 | ||
114 | /* redefine syslog macros to prepend module name instead of entire source path */ | 116 | /* Kernel message macros for situations where dev_printk and friends cannot be |
115 | /* The space before the comma in ", ##" is needed by gcc 2.95 */ | 117 | * used for lack of reliable access to a device structure. |
118 | * linux/usb.h already contains these but in an obsolete form which clutters | ||
119 | * the log needlessly, and according to the USB maintainer those should be | ||
120 | * removed rather than fixed anyway. | ||
121 | */ | ||
122 | #undef err | ||
116 | #undef info | 123 | #undef info |
117 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg) | ||
118 | |||
119 | #undef notice | ||
120 | #define notice(format, arg...) printk(KERN_NOTICE "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg) | ||
121 | |||
122 | #undef warn | 124 | #undef warn |
123 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg) | 125 | #undef notice |
124 | 126 | ||
125 | #undef err | 127 | #define err(format, arg...) printk(KERN_ERR KBUILD_MODNAME ": " \ |
126 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg) | 128 | format "\n" , ## arg) |
129 | #define info(format, arg...) printk(KERN_INFO KBUILD_MODNAME ": " \ | ||
130 | format "\n" , ## arg) | ||
131 | #define warn(format, arg...) printk(KERN_WARNING KBUILD_MODNAME ": " \ | ||
132 | format "\n" , ## arg) | ||
133 | #define notice(format, arg...) printk(KERN_NOTICE KBUILD_MODNAME ": " \ | ||
134 | format "\n" , ## arg) | ||
127 | 135 | ||
128 | #undef dbg | ||
129 | #ifdef CONFIG_GIGASET_DEBUG | 136 | #ifdef CONFIG_GIGASET_DEBUG |
130 | #define dbg(level, format, arg...) do { if (unlikely(((enum debuglevel)gigaset_debuglevel) & (level))) \ | 137 | |
131 | printk(KERN_DEBUG "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg); } while (0) | 138 | #define gig_dbg(level, format, arg...) \ |
139 | do { \ | ||
140 | if (unlikely(((enum debuglevel)gigaset_debuglevel) & (level))) \ | ||
141 | printk(KERN_DEBUG KBUILD_MODNAME ": " format "\n", \ | ||
142 | ## arg); \ | ||
143 | } while (0) | ||
144 | #define DEBUG_DEFAULT (DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ) | ||
145 | |||
132 | #else | 146 | #else |
133 | #define dbg(level, format, arg...) do {} while (0) | 147 | |
148 | #define gig_dbg(level, format, arg...) do {} while (0) | ||
149 | #define DEBUG_DEFAULT 0 | ||
150 | |||
134 | #endif | 151 | #endif |
135 | 152 | ||
136 | void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, | 153 | void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, |
137 | size_t len, const unsigned char *buf, int from_user); | 154 | size_t len, const unsigned char *buf); |
138 | 155 | ||
139 | /* connection state */ | 156 | /* connection state */ |
140 | #define ZSAU_NONE 0 | 157 | #define ZSAU_NONE 0 |
@@ -148,13 +165,14 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, | |||
148 | #define ZSAU_UNKNOWN -1 | 165 | #define ZSAU_UNKNOWN -1 |
149 | 166 | ||
150 | /* USB control transfer requests */ | 167 | /* USB control transfer requests */ |
151 | #define OUT_VENDOR_REQ (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT) | 168 | #define OUT_VENDOR_REQ (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT) |
152 | #define IN_VENDOR_REQ (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT) | 169 | #define IN_VENDOR_REQ (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT) |
153 | 170 | ||
154 | /* int-in-events 3070 */ | 171 | /* int-in-events 3070 */ |
155 | #define HD_B1_FLOW_CONTROL 0x80 | 172 | #define HD_B1_FLOW_CONTROL 0x80 |
156 | #define HD_B2_FLOW_CONTROL 0x81 | 173 | #define HD_B2_FLOW_CONTROL 0x81 |
157 | #define HD_RECEIVEATDATA_ACK (0x35) // 3070 // att: HD_RECEIVE>>AT<<DATA_ACK | 174 | #define HD_RECEIVEATDATA_ACK (0x35) // 3070 |
175 | // att: HD_RECEIVE>>AT<<DATA_ACK | ||
158 | #define HD_READY_SEND_ATDATA (0x36) // 3070 | 176 | #define HD_READY_SEND_ATDATA (0x36) // 3070 |
159 | #define HD_OPEN_ATCHANNEL_ACK (0x37) // 3070 | 177 | #define HD_OPEN_ATCHANNEL_ACK (0x37) // 3070 |
160 | #define HD_CLOSE_ATCHANNEL_ACK (0x38) // 3070 | 178 | #define HD_CLOSE_ATCHANNEL_ACK (0x38) // 3070 |
@@ -181,17 +199,18 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, | |||
181 | #define HD_CLOSE_ATCHANNEL (0x29) // 3070 | 199 | #define HD_CLOSE_ATCHANNEL (0x29) // 3070 |
182 | 200 | ||
183 | /* USB frames for isochronous transfer */ | 201 | /* USB frames for isochronous transfer */ |
184 | #define BAS_FRAMETIME 1 /* number of milliseconds between frames */ | 202 | #define BAS_FRAMETIME 1 /* number of milliseconds between frames */ |
185 | #define BAS_NUMFRAMES 8 /* number of frames per URB */ | 203 | #define BAS_NUMFRAMES 8 /* number of frames per URB */ |
186 | #define BAS_MAXFRAME 16 /* allocated bytes per frame */ | 204 | #define BAS_MAXFRAME 16 /* allocated bytes per frame */ |
187 | #define BAS_NORMFRAME 8 /* send size without flow control */ | 205 | #define BAS_NORMFRAME 8 /* send size without flow control */ |
188 | #define BAS_HIGHFRAME 10 /* " " with positive flow control */ | 206 | #define BAS_HIGHFRAME 10 /* " " with positive flow control */ |
189 | #define BAS_LOWFRAME 5 /* " " with negative flow control */ | 207 | #define BAS_LOWFRAME 5 /* " " with negative flow control */ |
190 | #define BAS_CORRFRAMES 4 /* flow control multiplicator */ | 208 | #define BAS_CORRFRAMES 4 /* flow control multiplicator */ |
191 | 209 | ||
192 | #define BAS_INBUFSIZE (BAS_MAXFRAME * BAS_NUMFRAMES) /* size of isochronous input buffer per URB */ | 210 | #define BAS_INBUFSIZE (BAS_MAXFRAME * BAS_NUMFRAMES) |
193 | #define BAS_OUTBUFSIZE 4096 /* size of common isochronous output buffer */ | 211 | /* size of isoc in buf per URB */ |
194 | #define BAS_OUTBUFPAD BAS_MAXFRAME /* size of pad area for isochronous output buffer */ | 212 | #define BAS_OUTBUFSIZE 4096 /* size of common isoc out buffer */ |
213 | #define BAS_OUTBUFPAD BAS_MAXFRAME /* size of pad area for isoc out buf */ | ||
195 | 214 | ||
196 | #define BAS_INURBS 3 | 215 | #define BAS_INURBS 3 |
197 | #define BAS_OUTURBS 3 | 216 | #define BAS_OUTURBS 3 |
@@ -207,40 +226,40 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, | |||
207 | #define AT_NUM 7 | 226 | #define AT_NUM 7 |
208 | 227 | ||
209 | /* variables in struct at_state_t */ | 228 | /* variables in struct at_state_t */ |
210 | #define VAR_ZSAU 0 | 229 | #define VAR_ZSAU 0 |
211 | #define VAR_ZDLE 1 | 230 | #define VAR_ZDLE 1 |
212 | #define VAR_ZVLS 2 | 231 | #define VAR_ZVLS 2 |
213 | #define VAR_ZCTP 3 | 232 | #define VAR_ZCTP 3 |
214 | #define VAR_NUM 4 | 233 | #define VAR_NUM 4 |
215 | 234 | ||
216 | #define STR_NMBR 0 | 235 | #define STR_NMBR 0 |
217 | #define STR_ZCPN 1 | 236 | #define STR_ZCPN 1 |
218 | #define STR_ZCON 2 | 237 | #define STR_ZCON 2 |
219 | #define STR_ZBC 3 | 238 | #define STR_ZBC 3 |
220 | #define STR_ZHLC 4 | 239 | #define STR_ZHLC 4 |
221 | #define STR_NUM 5 | 240 | #define STR_NUM 5 |
222 | 241 | ||
223 | #define EV_TIMEOUT -105 | 242 | #define EV_TIMEOUT -105 |
224 | #define EV_IF_VER -106 | 243 | #define EV_IF_VER -106 |
225 | #define EV_PROC_CIDMODE -107 | 244 | #define EV_PROC_CIDMODE -107 |
226 | #define EV_SHUTDOWN -108 | 245 | #define EV_SHUTDOWN -108 |
227 | #define EV_START -110 | 246 | #define EV_START -110 |
228 | #define EV_STOP -111 | 247 | #define EV_STOP -111 |
229 | #define EV_IF_LOCK -112 | 248 | #define EV_IF_LOCK -112 |
230 | #define EV_PROTO_L2 -113 | 249 | #define EV_PROTO_L2 -113 |
231 | #define EV_ACCEPT -114 | 250 | #define EV_ACCEPT -114 |
232 | #define EV_DIAL -115 | 251 | #define EV_DIAL -115 |
233 | #define EV_HUP -116 | 252 | #define EV_HUP -116 |
234 | #define EV_BC_OPEN -117 | 253 | #define EV_BC_OPEN -117 |
235 | #define EV_BC_CLOSED -118 | 254 | #define EV_BC_CLOSED -118 |
236 | 255 | ||
237 | /* input state */ | 256 | /* input state */ |
238 | #define INS_command 0x0001 | 257 | #define INS_command 0x0001 |
239 | #define INS_DLE_char 0x0002 | 258 | #define INS_DLE_char 0x0002 |
240 | #define INS_byte_stuff 0x0004 | 259 | #define INS_byte_stuff 0x0004 |
241 | #define INS_have_data 0x0008 | 260 | #define INS_have_data 0x0008 |
242 | #define INS_skip_frame 0x0010 | 261 | #define INS_skip_frame 0x0010 |
243 | #define INS_DLE_command 0x0020 | 262 | #define INS_DLE_command 0x0020 |
244 | #define INS_flag_hunt 0x0040 | 263 | #define INS_flag_hunt 0x0040 |
245 | 264 | ||
246 | /* channel state */ | 265 | /* channel state */ |
@@ -248,27 +267,27 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg, | |||
248 | #define CHS_B_UP 0x02 | 267 | #define CHS_B_UP 0x02 |
249 | #define CHS_NOTIFY_LL 0x04 | 268 | #define CHS_NOTIFY_LL 0x04 |
250 | 269 | ||
251 | #define ICALL_REJECT 0 | 270 | #define ICALL_REJECT 0 |
252 | #define ICALL_ACCEPT 1 | 271 | #define ICALL_ACCEPT 1 |
253 | #define ICALL_IGNORE 2 | 272 | #define ICALL_IGNORE 2 |
254 | 273 | ||
255 | /* device state */ | 274 | /* device state */ |
256 | #define MS_UNINITIALIZED 0 | 275 | #define MS_UNINITIALIZED 0 |
257 | #define MS_INIT 1 | 276 | #define MS_INIT 1 |
258 | #define MS_LOCKED 2 | 277 | #define MS_LOCKED 2 |
259 | #define MS_SHUTDOWN 3 | 278 | #define MS_SHUTDOWN 3 |
260 | #define MS_RECOVER 4 | 279 | #define MS_RECOVER 4 |
261 | #define MS_READY 5 | 280 | #define MS_READY 5 |
262 | 281 | ||
263 | /* mode */ | 282 | /* mode */ |
264 | #define M_UNKNOWN 0 | 283 | #define M_UNKNOWN 0 |
265 | #define M_CONFIG 1 | 284 | #define M_CONFIG 1 |
266 | #define M_UNIMODEM 2 | 285 | #define M_UNIMODEM 2 |
267 | #define M_CID 3 | 286 | #define M_CID 3 |
268 | 287 | ||
269 | /* start mode */ | 288 | /* start mode */ |
270 | #define SM_LOCKED 0 | 289 | #define SM_LOCKED 0 |
271 | #define SM_ISDN 1 /* default */ | 290 | #define SM_ISDN 1 /* default */ |
272 | 291 | ||
273 | struct gigaset_ops; | 292 | struct gigaset_ops; |
274 | struct gigaset_driver; | 293 | struct gigaset_driver; |
@@ -283,27 +302,26 @@ struct ser_bc_state; | |||
283 | struct bas_bc_state; | 302 | struct bas_bc_state; |
284 | 303 | ||
285 | struct reply_t { | 304 | struct reply_t { |
286 | int resp_code; /* RSP_XXXX */ | 305 | int resp_code; /* RSP_XXXX */ |
287 | int min_ConState; /* <0 => ignore */ | 306 | int min_ConState; /* <0 => ignore */ |
288 | int max_ConState; /* <0 => ignore */ | 307 | int max_ConState; /* <0 => ignore */ |
289 | int parameter; /* e.g. ZSAU_XXXX <0: ignore*/ | 308 | int parameter; /* e.g. ZSAU_XXXX <0: ignore*/ |
290 | int new_ConState; /* <0 => ignore */ | 309 | int new_ConState; /* <0 => ignore */ |
291 | int timeout; /* >0 => *HZ; <=0 => TOUT_XXXX*/ | 310 | int timeout; /* >0 => *HZ; <=0 => TOUT_XXXX*/ |
292 | int action[MAXACT]; /* ACT_XXXX */ | 311 | int action[MAXACT]; /* ACT_XXXX */ |
293 | char *command; /* NULL==none */ | 312 | char *command; /* NULL==none */ |
294 | }; | 313 | }; |
295 | 314 | ||
296 | extern struct reply_t gigaset_tab_cid_m10x[]; | 315 | extern struct reply_t gigaset_tab_cid_m10x[]; |
297 | extern struct reply_t gigaset_tab_nocid_m10x[]; | 316 | extern struct reply_t gigaset_tab_nocid_m10x[]; |
298 | 317 | ||
299 | struct inbuf_t { | 318 | struct inbuf_t { |
300 | unsigned char *rcvbuf; /* usb-gigaset receive buffer */ | 319 | unsigned char *rcvbuf; /* usb-gigaset receive buffer */ |
301 | struct bc_state *bcs; | 320 | struct bc_state *bcs; |
302 | struct cardstate *cs; | 321 | struct cardstate *cs; |
303 | int inputstate; | 322 | int inputstate; |
304 | 323 | atomic_t head, tail; | |
305 | atomic_t head, tail; | 324 | unsigned char data[RBUFSIZE]; |
306 | unsigned char data[RBUFSIZE]; | ||
307 | }; | 325 | }; |
308 | 326 | ||
309 | /* isochronous write buffer structure | 327 | /* isochronous write buffer structure |
@@ -319,16 +337,9 @@ struct inbuf_t { | |||
319 | * if writesem <= 0, data[write..read-1] is currently being written to | 337 | * if writesem <= 0, data[write..read-1] is currently being written to |
320 | * - idle contains the byte value to repeat when the end of valid data is | 338 | * - idle contains the byte value to repeat when the end of valid data is |
321 | * reached; if nextread==write (buffer contains no data to send), either the | 339 | * reached; if nextread==write (buffer contains no data to send), either the |
322 | * BAS_OUTBUFPAD bytes immediately before data[write] (if write>=BAS_OUTBUFPAD) | 340 | * BAS_OUTBUFPAD bytes immediately before data[write] (if |
323 | * or those of the pad area (if write<BAS_OUTBUFPAD) are also filled with that | 341 | * write>=BAS_OUTBUFPAD) or those of the pad area (if write<BAS_OUTBUFPAD) |
324 | * value | 342 | * are also filled with that value |
325 | * - optionally, the following statistics on the buffer's usage can be collected: | ||
326 | * maxfill: maximum number of bytes occupied | ||
327 | * idlefills: number of times a frame of idle bytes is prepared | ||
328 | * emptygets: number of times the buffer was empty when a data frame was requested | ||
329 | * backtoback: number of times two data packets were entered into the buffer | ||
330 | * without intervening idle flags | ||
331 | * nakedback: set if no idle flags have been inserted since the last data packet | ||
332 | */ | 343 | */ |
333 | struct isowbuf_t { | 344 | struct isowbuf_t { |
334 | atomic_t read; | 345 | atomic_t read; |
@@ -358,34 +369,28 @@ struct isow_urbctx_t { | |||
358 | * it is currently assigned a B channel | 369 | * it is currently assigned a B channel |
359 | */ | 370 | */ |
360 | struct at_state_t { | 371 | struct at_state_t { |
361 | struct list_head list; | 372 | struct list_head list; |
362 | int waiting; | 373 | int waiting; |
363 | int getstring; | 374 | int getstring; |
364 | atomic_t timer_index; | 375 | unsigned timer_index; |
365 | unsigned long timer_expires; | 376 | unsigned long timer_expires; |
366 | int timer_active; | 377 | int timer_active; |
367 | unsigned int ConState; /* State of connection */ | 378 | unsigned int ConState; /* State of connection */ |
368 | struct reply_t *replystruct; | 379 | struct reply_t *replystruct; |
369 | int cid; | 380 | int cid; |
370 | int int_var[VAR_NUM]; /* see VAR_XXXX */ | 381 | int int_var[VAR_NUM]; /* see VAR_XXXX */ |
371 | char *str_var[STR_NUM]; /* see STR_XXXX */ | 382 | char *str_var[STR_NUM]; /* see STR_XXXX */ |
372 | unsigned pending_commands; /* see PC_XXXX */ | 383 | unsigned pending_commands; /* see PC_XXXX */ |
373 | atomic_t seq_index; | 384 | unsigned seq_index; |
374 | 385 | ||
375 | struct cardstate *cs; | 386 | struct cardstate *cs; |
376 | struct bc_state *bcs; | 387 | struct bc_state *bcs; |
377 | }; | 388 | }; |
378 | 389 | ||
379 | struct resp_type_t { | 390 | struct resp_type_t { |
380 | unsigned char *response; | 391 | unsigned char *response; |
381 | int resp_code; /* RSP_XXXX */ | 392 | int resp_code; /* RSP_XXXX */ |
382 | int type; /* RT_XXXX */ | 393 | int type; /* RT_XXXX */ |
383 | }; | ||
384 | |||
385 | struct prot_skb { | ||
386 | atomic_t empty; | ||
387 | struct semaphore *sem; | ||
388 | struct sk_buff *skb; | ||
389 | }; | 394 | }; |
390 | 395 | ||
391 | struct event_t { | 396 | struct event_t { |
@@ -398,29 +403,29 @@ struct event_t { | |||
398 | 403 | ||
399 | /* This buffer holds all information about the used B-Channel */ | 404 | /* This buffer holds all information about the used B-Channel */ |
400 | struct bc_state { | 405 | struct bc_state { |
401 | struct sk_buff *tx_skb; /* Current transfer buffer to modem */ | 406 | struct sk_buff *tx_skb; /* Current transfer buffer to modem */ |
402 | struct sk_buff_head squeue; /* B-Channel send Queue */ | 407 | struct sk_buff_head squeue; /* B-Channel send Queue */ |
403 | 408 | ||
404 | /* Variables for debugging .. */ | 409 | /* Variables for debugging .. */ |
405 | int corrupted; /* Counter for corrupted packages */ | 410 | int corrupted; /* Counter for corrupted packages */ |
406 | int trans_down; /* Counter of packages (downstream) */ | 411 | int trans_down; /* Counter of packages (downstream) */ |
407 | int trans_up; /* Counter of packages (upstream) */ | 412 | int trans_up; /* Counter of packages (upstream) */ |
408 | 413 | ||
409 | struct at_state_t at_state; | 414 | struct at_state_t at_state; |
410 | unsigned long rcvbytes; | 415 | unsigned long rcvbytes; |
411 | 416 | ||
412 | __u16 fcs; | 417 | __u16 fcs; |
413 | struct sk_buff *skb; | 418 | struct sk_buff *skb; |
414 | int inputstate; /* see INS_XXXX */ | 419 | int inputstate; /* see INS_XXXX */ |
415 | 420 | ||
416 | int channel; | 421 | int channel; |
417 | 422 | ||
418 | struct cardstate *cs; | 423 | struct cardstate *cs; |
419 | 424 | ||
420 | unsigned chstate; /* bitmap (CHS_*) */ | 425 | unsigned chstate; /* bitmap (CHS_*) */ |
421 | int ignore; | 426 | int ignore; |
422 | unsigned proto2; /* Layer 2 protocol (ISDN_PROTO_L2_*) */ | 427 | unsigned proto2; /* Layer 2 protocol (ISDN_PROTO_L2_*) */ |
423 | char *commands[AT_NUM]; /* see AT_XXXX */ | 428 | char *commands[AT_NUM]; /* see AT_XXXX */ |
424 | 429 | ||
425 | #ifdef CONFIG_GIGASET_DEBUG | 430 | #ifdef CONFIG_GIGASET_DEBUG |
426 | int emptycount; | 431 | int emptycount; |
@@ -428,37 +433,39 @@ struct bc_state { | |||
428 | int busy; | 433 | int busy; |
429 | int use_count; | 434 | int use_count; |
430 | 435 | ||
431 | /* hardware drivers */ | 436 | /* private data of hardware drivers */ |
432 | union { | 437 | union { |
433 | struct ser_bc_state *ser; /* private data of serial hardware driver */ | 438 | struct ser_bc_state *ser; /* serial hardware driver */ |
434 | struct usb_bc_state *usb; /* private data of usb hardware driver */ | 439 | struct usb_bc_state *usb; /* usb hardware driver (m105) */ |
435 | struct bas_bc_state *bas; | 440 | struct bas_bc_state *bas; /* usb hardware driver (base) */ |
436 | } hw; | 441 | } hw; |
437 | }; | 442 | }; |
438 | 443 | ||
439 | struct cardstate { | 444 | struct cardstate { |
440 | struct gigaset_driver *driver; | 445 | struct gigaset_driver *driver; |
441 | unsigned minor_index; | 446 | unsigned minor_index; |
447 | struct device *dev; | ||
442 | 448 | ||
443 | const struct gigaset_ops *ops; | 449 | const struct gigaset_ops *ops; |
444 | 450 | ||
445 | /* Stuff to handle communication */ | 451 | /* Stuff to handle communication */ |
446 | //wait_queue_head_t initwait; | ||
447 | wait_queue_head_t waitqueue; | 452 | wait_queue_head_t waitqueue; |
448 | int waiting; | 453 | int waiting; |
449 | atomic_t mode; /* see M_XXXX */ | 454 | atomic_t mode; /* see M_XXXX */ |
450 | atomic_t mstate; /* Modem state: see MS_XXXX */ | 455 | atomic_t mstate; /* Modem state: see MS_XXXX */ |
451 | /* only changed by the event layer */ | 456 | /* only changed by the event layer */ |
452 | int cmd_result; | 457 | int cmd_result; |
453 | 458 | ||
454 | int channels; | 459 | int channels; |
455 | struct bc_state *bcs; /* Array of struct bc_state */ | 460 | struct bc_state *bcs; /* Array of struct bc_state */ |
456 | 461 | ||
457 | int onechannel; /* data and commands transmitted in one stream (M10x) */ | 462 | int onechannel; /* data and commands transmitted in one |
463 | stream (M10x) */ | ||
458 | 464 | ||
459 | spinlock_t lock; | 465 | spinlock_t lock; |
460 | struct at_state_t at_state; /* at_state_t for cid == 0 */ | 466 | struct at_state_t at_state; /* at_state_t for cid == 0 */ |
461 | struct list_head temp_at_states; /* list of temporary "struct at_state_t"s without B channel */ | 467 | struct list_head temp_at_states;/* list of temporary "struct |
468 | at_state_t"s without B channel */ | ||
462 | 469 | ||
463 | struct inbuf_t *inbuf; | 470 | struct inbuf_t *inbuf; |
464 | 471 | ||
@@ -474,58 +481,69 @@ struct cardstate { | |||
474 | unsigned fwver[4]; | 481 | unsigned fwver[4]; |
475 | int gotfwver; | 482 | int gotfwver; |
476 | 483 | ||
477 | atomic_t running; /* !=0 if events are handled */ | 484 | unsigned running; /* !=0 if events are handled */ |
478 | atomic_t connected; /* !=0 if hardware is connected */ | 485 | unsigned connected; /* !=0 if hardware is connected */ |
486 | unsigned isdn_up; /* !=0 after ISDN_STAT_RUN */ | ||
479 | 487 | ||
480 | atomic_t cidmode; | 488 | unsigned cidmode; |
481 | 489 | ||
482 | int myid; /* id for communication with LL */ | 490 | int myid; /* id for communication with LL */ |
483 | isdn_if iif; | 491 | isdn_if iif; |
484 | 492 | ||
485 | struct reply_t *tabnocid; | 493 | struct reply_t *tabnocid; |
486 | struct reply_t *tabcid; | 494 | struct reply_t *tabcid; |
487 | int cs_init; | 495 | int cs_init; |
488 | int ignoreframes; /* frames to ignore after setting up the B channel */ | 496 | int ignoreframes; /* frames to ignore after setting up the |
489 | struct semaphore sem; /* locks this structure: */ | 497 | B channel */ |
490 | /* connected is not changed, */ | 498 | struct mutex mutex; /* locks this structure: |
491 | /* hardware_up is not changed, */ | 499 | * connected is not changed, |
492 | /* MState is not changed to or from MS_LOCKED */ | 500 | * hardware_up is not changed, |
501 | * MState is not changed to or from | ||
502 | * MS_LOCKED */ | ||
493 | 503 | ||
494 | struct timer_list timer; | 504 | struct timer_list timer; |
495 | int retry_count; | 505 | int retry_count; |
496 | int dle; /* !=0 if modem commands/responses are dle encoded */ | 506 | int dle; /* !=0 if modem commands/responses are |
497 | int cur_at_seq; /* sequence of AT commands being processed */ | 507 | dle encoded */ |
498 | int curchannel; /* channel, those commands are meant for */ | 508 | int cur_at_seq; /* sequence of AT commands being |
499 | atomic_t commands_pending; /* flag(s) in xxx.commands_pending have been set */ | 509 | processed */ |
500 | struct tasklet_struct event_tasklet; /* tasklet for serializing AT commands. Scheduled | 510 | int curchannel; /* channel those commands are meant |
501 | * -> for modem reponses (and incomming data for M10x) | 511 | for */ |
502 | * -> on timeout | 512 | atomic_t commands_pending; /* flag(s) in xxx.commands_pending have |
503 | * -> after setting bits in xxx.at_state.pending_command | 513 | been set */ |
504 | * (e.g. command from LL) */ | 514 | struct tasklet_struct event_tasklet; |
505 | struct tasklet_struct write_tasklet; /* tasklet for serial output | 515 | /* tasklet for serializing AT commands. |
506 | * (not used in base driver) */ | 516 | * Scheduled |
517 | * -> for modem reponses (and | ||
518 | * incoming data for M10x) | ||
519 | * -> on timeout | ||
520 | * -> after setting bits in | ||
521 | * xxx.at_state.pending_command | ||
522 | * (e.g. command from LL) */ | ||
523 | struct tasklet_struct write_tasklet; | ||
524 | /* tasklet for serial output | ||
525 | * (not used in base driver) */ | ||
507 | 526 | ||
508 | /* event queue */ | 527 | /* event queue */ |
509 | struct event_t events[MAX_EVENTS]; | 528 | struct event_t events[MAX_EVENTS]; |
510 | atomic_t ev_tail, ev_head; | 529 | unsigned ev_tail, ev_head; |
511 | spinlock_t ev_lock; | 530 | spinlock_t ev_lock; |
512 | 531 | ||
513 | /* current modem response */ | 532 | /* current modem response */ |
514 | unsigned char respdata[MAX_RESP_SIZE]; | 533 | unsigned char respdata[MAX_RESP_SIZE]; |
515 | unsigned cbytes; | 534 | unsigned cbytes; |
516 | 535 | ||
517 | /* hardware drivers */ | 536 | /* private data of hardware drivers */ |
518 | union { | 537 | union { |
519 | struct usb_cardstate *usb; /* private data of USB hardware driver */ | 538 | struct usb_cardstate *usb; /* USB hardware driver (m105) */ |
520 | struct ser_cardstate *ser; /* private data of serial hardware driver */ | 539 | struct ser_cardstate *ser; /* serial hardware driver */ |
521 | struct bas_cardstate *bas; /* private data of base hardware driver */ | 540 | struct bas_cardstate *bas; /* USB hardware driver (base) */ |
522 | } hw; | 541 | } hw; |
523 | }; | 542 | }; |
524 | 543 | ||
525 | struct gigaset_driver { | 544 | struct gigaset_driver { |
526 | struct list_head list; | 545 | struct list_head list; |
527 | spinlock_t lock; /* locks minor tables and blocked */ | 546 | spinlock_t lock; /* locks minor tables and blocked */ |
528 | //struct semaphore sem; /* locks this structure */ | ||
529 | struct tty_driver *tty; | 547 | struct tty_driver *tty; |
530 | unsigned have_tty; | 548 | unsigned have_tty; |
531 | unsigned minor; | 549 | unsigned minor; |
@@ -553,37 +571,42 @@ struct bas_bc_state { | |||
553 | struct isow_urbctx_t isoouturbs[BAS_OUTURBS]; | 571 | struct isow_urbctx_t isoouturbs[BAS_OUTURBS]; |
554 | struct isow_urbctx_t *isooutdone, *isooutfree, *isooutovfl; | 572 | struct isow_urbctx_t *isooutdone, *isooutfree, *isooutovfl; |
555 | struct isowbuf_t *isooutbuf; | 573 | struct isowbuf_t *isooutbuf; |
556 | unsigned numsub; /* submitted URB counter (for diagnostic messages only) */ | 574 | unsigned numsub; /* submitted URB counter |
575 | (for diagnostic messages only) */ | ||
557 | struct tasklet_struct sent_tasklet; | 576 | struct tasklet_struct sent_tasklet; |
558 | 577 | ||
559 | /* isochronous input state */ | 578 | /* isochronous input state */ |
560 | spinlock_t isoinlock; | 579 | spinlock_t isoinlock; |
561 | struct urb *isoinurbs[BAS_INURBS]; | 580 | struct urb *isoinurbs[BAS_INURBS]; |
562 | unsigned char isoinbuf[BAS_INBUFSIZE * BAS_INURBS]; | 581 | unsigned char isoinbuf[BAS_INBUFSIZE * BAS_INURBS]; |
563 | struct urb *isoindone; /* completed isoc read URB */ | 582 | struct urb *isoindone; /* completed isoc read URB */ |
564 | int loststatus; /* status of dropped URB */ | 583 | int loststatus; /* status of dropped URB */ |
565 | unsigned isoinlost; /* number of bytes lost */ | 584 | unsigned isoinlost; /* number of bytes lost */ |
566 | /* state of bit unstuffing algorithm (in addition to BC_state.inputstate) */ | 585 | /* state of bit unstuffing algorithm |
567 | unsigned seqlen; /* number of '1' bits not yet unstuffed */ | 586 | (in addition to BC_state.inputstate) */ |
568 | unsigned inbyte, inbits; /* collected bits for next byte */ | 587 | unsigned seqlen; /* number of '1' bits not yet |
588 | unstuffed */ | ||
589 | unsigned inbyte, inbits; /* collected bits for next byte */ | ||
569 | /* statistics */ | 590 | /* statistics */ |
570 | unsigned goodbytes; /* bytes correctly received */ | 591 | unsigned goodbytes; /* bytes correctly received */ |
571 | unsigned alignerrs; /* frames with incomplete byte at end */ | 592 | unsigned alignerrs; /* frames with incomplete byte at end */ |
572 | unsigned fcserrs; /* FCS errors */ | 593 | unsigned fcserrs; /* FCS errors */ |
573 | unsigned frameerrs; /* framing errors */ | 594 | unsigned frameerrs; /* framing errors */ |
574 | unsigned giants; /* long frames */ | 595 | unsigned giants; /* long frames */ |
575 | unsigned runts; /* short frames */ | 596 | unsigned runts; /* short frames */ |
576 | unsigned aborts; /* HDLC aborts */ | 597 | unsigned aborts; /* HDLC aborts */ |
577 | unsigned shared0s; /* '0' bits shared between flags */ | 598 | unsigned shared0s; /* '0' bits shared between flags */ |
578 | unsigned stolen0s; /* '0' stuff bits also serving as leading flag bits */ | 599 | unsigned stolen0s; /* '0' stuff bits also serving as |
600 | leading flag bits */ | ||
579 | struct tasklet_struct rcvd_tasklet; | 601 | struct tasklet_struct rcvd_tasklet; |
580 | }; | 602 | }; |
581 | 603 | ||
582 | struct gigaset_ops { | 604 | struct gigaset_ops { |
583 | /* Called from ev-layer.c/interface.c for sending AT commands to the device */ | 605 | /* Called from ev-layer.c/interface.c for sending AT commands to the |
606 | device */ | ||
584 | int (*write_cmd)(struct cardstate *cs, | 607 | int (*write_cmd)(struct cardstate *cs, |
585 | const unsigned char *buf, int len, | 608 | const unsigned char *buf, int len, |
586 | struct tasklet_struct *wake_tasklet); | 609 | struct tasklet_struct *wake_tasklet); |
587 | 610 | ||
588 | /* Called from interface.c for additional device control */ | 611 | /* Called from interface.c for additional device control */ |
589 | int (*write_room)(struct cardstate *cs); | 612 | int (*write_room)(struct cardstate *cs); |
@@ -604,7 +627,8 @@ struct gigaset_ops { | |||
604 | /* Called by gigaset_freecs() for freeing bcs->hw.xxx */ | 627 | /* Called by gigaset_freecs() for freeing bcs->hw.xxx */ |
605 | int (*freebcshw)(struct bc_state *bcs); | 628 | int (*freebcshw)(struct bc_state *bcs); |
606 | 629 | ||
607 | /* Called by gigaset_stop() or gigaset_bchannel_down() for resetting bcs->hw.xxx */ | 630 | /* Called by gigaset_stop() or gigaset_bchannel_down() for resetting |
631 | bcs->hw.xxx */ | ||
608 | void (*reinitbcshw)(struct bc_state *bcs); | 632 | void (*reinitbcshw)(struct bc_state *bcs); |
609 | 633 | ||
610 | /* Called by gigaset_initcs() for setting up cs->hw.xxx */ | 634 | /* Called by gigaset_initcs() for setting up cs->hw.xxx */ |
@@ -613,13 +637,10 @@ struct gigaset_ops { | |||
613 | /* Called by gigaset_freecs() for freeing cs->hw.xxx */ | 637 | /* Called by gigaset_freecs() for freeing cs->hw.xxx */ |
614 | void (*freecshw)(struct cardstate *cs); | 638 | void (*freecshw)(struct cardstate *cs); |
615 | 639 | ||
616 | ///* Called by gigaset_stop() for killing URBs, shutting down the device, ... | 640 | /* Called from common.c/interface.c for additional serial port |
617 | // hardwareup: ==0: don't try to shut down the device, hardware is really not accessible | 641 | control */ |
618 | // !=0: hardware still up */ | 642 | int (*set_modem_ctrl)(struct cardstate *cs, unsigned old_state, |
619 | //void (*stophw)(struct cardstate *cs, int hardwareup); | 643 | unsigned new_state); |
620 | |||
621 | /* Called from common.c/interface.c for additional serial port control */ | ||
622 | int (*set_modem_ctrl)(struct cardstate *cs, unsigned old_state, unsigned new_state); | ||
623 | int (*baud_rate)(struct cardstate *cs, unsigned cflag); | 644 | int (*baud_rate)(struct cardstate *cs, unsigned cflag); |
624 | int (*set_line_ctrl)(struct cardstate *cs, unsigned cflag); | 645 | int (*set_line_ctrl)(struct cardstate *cs, unsigned cflag); |
625 | 646 | ||
@@ -639,7 +660,7 @@ struct gigaset_ops { | |||
639 | * <DLE_FLAG>: 0x10 | 660 | * <DLE_FLAG>: 0x10 |
640 | * <EVENT>: ((a-z)* | (A-Z)* | (0-10)*)+ | 661 | * <EVENT>: ((a-z)* | (A-Z)* | (0-10)*)+ |
641 | */ | 662 | */ |
642 | #define DLE_FLAG 0x10 | 663 | #define DLE_FLAG 0x10 |
643 | 664 | ||
644 | /* =========================================================================== | 665 | /* =========================================================================== |
645 | * Functions implemented in asyncdata.c | 666 | * Functions implemented in asyncdata.c |
@@ -667,7 +688,8 @@ void gigaset_isoc_input(struct inbuf_t *inbuf); | |||
667 | 688 | ||
668 | /* Called from bas-gigaset.c to process a block of data | 689 | /* Called from bas-gigaset.c to process a block of data |
669 | * received through the isochronous channel */ | 690 | * received through the isochronous channel */ |
670 | void gigaset_isoc_receive(unsigned char *src, unsigned count, struct bc_state *bcs); | 691 | void gigaset_isoc_receive(unsigned char *src, unsigned count, |
692 | struct bc_state *bcs); | ||
671 | 693 | ||
672 | /* Called from bas-gigaset.c to put a block of data | 694 | /* Called from bas-gigaset.c to put a block of data |
673 | * into the isochronous output buffer */ | 695 | * into the isochronous output buffer */ |
@@ -703,7 +725,7 @@ static inline void gigaset_isdn_rcv_err(struct bc_state *bcs) | |||
703 | isdn_ctrl response; | 725 | isdn_ctrl response; |
704 | 726 | ||
705 | /* error -> LL */ | 727 | /* error -> LL */ |
706 | dbg(DEBUG_CMD, "sending L1ERR"); | 728 | gig_dbg(DEBUG_CMD, "sending L1ERR"); |
707 | response.driver = bcs->cs->myid; | 729 | response.driver = bcs->cs->myid; |
708 | response.command = ISDN_STAT_L1ERR; | 730 | response.command = ISDN_STAT_L1ERR; |
709 | response.arg = bcs->channel; | 731 | response.arg = bcs->channel; |
@@ -727,8 +749,8 @@ void gigaset_handle_modem_response(struct cardstate *cs); | |||
727 | */ | 749 | */ |
728 | 750 | ||
729 | /* initialize sysfs for device */ | 751 | /* initialize sysfs for device */ |
730 | void gigaset_init_dev_sysfs(struct usb_interface *interface); | 752 | void gigaset_init_dev_sysfs(struct cardstate *cs); |
731 | void gigaset_free_dev_sysfs(struct usb_interface *interface); | 753 | void gigaset_free_dev_sysfs(struct cardstate *cs); |
732 | 754 | ||
733 | /* =========================================================================== | 755 | /* =========================================================================== |
734 | * Functions implemented in common.c/gigaset.h | 756 | * Functions implemented in common.c/gigaset.h |
@@ -736,7 +758,7 @@ void gigaset_free_dev_sysfs(struct usb_interface *interface); | |||
736 | 758 | ||
737 | void gigaset_bcs_reinit(struct bc_state *bcs); | 759 | void gigaset_bcs_reinit(struct bc_state *bcs); |
738 | void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs, | 760 | void gigaset_at_init(struct at_state_t *at_state, struct bc_state *bcs, |
739 | struct cardstate *cs, int cid); | 761 | struct cardstate *cs, int cid); |
740 | int gigaset_get_channel(struct bc_state *bcs); | 762 | int gigaset_get_channel(struct bc_state *bcs); |
741 | void gigaset_free_channel(struct bc_state *bcs); | 763 | void gigaset_free_channel(struct bc_state *bcs); |
742 | int gigaset_get_channels(struct cardstate *cs); | 764 | int gigaset_get_channels(struct cardstate *cs); |
@@ -745,16 +767,15 @@ void gigaset_block_channels(struct cardstate *cs); | |||
745 | 767 | ||
746 | /* Allocate and initialize driver structure. */ | 768 | /* Allocate and initialize driver structure. */ |
747 | struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, | 769 | struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, |
748 | const char *procname, | 770 | const char *procname, |
749 | const char *devname, | 771 | const char *devname, |
750 | const char *devfsname, | 772 | const char *devfsname, |
751 | const struct gigaset_ops *ops, | 773 | const struct gigaset_ops *ops, |
752 | struct module *owner); | 774 | struct module *owner); |
753 | 775 | ||
754 | /* Deallocate driver structure. */ | 776 | /* Deallocate driver structure. */ |
755 | void gigaset_freedriver(struct gigaset_driver *drv); | 777 | void gigaset_freedriver(struct gigaset_driver *drv); |
756 | void gigaset_debugdrivers(void); | 778 | void gigaset_debugdrivers(void); |
757 | struct cardstate *gigaset_get_cs_by_minor(unsigned minor); | ||
758 | struct cardstate *gigaset_get_cs_by_tty(struct tty_struct *tty); | 779 | struct cardstate *gigaset_get_cs_by_tty(struct tty_struct *tty); |
759 | struct cardstate *gigaset_get_cs_by_id(int id); | 780 | struct cardstate *gigaset_get_cs_by_id(int id); |
760 | 781 | ||
@@ -763,7 +784,8 @@ struct cardstate *gigaset_getunassignedcs(struct gigaset_driver *drv); | |||
763 | void gigaset_unassign(struct cardstate *cs); | 784 | void gigaset_unassign(struct cardstate *cs); |
764 | void gigaset_blockdriver(struct gigaset_driver *drv); | 785 | void gigaset_blockdriver(struct gigaset_driver *drv); |
765 | 786 | ||
766 | /* Allocate and initialize card state. Calls hardware dependent gigaset_init[b]cs(). */ | 787 | /* Allocate and initialize card state. Calls hardware dependent |
788 | gigaset_init[b]cs(). */ | ||
767 | struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | 789 | struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, |
768 | int onechannel, int ignoreframes, | 790 | int onechannel, int ignoreframes, |
769 | int cidmode, const char *modulename); | 791 | int cidmode, const char *modulename); |
@@ -788,8 +810,8 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb); | |||
788 | * ptr must be kmalloc()ed (and not be freed by the caller). | 810 | * ptr must be kmalloc()ed (and not be freed by the caller). |
789 | */ | 811 | */ |
790 | struct event_t *gigaset_add_event(struct cardstate *cs, | 812 | struct event_t *gigaset_add_event(struct cardstate *cs, |
791 | struct at_state_t *at_state, int type, | 813 | struct at_state_t *at_state, int type, |
792 | void *ptr, int parameter, void *arg); | 814 | void *ptr, int parameter, void *arg); |
793 | 815 | ||
794 | /* Called on CONFIG1 command from frontend. */ | 816 | /* Called on CONFIG1 command from frontend. */ |
795 | int gigaset_enterconfigmode(struct cardstate *cs); //0: success <0: errorcode | 817 | int gigaset_enterconfigmode(struct cardstate *cs); //0: success <0: errorcode |
@@ -799,7 +821,7 @@ static inline void gigaset_schedule_event(struct cardstate *cs) | |||
799 | { | 821 | { |
800 | unsigned long flags; | 822 | unsigned long flags; |
801 | spin_lock_irqsave(&cs->lock, flags); | 823 | spin_lock_irqsave(&cs->lock, flags); |
802 | if (atomic_read(&cs->running)) | 824 | if (cs->running) |
803 | tasklet_schedule(&cs->event_tasklet); | 825 | tasklet_schedule(&cs->event_tasklet); |
804 | spin_unlock_irqrestore(&cs->lock, flags); | 826 | spin_unlock_irqrestore(&cs->lock, flags); |
805 | } | 827 | } |
@@ -810,7 +832,7 @@ static inline void gigaset_bchannel_down(struct bc_state *bcs) | |||
810 | { | 832 | { |
811 | gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_CLOSED, NULL, 0, NULL); | 833 | gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_CLOSED, NULL, 0, NULL); |
812 | 834 | ||
813 | dbg(DEBUG_CMD, "scheduling BC_CLOSED"); | 835 | gig_dbg(DEBUG_CMD, "scheduling BC_CLOSED"); |
814 | gigaset_schedule_event(bcs->cs); | 836 | gigaset_schedule_event(bcs->cs); |
815 | } | 837 | } |
816 | 838 | ||
@@ -820,36 +842,19 @@ static inline void gigaset_bchannel_up(struct bc_state *bcs) | |||
820 | { | 842 | { |
821 | gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_OPEN, NULL, 0, NULL); | 843 | gigaset_add_event(bcs->cs, &bcs->at_state, EV_BC_OPEN, NULL, 0, NULL); |
822 | 844 | ||
823 | dbg(DEBUG_CMD, "scheduling BC_OPEN"); | 845 | gig_dbg(DEBUG_CMD, "scheduling BC_OPEN"); |
824 | gigaset_schedule_event(bcs->cs); | 846 | gigaset_schedule_event(bcs->cs); |
825 | } | 847 | } |
826 | 848 | ||
827 | /* handling routines for sk_buff */ | 849 | /* handling routines for sk_buff */ |
828 | /* ============================= */ | 850 | /* ============================= */ |
829 | 851 | ||
830 | /* private version of __skb_put() | ||
831 | * append 'len' bytes to the content of 'skb', already knowing that the | ||
832 | * existing buffer can accomodate them | ||
833 | * returns a pointer to the location where the new bytes should be copied to | ||
834 | * This function does not take any locks so it must be called with the | ||
835 | * appropriate locks held only. | ||
836 | */ | ||
837 | static inline unsigned char *gigaset_skb_put_quick(struct sk_buff *skb, | ||
838 | unsigned int len) | ||
839 | { | ||
840 | unsigned char *tmp = skb->tail; | ||
841 | /*SKB_LINEAR_ASSERT(skb);*/ /* not needed here */ | ||
842 | skb->tail += len; | ||
843 | skb->len += len; | ||
844 | return tmp; | ||
845 | } | ||
846 | |||
847 | /* pass received skb to LL | 852 | /* pass received skb to LL |
848 | * Warning: skb must not be accessed anymore! | 853 | * Warning: skb must not be accessed anymore! |
849 | */ | 854 | */ |
850 | static inline void gigaset_rcv_skb(struct sk_buff *skb, | 855 | static inline void gigaset_rcv_skb(struct sk_buff *skb, |
851 | struct cardstate *cs, | 856 | struct cardstate *cs, |
852 | struct bc_state *bcs) | 857 | struct bc_state *bcs) |
853 | { | 858 | { |
854 | cs->iif.rcvcallb_skb(cs->myid, bcs->channel, skb); | 859 | cs->iif.rcvcallb_skb(cs->myid, bcs->channel, skb); |
855 | bcs->trans_down++; | 860 | bcs->trans_down++; |
@@ -859,8 +864,8 @@ static inline void gigaset_rcv_skb(struct sk_buff *skb, | |||
859 | * Warning: skb must not be accessed anymore! | 864 | * Warning: skb must not be accessed anymore! |
860 | */ | 865 | */ |
861 | static inline void gigaset_rcv_error(struct sk_buff *procskb, | 866 | static inline void gigaset_rcv_error(struct sk_buff *procskb, |
862 | struct cardstate *cs, | 867 | struct cardstate *cs, |
863 | struct bc_state *bcs) | 868 | struct bc_state *bcs) |
864 | { | 869 | { |
865 | if (procskb) | 870 | if (procskb) |
866 | dev_kfree_skb(procskb); | 871 | dev_kfree_skb(procskb); |
@@ -877,46 +882,9 @@ static inline void gigaset_rcv_error(struct sk_buff *procskb, | |||
877 | /* bitwise byte inversion table */ | 882 | /* bitwise byte inversion table */ |
878 | extern __u8 gigaset_invtab[]; /* in common.c */ | 883 | extern __u8 gigaset_invtab[]; /* in common.c */ |
879 | 884 | ||
880 | |||
881 | /* append received bytes to inbuf */ | 885 | /* append received bytes to inbuf */ |
882 | static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf, | 886 | int gigaset_fill_inbuf(struct inbuf_t *inbuf, const unsigned char *src, |
883 | const unsigned char *src, | 887 | unsigned numbytes); |
884 | unsigned numbytes) | ||
885 | { | ||
886 | unsigned n, head, tail, bytesleft; | ||
887 | |||
888 | dbg(DEBUG_INTR, "received %u bytes", numbytes); | ||
889 | |||
890 | if (!numbytes) | ||
891 | return 0; | ||
892 | |||
893 | bytesleft = numbytes; | ||
894 | tail = atomic_read(&inbuf->tail); | ||
895 | head = atomic_read(&inbuf->head); | ||
896 | dbg(DEBUG_INTR, "buffer state: %u -> %u", head, tail); | ||
897 | |||
898 | while (bytesleft) { | ||
899 | if (head > tail) | ||
900 | n = head - 1 - tail; | ||
901 | else if (head == 0) | ||
902 | n = (RBUFSIZE-1) - tail; | ||
903 | else | ||
904 | n = RBUFSIZE - tail; | ||
905 | if (!n) { | ||
906 | err("buffer overflow (%u bytes lost)", bytesleft); | ||
907 | break; | ||
908 | } | ||
909 | if (n > bytesleft) | ||
910 | n = bytesleft; | ||
911 | memcpy(inbuf->data + tail, src, n); | ||
912 | bytesleft -= n; | ||
913 | tail = (tail + n) % RBUFSIZE; | ||
914 | src += n; | ||
915 | } | ||
916 | dbg(DEBUG_INTR, "setting tail to %u", tail); | ||
917 | atomic_set(&inbuf->tail, tail); | ||
918 | return numbytes != bytesleft; | ||
919 | } | ||
920 | 888 | ||
921 | /* =========================================================================== | 889 | /* =========================================================================== |
922 | * Functions implemented in interface.c | 890 | * Functions implemented in interface.c |
@@ -924,7 +892,7 @@ static inline int gigaset_fill_inbuf(struct inbuf_t *inbuf, | |||
924 | 892 | ||
925 | /* initialize interface */ | 893 | /* initialize interface */ |
926 | void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname, | 894 | void gigaset_if_initdriver(struct gigaset_driver *drv, const char *procname, |
927 | const char *devname, const char *devfsname); | 895 | const char *devname, const char *devfsname); |
928 | /* release interface */ | 896 | /* release interface */ |
929 | void gigaset_if_freedriver(struct gigaset_driver *drv); | 897 | void gigaset_if_freedriver(struct gigaset_driver *drv); |
930 | /* add minor */ | 898 | /* add minor */ |
@@ -933,6 +901,6 @@ void gigaset_if_init(struct cardstate *cs); | |||
933 | void gigaset_if_free(struct cardstate *cs); | 901 | void gigaset_if_free(struct cardstate *cs); |
934 | /* device received data */ | 902 | /* device received data */ |
935 | void gigaset_if_receive(struct cardstate *cs, | 903 | void gigaset_if_receive(struct cardstate *cs, |
936 | unsigned char *buffer, size_t len); | 904 | unsigned char *buffer, size_t len); |
937 | 905 | ||
938 | #endif | 906 | #endif |