1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39#ifndef _WANPIPE_H
40#define _WANPIPE_H
41
42#include <linux/version.h>
43
44#ifndef KERNEL_VERSION
45 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
46#endif
47
48#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,0)
49
50 #define LINUX_2_4
51 #define netdevice_t struct net_device
52
53 #define FREE_READ 1
54 #define FREE_WRITE 0
55
56 #define stop_net_queue(a) netif_stop_queue(a)
57 #define start_net_queue(a) netif_start_queue(a)
58 #define is_queue_stopped(a) netif_queue_stopped(a)
59 #define wake_net_dev(a) netif_wake_queue(a)
60 #define is_dev_running(a) netif_running(a)
61 #define wan_dev_kfree_skb(a,b) dev_kfree_skb_any(a)
62
63
64#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
65
66 #define LINUX_2_1
67 #define netdevice_t struct device
68 #define FREE_READ 1
69 #define FREE_WRITE 0
70
71 #define stop_net_queue(a) (set_bit(0, &##a->tbusy))
72 #define start_net_queue(a) (clear_bit(0,&##a->tbusy))
73 #define is_queue_stopped(a) (##a->tbusy)
74 #define wake_net_dev(a) {clear_bit(0,&##a->tbusy);mark_bh(NET_BH);}
75 #define is_dev_running(a) (test_bit(0,&##a->start))
76 #define wan_dev_kfree_skb(a,b) dev_kfree_skb(a)
77
78#else
79 #define LINUX_2_0
80 #define netdevice_t struct device
81
82 #define test_and_set_bit set_bit
83 #define net_ratelimit() 1
84
85 #define stop_net_queue(a) (set_bit(0, &##a->tbusy))
86 #define start_net_queue(a) (clear_bit(0,&##a->tbusy))
87 #define is_queue_stopped(a) (##a->tbusy)
88 #define wake_net_dev(a) {clear_bit(0,&##a->tbusy);mark_bh(NET_BH);}
89 #define is_dev_running(a) (test_bit(0,(void*)&##a->start))
90 #define wan_dev_kfree_skb(a,b) dev_kfree_skb(a,b)
91 #define spin_lock_init(a)
92 #define spin_lock(a)
93 #define spin_unlock(a)
94#endif
95
96#include <linux/wanrouter.h>
97
98
99
100#ifndef PACKED
101#define PACKED __attribute__((packed))
102#endif
103
104#define WANPIPE_MAGIC 0x414C4453L
105
106
107#define WANPIPE_DUMP (ROUTER_USER+0)
108#define WANPIPE_EXEC (ROUTER_USER+1)
109
110#define TRACE_ALL 0x00
111#define TRACE_PROT 0x01
112#define TRACE_DATA 0x02
113
114
115#define UDPMGMT_REQUEST 0x01
116#define UDPMGMT_REPLY 0x02
117#define UDP_OFFSET 12
118
119#define MAX_CMD_BUFF 10
120#define MAX_X25_LCN 255
121#define MAX_LCN_NUM 4095
122#define MAX_FT1_RETRY 100
123
124#ifdef LINUX_2_4
125 #ifndef AF_WANPIPE
126 #define AF_WANPIPE 25
127 #ifndef PF_WANPIPE
128 #define PF_WANPIPE AF_WANPIPE
129 #endif
130 #endif
131
132#else
133 #ifndef AF_WANPIPE
134 #define AF_WANPIPE 24
135 #ifndef PF_WANPIPE
136 #define PF_WANPIPE AF_WANPIPE
137 #endif
138 #endif
139#endif
140
141
142#define TX_TIMEOUT 5*HZ
143
144
145#define SEND_CRIT 0x00
146#define PERI_CRIT 0x01
147
148
149#define POLL_CRIT 0x03
150
151
152#define SEND_TXIRQ_CRIT 0x02
153
154
155#define ARP_CRIT 0x03
156
157
158
159
160
161
162#define DYN_OPT_ON 0x00
163#define DEV_DOWN 0x01
164
165
166
167
168
169typedef struct sdla_dump
170{
171 unsigned long magic;
172 unsigned long offset;
173 unsigned long length;
174 void* ptr;
175} sdla_dump_t;
176
177typedef struct sdla_exec
178{
179 unsigned long magic;
180 void* cmd;
181 void* data;
182} sdla_exec_t;
183
184
185
186typedef struct wum_header
187{
188 unsigned char signature[8];
189 unsigned char type;
190 unsigned char command;
191 unsigned char reserved[6];
192} wum_header_t;
193
194
195
196
197
198typedef struct global_stats
199{
200 unsigned long isr_entry;
201 unsigned long isr_already_critical;
202 unsigned long isr_rx;
203 unsigned long isr_tx;
204 unsigned long isr_intr_test;
205 unsigned long isr_spurious;
206 unsigned long isr_enable_tx_int;
207 unsigned long rx_intr_corrupt_rx_bfr;
208 unsigned long rx_intr_on_orphaned_DLCI;
209 unsigned long rx_intr_dev_not_started;
210 unsigned long tx_intr_dev_not_started;
211 unsigned long poll_entry;
212 unsigned long poll_already_critical;
213 unsigned long poll_processed;
214 unsigned long poll_tbusy_bad_status;
215 unsigned long poll_host_disable_irq;
216 unsigned long poll_host_enable_irq;
217
218} global_stats_t;
219
220
221typedef struct{
222 unsigned short udp_src_port PACKED;
223 unsigned short udp_dst_port PACKED;
224 unsigned short udp_length PACKED;
225 unsigned short udp_checksum PACKED;
226} udp_pkt_t;
227
228
229typedef struct {
230 unsigned char ver_inet_hdr_length PACKED;
231 unsigned char service_type PACKED;
232 unsigned short total_length PACKED;
233 unsigned short identifier PACKED;
234 unsigned short flags_frag_offset PACKED;
235 unsigned char ttl PACKED;
236 unsigned char protocol PACKED;
237 unsigned short hdr_checksum PACKED;
238 unsigned long ip_src_address PACKED;
239 unsigned long ip_dst_address PACKED;
240} ip_pkt_t;
241
242
243typedef struct {
244 unsigned char signature[8] PACKED;
245 unsigned char request_reply PACKED;
246 unsigned char id PACKED;
247 unsigned char reserved[6] PACKED;
248} wp_mgmt_t;
249
250
251
252
253typedef struct if_send_stat{
254 unsigned long if_send_entry;
255 unsigned long if_send_skb_null;
256 unsigned long if_send_broadcast;
257 unsigned long if_send_multicast;
258 unsigned long if_send_critical_ISR;
259 unsigned long if_send_critical_non_ISR;
260 unsigned long if_send_tbusy;
261 unsigned long if_send_tbusy_timeout;
262 unsigned long if_send_PIPE_request;
263 unsigned long if_send_wan_disconnected;
264 unsigned long if_send_dlci_disconnected;
265 unsigned long if_send_no_bfrs;
266 unsigned long if_send_adptr_bfrs_full;
267 unsigned long if_send_bfr_passed_to_adptr;
268 unsigned long if_send_protocol_error;
269 unsigned long if_send_bfr_not_passed_to_adptr;
270 unsigned long if_send_tx_int_enabled;
271 unsigned long if_send_consec_send_fail;
272} if_send_stat_t;
273
274typedef struct rx_intr_stat{
275 unsigned long rx_intr_no_socket;
276 unsigned long rx_intr_dev_not_started;
277 unsigned long rx_intr_PIPE_request;
278 unsigned long rx_intr_bfr_not_passed_to_stack;
279 unsigned long rx_intr_bfr_passed_to_stack;
280} rx_intr_stat_t;
281
282typedef struct pipe_mgmt_stat{
283 unsigned long UDP_PIPE_mgmt_kmalloc_err;
284 unsigned long UDP_PIPE_mgmt_direction_err;
285 unsigned long UDP_PIPE_mgmt_adptr_type_err;
286 unsigned long UDP_PIPE_mgmt_adptr_cmnd_OK;
287 unsigned long UDP_PIPE_mgmt_adptr_cmnd_timeout;
288 unsigned long UDP_PIPE_mgmt_adptr_send_passed;
289 unsigned long UDP_PIPE_mgmt_adptr_send_failed;
290 unsigned long UDP_PIPE_mgmt_not_passed_to_stack;
291 unsigned long UDP_PIPE_mgmt_passed_to_stack;
292 unsigned long UDP_PIPE_mgmt_no_socket;
293 unsigned long UDP_PIPE_mgmt_passed_to_adptr;
294} pipe_mgmt_stat_t;
295
296
297typedef struct {
298 struct sk_buff *skb;
299} bh_data_t, cmd_data_t;
300
301#define MAX_LGTH_UDP_MGNT_PKT 2000
302
303
304
305#define INTR_TEST_MODE 0x02
306
307#define WUM_SIGNATURE_L 0x50495046
308#define WUM_SIGNATURE_H 0x444E3845
309
310#define WUM_KILL 0x50
311#define WUM_EXEC 0x51
312
313#define WANPIPE 0x00
314#define API 0x01
315#define BRIDGE 0x02
316#define BRIDGE_NODE 0x03
317
318#ifdef __KERNEL__
319
320
321#include <linux/sdladrv.h>
322#include <linux/sdlasfm.h>
323#include <linux/tqueue.h>
324#ifdef LINUX_2_4
325 #include <linux/serial.h>
326 #include <linux/serialP.h>
327 #include <linux/serial_reg.h>
328 #include <asm/serial.h>
329#endif
330#include <linux/tty.h>
331#include <linux/tty_driver.h>
332#include <linux/tty_flip.h>
333
334
335#define is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0)
336#define is_alpha(ch) ((((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'z')||\
337 ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'Z'))?1:0)
338#define is_hex_digit(ch) ((((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')||\
339 ((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'f')||\
340 ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'F'))?1:0)
341
342
343
344
345
346
347
348
349typedef struct sdla
350{
351 char devname[WAN_DRVNAME_SZ+1];
352 sdlahw_t hw;
353 wan_device_t wandev;
354
355 unsigned open_cnt;
356 unsigned long state_tick;
357 unsigned intr_mode;
358 char in_isr;
359 char buff_int_mode_unbusy;
360 char dlci_int_mode_unbusy;
361 char configured;
362
363 unsigned short irq_dis_if_send_count;
364 unsigned short irq_dis_poll_count;
365 unsigned short force_enable_irq;
366 char TracingEnabled;
367 global_stats_t statistics;
368 void* mbox;
369 void* rxmb;
370 void* flags;
371 void (*isr)(struct sdla* card);
372 void (*poll)(struct sdla* card);
373 int (*exec)(struct sdla* card, void* u_cmd, void* u_data);
374
375
376 int (*func) (struct sk_buff *, struct sock *);
377 struct sock *sk;
378
379
380 void (*disable_comm) (struct sdla *card);
381
382
383 struct sdla *next;
384
385
386 unsigned char tty_opt;
387 struct tty_struct *tty;
388 unsigned int tty_minor;
389 unsigned int tty_open;
390 unsigned char *tty_buf;
391 unsigned char *tty_rx;
392 struct tq_struct tty_task_queue;
393
394 union
395 {
396 struct
397 {
398 u32 lo_pvc;
399 u32 hi_pvc;
400 u32 lo_svc;
401 u32 hi_svc;
402 netdevice_t *svc_to_dev_map[MAX_X25_LCN];
403 netdevice_t *pvc_to_dev_map[MAX_X25_LCN];
404 netdevice_t *tx_dev;
405 netdevice_t *cmd_dev;
406 u32 no_dev;
407 volatile u8 *hdlc_buf_status;
408 u32 tx_interrupts_pending;
409 u16 timer_int_enabled;
410 netdevice_t *poll_device;
411 atomic_t command_busy;
412
413 u16 udp_pkt_lgth;
414 u32 udp_type;
415 u8 udp_pkt_src;
416 u32 udp_lcn;
417 netdevice_t * udp_dev;
418 s8 udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
419
420 u8 LAPB_hdlc;
421 u8 logging;
422 u8 oob_on_modem;
423 u16 num_of_ch;
424
425 struct tq_struct x25_poll_task;
426 struct timer_list x25_timer;
427 } x;
428 struct
429 {
430 void* rxmb_base;
431 void* rxmb_last;
432 unsigned rx_base;
433 unsigned rx_top;
434 unsigned short node_dlci[100];
435 unsigned short dlci_num;
436 netdevice_t *dlci_to_dev_map[991 + 1];
437 unsigned tx_interrupts_pending;
438 unsigned short timer_int_enabled;
439 unsigned short udp_pkt_lgth;
440 int udp_type;
441 char udp_pkt_src;
442 unsigned udp_dlci;
443 char udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
444 void* trc_el_base;
445 void* trc_el_last;
446 void *curr_trc_el;
447 unsigned short trc_bfr_space;
448 unsigned char update_comms_stats;
449 netdevice_t *arp_dev;
450 spinlock_t if_send_lock;
451 } f;
452 struct
453 {
454 char if_name[WAN_IFNAME_SZ+1];
455 void* txbuf;
456 void* txbuf_base;
457 void* txbuf_last;
458 void* rxbuf_base;
459 void* rxbuf_last;
460 unsigned rx_base;
461 unsigned rx_top;
462 char ip_mode;
463 char authenticator;
464 unsigned char comm_enabled;
465 unsigned char peer_route;
466 unsigned long *txbuf_next;
467 unsigned long *rxbuf_next;
468 } p;
469 struct
470 {
471 char if_name[WAN_IFNAME_SZ+1];
472 unsigned char comm_port;
473 unsigned char usedby;
474 void* rxmb;
475 void* flags;
476 void* tx_status;
477 void* rx_status;
478 void* txbuf;
479 void* txbuf_base;
480 void* txbuf_last;
481 void* rxbuf_base;
482 void* rxbuf_last;
483 unsigned rx_base;
484 unsigned rx_top;
485 unsigned char receive_only;
486 unsigned short protocol_options;
487 unsigned short kpalv_tx;
488 unsigned short kpalv_rx;
489 unsigned short kpalv_err;
490 unsigned short slarp_timer;
491 unsigned state;
492 unsigned char api_status;
493 unsigned char update_call_count;
494 unsigned short api_options;
495 unsigned char async_mode;
496 unsigned short tx_bits_per_char;
497 unsigned short rx_bits_per_char;
498 unsigned short stop_bits;
499 unsigned short parity;
500 unsigned short break_timer;
501 unsigned short inter_char_timer;
502 unsigned short rx_complete_length;
503 unsigned short xon_char;
504 unsigned short xoff_char;
505 unsigned char comm_enabled;
506 unsigned char backup;
507 } c;
508 struct
509 {
510 void* tx_status;
511 void* rx_status;
512 void* trace_status;
513 void* txbuf;
514 void* txbuf_base;
515 void* txbuf_last;
516 void* rxbuf_base;
517 void* rxbuf_last;
518 void* tracebuf;
519 void* tracebuf_base;
520 void* tracebuf_last;
521 unsigned rx_base;
522 unsigned rx_end;
523 unsigned trace_base;
524 unsigned trace_end;
525
526 } h;
527 } u;
528} sdla_t;
529
530
531
532void wanpipe_open (sdla_t* card);
533void wanpipe_close (sdla_t* card);
534void wanpipe_set_state (sdla_t* card, int state);
535
536int wpx_init (sdla_t* card, wandev_conf_t* conf);
537int wpf_init (sdla_t* card, wandev_conf_t* conf);
538int wpp_init (sdla_t* card, wandev_conf_t* conf);
539int wpc_init (sdla_t* card, wandev_conf_t* conf);
540int bsc_init (sdla_t* card, wandev_conf_t* conf);
541int hdlc_init(sdla_t* card, wandev_conf_t* conf);
542int wpft1_init (sdla_t* card, wandev_conf_t* conf);
543int wsppp_init (sdla_t* card, wandev_conf_t* conf);
544
545extern sdla_t * wanpipe_find_card(char *);
546extern sdla_t * wanpipe_find_card_num (int);
547
548extern void wanpipe_queue_tq (struct tq_struct *);
549extern void wanpipe_mark_bh (void);
550extern void wakeup_sk_bh (netdevice_t *);
551extern int change_dev_flags (netdevice_t *, unsigned);
552extern unsigned long get_ip_address (netdevice_t *dev, int option);
553extern void add_gateway(sdla_t *, netdevice_t *);
554
555
556#endif
557#endif
558
559