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-1999 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 * Oct 04, 1999 Nenad Corbic New CHDLC and FRAME RELAY code, SMP support
16 * Jun 02, 1999 Gideon Hack Added 'update_call_count' for Cisco HDLC
17 * support
18 * Jun 26, 1998 David Fong Added 'ip_mode' in sdla_t.u.p for dynamic IP
19 * routing mode configuration
20 * Jun 12, 1998 David Fong Added Cisco HDLC union member in sdla_t
21 * Dec 08, 1997 Jaspreet Singh Added 'authenticator' in union of 'sdla_t'
22 * Nov 26, 1997 Jaspreet Singh Added 'load_sharing' structure. Also added
23 * 'devs_struct','dev_to_devtint_next' to 'sdla_t'
24 * Nov 24, 1997 Jaspreet Singh Added 'irq_dis_if_send_count',
25 * 'irq_dis_poll_count' to 'sdla_t'.
26 * Nov 06, 1997 Jaspreet Singh Added a define called 'INTR_TEST_MODE'
27 * Oct 20, 1997 Jaspreet Singh Added 'buff_intr_mode_unbusy' and
28 * 'dlci_intr_mode_unbusy' to 'sdla_t'
29 * Oct 18, 1997 Jaspreet Singh Added structure to maintain global driver
30 * statistics.
31 * Jan 15, 1997 Gene Kozin Version 3.1.0
32 * o added UDP management stuff
33 * Jan 02, 1997 Gene Kozin Version 3.0.0
34 *****************************************************************************/
35 #ifndef _WANPIPE_H
36 #define _WANPIPE_H
37
38 #include <linux/config.h>
39
40 #ifdef CONFIG_SMP
41 #include <asm/spinlock.h> /* Support for SMP Locking */
42 #endif
43
44 #include <linux/wanrouter.h>
45
46 /* Defines */
47
48 #ifndef PACKED
49 #define PACKED __attribute__((packed))
50 #endif
51
52 #define WANPIPE_MAGIC 0x414C4453L /* signatire: 'SDLA' reversed */
53
54 /* IOCTL numbers (up to 16) */
55 #define WANPIPE_DUMP (ROUTER_USER+0) /* dump adapter's memory */
56 #define WANPIPE_EXEC (ROUTER_USER+1) /* execute firmware command */
57
58 #define TRACE_ALL 0x00
59 #define TRACE_PROT 0x01
60 #define TRACE_DATA 0x02
61
62 /* values for request/reply byte */
63 #define UDPMGMT_REQUEST 0x01
64 #define UDPMGMT_REPLY 0x02
65 #define UDP_OFFSET 12
66
67
68 /*
69 * Data structures for IOCTL calls.
70 */
71
72 typedef struct sdla_dump /* WANPIPE_DUMP */
73 {
74 unsigned long magic; /* for verification */
75 unsigned long offset; /* absolute adapter memory address */
76 unsigned long length; /* block length */
77 void* ptr; /* -> buffer */
78 } sdla_dump_t;
79
80 typedef struct sdla_exec /* WANPIPE_EXEC */
81 {
82 unsigned long magic; /* for verification */
83 void* cmd; /* -> command structure */
84 void* data; /* -> data buffer */
85 } sdla_exec_t;
86
87 /* UDP management stuff */
88
89 typedef struct wum_header
90 {
91 unsigned char signature[8]; /* 00h: signature */
92 unsigned char type; /* 08h: request/reply */
93 unsigned char command; /* 09h: commnand */
94 unsigned char reserved[6]; /* 0Ah: reserved */
95 } wum_header_t;
96
97 /*************************************************************************
98 Data Structure for global statistics
99 *************************************************************************/
100
101 typedef struct global_stats
102 {
103 unsigned long isr_entry;
104 unsigned long isr_already_critical;
105 unsigned long isr_rx;
106 unsigned long isr_tx;
107 unsigned long isr_intr_test;
108 unsigned long isr_spurious;
109 unsigned long isr_enable_tx_int;
110 unsigned long rx_intr_corrupt_rx_bfr;
111 unsigned long rx_intr_on_orphaned_DLCI;
112 unsigned long rx_intr_dev_not_started;
113 unsigned long tx_intr_dev_not_started;
114 unsigned long poll_entry;
115 unsigned long poll_already_critical;
116 unsigned long poll_processed;
117 unsigned long poll_tbusy_bad_status;
118 unsigned long poll_host_disable_irq;
119 unsigned long poll_host_enable_irq;
120
121 } global_stats_t;
122
123
124 typedef struct{
125 unsigned short udp_src_port PACKED;
126 unsigned short udp_dst_port PACKED;
127 unsigned short udp_length PACKED;
128 unsigned short udp_checksum PACKED;
129 } udp_pkt_t;
130
131
132 typedef struct {
133 unsigned char ver_inet_hdr_length PACKED;
134 unsigned char service_type PACKED;
135 unsigned short total_length PACKED;
136 unsigned short identifier PACKED;
137 unsigned short flags_frag_offset PACKED;
138 unsigned char ttl PACKED;
139 unsigned char protocol PACKED;
140 unsigned short hdr_checksum PACKED;
141 unsigned long ip_src_address PACKED;
142 unsigned long ip_dst_address PACKED;
143 } ip_pkt_t;
144
145
146 typedef struct {
147 unsigned char signature[8] PACKED;
148 unsigned char request_reply PACKED;
149 unsigned char id PACKED;
150 unsigned char reserved[6] PACKED;
151 } wp_mgmt_t;
152
153 /*************************************************************************
154 Data Structure for if_send statistics
155 *************************************************************************/
156 typedef struct if_send_stat{
157 unsigned long if_send_entry;
158 unsigned long if_send_skb_null;
159 unsigned long if_send_broadcast;
160 unsigned long if_send_multicast;
161 unsigned long if_send_critical_ISR;
162 unsigned long if_send_critical_non_ISR;
163 unsigned long if_send_tbusy;
164 unsigned long if_send_tbusy_timeout;
165 unsigned long if_send_PIPE_request;
166 unsigned long if_send_wan_disconnected;
167 unsigned long if_send_dlci_disconnected;
168 unsigned long if_send_no_bfrs;
169 unsigned long if_send_adptr_bfrs_full;
170 unsigned long if_send_bfr_passed_to_adptr;
171 unsigned long if_send_protocol_error;
172 unsigned long if_send_bfr_not_passed_to_adptr;
173 unsigned long if_send_tx_int_enabled;
174 unsigned long if_send_consec_send_fail;
175 } if_send_stat_t;
176
177 typedef struct rx_intr_stat{
178 unsigned long rx_intr_no_socket;
179 unsigned long rx_intr_dev_not_started;
180 unsigned long rx_intr_PIPE_request;
181 unsigned long rx_intr_bfr_not_passed_to_stack;
182 unsigned long rx_intr_bfr_passed_to_stack;
183 } rx_intr_stat_t;
184
185 typedef struct pipe_mgmt_stat{
186 unsigned long UDP_PIPE_mgmt_kmalloc_err;
187 unsigned long UDP_PIPE_mgmt_direction_err;
188 unsigned long UDP_PIPE_mgmt_adptr_type_err;
189 unsigned long UDP_PIPE_mgmt_adptr_cmnd_OK;
190 unsigned long UDP_PIPE_mgmt_adptr_cmnd_timeout;
191 unsigned long UDP_PIPE_mgmt_adptr_send_passed;
192 unsigned long UDP_PIPE_mgmt_adptr_send_failed;
193 unsigned long UDP_PIPE_mgmt_not_passed_to_stack;
194 unsigned long UDP_PIPE_mgmt_passed_to_stack;
195 unsigned long UDP_PIPE_mgmt_no_socket;
196 unsigned long UDP_PIPE_mgmt_passed_to_adptr;
197 } pipe_mgmt_stat_t;
198
199
200
201 #define MAX_LGTH_UDP_MGNT_PKT 2000
202
203
204 /* This is used for interrupt testing */
205 #define INTR_TEST_MODE 0x02
206
207 #define WUM_SIGNATURE_L 0x50495046
208 #define WUM_SIGNATURE_H 0x444E3845
209
210 #define WUM_KILL 0x50
211 #define WUM_EXEC 0x51
212
213 #ifdef __KERNEL__
214 /****** Kernel Interface ****************************************************/
215
216 #include <linux/sdladrv.h> /* SDLA support module API definitions */
217 #include <linux/sdlasfm.h> /* SDLA firmware module definitions */
218
219 #ifndef min
220 #define min(a,b) (((a)<(b))?(a):(b))
221 #endif
222 #ifndef max
223 #define max(a,b) (((a)>(b))?(a):(b))
224 #endif
225
226 #define is_digit(ch) (((ch)>=(unsigned)''&&(ch)<=(unsigned)'9')?1:0)
227 #define is_alpha(ch) ((((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'z')||\
228 ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'Z'))?1:0)
229 #define is_hex_digit(ch) ((((ch)>=(unsigned)''&&(ch)<=(unsigned)'9')||\
230 ((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'f')||\
231 ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'F'))?1:0)
232
233 /****** Data Structures *****************************************************/
234
235 /* Adapter Data Space.
236 * This structure is needed because we handle multiple cards, otherwise
237 * static data would do it.
238 */
239 typedef struct sdla
240 {
241 char devname[WAN_DRVNAME_SZ+1]; /* card name */
242 sdlahw_t hw; /* hardware configuration */
243 wan_device_t wandev; /* WAN device data space */
244 unsigned open_cnt; /* number of open interfaces */
245 unsigned long state_tick; /* link state timestamp */
246 unsigned intr_mode; /* Type of Interrupt Mode */
247 char in_isr; /* interrupt-in-service flag */
248 char buff_int_mode_unbusy; /* flag for carrying out dev_tint */
249 char dlci_int_mode_unbusy; /* flag for carrying out dev_tint */
250 char configured; /* flag for previous configurations */
251 unsigned short irq_dis_if_send_count; /* Disabling irqs in if_send*/
252 unsigned short irq_dis_poll_count; /* Disabling irqs in poll routine*/
253 unsigned short force_enable_irq;
254 char TracingEnabled; /* flag for enabling trace */
255 global_stats_t statistics; /* global statistics */
256 #ifdef CONFIG_SMP
257 spinlock_t lock; /* Support for SMP Locking */
258 #endif
259 void* mbox; /* -> mailbox */
260 void* rxmb; /* -> receive mailbox */
261 void* flags; /* -> adapter status flags */
262 void (*isr)(struct sdla* card); /* interrupt service routine */
263 void (*poll)(struct sdla* card); /* polling routine */
264 int (*exec)(struct sdla* card, void* u_cmd, void* u_data);
265
266 struct sdla *next; /* Secondary Port Device: Piggibacking */
267 union
268 {
269 struct
270 { /****** X.25 specific data **********/
271 unsigned lo_pvc;
272 unsigned hi_pvc;
273 unsigned lo_svc;
274 unsigned hi_svc;
275 } x;
276 struct
277 { /****** frame relay specific data ***/
278 void* rxmb_base; /* -> first Rx buffer */
279 void* rxmb_last; /* -> last Rx buffer */
280 unsigned rx_base; /* S508 receive buffer base */
281 unsigned rx_top; /* S508 receive buffer end */
282 unsigned short node_dlci[100];
283 unsigned short dlci_num;
284 struct net_device *dlci_to_dev_map[991 + 1];
285 unsigned tx_interrupts_pending;
286 unsigned short timer_int_enabled;
287 unsigned short udp_pkt_lgth;
288 int udp_type;
289 char udp_pkt_src;
290 unsigned udp_dlci;
291 char udp_pkt_data[MAX_LGTH_UDP_MGNT_PKT];
292 void* trc_el_base; /* first trace element */
293 void* trc_el_last; /* last trace element */
294 void *curr_trc_el; /* current trace element */
295 unsigned short trc_bfr_space; /* trace buffer space */
296 unsigned char update_comms_stats;
297 } f;
298 struct /****** PPP-specific data ***********/
299 {
300 char if_name[WAN_IFNAME_SZ+1]; /* interface name */
301 void* txbuf; /* -> current Tx buffer */
302 void* txbuf_base; /* -> first Tx buffer */
303 void* txbuf_last; /* -> last Tx buffer */
304 void* rxbuf_base; /* -> first Rx buffer */
305 void* rxbuf_last; /* -> last Rx buffer */
306 unsigned rx_base; /* S508 receive buffer base */
307 unsigned rx_top; /* S508 receive buffer end */
308 char ip_mode; /* STATIC/HOST/PEER IP Mode */
309 char authenticator; /* Authenticator for PAP/CHAP */
310 } p;
311 struct /* Cisco HDLC-specific data */
312 {
313 char if_name[WAN_IFNAME_SZ+1]; /* interface name */
314 unsigned char comm_port;/* Communication Port O or 1 */
315 unsigned char usedby; /* Used by WANPIPE or API */
316 void* rxmb; /* Receive mail box */
317 void* flags; /* flags */
318 void* tx_status; /* Tx status element */
319 void* rx_status; /* Rx status element */
320 void* txbuf; /* -> current Tx buffer */
321 void* txbuf_base; /* -> first Tx buffer */
322 void* txbuf_last; /* -> last Tx buffer */
323 void* rxbuf_base; /* -> first Rx buffer */
324 void* rxbuf_last; /* -> last Rx buffer */
325 unsigned rx_base; /* S508 receive buffer base */
326 unsigned rx_top; /* S508 receive buffer end */
327 unsigned short protocol_options;
328 unsigned short kpalv_tx; /* Tx kpalv timer */
329 unsigned short kpalv_rx; /* Rx kpalv timer */
330 unsigned short kpalv_err; /* Error tolerance */
331 unsigned short slarp_timer; /* SLARP req timer */
332 unsigned state; /* state of the link */
333 unsigned char api_status;
334 unsigned char update_call_count;
335 } c;
336 struct
337 {
338 void* tx_status; /* Tx status element */
339 void* rx_status; /* Rx status element */
340 void* trace_status; /* Trace status element */
341 void* txbuf; /* -> current Tx buffer */
342 void* txbuf_base; /* -> first Tx buffer */
343 void* txbuf_last; /* -> last Tx buffer */
344 void* rxbuf_base; /* -> first Rx buffer */
345 void* rxbuf_last; /* -> last Rx buffer */
346 void* tracebuf; /* -> current Trace buffer */
347 void* tracebuf_base; /* -> current Trace buffer */
348 void* tracebuf_last; /* -> current Trace buffer */
349 unsigned rx_base; /* receive buffer base */
350 unsigned rx_end; /* receive buffer end */
351 unsigned trace_base; /* trace buffer base */
352 unsigned trace_end; /* trace buffer end */
353
354 } h;
355 } u;
356 } sdla_t;
357
358 /****** Public Functions ****************************************************/
359
360 void wanpipe_open (sdla_t* card); /* wpmain.c */
361 void wanpipe_close (sdla_t* card); /* wpmain.c */
362 void wanpipe_set_state (sdla_t* card, int state); /* wpmain.c */
363
364 int wpx_init (sdla_t* card, wandev_conf_t* conf); /* wpx.c */
365 int wpf_init (sdla_t* card, wandev_conf_t* conf); /* wpf.c */
366 int wpp_init (sdla_t* card, wandev_conf_t* conf); /* wpp.c */
367 int wpc_init (sdla_t* card, wandev_conf_t* conf); /* Cisco HDLC */
368 int bsc_init (sdla_t* card, wandev_conf_t* conf); /* BSC streaming */
369 int hdlc_init(sdla_t* card, wandev_conf_t* conf); /* HDLC support */
370 int wpft1_init (sdla_t* card, wandev_conf_t* conf); /* FT1 Config support */
371
372 #endif /* __KERNEL__ */
373 #endif /* _WANPIPE_H */
374
375
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.