1 /* $OpenBSD: if_san_front_end.h,v 1.4 2004/12/07 06:10:24 mcbride Exp $ */
2
3 /*-
4 * Copyright (c) 2001-2004 Sangoma Technologies (SAN)
5 * All rights reserved. www.sangoma.com
6 *
7 * This code is written by Alex Feldman <al.feldman@sangoma.com> for SAN.
8 * The code is derived from permitted modifications to software created
9 * by Nenad Corbic (ncorbic@sangoma.com).
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following disclaimer
18 * in the documentation and/or other materials provided with the
19 * distribution.
20 * 3. Neither the name of Sangoma Technologies nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY SANGOMA TECHNOLOGIES AND CONTRIBUTORS
25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34 * THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 #ifndef __IF_SAN_FRONT_END_H_
38 #define __IF_SAN_FRONT_END_H_
39
40 /* The hardware media */
41 #define WAN_MEDIA_NONE 0x00 /* Regular card */
42 #define WAN_MEDIA_T1 0x01 /* T1 connection */
43 #define WAN_MEDIA_E1 0x02 /* E1 connection */
44 #define WAN_MEDIA_56K 0x03 /* 56K connection */
45
46 /* settings for the 'adapter_type' */
47 #define S508_ADPTR 0x0001 /* S508 */
48 #define S5141_ADPTR_1_CPU_SERIAL 0x0011 /* S5141, single CPU, serial */
49 #define S5142_ADPTR_2_CPU_SERIAL 0x0012 /* S5142, dual CPU, serial */
50 #define S5143_ADPTR_1_CPU_FT1 0x0013 /* S5143, single CPU, FT1 */
51 #define S5144_ADPTR_1_CPU_T1E1 0x0014 /* S5144, single CPU, T1/E1 */
52 #define S5145_ADPTR_1_CPU_56K 0x0015 /* S5145, single CPU, 56K */
53 #define S5147_ADPTR_2_CPU_T1E1 0x0017 /* S5147, dual CPU, T1/E1 */
54 #define S5148_ADPTR_1_CPU_T1E1 0x0018 /* S5148, single CPU, T1/E1 */
55
56 #define S518_ADPTR_1_CPU_ADSL 0x0018 /* S518, adsl card */
57
58 #define A101_ADPTR_T1E1_MASK 0x0040 /* T1/E1 type mask */
59 #define A101_ADPTR_1TE1 0x0041 /* 1 Channel T1/E1 */
60 #define A101_ADPTR_2TE1 0x0042 /* 2 Channels T1/E1 */
61
62 #define A100_ADPTR_T3E3_MASK 0x0080 /* T3/E3 type mask */
63 #define A100_ADPTR_1_CHN_T3E3 0x0081 /* 1 Channel T3/E3 (Proto.) */
64 #define A105_ADPTR_1_CHN_T3E3 0x0082 /* 1 Channel T3/E3 */
65
66 #define OPERATE_T1E1_AS_SERIAL 0x8000 /* For bitstreaming only
67 * Allow the applicatoin to
68 * E1 front end */
69
70 #define SDLA_ADPTR_DECODE(adapter_type) \
71 (adapter_type == S5141_ADPTR_1_CPU_SERIAL) ? "S514-1-PCI" : \
72 (adapter_type == S5142_ADPTR_2_CPU_SERIAL) ? "S514-2-PCI" : \
73 (adapter_type == S5143_ADPTR_1_CPU_FT1) ? "S514-3-PCI" : \
74 (adapter_type == S5144_ADPTR_1_CPU_T1E1) ? "S514-4-PCI" : \
75 (adapter_type == S5145_ADPTR_1_CPU_56K) ? "S514-5-PCI" : \
76 (adapter_type == S5147_ADPTR_2_CPU_T1E1) ? "S514-7-PCI" : \
77 (adapter_type == S518_ADPTR_1_CPU_ADSL) ? "S518-PCI " : \
78 (adapter_type == A101_ADPTR_1TE1) ? "AFT-A101 " : \
79 (adapter_type == A101_ADPTR_2TE1) ? "AFT-A102 " : \
80 (adapter_type == A105_ADPTR_1_CHN_T3E3) ? "A105-1-PCI" : \
81 (adapter_type == A105_ADPTR_1_CHN_T3E3) ? "A105-2 " : \
82 "UNKNOWN "
83
84 /* front-end UDP command */
85 #define WAN_FE_GET_STAT (WAN_FE_UDP_CMD_START + 0)
86 #define WAN_FE_SET_LB_MODE (WAN_FE_UDP_CMD_START + 1)
87 #define WAN_FE_FLUSH_PMON (WAN_FE_UDP_CMD_START + 2)
88 #define WAN_FE_GET_CFG (WAN_FE_UDP_CMD_START + 3)
89
90 /* front-end configuration and access interface commands */
91
92 /* 0x90 read from front-end register */
93 #define READ_FRONT_END_REGISTER (WAN_FE_CMD_START+0)
94
95 /* 0x91 write to front-end register */
96 #define WRITE_FRONT_END_REGISTER (WAN_FE_CMD_START+1)
97
98 /* 0x92 read the front-end statistics */
99 #define READ_FRONT_END_STATISTICS (WAN_FE_CMD_START+2)
100
101 /* 0x93 flush the front-end statistics */
102 #define FLUSH_FRONT_END_STATISTICS (WAN_FE_CMD_START+3)
103
104 #ifdef _KERNEL
105
106 /* adapter configuration interface commands */
107
108 /* 0xA0 set adapter configuration */
109 #define SET_ADAPTER_CONFIGURATION (WAN_INTERFACE_CMD_START+0)
110
111 /* 0xA1 read adapter configuration */
112 #define READ_ADAPTER_CONFIGURATION (WAN_INTERFACE_CMD_START+1)
113
114 /* front-end command */
115 #define WAN_FE_GET_STAT (WAN_FE_UDP_CMD_START + 0)
116 #define WAN_FE_SET_LB_MODE (WAN_FE_UDP_CMD_START + 1)
117 #define WAN_FE_FLUSH_PMON (WAN_FE_UDP_CMD_START + 2)
118 #define WAN_FE_GET_CFG (WAN_FE_UDP_CMD_START + 3)
119
120 /*
121 * return codes from interface commands
122 */
123 /* the length of the FE_RX_DISC_TX_IDLE_STRUCT is invalid */
124 #define LGTH_FE_CFG_DATA_INVALID 0x91
125
126 /* the length of the passed configuration data is invalid */
127 #define LGTH_ADAPTER_CFG_DATA_INVALID 0x91
128
129 /* the passed SET_FE_RX_DISC_TX_IDLE_CFG data is invalid */
130 #define INVALID_FE_CFG_DATA 0x92
131
132 /* an invalid adapter operating frequency was selected */
133 #define ADPTR_OPERATING_FREQ_INVALID 0x92
134
135 /* set the protocol-level configuration before setting the FE configuration */
136 #define PROT_CFG_BEFORE_FE_CFG 0x93
137
138 /* set the front-end Rx discard/Tx idle configuration */
139 #define SET_FE_RX_DISC_TX_IDLE_CFG 0x98
140
141 /* read the front-end Rx discard/Tx idle configuration */
142 #define READ_FE_RX_DISC_TX_IDLE_CFG 0x99
143
144 /* set the T1/E1 signaling configuration */
145 #define SET_TE1_SIGNALING_CFG 0x9A
146
147 /* read the T1/E1 signaling configuration */
148 #define READ_TE1_SIGNALING_CFG 0x9B
149
150
151 /* the command is invalid for the adapter type */
152 #define COMMAND_INVALID_FOR_ADAPTER 0x9F
153
154
155 /*
156 * Constants for the SET_FE_RX_DISC_TX_IDLE_CFG
157 * and READ_FE_RX_DISC_TX_IDLE_CFG commands
158 */
159
160 /* T1 - no active time slots used for reception */
161 #define NO_ACTIVE_RX_TIME_SLOTS_T1 24
162
163 /* T1 - no active time slots used for transmission */
164 #define NO_ACTIVE_TX_TIME_SLOTS_T1 24
165
166 /* E1 - no active time slots used for reception */
167 #define NO_ACTIVE_RX_TIME_SLOTS_E1 32
168
169 /*
170 * E1 - no active time slots used for transmission
171 * (channel 0 reserved for framing)
172 */
173 #define NO_ACTIVE_TX_TIME_SLOTS_E1 31
174
175 /* Read/Write to front-end register */
176 #define READ_REG(reg) card->read_front_end_reg(card, reg)
177 #define WRITE_REG(reg, value) card->write_front_end_reg(card, reg, \
178 (unsigned char)(value))
179
180 /*
181 * the structure used for the SET_FE_RX_DISC_TX_IDLE_CFG and
182 * READ_FE_RX_DISC_TX_IDLE_CFG command
183 */
184 #pragma pack(1)
185 typedef struct {
186 /* the length of the Rx discard buffer */
187 unsigned short lgth_Rx_disc_bfr;
188
189 /* the length of the Tx idle buffer */
190 unsigned short lgth_Tx_idle_bfr;
191
192 /* the transmit idle data buffer */
193 unsigned char Tx_idle_data_bfr[NO_ACTIVE_TX_TIME_SLOTS_E1];
194 } FE_RX_DISC_TX_IDLE_STRUCT;
195 #pragma pack()
196
197
198 /*
199 * Constants for front-end access
200 */
201
202 /*
203 * the structure used for the READ_FRONT_END_REGISTER and
204 * WRITE_FRONT_END_REGISTER command
205 */
206 #pragma pack(1)
207 typedef struct {
208 /* the register number to be read from or written to */
209 unsigned short register_number;
210
211 /* the register value read/written */
212 unsigned char register_value;
213 } FRONT_END_REG_STRUCT;
214 #pragma pack()
215
216
217 /* -----------------------------------------------------------------------------
218 * Constants for the READ_FRONT_END_STATISTICS command
219 * ---------------------------------------------------------------------------*/
220
221 /* the front-end statistics structure */
222 #pragma pack(1)
223 typedef struct {
224 /* the number of front-end interrupts generated */
225 unsigned long FE_interrupt_count;
226
227 /* the number of front-end interrupt application timeouts */
228 unsigned long FE_app_timeout_count;
229 } FE_STATISTICS_STRUCT;
230 #pragma pack()
231
232
233
234 /*
235 * Constants for the SET_ADAPTER_CONFIGURATION
236 * and READ_ADAPTER_CONFIGURATION commands
237 */
238
239 /* the adapter configuration structure */
240 #pragma pack(1)
241 typedef struct {
242 unsigned short adapter_type; /* type of adapter */
243 unsigned short adapter_config; /* misc adapter config */
244 unsigned long operating_frequency; /* adapter operating freq */
245 } ADAPTER_CONFIGURATION_STRUCT;
246 #pragma pack()
247
248
249
250 typedef unsigned char (WRITE_FRONT_END_REG_T)
251 (void *, unsigned short, unsigned char);
252 typedef unsigned char (READ_FRONT_END_REG_T)
253 (void *, unsigned short);
254
255
256 enum {
257 AFT_LED_ON,
258 AFT_LED_OFF,
259 AFT_LED_TOGGLE
260 };
261
262
263 /*
264 * Sangoma Front-End interface structure
265 */
266 typedef struct {
267 /* In-Service or Not (T1/E1/56K) */
268 unsigned long (*get_fe_service_status)(void*);
269
270 /* Print Front-End alarm (T1/E1/56K) */
271 void (*print_fe_alarm)(void*,unsigned long);
272
273 /* Print Front-End alarm (T1/E1/56K) */
274 char* (*print_fe_act_channels)(void*);
275
276 /* Set Front-End alarm (T1/E1) */
277 void (*set_fe_alarm)(void*,unsigned long);
278 } sdla_fe_iface_t;
279
280
281 #endif /* _KERNEL */
282
283 #endif