blob: 01ccdecd43f76920435b17365c7a5e950d4edf65 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* $Id: capi.h,v 1.6.6.2 2001/09/23 22:24:32 kai Exp $
2 *
3 * ISDN lowlevel-module for the IBM ISDN-S0 Active 2000.
4 *
5 * Author Fritz Elfert
6 * Copyright by Fritz Elfert <fritz@isdn4linux.de>
Joe Perches475be4d2012-02-19 19:52:38 -08007 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference.
10 *
11 * Thanks to Friedemann Baitinger and IBM Germany
12 *
13 */
14
15#ifndef CAPI_H
16#define CAPI_H
17
18/* Command-part of a CAPI message */
19typedef struct actcapi_msgcmd {
20 __u8 cmd;
21 __u8 subcmd;
22} actcapi_msgcmd;
23
24/* CAPI message header */
25typedef struct actcapi_msghdr {
26 __u16 len;
27 __u16 applicationID;
28 actcapi_msgcmd cmd;
29 __u16 msgnum;
30} actcapi_msghdr;
31
32/* CAPI message description (for debugging) */
33typedef struct actcapi_msgdsc {
34 actcapi_msgcmd cmd;
35 char *description;
36} actcapi_msgdsc;
37
38/* CAPI Address */
39typedef struct actcapi_addr {
40 __u8 len; /* Length of element */
41 __u8 tnp; /* Type/Numbering Plan */
42 __u8 num[20]; /* Caller ID */
43} actcapi_addr;
44
45/* CAPI INFO element mask */
46typedef union actcapi_infonr { /* info number */
47 __u16 mask; /* info-mask field */
48 struct bmask { /* bit definitions */
Joe Perches475be4d2012-02-19 19:52:38 -080049 unsigned codes:3; /* code set */
50 unsigned rsvd:5; /* reserved */
51 unsigned svind:1; /* single, variable length ind. */
52 unsigned wtype:7; /* W-element type */
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 } bmask;
54} actcapi_infonr;
55
56/* CAPI INFO element */
57typedef union actcapi_infoel { /* info element */
58 __u8 len; /* length of info element */
59 __u8 display[40]; /* display contents */
60 __u8 uuinfo[40]; /* User-user info field */
61 struct cause { /* Cause information */
Joe Perches475be4d2012-02-19 19:52:38 -080062 unsigned ext2:1; /* extension */
63 unsigned cod:2; /* coding standard */
64 unsigned spare:1; /* spare */
65 unsigned loc:4; /* location */
66 unsigned ext1:1; /* extension */
67 unsigned cval:7; /* Cause value */
68 } cause;
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 struct charge { /* Charging information */
70 __u8 toc; /* type of charging info */
71 __u8 unit[10]; /* charging units */
72 } charge;
73 __u8 date[20]; /* date fields */
74 __u8 stat; /* state of remote party */
75} actcapi_infoel;
76
77/* Message for EAZ<->MSN Mapping */
78typedef struct actcapi_msn {
79 __u8 eaz;
80 __u8 len; /* Length of MSN */
Jan Blunck9fe656e2006-01-08 01:05:09 -080081 __u8 msn[15];
82} __attribute__((packed)) actcapi_msn;
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
84typedef struct actcapi_dlpd {
85 __u8 len; /* Length of structure */
Jan Blunck9fe656e2006-01-08 01:05:09 -080086 __u16 dlen; /* Data Length */
87 __u8 laa; /* Link Address A */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 __u8 lab; /* Link Address B */
89 __u8 modulo; /* Modulo Mode */
90 __u8 win; /* Window size */
91 __u8 xid[100]; /* XID Information */
Jan Blunck9fe656e2006-01-08 01:05:09 -080092} __attribute__((packed)) actcapi_dlpd;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
94typedef struct actcapi_ncpd {
95 __u8 len; /* Length of structure */
Jan Blunck9fe656e2006-01-08 01:05:09 -080096 __u16 lic;
97 __u16 hic;
98 __u16 ltc;
99 __u16 htc;
100 __u16 loc;
101 __u16 hoc;
102 __u8 modulo;
103} __attribute__((packed)) actcapi_ncpd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104#define actcapi_ncpi actcapi_ncpd
105
106/*
107 * Layout of NCCI field in a B3 DATA CAPI message is different from
108 * standard at act2000:
109 *
110 * Bit 0-4 = PLCI
111 * Bit 5-7 = Controller
112 * Bit 8-15 = NCCI
113 */
Joe Perches475be4d2012-02-19 19:52:38 -0800114#define MAKE_NCCI(plci, contr, ncci) \
115 ((plci & 0x1f) | ((contr & 0x7) << 5) | ((ncci & 0xff) << 8))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Joe Perches475be4d2012-02-19 19:52:38 -0800117#define EVAL_NCCI(fakencci, plci, contr, ncci) { \
118 plci = fakencci & 0x1f; \
119 contr = (fakencci >> 5) & 0x7; \
120 ncci = (fakencci >> 8) & 0xff; \
121 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123/*
124 * Layout of PLCI field in a B3 DATA CAPI message is different from
125 * standard at act2000:
126 *
127 * Bit 0-4 = PLCI
128 * Bit 5-7 = Controller
129 * Bit 8-15 = reserved (must be 0)
130 */
Joe Perches475be4d2012-02-19 19:52:38 -0800131#define MAKE_PLCI(plci, contr) \
132 ((plci & 0x1f) | ((contr & 0x7) << 5))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
Joe Perches475be4d2012-02-19 19:52:38 -0800134#define EVAL_PLCI(fakeplci, plci, contr) { \
135 plci = fakeplci & 0x1f; \
136 contr = (fakeplci >> 5) & 0x7; \
137 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
139typedef struct actcapi_msg {
140 actcapi_msghdr hdr;
141 union {
142 __u16 manuf_msg;
143 struct manufacturer_req_net {
144 __u16 manuf_msg;
145 __u16 controller;
146 __u8 nettype;
147 } manufacturer_req_net;
148 struct manufacturer_req_v42 {
149 __u16 manuf_msg;
150 __u16 controller;
151 __u32 v42control;
152 } manufacturer_req_v42;
153 struct manufacturer_conf_v42 {
154 __u16 manuf_msg;
155 __u16 controller;
156 } manufacturer_conf_v42;
157 struct manufacturer_req_err {
158 __u16 manuf_msg;
159 __u16 controller;
160 } manufacturer_req_err;
161 struct manufacturer_ind_err {
162 __u16 manuf_msg;
163 __u16 controller;
164 __u32 errcode;
165 __u8 errstring; /* actually up to 160 */
166 } manufacturer_ind_err;
167 struct manufacturer_req_msn {
168 __u16 manuf_msg;
169 __u16 controller;
170 actcapi_msn msnmap;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800171 } __attribute ((packed)) manufacturer_req_msn;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 /* TODO: TraceInit-req/conf/ind/resp and
173 * TraceDump-req/conf/ind/resp
174 */
175 struct connect_req {
176 __u8 controller;
177 __u8 bchan;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800178 __u32 infomask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 __u8 si1;
180 __u8 si2;
181 __u8 eaz;
182 actcapi_addr addr;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800183 } __attribute__ ((packed)) connect_req;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 struct connect_conf {
185 __u16 plci;
186 __u16 info;
187 } connect_conf;
188 struct connect_ind {
189 __u16 plci;
190 __u8 controller;
191 __u8 si1;
192 __u8 si2;
193 __u8 eaz;
194 actcapi_addr addr;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800195 } __attribute__ ((packed)) connect_ind;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 struct connect_resp {
197 __u16 plci;
198 __u8 rejectcause;
199 } connect_resp;
200 struct connect_active_ind {
201 __u16 plci;
202 actcapi_addr addr;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800203 } __attribute__ ((packed)) connect_active_ind;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 struct connect_active_resp {
205 __u16 plci;
206 } connect_active_resp;
207 struct connect_b3_req {
208 __u16 plci;
209 actcapi_ncpi ncpi;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800210 } __attribute__ ((packed)) connect_b3_req;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 struct connect_b3_conf {
212 __u16 plci;
213 __u16 ncci;
214 __u16 info;
215 } connect_b3_conf;
216 struct connect_b3_ind {
217 __u16 ncci;
218 __u16 plci;
219 actcapi_ncpi ncpi;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800220 } __attribute__ ((packed)) connect_b3_ind;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 struct connect_b3_resp {
222 __u16 ncci;
223 __u8 rejectcause;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800224 actcapi_ncpi ncpi;
225 } __attribute__ ((packed)) connect_b3_resp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 struct disconnect_req {
227 __u16 plci;
228 __u8 cause;
229 } disconnect_req;
230 struct disconnect_conf {
231 __u16 plci;
232 __u16 info;
233 } disconnect_conf;
234 struct disconnect_ind {
235 __u16 plci;
236 __u16 info;
237 } disconnect_ind;
238 struct disconnect_resp {
239 __u16 plci;
240 } disconnect_resp;
241 struct connect_b3_active_ind {
242 __u16 ncci;
243 actcapi_ncpi ncpi;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800244 } __attribute__ ((packed)) connect_b3_active_ind;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 struct connect_b3_active_resp {
246 __u16 ncci;
247 } connect_b3_active_resp;
248 struct disconnect_b3_req {
249 __u16 ncci;
250 actcapi_ncpi ncpi;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800251 } __attribute__ ((packed)) disconnect_b3_req;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 struct disconnect_b3_conf {
253 __u16 ncci;
254 __u16 info;
255 } disconnect_b3_conf;
256 struct disconnect_b3_ind {
257 __u16 ncci;
258 __u16 info;
259 actcapi_ncpi ncpi;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800260 } __attribute__ ((packed)) disconnect_b3_ind;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 struct disconnect_b3_resp {
262 __u16 ncci;
263 } disconnect_b3_resp;
264 struct info_ind {
265 __u16 plci;
266 actcapi_infonr nr;
267 actcapi_infoel el;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800268 } __attribute__ ((packed)) info_ind;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 struct info_resp {
270 __u16 plci;
271 } info_resp;
272 struct listen_b3_req {
273 __u16 plci;
274 } listen_b3_req;
275 struct listen_b3_conf {
276 __u16 plci;
277 __u16 info;
278 } listen_b3_conf;
279 struct select_b2_protocol_req {
280 __u16 plci;
281 __u8 protocol;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800282 actcapi_dlpd dlpd;
283 } __attribute__ ((packed)) select_b2_protocol_req;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 struct select_b2_protocol_conf {
285 __u16 plci;
286 __u16 info;
287 } select_b2_protocol_conf;
288 struct select_b3_protocol_req {
289 __u16 plci;
290 __u8 protocol;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800291 actcapi_ncpd ncpd;
292 } __attribute__ ((packed)) select_b3_protocol_req;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 struct select_b3_protocol_conf {
294 __u16 plci;
295 __u16 info;
296 } select_b3_protocol_conf;
297 struct listen_req {
298 __u8 controller;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800299 __u32 infomask;
300 __u16 eazmask;
301 __u16 simask;
302 } __attribute__ ((packed)) listen_req;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 struct listen_conf {
304 __u8 controller;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800305 __u16 info;
306 } __attribute__ ((packed)) listen_conf;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 struct data_b3_req {
308 __u16 fakencci;
309 __u16 datalen;
310 __u32 unused;
311 __u8 blocknr;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800312 __u16 flags;
313 } __attribute ((packed)) data_b3_req;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 struct data_b3_ind {
315 __u16 fakencci;
316 __u16 datalen;
317 __u32 unused;
318 __u8 blocknr;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800319 __u16 flags;
320 } __attribute__ ((packed)) data_b3_ind;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 struct data_b3_resp {
322 __u16 ncci;
323 __u8 blocknr;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800324 } __attribute__ ((packed)) data_b3_resp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 struct data_b3_conf {
326 __u16 ncci;
327 __u8 blocknr;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800328 __u16 info;
329 } __attribute__ ((packed)) data_b3_conf;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 } msg;
Jan Blunck9fe656e2006-01-08 01:05:09 -0800331} __attribute__ ((packed)) actcapi_msg;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332
Adrian Bunkb7b4d7a2006-01-08 01:02:16 -0800333static inline unsigned short
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334actcapi_nextsmsg(act2000_card *card)
335{
336 unsigned long flags;
337 unsigned short n;
338
339 spin_lock_irqsave(&card->mnlock, flags);
340 n = card->msgnum;
341 card->msgnum++;
342 card->msgnum &= 0x7fff;
343 spin_unlock_irqrestore(&card->mnlock, flags);
344 return n;
345}
346#define DEBUG_MSG
347#undef DEBUG_DATA_MSG
348#undef DEBUG_DUMP_SKB
349
350extern int actcapi_chkhdr(act2000_card *, actcapi_msghdr *);
351extern int actcapi_listen_req(act2000_card *);
352extern int actcapi_manufacturer_req_net(act2000_card *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353extern int actcapi_manufacturer_req_errh(act2000_card *);
354extern int actcapi_manufacturer_req_msn(act2000_card *);
355extern int actcapi_connect_req(act2000_card *, act2000_chan *, char *, char, int, int);
356extern void actcapi_select_b2_protocol_req(act2000_card *, act2000_chan *);
357extern void actcapi_disconnect_b3_req(act2000_card *, act2000_chan *);
358extern void actcapi_connect_resp(act2000_card *, act2000_chan *, __u8);
David Howellsc4028952006-11-22 14:57:56 +0000359extern void actcapi_dispatch(struct work_struct *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360#ifdef DEBUG_MSG
361extern void actcapi_debug_msg(struct sk_buff *skb, int);
362#else
363#define actcapi_debug_msg(skb, len)
364#endif
365#endif