Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 1
/*****************************************************************************
2
* wanpipe.h     WANPIPE(tm) Multiprotocol WAN Link Driver.
3
*               User-level API definitions.
4
*
5
* Author:       Nenad Corbic <ncorbic@sangoma.com>
6
*               Gideon Hack    
7
*
8
* Copyright:    (c) 1995-2000 Sangoma Technologies Inc.
9
*
10
*               This program is free software; you can redistribute it and/or
11
*               modify it under the terms of the GNU General Public License
12
*               as published by the Free Software Foundation; either version
13
*               2 of the License, or (at your option) any later version.
14
* ============================================================================
15
* Nov 3,  2000  Nenad Corbic    Added config_id to sdla_t structure.
16
*                               Used to determine the protocol running.
17
* Jul 13, 2000  Nenad Corbic    Added SyncPPP Support
18
* Feb 24, 2000  Nenad Corbic    Added support for x25api driver
19
* Oct 04, 1999  Nenad Corbic    New CHDLC and FRAME RELAY code, SMP support
20
* Jun 02, 1999  Gideon Hack     Added 'update_call_count' for Cisco HDLC
21
*                               support
22
* Jun 26, 1998  David Fong      Added 'ip_mode' in sdla_t.u.p for dynamic IP
23
*                               routing mode configuration
24
* Jun 12, 1998  David Fong      Added Cisco HDLC union member in sdla_t
25
* Dec 08, 1997  Jaspreet Singh  Added 'authenticator' in union of 'sdla_t'
26
* Nov 26, 1997  Jaspreet Singh  Added 'load_sharing' structure.  Also added
27
*                               'devs_struct','dev_to_devtint_next' to 'sdla_t'
28
* Nov 24, 1997  Jaspreet Singh  Added 'irq_dis_if_send_count',
29
*                               'irq_dis_poll_count' to 'sdla_t'.
30
* Nov 06, 1997  Jaspreet Singh  Added a define called 'INTR_TEST_MODE'
31
* Oct 20, 1997  Jaspreet Singh  Added 'buff_intr_mode_unbusy' and
32
*                               'dlci_intr_mode_unbusy' to 'sdla_t'
33
* Oct 18, 1997  Jaspreet Singh  Added structure to maintain global driver
34
*                               statistics.
35
* Jan 15, 1997  Gene Kozin      Version 3.1.0
36
*                                o added UDP management stuff
37
* Jan 02, 1997  Gene Kozin      Version 3.0.0
38
*****************************************************************************/
39
#ifndef _WANPIPE_H
40
#define _WANPIPE_H
41
 
42
#include <linux/wanrouter.h>
43
 
44
/* Defines */
45
 
46
#ifndef PACKED
47
#define PACKED  __attribute__((packed))
48
#endif
49
 
50
#define WANPIPE_MAGIC   0x414C4453L     /* signature: 'SDLA' reversed */
51
 
52
/* IOCTL numbers (up to 16) */
53
#define WANPIPE_DUMP    (ROUTER_USER+0) /* dump adapter's memory */
54
#define WANPIPE_EXEC    (ROUTER_USER+1) /* execute firmware command */
55
 
56
#define TRACE_ALL                       0x00
57
#define TRACE_PROT                      0x01
58
#define TRACE_DATA                      0x02
59
 
60
/* values for request/reply byte */
61
#define UDPMGMT_REQUEST 0x01
62
#define UDPMGMT_REPLY   0x02
63
#define UDP_OFFSET      12
64
 
65
#define MAX_CMD_BUFF    10
66
#define MAX_X25_LCN     255     /* Maximum number of x25 channels */
67
#define MAX_LCN_NUM     4095    /* Maximum lcn number */
68
#define MAX_FT1_RETRY   100
69
 
70
#ifndef AF_WANPIPE
71
        #define AF_WANPIPE 25
72
        #ifndef PF_WANPIPE
73
                #define PF_WANPIPE AF_WANPIPE
74
        #endif
75
#endif
76
 
77
 
78
#define TX_TIMEOUT 5*HZ
79
 
80
/* General Critical Flags */
81
#define SEND_CRIT       0x00
82
#define PERI_CRIT       0x01
83
 
84
/* Chdlc and PPP polling critical flag */
85
#define POLL_CRIT       0x03
86
 
87
/* Frame Relay Tx IRQ send critical flag */
88
#define SEND_TXIRQ_CRIT 0x02
89
 
90
/* Frame Relay ARP critical flag */
91
#define ARP_CRIT        0x03
92
 
93
/* Bit maps for dynamic interface configuration
94
 * DYN_OPT_ON : turns this option on/off
95
 * DEV_DOWN   : device was shutdown by the driver not
96
 *              by user
97
 */
