]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_Timer.c
9f551fd0eda0eef8f75a0c343f448242a6f5b074
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1990, 1996-1998 Apple Computer, Inc.
30 * All Rights Reserved.
36 * From v01.12 06/22/90 mbs
37 * Modified for MP, 1996 by Tuyen Nguyen
38 * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX.
41 #include <sys/errno.h>
42 #include <sys/types.h>
43 #include <sys/param.h>
44 #include <machine/spl.h>
45 #include <sys/systm.h>
46 #include <sys/kernel.h>
48 #include <sys/filedesc.h>
49 #include <sys/fcntl.h>
51 #include <sys/socket.h>
54 #include <netat/sysglue.h>
55 #include <netat/appletalk.h>
56 #include <netat/at_pcb.h>
57 #include <netat/debug.h>
58 #include <netat/adsp.h>
59 #include <netat/adsp_internal.h>
66 * Cleanly abort a session that might be open. Called if probe timer expires,
67 * or from AppleTalk event handler (close or network gone away)
69 * Only call if the session is active (I.e. not for closed or listeners)
76 void TrashSession(sp
) /* (CCBPtr sp) */
80 sp
->userFlags
|= eTearDown
;
84 DoClose(sp
, errAborted
, 1);
96 void DoTimerElem(t
) /* (TimerElemPtr t) */
101 sp
= (CCBPtr
)((Ptr
)t
- t
->type
); /* Recover stream pointer for this guy */
103 if (t
->type
== kFlushTimerType
) { /* flush write data time just fired */
104 if (sp
->sData
) { /* If there's any data, flush it. */
108 } else if (t
->type
== kRetryTimerType
) {
109 if (sp
->waitingAck
) {
112 sp
->sendSeq
= sp
->firstRtmtSeq
;
114 sp
->resentData
= 1; /* Had to resend data */
115 sp
->noXmitFlow
= 1; /* Don't incr. max packets. */
117 if ((sp
->pktSendMax
/= 2) == 0) /* Back off on max # packets
121 if ((sp
->roundTrip
*= 2) > sp
->probeInterval
)
122 sp
->roundTrip
= sp
->probeInterval
;
123 sp
->rtmtInterval
= sp
->roundTrip
+ ((short)2 *
124 (short)sp
->deviation
);
127 } else if (t
->type
== kAttnTimerType
) {
128 if (sp
->sapb
) { /* Unacknowledged attn pkt */
129 sp
->sendAttnData
= 1;
132 } else if (t
->type
== kResetTimerType
) {
133 if (sp
->frpb
) { /* Unacknowledged forward reset */
134 sp
->sendCtl
|= B_CTL_FRESET
;
137 } else if (t
->type
== kProbeTimerType
) {
138 if (sp
->state
== sOpen
|| sp
->state
== sClosing
) {
139 if (--sp
->probeCntr
== 0) { /* Connection died */
143 InsertTimerElem(&adspGlobal
.slowTimers
, &sp
->ProbeTimer
,
145 sp
->sendCtl
|= B_CTL_PROBE
;
148 } else if (sp
->state
== sOpening
) {
149 if ((sp
->openState
== O_STATE_OPENWAIT
) ||
150 (sp
->openState
== O_STATE_ESTABLISHED
))
152 if (--sp
->openRetrys
== 0) { /* Oops, didn't open */
154 DoClose(sp
, errOpening
, 1);
157 else /* Send packet again */
159 sp
->sendCtl
|= (sp
->openState
== O_STATE_OPENWAIT
) ?
160 B_CTL_OREQ
: B_CTL_OREQACK
;
163 } /* we're opening */
168 dPrintf(D_M_ADSP
, D_L_ERROR
, ("DoTimerElem:Unknown timer type!\n"));
177 void TimerTick_funnel(void *arg
)
189 * Called 6 times per second
195 void TimerTick() /* (void) */
201 TimerQueueTick(&adspGlobal
.slowTimers
);
202 TimerQueueTick(&adspGlobal
.fastTimers
);
203 timeout(TimerTick_funnel
, (caddr_t
)0, HZ
/6);
209 untimeout(TimerTick_funnel
, (caddr_t
) 0);