2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 /* RX: Globals for internal use, basically */
12 #ifndef AFS_RX_GLOBALS_H
13 #define AFS_RX_GLOBALS_H
23 #define GLOBALSINIT(x)
24 #if defined(AFS_NT40_ENV)
25 #define RX_STATS_INTERLOCKED 1
26 #if defined(AFS_PTHREAD_ENV)
27 #define EXT __declspec(dllimport) extern
28 #else /* AFS_PTHREAD_ENV */
30 #endif /* AFS_PTHREAD_ENV */
31 #else /* AFS_NT40_ENV */
33 #endif /* AFS_NT40_ENV */
34 #endif /* !GLOBALSINIT */
36 /* Basic socket for client requests; other sockets (for receiving server requests) are in the service structures */
37 EXT osi_socket rx_socket;
39 /* The array of installed services. Null terminated. */
40 EXT struct rx_service *rx_services[RX_MAX_SERVICES + 1];
41 #ifdef RX_ENABLE_LOCKS
42 /* Protects nRequestsRunning as well as pool allocation variables. */
43 EXT afs_kmutex_t rx_serverPool_lock;
44 #endif /* RX_ENABLE_LOCKS */
46 /* Incoming calls wait on this queue when there are no available server processes */
47 EXT struct rx_queue rx_incomingCallQueue;
49 /* Server processes wait on this queue when there are no appropriate calls to process */
50 EXT struct rx_queue rx_idleServerQueue;
52 /* Constant delay time before sending a hard ack if the receiver consumes
53 * a packet while no delayed ack event is scheduled. Ensures that the
54 * sender is able to advance its window when the receiver consumes a packet
55 * after the sender has exhausted its transmit window.
57 EXT struct clock rx_hardAckDelay;
59 #if defined(RXDEBUG) || defined(AFS_NT40_ENV)
60 /* Variable to allow introduction of network unreliability; exported from libafsrpc */
61 EXT int rx_intentionallyDroppedPacketsPer100 GLOBALSINIT(0); /* Dropped on Send */
62 EXT int rx_intentionallyDroppedOnReadPer100 GLOBALSINIT(0); /* Dropped on Read */
65 /* extra packets to add to the quota */
66 EXT int rx_extraQuota GLOBALSINIT(0);
67 /* extra packets to alloc (2 * maxWindowSize by default) */
68 EXT int rx_extraPackets GLOBALSINIT(256);
70 EXT int rx_stackSize GLOBALSINIT(RX_DEFAULT_STACK_SIZE);
72 /* Time until an unresponsive connection is declared dead */
73 EXT int rx_connDeadTime GLOBALSINIT(12);
75 /* Set rx default connection dead time; set on both services and connections at creation time */
77 void rx_SetRxDeadTime(int seconds);
79 #define rx_SetRxDeadTime(seconds) (rx_connDeadTime = (seconds))
82 /* Time until we toss an idle connection */
83 EXT int rx_idleConnectionTime GLOBALSINIT(700);
84 /* Time until we toss a peer structure, after all connections using are gone */
85 EXT int rx_idlePeerTime GLOBALSINIT(60);
87 /* The file server is temporarily salvaging */
88 EXT int rx_tranquil GLOBALSINIT(0);
90 /* UDP rcv buffer size */
91 EXT int rx_UdpBufSize GLOBALSINIT(64 * 1024);
93 int rx_GetMinUdpBufSize(void);
94 void rx_SetUdpBufSize(int x);
96 #define rx_GetMinUdpBufSize() (64*1024)
97 #define rx_SetUdpBufSize(x) (((x)>rx_GetMinUdpBufSize()) ? (rx_UdpBufSize = (x)):0)
100 * Variables to control RX overload management. When the number of calls
101 * waiting for a thread exceed the threshold, new calls are aborted
102 * with the busy error.
104 EXT int rx_BusyThreshold GLOBALSINIT(-1); /* default is disabled */
105 EXT int rx_BusyError GLOBALSINIT(-1);
107 /* These definitions should be in one place */
109 #define RX_CBUF_TIME 180 /* Check for packet deficit */
110 #define RX_REAP_TIME 90 /* Check for tossable connections every 90 seconds */
112 #define RX_CBUF_TIME 120 /* Check for packet deficit */
113 #define RX_REAP_TIME 60 /* Check for tossable connections every 60 seconds */
116 #define RX_FAST_ACK_RATE 1 /* as of 3.4, ask for an ack every
119 EXT int rx_minPeerTimeout GLOBALSINIT(20); /* in milliseconds */
120 EXT int rx_minWindow GLOBALSINIT(1);
121 EXT int rx_maxWindow GLOBALSINIT(RX_MAXACKS); /* must ack what we receive */
122 EXT int rx_initReceiveWindow GLOBALSINIT(16); /* how much to accept */
123 EXT int rx_maxReceiveWindow GLOBALSINIT(32); /* how much to accept */
124 EXT int rx_initSendWindow GLOBALSINIT(16);
125 EXT int rx_maxSendWindow GLOBALSINIT(32);
126 EXT int rx_nackThreshold GLOBALSINIT(3); /* Number NACKS to trigger congestion recovery */
127 EXT int rx_nDgramThreshold GLOBALSINIT(4); /* Number of packets before increasing
128 * packets per datagram */
129 #define RX_MAX_FRAGS 4
130 EXT int rxi_nSendFrags GLOBALSINIT(RX_MAX_FRAGS); /* max fragments in a datagram */
131 EXT int rxi_nRecvFrags GLOBALSINIT(RX_MAX_FRAGS);
132 EXT int rxi_OrphanFragSize GLOBALSINIT(512);
134 #define RX_MAX_DGRAM_PACKETS 6 /* max packets per jumbogram */
136 EXT int rxi_nDgramPackets GLOBALSINIT(RX_MAX_DGRAM_PACKETS);
137 /* allow n packets between soft acks - must be power of 2 -1, else change
139 EXT int rxi_SoftAckRate GLOBALSINIT(RX_FAST_ACK_RATE);
140 /* consume n packets before sending hard ack, should be larger than above,
141 but not absolutely necessary. If it's smaller, than fast receivers will
142 send a soft ack, immediately followed by a hard ack. */
143 EXT int rxi_HardAckRate GLOBALSINIT(RX_FAST_ACK_RATE + 1);
145 /* If window sizes become very variable (in terms of #packets), be
146 * sure that the sender can get back a hard acks without having to wait for
147 * some kind of timer event first (like a keep-alive, for instance).
148 * It might be kind of tricky, so it might be better to shrink the
149 * window size by reducing the packet size below the "natural" MTU. */
151 #define ACKHACK(p,r) { if (((p)->header.seq & (rxi_SoftAckRate))==0) (p)->header.flags |= RX_REQUEST_ACK; }
153 EXT int rx_nPackets GLOBALSINIT(0); /* preallocate packets with rx_extraPackets */
156 * pthreads thread-specific rx info support
157 * the rx_ts_info_t struct is meant to support all kinds of
158 * thread-specific rx data:
160 * _FPQ member contains a thread-specific free packet queue
162 #ifdef AFS_PTHREAD_ENV
163 EXT pthread_key_t rx_ts_info_key;
164 typedef struct rx_ts_info_t {
166 struct rx_queue queue;
167 int len; /* local queue length */
168 int delta; /* number of new packets alloc'd locally since last sync w/ global queue */
184 struct rx_packet * local_special_packet;
186 EXT struct rx_ts_info_t * rx_ts_info_init(void); /* init function for thread-specific data struct */
187 #define RX_TS_INFO_GET(ts_info_p) \
189 ts_info_p = (struct rx_ts_info_t*)pthread_getspecific(rx_ts_info_key); \
190 if (ts_info_p == NULL) { \
191 osi_Assert((ts_info_p = rx_ts_info_init()) != NULL); \
194 #endif /* AFS_PTHREAD_ENV */
197 /* List of free packets */
198 /* in pthreads rx, free packet queue is now a two-tiered queueing system
199 * in which the first tier is thread-specific, and the second tier is
200 * a global free packet queue */
201 EXT struct rx_queue rx_freePacketQueue;
202 #ifdef RX_TRACK_PACKETS
203 #define RX_FPQ_MARK_FREE(p) \
205 if ((p)->flags & RX_PKTFLAG_FREE) \
206 osi_Panic("rx packet already free\n"); \
207 (p)->flags |= RX_PKTFLAG_FREE; \
208 (p)->flags &= ~(RX_PKTFLAG_TQ|RX_PKTFLAG_IOVQ|RX_PKTFLAG_RQ|RX_PKTFLAG_CP); \
212 #define RX_FPQ_MARK_USED(p) \
214 if (!((p)->flags & RX_PKTFLAG_FREE)) \
215 osi_Panic("rx packet not free\n"); \
216 (p)->flags = 0; /* clear RX_PKTFLAG_FREE, initialize the rest */ \
217 (p)->header.flags = 0; \
220 #define RX_FPQ_MARK_FREE(p) \
225 #define RX_FPQ_MARK_USED(p) \
227 (p)->flags = 0; /* clear RX_PKTFLAG_FREE, initialize the rest */ \
228 (p)->header.flags = 0; \
231 #define RX_PACKET_IOV_INIT(p) \
233 (p)->wirevec[0].iov_base = (char *)((p)->wirehead); \
234 (p)->wirevec[0].iov_len = RX_HEADER_SIZE; \
235 (p)->wirevec[1].iov_base = (char *)((p)->localdata); \
236 (p)->wirevec[1].iov_len = RX_FIRSTBUFFERSIZE; \
238 #define RX_PACKET_IOV_FULLINIT(p) \
240 (p)->wirevec[0].iov_base = (char *)((p)->wirehead); \
241 (p)->wirevec[0].iov_len = RX_HEADER_SIZE; \
242 (p)->wirevec[1].iov_base = (char *)((p)->localdata); \
243 (p)->wirevec[1].iov_len = RX_FIRSTBUFFERSIZE; \
245 (p)->length = RX_FIRSTBUFFERSIZE; \
248 #ifdef RX_ENABLE_LOCKS
249 EXT afs_kmutex_t rx_freePktQ_lock;
250 #endif /* RX_ENABLE_LOCKS */
252 #if defined(AFS_PTHREAD_ENV)
253 #define RX_ENABLE_TSFPQ
254 EXT int rx_TSFPQGlobSize GLOBALSINIT(3); /* number of packets to transfer between global and local queues in one op */
255 EXT int rx_TSFPQLocalMax GLOBALSINIT(15); /* max number of packets on local FPQ before returning a glob to the global pool */
256 EXT int rx_TSFPQMaxProcs GLOBALSINIT(0); /* max number of threads expected */
257 #define RX_TS_FPQ_FLUSH_GLOBAL 1
258 #define RX_TS_FPQ_PULL_GLOBAL 1
259 #define RX_TS_FPQ_ALLOW_OVERCOMMIT 1
261 * compute the localmax and globsize values from rx_TSFPQMaxProcs and rx_nPackets.
262 * arbitarily set local max so that all threads consume 90% of packets, if all local queues are full.
263 * arbitarily set transfer glob size to 20% of max local packet queue length.
264 * also set minimum values of 15 and 3. Given the algorithms, the number of buffers allocated
265 * by each call to AllocPacketBufs() will increase indefinitely without a cap on the transfer
266 * glob size. A cap of 64 is selected because that will produce an allocation of greater than
267 * three times that amount which is greater than half of ncalls * maxReceiveWindow.
268 * Must be called under rx_packets_mutex.
270 #define RX_TS_FPQ_COMPUTE_LIMITS \
272 int newmax, newglob; \
273 newmax = (rx_nPackets * 9) / (10 * rx_TSFPQMaxProcs); \
274 newmax = (newmax >= 15) ? newmax : 15; \
275 newglob = newmax / 5; \
276 newglob = (newglob >= 3) ? (newglob < 64 ? newglob : 64) : 3; \
277 rx_TSFPQLocalMax = newmax; \
278 rx_TSFPQGlobSize = newglob; \
280 /* record the number of packets allocated by this thread
281 * and stored in the thread local queue */
282 #define RX_TS_FPQ_LOCAL_ALLOC(rx_ts_info_p,num_alloc) \
284 (rx_ts_info_p)->_FPQ.lalloc_ops++; \
285 (rx_ts_info_p)->_FPQ.lalloc_xfer += num_alloc; \
287 /* record the number of packets allocated by this thread
288 * and stored in the global queue */
289 #define RX_TS_FPQ_GLOBAL_ALLOC(rx_ts_info_p,num_alloc) \
291 (rx_ts_info_p)->_FPQ.galloc_ops++; \
292 (rx_ts_info_p)->_FPQ.galloc_xfer += num_alloc; \
294 /* move packets from local (thread-specific) to global free packet queue.
295 rx_freePktQ_lock must be held. default is to reduce the queue size to 40% ofmax */
296 #define RX_TS_FPQ_LTOG(rx_ts_info_p) \
299 struct rx_packet * p; \
300 int tsize = MIN((rx_ts_info_p)->_FPQ.len, (rx_ts_info_p)->_FPQ.len - rx_TSFPQLocalMax + 3 * rx_TSFPQGlobSize); \
301 if (tsize <= 0) break; \
302 for (i=0,p=queue_Last(&((rx_ts_info_p)->_FPQ), rx_packet); \
303 i < tsize; i++,p=queue_Prev(p, rx_packet)); \
304 queue_SplitAfterPrepend(&((rx_ts_info_p)->_FPQ),&rx_freePacketQueue,p); \
305 (rx_ts_info_p)->_FPQ.len -= tsize; \
306 rx_nFreePackets += tsize; \
307 (rx_ts_info_p)->_FPQ.ltog_ops++; \
308 (rx_ts_info_p)->_FPQ.ltog_xfer += tsize; \
309 if ((rx_ts_info_p)->_FPQ.delta) { \
310 MUTEX_ENTER(&rx_packets_mutex); \
311 RX_TS_FPQ_COMPUTE_LIMITS; \
312 MUTEX_EXIT(&rx_packets_mutex); \
313 (rx_ts_info_p)->_FPQ.delta = 0; \
316 /* same as above, except user has direct control over number to transfer */
317 #define RX_TS_FPQ_LTOG2(rx_ts_info_p,num_transfer) \
320 struct rx_packet * p; \
321 if (num_transfer <= 0) break; \
322 for (i=0,p=queue_Last(&((rx_ts_info_p)->_FPQ), rx_packet); \
323 i < (num_transfer); i++,p=queue_Prev(p, rx_packet)); \
324 queue_SplitAfterPrepend(&((rx_ts_info_p)->_FPQ),&rx_freePacketQueue,p); \
325 (rx_ts_info_p)->_FPQ.len -= (num_transfer); \
326 rx_nFreePackets += (num_transfer); \
327 (rx_ts_info_p)->_FPQ.ltog_ops++; \
328 (rx_ts_info_p)->_FPQ.ltog_xfer += (num_transfer); \
329 if ((rx_ts_info_p)->_FPQ.delta) { \
330 MUTEX_ENTER(&rx_packets_mutex); \
331 RX_TS_FPQ_COMPUTE_LIMITS; \
332 MUTEX_EXIT(&rx_packets_mutex); \
333 (rx_ts_info_p)->_FPQ.delta = 0; \
336 /* move packets from global to local (thread-specific) free packet queue.
337 rx_freePktQ_lock must be held. */
338 #define RX_TS_FPQ_GTOL(rx_ts_info_p) \
341 struct rx_packet * p; \
342 tsize = (rx_TSFPQGlobSize <= rx_nFreePackets) ? \
343 rx_TSFPQGlobSize : rx_nFreePackets; \
344 for (i=0,p=queue_First(&rx_freePacketQueue, rx_packet); \
345 i < tsize; i++,p=queue_Next(p, rx_packet)); \
346 queue_SplitBeforeAppend(&rx_freePacketQueue,&((rx_ts_info_p)->_FPQ),p); \
347 (rx_ts_info_p)->_FPQ.len += i; \
348 rx_nFreePackets -= i; \
349 (rx_ts_info_p)->_FPQ.gtol_ops++; \
350 (rx_ts_info_p)->_FPQ.gtol_xfer += i; \
352 /* same as above, except user has direct control over number to transfer */
353 #define RX_TS_FPQ_GTOL2(rx_ts_info_p,num_transfer) \
356 struct rx_packet * p; \
357 tsize = (num_transfer); \
358 if (tsize > rx_nFreePackets) tsize = rx_nFreePackets; \
359 for (i=0,p=queue_First(&rx_freePacketQueue, rx_packet); \
360 i < tsize; i++,p=queue_Next(p, rx_packet)); \
361 queue_SplitBeforeAppend(&rx_freePacketQueue,&((rx_ts_info_p)->_FPQ),p); \
362 (rx_ts_info_p)->_FPQ.len += i; \
363 rx_nFreePackets -= i; \
364 (rx_ts_info_p)->_FPQ.gtol_ops++; \
365 (rx_ts_info_p)->_FPQ.gtol_xfer += i; \
367 /* checkout a packet from the thread-specific free packet queue */
368 #define RX_TS_FPQ_CHECKOUT(rx_ts_info_p,p) \
370 (p) = queue_First(&((rx_ts_info_p)->_FPQ), rx_packet); \
372 RX_FPQ_MARK_USED(p); \
373 (rx_ts_info_p)->_FPQ.len--; \
374 (rx_ts_info_p)->_FPQ.checkout_ops++; \
375 (rx_ts_info_p)->_FPQ.checkout_xfer++; \
377 /* checkout multiple packets from the thread-specific free packet queue.
378 * num_transfer must be a variable.
380 #define RX_TS_FPQ_QCHECKOUT(rx_ts_info_p,num_transfer,q) \
383 struct rx_packet *p; \
384 if (num_transfer > (rx_ts_info_p)->_FPQ.len) num_transfer = (rx_ts_info_p)->_FPQ.len; \
385 for (i=0, p=queue_First(&((rx_ts_info_p)->_FPQ), rx_packet); \
387 i++, p=queue_Next(p, rx_packet)) { \
388 RX_FPQ_MARK_USED(p); \
390 queue_SplitBeforeAppend(&((rx_ts_info_p)->_FPQ),(q),p); \
391 (rx_ts_info_p)->_FPQ.len -= num_transfer; \
392 (rx_ts_info_p)->_FPQ.checkout_ops++; \
393 (rx_ts_info_p)->_FPQ.checkout_xfer += num_transfer; \
395 /* check a packet into the thread-specific free packet queue */
396 #define RX_TS_FPQ_CHECKIN(rx_ts_info_p,p) \
398 queue_Prepend(&((rx_ts_info_p)->_FPQ), (p)); \
399 RX_FPQ_MARK_FREE(p); \
400 (rx_ts_info_p)->_FPQ.len++; \
401 (rx_ts_info_p)->_FPQ.checkin_ops++; \
402 (rx_ts_info_p)->_FPQ.checkin_xfer++; \
404 /* check multiple packets into the thread-specific free packet queue */
405 /* num_transfer must equal length of (q); it is not a means of checking
406 * in part of (q). passing num_transfer just saves us instructions
407 * since caller already knows length of (q) for other reasons */
408 #define RX_TS_FPQ_QCHECKIN(rx_ts_info_p,num_transfer,q) \
410 struct rx_packet *p, *np; \
411 for (queue_Scan((q), p, np, rx_packet)) { \
412 RX_FPQ_MARK_FREE(p); \
414 queue_SplicePrepend(&((rx_ts_info_p)->_FPQ),(q)); \
415 (rx_ts_info_p)->_FPQ.len += (num_transfer); \
416 (rx_ts_info_p)->_FPQ.checkin_ops++; \
417 (rx_ts_info_p)->_FPQ.checkin_xfer += (num_transfer); \
419 #endif /* AFS_PTHREAD_ENV */
421 /* Number of free packets */
422 EXT int rx_nFreePackets GLOBALSINIT(0);
423 EXT int rxi_NeedMorePackets GLOBALSINIT(0);
424 EXT int rx_packetReclaims GLOBALSINIT(0);
426 /* largest packet which we can safely receive, initialized to AFS 3.2 value
427 * This is provided for backward compatibility with peers which may be unable
428 * to swallow anything larger. THIS MUST NEVER DECREASE WHILE AN APPLICATION
430 EXT afs_uint32 rx_maxReceiveSize GLOBALSINIT(_OLD_MAX_PACKET_SIZE * RX_MAX_FRAGS +
431 UDP_HDR_SIZE * (RX_MAX_FRAGS - 1));
433 /* this is the maximum packet size that the user wants us to receive */
434 /* this is set by rxTune if required */
435 EXT afs_uint32 rx_maxReceiveSizeUser GLOBALSINIT(0xffffffff);
437 /* rx_MyMaxSendSize is the size of the largest packet we will send,
438 * including the RX header. Just as rx_maxReceiveSize is the
439 * max we will receive, including the rx header.
441 EXT afs_uint32 rx_MyMaxSendSize GLOBALSINIT(8588);
443 /* Maximum size of a jumbo datagram we can receive */
444 EXT afs_uint32 rx_maxJumboRecvSize GLOBALSINIT(RX_MAX_PACKET_SIZE);
446 /* need this to permit progs to run on AIX systems */
447 EXT int (*rxi_syscallp) (afs_uint32 a3, afs_uint32 a4, void *a5)GLOBALSINIT(0);
449 /* List of free queue entries */
450 EXT struct rx_serverQueueEntry *rx_FreeSQEList GLOBALSINIT(0);
451 #ifdef RX_ENABLE_LOCKS
452 EXT afs_kmutex_t freeSQEList_lock;
455 /* List of free call structures */
456 EXT struct rx_queue rx_freeCallQueue;
457 #ifdef RX_ENABLE_LOCKS
458 EXT afs_kmutex_t rx_freeCallQueue_lock;
460 EXT afs_int32 rxi_nCalls GLOBALSINIT(0);
462 /* Port requested at rx_Init. If this is zero, the actual port used will be different--but it will only be used for client operations. If non-zero, server provided services may use the same port. */
465 #if !defined(KERNEL) && !defined(AFS_PTHREAD_ENV)
466 /* 32-bit select Mask for rx_Listener. */
467 EXT fd_set rx_selectMask;
468 EXT osi_socket rx_maxSocketNumber; /* Maximum socket number in the select mask. */
469 /* Minumum socket number in the select mask. */
470 EXT osi_socket rx_minSocketNumber GLOBALSINIT(0x7fffffff);
473 /* This is actually the minimum number of packets that must remain free,
474 overall, immediately after a packet of the requested class has been
475 allocated. *WARNING* These must be assigned with a great deal of care.
476 In order, these are receive quota, send quota, special quota, receive
477 continuation quota, and send continuation quota. */
478 #define RX_PACKET_QUOTAS {1, 10, 0, 1, 10}
479 /* value large enough to guarantee that no allocation fails due to RX_PACKET_QUOTAS.
480 Make it a little bigger, just for fun */
481 #define RX_MAX_QUOTA 15 /* part of min packet computation */
482 EXT int rx_packetQuota[RX_N_PACKET_CLASSES] GLOBALSINIT(RX_PACKET_QUOTAS);
483 EXT int meltdown_1pkt GLOBALSINIT(1); /* prefer to schedule single-packet calls */
484 EXT int rxi_md2cnt GLOBALSINIT(0); /* counter of skipped calls */
485 EXT int rxi_2dchoice GLOBALSINIT(1); /* keep track of another call to schedule */
487 /* quota system: each attached server process must be able to make
488 progress to avoid system deadlock, so we ensure that we can always
489 handle the arrival of the next unacknowledged data packet for an
490 attached call. rxi_dataQuota gives the max # of packets that must be
491 reserved for active calls for them to be able to make progress, which is
492 essentially enough to queue up a window-full of packets (the first packet
493 may be missing, so these may not get read) + the # of packets the thread
494 may use before reading all of its input (# free must be one more than send
495 packet quota). Thus, each thread allocates rx_maxReceiveWindow+1 (max
496 queued packets) + an extra for sending data. The system also reserves
497 RX_MAX_QUOTA (must be more than RX_PACKET_QUOTA[i], which is 10), so that
498 the extra packet can be sent (must be under the system-wide send packet
499 quota to send any packets) */
500 /* # to reserve so that thread with input can still make calls (send packets)
502 EXT int rxi_dataQuota GLOBALSINIT(RX_MAX_QUOTA); /* packets to reserve for active threads */
504 EXT afs_int32 rxi_availProcs GLOBALSINIT(0); /* number of threads in the pool */
505 EXT afs_int32 rxi_totalMin GLOBALSINIT(0); /* Sum(minProcs) forall services */
506 EXT afs_int32 rxi_minDeficit GLOBALSINIT(0); /* number of procs needed to handle all minProcs */
508 EXT int rx_nextCid; /* Next connection call id */
509 EXT int rx_epoch; /* Initialization time of rx */
510 #ifdef RX_ENABLE_LOCKS
511 EXT afs_kcondvar_t rx_waitingForPackets_cv;
513 EXT char rx_waitingForPackets; /* Processes set and wait on this variable when waiting for packet buffers */
515 EXT struct rx_peer **rx_peerHashTable;
516 EXT struct rx_connection **rx_connHashTable;
517 EXT struct rx_connection *rx_connCleanup_list GLOBALSINIT(0);
518 EXT afs_uint32 rx_hashTableSize GLOBALSINIT(257); /* Prime number */
519 #ifdef RX_ENABLE_LOCKS
520 EXT afs_kmutex_t rx_peerHashTable_lock;
521 EXT afs_kmutex_t rx_connHashTable_lock;
522 #endif /* RX_ENABLE_LOCKS */
524 #define CONN_HASH(host, port, cid, epoch, type) ((((cid)>>RX_CIDSHIFT)%rx_hashTableSize))
526 #define PEER_HASH(host, port) ((host ^ port) % rx_hashTableSize)
528 /* Forward definitions of internal procedures */
529 #define rxi_ChallengeOff(conn) \
530 rxevent_Cancel(&(conn)->challengeEvent, NULL, 0)
531 #define rxi_KeepAliveOff(call) \
532 rxevent_Cancel(&(call)->keepAliveEvent, call, RX_CALL_REFCOUNT_ALIVE)
533 #define rxi_NatKeepAliveOff(conn) \
534 rxevent_Cancel(&(conn)->natKeepAliveEvent, NULL, 0)
536 #define rxi_AllocSecurityObject() rxi_Alloc(sizeof(struct rx_securityClass))
537 #define rxi_FreeSecurityObject(obj) rxi_Free(obj, sizeof(struct rx_securityClass))
538 #define rxi_AllocService() rxi_Alloc(sizeof(struct rx_service))
539 #define rxi_FreeService(obj) \
541 MUTEX_DESTROY(&(obj)->svc_data_lock); \
542 rxi_Free((obj), sizeof(struct rx_service)); \
544 #define rxi_AllocPeer() rxi_Alloc(sizeof(struct rx_peer))
545 #define rxi_FreePeer(peer) rxi_Free(peer, sizeof(struct rx_peer))
546 #define rxi_AllocConnection() rxi_Alloc(sizeof(struct rx_connection))
547 #define rxi_FreeConnection(conn) (rxi_Free(conn, sizeof(struct rx_connection)))
549 EXT afs_int32 rx_stats_active GLOBALSINIT(1); /* boolean - rx statistics gathering */
552 /* Some debugging stuff */
553 EXT FILE *rx_debugFile; /* Set by the user to a stdio file for debugging output */
554 EXT FILE *rxevent_debugFile; /* Set to an stdio descriptor for event logging to that file */
558 # define rx_Log rx_debugFile
560 EXT int rxdebug_active;
561 # define dpf(args) do { if (rxdebug_active) rxi_DebugPrint args; } while (0)
564 # include <afs/afsutil.h>
565 # define dpf(args) FSLog args
567 # define dpf(args) do { if (rx_debugFile) rxi_DebugPrint args; } while (0)
570 # define rx_Log_event rxevent_debugFile
575 EXT char *rx_packetTypes[RX_N_PACKET_TYPES] GLOBALSINIT(RX_PACKET_TYPES); /* Strings defined in rx.h */
579 * Counter used to implement connection specific data
581 EXT int rxi_keyCreate_counter GLOBALSINIT(0);
583 * Array of function pointers used to destory connection specific data
585 EXT rx_destructor_t *rxi_keyCreate_destructor GLOBALSINIT(NULL);
586 #ifdef RX_ENABLE_LOCKS
587 EXT afs_kmutex_t rxi_keyCreate_lock;
588 #endif /* RX_ENABLE_LOCKS */
592 * SERVER ONLY: Threshholds used to throttle error replies to looping
593 * clients. When consecutive calls are aborting with the same error, the
594 * server throttles the client by waiting before sending error messages.
595 * Disabled if abort thresholds are zero.
597 EXT int rxi_connAbortThreshhold GLOBALSINIT(0);
598 EXT int rxi_connAbortDelay GLOBALSINIT(3000);
599 EXT int rxi_callAbortThreshhold GLOBALSINIT(0);
600 EXT int rxi_callAbortDelay GLOBALSINIT(3000);
603 * Thread specific thread ID used to implement LWP_Index().
606 #if defined(AFS_PTHREAD_ENV)
607 EXT int rxi_fcfs_thread_num GLOBALSINIT(0);
608 EXT pthread_key_t rx_thread_id_key;
610 #define rxi_fcfs_thread_num (0)
613 #if defined(RX_ENABLE_LOCKS)
614 EXT afs_kmutex_t rx_waiting_mutex; /* used to protect waiting counters */
615 EXT afs_kmutex_t rx_quota_mutex; /* used to protect quota counters */
616 EXT afs_kmutex_t rx_pthread_mutex; /* used to protect pthread counters */
617 EXT afs_kmutex_t rx_packets_mutex; /* used to protect packet counters */
618 EXT afs_kmutex_t rx_refcnt_mutex; /* used to protect conn/call ref counts */
621 EXT int rx_enable_stats GLOBALSINIT(0);
624 * Set this flag to enable the listener thread to trade places with an idle
625 * worker thread to move the context switch from listener to worker out of
628 EXT int rx_enable_hot_thread GLOBALSINIT(0);
630 EXT int RX_IPUDP_SIZE GLOBALSINIT(_RX_IPUDP_SIZE);
631 #endif /* AFS_RX_GLOBALS_H */