Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

328 lines
9.6 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. afddata.h
  5. Abstract:
  6. This module declares global data for AFD.
  7. Author:
  8. David Treadwell (davidtr) 21-Feb-1992
  9. Revision History:
  10. Vadim Eydelman (vadime)
  11. 1998-1999 NT5.0 optimizations
  12. --*/
  13. #ifndef _AFDDATA_
  14. #define _AFDDATA_
  15. extern PDEVICE_OBJECT AfdDeviceObject;
  16. extern LIST_ENTRY AfdEndpointListHead;
  17. extern LIST_ENTRY AfdConstrainedEndpointListHead;
  18. extern LIST_ENTRY AfdPollListHead;
  19. extern AFD_QSPIN_LOCK AfdPollListLock;
  20. extern LIST_ENTRY AfdTransportInfoListHead;
  21. extern KEVENT AfdContextWaitEvent;
  22. #define AFD_CONTEXT_BUSY ((PVOID)-1)
  23. #define AFD_CONTEXT_WAITING ((PVOID)-2)
  24. extern PKPROCESS AfdSystemProcess;
  25. extern FAST_IO_DISPATCH AfdFastIoDispatch;
  26. //
  27. // Global data which must always be in nonpaged pool,
  28. // even when the driver is paged out (resource, lookaside lists).
  29. //
  30. PAFD_GLOBAL_DATA AfdGlobalData;
  31. #define AfdResource (&AfdGlobalData->Resource)
  32. #define AfdLookasideLists (AfdGlobalData)
  33. #define AfdAlignmentTable (AfdGlobalData->BufferAlignmentTable)
  34. //
  35. // Globals for dealing with AFD's executive worker thread.
  36. //
  37. extern LIST_ENTRY AfdWorkQueueListHead;
  38. extern BOOLEAN AfdWorkThreadRunning;
  39. extern PIO_WORKITEM AfdWorkQueueItem;
  40. //
  41. // Globals to track the buffers used by AFD.
  42. //
  43. extern ULONG AfdLargeBufferListDepth;
  44. #define AFD_SM_DEFAULT_LARGE_LIST_DEPTH 0
  45. #define AFD_MM_DEFAULT_LARGE_LIST_DEPTH 2
  46. #define AFD_LM_DEFAULT_LARGE_LIST_DEPTH 10
  47. extern ULONG AfdMediumBufferListDepth;
  48. #define AFD_SM_DEFAULT_MEDIUM_LIST_DEPTH 4
  49. #define AFD_MM_DEFAULT_MEDIUM_LIST_DEPTH 8
  50. #define AFD_LM_DEFAULT_MEDIUM_LIST_DEPTH 24
  51. extern ULONG AfdSmallBufferListDepth;
  52. #define AFD_SM_DEFAULT_SMALL_LIST_DEPTH 8
  53. #define AFD_MM_DEFAULT_SMALL_LIST_DEPTH 16
  54. #define AFD_LM_DEFAULT_SMALL_LIST_DEPTH 32
  55. extern ULONG AfdBufferTagListDepth;
  56. #define AFD_SM_DEFAULT_TAG_LIST_DEPTH 16
  57. #define AFD_MM_DEFAULT_TAG_LIST_DEPTH 32
  58. #define AFD_LM_DEFAULT_TAG_LIST_DEPTH 64
  59. extern ULONG AfdLargeBufferSize;
  60. // default value is AfdBufferLengthForOnePage
  61. extern ULONG AfdMediumBufferSize;
  62. #define AFD_DEFAULT_MEDIUM_BUFFER_SIZE 1504
  63. extern ULONG AfdSmallBufferSize;
  64. #define AFD_DEFAULT_SMALL_BUFFER_SIZE 128
  65. extern ULONG AfdBufferTagSize;
  66. #define AFD_DEFAULT_TAG_BUFFER_SIZE 0
  67. extern ULONG AfdStandardAddressLength;
  68. #define AFD_DEFAULT_STD_ADDRESS_LENGTH sizeof(TA_IP_ADDRESS)
  69. extern ULONG AfdBufferLengthForOnePage;
  70. extern ULONG AfdBufferAlignment;
  71. #define AFD_MINIMUM_BUFFER_ALIGNMENT \
  72. max(TYPE_ALIGNMENT(TRANSPORT_ADDRESS), \
  73. max(TYPE_ALIGNMENT(KAPC), \
  74. max(TYPE_ALIGNMENT(WORK_QUEUE_ITEM), \
  75. max(TYPE_ALIGNMENT(AFD_BUFFER), \
  76. max(TYPE_ALIGNMENT(MDL), \
  77. max(TYPE_ALIGNMENT(IRP), \
  78. MEMORY_ALLOCATION_ALIGNMENT))))))
  79. extern ULONG AfdAlignmentTableSize;
  80. extern ULONG AfdAlignmentOverhead;
  81. extern ULONG AfdBufferOverhead;
  82. //
  83. // Globals for tuning TransmitFile().
  84. //
  85. extern LIST_ENTRY AfdQueuedTransmitFileListHead;
  86. extern AFD_QSPIN_LOCK AfdQueuedTransmitFileSpinLock;
  87. extern ULONG AfdActiveTransmitFileCount;
  88. extern ULONG AfdMaxActiveTransmitFileCount;
  89. #define AFD_DEFAULT_MAX_ACTIVE_TRANSMIT_FILE_COUNT 2
  90. extern ULONG AfdDefaultTransmitWorker;
  91. #define AFD_DEFAULT_TRANSMIT_WORKER AFD_TF_USE_SYSTEM_THREAD
  92. #define AFD_MAX_FAST_TRANSPORT_ADDRESS sizeof (TA_IP6_ADDRESS)
  93. //
  94. // Various pieces of configuration information, with default values.
  95. //
  96. extern CCHAR AfdIrpStackSize;
  97. extern CCHAR AfdTdiStackSize;
  98. #ifdef _AFD_VARIABLE_STACK_
  99. extern CCHAR AfdMaxStackSize;
  100. #endif // _AFD_VARIABLE_STACK_
  101. #define AFD_DEFAULT_IRP_STACK_SIZE 4
  102. extern CCHAR AfdPriorityBoost;
  103. #define AFD_DEFAULT_PRIORITY_BOOST 2
  104. extern ULONG AfdBlockingSendCopyThreshold;
  105. #define AFD_BLOCKING_SEND_COPY_THRESHOLD 65536
  106. extern ULONG AfdFastSendDatagramThreshold;
  107. #define AFD_FAST_SEND_DATAGRAM_THRESHOLD 1024
  108. extern ULONG AfdTPacketsCopyThreshold;
  109. #define AFD_TPACKETS_COPY_THRESHOLD AFD_DEFAULT_MEDIUM_BUFFER_SIZE
  110. extern PVOID AfdDiscardableCodeHandle;
  111. extern PKEVENT AfdLoaded;
  112. extern AFD_WORK_ITEM AfdUnloadWorker;
  113. extern BOOLEAN AfdVolatileConfig;
  114. extern HANDLE AfdParametersNotifyHandle;
  115. extern WORK_QUEUE_ITEM AfdParametersNotifyWorker;
  116. extern PKEVENT AfdParametersUnloadEvent;
  117. //
  118. // Various globals for SAN
  119. //
  120. extern HANDLE AfdSanCodeHandle;
  121. extern LIST_ENTRY AfdSanHelperList;
  122. extern PAFD_ENDPOINT AfdSanServiceHelper;
  123. extern HANDLE AfdSanServicePid;
  124. extern POBJECT_TYPE IoCompletionObjectType;
  125. extern LONG AfdSanProviderListSeqNum;
  126. extern ULONG AfdReceiveWindowSize;
  127. #define AFD_LM_DEFAULT_RECEIVE_WINDOW 8192
  128. #define AFD_MM_DEFAULT_RECEIVE_WINDOW 8192
  129. #define AFD_SM_DEFAULT_RECEIVE_WINDOW 4096
  130. extern ULONG AfdSendWindowSize;
  131. #define AFD_LM_DEFAULT_SEND_WINDOW 8192
  132. #define AFD_MM_DEFAULT_SEND_WINDOW 8192
  133. #define AFD_SM_DEFAULT_SEND_WINDOW 4096
  134. extern ULONG AfdBufferMultiplier;
  135. #define AFD_DEFAULT_BUFFER_MULTIPLIER 4
  136. extern ULONG AfdTransmitIoLength;
  137. #define AFD_LM_DEFAULT_TRANSMIT_IO_LENGTH 65536
  138. #define AFD_MM_DEFAULT_TRANSMIT_IO_LENGTH (PAGE_SIZE*2)
  139. #define AFD_SM_DEFAULT_TRANSMIT_IO_LENGTH PAGE_SIZE
  140. extern ULONG AfdMaxFastTransmit;
  141. #define AFD_DEFAULT_MAX_FAST_TRANSMIT 65536
  142. extern ULONG AfdMaxFastCopyTransmit;
  143. #define AFD_DEFAULT_MAX_FAST_COPY_TRANSMIT 128
  144. extern LONG AfdEndpointsOpened;
  145. extern LONG AfdEndpointsCleanedUp;
  146. extern LONG AfdEndpointsClosed;
  147. #define AFD_ENDPOINTS_FREEING_MAX 10
  148. extern LONG AfdEndpointsFreeing;
  149. #define AFD_CONNECTIONS_FREEING_MAX 10
  150. extern LONG AfdConnectionsFreeing;
  151. extern BOOLEAN AfdIgnorePushBitOnReceives;
  152. extern BOOLEAN AfdEnableDynamicBacklog;
  153. #define AFD_DEFAULT_ENABLE_DYNAMIC_BACKLOG FALSE
  154. extern LONG AfdMinimumDynamicBacklog;
  155. #define AFD_DEFAULT_MINIMUM_DYNAMIC_BACKLOG 0
  156. extern LONG AfdMaximumDynamicBacklog;
  157. #define AFD_DEFAULT_MAXIMUM_DYNAMIC_BACKLOG 0
  158. extern LONG AfdDynamicBacklogGrowthDelta;
  159. #define AFD_DEFAULT_DYNAMIC_BACKLOG_GROWTH_DELTA 0
  160. // Maximum number of free connections that we keep
  161. // on listening endpoint. This is not the same as a backlog,
  162. // it is just a policy on connection object reuse via AcceptEx
  163. // We stop reusing if we have that many free objects in the list
  164. // Currently the main reason for this limit is the ability to use the
  165. // SLists which have USHORT for item count.
  166. #define AFD_MAXIMUM_FREE_CONNECTIONS 32767
  167. //
  168. // These are limits on backlog in AFD_START_LISTEN
  169. // Application can work around this limit by posting AcceptEx(-s)
  170. //
  171. #define AFD_MAXIMUM_BACKLOG_NTS 200
  172. #define AFD_MAXIMUM_BACKLOG_NTW 5
  173. #define AFD_MINIMUM_BACKLOG 1
  174. extern BOOLEAN AfdDisableRawSecurity;
  175. extern PSECURITY_DESCRIPTOR AfdAdminSecurityDescriptor;
  176. extern SECURITY_DESCRIPTOR AfdEmptySd;
  177. extern BOOLEAN AfdDisableDirectSuperAccept;
  178. extern BOOLEAN AfdDisableChainedReceive;
  179. #ifdef TDI_SERVICE_SEND_AND_DISCONNECT
  180. extern BOOLEAN AfdUseTdiSendAndDisconnect;
  181. #endif //TDI_SERVICE_SEND_AND_DISCONNECT
  182. #define AFD_MINIMUM_TPINFO_ELEMENT_COUNT 3 // For transmit file compatibility.
  183. extern ULONG AfdDefaultTpInfoElementCount;
  184. //
  185. // Data for transport address lists and queued change queries
  186. //
  187. extern HANDLE AfdBindingHandle;
  188. extern LIST_ENTRY AfdAddressEntryList;
  189. extern LIST_ENTRY AfdAddressChangeList;
  190. extern PERESOURCE AfdAddressListLock;
  191. extern AFD_QSPIN_LOCK AfdAddressChangeLock;
  192. extern PERESOURCE AfdTdiPnPHandlerLock;
  193. extern AFD_WORK_ITEM AfdPnPDeregisterWorker;
  194. extern IO_STATUS_BLOCK AfdDontCareIoStatus;
  195. // Holds TDI connect timeout (-1).
  196. extern const LARGE_INTEGER AfdInfiniteTimeout;
  197. extern SLIST_HEADER AfdLRList;
  198. extern KDPC AfdLRListDpc;
  199. extern KTIMER AfdLRListTimer;
  200. extern AFD_WORK_ITEM AfdLRListWorker;
  201. extern LONG AfdLRListCount;
  202. extern SLIST_HEADER AfdLRFileMdlList;
  203. extern AFD_LR_LIST_ITEM AfdLRFileMdlListItem;
  204. #if AFD_PERF_DBG
  205. extern LONG AfdFullReceiveIndications;
  206. extern LONG AfdPartialReceiveIndications;
  207. extern LONG AfdFullReceiveDatagramIndications;
  208. extern LONG AfdPartialReceiveDatagramIndications;
  209. extern LONG AfdFastSendsSucceeded;
  210. extern LONG AfdFastSendsFailed;
  211. extern LONG AfdFastReceivesSucceeded;
  212. extern LONG AfdFastReceivesFailed;
  213. extern LONG AfdFastSendDatagramsSucceeded;
  214. extern LONG AfdFastSendDatagramsFailed;
  215. extern LONG AfdFastReceiveDatagramsSucceeded;
  216. extern LONG AfdFastReceiveDatagramsFailed;
  217. extern LONG AfdFastReadsSucceeded;
  218. extern LONG AfdFastReadsFailed;
  219. extern LONG AfdFastWritesSucceeded;
  220. extern LONG AfdFastWritesFailed;
  221. extern LONG AfdFastTfSucceeded;
  222. extern LONG AfdFastTfFailed;
  223. extern LONG AfdFastTfReadFailed;
  224. extern LONG AfdTPWorkersExecuted;
  225. extern LONG AfdTPRequests;
  226. extern BOOLEAN AfdDisableFastIo;
  227. extern BOOLEAN AfdDisableConnectionReuse;
  228. #endif // if AFD_PERF_DBG
  229. #if AFD_KEEP_STATS
  230. extern AFD_QUOTA_STATS AfdQuotaStats;
  231. extern AFD_HANDLE_STATS AfdHandleStats;
  232. extern AFD_QUEUE_STATS AfdQueueStats;
  233. extern AFD_CONNECTION_STATS AfdConnectionStats;
  234. #endif // if AFD_KEEP_STATS
  235. #if DBG
  236. extern BOOLEAN AfdUsePrivateAssert;
  237. #endif
  238. #ifdef _WIN64
  239. extern QOS32 AfdDefaultQos32;
  240. #endif
  241. extern QOS AfdDefaultQos;
  242. ULONG AfdIoctlTable[AFD_NUM_IOCTLS];
  243. PAFD_IMMEDIATE_CALL AfdImmediateCallDispatch[AFD_NUM_IOCTLS];
  244. PAFD_IRP_CALL AfdIrpCallDispatch[AFD_NUM_IOCTLS];
  245. #define AFD_FAST_CONNECT_DATA_SIZE 256
  246. #endif // ndef _AFDDATA_