This source file includes following definitions.
- wan_conf_t
- sdla_dump_t
- sdla_exec_t
- wan_trace_pkt_t
- wan_trace_t
- wan_mgmt_t
- wan_trace_info_t
- wan_udp_hdr_t
- wan_udp_pkt_t
- wanpipe_common_t
- sdla_xilinx_t
- sdla_t
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 #ifndef __IF_SAN_COMMON_H
36 #define __IF_SAN_COMMON_H
37
38 # include <dev/pci/if_san_te1.h>
39 # include <dev/pci/if_sandrv.h>
40
41 #define ADDR_MASK(x,y) (((caddr_t)(x) - (caddr_t)0) & (y))
42
43 #define WANPIPE_LITE_VERSION "1.1.1"
44 #define WAN_OPENBSD_PLATFORM 0x06
45 #define WAN_PLATFORM_ID WAN_OPENBSD_PLATFORM
46 #define WANPIPE_MAGIC 0x414C4453L
47
48 #define ROUTER_NAME "wanrouter"
49 #define ROUTER_IOCTL 'W'
50
51 #define WANROUTER_MAJOR_VER 2
52 #define WANROUTER_MINOR_VER 1
53
54
55 #define WANPIPE_DUMP _IOW(ROUTER_IOCTL, 16, wan_conf_t)
56 #define WANPIPE_EXEC _IOWR(ROUTER_IOCTL, 17, wan_conf_t)
57
58
59 #define SIOC_WANPIPE_PIPEMON _IOWR('i', 150, struct ifreq)
60
61
62 #define SIOC_WANPIPE_DEVICE _IOWR('i', 151, struct ifreq)
63
64
65 #define SIOC_WANPIPE_HWPROBE _IOWR('i', 152, struct ifreq)
66
67
68 #define SIOC_WANPIPE_DUMP _IOWR('i', 153, struct ifreq)
69
70
71
72 #define WAN_EXTERNAL 0
73 #define WAN_INTERNAL 1
74
75
76 #define WAN_RS232 0
77 #define WAN_V35 1
78
79 #define WAN_UDP_FAILED_CMD 0xCF
80 #define WAN_UDP_INVALID_CMD 0xCE
81 #define WAN_UDP_TIMEOUT_CMD 0xAA
82 #define WAN_UDP_INVALID_NET_CMD 0xCD
83
84 #define WAN_NO 0
85 #define WAN_YES 1
86
87
88 #define UDP_PKT_FRM_STACK 0x00
89 #define UDP_PKT_FRM_NETWORK 0x01
90
91 #define WANCONFIG_FR 102
92 #define WANCONFIG_PPP 103
93 #define WANCONFIG_CHDLC 104
94 #define WANCONFIG_AFT 117
95
96
97
98
99 enum fe_status {
100 FE_UNITIALIZED = 0x00,
101 FE_DISCONNECTED,
102 FE_CONNECTED
103 };
104
105
106 enum wan_states
107 {
108 WAN_UNCONFIGURED,
109 WAN_DISCONNECTED,
110 WAN_CONNECTING,
111 WAN_CONNECTED,
112 WAN_LIMIT,
113 WAN_DUALPORT,
114 WAN_DISCONNECTING,
115 WAN_FT1_READY
116 };
117
118
119 #define WAN_MODEM_CTS 0x0001
120 #define WAN_MODEM_DCD 0x0002
121 #define WAN_MODEM_DTR 0x0010
122 #define WAN_MODEM_RTS 0x0020
123
124 typedef struct wan_conf {
125 char devname[IFNAMSIZ+1];
126 void* arg;
127 } wan_conf_t;
128
129
130
131
132 #define TRACE_ALL 0x00
133 #define TRACE_PROT 0x01
134 #define TRACE_DATA 0x02
135
136
137 #define UDPMGMT_REQUEST 0x01
138 #define UDPMGMT_REPLY 0x02
139 #define UDP_OFFSET 12
140
141 #define MAX_FT1_RETRY 100
142
143
144 enum {
145 SEND_CRIT,
146 PERI_CRIT,
147 RX_CRIT,
148 PRIV_CRIT
149 };
150
151
152
153
154
155 typedef struct sdla_dump {
156 unsigned long magic;
157 unsigned long offset;
158 unsigned long length;
159 void* ptr;
160 } sdla_dump_t;
161
162 typedef struct sdla_exec {
163 unsigned long magic;
164 void* cmd;
165 void* data;
166 } sdla_exec_t;
167
168 #define TRC_INCOMING_FRM 0x00
169 #define TRC_OUTGOING_FRM 0x01
170 typedef struct {
171 unsigned char status;
172 unsigned char data_avail;
173 unsigned short real_length;
174 unsigned short time_stamp;
175 unsigned long sec;
176 unsigned long usec;
177 unsigned char data[0];
178 } wan_trace_pkt_t;
179
180 typedef struct wan_trace {
181 unsigned long tracing_enabled;
182 struct ifqueue ifq;
183 unsigned int trace_timeout;
184 unsigned int max_trace_queue;
185 } wan_trace_t;
186
187
188
189
190
191 #define GLOBAL_UDP_SIGNATURE "WANPIPE"
192 #define GLOBAL_UDP_SIGNATURE_LEN 7
193 #define UDPMGMT_UDP_PROTOCOL 0x11
194 #define WAN_UDP_CMD_START 0x60
195 #define WAN_GET_PROTOCOL (WAN_UDP_CMD_START+0)
196 #define WAN_GET_PLATFORM (WAN_UDP_CMD_START+1)
197 #define WAN_GET_MEDIA_TYPE (WAN_UDP_CMD_START+2)
198 #define WAN_UDP_CMD_END 0x6F
199
200 #define WAN_FE_CMD_START 0x90
201 #define WAN_FE_CMD_END 0x9F
202
203 #define WAN_INTERFACE_CMD_START 0xA0
204 #define WAN_INTERFACE_CMD_END 0xAF
205
206 #define WAN_FE_UDP_CMD_START 0xB0
207 #define WAN_FE_UDP_CMD_END 0xBF
208
209 typedef struct {
210 unsigned char signature[8];
211 unsigned char request_reply;
212 unsigned char id;
213 unsigned char reserved[6];
214 } wan_mgmt_t;
215
216
217
218 typedef struct {
219 unsigned char num_frames;
220 unsigned char ismoredata;
221 } wan_trace_info_t;
222
223 typedef struct wan_udp_hdr{
224 wan_mgmt_t wan_mgmt;
225 wan_cmd_t wan_cmd;
226 union {
227 struct {
228 wan_trace_info_t trace_info;
229 unsigned char data[WAN_MAX_DATA_SIZE];
230 } chdlc, aft;
231 unsigned char data[WAN_MAX_DATA_SIZE];
232 } wan_udphdr_u;
233 #define wan_udphdr_signature wan_mgmt.signature
234 #define wan_udphdr_request_reply wan_mgmt.request_reply
235 #define wan_udphdr_id wan_mgmt.id
236 #define wan_udphdr_opp_flag wan_cmd.wan_cmd_opp_flag
237 #define wan_udphdr_command wan_cmd.wan_cmd_command
238 #define wan_udphdr_data_len wan_cmd.wan_cmd_data_len
239 #define wan_udphdr_return_code wan_cmd.wan_cmd_return_code
240 #define wan_udphdr_chdlc_num_frames wan_udphdr_u.chdlc.trace_info.num_frames
241 #define wan_udphdr_chdlc_ismoredata wan_udphdr_u.chdlc.trace_info.ismoredata
242 #define wan_udphdr_chdlc_data wan_udphdr_u.chdlc.data
243
244 #define wan_udphdr_aft_num_frames wan_udphdr_u.aft.trace_info.num_frames
245 #define wan_udphdr_aft_ismoredata wan_udphdr_u.aft.trace_info.ismoredata
246 #define wan_udphdr_aft_data wan_udphdr_u.aft.data
247 #define wan_udphdr_data wan_udphdr_u.data
248 } wan_udp_hdr_t;
249
250 #define MAX_LGTH_UDP_MGNT_PKT 2000
251
252
253 #define INTR_TEST_MODE 0x02
254
255 #define WUM_SIGNATURE_L 0x50495046
256 #define WUM_SIGNATURE_H 0x444E3845
257
258 #define WUM_KILL 0x50
259 #define WUM_EXEC 0x51
260
261
262 #if defined(_KERNEL)
263
264
265
266 #define MAX_E1_CHANNELS 32
267 #define MAX_FR_CHANNELS (991+1)
268
269 #ifndef min
270 #define min(a,b) (((a)<(b))?(a):(b))
271 #endif
272 #ifndef max
273 #define max(a,b) (((a)>(b))?(a):(b))
274 #endif
275
276 #define is_digit(ch) (((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')?1:0)
277
278 #define is_alpha(ch) ((((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'z')|| \
279 ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'Z'))?1:0)
280
281 #define is_hex_digit(ch) ((((ch)>=(unsigned)'0'&&(ch)<=(unsigned)'9')|| \
282 ((ch)>=(unsigned)'a'&&(ch)<=(unsigned)'f')||\
283 ((ch)>=(unsigned)'A'&&(ch)<=(unsigned)'F'))?1:0)
284 #if !defined(offsetof)
285 # define offsetof(type, member) ((size_t)(&((type*)0)->member))
286 #endif
287
288 # define irqreturn_t void
289
290 # define WAN_IRQ_RETVAL(a) return;
291
292 #define _bit_byte(bit) ((bit) >> 3)
293 #define _bit_mask(bit) (1 << ((bit)&0x7))
294
295
296 #define bit_test(name, bit) ((name)[_bit_byte(bit)] & _bit_mask(bit))
297
298
299 #define bit_set(name, bit) ((name)[_bit_byte(bit)] |= _bit_mask(bit))
300
301
302 #define bit_clear(name, bit) ((name)[_bit_byte(bit)] &= ~_bit_mask(bit))
303
304
305 #define SAN_ASSERT(a) \
306 if (a){ \
307 log(LOG_INFO, "%s:%d: Critical Error!\n", \
308 __FUNCTION__,__LINE__); \
309 return (EINVAL); \
310 }
311
312
313
314 typedef struct wan_udp_pkt {
315 struct ip ip_hdr;
316 struct udphdr udp_hdr;
317 wan_udp_hdr_t wan_udp_hdr;
318 #define wan_udp_cmd wan_udp_hdr.wan_cmd
319 #define wan_udp_signature wan_udp_hdr.wan_udphdr_signature
320 #define wan_udp_request_reply wan_udp_hdr.wan_udphdr_request_reply
321 #define wan_udp_id wan_udp_hdr.wan_udphdr_id
322 #define wan_udp_opp_flag wan_udp_hdr.wan_udphdr_opp_flag
323 #define wan_udp_command wan_udp_hdr.wan_udphdr_command
324 #define wan_udp_data_len wan_udp_hdr.wan_udphdr_data_len
325 #define wan_udp_return_code wan_udp_hdr.wan_udphdr_return_code
326 #define wan_udp_hdlc_PF_bit wan_udp_hdr.wan_udphdr_hdlc_PF_bit
327 #define wan_udp_fr_dlci wan_udp_hdr.wan_udphdr_fr_dlci
328 #define wan_udp_fr_attr wan_udp_hdr.wan_udphdr_fr_attr
329 #define wan_udp_fr_rxlost1 wan_udp_hdr.wan_udphdr_fr_rxlost1
330 #define wan_udp_fr_rxlost2 wan_udp_hdr.wan_udphdr_fr_rxlost2
331 #define wan_udp_chdlc_num_frames wan_udp_hdr.wan_udphdr_chdlc_num_frames
332 #define wan_udp_chdlc_ismoredata wan_udp_hdr.wan_udphdr_chdlc_ismoredata
333 #define wan_udp_chdlc_data wan_udp_hdr.wan_udphdr_chdlc_data
334
335 #define wan_udp_aft_num_frames wan_udp_hdr.wan_udphdr_aft_num_frames
336 #define wan_udp_aft_ismoredata wan_udp_hdr.wan_udphdr_aft_ismoredata
337 #define wan_udp_data wan_udp_hdr.wan_udphdr_data
338 } wan_udp_pkt_t;
339
340 #define WAN_IFP_TO_COMMON(ifp) (wanpipe_common_t*)((ifp)->if_softc)
341 typedef struct wanpipe_common {
342 struct sppp ifp;
343 void *card;
344 struct timeout dev_timer;
345 unsigned int protocol;
346 struct ifmedia ifm;
347
348 LIST_ENTRY(wanpipe_common) next;
349 } wanpipe_common_t;
350
351 typedef struct {
352 unsigned long time_slot_map;
353 unsigned long logic_ch_map;
354 unsigned char num_of_time_slots;
355 unsigned char top_logic_ch;
356 unsigned long bar;
357 void *trace_info;
358 void *dev_to_ch_map[MAX_E1_CHANNELS];
359 void *rx_dma_ptr;
360 void *tx_dma_ptr;
361 unsigned short num_of_ch;
362 unsigned short dma_per_ch;
363 unsigned short mru_trans;
364 unsigned long dma_mtu_off;
365 unsigned short dma_mtu;
366 unsigned char state_change_exit_isr;
367 unsigned long active_ch_map;
368 unsigned long fifo_addr_map;
369 struct timeout led_timer;
370 } sdla_xilinx_t;
371
372
373
374
375
376 typedef struct sdla {
377 unsigned magic;
378 char devname[IFNAMSIZ+1];
379 void *hw;
380 unsigned int type;
381 unsigned char line_idle;
382
383 char state;
384 unsigned long critical;
385
386 int(*iface_up) (struct ifnet*);
387 int(*iface_down) (struct ifnet*);
388 int(*iface_send) (struct mbuf* skb, struct ifnet*);
389 int(*iface_ioctl) (struct ifnet*, int, struct ifreq*);
390
391 unsigned long state_tick;
392 unsigned long in_isr;
393 unsigned long configured;
394 int(*del_if) (struct sdla*, struct ifnet*);
395 void(*isr)(struct sdla*);
396 void(*poll)(struct sdla*);
397 int(*exec)(struct sdla*, void*, void*);
398 int(*ioctl) (struct ifnet*, int, struct ifreq*);
399
400 union {
401 sdla_xilinx_t xilinx;
402 } u;
403
404 sdla_fe_iface_t fe_iface;
405 union {
406 #define fe_te u_fe.te_sc
407 sdla_te_softc_t te_sc;
408 } u_fe;
409
410 unsigned char front_end_status;
411 WRITE_FRONT_END_REG_T* write_front_end_reg;
412 READ_FRONT_END_REG_T* read_front_end_reg;
413 void(*te_enable_timer) (void*);
414 void(*te_link_state) (void*);
415
416 LIST_HEAD(,wanpipe_common) dev_head;
417 LIST_ENTRY(sdla) next;
418 } sdla_t;
419
420
421
422 void* wan_xilinx_init(sdla_t*);
423 struct mbuf* wan_mbuf_alloc(int);
424 int wan_mbuf_to_buffer(struct mbuf**);
425
426 #endif
427 #endif