2 * Copyright (c) 1997, 1999 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_l2timer.c - layer 2 timer handling
28 * --------------------------------------
30 * $Id: i4b_l2timer.c,v 1.17 1999/12/13 21:25:27 hm Exp $
34 * last edit-date: [Mon Dec 13 22:03:56 1999]
36 *---------------------------------------------------------------------------*/
45 #include <sys/param.h>
47 #if defined(__FreeBSD__)
49 #include <sys/ioctl.h>
51 #include <sys/kernel.h>
52 #include <sys/systm.h>
54 #include <sys/socket.h>
58 #include <machine/i4b_debug.h>
59 #include <machine/i4b_ioctl.h>
61 #include <i4b/i4b_debug.h>
62 #include <i4b/i4b_ioctl.h>
65 #include <i4b/include/i4b_global.h>
66 #include <i4b/include/i4b_l1l2.h>
67 #include <i4b/include/i4b_l2l3.h>
68 #include <i4b/include/i4b_isdnq931.h>
69 #include <i4b/include/i4b_mbuf.h>
71 #include <i4b/layer2/i4b_l2.h>
72 #include <i4b/layer2/i4b_l2fsm.h>
74 /*---------------------------------------------------------------------------*
75 * Q.921 timer T200 timeout function
76 *---------------------------------------------------------------------------*/
78 i4b_T200_timeout(l2_softc_t *l2sc)
80 DBGL2(L2_T_ERR, "i4b_T200_timeout", ("unit %d, RC = %d\n", l2sc->unit, l2sc->RC));
81 i4b_next_l2state(l2sc, EV_T200EXP);
84 /*---------------------------------------------------------------------------*
85 * Q.921 timer T200 start
86 *---------------------------------------------------------------------------*/
88 i4b_T200_start(l2_softc_t *l2sc)
90 if(l2sc->T200 == TIMER_ACTIVE)
93 DBGL2(L2_T_MSG, "i4b_T200_start", ("unit %d\n", l2sc->unit));
94 l2sc->T200 = TIMER_ACTIVE;
96 #if defined(__FreeBSD__)
97 l2sc->T200_callout = timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF);
99 timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF);
103 /*---------------------------------------------------------------------------*
104 * Q.921 timer T200 stop
105 *---------------------------------------------------------------------------*/
107 i4b_T200_stop(l2_softc_t *l2sc)
111 if(l2sc->T200 != TIMER_IDLE)
113 #if defined(__FreeBSD__)
114 untimeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, l2sc->T200_callout);
116 untimeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc);
118 l2sc->T200 = TIMER_IDLE;
121 DBGL2(L2_T_MSG, "i4b_T200_stop", ("unit %d\n", l2sc->unit));
124 /*---------------------------------------------------------------------------*
125 * Q.921 timer T200 restart
126 *---------------------------------------------------------------------------*/
128 i4b_T200_restart(l2_softc_t *l2sc)
132 if(l2sc->T200 != TIMER_IDLE)
134 #if defined(__FreeBSD__)
135 untimeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, l2sc->T200_callout);
137 untimeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc);
142 l2sc->T200 = TIMER_ACTIVE;
145 #if defined(__FreeBSD__)
146 l2sc->T200_callout = timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF);
148 timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF);
151 DBGL2(L2_T_MSG, "i4b_T200_restart", ("unit %d\n", l2sc->unit));
154 /*---------------------------------------------------------------------------*
155 * Q.921 timer T202 timeout function
156 *---------------------------------------------------------------------------*/
158 i4b_T202_timeout(l2_softc_t *l2sc)
160 DBGL2(L2_T_ERR, "i4b_T202_timeout", ("unit %d, N202 = %d\n", l2sc->unit, l2sc->N202));
164 (*l2sc->T202func)(l2sc);
168 /*---------------------------------------------------------------------------*
169 * Q.921 timer T202 start
170 *---------------------------------------------------------------------------*/
172 i4b_T202_start(l2_softc_t *l2sc)
174 if (l2sc->N202 == TIMER_ACTIVE)
177 DBGL2(L2_T_MSG, "i4b_T202_start", ("unit %d\n", l2sc->unit));
178 l2sc->N202 = N202DEF;
179 l2sc->T202 = TIMER_ACTIVE;
181 #if defined(__FreeBSD__)
182 l2sc->T202_callout = timeout((TIMEOUT_FUNC_T)i4b_T202_timeout, (void *)l2sc, T202DEF);
184 timeout((TIMEOUT_FUNC_T)i4b_T202_timeout, (void *)l2sc, T202DEF);
188 /*---------------------------------------------------------------------------*
189 * Q.921 timer T202 stop
190 *---------------------------------------------------------------------------*/
192 i4b_T202_stop(l2_softc_t *l2sc)
196 if(l2sc->T202 != TIMER_IDLE)
198 #if defined(__FreeBSD__)
199 untimeout((TIMEOUT_FUNC_T)i4b_T202_timeout, (void *)l2sc, l2sc->T202_callout);
201 untimeout((TIMEOUT_FUNC_T)i4b_T202_timeout, (void *)l2sc);
203 l2sc->T202 = TIMER_IDLE;
206 DBGL2(L2_T_MSG, "i4b_T202_stop", ("unit %d\n", l2sc->unit));
209 /*---------------------------------------------------------------------------*
210 * Q.921 timer T203 timeout function
211 *---------------------------------------------------------------------------*/
214 i4b_T203_timeout(l2_softc_t *l2sc)
216 DBGL2(L2_T_ERR, "i4b_T203_timeout", ("unit %d\n", l2sc->unit));
217 i4b_next_l2state(l2sc, EV_T203EXP);
221 /*---------------------------------------------------------------------------*
222 * Q.921 timer T203 start
223 *---------------------------------------------------------------------------*/
225 i4b_T203_start(l2_softc_t *l2sc)
228 if (l2sc->T203 == TIMER_ACTIVE)
231 DBGL2(L2_T_MSG, "i4b_T203_start", ("unit %d\n", l2sc->unit));
232 l2sc->T203 = TIMER_ACTIVE;
234 #if defined(__FreeBSD__)
235 l2sc->T203_callout = timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF);
237 timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF);
242 /*---------------------------------------------------------------------------*
243 * Q.921 timer T203 stop
244 *---------------------------------------------------------------------------*/
246 i4b_T203_stop(l2_softc_t *l2sc)
251 if(l2sc->T203 != TIMER_IDLE)
253 #if defined(__FreeBSD__)
254 untimeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, l2sc->T203_callout);
256 untimeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc);
258 l2sc->T203 = TIMER_IDLE;
261 DBGL2(L2_T_MSG, "i4b_T203_stop", ("unit %d\n", l2sc->unit));
265 /*---------------------------------------------------------------------------*
266 * Q.921 timer T203 restart
267 *---------------------------------------------------------------------------*/
269 i4b_T203_restart(l2_softc_t *l2sc)
275 if(l2sc->T203 != TIMER_IDLE)
277 #if defined(__FreeBSD__)
278 untimeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, l2sc->T203_callout);
280 untimeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc);
285 l2sc->T203 = TIMER_ACTIVE;
288 #if defined(__FreeBSD__)
289 l2sc->T203_callout = timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF);
291 timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF);
294 DBGL2(L2_T_MSG, "i4b_T203_restart", ("unit %d\n", l2sc->unit));
298 #endif /* NI4BQ921 > 0 */