]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_Timer.c
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>
56 #include <netat/sysglue.h>
57 #include <netat/appletalk.h>
58 #include <netat/at_pcb.h>
59 #include <netat/at_var.h>
60 #include <netat/debug.h>
61 #include <netat/adsp.h>
62 #include <netat/adsp_internal.h>
68 * Cleanly abort a session that might be open. Called if probe timer expires,
69 * or from AppleTalk event handler (close or network gone away)
71 * Only call if the session is active (I.e. not for closed or listeners)
78 void TrashSession(CCBPtr
);
80 void TrashSession(sp
) /* (CCBPtr sp) */
84 sp
->userFlags
|= eTearDown
;
88 DoClose(sp
, errAborted
, 1);
100 void DoTimerElem(TimerElemPtr
);
102 void DoTimerElem(t
) /* (TimerElemPtr t) */
107 sp
= (CCBPtr
)((Ptr
)t
- t
->type
); /* Recover stream pointer for this guy */
109 if (t
->type
== kFlushTimerType
) { /* flush write data time just fired */
110 if (sp
->sData
) { /* If there's any data, flush it. */
114 } else if (t
->type
== kRetryTimerType
) {
115 if (sp
->waitingAck
) {
118 sp
->sendSeq
= sp
->firstRtmtSeq
;
120 sp
->resentData
= 1; /* Had to resend data */
121 sp
->noXmitFlow
= 1; /* Don't incr. max packets. */
123 if ((sp
->pktSendMax
/= 2) == 0) /* Back off on max # packets
127 if ((sp
->roundTrip
*= 2) > sp
->probeInterval
)
128 sp
->roundTrip
= sp
->probeInterval
;
129 sp
->rtmtInterval
= sp
->roundTrip
+ ((short)2 *
130 (short)sp
->deviation
);
133 } else if (t
->type
== kAttnTimerType
) {
134 if (sp
->sapb
) { /* Unacknowledged attn pkt */
135 sp
->sendAttnData
= 1;
138 } else if (t
->type
== kResetTimerType
) {
139 if (sp
->frpb
) { /* Unacknowledged forward reset */
140 sp
->sendCtl
|= B_CTL_FRESET
;
143 } else if (t
->type
== kProbeTimerType
) {
144 if (sp
->state
== sOpen
|| sp
->state
== sClosing
) {
145 if (--sp
->probeCntr
== 0) { /* Connection died */
149 InsertTimerElem(&adspGlobal
.slowTimers
, &sp
->ProbeTimer
,
151 sp
->sendCtl
|= B_CTL_PROBE
;
154 } else if (sp
->state
== sOpening
) {
155 if ((sp
->openState
== O_STATE_OPENWAIT
) ||
156 (sp
->openState
== O_STATE_ESTABLISHED
))
158 if (--sp
->openRetrys
== 0) { /* Oops, didn't open */
160 DoClose(sp
, errOpening
, 1);
163 else /* Send packet again */
165 sp
->sendCtl
|= (sp
->openState
== O_STATE_OPENWAIT
) ?
166 B_CTL_OREQ
: B_CTL_OREQACK
;
169 } /* we're opening */
174 dPrintf(D_M_ADSP
, D_L_ERROR
, ("DoTimerElem:Unknown timer type!\n"));
183 void TimerTick_funnel(void *arg
);
185 void TimerTick_funnel(__unused
void *arg
)
192 static int StopTimer
;
197 * Called 6 times per second
203 void TimerTick() /* (void) */
209 TimerQueueTick(&adspGlobal
.slowTimers
);
210 TimerQueueTick(&adspGlobal
.fastTimers
);
211 timeout(TimerTick_funnel
, (caddr_t
)0, HZ
/6);
217 untimeout(TimerTick_funnel
, (caddr_t
) 0);