* Copyright (c) 1991 The Regents of the University of California.
* %sccs.include.redist.c%
* @(#)tp_timer.c 7.13 (Berkeley) %G%
/***********************************************************
Copyright IBM Corporation 1987
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of IBM not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
******************************************************************/
* ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
* $Header: tp_timer.c,v 5.2 88/11/18 17:29:07 nhall Exp $
* $Source: /usr/argo/sys/netiso/RCS/tp_timer.c,v $
int tp_rttdiv
, tp_rttadd
, N_TPREF
= 127;
struct tp_refinfo tp_refinfo
;
struct tp_pcb
*tp_ftimeolist
= (struct tp_pcb
*)&tp_ftimeolist
;
* at autoconfig time from tp_init()
* a combo of event, state, predicate
* FUNCTION and ARGUMENTS:
* initialize data structures for the timers
tp_refinfo
.tpr_size
= N_TPREF
+ 1; /* Need to start somewhere */
s
= sizeof(*tp_ref
) * tp_refinfo
.tpr_size
;
if ((tp_ref
= (struct tp_ref
*) malloc(s
, M_PCB
, M_NOWAIT
)) == 0)
bzero((caddr_t
)tp_ref
, (unsigned) s
);
tp_refinfo
.tpr_base
= tp_ref
;
tp_rttdiv
= hz
/ PR_SLOWHZ
;
tp_rttadd
= (2 * tp_rttdiv
) - 1;
/********************** e timers *************************/
* FUNCTION and ARGUMENTS:
tp_etimeout(tpcb
, fun
, ticks
)
register struct tp_pcb
*tpcb
;
int fun
; /* function to be called */
printf("etimeout pcb 0x%x state 0x%x\n", tpcb
, tpcb
->tp_state
);
tptrace(TPPTmisc
, "tp_etimeout ref refstate tks Etick", tpcb
->tp_lref
,
tpcb
->tp_state
, ticks
, tp_stat
.ts_Eticks
);
callp
= tpcb
->tp_timer
+ fun
;
if (*callp
== 0 || *callp
> ticks
)
* FUNCTION and ARGUMENTS:
* Cancel all occurrences of E-timer function (fun) for reference (refp)
register struct tp_pcb
*tpcb
;
tptrace(TPPTmisc
, "tp_euntimeout ref", tpcb
->tp_lref
, 0, 0, 0);
/**************** c timers **********************
* These are not chained together; they sit
* in the tp_ref structure. they are the kind that
* are typically cancelled so it's faster not to
* the clock, every 500 ms
* FUNCTION and ARGUMENTS:
* Look for open references with active timers.
* If they exist, call the appropriate timer routines to update
* the timers and possibly generate events.
register struct tp_ref
*rp
;
/* check only open reference structures */
/* tp_ref[0] is never used */
for (rp
= tp_ref
+ tp_refinfo
.tpr_maxopen
; rp
> tp_ref
; rp
--) {
if ((tpcb
= rp
->tpr_pcb
) == 0 || tpcb
->tp_refstate
< REF_OPEN
)
for (t
= 0; t
< TM_NTIMERS
; t
++) {
if (*cp
&& --(*cp
) <= 0 ) {
printf("C expired! type 0x%x\n", t
);
if (t
== TM_reference
&& tpcb
->tp_state
== TP_CLOSED
) {
if (tpcb
->tp_notdetached
) {
printf("PRU_DETACH: not detached\n");
/* XXX wart; where else to do it? */
free((caddr_t
)tpcb
, M_PCB
);
* Called From: tp.trans from tp_slowtimo() -- retransmission timer went off.
register struct tp_pcb
*tpcb
;
tpcb
->tp_rttemit
= 0; /* cancel current round trip time */
tpcb
->tp_sndnxt
= tpcb
->tp_snduna
;
if (tpcb
->tp_fcredit
== 0) {
* We transmitted new data, started timing it and the window
* got shrunk under us. This can only happen if all data
* that they wanted us to send got acked, so don't
* bother shrinking the congestion windows, et. al.
* The retransmission timer should have been reset in goodack()
printf("tp_data_retrans: 0 window tpcb 0x%x una 0x%x\n",
tpcb
->tp_timer
[TM_data_retrans
] = 0;
tpcb
->tp_timer
[TM_sendack
] = tpcb
->tp_dt_ticks
;
rexmt
= tpcb
->tp_dt_ticks
<< min(tpcb
->tp_rxtshift
, TP_MAXRXTSHIFT
);
win
= min(tpcb
->tp_fcredit
, (tpcb
->tp_cong_win
/ tpcb
->tp_l_tpdusize
/ 2));
tpcb
->tp_cong_win
= tpcb
->tp_l_tpdusize
; /* slow start again. */
tpcb
->tp_ssthresh
= win
* tpcb
->tp_l_tpdusize
;
/* We're losing; our srtt estimate is probably bogus.
* Clobber it so we'll take the next rtt measurement as our srtt;
* Maintain current rxt times until then.
if (++tpcb
->tp_rxtshift
> TP_NRETRANS
/ 4) {
/* tpcb->tp_nlprotosw->nlp_losing(tpcb->tp_npcb) someday */
TP_RANGESET(tpcb
->tp_rxtcur
, rexmt
, tpcb
->tp_peer_acktime
, 128);
tpcb
->tp_timer
[TM_data_retrans
] = tpcb
->tp_rxtcur
;
register struct tp_pcb
*t
;
E
.ev_number
= TM_sendack
;
while ((t
= tp_ftimeolist
) != (struct tp_pcb
*)&tp_ftimeolist
) {
printf("tp_fasttimeo: should panic");
tp_ftimeolist
= (struct tp_pcb
*)&tp_ftimeolist
;
if (t
->tp_flags
& TPF_DELACK
) {
t
->tp_flags
&= ~TPF_DELACK
;
tp_ftimeolist
= t
->tp_fasttimeo
;
* FUNCTION and ARGUMENTS:
* Set a C type timer of type (which) to go off after (ticks) time.
tp_ctimeout(tpcb
, which
, ticks
)
register struct tp_pcb
*tpcb
;
tptrace(TPPTmisc
, "tp_ctimeout ref which tpcb active",
tpcb
->tp_lref
, which
, tpcb
, tpcb
->tp_timer
[which
]);
if(tpcb
->tp_timer
[which
])
tpcb
->tp_timer
[which
] = ticks
;
* FUNCTION and ARGUMENTS:
* Version of tp_ctimeout that resets the C-type time if the
* parameter (ticks) is > the current value of the timer.
tp_ctimeout_MIN(tpcb
, which
, ticks
)
register struct tp_pcb
*tpcb
;
tptrace(TPPTmisc
, "tp_ctimeout_MIN ref which tpcb active",
tpcb
->tp_lref
, which
, tpcb
, tpcb
->tp_timer
[which
]);
if (tpcb
->tp_timer
[which
]) {
tpcb
->tp_timer
[which
] = MIN(ticks
, tpcb
->tp_timer
[which
]);
tpcb
->tp_timer
[which
] = ticks
;
* FUNCTION and ARGUMENTS:
* Cancel the (which) timer in the ref structure indicated by (refp).
tp_cuntimeout(tpcb
, which
)
register struct tp_pcb
*tpcb
;
printf("tp_cuntimeout(0x%x, %d) active %d\n",
tpcb
, which
, tpcb
->tp_timer
[which
]);
tptrace(TPPTmisc
, "tp_cuntimeout ref which, active", refp
-tp_ref
,
which
, tpcb
->tp_timer
[which
], 0);
if (tpcb
->tp_timer
[which
])
tpcb
->tp_timer
[which
] = 0;