OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [isdn/] [hisax/] [callc.c] - Blame information for rev 1626

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1626 jcastillo
/* $Id: callc.c,v 1.1 2005-12-20 10:17:01 jcastillo Exp $
2
 
3
 * Author       Karsten Keil (keil@isdn4linux.de)
4
 *              based on the teles driver from Jan den Ouden
5
 *
6
 *              This file is (c) under GNU PUBLIC LICENSE
7
 *              For changes and modifications please read
8
 *              ../../../Documentation/isdn/HiSax.cert
9
 *
10
 * Thanks to    Jan den Ouden
11
 *              Fritz Elfert
12
 *
13
 * $Log: not supported by cvs2svn $
14
 * Revision 1.1.1.1  2001/09/10 07:44:18  simons
15
 * Initial import
16
 *
17
 * Revision 1.1.1.1  2001/07/02 17:58:32  simons
18
 * Initial revision
19
 *
20
 * Revision 1.30.2.13  1998/11/05 21:13:32  keil
21
 * minor fixes
22
 *
23
 * Revision 1.30.2.12  1998/11/03 00:05:51  keil
24
 * certification related changes
25
 * fixed logging for smaller stack use
26
 *
27
 * Revision 1.30.2.11  1998/09/30 22:20:05  keil
28
 * Cosmetics
29
 *
30
 * Revision 1.30.2.10  1998/09/27 13:05:35  keil
31
 * Apply most changes from 2.1.X (HiSax 3.1)
32
 *
33
 * Revision 1.30.2.9  1998/05/27 18:04:53  keil
34
 * HiSax 3.0
35
 *
36
 * Revision 1.30.2.8  1998/04/11 18:48:26  keil
37
 * remove debug
38
 *
39
 * Revision 1.30.2.7  1998/04/08 21:51:50  keil
40
 * new debug
41
 *
42
 * Revision 1.30.2.6  1998/03/07 23:15:02  tsbogend
43
 * made HiSax working on Linux/Alpha
44
 *
45
 * Revision 1.30.2.5  1998/02/09 11:24:17  keil
46
 * New leased line support (Read README.HiSax!)
47
 *
48
 * Revision 1.30.2.4  1998/01/27 22:46:00  keil
49
 * B-channel send delay now configurable
50
 *
51
 * Revision 1.30.2.3  1998/01/11 23:21:03  keil
52
 * Missing callc state
53
 *
54
 * Revision 1.30.2.2  1997/11/15 18:54:31  keil
55
 * cosmetics
56
 *
57
 * Revision 1.30.2.1  1997/10/17 22:13:32  keil
58
 * update to last hisax version
59
 *
60
 * Revision 2.6  1997/09/11 17:26:58  keil
61
 * Open B-channel if here are incomming packets
62
 *
63
 * Revision 2.5  1997/08/07 17:46:05  keil
64
 * Fix Incomming Call without broadcast
65
 *
66
 * Revision 2.4  1997/08/03 14:37:58  keil
67
 * Activate Layer2 in PtP mode
68
 *
69
 * Revision 2.3  1997/07/31 19:23:40  keil
70
 * LAYER2_WATCHING for PtP
71
 *
72
 * Revision 2.2  1997/07/31 11:48:18  keil
73
 * experimental REJECT after ALERTING
74
 *
75
 * Revision 2.1  1997/07/30 17:12:59  keil
76
 * more changes for 'One TEI per card'
77
 *
78
 * Revision 2.0  1997/07/27 21:12:21  keil
79
 * CRef based L3; new channel handling; many other stuff
80
 *
81
 * Revision 1.31  1997/06/26 11:09:23  keil
82
 * New managment and minor changes
83
 *
84
 * old logs removed /KKe
85
 *
86
 */
87
 
88
#define __NO_VERSION__
89
#include "hisax.h"
90
#include "../avmb1/capicmd.h"  /* this should be moved in a common place */
91
 
92
#ifdef MODULE
93
extern long mod_use_count_;
94
#define MOD_USE_COUNT mod_use_count_
95
#endif                          /* MODULE */
96
 
97
const char *lli_revision = "$Revision: 1.1 $";
98
 
99
extern struct IsdnCard cards[];
100
extern int nrcards;
101
extern void HiSax_mod_dec_use_count(void);
102
extern void HiSax_mod_inc_use_count(void);
103
 
104
static int init_b_st(struct Channel *chanp, int incoming);
105
static void release_b_st(struct Channel *chanp);
106
 
107
static struct Fsm callcfsm =
108
{NULL, 0, 0, NULL, NULL};
109
 
110
static int chancount = 0;
111
 
112
/* experimental REJECT after ALERTING for CALLBACK to beat the 4s delay */
113
#define ALERT_REJECT 0
114
 
115
/* Value to delay the sending of the first B-channel paket after CONNECT
116
 * here is no value given by ITU, but experience shows that 300 ms will
117
 * work on many networks, if you or your other side is behind local exchanges
118
 * a greater value may be recommented. If the delay is to short the first paket
119
 * will be lost and autodetect on many comercial routers goes wrong !
120
 * You can adjust this value on runtime with
121
 * hisaxctrl <id> 2 <value>
122
 * value is in milliseconds
123
 */
124
#define DEFAULT_B_DELAY 300
125
 
126
/* Flags for remembering action done in lli */
127
 
128
#define  FLG_START_D    0
129
#define  FLG_ESTAB_D    1
130
#define  FLG_CALL_SEND  2
131
#define  FLG_CALL_REC   3
132
#define  FLG_CALL_ALERT 4
133
#define  FLG_START_B    5
134
#define  FLG_CONNECT_B  6
135
#define  FLG_LL_DCONN   7
136
#define  FLG_LL_BCONN   8
137
#define  FLG_DISC_SEND  9
138
#define  FLG_DISC_REC   10
139
#define  FLG_REL_REC    11
140
#define  FLG_DO_ALERT   12
141
#define  FLG_DO_HANGUP  13
142
#define  FLG_DO_CONNECT 14
143
#define  FLG_DO_ESTAB   15
144
#define  FLG_RESUME     16
145
 
146
/*
147
 * Because of callback it's a good idea to delay the shutdown of the d-channel
148
 */
149
#define DREL_TIMER_VALUE 40000
150
 
151
/*
152
 * Find card with given driverId
153
 */
154
static inline struct IsdnCardState
155
*
156
hisax_findcard(int driverid)
157
{
158
        int i;
159
 
160
        for (i = 0; i < nrcards; i++)
161
                if (cards[i].cs)
162
                        if (cards[i].cs->myid == driverid)
163
                                return (cards[i].cs);
164
        return (struct IsdnCardState *) 0;
165
}
166
 
167
int
168
discard_queue(struct sk_buff_head *q)
169
{
170
        struct sk_buff *skb;
171
        int ret=0;
172
 
173
        while ((skb = skb_dequeue(q))) {
174
                dev_kfree_skb(skb, FREE_READ);
175
                ret++;
176
        }
177
        return(ret);
178
}
179
 
180
static void
181
link_debug(struct Channel *chanp, int direction, char *fmt, ...)
182
{
183
        va_list args;
184
        char tmp[16];
185
 
186
        va_start(args, fmt);
187
        sprintf(tmp, "Ch%d %s ", chanp->chan,
188
                direction ? "LL->HL" : "HL->LL");
189
        VHiSax_putstatus(chanp->cs, tmp, fmt, args);
190
        va_end(args);
191
}
192
 
193
 
194
enum {
195
        ST_NULL,                /*  0 inactive */
196
        ST_OUT_WAIT_D,          /*  1 outgoing, awaiting d-channel establishment */
197
        ST_IN_WAIT_D,           /*  2 incoming, awaiting d-channel establishment */
198
        ST_OUT_DIAL,            /*  3 outgoing, SETUP send; awaiting confirm */
199
        ST_IN_WAIT_LL,          /*  4 incoming call received; wait for LL confirm */
200
        ST_IN_ALERT_SEND,       /*  5 incoming call received; ALERT send */
201
        ST_IN_WAIT_CONN_ACK,    /*  6 incoming CONNECT send; awaiting CONN_ACK */
202
        ST_WAIT_BCONN,          /*  7 CONNECT/CONN_ACK received, awaiting b-channel prot. estbl. */
203
        ST_ACTIVE,              /*  8 active, b channel prot. established */
204
        ST_WAIT_BRELEASE,       /*  9 call clear. (initiator), awaiting b channel prot. rel. */
205
        ST_WAIT_BREL_DISC,      /* 10 call clear. (receiver), DISCONNECT req. received */
206
        ST_WAIT_DCOMMAND,       /* 11 call clear. (receiver), awaiting DCHANNEL message */
207
        ST_WAIT_DRELEASE,       /* 12 DISCONNECT sent, awaiting RELEASE */
208
        ST_WAIT_D_REL_CNF,      /* 13 RELEASE sent, awaiting RELEASE confirm */
209
        ST_WAIT_DSHUTDOWN,      /*  14 awaiting d-channel shutdown */
210
};
211
 
212
#define STATE_COUNT (ST_WAIT_DSHUTDOWN +1)
213
 
214
static char *strState[] =
215
{
216
        "ST_NULL",
217
        "ST_OUT_WAIT_D",
218
        "ST_IN_WAIT_D",
219
        "ST_OUT_DIAL",
220
        "ST_IN_WAIT_LL",
221
        "ST_IN_ALERT_SEND",
222
        "ST_IN_WAIT_CONN_ACK",
223
        "ST_WAIT_BCONN",
224
        "ST_ACTIVE",
225
        "ST_WAIT_BRELEASE",
226
        "ST_WAIT_BREL_DISC",
227
        "ST_WAIT_DCOMMAND",
228
        "ST_WAIT_DRELEASE",
229
        "ST_WAIT_D_REL_CNF",
230
        "ST_WAIT_DSHUTDOWN",
231
};
232
 
233
enum {
234
        EV_DIAL,                /*  0 */
235
        EV_SETUP_CNF,           /*  1 */
236
        EV_ACCEPTB,             /*  2 */
237
        EV_DISCONNECT_IND,      /*  3 */
238
        EV_RELEASE_CNF,         /*  4 */
239
        EV_DLEST,               /*  5 */
240
        EV_DLRL,                /*  6 */
241
        EV_SETUP_IND,           /*  7 */
242
        EV_RELEASE_IND,         /*  8 */
243
        EV_ACCEPTD,             /*  9 */
244
        EV_SETUP_CMPL_IND,      /* 10 */
245
        EV_BC_EST,              /* 11 */
246
        EV_WRITEBUF,            /* 12 */
247
        EV_ESTABLISH,           /* 13 */
248
        EV_HANGUP,              /* 14 */
249
        EV_BC_REL,              /* 15 */
250
        EV_CINF,                /* 16 */
251
        EV_SUSPEND,             /* 17 */
252
        EV_RESUME,              /* 18 */
253
        EV_SHUTDOWN_D,          /* 19 */
254
        EV_NOSETUP_RSP,         /* 20 */
255
        EV_SETUP_ERR,           /* 21 */
256
        EV_CONNECT_ERR,         /* 22 */
257
        EV_RELEASE_ERR,         /* 23 */
258
};
259
 
260
#define EVENT_COUNT (EV_RELEASE_ERR +1)
261
 
262
static char *strEvent[] =
263
{
264
        "EV_DIAL",
265
        "EV_SETUP_CNF",
266
        "EV_ACCEPTB",
267
        "EV_DISCONNECT_IND",
268
        "EV_RELEASE_CNF",
269
        "EV_DLEST",
270
        "EV_DLRL",
271
        "EV_SETUP_IND",
272
        "EV_RELEASE_IND",
273
        "EV_ACCEPTD",
274
        "EV_SETUP_CMPL_IND",
275
        "EV_BC_EST",
276
        "EV_WRITEBUF",
277
        "EV_ESTABLISH",
278
        "EV_HANGUP",
279
        "EV_BC_REL",
280
        "EV_CINF",
281
        "EV_SUSPEND",
282
        "EV_RESUME",
283
        "EV_SHUTDOWN_D",
284
        "EV_NOSETUP_RSP",
285
        "EV_SETUP_ERR",
286
        "EV_CONNECT_ERR",
287
        "EV_RELEASE_ERR",
288
};
289
 
