1 /*
2 * Ioctl interface to Cronyx serial drivers.
3 *
4 * Copyright (C) 1997-2002 Cronyx Engineering.
5 * Author: Serge Vakulenko, <vak@cronyx.ru>
6 *
7 * Copyright (C) 2001-2003 Cronyx Engineering.
8 * Author: Roman Kurakin, <rik@cronyx.ru>
9 *
10 * This software is distributed with NO WARRANTIES, not even the implied
11 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 *
13 * Authors grant any other persons or organisations permission to use
14 * or modify this software as long as this message is kept with the software,
15 * all derivative works or modified versions.
16 *
17 * Cronyx Id: cserial.h,v 1.1.2.4 2003/11/12 17:11:08 rik Exp $
18 * $FreeBSD: releng/5.3/sys/i386/include/cserial.h 123120 2003-12-03 07:29:38Z imp $
19 */
20
21 /*
22 * General channel statistics.
23 */
24 struct serial_statistics {
25 unsigned long rintr; /* receive interrupts */
26 unsigned long tintr; /* transmit interrupts */
27 unsigned long mintr; /* modem interrupts */
28 unsigned long ibytes; /* input bytes */
29 unsigned long ipkts; /* input packets */
30 unsigned long ierrs; /* input errors */
31 unsigned long obytes; /* output bytes */
32 unsigned long opkts; /* output packets */
33 unsigned long oerrs; /* output errors */
34 };
35
36 /*
37 * Statistics for E1/G703 channels.
38 */
39 struct e1_counters {
40 unsigned long bpv; /* bipolar violations */
41 unsigned long fse; /* frame sync errors */
42 unsigned long crce; /* CRC errors */
43 unsigned long rcrce; /* remote CRC errors (E-bit) */
44 unsigned long uas; /* unavailable seconds */
45 unsigned long les; /* line errored seconds */
46 unsigned long es; /* errored seconds */
47 unsigned long bes; /* bursty errored seconds */
48 unsigned long ses; /* severely errored seconds */
49 unsigned long oofs; /* out of frame seconds */
50 unsigned long css; /* controlled slip seconds */
51 unsigned long dm; /* degraded minutes */
52 };
53
54 struct e1_statistics {
55 unsigned long status; /* line status bit mask */
56 unsigned long cursec; /* seconds in current interval */
57 unsigned long totsec; /* total seconds elapsed */
58 struct e1_counters currnt; /* current 15-min interval data */
59 struct e1_counters total; /* total statistics data */
60 struct e1_counters interval [48]; /* 12 hour period data */
61 };
62
63 struct e3_statistics {
64 unsigned long status;
65 unsigned long cursec;
66 unsigned long totsec;
67 unsigned long ccv;
68 unsigned long tcv;
69 unsigned long icv[48];
70 };
71
72 #define M_ASYNC 0 /* asynchronous mode */
73 #define M_HDLC 1 /* bit-sync mode (HDLC) */
74 #define M_G703 2
75 #define M_E1 3
76
77 /*
78 * Receive error codes.
79 */
80 #define ER_FRAMING 1 /* framing error */
81 #define ER_CHECKSUM 2 /* parity/CRC error */
82 #define ER_BREAK 3 /* break state */
83 #define ER_OVERFLOW 4 /* receive buffer overflow */
84 #define ER_OVERRUN 5 /* receive fifo overrun */
85 #define ER_UNDERRUN 6 /* transmit fifo underrun */
86 #define ER_SCC_FRAMING 7 /* subchannel framing error */
87 #define ER_SCC_OVERFLOW 8 /* subchannel receive buffer overflow */
88 #define ER_SCC_OVERRUN 9 /* subchannel receiver overrun */
89
90 /*
91 * E1 channel status.
92 */
93 #define E1_NOALARM 0x0001 /* no alarm present */
94 #define E1_FARLOF 0x0002 /* receiving far loss of framing */
95 #define E1_AIS 0x0008 /* receiving all ones */
96 #define E1_LOF 0x0020 /* loss of framing */
97 #define E1_LOS 0x0040 /* loss of signal */
98 #define E1_AIS16 0x0100 /* receiving all ones in timeslot 16 */
99 #define E1_FARLOMF 0x0200 /* receiving alarm in timeslot 16 */
100 #define E1_LOMF 0x0400 /* loss of multiframe sync */
101 #define E1_TSTREQ 0x0800 /* test code detected */
102 #define E1_TSTERR 0x1000 /* test error */
103
104 #define E3_LOS 0x00000002 /* Lost of synchronization */
105 #define E3_TXE 0x00000004 /* Transmit error */
106
107 /*
108 * Query the mask of all registered channels, max 128.
109 */
110 #define SERIAL_GETREGISTERED _IOR ('x', 0, char[16])
111
112 /*
113 * Attach/detach the protocol to the channel.
114 * The protocol is given by it's name, char[8].
115 * For example "async", "hdlc", "cisco", "fr", "ppp".
116 */
117 #define SERIAL_GETPROTO _IOR ('x', 1, char [8])
118 #define SERIAL_SETPROTO _IOW ('x', 1, char [8])
119
120 /*
121 * Query/set the hardware mode for the channel.
122 */
123 #define SERIAL_GETMODE _IOR ('x', 2, int)
124 #define SERIAL_SETMODE _IOW ('x', 2, int)
125
126 #define SERIAL_ASYNC 1
127 #define SERIAL_HDLC 2
128
129 /*
130 * Get/clear the channel statistics.
131 */
132 #define SERIAL_GETSTAT _IOR ('x', 3, struct serial_statistics)
133 #define SERIAL_GETESTAT _IOR ('x', 3, struct e1_statistics)
134 #define SERIAL_GETE3STAT _IOR ('x', 3, struct e3_statistics)
135 #define SERIAL_CLRSTAT _IO ('x', 3)
136
137 /*
138 * Query/set the synchronization mode and baud rate.
139 * If baud==0 then the external clock is used.
140 */
141 #define SERIAL_GETBAUD _IOR ('x', 4, long)
142 #define SERIAL_SETBAUD _IOW ('x', 4, long)
143
144 /*
145 * Query/set the internal loopback mode,
146 * useful for debugging purposes.
147 */
148 #define SERIAL_GETLOOP _IOR ('x', 5, int)
149 #define SERIAL_SETLOOP _IOW ('x', 5, int)
150
151 /*
152 * Query/set the DPLL mode, commonly used with NRZI
153 * for channels lacking synchro signals.
154 */
155 #define SERIAL_GETDPLL _IOR ('x', 6, int)
156 #define SERIAL_SETDPLL _IOW ('x', 6, int)
157
158 /*
159 * Query/set the NRZI encoding (default is NRZ).
160 */
161 #define SERIAL_GETNRZI _IOR ('x', 7, int)
162 #define SERIAL_SETNRZI _IOW ('x', 7, int)
163
164 /*
165 * Invert receive and transmit clock.
166 */
167 #define SERIAL_GETINVCLK _IOR ('x', 8, int)
168 #define SERIAL_SETINVCLK _IOW ('x', 8, int)
169
170 /*
171 * Query/set the E1/G703 synchronization mode.
172 */
173 #define SERIAL_GETCLK _IOR ('x', 9, int)
174 #define SERIAL_SETCLK _IOW ('x', 9, int)
175
176 #define E1CLK_INTERNAL 0
177 #define E1CLK_RECEIVE 1
178 #define E1CLK_RECEIVE_CHAN0 2
179 #define E1CLK_RECEIVE_CHAN1 3
180 #define E1CLK_RECEIVE_CHAN2 4
181 #define E1CLK_RECEIVE_CHAN3 5
182
183 /*
184 * Query/set the E1 timeslot mask.
185 */
186 #define SERIAL_GETTIMESLOTS _IOR ('x', 10, long)
187 #define SERIAL_SETTIMESLOTS _IOW ('x', 10, long)
188
189 /*
190 * Query/set the E1 subchannel timeslot mask.
191 */
192 #define SERIAL_GETSUBCHAN _IOR ('x', 11, long)
193 #define SERIAL_SETSUBCHAN _IOW ('x', 11, long)
194
195 /*
196 * Query/set the high input sensitivity mode (E1).
197 */
198 #define SERIAL_GETHIGAIN _IOR ('x', 12, int)
199 #define SERIAL_SETHIGAIN _IOW ('x', 12, int)
200
201 /*
202 * Query the input signal level in santibells.
203 */
204 #define SERIAL_GETLEVEL _IOR ('x', 13, int)
205
206 /*
207 * Get the channel name.
208 */
209 #define SERIAL_GETNAME _IOR ('x', 14, char [32])
210
211 /*
212 * Get version string.
213 */
214 #define SERIAL_GETVERSIONSTRING _IOR ('x', 15, char [256])
215
216 /*
217 * Query/set master channel.
218 */
219 #define SERIAL_GETMASTER _IOR ('x', 16, char [16])
220 #define SERIAL_SETMASTER _IOW ('x', 16, char [16])
221
222 /*
223 * Query/set keepalive.
224 */
225 #define SERIAL_GETKEEPALIVE _IOR ('x', 17, int)
226 #define SERIAL_SETKEEPALIVE _IOW ('x', 17, int)
227
228 /*
229 * Query/set E1 configuration.
230 */
231 #define SERIAL_GETCFG _IOR ('x', 18, char)
232 #define SERIAL_SETCFG _IOW ('x', 18, char)
233
234 /*
235 * Query/set debug.
236 */
237 #define SERIAL_GETDEBUG _IOR ('x', 19, int)
238 #define SERIAL_SETDEBUG _IOW ('x', 19, int)
239
240 /*
241 * Query/set phony mode (E1).
242 */
243 #define SERIAL_GETPHONY _IOR ('x', 20, int)
244 #define SERIAL_SETPHONY _IOW ('x', 20, int)
245
246 /*
247 * Query/set timeslot 16 usage mode (E1).
248 */
249 #define SERIAL_GETUSE16 _IOR ('x', 21, int)
250 #define SERIAL_SETUSE16 _IOW ('x', 21, int)
251
252 /*
253 * Query/set crc4 mode (E1).
254 */
255 #define SERIAL_GETCRC4 _IOR ('x', 22, int)
256 #define SERIAL_SETCRC4 _IOW ('x', 22, int)
257
258 /*
259 * Query/set the timeout to recover after transmit interrupt loss.
260 * If timo==0 recover will be disabled.
261 */
262 #define SERIAL_GETTIMO _IOR ('x', 23, long)
263 #define SERIAL_SETTIMO _IOW ('x', 23, long)
264
265 /*
266 * Query/set port type for old models of Sigma
267 * -1 Fixed or cable select
268 * 0 RS-232
269 * 1 V35
270 * 2 RS-449
271 * 3 E1 (only for Windows 2000)
272 * 4 G.703 (only for Windows 2000)
273 * 5 DATA (only for Windows 2000)
274 * 6 E3 (only for Windows 2000)
275 * 7 T3 (only for Windows 2000)
276 * 8 STS1 (only for Windows 2000)
277 */
278 #define SERIAL_GETPORT _IOR ('x', 25, int)
279 #define SERIAL_SETPORT _IOW ('x', 25, int)
280
281 /*
282 * Add the virtual channel DLCI (Frame Relay).
283 */
284 #define SERIAL_ADDDLCI _IOW ('x', 26, int)
285
286 /*
287 * Invert receive clock.
288 */
289 #define SERIAL_GETINVRCLK _IOR ('x', 27, int)
290 #define SERIAL_SETINVRCLK _IOW ('x', 27, int)
291
292 /*
293 * Invert transmit clock.
294 */
295 #define SERIAL_GETINVTCLK _IOR ('x', 28, int)
296 #define SERIAL_SETINVTCLK _IOW ('x', 28, int)
297
298 /*
299 * Unframed E1 mode.
300 */
301 #define SERIAL_GETUNFRAM _IOR ('x', 29, int)
302 #define SERIAL_SETUNFRAM _IOW ('x', 29, int)
303
304 /*
305 * E1 monitoring mode.
306 */
307 #define SERIAL_GETMONITOR _IOR ('x', 30, int)
308 #define SERIAL_SETMONITOR _IOW ('x', 30, int)
309
310 /*
311 * Interrupt number.
312 */
313 #define SERIAL_GETIRQ _IOR ('x', 31, int)
314
315 /*
316 * Reset.
317 */
318 #define SERIAL_RESET _IO ('x', 32)
319
320 /*
321 * Hard reset.
322 */
323 #define SERIAL_HARDRESET _IO ('x', 33)
324
325 /*
326 * Query cable type.
327 */
328 #define SERIAL_GETCABLE _IOR ('x', 34, int)
329
330 /*
331 * Assignment of HDLC ports to E1 channels.
332 */
333 #define SERIAL_GETDIR _IOR ('x', 35, int)
334 #define SERIAL_SETDIR _IOW ('x', 35, int)
335
336 struct dxc_table { /* cross-connector parameters */
337 unsigned char ts [32]; /* timeslot number */
338 unsigned char link [32]; /* E1 link number */
339 };
340
341 /*
342 * DXC cross-connector settings for E1 channels.
343 */
344 #define SERIAL_GETDXC _IOR ('x', 36, struct dxc_table)
345 #define SERIAL_SETDXC _IOW ('x', 36, struct dxc_table)
346
347 /*
348 * Scrambler for G.703.
349 */
350 #define SERIAL_GETSCRAMBLER _IOR ('x', 37, int)
351 #define SERIAL_SETSCRAMBLER _IOW ('x', 37, int)
352
353 /*
354 * Length of cable for T3 and STS-1.
355 */
356 #define SERIAL_GETCABLEN _IOR ('x', 38, int)
357 #define SERIAL_SETCABLEN _IOW ('x', 38, int)
358
359 /*
360 * Remote loopback for E3, T3 and STS-1.
361 */
362 #define SERIAL_GETRLOOP _IOR ('x', 39, int)
363 #define SERIAL_SETRLOOP _IOW ('x', 39, int)
364
365 /*
366 * Dynamic binder interface.
367 */
368 #ifdef __KERNEL__
369 typedef struct _chan_t chan_t;
370 typedef struct _proto_t proto_t;
371
372 void binder_register_protocol (proto_t *p);
373 void binder_unregister_protocol (proto_t *p);
374
375 int binder_register_channel (chan_t *h, char *prefix, int minor);
376 void binder_unregister_channel (chan_t *h);
377
378 /*
379 * Hardware channel driver structure.
380 */
381 struct sk_buff;
382
383 struct _chan_t {
384 char name [16];
385 int mtu; /* max packet size */
386 int fifosz; /* total hardware i/o buffer size */
387 int port; /* hardware base i/o port */
388 int irq; /* hardware interrupt line */
389 int minor; /* minor number 0..127, assigned by binder */
390 int debug; /* debug level, 0..2 */
391 int running; /* running, 0..1 */
392 struct _proto_t *proto; /* protocol interface data */
393 void *sw; /* protocol private data */
394 void *hw; /* hardware layer private data */
395
396 /* Interface to protocol */
397 int (*up) (chan_t *h);
398 void (*down) (chan_t *h);
399 int (*transmit) (chan_t *h, struct sk_buff *skb);
400 void (*set_dtr) (chan_t *h, int val);
401 void (*set_rts) (chan_t *h, int val);
402 int (*query_dtr) (chan_t *h);
403 int (*query_rts) (chan_t *h);
404 int (*query_dsr) (chan_t *h);
405 int (*query_cts) (chan_t *h);
406 int (*query_dcd) (chan_t *h);
407
408 /* Interface to async protocol */
409 void (*set_async_param) (chan_t *h, int baud, int bits, int parity,
410 int stop2, int ignpar, int rtscts,
411 int ixon, int ixany, int symstart, int symstop);
412 void (*send_break) (chan_t *h, int msec);
413 void (*send_xon) (chan_t *h);
414 void (*send_xoff) (chan_t *h);
415 void (*start_transmitter) (chan_t *h);
416 void (*stop_transmitter) (chan_t *h);
417 void (*flush_transmit_buffer) (chan_t *h);
418
419 /* Control interface */
420 int (*control) (chan_t *h, unsigned int cmd, unsigned long arg);
421 };
422
423 /*
424 * Protocol driver structure.
425 */
426 struct _proto_t {
427 char *name;
428 struct _proto_t *next;
429
430 /* Interface to channel */
431 void (*receive) (chan_t *h, struct sk_buff *skb);
432 void (*receive_error) (chan_t *h, int errcode);
433 void (*transmit) (chan_t *h);
434 void (*modem_event) (chan_t *h);
435
436 /* Interface to binder */
437 int (*open) (chan_t *h);
438 void (*close) (chan_t *h);
439 int (*read) (chan_t *h, unsigned short flg, char *buf, int len);
440 int (*write) (chan_t *h, unsigned short flg, const char *buf, int len);
441 int (*select) (chan_t *h, int type, void *st, struct file *filp);
442 struct fasync_struct *fasync;
443
444 /* Control interface */
445 int (*attach) (chan_t *h);
446 int (*detach) (chan_t *h);
447 int (*control) (chan_t *h, unsigned int cmd, unsigned long arg);
448 };
449 #endif /* KERNEL */
Cache object: 97072bc9cfffd521c8b9da5f977eb6bb
|