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.3 2003/08/07 21:17:29 dillon Exp $
35 * last edit-date: [Tue May 30 15:48:20 2000]
37 *---------------------------------------------------------------------------*/
40 #include "use_i4bq921.h"
46 #include <sys/param.h>
47 #include <sys/systm.h>
48 #include <sys/socket.h>
51 #if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
52 #include <sys/callout.h>
56 #include <net/i4b/include/machine/i4b_debug.h>
57 #include <net/i4b/include/machine/i4b_ioctl.h>
59 #include <i4b/i4b_debug.h>
60 #include <i4b/i4b_ioctl.h>
63 #include "../include/i4b_global.h"
64 #include "../include/i4b_l2l3.h"
65 #include "../include/i4b_mbuf.h"
68 #include "i4b_l2fsm.h"
70 l2_softc_t l2_softc[MAXL1UNITS];
73 static char *l2state_text[N_STATES] = {
88 static char *l2event_text[N_EVENTS] = {
113 static void F_TU01 __P((l2_softc_t *));
114 static void F_TU03 __P((l2_softc_t *));
116 static void F_TA03 __P((l2_softc_t *));
117 static void F_TA04 __P((l2_softc_t *));
118 static void F_TA05 __P((l2_softc_t *));
120 static void F_TE03 __P((l2_softc_t *));
121 static void F_TE04 __P((l2_softc_t *));
122 static void F_TE05 __P((l2_softc_t *));
124 static void F_T01 __P((l2_softc_t *));
125 static void F_T05 __P((l2_softc_t *));
126 static void F_T06 __P((l2_softc_t *));
127 static void F_T07 __P((l2_softc_t *));
128 static void F_T08 __P((l2_softc_t *));
129 static void F_T09 __P((l2_softc_t *));
130 static void F_T10 __P((l2_softc_t *));
131 static void F_T13 __P((l2_softc_t *));
133 static void F_AE01 __P((l2_softc_t *));
134 static void F_AE05 __P((l2_softc_t *));
135 static void F_AE06 __P((l2_softc_t *));
136 static void F_AE07 __P((l2_softc_t *));
137 static void F_AE08 __P((l2_softc_t *));
138 static void F_AE09 __P((l2_softc_t *));
139 static void F_AE10 __P((l2_softc_t *));
140 static void F_AE11 __P((l2_softc_t *));
141 static void F_AE12 __P((l2_softc_t *));
143 static void F_AR05 __P((l2_softc_t *));
144 static void F_AR06 __P((l2_softc_t *));
145 static void F_AR07 __P((l2_softc_t *));
146 static void F_AR08 __P((l2_softc_t *));
147 static void F_AR09 __P((l2_softc_t *));
148 static void F_AR10 __P((l2_softc_t *));
149 static void F_AR11 __P((l2_softc_t *));
151 static void F_MF01 __P((l2_softc_t *));
152 static void F_MF05 __P((l2_softc_t *));
153 static void F_MF06 __P((l2_softc_t *));
154 static void F_MF07 __P((l2_softc_t *));
155 static void F_MF08 __P((l2_softc_t *));
156 static void F_MF09 __P((l2_softc_t *));
157 static void F_MF10 __P((l2_softc_t *));
158 static void F_MF11 __P((l2_softc_t *));
159 static void F_MF12 __P((l2_softc_t *));
160 static void F_MF13 __P((l2_softc_t *));
161 static void F_MF14 __P((l2_softc_t *));
162 static void F_MF15 __P((l2_softc_t *));
163 static void F_MF16 __P((l2_softc_t *));
164 static void F_MF17 __P((l2_softc_t *));
165 static void F_MF18 __P((l2_softc_t *));
166 static void F_MF19 __P((l2_softc_t *));
167 static void F_MF20 __P((l2_softc_t *));
169 static void F_TR01 __P((l2_softc_t *));
170 static void F_TR05 __P((l2_softc_t *));
171 static void F_TR06 __P((l2_softc_t *));
172 static void F_TR07 __P((l2_softc_t *));
173 static void F_TR08 __P((l2_softc_t *));
174 static void F_TR09 __P((l2_softc_t *));
175 static void F_TR10 __P((l2_softc_t *));
176 static void F_TR11 __P((l2_softc_t *));
177 static void F_TR12 __P((l2_softc_t *));
178 static void F_TR13 __P((l2_softc_t *));
179 static void F_TR15 __P((l2_softc_t *));
180 static void F_TR16 __P((l2_softc_t *));
181 static void F_TR17 __P((l2_softc_t *));
182 static void F_TR18 __P((l2_softc_t *));
183 static void F_TR19 __P((l2_softc_t *));
184 static void F_TR20 __P((l2_softc_t *));
185 static void F_ILL __P((l2_softc_t *));
186 static void F_NCNA __P((l2_softc_t *));
188 /*---------------------------------------------------------------------------*
189 * FSM illegal state default action
190 *---------------------------------------------------------------------------*/
192 F_ILL(l2_softc_t *l2sc)
194 NDBGL2(L2_F_ERR, "FSM function F_ILL executing");
197 /*---------------------------------------------------------------------------*
198 * FSM No change, No action
199 *---------------------------------------------------------------------------*/
201 F_NCNA(l2_softc_t *l2sc)
203 NDBGL2(L2_F_MSG, "FSM function F_NCNA executing");
206 /*---------------------------------------------------------------------------*
207 * layer 2 state transition table
208 *---------------------------------------------------------------------------*/
210 void (*func) __P((l2_softc_t *)); /* function to execute */
211 int newstate; /* next state */
212 } l2state_tab[N_EVENTS][N_STATES] = {
214 /* 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 */
215 /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
216 /*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} },
217 /*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} },
218 /*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} },
219 /*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} },
220 /*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} },
221 /*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} },
222 /*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} },
223 /*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} },
224 /*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} },
225 /*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} },
226 /*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} },
227 /*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} },
228 /*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} },
229 /*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} },
230 /*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} },
231 /*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} },
232 /*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} },
233 /*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} },
234 /*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} },
235 /*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} },
236 /*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} }
239 /*---------------------------------------------------------------------------*
240 * event handler, executes function and sets new state
241 *---------------------------------------------------------------------------*/
242 void i4b_next_l2state(l2_softc_t *l2sc, int event)
244 int currstate, newstate;
245 int (*savpostfsmfunc)(int) = NULL;
247 /* check event number */
249 panic("i4b_l2fsm.c: event > N_EVENTS\n");
251 /* get current state and check it */
252 if((currstate = l2sc->Q921_state) > N_STATES) /* failsafe */
253 panic("i4b_l2fsm.c: currstate > N_STATES\n");
255 /* get new state and check it */
256 if((newstate = l2state_tab[event][currstate].newstate) > N_STATES)
257 panic("i4b_l2fsm.c: newstate > N_STATES\n");
260 if(newstate != ST_SUBSET)
261 { /* state function does NOT set new state */
262 NDBGL2(L2_F_MSG, "FSM event [%s]: [%s/%d => %s/%d]",
264 l2state_text[currstate], currstate,
265 l2state_text[newstate], newstate);
268 /* execute state transition function */
269 (*l2state_tab[event][currstate].func)(l2sc);
271 if(newstate == ST_SUBSET)
272 { /* state function DOES set new state */
273 NDBGL2(L2_F_MSG, "FSM S-event [%s]: [%s => %s]", l2event_text[event],
274 l2state_text[currstate],
275 l2state_text[l2sc->Q921_state]);
278 /* check for illegal new state */
280 if(newstate == ST_ILL)
282 newstate = currstate;
283 NDBGL2(L2_F_ERR, "FSM illegal state, state = %s, event = %s!",
284 l2state_text[currstate],
285 l2event_text[event]);
288 /* check if state machine function has to set new state */
290 if(newstate != ST_SUBSET)
291 l2sc->Q921_state = newstate; /* no, we set new state */
293 if(l2sc->postfsmfunc != NULL)
295 NDBGL2(L2_F_MSG, "FSM executing postfsmfunc!");
296 /* try to avoid an endless loop */
297 savpostfsmfunc = l2sc->postfsmfunc;
298 l2sc->postfsmfunc = NULL;
299 (*savpostfsmfunc)(l2sc->postfsmarg);
304 /*---------------------------------------------------------------------------*
305 * return pointer to current state description
306 *---------------------------------------------------------------------------*/
307 char *i4b_print_l2state(l2_softc_t *l2sc)
309 return((char *) l2state_text[l2sc->Q921_state]);
313 /*---------------------------------------------------------------------------*
314 * FSM state ST_TEI_UNAS event dl establish request
315 *---------------------------------------------------------------------------*/
317 F_TU01(l2_softc_t *l2sc)
319 NDBGL2(L2_F_MSG, "FSM function F_TU01 executing");
320 i4b_mdl_assign_ind(l2sc);
323 /*---------------------------------------------------------------------------*
324 * FSM state ST_TEI_UNAS event mdl assign request
325 *---------------------------------------------------------------------------*/
327 F_TU03(l2_softc_t *l2sc)
329 NDBGL2(L2_F_MSG, "FSM function F_TU03 executing");
332 /*---------------------------------------------------------------------------*
333 * FSM state ST_ASG_AW_TEI event mdl assign request
334 *---------------------------------------------------------------------------*/
336 F_TA03(l2_softc_t *l2sc)
338 NDBGL2(L2_F_MSG, "FSM function F_TA03 executing");
341 /*---------------------------------------------------------------------------*
342 * FSM state ST_ASG_AW_TEI event mdl error response
343 *---------------------------------------------------------------------------*/
345 F_TA04(l2_softc_t *l2sc)
347 NDBGL2(L2_F_MSG, "FSM function F_TA04 executing");
350 /*---------------------------------------------------------------------------*
351 * FSM state ST_ASG_AW_TEI event persistent deactivation
352 *---------------------------------------------------------------------------*/
354 F_TA05(l2_softc_t *l2sc)
356 NDBGL2(L2_F_MSG, "FSM function F_TA05 executing");
359 /*---------------------------------------------------------------------------*
360 * FSM state ST_EST_AW_TEI event mdl assign request
361 *---------------------------------------------------------------------------*/
363 F_TE03(l2_softc_t *l2sc)
365 NDBGL2(L2_F_MSG, "FSM function F_TE03 executing");
366 i4b_establish_data_link(l2sc);
367 l2sc->l3initiated = 1;
370 /*---------------------------------------------------------------------------*
371 * FSM state ST_EST_AW_TEI event mdl error response
372 *---------------------------------------------------------------------------*/
374 F_TE04(l2_softc_t *l2sc)
376 NDBGL2(L2_F_MSG, "FSM function F_TE04 executing");
377 l2sc->postfsmarg = l2sc->unit;
378 l2sc->postfsmfunc = DL_Rel_Ind_A;
381 /*---------------------------------------------------------------------------*
382 * FSM state ST_EST_AW_TEI event persistent deactivation
383 *---------------------------------------------------------------------------*/
385 F_TE05(l2_softc_t *l2sc)
387 NDBGL2(L2_F_MSG, "FSM function F_TE05 executing");
388 l2sc->postfsmarg = l2sc->unit;
389 l2sc->postfsmfunc = DL_Rel_Ind_A;
392 /*---------------------------------------------------------------------------*
393 * FSM state ST_TEI_ASGD event dl establish request
394 *---------------------------------------------------------------------------*/
396 F_T01(l2_softc_t *l2sc)
398 NDBGL2(L2_F_MSG, "FSM function F_T01 executing");
399 i4b_establish_data_link(l2sc);
400 l2sc->l3initiated = 1;
403 /*---------------------------------------------------------------------------*
404 * FSM state ST_TEI_ASGD event persistent deactivation
405 *---------------------------------------------------------------------------*/
407 F_T05(l2_softc_t *l2sc)
409 NDBGL2(L2_F_MSG, "FSM function F_T05 executing");
412 /*---------------------------------------------------------------------------*
413 * FSM state ST_TEI_ASGD event mdl remove request
414 *---------------------------------------------------------------------------*/
416 F_T06(l2_softc_t *l2sc)
418 NDBGL2(L2_F_MSG, "FSM function F_T06 executing");
419 /*XXX*/ i4b_mdl_assign_ind(l2sc);
422 /*---------------------------------------------------------------------------*
423 * FSM state ST_TEI_ASGD event rx'd SABME
424 *---------------------------------------------------------------------------*/
426 F_T07(l2_softc_t *l2sc)
428 NDBGL2(L2_F_MSG, "FSM function F_T07 executing");
432 if(NOT able to establish)
434 i4b_tx_dm(l2sc, l2sc->rxd_PF);
435 l2sc->Q921_state = ST_TEI_ASGD;
440 i4b_clear_exception_conditions(l2sc);
442 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
444 i4b_tx_ua(l2sc, l2sc->rxd_PF);
450 l2sc->postfsmarg = l2sc->unit;
451 l2sc->postfsmfunc = DL_Est_Ind_A;
453 i4b_T203_start(l2sc);
455 l2sc->Q921_state = ST_MULTIFR;
458 /*---------------------------------------------------------------------------*
459 * FSM state ST_TEI_ASGD event rx'd DISC
460 *---------------------------------------------------------------------------*/
462 F_T08(l2_softc_t *l2sc)
464 NDBGL2(L2_F_MSG, "FSM function F_T08 executing");
465 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
466 i4b_tx_ua(l2sc, l2sc->rxd_PF);
469 /*---------------------------------------------------------------------------*
470 * FSM state ST_TEI_ASGD event rx'd UA
471 *---------------------------------------------------------------------------*/
473 F_T09(l2_softc_t *l2sc)
475 NDBGL2(L2_F_MSG, "FSM function F_T09 executing");
476 i4b_mdl_error_ind(l2sc, "F_T09", MDL_ERR_C);
477 i4b_mdl_error_ind(l2sc, "F_T09", MDL_ERR_D);
480 /*---------------------------------------------------------------------------*
481 * FSM state ST_TEI_ASGD event rx'd DM
482 *---------------------------------------------------------------------------*/
484 F_T10(l2_softc_t *l2sc)
486 NDBGL2(L2_F_MSG, "FSM function F_T10 executing");
490 l2sc->Q921_state = ST_TEI_ASGD;
495 if(NOT able_to_etablish)
497 l2sc->Q921_state = ST_TEI_ASGD;
501 i4b_establish_data_link(l2sc);
503 l2sc->l3initiated = 1;
505 l2sc->Q921_state = ST_AW_EST;
509 /*---------------------------------------------------------------------------*
510 * FSM state ST_TEI_ASGD event dl release request
511 *---------------------------------------------------------------------------*/
513 F_T13(l2_softc_t *l2sc)
515 NDBGL2(L2_F_MSG, "FSM function F_T13 executing");
516 l2sc->postfsmarg = l2sc->unit;
517 l2sc->postfsmfunc = DL_Rel_Cnf_A;
520 /*---------------------------------------------------------------------------*
521 * FSM state ST_AW_EST event dl establish request
522 *---------------------------------------------------------------------------*/
524 F_AE01(l2_softc_t *l2sc)
526 NDBGL2(L2_F_MSG, "FSM function F_AE01 executing");
528 i4b_Dcleanifq(&l2sc->i_queue);
530 l2sc->l3initiated = 1;
533 /*---------------------------------------------------------------------------*
534 * FSM state ST_AW_EST event persistent deactivation
535 *---------------------------------------------------------------------------*/
537 F_AE05(l2_softc_t *l2sc)
539 NDBGL2(L2_F_MSG, "FSM function F_AE05 executing");
541 i4b_Dcleanifq(&l2sc->i_queue);
543 l2sc->postfsmarg = l2sc->unit;
544 l2sc->postfsmfunc = DL_Rel_Ind_A;
549 /*---------------------------------------------------------------------------*
550 * FSM state ST_AW_EST event mdl remove request
551 *---------------------------------------------------------------------------*/
553 F_AE06(l2_softc_t *l2sc)
555 NDBGL2(L2_F_MSG, "FSM function F_AE06 executing");
557 i4b_Dcleanifq(&l2sc->i_queue);
559 l2sc->postfsmarg = l2sc->unit;
560 l2sc->postfsmfunc = DL_Rel_Ind_A;
564 /*XXX*/ i4b_mdl_assign_ind(l2sc);
567 /*---------------------------------------------------------------------------*
568 * FSM state ST_AW_EST event rx'd SABME
569 *---------------------------------------------------------------------------*/
571 F_AE07(l2_softc_t *l2sc)
573 NDBGL2(L2_F_MSG, "FSM function F_AE07 executing");
574 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
575 i4b_tx_ua(l2sc, l2sc->rxd_PF);
578 /*---------------------------------------------------------------------------*
579 * FSM state ST_AW_EST event rx'd DISC
580 *---------------------------------------------------------------------------*/
582 F_AE08(l2_softc_t *l2sc)
584 NDBGL2(L2_F_MSG, "FSM function F_AE08 executing");
585 i4b_tx_dm(l2sc, l2sc->rxd_PF);
588 /*---------------------------------------------------------------------------*
589 * FSM state ST_AW_EST event rx'd UA
590 *---------------------------------------------------------------------------*/
592 F_AE09(l2_softc_t *l2sc)
594 NDBGL2(L2_F_MSG, "FSM function F_AE09 executing");
596 if(l2sc->rxd_PF == 0)
598 i4b_mdl_error_ind(l2sc, "F_AE09", MDL_ERR_D);
599 l2sc->Q921_state = ST_AW_EST;
603 if(l2sc->l3initiated)
605 l2sc->l3initiated = 0;
607 l2sc->postfsmarg = l2sc->unit;
608 l2sc->postfsmfunc = DL_Est_Cnf_A;
612 if(l2sc->vs != l2sc->va)
614 i4b_Dcleanifq(&l2sc->i_queue);
615 l2sc->postfsmarg = l2sc->unit;
616 l2sc->postfsmfunc = DL_Est_Ind_A;
620 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
623 i4b_T203_start(l2sc);
628 l2sc->Q921_state = ST_MULTIFR;
632 /*---------------------------------------------------------------------------*
633 * FSM state ST_AW_EST event rx'd DM
634 *---------------------------------------------------------------------------*/
636 F_AE10(l2_softc_t *l2sc)
638 NDBGL2(L2_F_MSG, "FSM function F_AE10 executing");
640 if(l2sc->rxd_PF == 0)
642 l2sc->Q921_state = ST_AW_EST;
646 i4b_Dcleanifq(&l2sc->i_queue);
648 l2sc->postfsmarg = l2sc->unit;
649 l2sc->postfsmfunc = DL_Rel_Ind_A;
653 l2sc->Q921_state = ST_TEI_ASGD;
657 /*---------------------------------------------------------------------------*
658 * FSM state ST_AW_EST event T200 expiry
659 *---------------------------------------------------------------------------*/
661 F_AE11(l2_softc_t *l2sc)
663 NDBGL2(L2_F_MSG, "FSM function F_AE11 executing");
667 i4b_Dcleanifq(&l2sc->i_queue);
669 i4b_mdl_error_ind(l2sc, "F_AE11", MDL_ERR_G);
671 l2sc->postfsmarg = l2sc->unit;
672 l2sc->postfsmfunc = DL_Rel_Ind_A;
674 l2sc->Q921_state = ST_TEI_ASGD;
680 i4b_tx_sabme(l2sc, P1);
682 i4b_T200_start(l2sc);
684 l2sc->Q921_state = ST_AW_EST;
688 /*---------------------------------------------------------------------------*
689 * FSM state ST_AW_EST event dl data request
690 *---------------------------------------------------------------------------*/
692 F_AE12(l2_softc_t *l2sc)
694 NDBGL2(L2_F_MSG, "FSM function F_AE12 executing");
696 if(l2sc->l3initiated == 0)
698 i4b_i_frame_queued_up(l2sc);
702 /*---------------------------------------------------------------------------*
703 * FSM state ST_AW_REL event persistent deactivation
704 *---------------------------------------------------------------------------*/
706 F_AR05(l2_softc_t *l2sc)
708 NDBGL2(L2_F_MSG, "FSM function F_AR05 executing");
710 l2sc->postfsmarg = l2sc->unit;
711 l2sc->postfsmfunc = DL_Rel_Cnf_A;
716 /*---------------------------------------------------------------------------*
717 * FSM state ST_AW_REL event mdl remove request
718 *---------------------------------------------------------------------------*/
720 F_AR06(l2_softc_t *l2sc)
722 NDBGL2(L2_F_MSG, "FSM function F_AR06 executing");
724 l2sc->postfsmarg = l2sc->unit;
725 l2sc->postfsmfunc = DL_Rel_Cnf_A;
729 /*XXX*/ i4b_mdl_assign_ind(l2sc);
732 /*---------------------------------------------------------------------------*
733 * FSM state ST_AW_REL event rx'd SABME
734 *---------------------------------------------------------------------------*/
736 F_AR07(l2_softc_t *l2sc)
738 NDBGL2(L2_F_MSG, "FSM function F_AR07 executing");
739 i4b_tx_dm(l2sc, l2sc->rxd_PF);
742 /*---------------------------------------------------------------------------*
743 * FSM state ST_AW_REL event rx'd DISC
744 *---------------------------------------------------------------------------*/
746 F_AR08(l2_softc_t *l2sc)
748 NDBGL2(L2_F_MSG, "FSM function F_AR08 executing");
749 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
750 i4b_tx_ua(l2sc, l2sc->rxd_PF);
753 /*---------------------------------------------------------------------------*
754 * FSM state ST_AW_REL event rx'd UA
755 *---------------------------------------------------------------------------*/
757 F_AR09(l2_softc_t *l2sc)
759 NDBGL2(L2_F_MSG, "FSM function F_AR09 executing");
763 l2sc->postfsmarg = l2sc->unit;
764 l2sc->postfsmfunc = DL_Rel_Cnf_A;
768 l2sc->Q921_state = ST_TEI_ASGD;
772 i4b_mdl_error_ind(l2sc, "F_AR09", MDL_ERR_D);
774 l2sc->Q921_state = ST_AW_REL;
778 /*---------------------------------------------------------------------------*
779 * FSM state ST_AW_REL event rx'd DM
780 *---------------------------------------------------------------------------*/
782 F_AR10(l2_softc_t *l2sc)
784 NDBGL2(L2_F_MSG, "FSM function F_AR10 executing");
788 l2sc->postfsmarg = l2sc->unit;
789 l2sc->postfsmfunc = DL_Rel_Cnf_A;
793 l2sc->Q921_state = ST_TEI_ASGD;
797 l2sc->Q921_state = ST_AW_REL;
801 /*---------------------------------------------------------------------------*
802 * FSM state ST_AW_REL event T200 expiry
803 *---------------------------------------------------------------------------*/
805 F_AR11(l2_softc_t *l2sc)
807 NDBGL2(L2_F_MSG, "FSM function F_AR11 executing");
811 i4b_mdl_error_ind(l2sc, "F_AR11", MDL_ERR_H);
813 l2sc->postfsmarg = l2sc->unit;
814 l2sc->postfsmfunc = DL_Rel_Cnf_A;
816 l2sc->Q921_state = ST_TEI_ASGD;
822 i4b_tx_disc(l2sc, P1);
824 i4b_T200_start(l2sc);
826 l2sc->Q921_state = ST_AW_REL;
830 /*---------------------------------------------------------------------------*
831 * FSM state ST_MULTIFR event dl establish request
832 *---------------------------------------------------------------------------*/
834 F_MF01(l2_softc_t *l2sc)
836 NDBGL2(L2_F_MSG, "FSM function F_MF01 executing");
838 i4b_Dcleanifq(&l2sc->i_queue);
840 i4b_establish_data_link(l2sc);
842 l2sc->l3initiated = 1;
845 /*---------------------------------------------------------------------------*
846 * FSM state ST_MULTIFR event persistent deactivation
847 *---------------------------------------------------------------------------*/
849 F_MF05(l2_softc_t *l2sc)
851 NDBGL2(L2_F_MSG, "FSM function F_MF05 executing");
853 i4b_Dcleanifq(&l2sc->i_queue);
855 l2sc->postfsmarg = l2sc->unit;
856 l2sc->postfsmfunc = DL_Rel_Ind_A;
862 /*---------------------------------------------------------------------------*
863 * FSM state ST_MULTIFR event mdl remove request
864 *---------------------------------------------------------------------------*/
866 F_MF06(l2_softc_t *l2sc)
868 NDBGL2(L2_F_MSG, "FSM function F_MF06 executing");
870 i4b_Dcleanifq(&l2sc->i_queue);
872 l2sc->postfsmarg = l2sc->unit;
873 l2sc->postfsmfunc = DL_Rel_Ind_A;
878 /*XXX*/ i4b_mdl_assign_ind(l2sc);
881 /*---------------------------------------------------------------------------*
882 * FSM state ST_MULTIFR event rx'd SABME
883 *---------------------------------------------------------------------------*/
885 F_MF07(l2_softc_t *l2sc)
887 NDBGL2(L2_F_MSG, "FSM function F_MF07 executing");
889 i4b_clear_exception_conditions(l2sc);
891 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
893 i4b_tx_ua(l2sc, l2sc->rxd_PF);
895 i4b_mdl_error_ind(l2sc, "F_MF07", MDL_ERR_F);
897 if(l2sc->vs != l2sc->va)
899 i4b_Dcleanifq(&l2sc->i_queue);
901 l2sc->postfsmarg = l2sc->unit;
902 l2sc->postfsmfunc = DL_Est_Ind_A;
906 i4b_T203_start(l2sc);
913 /*---------------------------------------------------------------------------*
914 * FSM state ST_MULTIFR event rx'd DISC
915 *---------------------------------------------------------------------------*/
917 F_MF08(l2_softc_t *l2sc)
919 NDBGL2(L2_F_MSG, "FSM function F_MF08 executing");
921 i4b_Dcleanifq(&l2sc->i_queue);
922 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
923 i4b_tx_ua(l2sc, l2sc->rxd_PF);
925 l2sc->postfsmarg = l2sc->unit;
926 l2sc->postfsmfunc = DL_Rel_Ind_A;
932 /*---------------------------------------------------------------------------*
933 * FSM state ST_MULTIFR event rx'd UA
934 *---------------------------------------------------------------------------*/
936 F_MF09(l2_softc_t *l2sc)
938 NDBGL2(L2_F_MSG, "FSM function F_MF09 executing");
940 i4b_mdl_error_ind(l2sc, "F_MF09", MDL_ERR_C);
942 i4b_mdl_error_ind(l2sc, "F_MF09", MDL_ERR_D);
945 /*---------------------------------------------------------------------------*
946 * FSM state ST_MULTIFR event rx'd DM
947 *---------------------------------------------------------------------------*/
949 F_MF10(l2_softc_t *l2sc)
951 NDBGL2(L2_F_MSG, "FSM function F_MF10 executing");
955 i4b_mdl_error_ind(l2sc, "F_MF10", MDL_ERR_B);
957 l2sc->Q921_state = ST_MULTIFR;
961 i4b_mdl_error_ind(l2sc, "F_MF10", MDL_ERR_E);
963 i4b_establish_data_link(l2sc);
965 l2sc->l3initiated = 0;
967 l2sc->Q921_state = ST_AW_EST;
971 /*---------------------------------------------------------------------------*
972 * FSM state ST_MULTIFR event T200 expiry
973 *---------------------------------------------------------------------------*/
975 F_MF11(l2_softc_t *l2sc)
977 NDBGL2(L2_F_MSG, "FSM function F_MF11 executing");
981 i4b_transmit_enquire(l2sc);
986 /*---------------------------------------------------------------------------*
987 * FSM state ST_MULTIFR event dl data request
988 *---------------------------------------------------------------------------*/
990 F_MF12(l2_softc_t *l2sc)
992 NDBGL2(L2_F_MSG, "FSM function F_MF12 executing");
994 i4b_i_frame_queued_up(l2sc);
997 /*---------------------------------------------------------------------------*
998 * FSM state ST_MULTIFR event dl release request
999 *---------------------------------------------------------------------------*/
1001 F_MF13(l2_softc_t *l2sc)
1003 NDBGL2(L2_F_MSG, "FSM function F_MF13 executing");
1005 i4b_Dcleanifq(&l2sc->i_queue);
1009 i4b_tx_disc(l2sc, P1);
1011 i4b_T203_stop(l2sc);
1012 i4b_T200_restart(l2sc);
1015 /*---------------------------------------------------------------------------*
1016 * FSM state ST_MULTIFR event T203 expiry
1017 *---------------------------------------------------------------------------*/
1019 F_MF14(l2_softc_t *l2sc)
1021 NDBGL2(L2_F_MSG, "FSM function F_MF14 executing");
1023 i4b_transmit_enquire(l2sc);
1028 /*---------------------------------------------------------------------------*
1029 * FSM state ST_MULTIFR event set own rx busy
1030 *---------------------------------------------------------------------------*/
1032 F_MF15(l2_softc_t *l2sc)
1034 NDBGL2(L2_F_MSG, "FSM function F_MF15 executing");
1036 if(l2sc->own_busy == 0)
1040 i4b_tx_rnr_response(l2sc, F0); /* wrong in Q.921 03/93 p 64 */
1046 /*---------------------------------------------------------------------------*
1047 * FSM state ST_MULTIFR event clear own rx busy
1048 *---------------------------------------------------------------------------*/
1050 F_MF16(l2_softc_t *l2sc)
1052 NDBGL2(L2_F_MSG, "FSM function F_MF16 executing");
1054 if(l2sc->own_busy != 0)
1058 i4b_tx_rr_response(l2sc, F0); /* wrong in Q.921 03/93 p 64 */
1064 /*---------------------------------------------------------------------------*
1065 * FSM state ST_MULTIFR event rx'd RR
1066 *---------------------------------------------------------------------------*/
1068 F_MF17(l2_softc_t *l2sc)
1070 NDBGL2(L2_F_MSG, "FSM function F_MF17 executing");
1072 l2sc->peer_busy = 0;
1074 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1076 if(l2sc->rxd_PF == 1)
1078 i4b_enquiry_response(l2sc);
1083 if(l2sc->rxd_PF == 1)
1085 i4b_mdl_error_ind(l2sc, "F_MF17", MDL_ERR_A);
1089 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1091 if(l2sc->rxd_NR == l2sc->vs)
1093 l2sc->va = l2sc->rxd_NR;
1094 i4b_T200_stop(l2sc);
1095 i4b_T203_restart(l2sc);
1097 else if(l2sc->rxd_NR != l2sc->va)
1099 l2sc->va = l2sc->rxd_NR;
1100 i4b_T200_restart(l2sc);
1102 l2sc->Q921_state = ST_MULTIFR;
1106 i4b_nr_error_recovery(l2sc);
1107 l2sc->Q921_state = ST_AW_EST;
1111 /*---------------------------------------------------------------------------*
1112 * FSM state ST_MULTIFR event rx'd REJ
1113 *---------------------------------------------------------------------------*/
1115 F_MF18(l2_softc_t *l2sc)
1117 NDBGL2(L2_F_MSG, "FSM function F_MF18 executing");
1119 l2sc->peer_busy = 0;
1121 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1123 if(l2sc->rxd_PF == 1)
1125 i4b_enquiry_response(l2sc);
1130 if(l2sc->rxd_PF == 1)
1132 i4b_mdl_error_ind(l2sc, "F_MF18", MDL_ERR_A);
1136 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1138 l2sc->va = l2sc->rxd_NR;
1139 i4b_T200_stop(l2sc);
1140 i4b_T203_start(l2sc);
1141 i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
1142 l2sc->Q921_state = ST_MULTIFR;
1146 i4b_nr_error_recovery(l2sc);
1147 l2sc->Q921_state = ST_AW_EST;
1151 /*---------------------------------------------------------------------------*
1152 * FSM state ST_MULTIFR event rx'd RNR
1153 *---------------------------------------------------------------------------*/
1155 F_MF19(l2_softc_t *l2sc)
1157 NDBGL2(L2_F_MSG, "FSM function F_MF19 executing");
1159 l2sc->peer_busy = 1;
1161 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1163 if(l2sc->rxd_PF == 1)
1165 i4b_enquiry_response(l2sc);
1170 if(l2sc->rxd_PF == 1)
1172 i4b_mdl_error_ind(l2sc, "F_MF19", MDL_ERR_A);
1176 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1178 l2sc->va = l2sc->rxd_NR;
1179 i4b_T203_stop(l2sc);
1180 i4b_T200_restart(l2sc);
1181 l2sc->Q921_state = ST_MULTIFR;
1185 i4b_nr_error_recovery(l2sc);
1186 l2sc->Q921_state = ST_AW_EST;
1190 /*---------------------------------------------------------------------------*
1191 * FSM state ST_MULTIFR event rx'd FRMR
1192 *---------------------------------------------------------------------------*/
1194 F_MF20(l2_softc_t *l2sc)
1196 NDBGL2(L2_F_MSG, "FSM function F_MF20 executing");
1198 i4b_mdl_error_ind(l2sc, "F_MF20", MDL_ERR_K);
1200 i4b_establish_data_link(l2sc);
1202 l2sc->l3initiated = 0;
1205 /*---------------------------------------------------------------------------*
1206 * FSM state ST_TIMREC event dl establish request
1207 *---------------------------------------------------------------------------*/
1209 F_TR01(l2_softc_t *l2sc)
1211 NDBGL2(L2_F_MSG, "FSM function F_TR01 executing");
1213 i4b_Dcleanifq(&l2sc->i_queue);
1215 i4b_establish_data_link(l2sc);
1217 l2sc->l3initiated = 1;
1220 /*---------------------------------------------------------------------------*
1221 * FSM state ST_TIMREC event persistent deactivation
1222 *---------------------------------------------------------------------------*/
1224 F_TR05(l2_softc_t *l2sc)
1226 NDBGL2(L2_F_MSG, "FSM function F_TR05 executing");
1228 i4b_Dcleanifq(&l2sc->i_queue);
1230 l2sc->postfsmarg = l2sc->unit;
1231 l2sc->postfsmfunc = DL_Rel_Ind_A;
1233 i4b_T200_stop(l2sc);
1236 /*---------------------------------------------------------------------------*
1237 * FSM state ST_TIMREC event mdl remove request
1238 *---------------------------------------------------------------------------*/
1240 F_TR06(l2_softc_t *l2sc)
1242 NDBGL2(L2_F_MSG, "FSM function F_TR06 executing");
1244 i4b_Dcleanifq(&l2sc->i_queue);
1246 l2sc->postfsmarg = l2sc->unit;
1247 l2sc->postfsmfunc = DL_Rel_Ind_A;
1249 i4b_T200_stop(l2sc);
1251 /*XXX*/ i4b_mdl_assign_ind(l2sc);
1254 /*---------------------------------------------------------------------------*
1255 * FSM state ST_TIMREC event rx'd SABME
1256 *---------------------------------------------------------------------------*/
1258 F_TR07(l2_softc_t *l2sc)
1260 NDBGL2(L2_F_MSG, "FSM function F_TR07 executing");
1262 i4b_clear_exception_conditions(l2sc);
1264 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
1266 i4b_tx_ua(l2sc, l2sc->rxd_PF);
1268 i4b_mdl_error_ind(l2sc, "F_TR07", MDL_ERR_F);
1270 if(l2sc->vs != l2sc->va)
1272 i4b_Dcleanifq(&l2sc->i_queue);
1274 l2sc->postfsmarg = l2sc->unit;
1275 l2sc->postfsmfunc = DL_Est_Ind_A;
1278 i4b_T200_stop(l2sc);
1279 i4b_T203_start(l2sc);
1286 /*---------------------------------------------------------------------------*
1287 * FSM state ST_TIMREC event rx'd DISC
1288 *---------------------------------------------------------------------------*/
1290 F_TR08(l2_softc_t *l2sc)
1292 NDBGL2(L2_F_MSG, "FSM function F_TR08 executing");
1294 i4b_Dcleanifq(&l2sc->i_queue);
1295 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
1296 i4b_tx_ua(l2sc, l2sc->rxd_PF);
1298 l2sc->postfsmarg = l2sc->unit;
1299 l2sc->postfsmfunc = DL_Rel_Ind_A;
1301 i4b_T200_stop(l2sc);
1304 /*---------------------------------------------------------------------------*
1305 * FSM state ST_TIMREC event rx'd UA
1306 *---------------------------------------------------------------------------*/
1308 F_TR09(l2_softc_t *l2sc)
1310 NDBGL2(L2_F_MSG, "FSM function F_TR09 executing");
1312 i4b_mdl_error_ind(l2sc, "F_TR09", MDL_ERR_C);
1314 i4b_mdl_error_ind(l2sc, "F_TR09", MDL_ERR_D);
1317 /*---------------------------------------------------------------------------*
1318 * FSM state ST_TIMREC event rx'd DM
1319 *---------------------------------------------------------------------------*/
1321 F_TR10(l2_softc_t *l2sc)
1323 NDBGL2(L2_F_MSG, "FSM function F_TR10 executing");
1327 i4b_mdl_error_ind(l2sc, "F_TR10", MDL_ERR_B);
1331 i4b_mdl_error_ind(l2sc, "F_TR10", MDL_ERR_E);
1334 i4b_establish_data_link(l2sc);
1336 l2sc->l3initiated = 0;
1339 /*---------------------------------------------------------------------------*
1340 * FSM state ST_TIMREC event T200 expiry
1341 *---------------------------------------------------------------------------*/
1343 F_TR11(l2_softc_t *l2sc)
1345 NDBGL2(L2_F_MSG, "FSM function F_TR11 executing");
1347 if(l2sc->RC >= N200)
1349 i4b_mdl_error_ind(l2sc, "F_TR11", MDL_ERR_I);
1351 i4b_establish_data_link(l2sc);
1353 l2sc->l3initiated = 0;
1355 l2sc->Q921_state = ST_AW_EST;
1359 i4b_transmit_enquire(l2sc);
1363 l2sc->Q921_state = ST_TIMREC;
1367 /*---------------------------------------------------------------------------*
1368 * FSM state ST_TIMREC event dl data request
1369 *---------------------------------------------------------------------------*/
1371 F_TR12(l2_softc_t *l2sc)
1373 NDBGL2(L2_F_MSG, "FSM function F_TR12 executing");
1375 i4b_i_frame_queued_up(l2sc);
1378 /*---------------------------------------------------------------------------*
1379 * FSM state ST_TIMREC event dl release request
1380 *---------------------------------------------------------------------------*/
1382 F_TR13(l2_softc_t *l2sc)
1384 NDBGL2(L2_F_MSG, "FSM function F_TR13 executing");
1386 i4b_Dcleanifq(&l2sc->i_queue);
1390 i4b_tx_disc(l2sc, P1);
1392 i4b_T200_restart(l2sc);
1395 /*---------------------------------------------------------------------------*
1396 * FSM state ST_TIMREC event set own rx busy
1397 *---------------------------------------------------------------------------*/
1399 F_TR15(l2_softc_t *l2sc)
1401 NDBGL2(L2_F_MSG, "FSM function F_TR15 executing");
1403 if(l2sc->own_busy == 0)
1407 i4b_tx_rnr_response(l2sc, F0);
1413 /*---------------------------------------------------------------------------*
1414 * FSM state ST_TIMREC event clear own rx busy
1415 *---------------------------------------------------------------------------*/
1417 F_TR16(l2_softc_t *l2sc)
1419 NDBGL2(L2_F_MSG, "FSM function F_TR16 executing");
1421 if(l2sc->own_busy != 0)
1425 i4b_tx_rr_response(l2sc, F0); /* this is wrong */
1426 /* in Q.921 03/93 p 74 ! */
1431 /*---------------------------------------------------------------------------*
1432 * FSM state ST_TIMREC event rx'd RR
1433 *---------------------------------------------------------------------------*/
1435 F_TR17(l2_softc_t *l2sc)
1437 NDBGL2(L2_F_MSG, "FSM function F_TR17 executing");
1439 l2sc->peer_busy = 0;
1441 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1443 if(l2sc->rxd_PF == 1)
1445 i4b_enquiry_response(l2sc);
1450 if(l2sc->rxd_PF == 1)
1452 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1454 l2sc->va = l2sc->rxd_NR;
1455 i4b_T200_stop(l2sc);
1456 i4b_T203_start(l2sc);
1457 i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
1458 l2sc->Q921_state = ST_MULTIFR;
1463 i4b_nr_error_recovery(l2sc);
1464 l2sc->Q921_state = ST_AW_EST;
1470 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1472 l2sc->va = l2sc->rxd_NR;
1473 l2sc->Q921_state = ST_TIMREC;
1477 i4b_nr_error_recovery(l2sc);
1478 l2sc->Q921_state = ST_AW_EST;
1482 /*---------------------------------------------------------------------------*
1483 * FSM state ST_TIMREC event
1484 *---------------------------------------------------------------------------*/
1486 F_TR18(l2_softc_t *l2sc)
1488 NDBGL2(L2_F_MSG, "FSM function F_TR18 executing");
1490 l2sc->peer_busy = 0;
1492 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1494 if(l2sc->rxd_PF == 1)
1496 i4b_enquiry_response(l2sc);
1501 if(l2sc->rxd_PF == 1)
1503 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1505 l2sc->va = l2sc->rxd_NR;
1506 i4b_T200_stop(l2sc);
1507 i4b_T203_start(l2sc);
1508 i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
1509 l2sc->Q921_state = ST_MULTIFR;
1514 i4b_nr_error_recovery(l2sc);
1515 l2sc->Q921_state = ST_AW_EST;
1521 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1523 l2sc->va = l2sc->rxd_NR;
1524 l2sc->Q921_state = ST_TIMREC;
1528 i4b_nr_error_recovery(l2sc);
1529 l2sc->Q921_state = ST_AW_EST;
1533 /*---------------------------------------------------------------------------*
1534 * FSM state ST_TIMREC event rx'd RNR
1535 *---------------------------------------------------------------------------*/
1537 F_TR19(l2_softc_t *l2sc)
1539 NDBGL2(L2_F_MSG, "FSM function F_TR19 executing");
1541 l2sc->peer_busy = 0;
1543 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1545 if(l2sc->rxd_PF == 1)
1547 i4b_enquiry_response(l2sc);
1552 if(l2sc->rxd_PF == 1)
1554 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1556 l2sc->va = l2sc->rxd_NR;
1557 i4b_T200_restart(l2sc);
1558 i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
1559 l2sc->Q921_state = ST_MULTIFR;
1564 i4b_nr_error_recovery(l2sc);
1565 l2sc->Q921_state = ST_AW_EST;
1571 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1573 l2sc->va = l2sc->rxd_NR;
1574 l2sc->Q921_state = ST_TIMREC;
1578 i4b_nr_error_recovery(l2sc);
1579 l2sc->Q921_state = ST_AW_EST;
1583 /*---------------------------------------------------------------------------*
1584 * FSM state ST_TIMREC event rx'd FRMR
1585 *---------------------------------------------------------------------------*/
1587 F_TR20(l2_softc_t *l2sc)
1589 NDBGL2(L2_F_MSG, "FSM function F_TR20 executing");
1591 i4b_mdl_error_ind(l2sc, "F_TR20", MDL_ERR_K);
1593 i4b_establish_data_link(l2sc);
1595 l2sc->l3initiated = 0;
1598 #endif /* NI4BQ921 > 0 */