98
#define DYN_OPT_ON      0x00
99
#define DEV_DOWN        0x01
100
 
101
/*
102
 * Data structures for IOCTL calls.
103
 */
104
 
105
typedef struct sdla_dump        /* WANPIPE_DUMP */
106
{
107
        unsigned long magic;    /* for verification */
108
        unsigned long offset;   /* absolute adapter memory address */
109
        unsigned long length;   /* block length */
110
        void* ptr;              /* -> buffer */
111
} sdla_dump_t;
112
 
113
typedef struct sdla_exec        /* WANPIPE_EXEC */
114
{
115
        unsigned long magic;    /* for verification */
116
        void* cmd;              /* -> command structure */
117
        void* data;             /* -> data buffer */
118
} sdla_exec_t;
119
 
120
/* UDP management stuff */
121
 
122
typedef struct wum_header
123
{
124
        unsigned char signature[8];     /* 00h: signature */
125
        unsigned char type;             /* 08h: request/reply */
126
        unsigned char command;          /* 09h: commnand */
127
        unsigned char reserved[6];      /* 0Ah: reserved */
128
} wum_header_t;
129
 
130
/*************************************************************************
131
 Data Structure for global statistics
132
*************************************************************************/
133
 
134
typedef struct global_stats
135
{
136
        unsigned long isr_entry;
137
        unsigned long isr_already_critical;            
138
        unsigned long isr_rx;
139
        unsigned long isr_tx;
140
        unsigned long isr_intr_test;
141
        unsigned long isr_spurious;
142
        unsigned long isr_enable_tx_int;
143
        unsigned long rx_intr_corrupt_rx_bfr;
144
        unsigned long rx_intr_on_orphaned_DLCI;
145
        unsigned long rx_intr_dev_not_started;
146
        unsigned long tx_intr_dev_not_started;
147
        unsigned long poll_entry;
148
        unsigned long poll_already_critical;
149
        unsigned long poll_processed;
150
        unsigned long poll_tbusy_bad_status;
151
        unsigned long poll_host_disable_irq;
152
        unsigned long poll_host_enable_irq;
153
 
154
} global_stats_t;
155
 
156
 
157
typedef struct{
158
        unsigned short  udp_src_port            PACKED;
159
        unsigned short  udp_dst_port            PACKED;
160
        unsigned short  udp_length              PACKED;
161
        unsigned short  udp_checksum            PACKED;
162
} udp_pkt_t;
163
 
164
 
165
typedef struct {
166
        unsigned char   ver_inet_hdr_length     PACKED;
167
        unsigned char   service_type            PACKED;
168
        unsigned short  total_length            PACKED;
169
        unsigned short  identifier              PACKED;
170
        unsigned short  flags_frag_offset       PACKED;
171
        unsigned char   ttl                     PACKED;
172
        unsigned char   protocol                PACKED;
173
        unsigned short  hdr_checksum            PACKED;
174
        unsigned long   ip_src_address          PACKED;
175
        unsigned long   ip_dst_address          PACKED;
176
} ip_pkt_t;
177
 
178
 
179
typedef struct {
180
        unsigned char           signature[8]    PACKED;
181
        unsigned char           request_reply   PACKED;
182
        unsigned char           id              PACKED;
183
        unsigned char           reserved[6]     PACKED;
184
} wp_mgmt_t;
185
 
186
/*************************************************************************
187
 Data Structure for if_send  statistics
188
*************************************************************************/  
189
typedef struct if_send_stat{
190
        unsigned long if_send_entry;
191
        unsigned long if_send_skb_null;
192
        unsigned long if_send_broadcast;
193
        unsigned long if_send_multicast;
194
        unsigned long if_send_critical_ISR;
195
        unsigned long if_send_critical_non_ISR;
196
        unsigned long if_send_tbusy;
197
        unsigned long if_send_tbusy_timeout;
198
        unsigned long if_send_PIPE_request;
199
        unsigned long if_send_wan_disconnected;
200
        unsigned long if_send_dlci_disconnected;
201
        unsigned long if_send_no_bfrs;
202
        unsigned long if_send_adptr_bfrs_full;
203
        unsigned long if_send_bfr_passed_to_adptr;
204
        unsigned long if_send_protocol_error;
205
        unsigned long if_send_bfr_not_passed_to_adptr;
206
        unsigned long if_send_tx_int_enabled;
207
        unsigned long if_send_consec_send_fail;
208
} if_send_stat_t;
209
 