290
static inline void
291
lli_deliver_cause(struct Channel *chanp, isdn_ctrl *ic)
292
{
293
        if (chanp->proc->para.cause < 0)
294
                return;
295
        ic->driver = chanp->cs->myid;
296
        ic->command = ISDN_STAT_CAUSE;
297
        ic->arg = chanp->chan;
298
        if (chanp->cs->protocol == ISDN_PTYPE_EURO)
299
                sprintf(ic->parm.num, "E%02X%02X", chanp->proc->para.loc & 0x7f,
300
                        chanp->proc->para.cause & 0x7f);
301
        else
302
                sprintf(ic->parm.num, "%02X%02X", chanp->proc->para.loc & 0x7f,
303
                        chanp->proc->para.cause & 0x7f);
304
        chanp->cs->iif.statcallb(ic);
305
}
306
 
307
static void
308
lli_d_established(struct FsmInst *fi, int event, void *arg)
309
{
310
        struct Channel *chanp = fi->userdata;
311
 
312
        test_and_set_bit(FLG_ESTAB_D, &chanp->Flags);
313
        if (chanp->leased) {
314
                isdn_ctrl ic;
315
                int ret;
316
 
317
                chanp->cs->cardmsg(chanp->cs, MDL_INFO_SETUP, (void *) (long)chanp->chan);
318
                FsmChangeState(fi, ST_IN_WAIT_LL);
319
                test_and_set_bit(FLG_CALL_REC, &chanp->Flags);
320
                if (chanp->debug & 1)
321
                        link_debug(chanp, 0, "STAT_ICALL_LEASED");
322
                ic.driver = chanp->cs->myid;
323
                ic.command = ISDN_STAT_ICALL;
324
                ic.arg = chanp->chan;
325
                ic.parm.setup.si1 = 7;
326
                ic.parm.setup.si2 = 0;
327
                ic.parm.setup.plan = 0;
328
                ic.parm.setup.screen = 0;
329
                sprintf(ic.parm.setup.eazmsn,"%d", chanp->chan + 1);
330
                sprintf(ic.parm.setup.phone,"LEASED%d", chanp->cs->myid);
331
                ret = chanp->cs->iif.statcallb(&ic);
332
                if (chanp->debug & 1)
333
                        link_debug(chanp, 1, "statcallb ret=%d", ret);
334
                if (!ret) {
335
                        chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) (long)chanp->chan);
336
                        FsmChangeState(fi, ST_NULL);
337
                }
338
        } else if (fi->state == ST_WAIT_DSHUTDOWN)
339
                FsmChangeState(fi, ST_NULL);
340
}
341
 
342
static void
343
lli_d_released(struct FsmInst *fi, int event, void *arg)
344
{
345
        struct Channel *chanp = fi->userdata;
346
 
347
        test_and_clear_bit(FLG_START_D, &chanp->Flags);
348
}
349
 
350
/*
351
 * Dial out
352
 */
353
static void
354
lli_prep_dialout(struct FsmInst *fi, int event, void *arg)
355
{
356
        struct Channel *chanp = fi->userdata;
357
 
358
        FsmChangeState(fi, ST_OUT_WAIT_D);
359
        FsmDelTimer(&chanp->drel_timer, 60);
360
        FsmDelTimer(&chanp->dial_timer, 73);
361
        chanp->l2_active_protocol = chanp->l2_protocol;
362
        chanp->incoming = 0;
363
        if (test_bit(FLG_ESTAB_D, &chanp->Flags)) {
364
                FsmEvent(fi, EV_DLEST, NULL);
365
        } else {
366
                chanp->Flags = 0;
367
                if (EV_RESUME == event)
368
                        test_and_set_bit(FLG_RESUME, &chanp->Flags);
369
                test_and_set_bit(FLG_START_D, &chanp->Flags);
370
                chanp->d_st->lli.l4l3(chanp->d_st, DL_ESTABLISH | REQUEST, NULL);
371
        }
372
}
373
 
374
static void
375
lli_do_dialout(struct FsmInst *fi, int event, void *arg)
376
{
377
        struct Channel *chanp = fi->userdata;
378
        int ev;
379
 
380
        FsmChangeState(fi, ST_OUT_DIAL);
381
        chanp->cs->cardmsg(chanp->cs, MDL_INFO_SETUP, (void *) (long)chanp->chan);
382
        if (test_and_clear_bit(FLG_RESUME, &chanp->Flags))
383
                ev = CC_RESUME | REQUEST;
384
        else
385
                ev = CC_SETUP | REQUEST;
386
        if (chanp->leased) {
387
                FsmEvent(&chanp->fi, EV_SETUP_CNF, NULL);
388
        } else {
389
                test_and_set_bit(FLG_ESTAB_D, &chanp->Flags);
390
                chanp->d_st->lli.l4l3(chanp->d_st, ev, chanp);
391
                test_and_set_bit(FLG_CALL_SEND, &chanp->Flags);
392
        }
393
}
394
 
395
static void
396
lli_init_bchan_out(struct FsmInst *fi, int event, void *arg)
397
{
398
        struct Channel *chanp = fi->userdata;
399
        isdn_ctrl ic;
400
 
401
        FsmChangeState(fi, ST_WAIT_BCONN);
402
        test_and_set_bit(FLG_LL_DCONN, &chanp->Flags);
403
        if (chanp->debug & 1)
404
                link_debug(chanp, 0, "STAT_DCONN");
405
        ic.driver = chanp->cs->myid;
406
        ic.command = ISDN_STAT_DCONN;
407
        ic.arg = chanp->chan;
408
        chanp->cs->iif.statcallb(&ic);
409
        init_b_st(chanp, 0);
410
        test_and_set_bit(FLG_START_B, &chanp->Flags);
411
        chanp->b_st->lli.l4l3(chanp->b_st, DL_ESTABLISH | REQUEST, NULL);
412
}
413
 
414
static void
415
lli_go_active(struct FsmInst *fi, int event, void *arg)
416
{
417
        struct Channel *chanp = fi->userdata;
418
        isdn_ctrl ic;
419
 
420
        FsmChangeState(fi, ST_ACTIVE);
421
        chanp->data_open = !0;
422
        test_and_set_bit(FLG_CONNECT_B, &chanp->Flags);
423
        if (chanp->debug & 1)
424
                link_debug(chanp, 0, "STAT_BCONN");
425
        test_and_set_bit(FLG_LL_BCONN, &chanp->Flags);
426
        ic.driver = chanp->cs->myid;
427
        ic.command = ISDN_STAT_BCONN;
428
        ic.arg = chanp->chan;
429
        chanp->cs->iif.statcallb(&ic);
430
        chanp->cs->cardmsg(chanp->cs, MDL_INFO_CONN, (void *) (long)chanp->chan);
431
}
432
 
433
/*
434
 * RESUME
435
 */
436
 
437
/* incomming call */
438
 
439
static void
440
lli_start_dchan(struct FsmInst *fi, int event, void *arg)
441
{
442
        struct Channel *chanp = fi->userdata;
443
 
444
        FsmChangeState(fi, ST_IN_WAIT_D);
445
        FsmDelTimer(&chanp->drel_timer, 61);
446
        if (event == EV_ACCEPTD)
447
                test_and_set_bit(FLG_DO_CONNECT, &chanp->Flags);
448
        else if (event == EV_HANGUP) {
449
                test_and_set_bit(FLG_DO_HANGUP, &chanp->Flags);
450
#ifdef ALERT_REJECT
451
                test_and_set_bit(FLG_DO_ALERT, &chanp->Flags);
452
#endif
453
        }
454
        if (test_bit(FLG_ESTAB_D, &chanp->Flags)) {
455
                FsmEvent(fi, EV_DLEST, NULL);
456
        } else if (!test_and_set_bit(FLG_START_D, &chanp->Flags))
457
                chanp->d_st->lli.l4l3(chanp->d_st, DL_ESTABLISH | REQUEST, NULL);
458
}
459
 
460
static void
461
lli_deliver_call(struct FsmInst *fi, int event, void *arg)
462
{
463
        struct Channel *chanp = fi->userdata;
464
        isdn_ctrl ic;
465
        int ret;
466
 
467
        chanp->cs->cardmsg(chanp->cs, MDL_INFO_SETUP, (void *) (long)chanp->chan);
468
        /*
469
         * Report incoming calls only once to linklevel, use CallFlags
470
         * which is set to 3 with each broadcast message in isdnl1.c
471
         * and resetted if a interface  answered the STAT_ICALL.
472
         */
473
        if (1) { /* for only one TEI */
474
                FsmChangeState(fi, ST_IN_WAIT_LL);
475
                test_and_set_bit(FLG_CALL_REC, &chanp->Flags);
476
                if (chanp->debug & 1)
477
                        link_debug(chanp, 0, "STAT_ICALL");
478
                ic.driver = chanp->cs->myid;
479
                ic.command = ISDN_STAT_ICALL;
480
                ic.arg = chanp->chan;
481
                /*
482
                 * No need to return "unknown" for calls without OAD,
483
                 * cause that's handled in linklevel now (replaced by '0')
484
                 */
485
                ic.parm.setup = chanp->proc->para.setup;
486
                ret = chanp->cs->iif.statcallb(&ic);
487
                if (chanp->debug & 1)
488
                        link_debug(chanp, 1, "statcallb ret=%d", ret);
489
                switch (ret) {
490
                        case 1: /* OK, anybody likes this call */
491
                                FsmDelTimer(&chanp->drel_timer, 61);
492
                                if (test_bit(FLG_ESTAB_D, &chanp->Flags)) {
493
                                        FsmChangeState(fi, ST_IN_ALERT_SEND);
494
                                        test_and_set_bit(FLG_CALL_ALERT, &chanp->Flags);
495
                                        chanp->d_st->lli.l4l3(chanp->d_st, CC_ALERTING | REQUEST, chanp->proc);
496
                                } else {
497
                                        test_and_set_bit(FLG_DO_ALERT, &chanp->Flags);
498
                                        FsmChangeState(fi, ST_IN_WAIT_D);
499
                                        test_and_set_bit(FLG_START_D, &chanp->Flags);
500
                                        chanp->d_st->lli.l4l3(chanp->d_st,
501
                                                DL_ESTABLISH | REQUEST, NULL);
502
                                }
503
                                break;
504
                        case 2: /* Rejecting Call */
505
                                test_and_clear_bit(FLG_CALL_REC, &chanp->Flags);
506
                                break;
507
                        case 0:  /* OK, nobody likes this call */
508
                        default:        /* statcallb problems */
509
                                chanp->d_st->lli.l4l3(chanp->d_st, CC_IGNORE | REQUEST, chanp->proc);
510
                                chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) (long)chanp->chan);
511
                                FsmChangeState(fi, ST_NULL);
512
                                if (test_bit(FLG_ESTAB_D, &chanp->Flags) &&
513
                                        !test_bit(FLG_PTP, &chanp->d_st->l2.flag))
514
                                        FsmRestartTimer(&chanp->drel_timer, DREL_TIMER_VALUE, EV_SHUTDOWN_D, NULL, 61);
515
                                break;
516
                }
517
        } else {
518
                chanp->d_st->lli.l4l3(chanp->d_st, CC_IGNORE | REQUEST, chanp->proc);
519
                chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) (long)chanp->chan);
520
                FsmChangeState(fi, ST_NULL);
521
                if (test_bit(FLG_ESTAB_D, &chanp->Flags) &&
522
                        !test_bit(FLG_PTP, &chanp->d_st->l2.flag))
523
                        FsmRestartTimer(&chanp->drel_timer, DREL_TIMER_VALUE, EV_SHUTDOWN_D, NULL, 62);
524
        }
525
}
526
 
527
static void
528
lli_establish_d(struct FsmInst *fi, int event, void *arg)
529
{
530
        /* This establish the D-channel for pending L3 messages
531
         * without blocking the channel
532
         */
533
        struct Channel *chanp = fi->userdata;
534
 
535
        test_and_set_bit(FLG_DO_ESTAB, &chanp->Flags);
536
        FsmChangeState(fi, ST_IN_WAIT_D);
537
        test_and_set_bit(FLG_START_D, &chanp->Flags);
538
        chanp->d_st->lli.l4l3(chanp->d_st, DL_ESTABLISH | REQUEST, NULL);
539
}
540
 
