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 $
34 * last edit-date: [Tue May 30 15:48:20 2000]
36 *---------------------------------------------------------------------------*/
45 #include <sys/param.h>
46 #include <sys/systm.h>
47 #include <sys/socket.h>
50 #if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
51 #include <sys/callout.h>
55 #include <machine/i4b_debug.h>
56 #include <machine/i4b_ioctl.h>
58 #include <i4b/i4b_debug.h>
59 #include <i4b/i4b_ioctl.h>
62 #include <i4b/include/i4b_global.h>
63 #include <i4b/include/i4b_l2l3.h>
64 #include <i4b/include/i4b_mbuf.h>
66 #include <i4b/layer2/i4b_l2.h>
67 #include <i4b/layer2/i4b_l2fsm.h>
69 l2_softc_t l2_softc[MAXL1UNITS];
72 static char *l2state_text[N_STATES] = {
87 static char *l2event_text[N_EVENTS] = {
112 static void F_TU01 __P((l2_softc_t *));
113 static void F_TU03 __P((l2_softc_t *));
115 static void F_TA03 __P((l2_softc_t *));
116 static void F_TA04 __P((l2_softc_t *));
117 static void F_TA05 __P((l2_softc_t *));
119 static void F_TE03 __P((l2_softc_t *));
120 static void F_TE04 __P((l2_softc_t *));
121 static void F_TE05 __P((l2_softc_t *));
123 static void F_T01 __P((l2_softc_t *));
124 static void F_T05 __P((l2_softc_t *));
125 static void F_T06 __P((l2_softc_t *));
126 static void F_T07 __P((l2_softc_t *));
127 static void F_T08 __P((l2_softc_t *));
128 static void F_T09 __P((l2_softc_t *));
129 static void F_T10 __P((l2_softc_t *));
130 static void F_T13 __P((l2_softc_t *));
132 static void F_AE01 __P((l2_softc_t *));
133 static void F_AE05 __P((l2_softc_t *));
134 static void F_AE06 __P((l2_softc_t *));
135 static void F_AE07 __P((l2_softc_t *));
136 static void F_AE08 __P((l2_softc_t *));
137 static void F_AE09 __P((l2_softc_t *));
138 static void F_AE10 __P((l2_softc_t *));
139 static void F_AE11 __P((l2_softc_t *));
140 static void F_AE12 __P((l2_softc_t *));
142 static void F_AR05 __P((l2_softc_t *));
143 static void F_AR06 __P((l2_softc_t *));
144 static void F_AR07 __P((l2_softc_t *));
145 static void F_AR08 __P((l2_softc_t *));
146 static void F_AR09 __P((l2_softc_t *));
147 static void F_AR10 __P((l2_softc_t *));
148 static void F_AR11 __P((l2_softc_t *));
150 static void F_MF01 __P((l2_softc_t *));
151 static void F_MF05 __P((l2_softc_t *));
152 static void F_MF06 __P((l2_softc_t *));
153 static void F_MF07 __P((l2_softc_t *));
154 static void F_MF08 __P((l2_softc_t *));
155 static void F_MF09 __P((l2_softc_t *));
156 static void F_MF10 __P((l2_softc_t *));
157 static void F_MF11 __P((l2_softc_t *));
158 static void F_MF12 __P((l2_softc_t *));
159 static void F_MF13 __P((l2_softc_t *));
160 static void F_MF14 __P((l2_softc_t *));
161 static void F_MF15 __P((l2_softc_t *));
162 static void F_MF16 __P((l2_softc_t *));
163 static void F_MF17 __P((l2_softc_t *));
164 static void F_MF18 __P((l2_softc_t *));
165 static void F_MF19 __P((l2_softc_t *));
166 static void F_MF20 __P((l2_softc_t *));
168 static void F_TR01 __P((l2_softc_t *));
169 static void F_TR05 __P((l2_softc_t *));
170 static void F_TR06 __P((l2_softc_t *));
171 static void F_TR07 __P((l2_softc_t *));
172 static void F_TR08 __P((l2_softc_t *));
173 static void F_TR09 __P((l2_softc_t *));
174 static void F_TR10 __P((l2_softc_t *));
175 static void F_TR11 __P((l2_softc_t *));
176 static void F_TR12 __P((l2_softc_t *));
177 static void F_TR13 __P((l2_softc_t *));
178 static void F_TR15 __P((l2_softc_t *));
179 static void F_TR16 __P((l2_softc_t *));
180 static void F_TR17 __P((l2_softc_t *));
181 static void F_TR18 __P((l2_softc_t *));
182 static void F_TR19 __P((l2_softc_t *));
183 static void F_TR20 __P((l2_softc_t *));
184 static void F_ILL __P((l2_softc_t *));
185 static void F_NCNA __P((l2_softc_t *));
187 /*---------------------------------------------------------------------------*
188 * FSM illegal state default action
189 *---------------------------------------------------------------------------*/
191 F_ILL(l2_softc_t *l2sc)
193 NDBGL2(L2_F_ERR, "FSM function F_ILL executing");
196 /*---------------------------------------------------------------------------*
197 * FSM No change, No action
198 *---------------------------------------------------------------------------*/
200 F_NCNA(l2_softc_t *l2sc)
202 NDBGL2(L2_F_MSG, "FSM function F_NCNA executing");
205 /*---------------------------------------------------------------------------*
206 * layer 2 state transition table
207 *---------------------------------------------------------------------------*/
209 void (*func) __P((l2_softc_t *)); /* function to execute */
210 int newstate; /* next state */
211 } l2state_tab[N_EVENTS][N_STATES] = {
213 /* 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 */
214 /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
215 /*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} },
216 /*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} },
217 /*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} },
218 /*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} },
219 /*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} },
220 /*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} },
221 /*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} },
222 /*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} },
223 /*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} },
224 /*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} },
225 /*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} },
226 /*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} },
227 /*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} },
228 /*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} },
229 /*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} },
230 /*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} },
231 /*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} },
232 /*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} },
233 /*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} },
234 /*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} },
235 /*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} }
238 /*---------------------------------------------------------------------------*
239 * event handler, executes function and sets new state
240 *---------------------------------------------------------------------------*/
241 void i4b_next_l2state(l2_softc_t *l2sc, int event)
243 int currstate, newstate;
244 int (*savpostfsmfunc)(int) = NULL;
246 /* check event number */
248 panic("i4b_l2fsm.c: event > N_EVENTS\n");
250 /* get current state and check it */
251 if((currstate = l2sc->Q921_state) > N_STATES) /* failsafe */
252 panic("i4b_l2fsm.c: currstate > N_STATES\n");
254 /* get new state and check it */
255 if((newstate = l2state_tab[event][currstate].newstate) > N_STATES)
256 panic("i4b_l2fsm.c: newstate > N_STATES\n");
259 if(newstate != ST_SUBSET)
260 { /* state function does NOT set new state */
261 NDBGL2(L2_F_MSG, "FSM event [%s]: [%s/%d => %s/%d]",
263 l2state_text[currstate], currstate,
264 l2state_text[newstate], newstate);
267 /* execute state transition function */
268 (*l2state_tab[event][currstate].func)(l2sc);
270 if(newstate == ST_SUBSET)
271 { /* state function DOES set new state */
272 NDBGL2(L2_F_MSG, "FSM S-event [%s]: [%s => %s]", l2event_text[event],
273 l2state_text[currstate],
274 l2state_text[l2sc->Q921_state]);
277 /* check for illegal new state */
279 if(newstate == ST_ILL)
281 newstate = currstate;
282 NDBGL2(L2_F_ERR, "FSM illegal state, state = %s, event = %s!",
283 l2state_text[currstate],
284 l2event_text[event]);
287 /* check if state machine function has to set new state */
289 if(newstate != ST_SUBSET)
290 l2sc->Q921_state = newstate; /* no, we set new state */
292 if(l2sc->postfsmfunc != NULL)
294 NDBGL2(L2_F_MSG, "FSM executing postfsmfunc!");
295 /* try to avoid an endless loop */
296 savpostfsmfunc = l2sc->postfsmfunc;
297 l2sc->postfsmfunc = NULL;
298 (*savpostfsmfunc)(l2sc->postfsmarg);
303 /*---------------------------------------------------------------------------*
304 * return pointer to current state description
305 *---------------------------------------------------------------------------*/
306 char *i4b_print_l2state(l2_softc_t *l2sc)
308 return((char *) l2state_text[l2sc->Q921_state]);
312 /*---------------------------------------------------------------------------*
313 * FSM state ST_TEI_UNAS event dl establish request
314 *---------------------------------------------------------------------------*/
316 F_TU01(l2_softc_t *l2sc)
318 NDBGL2(L2_F_MSG, "FSM function F_TU01 executing");
319 i4b_mdl_assign_ind(l2sc);
322 /*---------------------------------------------------------------------------*
323 * FSM state ST_TEI_UNAS event mdl assign request
324 *---------------------------------------------------------------------------*/
326 F_TU03(l2_softc_t *l2sc)
328 NDBGL2(L2_F_MSG, "FSM function F_TU03 executing");
331 /*---------------------------------------------------------------------------*
332 * FSM state ST_ASG_AW_TEI event mdl assign request
333 *---------------------------------------------------------------------------*/
335 F_TA03(l2_softc_t *l2sc)
337 NDBGL2(L2_F_MSG, "FSM function F_TA03 executing");
340 /*---------------------------------------------------------------------------*
341 * FSM state ST_ASG_AW_TEI event mdl error response
342 *---------------------------------------------------------------------------*/
344 F_TA04(l2_softc_t *l2sc)
346 NDBGL2(L2_F_MSG, "FSM function F_TA04 executing");
349 /*---------------------------------------------------------------------------*
350 * FSM state ST_ASG_AW_TEI event persistent deactivation
351 *---------------------------------------------------------------------------*/
353 F_TA05(l2_softc_t *l2sc)
355 NDBGL2(L2_F_MSG, "FSM function F_TA05 executing");
358 /*---------------------------------------------------------------------------*
359 * FSM state ST_EST_AW_TEI event mdl assign request
360 *---------------------------------------------------------------------------*/
362 F_TE03(l2_softc_t *l2sc)
364 NDBGL2(L2_F_MSG, "FSM function F_TE03 executing");
365 i4b_establish_data_link(l2sc);
366 l2sc->l3initiated = 1;
369 /*---------------------------------------------------------------------------*
370 * FSM state ST_EST_AW_TEI event mdl error response
371 *---------------------------------------------------------------------------*/
373 F_TE04(l2_softc_t *l2sc)
375 NDBGL2(L2_F_MSG, "FSM function F_TE04 executing");
376 l2sc->postfsmarg = l2sc->unit;
377 l2sc->postfsmfunc = DL_Rel_Ind_A;
380 /*---------------------------------------------------------------------------*
381 * FSM state ST_EST_AW_TEI event persistent deactivation
382 *---------------------------------------------------------------------------*/
384 F_TE05(l2_softc_t *l2sc)
386 NDBGL2(L2_F_MSG, "FSM function F_TE05 executing");
387 l2sc->postfsmarg = l2sc->unit;
388 l2sc->postfsmfunc = DL_Rel_Ind_A;
391 /*---------------------------------------------------------------------------*
392 * FSM state ST_TEI_ASGD event dl establish request
393 *---------------------------------------------------------------------------*/
395 F_T01(l2_softc_t *l2sc)
397 NDBGL2(L2_F_MSG, "FSM function F_T01 executing");
398 i4b_establish_data_link(l2sc);
399 l2sc->l3initiated = 1;
402 /*---------------------------------------------------------------------------*
403 * FSM state ST_TEI_ASGD event persistent deactivation
404 *---------------------------------------------------------------------------*/
406 F_T05(l2_softc_t *l2sc)
408 NDBGL2(L2_F_MSG, "FSM function F_T05 executing");
411 /*---------------------------------------------------------------------------*
412 * FSM state ST_TEI_ASGD event mdl remove request
413 *---------------------------------------------------------------------------*/
415 F_T06(l2_softc_t *l2sc)
417 NDBGL2(L2_F_MSG, "FSM function F_T06 executing");
418 /*XXX*/ i4b_mdl_assign_ind(l2sc);
421 /*---------------------------------------------------------------------------*
422 * FSM state ST_TEI_ASGD event rx'd SABME
423 *---------------------------------------------------------------------------*/
425 F_T07(l2_softc_t *l2sc)
427 NDBGL2(L2_F_MSG, "FSM function F_T07 executing");
431 if(NOT able to establish)
433 i4b_tx_dm(l2sc, l2sc->rxd_PF);
434 l2sc->Q921_state = ST_TEI_ASGD;
439 i4b_clear_exception_conditions(l2sc);
441 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
443 i4b_tx_ua(l2sc, l2sc->rxd_PF);
449 l2sc->postfsmarg = l2sc->unit;
450 l2sc->postfsmfunc = DL_Est_Ind_A;
452 i4b_T203_start(l2sc);
454 l2sc->Q921_state = ST_MULTIFR;
457 /*---------------------------------------------------------------------------*
458 * FSM state ST_TEI_ASGD event rx'd DISC
459 *---------------------------------------------------------------------------*/
461 F_T08(l2_softc_t *l2sc)
463 NDBGL2(L2_F_MSG, "FSM function F_T08 executing");
464 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
465 i4b_tx_ua(l2sc, l2sc->rxd_PF);
468 /*---------------------------------------------------------------------------*
469 * FSM state ST_TEI_ASGD event rx'd UA
470 *---------------------------------------------------------------------------*/
472 F_T09(l2_softc_t *l2sc)
474 NDBGL2(L2_F_MSG, "FSM function F_T09 executing");
475 i4b_mdl_error_ind(l2sc, "F_T09", MDL_ERR_C);
476 i4b_mdl_error_ind(l2sc, "F_T09", MDL_ERR_D);
479 /*---------------------------------------------------------------------------*
480 * FSM state ST_TEI_ASGD event rx'd DM
481 *---------------------------------------------------------------------------*/
483 F_T10(l2_softc_t *l2sc)
485 NDBGL2(L2_F_MSG, "FSM function F_T10 executing");
489 l2sc->Q921_state = ST_TEI_ASGD;
494 if(NOT able_to_etablish)
496 l2sc->Q921_state = ST_TEI_ASGD;
500 i4b_establish_data_link(l2sc);
502 l2sc->l3initiated = 1;
504 l2sc->Q921_state = ST_AW_EST;
508 /*---------------------------------------------------------------------------*
509 * FSM state ST_TEI_ASGD event dl release request
510 *---------------------------------------------------------------------------*/
512 F_T13(l2_softc_t *l2sc)
514 NDBGL2(L2_F_MSG, "FSM function F_T13 executing");
515 l2sc->postfsmarg = l2sc->unit;
516 l2sc->postfsmfunc = DL_Rel_Cnf_A;
519 /*---------------------------------------------------------------------------*
520 * FSM state ST_AW_EST event dl establish request
521 *---------------------------------------------------------------------------*/
523 F_AE01(l2_softc_t *l2sc)
525 NDBGL2(L2_F_MSG, "FSM function F_AE01 executing");
527 i4b_Dcleanifq(&l2sc->i_queue);
529 l2sc->l3initiated = 1;
532 /*---------------------------------------------------------------------------*
533 * FSM state ST_AW_EST event persistent deactivation
534 *---------------------------------------------------------------------------*/
536 F_AE05(l2_softc_t *l2sc)
538 NDBGL2(L2_F_MSG, "FSM function F_AE05 executing");
540 i4b_Dcleanifq(&l2sc->i_queue);
542 l2sc->postfsmarg = l2sc->unit;
543 l2sc->postfsmfunc = DL_Rel_Ind_A;
548 /*---------------------------------------------------------------------------*
549 * FSM state ST_AW_EST event mdl remove request
550 *---------------------------------------------------------------------------*/
552 F_AE06(l2_softc_t *l2sc)
554 NDBGL2(L2_F_MSG, "FSM function F_AE06 executing");
556 i4b_Dcleanifq(&l2sc->i_queue);
558 l2sc->postfsmarg = l2sc->unit;
559 l2sc->postfsmfunc = DL_Rel_Ind_A;
563 /*XXX*/ i4b_mdl_assign_ind(l2sc);
566 /*---------------------------------------------------------------------------*
567 * FSM state ST_AW_EST event rx'd SABME
568 *---------------------------------------------------------------------------*/
570 F_AE07(l2_softc_t *l2sc)
572 NDBGL2(L2_F_MSG, "FSM function F_AE07 executing");
573 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
574 i4b_tx_ua(l2sc, l2sc->rxd_PF);
577 /*---------------------------------------------------------------------------*
578 * FSM state ST_AW_EST event rx'd DISC
579 *---------------------------------------------------------------------------*/
581 F_AE08(l2_softc_t *l2sc)
583 NDBGL2(L2_F_MSG, "FSM function F_AE08 executing");
584 i4b_tx_dm(l2sc, l2sc->rxd_PF);
587 /*---------------------------------------------------------------------------*
588 * FSM state ST_AW_EST event rx'd UA
589 *---------------------------------------------------------------------------*/
591 F_AE09(l2_softc_t *l2sc)
593 NDBGL2(L2_F_MSG, "FSM function F_AE09 executing");
595 if(l2sc->rxd_PF == 0)
597 i4b_mdl_error_ind(l2sc, "F_AE09", MDL_ERR_D);
598 l2sc->Q921_state = ST_AW_EST;
602 if(l2sc->l3initiated)
604 l2sc->l3initiated = 0;
606 l2sc->postfsmarg = l2sc->unit;
607 l2sc->postfsmfunc = DL_Est_Cnf_A;
611 if(l2sc->vs != l2sc->va)
613 i4b_Dcleanifq(&l2sc->i_queue);
614 l2sc->postfsmarg = l2sc->unit;
615 l2sc->postfsmfunc = DL_Est_Ind_A;
619 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
622 i4b_T203_start(l2sc);
627 l2sc->Q921_state = ST_MULTIFR;
631 /*---------------------------------------------------------------------------*
632 * FSM state ST_AW_EST event rx'd DM
633 *---------------------------------------------------------------------------*/
635 F_AE10(l2_softc_t *l2sc)
637 NDBGL2(L2_F_MSG, "FSM function F_AE10 executing");
639 if(l2sc->rxd_PF == 0)
641 l2sc->Q921_state = ST_AW_EST;
645 i4b_Dcleanifq(&l2sc->i_queue);
647 l2sc->postfsmarg = l2sc->unit;
648 l2sc->postfsmfunc = DL_Rel_Ind_A;
652 l2sc->Q921_state = ST_TEI_ASGD;
656 /*---------------------------------------------------------------------------*
657 * FSM state ST_AW_EST event T200 expiry
658 *---------------------------------------------------------------------------*/
660 F_AE11(l2_softc_t *l2sc)
662 NDBGL2(L2_F_MSG, "FSM function F_AE11 executing");
666 i4b_Dcleanifq(&l2sc->i_queue);
668 i4b_mdl_error_ind(l2sc, "F_AE11", MDL_ERR_G);
670 l2sc->postfsmarg = l2sc->unit;
671 l2sc->postfsmfunc = DL_Rel_Ind_A;
673 l2sc->Q921_state = ST_TEI_ASGD;
679 i4b_tx_sabme(l2sc, P1);
681 i4b_T200_start(l2sc);
683 l2sc->Q921_state = ST_AW_EST;
687 /*---------------------------------------------------------------------------*
688 * FSM state ST_AW_EST event dl data request
689 *---------------------------------------------------------------------------*/
691 F_AE12(l2_softc_t *l2sc)
693 NDBGL2(L2_F_MSG, "FSM function F_AE12 executing");
695 if(l2sc->l3initiated == 0)
697 i4b_i_frame_queued_up(l2sc);
701 /*---------------------------------------------------------------------------*
702 * FSM state ST_AW_REL event persistent deactivation
703 *---------------------------------------------------------------------------*/
705 F_AR05(l2_softc_t *l2sc)
707 NDBGL2(L2_F_MSG, "FSM function F_AR05 executing");
709 l2sc->postfsmarg = l2sc->unit;
710 l2sc->postfsmfunc = DL_Rel_Cnf_A;
715 /*---------------------------------------------------------------------------*
716 * FSM state ST_AW_REL event mdl remove request
717 *---------------------------------------------------------------------------*/
719 F_AR06(l2_softc_t *l2sc)
721 NDBGL2(L2_F_MSG, "FSM function F_AR06 executing");
723 l2sc->postfsmarg = l2sc->unit;
724 l2sc->postfsmfunc = DL_Rel_Cnf_A;
728 /*XXX*/ i4b_mdl_assign_ind(l2sc);
731 /*---------------------------------------------------------------------------*
732 * FSM state ST_AW_REL event rx'd SABME
733 *---------------------------------------------------------------------------*/
735 F_AR07(l2_softc_t *l2sc)
737 NDBGL2(L2_F_MSG, "FSM function F_AR07 executing");
738 i4b_tx_dm(l2sc, l2sc->rxd_PF);
741 /*---------------------------------------------------------------------------*
742 * FSM state ST_AW_REL event rx'd DISC
743 *---------------------------------------------------------------------------*/
745 F_AR08(l2_softc_t *l2sc)
747 NDBGL2(L2_F_MSG, "FSM function F_AR08 executing");
748 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
749 i4b_tx_ua(l2sc, l2sc->rxd_PF);
752 /*---------------------------------------------------------------------------*
753 * FSM state ST_AW_REL event rx'd UA
754 *---------------------------------------------------------------------------*/
756 F_AR09(l2_softc_t *l2sc)
758 NDBGL2(L2_F_MSG, "FSM function F_AR09 executing");
762 l2sc->postfsmarg = l2sc->unit;
763 l2sc->postfsmfunc = DL_Rel_Cnf_A;
767 l2sc->Q921_state = ST_TEI_ASGD;
771 i4b_mdl_error_ind(l2sc, "F_AR09", MDL_ERR_D);
773 l2sc->Q921_state = ST_AW_REL;
777 /*---------------------------------------------------------------------------*
778 * FSM state ST_AW_REL event rx'd DM
779 *---------------------------------------------------------------------------*/
781 F_AR10(l2_softc_t *l2sc)
783 NDBGL2(L2_F_MSG, "FSM function F_AR10 executing");
787 l2sc->postfsmarg = l2sc->unit;
788 l2sc->postfsmfunc = DL_Rel_Cnf_A;
792 l2sc->Q921_state = ST_TEI_ASGD;
796 l2sc->Q921_state = ST_AW_REL;
800 /*---------------------------------------------------------------------------*
801 * FSM state ST_AW_REL event T200 expiry
802 *---------------------------------------------------------------------------*/
804 F_AR11(l2_softc_t *l2sc)
806 NDBGL2(L2_F_MSG, "FSM function F_AR11 executing");
810 i4b_mdl_error_ind(l2sc, "F_AR11", MDL_ERR_H);
812 l2sc->postfsmarg = l2sc->unit;
813 l2sc->postfsmfunc = DL_Rel_Cnf_A;
815 l2sc->Q921_state = ST_TEI_ASGD;
821 i4b_tx_disc(l2sc, P1);
823 i4b_T200_start(l2sc);
825 l2sc->Q921_state = ST_AW_REL;
829 /*---------------------------------------------------------------------------*
830 * FSM state ST_MULTIFR event dl establish request
831 *---------------------------------------------------------------------------*/
833 F_MF01(l2_softc_t *l2sc)
835 NDBGL2(L2_F_MSG, "FSM function F_MF01 executing");
837 i4b_Dcleanifq(&l2sc->i_queue);
839 i4b_establish_data_link(l2sc);
841 l2sc->l3initiated = 1;
844 /*---------------------------------------------------------------------------*
845 * FSM state ST_MULTIFR event persistent deactivation
846 *---------------------------------------------------------------------------*/
848 F_MF05(l2_softc_t *l2sc)
850 NDBGL2(L2_F_MSG, "FSM function F_MF05 executing");
852 i4b_Dcleanifq(&l2sc->i_queue);
854 l2sc->postfsmarg = l2sc->unit;
855 l2sc->postfsmfunc = DL_Rel_Ind_A;
861 /*---------------------------------------------------------------------------*
862 * FSM state ST_MULTIFR event mdl remove request
863 *---------------------------------------------------------------------------*/
865 F_MF06(l2_softc_t *l2sc)
867 NDBGL2(L2_F_MSG, "FSM function F_MF06 executing");
869 i4b_Dcleanifq(&l2sc->i_queue);
871 l2sc->postfsmarg = l2sc->unit;
872 l2sc->postfsmfunc = DL_Rel_Ind_A;
877 /*XXX*/ i4b_mdl_assign_ind(l2sc);
880 /*---------------------------------------------------------------------------*
881 * FSM state ST_MULTIFR event rx'd SABME
882 *---------------------------------------------------------------------------*/
884 F_MF07(l2_softc_t *l2sc)
886 NDBGL2(L2_F_MSG, "FSM function F_MF07 executing");
888 i4b_clear_exception_conditions(l2sc);
890 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
892 i4b_tx_ua(l2sc, l2sc->rxd_PF);
894 i4b_mdl_error_ind(l2sc, "F_MF07", MDL_ERR_F);
896 if(l2sc->vs != l2sc->va)
898 i4b_Dcleanifq(&l2sc->i_queue);
900 l2sc->postfsmarg = l2sc->unit;
901 l2sc->postfsmfunc = DL_Est_Ind_A;
905 i4b_T203_start(l2sc);
912 /*---------------------------------------------------------------------------*
913 * FSM state ST_MULTIFR event rx'd DISC
914 *---------------------------------------------------------------------------*/
916 F_MF08(l2_softc_t *l2sc)
918 NDBGL2(L2_F_MSG, "FSM function F_MF08 executing");
920 i4b_Dcleanifq(&l2sc->i_queue);
921 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
922 i4b_tx_ua(l2sc, l2sc->rxd_PF);
924 l2sc->postfsmarg = l2sc->unit;
925 l2sc->postfsmfunc = DL_Rel_Ind_A;
931 /*---------------------------------------------------------------------------*
932 * FSM state ST_MULTIFR event rx'd UA
933 *---------------------------------------------------------------------------*/
935 F_MF09(l2_softc_t *l2sc)
937 NDBGL2(L2_F_MSG, "FSM function F_MF09 executing");
939 i4b_mdl_error_ind(l2sc, "F_MF09", MDL_ERR_C);
941 i4b_mdl_error_ind(l2sc, "F_MF09", MDL_ERR_D);
944 /*---------------------------------------------------------------------------*
945 * FSM state ST_MULTIFR event rx'd DM
946 *---------------------------------------------------------------------------*/
948 F_MF10(l2_softc_t *l2sc)
950 NDBGL2(L2_F_MSG, "FSM function F_MF10 executing");
954 i4b_mdl_error_ind(l2sc, "F_MF10", MDL_ERR_B);
956 l2sc->Q921_state = ST_MULTIFR;
960 i4b_mdl_error_ind(l2sc, "F_MF10", MDL_ERR_E);
962 i4b_establish_data_link(l2sc);
964 l2sc->l3initiated = 0;
966 l2sc->Q921_state = ST_AW_EST;
970 /*---------------------------------------------------------------------------*
971 * FSM state ST_MULTIFR event T200 expiry
972 *---------------------------------------------------------------------------*/
974 F_MF11(l2_softc_t *l2sc)
976 NDBGL2(L2_F_MSG, "FSM function F_MF11 executing");
980 i4b_transmit_enquire(l2sc);
985 /*---------------------------------------------------------------------------*
986 * FSM state ST_MULTIFR event dl data request
987 *---------------------------------------------------------------------------*/
989 F_MF12(l2_softc_t *l2sc)
991 NDBGL2(L2_F_MSG, "FSM function F_MF12 executing");
993 i4b_i_frame_queued_up(l2sc);
996 /*---------------------------------------------------------------------------*
997 * FSM state ST_MULTIFR event dl release request
998 *---------------------------------------------------------------------------*/
1000 F_MF13(l2_softc_t *l2sc)
1002 NDBGL2(L2_F_MSG, "FSM function F_MF13 executing");
1004 i4b_Dcleanifq(&l2sc->i_queue);
1008 i4b_tx_disc(l2sc, P1);
1010 i4b_T203_stop(l2sc);
1011 i4b_T200_restart(l2sc);
1014 /*---------------------------------------------------------------------------*
1015 * FSM state ST_MULTIFR event T203 expiry
1016 *---------------------------------------------------------------------------*/
1018 F_MF14(l2_softc_t *l2sc)
1020 NDBGL2(L2_F_MSG, "FSM function F_MF14 executing");
1022 i4b_transmit_enquire(l2sc);
1027 /*---------------------------------------------------------------------------*
1028 * FSM state ST_MULTIFR event set own rx busy
1029 *---------------------------------------------------------------------------*/
1031 F_MF15(l2_softc_t *l2sc)
1033 NDBGL2(L2_F_MSG, "FSM function F_MF15 executing");
1035 if(l2sc->own_busy == 0)
1039 i4b_tx_rnr_response(l2sc, F0); /* wrong in Q.921 03/93 p 64 */
1045 /*---------------------------------------------------------------------------*
1046 * FSM state ST_MULTIFR event clear own rx busy
1047 *---------------------------------------------------------------------------*/
1049 F_MF16(l2_softc_t *l2sc)
1051 NDBGL2(L2_F_MSG, "FSM function F_MF16 executing");
1053 if(l2sc->own_busy != 0)
1057 i4b_tx_rr_response(l2sc, F0); /* wrong in Q.921 03/93 p 64 */
1063 /*---------------------------------------------------------------------------*
1064 * FSM state ST_MULTIFR event rx'd RR
1065 *---------------------------------------------------------------------------*/
1067 F_MF17(l2_softc_t *l2sc)
1069 NDBGL2(L2_F_MSG, "FSM function F_MF17 executing");
1071 l2sc->peer_busy = 0;
1073 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1075 if(l2sc->rxd_PF == 1)
1077 i4b_enquiry_response(l2sc);
1082 if(l2sc->rxd_PF == 1)
1084 i4b_mdl_error_ind(l2sc, "F_MF17", MDL_ERR_A);
1088 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1090 if(l2sc->rxd_NR == l2sc->vs)
1092 l2sc->va = l2sc->rxd_NR;
1093 i4b_T200_stop(l2sc);
1094 i4b_T203_restart(l2sc);
1096 else if(l2sc->rxd_NR != l2sc->va)
1098 l2sc->va = l2sc->rxd_NR;
1099 i4b_T200_restart(l2sc);
1101 l2sc->Q921_state = ST_MULTIFR;
1105 i4b_nr_error_recovery(l2sc);
1106 l2sc->Q921_state = ST_AW_EST;
1110 /*---------------------------------------------------------------------------*
1111 * FSM state ST_MULTIFR event rx'd REJ
1112 *---------------------------------------------------------------------------*/
1114 F_MF18(l2_softc_t *l2sc)
1116 NDBGL2(L2_F_MSG, "FSM function F_MF18 executing");
1118 l2sc->peer_busy = 0;
1120 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1122 if(l2sc->rxd_PF == 1)
1124 i4b_enquiry_response(l2sc);
1129 if(l2sc->rxd_PF == 1)
1131 i4b_mdl_error_ind(l2sc, "F_MF18", MDL_ERR_A);
1135 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1137 l2sc->va = l2sc->rxd_NR;
1138 i4b_T200_stop(l2sc);
1139 i4b_T203_start(l2sc);
1140 i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
1141 l2sc->Q921_state = ST_MULTIFR;
1145 i4b_nr_error_recovery(l2sc);
1146 l2sc->Q921_state = ST_AW_EST;
1150 /*---------------------------------------------------------------------------*
1151 * FSM state ST_MULTIFR event rx'd RNR
1152 *---------------------------------------------------------------------------*/
1154 F_MF19(l2_softc_t *l2sc)
1156 NDBGL2(L2_F_MSG, "FSM function F_MF19 executing");
1158 l2sc->peer_busy = 1;
1160 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1162 if(l2sc->rxd_PF == 1)
1164 i4b_enquiry_response(l2sc);
1169 if(l2sc->rxd_PF == 1)
1171 i4b_mdl_error_ind(l2sc, "F_MF19", MDL_ERR_A);
1175 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1177 l2sc->va = l2sc->rxd_NR;
1178 i4b_T203_stop(l2sc);
1179 i4b_T200_restart(l2sc);
1180 l2sc->Q921_state = ST_MULTIFR;
1184 i4b_nr_error_recovery(l2sc);
1185 l2sc->Q921_state = ST_AW_EST;
1189 /*---------------------------------------------------------------------------*
1190 * FSM state ST_MULTIFR event rx'd FRMR
1191 *---------------------------------------------------------------------------*/
1193 F_MF20(l2_softc_t *l2sc)
1195 NDBGL2(L2_F_MSG, "FSM function F_MF20 executing");
1197 i4b_mdl_error_ind(l2sc, "F_MF20", MDL_ERR_K);
1199 i4b_establish_data_link(l2sc);
1201 l2sc->l3initiated = 0;
1204 /*---------------------------------------------------------------------------*
1205 * FSM state ST_TIMREC event dl establish request
1206 *---------------------------------------------------------------------------*/
1208 F_TR01(l2_softc_t *l2sc)
1210 NDBGL2(L2_F_MSG, "FSM function F_TR01 executing");
1212 i4b_Dcleanifq(&l2sc->i_queue);
1214 i4b_establish_data_link(l2sc);
1216 l2sc->l3initiated = 1;
1219 /*---------------------------------------------------------------------------*
1220 * FSM state ST_TIMREC event persistent deactivation
1221 *---------------------------------------------------------------------------*/
1223 F_TR05(l2_softc_t *l2sc)
1225 NDBGL2(L2_F_MSG, "FSM function F_TR05 executing");
1227 i4b_Dcleanifq(&l2sc->i_queue);
1229 l2sc->postfsmarg = l2sc->unit;
1230 l2sc->postfsmfunc = DL_Rel_Ind_A;
1232 i4b_T200_stop(l2sc);
1235 /*---------------------------------------------------------------------------*
1236 * FSM state ST_TIMREC event mdl remove request
1237 *---------------------------------------------------------------------------*/
1239 F_TR06(l2_softc_t *l2sc)
1241 NDBGL2(L2_F_MSG, "FSM function F_TR06 executing");
1243 i4b_Dcleanifq(&l2sc->i_queue);
1245 l2sc->postfsmarg = l2sc->unit;
1246 l2sc->postfsmfunc = DL_Rel_Ind_A;
1248 i4b_T200_stop(l2sc);
1250 /*XXX*/ i4b_mdl_assign_ind(l2sc);
1253 /*---------------------------------------------------------------------------*
1254 * FSM state ST_TIMREC event rx'd SABME
1255 *---------------------------------------------------------------------------*/
1257 F_TR07(l2_softc_t *l2sc)
1259 NDBGL2(L2_F_MSG, "FSM function F_TR07 executing");
1261 i4b_clear_exception_conditions(l2sc);
1263 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_ACTIVE);
1265 i4b_tx_ua(l2sc, l2sc->rxd_PF);
1267 i4b_mdl_error_ind(l2sc, "F_TR07", MDL_ERR_F);
1269 if(l2sc->vs != l2sc->va)
1271 i4b_Dcleanifq(&l2sc->i_queue);
1273 l2sc->postfsmarg = l2sc->unit;
1274 l2sc->postfsmfunc = DL_Est_Ind_A;
1277 i4b_T200_stop(l2sc);
1278 i4b_T203_start(l2sc);
1285 /*---------------------------------------------------------------------------*
1286 * FSM state ST_TIMREC event rx'd DISC
1287 *---------------------------------------------------------------------------*/
1289 F_TR08(l2_softc_t *l2sc)
1291 NDBGL2(L2_F_MSG, "FSM function F_TR08 executing");
1293 i4b_Dcleanifq(&l2sc->i_queue);
1294 MDL_Status_Ind(l2sc->unit, STI_L2STAT, LAYER_IDLE);
1295 i4b_tx_ua(l2sc, l2sc->rxd_PF);
1297 l2sc->postfsmarg = l2sc->unit;
1298 l2sc->postfsmfunc = DL_Rel_Ind_A;
1300 i4b_T200_stop(l2sc);
1303 /*---------------------------------------------------------------------------*
1304 * FSM state ST_TIMREC event rx'd UA
1305 *---------------------------------------------------------------------------*/
1307 F_TR09(l2_softc_t *l2sc)
1309 NDBGL2(L2_F_MSG, "FSM function F_TR09 executing");
1311 i4b_mdl_error_ind(l2sc, "F_TR09", MDL_ERR_C);
1313 i4b_mdl_error_ind(l2sc, "F_TR09", MDL_ERR_D);
1316 /*---------------------------------------------------------------------------*
1317 * FSM state ST_TIMREC event rx'd DM
1318 *---------------------------------------------------------------------------*/
1320 F_TR10(l2_softc_t *l2sc)
1322 NDBGL2(L2_F_MSG, "FSM function F_TR10 executing");
1326 i4b_mdl_error_ind(l2sc, "F_TR10", MDL_ERR_B);
1330 i4b_mdl_error_ind(l2sc, "F_TR10", MDL_ERR_E);
1333 i4b_establish_data_link(l2sc);
1335 l2sc->l3initiated = 0;
1338 /*---------------------------------------------------------------------------*
1339 * FSM state ST_TIMREC event T200 expiry
1340 *---------------------------------------------------------------------------*/
1342 F_TR11(l2_softc_t *l2sc)
1344 NDBGL2(L2_F_MSG, "FSM function F_TR11 executing");
1346 if(l2sc->RC >= N200)
1348 i4b_mdl_error_ind(l2sc, "F_TR11", MDL_ERR_I);
1350 i4b_establish_data_link(l2sc);
1352 l2sc->l3initiated = 0;
1354 l2sc->Q921_state = ST_AW_EST;
1358 i4b_transmit_enquire(l2sc);
1362 l2sc->Q921_state = ST_TIMREC;
1366 /*---------------------------------------------------------------------------*
1367 * FSM state ST_TIMREC event dl data request
1368 *---------------------------------------------------------------------------*/
1370 F_TR12(l2_softc_t *l2sc)
1372 NDBGL2(L2_F_MSG, "FSM function F_TR12 executing");
1374 i4b_i_frame_queued_up(l2sc);
1377 /*---------------------------------------------------------------------------*
1378 * FSM state ST_TIMREC event dl release request
1379 *---------------------------------------------------------------------------*/
1381 F_TR13(l2_softc_t *l2sc)
1383 NDBGL2(L2_F_MSG, "FSM function F_TR13 executing");
1385 i4b_Dcleanifq(&l2sc->i_queue);
1389 i4b_tx_disc(l2sc, P1);
1391 i4b_T200_restart(l2sc);
1394 /*---------------------------------------------------------------------------*
1395 * FSM state ST_TIMREC event set own rx busy
1396 *---------------------------------------------------------------------------*/
1398 F_TR15(l2_softc_t *l2sc)
1400 NDBGL2(L2_F_MSG, "FSM function F_TR15 executing");
1402 if(l2sc->own_busy == 0)
1406 i4b_tx_rnr_response(l2sc, F0);
1412 /*---------------------------------------------------------------------------*
1413 * FSM state ST_TIMREC event clear own rx busy
1414 *---------------------------------------------------------------------------*/
1416 F_TR16(l2_softc_t *l2sc)
1418 NDBGL2(L2_F_MSG, "FSM function F_TR16 executing");
1420 if(l2sc->own_busy != 0)
1424 i4b_tx_rr_response(l2sc, F0); /* this is wrong */
1425 /* in Q.921 03/93 p 74 ! */
1430 /*---------------------------------------------------------------------------*
1431 * FSM state ST_TIMREC event rx'd RR
1432 *---------------------------------------------------------------------------*/
1434 F_TR17(l2_softc_t *l2sc)
1436 NDBGL2(L2_F_MSG, "FSM function F_TR17 executing");
1438 l2sc->peer_busy = 0;
1440 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1442 if(l2sc->rxd_PF == 1)
1444 i4b_enquiry_response(l2sc);
1449 if(l2sc->rxd_PF == 1)
1451 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1453 l2sc->va = l2sc->rxd_NR;
1454 i4b_T200_stop(l2sc);
1455 i4b_T203_start(l2sc);
1456 i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
1457 l2sc->Q921_state = ST_MULTIFR;
1462 i4b_nr_error_recovery(l2sc);
1463 l2sc->Q921_state = ST_AW_EST;
1469 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1471 l2sc->va = l2sc->rxd_NR;
1472 l2sc->Q921_state = ST_TIMREC;
1476 i4b_nr_error_recovery(l2sc);
1477 l2sc->Q921_state = ST_AW_EST;
1481 /*---------------------------------------------------------------------------*
1482 * FSM state ST_TIMREC event
1483 *---------------------------------------------------------------------------*/
1485 F_TR18(l2_softc_t *l2sc)
1487 NDBGL2(L2_F_MSG, "FSM function F_TR18 executing");
1489 l2sc->peer_busy = 0;
1491 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1493 if(l2sc->rxd_PF == 1)
1495 i4b_enquiry_response(l2sc);
1500 if(l2sc->rxd_PF == 1)
1502 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1504 l2sc->va = l2sc->rxd_NR;
1505 i4b_T200_stop(l2sc);
1506 i4b_T203_start(l2sc);
1507 i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
1508 l2sc->Q921_state = ST_MULTIFR;
1513 i4b_nr_error_recovery(l2sc);
1514 l2sc->Q921_state = ST_AW_EST;
1520 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1522 l2sc->va = l2sc->rxd_NR;
1523 l2sc->Q921_state = ST_TIMREC;
1527 i4b_nr_error_recovery(l2sc);
1528 l2sc->Q921_state = ST_AW_EST;
1532 /*---------------------------------------------------------------------------*
1533 * FSM state ST_TIMREC event rx'd RNR
1534 *---------------------------------------------------------------------------*/
1536 F_TR19(l2_softc_t *l2sc)
1538 NDBGL2(L2_F_MSG, "FSM function F_TR19 executing");
1540 l2sc->peer_busy = 0;
1542 if(l2sc->rxd_CR == CR_CMD_FROM_NT)
1544 if(l2sc->rxd_PF == 1)
1546 i4b_enquiry_response(l2sc);
1551 if(l2sc->rxd_PF == 1)
1553 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1555 l2sc->va = l2sc->rxd_NR;
1556 i4b_T200_restart(l2sc);
1557 i4b_invoke_retransmission(l2sc, l2sc->rxd_NR);
1558 l2sc->Q921_state = ST_MULTIFR;
1563 i4b_nr_error_recovery(l2sc);
1564 l2sc->Q921_state = ST_AW_EST;
1570 if(i4b_l2_nr_ok(l2sc->rxd_NR, l2sc->va, l2sc->vs))
1572 l2sc->va = l2sc->rxd_NR;
1573 l2sc->Q921_state = ST_TIMREC;
1577 i4b_nr_error_recovery(l2sc);
1578 l2sc->Q921_state = ST_AW_EST;
1582 /*---------------------------------------------------------------------------*
1583 * FSM state ST_TIMREC event rx'd FRMR
1584 *---------------------------------------------------------------------------*/
1586 F_TR20(l2_softc_t *l2sc)
1588 NDBGL2(L2_F_MSG, "FSM function F_TR20 executing");
1590 i4b_mdl_error_ind(l2sc, "F_TR20", MDL_ERR_K);
1592 i4b_establish_data_link(l2sc);
1594 l2sc->l3initiated = 0;
1597 #endif /* NI4BQ921 > 0 */