1 /*****************************************************************************
2 * wanpipe.h WANPIPE(tm) Multiprotocol WAN Link Driver.
3 * User-level API definitions.
5 * Author: Gene Kozin <genek@compuserve.com>
6 * Jaspreet Singh <jaspreet@sangoma.com>
8 * Copyright: (c) 1995-1997 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 26, 1997 Jaspreet Singh Added 'load_sharing' structure. Also added
16 * 'devs_struct','dev_to_devtint_next' to 'sdla_t'
17 * Nov 24, 1997 Jaspreet Singh Added 'irq_dis_if_send_count',
18 * 'irq_dis_poll_count' to 'sdla_t'.
19 * Nov 06, 1997 Jaspreet Singh Added a define called 'INTR_TEST_MODE'
20 * Oct 20, 1997 Jaspreet Singh Added 'buff_intr_mode_unbusy' and
21 * 'dlci_intr_mode_unbusy' to 'sdla_t'
22 * Oct 18, 1997 Jaspreet Singh Added structure to maintain global driver
24 * Jan 15, 1997 Gene Kozin Version 3.1.0
25 * o added UDP management stuff
26 * Jan 02, 1997 Gene Kozin Version 3.0.0
27 *****************************************************************************/
31 #include <linux/wanrouter.h>
36 #define PACKED __attribute__((packed))
39 #define WANPIPE_MAGIC 0x414C4453L /* signatire: 'SDLA' reversed */
41 /* IOCTL numbers (up to 16) */
42 #define WANPIPE_DUMP (ROUTER_USER+0) /* dump adapter's memory */
43 #define WANPIPE_EXEC (ROUTER_USER+1) /* execute firmware command */
46 * Data structures for IOCTL calls.
49 typedef struct sdla_dump
/* WANPIPE_DUMP */
51 unsigned long magic
; /* for verification */
52 unsigned long offset
; /* absolute adapter memory address */
53 unsigned long length
; /* block length */
54 void* ptr
; /* -> buffer */
57 typedef struct sdla_exec
/* WANPIPE_EXEC */
59 unsigned long magic
; /* for verification */
60 void* cmd
; /* -> command structure */
61 void* data
; /* -> data buffer */
64 /* UDP management stuff */
66 typedef struct wum_header
68 unsigned char signature
[8]; /* 00h: signature */
69 unsigned char type
; /* 08h: request/reply */
70 unsigned char command
; /* 09h: commnand */
71 unsigned char reserved
[6]; /* 0Ah: reserved */
74 /*************************************************************************
75 Data Structure for global statistics
76 *************************************************************************/
78 typedef struct global_stats
80 unsigned long isr_entry
;
81 unsigned long isr_already_critical
;
84 unsigned long isr_intr_test
;
85 unsigned long isr_spurious
;
86 unsigned long isr_enable_tx_int
;
87 unsigned long rx_intr_corrupt_rx_bfr
;
88 unsigned long rx_intr_on_orphaned_DLCI
;
89 unsigned long rx_intr_dev_not_started
;
90 unsigned long tx_intr_dev_not_started
;
91 unsigned long poll_entry
;
92 unsigned long poll_already_critical
;
93 unsigned long poll_processed
;
94 unsigned long poll_tbusy_bad_status
;
95 unsigned long poll_host_disable_irq
;
96 unsigned long poll_host_enable_irq
;
100 /* This structure is used for maitaining a circular linked list of all
101 * interfaces(devices) per card. It is used in the Interrupt Service routine
102 * for a transmit interrupt where the start of the loop to dev_tint all
103 * interfaces changes.
105 typedef struct load_sharing
107 struct net_device
* dev_ptr
;
108 struct load_sharing
* next
;
111 /* This is used for interrupt testing */
112 #define INTR_TEST_MODE 0x02
114 #define WUM_SIGNATURE_L 0x50495046
115 #define WUM_SIGNATURE_H 0x444E3845
117 #define WUM_KILL 0x50
118 #define WUM_EXEC 0x51
121 /****** Kernel Interface ****************************************************/
123 #include <linux/sdladrv.h> /* SDLA support module API definitions */
124 #include <linux/sdlasfm.h> /* SDLA firmware module definitions */
127 #define min(a,b) (((a)<(b))?(a):(b))
130 #define max(a,b) (((a)>(b))?(a):(b))
133 #define is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0)
134 #define is_alpha(ch) ((((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'z')||\
135 ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'Z'))?1:0)
136 #define is_hex_digit(ch) ((((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')||\
137 ((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'f')||\
138 ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'F'))?1:0)
140 /****** Data Structures *****************************************************/
142 /* Adapter Data Space.
143 * This structure is needed because we handle multiple cards, otherwise
144 * static data would do it.
148 char devname
[WAN_DRVNAME_SZ
+1]; /* card name */
149 sdlahw_t hw
; /* hardware configuration */
150 wan_device_t wandev
; /* WAN device data space */
151 unsigned open_cnt
; /* number of open interfaces */
152 unsigned long state_tick
; /* link state timestamp */
153 unsigned intr_mode
; /* Type of Interrupt Mode */
154 char in_isr
; /* interrupt-in-service flag */
155 char buff_int_mode_unbusy
; /* flag for carrying out dev_tint */
156 char dlci_int_mode_unbusy
; /* flag for carrying out dev_tint */
157 unsigned short irq_dis_if_send_count
; /* Disabling irqs in if_send*/
158 unsigned short irq_dis_poll_count
; /* Disabling irqs in poll routine*/
159 global_stats_t statistics
; /* global statistics */
161 /* The following is used as a pointer to the structure in our
162 circular linked list which changes the start of the loop for
163 dev_tint of all interfaces */
165 load_sharing_t
* dev_to_devtint_next
;
166 load_sharing_t
* devs_struct
;
168 void* mbox
; /* -> mailbox */
169 void* rxmb
; /* -> receive mailbox */
170 void* flags
; /* -> adapter status flags */
171 void (*isr
)(struct sdla
* card
); /* interrupt service routine */
172 void (*poll
)(struct sdla
* card
); /* polling routine */
173 int (*exec
)(struct sdla
* card
, void* u_cmd
, void* u_data
);
177 { /****** X.25 specific data **********/
184 { /****** frame relay specific data ***/
185 void* rxmb_base
; /* -> first Rx buffer */
186 void* rxmb_last
; /* -> last Rx buffer */
187 unsigned rx_base
; /* S508 receive buffer base */
188 unsigned rx_top
; /* S508 receive buffer end */
189 unsigned short node_dlci
[100];
190 unsigned short dlci_num
;
192 struct /****** PPP-specific data ***********/
194 char if_name
[WAN_IFNAME_SZ
+1]; /* interface name */
195 void* txbuf
; /* -> current Tx buffer */
196 void* txbuf_base
; /* -> first Tx buffer */
197 void* txbuf_last
; /* -> last Tx buffer */
198 void* rxbuf_base
; /* -> first Rx buffer */
199 void* rxbuf_last
; /* -> last Rx buffer */
200 unsigned rx_base
; /* S508 receive buffer base */
201 unsigned rx_top
; /* S508 receive buffer end */
206 /****** Public Functions ****************************************************/
208 void wanpipe_open (sdla_t
* card
); /* wpmain.c */
209 void wanpipe_close (sdla_t
* card
); /* wpmain.c */
210 void wanpipe_set_state (sdla_t
* card
, int state
); /* wpmain.c */
212 int wpx_init (sdla_t
* card
, wandev_conf_t
* conf
); /* wpx.c */
213 int wpf_init (sdla_t
* card
, wandev_conf_t
* conf
); /* wpf.c */
214 int wpp_init (sdla_t
* card
, wandev_conf_t
* conf
); /* wpp.c */
216 #endif /* __KERNEL__ */
217 #endif /* _WANPIPE_H */