xref: /freebsd-13-stable/sys/dev/ce/ceddk.h (revision 4b40a16f0d188422227478889b38cc341d50f88f)
1 /*
2  * Middle-level code for Cronyx Tau32-PCI adapters.
3  *
4  * Copyright (C) 2004 Cronyx Engineering
5  * Copyright (C) 2004 Roman Kurakin <rik@FreeBSD.org>
6  *
7  * This software is distributed with NO WARRANTIES, not even the implied
8  * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9  *
10  * Authors grant any other persons or organisations a permission to use,
11  * modify and redistribute this software in source and binary forms,
12  * as long as this message is kept with the software, all derivative
13  * works or modified versions.
14  *
15  * $Cronyx: ceddk.h,v 1.2.6.1 2005/11/09 13:01:39 rik Exp $
16  */
17 
18 #define TAU32_UserContext_Add	void	*sys;
19 #define TAU32_UserRequest_Add	void	*sys; TAU32_UserRequest *next;
20 
21 #include <dev/ce/tau32-ddk.h>
22 
23 #define NCHAN	TAU32_CHANNELS
24 #ifndef NBRD
25 #   define NBRD 6
26 #endif
27 #if NBRD != 6
28 #   error "NBRD != 6"
29 #endif
30 
31 #define BUFSZ	1664
32 
33 typedef struct _ce_buf_item_t {
34 	TAU32_UserRequest req;
35 	unsigned char buf [BUFSZ+4];
36 	unsigned long phys;
37 } ce_buf_item_t;
38 
39 typedef struct _ce_buf_t {
40 	ce_buf_item_t tx_item[TAU32_IO_QUEUE];
41 	ce_buf_item_t rx_item[TAU32_IO_QUEUE];
42 } ce_buf_t;
43 
44 typedef struct {
45 	unsigned long bpv;		/* bipolar violations */
46 	unsigned long fse;		/* frame sync errors */
47 	unsigned long crce;		/* CRC errors */
48 	unsigned long rcrce;		/* remote CRC errors (E-bit) */
49 	unsigned long uas;		/* unavailable seconds */
50 	unsigned long les;		/* line errored seconds */
51 	unsigned long es;		/* errored seconds */
52 	unsigned long bes;		/* bursty errored seconds */
53 	unsigned long ses;		/* severely errored seconds */
54 	unsigned long oofs;		/* out of frame seconds */
55 	unsigned long css;		/* controlled slip seconds */
56 	unsigned long dm;		/* degraded minutes */
57 } ce_gstat_t;
58 
59 typedef struct _ce_chan_t {
60 	unsigned char num;
61 	unsigned char type;
62 #define T_NONE		0		/* no channel */
63 #define T_E1		3		/* E1 */
64 #define T_DATA		6		/* no physical interface */
65 
66 	struct _ce_board_t *board;
67 	unsigned char dtr;
68 	unsigned char rts;
69 	ce_buf_item_t *tx_item;
70 	ce_buf_item_t *rx_item;
71 	TAU32_UserRequest *rx_queue;
72 	TAU32_UserRequest *tx_queue;
73 	unsigned char debug;
74 	unsigned char debug_shadow;
75 	void (*transmit) (struct _ce_chan_t*, void*, int);
76 	void (*receive) (struct _ce_chan_t*, unsigned char*, int);
77 	void (*error) (struct _ce_chan_t*, int);
78 #define CE_FRAME	 1
79 #define CE_CRC		 2
80 #define CE_UNDERRUN	 3
81 #define CE_OVERRUN	 4
82 #define CE_OVERFLOW	 5
83 	int tx_pending;
84 	int rx_pending;
85 	unsigned long rintr;
86 	unsigned long tintr;
87 	ulong64	ibytes;
88 	ulong64	obytes;
89 	unsigned long ipkts;
90 	unsigned long opkts;
91 	unsigned long underrun;
92 	unsigned long overrun;
93 	unsigned long frame;
94 	unsigned long crc;
95 
96 	unsigned short status;		/* E1/G.703 line status bit mask */
97 #define ESTS_NOALARM	0x0001		/* no alarm present */
98 #define ESTS_FARLOF	0x0002		/* receiving far loss of framing */
99 #define ESTS_AIS	0x0008		/* receiving all ones */
100 #define ESTS_LOF	0x0020		/* loss of framing */
101 #define ESTS_LOS	0x0040		/* loss of signal */
102 #define ESTS_AIS16	0x0100		/* receiving all ones in timeslot 16 */
103 #define ESTS_FARLOMF	0x0200		/* receiving alarm in timeslot 16 */
104 #define ESTS_LOMF	0x0400		/* loss of multiframe sync */
105 #define ESTS_TSTREQ	0x0800		/* test code detected */
106 #define ESTS_TSTERR	0x1000		/* test error */
107 
108 	unsigned long totsec;		/* total seconds elapsed */
109 	unsigned long cursec;		/* current seconds elapsed */
110 	unsigned long degsec;		/* degraded seconds */
111 	unsigned long degerr;		/* errors during degraded seconds */
112 	ce_gstat_t currnt;		/* current 15-min interval data */
113 	ce_gstat_t total;		/* total statistics data */
114 	ce_gstat_t interval [48];	/* 12 hour period data */
115 
116 	unsigned int acc_status;
117 	unsigned long config;
118 	unsigned long baud;
119 	unsigned long ts;
120 	unsigned long ts_mask;
121 	unsigned char dir;
122 	unsigned char lloop;
123 	unsigned char rloop;
124 	unsigned char higain;
125 	unsigned char phony;
126 	unsigned char scrambler;
127 	unsigned char unfram;
128 	unsigned char monitor;
129 	unsigned char crc4;
130 	unsigned char use16;
131 	unsigned char gsyn;		/* G.703 clock mode */
132 #define GSYN_INT	0		/* internal transmit clock source */
133 #define GSYN_RCV	1		/* transmit clock source = receive */
134 #define GSYN_RCV0	2		/* tclk = rclk from channel 0 */
135 #define GSYN_RCV1	3		/* ...from channel 1 */
136 	unsigned long mtu;
137 	void *sys;
138 } ce_chan_t;
139 
140 #define CONFREQSZ	128
141 typedef struct _ce_conf_req {
142 	TAU32_UserRequest req[CONFREQSZ+10];
143 	TAU32_UserRequest *queue;
144 	int	pending;
145 } ce_conf_req;
146 
147 typedef struct _ce_board_t {
148 	TAU32_UserContext	ddk;
149 	ce_chan_t		chan[NCHAN];
150 	int			num;
151 	int			mux;
152 #define TAU32_BASE_NAME		"Tau-PCI-32"
153 #define TAU32_LITE_NAME		"Tau-PCI-32/Lite"
154 #define TAU32_ADPCM_NAME	"Tau-PCI-32/ADPCM"
155 #define TAU32_UNKNOWN_NAME	"Unknown Tau-PCI-32"
156 	char			name [32];
157 	ce_conf_req		cr;
158 	TAU32_CrossMatrix	dxc;
159 	unsigned long		pmask;
160 	void *sys;
161 } ce_board_t;
162 
163 void ce_set_dtr (ce_chan_t *c, int on);
164 void ce_set_rts (ce_chan_t *c, int on);
165 int ce_get_cd (ce_chan_t *c);
166 int ce_get_cts (ce_chan_t *c);
167 int ce_get_dsr (ce_chan_t *c);
168 
169 int ce_transmit_space (ce_chan_t *c);
170 int ce_send_packet (ce_chan_t *c, unsigned char *buf, int len, void *tag);
171 void ce_start_chan (ce_chan_t *c, int tx, int rx, ce_buf_t *cb, unsigned long phys);
172 void ce_stop_chan (ce_chan_t *c);
173 void ce_register_transmit (ce_chan_t *c, void (*func) (ce_chan_t*, void*, int));
174 void ce_register_receive (ce_chan_t *c, void (*func) (ce_chan_t*,
175 							unsigned char*, int));
176 void ce_register_error (ce_chan_t *c, void (*func) (ce_chan_t*, int));
177 
178 void TAU32_CALLBACK_TYPE
179 	ce_error_callback(TAU32_UserContext *pContext, int Item,
180 			  unsigned NotifyBits);
181 void TAU32_CALLBACK_TYPE
182 	ce_status_callback(TAU32_UserContext *pContext, int Item,
183 			  unsigned NotifyBits);
184 
185 void ce_set_baud (ce_chan_t *c, unsigned long baud);
186 void ce_set_lloop (ce_chan_t *c, unsigned char on);
187 void ce_set_rloop (ce_chan_t *c, unsigned char on);
188 void ce_set_higain (ce_chan_t *c, unsigned char on);
189 void ce_set_unfram (ce_chan_t *c, unsigned char on);
190 void ce_set_ts (ce_chan_t *c, unsigned long ts);
191 void ce_set_phony (ce_chan_t *c, unsigned char on);
192 void ce_set_scrambler (ce_chan_t *c, unsigned char on);
193 void ce_set_monitor (ce_chan_t *c, unsigned char on);
194 void ce_set_use16 (ce_chan_t *c, unsigned char on);
195 void ce_set_crc4 (ce_chan_t *c, unsigned char on);
196 void ce_set_gsyn (ce_chan_t *c, int syn);
197 #define CABLE_TP		11
198 int ce_get_cable (ce_chan_t *c);
199 void ce_set_dir (ce_chan_t *c, int dir);
200 void ce_e1_timer (ce_chan_t *c);
201 void ce_init_board (ce_board_t *b);
202