541
static void
542
lli_do_action(struct FsmInst *fi, int event, void *arg)
543
{
544
        struct Channel *chanp = fi->userdata;
545
 
546
        test_and_set_bit(FLG_ESTAB_D, &chanp->Flags);
547
        if (chanp->leased) {
548
                FsmChangeState(fi, ST_IN_WAIT_CONN_ACK);
549
                test_and_clear_bit(FLG_DO_ALERT, &chanp->Flags);
550
                test_and_clear_bit(FLG_DO_CONNECT, &chanp->Flags);
551
                FsmEvent(&chanp->fi, EV_SETUP_CMPL_IND, NULL);
552
        } else if (test_and_clear_bit(FLG_DO_CONNECT, &chanp->Flags) &&
553
                !test_bit(FLG_DO_HANGUP, &chanp->Flags)) {
554
                FsmChangeState(fi, ST_IN_WAIT_CONN_ACK);
555
                test_and_clear_bit(FLG_DO_ALERT, &chanp->Flags);
556
                chanp->d_st->lli.l4l3(chanp->d_st, CC_SETUP | RESPONSE, chanp->proc);
557
        } else if (test_and_clear_bit(FLG_DO_ALERT, &chanp->Flags)) {
558
                if (test_bit(FLG_DO_HANGUP, &chanp->Flags))
559
                        FsmRestartTimer(&chanp->drel_timer, 40, EV_HANGUP, NULL, 63);
560
                FsmChangeState(fi, ST_IN_ALERT_SEND);
561
                test_and_set_bit(FLG_CALL_ALERT, &chanp->Flags);
562
                chanp->d_st->lli.l4l3(chanp->d_st, CC_ALERTING | REQUEST, chanp->proc);
563
        } else if (test_and_clear_bit(FLG_DO_HANGUP, &chanp->Flags)) {
564
                FsmChangeState(fi, ST_WAIT_DRELEASE);
565
                chanp->proc->para.cause = 0x15;         /* Call Rejected */
566
                chanp->d_st->lli.l4l3(chanp->d_st, CC_REJECT | REQUEST, chanp->proc);
567
                test_and_set_bit(FLG_DISC_SEND, &chanp->Flags);
568
        }
569
}
570
 
571
static void
572
lli_send_dconnect(struct FsmInst *fi, int event, void *arg)
573
{
574
        struct Channel *chanp = fi->userdata;
575
 
576
        FsmChangeState(fi, ST_IN_WAIT_CONN_ACK);
577
        chanp->d_st->lli.l4l3(chanp->d_st, CC_SETUP | RESPONSE, chanp->proc);
578
}
579
 
580
static void
581
lli_init_bchan_in(struct FsmInst *fi, int event, void *arg)
582
{
583
        struct Channel *chanp = fi->userdata;
584
        isdn_ctrl ic;
585
 
586
        FsmChangeState(fi, ST_WAIT_BCONN);
587
        test_and_set_bit(FLG_LL_DCONN, &chanp->Flags);
588
        if (chanp->debug & 1)
589
                link_debug(chanp, 0, "STAT_DCONN");
590
        ic.driver = chanp->cs->myid;
591
        ic.command = ISDN_STAT_DCONN;
592
        ic.arg = chanp->chan;
593
        chanp->cs->iif.statcallb(&ic);
594
        chanp->l2_active_protocol = chanp->l2_protocol;
595
        chanp->incoming = !0;
596
        init_b_st(chanp, !0);
597
        test_and_set_bit(FLG_START_B, &chanp->Flags);
598
        chanp->b_st->lli.l4l3(chanp->b_st, DL_ESTABLISH | REQUEST, NULL);
599
}
600
 
601
/* Call suspend */
602
 
603
static void
604
lli_suspend(struct FsmInst *fi, int event, void *arg)
605
{
606
        struct Channel *chanp = fi->userdata;
607
 
608
        chanp->d_st->lli.l4l3(chanp->d_st, CC_SUSPEND | REQUEST, chanp->proc);
609
}
610
 
611
/* Call clearing */
612
 
613
static void
614
lli_cancel_call(struct FsmInst *fi, int event, void *arg)
615
{
616
        struct Channel *chanp = fi->userdata;
617
        isdn_ctrl ic;
618
 
619
        FsmChangeState(fi, ST_WAIT_DRELEASE);
620
        if (test_and_clear_bit(FLG_LL_BCONN, &chanp->Flags)) {
621
                if (chanp->debug & 1)
622
                        link_debug(chanp, 0, "STAT_BHUP");
623
                ic.driver = chanp->cs->myid;
624
                ic.command = ISDN_STAT_BHUP;
625
                ic.arg = chanp->chan;
626
                chanp->cs->iif.statcallb(&ic);
627
        }
628
        if (test_and_clear_bit(FLG_START_B, &chanp->Flags))
629
                release_b_st(chanp);
630
        chanp->proc->para.cause = 0x10;         /* Normal Call Clearing */
631
        chanp->d_st->lli.l4l3(chanp->d_st, CC_DISCONNECT | REQUEST, chanp->proc);
632
        test_and_set_bit(FLG_DISC_SEND, &chanp->Flags);
633
}
634
 
635
static void
636
lli_shutdown_d(struct FsmInst *fi, int event, void *arg)
637
{
638
        struct Channel *chanp = fi->userdata;
639
 
640
        FsmDelTimer(&chanp->drel_timer, 62);
641
        if (test_bit(FLG_PTP, &chanp->d_st->l2.flag)) {
642
                FsmChangeState(fi, ST_NULL);
643
        } else {
644
                if (!test_bit(FLG_TWO_DCHAN, &chanp->cs->HW_Flags)) {
645
                        if (chanp->chan) {
646
                                if (chanp->cs->channel[0].fi.state != ST_NULL)
647
                                        return;
648
                        } else {
649
                                if (chanp->cs->channel[1].fi.state != ST_NULL)
650
                                        return;
651
                        }
652
                }
653
                FsmChangeState(fi, ST_WAIT_DSHUTDOWN);
654
                test_and_clear_bit(FLG_ESTAB_D, &chanp->Flags);
655
                chanp->d_st->lli.l4l3(chanp->d_st, DL_RELEASE | REQUEST, NULL);
656
        }
657
}
658
 
659
static void
660
lli_timeout_d(struct FsmInst *fi, int event, void *arg)
661
{
662
        struct Channel *chanp = fi->userdata;
663
        isdn_ctrl ic;
664
 
665
        test_and_clear_bit(FLG_LL_DCONN, &chanp->Flags);
666
        if (chanp->debug & 1)
667
                link_debug(chanp, 0, "STAT_DHUP");
668
        lli_deliver_cause(chanp, &ic);
669
        ic.driver = chanp->cs->myid;
670
        ic.command = ISDN_STAT_DHUP;
671
        ic.arg = chanp->chan;
672
        chanp->cs->iif.statcallb(&ic);
673
        FsmChangeState(fi, ST_NULL);
674
        chanp->Flags = 0;
675
        test_and_set_bit(FLG_ESTAB_D, &chanp->Flags);
676
        if (!test_bit(FLG_PTP, &chanp->d_st->l2.flag))
677
                FsmAddTimer(&chanp->drel_timer, DREL_TIMER_VALUE, EV_SHUTDOWN_D, NULL, 60);
678
        chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) (long)chanp->chan);
679
}
680
 
681
static void
682
lli_go_null(struct FsmInst *fi, int event, void *arg)
683
{
684
        struct Channel *chanp = fi->userdata;
685
 
686
        FsmChangeState(fi, ST_NULL);
687
        chanp->Flags = 0;
688
        FsmDelTimer(&chanp->drel_timer, 63);
689
        chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) (long)chanp->chan);
690
}
691
 
692
static void
693
lli_disconn_bchan(struct FsmInst *fi, int event, void *arg)
694
{
695
        struct Channel *chanp = fi->userdata;
696
 
697
        chanp->data_open = 0;
698
        FsmChangeState(fi, ST_WAIT_BRELEASE);
699
        test_and_clear_bit(FLG_CONNECT_B, &chanp->Flags);
700
        chanp->b_st->lli.l4l3(chanp->b_st, DL_RELEASE | REQUEST, NULL);
701
}
702
 
703
static void
704
lli_send_d_disc(struct FsmInst *fi, int event, void *arg)
705
{
706
        struct Channel *chanp = fi->userdata;
707
        isdn_ctrl ic;
708
 
709
        if (test_bit(FLG_DISC_REC, &chanp->Flags) ||
710
                test_bit(FLG_REL_REC, &chanp->Flags))
711
                return;
712
        FsmChangeState(fi, ST_WAIT_DRELEASE);
713
        if (test_and_clear_bit(FLG_LL_BCONN, &chanp->Flags)) {
714
                if (chanp->debug & 1)
715
                        link_debug(chanp, 0, "STAT_BHUP");
716
                ic.driver = chanp->cs->myid;
717
                ic.command = ISDN_STAT_BHUP;
718
                ic.arg = chanp->chan;
719
                chanp->cs->iif.statcallb(&ic);
720
        }
721
        if (test_and_clear_bit(FLG_START_B, &chanp->Flags))
722
                release_b_st(chanp);
723
        if (chanp->leased) {
724
                ic.command = ISDN_STAT_CAUSE;
725
                ic.arg = chanp->chan;
726
                sprintf(ic.parm.num, "L0010");
727
                chanp->cs->iif.statcallb(&ic);
728
                if (chanp->debug & 1)
729
                        link_debug(chanp, 0, "STAT_DHUP");
730
                ic.driver = chanp->cs->myid;
731
                ic.command = ISDN_STAT_DHUP;
732
                ic.arg = chanp->chan;
733
                chanp->cs->iif.statcallb(&ic);
734
                FsmChangeState(fi, ST_WAIT_DSHUTDOWN);
735
                test_and_clear_bit(FLG_ESTAB_D, &chanp->Flags);
736
                chanp->d_st->lli.l4l3(chanp->d_st, DL_RELEASE | REQUEST, NULL);
737
        } else {
738
                if (test_and_clear_bit(FLG_DO_HANGUP, &chanp->Flags))
739
                        chanp->proc->para.cause = 0x15;         /* Call Reject */
740
                else
741
                        chanp->proc->para.cause = 0x10;         /* Normal Call Clearing */
742
                chanp->d_st->lli.l4l3(chanp->d_st, CC_DISCONNECT | REQUEST, chanp->proc);
743
                test_and_set_bit(FLG_DISC_SEND, &chanp->Flags);
744
        }
745
}
746
 
747
static void
748
lli_released_bchan(struct FsmInst *fi, int event, void *arg)
749
{
750
        struct Channel *chanp = fi->userdata;
751
        isdn_ctrl ic;
752
 
753
        FsmChangeState(fi, ST_WAIT_DCOMMAND);
754
        chanp->data_open = 0;
755
        if (test_and_clear_bit(FLG_LL_BCONN, &chanp->Flags)) {
756
                if (chanp->debug & 1)
757
                        link_debug(chanp, 0, "STAT_BHUP");
758
                ic.driver = chanp->cs->myid;
759
                ic.command = ISDN_STAT_BHUP;
760
                ic.arg = chanp->chan;
761
                chanp->cs->iif.statcallb(&ic);
762
        }
763
        release_b_st(chanp);
764
        test_and_clear_bit(FLG_START_B, &chanp->Flags);
765
}
766
 
767
 
768
static void
769
lli_release_bchan(struct FsmInst *fi, int event, void *arg)
770
{
771
        struct Channel *chanp = fi->userdata;
772
 
773
        chanp->data_open = 0;
774
        test_and_set_bit(FLG_DISC_REC, &chanp->Flags);
775
        FsmChangeState(fi, ST_WAIT_BREL_DISC);
776
        test_and_clear_bit(FLG_CONNECT_B, &chanp->Flags);
777
        chanp->b_st->lli.l4l3(chanp->b_st, DL_RELEASE | REQUEST, NULL);
778
}
779
 
780
static void
781
lli_received_d_rel(struct FsmInst *fi, int event, void *arg)
782
{
783
        struct Channel *chanp = fi->userdata;
784
        isdn_ctrl ic;
785
 
786
        chanp->data_open = 0;
787
        FsmChangeState(fi, ST_NULL);
788
        test_and_set_bit(FLG_REL_REC, &chanp->Flags);
789
        if (test_and_clear_bit(FLG_CONNECT_B, &chanp->Flags)) {
790
                chanp->b_st->lli.l4l3(chanp->b_st, DL_RELEASE | REQUEST, NULL);
791
        }
792
        if (test_and_clear_bit(FLG_LL_BCONN, &chanp->Flags)) {
793
                if (chanp->debug & 1)
794
                        link_debug(chanp, 0, "STAT_BHUP");
795
                ic.driver = chanp->cs->myid;
796
                ic.command = ISDN_STAT_BHUP;
797
                ic.arg = chanp->chan;
798
                chanp->cs->iif.statcallb(&ic);
799
        }
800
        if (test_and_clear_bit(FLG_START_B, &chanp->Flags))
801
                release_b_st(chanp);
802
        if (chanp->debug & 1)
803
                link_debug(chanp, 0, "STAT_DHUP");
804
        lli_deliver_cause(chanp, &ic);
805
        ic.driver = chanp->cs->myid;
806
        ic.command = ISDN_STAT_DHUP;
807
        ic.arg = chanp->chan;
808
        chanp->cs->iif.statcallb(&ic);
809
        test_and_clear_bit(FLG_DISC_SEND, &chanp->Flags);
810
        test_and_clear_bit(FLG_CALL_REC, &chanp->Flags);
811
        test_and_clear_bit(FLG_CALL_ALERT, &chanp->Flags);
812
        test_and_clear_bit(FLG_LL_DCONN, &chanp->Flags);
813
        test_and_clear_bit(FLG_CALL_SEND, &chanp->Flags);
814
        lli_timeout_d(fi, event, arg);
815
}
816
 
