diff options
author | hm <hm@FreeBSD.org> | 1999-05-20 10:14:57 +0000 |
---|---|---|
committer | hm <hm@FreeBSD.org> | 1999-05-20 10:14:57 +0000 |
commit | 2077acfca034178f39e3fa4e86cb8d371f44737c (patch) | |
tree | 730187a2063473cb0d2e7cac998a9a4307285426 /sys/i4b/layer2 | |
parent | 5ea75aea8a2633cc0acf9dd870c1e1db1abd6a21 (diff) | |
download | FreeBSD-src-2077acfca034178f39e3fa4e86cb8d371f44737c.zip FreeBSD-src-2077acfca034178f39e3fa4e86cb8d371f44737c.tar.gz |
upgrade isdn4bsd from version 0.71 to the just released version 0.81
Diffstat (limited to 'sys/i4b/layer2')
-rw-r--r-- | sys/i4b/layer2/i4b_iframe.c | 64 | ||||
-rw-r--r-- | sys/i4b/layer2/i4b_l2.c | 27 | ||||
-rw-r--r-- | sys/i4b/layer2/i4b_l2.h | 13 | ||||
-rw-r--r-- | sys/i4b/layer2/i4b_l2fsm.c | 9 | ||||
-rw-r--r-- | sys/i4b/layer2/i4b_l2timer.c | 45 | ||||
-rw-r--r-- | sys/i4b/layer2/i4b_util.c | 39 |
6 files changed, 140 insertions, 57 deletions
diff --git a/sys/i4b/layer2/i4b_iframe.c b/sys/i4b/layer2/i4b_iframe.c index 887f828..3a37d04 100644 --- a/sys/i4b/layer2/i4b_iframe.c +++ b/sys/i4b/layer2/i4b_iframe.c @@ -27,9 +27,9 @@ * i4b_iframe.c - i frame handling routines * ------------------------------------------ * - * $Id: i4b_iframe.c,v 1.16 1999/02/14 09:45:00 hm Exp $ + * $Id: i4b_iframe.c,v 1.19 1999/04/21 07:36:32 hm Exp $ * - * last edit-date: [Sun Feb 14 10:31:19 1999] + * last edit-date: [Wed Apr 21 09:24:34 1999] * *---------------------------------------------------------------------------*/ @@ -73,7 +73,7 @@ /*---------------------------------------------------------------------------* * process i frame - * implements the routine "I COMMAND" Q.921 03/93 pp 77 + * implements the routine "I COMMAND" Q.921 03/93 pp 68 and pp 77 *---------------------------------------------------------------------------*/ void i4b_rxd_i_frame(int unit, struct mbuf *m) @@ -83,7 +83,7 @@ i4b_rxd_i_frame(int unit, struct mbuf *m) int nr; int ns; int p; - int x; + CRIT_VAR; if(!((l2sc->tei_valid == TEI_VALID) && (l2sc->tei == GETTEI(*(ptr+OFF_TEI))))) @@ -99,7 +99,7 @@ i4b_rxd_i_frame(int unit, struct mbuf *m) return; } - x = SPLI4B(); + CRIT_BEG; nr = GETINR(*(ptr + OFF_INR)); ns = GETINS(*(ptr + OFF_INS)); @@ -165,7 +165,9 @@ i4b_rxd_i_frame(int unit, struct mbuf *m) if(l2sc->Q921_state == ST_TIMREC) { l2sc->va = nr; - splx(x); + + CRIT_END; + return; } @@ -196,7 +198,8 @@ i4b_rxd_i_frame(int unit, struct mbuf *m) i4b_nr_error_recovery(l2sc); /* sequence error */ l2sc->Q921_state = ST_AW_EST; } - splx(x); + + CRIT_END; } /*---------------------------------------------------------------------------* @@ -205,26 +208,39 @@ i4b_rxd_i_frame(int unit, struct mbuf *m) void i4b_i_frame_queued_up(l2_softc_t *l2sc) { - int x; struct mbuf *m; u_char *ptr; + CRIT_VAR; - x = SPLI4B(); - - if(l2sc->peer_busy) + CRIT_BEG; + + if((l2sc->peer_busy) || (l2sc->vs == ((l2sc->va + MAX_K_VALUE) & 127))) { - DBGL2(L2_I_MSG, "i4b_i_frame_queued_up", ("peer busy!\n")); - i4b_print_l2var(l2sc); - splx(x); - return; - } + if(l2sc->peer_busy) + { + DBGL2(L2_I_MSG, "i4b_i_frame_queued_up", ("regen IFQUP, cause: peer busy!\n")); + } - if(l2sc->vs == ((l2sc->va + MAX_K_VALUE) & 127)) - { - DBGL2(L2_I_ERR, "i4b_i_frame_queued_up", ("V(S) == ((V(A) + k) & 127)!\n")); - DBGL2(L2_I_ERR, "i4b_i_frame_queued_up", ("state = %s\n", i4b_print_l2state(l2sc))); - i4b_print_l2var(l2sc); - splx(x); + if(l2sc->vs == ((l2sc->va + MAX_K_VALUE) & 127)) + { + DBGL2(L2_I_MSG, "i4b_i_frame_queued_up", ("regen IFQUP, cause: vs=va+k!\n")); + } + + /* + * XXX see: Q.921, page 36, 5.6.1 ".. may retransmit an I + * frame ...", shall we retransmit the last i frame ? + */ + + if(!(IF_QEMPTY(&l2sc->i_queue))) + { + DBGL2(L2_I_MSG, "i4b_i_frame_queued_up", ("re-scheduling IFQU call!\n")); +#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 + l2sc->IFQU_callout = timeout((TIMEOUT_FUNC_T)i4b_i_frame_queued_up, (void *)l2sc, IFQU_DLY); +#else + timeout((TIMEOUT_FUNC_T)i4b_i_frame_queued_up, (void *)l2sc, IFQU_DLY); +#endif + } + CRIT_END; return; } @@ -233,7 +249,7 @@ i4b_i_frame_queued_up(l2_softc_t *l2sc) if(!m) { DBGL2(L2_I_ERR, "i4b_i_frame_queued_up", ("ERROR, mbuf NULL after IF_DEQUEUE\n")); - splx(x); + CRIT_END; return; } @@ -263,7 +279,7 @@ i4b_i_frame_queued_up(l2_softc_t *l2sc) l2sc->ack_pend = 0; - splx(x); + CRIT_END; if(l2sc->T200 == TIMER_IDLE) { diff --git a/sys/i4b/layer2/i4b_l2.c b/sys/i4b/layer2/i4b_l2.c index 875fabb..80072bb 100644 --- a/sys/i4b/layer2/i4b_l2.c +++ b/sys/i4b/layer2/i4b_l2.c @@ -27,9 +27,9 @@ * i4b_l2.c - ISDN layer 2 (Q.921) * ------------------------------- * - * $Id: i4b_l2.c,v 1.24 1999/02/14 09:45:00 hm Exp $ + * $Id: i4b_l2.c,v 1.26 1999/04/15 09:53:55 hm Exp $ * - * last edit-date: [Sun Feb 14 10:31:25 1999] + * last edit-date: [Thu Apr 15 11:32:11 1999] * *---------------------------------------------------------------------------*/ @@ -156,7 +156,7 @@ int i4b_dl_unit_data_req(int unit, struct mbuf *m) int i4b_dl_data_req(int unit, struct mbuf *m) { l2_softc_t *l2sc = &l2_softc[unit]; - int x; + #ifdef NOTDEF DBGL2(L2_PRIM, "DL-DATA-REQ", ("unit %d\n",unit)); #endif @@ -173,9 +173,12 @@ int i4b_dl_data_req(int unit, struct mbuf *m) } else { - x = splimp(); + CRIT_VAR; + + CRIT_BEG; IF_ENQUEUE(&l2sc->i_queue, m); - splx(x); + CRIT_END; + i4b_i_frame_queued_up(l2sc); } break; @@ -222,7 +225,9 @@ static void i4b_l2_unit_init(int unit) { l2_softc_t *l2sc = &l2_softc[unit]; + CRIT_VAR; + CRIT_BEG; l2sc->Q921_state = ST_TEI_UNAS; l2sc->tei_valid = TEI_INVALID; l2sc->vr = 0; @@ -251,7 +256,9 @@ i4b_l2_unit_init(int unit) i4b_T200_stop(l2sc); i4b_T202_stop(l2sc); - i4b_T203_stop(l2sc); + i4b_T203_stop(l2sc); + + CRIT_END; } /*---------------------------------------------------------------------------* @@ -261,9 +268,10 @@ int i4b_mph_status_ind(int unit, int status, int parm) { l2_softc_t *l2sc = &l2_softc[unit]; + CRIT_VAR; int sendup = 1; - - int x = SPLI4B(); + + CRIT_BEG; DBGL1(L1_PRIM, "MPH-STATUS-IND", ("unit %d, status=%d, parm=%d\n", unit, status, parm)); @@ -280,6 +288,7 @@ i4b_mph_status_ind(int unit, int status, int parm) callout_handle_init(&l2sc->T200_callout); callout_handle_init(&l2sc->T202_callout); callout_handle_init(&l2sc->T203_callout); + callout_handle_init(&l2sc->IFQU_callout); #endif break; @@ -312,7 +321,7 @@ i4b_mph_status_ind(int unit, int status, int parm) if(sendup) MDL_Status_Ind(unit, status, parm); /* send up to layer 3 */ - splx(x); + CRIT_END; return(0); } diff --git a/sys/i4b/layer2/i4b_l2.h b/sys/i4b/layer2/i4b_l2.h index dd63f43..c829a07 100644 --- a/sys/i4b/layer2/i4b_l2.h +++ b/sys/i4b/layer2/i4b_l2.h @@ -27,9 +27,9 @@ * i4b_l2.h - ISDN layer 2 (Q.921) definitions * --------------------------------------------- * - * $Id: i4b_l2.h,v 1.15 1999/02/14 09:45:00 hm Exp $ + * $Id: i4b_l2.h,v 1.17 1999/04/22 11:51:45 hm Exp $ * - * last edit-date: [Sun Feb 14 10:31:31 1999] + * last edit-date: [Thu Apr 22 13:50:55 1999] * *---------------------------------------------------------------------------*/ @@ -65,8 +65,17 @@ typedef struct { struct callout_handle T200_callout; struct callout_handle T202_callout; struct callout_handle T203_callout; + struct callout_handle IFQU_callout; #endif +/* + * i4b_iframe.c, i4b_i_frame_queued_up(): value of IFQU_DLY + * some experimentation Gary did showed a minimal value of (hz/20) was + * possible to let this work, Gary suggested using (hz/10) but i settled + * down to using (hz/5) for now (-hm). + */ +#define IFQU_DLY (hz/5) /* reschedule I-FRAME-QUEUED-UP 0.2 sec */ + int vr; /* receive sequence frame counter */ int vs; /* transmit sequence frame counter */ int va; /* acknowledge sequence frame counter */ diff --git a/sys/i4b/layer2/i4b_l2fsm.c b/sys/i4b/layer2/i4b_l2fsm.c index dbbe0ca..ea04662 100644 --- a/sys/i4b/layer2/i4b_l2fsm.c +++ b/sys/i4b/layer2/i4b_l2fsm.c @@ -27,9 +27,9 @@ * i4b_l2fsm.c - layer 2 FSM * ------------------------- * - * $Id: i4b_l2fsm.c,v 1.14 1999/02/14 09:45:00 hm Exp $ + * $Id: i4b_l2fsm.c,v 1.15 1999/03/16 15:29:06 hm Exp $ * - * last edit-date: [Sun Feb 14 10:31:37 1999] + * last edit-date: [Tue Mar 16 16:27:12 1999] * *---------------------------------------------------------------------------*/ @@ -242,6 +242,7 @@ struct l2state_tab { void i4b_next_l2state(l2_softc_t *l2sc, int event) { int currstate, newstate; + int (*savpostfsmfunc)(int) = NULL; /* check event number */ if(event > N_EVENTS) @@ -292,8 +293,10 @@ void i4b_next_l2state(l2_softc_t *l2sc, int event) if(l2sc->postfsmfunc != NULL) { DBGL2(L2_F_MSG, "i4b_next_l2state", ("FSM executing postfsmfunc!\n")); - (*l2sc->postfsmfunc)(l2sc->postfsmarg); + /* try to avoid an endless loop */ + savpostfsmfunc = l2sc->postfsmfunc; l2sc->postfsmfunc = NULL; + (*savpostfsmfunc)(l2sc->postfsmarg); } } diff --git a/sys/i4b/layer2/i4b_l2timer.c b/sys/i4b/layer2/i4b_l2timer.c index b9ae4a1..7a7db04 100644 --- a/sys/i4b/layer2/i4b_l2timer.c +++ b/sys/i4b/layer2/i4b_l2timer.c @@ -27,9 +27,9 @@ * i4b_l2timer.c - layer 2 timer handling * -------------------------------------- * - * $Id: i4b_l2timer.c,v 1.13 1999/02/14 09:45:00 hm Exp $ + * $Id: i4b_l2timer.c,v 1.15 1999/04/21 07:36:32 hm Exp $ * - * last edit-date: [Sun Feb 14 10:31:48 1999] + * last edit-date: [Wed Apr 21 09:17:58 1999] * *---------------------------------------------------------------------------*/ @@ -85,8 +85,12 @@ i4b_T200_timeout(l2_softc_t *l2sc) void i4b_T200_start(l2_softc_t *l2sc) { + if(l2sc->T200 == TIMER_ACTIVE) + return; + DBGL2(L2_T_MSG, "i4b_T200_start", ("unit %d\n", l2sc->unit)); l2sc->T200 = TIMER_ACTIVE; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 l2sc->T200_callout = timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF); #else @@ -100,6 +104,8 @@ i4b_T200_start(l2_softc_t *l2sc) void i4b_T200_stop(l2_softc_t *l2sc) { + CRIT_VAR; + CRIT_BEG; if(l2sc->T200 != TIMER_IDLE) { #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 @@ -109,6 +115,7 @@ i4b_T200_stop(l2_softc_t *l2sc) #endif l2sc->T200 = TIMER_IDLE; } + CRIT_END; DBGL2(L2_T_MSG, "i4b_T200_stop", ("unit %d\n", l2sc->unit)); } @@ -118,21 +125,27 @@ i4b_T200_stop(l2_softc_t *l2sc) void i4b_T200_restart(l2_softc_t *l2sc) { + CRIT_VAR; + CRIT_BEG; if(l2sc->T200 != TIMER_IDLE) + { #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 untimeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, l2sc->T200_callout); #else untimeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc); #endif + } else + { l2sc->T200 = TIMER_ACTIVE; - + } + #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 l2sc->T200_callout = timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF); #else timeout((TIMEOUT_FUNC_T)i4b_T200_timeout, (void *)l2sc, T200DEF); #endif - + CRIT_END; DBGL2(L2_T_MSG, "i4b_T200_restart", ("unit %d\n", l2sc->unit)); } @@ -156,9 +169,13 @@ i4b_T202_timeout(l2_softc_t *l2sc) void i4b_T202_start(l2_softc_t *l2sc) { + if (l2sc->N202 == TIMER_ACTIVE) + return; + DBGL2(L2_T_MSG, "i4b_T202_start", ("unit %d\n", l2sc->unit)); l2sc->N202 = N202DEF; l2sc->T202 = TIMER_ACTIVE; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 l2sc->T202_callout = timeout((TIMEOUT_FUNC_T)i4b_T202_timeout, (void *)l2sc, T202DEF); #else @@ -172,6 +189,8 @@ i4b_T202_start(l2_softc_t *l2sc) void i4b_T202_stop(l2_softc_t *l2sc) { + CRIT_VAR; + CRIT_BEG; if(l2sc->T202 != TIMER_IDLE) { #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 @@ -181,6 +200,7 @@ i4b_T202_stop(l2_softc_t *l2sc) #endif l2sc->T202 = TIMER_IDLE; } + CRIT_END; DBGL2(L2_T_MSG, "i4b_T202_stop", ("unit %d\n", l2sc->unit)); } @@ -203,8 +223,12 @@ void i4b_T203_start(l2_softc_t *l2sc) { #if I4B_T203_ACTIVE + if (l2sc->T203 == TIMER_ACTIVE) + return; + DBGL2(L2_T_MSG, "i4b_T203_start", ("unit %d\n", l2sc->unit)); l2sc->T203 = TIMER_ACTIVE; + #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 l2sc->T203_callout = timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF); #else @@ -220,6 +244,8 @@ void i4b_T203_stop(l2_softc_t *l2sc) { #if I4B_T203_ACTIVE + CRIT_VAR; + CRIT_BEG; if(l2sc->T203 != TIMER_IDLE) { #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 @@ -229,6 +255,7 @@ i4b_T203_stop(l2_softc_t *l2sc) #endif l2sc->T203 = TIMER_IDLE; } + CRIT_END; DBGL2(L2_T_MSG, "i4b_T203_stop", ("unit %d\n", l2sc->unit)); #endif } @@ -240,24 +267,30 @@ void i4b_T203_restart(l2_softc_t *l2sc) { #if I4B_T203_ACTIVE + CRIT_VAR; + CRIT_BEG; + if(l2sc->T203 != TIMER_IDLE) + { #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 untimeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, l2sc->T203_callout); #else untimeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc); #endif + } else + { l2sc->T203 = TIMER_ACTIVE; + } #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 l2sc->T203_callout = timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF); #else timeout((TIMEOUT_FUNC_T)i4b_T203_timeout, (void *)l2sc, T203DEF); #endif - + CRIT_END; DBGL2(L2_T_MSG, "i4b_T203_restart", ("unit %d\n", l2sc->unit)); #endif } #endif /* NI4BQ921 > 0 */ - diff --git a/sys/i4b/layer2/i4b_util.c b/sys/i4b/layer2/i4b_util.c index 047e438..141bef0 100644 --- a/sys/i4b/layer2/i4b_util.c +++ b/sys/i4b/layer2/i4b_util.c @@ -27,9 +27,9 @@ * i4b_util.c - layer 2 utility routines * ------------------------------------- * - * $Id: i4b_util.c,v 1.17 1999/02/14 09:45:01 hm Exp $ + * $Id: i4b_util.c,v 1.20 1999/04/15 09:53:55 hm Exp $ * - * last edit-date: [Sun Feb 14 10:32:23 1999] + * last edit-date: [Thu Apr 15 10:47:52 1999] * *---------------------------------------------------------------------------*/ @@ -94,12 +94,15 @@ i4b_establish_data_link(l2_softc_t *l2sc) void i4b_clear_exception_conditions(l2_softc_t *l2sc) { + CRIT_VAR; + CRIT_BEG; + /*XXX -------------------------------------------------------------- */ /*XXX is this really appropriate here or should it moved elsewhere ? */ i4b_Dcleanifq(&l2sc->i_queue); - + if(l2sc->ua_num != UA_EMPTY) { i4b_Dfreembuf(l2sc->ua_frame); @@ -114,6 +117,8 @@ i4b_clear_exception_conditions(l2_softc_t *l2sc) l2sc->own_busy = 0; l2sc->ack_pend = 0; + + CRIT_END; } /*---------------------------------------------------------------------------* @@ -165,13 +170,15 @@ i4b_enquiry_response(l2_softc_t *l2sc) void i4b_invoke_retransmission(l2_softc_t *l2sc, int nr) { - int x = SPLI4B(); + CRIT_VAR; + + CRIT_BEG; DBGL2(L2_ERROR, "i4b_invoke_retransmission", ("nr = %d\n", nr )); while(l2sc->vs != nr) { - DBGL2(L2_ERROR, "i4b_invoke_retransmission", ("nr != vs, nr = %d, vs = %d\n", nr, l2sc->vs)); + DBGL2(L2_ERROR, "i4b_invoke_retransmission", ("nr(%d) != vs(%d)\n", nr, l2sc->vs)); M128DEC(l2sc->vs); @@ -179,8 +186,15 @@ i4b_invoke_retransmission(l2_softc_t *l2sc, int nr) if((l2sc->ua_num != UA_EMPTY) && (l2sc->vs == l2sc->ua_num)) { - IF_ENQUEUE(&l2sc->i_queue, l2sc->ua_frame); - l2sc->ua_num = UA_EMPTY; + if(IF_QFULL(&l2sc->i_queue)) + { + DBGL2(L2_ERROR, "i4b_invoke_retransmission", ("ERROR, I-queue full!\n")); + } + else + { + IF_ENQUEUE(&l2sc->i_queue, l2sc->ua_frame); + l2sc->ua_num = UA_EMPTY; + } } else { @@ -192,7 +206,7 @@ i4b_invoke_retransmission(l2_softc_t *l2sc, int nr) i4b_i_frame_queued_up(l2sc); } - splx(x); + CRIT_END; } /*---------------------------------------------------------------------------* @@ -260,9 +274,9 @@ i4b_rxd_ack(l2_softc_t *l2sc, int nr) if(l2sc->ua_num != UA_EMPTY) { - int s; - - s = SPLI4B(); + CRIT_VAR; + + CRIT_BEG; M128DEC(nr); @@ -272,7 +286,7 @@ i4b_rxd_ack(l2_softc_t *l2sc, int nr) i4b_Dfreembuf(l2sc->ua_frame); l2sc->ua_num = UA_EMPTY; - splx(s); + CRIT_END; } } @@ -308,7 +322,6 @@ i4b_l2_nr_ok(int nr, int va, int vs) DBGL2(L2_ERROR, "i4b_l2_nr_ok", ("ERROR, va = %d, nr = %d, vs = %d [2]\n", va, nr, vs)); return 0; /* fail */ } - return 1; /* good */ } |