GNU Linux-libre 4.9.333-gnu1
[releases.git] / drivers / staging / i4l / act2000 / capi.h
1 /* $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>
7  *
8  * 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 */
19 typedef struct actcapi_msgcmd {
20         __u8 cmd;
21         __u8 subcmd;
22 } actcapi_msgcmd;
23
24 /* CAPI message header */
25 typedef 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) */
33 typedef struct actcapi_msgdsc {
34         actcapi_msgcmd cmd;
35         char *description;
36 } actcapi_msgdsc;
37
38 /* CAPI Address */
39 typedef 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 */
46 typedef  union actcapi_infonr {              /* info number                  */
47         __u16 mask;                          /* info-mask field              */
48         struct bmask {                       /* bit definitions              */
49                 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               */
53         } bmask;
54 } actcapi_infonr;
55
56 /* CAPI INFO element */
57 typedef 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            */
62                 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;
69         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 */
78 typedef struct actcapi_msn {
79         __u8 eaz;
80         __u8 len;                            /* Length of MSN                */
81         __u8 msn[15];
82 }  __attribute__((packed)) actcapi_msn;
83
84 typedef struct actcapi_dlpd {
85         __u8 len;                            /* Length of structure          */
86         __u16 dlen;                          /* Data Length                  */
87         __u8 laa;                            /* Link Address A               */
88         __u8 lab;                            /* Link Address B               */
89         __u8 modulo;                         /* Modulo Mode                  */
90         __u8 win;                            /* Window size                  */
91         __u8 xid[100];                       /* XID Information              */
92 } __attribute__((packed)) actcapi_dlpd;
93
94 typedef struct actcapi_ncpd {
95         __u8   len;                          /* Length of structure          */
96         __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;
104 #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  */
114 #define MAKE_NCCI(plci, contr, ncci)                                    \
115         ((plci & 0x1f) | ((contr & 0x7) << 5) | ((ncci & 0xff) << 8))
116
117 #define EVAL_NCCI(fakencci, plci, ncci) {       \
118                 plci  = fakencci & 0x1f;                \
119                 ncci  = (fakencci >> 8) & 0xff;         \
120         }
121
122 /*
123  * Layout of PLCI field in a B3 DATA CAPI message is different from
124  * standard at act2000:
125  *
126  * Bit 0-4  = PLCI
127  * Bit 5-7  = Controller
128  * Bit 8-15 = reserved (must be 0)
129  */
130
131 typedef struct actcapi_msg {
132         actcapi_msghdr hdr;
133         union {
134                 __u16 manuf_msg;
135                 struct manufacturer_req_net {
136                         __u16 manuf_msg;
137                         __u16 controller;
138                         __u8  nettype;
139                 } manufacturer_req_net;
140                 struct manufacturer_req_v42 {
141                         __u16 manuf_msg;
142                         __u16 controller;
143                         __u32 v42control;
144                 } manufacturer_req_v42;
145                 struct manufacturer_conf_v42 {
146                         __u16 manuf_msg;
147                         __u16 controller;
148                 } manufacturer_conf_v42;
149                 struct manufacturer_req_err {
150                         __u16 manuf_msg;
151                         __u16 controller;
152                 } manufacturer_req_err;
153                 struct manufacturer_ind_err {
154                         __u16 manuf_msg;
155                         __u16 controller;
156                         __u32 errcode;
157                         __u8  errstring; /* actually up to 160 */
158                 } manufacturer_ind_err;
159                 struct manufacturer_req_msn {
160                         __u16 manuf_msg;
161                         __u16 controller;
162                         actcapi_msn msnmap;
163                 } __attribute ((packed)) manufacturer_req_msn;
164                 /* TODO: TraceInit-req/conf/ind/resp and
165                  *       TraceDump-req/conf/ind/resp
166                  */
167                 struct connect_req {
168                         __u8  controller;
169                         __u8  bchan;
170                         __u32 infomask;
171                         __u8  si1;
172                         __u8  si2;
173                         __u8  eaz;
174                         actcapi_addr addr;
175                 } __attribute__ ((packed)) connect_req;
176                 struct connect_conf {
177                         __u16 plci;
178                         __u16 info;
179                 } connect_conf;
180                 struct connect_ind {
181                         __u16 plci;
182                         __u8  controller;
183                         __u8  si1;
184                         __u8  si2;
185                         __u8  eaz;
186                         actcapi_addr addr;
187                 } __attribute__ ((packed)) connect_ind;
188                 struct connect_resp {
189                         __u16 plci;
190                         __u8  rejectcause;
191                 } connect_resp;
192                 struct connect_active_ind {
193                         __u16 plci;
194                         actcapi_addr addr;
195                 } __attribute__ ((packed)) connect_active_ind;
196                 struct connect_active_resp {
197                         __u16 plci;
198                 } connect_active_resp;
199                 struct connect_b3_req {
200                         __u16 plci;
201                         actcapi_ncpi ncpi;
202                 } __attribute__ ((packed)) connect_b3_req;
203                 struct connect_b3_conf {
204                         __u16 plci;
205                         __u16 ncci;
206                         __u16 info;
207                 } connect_b3_conf;
208                 struct connect_b3_ind {
209                         __u16 ncci;
210                         __u16 plci;
211                         actcapi_ncpi ncpi;
212                 } __attribute__ ((packed)) connect_b3_ind;
213                 struct connect_b3_resp {
214                         __u16 ncci;
215                         __u8  rejectcause;
216                         actcapi_ncpi ncpi;
217                 } __attribute__ ((packed)) connect_b3_resp;
218                 struct disconnect_req {
219                         __u16 plci;
220                         __u8  cause;
221                 } disconnect_req;
222                 struct disconnect_conf {
223                         __u16 plci;
224                         __u16 info;
225                 } disconnect_conf;
226                 struct disconnect_ind {
227                         __u16 plci;
228                         __u16 info;
229                 } disconnect_ind;
230                 struct disconnect_resp {
231                         __u16 plci;
232                 } disconnect_resp;
233                 struct connect_b3_active_ind {
234                         __u16 ncci;
235                         actcapi_ncpi ncpi;
236                 } __attribute__ ((packed)) connect_b3_active_ind;
237                 struct connect_b3_active_resp {
238                         __u16 ncci;
239                 } connect_b3_active_resp;
240                 struct disconnect_b3_req {
241                         __u16 ncci;
242                         actcapi_ncpi ncpi;
243                 } __attribute__ ((packed)) disconnect_b3_req;
244                 struct disconnect_b3_conf {
245                         __u16 ncci;
246                         __u16 info;
247                 } disconnect_b3_conf;
248                 struct disconnect_b3_ind {
249                         __u16 ncci;
250                         __u16 info;
251                         actcapi_ncpi ncpi;
252                 } __attribute__ ((packed)) disconnect_b3_ind;
253                 struct disconnect_b3_resp {
254                         __u16 ncci;
255                 } disconnect_b3_resp;
256                 struct info_ind {
257                         __u16 plci;
258                         actcapi_infonr nr;
259                         actcapi_infoel el;
260                 } __attribute__ ((packed)) info_ind;
261                 struct info_resp {
262                         __u16 plci;
263                 } info_resp;
264                 struct listen_b3_req {
265                         __u16 plci;
266                 } listen_b3_req;
267                 struct listen_b3_conf {
268                         __u16 plci;
269                         __u16 info;
270                 } listen_b3_conf;
271                 struct select_b2_protocol_req {
272                         __u16 plci;
273                         __u8  protocol;
274                         actcapi_dlpd dlpd;
275                 } __attribute__ ((packed)) select_b2_protocol_req;
276                 struct select_b2_protocol_conf {
277                         __u16 plci;
278                         __u16 info;
279                 } select_b2_protocol_conf;
280                 struct select_b3_protocol_req {
281                         __u16 plci;
282                         __u8  protocol;
283                         actcapi_ncpd ncpd;
284                 } __attribute__ ((packed)) select_b3_protocol_req;
285                 struct select_b3_protocol_conf {
286                         __u16 plci;
287                         __u16 info;
288                 } select_b3_protocol_conf;
289                 struct listen_req {
290                         __u8  controller;
291                         __u32 infomask;
292                         __u16 eazmask;
293                         __u16 simask;
294                 } __attribute__ ((packed)) listen_req;
295                 struct listen_conf {
296                         __u8  controller;
297                         __u16 info;
298                 } __attribute__ ((packed)) listen_conf;
299                 struct data_b3_req {
300                         __u16 fakencci;
301                         __u16 datalen;
302                         __u32 unused;
303                         __u8  blocknr;
304                         __u16 flags;
305                 } __attribute ((packed)) data_b3_req;
306                 struct data_b3_ind {
307                         __u16 fakencci;
308                         __u16 datalen;
309                         __u32 unused;
310                         __u8  blocknr;
311                         __u16 flags;
312                 } __attribute__ ((packed)) data_b3_ind;
313                 struct data_b3_resp {
314                         __u16 ncci;
315                         __u8  blocknr;
316                 } __attribute__ ((packed)) data_b3_resp;
317                 struct data_b3_conf {
318                         __u16 ncci;
319                         __u8  blocknr;
320                         __u16 info;
321                 } __attribute__ ((packed)) data_b3_conf;
322         } msg;
323 } __attribute__ ((packed)) actcapi_msg;
324
325 static inline unsigned short
326 actcapi_nextsmsg(act2000_card *card)
327 {
328         unsigned long flags;
329         unsigned short n;
330
331         spin_lock_irqsave(&card->mnlock, flags);
332         n = card->msgnum;
333         card->msgnum++;
334         card->msgnum &= 0x7fff;
335         spin_unlock_irqrestore(&card->mnlock, flags);
336         return n;
337 }
338 #define DEBUG_MSG
339 #undef DEBUG_DATA_MSG
340 #undef DEBUG_DUMP_SKB
341
342 extern int actcapi_chkhdr(act2000_card *, actcapi_msghdr *);
343 extern int actcapi_listen_req(act2000_card *);
344 extern int actcapi_manufacturer_req_net(act2000_card *);
345 extern int actcapi_manufacturer_req_errh(act2000_card *);
346 extern int actcapi_manufacturer_req_msn(act2000_card *);
347 extern int actcapi_connect_req(act2000_card *, act2000_chan *, char *, char, int, int);
348 extern void actcapi_select_b2_protocol_req(act2000_card *, act2000_chan *);
349 extern void actcapi_disconnect_b3_req(act2000_card *, act2000_chan *);
350 extern void actcapi_connect_resp(act2000_card *, act2000_chan *, __u8);
351 extern void actcapi_dispatch(struct work_struct *);
352 #ifdef DEBUG_MSG
353 extern void actcapi_debug_msg(struct sk_buff *skb, int);
354 #else
355 #define actcapi_debug_msg(skb, len)
356 #endif
357 #endif