aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/gigaset/gigaset.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/isdn/gigaset/gigaset.h')
-rw-r--r--drivers/isdn/gigaset/gigaset.h470
1 files changed, 266 insertions, 204 deletions
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h
index 729edcdb6dac..d34f0023ac74 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 <Eilers.Stefan@epost.de>
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
@@ -67,68 +72,108 @@
67 72
68#define MAXACT 3 73#define MAXACT 3
69 74
70#define IFNULL(a) if (unlikely(!(a))) 75#define IFNULL(a) \
71#define IFNULLRET(a) if (unlikely(!(a))) {err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); return; } 76 if (unlikely(!(a)))
72#define IFNULLRETVAL(a,b) if (unlikely(!(a))) {err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); return (b); } 77
73#define IFNULLCONT(a) if (unlikely(!(a))) {err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); continue; } 78#define IFNULLRET(a) \
74#define IFNULLGOTO(a,b) if (unlikely(!(a))) {err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); goto b; } 79 if (unlikely(!(a))) { \
80 err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); \
81 return; \
82 }
83
84#define IFNULLRETVAL(a,b) \
85 if (unlikely(!(a))) { \
86 err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); \
87 return (b); \
88 }
89
90#define IFNULLCONT(a) \
91 if (unlikely(!(a))) { \
92 err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); \
93 continue; \
94 }
95
96#define IFNULLGOTO(a,b) \
97 if (unlikely(!(a))) { \
98 err("%s==NULL at %s:%d!", #a, __FILE__, __LINE__); \
99 goto b; \
100 }
75 101
76extern int gigaset_debuglevel; /* "needs" cast to (enum debuglevel) */ 102extern int gigaset_debuglevel; /* "needs" cast to (enum debuglevel) */
77 103
78/* any combination of these can be given with the 'debug=' parameter to insmod, e.g. 104/* 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. */ 105 * e.g. 'insmod usb_gigaset.o debug=0x2c' will set DEBUG_OPEN, DEBUG_CMD and
106 * DEBUG_INTR.
107 */
80enum debuglevel { /* up to 24 bits (atomic_t) */ 108enum debuglevel { /* up to 24 bits (atomic_t) */
81 DEBUG_REG = 0x0002, /* serial port I/O register operations */ 109 DEBUG_REG = 0x0002,/* serial port I/O register operations */
82 DEBUG_OPEN = 0x0004, /* open/close serial port */ 110 DEBUG_OPEN = 0x0004, /* open/close serial port */
83 DEBUG_INTR = 0x0008, /* interrupt processing */ 111 DEBUG_INTR = 0x0008, /* interrupt processing */
84 DEBUG_INTR_DUMP = 0x0010, /* Activating hexdump debug output on interrupt 112 DEBUG_INTR_DUMP = 0x0010, /* Activating hexdump debug output on
85 requests, not available as run-time option */ 113 interrupt requests, not available as
114 run-time option */
86 DEBUG_CMD = 0x00020, /* sent/received LL commands */ 115 DEBUG_CMD = 0x00020, /* sent/received LL commands */
87 DEBUG_STREAM = 0x00040, /* application data stream I/O events */ 116 DEBUG_STREAM = 0x00040, /* application data stream I/O events */
88 DEBUG_STREAM_DUMP = 0x00080, /* application data stream content */ 117 DEBUG_STREAM_DUMP = 0x00080, /* application data stream content */
89 DEBUG_LLDATA = 0x00100, /* sent/received LL data */ 118 DEBUG_LLDATA = 0x00100, /* sent/received LL data */
90 DEBUG_INTR_0 = 0x00200, /* serial port output interrupt processing */ 119 DEBUG_INTR_0 = 0x00200, /* serial port interrupt processing */
91 DEBUG_DRIVER = 0x00400, /* driver structure */ 120 DEBUG_DRIVER = 0x00400, /* driver structure */
92 DEBUG_HDLC = 0x00800, /* M10x HDLC processing */ 121 DEBUG_HDLC = 0x00800, /* M10x HDLC processing */
93 DEBUG_WRITE = 0x01000, /* M105 data write */ 122 DEBUG_WRITE = 0x01000, /* M105 data write */
94 DEBUG_TRANSCMD = 0x02000, /*AT-COMMANDS+RESPONSES*/ 123 DEBUG_TRANSCMD = 0x02000, /* AT-COMMANDS+RESPONSES */
95 DEBUG_MCMD = 0x04000, /*COMMANDS THAT ARE SENT VERY OFTEN*/ 124 DEBUG_MCMD = 0x04000, /* COMMANDS THAT ARE SENT VERY OFTEN */
96 DEBUG_INIT = 0x08000, /* (de)allocation+initialization of data structures */ 125 DEBUG_INIT = 0x08000, /* (de)allocation+initialization of data
126 structures */
97 DEBUG_LOCK = 0x10000, /* semaphore operations */ 127 DEBUG_LOCK = 0x10000, /* semaphore operations */
98 DEBUG_OUTPUT = 0x20000, /* output to device */ 128 DEBUG_OUTPUT = 0x20000, /* output to device */
99 DEBUG_ISO = 0x40000, /* isochronous transfers */ 129 DEBUG_ISO = 0x40000, /* isochronous transfers */
100 DEBUG_IF = 0x80000, /* character device operations */ 130 DEBUG_IF = 0x80000, /* character device operations */
101 DEBUG_USBREQ = 0x100000, /* USB communication (except payload data) */ 131 DEBUG_USBREQ = 0x100000, /* USB communication (except payload
102 DEBUG_LOCKCMD = 0x200000, /* AT commands and responses when MS_LOCKED */ 132 data) */
133 DEBUG_LOCKCMD = 0x200000, /* AT commands and responses when
134 MS_LOCKED */
103 135
104 DEBUG_ANY = 0x3fffff, /* print message if any of the others is activated */ 136 DEBUG_ANY = 0x3fffff, /* print message if any of the others is
137 activated */
105}; 138};
106 139
107#ifdef CONFIG_GIGASET_DEBUG 140#ifdef CONFIG_GIGASET_DEBUG
108#define DEBUG_DEFAULT (DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ) 141#define DEBUG_DEFAULT (DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ)
109//#define DEBUG_DEFAULT (DEBUG_LOCK | DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUF_IF | DEBUG_DRIVER | DEBUG_OUTPUT | DEBUG_INTR)
110#else 142#else
111#define DEBUG_DEFAULT 0 143#define DEBUG_DEFAULT 0
112#endif 144#endif
113 145
114/* redefine syslog macros to prepend module name instead of entire source path */ 146/* redefine syslog macros to prepend module name instead of entire
115/* The space before the comma in ", ##" is needed by gcc 2.95 */ 147 * source path */
116#undef info 148#undef info
117#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg) 149#define info(format, arg...) \
150 printk(KERN_INFO "%s: " format "\n", \
151 THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
118 152
119#undef notice 153#undef notice
120#define notice(format, arg...) printk(KERN_NOTICE "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg) 154#define notice(format, arg...) \
155 printk(KERN_NOTICE "%s: " format "\n", \
156 THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
121 157
122#undef warn 158#undef warn
123#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg) 159#define warn(format, arg...) \
160 printk(KERN_WARNING "%s: " format "\n", \
161 THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
124 162
125#undef err 163#undef err
126#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg) 164#define err(format, arg...) \
165 printk(KERN_ERR "%s: " format "\n", \
166 THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg)
127 167
128#undef dbg 168#undef dbg
129#ifdef CONFIG_GIGASET_DEBUG 169#ifdef CONFIG_GIGASET_DEBUG
130#define dbg(level, format, arg...) do { if (unlikely(((enum debuglevel)gigaset_debuglevel) & (level))) \ 170#define dbg(level, format, arg...) \
131 printk(KERN_DEBUG "%s: " format "\n", THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" , ## arg); } while (0) 171 do { \
172 if (unlikely(((enum debuglevel)gigaset_debuglevel) & (level))) \
173 printk(KERN_DEBUG "%s: " format "\n", \
174 THIS_MODULE ? THIS_MODULE->name : "gigaset_hw" \
175 , ## arg); \
176 } while (0)
132#else 177#else
133#define dbg(level, format, arg...) do {} while (0) 178#define dbg(level, format, arg...) do {} while (0)
134#endif 179#endif
@@ -148,13 +193,14 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
148#define ZSAU_UNKNOWN -1 193#define ZSAU_UNKNOWN -1
149 194
150/* USB control transfer requests */ 195/* USB control transfer requests */
151#define OUT_VENDOR_REQ (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT) 196#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) 197#define IN_VENDOR_REQ (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT)
153 198
154/* int-in-events 3070 */ 199/* int-in-events 3070 */
155#define HD_B1_FLOW_CONTROL 0x80 200#define HD_B1_FLOW_CONTROL 0x80
156#define HD_B2_FLOW_CONTROL 0x81 201#define HD_B2_FLOW_CONTROL 0x81
157#define HD_RECEIVEATDATA_ACK (0x35) // 3070 // att: HD_RECEIVE>>AT<<DATA_ACK 202#define HD_RECEIVEATDATA_ACK (0x35) // 3070
203 // att: HD_RECEIVE>>AT<<DATA_ACK
158#define HD_READY_SEND_ATDATA (0x36) // 3070 204#define HD_READY_SEND_ATDATA (0x36) // 3070
159#define HD_OPEN_ATCHANNEL_ACK (0x37) // 3070 205#define HD_OPEN_ATCHANNEL_ACK (0x37) // 3070
160#define HD_CLOSE_ATCHANNEL_ACK (0x38) // 3070 206#define HD_CLOSE_ATCHANNEL_ACK (0x38) // 3070
@@ -181,17 +227,18 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
181#define HD_CLOSE_ATCHANNEL (0x29) // 3070 227#define HD_CLOSE_ATCHANNEL (0x29) // 3070
182 228
183/* USB frames for isochronous transfer */ 229/* USB frames for isochronous transfer */
184#define BAS_FRAMETIME 1 /* number of milliseconds between frames */ 230#define BAS_FRAMETIME 1 /* number of milliseconds between frames */
185#define BAS_NUMFRAMES 8 /* number of frames per URB */ 231#define BAS_NUMFRAMES 8 /* number of frames per URB */
186#define BAS_MAXFRAME 16 /* allocated bytes per frame */ 232#define BAS_MAXFRAME 16 /* allocated bytes per frame */
187#define BAS_NORMFRAME 8 /* send size without flow control */ 233#define BAS_NORMFRAME 8 /* send size without flow control */
188#define BAS_HIGHFRAME 10 /* " " with positive flow control */ 234#define BAS_HIGHFRAME 10 /* " " with positive flow control */
189#define BAS_LOWFRAME 5 /* " " with negative flow control */ 235#define BAS_LOWFRAME 5 /* " " with negative flow control */
190#define BAS_CORRFRAMES 4 /* flow control multiplicator */ 236#define BAS_CORRFRAMES 4 /* flow control multiplicator */
191 237
192#define BAS_INBUFSIZE (BAS_MAXFRAME * BAS_NUMFRAMES) /* size of isochronous input buffer per URB */ 238#define BAS_INBUFSIZE (BAS_MAXFRAME * BAS_NUMFRAMES)
193#define BAS_OUTBUFSIZE 4096 /* size of common isochronous output buffer */ 239 /* size of isoc in buf per URB */
194#define BAS_OUTBUFPAD BAS_MAXFRAME /* size of pad area for isochronous output buffer */ 240#define BAS_OUTBUFSIZE 4096 /* size of common isoc out buffer */
241#define BAS_OUTBUFPAD BAS_MAXFRAME /* size of pad area for isoc out buf */
195 242
196#define BAS_INURBS 3 243#define BAS_INURBS 3
197#define BAS_OUTURBS 3 244#define BAS_OUTURBS 3
@@ -207,40 +254,40 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
207#define AT_NUM 7 254#define AT_NUM 7
208 255
209/* variables in struct at_state_t */ 256/* variables in struct at_state_t */
210#define VAR_ZSAU 0 257#define VAR_ZSAU 0
211#define VAR_ZDLE 1 258#define VAR_ZDLE 1
212#define VAR_ZVLS 2 259#define VAR_ZVLS 2
213#define VAR_ZCTP 3 260#define VAR_ZCTP 3
214#define VAR_NUM 4 261#define VAR_NUM 4
215 262
216#define STR_NMBR 0 263#define STR_NMBR 0
217#define STR_ZCPN 1 264#define STR_ZCPN 1
218#define STR_ZCON 2 265#define STR_ZCON 2
219#define STR_ZBC 3 266#define STR_ZBC 3
220#define STR_ZHLC 4 267#define STR_ZHLC 4
221#define STR_NUM 5 268#define STR_NUM 5
222 269
223#define EV_TIMEOUT -105 270#define EV_TIMEOUT -105
224#define EV_IF_VER -106 271#define EV_IF_VER -106
225#define EV_PROC_CIDMODE -107 272#define EV_PROC_CIDMODE -107
226#define EV_SHUTDOWN -108 273#define EV_SHUTDOWN -108
227#define EV_START -110 274#define EV_START -110
228#define EV_STOP -111 275#define EV_STOP -111
229#define EV_IF_LOCK -112 276#define EV_IF_LOCK -112
230#define EV_PROTO_L2 -113 277#define EV_PROTO_L2 -113
231#define EV_ACCEPT -114 278#define EV_ACCEPT -114
232#define EV_DIAL -115 279#define EV_DIAL -115
233#define EV_HUP -116 280#define EV_HUP -116
234#define EV_BC_OPEN -117 281#define EV_BC_OPEN -117
235#define EV_BC_CLOSED -118 282#define EV_BC_CLOSED -118
236 283
237/* input state */ 284/* input state */
238#define INS_command 0x0001 285#define INS_command 0x0001
239#define INS_DLE_char 0x0002 286#define INS_DLE_char 0x0002
240#define INS_byte_stuff 0x0004 287#define INS_byte_stuff 0x0004
241#define INS_have_data 0x0008 288#define INS_have_data 0x0008
242#define INS_skip_frame 0x0010 289#define INS_skip_frame 0x0010
243#define INS_DLE_command 0x0020 290#define INS_DLE_command 0x0020
244#define INS_flag_hunt 0x0040 291#define INS_flag_hunt 0x0040
245 292
246/* channel state */ 293/* channel state */
@@ -248,27 +295,27 @@ void gigaset_dbg_buffer(enum debuglevel level, const unsigned char *msg,
248#define CHS_B_UP 0x02 295#define CHS_B_UP 0x02
249#define CHS_NOTIFY_LL 0x04 296#define CHS_NOTIFY_LL 0x04
250 297
251#define ICALL_REJECT 0 298#define ICALL_REJECT 0
252#define ICALL_ACCEPT 1 299#define ICALL_ACCEPT 1
253#define ICALL_IGNORE 2 300#define ICALL_IGNORE 2
254 301
255/* device state */ 302/* device state */
256#define MS_UNINITIALIZED 0 303#define MS_UNINITIALIZED 0
257#define MS_INIT 1 304#define MS_INIT 1
258#define MS_LOCKED 2 305#define MS_LOCKED 2
259#define MS_SHUTDOWN 3 306#define MS_SHUTDOWN 3
260#define MS_RECOVER 4 307#define MS_RECOVER 4
261#define MS_READY 5 308#define MS_READY 5
262 309
263/* mode */ 310/* mode */
264#define M_UNKNOWN 0 311#define M_UNKNOWN 0
265#define M_CONFIG 1 312#define M_CONFIG 1
266#define M_UNIMODEM 2 313#define M_UNIMODEM 2
267#define M_CID 3 314#define M_CID 3
268 315
269/* start mode */ 316/* start mode */
270#define SM_LOCKED 0 317#define SM_LOCKED 0
271#define SM_ISDN 1 /* default */ 318#define SM_ISDN 1 /* default */
272 319
273struct gigaset_ops; 320struct gigaset_ops;
274struct gigaset_driver; 321struct gigaset_driver;
@@ -283,27 +330,26 @@ struct ser_bc_state;
283struct bas_bc_state; 330struct bas_bc_state;
284 331
285struct reply_t { 332struct reply_t {
286 int resp_code; /* RSP_XXXX */ 333 int resp_code; /* RSP_XXXX */
287 int min_ConState; /* <0 => ignore */ 334 int min_ConState; /* <0 => ignore */
288 int max_ConState; /* <0 => ignore */ 335 int max_ConState; /* <0 => ignore */
289 int parameter; /* e.g. ZSAU_XXXX <0: ignore*/ 336 int parameter; /* e.g. ZSAU_XXXX <0: ignore*/
290 int new_ConState; /* <0 => ignore */ 337 int new_ConState; /* <0 => ignore */
291 int timeout; /* >0 => *HZ; <=0 => TOUT_XXXX*/ 338 int timeout; /* >0 => *HZ; <=0 => TOUT_XXXX*/
292 int action[MAXACT]; /* ACT_XXXX */ 339 int action[MAXACT]; /* ACT_XXXX */
293 char *command; /* NULL==none */ 340 char *command; /* NULL==none */
294}; 341};
295 342
296extern struct reply_t gigaset_tab_cid_m10x[]; 343extern struct reply_t gigaset_tab_cid_m10x[];
297extern struct reply_t gigaset_tab_nocid_m10x[]; 344extern struct reply_t gigaset_tab_nocid_m10x[];
298 345
299struct inbuf_t { 346struct inbuf_t {
300 unsigned char *rcvbuf; /* usb-gigaset receive buffer */ 347 unsigned char *rcvbuf; /* usb-gigaset receive buffer */
301 struct bc_state *bcs; 348 struct bc_state *bcs;
302 struct cardstate *cs; 349 struct cardstate *cs;
303 int inputstate; 350 int inputstate;
304 351 atomic_t head, tail;
305 atomic_t head, tail; 352 unsigned char data[RBUFSIZE];
306 unsigned char data[RBUFSIZE];
307}; 353};
308 354
309/* isochronous write buffer structure 355/* isochronous write buffer structure
@@ -319,16 +365,19 @@ struct inbuf_t {
319 * if writesem <= 0, data[write..read-1] is currently being written to 365 * 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 366 * - 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 367 * reached; if nextread==write (buffer contains no data to send), either the
322 * BAS_OUTBUFPAD bytes immediately before data[write] (if write>=BAS_OUTBUFPAD) 368 * BAS_OUTBUFPAD bytes immediately before data[write] (if
323 * or those of the pad area (if write<BAS_OUTBUFPAD) are also filled with that 369 * write>=BAS_OUTBUFPAD) or those of the pad area (if write<BAS_OUTBUFPAD)
324 * value 370 * are also filled with that value
325 * - optionally, the following statistics on the buffer's usage can be collected: 371 * - optionally, the following statistics on the buffer's usage can be
326 * maxfill: maximum number of bytes occupied 372 * collected:
327 * idlefills: number of times a frame of idle bytes is prepared 373 * maxfill: maximum number of bytes occupied
328 * emptygets: number of times the buffer was empty when a data frame was requested 374 * idlefills: number of times a frame of idle bytes is prepared
375 * emptygets: number of times the buffer was empty when a data frame was
376 * requested
329 * backtoback: number of times two data packets were entered into the buffer 377 * backtoback: number of times two data packets were entered into the buffer
330 * without intervening idle flags 378 * without intervening idle flags
331 * nakedback: set if no idle flags have been inserted since the last data packet 379 * nakedback: set if no idle flags have been inserted since the last data
380 * packet
332 */ 381 */
333struct isowbuf_t { 382struct isowbuf_t {
334 atomic_t read; 383 atomic_t read;
@@ -358,34 +407,28 @@ struct isow_urbctx_t {
358 * it is currently assigned a B channel 407 * it is currently assigned a B channel
359 */ 408 */
360struct at_state_t { 409struct at_state_t {
361 struct list_head list; 410 struct list_head list;
362 int waiting; 411 int waiting;
363 int getstring; 412 int getstring;
364 atomic_t timer_index; 413 atomic_t timer_index;
365 unsigned long timer_expires; 414 unsigned long timer_expires;
366 int timer_active; 415 int timer_active;
367 unsigned int ConState; /* State of connection */ 416 unsigned int ConState; /* State of connection */
368 struct reply_t *replystruct; 417 struct reply_t *replystruct;
369 int cid; 418 int cid;
370 int int_var[VAR_NUM]; /* see VAR_XXXX */ 419 int int_var[VAR_NUM]; /* see VAR_XXXX */
371 char *str_var[STR_NUM]; /* see STR_XXXX */ 420 char *str_var[STR_NUM]; /* see STR_XXXX */
372 unsigned pending_commands; /* see PC_XXXX */ 421 unsigned pending_commands; /* see PC_XXXX */
373 atomic_t seq_index; 422 atomic_t seq_index;
374 423
375 struct cardstate *cs; 424 struct cardstate *cs;
376 struct bc_state *bcs; 425 struct bc_state *bcs;
377}; 426};
378 427
379struct resp_type_t { 428struct resp_type_t {
380 unsigned char *response; 429 unsigned char *response;
381 int resp_code; /* RSP_XXXX */ 430 int resp_code; /* RSP_XXXX */
382 int type; /* RT_XXXX */ 431 int type; /* RT_XXXX */
383};
384
385struct prot_skb {
386 atomic_t empty;
387 struct semaphore *sem;
388 struct sk_buff *skb;
389}; 432};
390 433
391struct event_t { 434struct event_t {
@@ -398,29 +441,29 @@ struct event_t {
398 441
399/* This buffer holds all information about the used B-Channel */ 442/* This buffer holds all information about the used B-Channel */
400struct bc_state { 443struct bc_state {
401 struct sk_buff *tx_skb; /* Current transfer buffer to modem */ 444 struct sk_buff *tx_skb; /* Current transfer buffer to modem */
402 struct sk_buff_head squeue; /* B-Channel send Queue */ 445 struct sk_buff_head squeue; /* B-Channel send Queue */
403 446
404 /* Variables for debugging .. */ 447 /* Variables for debugging .. */
405 int corrupted; /* Counter for corrupted packages */ 448 int corrupted; /* Counter for corrupted packages */
406 int trans_down; /* Counter of packages (downstream) */ 449 int trans_down; /* Counter of packages (downstream) */
407 int trans_up; /* Counter of packages (upstream) */ 450 int trans_up; /* Counter of packages (upstream) */
408 451
409 struct at_state_t at_state; 452 struct at_state_t at_state;
410 unsigned long rcvbytes; 453 unsigned long rcvbytes;
411 454
412 __u16 fcs; 455 __u16 fcs;
413 struct sk_buff *skb; 456 struct sk_buff *skb;
414 int inputstate; /* see INS_XXXX */ 457 int inputstate; /* see INS_XXXX */
415 458
416 int channel; 459 int channel;
417 460
418 struct cardstate *cs; 461 struct cardstate *cs;
419 462
420 unsigned chstate; /* bitmap (CHS_*) */ 463 unsigned chstate; /* bitmap (CHS_*) */
421 int ignore; 464 int ignore;
422 unsigned proto2; /* Layer 2 protocol (ISDN_PROTO_L2_*) */ 465 unsigned proto2; /* Layer 2 protocol (ISDN_PROTO_L2_*) */
423 char *commands[AT_NUM]; /* see AT_XXXX */ 466 char *commands[AT_NUM]; /* see AT_XXXX */
424 467
425#ifdef CONFIG_GIGASET_DEBUG 468#ifdef CONFIG_GIGASET_DEBUG
426 int emptycount; 469 int emptycount;
@@ -430,9 +473,9 @@ struct bc_state {
430 473
431 /* hardware drivers */ 474 /* hardware drivers */
432 union { 475 union {
433 struct ser_bc_state *ser; /* private data of serial hardware driver */ 476 struct ser_bc_state *ser; /* serial hardware driver */
434 struct usb_bc_state *usb; /* private data of usb hardware driver */ 477 struct usb_bc_state *usb; /* usb hardware driver (m105) */
435 struct bas_bc_state *bas; 478 struct bas_bc_state *bas; /* usb hardware driver (base) */
436 } hw; 479 } hw;
437}; 480};
438 481
@@ -443,22 +486,23 @@ struct cardstate {
443 const struct gigaset_ops *ops; 486 const struct gigaset_ops *ops;
444 487
445 /* Stuff to handle communication */ 488 /* Stuff to handle communication */
446 //wait_queue_head_t initwait;
447 wait_queue_head_t waitqueue; 489 wait_queue_head_t waitqueue;
448 int waiting; 490 int waiting;
449 atomic_t mode; /* see M_XXXX */ 491 atomic_t mode; /* see M_XXXX */
450 atomic_t mstate; /* Modem state: see MS_XXXX */ 492 atomic_t mstate; /* Modem state: see MS_XXXX */
451 /* only changed by the event layer */ 493 /* only changed by the event layer */
452 int cmd_result; 494 int cmd_result;
453 495
454 int channels; 496 int channels;
455 struct bc_state *bcs; /* Array of struct bc_state */ 497 struct bc_state *bcs; /* Array of struct bc_state */
456 498
457 int onechannel; /* data and commands transmitted in one stream (M10x) */ 499 int onechannel; /* data and commands transmitted in one
500 stream (M10x) */
458 501
459 spinlock_t lock; 502 spinlock_t lock;
460 struct at_state_t at_state; /* at_state_t for cid == 0 */ 503 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 */ 504 struct list_head temp_at_states;/* list of temporary "struct
505 at_state_t"s without B channel */
462 506
463 struct inbuf_t *inbuf; 507 struct inbuf_t *inbuf;
464 508
@@ -474,36 +518,47 @@ struct cardstate {
474 unsigned fwver[4]; 518 unsigned fwver[4];
475 int gotfwver; 519 int gotfwver;
476 520
477 atomic_t running; /* !=0 if events are handled */ 521 atomic_t running; /* !=0 if events are handled */
478 atomic_t connected; /* !=0 if hardware is connected */ 522 atomic_t connected; /* !=0 if hardware is connected */
479 523
480 atomic_t cidmode; 524 atomic_t cidmode;
481 525
482 int myid; /* id for communication with LL */ 526 int myid; /* id for communication with LL */
483 isdn_if iif; 527 isdn_if iif;
484 528
485 struct reply_t *tabnocid; 529 struct reply_t *tabnocid;
486 struct reply_t *tabcid; 530 struct reply_t *tabcid;
487 int cs_init; 531 int cs_init;
488 int ignoreframes; /* frames to ignore after setting up the B channel */ 532 int ignoreframes; /* frames to ignore after setting up the
489 struct semaphore sem; /* locks this structure: */ 533 B channel */
490 /* connected is not changed, */ 534 struct semaphore sem; /* locks this structure: */
491 /* hardware_up is not changed, */ 535 /* connected is not changed, */
492 /* MState is not changed to or from MS_LOCKED */ 536 /* hardware_up is not changed, */
537 /* MState is not changed to or from
538 MS_LOCKED */
493 539
494 struct timer_list timer; 540 struct timer_list timer;
495 int retry_count; 541 int retry_count;
496 int dle; /* !=0 if modem commands/responses are dle encoded */ 542 int dle; /* !=0 if modem commands/responses are
497 int cur_at_seq; /* sequence of AT commands being processed */ 543 dle encoded */
498 int curchannel; /* channel, those commands are meant for */ 544 int cur_at_seq; /* sequence of AT commands being
499 atomic_t commands_pending; /* flag(s) in xxx.commands_pending have been set */ 545 processed */
500 struct tasklet_struct event_tasklet; /* tasklet for serializing AT commands. Scheduled 546 int curchannel; /* channel, those commands are meant
501 * -> for modem reponses (and incomming data for M10x) 547 for */
502 * -> on timeout 548 atomic_t commands_pending; /* flag(s) in xxx.commands_pending have
503 * -> after setting bits in xxx.at_state.pending_command 549 been set */
504 * (e.g. command from LL) */ 550 struct tasklet_struct event_tasklet;
505 struct tasklet_struct write_tasklet; /* tasklet for serial output 551 /* tasklet for serializing AT commands.
506 * (not used in base driver) */ 552 * Scheduled
553 * -> for modem reponses (and
554 * incomming data for M10x)
555 * -> on timeout
556 * -> after setting bits in
557 * xxx.at_state.pending_command
558 * (e.g. command from LL) */
559 struct tasklet_struct write_tasklet;
560 /* tasklet for serial output
561 * (not used in base driver) */
507 562
508 /* event queue */ 563 /* event queue */
509 struct event_t events[MAX_EVENTS]; 564 struct event_t events[MAX_EVENTS];
@@ -516,16 +571,15 @@ struct cardstate {
516 571
517 /* hardware drivers */ 572 /* hardware drivers */
518 union { 573 union {
519 struct usb_cardstate *usb; /* private data of USB hardware driver */ 574 struct usb_cardstate *usb; /* USB hardware driver (m105) */
520 struct ser_cardstate *ser; /* private data of serial hardware driver */ 575 struct ser_cardstate *ser; /* serial hardware driver */
521 struct bas_cardstate *bas; /* private data of base hardware driver */ 576 struct bas_cardstate *bas; /* USB hardware driver (base) */
522 } hw; 577 } hw;
523}; 578};
524 579
525struct gigaset_driver { 580struct gigaset_driver {
526 struct list_head list; 581 struct list_head list;
527 spinlock_t lock; /* locks minor tables and blocked */ 582 spinlock_t lock; /* locks minor tables and blocked */
528 //struct semaphore sem; /* locks this structure */
529 struct tty_driver *tty; 583 struct tty_driver *tty;
530 unsigned have_tty; 584 unsigned have_tty;
531 unsigned minor; 585 unsigned minor;
@@ -553,7 +607,8 @@ struct bas_bc_state {
553 struct isow_urbctx_t isoouturbs[BAS_OUTURBS]; 607 struct isow_urbctx_t isoouturbs[BAS_OUTURBS];
554 struct isow_urbctx_t *isooutdone, *isooutfree, *isooutovfl; 608 struct isow_urbctx_t *isooutdone, *isooutfree, *isooutovfl;
555 struct isowbuf_t *isooutbuf; 609 struct isowbuf_t *isooutbuf;
556 unsigned numsub; /* submitted URB counter (for diagnostic messages only) */ 610 unsigned numsub; /* submitted URB counter (for
611 diagnostic messages only) */
557 struct tasklet_struct sent_tasklet; 612 struct tasklet_struct sent_tasklet;
558 613
559 /* isochronous input state */ 614 /* isochronous input state */
@@ -563,24 +618,31 @@ struct bas_bc_state {
563 struct urb *isoindone; /* completed isoc read URB */ 618 struct urb *isoindone; /* completed isoc read URB */
564 int loststatus; /* status of dropped URB */ 619 int loststatus; /* status of dropped URB */
565 unsigned isoinlost; /* number of bytes lost */ 620 unsigned isoinlost; /* number of bytes lost */
566 /* state of bit unstuffing algorithm (in addition to BC_state.inputstate) */ 621 /* state of bit unstuffing algorithm (in addition to
567 unsigned seqlen; /* number of '1' bits not yet unstuffed */ 622 BC_state.inputstate) */
568 unsigned inbyte, inbits; /* collected bits for next byte */ 623 unsigned seqlen; /* number of '1' bits not yet
624 unstuffed */
625 unsigned inbyte, inbits; /* collected bits for next byte
626 */
569 /* statistics */ 627 /* statistics */
570 unsigned goodbytes; /* bytes correctly received */ 628 unsigned goodbytes; /* bytes correctly received */
571 unsigned alignerrs; /* frames with incomplete byte at end */ 629 unsigned alignerrs; /* frames with incomplete byte
630 at end */
572 unsigned fcserrs; /* FCS errors */ 631 unsigned fcserrs; /* FCS errors */
573 unsigned frameerrs; /* framing errors */ 632 unsigned frameerrs; /* framing errors */
574 unsigned giants; /* long frames */ 633 unsigned giants; /* long frames */
575 unsigned runts; /* short frames */ 634 unsigned runts; /* short frames */
576 unsigned aborts; /* HDLC aborts */ 635 unsigned aborts; /* HDLC aborts */
577 unsigned shared0s; /* '0' bits shared between flags */ 636 unsigned shared0s; /* '0' bits shared between flags
578 unsigned stolen0s; /* '0' stuff bits also serving as leading flag bits */ 637 */
638 unsigned stolen0s; /* '0' stuff bits also serving
639 as leading flag bits */
579 struct tasklet_struct rcvd_tasklet; 640 struct tasklet_struct rcvd_tasklet;
580}; 641};
581 642
582struct gigaset_ops { 643struct gigaset_ops {
583 /* Called from ev-layer.c/interface.c for sending AT commands to the device */ 644 /* Called from ev-layer.c/interface.c for sending AT commands to the
645 device */
584 int (*write_cmd)(struct cardstate *cs, 646 int (*write_cmd)(struct cardstate *cs,
585 const unsigned char *buf, int len, 647 const unsigned char *buf, int len,
586 struct tasklet_struct *wake_tasklet); 648 struct tasklet_struct *wake_tasklet);
@@ -604,7 +666,8 @@ struct gigaset_ops {
604 /* Called by gigaset_freecs() for freeing bcs->hw.xxx */ 666 /* Called by gigaset_freecs() for freeing bcs->hw.xxx */
605 int (*freebcshw)(struct bc_state *bcs); 667 int (*freebcshw)(struct bc_state *bcs);
606 668
607 /* Called by gigaset_stop() or gigaset_bchannel_down() for resetting bcs->hw.xxx */ 669 /* Called by gigaset_stop() or gigaset_bchannel_down() for resetting
670 bcs->hw.xxx */
608 void (*reinitbcshw)(struct bc_state *bcs); 671 void (*reinitbcshw)(struct bc_state *bcs);
609 672
610 /* Called by gigaset_initcs() for setting up cs->hw.xxx */ 673 /* Called by gigaset_initcs() for setting up cs->hw.xxx */
@@ -613,13 +676,10 @@ struct gigaset_ops {
613 /* Called by gigaset_freecs() for freeing cs->hw.xxx */ 676 /* Called by gigaset_freecs() for freeing cs->hw.xxx */
614 void (*freecshw)(struct cardstate *cs); 677 void (*freecshw)(struct cardstate *cs);
615 678
616 ///* Called by gigaset_stop() for killing URBs, shutting down the device, ... 679 /* 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 680 control */
618 // !=0: hardware still up */ 681 int (*set_modem_ctrl)(struct cardstate *cs, unsigned old_state,
619 //void (*stophw)(struct cardstate *cs, int hardwareup); 682 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); 683 int (*baud_rate)(struct cardstate *cs, unsigned cflag);
624 int (*set_line_ctrl)(struct cardstate *cs, unsigned cflag); 684 int (*set_line_ctrl)(struct cardstate *cs, unsigned cflag);
625 685
@@ -667,7 +727,8 @@ void gigaset_isoc_input(struct inbuf_t *inbuf);
667 727
668/* Called from bas-gigaset.c to process a block of data 728/* Called from bas-gigaset.c to process a block of data
669 * received through the isochronous channel */ 729 * received through the isochronous channel */
670void gigaset_isoc_receive(unsigned char *src, unsigned count, struct bc_state *bcs); 730void gigaset_isoc_receive(unsigned char *src, unsigned count,
731 struct bc_state *bcs);
671 732
672/* Called from bas-gigaset.c to put a block of data 733/* Called from bas-gigaset.c to put a block of data
673 * into the isochronous output buffer */ 734 * into the isochronous output buffer */
@@ -763,7 +824,8 @@ struct cardstate *gigaset_getunassignedcs(struct gigaset_driver *drv);
763void gigaset_unassign(struct cardstate *cs); 824void gigaset_unassign(struct cardstate *cs);
764void gigaset_blockdriver(struct gigaset_driver *drv); 825void gigaset_blockdriver(struct gigaset_driver *drv);
765 826
766/* Allocate and initialize card state. Calls hardware dependent gigaset_init[b]cs(). */ 827/* Allocate and initialize card state. Calls hardware dependent
828 gigaset_init[b]cs(). */
767struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, 829struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
768 int onechannel, int ignoreframes, 830 int onechannel, int ignoreframes,
769 int cidmode, const char *modulename); 831 int cidmode, const char *modulename);