OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/rx/rx_globals.h
00001 /*
00002  * Copyright 2000, International Business Machines Corporation and others.
00003  * All Rights Reserved.
00004  *
00005  * This software has been released under the terms of the IBM Public
00006  * License.  For details, see the LICENSE file in the top-level source
00007  * directory or online at http://www.openafs.org/dl/license10.html
00008  */
00009 
00010 /* RX:  Globals for internal use, basically */
00011 
00012 #ifndef AFS_RX_GLOBALS_H
00013 #define AFS_RX_GLOBALS_H
00014 
00015 
00016 #ifdef  KERNEL
00017 #include "rx/rx.h"
00018 #else /* KERNEL */
00019 # include "rx.h"
00020 #endif /* KERNEL */
00021 
00022 #ifndef GLOBALSINIT
00023 #define GLOBALSINIT(x)
00024 #define POSTAMBLE
00025 #if defined(AFS_NT40_ENV)
00026 #define RX_STATS_INTERLOCKED 1
00027 #if defined(AFS_PTHREAD_ENV)
00028 #define EXT __declspec(dllimport) extern
00029 #else /* AFS_PTHREAD_ENV */
00030 #define EXT extern
00031 #endif /* AFS_PTHREAD_ENV */
00032 #else /* AFS_NT40_ENV */
00033 #define EXT extern
00034 #endif /* AFS_NT40_ENV */
00035 #endif /* !GLOBALSINIT */
00036 
00037 /* Basic socket for client requests; other sockets (for receiving server requests) are in the service structures */
00038 EXT osi_socket rx_socket;
00039 
00040 /* The array of installed services.  Null terminated. */
00041 EXT struct rx_service *rx_services[RX_MAX_SERVICES + 1];
00042 #ifdef RX_ENABLE_LOCKS
00043 /* Protects nRequestsRunning as well as pool allocation variables. */
00044 EXT afs_kmutex_t rx_serverPool_lock;
00045 #endif /* RX_ENABLE_LOCKS */
00046 
00047 /* Incoming calls wait on this queue when there are no available server processes */
00048 EXT struct rx_queue rx_incomingCallQueue;
00049 
00050 /* Server processes wait on this queue when there are no appropriate calls to process */
00051 EXT struct rx_queue rx_idleServerQueue;
00052 
00053 /* Constant delay time before sending a hard ack if the receiver consumes
00054  * a packet while no delayed ack event is scheduled. Ensures that the
00055  * sender is able to advance its window when the receiver consumes a packet
00056  * after the sender has exhausted its transmit window.
00057  */
00058 EXT struct clock rx_hardAckDelay;
00059 
00060 #if defined(RXDEBUG) || defined(AFS_NT40_ENV)
00061 /* Variable to allow introduction of network unreliability; exported from libafsrpc */
00062 EXT int rx_intentionallyDroppedPacketsPer100 GLOBALSINIT(0);    /* Dropped on Send */
00063 EXT int rx_intentionallyDroppedOnReadPer100  GLOBALSINIT(0);    /* Dropped on Read */
00064 #endif
00065 
00066 /* extra packets to add to the quota */
00067 EXT int rx_extraQuota GLOBALSINIT(0);
00068 /* extra packets to alloc (2 * maxWindowSize by default) */
00069 EXT int rx_extraPackets GLOBALSINIT(256);
00070 
00071 EXT int rx_stackSize GLOBALSINIT(RX_DEFAULT_STACK_SIZE);
00072 
00073 /* Time until an unresponsive connection is declared dead */
00074 EXT int rx_connDeadTime GLOBALSINIT(12);
00075 
00076 /* Set rx default connection dead time; set on both services and connections at creation time */
00077 #ifdef AFS_NT40_ENV
00078 void rx_SetRxDeadTime(int seconds);
00079 #else
00080 #define rx_SetRxDeadTime(seconds)   (rx_connDeadTime = (seconds))
00081 #endif
00082 
00083 /* Time until we toss an idle connection */
00084 EXT int rx_idleConnectionTime GLOBALSINIT(700);
00085 /* Time until we toss a peer structure, after all connections using are gone */
00086 EXT int rx_idlePeerTime GLOBALSINIT(60);
00087 
00088 /* The file server is temporarily salvaging */
00089 EXT int rx_tranquil GLOBALSINIT(0);
00090 
00091 /* UDP rcv buffer size */
00092 EXT int rx_UdpBufSize GLOBALSINIT(64 * 1024);
00093 #ifdef AFS_NT40_ENV
00094 int   rx_GetMinUdpBufSize(void);
00095 void  rx_SetUdpBufSize(int x);
00096 #else
00097 #define rx_GetMinUdpBufSize()   (64*1024)
00098 #define rx_SetUdpBufSize(x)     (((x)>rx_GetMinUdpBufSize()) ? (rx_UdpBufSize = (x)):0)
00099 #endif
00100 /*
00101  * Variables to control RX overload management. When the number of calls
00102  * waiting for a thread exceed the threshold, new calls are aborted
00103  * with the busy error.
00104  */
00105 EXT int rx_BusyThreshold GLOBALSINIT(-1);       /* default is disabled */
00106 EXT int rx_BusyError GLOBALSINIT(-1);
00107 
00108 /* These definitions should be in one place */
00109 #ifdef  AFS_SUN5_ENV
00110 #define RX_CBUF_TIME    180     /* Check for packet deficit */
00111 #define RX_REAP_TIME    90      /* Check for tossable connections every 90 seconds */
00112 #else
00113 #define RX_CBUF_TIME    120     /* Check for packet deficit */
00114 #define RX_REAP_TIME    60      /* Check for tossable connections every 60 seconds */
00115 #endif
00116 
00117 #define RX_FAST_ACK_RATE 1      /* as of 3.4, ask for an ack every
00118                                  * other packet. */
00119 
00120 EXT int rx_minPeerTimeout GLOBALSINIT(20);      /* in milliseconds */
00121 EXT int rx_minWindow GLOBALSINIT(1);
00122 EXT int rx_maxWindow GLOBALSINIT(RX_MAXACKS);   /* must ack what we receive */
00123 EXT int rx_initReceiveWindow GLOBALSINIT(16);   /* how much to accept */
00124 EXT int rx_maxReceiveWindow GLOBALSINIT(32);    /* how much to accept */
00125 EXT int rx_initSendWindow GLOBALSINIT(16);
00126 EXT int rx_maxSendWindow GLOBALSINIT(32);
00127 EXT int rx_nackThreshold GLOBALSINIT(3);        /* Number NACKS to trigger congestion recovery */
00128 EXT int rx_nDgramThreshold GLOBALSINIT(4);      /* Number of packets before increasing
00129                                                  * packets per datagram */
00130 #define RX_MAX_FRAGS 4
00131 EXT int rxi_nSendFrags GLOBALSINIT(RX_MAX_FRAGS);       /* max fragments in a datagram */
00132 EXT int rxi_nRecvFrags GLOBALSINIT(RX_MAX_FRAGS);
00133 EXT int rxi_OrphanFragSize GLOBALSINIT(512);
00134 
00135 #define RX_MAX_DGRAM_PACKETS 6  /* max packets per jumbogram */
00136 
00137 EXT int rxi_nDgramPackets GLOBALSINIT(RX_MAX_DGRAM_PACKETS);
00138 /* allow n packets between soft acks */
00139 EXT int rxi_SoftAckRate GLOBALSINIT(RX_FAST_ACK_RATE);
00140 /* consume n packets before sending hard ack, should be larger than above,
00141    but not absolutely necessary.  If it's smaller, than fast receivers will
00142    send a soft ack, immediately followed by a hard ack. */
00143 EXT int rxi_HardAckRate GLOBALSINIT(RX_FAST_ACK_RATE + 1);
00144 
00145 EXT int rx_nPackets GLOBALSINIT(0);     /* preallocate packets with rx_extraPackets */
00146 
00147 /*
00148  * pthreads thread-specific rx info support
00149  * the rx_ts_info_t struct is meant to support all kinds of
00150  * thread-specific rx data:
00151  *
00152  *  _FPQ member contains a thread-specific free packet queue
00153  */
00154 #ifdef AFS_PTHREAD_ENV
00155 EXT pthread_key_t rx_ts_info_key;
00156 typedef struct rx_ts_info_t {
00157     struct {
00158         struct rx_queue queue;
00159         int len;                /* local queue length */
00160         int delta;              /* number of new packets alloc'd locally since last sync w/ global queue */
00161 
00162         /* FPQ stats */
00163         int checkin_ops;
00164         int checkin_xfer;
00165         int checkout_ops;
00166         int checkout_xfer;
00167         int gtol_ops;
00168         int gtol_xfer;
00169         int ltog_ops;
00170         int ltog_xfer;
00171         int lalloc_ops;
00172         int lalloc_xfer;
00173         int galloc_ops;
00174         int galloc_xfer;
00175     } _FPQ;
00176     struct rx_packet * local_special_packet;
00177 } rx_ts_info_t;
00178 EXT struct rx_ts_info_t * rx_ts_info_init(void);   /* init function for thread-specific data struct */
00179 #define RX_TS_INFO_GET(ts_info_p) \
00180     do { \
00181         ts_info_p = (struct rx_ts_info_t*)pthread_getspecific(rx_ts_info_key); \
00182         if (ts_info_p == NULL) { \
00183             opr_Verify((ts_info_p = rx_ts_info_init()) != NULL); \
00184         } \
00185     } while(0)
00186 #endif /* AFS_PTHREAD_ENV */
00187 
00188 
00189 /* List of free packets */
00190 /* in pthreads rx, free packet queue is now a two-tiered queueing system
00191  * in which the first tier is thread-specific, and the second tier is
00192  * a global free packet queue */
00193 EXT struct rx_queue rx_freePacketQueue;
00194 #ifdef RX_TRACK_PACKETS
00195 #define RX_FPQ_MARK_FREE(p) \
00196     do { \
00197         if ((p)->flags & RX_PKTFLAG_FREE) \
00198             osi_Panic("rx packet already free\n"); \
00199         (p)->flags |= RX_PKTFLAG_FREE; \
00200         (p)->flags &= ~(RX_PKTFLAG_TQ|RX_PKTFLAG_IOVQ|RX_PKTFLAG_RQ|RX_PKTFLAG_CP); \
00201         (p)->length = 0; \
00202         (p)->niovecs = 0; \
00203     } while(0)
00204 #define RX_FPQ_MARK_USED(p) \
00205     do { \
00206         if (!((p)->flags & RX_PKTFLAG_FREE)) \
00207             osi_Panic("rx packet not free\n"); \
00208         (p)->flags = 0;         /* clear RX_PKTFLAG_FREE, initialize the rest */ \
00209         (p)->header.flags = 0; \
00210     } while(0)
00211 #else
00212 #define RX_FPQ_MARK_FREE(p) \
00213     do { \
00214         (p)->length = 0; \
00215         (p)->niovecs = 0; \
00216     } while(0)
00217 #define RX_FPQ_MARK_USED(p) \
00218     do { \
00219         (p)->flags = 0;         /* clear RX_PKTFLAG_FREE, initialize the rest */ \
00220         (p)->header.flags = 0; \
00221     } while(0)
00222 #endif
00223 #define RX_PACKET_IOV_INIT(p) \
00224     do { \
00225         (p)->wirevec[0].iov_base = (char *)((p)->wirehead); \
00226         (p)->wirevec[0].iov_len = RX_HEADER_SIZE; \
00227         (p)->wirevec[1].iov_base = (char *)((p)->localdata); \
00228         (p)->wirevec[1].iov_len = RX_FIRSTBUFFERSIZE; \
00229     } while(0)
00230 #define RX_PACKET_IOV_FULLINIT(p) \
00231     do { \
00232         (p)->wirevec[0].iov_base = (char *)((p)->wirehead); \
00233         (p)->wirevec[0].iov_len = RX_HEADER_SIZE; \
00234         (p)->wirevec[1].iov_base = (char *)((p)->localdata); \
00235         (p)->wirevec[1].iov_len = RX_FIRSTBUFFERSIZE; \
00236         (p)->niovecs = 2; \
00237         (p)->length = RX_FIRSTBUFFERSIZE; \
00238     } while(0)
00239 
00240 #ifdef RX_ENABLE_LOCKS
00241 EXT afs_kmutex_t rx_freePktQ_lock;
00242 #endif /* RX_ENABLE_LOCKS */
00243 
00244 #if defined(AFS_PTHREAD_ENV)
00245 #define RX_ENABLE_TSFPQ
00246 EXT int rx_TSFPQGlobSize GLOBALSINIT(3); /* number of packets to transfer between global and local queues in one op */
00247 EXT int rx_TSFPQLocalMax GLOBALSINIT(15); /* max number of packets on local FPQ before returning a glob to the global pool */
00248 EXT int rx_TSFPQMaxProcs GLOBALSINIT(0); /* max number of threads expected */
00249 #define RX_TS_FPQ_FLUSH_GLOBAL 1
00250 #define RX_TS_FPQ_PULL_GLOBAL 1
00251 #define RX_TS_FPQ_ALLOW_OVERCOMMIT 1
00252 /*
00253  * compute the localmax and globsize values from rx_TSFPQMaxProcs and rx_nPackets.
00254  * arbitarily set local max so that all threads consume 90% of packets, if all local queues are full.
00255  * arbitarily set transfer glob size to 20% of max local packet queue length.
00256  * also set minimum values of 15 and 3.  Given the algorithms, the number of buffers allocated
00257  * by each call to AllocPacketBufs() will increase indefinitely without a cap on the transfer
00258  * glob size.  A cap of 64 is selected because that will produce an allocation of greater than
00259  * three times that amount which is greater than half of ncalls * maxReceiveWindow.
00260  * Must be called under rx_packets_mutex.
00261  */
00262 #define RX_TS_FPQ_COMPUTE_LIMITS \
00263     do { \
00264         int newmax, newglob; \
00265         newmax = (rx_nPackets * 9) / (10 * rx_TSFPQMaxProcs); \
00266         newmax = (newmax >= 15) ? newmax : 15; \
00267         newglob = newmax / 5; \
00268         newglob = (newglob >= 3) ? (newglob < 64 ? newglob : 64) : 3; \
00269         rx_TSFPQLocalMax = newmax; \
00270         rx_TSFPQGlobSize = newglob; \
00271     } while(0)
00272 /* record the number of packets allocated by this thread
00273  * and stored in the thread local queue */
00274 #define RX_TS_FPQ_LOCAL_ALLOC(rx_ts_info_p,num_alloc) \
00275     do { \
00276         (rx_ts_info_p)->_FPQ.lalloc_ops++; \
00277         (rx_ts_info_p)->_FPQ.lalloc_xfer += num_alloc; \
00278     } while (0)
00279 /* record the number of packets allocated by this thread
00280  * and stored in the global queue */
00281 #define RX_TS_FPQ_GLOBAL_ALLOC(rx_ts_info_p,num_alloc) \
00282     do { \
00283         (rx_ts_info_p)->_FPQ.galloc_ops++; \
00284         (rx_ts_info_p)->_FPQ.galloc_xfer += num_alloc; \
00285     } while (0)
00286 /* move packets from local (thread-specific) to global free packet queue.
00287    rx_freePktQ_lock must be held. default is to reduce the queue size to 40% ofmax */
00288 #define RX_TS_FPQ_LTOG(rx_ts_info_p) \
00289     do { \
00290         int i; \
00291         struct rx_packet * p; \
00292         int tsize = MIN((rx_ts_info_p)->_FPQ.len, (rx_ts_info_p)->_FPQ.len - rx_TSFPQLocalMax + 3 *  rx_TSFPQGlobSize); \
00293         if (tsize <= 0) break; \
00294         for (i=0,p=queue_Last(&((rx_ts_info_p)->_FPQ), rx_packet); \
00295              i < tsize; i++,p=queue_Prev(p, rx_packet)); \
00296         queue_SplitAfterPrepend(&((rx_ts_info_p)->_FPQ),&rx_freePacketQueue,p); \
00297         (rx_ts_info_p)->_FPQ.len -= tsize; \
00298         rx_nFreePackets += tsize; \
00299         (rx_ts_info_p)->_FPQ.ltog_ops++; \
00300         (rx_ts_info_p)->_FPQ.ltog_xfer += tsize; \
00301         if ((rx_ts_info_p)->_FPQ.delta) { \
00302             MUTEX_ENTER(&rx_packets_mutex); \
00303             RX_TS_FPQ_COMPUTE_LIMITS; \
00304             MUTEX_EXIT(&rx_packets_mutex); \
00305            (rx_ts_info_p)->_FPQ.delta = 0; \
00306         } \
00307     } while(0)
00308 /* same as above, except user has direct control over number to transfer */
00309 #define RX_TS_FPQ_LTOG2(rx_ts_info_p,num_transfer) \
00310     do { \
00311         int i; \
00312         struct rx_packet * p; \
00313         if (num_transfer <= 0) break; \
00314         for (i=0,p=queue_Last(&((rx_ts_info_p)->_FPQ), rx_packet); \
00315              i < (num_transfer); i++,p=queue_Prev(p, rx_packet)); \
00316         queue_SplitAfterPrepend(&((rx_ts_info_p)->_FPQ),&rx_freePacketQueue,p); \
00317         (rx_ts_info_p)->_FPQ.len -= (num_transfer); \
00318         rx_nFreePackets += (num_transfer); \
00319         (rx_ts_info_p)->_FPQ.ltog_ops++; \
00320         (rx_ts_info_p)->_FPQ.ltog_xfer += (num_transfer); \
00321         if ((rx_ts_info_p)->_FPQ.delta) { \
00322             MUTEX_ENTER(&rx_packets_mutex); \
00323             RX_TS_FPQ_COMPUTE_LIMITS; \
00324             MUTEX_EXIT(&rx_packets_mutex); \
00325             (rx_ts_info_p)->_FPQ.delta = 0; \
00326         } \
00327     } while(0)
00328 /* move packets from global to local (thread-specific) free packet queue.
00329    rx_freePktQ_lock must be held. */
00330 #define RX_TS_FPQ_GTOL(rx_ts_info_p) \
00331     do { \
00332         int i, tsize; \
00333         struct rx_packet * p; \
00334         tsize = (rx_TSFPQGlobSize <= rx_nFreePackets) ? \
00335                  rx_TSFPQGlobSize : rx_nFreePackets; \
00336         for (i=0,p=queue_First(&rx_freePacketQueue, rx_packet); \
00337              i < tsize; i++,p=queue_Next(p, rx_packet)); \
00338         queue_SplitBeforeAppend(&rx_freePacketQueue,&((rx_ts_info_p)->_FPQ),p); \
00339         (rx_ts_info_p)->_FPQ.len += i; \
00340         rx_nFreePackets -= i; \
00341         (rx_ts_info_p)->_FPQ.gtol_ops++; \
00342         (rx_ts_info_p)->_FPQ.gtol_xfer += i; \
00343     } while(0)
00344 /* same as above, except user has direct control over number to transfer */
00345 #define RX_TS_FPQ_GTOL2(rx_ts_info_p,num_transfer) \
00346     do { \
00347         int i, tsize; \
00348         struct rx_packet * p; \
00349         tsize = (num_transfer); \
00350         if (tsize > rx_nFreePackets) tsize = rx_nFreePackets; \
00351         for (i=0,p=queue_First(&rx_freePacketQueue, rx_packet); \
00352              i < tsize; i++,p=queue_Next(p, rx_packet)); \
00353         queue_SplitBeforeAppend(&rx_freePacketQueue,&((rx_ts_info_p)->_FPQ),p); \
00354         (rx_ts_info_p)->_FPQ.len += i; \
00355         rx_nFreePackets -= i; \
00356         (rx_ts_info_p)->_FPQ.gtol_ops++; \
00357         (rx_ts_info_p)->_FPQ.gtol_xfer += i; \
00358     } while(0)
00359 /* checkout a packet from the thread-specific free packet queue */
00360 #define RX_TS_FPQ_CHECKOUT(rx_ts_info_p,p) \
00361     do { \
00362         (p) = queue_First(&((rx_ts_info_p)->_FPQ), rx_packet); \
00363         queue_Remove(p); \
00364         RX_FPQ_MARK_USED(p); \
00365         (rx_ts_info_p)->_FPQ.len--; \
00366         (rx_ts_info_p)->_FPQ.checkout_ops++; \
00367         (rx_ts_info_p)->_FPQ.checkout_xfer++; \
00368     } while(0)
00369 /* checkout multiple packets from the thread-specific free packet queue.
00370  * num_transfer must be a variable.
00371  */
00372 #define RX_TS_FPQ_QCHECKOUT(rx_ts_info_p,num_transfer,q) \
00373     do { \
00374         int i; \
00375         struct rx_packet *p; \
00376         if (num_transfer > (rx_ts_info_p)->_FPQ.len) num_transfer = (rx_ts_info_p)->_FPQ.len; \
00377         for (i=0, p=queue_First(&((rx_ts_info_p)->_FPQ), rx_packet); \
00378              i < num_transfer; \
00379              i++, p=queue_Next(p, rx_packet)) { \
00380             RX_FPQ_MARK_USED(p); \
00381         } \
00382         queue_SplitBeforeAppend(&((rx_ts_info_p)->_FPQ),(q),p); \
00383         (rx_ts_info_p)->_FPQ.len -= num_transfer; \
00384         (rx_ts_info_p)->_FPQ.checkout_ops++; \
00385         (rx_ts_info_p)->_FPQ.checkout_xfer += num_transfer; \
00386     } while(0)
00387 /* check a packet into the thread-specific free packet queue */
00388 #define RX_TS_FPQ_CHECKIN(rx_ts_info_p,p) \
00389     do { \
00390         queue_Prepend(&((rx_ts_info_p)->_FPQ), (p)); \
00391         RX_FPQ_MARK_FREE(p); \
00392         (rx_ts_info_p)->_FPQ.len++; \
00393         (rx_ts_info_p)->_FPQ.checkin_ops++; \
00394         (rx_ts_info_p)->_FPQ.checkin_xfer++; \
00395     } while(0)
00396 /* check multiple packets into the thread-specific free packet queue */
00397 /* num_transfer must equal length of (q); it is not a means of checking
00398  * in part of (q).  passing num_transfer just saves us instructions
00399  * since caller already knows length of (q) for other reasons */
00400 #define RX_TS_FPQ_QCHECKIN(rx_ts_info_p,num_transfer,q) \
00401     do { \
00402         struct rx_packet *p, *np; \
00403         for (queue_Scan((q), p, np, rx_packet)) { \
00404             RX_FPQ_MARK_FREE(p); \
00405         } \
00406         queue_SplicePrepend(&((rx_ts_info_p)->_FPQ),(q)); \
00407         (rx_ts_info_p)->_FPQ.len += (num_transfer); \
00408         (rx_ts_info_p)->_FPQ.checkin_ops++; \
00409         (rx_ts_info_p)->_FPQ.checkin_xfer += (num_transfer); \
00410     } while(0)
00411 #endif /* AFS_PTHREAD_ENV */
00412 
00413 /* Number of free packets */
00414 EXT int rx_nFreePackets GLOBALSINIT(0);
00415 EXT int rxi_NeedMorePackets GLOBALSINIT(0);
00416 EXT int rx_packetReclaims GLOBALSINIT(0);
00417 
00418 /* largest packet which we can safely receive, initialized to AFS 3.2 value
00419  * This is provided for backward compatibility with peers which may be unable
00420  * to swallow anything larger. THIS MUST NEVER DECREASE WHILE AN APPLICATION
00421  * IS RUNNING! */
00422 EXT afs_uint32 rx_maxReceiveSize GLOBALSINIT(_OLD_MAX_PACKET_SIZE * RX_MAX_FRAGS +
00423                                       UDP_HDR_SIZE * (RX_MAX_FRAGS - 1));
00424 
00425 /* this is the maximum packet size that the user wants us to receive */
00426 /* this is set by rxTune if required */
00427 EXT afs_uint32 rx_maxReceiveSizeUser GLOBALSINIT(0xffffffff);
00428 
00429 /* rx_MyMaxSendSize is the size of the largest packet we will send,
00430  * including the RX header. Just as rx_maxReceiveSize is the
00431  * max we will receive, including the rx header.
00432  */
00433 EXT afs_uint32 rx_MyMaxSendSize GLOBALSINIT(8588);
00434 
00435 /* Maximum size of a jumbo datagram we can receive */
00436 EXT afs_uint32 rx_maxJumboRecvSize GLOBALSINIT(RX_MAX_PACKET_SIZE);
00437 
00438 /* need this to permit progs to run on AIX systems */
00439 EXT int (*rxi_syscallp) (afs_uint32 a3, afs_uint32 a4, void *a5)GLOBALSINIT(0);
00440 
00441 /* List of free queue entries */
00442 EXT struct rx_serverQueueEntry *rx_FreeSQEList GLOBALSINIT(0);
00443 #ifdef  RX_ENABLE_LOCKS
00444 EXT afs_kmutex_t freeSQEList_lock;
00445 #endif
00446 
00447 /* List of free call structures */
00448 EXT struct rx_queue rx_freeCallQueue;
00449 #ifdef  RX_ENABLE_LOCKS
00450 EXT afs_kmutex_t rx_freeCallQueue_lock;
00451 #endif
00452 EXT afs_int32 rxi_nCalls GLOBALSINIT(0);
00453 
00454 /* 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. */
00455 EXT u_short rx_port;
00456 
00457 #if !defined(KERNEL) && !defined(AFS_PTHREAD_ENV)
00458 /* 32-bit select Mask for rx_Listener. */
00459 EXT fd_set rx_selectMask;
00460 EXT osi_socket rx_maxSocketNumber;      /* Maximum socket number in the select mask. */
00461 /* Minumum socket number in the select mask. */
00462 EXT osi_socket rx_minSocketNumber GLOBALSINIT(0x7fffffff);
00463 #endif
00464 
00465 /* This is actually the minimum number of packets that must remain free,
00466     overall, immediately after a packet of the requested class has been
00467     allocated.  *WARNING* These must be assigned with a great deal of care.
00468     In order, these are receive quota, send quota, special quota, receive
00469     continuation quota, and send continuation quota. */
00470 #define RX_PACKET_QUOTAS {1, 10, 0, 1, 10}
00471 /* value large enough to guarantee that no allocation fails due to RX_PACKET_QUOTAS.
00472    Make it a little bigger, just for fun */
00473 #define RX_MAX_QUOTA    15      /* part of min packet computation */
00474 EXT int rx_packetQuota[RX_N_PACKET_CLASSES] GLOBALSINIT(RX_PACKET_QUOTAS);
00475 EXT int meltdown_1pkt GLOBALSINIT(1);   /* prefer to schedule single-packet calls */
00476 EXT int rxi_md2cnt GLOBALSINIT(0);      /* counter of skipped calls */
00477 EXT int rxi_2dchoice GLOBALSINIT(1);    /* keep track of another call to schedule */
00478 
00479 /* quota system: each attached server process must be able to make
00480     progress to avoid system deadlock, so we ensure that we can always
00481     handle the arrival of the next unacknowledged data packet for an
00482     attached call.  rxi_dataQuota gives the max # of packets that must be
00483     reserved for active calls for them to be able to make progress, which is
00484     essentially enough to queue up a window-full of packets (the first packet
00485     may be missing, so these may not get read) + the # of packets the thread
00486     may use before reading all of its input (# free must be one more than send
00487     packet quota).  Thus, each thread allocates rx_maxReceiveWindow+1 (max
00488     queued packets) + an extra for sending data.  The system also reserves
00489     RX_MAX_QUOTA (must be more than RX_PACKET_QUOTA[i], which is 10), so that
00490     the extra packet can be sent (must be under the system-wide send packet
00491     quota to send any packets) */
00492 /* # to reserve so that thread with input can still make calls (send packets)
00493    without blocking */
00494 EXT int rxi_dataQuota GLOBALSINIT(RX_MAX_QUOTA);        /* packets to reserve for active threads */
00495 
00496 EXT afs_int32 rxi_availProcs GLOBALSINIT(0);    /* number of threads in the pool */
00497 EXT afs_int32 rxi_totalMin GLOBALSINIT(0);      /* Sum(minProcs) forall services */
00498 EXT afs_int32 rxi_minDeficit GLOBALSINIT(0);    /* number of procs needed to handle all minProcs */
00499 
00500 EXT int rx_nextCid;             /* Next connection call id */
00501 EXT int rx_epoch;               /* Initialization time of rx */
00502 #ifdef  RX_ENABLE_LOCKS
00503 EXT afs_kcondvar_t rx_waitingForPackets_cv;
00504 #endif
00505 EXT char rx_waitingForPackets;  /* Processes set and wait on this variable when waiting for packet buffers */
00506 
00507 EXT struct rx_peer **rx_peerHashTable;
00508 EXT struct rx_connection **rx_connHashTable;
00509 EXT struct rx_connection *rx_connCleanup_list GLOBALSINIT(0);
00510 EXT afs_uint32 rx_hashTableSize GLOBALSINIT(257);       /* Prime number */
00511 #ifdef RX_ENABLE_LOCKS
00512 EXT afs_kmutex_t rx_peerHashTable_lock;
00513 EXT afs_kmutex_t rx_connHashTable_lock;
00514 #endif /* RX_ENABLE_LOCKS */
00515 
00516 #define CONN_HASH(host, port, cid, epoch, type) ((((cid)>>RX_CIDSHIFT)%rx_hashTableSize))
00517 
00518 #define PEER_HASH(host, port)  ((host ^ port) % rx_hashTableSize)
00519 
00520 /* Forward definitions of internal procedures */
00521 #define rxi_ChallengeOff(conn)  \
00522         rxevent_Cancel(&(conn)->challengeEvent, NULL, 0)
00523 #define rxi_KeepAliveOff(call) \
00524         rxevent_Cancel(&(call)->keepAliveEvent, call, RX_CALL_REFCOUNT_ALIVE)
00525 #define rxi_NatKeepAliveOff(conn) \
00526         rxevent_Cancel(&(conn)->natKeepAliveEvent, NULL, 0)
00527 
00528 #define rxi_AllocSecurityObject() rxi_Alloc(sizeof(struct rx_securityClass))
00529 #define rxi_FreeSecurityObject(obj) rxi_Free(obj, sizeof(struct rx_securityClass))
00530 #define rxi_AllocService()      rxi_Alloc(sizeof(struct rx_service))
00531 #define rxi_FreeService(obj) \
00532 do { \
00533     MUTEX_DESTROY(&(obj)->svc_data_lock);  \
00534     rxi_Free((obj), sizeof(struct rx_service)); \
00535 } while (0)
00536 #define rxi_AllocPeer()         rxi_Alloc(sizeof(struct rx_peer))
00537 #define rxi_FreePeer(peer)      rxi_Free(peer, sizeof(struct rx_peer))
00538 #define rxi_AllocConnection()   rxi_Alloc(sizeof(struct rx_connection))
00539 #define rxi_FreeConnection(conn) (rxi_Free(conn, sizeof(struct rx_connection)))
00540 
00541 EXT afs_int32 rx_stats_active GLOBALSINIT(1);   /* boolean - rx statistics gathering */
00542 
00543 #ifndef KERNEL
00544 /* Some debugging stuff */
00545 EXT FILE *rx_debugFile;         /* Set by the user to a stdio file for debugging output */
00546 EXT FILE *rxevent_debugFile;    /* Set to an stdio descriptor for event logging to that file */
00547 #endif
00548 
00549 #ifdef RXDEBUG
00550 # define rx_Log rx_debugFile
00551 # ifdef AFS_NT40_ENV
00552 EXT int rxdebug_active;
00553 #  define dpf(args) do { if (rxdebug_active) rxi_DebugPrint args; } while (0)
00554 # else
00555 #  ifdef DPF_FSLOG
00556 #   include <afs/afsutil.h>
00557 #   define dpf(args) FSLog args
00558 #  else
00559 #   define dpf(args) do { if (rx_debugFile) rxi_DebugPrint args; } while (0)
00560 #  endif
00561 # endif
00562 # define rx_Log_event rxevent_debugFile
00563 #else
00564 # define dpf(args)
00565 #endif /* RXDEBUG */
00566 
00567 EXT char *rx_packetTypes[RX_N_PACKET_TYPES] GLOBALSINIT(RX_PACKET_TYPES);       /* Strings defined in rx.h */
00568 
00569 #ifndef KERNEL
00570 /*
00571  * Counter used to implement connection specific data
00572  */
00573 EXT int rxi_keyCreate_counter GLOBALSINIT(0);
00574 /*
00575  * Array of function pointers used to destory connection specific data
00576  */
00577 EXT rx_destructor_t *rxi_keyCreate_destructor GLOBALSINIT(NULL);
00578 #ifdef RX_ENABLE_LOCKS
00579 EXT afs_kmutex_t rxi_keyCreate_lock;
00580 #endif /* RX_ENABLE_LOCKS */
00581 #endif /* !KERNEL */
00582 
00583 /*
00584  * SERVER ONLY: Threshholds used to throttle error replies to looping
00585  * clients. When consecutive calls are aborting with the same error, the
00586  * server throttles the client by waiting before sending error messages.
00587  * Disabled if abort thresholds are zero.
00588  */
00589 EXT int rxi_connAbortThreshhold GLOBALSINIT(0);
00590 EXT int rxi_connAbortDelay GLOBALSINIT(3000);
00591 EXT int rxi_callAbortThreshhold GLOBALSINIT(0);
00592 EXT int rxi_callAbortDelay GLOBALSINIT(3000);
00593 
00594 /*
00595  * Thread specific thread ID used to implement LWP_Index().
00596  */
00597 
00598 #if defined(AFS_PTHREAD_ENV)
00599 EXT int rxi_fcfs_thread_num GLOBALSINIT(0);
00600 EXT pthread_key_t rx_thread_id_key;
00601 #else
00602 #define rxi_fcfs_thread_num (0)
00603 #endif
00604 
00605 #if defined(RX_ENABLE_LOCKS)
00606 EXT afs_kmutex_t rx_waiting_mutex POSTAMBLE;    /* used to protect waiting counters */
00607 EXT afs_kmutex_t rx_quota_mutex POSTAMBLE;      /* used to protect quota counters */
00608 EXT afs_kmutex_t rx_pthread_mutex POSTAMBLE;    /* used to protect pthread counters */
00609 EXT afs_kmutex_t rx_packets_mutex POSTAMBLE;    /* used to protect packet counters */
00610 EXT afs_kmutex_t rx_refcnt_mutex POSTAMBLE;       /* used to protect conn/call ref counts */
00611 #endif
00612 
00613 EXT int rx_enable_stats GLOBALSINIT(0);
00614 
00615 /*
00616  * Set this flag to enable the listener thread to trade places with an idle
00617  * worker thread to move the context switch from listener to worker out of
00618  * the request path.
00619  */
00620 EXT int rx_enable_hot_thread GLOBALSINIT(0);
00621 
00622 EXT int RX_IPUDP_SIZE GLOBALSINIT(_RX_IPUDP_SIZE);
00623 #endif /* AFS_RX_GLOBALS_H */
 All Data Structures Files Functions Variables