Linux v2.6.15-rc7
[pohmelfs.git] / include / linux / wanpipe.h
blobdae9860091ddc8c99d472979b54b68577ac321ba
1 /*****************************************************************************
2 * wanpipe.h WANPIPE(tm) Multiprotocol WAN Link Driver.
3 * User-level API definitions.
5 * Author: Nenad Corbic <ncorbic@sangoma.com>
6 * Gideon Hack
8 * Copyright: (c) 1995-2000 Sangoma Technologies Inc.
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
42 #include <linux/wanrouter.h>
44 /* Defines */
46 #ifndef PACKED
47 #define PACKED __attribute__((packed))
48 #endif
50 #define WANPIPE_MAGIC 0x414C4453L /* signature: 'SDLA' reversed */
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 */
56 #define TRACE_ALL 0x00
57 #define TRACE_PROT 0x01
58 #define TRACE_DATA 0x02
60 /* values for request/reply byte */
61 #define UDPMGMT_REQUEST 0x01
62 #define UDPMGMT_REPLY 0x02
63 #define UDP_OFFSET 12
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
70 #ifndef AF_WANPIPE
71 #define AF_WANPIPE 25
72 #ifndef PF_WANPIPE
73 #define PF_WANPIPE AF_WANPIPE
74 #endif
75 #endif
78 #define TX_TIMEOUT 5*HZ
80 /* General Critical Flags */
81 #define SEND_CRIT 0x00
82 #define PERI_CRIT 0x01
84 /* Chdlc and PPP polling critical flag */
85 #define POLL_CRIT 0x03
87 /* Frame Relay Tx IRQ send critical flag */
88 #define SEND_TXIRQ_CRIT 0x02
90 /* Frame Relay ARP critical flag */
91 #define ARP_CRIT 0x03
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
98 #define DYN_OPT_ON 0x00
99 #define DEV_DOWN 0x01
102 * Data structures for IOCTL calls.
105 typedef struct sdla_dump /* WANPIPE_DUMP */
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;
113 typedef struct sdla_exec /* WANPIPE_EXEC */
115 unsigned long magic; /* for verification */
116 void* cmd; /* -> command structure */
117 void* data; /* -> data buffer */
118 } sdla_exec_t;
120 /* UDP management stuff */
122 typedef struct wum_header
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;
130 /*************************************************************************
131 Data Structure for global statistics
132 *************************************************************************/
134 typedef struct global_stats
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;
154 } global_stats_t;
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;
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;
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;
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;
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;
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;
233 typedef struct {
234 struct sk_buff *skb;
235 } bh_data_t, cmd_data_t;
237 #define MAX_LGTH_UDP_MGNT_PKT 2000
240 /* This is used for interrupt testing */
241 #define INTR_TEST_MODE 0x02
243 #define WUM_SIGNATURE_L 0x50495046
244 #define WUM_SIGNATURE_H 0x444E3845
246 #define WUM_KILL 0x50
247 #define WUM_EXEC 0x51
249 #define WANPIPE 0x00
250 #define API 0x01
251 #define BRIDGE 0x02
252 #define BRIDGE_NODE 0x03
254 #ifdef __KERNEL__
255 /****** Kernel Interface ****************************************************/
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>
268 /****** Data Structures *****************************************************/
270 /* Adapter Data Space.
271 * This structure is needed because we handle multiple cards, otherwise
272 * static data would do it.
274 typedef struct sdla
276 char devname[WAN_DRVNAME_SZ+1]; /* card name */
277 sdlahw_t hw; /* hardware configuration */
278 struct wan_device wandev; /* WAN device data space */
280 unsigned open_cnt; /* number of open interfaces */
281 unsigned long state_tick; /* link state timestamp */
282 unsigned intr_mode; /* Type of Interrupt Mode */
283 char in_isr; /* interrupt-in-service flag */
284 char buff_int_mode_unbusy; /* flag for carrying out dev_tint */
285 char dlci_int_mode_unbusy; /* flag for carrying out dev_tint */
286 long configured; /* flag for previous configurations */
288 unsigned short irq_dis_if_send_count; /* Disabling irqs in if_send*/
289 unsigned short irq_dis_poll_count; /* Disabling irqs in poll routine*/
290 unsigned short force_enable_irq;
291 char TracingEnabled; /* flag for enabling trace */
292 global_stats_t statistics; /* global statistics */
293 void* mbox; /* -> mailbox */
294 void* rxmb; /* -> receive mailbox */
295 void* flags; /* -> adapter status flags */
296 void (*isr)(struct sdla* card); /* interrupt service routine */
297 void (*poll)(struct sdla* card); /* polling routine */
298 int (*exec)(struct sdla* card, void* u_cmd, void* u_data);
299 /* Used by the listen() system call */
300 /* Wanpipe Socket Interface */
301 int (*func) (struct sk_buff *, struct sock *);
302 struct sock *sk;
304 /* Shutdown function */
305 void (*disable_comm) (struct sdla *card);
307 /* Secondary Port Device: Piggibacking */
308 struct sdla *next;
310 /* TTY driver variables */
311 unsigned char tty_opt;
312 struct tty_struct *tty;
313 unsigned int tty_minor;
314 unsigned int tty_open;
315 unsigned char *tty_buf;
316 unsigned char *tty_rx;
317 struct work_struct tty_work;
319 union
321 struct
322 { /****** X.25 specific data **********/
323 u32 lo_pvc;
324 u32 hi_pvc;
325 u32 lo_svc;
326 u32 hi_svc;
327 struct net_device *svc_to_dev_map[MAX_X25_LCN];
328 struct net_device *pvc_to_dev_map[MAX_X25_LCN];
329 struct net_device *tx_dev;
330 struct net_device *cmd_dev;
331 u32 no_dev;
332 volatile u8 *hdlc_buf_status;
333 u32 tx_interrupts_pending;
334 u16 timer_int_enabled;
335 struct net_device *poll_device;
336 atomic_t command_busy;
338 u16 udp_pkt_lgth;
339 u32 udp_type;
340 u8 udp_pkt_src;
341 u32 udp_lcn;
342 struct net_device *udp_dev;
343 s8 udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
345 u8 LAPB_hdlc; /* Option to turn off X25 and run only LAPB */
346 u8 logging; /* Option to log call messages */
347 u8 oob_on_modem; /* Option to send modem status to the api */
348 u16 num_of_ch; /* Number of channels configured by the user */
350 struct work_struct x25_poll_work;
351 struct timer_list x25_timer;
352 } x;
353 struct
354 { /****** frame relay specific data ***/
355 void* rxmb_base; /* -> first Rx buffer */
356 void* rxmb_last; /* -> last Rx buffer */
357 unsigned rx_base; /* S508 receive buffer base */
358 unsigned rx_top; /* S508 receive buffer end */
359 unsigned short node_dlci[100];
360 unsigned short dlci_num;
361 struct net_device *dlci_to_dev_map[991 + 1];
362 unsigned tx_interrupts_pending;
363 unsigned short timer_int_enabled;
364 unsigned short udp_pkt_lgth;
365 int udp_type;
366 char udp_pkt_src;
367 unsigned udp_dlci;
368 char udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
369 void* trc_el_base; /* first trace element */
370 void* trc_el_last; /* last trace element */
371 void *curr_trc_el; /* current trace element */
372 unsigned short trc_bfr_space; /* trace buffer space */
373 unsigned char update_comms_stats;
374 struct net_device *arp_dev;
375 spinlock_t if_send_lock;
376 } f;
377 struct /****** PPP-specific data ***********/
379 char if_name[WAN_IFNAME_SZ+1]; /* interface name */
380 void* txbuf; /* -> current Tx buffer */
381 void* txbuf_base; /* -> first Tx buffer */
382 void* txbuf_last; /* -> last Tx buffer */
383 void* rxbuf_base; /* -> first Rx buffer */
384 void* rxbuf_last; /* -> last Rx buffer */
385 unsigned rx_base; /* S508 receive buffer base */
386 unsigned rx_top; /* S508 receive buffer end */
387 char ip_mode; /* STATIC/HOST/PEER IP Mode */
388 char authenticator; /* Authenticator for PAP/CHAP */
389 unsigned char comm_enabled; /* Is comm enabled or not */
390 unsigned char peer_route; /* Process Peer Route */
391 unsigned long *txbuf_next; /* Next Tx buffer to use */
392 unsigned long *rxbuf_next; /* Next Rx buffer to use */
393 } p;
394 struct /* Cisco HDLC-specific data */
396 char if_name[WAN_IFNAME_SZ+1]; /* interface name */
397 unsigned char comm_port;/* Communication Port O or 1 */
398 unsigned char usedby; /* Used by WANPIPE or API */
399 void* rxmb; /* Receive mail box */
400 void* flags; /* flags */
401 void* tx_status; /* Tx status element */
402 void* rx_status; /* Rx status element */
403 void* txbuf; /* -> current Tx buffer */
404 void* txbuf_base; /* -> first Tx buffer */
405 void* txbuf_last; /* -> last Tx buffer */
406 void* rxbuf_base; /* -> first Rx buffer */
407 void* rxbuf_last; /* -> last Rx buffer */
408 unsigned rx_base; /* S508 receive buffer base */
409 unsigned rx_top; /* S508 receive buffer end */
410 unsigned char receive_only; /* high speed receivers */
411 unsigned short protocol_options;
412 unsigned short kpalv_tx; /* Tx kpalv timer */
413 unsigned short kpalv_rx; /* Rx kpalv timer */
414 unsigned short kpalv_err; /* Error tolerance */
415 unsigned short slarp_timer; /* SLARP req timer */
416 unsigned state; /* state of the link */
417 unsigned char api_status;
418 unsigned char update_call_count;
419 unsigned short api_options; /* for async config */
420 unsigned char async_mode;
421 unsigned short tx_bits_per_char;
422 unsigned short rx_bits_per_char;
423 unsigned short stop_bits;
424 unsigned short parity;
425 unsigned short break_timer;
426 unsigned short inter_char_timer;
427 unsigned short rx_complete_length;
428 unsigned short xon_char;
429 unsigned short xoff_char;
430 unsigned char comm_enabled; /* Is comm enabled or not */
431 unsigned char backup;
432 } c;
433 struct
435 void* tx_status; /* Tx status element */
436 void* rx_status; /* Rx status element */
437 void* trace_status; /* Trace status element */
438 void* txbuf; /* -> current Tx buffer */
439 void* txbuf_base; /* -> first Tx buffer */
440 void* txbuf_last; /* -> last Tx buffer */
441 void* rxbuf_base; /* -> first Rx buffer */
442 void* rxbuf_last; /* -> last Rx buffer */
443 void* tracebuf; /* -> current Trace buffer */
444 void* tracebuf_base; /* -> current Trace buffer */
445 void* tracebuf_last; /* -> current Trace buffer */
446 unsigned rx_base; /* receive buffer base */
447 unsigned rx_end; /* receive buffer end */
448 unsigned trace_base; /* trace buffer base */
449 unsigned trace_end; /* trace buffer end */
451 } h;
452 } u;
453 } sdla_t;
455 /****** Public Functions ****************************************************/
457 void wanpipe_open (sdla_t* card); /* wpmain.c */
458 void wanpipe_close (sdla_t* card); /* wpmain.c */
459 void wanpipe_set_state (sdla_t* card, int state); /* wpmain.c */
461 int wpx_init (sdla_t* card, wandev_conf_t* conf); /* wpx.c */
462 int wpf_init (sdla_t* card, wandev_conf_t* conf); /* wpf.c */
463 int wpp_init (sdla_t* card, wandev_conf_t* conf); /* wpp.c */
464 int wpc_init (sdla_t* card, wandev_conf_t* conf); /* Cisco HDLC */
465 int bsc_init (sdla_t* card, wandev_conf_t* conf); /* BSC streaming */
466 int hdlc_init(sdla_t* card, wandev_conf_t* conf); /* HDLC support */
467 int wpft1_init (sdla_t* card, wandev_conf_t* conf); /* FT1 Config support */
468 int wsppp_init (sdla_t* card, wandev_conf_t* conf); /* Sync PPP on top of RAW CHDLC */
470 extern sdla_t * wanpipe_find_card(char *);
471 extern sdla_t * wanpipe_find_card_num (int);
473 extern void wanpipe_queue_work (struct work_struct *);
474 extern void wanpipe_mark_bh (void);
475 extern void wakeup_sk_bh(struct net_device *dev);
476 extern int change_dev_flags(struct net_device *dev, unsigned flags);
477 extern unsigned long get_ip_address(struct net_device *dev, int option);
478 extern void add_gateway(sdla_t *card, struct net_device *dev);
481 #endif /* __KERNEL__ */
482 #endif /* _WANPIPE_H */