1 /*****************************************************************************
2 * wanrouter.h Definitions for the WAN Multiprotocol Router Module.
3 * This module provides API and common services for WAN Link
4 * Drivers and is completely hardware-independent.
6 * Author: Nenad Corbic <ncorbic@sangoma.com>
8 * Additions: Arnaldo Melo
10 * Copyright: (c) 1995-2000 Sangoma Technologies Inc.
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 * ============================================================================
17 * Jul 21, 2000 Nenad Corbic Added WAN_FT1_READY State
18 * Feb 24, 2000 Nenad Corbic Added support for socket based x25api
19 * Jan 28, 2000 Nenad Corbic Added support for the ASYNC protocol.
20 * Oct 04, 1999 Nenad Corbic Updated for 2.1.0 release
21 * Jun 02, 1999 Gideon Hack Added support for the S514 adapter.
22 * May 23, 1999 Arnaldo Melo Added local_addr to wanif_conf_t
23 * WAN_DISCONNECTING state added
24 * Jul 20, 1998 David Fong Added Inverse ARP options to 'wanif_conf_t'
25 * Jun 12, 1998 David Fong Added Cisco HDLC support.
26 * Dec 16, 1997 Jaspreet Singh Moved 'enable_IPX' and 'network_number' to
28 * Dec 05, 1997 Jaspreet Singh Added 'pap', 'chap' to 'wanif_conf_t'
29 * Added 'authenticator' to 'wan_ppp_conf_t'
30 * Nov 06, 1997 Jaspreet Singh Changed Router Driver version to 1.1 from 1.0
31 * Oct 20, 1997 Jaspreet Singh Added 'cir','bc','be' and 'mc' to 'wanif_conf_t'
32 * Added 'enable_IPX' and 'network_number' to
33 * 'wan_device_t'. Also added defines for
34 * UDP PACKET TYPE, Interrupt test, critical values
35 * for RACE conditions.
36 * Oct 05, 1997 Jaspreet Singh Added 'dlci_num' and 'dlci[100]' to
37 * 'wan_fr_conf_t' to configure a list of dlci(s)
39 * Jul 07, 1997 Jaspreet Singh Added 'ttl' to 'wandev_conf_t' & 'wan_device_t'
40 * May 29, 1997 Jaspreet Singh Added 'tx_int_enabled' to 'wan_device_t'
41 * May 21, 1997 Jaspreet Singh Added 'udp_port' to 'wan_device_t'
42 * Apr 25, 1997 Farhan Thawar Added 'udp_port' to 'wandev_conf_t'
43 * Jan 16, 1997 Gene Kozin router_devlist made public
44 * Jan 02, 1997 Gene Kozin Initial version (based on wanpipe.h).
45 *****************************************************************************/
50 #define ROUTER_NAME "wanrouter" /* in case we ever change it */
51 #define ROUTER_VERSION 1 /* version number */
52 #define ROUTER_RELEASE 1 /* release (minor version) number */
53 #define ROUTER_IOCTL 'W' /* for IOCTL calls */
54 #define ROUTER_MAGIC 0x524D4157L /* signature: 'WANR' reversed */
56 /* IOCTL codes for /proc/router/<device> entries (up to 255) */
59 ROUTER_SETUP = ROUTER_IOCTL<<8, /* configure device */
60 ROUTER_DOWN, /* shut down device */
61 ROUTER_STAT, /* get device status */
62 ROUTER_IFNEW, /* add interface */
63 ROUTER_IFDEL, /* delete interface */
64 ROUTER_IFSTAT, /* get interface status */
65 ROUTER_USER = (ROUTER_IOCTL<<8)+16, /* driver-specific calls */
66 ROUTER_USER_MAX = (ROUTER_IOCTL<<8)+31
69 /* identifiers for displaying proc file data for dual port adapters */
70 #define PROC_DATA_PORT_0 0x8000 /* the data is for port 0 */
71 #define PROC_DATA_PORT_1 0x8001 /* the data is for port 1 */
73 /* NLPID for packet encapsulation (ISO/IEC TR 9577) */
74 #define NLPID_IP 0xCC /* Internet Protocol Datagram */
75 #define NLPID_SNAP 0x80 /* IEEE Subnetwork Access Protocol */
76 #define NLPID_CLNP 0x81 /* ISO/IEC 8473 */
77 #define NLPID_ESIS 0x82 /* ISO/IEC 9542 */
78 #define NLPID_ISIS 0x83 /* ISO/IEC ISIS */
79 #define NLPID_Q933 0x08 /* CCITT Q.933 */
82 #define WAN_IFNAME_SZ 15 /* max length of the interface name */
83 #define WAN_DRVNAME_SZ 15 /* max length of the link driver name */
84 #define WAN_ADDRESS_SZ 31 /* max length of the WAN media address */
85 #define USED_BY_FIELD 8 /* max length of the used by field */
87 /* Defines for UDP PACKET TYPE */
88 #define UDP_PTPIPE_TYPE 0x01
89 #define UDP_FPIPE_TYPE 0x02
90 #define UDP_CPIPE_TYPE 0x03
91 #define UDP_DRVSTATS_TYPE 0x04
92 #define UDP_INVALID_TYPE 0x05
94 /* Command return code */
95 #define CMD_OK 0 /* normal firmware return code */
96 #define CMD_TIMEOUT 0xFF /* firmware command timed out */
98 /* UDP Packet Management */
99 #define UDP_PKT_FRM_STACK 0x00
100 #define UDP_PKT_FRM_NETWORK 0x01
102 /* Maximum interrupt test counter */
103 #define MAX_INTR_TEST_COUNTER 100
105 /* Critical Values for RACE conditions*/
106 #define CRITICAL_IN_ISR 0xA1
107 #define CRITICAL_INTR_HANDLED 0xB1
109 /****** Data Types **********************************************************/
111 /*----------------------------------------------------------------------------
112 * X.25-specific link-level configuration.
114 typedef struct wan_x25_conf
116 unsigned lo_pvc; /* lowest permanent circuit number */
117 unsigned hi_pvc; /* highest permanent circuit number */
118 unsigned lo_svc; /* lowest switched circuit number */
119 unsigned hi_svc; /* highest switched circuit number */
120 unsigned hdlc_window; /* HDLC window size (1..7) */
121 unsigned pkt_window; /* X.25 packet window size (1..7) */
122 unsigned t1; /* HDLC timer T1, sec (1..30) */
123 unsigned t2; /* HDLC timer T2, sec (0..29) */
124 unsigned t4; /* HDLC supervisory frame timer = T4 * T1 */
125 unsigned n2; /* HDLC retransmission limit (1..30) */
126 unsigned t10_t20; /* X.25 RESTART timeout, sec (1..255) */
127 unsigned t11_t21; /* X.25 CALL timeout, sec (1..255) */
128 unsigned t12_t22; /* X.25 RESET timeout, sec (1..255) */
129 unsigned t13_t23; /* X.25 CLEAR timeout, sec (1..255) */
130 unsigned t16_t26; /* X.25 INTERRUPT timeout, sec (1..255) */
131 unsigned t28; /* X.25 REGISTRATION timeout, sec (1..255) */
132 unsigned r10_r20; /* RESTART retransmission limit (0..250) */
133 unsigned r12_r22; /* RESET retransmission limit (0..250) */
134 unsigned r13_r23; /* CLEAR retransmission limit (0..250) */
135 unsigned ccitt_compat; /* compatibility mode: 1988/1984/1980 */
136 unsigned x25_conf_opt; /* User defined x25 config optoins */
137 unsigned char LAPB_hdlc_only; /* Run in HDLC only mode */
138 unsigned char logging; /* Control connection logging */
139 unsigned char oob_on_modem; /* Whether to send modem status to the user app */
142 /*----------------------------------------------------------------------------
143 * Frame relay specific link-level configuration.
145 typedef struct wan_fr_conf
147 unsigned signalling; /* local in-channel signalling type */
148 unsigned t391; /* link integrity verification timer */
149 unsigned t392; /* polling verification timer */
150 unsigned n391; /* full status polling cycle counter */
151 unsigned n392; /* error threshold counter */
152 unsigned n393; /* monitored events counter */
153 unsigned dlci_num; /* number of DLCs (access node) */
154 unsigned dlci[100]; /* List of all DLCIs */
157 /*----------------------------------------------------------------------------
158 * PPP-specific link-level configuration.
160 typedef struct wan_ppp_conf
162 unsigned restart_tmr; /* restart timer */
163 unsigned auth_rsrt_tmr; /* authentication timer */
164 unsigned auth_wait_tmr; /* authentication timer */
165 unsigned mdm_fail_tmr; /* modem failure timer */
166 unsigned dtr_drop_tmr; /* DTR drop timer */
167 unsigned connect_tmout; /* connection timeout */
168 unsigned conf_retry; /* max. retry */
169 unsigned term_retry; /* max. retry */
170 unsigned fail_retry; /* max. retry */
171 unsigned auth_retry; /* max. retry */
172 unsigned auth_options; /* authentication opt. */
173 unsigned ip_options; /* IP options */
174 char authenticator; /* AUTHENTICATOR or not */
175 char ip_mode; /* Static/Host/Peer */
178 /*----------------------------------------------------------------------------
179 * CHDLC-specific link-level configuration.
181 typedef struct wan_chdlc_conf
183 unsigned char ignore_dcd; /* Protocol options: */
184 unsigned char ignore_cts; /* Ignore these to determine */
185 unsigned char ignore_keepalive; /* link status (Yes or No) */
186 unsigned char hdlc_streaming; /* hdlc_streaming mode (Y/N) */
187 unsigned char receive_only; /* no transmit buffering (Y/N) */
188 unsigned keepalive_tx_tmr; /* transmit keepalive timer */
189 unsigned keepalive_rx_tmr; /* receive keepalive timer */
190 unsigned keepalive_err_margin; /* keepalive_error_tolerance */
191 unsigned slarp_timer; /* SLARP request timer */
195 /*----------------------------------------------------------------------------
196 * WAN device configuration. Passed to ROUTER_SETUP IOCTL.
198 typedef struct wandev_conf
200 unsigned magic; /* magic number (for verification) */
201 unsigned config_id; /* configuration structure identifier */
202 /****** hardware configuration ******/
203 unsigned ioport; /* adapter I/O port base */
204 unsigned long maddr; /* dual-port memory address */
205 unsigned msize; /* dual-port memory size */
206 int irq; /* interrupt request level */
207 int dma; /* DMA request level */
208 char S514_CPU_no[1]; /* S514 PCI adapter CPU number ('A' or 'B') */
209 unsigned PCI_slot_no; /* S514 PCI adapter slot number */
210 char auto_pci_cfg; /* S515 PCI automatic slot detection */
211 char comm_port; /* Communication Port (PRI=0, SEC=1) */
212 unsigned bps; /* data transfer rate */
213 unsigned mtu; /* maximum transmit unit size */
214 unsigned udp_port; /* UDP port for management */
215 unsigned char ttl; /* Time To Live for UDP security */
216 unsigned char ft1; /* FT1 Configurator Option */
217 char interface; /* RS-232/V.35, etc. */
218 char clocking; /* external/internal */
219 char line_coding; /* NRZ/NRZI/FM0/FM1, etc. */
220 char station; /* DTE/DCE, primary/secondary, etc. */
221 char connection; /* permanent/switched/on-demand */
222 char read_mode; /* read mode: Polling or interrupt */
223 char receive_only; /* disable tx buffers */
224 char tty; /* Create a fake tty device */
225 unsigned tty_major; /* Major number for wanpipe tty device */
226 unsigned tty_minor; /* Minor number for wanpipe tty device */
227 unsigned tty_mode; /* TTY operation mode SYNC or ASYNC */
228 char backup; /* Backup Mode */
229 unsigned hw_opt[4]; /* other hardware options */
230 unsigned reserved[4];
231 /****** arbitrary data ***************/
232 unsigned data_size; /* data buffer size */
233 void* data; /* data buffer, e.g. firmware */
234 union /****** protocol-specific ************/
236 wan_x25_conf_t x25; /* X.25 configuration */
237 wan_ppp_conf_t ppp; /* PPP configuration */
238 wan_fr_conf_t fr; /* frame relay configuration */
239 wan_chdlc_conf_t chdlc; /* Cisco HDLC configuration */
243 /* 'config_id' definitions */
244 #define WANCONFIG_X25 101 /* X.25 link */
245 #define WANCONFIG_FR 102 /* frame relay link */
246 #define WANCONFIG_PPP 103 /* synchronous PPP link */
247 #define WANCONFIG_CHDLC 104 /* Cisco HDLC Link */
248 #define WANCONFIG_BSC 105 /* BiSync Streaming */
249 #define WANCONFIG_HDLC 106 /* HDLC Support */
250 #define WANCONFIG_MPPP 107 /* Multi Port PPP over RAW CHDLC */
253 * Configuration options defines.
255 /* general options */
261 /* intercace options */
262 #define WANOPT_RS232 0
265 /* data encoding options */
267 #define WANOPT_NRZI 1
271 /* link type options */
272 #define WANOPT_POINTTOPOINT 0 /* RTS always active */
273 #define WANOPT_MULTIDROP 1 /* RTS is active when transmitting */
275 /* clocking options */
276 #define WANOPT_EXTERNAL 0
277 #define WANOPT_INTERNAL 1
279 /* station options */
283 #define WANOPT_NODE 1
284 #define WANOPT_SECONDARY 0
285 #define WANOPT_PRIMARY 1
287 /* connection options */
288 #define WANOPT_PERMANENT 0 /* DTR always active */
289 #define WANOPT_SWITCHED 1 /* use DTR to setup link (dial-up) */
290 #define WANOPT_ONDEMAND 2 /* activate DTR only before sending */
292 /* frame relay in-channel signalling */
293 #define WANOPT_FR_ANSI 1 /* ANSI T1.617 Annex D */
294 #define WANOPT_FR_Q933 2 /* ITU Q.933A */
295 #define WANOPT_FR_LMI 3 /* LMI */
297 /* PPP IP Mode Options */
298 #define WANOPT_PPP_STATIC 0
299 #define WANOPT_PPP_HOST 1
300 #define WANOPT_PPP_PEER 2
302 /* ASY Mode Options */
305 #define WANOPT_ONE_AND_HALF 3
307 #define WANOPT_NONE 0
309 #define WANOPT_EVEN 2
311 /* CHDLC Protocol Options */
312 /* DF Commmented out for now.
314 #define WANOPT_CHDLC_NO_DCD IGNORE_DCD_FOR_LINK_STAT
315 #define WANOPT_CHDLC_NO_CTS IGNORE_CTS_FOR_LINK_STAT
316 #define WANOPT_CHDLC_NO_KEEPALIVE IGNORE_KPALV_FOR_LINK_STAT
323 #define WANOPT_INTR 0
324 #define WANOPT_POLL 1
327 #define WANOPT_TTY_SYNC 0
328 #define WANOPT_TTY_ASYNC 1
329 /*----------------------------------------------------------------------------
330 * WAN Link Status Info (for ROUTER_STAT IOCTL).
332 typedef struct wandev_stat
334 unsigned state; /* link state */
335 unsigned ndev; /* number of configured interfaces */
337 /* link/interface configuration */
338 unsigned connection; /* permanent/switched/on-demand */
339 unsigned media_type; /* Frame relay/PPP/X.25/SDLC, etc. */
340 unsigned mtu; /* max. transmit unit for this device */
342 /* physical level statistics */
343 unsigned modem_status; /* modem status */
344 unsigned rx_frames; /* received frames count */
345 unsigned rx_overruns; /* receiver overrun error count */
346 unsigned rx_crc_err; /* receive CRC error count */
347 unsigned rx_aborts; /* received aborted frames count */
348 unsigned rx_bad_length; /* unexpetedly long/short frames count */
349 unsigned rx_dropped; /* frames discarded at device level */
350 unsigned tx_frames; /* transmitted frames count */
351 unsigned tx_underruns; /* aborted transmissions (underruns) count */
352 unsigned tx_timeouts; /* transmission timeouts */
353 unsigned tx_rejects; /* other transmit errors */
355 /* media level statistics */
356 unsigned rx_bad_format; /* frames with invalid format */
357 unsigned rx_bad_addr; /* frames with invalid media address */
358 unsigned tx_retries; /* frames re-transmitted */
359 unsigned reserved[16]; /* reserved for future use */
362 /* 'state' defines */
365 WAN_UNCONFIGURED, /* link/channel is not configured */
366 WAN_DISCONNECTED, /* link/channel is disconnected */
367 WAN_CONNECTING, /* connection is in progress */
368 WAN_CONNECTED, /* link/channel is operational */
369 WAN_LIMIT, /* for verification only */
370 WAN_DUALPORT, /* for Dual Port cards */
372 WAN_FT1_READY /* FT1 Configurator Ready */
382 /* 'modem_status' masks */
383 #define WAN_MODEM_CTS 0x0001 /* CTS line active */
384 #define WAN_MODEM_DCD 0x0002 /* DCD line active */
385 #define WAN_MODEM_DTR 0x0010 /* DTR line active */
386 #define WAN_MODEM_RTS 0x0020 /* RTS line active */
388 /*----------------------------------------------------------------------------
389 * WAN interface (logical channel) configuration (for ROUTER_IFNEW IOCTL).
391 typedef struct wanif_conf
393 unsigned magic; /* magic number */
394 unsigned config_id; /* configuration identifier */
395 char name[WAN_IFNAME_SZ+1]; /* interface name, ASCIIZ */
396 char addr[WAN_ADDRESS_SZ+1]; /* media address, ASCIIZ */
397 char usedby[USED_BY_FIELD]; /* used by API or WANPIPE */
398 unsigned idle_timeout; /* sec, before disconnecting */
399 unsigned hold_timeout; /* sec, before re-connecting */
400 unsigned cir; /* Committed Information Rate fwd,bwd*/
401 unsigned bc; /* Committed Burst Size fwd, bwd */
402 unsigned be; /* Excess Burst Size fwd, bwd */
403 unsigned char enable_IPX; /* Enable or Disable IPX */
404 unsigned char inarp; /* Send Inverse ARP requests Y/N */
405 unsigned inarp_interval; /* sec, between InARP requests */
406 unsigned long network_number; /* Network Number for IPX */
407 char mc; /* Multicast on or off */
408 char local_addr[WAN_ADDRESS_SZ+1];/* local media address, ASCIIZ */
409 unsigned char port; /* board port */
410 unsigned char protocol; /* prococol used in this channel (TCPOX25 or X25) */
411 char pap; /* PAP enabled or disabled */
412 char chap; /* CHAP enabled or disabled */
413 unsigned char userid[511]; /* List of User Id */
414 unsigned char passwd[511]; /* List of passwords */
415 unsigned char sysname[31]; /* Name of the system */
416 unsigned char ignore_dcd; /* Protocol options: */
417 unsigned char ignore_cts; /* Ignore these to determine */
418 unsigned char ignore_keepalive; /* link status (Yes or No) */
419 unsigned char hdlc_streaming; /* Hdlc streaming mode (Y/N) */
420 unsigned keepalive_tx_tmr; /* transmit keepalive timer */
421 unsigned keepalive_rx_tmr; /* receive keepalive timer */
422 unsigned keepalive_err_margin; /* keepalive_error_tolerance */
423 unsigned slarp_timer; /* SLARP request timer */
424 unsigned char ttl; /* Time To Live for UDP security */
425 char interface; /* RS-232/V.35, etc. */
426 char clocking; /* external/internal */
427 unsigned bps; /* data transfer rate */
428 unsigned mtu; /* maximum transmit unit size */
429 unsigned char if_down; /* brind down interface when disconnected */
430 unsigned char gateway; /* Is this interface a gateway */
431 unsigned char true_if_encoding; /* Set the dev->type to true board protocol */
433 unsigned char asy_data_trans; /* async API options */
434 unsigned char rts_hs_for_receive; /* async Protocol options */
435 unsigned char xon_xoff_hs_for_receive;
436 unsigned char xon_xoff_hs_for_transmit;
437 unsigned char dcd_hs_for_transmit;
438 unsigned char cts_hs_for_transmit;
439 unsigned char async_mode;
440 unsigned tx_bits_per_char;
441 unsigned rx_bits_per_char;
443 unsigned char parity;
444 unsigned break_timer;
445 unsigned inter_char_timer;
446 unsigned rx_complete_length;
449 unsigned char receive_only; /* no transmit buffering (Y/N) */
453 /****** Kernel Interface ****************************************************/
455 #include <linux/fs.h> /* support for device drivers */
456 #include <linux/proc_fs.h> /* proc filesystem pragmatics */
457 #include <linux/netdevice.h> /* support for network drivers */
458 #include <linux/spinlock.h> /* Support for SMP Locking */
460 /*----------------------------------------------------------------------------
461 * WAN device data space.
464 unsigned magic; /* magic number */
465 char* name; /* -> WAN device name (ASCIIZ) */
466 void* private; /* -> driver private data */
467 unsigned config_id; /* Configuration ID */
468 /****** hardware configuration ******/
469 unsigned ioport; /* adapter I/O port base #1 */
470 char S514_cpu_no[1]; /* PCI CPU Number */
471 unsigned char S514_slot_no; /* PCI Slot Number */
472 unsigned long maddr; /* dual-port memory address */
473 unsigned msize; /* dual-port memory size */
474 int irq; /* interrupt request level */
475 int dma; /* DMA request level */
476 unsigned bps; /* data transfer rate */
477 unsigned mtu; /* max physical transmit unit size */
478 unsigned udp_port; /* UDP port for management */
479 unsigned char ttl; /* Time To Live for UDP security */
480 unsigned enable_tx_int; /* Transmit Interrupt enabled or not */
481 char interface; /* RS-232/V.35, etc. */
482 char clocking; /* external/internal */
483 char line_coding; /* NRZ/NRZI/FM0/FM1, etc. */
484 char station; /* DTE/DCE, primary/secondary, etc. */
485 char connection; /* permanent/switched/on-demand */
486 char signalling; /* Signalling RS232 or V35 */
487 char read_mode; /* read mode: Polling or interrupt */
488 char new_if_cnt; /* Number of interfaces per wanpipe */
489 char del_if_cnt; /* Number of times del_if() gets called */
490 unsigned char piggyback; /* Piggibacking a port */
491 unsigned hw_opt[4]; /* other hardware options */
492 /****** status and statistics *******/
493 char state; /* device state */
494 char api_status; /* device api status */
495 struct net_device_stats stats; /* interface statistics */
496 unsigned reserved[16]; /* reserved for future use */
497 unsigned long critical; /* critical section flag */
498 spinlock_t lock; /* Support for SMP Locking */
500 /****** device management methods ***/
501 int (*setup) (struct wan_device *wandev, wandev_conf_t *conf);
502 int (*shutdown) (struct wan_device *wandev);
503 int (*update) (struct wan_device *wandev);
504 int (*ioctl) (struct wan_device *wandev, unsigned cmd,
506 int (*new_if)(struct wan_device *wandev, struct net_device *dev,
508 int (*del_if)(struct wan_device *wandev, struct net_device *dev);
509 /****** maintained by the router ****/
510 struct wan_device* next; /* -> next device */
511 struct net_device* dev; /* list of network interfaces */
512 unsigned ndev; /* number of interfaces */
513 struct proc_dir_entry *dent; /* proc filesystem entry */
516 /* Public functions available for device drivers */
517 extern int register_wan_device(struct wan_device *wandev);
518 extern int unregister_wan_device(char *name);
520 /* Proc interface functions. These must not be called by the drivers! */
521 extern int wanrouter_proc_init(void);
522 extern void wanrouter_proc_cleanup(void);
523 extern int wanrouter_proc_add(struct wan_device *wandev);
524 extern int wanrouter_proc_delete(struct wan_device *wandev);
525 extern int wanrouter_ioctl( struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
528 /* list of registered devices */
529 extern struct wan_device *wanrouter_router_devlist;
531 #endif /* __KERNEL__ */
532 #endif /* _ROUTER_H */