817
static void
818
lli_received_d_relcnf(struct FsmInst *fi, int event, void *arg)
819
{
820
        struct Channel *chanp = fi->userdata;
821
        isdn_ctrl ic;
822
 
823
        chanp->data_open = 0;
824
        FsmChangeState(fi, ST_NULL);
825
        if (test_and_clear_bit(FLG_CONNECT_B, &chanp->Flags)) {
826
                chanp->b_st->lli.l4l3(chanp->b_st, DL_RELEASE | REQUEST, NULL);
827
        }
828
        if (test_and_clear_bit(FLG_LL_BCONN, &chanp->Flags)) {
829
                if (chanp->debug & 1)
830
                        link_debug(chanp, 0, "STAT_BHUP");
831
                ic.driver = chanp->cs->myid;
832
                ic.command = ISDN_STAT_BHUP;
833
                ic.arg = chanp->chan;
834
                chanp->cs->iif.statcallb(&ic);
835
        }
836
        if (test_and_clear_bit(FLG_START_B, &chanp->Flags))
837
                release_b_st(chanp);
838
        if (chanp->debug & 1)
839
                link_debug(chanp, 0, "STAT_DHUP");
840
        lli_deliver_cause(chanp, &ic);
841
        ic.driver = chanp->cs->myid;
842
        ic.command = ISDN_STAT_DHUP;
843
        ic.arg = chanp->chan;
844
        chanp->cs->iif.statcallb(&ic);
845
        test_and_clear_bit(FLG_DISC_SEND, &chanp->Flags);
846
        test_and_clear_bit(FLG_CALL_REC, &chanp->Flags);
847
        test_and_clear_bit(FLG_CALL_ALERT, &chanp->Flags);
848
        test_and_clear_bit(FLG_LL_DCONN, &chanp->Flags);
849
        test_and_clear_bit(FLG_CALL_SEND, &chanp->Flags);
850
        lli_timeout_d(fi, event, arg);
851
}
852
 
853
static void
854
lli_received_d_disc(struct FsmInst *fi, int event, void *arg)
855
{
856
        struct Channel *chanp = fi->userdata;
857
        isdn_ctrl ic;
858
 
859
        chanp->data_open = 0;
860
        FsmChangeState(fi, ST_WAIT_D_REL_CNF);
861
        test_and_set_bit(FLG_DISC_REC, &chanp->Flags);
862
        if (test_and_clear_bit(FLG_LL_BCONN, &chanp->Flags)) {
863
                if (chanp->debug & 1)
864
                        link_debug(chanp, 0, "STAT_BHUP");
865
                ic.driver = chanp->cs->myid;
866
                ic.command = ISDN_STAT_BHUP;
867
                ic.arg = chanp->chan;
868
                chanp->cs->iif.statcallb(&ic);
869
        }
870
        if (test_and_clear_bit(FLG_START_B, &chanp->Flags))
871
                release_b_st(chanp);
872
        if (chanp->debug & 1)
873
                link_debug(chanp, 0, "STAT_DHUP");
874
        lli_deliver_cause(chanp, &ic);
875
        ic.driver = chanp->cs->myid;
876
        ic.command = ISDN_STAT_DHUP;
877
        ic.arg = chanp->chan;
878
        chanp->cs->iif.statcallb(&ic);
879
        test_and_clear_bit(FLG_CALL_ALERT, &chanp->Flags);
880
        test_and_clear_bit(FLG_LL_DCONN, &chanp->Flags);
881
        test_and_clear_bit(FLG_CALL_SEND, &chanp->Flags);
882
        chanp->d_st->lli.l4l3(chanp->d_st, CC_RELEASE | REQUEST, chanp->proc);
883
}
884
 
885
/* processing charge info */
886
static void
887
lli_charge_info(struct FsmInst *fi, int event, void *arg)
888
{
889
        struct Channel *chanp = fi->userdata;
890
        isdn_ctrl ic;
891
 
892
        ic.driver = chanp->cs->myid;
893
        ic.command = ISDN_STAT_CINF;
894
        ic.arg = chanp->chan;
895
        sprintf(ic.parm.num, "%d", chanp->proc->para.chargeinfo);
896
        chanp->cs->iif.statcallb(&ic);
897
}
898
 
899
/* error procedures */
900
 
901
static void
902
lli_no_dchan(struct FsmInst *fi, int event, void *arg)
903
{
904
        struct Channel *chanp = fi->userdata;
905
        isdn_ctrl ic;
906
 
907
        if (chanp->debug & 1)
908
                link_debug(chanp, 0, "STAT_NODCH");
909
        ic.driver = chanp->cs->myid;
910
        ic.command = ISDN_STAT_NODCH;
911
        ic.arg = chanp->chan;
912
        chanp->cs->iif.statcallb(&ic);
913
        chanp->Flags = 0;
914
        FsmChangeState(fi, ST_NULL);
915
        chanp->d_st->lli.l4l3(chanp->d_st, DL_RELEASE | REQUEST, NULL);
916
}
917
 
918
static void
919
lli_no_dchan_ready(struct FsmInst *fi, int event, void *arg)
920
{
921
        struct Channel *chanp = fi->userdata;
922
        isdn_ctrl ic;
923
 
924
        if (chanp->debug & 1)
925
                link_debug(chanp, 0, "STAT_DHUP");
926
        ic.driver = chanp->cs->myid;
927
        ic.command = ISDN_STAT_DHUP;
928
        ic.arg = chanp->chan;
929
        chanp->cs->iif.statcallb(&ic);
930
}
931
 
932
static void
933
lli_no_dchan_in(struct FsmInst *fi, int event, void *arg)
934
{
935
        struct Channel *chanp = fi->userdata;
936
        isdn_ctrl ic;
937
 
938
        if (chanp->debug & 1)
939
                link_debug(chanp, 0, "STAT_DHUP");
940
        ic.driver = chanp->cs->myid;
941
        ic.command = ISDN_STAT_DHUP;
942
        ic.arg = chanp->chan;
943
        chanp->cs->iif.statcallb(&ic);
944
        chanp->d_st->lli.l4l3(chanp->d_st, CC_DLRL | REQUEST, chanp->proc);
945
        chanp->Flags = 0;
946
        FsmChangeState(fi, ST_NULL);
947
        chanp->d_st->lli.l4l3(chanp->d_st, DL_RELEASE | REQUEST, NULL);
948
}
949
 
950
static void
951
lli_no_setup_rsp(struct FsmInst *fi, int event, void *arg)
952
{
953
        struct Channel *chanp = fi->userdata;
954
        isdn_ctrl ic;
955
 
956
        FsmChangeState(fi, ST_NULL);
957
        test_and_clear_bit(FLG_CALL_SEND, &chanp->Flags);
958
        if (chanp->debug & 1)
959
                link_debug(chanp, 0, "STAT_DHUP");
960
        ic.driver = chanp->cs->myid;
961
        ic.command = ISDN_STAT_DHUP;
962
        ic.arg = chanp->chan;
963
        chanp->cs->iif.statcallb(&ic);
964
        lli_shutdown_d(fi, event, arg);
965
}
966
 
967
static void
968
lli_setup_err(struct FsmInst *fi, int event, void *arg)
969
{
970
        struct Channel *chanp = fi->userdata;
971
        isdn_ctrl ic;
972
 
973
        FsmChangeState(fi, ST_WAIT_DRELEASE);
974
        test_and_clear_bit(FLG_LL_DCONN, &chanp->Flags);
975
        if (chanp->debug & 1)
976
                link_debug(chanp, 0, "STAT_DHUP");
977
        lli_deliver_cause(chanp, &ic);
978
        ic.driver = chanp->cs->myid;
979
        ic.command = ISDN_STAT_DHUP;
980
        ic.arg = chanp->chan;
981
        chanp->cs->iif.statcallb(&ic);
982
        test_and_set_bit(FLG_DISC_SEND, &chanp->Flags); /* DISCONN was sent from L3 */
983
}
984
 
985
static void
986
lli_connect_err(struct FsmInst *fi, int event, void *arg)
987
{
988
        struct Channel *chanp = fi->userdata;
989
        isdn_ctrl ic;
990
 
991
        FsmChangeState(fi, ST_WAIT_DRELEASE);
992
        test_and_clear_bit(FLG_LL_DCONN, &chanp->Flags);
993
        if (chanp->debug & 1)
994
                link_debug(chanp, 0, "STAT_DHUP");
995
        lli_deliver_cause(chanp, &ic);
996
        ic.driver = chanp->cs->myid;
997
        ic.command = ISDN_STAT_DHUP;
998
        ic.arg = chanp->chan;
999
        chanp->cs->iif.statcallb(&ic);
1000
        test_and_set_bit(FLG_DISC_SEND, &chanp->Flags); /* DISCONN was sent from L3 */
1001
}
1002
 
1003
static void
1004
lli_got_dlrl(struct FsmInst *fi, int event, void *arg)
1005
{
1006
        struct Channel *chanp = fi->userdata;
1007
        isdn_ctrl ic;
1008
 
1009
        chanp->data_open = 0;
1010
        FsmChangeState(fi, ST_NULL);
1011
        if (test_and_clear_bit(FLG_CONNECT_B, &chanp->Flags)) {
1012
                chanp->b_st->lli.l4l3(chanp->b_st, DL_RELEASE | REQUEST, NULL);
1013
        }
1014
        if (test_and_clear_bit(FLG_LL_BCONN, &chanp->Flags)) {
1015
                if (chanp->debug & 1)
1016
                        link_debug(chanp, 0, "STAT_BHUP");
1017
                ic.driver = chanp->cs->myid;
1018
                ic.command = ISDN_STAT_BHUP;
1019
                ic.arg = chanp->chan;
1020
                chanp->cs->iif.statcallb(&ic);
1021
        }
1022
        if (test_and_clear_bit(FLG_START_B, &chanp->Flags))
1023
                release_b_st(chanp);
1024
        if (chanp->leased) {
1025
                ic.driver = chanp->cs->myid;
1026
                ic.command = ISDN_STAT_CAUSE;
1027
                ic.arg = chanp->chan;
1028
                sprintf(ic.parm.num, "L%02X%02X", 0, 0x2f);
1029
                chanp->cs->iif.statcallb(&ic);
1030
                ic.driver = chanp->cs->myid;
1031
                ic.command = ISDN_STAT_DHUP;
1032
                ic.arg = chanp->chan;
1033
                chanp->cs->iif.statcallb(&ic);
1034
                chanp->Flags = 0;
1035
        } else {
1036
                test_and_clear_bit(FLG_LL_DCONN, &chanp->Flags);
1037
                if (chanp->debug & 1)
1038
                        link_debug(chanp, 0, "STAT_DHUP");
1039
                if (chanp->cs->protocol == ISDN_PTYPE_EURO) {
1040
                        chanp->proc->para.cause = 0x2f;
1041
                        chanp->proc->para.loc = 0;
1042
                } else {
1043
                        chanp->proc->para.cause = 0x70;
1044
                        chanp->proc->para.loc = 0;
1045
                }
1046
                lli_deliver_cause(chanp, &ic);
1047
                ic.driver = chanp->cs->myid;
1048
                ic.command = ISDN_STAT_DHUP;
1049
                ic.arg = chanp->chan;
1050
                chanp->cs->iif.statcallb(&ic);
1051
                chanp->d_st->lli.l4l3(chanp->d_st, CC_DLRL | REQUEST, chanp->proc);
1052
                chanp->Flags = 0;
1053
                chanp->d_st->lli.l4l3(chanp->d_st, DL_RELEASE | REQUEST, NULL);
1054
        }
1055
        chanp->cs->cardmsg(chanp->cs, MDL_INFO_REL, (void *) (long)chanp->chan);
1056
}
1057
 
