pre-2.3.4..
[davej-history.git] / drivers / isdn / act2000 / capi.h
blob69a1041005ffc1cb6394a92bdacbc8eeb7109e33
1 /* $Id: capi.h,v 1.5 1998/11/05 22:12:48 fritz Exp $
3 * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000.
5 * Copyright 1998 by Fritz Elfert (fritz@isdn4linux.de)
6 * Thanks to Friedemann Baitinger and IBM Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * $Log: capi.h,v $
23 * Revision 1.5 1998/11/05 22:12:48 fritz
24 * Changed mail-address.
26 * Revision 1.4 1997/10/01 09:21:04 fritz
27 * Removed old compatibility stuff for 2.0.X kernels.
28 * From now on, this code is for 2.1.X ONLY!
29 * Old stuff is still in the separate branch.
31 * Revision 1.3 1997/09/25 17:25:41 fritz
32 * Support for adding cards at runtime.
33 * Support for new Firmware.
35 * Revision 1.2 1997/09/24 19:44:15 fritz
36 * Added MSN mapping support, some cleanup.
38 * Revision 1.1 1997/09/23 18:00:10 fritz
39 * New driver for IBM Active 2000.
43 #ifndef CAPI_H
44 #define CAPI_H
46 /* Command-part of a CAPI message */
47 typedef struct actcapi_msgcmd {
48 __u8 cmd;
49 __u8 subcmd;
50 } actcapi_msgcmd;
52 /* CAPI message header */
53 typedef struct actcapi_msghdr {
54 __u16 len;
55 __u16 applicationID;
56 actcapi_msgcmd cmd;
57 __u16 msgnum;
58 } actcapi_msghdr;
60 /* CAPI message description (for debugging) */
61 typedef struct actcapi_msgdsc {
62 actcapi_msgcmd cmd;
63 char *description;
64 } actcapi_msgdsc;
66 /* CAPI Adress */
67 typedef struct actcapi_addr {
68 __u8 len; /* Length of element */
69 __u8 tnp; /* Type/Numbering Plan */
70 __u8 num[20]; /* Caller ID */
71 } actcapi_addr;
73 /* CAPI INFO element mask */
74 typedef union actcapi_infonr { /* info number */
75 __u16 mask; /* info-mask field */
76 struct bmask { /* bit definitions */
77 unsigned codes : 3; /* code set */
78 unsigned rsvd : 5; /* reserved */
79 unsigned svind : 1; /* single, variable length ind. */
80 unsigned wtype : 7; /* W-element type */
81 } bmask;
82 } actcapi_infonr;
84 /* CAPI INFO element */
85 typedef union actcapi_infoel { /* info element */
86 __u8 len; /* length of info element */
87 __u8 display[40]; /* display contents */
88 __u8 uuinfo[40]; /* User-user info field */
89 struct cause { /* Cause information */
90 unsigned ext2 : 1; /* extension */
91 unsigned cod : 2; /* coding standard */
92 unsigned spare : 1; /* spare */
93 unsigned loc : 4; /* location */
94 unsigned ext1 : 1; /* extension */
95 unsigned cval : 7; /* Cause value */
96 } cause;
97 struct charge { /* Charging information */
98 __u8 toc; /* type of charging info */
99 __u8 unit[10]; /* charging units */
100 } charge;
101 __u8 date[20]; /* date fields */
102 __u8 stat; /* state of remote party */
103 } actcapi_infoel;
105 /* Message for EAZ<->MSN Mapping */
106 typedef struct actcapi_msn {
107 __u8 eaz;
108 __u8 len; /* Length of MSN */
109 __u8 msn[15] __attribute__ ((packed));
110 } actcapi_msn;
112 typedef struct actcapi_dlpd {
113 __u8 len; /* Length of structure */
114 __u16 dlen __attribute__ ((packed)); /* Data Length */
115 __u8 laa __attribute__ ((packed)); /* Link Address A */
116 __u8 lab; /* Link Address B */
117 __u8 modulo; /* Modulo Mode */
118 __u8 win; /* Window size */
119 __u8 xid[100]; /* XID Information */
120 } actcapi_dlpd;
122 typedef struct actcapi_ncpd {
123 __u8 len; /* Length of structure */
124 __u16 lic __attribute__ ((packed));
125 __u16 hic __attribute__ ((packed));
126 __u16 ltc __attribute__ ((packed));
127 __u16 htc __attribute__ ((packed));
128 __u16 loc __attribute__ ((packed));
129 __u16 hoc __attribute__ ((packed));
130 __u8 modulo __attribute__ ((packed));
131 } actcapi_ncpd;
132 #define actcapi_ncpi actcapi_ncpd
135 * Layout of NCCI field in a B3 DATA CAPI message is different from
136 * standard at act2000:
138 * Bit 0-4 = PLCI
139 * Bit 5-7 = Controller
140 * Bit 8-15 = NCCI
142 #define MAKE_NCCI(plci,contr,ncci) \
143 ((plci & 0x1f) | ((contr & 0x7) << 5) | ((ncci & 0xff) << 8))
145 #define EVAL_NCCI(fakencci,plci,contr,ncci) { \
146 plci = fakencci & 0x1f; \
147 contr = (fakencci >> 5) & 0x7; \
148 ncci = (fakencci >> 8) & 0xff; \
152 * Layout of PLCI field in a B3 DATA CAPI message is different from
153 * standard at act2000:
155 * Bit 0-4 = PLCI
156 * Bit 5-7 = Controller
157 * Bit 8-15 = reserved (must be 0)
159 #define MAKE_PLCI(plci,contr) \
160 ((plci & 0x1f) | ((contr & 0x7) << 5))
162 #define EVAL_PLCI(fakeplci,plci,contr) { \
163 plci = fakeplci & 0x1f; \
164 contr = (fakeplci >> 5) & 0x7; \
167 typedef struct actcapi_msg {
168 actcapi_msghdr hdr;
169 union msg {
170 __u16 manuf_msg;
171 struct manufacturer_req_net {
172 __u16 manuf_msg;
173 __u16 controller;
174 __u8 nettype;
175 } manufacturer_req_net;
176 struct manufacturer_req_v42 {
177 __u16 manuf_msg;
178 __u16 controller;
179 __u32 v42control;
180 } manufacturer_req_v42;
181 struct manufacturer_conf_v42 {
182 __u16 manuf_msg;
183 __u16 controller;
184 } manufacturer_conf_v42;
185 struct manufacturer_req_err {
186 __u16 manuf_msg;
187 __u16 controller;
188 } manufacturer_req_err;
189 struct manufacturer_ind_err {
190 __u16 manuf_msg;
191 __u16 controller;
192 __u32 errcode;
193 __u8 errstring; /* actually up to 160 */
194 } manufacturer_ind_err;
195 struct manufacturer_req_msn {
196 __u16 manuf_msg;
197 __u16 controller;
198 actcapi_msn msnmap;
199 } manufacturer_req_msn;
200 /* TODO: TraceInit-req/conf/ind/resp and
201 * TraceDump-req/conf/ind/resp
203 struct connect_req {
204 __u8 controller;
205 __u8 bchan;
206 __u32 infomask __attribute__ ((packed));
207 __u8 si1;
208 __u8 si2;
209 __u8 eaz;
210 actcapi_addr addr;
211 } connect_req;
212 struct connect_conf {
213 __u16 plci;
214 __u16 info;
215 } connect_conf;
216 struct connect_ind {
217 __u16 plci;
218 __u8 controller;
219 __u8 si1;
220 __u8 si2;
221 __u8 eaz;
222 actcapi_addr addr;
223 } connect_ind;
224 struct connect_resp {
225 __u16 plci;
226 __u8 rejectcause;
227 } connect_resp;
228 struct connect_active_ind {
229 __u16 plci;
230 actcapi_addr addr;
231 } connect_active_ind;
232 struct connect_active_resp {
233 __u16 plci;
234 } connect_active_resp;
235 struct connect_b3_req {
236 __u16 plci;
237 actcapi_ncpi ncpi;
238 } connect_b3_req;
239 struct connect_b3_conf {
240 __u16 plci;
241 __u16 ncci;
242 __u16 info;
243 } connect_b3_conf;
244 struct connect_b3_ind {
245 __u16 ncci;
246 __u16 plci;
247 actcapi_ncpi ncpi;
248 } connect_b3_ind;
249 struct connect_b3_resp {
250 __u16 ncci;
251 __u8 rejectcause;
252 actcapi_ncpi ncpi __attribute__ ((packed));
253 } connect_b3_resp;
254 struct disconnect_req {
255 __u16 plci;
256 __u8 cause;
257 } disconnect_req;
258 struct disconnect_conf {
259 __u16 plci;
260 __u16 info;
261 } disconnect_conf;
262 struct disconnect_ind {
263 __u16 plci;
264 __u16 info;
265 } disconnect_ind;
266 struct disconnect_resp {
267 __u16 plci;
268 } disconnect_resp;
269 struct connect_b3_active_ind {
270 __u16 ncci;
271 actcapi_ncpi ncpi;
272 } connect_b3_active_ind;
273 struct connect_b3_active_resp {
274 __u16 ncci;
275 } connect_b3_active_resp;
276 struct disconnect_b3_req {
277 __u16 ncci;
278 actcapi_ncpi ncpi;
279 } disconnect_b3_req;
280 struct disconnect_b3_conf {
281 __u16 ncci;
282 __u16 info;
283 } disconnect_b3_conf;
284 struct disconnect_b3_ind {
285 __u16 ncci;
286 __u16 info;
287 actcapi_ncpi ncpi;
288 } disconnect_b3_ind;
289 struct disconnect_b3_resp {
290 __u16 ncci;
291 } disconnect_b3_resp;
292 struct info_ind {
293 __u16 plci;
294 actcapi_infonr nr;
295 actcapi_infoel el;
296 } info_ind;
297 struct info_resp {
298 __u16 plci;
299 } info_resp;
300 struct listen_b3_req {
301 __u16 plci;
302 } listen_b3_req;
303 struct listen_b3_conf {
304 __u16 plci;
305 __u16 info;
306 } listen_b3_conf;
307 struct select_b2_protocol_req {
308 __u16 plci;
309 __u8 protocol;
310 actcapi_dlpd dlpd __attribute__ ((packed));
311 } select_b2_protocol_req;
312 struct select_b2_protocol_conf {
313 __u16 plci;
314 __u16 info;
315 } select_b2_protocol_conf;
316 struct select_b3_protocol_req {
317 __u16 plci;
318 __u8 protocol;
319 actcapi_ncpd ncpd __attribute__ ((packed));
320 } select_b3_protocol_req;
321 struct select_b3_protocol_conf {
322 __u16 plci;
323 __u16 info;
324 } select_b3_protocol_conf;
325 #if 0
326 struct listen_req {
327 __u32 controller;
328 __u32 infomask;
329 __u32 cipmask;
330 __u32 cipmask2;
331 __u16 dummy; /* 2 Length-bytes of 2 Structs MUST always be 0!!! */
332 } listen_req;
333 struct listen_conf {
334 __u32 controller;
335 __u16 info;
336 } listen_conf;
337 #else
338 struct listen_req {
339 __u8 controller;
340 __u32 infomask __attribute__ ((packed));
341 __u16 eazmask __attribute__ ((packed));
342 __u16 simask __attribute__ ((packed));
343 } listen_req;
344 struct listen_conf {
345 __u8 controller;
346 __u16 info __attribute__ ((packed));
347 } listen_conf;
348 #endif
349 struct data_b3_req {
350 __u16 fakencci;
351 __u16 datalen;
352 __u32 unused;
353 __u8 blocknr;
354 __u16 flags __attribute__ ((packed));
355 } data_b3_req;
356 struct data_b3_ind {
357 __u16 fakencci;
358 __u16 datalen;
359 __u32 unused;
360 __u8 blocknr;
361 __u16 flags __attribute__ ((packed));
362 } data_b3_ind;
363 struct data_b3_resp {
364 __u16 ncci;
365 __u8 blocknr;
366 } data_b3_resp;
367 struct data_b3_conf {
368 __u16 ncci;
369 __u8 blocknr;
370 __u16 info __attribute__ ((packed));
371 } data_b3_conf;
372 } msg;
373 } actcapi_msg;
375 extern __inline__ unsigned short
376 actcapi_nextsmsg(act2000_card *card)
378 unsigned long flags;
379 unsigned short n;
381 save_flags(flags);
382 cli();
383 n = card->msgnum;
384 card->msgnum++;
385 card->msgnum &= 0x7fff;
386 restore_flags(flags);
387 return n;
389 #define DEBUG_MSG
390 #undef DEBUG_DATA_MSG
391 #undef DEBUG_DUMP_SKB
393 extern int actcapi_chkhdr(act2000_card *, actcapi_msghdr *);
394 extern int actcapi_listen_req(act2000_card *);
395 extern int actcapi_manufacturer_req_net(act2000_card *);
396 extern int actcapi_manufacturer_req_v42(act2000_card *, ulong);
397 extern int actcapi_manufacturer_req_errh(act2000_card *);
398 extern int actcapi_manufacturer_req_msn(act2000_card *);
399 extern int actcapi_connect_req(act2000_card *, act2000_chan *, char *, char, int, int);
400 extern void actcapi_select_b2_protocol_req(act2000_card *, act2000_chan *);
401 extern void actcapi_disconnect_b3_req(act2000_card *, act2000_chan *);
402 extern void actcapi_connect_resp(act2000_card *, act2000_chan *, __u8);
403 extern void actcapi_dispatch(act2000_card *);
404 #ifdef DEBUG_MSG
405 extern void actcapi_debug_msg(struct sk_buff *skb, int);
406 #else
407 #define actcapi_debug_msg(skb, len)
408 #endif
409 #endif