210
typedef struct rx_intr_stat{
211
        unsigned long rx_intr_no_socket;
212
        unsigned long rx_intr_dev_not_started;
213
        unsigned long rx_intr_PIPE_request;
214
        unsigned long rx_intr_bfr_not_passed_to_stack;
215
        unsigned long rx_intr_bfr_passed_to_stack;
216
} rx_intr_stat_t;      
217
 
218
typedef struct pipe_mgmt_stat{
219
        unsigned long UDP_PIPE_mgmt_kmalloc_err;
220
        unsigned long UDP_PIPE_mgmt_direction_err;
221
        unsigned long UDP_PIPE_mgmt_adptr_type_err;
222
        unsigned long UDP_PIPE_mgmt_adptr_cmnd_OK;
223
        unsigned long UDP_PIPE_mgmt_adptr_cmnd_timeout;
224
        unsigned long UDP_PIPE_mgmt_adptr_send_passed;
225
        unsigned long UDP_PIPE_mgmt_adptr_send_failed;
226
        unsigned long UDP_PIPE_mgmt_not_passed_to_stack;
227
        unsigned long UDP_PIPE_mgmt_passed_to_stack;
228
        unsigned long UDP_PIPE_mgmt_no_socket;
229
        unsigned long UDP_PIPE_mgmt_passed_to_adptr;
230
} pipe_mgmt_stat_t;
231
 
232
 
233
typedef struct {
234
        struct sk_buff *skb;
235
} bh_data_t, cmd_data_t;
236
 
237
#define MAX_LGTH_UDP_MGNT_PKT 2000
238
 
239
 
240
/* This is used for interrupt testing */
241
#define INTR_TEST_MODE  0x02
242
 
243
#define WUM_SIGNATURE_L 0x50495046
244
#define WUM_SIGNATURE_H 0x444E3845
245
 
246
#define WUM_KILL        0x50
247
#define WUM_EXEC        0x51
248
 
249
#define WANPIPE         0x00
250
#define API             0x01
251
#define BRIDGE          0x02
252
#define BRIDGE_NODE     0x03
253
 
254
#ifdef  __KERNEL__
255
/****** Kernel Interface ****************************************************/
256
 
257
#include <linux/sdladrv.h>      /* SDLA support module API definitions */
258
#include <linux/sdlasfm.h>      /* SDLA firmware module definitions */
259
#include <linux/workqueue.h>
260
#include <linux/serial.h>
261
#include <linux/serialP.h>
262
#include <linux/serial_reg.h>
263
#include <asm/serial.h>
264
#include <linux/tty.h>
265
#include <linux/tty_driver.h>
266
#include <linux/tty_flip.h>
267
 
268
 
269
#define is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0)
270
#define is_alpha(ch) ((((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'z')||\
271
                  ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'Z'))?1:0)
272
#define is_hex_digit(ch) ((((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')||\
273
                  ((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'f')||\
274
                  ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'F'))?1:0)
275
 
276
 
277
/****** Data Structures *****************************************************/
278
 
279
/* Adapter Data Space.
280
 * This structure is needed because we handle multiple cards, otherwise
281
 * static data would do it.
282
 */
