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 * --------------------------------------
32 * last edit-date: [Wed Apr 21 09:17:58 1999]
34 *---------------------------------------------------------------------------*/
43 #include <sys/param.h>
44 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
45 #include <sys/ioccom.h>
47 #include <sys/ioctl.h>
49 #include <sys/kernel.h>
50 #include <sys/systm.h>
52 #include <sys/socket.h>
56 #include <machine/i4b_debug.h>
57 #include <machine/i4b_ioctl.h>
59 #include <i4b/i4b_debug.h>
60 #include <i4b/i4b_ioctl.h>
63 #include <i4b/include/i4b_global.h>
64 #include <i4b/include/i4b_l1l2.h>
65 #include <i4b/include/i4b_l2l3.h>
66 #include <i4b/include/i4b_isdnq931.h>
67 #include <i4b/include/i4b_mbuf.h>
69 #include <i4b/layer2/i4b_l2.h>
70 #include <i4b/layer2/i4b_l2fsm.h>
72 /*---------------------------------------------------------------------------*
73 * Q.921 timer T200 timeout function
74 *---------------------------------------------------------------------------*/
76 i4b_T200_timeout(l2_softc_t *l2sc)
78 DBGL2(L2_T_ERR, "i4b_T200_timeout", ("unit %d, RC = %d\n", l2sc->unit, l2sc->RC));
79 i4b_next_l2state(l2sc, EV_T200EXP);
82 /*---------------------------------------------------------------------------*
83 * Q.921 timer T200 start
84 *---------------------------------------------------------------------------*/
86 i4b_T200_start(l2_softc_t *l2sc)
88 if(l2sc->T200 == TIMER_ACTIVE)
91 DBGL2(L2_T_MSG, "i4b_T200_start", ("unit %d\n", l2sc->unit));
92 l2sc->T200 = TIMER_ACTIVE;
94 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
95 l2sc->T200_callout = timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF);
97 timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF);
101 /*---------------------------------------------------------------------------*
102 * Q.921 timer T200 stop
103 *---------------------------------------------------------------------------*/
105 i4b_T200_stop(l2_softc_t *l2sc)
109 if(l2sc->T200 != TIMER_IDLE)
111 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
112 untimeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, l2sc->T200_callout);
114 untimeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc);
116 l2sc->T200 = TIMER_IDLE;
119 DBGL2(L2_T_MSG, "i4b_T200_stop", ("unit %d\n", l2sc->unit));
122 /*---------------------------------------------------------------------------*
123 * Q.921 timer T200 restart
124 *---------------------------------------------------------------------------*/
126 i4b_T200_restart(l2_softc_t *l2sc)
130 if(l2sc->T200 != TIMER_IDLE)
132 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
133 untimeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, l2sc->T200_callout);
135 untimeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc);
140 l2sc->T200 = TIMER_ACTIVE;
143 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
144 l2sc->T200_callout = timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF);
146 timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF);
149 DBGL2(L2_T_MSG, "i4b_T200_restart", ("unit %d\n", l2sc->unit));
152 /*---------------------------------------------------------------------------*
153 * Q.921 timer T202 timeout function
154 *---------------------------------------------------------------------------*/
156 i4b_T202_timeout(l2_softc_t *l2sc)
158 DBGL2(L2_T_ERR, "i4b_T202_timeout", ("unit %d, N202 = %d\n", l2sc->unit, l2sc->N202));
162 (*l2sc->T202func)(l2sc);
166 /*---------------------------------------------------------------------------*
167 * Q.921 timer T202 start
168 *---------------------------------------------------------------------------*/
170 i4b_T202_start(l2_softc_t *l2sc)
172 if (l2sc->N202 == TIMER_ACTIVE)
175 DBGL2(L2_T_MSG, "i4b_T202_start", ("unit %d\n", l2sc->unit));
176 l2sc->N202 = N202DEF;
177 l2sc->T202 = TIMER_ACTIVE;
179 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
180 l2sc->T202_callout = timeout((TIMEOUT_FUNC_T)i4b_T202_timeout, (void *)l2sc, T202DEF);
182 timeout((TIMEOUT_FUNC_T)i4b_T202_timeout, (void *)l2sc, T202DEF);
186 /*---------------------------------------------------------------------------*
187 * Q.921 timer T202 stop
188 *---------------------------------------------------------------------------*/
190 i4b_T202_stop(l2_softc_t *l2sc)
194 if(l2sc->T202 != TIMER_IDLE)
196 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
197 untimeout((TIMEOUT_FUNC_T)i4b_T202_timeout, (void *)l2sc, l2sc->T202_callout);
199 untimeout((TIMEOUT_FUNC_T)i4b_T202_timeout, (void *)l2sc);
201 l2sc->T202 = TIMER_IDLE;
204 DBGL2(L2_T_MSG, "i4b_T202_stop", ("unit %d\n", l2sc->unit));
207 /*---------------------------------------------------------------------------*
208 * Q.921 timer T203 timeout function
209 *---------------------------------------------------------------------------*/
212 i4b_T203_timeout(l2_softc_t *l2sc)
214 DBGL2(L2_T_ERR, "i4b_T203_timeout", ("unit %d\n", l2sc->unit));
215 i4b_next_l2state(l2sc, EV_T203EXP);
219 /*---------------------------------------------------------------------------*
220 * Q.921 timer T203 start
221 *---------------------------------------------------------------------------*/
223 i4b_T203_start(l2_softc_t *l2sc)
226 if (l2sc->T203 == TIMER_ACTIVE)
229 DBGL2(L2_T_MSG, "i4b_T203_start", ("unit %d\n", l2sc->unit));
230 l2sc->T203 = TIMER_ACTIVE;
232 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
233 l2sc->T203_callout = timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF);
235 timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF);
240 /*---------------------------------------------------------------------------*
241 * Q.921 timer T203 stop
242 *---------------------------------------------------------------------------*/
244 i4b_T203_stop(l2_softc_t *l2sc)
249 if(l2sc->T203 != TIMER_IDLE)
251 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
252 untimeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, l2sc->T203_callout);
254 untimeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc);
256 l2sc->T203 = TIMER_IDLE;
259 DBGL2(L2_T_MSG, "i4b_T203_stop", ("unit %d\n", l2sc->unit));
263 /*---------------------------------------------------------------------------*
264 * Q.921 timer T203 restart
265 *---------------------------------------------------------------------------*/
267 i4b_T203_restart(l2_softc_t *l2sc)
273 if(l2sc->T203 != TIMER_IDLE)
275 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
276 untimeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, l2sc->T203_callout);
278 untimeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc);
283 l2sc->T203 = TIMER_ACTIVE;
286 #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
287 l2sc->T203_callout = timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF);
289 timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF);
292 DBGL2(L2_T_MSG, "i4b_T203_restart", ("unit %d\n", l2sc->unit));
296 #endif /* NI4BQ921 > 0 */