1058
/* *INDENT-OFF* */
1059
static struct FsmNode fnlist[] HISAX_INITDATA =
1060
{
1061
        {ST_NULL,               EV_DIAL,                lli_prep_dialout},
1062
        {ST_NULL,               EV_RESUME,              lli_prep_dialout},
1063
        {ST_NULL,               EV_SETUP_IND,           lli_deliver_call},
1064
        {ST_NULL,               EV_SHUTDOWN_D,          lli_shutdown_d},
1065
        {ST_NULL,               EV_DLRL,                lli_go_null},
1066
        {ST_NULL,               EV_DLEST,               lli_d_established},
1067
        {ST_NULL,               EV_ESTABLISH,           lli_establish_d},
1068
        {ST_OUT_WAIT_D,         EV_DLEST,               lli_do_dialout},
1069
        {ST_OUT_WAIT_D,         EV_DLRL,                lli_no_dchan},
1070
        {ST_OUT_WAIT_D,         EV_HANGUP,              lli_no_dchan},
1071
        {ST_IN_WAIT_D,          EV_DLEST,               lli_do_action},
1072
        {ST_IN_WAIT_D,          EV_DLRL,                lli_no_dchan_in},
1073
        {ST_IN_WAIT_D,          EV_ACCEPTD,             lli_start_dchan},
1074
        {ST_IN_WAIT_D,          EV_HANGUP,              lli_start_dchan},
1075
        {ST_OUT_DIAL,           EV_SETUP_CNF,           lli_init_bchan_out},
1076
        {ST_OUT_DIAL,           EV_HANGUP,              lli_cancel_call},
1077
        {ST_OUT_DIAL,           EV_DISCONNECT_IND,      lli_received_d_disc},
1078
        {ST_OUT_DIAL,           EV_RELEASE_IND,         lli_received_d_rel},
1079
        {ST_OUT_DIAL,           EV_RELEASE_CNF,         lli_received_d_relcnf},
1080
        {ST_OUT_DIAL,           EV_NOSETUP_RSP,         lli_no_setup_rsp},
1081
        {ST_OUT_DIAL,           EV_SETUP_ERR,           lli_setup_err},
1082
        {ST_OUT_DIAL,           EV_DLRL,                lli_got_dlrl},
1083
        {ST_IN_WAIT_LL,         EV_DLEST,               lli_d_established},
1084
        {ST_IN_WAIT_LL,         EV_DLRL,                lli_d_released},
1085
        {ST_IN_WAIT_LL,         EV_ACCEPTD,             lli_start_dchan},
1086
        {ST_IN_WAIT_LL,         EV_HANGUP,              lli_start_dchan},
1087
        {ST_IN_WAIT_LL,         EV_DISCONNECT_IND,      lli_received_d_disc},
1088
        {ST_IN_WAIT_LL,         EV_RELEASE_IND,         lli_received_d_rel},
1089
        {ST_IN_WAIT_LL,         EV_RELEASE_CNF,         lli_received_d_relcnf},
1090
        {ST_IN_ALERT_SEND,      EV_SETUP_CMPL_IND,      lli_init_bchan_in},
1091
        {ST_IN_ALERT_SEND,      EV_ACCEPTD,             lli_send_dconnect},
1092
        {ST_IN_ALERT_SEND,      EV_HANGUP,              lli_send_d_disc},
1093
        {ST_IN_ALERT_SEND,      EV_DISCONNECT_IND,      lli_received_d_disc},
1094
        {ST_IN_ALERT_SEND,      EV_RELEASE_IND,         lli_received_d_rel},
1095
        {ST_IN_ALERT_SEND,      EV_RELEASE_CNF,         lli_received_d_relcnf},
1096
        {ST_IN_ALERT_SEND,      EV_DLRL,                lli_got_dlrl},
1097
        {ST_IN_WAIT_CONN_ACK,   EV_SETUP_CMPL_IND,      lli_init_bchan_in},
1098
        {ST_IN_WAIT_CONN_ACK,   EV_HANGUP,              lli_send_d_disc},
1099
        {ST_IN_WAIT_CONN_ACK,   EV_DISCONNECT_IND,      lli_received_d_disc},
1100
        {ST_IN_WAIT_CONN_ACK,   EV_RELEASE_IND,         lli_received_d_rel},
1101
        {ST_IN_WAIT_CONN_ACK,   EV_RELEASE_CNF,         lli_received_d_relcnf},
1102
        {ST_IN_WAIT_CONN_ACK,   EV_CONNECT_ERR,         lli_connect_err},
1103
        {ST_IN_WAIT_CONN_ACK,   EV_DLRL,                lli_got_dlrl},
1104
        {ST_WAIT_BCONN,         EV_BC_EST,              lli_go_active},
1105
        {ST_WAIT_BCONN,         EV_BC_REL,              lli_send_d_disc},
1106
        {ST_WAIT_BCONN,         EV_HANGUP,              lli_send_d_disc},
1107
        {ST_WAIT_BCONN,         EV_DISCONNECT_IND,      lli_received_d_disc},
1108
        {ST_WAIT_BCONN,         EV_RELEASE_IND,         lli_received_d_rel},
1109
        {ST_WAIT_BCONN,         EV_RELEASE_CNF,         lli_received_d_relcnf},
1110
        {ST_WAIT_BCONN,         EV_DLRL,                lli_got_dlrl},
1111
        {ST_WAIT_BCONN,         EV_CINF,                lli_charge_info},
1112
        {ST_ACTIVE,             EV_CINF,                lli_charge_info},
1113
        {ST_ACTIVE,             EV_BC_REL,              lli_released_bchan},
1114
        {ST_ACTIVE,             EV_SUSPEND,             lli_suspend},
1115
        {ST_ACTIVE,             EV_HANGUP,              lli_disconn_bchan},
1116
        {ST_ACTIVE,             EV_DISCONNECT_IND,      lli_release_bchan},
1117
        {ST_ACTIVE,             EV_RELEASE_CNF,         lli_received_d_relcnf},
1118
        {ST_ACTIVE,             EV_RELEASE_IND,         lli_received_d_rel},
1119
        {ST_ACTIVE,             EV_DLRL,                lli_got_dlrl},
1120
        {ST_WAIT_BRELEASE,      EV_BC_REL,              lli_send_d_disc},
1121
        {ST_WAIT_BRELEASE,      EV_DISCONNECT_IND,      lli_received_d_disc},
1122
        {ST_WAIT_BRELEASE,      EV_RELEASE_CNF,         lli_received_d_relcnf},
1123
        {ST_WAIT_BRELEASE,      EV_RELEASE_IND,         lli_received_d_rel},
1124
        {ST_WAIT_BRELEASE,      EV_DLRL,                lli_got_dlrl},
1125
        {ST_WAIT_BREL_DISC,     EV_BC_REL,              lli_received_d_disc},
1126
        {ST_WAIT_BREL_DISC,     EV_RELEASE_CNF,         lli_received_d_relcnf},
1127
        {ST_WAIT_BREL_DISC,     EV_RELEASE_IND,         lli_received_d_rel},
1128
        {ST_WAIT_BREL_DISC,     EV_DLRL,                lli_got_dlrl},
1129
        {ST_WAIT_DCOMMAND,      EV_HANGUP,              lli_send_d_disc},
1130
        {ST_WAIT_DCOMMAND,      EV_DISCONNECT_IND,      lli_received_d_disc},
1131
        {ST_WAIT_DCOMMAND,      EV_RELEASE_CNF,         lli_received_d_relcnf},
1132
        {ST_WAIT_DCOMMAND,      EV_RELEASE_IND,         lli_received_d_rel},
1133
        {ST_WAIT_DCOMMAND,      EV_DLRL,                lli_got_dlrl},
1134
        {ST_WAIT_DRELEASE,      EV_RELEASE_IND,         lli_timeout_d},
1135
        {ST_WAIT_DRELEASE,      EV_RELEASE_CNF,         lli_timeout_d},
1136
        {ST_WAIT_DRELEASE,      EV_RELEASE_ERR,         lli_timeout_d},
1137
        {ST_WAIT_DRELEASE,      EV_DIAL,                lli_no_dchan_ready},
1138
        {ST_WAIT_DRELEASE,      EV_DLRL,                lli_got_dlrl},
1139
        {ST_WAIT_D_REL_CNF,     EV_RELEASE_CNF,         lli_timeout_d},
1140
        {ST_WAIT_D_REL_CNF,     EV_RELEASE_ERR,         lli_timeout_d},
1141
/* ETS 300-104 16.1 */
1142
        {ST_WAIT_D_REL_CNF,     EV_RELEASE_IND,         lli_timeout_d},
1143
        {ST_WAIT_D_REL_CNF,     EV_DIAL,                lli_no_dchan_ready},
1144
        {ST_WAIT_D_REL_CNF,     EV_DLRL,                lli_got_dlrl},
1145
        {ST_WAIT_DSHUTDOWN,     EV_DLRL,                lli_go_null},
1146
        {ST_WAIT_DSHUTDOWN,     EV_DLEST,               lli_d_established},
1147
        {ST_WAIT_DSHUTDOWN,     EV_DIAL,                lli_prep_dialout},
1148
        {ST_WAIT_DSHUTDOWN,     EV_RESUME,              lli_prep_dialout},
1149
        {ST_WAIT_DSHUTDOWN,     EV_SETUP_IND,           lli_deliver_call},
1150
};
1151
/* *INDENT-ON* */
1152
 
1153
 
1154
#define FNCOUNT (sizeof(fnlist)/sizeof(struct FsmNode))
1155
 
1156
HISAX_INITFUNC(void
1157
CallcNew(void))
1158
{
1159
        callcfsm.state_count = STATE_COUNT;
1160
        callcfsm.event_count = EVENT_COUNT;
1161
        callcfsm.strEvent = strEvent;
1162
        callcfsm.strState = strState;
1163
        FsmNew(&callcfsm, fnlist, FNCOUNT);
1164
}
1165
 
1166
void
1167
CallcFree(void)
1168
{
1169
        FsmFree(&callcfsm);
1170
}
1171
 
1172
static void
1173
release_b_st(struct Channel *chanp)
1174
{
1175
        struct PStack *st = chanp->b_st;
1176
 
1177
        chanp->bcs->BC_Close(chanp->bcs);
1178
        switch (chanp->l2_active_protocol) {
1179
                case (ISDN_PROTO_L2_X75I):
1180
                        releasestack_isdnl2(st);
1181
                        break;
1182
                case (ISDN_PROTO_L2_HDLC):
1183
                case (ISDN_PROTO_L2_TRANS):
1184
//              case (ISDN_PROTO_L2_MODEM):
1185
                        releasestack_transl2(st);
1186
                        break;
1187
        }
1188
}
1189
 
1190
struct Channel
1191
*selectfreechannel(struct PStack *st)
1192
{
1193
        struct IsdnCardState *cs = st->l1.hardware;
1194
        struct Channel *chanp = st->lli.userdata;
1195
        int i;
1196
 
1197
        if (test_bit(FLG_TWO_DCHAN, &cs->HW_Flags))
1198
                i=1;
1199
        else
1200
                i=0;
1201
        while (i<2) {
1202
                if (chanp->fi.state == ST_NULL)
1203
                        return (chanp);
1204
                chanp++;
1205
                i++;
1206
        }
1207
        return (NULL);
1208
}
1209
 
1210
int
1211
is_activ(struct PStack *st)
1212
{
1213
        struct IsdnCardState *cs = st->l1.hardware;
1214
        struct Channel *chanp = st->lli.userdata;
1215
        int i;
1216
 
1217
        if (test_bit(FLG_TWO_DCHAN, &cs->HW_Flags))
1218
                i=1;
1219
        else
1220
                i=0;
1221
        while (i<2) {
1222
                if (test_bit(FLG_ESTAB_D, &chanp->Flags))
1223
                        return (1);
1224
                chanp++;
1225
                i++;
1226
        }
1227
        return (0);
1228
}
1229
 
