2 * Ioctl interface to Cronyx serial drivers.
4 * Copyright (C) 1997-2002 Cronyx Engineering.
5 * Author: Serge Vakulenko, <vak@cronyx.ru>
7 * Copyright (C) 2001-2005 Cronyx Engineering.
8 * Author: Roman Kurakin, <rik@FreeBSD.org>
10 * Copyright (C) 2004-2005 Cronyx Engineering.
11 * Author: Leo Yuriev, <ly@cronyx.ru>
13 * This software is distributed with NO WARRANTIES, not even the implied
14 * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * Authors grant any other persons or organisations permission to use
17 * or modify this software as long as this message is kept with the software,
18 * all derivative works or modified versions.
20 * Cronyx Id: cserial.h,v 1.4.2.2 2005/11/09 13:01:35 rik Exp $
25 * General channel statistics.
27 struct serial_statistics {
28 unsigned long rintr; /* receive interrupts */
29 unsigned long tintr; /* transmit interrupts */
30 unsigned long mintr; /* modem interrupts */
31 unsigned long ibytes; /* input bytes */
32 unsigned long ipkts; /* input packets */
33 unsigned long ierrs; /* input errors */
34 unsigned long obytes; /* output bytes */
35 unsigned long opkts; /* output packets */
36 unsigned long oerrs; /* output errors */
40 * Statistics for E1/G703 channels.
43 unsigned long bpv; /* bipolar violations */
44 unsigned long fse; /* frame sync errors */
45 unsigned long crce; /* CRC errors */
46 unsigned long rcrce; /* remote CRC errors (E-bit) */
47 unsigned long uas; /* unavailable seconds */
48 unsigned long les; /* line errored seconds */
49 unsigned long es; /* errored seconds */
50 unsigned long bes; /* bursty errored seconds */
51 unsigned long ses; /* severely errored seconds */
52 unsigned long oofs; /* out of frame seconds */
53 unsigned long css; /* controlled slip seconds */
54 unsigned long dm; /* degraded minutes */
57 struct e1_statistics {
58 unsigned long status; /* line status bit mask */
59 unsigned long cursec; /* seconds in current interval */
60 unsigned long totsec; /* total seconds elapsed */
61 struct e1_counters currnt; /* current 15-min interval data */
62 struct e1_counters total; /* total statistics data */
63 struct e1_counters interval [48]; /* 12 hour period data */
66 struct e3_statistics {
72 unsigned long icv[48];
75 #define M_ASYNC 0 /* asynchronous mode */
76 #define M_HDLC 1 /* bit-sync mode (HDLC) */
81 * Receive error codes.
83 #define ER_FRAMING 1 /* framing error */
84 #define ER_CHECKSUM 2 /* parity/CRC error */
85 #define ER_BREAK 3 /* break state */
86 #define ER_OVERFLOW 4 /* receive buffer overflow */
87 #define ER_OVERRUN 5 /* receive fifo overrun */
88 #define ER_UNDERRUN 6 /* transmit fifo underrun */
89 #define ER_SCC_FRAMING 7 /* subchannel framing error */
90 #define ER_SCC_OVERFLOW 8 /* subchannel receive buffer overflow */
91 #define ER_SCC_OVERRUN 9 /* subchannel receiver overrun */
92 #define ER_SCC_UNDERRUN 10 /* subchannel transmiter underrun */
93 #define ER_BUS 11 /* system bus is too busy (e.g PCI) */
98 #define E1_NOALARM 0x0001 /* no alarm present */
99 #define E1_FARLOF 0x0002 /* receiving far loss of framing */
100 #define E1_CRC4E 0x0004 /* crc4 errors */
101 #define E1_AIS 0x0008 /* receiving all ones */
102 #define E1_LOF 0x0020 /* loss of framing */
103 #define E1_LOS 0x0040 /* loss of signal */
104 #define E1_AIS16 0x0100 /* receiving all ones in timeslot 16 */
105 #define E1_FARLOMF 0x0200 /* receiving alarm in timeslot 16 */
106 #define E1_LOMF 0x0400 /* loss of multiframe sync */
107 #define E1_TSTREQ 0x0800 /* test code detected */
108 #define E1_TSTERR 0x1000 /* test error */
110 #define E3_LOS 0x00000002 /* Lost of synchronization */
111 #define E3_TXE 0x00000004 /* Transmit error */
114 * Query the mask of all registered channels, max 128.
116 #define SERIAL_GETREGISTERED _IOR ('x', 0, char[16])
119 * Attach/detach the protocol to the channel.
120 * The protocol is given by it's name, char[8].
121 * For example "async", "hdlc", "cisco", "fr", "ppp".
123 #define SERIAL_GETPROTO _IOR ('x', 1, char [8])
124 #define SERIAL_SETPROTO _IOW ('x', 1, char [8])
127 * Query/set the hardware mode for the channel.
129 #define SERIAL_GETMODE _IOR ('x', 2, int)
130 #define SERIAL_SETMODE _IOW ('x', 2, int)
132 #define SERIAL_ASYNC 1
133 #define SERIAL_HDLC 2
137 * Get/clear the channel statistics.
139 #define SERIAL_GETSTAT _IOR ('x', 3, struct serial_statistics)
140 #define SERIAL_GETESTAT _IOR ('x', 3, struct e1_statistics)
141 #define SERIAL_GETE3STAT _IOR ('x', 3, struct e3_statistics)
142 #define SERIAL_CLRSTAT _IO ('x', 3)
145 * Query/set the synchronization mode and baud rate.
146 * If baud==0 then the external clock is used.
148 #define SERIAL_GETBAUD _IOR ('x', 4, long)
149 #define SERIAL_SETBAUD _IOW ('x', 4, long)
152 * Query/set the internal loopback mode,
153 * useful for debugging purposes.
155 #define SERIAL_GETLOOP _IOR ('x', 5, int)
156 #define SERIAL_SETLOOP _IOW ('x', 5, int)
159 * Query/set the DPLL mode, commonly used with NRZI
160 * for channels lacking synchro signals.
162 #define SERIAL_GETDPLL _IOR ('x', 6, int)
163 #define SERIAL_SETDPLL _IOW ('x', 6, int)
166 * Query/set the NRZI encoding (default is NRZ).
168 #define SERIAL_GETNRZI _IOR ('x', 7, int)
169 #define SERIAL_SETNRZI _IOW ('x', 7, int)
172 * Invert receive and transmit clock.
174 #define SERIAL_GETINVCLK _IOR ('x', 8, int)
175 #define SERIAL_SETINVCLK _IOW ('x', 8, int)
178 * Query/set the E1/G703 synchronization mode.
180 #define SERIAL_GETCLK _IOR ('x', 9, int)
181 #define SERIAL_SETCLK _IOW ('x', 9, int)
183 #define E1CLK_RECOVERY -1
184 #define E1CLK_INTERNAL 0
185 #define E1CLK_RECEIVE 1
186 #define E1CLK_RECEIVE_CHAN0 2
187 #define E1CLK_RECEIVE_CHAN1 3
188 #define E1CLK_RECEIVE_CHAN2 4
189 #define E1CLK_RECEIVE_CHAN3 5
192 * Query/set the E1 timeslot mask.
194 #define SERIAL_GETTIMESLOTS _IOR ('x', 10, long)
195 #define SERIAL_SETTIMESLOTS _IOW ('x', 10, long)
198 * Query/set the E1 subchannel timeslot mask.
200 #define SERIAL_GETSUBCHAN _IOR ('x', 11, long)
201 #define SERIAL_SETSUBCHAN _IOW ('x', 11, long)
204 * Query/set the high input sensitivity mode (E1).
206 #define SERIAL_GETHIGAIN _IOR ('x', 12, int)
207 #define SERIAL_SETHIGAIN _IOW ('x', 12, int)
210 * Query the input signal level in santibells.
212 #define SERIAL_GETLEVEL _IOR ('x', 13, int)
215 * Get the channel name.
217 #define SERIAL_GETNAME _IOR ('x', 14, char [32])
220 * Get version string.
222 #define SERIAL_GETVERSIONSTRING _IOR ('x', 15, char [256])
225 * Query/set master channel.
227 #define SERIAL_GETMASTER _IOR ('x', 16, char [16])
228 #define SERIAL_SETMASTER _IOW ('x', 16, char [16])
231 * Query/set keepalive.
233 #define SERIAL_GETKEEPALIVE _IOR ('x', 17, int)
234 #define SERIAL_SETKEEPALIVE _IOW ('x', 17, int)
237 * Query/set E1 configuration.
239 #define SERIAL_GETCFG _IOR ('x', 18, char)
240 #define SERIAL_SETCFG _IOW ('x', 18, char)
245 #define SERIAL_GETDEBUG _IOR ('x', 19, int)
246 #define SERIAL_SETDEBUG _IOW ('x', 19, int)
249 * Query/set phony mode (E1).
251 #define SERIAL_GETPHONY _IOR ('x', 20, int)
252 #define SERIAL_SETPHONY _IOW ('x', 20, int)
255 * Query/set timeslot 16 usage mode (E1).
257 #define SERIAL_GETUSE16 _IOR ('x', 21, int)
258 #define SERIAL_SETUSE16 _IOW ('x', 21, int)
261 * Query/set crc4 mode (E1).
263 #define SERIAL_GETCRC4 _IOR ('x', 22, int)
264 #define SERIAL_SETCRC4 _IOW ('x', 22, int)
267 * Query/set the timeout to recover after transmit interrupt loss.
268 * If timo==0 recover will be disabled.
270 #define SERIAL_GETTIMO _IOR ('x', 23, long)
271 #define SERIAL_SETTIMO _IOW ('x', 23, long)
274 * Query/set port type for old models of Sigma
275 * -1 Fixed or cable select
279 * 3 E1 (only for Windows 2000)
280 * 4 G.703 (only for Windows 2000)
281 * 5 DATA (only for Windows 2000)
282 * 6 E3 (only for Windows 2000)
283 * 7 T3 (only for Windows 2000)
284 * 8 STS1 (only for Windows 2000)
286 #define SERIAL_GETPORT _IOR ('x', 25, int)
287 #define SERIAL_SETPORT _IOW ('x', 25, int)
290 * Add the virtual channel DLCI (Frame Relay).
292 #define SERIAL_ADDDLCI _IOW ('x', 26, int)
295 * Invert receive clock.
297 #define SERIAL_GETINVRCLK _IOR ('x', 27, int)
298 #define SERIAL_SETINVRCLK _IOW ('x', 27, int)
301 * Invert transmit clock.
303 #define SERIAL_GETINVTCLK _IOR ('x', 28, int)
304 #define SERIAL_SETINVTCLK _IOW ('x', 28, int)
309 #define SERIAL_GETUNFRAM _IOR ('x', 29, int)
310 #define SERIAL_SETUNFRAM _IOW ('x', 29, int)
313 * E1 monitoring mode.
315 #define SERIAL_GETMONITOR _IOR ('x', 30, int)
316 #define SERIAL_SETMONITOR _IOW ('x', 30, int)
321 #define SERIAL_GETIRQ _IOR ('x', 31, int)
326 #define SERIAL_RESET _IO ('x', 32)
331 #define SERIAL_HARDRESET _IO ('x', 33)
336 #define SERIAL_GETCABLE _IOR ('x', 34, int)
339 * Assignment of HDLC ports to E1 channels.
341 #define SERIAL_GETDIR _IOR ('x', 35, int)
342 #define SERIAL_SETDIR _IOW ('x', 35, int)
344 struct dxc_table { /* cross-connector parameters */
345 unsigned char ts [32]; /* timeslot number */
346 unsigned char link [32]; /* E1 link number */
350 * DXC cross-connector settings for E1 channels.
352 #define SERIAL_GETDXC _IOR ('x', 36, struct dxc_table)
353 #define SERIAL_SETDXC _IOW ('x', 36, struct dxc_table)
356 * Scrambler for G.703.
358 #define SERIAL_GETSCRAMBLER _IOR ('x', 37, int)
359 #define SERIAL_SETSCRAMBLER _IOW ('x', 37, int)
362 * Length of cable for T3 and STS-1.
364 #define SERIAL_GETCABLEN _IOR ('x', 38, int)
365 #define SERIAL_SETCABLEN _IOW ('x', 38, int)
368 * Remote loopback for E3, T3 and STS-1.
370 #define SERIAL_GETRLOOP _IOR ('x', 39, int)
371 #define SERIAL_SETRLOOP _IOW ('x', 39, int)
376 #define SERIAL_GETLCODE _IOR ('x', 40, int)
377 #define SERIAL_SETLCODE _IOW ('x', 40, int)
382 #define SERIAL_GETMTU _IOR ('x', 41, int)
383 #define SERIAL_SETMTU _IOW ('x', 41, int)
386 * Receive Queue Length
388 #define SERIAL_GETRQLEN _IOR ('x', 42, int)
389 #define SERIAL_SETRQLEN _IOW ('x', 42, int)
393 # define LYSAP_PEER_ADD _IOWR('x', 101, lysap_peer_config_t)
394 # define LYSAP_PEER_REMOVE _IOW('x', 102, unsigned)
395 # define LYSAP_PEER_INFO _IOWR('x', 103, lysap_peer_info_t)
396 # define LYSAP_PEER_COUNT _IOR('x', 104, unsigned)
397 # define LYSAP_PEER_ENUM _IOWR('x', 105, unsigned)
398 # define LYSAP_PEER_CLEAR _IOW('x', 106, unsigned)
400 # define LYSAP_CHAN_ADD _IOWR('x', 111, lysap_channel_config_t)
401 # define LYSAP_CHAN_REMOVE _IO('x', 112)
402 # define LYSAP_CHAN_INFO _IOR('x', 113, lysap_channel_info_t)
403 # define LYSAP_CHAN_COUNT _IOR('x', 114, unsigned)
404 # define LYSAP_CHAN_ENUM _IOWR('x', 115, unsigned)
405 # define LYSAP_CHAN_CLEAR _IO('x', 116)
406 # include "lysap-linux.h"
407 #else /* CRONYX_LYSAP */
408 typedef struct _lysap_channel_t lysap_channel_t;
409 typedef struct _lysap_channel_config_t lysap_channel_config_t;
410 typedef struct _LYSAP_DeviceInterfaceConfig LYSAP_DeviceInterfaceConfig;
411 typedef struct _LYSAP_ChannelConfig LYSAP_ChannelConfig;
412 typedef struct _lysap_buf_t lysap_buf_t;
413 #endif /* !CRONYX_LYSAP */
416 * Dynamic binder interface.
418 typedef struct _chan_t chan_t;
419 typedef struct _proto_t proto_t;
421 void binder_register_protocol (proto_t *p);
422 void binder_unregister_protocol (proto_t *p);
424 int binder_register_channel (chan_t *h, char *prefix, int minor);
425 void binder_unregister_channel (chan_t *h);
428 * Hardware channel driver structure.
434 int mtu; /* max packet size */
435 int fifosz; /* total hardware i/o buffer size */
436 int port; /* hardware base i/o port */
437 int irq; /* hardware interrupt line */
438 int minor; /* minor number 0..127, assigned by binder */
439 int debug; /* debug level, 0..2 */
440 int running; /* running, 0..1 */
441 struct _proto_t *proto; /* protocol interface data */
442 void *sw; /* protocol private data */
443 void *hw; /* hardware layer private data */
445 /* Interface to protocol */
446 int (*up) (chan_t *h);
447 void (*down) (chan_t *h);
448 int (*transmit) (chan_t *h, struct sk_buff *skb);
449 void (*set_dtr) (chan_t *h, int val);
450 void (*set_rts) (chan_t *h, int val);
451 int (*query_dtr) (chan_t *h);
452 int (*query_rts) (chan_t *h);
453 int (*query_dsr) (chan_t *h);
454 int (*query_cts) (chan_t *h);
455 int (*query_dcd) (chan_t *h);
457 /* Interface to async protocol */
458 void (*set_async_param) (chan_t *h, int baud, int bits, int parity,
459 int stop2, int ignpar, int rtscts,
460 int ixon, int ixany, int symstart, int symstop);
461 void (*send_break) (chan_t *h, int msec);
462 void (*send_xon) (chan_t *h);
463 void (*send_xoff) (chan_t *h);
464 void (*start_transmitter) (chan_t *h);
465 void (*stop_transmitter) (chan_t *h);
466 void (*flush_transmit_buffer) (chan_t *h);
468 /* Control interface */
469 int (*control) (chan_t *h, unsigned int cmd, unsigned long arg);
471 /* LYSAP interface */
474 lysap_channel_t *link;
475 int (*inspect_config)(chan_t *h, lysap_channel_config_t *,
476 LYSAP_DeviceInterfaceConfig *, LYSAP_ChannelConfig *);
477 unsigned long (*probe_freq)(chan_t *h, unsigned long freq);
478 unsigned long (*set_freq)(chan_t *h, unsigned long freq);
479 unsigned (*get_status)(chan_t *h);
480 int (*transmit) (chan_t *h, lysap_buf_t *b);
481 lysap_buf_t* (*alloc_buf) (chan_t *h, unsigned len);
482 int (*set_clock_master)(chan_t *h, int enable);
483 unsigned long (*get_master_freq)(chan_t *h);
488 * Protocol driver structure.
492 struct _proto_t *next;
494 /* Interface to channel */
495 void (*receive) (chan_t *h, struct sk_buff *skb);
496 void (*receive_error) (chan_t *h, int errcode);
497 void (*transmit) (chan_t *h);
498 void (*modem_event) (chan_t *h);
500 /* Interface to binder */
501 int (*open) (chan_t *h);
502 void (*close) (chan_t *h);
503 int (*read) (chan_t *h, unsigned short flg, char *buf, int len);
504 int (*write) (chan_t *h, unsigned short flg, const char *buf, int len);
505 int (*select) (chan_t *h, int type, void *st, struct file *filp);
506 struct fasync_struct *fasync;
508 /* Control interface */
509 int (*attach) (chan_t *h);
510 int (*detach) (chan_t *h);
511 int (*control) (chan_t *h, unsigned int cmd, unsigned long arg);
513 /* LYSAP interface */
514 void (*transmit_error) (chan_t *h, int errcode);
515 void (*lysap_notify_receive) (chan_t *h, lysap_buf_t *b);
516 void (*lysap_notify_transmit) (chan_t *h);
517 lysap_buf_t* (*lysap_get_data)(chan_t *h);