]>
git.saurik.com Git - apple/xnu.git/blob - bsd/netat/adsp_internal.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 #ifndef _NETAT_ADSP_INTERNAL_H_
26 #define _NETAT_ADSP_INTERNAL_H_
27 #include <sys/appleapiopts.h>
29 #include <sys/types.h>
32 #ifdef __APPLE_API_PRIVATE
34 /* from h/adsp_portab.h */
36 /* TypeDefs for the basic data bytes. */
38 typedef unsigned char byte
, *bytePtr
;
46 typedef unsigned char boolean
;
48 typedef unsigned short word
;
50 typedef unsigned int dword
;
52 #define BYTE_AT(x) (*((byte PTR)(x)))
53 #define WORD_AT(x) (*((word PTR)(x)))
54 #define DWORD_AT(x) (*((dword PTR)(x)))
56 #define high(x) ((byte)((x) >> 8))
57 #define low(x) ((byte)(x))
58 #define hlword(h, l) (((byte)(l)) | (((byte)(h)) << 8))
62 * On a Mac, there is no need to byte-swap data on the network, so
63 * these macros do nothing
71 at_net network
; /* network number */
72 byte nodeid
; /* node number */
73 byte socket
; /* socket number */
74 } AddrBlk
, *AddrBlkPtr
;
79 } AddrUnion
, *AddrUnionPtr
;
83 /* from h/adsp_internal.h */
88 * Default Behavior for ADSP
90 #define ocIntervalDefault 6
91 #define ocMaximumDefault 10
92 #define probeIntervalDefault 180
95 * MACROS for comparing 32-bit sequence numbers
97 #define GT(x,y) (((long)(x-y)) > (long) 0)
98 #define LT(x,y) (((long)(x-y)) < (long) 0)
99 #define GTE(x,y) (((long)(x-y)) >= (long) 0)
100 #define LTE(x,y) (((long)(x-y)) <= (long) 0)
101 #define BETWEEN(x,y,z) (LTE(x,y) && LTE(y,z))
104 * Use the kernel tick counter for SysTicks.
107 #define SysTicks() lbolt
110 * Timer element used for handling timings
112 typedef struct timerelem
{
113 struct timerelem
*link
;
116 unsigned onQ
:1; /* Bit-fields are faster than booleans */
119 typedef TimerElem
*TimerElemPtr
;
122 * For AppleTalk Phase 2 event queue
126 unsigned short qType
;
130 typedef LAPEventElem
*LAPEventElemPtr
;
133 * The Event types we're passed when an AppleTalk transition occurs
135 #define AOpenTransition 0
136 #define ACloseTransition 2
137 #define ANetworkTransition 5
140 * The element we're passed when a NetworkTransaction event occurs
142 typedef struct TNetworkTransition
{
143 Ptr
private; /* pointer used internally by NetShare */
144 ProcPtr netValidProc
; /* pointer to the network valid procedure */
145 } TNetworkTransition
, *TPNetworkTransition
;
147 typedef long (*NetworkTransitionProcPtr
)();
148 /* (TPNetworkTransition nettrans,
149 unsigned long thenet); */
151 * This is the connection control block
154 /*---These fields may not change order or size-----------*/
156 struct ccb
*ccbLink
; /* link to next ccb */
157 unsigned short state
; /* state of the connection end */
158 unsigned char userFlags
; /* flags for unsolicited connection events */
159 unsigned char localSocket
; /* socket number of this connection end */
160 AddrUnion remoteAddress
; /* internet address of remote end */
161 unsigned short attnCode
; /* attention code received */
162 unsigned short attnSize
; /* size of received attention data */
163 unsigned char *attnPtr
; /* ptr to received attention data */
164 unsigned short recvQPending
; /* # bytes in receive queue %%% */
165 /*------------------------------------------------------ */
167 struct adspcmd
*opb
; /* Outstanding open/close/remove/listens */
168 struct adspcmd
*spb
; /* Outstanding Sends */
169 struct adspcmd
*sapb
; /* Outstanding Send Attentions */
170 struct adspcmd
*frpb
; /* Outstanding Forward Resets */
171 struct adspcmd
*rpb
; /* Outstanding Read Requests */
173 struct ccb
*otccbLink
; /* link to next ccb */
174 int pid
; /* Process ID for CCB owner */
176 unsigned short remCID
; /* Remote Connection ID */
177 unsigned short locCID
; /* Local Connection ID */
178 int sendSeq
; /* Seq number of next char to send to remote */
179 int firstRtmtSeq
; /* oldest seq # in local send queue */
180 int sendWdwSeq
; /* Seq # of last char remote has bfr for */
181 int recvSeq
; /* Seq of # of next char expected from rmte */
182 int recvWdw
; /* # of bytes local end has buffer space for */
183 int attnSendSeq
; /* Seq # of next attn pkt to send to remote */
184 int attnRecvSeq
; /* Seq # of next packet local end expects */
185 int maxSendSeq
; /* Highest seq # we ever sent on connection */
187 /* These must be in the first 255 bytes of the CCB */
188 TimerElem ProbeTimer
; /* Timer element for probes (and open) */
189 TimerElem FlushTimer
; /* Timer element for flushing data */
190 TimerElem RetryTimer
; /* Timer element for retransmissions */
191 TimerElem AttnTimer
; /* Timer element for attention packets */
192 TimerElem ResetTimer
; /* Timer element for forward resets */
194 short openInterval
; /* Interval between open connection packets */
195 short probeInterval
; /* Interval between probes */
196 short sendInterval
; /* Interval before automatic flush */
197 short rtmtInterval
; /* Rexmit interval (dynamically determined) */
199 short sendCtl
; /* Send control message bits */
200 short sendBlocking
; /* Flush unsent data if > than sendBlocking */
201 short openRetrys
; /* # of retrys for Connect & Accept */
202 short rbuflen
; /* Total size of receive buffer */
203 short sbuflen
; /* Total size of receive buffer */
206 char badSeqMax
; /* retransmit advice send threshold */
207 char badSeqCnt
; /* # of of out-of-order packets received */
208 char useCheckSum
; /* true to use DDP checksums */
209 char openState
; /* Used for opening a connection (see below) */
211 gbuf_t
*rbuf_mb
; /* message block for the recv buffer */
213 gbuf_t
*sbuf_mb
; /* message block for the send buffer */
215 gbuf_t
*attn_mb
; /* message block for the attention buffer */
216 gbuf_t
*deferred_mb
; /* message block deferred for later processing */
219 char ioDone
; /* flag for when the adsp header is busy */
221 char probeCntr
; /* # of probes we can miss (counts down) */
222 char pktSendMax
; /* Max # of packets to send without an ack */
223 char pktSendCnt
; /* # of packets sent so far */
225 int sendStamp
; /* Time of last ackRequest */
226 int timerSeq
; /* Seq # of char corresponding to above time stamp */
227 short roundTrip
; /* Average Round-Trip time (in 6ths of a second) */
228 short deviation
; /* deviation from roundTrip time */
230 unsigned sData
:1; /* There's data in the send queue */
231 unsigned waitingAck
:1; /* We're waiting for an ack packet */
232 unsigned rData
:1; /* There's data in the receive queue */
233 unsigned resentData
:1; /* True when we resend data due to timeout */
234 unsigned sendDataAck
:1; /* True if he requested an ack */
235 unsigned sendAttnAck
:1; /* Must send attn acknowlege */
236 unsigned sendAttnData
:1; /* Must send attn data */
237 unsigned callSend
:1; /* Must call CheckSend() */
238 unsigned rbufFull
:1; /* We've closed our receive window. */
239 unsigned noXmitFlow
:1; /* True stops incrementing # of xmit
240 * packets to send in a row after receiving
242 unsigned secureCCB
:1; /* True if this is a secure connection */
243 unsigned removing
:1; /* There is a dspRemove pending */
244 unsigned writeFlush
:1; /* Flush send queue even if # bytes to
245 * send is less than send blocking. */
246 unsigned delay
:1; /* do not complete commands until user
247 * *** NO LONGER USED IN KERNEL *** */
248 ADSP_FRAME f
; /* Used to send every packet */
249 ADSP_OPEN_DATA of
; /* Holds the data for the open exchange */
250 gref_t
*gref
; /* The queue associated with the CCB */
259 * Change order and die !!! --- See the receive open packet code
261 #define O_STATE_NOTHING 0 /* Not opening */
262 #define O_STATE_LISTEN 1 /* Listening for open request */
263 #define O_STATE_OPENWAIT 2 /* Sent Req, waiting for Ack to open
265 #define O_STATE_ESTABLISHED 3 /* Got Req, send Req+Ack,waiting Ack */
266 #define O_STATE_OPEN 4 /* Connection is open */
269 * These bits are used in the sendCtl field to indicate what needs to be sent
271 #define B_CTL_PROBE 0x0001
272 #define B_CTL_OREQ 0x0002
273 #define B_CTL_OACK 0x0004
274 #define B_CTL_OREQACK 0x0008
275 #define B_CTL_ODENY 0x0010
276 #define B_CTL_CLOSE 0x0020
277 #define B_CTL_FRESET 0x0040
278 #define B_CTL_FRESETACK 0x0080
279 #define B_CTL_RETRANSMIT 0x0100
282 #define kProbeTimerType offsetof(CCB, ProbeTimer)
283 #define kFlushTimerType offsetof(CCB, FlushTimer)
284 #define kRetryTimerType offsetof(CCB, RetryTimer)
285 #define kAttnTimerType offsetof(CCB, AttnTimer)
286 #define kResetTimerType offsetof(CCB, ResetTimer)
289 * Used to manage the send receive queue
292 short len
; /* # of bytes in this fragment */
293 char flags
; /* See #define's below */
297 #define HDR_LEN 3 /* Yes, I know it really is 4 bytes long... */
303 #define F_ENCRYPTED 0x20 /* %%% Needed ??? */
304 #define F_LAST 0x40 /* This is last block in buffer */
307 /* %%% Are these two used anymore? */
308 #define sbufPtr(y) (&sp->sbuf[((y) < sp->sbuflen) ? (y) : ((y) - sp->sbuflen)])
309 #define rbufPtr(y) (&sp->rbuf[((y) < sp->rbuflen) ? (y) : ((y) - sp->rbuflen)])
313 /* fron h/adsp_supp.h */
315 void CallUserRoutine(); /* (CCB FPTR sp); */
319 * Add queue element to end of queue. Pass Address of ptr to
320 * 1st element of queue
322 int qAddToEnd(); /* (void FPTR FPTR qhead, void FPTR qelem); */
325 * Hunt down a linked list of queue elements looking for an element with
326 * 'data' at 'offset' bytes into the queue element.
328 void *qfind_b(); /* (void *qhead, word offset, word data); */
329 void *qfind_w(); /* (void *qhead, word offset, word data); */
330 void *qfind_p(); /* (void *qhead, word offset, void *ptr); */
331 void *qfind_o(); /* (void *qhead, word offset, void *ptr); */
332 void *qfind_m(); /* (void *qhead, void *match,
333 ProcPtr compare_fnx); */
337 * Routines to handle sorted timer queues
339 void InsertTimerElem(); /* (TimerElemPtr *qhead, TimerElemPtr t,
341 void RemoveTimerElem(); /* (TimerElemPtr *qhead, TimerElemPtr t); */
342 void TimerQueueTick(); /* (TimerElemPtr *qhead);*/
344 /* from h/adsp_global.h */
347 void *ccbList
; /* Ptr to list of connection control blocks */
349 TimerElemPtr slowTimers
; /* The probe timer list */
350 TimerElemPtr fastTimers
; /* The fast timer list */
352 unsigned short lastCID
; /* Last connection ID assigned */
353 char inTimer
; /* We're inside timer routine */
356 extern GLOBAL adspGlobal
;
358 /* Address of ptr to list of ccb's */
359 #define AT_ADSP_STREAMS ((CCB **)&(adspGlobal.ccbList))
361 #endif /* __APPLE_API_PRIVATE */
364 #endif /* _NETAT_ADSP_INTERNAL_H_ */