1230
static void
1231
dchan_l3l4(struct PStack *st, int pr, void *arg)
1232
{
1233
        struct l3_process *pc = arg;
1234
        struct IsdnCardState *cs = st->l1.hardware;
1235
        struct Channel *chanp;
1236
        int event;
1237
 
1238
        switch (pr) {
1239
                case (DL_ESTABLISH | INDICATION):
1240
                        event = EV_DLEST;
1241
                        break;
1242
                case (DL_RELEASE | INDICATION):
1243
                        event = EV_DLRL;
1244
                        break;
1245
                default:
1246
                        event = -1;
1247
                        break;
1248
        }
1249
        if (event >= 0) {
1250
                int i;
1251
 
1252
                chanp = st->lli.userdata;
1253
                if (test_bit(FLG_TWO_DCHAN, &cs->HW_Flags))
1254
                        i = 1;
1255
                else
1256
                        i = 0;
1257
                while (i < 2) {
1258
                        FsmEvent(&chanp->fi, event, NULL);
1259
                        chanp++;
1260
                        i++;
1261
                }
1262
                return;
1263
        } else if (pr == (CC_SETUP | INDICATION)) {
1264
                if (!(chanp = selectfreechannel(pc->st))) {
1265
                        pc->st->lli.l4l3(pc->st, CC_DLRL | REQUEST, pc);
1266
                } else {
1267
                        chanp->proc = pc;
1268
                        pc->chan = chanp;
1269
                        FsmEvent(&chanp->fi, EV_SETUP_IND, NULL);
1270
                }
1271
                return;
1272
        }
1273
        if (!(chanp = pc->chan))
1274
                return;
1275
 
1276
        switch (pr) {
1277
                case (CC_DISCONNECT | INDICATION):
1278
                        FsmEvent(&chanp->fi, EV_DISCONNECT_IND, NULL);
1279
                        break;
1280
                case (CC_RELEASE | CONFIRM):
1281
                        FsmEvent(&chanp->fi, EV_RELEASE_CNF, NULL);
1282
                        break;
1283
                case (CC_SUSPEND | CONFIRM):
1284
                        FsmEvent(&chanp->fi, EV_RELEASE_CNF, NULL);
1285
                        break;
1286
                case (CC_RESUME | CONFIRM):
1287
                        FsmEvent(&chanp->fi, EV_SETUP_CNF, NULL);
1288
                        break;
1289
                case (CC_RESUME_ERR):
1290
                        FsmEvent(&chanp->fi, EV_RELEASE_CNF, NULL);
1291
                        break;
1292
                case (CC_RELEASE | INDICATION):
1293
                        FsmEvent(&chanp->fi, EV_RELEASE_IND, NULL);
1294
                        break;
1295
                case (CC_SETUP_COMPL | INDICATION):
1296
                        FsmEvent(&chanp->fi, EV_SETUP_CMPL_IND, NULL);
1297
                        break;
1298
                case (CC_SETUP | CONFIRM):
1299
                        FsmEvent(&chanp->fi, EV_SETUP_CNF, NULL);
1300
                        break;
1301
                case (CC_CHARGE | INDICATION):
1302
                        FsmEvent(&chanp->fi, EV_CINF, NULL);
1303
                        break;
1304
                case (CC_NOSETUP_RSP):
1305
                        FsmEvent(&chanp->fi, EV_NOSETUP_RSP, NULL);
1306
                        break;
1307
                case (CC_SETUP_ERR):
1308
                        FsmEvent(&chanp->fi, EV_SETUP_ERR, NULL);
1309
                        break;
1310
                case (CC_CONNECT_ERR):
1311
                        FsmEvent(&chanp->fi, EV_CONNECT_ERR, NULL);
1312
                        break;
1313
                case (CC_RELEASE_ERR):
1314
                        FsmEvent(&chanp->fi, EV_RELEASE_ERR, NULL);
1315
                        break;
1316
                case (CC_PROCEEDING | INDICATION):
1317
                case (CC_ALERTING | INDICATION):
1318
                        break;
1319
                default:
1320
                        if (chanp->debug & 0x800) {
1321
                                HiSax_putstatus(chanp->cs, "Ch",
1322
                                        "%d L3->L4 unknown primitiv %x",
1323
                                        chanp->chan, pr);
1324
                        }
1325
        }
1326
}
1327
 
1328
static void
1329
init_d_st(struct Channel *chanp)
1330
{
1331
        struct PStack *st = chanp->d_st;
1332
        struct IsdnCardState *cs = chanp->cs;
1333
        char tmp[16];
1334
 
1335
        HiSax_addlist(cs, st);
1336
        setstack_HiSax(st, cs);
1337
        st->l2.sap = 0;
1338
        st->l2.tei = -1;
1339
        st->l2.flag = 0;
1340
        test_and_set_bit(FLG_MOD128, &st->l2.flag);
1341
        test_and_set_bit(FLG_LAPD, &st->l2.flag);
1342
        test_and_set_bit(FLG_ORIG, &st->l2.flag);
1343
        st->l2.maxlen = MAX_DFRAME_LEN;
1344
        st->l2.window = 1;
1345
        st->l2.T200 = 1000;     /* 1000 milliseconds  */
1346
        st->l2.N200 = 3;        /* try 3 times        */
1347
        st->l2.T203 = 10000;    /* 10000 milliseconds */
1348
        if (test_bit(FLG_TWO_DCHAN, &cs->HW_Flags))
1349
                sprintf(tmp, "DCh%d Q.921 ", chanp->chan);
1350
        else
1351
                sprintf(tmp, "DCh Q.921 ");
1352
        setstack_isdnl2(st, tmp);
1353
        setstack_l3dc(st, chanp);
1354
        st->lli.userdata = chanp;
1355
        st->lli.l2writewakeup = NULL;
1356
        st->l3.l3l4 = dchan_l3l4;
1357
}
1358
 
1359
static void
1360
callc_debug(struct FsmInst *fi, char *fmt, ...)
1361
{
1362
        va_list args;
1363
        struct Channel *chanp = fi->userdata;
1364
        char tmp[16];
1365
 
1366
        va_start(args, fmt);
1367
        sprintf(tmp, "Ch%d callc ", chanp->chan);
1368
        VHiSax_putstatus(chanp->cs, tmp, fmt, args);
1369
        va_end(args);
1370
}
1371
 
1372
static void
1373
dummy_pstack(struct PStack *st, int pr, void *arg) {
1374
        printk(KERN_WARNING"call to dummy_pstack pr=%04x arg %lx\n", pr, (long)arg);
1375
}
1376
 
1377
static void
1378
init_PStack(struct PStack **stp) {
1379
        *stp = kmalloc(sizeof(struct PStack), GFP_ATOMIC);
1380
        (*stp)->next = NULL;
1381
        (*stp)->l1.l1l2 = dummy_pstack;
1382
        (*stp)->l1.l1hw = dummy_pstack;
1383
        (*stp)->l1.l1tei = dummy_pstack;
1384
        (*stp)->l2.l2tei = dummy_pstack;
1385
        (*stp)->l2.l2l1 = dummy_pstack;
1386
        (*stp)->l2.l2l3 = dummy_pstack;
1387
        (*stp)->l3.l3l2 = dummy_pstack;
1388
        (*stp)->l3.l3l4 = dummy_pstack;
1389
        (*stp)->lli.l4l3 = dummy_pstack;
1390
        (*stp)->ma.layer = dummy_pstack;
1391
}
1392
 
1393
static void
1394
init_chan(int chan, struct IsdnCardState *csta)
1395
{
1396
        struct Channel *chanp = csta->channel + chan;
1397
 
1398
        chanp->cs = csta;
1399
        chanp->bcs = csta->bcs + chan;
1400
        chanp->chan = chan;
1401
        chanp->incoming = 0;
1402
        chanp->debug = 0;
1403
        chanp->Flags = 0;
1404
        chanp->leased = 0;
1405
        init_PStack(&chanp->b_st);
1406
        chanp->b_st->l1.delay = DEFAULT_B_DELAY;
1407
        chanp->fi.fsm = &callcfsm;
1408
        chanp->fi.state = ST_NULL;
1409
        chanp->fi.debug = 0;
1410
        chanp->fi.userdata = chanp;
1411
        chanp->fi.printdebug = callc_debug;
1412
        FsmInitTimer(&chanp->fi, &chanp->dial_timer);
1413
        FsmInitTimer(&chanp->fi, &chanp->drel_timer);
1414
        if (!chan || test_bit(FLG_TWO_DCHAN, &csta->HW_Flags)) {
1415
                init_PStack(&chanp->d_st);
1416
                if (chan)
1417
                        csta->channel->d_st->next = chanp->d_st;
1418
                chanp->d_st->next = NULL;
1419
                init_d_st(chanp);
1420
        } else {
1421
                chanp->d_st = csta->channel->d_st;
1422
        }
1423
        chanp->data_open = 0;
1424
}
1425
 
1426
int
1427
CallcNewChan(struct IsdnCardState *csta)
1428
{
1429
        chancount += 2;
1430
        init_chan(0, csta);
1431
        init_chan(1, csta);
1432
        printk(KERN_INFO "HiSax: 2 channels added\n");
1433
        if (test_bit(FLG_PTP, &csta->channel->d_st->l2.flag)) {
1434
                printk(KERN_INFO "LAYER2 WATCHING ESTABLISH\n");
1435
                test_and_set_bit(FLG_START_D, &csta->channel->Flags);
1436
                csta->channel->d_st->lli.l4l3(csta->channel->d_st,
1437
                        DL_ESTABLISH | REQUEST, NULL);
1438
        }
1439
        return (2);
1440
}
1441
 
1442
static void
1443
release_d_st(struct Channel *chanp)
1444
{
1445
        struct PStack *st = chanp->d_st;
1446
 
1447
        if (!st)
1448
                return;
1449
        releasestack_isdnl2(st);
1450
        releasestack_isdnl3(st);
1451
        HiSax_rmlist(st->l1.hardware, st);
1452
        kfree(st);
1453
        chanp->d_st = NULL;
1454
}
1455
 
1456
void
1457
CallcFreeChan(struct IsdnCardState *csta)
1458
{
1459
        int i;
1460
 
1461
        for (i = 0; i < 2; i++) {
1462
                FsmDelTimer(&csta->channel[i].drel_timer, 74);
1463
                FsmDelTimer(&csta->channel[i].dial_timer, 75);
1464
                if (i || test_bit(FLG_TWO_DCHAN, &csta->HW_Flags))
1465
                        release_d_st(csta->channel + i);
1466
                if (csta->channel[i].b_st) {
1467
                        if (test_and_clear_bit(FLG_START_B, &csta->channel[i].Flags))
1468
                                release_b_st(csta->channel + i);
1469
                        kfree(csta->channel[i].b_st);
1470
                        csta->channel[i].b_st = NULL;
1471
                } else
1472
                        printk(KERN_WARNING "CallcFreeChan b_st ch%d allready freed\n", i);
1473
                if (i || test_bit(FLG_TWO_DCHAN, &csta->HW_Flags)) {
1474
                        release_d_st(csta->channel + i);
1475
                } else
1476
                        csta->channel[i].d_st = NULL;
1477
        }
1478
}
1479
 
1480
static void
1481
lldata_handler(struct PStack *st, int pr, void *arg)
1482
{
1483
        struct Channel *chanp = (struct Channel *) st->lli.userdata;
1484
        struct sk_buff *skb = arg;
1485
 
1486
        switch (pr) {
1487
                case (DL_DATA  | INDICATION):
1488
                        if (chanp->data_open)
1489
                                chanp->cs->iif.rcvcallb_skb(chanp->cs->myid, chanp->chan, skb);
1490
                        else {
1491
                                dev_kfree_skb(skb, FREE_READ);
1492
                        }
1493
                        break;
1494
                case (DL_ESTABLISH | INDICATION):
1495
                case (DL_ESTABLISH | CONFIRM):
1496
                        FsmEvent(&chanp->fi, EV_BC_EST, NULL);
1497
                        break;
1498
                case (DL_RELEASE | INDICATION):
1499
                case (DL_RELEASE | CONFIRM):
1500
                        FsmEvent(&chanp->fi, EV_BC_REL, NULL);
1501
                        break;
1502
                default:
1503
                        printk(KERN_WARNING "lldata_handler unknown primitive %x\n",
1504
                               pr);
1505
                        break;
1506
        }
1507
}
1508
 
1509
static void
1510
lltrans_handler(struct PStack *st, int pr, void *arg)
1511
{
1512
        struct Channel *chanp = (struct Channel *) st->lli.userdata;
1513
        struct sk_buff *skb = arg;
1514
 
1515
        switch (pr) {
1516
                case (PH_DATA | INDICATION):
1517
                        if (chanp->data_open)
1518
                                chanp->cs->iif.rcvcallb_skb(chanp->cs->myid, chanp->chan, skb);
1519
                        else {
1520
                                link_debug(chanp, 0, "channel not open");
1521
                                dev_kfree_skb(skb, FREE_READ);
1522
                        }
1523
                        break;
1524
                case (PH_ACTIVATE | INDICATION):
1525
                case (PH_ACTIVATE | CONFIRM):
1526
                        FsmEvent(&chanp->fi, EV_BC_EST, NULL);
1527
                        break;
1528
                case (PH_DEACTIVATE | INDICATION):
1529
                case (PH_DEACTIVATE | CONFIRM):
1530
                        FsmEvent(&chanp->fi, EV_BC_REL, NULL);
1531
                        break;
1532
                default:
1533
                        printk(KERN_WARNING "lltrans_handler unknown primitive %x\n",
1534
                               pr);
1535
                        break;
1536
        }
1537
}
1538
 
