2 * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 *---------------------------------------------------------------------------
27 * i4b_l2fsm.c - layer 2 FSM
28 * -------------------------
30 * $Id: i4b_l2fsm.c,v 1.22 2000/08/24 11:48:58 hm Exp $
32 * $FreeBSD: src/sys/i4b/layer2/i4b_l2fsm.c,v 1.6.2.1 2001/08/10 14:08:41 obrien Exp $
33 * $DragonFly: src/sys/net/i4b/layer2/i4b_l2fsm.c,v 1.6 2005/06/14 21:19:19 joerg Exp $
35 * last edit-date: [Tue May 30 15:48:20 2000]
37 *---------------------------------------------------------------------------*/
39 #include "use_i4bq921.h"
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/socket.h>
47 #include <net/i4b/include/machine/i4b_debug.h>
48 #include <net/i4b/include/machine/i4b_ioctl.h>
50 #include "../include/i4b_global.h"
51 #include "../include/i4b_l2l3.h"
52 #include "../include/i4b_mbuf.h"
55 #include "i4b_l2fsm.h"
57 l2_softc_t l2_softc[MAXL1UNITS];
60 static char *l2state_text[N_STATES] = {
75 static char *l2event_text[N_EVENTS] = {
100 static void F_TU01 (l2_softc_t *);
101 static void F_TU03 (l2_softc_t *);
103 static void F_TA03 (l2_softc_t *);
104 static void F_TA04 (l2_softc_t *);
105 static void F_TA05 (l2_softc_t *);
107 static void F_TE03 (l2_softc_t *);
108 static void F_TE04 (l2_softc_t *);
109 static void F_TE05 (l2_softc_t *);
111 static void F_T01 (l2_softc_t *);
112 static void F_T05 (l2_softc_t *);
113 static void F_T06 (l2_softc_t *);
114 static void F_T07 (l2_softc_t *);
115 static void F_T08 (l2_softc_t *);
116 static void F_T09 (l2_softc_t *);
117 static void F_T10 (l2_softc_t *);
118 static void F_T13 (l2_softc_t *);
120 static void F_AE01 (l2_softc_t *);
121 static void F_AE05 (l2_softc_t *);
122 static void F_AE06 (l2_softc_t *);
123 static void F_AE07 (l2_softc_t *);
124 static void F_AE08 (l2_softc_t *);
125 static void F_AE09 (l2_softc_t *);
126 static void F_AE10 (l2_softc_t *);
127 static void F_AE11 (l2_softc_t *);
128 static void F_AE12 (l2_softc_t *);
130 static void F_AR05 (l2_softc_t *);
131 static void F_AR06 (l2_softc_t *);
132 static void F_AR07 (l2_softc_t *);
133 static void F_AR08 (l2_softc_t *);
134 static void F_AR09 (l2_softc_t *);
135 static void F_AR10 (l2_softc_t *);
136 static void F_AR11 (l2_softc_t *);
138 static void F_MF01 (l2_softc_t *);
139 static void F_MF05 (l2_softc_t *);
140 static void F_MF06 (l2_softc_t *);
141 static void F_MF07 (l2_softc_t *);
142 static void F_MF08 (l2_softc_t *);
143 static void F_MF09 (l2_softc_t *);
144 static void F_MF10 (l2_softc_t *);
145 static void F_MF11 (l2_softc_t *);
146 static void F_MF12 (l2_softc_t *);
147 static void F_MF13 (l2_softc_t *);
148 static void F_MF14 (l2_softc_t *);
149 static void F_MF15 (l2_softc_t *);
150 static void F_MF16 (l2_softc_t *);
151 static void F_MF17 (l2_softc_t *);
152 static void F_MF18 (l2_softc_t *);
153 static void F_MF19 (l2_softc_t *);
154 static void F_MF20 (l2_softc_t *);
156 static void F_TR01 (l2_softc_t *);
157 static void F_TR05 (l2_softc_t *);
158 static void F_TR06 (l2_softc_t *);
159 static void F_TR07 (l2_softc_t *);
160 static void F_TR08 (l2_softc_t *);
161 static void F_TR09 (l2_softc_t *);
162 static void F_TR10 (l2_softc_t *);
163 static void F_TR11 (l2_softc_t *);
164 static void F_TR12 (l2_softc_t *);
165 static void F_TR13 (l2_softc_t *);
166 static void F_TR15 (l2_softc_t *);
167 static void F_TR16 (l2_softc_t *);
168 static void F_TR17 (l2_softc_t *);
169 static void F_TR18 (l2_softc_t *);
170 static void F_TR19 (l2_softc_t *);
171 static void F_TR20 (l2_softc_t *);
172 static void F_ILL (l2_softc_t *);
173 static void F_NCNA (l2_softc_t *);
175 /*---------------------------------------------------------------------------*
176 * FSM illegal state default action
177 *---------------------------------------------------------------------------*/
179 F_ILL(l2_softc_t *l2sc)
181 NDBGL2(L2_F_ERR, "FSM function F_ILL executing");
184 /*---------------------------------------------------------------------------*
185 * FSM No change, No action
186 *---------------------------------------------------------------------------*/
188 F_NCNA(l2_softc_t *l2sc)
190 NDBGL2(L2_F_MSG, "FSM function F_NCNA executing");
193 /*---------------------------------------------------------------------------*
194 * layer 2 state transition table
195 *---------------------------------------------------------------------------*/
197 void (*func) (l2_softc_t *); /* function to execute */
198 int newstate; /* next state */
199 } l2state_tab[N_EVENTS][N_STATES] = {
201 /* STATE: ST_TEI_UNAS, ST_ASG_AW_TEI, ST_EST_AW_TEI, ST_TEI_ASGD, ST_AW_EST, ST_AW_REL, ST_MULTIFR, ST_TIMREC, ST_SUBSET, ILLEGAL STATE */
202 /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
203 /*EV_DLESTRQ*/{ {F_TU01, ST_EST_AW_TEI}, {F_NCNA, ST_EST_AW_TEI}, {F_ILL, ST_ILL}, {F_T01, ST_AW_EST}, {F_AE01, ST_AW_EST}, {F_ILL, ST_ILL}, {F_MF01, ST_AW_EST}, {F_TR01, ST_AW_EST}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
204 /*EV_DLUDTRQ*/{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
205 /*EV_MDASGRQ*/{ {F_TU03, ST_TEI_ASGD}, {F_TA03, ST_TEI_ASGD}, {F_TE03, ST_AW_EST}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
206 /*EV_MDERRRS*/{ {F_ILL, ST_ILL}, {F_TA04, ST_TEI_UNAS}, {F_TE04, ST_TEI_UNAS}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
207 /*EV_PSDEACT*/{ {F_ILL, ST_ILL}, {F_TA05, ST_TEI_UNAS}, {F_TE05, ST_TEI_UNAS}, {F_T05, ST_TEI_ASGD}, {F_AE05, ST_TEI_ASGD}, {F_AR05, ST_TEI_ASGD}, {F_MF05, ST_TEI_ASGD}, {F_TR05, ST_TEI_ASGD}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
208 /*EV_MDREMRQ*/{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_T06, ST_TEI_UNAS}, {F_AE06, ST_TEI_UNAS}, {F_AR06, ST_TEI_UNAS}, {F_MF06, ST_TEI_UNAS}, {F_TR06, ST_TEI_UNAS}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
209 /*EV_RXSABME*/{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_T07, ST_SUBSET}, {F_AE07, ST_AW_EST}, {F_AR07, ST_AW_REL}, {F_MF07, ST_MULTIFR}, {F_TR07, ST_MULTIFR}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
210 /*EV_RXDISC */{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_T08, ST_TEI_ASGD}, {F_AE08, ST_AW_EST}, {F_AR08, ST_AW_REL}, {F_MF08, ST_TEI_ASGD}, {F_TR08, ST_TEI_ASGD}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
211 /*EV_RXUA */{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_T09, ST_TEI_ASGD}, {F_AE09, ST_SUBSET}, {F_AR09, ST_SUBSET}, {F_MF09, ST_MULTIFR}, {F_TR09, ST_TIMREC}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
212 /*EV_RXDM */{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_T10, ST_SUBSET}, {F_AE10, ST_SUBSET}, {F_AR10, ST_SUBSET}, {F_MF10, ST_SUBSET}, {F_TR10, ST_AW_EST}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
213 /*EV_T200EXP*/{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_AE11, ST_SUBSET}, {F_AR11, ST_SUBSET}, {F_MF11, ST_TIMREC}, {F_TR11, ST_SUBSET}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
214 /*EV_DLDATRQ*/{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_AE12, ST_AW_EST}, {F_ILL, ST_ILL}, {F_MF12, ST_MULTIFR}, {F_TR12, ST_TIMREC}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
215 /*EV_DLRELRQ*/{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_T13, ST_TEI_ASGD}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_MF13, ST_AW_REL}, {F_TR13, ST_AW_REL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
216 /*EV_T203EXP*/{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_MF14, ST_TIMREC}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
217 /*EV_OWNBUSY*/{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_MF15, ST_MULTIFR}, {F_TR15, ST_TIMREC}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
218 /*EV_OWNRDY */{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_MF16, ST_MULTIFR}, {F_TR16, ST_TIMREC}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
219 /*EV_RXRR */{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_MF17, ST_SUBSET}, {F_TR17, ST_SUBSET}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
220 /*EV_RXREJ */{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_MF18, ST_SUBSET}, {F_TR18, ST_SUBSET}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
221 /*EV_RXRNR */{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_MF19, ST_SUBSET}, {F_TR19, ST_SUBSET}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
222 /*EV_RXFRMR */{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_MF20, ST_AW_EST}, {F_TR20, ST_AW_EST}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} },
223 /*EV_ILL */{ {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL}, {F_ILL, ST_ILL} }
226 /*---------------------------------------------------------------------------*
227 * event handler, executes function and sets new state
228 *---------------------------------------------------------------------------*/
229 void i4b_next_l2state(l2_softc_t *l2sc, int event)
231 int currstate, newstate;
232 int (*savpostfsmfunc)(int) = NULL;
234 /* check event number */
236 panic("i4b_l2fsm.c: event > N_EVENTS\n");
238 /* get current state and check it */
239 if((currstate = l2sc->Q921_state) > N_STATES) /* failsafe */
240 panic("i4b_l2fsm.c: currstate > N_STATES\n");
242 /* get new state and check it */
243 if((newstate = l2state_tab[event][currstate].newstate) > N_STATES)
244 panic("i4b_l2fsm.c: newstate > N_STATES\n");
247 if(newstate != ST_SUBSET)
248 { /* state function does NOT set new state */
249 NDBGL2(L2_F_MSG, "FSM event [%s]: [%s/%d => %s/%d]",
251 l2state_text[currstate], currstate,
252 l2state_text[newstate], newstate);
255 /* execute state transition function */
256 (*l2state_tab[event][currstate].func)(l2sc);
258 if(newstate == ST_SUBSET)
259 { /* state function DOES set new state */
260 NDBGL2(L2_F_MSG, "FSM S-event [%s]: [%s => %s]", l2event_text[event],
261 l2state_text[currstate],
262 l2state_text[l2sc->Q921_state]);
265 /* check for illegal new state */
267 if(newstate == ST_ILL)
269 newstate = currstate;
270 NDBGL2(L2_F_ERR, "FSM illegal state, state = %s, event = %s!",
271 l2state_text[currstate],
272 l2event_text[event]);
275 /* check if state machine function has to set new state */
277 if(newstate != ST_SUBSET)
278 l2sc->Q921_state = newstate; /* no, we set new state */
280 if(l2sc->postfsmfunc != NULL)
282 NDBGL2(L2_F_MSG, "FSM executing postfsmfunc!");
283 /* try to avoid an endless loop */
284 savpostfsmfunc = l2sc->postfsmfunc;
285 l2sc->postfsmfunc = NULL;
286 (*savpostfsmfunc)(l2sc->postfsmarg);
291 /*---------------------------------------------------------------------------*
292 * return pointer to current state description
293 *---------------------------------------------------------------------------*/
294 char *i4b_print_l2state(l2_softc_t *l2sc)
296 return((char *) l2state_text[l2sc->Q921_state]);
300 /*---------------------------------------------------------------------------*
301 * FSM state ST_TEI_UNAS event dl establish request
302 *---------------------------------------------------------------------------*/
304 F_TU01(l2_softc_t *l2sc)
306 NDBGL2(L2_F_MSG, "FSM function F_TU01 executing");
307 i4b_mdl_assign_ind(l2sc);
310 /*---------------------------------------------------------------------------*
311 * FSM state ST_TEI_UNAS event mdl assign request
312 *---------------------------------------------------------------------------*/
314 F_TU03(l2_softc_t *l2sc)
316 NDBGL2(L2_F_MSG, "FSM function F_TU03 executing");
319 /*---------------------------------------------------------------------------*
320 * FSM state ST_ASG_AW_TEI event mdl assign request
321 *---------------------------------------------------------------------------*/
323 F_TA03(l2_softc_t *l2sc)
325 NDBGL2(L2_F_MSG, "FSM function F_TA03 executing");
328 /*---------------------------------------------------------------------------*
329 * FSM state ST_ASG_AW_TEI event mdl error response
330 *---------------------------------------------------------------------------*/
332 F_TA04(l2_softc_t *l2sc)
334 NDBGL2(L2_F_MSG, "FSM function F_TA04 executing");
337 /*---------------------------------------------------------------------------*
338 * FSM state ST_ASG_AW_TEI event persistent deactivation
339 *---------------------------------------------------------------------------*/
341 F_TA05(l2_softc_t *l2sc)
343 NDBGL2(L2_F_MSG, "FSM function F_TA05 executing");
346 /*---------------------------------------------------------------------------*
347 * FSM state ST_EST_AW_TEI event mdl assign request
348 *---------------------------------------------------------------------------*/
350 F_TE03(l2_softc_t *l2sc)
352 NDBGL2(L2_F_MSG, "FSM function F_TE03 executing");
353 i4b_establish_data_link(l2sc);
354 l2sc->l3initiated = 1;
357 /*---------------------------------------------------------------------------*
358 * FSM state ST_EST_AW_TEI event mdl error response
359 *---------------------------------------------------------------------------*/
361 F_TE04(l2_softc_t *l2sc)
363 NDBGL2(L2_F_MSG, "FSM function F_TE04 executing");
364 l2sc->postfsmarg = l2sc->unit;
365 l2sc->postfsmfunc = DL_Rel_Ind_A;
368 /*---------------------------------------------------------------------------*
369 * FSM state ST_EST_AW_TEI event persistent deactivation
370 *---------------------------------------------------------------------------*/
372 F_TE05(l2_softc_t *l2sc)
374 NDBGL2(L2_F_MSG, "FSM function F_TE05 executing");
375 l2sc->postfsmarg = l2sc->unit;
376 l2sc->postfsmfunc = DL_Rel_Ind_A;
379 /*---------------------------------------------------------------------------*
380 * FSM state ST_TEI_ASGD event dl establish request
381 *---------------------------------------------------------------------------*/
383 F_T01(l2_softc_t *l2sc)
385 NDBGL2(L2_F_MSG, "FSM function F_T01 executing");
386 i4b_establish_data_link(l2sc);
387 l2sc->l3initiated = 1;
390 /*---------------------------------------------------------------------------*
391 * FSM state ST_TEI_ASGD event persistent deactivation
392 *---------------------------------------------------------------------------*/
394 F_T05(l2_softc_t *l2sc)
396 NDBGL2(L2_F_MSG, "FSM function F_T05 executing");
399 /*---------------------------------------------------------------------------*
400 * FSM state ST_TEI_ASGD event mdl remove request
401 *---------------------------------------------------------------------------*/
403 F_T06(l2_softc_t *l2sc)
405 NDBGL2(L2_F_MSG, "FSM function F_T06 executing");
406 /*XXX*/ i4b_mdl_assign_ind(l2sc);
409 /*---------------------------------------------------------------------------*
410 * FSM state ST_TEI_ASGD event rx'd SABME
411 *---------------------------------------------------------------------------*/
413 F_T07(l2_softc_t *l2sc)
415 NDBGL2(L2_F_MSG, "FSM function F_T07 executing");
419 if(NOT able to establish)
421 i4b_tx_dm(l2sc, l2sc->rxd_PF);
422 l2sc->Q921_state = ST_TEI_ASGD;
427 i4b_clear_exception_conditions(l2sc);
429 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
431 i4b_tx_ua(l2sc, l2sc->rxd_PF);
437 l2sc->postfsmarg = l2sc->unit;
438 l2sc->postfsmfunc = DL_Est_Ind_A;
440 i4b_T203_start(l2sc);
442 l2sc->Q921_state = ST_MULTIFR;
445 /*---------------------------------------------------------------------------*
446 * FSM state ST_TEI_ASGD event rx'd DISC
447 *---------------------------------------------------------------------------*/
449 F_T08(l2_softc_t *l2sc)
451 NDBGL2(L2_F_MSG, "FSM function F_T08 executing");
452 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
453 i4b_tx_ua(l2sc, l2sc->rxd_PF);
456 /*---------------------------------------------------------------------------*
457 * FSM state ST_TEI_ASGD event rx'd UA
458 *---------------------------------------------------------------------------*/
460 F_T09(l2_softc_t *l2sc)
462 NDBGL2(L2_F_MSG, "FSM function F_T09 executing");
463 i4b_mdl_error_ind(l2sc, "F_T09", MDL_ERR_C);
464 i4b_mdl_error_ind(l2sc, "F_T09", MDL_ERR_D);
467 /*---------------------------------------------------------------------------*
468 * FSM state ST_TEI_ASGD event rx'd DM
469 *---------------------------------------------------------------------------*/
471 F_T10(l2_softc_t *l2sc)
473 NDBGL2(L2_F_MSG, "FSM function F_T10 executing");
477 l2sc->Q921_state = ST_TEI_ASGD;
482 if(NOT able_to_etablish)
484 l2sc->Q921_state = ST_TEI_ASGD;
488 i4b_establish_data_link(l2sc);
490 l2sc->l3initiated = 1;
492 l2sc->Q921_state = ST_AW_EST;
496 /*---------------------------------------------------------------------------*
497 * FSM state ST_TEI_ASGD event dl release request
498 *---------------------------------------------------------------------------*/
500 F_T13(l2_softc_t *l2sc)
502 NDBGL2(L2_F_MSG, "FSM function F_T13 executing");
503 l2sc->postfsmarg = l2sc->unit;
504 l2sc->postfsmfunc = DL_Rel_Cnf_A;
507 /*---------------------------------------------------------------------------*
508 * FSM state ST_AW_EST event dl establish request
509 *---------------------------------------------------------------------------*/
511 F_AE01(l2_softc_t *l2sc)
513 NDBGL2(L2_F_MSG, "FSM function F_AE01 executing");
515 i4b_Dcleanifq(&l2sc->i_queue);
517 l2sc->l3initiated = 1;
520 /*---------------------------------------------------------------------------*
521 * FSM state ST_AW_EST event persistent deactivation
522 *---------------------------------------------------------------------------*/
524 F_AE05(l2_softc_t *l2sc)
526 NDBGL2(L2_F_MSG, "FSM function F_AE05 executing");
528 i4b_Dcleanifq(&l2sc->i_queue);
530 l2sc->postfsmarg = l2sc->unit;
531 l2sc->postfsmfunc = DL_Rel_Ind_A;
536 /*---------------------------------------------------------------------------*
537 * FSM state ST_AW_EST event mdl remove request
538 *---------------------------------------------------------------------------*/
540 F_AE06(l2_softc_t *l2sc)
542 NDBGL2(L2_F_MSG, "FSM function F_AE06 executing");
544 i4b_Dcleanifq(&l2sc->i_queue);
546 l2sc->postfsmarg = l2sc->unit;
547 l2sc->postfsmfunc = DL_Rel_Ind_A;
551 /*XXX*/ i4b_mdl_assign_ind(l2sc);
554 /*---------------------------------------------------------------------------*
555 * FSM state ST_AW_EST event rx'd SABME
556 *---------------------------------------------------------------------------*/
558 F_AE07(l2_softc_t *l2sc)
560 NDBGL2(L2_F_MSG, "FSM function F_AE07 executing");
561 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
562 i4b_tx_ua(l2sc, l2sc->rxd_PF);
565 /*---------------------------------------------------------------------------*
566 * FSM state ST_AW_EST event rx'd DISC
567 *---------------------------------------------------------------------------*/
569 F_AE08(l2_softc_t *l2sc)
571 NDBGL2(L2_F_MSG, "FSM function F_AE08 executing");
572 i4b_tx_dm(l2sc, l2sc->rxd_PF);
575 /*---------------------------------------------------------------------------*
576 * FSM state ST_AW_EST event rx'd UA
577 *---------------------------------------------------------------------------*/
579 F_AE09(l2_softc_t *l2sc)
581 NDBGL2(L2_F_MSG, "FSM function F_AE09 executing");
583 if(l2sc->rxd_PF == 0)
585 i4b_mdl_error_ind(l2sc, "F_AE09", MDL_ERR_D);
586 l2sc->Q921_state = ST_AW_EST;
590 if(l2sc->l3initiated)
592 l2sc->l3initiated = 0;
594 l2sc->postfsmarg = l2sc->unit;
595 l2sc->postfsmfunc = DL_Est_Cnf_A;
599 if(l2sc->vs != l2sc->va)
601 i4b_Dcleanifq(&l2sc->i_queue);
602 l2sc->postfsmarg = l2sc->unit;
603 l2sc->postfsmfunc = DL_Est_Ind_A;
607 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
610 i4b_T203_start(l2sc);
615 l2sc->Q921_state = ST_MULTIFR;
619 /*---------------------------------------------------------------------------*
620 * FSM state ST_AW_EST event rx'd DM
621 *---------------------------------------------------------------------------*/
623 F_AE10(l2_softc_t *l2sc)
625 NDBGL2(L2_F_MSG, "FSM function F_AE10 executing");
627 if(l2sc->rxd_PF == 0)
629 l2sc->Q921_state = ST_AW_EST;
633 i4b_Dcleanifq(&l2sc->i_queue);
635 l2sc->postfsmarg = l2sc->unit;
636 l2sc->postfsmfunc = DL_Rel_Ind_A;
640 l2sc->Q921_state = ST_TEI_ASGD;
644 /*---------------------------------------------------------------------------*
645 * FSM state ST_AW_EST event T200 expiry
646 *---------------------------------------------------------------------------*/
648 F_AE11(l2_softc_t *l2sc)
650 NDBGL2(L2_F_MSG, "FSM function F_AE11 executing");
654 i4b_Dcleanifq(&l2sc->i_queue);
656 i4b_mdl_error_ind(l2sc, "F_AE11", MDL_ERR_G);
658 l2sc->postfsmarg = l2sc->unit;
659 l2sc->postfsmfunc = DL_Rel_Ind_A;
661 l2sc->Q921_state = ST_TEI_ASGD;
667 i4b_tx_sabme(l2sc, P1);
669 i4b_T200_start(l2sc);
671 l2sc->Q921_state = ST_AW_EST;
675 /*---------------------------------------------------------------------------*
676 * FSM state ST_AW_EST event dl data request
677 *---------------------------------------------------------------------------*/
679 F_AE12(l2_softc_t *l2sc)
681 NDBGL2(L2_F_MSG, "FSM function F_AE12 executing");
683 if(l2sc->l3initiated == 0)
685 i4b_i_frame_queued_up(l2sc);
689 /*---------------------------------------------------------------------------*
690 * FSM state ST_AW_REL event persistent deactivation
691 *---------------------------------------------------------------------------*/
693 F_AR05(l2_softc_t *l2sc)
695 NDBGL2(L2_F_MSG, "FSM function F_AR05 executing");
697 l2sc->postfsmarg = l2sc->unit;
698 l2sc->postfsmfunc = DL_Rel_Cnf_A;
703 /*---------------------------------------------------------------------------*
704 * FSM state ST_AW_REL event mdl remove request
705 *---------------------------------------------------------------------------*/
707 F_AR06(l2_softc_t *l2sc)
709 NDBGL2(L2_F_MSG, "FSM function F_AR06 executing");
711 l2sc->postfsmarg = l2sc->unit;
712 l2sc->postfsmfunc = DL_Rel_Cnf_A;
716 /*XXX*/ i4b_mdl_assign_ind(l2sc);
719 /*---------------------------------------------------------------------------*
720 * FSM state ST_AW_REL event rx'd SABME
721 *---------------------------------------------------------------------------*/
723 F_AR07(l2_softc_t *l2sc)
725 NDBGL2(L2_F_MSG, "FSM function F_AR07 executing");
726 i4b_tx_dm(l2sc, l2sc->rxd_PF);
729 /*---------------------------------------------------------------------------*
730 * FSM state ST_AW_REL event rx'd DISC
731 *---------------------------------------------------------------------------*/
733 F_AR08(l2_softc_t *l2sc)
735 NDBGL2(L2_F_MSG, "FSM function F_AR08 executing");
736 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
737 i4b_tx_ua(l2sc, l2sc->rxd_PF);
740 /*---------------------------------------------------------------------------*
741 * FSM state ST_AW_REL event rx'd UA
742 *---------------------------------------------------------------------------*/
744 F_AR09(l2_softc_t *l2sc)
746 NDBGL2(L2_F_MSG, "FSM function F_AR09 executing");
750 l2sc->postfsmarg = l2sc->unit;
751 l2sc->postfsmfunc = DL_Rel_Cnf_A;
755 l2sc->Q921_state = ST_TEI_ASGD;
759 i4b_mdl_error_ind(l2sc, "F_AR09", MDL_ERR_D);
761 l2sc->Q921_state = ST_AW_REL;
765 /*---------------------------------------------------------------------------*
766 * FSM state ST_AW_REL event rx'd DM
767 *---------------------------------------------------------------------------*/
769 F_AR10(l2_softc_t *l2sc)
771 NDBGL2(L2_F_MSG, "FSM function F_AR10 executing");
775 l2sc->postfsmarg = l2sc->unit;
776 l2sc->postfsmfunc = DL_Rel_Cnf_A;
780 l2sc->Q921_state = ST_TEI_ASGD;
784 l2sc->Q921_state = ST_AW_REL;
788 /*---------------------------------------------------------------------------*
789 * FSM state ST_AW_REL event T200 expiry
790 *---------------------------------------------------------------------------*/
792 F_AR11(l2_softc_t *l2sc)
794 NDBGL2(L2_F_MSG, "FSM function F_AR11 executing");
798 i4b_mdl_error_ind(l2sc, "F_AR11", MDL_ERR_H);
800 l2sc->postfsmarg = l2sc->unit;
801 l2sc->postfsmfunc = DL_Rel_Cnf_A;
803 l2sc->Q921_state = ST_TEI_ASGD;
809 i4b_tx_disc(l2sc, P1);
811 i4b_T200_start(l2sc);
813 l2sc->Q921_state = ST_AW_REL;
817 /*---------------------------------------------------------------------------*
818 * FSM state ST_MULTIFR event dl establish request
819 *---------------------------------------------------------------------------*/
821 F_MF01(l2_softc_t *l2sc)
823 NDBGL2(L2_F_MSG, "FSM function F_MF01 executing");
825 i4b_Dcleanifq(&l2sc->i_queue);
827 i4b_establish_data_link(l2sc);
829 l2sc->l3initiated = 1;
832 /*---------------------------------------------------------------------------*
833 * FSM state ST_MULTIFR event persistent deactivation
834 *---------------------------------------------------------------------------*/
836 F_MF05(l2_softc_t *l2sc)
838 NDBGL2(L2_F_MSG, "FSM function F_MF05 executing");
840 i4b_Dcleanifq(&l2sc->i_queue);
842 l2sc->postfsmarg = l2sc->unit;
843 l2sc->postfsmfunc = DL_Rel_Ind_A;
849 /*---------------------------------------------------------------------------*
850 * FSM state ST_MULTIFR event mdl remove request
851 *---------------------------------------------------------------------------*/
853 F_MF06(l2_softc_t *l2sc)
855 NDBGL2(L2_F_MSG, "FSM function F_MF06 executing");
857 i4b_Dcleanifq(&l2sc->i_queue);
859 l2sc->postfsmarg = l2sc->unit;
860 l2sc->postfsmfunc = DL_Rel_Ind_A;
865 /*XXX*/ i4b_mdl_assign_ind(l2sc);
868 /*---------------------------------------------------------------------------*
869 * FSM state ST_MULTIFR event rx'd SABME
870 *---------------------------------------------------------------------------*/
872 F_MF07(l2_softc_t *l2sc)
874 NDBGL2(L2_F_MSG, "FSM function F_MF07 executing");
876 i4b_clear_exception_conditions(l2sc);
878 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
880 i4b_tx_ua(l2sc, l2sc->rxd_PF);
882 i4b_mdl_error_ind(l2sc, "F_MF07", MDL_ERR_F);
884 if(l2sc->vs != l2sc->va)
886 i4b_Dcleanifq(&l2sc->i_queue);
888 l2sc->postfsmarg = l2sc->unit;
889 l2sc->postfsmfunc = DL_Est_Ind_A;
893 i4b_T203_start(l2sc);
900 /*---------------------------------------------------------------------------*
901 * FSM state ST_MULTIFR event rx'd DISC
902 *---------------------------------------------------------------------------*/
904 F_MF08(l2_softc_t *l2sc)
906 NDBGL2(L2_F_MSG, "FSM function F_MF08 executing");
908 i4b_Dcleanifq(&l2sc->i_queue);
909 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
910 i4b_tx_ua(l2sc, l2sc->rxd_PF);
912 l2sc->postfsmarg = l2sc->unit;
913 l2sc->postfsmfunc = DL_Rel_Ind_A;
919 /*---------------------------------------------------------------------------*
920 * FSM state ST_MULTIFR event rx'd UA
921 *---------------------------------------------------------------------------*/
923 F_MF09(l2_softc_t *l2sc)
925 NDBGL2(L2_F_MSG, "FSM function F_MF09 executing");
927 i4b_mdl_error_ind(l2sc, "F_MF09", MDL_ERR_C);
929 i4b_mdl_error_ind(l2sc, "F_MF09", MDL_ERR_D);
932 /*---------------------------------------------------------------------------*
933 * FSM state ST_MULTIFR event rx'd DM
934 *---------------------------------------------------------------------------*/
936 F_MF10(l2_softc_t *l2sc)
938 NDBGL2(L2_F_MSG, "FSM function F_MF10 executing");
942 i4b_mdl_error_ind(l2sc, "F_MF10", MDL_ERR_B);
944 l2sc->Q921_state = ST_MULTIFR;
948 i4b_mdl_error_ind(l2sc, "F_MF10", MDL_ERR_E);
950 i4b_establish_data_link(l2sc);
952 l2sc->l3initiated = 0;
954 l2sc->Q921_state = ST_AW_EST;
958 /*---------------------------------------------------------------------------*
959 * FSM state ST_MULTIFR event T200 expiry
960 *---------------------------------------------------------------------------*/
962 F_MF11(l2_softc_t *l2sc)
964 NDBGL2(L2_F_MSG, "FSM function F_MF11 executing");
968 i4b_transmit_enquire(l2sc);
973 /*---------------------------------------------------------------------------*
974 * FSM state ST_MULTIFR event dl data request
975 *---------------------------------------------------------------------------*/
977 F_MF12(l2_softc_t *l2sc)
979 NDBGL2(L2_F_MSG, "FSM function F_MF12 executing");
981 i4b_i_frame_queued_up(l2sc);
984 /*---------------------------------------------------------------------------*
985 * FSM state ST_MULTIFR event dl release request
986 *---------------------------------------------------------------------------*/
988 F_MF13(l2_softc_t *l2sc)
990 NDBGL2(L2_F_MSG, "FSM function F_MF13 executing");
992 i4b_Dcleanifq(&l2sc->i_queue);
996 i4b_tx_disc(l2sc, P1);
999 i4b_T200_restart(l2sc);
1002 /*---------------------------------------------------------------------------*
1003 * FSM state ST_MULTIFR event T203 expiry
1004 *---------------------------------------------------------------------------*/
1006 F_MF14(l2_softc_t *l2sc)
1008 NDBGL2(L2_F_MSG, "FSM function F_MF14 executing");
1010 i4b_transmit_enquire(l2sc);
1015 /*---------------------------------------------------------------------------*
1016 * FSM state ST_MULTIFR event set own rx busy
1017 *---------------------------------------------------------------------------*/
1019 F_MF15(l2_softc_t *l2sc)
1021 NDBGL2(L2_F_MSG, "FSM function F_MF15 executing");
1023 if(l2sc->own_busy == 0)
1027 i4b_tx_rnr_response(l2sc, F0); /* wrong in Q.921 03/93 p 64 */
1033 /*---------------------------------------------------------------------------*
1034 * FSM state ST_MULTIFR event clear own rx busy
1035 *---------------------------------------------------------------------------*/
1037 F_MF16(l2_softc_t *l2sc)
1039 NDBGL2(L2_F_MSG, "FSM function F_MF16 executing");
1041 if(l2sc->own_busy != 0)
1045 i4b_tx_rr_response(l2sc, F0); /* wrong in Q.921 03/93 p 64 */
1051 /*---------------------------------------------------------------------------*
1052 * FSM state ST_MULTIFR event rx'd RR
1053 *---------------------------------------------------------------------------*/
1055 F_MF17(l2_softc_t *l2sc)
1057 NDBGL2(L2_F_MSG, "FSM function F_MF17 executing");
1059 l2sc->peer_busy = 0;
1061 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1063 if(l2sc->rxd_PF == 1)
1065 i4b_enquiry_response(l2sc);
1070 if(l2sc->rxd_PF == 1)
1072 i4b_mdl_error_ind(l2sc, "F_MF17", MDL_ERR_A);
1076 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1078 if(l2sc->rxd_NR == l2sc->vs)
1080 l2sc->va = l2sc->rxd_NR;
1081 i4b_T200_stop(l2sc);
1082 i4b_T203_restart(l2sc);
1084 else if(l2sc->rxd_NR != l2sc->va)
1086 l2sc->va = l2sc->rxd_NR;
1087 i4b_T200_restart(l2sc);
1089 l2sc->Q921_state = ST_MULTIFR;
1093 i4b_nr_error_recovery(l2sc);
1094 l2sc->Q921_state = ST_AW_EST;
1098 /*---------------------------------------------------------------------------*
1099 * FSM state ST_MULTIFR event rx'd REJ
1100 *---------------------------------------------------------------------------*/
1102 F_MF18(l2_softc_t *l2sc)
1104 NDBGL2(L2_F_MSG, "FSM function F_MF18 executing");
1106 l2sc->peer_busy = 0;
1108 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1110 if(l2sc->rxd_PF == 1)
1112 i4b_enquiry_response(l2sc);
1117 if(l2sc->rxd_PF == 1)
1119 i4b_mdl_error_ind(l2sc, "F_MF18", MDL_ERR_A);
1123 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1125 l2sc->va = l2sc->rxd_NR;
1126 i4b_T200_stop(l2sc);
1127 i4b_T203_start(l2sc);
1128 i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
1129 l2sc->Q921_state = ST_MULTIFR;
1133 i4b_nr_error_recovery(l2sc);
1134 l2sc->Q921_state = ST_AW_EST;
1138 /*---------------------------------------------------------------------------*
1139 * FSM state ST_MULTIFR event rx'd RNR
1140 *---------------------------------------------------------------------------*/
1142 F_MF19(l2_softc_t *l2sc)
1144 NDBGL2(L2_F_MSG, "FSM function F_MF19 executing");
1146 l2sc->peer_busy = 1;
1148 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1150 if(l2sc->rxd_PF == 1)
1152 i4b_enquiry_response(l2sc);
1157 if(l2sc->rxd_PF == 1)
1159 i4b_mdl_error_ind(l2sc, "F_MF19", MDL_ERR_A);
1163 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1165 l2sc->va = l2sc->rxd_NR;
1166 i4b_T203_stop(l2sc);
1167 i4b_T200_restart(l2sc);
1168 l2sc->Q921_state = ST_MULTIFR;
1172 i4b_nr_error_recovery(l2sc);
1173 l2sc->Q921_state = ST_AW_EST;
1177 /*---------------------------------------------------------------------------*
1178 * FSM state ST_MULTIFR event rx'd FRMR
1179 *---------------------------------------------------------------------------*/
1181 F_MF20(l2_softc_t *l2sc)
1183 NDBGL2(L2_F_MSG, "FSM function F_MF20 executing");
1185 i4b_mdl_error_ind(l2sc, "F_MF20", MDL_ERR_K);
1187 i4b_establish_data_link(l2sc);
1189 l2sc->l3initiated = 0;
1192 /*---------------------------------------------------------------------------*
1193 * FSM state ST_TIMREC event dl establish request
1194 *---------------------------------------------------------------------------*/
1196 F_TR01(l2_softc_t *l2sc)
1198 NDBGL2(L2_F_MSG, "FSM function F_TR01 executing");
1200 i4b_Dcleanifq(&l2sc->i_queue);
1202 i4b_establish_data_link(l2sc);
1204 l2sc->l3initiated = 1;
1207 /*---------------------------------------------------------------------------*
1208 * FSM state ST_TIMREC event persistent deactivation
1209 *---------------------------------------------------------------------------*/
1211 F_TR05(l2_softc_t *l2sc)
1213 NDBGL2(L2_F_MSG, "FSM function F_TR05 executing");
1215 i4b_Dcleanifq(&l2sc->i_queue);
1217 l2sc->postfsmarg = l2sc->unit;
1218 l2sc->postfsmfunc = DL_Rel_Ind_A;
1220 i4b_T200_stop(l2sc);
1223 /*---------------------------------------------------------------------------*
1224 * FSM state ST_TIMREC event mdl remove request
1225 *---------------------------------------------------------------------------*/
1227 F_TR06(l2_softc_t *l2sc)
1229 NDBGL2(L2_F_MSG, "FSM function F_TR06 executing");
1231 i4b_Dcleanifq(&l2sc->i_queue);
1233 l2sc->postfsmarg = l2sc->unit;
1234 l2sc->postfsmfunc = DL_Rel_Ind_A;
1236 i4b_T200_stop(l2sc);
1238 /*XXX*/ i4b_mdl_assign_ind(l2sc);
1241 /*---------------------------------------------------------------------------*
1242 * FSM state ST_TIMREC event rx'd SABME
1243 *---------------------------------------------------------------------------*/
1245 F_TR07(l2_softc_t *l2sc)
1247 NDBGL2(L2_F_MSG, "FSM function F_TR07 executing");
1249 i4b_clear_exception_conditions(l2sc);
1251 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
1253 i4b_tx_ua(l2sc, l2sc->rxd_PF);
1255 i4b_mdl_error_ind(l2sc, "F_TR07", MDL_ERR_F);
1257 if(l2sc->vs != l2sc->va)
1259 i4b_Dcleanifq(&l2sc->i_queue);
1261 l2sc->postfsmarg = l2sc->unit;
1262 l2sc->postfsmfunc = DL_Est_Ind_A;
1265 i4b_T200_stop(l2sc);
1266 i4b_T203_start(l2sc);
1273 /*---------------------------------------------------------------------------*
1274 * FSM state ST_TIMREC event rx'd DISC
1275 *---------------------------------------------------------------------------*/
1277 F_TR08(l2_softc_t *l2sc)
1279 NDBGL2(L2_F_MSG, "FSM function F_TR08 executing");
1281 i4b_Dcleanifq(&l2sc->i_queue);
1282 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
1283 i4b_tx_ua(l2sc, l2sc->rxd_PF);
1285 l2sc->postfsmarg = l2sc->unit;
1286 l2sc->postfsmfunc = DL_Rel_Ind_A;
1288 i4b_T200_stop(l2sc);
1291 /*---------------------------------------------------------------------------*
1292 * FSM state ST_TIMREC event rx'd UA
1293 *---------------------------------------------------------------------------*/
1295 F_TR09(l2_softc_t *l2sc)
1297 NDBGL2(L2_F_MSG, "FSM function F_TR09 executing");
1299 i4b_mdl_error_ind(l2sc, "F_TR09", MDL_ERR_C);
1301 i4b_mdl_error_ind(l2sc, "F_TR09", MDL_ERR_D);
1304 /*---------------------------------------------------------------------------*
1305 * FSM state ST_TIMREC event rx'd DM
1306 *---------------------------------------------------------------------------*/
1308 F_TR10(l2_softc_t *l2sc)
1310 NDBGL2(L2_F_MSG, "FSM function F_TR10 executing");
1314 i4b_mdl_error_ind(l2sc, "F_TR10", MDL_ERR_B);
1318 i4b_mdl_error_ind(l2sc, "F_TR10", MDL_ERR_E);
1321 i4b_establish_data_link(l2sc);
1323 l2sc->l3initiated = 0;
1326 /*---------------------------------------------------------------------------*
1327 * FSM state ST_TIMREC event T200 expiry
1328 *---------------------------------------------------------------------------*/
1330 F_TR11(l2_softc_t *l2sc)
1332 NDBGL2(L2_F_MSG, "FSM function F_TR11 executing");
1334 if(l2sc->RC >= N200)
1336 i4b_mdl_error_ind(l2sc, "F_TR11", MDL_ERR_I);
1338 i4b_establish_data_link(l2sc);
1340 l2sc->l3initiated = 0;
1342 l2sc->Q921_state = ST_AW_EST;
1346 i4b_transmit_enquire(l2sc);
1350 l2sc->Q921_state = ST_TIMREC;
1354 /*---------------------------------------------------------------------------*
1355 * FSM state ST_TIMREC event dl data request
1356 *---------------------------------------------------------------------------*/
1358 F_TR12(l2_softc_t *l2sc)
1360 NDBGL2(L2_F_MSG, "FSM function F_TR12 executing");
1362 i4b_i_frame_queued_up(l2sc);
1365 /*---------------------------------------------------------------------------*
1366 * FSM state ST_TIMREC event dl release request
1367 *---------------------------------------------------------------------------*/
1369 F_TR13(l2_softc_t *l2sc)
1371 NDBGL2(L2_F_MSG, "FSM function F_TR13 executing");
1373 i4b_Dcleanifq(&l2sc->i_queue);
1377 i4b_tx_disc(l2sc, P1);
1379 i4b_T200_restart(l2sc);
1382 /*---------------------------------------------------------------------------*
1383 * FSM state ST_TIMREC event set own rx busy
1384 *---------------------------------------------------------------------------*/
1386 F_TR15(l2_softc_t *l2sc)
1388 NDBGL2(L2_F_MSG, "FSM function F_TR15 executing");
1390 if(l2sc->own_busy == 0)
1394 i4b_tx_rnr_response(l2sc, F0);
1400 /*---------------------------------------------------------------------------*
1401 * FSM state ST_TIMREC event clear own rx busy
1402 *---------------------------------------------------------------------------*/
1404 F_TR16(l2_softc_t *l2sc)
1406 NDBGL2(L2_F_MSG, "FSM function F_TR16 executing");
1408 if(l2sc->own_busy != 0)
1412 i4b_tx_rr_response(l2sc, F0); /* this is wrong */
1413 /* in Q.921 03/93 p 74 ! */
1418 /*---------------------------------------------------------------------------*
1419 * FSM state ST_TIMREC event rx'd RR
1420 *---------------------------------------------------------------------------*/
1422 F_TR17(l2_softc_t *l2sc)
1424 NDBGL2(L2_F_MSG, "FSM function F_TR17 executing");
1426 l2sc->peer_busy = 0;
1428 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1430 if(l2sc->rxd_PF == 1)
1432 i4b_enquiry_response(l2sc);
1437 if(l2sc->rxd_PF == 1)
1439 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1441 l2sc->va = l2sc->rxd_NR;
1442 i4b_T200_stop(l2sc);
1443 i4b_T203_start(l2sc);
1444 i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
1445 l2sc->Q921_state = ST_MULTIFR;
1450 i4b_nr_error_recovery(l2sc);
1451 l2sc->Q921_state = ST_AW_EST;
1457 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1459 l2sc->va = l2sc->rxd_NR;
1460 l2sc->Q921_state = ST_TIMREC;
1464 i4b_nr_error_recovery(l2sc);
1465 l2sc->Q921_state = ST_AW_EST;
1469 /*---------------------------------------------------------------------------*
1470 * FSM state ST_TIMREC event
1471 *---------------------------------------------------------------------------*/
1473 F_TR18(l2_softc_t *l2sc)
1475 NDBGL2(L2_F_MSG, "FSM function F_TR18 executing");
1477 l2sc->peer_busy = 0;
1479 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1481 if(l2sc->rxd_PF == 1)
1483 i4b_enquiry_response(l2sc);
1488 if(l2sc->rxd_PF == 1)
1490 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1492 l2sc->va = l2sc->rxd_NR;
1493 i4b_T200_stop(l2sc);
1494 i4b_T203_start(l2sc);
1495 i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
1496 l2sc->Q921_state = ST_MULTIFR;
1501 i4b_nr_error_recovery(l2sc);
1502 l2sc->Q921_state = ST_AW_EST;
1508 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1510 l2sc->va = l2sc->rxd_NR;
1511 l2sc->Q921_state = ST_TIMREC;
1515 i4b_nr_error_recovery(l2sc);
1516 l2sc->Q921_state = ST_AW_EST;
1520 /*---------------------------------------------------------------------------*
1521 * FSM state ST_TIMREC event rx'd RNR
1522 *---------------------------------------------------------------------------*/
1524 F_TR19(l2_softc_t *l2sc)
1526 NDBGL2(L2_F_MSG, "FSM function F_TR19 executing");
1528 l2sc->peer_busy = 0;
1530 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1532 if(l2sc->rxd_PF == 1)
1534 i4b_enquiry_response(l2sc);
1539 if(l2sc->rxd_PF == 1)
1541 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1543 l2sc->va = l2sc->rxd_NR;
1544 i4b_T200_restart(l2sc);
1545 i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
1546 l2sc->Q921_state = ST_MULTIFR;
1551 i4b_nr_error_recovery(l2sc);
1552 l2sc->Q921_state = ST_AW_EST;
1558 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1560 l2sc->va = l2sc->rxd_NR;
1561 l2sc->Q921_state = ST_TIMREC;
1565 i4b_nr_error_recovery(l2sc);
1566 l2sc->Q921_state = ST_AW_EST;
1570 /*---------------------------------------------------------------------------*
1571 * FSM state ST_TIMREC event rx'd FRMR
1572 *---------------------------------------------------------------------------*/
1574 F_TR20(l2_softc_t *l2sc)
1576 NDBGL2(L2_F_MSG, "FSM function F_TR20 executing");
1578 i4b_mdl_error_ind(l2sc, "F_TR20", MDL_ERR_K);
1580 i4b_establish_data_link(l2sc);
1582 l2sc->l3initiated = 0;
1585 #endif /* NI4BQ921 > 0 */