283
typedef struct sdla
284
{
285
        char devname[WAN_DRVNAME_SZ+1]; /* card name */
286
        sdlahw_t hw;                    /* hardware configuration */
287
        struct wan_device wandev;       /* WAN device data space */
288
 
289
        unsigned open_cnt;              /* number of open interfaces */
290
        unsigned long state_tick;       /* link state timestamp */
291
        unsigned intr_mode;             /* Type of Interrupt Mode */
292
        char in_isr;                    /* interrupt-in-service flag */
293
        char buff_int_mode_unbusy;      /* flag for carrying out dev_tint */  
294
        char dlci_int_mode_unbusy;      /* flag for carrying out dev_tint */
295
        long configured;                /* flag for previous configurations */
296
 
297
        unsigned short irq_dis_if_send_count; /* Disabling irqs in if_send*/
298
        unsigned short irq_dis_poll_count;   /* Disabling irqs in poll routine*/
299
        unsigned short force_enable_irq;
300
        char TracingEnabled;            /* flag for enabling trace */
301
        global_stats_t statistics;      /* global statistics */
302
        void* mbox;                     /* -> mailbox */
303
        void* rxmb;                     /* -> receive mailbox */
304
        void* flags;                    /* -> adapter status flags */
305
        void (*isr)(struct sdla* card); /* interrupt service routine */
306
        void (*poll)(struct sdla* card); /* polling routine */
307
        int (*exec)(struct sdla* card, void* u_cmd, void* u_data);
308
                                        /* Used by the listen() system call */         
309
        /* Wanpipe Socket Interface */
310
        int   (*func) (struct sk_buff *, struct sock *);
311
        struct sock *sk;
312
 
313
        /* Shutdown function */
314
        void (*disable_comm) (struct sdla *card);
315
 
316
        /* Secondary Port Device: Piggibacking */
317
        struct sdla *next;
318
 
319
        /* TTY driver variables */
320
        unsigned char tty_opt;
321
        struct tty_struct *tty;
322
        unsigned int tty_minor;
323
        unsigned int tty_open;
324
        unsigned char *tty_buf;
325
        unsigned char *tty_rx;
326
        struct work_struct tty_work;
327
 
328
        union
329
        {
330
                struct
331
                {                       /****** X.25 specific data **********/
332
                        u32 lo_pvc;
333
                        u32 hi_pvc;
334
                        u32 lo_svc;
335
                        u32 hi_svc;
336
                        struct net_device *svc_to_dev_map[MAX_X25_LCN];
337
                        struct net_device *pvc_to_dev_map[MAX_X25_LCN];
338
                        struct net_device *tx_dev;
339
                        struct net_device *cmd_dev;
340
                        u32 no_dev;
341
                        volatile u8 *hdlc_buf_status;
342
                        u32 tx_interrupts_pending;
343
                        u16 timer_int_enabled;
344
                        struct net_device *poll_device;
345
                        atomic_t command_busy;
346
 
347
                        u16 udp_pkt_lgth;
348
                        u32 udp_type;
349
                        u8  udp_pkt_src;
350
                        u32 udp_lcn;
351
                        struct net_device *udp_dev;
352
                        s8 udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
353
 
354
                        u8 LAPB_hdlc;           /* Option to turn off X25 and run only LAPB */
355
                        u8 logging;             /* Option to log call messages */
356
                        u8 oob_on_modem;        /* Option to send modem status to the api */
357
                        u16 num_of_ch;          /* Number of channels configured by the user */
358
 
359
                        struct work_struct x25_poll_work;
360
                        struct timer_list x25_timer;
361
                } x;
362
                struct
363
                {                       /****** frame relay specific data ***/
364
                        void* rxmb_base;        /* -> first Rx buffer */
365
                        void* rxmb_last;        /* -> last Rx buffer */
366
                        unsigned rx_base;       /* S508 receive buffer base */
367
                        unsigned rx_top;        /* S508 receive buffer end */
368
                        unsigned short node_dlci[100];
369
                        unsigned short dlci_num;
370
                        struct net_device *dlci_to_dev_map[991 + 1];
371
                        unsigned tx_interrupts_pending;
372
                        unsigned short timer_int_enabled;
373
                        unsigned short udp_pkt_lgth;
374
                        int udp_type;
375
                        char udp_pkt_src;
376
                        unsigned udp_dlci;
377
                        char udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
378
                        void* trc_el_base;                      /* first trace element */
379
                        void* trc_el_last;                      /* last trace element */
380
                        void *curr_trc_el;                      /* current trace element */
381
                        unsigned short trc_bfr_space;           /* trace buffer space */
382
                        unsigned char  update_comms_stats;
383
                        struct net_device *arp_dev;
384
                        spinlock_t if_send_lock;
385
                } f;
386
                struct                  /****** PPP-specific data ***********/
387
                {
388
                        char if_name[WAN_IFNAME_SZ+1];  /* interface name */
389
                        void* txbuf;            /* -> current Tx buffer */
390
                        void* txbuf_base;       /* -> first Tx buffer */
391
                        void* txbuf_last;       /* -> last Tx buffer */
392
                        void* rxbuf_base;       /* -> first Rx buffer */
393
                        void* rxbuf_last;       /* -> last Rx buffer */
394
                        unsigned rx_base;       /* S508 receive buffer base */
395
                        unsigned rx_top;        /* S508 receive buffer end */
396
                        char ip_mode;           /* STATIC/HOST/PEER IP Mode */
397
                        char authenticator;     /* Authenticator for PAP/CHAP */
398
                        unsigned char comm_enabled; /* Is comm enabled or not */
399
                        unsigned char peer_route;   /* Process Peer Route */   
400
                        unsigned long *txbuf_next;  /* Next Tx buffer to use */
401
                        unsigned long *rxbuf_next;  /* Next Rx buffer to use */
402
                } p;
403
                struct                  /* Cisco HDLC-specific data */
404
                {
405
                        char if_name[WAN_IFNAME_SZ+1];  /* interface name */
406
                        unsigned char comm_port;/* Communication Port O or 1 */
407
                        unsigned char usedby;  /* Used by WANPIPE or API */
408
                        void* rxmb;             /* Receive mail box */
409
                        void* flags;            /* flags */
410
                        void* tx_status;        /* Tx status element */
411
                        void* rx_status;        /* Rx status element */
412
                        void* txbuf;            /* -> current Tx buffer */
413
                        void* txbuf_base;       /* -> first Tx buffer */
414
                        void* txbuf_last;       /* -> last Tx buffer */
415
                        void* rxbuf_base;       /* -> first Rx buffer */
416
                        void* rxbuf_last;       /* -> last Rx buffer */
417
                        unsigned rx_base;       /* S508 receive buffer base */
418
                        unsigned rx_top;        /* S508 receive buffer end */
419
                        unsigned char receive_only; /* high speed receivers */
420
                        unsigned short protocol_options;
421
                        unsigned short kpalv_tx;        /* Tx kpalv timer */
422
                        unsigned short kpalv_rx;        /* Rx kpalv timer */
423
                        unsigned short kpalv_err;       /* Error tolerance */
424
                        unsigned short slarp_timer;     /* SLARP req timer */
425
                        unsigned state;                 /* state of the link */
426
                        unsigned char api_status;
427
                        unsigned char update_call_count;
428
                        unsigned short api_options;     /* for async config */
429
                        unsigned char  async_mode;
430
                        unsigned short tx_bits_per_char;
431
                        unsigned short rx_bits_per_char;
432
                        unsigned short stop_bits;
433
                        unsigned short parity;
434
                        unsigned short break_timer;
435
                        unsigned short inter_char_timer;
436
                        unsigned short rx_complete_length;
437
                        unsigned short xon_char;
438
                        unsigned short xoff_char;
439
                        unsigned char comm_enabled; /* Is comm enabled or not */
440
                        unsigned char backup;
441
                } c;
442
                struct
443
                {
444
                        void* tx_status;        /* Tx status element */
445
                        void* rx_status;        /* Rx status element */
446
                        void* trace_status;     /* Trace status element */
447
                        void* txbuf;            /* -> current Tx buffer */
448
                        void* txbuf_base;       /* -> first Tx buffer */
449
                        void* txbuf_last;       /* -> last Tx buffer */
450
                        void* rxbuf_base;       /* -> first Rx buffer */
451
                        void* rxbuf_last;       /* -> last Rx buffer */
452
                        void* tracebuf;         /* -> current Trace buffer */
453
                        void* tracebuf_base;    /* -> current Trace buffer */
454
                        void* tracebuf_last;    /* -> current Trace buffer */
455
                        unsigned rx_base;       /* receive buffer base */
456
                        unsigned rx_end;        /* receive buffer end */
457
                        unsigned trace_base;    /* trace buffer base */
458
                        unsigned trace_end;     /* trace buffer end */
459
 
460
                } h;
461
        } u;
462
} sdla_t;
463
 