1539
static void
1540
ll_writewakeup(struct PStack *st, int len)
1541
{
1542
        struct Channel *chanp = st->lli.userdata;
1543
        isdn_ctrl ic;
1544
 
1545
        ic.driver = chanp->cs->myid;
1546
        ic.command = ISDN_STAT_BSENT;
1547
        ic.arg = chanp->chan;
1548
//      ic.parm.length = len;
1549
        chanp->cs->iif.statcallb(&ic);
1550
}
1551
 
1552
static int
1553
init_b_st(struct Channel *chanp, int incoming)
1554
{
1555
        struct PStack *st = chanp->b_st;
1556
        struct IsdnCardState *cs = chanp->cs;
1557
        char tmp[16];
1558
 
1559
        st->l1.hardware = cs;
1560
        if (chanp->leased)
1561
                st->l1.bc = chanp->chan & 1;
1562
        else
1563
                st->l1.bc = chanp->proc->para.bchannel - 1;
1564
        switch (chanp->l2_active_protocol) {
1565
                case (ISDN_PROTO_L2_X75I):
1566
                case (ISDN_PROTO_L2_HDLC):
1567
                        st->l1.mode = L1_MODE_HDLC;
1568
                        break;
1569
                case (ISDN_PROTO_L2_TRANS):
1570
                        st->l1.mode = L1_MODE_TRANS;
1571
                        break;
1572
#if 0
1573
                case (ISDN_PROTO_L2_MODEM):
1574
                        st->l1.mode = L1_MODE_MODEM;
1575
                        break;
1576
#endif
1577
        }
1578
        if (chanp->bcs->BC_SetStack(st, chanp->bcs))
1579
                return (-1);
1580
        st->l2.flag = 0;
1581
        test_and_set_bit(FLG_LAPB, &st->l2.flag);
1582
        st->l2.maxlen = MAX_DATA_SIZE;
1583
        if (!incoming)
1584
                test_and_set_bit(FLG_ORIG, &st->l2.flag);
1585
        st->l2.T200 = 1000;     /* 1000 milliseconds */
1586
        st->l2.window = 7;
1587
        st->l2.N200 = 4;        /* try 4 times       */
1588
        st->l2.T203 = 5000;     /* 5000 milliseconds */
1589
        st->l3.debug = 0;
1590
        switch (chanp->l2_active_protocol) {
1591
                case (ISDN_PROTO_L2_X75I):
1592
                        sprintf(tmp, "Ch%d X.75", chanp->chan);
1593
                        setstack_isdnl2(st, tmp);
1594
                        setstack_l3bc(st, chanp);
1595
                        st->l2.l2l3 = lldata_handler;
1596
                        st->lli.userdata = chanp;
1597
                        st->lli.l1writewakeup = NULL;
1598
                        st->lli.l2writewakeup = ll_writewakeup;
1599
                        st->l2.l2m.debug = chanp->debug & 16;
1600
                        st->l2.debug = chanp->debug & 64;
1601
                        break;
1602
                case (ISDN_PROTO_L2_HDLC):
1603
                case (ISDN_PROTO_L2_TRANS):
1604
//              case (ISDN_PROTO_L2_MODEM):
1605
                        st->l1.l1l2 = lltrans_handler;
1606
                        st->lli.userdata = chanp;
1607
                        st->lli.l1writewakeup = ll_writewakeup;
1608
                        setstack_transl2(st);
1609
                        setstack_l3bc(st, chanp);
1610
                        break;
1611
        }
1612
        return (0);
1613
}
1614
 
1615
static void
1616
leased_l4l3(struct PStack *st, int pr, void *arg)
1617
{
1618
        struct Channel *chanp = (struct Channel *) st->lli.userdata;
1619
        struct sk_buff *skb = arg;
1620
 
1621
        switch (pr) {
1622
                case (DL_DATA | REQUEST):
1623
                        link_debug(chanp, 0, "leased line d-channel DATA");
1624
                        dev_kfree_skb(skb, FREE_READ);
1625
                        break;
1626
                case (DL_ESTABLISH | REQUEST):
1627
                        st->l2.l2l1(st, PH_ACTIVATE | REQUEST, NULL);
1628
                        break;
1629
                case (DL_RELEASE | REQUEST):
1630
                        break;
1631
                default:
1632
                        printk(KERN_WARNING "transd_l4l3 unknown primitive %x\n",
1633
                               pr);
1634
                        break;
1635
        }
1636
}
1637
 
1638
static void
1639
leased_l1l2(struct PStack *st, int pr, void *arg)
1640
{
1641
        struct Channel *chanp = (struct Channel *) st->lli.userdata;
1642
        struct sk_buff *skb = arg;
1643
        int i,event = EV_DLRL;
1644
 
1645
        switch (pr) {
1646
                case (PH_DATA | INDICATION):
1647
                        link_debug(chanp, 0, "leased line d-channel DATA");
1648
                        dev_kfree_skb(skb, FREE_READ);
1649
                        break;
1650
                case (PH_ACTIVATE | INDICATION):
1651
                case (PH_ACTIVATE | CONFIRM):
1652
                        event = EV_DLEST;
1653
                case (PH_DEACTIVATE | INDICATION):
1654
                case (PH_DEACTIVATE | CONFIRM):
1655
                        if (test_bit(FLG_TWO_DCHAN, &chanp->cs->HW_Flags))
1656
                                i = 1;
1657
                        else
1658
                                i = 0;
1659
                        while (i < 2) {
1660
                                FsmEvent(&chanp->fi, event, NULL);
1661
                                chanp++;
1662
                                i++;
1663
                        }
1664
                        break;
1665
                default:
1666
                        printk(KERN_WARNING
1667
                                "transd_l1l2 unknown primitive %x\n", pr);
1668
                        break;
1669
        }
1670
}
1671
 
1672
static void
1673
channel_report(struct Channel *chanp)
1674
{
1675
}
1676
 
1677
static void
1678
distr_debug(struct IsdnCardState *csta, int debugflags)
1679
{
1680
        int i;
1681
        struct Channel *chanp = csta->channel;
1682
 
1683
        for (i = 0; i < 2; i++) {
1684
                chanp[i].debug = debugflags;
1685
                chanp[i].fi.debug = debugflags & 2;
1686
                chanp[i].d_st->l2.l2m.debug = debugflags & 8;
1687
                chanp[i].b_st->l2.l2m.debug = debugflags & 0x10;
1688
                chanp[i].d_st->l2.debug = debugflags & 0x20;
1689
                chanp[i].b_st->l2.debug = debugflags & 0x40;
1690
                chanp[i].d_st->l3.l3m.debug = debugflags & 0x80;
1691
                chanp[i].b_st->l3.l3m.debug = debugflags & 0x100;
1692
                chanp[i].b_st->ma.tei_m.debug = debugflags & 0x200;
1693
                chanp[i].b_st->ma.debug = debugflags & 0x200;
1694
                chanp[i].d_st->l1.l1m.debug = debugflags & 0x1000;
1695
                chanp[i].b_st->l1.l1m.debug = debugflags & 0x2000;
1696
        }
1697
        if (debugflags & 4)
1698
                csta->debug |= DEB_DLOG_HEX;
1699
        else
1700
                csta->debug &= ~DEB_DLOG_HEX;
1701
}
1702
 
1703
#if 0
1704
static char tmpbuf[256];
1705
 
1706
static void
1707
capi_debug(struct Channel *chanp, capi_msg *cm)
1708
{
1709
        char *t = tmpbuf;
1710
 
1711
        t += sprintf(tmpbuf, "%d CAPIMSG", chanp->chan);
1712
        t += QuickHex(t, (u_char *)cm, (cm->Length>50)? 50: cm->Length);
1713
        t--;
1714
        *t= 0;
1715
        HiSax_putstatus(chanp->cs, "Ch", "%d CAPIMSG %s", chanp->chan, tmpbuf);
1716
}
1717
 
1718
void
1719
lli_got_fac_req(struct Channel *chanp, capi_msg *cm) {
1720
        if ((cm->para[0] != 3) || (cm->para[1] != 0))
1721
                return;
1722
        if (cm->para[2]<3)
1723
                return;
1724
        if (cm->para[4] != 0)
1725
                return;
1726
        switch(cm->para[3]) {
1727
                case 4: /* Suspend */
1728
                        if (cm->para[5]) {
1729
                                strncpy(chanp->setup.phone, &cm->para[5], cm->para[5] +1);
1730
                                FsmEvent(&chanp->fi, EV_SUSPEND, cm);
1731
                        }
1732
                        break;
1733
                case 5: /* Resume */
1734
                        if (cm->para[5]) {
1735
                                strncpy(chanp->setup.phone, &cm->para[5], cm->para[5] +1);
1736
                                if (chanp->fi.state == ST_NULL) {
1737
                                        FsmEvent(&chanp->fi, EV_RESUME, cm);
1738
                                } else {
1739
                                        FsmDelTimer(&chanp->dial_timer, 72);
1740
                                        FsmAddTimer(&chanp->dial_timer, 80, EV_RESUME, cm, 73);
1741
                                }
1742
                        }
1743
                        break;
1744
        }
1745
}
1746
 
1747
void
1748
lli_got_manufacturer(struct Channel *chanp, struct IsdnCardState *cs, capi_msg *cm) {
1749
        if ((cs->typ == ISDN_CTYPE_ELSA) || (cs->typ == ISDN_CTYPE_ELSA_PNP) ||
1750
                (cs->typ == ISDN_CTYPE_ELSA_PCI)) {
1751
                if (cs->hw.elsa.MFlag) {
1752
                        cs->cardmsg(cs, CARD_AUX_IND, cm->para);
1753
                }
1754
        }
1755
}
1756
#endif
1757
 
