cserial.h revision 139790
1139790Simp/*-
2123120Simp * Ioctl interface to Cronyx serial drivers.
3123120Simp *
4123120Simp * Copyright (C) 1997-2002 Cronyx Engineering.
5123120Simp * Author: Serge Vakulenko, <vak@cronyx.ru>
6123120Simp *
7123120Simp * Copyright (C) 2001-2003 Cronyx Engineering.
8123120Simp * Author: Roman Kurakin, <rik@cronyx.ru>
9123120Simp *
10123120Simp * This software is distributed with NO WARRANTIES, not even the implied
11123120Simp * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12123120Simp *
13123120Simp * Authors grant any other persons or organisations permission to use
14123120Simp * or modify this software as long as this message is kept with the software,
15123120Simp * all derivative works or modified versions.
16123120Simp *
17123120Simp * Cronyx Id: cserial.h,v 1.1.2.4 2003/11/12 17:11:08 rik Exp $
18123120Simp * $FreeBSD: head/sys/i386/include/cserial.h 139790 2005-01-06 22:18:23Z imp $
19123120Simp */
20123120Simp
21123120Simp/*
22123120Simp * General channel statistics.
23123120Simp */
24123120Simpstruct serial_statistics {
25123120Simp	unsigned long rintr;		/* receive interrupts */
26123120Simp	unsigned long tintr;		/* transmit interrupts */
27123120Simp	unsigned long mintr;		/* modem interrupts */
28123120Simp	unsigned long ibytes;		/* input bytes */
29123120Simp	unsigned long ipkts;		/* input packets */
30123120Simp	unsigned long ierrs;		/* input errors */
31123120Simp	unsigned long obytes;		/* output bytes */
32123120Simp	unsigned long opkts;		/* output packets */
33123120Simp	unsigned long oerrs;		/* output errors */
34123120Simp};
35123120Simp
36123120Simp/*
37123120Simp * Statistics for E1/G703 channels.
38123120Simp */
39123120Simpstruct e1_counters {
40123120Simp	unsigned long bpv;		/* bipolar violations */
41123120Simp	unsigned long fse;		/* frame sync errors */
42123120Simp	unsigned long crce;		/* CRC errors */
43123120Simp	unsigned long rcrce;		/* remote CRC errors (E-bit) */
44123120Simp	unsigned long uas;		/* unavailable seconds */
45123120Simp	unsigned long les;		/* line errored seconds */
46123120Simp	unsigned long es;		/* errored seconds */
47123120Simp	unsigned long bes;		/* bursty errored seconds */
48123120Simp	unsigned long ses;		/* severely errored seconds */
49123120Simp	unsigned long oofs;		/* out of frame seconds */
50123120Simp	unsigned long css;		/* controlled slip seconds */
51123120Simp	unsigned long dm;		/* degraded minutes */
52123120Simp};
53123120Simp
54123120Simpstruct e1_statistics {
55123120Simp	unsigned long status;		/* line status bit mask */
56123120Simp	unsigned long cursec;		/* seconds in current interval */
57123120Simp	unsigned long totsec;		/* total seconds elapsed */
58123120Simp	struct e1_counters currnt;	/* current 15-min interval data */
59123120Simp	struct e1_counters total;	/* total statistics data */
60123120Simp	struct e1_counters interval [48]; /* 12 hour period data */
61123120Simp};
62123120Simp
63123120Simpstruct e3_statistics {
64123120Simp	unsigned long status;
65123120Simp	unsigned long cursec;
66123120Simp	unsigned long totsec;
67123120Simp	unsigned long ccv;
68123120Simp	unsigned long tcv;
69123120Simp	unsigned long icv[48];
70123120Simp};
71123120Simp
72123120Simp#define M_ASYNC         0		/* asynchronous mode */
73123120Simp#define M_HDLC          1		/* bit-sync mode (HDLC) */
74123120Simp#define M_G703          2
75123120Simp#define M_E1            3
76123120Simp
77123120Simp/*
78123120Simp * Receive error codes.
79123120Simp */
80123120Simp#define ER_FRAMING	1		/* framing error */
81123120Simp#define ER_CHECKSUM	2		/* parity/CRC error */
82123120Simp#define ER_BREAK	3		/* break state */
83123120Simp#define ER_OVERFLOW	4		/* receive buffer overflow */
84123120Simp#define ER_OVERRUN	5		/* receive fifo overrun */
85123120Simp#define ER_UNDERRUN	6		/* transmit fifo underrun */
86123120Simp#define ER_SCC_FRAMING	7		/* subchannel framing error */
87123120Simp#define ER_SCC_OVERFLOW	8		/* subchannel receive buffer overflow */
88123120Simp#define ER_SCC_OVERRUN	9		/* subchannel receiver overrun */
89123120Simp
90123120Simp/*
91123120Simp * E1 channel status.
92123120Simp */
93123120Simp#define E1_NOALARM	0x0001          /* no alarm present */
94123120Simp#define E1_FARLOF	0x0002          /* receiving far loss of framing */
95123120Simp#define E1_AIS		0x0008          /* receiving all ones */
96123120Simp#define E1_LOF		0x0020          /* loss of framing */
97123120Simp#define E1_LOS		0x0040          /* loss of signal */
98123120Simp#define E1_AIS16	0x0100          /* receiving all ones in timeslot 16 */
99123120Simp#define E1_FARLOMF	0x0200          /* receiving alarm in timeslot 16 */
100123120Simp#define E1_LOMF		0x0400          /* loss of multiframe sync */
101123120Simp#define E1_TSTREQ	0x0800          /* test code detected */
102123120Simp#define E1_TSTERR	0x1000          /* test error */
103123120Simp
104123120Simp#define E3_LOS		0x00000002	/* Lost of synchronization */
105123120Simp#define E3_TXE		0x00000004	/* Transmit error */
106123120Simp
107123120Simp/*
108123120Simp * Query the mask of all registered channels, max 128.
109123120Simp */
110123120Simp#define SERIAL_GETREGISTERED	_IOR ('x', 0, char[16])
111123120Simp
112123120Simp/*
113123120Simp * Attach/detach the protocol to the channel.
114123120Simp * The protocol is given by it's name, char[8].
115123120Simp * For example "async", "hdlc", "cisco", "fr", "ppp".
116123120Simp */
117123120Simp#define SERIAL_GETPROTO		_IOR ('x', 1, char [8])
118123120Simp#define SERIAL_SETPROTO		_IOW ('x', 1, char [8])
119123120Simp
120123120Simp/*
121123120Simp * Query/set the hardware mode for the channel.
122123120Simp */
123123120Simp#define SERIAL_GETMODE		_IOR ('x', 2, int)
124123120Simp#define SERIAL_SETMODE		_IOW ('x', 2, int)
125123120Simp
126123120Simp#define SERIAL_ASYNC		1
127123120Simp#define SERIAL_HDLC		2
128123120Simp
129123120Simp/*
130123120Simp * Get/clear the channel statistics.
131123120Simp */
132123120Simp#define SERIAL_GETSTAT		_IOR ('x', 3, struct serial_statistics)
133123120Simp#define SERIAL_GETESTAT		_IOR ('x', 3, struct e1_statistics)
134123120Simp#define SERIAL_GETE3STAT	_IOR ('x', 3, struct e3_statistics)
135123120Simp#define SERIAL_CLRSTAT		_IO  ('x', 3)
136123120Simp
137123120Simp/*
138123120Simp * Query/set the synchronization mode and baud rate.
139123120Simp * If baud==0 then the external clock is used.
140123120Simp */
141123120Simp#define SERIAL_GETBAUD		_IOR ('x', 4, long)
142123120Simp#define SERIAL_SETBAUD		_IOW ('x', 4, long)
143123120Simp
144123120Simp/*
145123120Simp * Query/set the internal loopback mode,
146123120Simp * useful for debugging purposes.
147123120Simp */
148123120Simp#define SERIAL_GETLOOP		_IOR ('x', 5, int)
149123120Simp#define SERIAL_SETLOOP		_IOW ('x', 5, int)
150123120Simp
151123120Simp/*
152123120Simp * Query/set the DPLL mode, commonly used with NRZI
153123120Simp * for channels lacking synchro signals.
154123120Simp */
155123120Simp#define SERIAL_GETDPLL		_IOR ('x', 6, int)
156123120Simp#define SERIAL_SETDPLL		_IOW ('x', 6, int)
157123120Simp
158123120Simp/*
159123120Simp * Query/set the NRZI encoding (default is NRZ).
160123120Simp */
161123120Simp#define SERIAL_GETNRZI		_IOR ('x', 7, int)
162123120Simp#define SERIAL_SETNRZI		_IOW ('x', 7, int)
163123120Simp
164123120Simp/*
165123120Simp * Invert receive and transmit clock.
166123120Simp */
167123120Simp#define SERIAL_GETINVCLK	_IOR ('x', 8, int)
168123120Simp#define SERIAL_SETINVCLK	_IOW ('x', 8, int)
169123120Simp
170123120Simp/*
171123120Simp * Query/set the E1/G703 synchronization mode.
172123120Simp */
173123120Simp#define SERIAL_GETCLK		_IOR ('x', 9, int)
174123120Simp#define SERIAL_SETCLK		_IOW ('x', 9, int)
175123120Simp
176123120Simp#define E1CLK_INTERNAL		0
177123120Simp#define E1CLK_RECEIVE		1
178123120Simp#define E1CLK_RECEIVE_CHAN0	2
179123120Simp#define E1CLK_RECEIVE_CHAN1	3
180123120Simp#define E1CLK_RECEIVE_CHAN2	4
181123120Simp#define E1CLK_RECEIVE_CHAN3	5
182123120Simp
183123120Simp/*
184123120Simp * Query/set the E1 timeslot mask.
185123120Simp */
186123120Simp#define SERIAL_GETTIMESLOTS	_IOR ('x', 10, long)
187123120Simp#define SERIAL_SETTIMESLOTS	_IOW ('x', 10, long)
188123120Simp
189123120Simp/*
190123120Simp * Query/set the E1 subchannel timeslot mask.
191123120Simp */
192123120Simp#define SERIAL_GETSUBCHAN	_IOR ('x', 11, long)
193123120Simp#define SERIAL_SETSUBCHAN	_IOW ('x', 11, long)
194123120Simp
195123120Simp/*
196123120Simp * Query/set the high input sensitivity mode (E1).
197123120Simp */
198123120Simp#define SERIAL_GETHIGAIN	_IOR ('x', 12, int)
199123120Simp#define SERIAL_SETHIGAIN	_IOW ('x', 12, int)
200123120Simp
201123120Simp/*
202123120Simp * Query the input signal level in santibells.
203123120Simp */
204123120Simp#define SERIAL_GETLEVEL		_IOR ('x', 13, int)
205123120Simp
206123120Simp/*
207123120Simp * Get the channel name.
208123120Simp */
209123120Simp#define SERIAL_GETNAME		_IOR ('x', 14, char [32])
210123120Simp
211123120Simp/*
212123120Simp * Get version string.
213123120Simp */
214123120Simp#define SERIAL_GETVERSIONSTRING _IOR ('x', 15, char [256])
215123120Simp
216123120Simp/*
217123120Simp * Query/set master channel.
218123120Simp */
219123120Simp#define SERIAL_GETMASTER	_IOR ('x', 16, char [16])
220123120Simp#define SERIAL_SETMASTER 	_IOW ('x', 16, char [16])
221123120Simp
222123120Simp/*
223123120Simp * Query/set keepalive.
224123120Simp */
225123120Simp#define SERIAL_GETKEEPALIVE 	_IOR ('x', 17, int)
226123120Simp#define SERIAL_SETKEEPALIVE 	_IOW ('x', 17, int)
227123120Simp
228123120Simp/*
229123120Simp * Query/set E1 configuration.
230123120Simp */
231123120Simp#define SERIAL_GETCFG		_IOR ('x', 18, char)
232123120Simp#define SERIAL_SETCFG		_IOW ('x', 18, char)
233123120Simp
234123120Simp/*
235123120Simp * Query/set debug.
236123120Simp */
237123120Simp#define SERIAL_GETDEBUG		_IOR ('x', 19, int)
238123120Simp#define SERIAL_SETDEBUG		_IOW ('x', 19, int)
239123120Simp
240123120Simp/*
241123120Simp * Query/set phony mode (E1).
242123120Simp */
243123120Simp#define SERIAL_GETPHONY		_IOR ('x', 20, int)
244123120Simp#define SERIAL_SETPHONY		_IOW ('x', 20, int)
245123120Simp
246123120Simp/*
247123120Simp * Query/set timeslot 16 usage mode (E1).
248123120Simp */
249123120Simp#define SERIAL_GETUSE16		_IOR ('x', 21, int)
250123120Simp#define SERIAL_SETUSE16		_IOW ('x', 21, int)
251123120Simp
252123120Simp/*
253123120Simp * Query/set crc4 mode (E1).
254123120Simp */
255123120Simp#define SERIAL_GETCRC4		_IOR ('x', 22, int)
256123120Simp#define SERIAL_SETCRC4		_IOW ('x', 22, int)
257123120Simp
258123120Simp/*
259123120Simp * Query/set the timeout to recover after transmit interrupt loss.
260123120Simp * If timo==0 recover will be disabled.
261123120Simp */
262123120Simp#define SERIAL_GETTIMO		_IOR ('x', 23, long)
263123120Simp#define SERIAL_SETTIMO		_IOW ('x', 23, long)
264123120Simp
265123120Simp/*
266123120Simp * Query/set port type for old models of Sigma
267123120Simp * -1 Fixed or cable select
268123120Simp * 0  RS-232
269123120Simp * 1  V35
270123120Simp * 2  RS-449
271123120Simp * 3  E1	(only for Windows 2000)
272123120Simp * 4  G.703	(only for Windows 2000)
273123120Simp * 5  DATA	(only for Windows 2000)
274123120Simp * 6  E3	(only for Windows 2000)
275123120Simp * 7  T3	(only for Windows 2000)
276123120Simp * 8  STS1	(only for Windows 2000)
277123120Simp */
278123120Simp#define SERIAL_GETPORT		_IOR ('x', 25, int)
279123120Simp#define SERIAL_SETPORT		_IOW ('x', 25, int)
280123120Simp
281123120Simp/*
282123120Simp * Add the virtual channel DLCI (Frame Relay).
283123120Simp */
284123120Simp#define SERIAL_ADDDLCI		_IOW ('x', 26, int)
285123120Simp
286123120Simp/*
287123120Simp * Invert receive clock.
288123120Simp */
289123120Simp#define SERIAL_GETINVRCLK	_IOR ('x', 27, int)
290123120Simp#define SERIAL_SETINVRCLK	_IOW ('x', 27, int)
291123120Simp
292123120Simp/*
293123120Simp * Invert transmit clock.
294123120Simp */
295123120Simp#define SERIAL_GETINVTCLK	_IOR ('x', 28, int)
296123120Simp#define SERIAL_SETINVTCLK	_IOW ('x', 28, int)
297123120Simp
298123120Simp/*
299123120Simp * Unframed E1 mode.
300123120Simp */
301123120Simp#define SERIAL_GETUNFRAM	_IOR ('x', 29, int)
302123120Simp#define SERIAL_SETUNFRAM	_IOW ('x', 29, int)
303123120Simp
304123120Simp/*
305123120Simp * E1 monitoring mode.
306123120Simp */
307123120Simp#define SERIAL_GETMONITOR	_IOR ('x', 30, int)
308123120Simp#define SERIAL_SETMONITOR	_IOW ('x', 30, int)
309123120Simp
310123120Simp/*
311123120Simp * Interrupt number.
312123120Simp */
313123120Simp#define SERIAL_GETIRQ		_IOR ('x', 31, int)
314123120Simp
315123120Simp/*
316123120Simp * Reset.
317123120Simp */
318123120Simp#define SERIAL_RESET		_IO ('x', 32)
319123120Simp
320123120Simp/*
321123120Simp * Hard reset.
322123120Simp */
323123120Simp#define SERIAL_HARDRESET	_IO ('x', 33)
324123120Simp
325123120Simp/*
326123120Simp * Query cable type.
327123120Simp */
328123120Simp#define SERIAL_GETCABLE		_IOR ('x', 34, int)
329123120Simp
330123120Simp/*
331123120Simp * Assignment of HDLC ports to E1 channels.
332123120Simp */
333123120Simp#define SERIAL_GETDIR		_IOR ('x', 35, int)
334123120Simp#define SERIAL_SETDIR		_IOW ('x', 35, int)
335123120Simp
336123120Simpstruct dxc_table {			/* cross-connector parameters */
337123120Simp	unsigned char ts [32];		/* timeslot number */
338123120Simp	unsigned char link [32];	/* E1 link number */
339123120Simp};
340123120Simp
341123120Simp/*
342123120Simp * DXC cross-connector settings for E1 channels.
343123120Simp */
344123120Simp#define SERIAL_GETDXC		_IOR ('x', 36, struct dxc_table)
345123120Simp#define SERIAL_SETDXC		_IOW ('x', 36, struct dxc_table)
346123120Simp
347123120Simp/*
348123120Simp * Scrambler for G.703.
349123120Simp */
350123120Simp#define SERIAL_GETSCRAMBLER	_IOR ('x', 37, int)
351123120Simp#define SERIAL_SETSCRAMBLER	_IOW ('x', 37, int)
352123120Simp
353123120Simp/*
354123120Simp * Length of cable for T3 and STS-1.
355123120Simp */
356123120Simp#define SERIAL_GETCABLEN	_IOR ('x', 38, int)
357123120Simp#define SERIAL_SETCABLEN	_IOW ('x', 38, int)
358123120Simp
359123120Simp/*
360123120Simp * Remote loopback for E3, T3 and STS-1.
361123120Simp */
362123120Simp#define SERIAL_GETRLOOP		_IOR ('x', 39, int)
363123120Simp#define SERIAL_SETRLOOP		_IOW ('x', 39, int)
364123120Simp
365123120Simp/*
366123120Simp * Dynamic binder interface.
367123120Simp */
368123120Simp#ifdef __KERNEL__
369123120Simptypedef struct _chan_t chan_t;
370123120Simptypedef struct _proto_t proto_t;
371123120Simp
372123120Simpvoid binder_register_protocol (proto_t *p);
373123120Simpvoid binder_unregister_protocol (proto_t *p);
374123120Simp
375123120Simpint binder_register_channel (chan_t *h, char *prefix, int minor);
376123120Simpvoid binder_unregister_channel (chan_t *h);
377123120Simp
378123120Simp/*
379123120Simp * Hardware channel driver structure.
380123120Simp */
381123120Simpstruct sk_buff;
382123120Simp
383123120Simpstruct _chan_t {
384123120Simp	char name [16];
385123120Simp	int mtu;			/* max packet size */
386123120Simp	int fifosz;			/* total hardware i/o buffer size */
387123120Simp	int port;			/* hardware base i/o port */
388123120Simp	int irq;			/* hardware interrupt line */
389123120Simp	int minor;			/* minor number 0..127, assigned by binder */
390123120Simp	int debug;			/* debug level, 0..2 */
391123120Simp	int running;			/* running, 0..1 */
392123120Simp	struct _proto_t *proto;		/* protocol interface data */
393123120Simp	void *sw;			/* protocol private data */
394123120Simp	void *hw;			/* hardware layer private data */
395123120Simp
396123120Simp	/* Interface to protocol */
397123120Simp	int (*up) (chan_t *h);
398123120Simp	void (*down) (chan_t *h);
399123120Simp	int (*transmit) (chan_t *h, struct sk_buff *skb);
400123120Simp	void (*set_dtr) (chan_t *h, int val);
401123120Simp	void (*set_rts) (chan_t *h, int val);
402123120Simp	int (*query_dtr) (chan_t *h);
403123120Simp	int (*query_rts) (chan_t *h);
404123120Simp	int (*query_dsr) (chan_t *h);
405123120Simp	int (*query_cts) (chan_t *h);
406123120Simp	int (*query_dcd) (chan_t *h);
407123120Simp
408123120Simp	/* Interface to async protocol */
409123120Simp	void (*set_async_param) (chan_t *h, int baud, int bits, int parity,
410123120Simp		int stop2, int ignpar, int rtscts,
411123120Simp		int ixon, int ixany, int symstart, int symstop);
412123120Simp	void (*send_break) (chan_t *h, int msec);
413123120Simp	void (*send_xon) (chan_t *h);
414123120Simp	void (*send_xoff) (chan_t *h);
415123120Simp	void (*start_transmitter) (chan_t *h);
416123120Simp	void (*stop_transmitter) (chan_t *h);
417123120Simp	void (*flush_transmit_buffer) (chan_t *h);
418123120Simp
419123120Simp	/* Control interface */
420123120Simp	int (*control) (chan_t *h, unsigned int cmd, unsigned long arg);
421123120Simp};
422123120Simp
423123120Simp/*
424123120Simp * Protocol driver structure.
425123120Simp */
426123120Simpstruct _proto_t {
427123120Simp	char *name;
428123120Simp	struct _proto_t *next;
429123120Simp
430123120Simp	/* Interface to channel */
431123120Simp	void (*receive) (chan_t *h, struct sk_buff *skb);
432123120Simp	void (*receive_error) (chan_t *h, int errcode);
433123120Simp	void (*transmit) (chan_t *h);
434123120Simp	void (*modem_event) (chan_t *h);
435123120Simp
436123120Simp	/* Interface to binder */
437123120Simp	int (*open) (chan_t *h);
438123120Simp	void (*close) (chan_t *h);
439123120Simp	int (*read) (chan_t *h, unsigned short flg, char *buf, int len);
440123120Simp	int (*write) (chan_t *h, unsigned short flg, const char *buf, int len);
441123120Simp	int (*select) (chan_t *h, int type, void *st, struct file *filp);
442123120Simp	struct fasync_struct *fasync;
443123120Simp
444123120Simp	/* Control interface */
445123120Simp	int (*attach) (chan_t *h);
446123120Simp	int (*detach) (chan_t *h);
447123120Simp	int (*control) (chan_t *h, unsigned int cmd, unsigned long arg);
448123120Simp};
449123120Simp#endif /* KERNEL */
450