464
/****** Public Functions ****************************************************/
465
 
466
void wanpipe_open      (sdla_t* card);                  /* wpmain.c */
467
void wanpipe_close     (sdla_t* card);                  /* wpmain.c */
468
void wanpipe_set_state (sdla_t* card, int state);       /* wpmain.c */
469
 
470
int wpx_init (sdla_t* card, wandev_conf_t* conf);       /* wpx.c */
471
int wpf_init (sdla_t* card, wandev_conf_t* conf);       /* wpf.c */
472
int wpp_init (sdla_t* card, wandev_conf_t* conf);       /* wpp.c */
473
int wpc_init (sdla_t* card, wandev_conf_t* conf); /* Cisco HDLC */
474
int bsc_init (sdla_t* card, wandev_conf_t* conf);       /* BSC streaming */
475
int hdlc_init(sdla_t* card, wandev_conf_t* conf);       /* HDLC support */
476
int wpft1_init (sdla_t* card, wandev_conf_t* conf);     /* FT1 Config support */
477
int wsppp_init (sdla_t* card, wandev_conf_t* conf);     /* Sync PPP on top of RAW CHDLC */
478
 
479
extern sdla_t * wanpipe_find_card(char *);
480
extern sdla_t * wanpipe_find_card_num (int);
481
 
482
extern void wanpipe_queue_work (struct work_struct *);
483
extern void wanpipe_mark_bh (void);
484
extern void wakeup_sk_bh(struct net_device *dev);
485
extern int change_dev_flags(struct net_device *dev, unsigned flags);
486
extern unsigned long get_ip_address(struct net_device *dev, int option);
487
extern void add_gateway(sdla_t *card, struct net_device *dev);
488
 
489
 
490
#endif  /* __KERNEL__ */
491
#endif  /* _WANPIPE_H */
492