1758
int
1759
HiSax_command(isdn_ctrl * ic)
1760
{
1761
        struct IsdnCardState *csta = hisax_findcard(ic->driver);
1762
        struct Channel *chanp;
1763
        int i;
1764
        u_int num;
1765
        u_long adr;
1766
 
1767
        if (!csta) {
1768
                printk(KERN_ERR
1769
                "HiSax: if_command %d called with invalid driverId %d!\n",
1770
                       ic->command, ic->driver);
1771
                return -ENODEV;
1772
        }
1773
 
1774
        switch (ic->command) {
1775
                case (ISDN_CMD_SETEAZ):
1776
                        chanp = csta->channel + ic->arg;
1777
                        break;
1778
 
1779
                case (ISDN_CMD_SETL2):
1780
                        chanp = csta->channel + (ic->arg & 0xff);
1781
                        if (chanp->debug & 1)
1782
                                link_debug(chanp, 1, "SETL2 card %d %ld",
1783
                                        csta->cardnr + 1, ic->arg >> 8);
1784
                        chanp->l2_protocol = ic->arg >> 8;
1785
                        break;
1786
                case (ISDN_CMD_SETL3):
1787
                        chanp = csta->channel + (ic->arg & 0xff);
1788
                        if (chanp->debug & 1)
1789
                                link_debug(chanp, 1, "SETL3 card %d %ld",
1790
                                        csta->cardnr + 1, ic->arg >> 8);
1791
                        chanp->l3_protocol = ic->arg >> 8;
1792
                        break;
1793
                case (ISDN_CMD_DIAL):
1794
                        chanp = csta->channel + (ic->arg & 0xff);
1795
                        if (chanp->debug & 1)
1796
                                link_debug(chanp, 1, "DIAL %s -> %s (%d,%d)",
1797
                                        ic->parm.setup.eazmsn, ic->parm.setup.phone,
1798
                                        ic->parm.setup.si1, ic->parm.setup.si2);
1799
                        chanp->setup = ic->parm.setup;
1800
                        if (!strcmp(chanp->setup.eazmsn, "0"))
1801
                                chanp->setup.eazmsn[0] = '\0';
1802
                        /* this solution is dirty and may be change, if
1803
                         * we make a callreference based callmanager */
1804
                        if (chanp->fi.state == ST_NULL) {
1805
                                FsmEvent(&chanp->fi, EV_DIAL, NULL);
1806
                        } else {
1807
                                FsmDelTimer(&chanp->dial_timer, 70);
1808
                                FsmAddTimer(&chanp->dial_timer, 50, EV_DIAL, NULL, 71);
1809
                        }
1810
                        break;
1811
                case (ISDN_CMD_ACCEPTB):
1812
                        chanp = csta->channel + ic->arg;
1813
                        if (chanp->debug & 1)
1814
                                link_debug(chanp, 1, "ACCEPTB");
1815
                        FsmEvent(&chanp->fi, EV_ACCEPTB, NULL);
1816
                        break;
1817
                case (ISDN_CMD_ACCEPTD):
1818
                        chanp = csta->channel + ic->arg;
1819
                        if (chanp->debug & 1)
1820
                                link_debug(chanp, 1, "ACCEPTD");
1821
                        FsmEvent(&chanp->fi, EV_ACCEPTD, NULL);
1822
                        break;
1823
                case (ISDN_CMD_HANGUP):
1824
                        chanp = csta->channel + ic->arg;
1825
                        if (chanp->debug & 1)
1826
                                link_debug(chanp, 1, "HANGUP");
1827
                        FsmEvent(&chanp->fi, EV_HANGUP, NULL);
1828
                        break;
1829
#if 0
1830
                case (CAPI_PUT_MESSAGE):
1831
                        chanp = csta->channel + ic->arg;
1832
                        if (chanp->debug & 1)
1833
                                capi_debug(chanp, &ic->parm.cmsg);
1834
                        if (ic->parm.cmsg.Length < 8)
1835
                                break;
1836
                        switch(ic->parm.cmsg.Command) {
1837
                                case CAPI_FACILITY:
1838
                                        if (ic->parm.cmsg.Subcommand == CAPI_REQ)
1839
                                                lli_got_fac_req(chanp, &ic->parm.cmsg);
1840
                                        break;
1841
                                case CAPI_MANUFACTURER:
1842
                                        if (ic->parm.cmsg.Subcommand == CAPI_REQ)
1843
                                                lli_got_manufacturer(chanp, csta, &ic->parm.cmsg);
1844
                                        break;
1845
                                default:
1846
                                        break;
1847
                        }
1848
                        break;
1849
#endif
1850
                case (ISDN_CMD_LOCK):
1851
                        HiSax_mod_inc_use_count();
1852
#ifdef MODULE
1853
                        if (csta->channel[0].debug & 0x400)
1854
                                HiSax_putstatus(csta, "   LOCK ", "modcnt %lx",
1855
                                        MOD_USE_COUNT);
1856
#endif                          /* MODULE */
1857
                        break;
1858
                case (ISDN_CMD_UNLOCK):
1859
                        HiSax_mod_dec_use_count();
1860
#ifdef MODULE
1861
                        if (csta->channel[0].debug & 0x400)
1862
                                HiSax_putstatus(csta, " UNLOCK ", "modcnt %lx",
1863
                                        MOD_USE_COUNT);
1864
#endif                          /* MODULE */
1865
                        break;
1866
                case (ISDN_CMD_IOCTL):
1867
                        switch (ic->arg) {
1868
                                case (0):
1869
                                        HiSax_reportcard(csta->cardnr);
1870
                                        for (i = 0; i < 2; i++)
1871
                                                channel_report(&csta->channel[i]);
1872
                                        break;
1873
                                case (1):
1874
                                        num = *(unsigned int *) ic->parm.num;
1875
                                        distr_debug(csta, num);
1876
                                        printk(KERN_DEBUG "HiSax: debugging flags card %d set to %x\n",
1877
                                                csta->cardnr + 1, num);
1878
                                        HiSax_putstatus(csta, "debugging flags ",
1879
                                                "card %d set to %x", csta->cardnr + 1, num);
1880
                                        break;
1881
                                case (2):
1882
                                        num = *(unsigned int *) ic->parm.num;
1883
                                        csta->channel[0].b_st->l1.delay = num;
1884
                                        csta->channel[1].b_st->l1.delay = num;
1885
                                        HiSax_putstatus(csta, "delay ", "card %d set to %d ms",
1886
                                                csta->cardnr + 1, num);
1887
                                        printk(KERN_DEBUG "HiSax: delay card %d set to %d ms\n",
1888
                                                csta->cardnr + 1, num);
1889
                                        break;
1890
                                case (3):
1891
                                        for (i = 0; i < *(unsigned int *) ic->parm.num; i++)
1892
                                                HiSax_mod_dec_use_count();
1893
                                        break;
1894
                                case (4):
1895
                                        for (i = 0; i < *(unsigned int *) ic->parm.num; i++)
1896
                                                HiSax_mod_inc_use_count();
1897
                                        break;
1898
                                case (5):       /* set card in leased mode */
1899
                                        num = *(unsigned int *) ic->parm.num;
1900
                                        if ((num <1) || (num > 2)) {
1901
                                                HiSax_putstatus(csta, "Set LEASED ",
1902
                                                        "wrong channel %d", num);
1903
                                                printk(KERN_WARNING "HiSax: Set LEASED wrong channel %d\n",
1904
                                                        num);
1905
                                        } else {
1906
                                                num--;
1907
                                                chanp = csta->channel +num;
1908
                                                chanp->leased = 1;
1909
                                                HiSax_putstatus(csta, "Card",
1910
                                                        "%d channel %d set leased mode\n",
1911
                                                        csta->cardnr + 1, num + 1);
1912
                                                chanp->d_st->l1.l1l2 = leased_l1l2;
1913
                                                chanp->d_st->lli.l4l3 = leased_l4l3;
1914
                                                chanp->d_st->lli.l4l3(chanp->d_st,
1915
                                                        DL_ESTABLISH | REQUEST, NULL);
1916
                                        }
1917
                                        break;
1918
                                case (6):       /* set B-channel test loop */
1919
                                        num = *(unsigned int *) ic->parm.num;
1920
                                        if (csta->stlist)
1921
                                                csta->stlist->l2.l2l1(csta->stlist,
1922
                                                        PH_TESTLOOP | REQUEST, (void *) (long)num);
1923
                                        break;
1924
                                case (7):       /* set card in PTP mode */
1925
                                        num = *(unsigned int *) ic->parm.num;
1926
                                        if (test_bit(FLG_TWO_DCHAN, &csta->HW_Flags)) {
1927
                                                printk(KERN_ERR "HiSax PTP mode only with one TEI possible\n");
1928
                                        } else if (num) {
1929
                                                test_and_set_bit(FLG_PTP, &csta->channel[0].d_st->l2.flag);
1930
                                                test_and_set_bit(FLG_FIXED_TEI, &csta->channel[0].d_st->l2.flag);
1931
                                                csta->channel[0].d_st->l2.tei = 0;
1932
                                                HiSax_putstatus(csta, "set card ", "in PTP mode");
1933
                                                printk(KERN_DEBUG "HiSax: set card in PTP mode\n");
1934
                                                printk(KERN_INFO "LAYER2 WATCHING ESTABLISH\n");
1935
                                                test_and_set_bit(FLG_START_D, &csta->channel[0].Flags);
1936
                                                test_and_set_bit(FLG_START_D, &csta->channel[1].Flags);
1937
                                                csta->channel[0].d_st->lli.l4l3(csta->channel[0].d_st,
1938
                                                        DL_ESTABLISH | REQUEST, NULL);
1939
                                        } else {
1940
                                                test_and_clear_bit(FLG_PTP, &csta->channel[0].d_st->l2.flag);
1941
                                                test_and_clear_bit(FLG_FIXED_TEI, &csta->channel[0].d_st->l2.flag);
1942
                                                HiSax_putstatus(csta, "set card ", "in PTMP mode");
1943
                                                printk(KERN_DEBUG "HiSax: set card in PTMP mode\n");
1944
                                        }
1945
                                        break;
1946
                                case (8):       /* set card in FIXED TEI mode */
1947
                                        num = *(unsigned int *) ic->parm.num;
1948
                                        chanp = csta->channel + (num & 1);
1949
                                        num = num >>1;
1950
                                        test_and_set_bit(FLG_FIXED_TEI, &chanp->d_st->l2.flag);
1951
                                        chanp->d_st->l2.tei = num;
1952
                                        HiSax_putstatus(csta, "set card ", "in FIXED TEI (%d) mode", num);
1953
                                        printk(KERN_DEBUG "HiSax: set card in FIXED TEI (%d) mode\n",
1954
                                                num);
1955
                                        break;
1956
                                case (9): /* load firmware */
1957
                                        memcpy(&adr, ic->parm.num, sizeof(ulong));
1958
                                        csta->cardmsg(csta, CARD_LOAD_FIRM,
1959
                                                (void *) adr);
1960
                                        break;
1961
#ifdef MODULE
1962
                                case (55):
1963
                                        MOD_USE_COUNT = 0;
1964
                                        HiSax_mod_inc_use_count();
1965
                                        break;
1966
#endif                          /* MODULE */
1967
                                case (11):
1968
                                        num = csta->debug & DEB_DLOG_HEX;
1969
                                        csta->debug = *(unsigned int *) ic->parm.num;
1970
                                        csta->debug |= num;
1971
                                        HiSax_putstatus(cards[0].cs, "l1 debugging ",
1972
                                                "flags card %d set to %x",
1973
                                                csta->cardnr + 1, csta->debug);
1974
                                        printk(KERN_DEBUG "HiSax: l1 debugging flags card %d set to %x\n",
1975
                                                csta->cardnr + 1, csta->debug);
1976
                                        break;
1977
                                case (13):
1978
                                        csta->channel[0].d_st->l3.debug = *(unsigned int *) ic->parm.num;
1979
                                        csta->channel[1].d_st->l3.debug = *(unsigned int *) ic->parm.num;
1980
                                        HiSax_putstatus(cards[0].cs, "l3 debugging ",
1981
                                                "flags card %d set to %x\n", csta->cardnr + 1,
1982
                                                *(unsigned int *) ic->parm.num);
1983
                                        printk(KERN_DEBUG "HiSax: l3 debugging flags card %d set to %x\n",
1984
                                                csta->cardnr + 1, *(unsigned int *) ic->parm.num);
1985
                                        break;
1986
                                default:
1987
                                        printk(KERN_DEBUG "HiSax: invalid ioclt %d\n",
1988
                                               (int) ic->arg);
1989
                                        return (-EINVAL);
1990
                        }
1991
                        break;
1992
                default:
1993
                        break;
1994
        }
1995
 
1996
        return (0);
1997
}
1998
 
1999
int
2000
HiSax_writebuf_skb(int id, int chan, struct sk_buff *skb)
2001
{
2002
        struct IsdnCardState *csta = hisax_findcard(id);
2003
        struct Channel *chanp;
2004
        struct PStack *st;
2005
        int len = skb->len;
2006
        unsigned long flags;
2007
        struct sk_buff *nskb;
2008
 
2009
        if (!csta) {
2010
                printk(KERN_ERR
2011
                    "HiSax: if_sendbuf called with invalid driverId!\n");
2012
                return -ENODEV;
2013
        }
2014
        chanp = csta->channel + chan;
2015
        st = chanp->b_st;
2016
        if (!chanp->data_open) {
2017
                link_debug(chanp, 1, "writebuf: channel not open");
2018
                return -EIO;
2019
        }
2020
        if (len > MAX_DATA_SIZE) {
2021
                link_debug(chanp, 1, "writebuf: packet too large (%d bytes)", len);
2022
                printk(KERN_WARNING "HiSax_writebuf: packet too large (%d bytes) !\n",
2023
                        len);
2024
                return -EINVAL;
2025
        }
2026
        if (len) {
2027
                if ((len + chanp->bcs->tx_cnt) > MAX_DATA_MEM) {
2028
                        /* Must return 0 here, since this is not an error
2029
                         * but a temporary lack of resources.
2030
                         */
2031
                        if (chanp->debug & 0x800)
2032
                                link_debug(chanp, 1, "writebuf: no buffers for %d bytes", len);
2033
                        return 0;
2034
                }
2035
                save_flags(flags);
2036
                cli();
2037
                nskb = skb_clone(skb, GFP_ATOMIC);
2038
                if (nskb) {
2039
//                      if (!ack)
2040
//                              nskb->pkt_type = PACKET_NOACK;
2041
                        if (chanp->l2_active_protocol == ISDN_PROTO_L2_X75I)
2042
                                st->l3.l3l2(st, DL_DATA | REQUEST, nskb);
2043
                        else {
2044
                                chanp->bcs->tx_cnt += len;
2045
                                st->l2.l2l1(st, PH_DATA | REQUEST, nskb);
2046
                        }
2047
                        dev_kfree_skb(skb, FREE_WRITE);
2048
                } else
2049
                        len = 0;
2050
                restore_flags(flags);
2051
        }
2052
        return (len);
2053
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.