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.

889 lines
29 KiB

  1. /*++
  2. Copyright (c) 1995-1999 Microsoft Corporation
  3. Module Name:
  4. globals.h
  5. Abstract:
  6. global defines and definitions
  7. Author:
  8. Charlie Wickham (charlwi) 19-Apr-1996
  9. Revision History:
  10. --*/
  11. #ifndef _GLOBALS_
  12. #define _GLOBALS_
  13. //
  14. // Macros
  15. //
  16. #define IsDeviceStateOn(_a) ((_a)->MPDeviceState == NdisDeviceStateD0 && (_a)->PTDeviceState == NdisDeviceStateD0)
  17. #define IsBestEffortVc(_vc) (_vc->Flags & GPC_CLIENT_BEST_EFFORT_VC)
  18. #define InitGpcClientVc(x, flags, _adapter) \
  19. NdisZeroMemory((x), sizeof(GPC_CLIENT_VC)); \
  20. (x)->Adapter = (_adapter); \
  21. PS_INIT_SPIN_LOCK(&(x)->Lock); \
  22. (x)->RefCount = 1; \
  23. (x)->ClVcState = CL_CALL_PENDING; \
  24. (x)->Flags = (flags);
  25. // given a pointer to an NDIS_PACKET, return a pointer to PS' protocol
  26. // context area.
  27. //
  28. #define PS_SEND_PACKET_CONTEXT_FROM_PACKET(_pkt) \
  29. ((PPS_SEND_PACKET_CONTEXT)((_pkt)->ProtocolReserved))
  30. #define PS_RECV_PACKET_CONTEXT_FROM_PACKET(_pkt) \
  31. ((PPS_RECV_PACKET_CONTEXT)((_pkt)->MiniportReserved))
  32. #define MIN_PACKET_POOL_SIZE 0x000000FF
  33. #define MAX_PACKET_POOL_SIZE 0x0000FFFF-MIN_PACKET_POOL_SIZE
  34. #define DEFAULT_MAX_OUTSTANDING_SENDS 0xFFFFFFFF /* Just making sure we don't do DRR by default..*/
  35. #define DEFAULT_ISSLOW_TOKENRATE 8192 /* In Bytes per second = 64 Kbps */
  36. #define DEFAULT_ISSLOW_PACKETSIZE 200 /* In Bytes */
  37. #define DEFAULT_ISSLOW_FRAGMENT_SIZE 100 /* In Bytes */
  38. #define DEFAULT_ISSLOW_LINKSPEED 19200 /* In Bytes per second = 128 Kbps */
  39. #define PS_IP_SERVICETYPE_CONFORMING_BESTEFFORT_DEFAULT 0
  40. #define PS_IP_SERVICETYPE_CONFORMING_CONTROLLEDLOAD_DEFAULT 0x18
  41. #define PS_IP_SERVICETYPE_CONFORMING_GUARANTEED_DEFAULT 0x28
  42. #define PS_IP_SERVICETYPE_CONFORMING_QUALITATIVE_DEFAULT 0
  43. #define PS_IP_SERVICETYPE_CONFORMING_NETWORK_CONTROL_DEFAULT 0x30
  44. #define PS_IP_SERVICETYPE_CONFORMING_TCPTRAFFIC_DEFAULT 0
  45. #define PS_IP_SERVICETYPE_NONCONFORMING_BESTEFFORT_DEFAULT 0
  46. #define PS_IP_SERVICETYPE_NONCONFORMING_CONTROLLEDLOAD_DEFAULT 0
  47. #define PS_IP_SERVICETYPE_NONCONFORMING_GUARANTEED_DEFAULT 0
  48. #define PS_IP_SERVICETYPE_NONCONFORMING_QUALITATIVE_DEFAULT 0
  49. #define PS_IP_SERVICETYPE_NONCONFORMING_NETWORK_CONTROL_DEFAULT 0
  50. #define PS_IP_SERVICETYPE_NONCONFORMING_TCPTRAFFIC_DEFAULT 0
  51. #define PS_IP_DS_CODEPOINT_MASK 0x03 //
  52. #define PREC_MAX_VALUE 0x3f // Range for the prec value.
  53. #define PS_USER_SERVICETYPE_NONCONFORMING_DEFAULT 1
  54. #define PS_USER_SERVICETYPE_BESTEFFORT_DEFAULT 0
  55. #define PS_USER_SERVICETYPE_CONTROLLEDLOAD_DEFAULT 4
  56. #define PS_USER_SERVICETYPE_GUARANTEED_DEFAULT 5
  57. #define PS_USER_SERVICETYPE_QUALITATIVE_DEFAULT 0
  58. #define PS_USER_SERVICETYPE_NETWORK_CONTROL_DEFAULT 7
  59. #define PS_USER_SERVICETYPE_TCPTRAFFIC_DEFAULT 0
  60. #define USER_PRIORITY_MAX_VALUE 7 // Range (0-7) for 802.1p
  61. #define WAN_TABLE_INITIAL_SIZE 16
  62. #define WAN_TABLE_INCREMENT 32
  63. extern PULONG_PTR g_WanLinkTable;
  64. extern USHORT g_NextWanIndex;
  65. extern USHORT g_WanTableSize;
  66. // Timer Wheel params //
  67. extern ULONG TimerTag;
  68. extern ULONG TsTag;
  69. #define INSTANCE_ID_SIZE (sizeof(WCHAR) * 20)
  70. //
  71. // the TC-API supports the following service types.
  72. //
  73. // SERVICETYPE_BESTEFFORT
  74. // SERVICETYPE_NETWORK_CONTROL
  75. // SERVICETYPE_QUALITATIVE
  76. // SERVICETYPE_CONTROLLEDLOAD
  77. // SERVICETYPE_GUARANTEED
  78. // SERVICETYPE_NONCONFORMING
  79. //
  80. #define NUM_TC_SERVICETYPES 6
  81. //
  82. // These are the states for the GPC client's VCs. We need to keep a fair
  83. // amount of state because we can get closes from the call manager below us,
  84. // from an unbind, or from the GPC.
  85. //
  86. typedef enum _CL_VC_STATE {
  87. CL_VC_INITIALIZED = 1,
  88. CL_CALL_PENDING,
  89. CL_INTERNAL_CALL_COMPLETE,
  90. CL_CALL_COMPLETE,
  91. CL_MODIFY_PENDING,
  92. CL_GPC_CLOSE_PENDING,
  93. CL_INTERNAL_CLOSE_PENDING
  94. } CL_VC_STATE;
  95. typedef enum _PS_DEVICE_STATE {
  96. PS_DEVICE_STATE_READY = 0,
  97. PS_DEVICE_STATE_ADDING,
  98. PS_DEVICE_STATE_DELETING
  99. } PS_DEVICE_STATE;
  100. extern ULONG CreateDeviceMutex;
  101. //
  102. // Simple Mutual Exclusion constructs used in preference to
  103. // using KeXXX calls since we don't have Mutex calls in NDIS.
  104. // These can only be called at passive IRQL.
  105. //
  106. #define MUX_ACQUIRE_MUTEX(_pMutexCounter) \
  107. { \
  108. while (NdisInterlockedIncrement(_pMutexCounter) != 1) \
  109. { \
  110. NdisInterlockedDecrement(_pMutexCounter); \
  111. NdisMSleep(10000); \
  112. } \
  113. }
  114. #define MUX_RELEASE_MUTEX(_pMutexCounter) \
  115. { \
  116. NdisInterlockedDecrement(_pMutexCounter); \
  117. }
  118. //
  119. // CL_VC_STATE is further modified by these flags.
  120. //
  121. // Indicates that the GPC has requested a close,
  122. // which we will need to complete.
  123. // COMPLETE_GPC_CLOSE : GPC has requested a close which we will need to
  124. // complete.
  125. // INTERNAL_CLOSE_REQUESTED: Indicates that an internal close has been
  126. // requested and should be processed upon completion
  127. // of the call.
  128. #define GPC_CLOSE_REQUESTED 0x00000001
  129. #define INTERNAL_CLOSE_REQUESTED 0x00000002
  130. #define GPC_CLIENT_BEST_EFFORT_VC 0x00000008
  131. #define GPC_MODIFY_REQUESTED 0x00000010
  132. #define GPC_WANLINK_VC 0x00000020
  133. #define GPC_ISSLOW_FLOW 0x00000040
  134. //
  135. // These are the states for the BE Vc. In addition to keeping the standard
  136. // CL Vc states for this Vc, we also keep some specific state. The BE Vc
  137. // is initially BE_VC_INITIALIZED. It becomes BE_VC_RUNNING after it has
  138. // successfully been opened. When it is time to shut down the BE Vc, it
  139. // goes to BE_VC_CLOSING if there are no pending packets, or to
  140. // BE_WAITING_FOR_PENDING_PACKETS, if there are pending packets.
  141. //
  142. extern PUCHAR GpcVcState[];
  143. //
  144. // The best effort VC structure for each adapter is contained in
  145. // the adapter structure. Also - each vc points to the adapter
  146. // with which it is associated. Therefore, pointers to best-effort
  147. // VCs can be identified beause they are the same address as the
  148. // offset of the best-effort VC in the adapter struct with which
  149. // they are associated.
  150. //
  151. //
  152. // current state of PS's MP device
  153. //
  154. typedef enum _ADAPTER_STATE {
  155. AdapterStateInitializing = 1,
  156. AdapterStateRunning,
  157. AdapterStateWaiting,
  158. AdapterStateDisabled,
  159. AdapterStateClosing,
  160. AdapterStateClosed
  161. } ADAPTER_STATE;
  162. typedef enum _DRIVER_STATE {
  163. DriverStateLoaded = 1,
  164. DriverStateUnloading,
  165. DriverStateUnloaded
  166. } DRIVER_STATE;
  167. typedef enum _ADAPTER_MODE {
  168. AdapterModeDiffservFlow = 1,
  169. AdapterModeRsvpFlow
  170. } ADAPTER_MODE;
  171. //
  172. // shutdown mask values
  173. //
  174. #define SHUTDOWN_CLOSE_WAN_ADDR_FAMILY 0x00000002 // Per adapter
  175. #define SHUTDOWN_DELETE_PIPE 0x00000008 // Per adapter
  176. #define SHUTDOWN_FREE_PS_CONTEXT 0x00000010 // Per adapter
  177. #define SHUTDOWN_UNBIND_CALLED 0x00000020 // Per adapter
  178. #define SHUTDOWN_MPHALT_CALLED 0x00000040 // Per adapter
  179. #define SHUTDOWN_CLEANUP_ADAPTER 0x00000080 // Per adapter
  180. #define SHUTDOWN_PROTOCOL_UNLOAD 0x00000100 // Per adapter
  181. #define SHUTDOWN_BIND_CALLED 0x00000200 // Per adapter
  182. #define SHUTDOWN_MPINIT_CALLED 0x00000400 // per adapter
  183. #define SHUTDOWN_RELEASE_TIMERQ 0x00010000
  184. #define SHUTDOWN_DEREGISTER_PROTOCOL 0x00040000
  185. #define SHUTDOWN_DELETE_DEVICE 0x00080000
  186. #define SHUTDOWN_DELETE_SYMLINK 0x00100000
  187. #define SHUTDOWN_DEREGISTER_GPC 0x00200000
  188. #define SHUTDOWN_DEREGISTER_MINIPORT 0x00400000
  189. #define LOCKED 0
  190. #define UNLOCKED 1
  191. #define NEW_VC 0
  192. #define MODIFY_VC 1
  193. //
  194. // QOS related
  195. //
  196. #define QOS_UNSPECIFIED (ULONG)-1
  197. //
  198. // bandwidth related
  199. //
  200. #define UNSPECIFIED_RATE -1 // indefinite bandwidth
  201. #define RESERVABLE_FRACTION 80 // percentage of link speed
  202. //
  203. // state flags for WAN AF bindings
  204. //
  205. #define WAN_ADDR_FAMILY_OPEN 0x00000001
  206. //
  207. // types of VCs. Note that dummy VCs are created to represent WAN links.
  208. // This allows them to be registered with WMI. They are differentiated by
  209. // the VC type.
  210. //
  211. #define VC_FLOW 1
  212. #define VC_WAN_INTFC 2
  213. typedef struct _PS_SPIN_LOCK
  214. {
  215. NDIS_SPIN_LOCK Lock;
  216. #if DBG
  217. LONG LockAcquired;
  218. UCHAR LastAcquiredFile[8];
  219. ULONG LastAcquiredLine;
  220. UCHAR LastReleasedFile[8];
  221. ULONG LastReleasedLine;
  222. #endif
  223. } PS_SPIN_LOCK, *PPS_SPIN_LOCK;
  224. #define BEVC_LIST_LEN 3 // We have these many BEVCs to do DRR.
  225. #define PORT_LIST_LEN 1 // Each BEVC will store upto these many port numbers.
  226. typedef struct _GPC_CLIENT_VC {
  227. //
  228. // LLTag - for tracking allocation from and freeing to LL list.
  229. //
  230. // Lock
  231. //
  232. // RefCount
  233. //
  234. //
  235. // Linkage - to put on the adapter block list
  236. //
  237. // ClVcState
  238. //
  239. // Flags - further modify state
  240. //
  241. // AdapterBlk - pointer to associated ADAPTER_BLK context
  242. //
  243. // CfInfoHandle - handle to CfInfo
  244. //
  245. // InstanceName - copy of instance name registered with WMI for this flow
  246. //
  247. // CfType - GPC classification family associated with this VC
  248. //
  249. // VcHandle - handle to VC created for this flow
  250. //
  251. // CallParameters - pointer to call parameters saved while a MakeCall or
  252. // ModifyCallQoS is in progress
  253. //
  254. // AdapterStats - pointer to the Adapter Stats (for non WAN links) or
  255. // per WAN stats.
  256. STRUCT_LLTAG;
  257. ULONG RefCount;
  258. CL_VC_STATE ClVcState;
  259. struct _ADAPTER *Adapter;
  260. ULONG Flags;
  261. PS_SPIN_LOCK Lock;
  262. LIST_ENTRY Linkage;
  263. NDIS_STRING InstanceName;
  264. UCHAR IPPrecedenceNonConforming;
  265. UCHAR UserPriorityConforming;
  266. UCHAR UserPriorityNonConforming;
  267. GPC_HANDLE CfInfoHandle;
  268. PCF_INFO_QOS CfInfoQoS;
  269. PCF_INFO_QOS ModifyCfInfoQoS;
  270. GPC_HANDLE CfType;
  271. NDIS_HANDLE NdisWanVcHandle;
  272. PCO_CALL_PARAMETERS CallParameters;
  273. PCO_CALL_PARAMETERS ModifyCallParameters;
  274. PPS_ADAPTER_STATS AdapterStats;
  275. struct _PS_WAN_LINK *WanLink;
  276. //
  277. // For the Scheduling Components
  278. //
  279. PPS_FLOW_CONTEXT PsFlowContext;
  280. PS_FLOW_STATS Stats;
  281. ULONG TokenRateChange;
  282. ULONG RemainingBandwidthIncreased;
  283. ULONG ShapeTokenRate;
  284. ULONG ISSLOWFragmentSize;
  285. //
  286. // These are used to optmize the send path. Over non Wan links, these point to
  287. // Adapter->PsComponent and Adapter->PsPipeContext. Over WanLinks, these point
  288. // to WanLink->PsComponent and WanLink->PspipeContext.
  289. //
  290. PPSI_INFO PsComponent;
  291. PPS_PIPE_CONTEXT PsPipeContext;
  292. PSU_SEND_COMPLETE SendComplete;
  293. PPS_PIPE_CONTEXT SendCompletePipeContext;
  294. //
  295. // This flag is added to indicate whether the RemoveFlow() should be called upon ref-count=0
  296. //
  297. BOOL bRemoveFlow;
  298. // We'll hold on to flows in this array //
  299. USHORT SrcPort[PORT_LIST_LEN];
  300. USHORT DstPort[PORT_LIST_LEN];
  301. USHORT NextSlot;
  302. } GPC_CLIENT_VC, *PGPC_CLIENT_VC;
  303. typedef struct _DIFFSERV_MAPPING {
  304. PGPC_CLIENT_VC Vc;
  305. UCHAR ConformingOutboundDSField;
  306. UCHAR NonConformingOutboundDSField;
  307. UCHAR ConformingUserPriority;
  308. UCHAR NonConformingUserPriority;
  309. } DIFFSERV_MAPPING, *PDIFFSERV_MAPPING;
  310. typedef struct _ADAPTER {
  311. LIST_ENTRY Linkage;
  312. //
  313. // MpDeviceName, UpperBinding - unicode device names for
  314. // the underlying MP device and the UpperBinding exposed.
  315. // The buffers for the strings are allocated with the
  316. // adapter and need to be freed with it.
  317. //
  318. // ShutdownMask - mask of operations to perform during
  319. // unbinding from lower MP
  320. //
  321. PS_SPIN_LOCK Lock;
  322. REF_CNT RefCount;
  323. NDIS_STRING MpDeviceName;
  324. NDIS_STRING UpperBinding;
  325. NDIS_STRING WMIInstanceName;
  326. NDIS_STRING ProfileName;
  327. // Points to the "psched\parameter\adapter\...\"
  328. NDIS_STRING RegistryPath;
  329. ULONG ShutdownMask;
  330. PNETWORK_ADDRESS_LIST IpNetAddressList;
  331. PNETWORK_ADDRESS_LIST IpxNetAddressList;
  332. //
  333. // PsMpState - init'ing, running, or closing
  334. //
  335. // PsNdisHandle - the handle that identifies the PS device to NDIS
  336. //
  337. // BlockingEvent - used to synchronize execution of functions that are
  338. // awaiting completion
  339. //
  340. // FinalStatus - holds status returned in completion routine
  341. //
  342. // SendBlockPool - Pool Handle for per-packet info in the send path
  343. // SendPacketPool - Pool handle for NDIS packets in the send path.
  344. // RecvPacketPool - Pool handle for NDIS packets in the recv path.
  345. //
  346. // RawLinkSpeed - link speed as determined by OID_GEN_LINK_SPEED,
  347. // in 100 bps units.
  348. //
  349. // BestEffortLimit - Bps for internal best effort VC;
  350. //
  351. // NonBestEffortLimit - Bps for total non best effort flows;
  352. //
  353. // ReservationLimitValue - The % of bandwidth that has to be used for non b/e flows.
  354. //
  355. // BestEffortVc - internal best effort VC struct
  356. //
  357. // BestEffortVcCreated - set after the VC has been created
  358. //
  359. // WanLinkList - list of WAN links on the underlying NDISWAN
  360. //
  361. ADAPTER_STATE PsMpState;
  362. NDIS_HANDLE PsNdisHandle;
  363. NDIS_EVENT BlockingEvent;
  364. NDIS_EVENT RefEvent;
  365. NDIS_EVENT MpInitializeEvent;
  366. NDIS_EVENT LocalRequestEvent;
  367. NDIS_STATUS FinalStatus;
  368. NDIS_HANDLE SendPacketPool;
  369. NDIS_HANDLE RecvPacketPool;
  370. NDIS_HANDLE SendBlockPool;
  371. ULONG RawLinkSpeed;
  372. ULONG BestEffortLimit;
  373. ULONG NonBestEffortLimit;
  374. ULONG ReservationLimitValue;
  375. GPC_CLIENT_VC BestEffortVc;
  376. LIST_ENTRY WanLinkList;
  377. //
  378. // Scheduler info:
  379. //
  380. // PSComponent - pointer to info first scheduling component
  381. //
  382. // PSPipeContext - scheduling component's context area for pipe
  383. //
  384. // BestEffortPSFlowContext - scheduling component's context area
  385. // for best effort VC
  386. //
  387. // FlowContextLength - length of flow context area for scheduler
  388. //
  389. // PacketContextLength - length of packet context area
  390. //
  391. // SendComplete - scheduler's send completion routine
  392. //
  393. PPSI_INFO PsComponent;
  394. PPS_PIPE_CONTEXT PsPipeContext;
  395. ULONG PipeContextLength;
  396. BOOLEAN PipeHasResources;
  397. ULONG FlowContextLength;
  398. ULONG PacketContextLength;
  399. ULONG ClassMapContextLength;
  400. //
  401. // Underlying adapter info - handle, type, etc.
  402. // LowerMPHandle - the binding handle to the underlying MP
  403. // BindContext - used in BindAdapterHandler
  404. // MediaType - self explanatory I would hope
  405. // LinkSpeed - in 100 bits/sec
  406. // TotalSize - max # of bytes including the header.
  407. // RemainingBandWidth - amount of schedulable bytes/second left on this adapter
  408. // PipeFlags - copy of flags parameter handed to scheduler during pipe initialization
  409. // HeaderSize - number of bytes in MAC header for this adapter
  410. // IPHeaderOffset - offset of the IP header - This could be different from HeaderSize because
  411. // the transport could add a LLC/SNAP header.
  412. // Stats - per adapter stats counters
  413. // SDModeControlledLoad - Default handling for non-conforming controlled load traffic
  414. // SDModeGuaranteed - Default handling for non-conforming guaranteed service traffic
  415. // MaxOutstandingSends - Maximum number of outstanding sends allowed
  416. NDIS_HANDLE LowerMpHandle;
  417. NDIS_MEDIUM MediaType;
  418. NDIS_HANDLE BindContext;
  419. ULONG LinkSpeed;
  420. ULONG TotalSize;
  421. ULONG RemainingBandWidth;
  422. ULONG PipeFlags;
  423. ULONG HeaderSize;
  424. ULONG IPHeaderOffset;
  425. PS_ADAPTER_STATS Stats;
  426. ULONG SDModeControlledLoad;
  427. ULONG SDModeGuaranteed;
  428. ULONG SDModeNetworkControl;
  429. ULONG SDModeQualitative;
  430. ULONG MaxOutstandingSends;
  431. //
  432. // WanCmHandle - handle to the WAN call manager, as returned from
  433. // NdisClOpenAddressFamily.
  434. //
  435. NDIS_HANDLE WanCmHandle;
  436. //
  437. // WanBindingState - state of WAN call manager binding
  438. ULONG WanBindingState;
  439. UCHAR IPServiceTypeBestEffort;
  440. UCHAR IPServiceTypeControlledLoad;
  441. UCHAR IPServiceTypeGuaranteed;
  442. UCHAR IPServiceTypeNetworkControl;
  443. UCHAR IPServiceTypeQualitative;
  444. UCHAR IPServiceTypeTcpTraffic;
  445. UCHAR IPServiceTypeBestEffortNC;
  446. UCHAR IPServiceTypeControlledLoadNC;
  447. UCHAR IPServiceTypeGuaranteedNC;
  448. UCHAR IPServiceTypeNetworkControlNC;
  449. UCHAR IPServiceTypeQualitativeNC;
  450. UCHAR IPServiceTypeTcpTrafficNC;
  451. UCHAR UserServiceTypeNonConforming;
  452. UCHAR UserServiceTypeBestEffort;
  453. UCHAR UserServiceTypeControlledLoad;
  454. UCHAR UserServiceTypeGuaranteed;
  455. UCHAR UserServiceTypeNetworkControl;
  456. UCHAR UserServiceTypeQualitative;
  457. UCHAR UserServiceTypeTcpTraffic;
  458. //
  459. // No of CfInfos - In the send path, this is used to determine whether we
  460. // have to classify the packet or send it over the b/e VC
  461. //
  462. ULONG CfInfosInstalled;
  463. ULONG FlowsInstalled;
  464. LIST_ENTRY GpcClientVcList;
  465. ULONG WanLinkCount;
  466. LARGE_INTEGER VcIndex;
  467. PDIFFSERV_MAPPING pDiffServMapping;
  468. ADAPTER_MODE AdapterMode;
  469. ULONG ISSLOWTokenRate;
  470. ULONG ISSLOWPacketSize;
  471. ULONG ISSLOWFragmentSize;
  472. ULONG ISSLOWLinkSpeed;
  473. BOOLEAN IndicateRcvComplete;
  474. BOOLEAN IfcNotification;
  475. BOOLEAN StandingBy;
  476. ULONG OutstandingNdisRequests;
  477. NDIS_DEVICE_POWER_STATE MPDeviceState;
  478. NDIS_DEVICE_POWER_STATE PTDeviceState;
  479. USHORT ProtocolType;
  480. struct _PS_NDIS_REQUEST *PendedNdisRequest;
  481. TC_INTERFACE_ID InterfaceID;
  482. } ADAPTER, *PADAPTER;
  483. //
  484. // Wan links are created when we get a WAN_LINE_UP from an underlying
  485. // NDISWAN. There may be multiple WAN links per adapter. Each WAN link
  486. // has a single best-effort VC on it and may have any number of additional
  487. // VCs (one per flow).
  488. //
  489. //
  490. // WAN VC - describes a VC associated with this WAN link
  491. //
  492. typedef enum _WAN_STATE {
  493. WanStateOpen = 1,
  494. WanStateClosing
  495. } WAN_STATE;
  496. typedef struct _PS_WAN_LINK
  497. {
  498. WAN_STATE State;
  499. LIST_ENTRY Linkage;
  500. ULONG RawLinkSpeed; // In 100 bps
  501. ULONG LinkSpeed; // In Bps (Bytes per second)
  502. UCHAR OriginalLocalMacAddress[ARP_802_ADDR_LENGTH];
  503. UCHAR OriginalRemoteMacAddress[ARP_802_ADDR_LENGTH];
  504. REF_CNT RefCount;
  505. DIAL_USAGE DialUsage;
  506. USHORT ProtocolType;
  507. ULONG LocalIpAddress;
  508. ULONG RemoteIpAddress;
  509. ULONG LocalIpxAddress;
  510. ULONG RemoteIpxAddress;
  511. PS_ADAPTER_STATS Stats;
  512. PS_SPIN_LOCK Lock;
  513. ULONG FlowsInstalled;
  514. NDIS_STRING InstanceName;
  515. NDIS_STRING MpDeviceName;
  516. PADAPTER Adapter;
  517. ULONG RemainingBandWidth;
  518. ULONG NonBestEffortLimit;
  519. PPSI_INFO PsComponent;
  520. PPS_PIPE_CONTEXT PsPipeContext;
  521. ULONG ShutdownMask;
  522. USHORT UniqueIndex;
  523. ETH_HEADER SendHeader;
  524. ETH_HEADER RecvHeader;
  525. ADAPTER_MODE AdapterMode;
  526. PDIFFSERV_MAPPING pDiffServMapping;
  527. ULONG CfInfosInstalled;
  528. TC_INTERFACE_ID InterfaceID;
  529. GPC_CLIENT_VC BestEffortVc;
  530. GPC_CLIENT_VC BeVcList[ BEVC_LIST_LEN ];
  531. int NextVc;
  532. } PS_WAN_LINK, *PPS_WAN_LINK;
  533. //
  534. // our NdisRequest super structure. There are two types of NdisRequests:
  535. // originated by the upper layer which go straight through to the
  536. // underlying miniport and originated by the PS. The latter also
  537. // degenerates into blocking and nonblocking.
  538. //
  539. // Since upper layer NdisRequests are unbundled to MPs, we need to
  540. // allocate our own structure to rebuild and issue the request to
  541. // the lower layer. We need some addt'l space to hold pointers to the
  542. // BytesWritten/BytesRead and BytesNeeded parameters of the original
  543. // request. These are tagged on at the end so the NdisRequest completion
  544. // routine can set those values in the NdisRequest originally issued to PS.
  545. //
  546. // There are allocated by NdisAllocateFromNPagedLookasideList, there is a STRUCT_LLTAG.
  547. // LocalRequest means the request was issued by PS and shouldn't be
  548. // completed to the higher layer. If a LocalCompletion routine is specified,
  549. // then this is a nonblocking request.
  550. //
  551. // OriginalNdisRequest is used to complete a higher layer CoRequest.
  552. //
  553. typedef VOID (*LOCAL_NDISREQUEST_COMPLETION_FUNCTION)(PADAPTER,
  554. NDIS_STATUS);
  555. typedef struct _PS_NDIS_REQUEST {
  556. NDIS_REQUEST ReqBuffer; // Must be first!!!
  557. STRUCT_LLTAG;
  558. PULONG BytesReadOrWritten;
  559. PULONG BytesNeeded;
  560. BOOLEAN LocalRequest;
  561. LOCAL_NDISREQUEST_COMPLETION_FUNCTION LocalCompletionFunc;
  562. } PS_NDIS_REQUEST, *PPS_NDIS_REQUEST;
  563. //
  564. // use Generic NdisRequest types to indicate NdisRequests that
  565. // were originated by PS
  566. //
  567. #define NdisRequestLocalSetInfo NdisRequestGeneric1
  568. #define NdisRequestLocalQueryInfo NdisRequestGeneric2
  569. //
  570. // Packet context structure. This area resides at the start of
  571. // the ProtocolReserved area of each packet
  572. //
  573. // Info - packet info block for this packet. Includes information
  574. // potentially needed by the scheduling components: queue links,
  575. // conformance time, packet length.
  576. //
  577. // AdapterVCLink - links packet on Adapter VC's list of outstanding
  578. // packets. Once a packet is removed from the timer Q for sending,
  579. // it is also removed from this list. This list is used to free
  580. // packets that are awaiting transmission when the adapter VC is
  581. // deactivate. Packets in the process of being transmitted
  582. // aren't linked since a reference was taken out for each packet
  583. // associated with the adapter VC.
  584. //
  585. // The following vars are used only during the sending of a packet:
  586. //
  587. // OriginalPacket - a pointer to the original packet (duh) handed to us by
  588. // the upper layer.
  589. //
  590. // AdapterVC - pointer back to AdapterVC struct. Used during send completion so
  591. // completion is propagated to higher layer in the correct manner
  592. //
  593. // SchedulingComponentInfo - Any packet context area required by the scheduling
  594. // components is stored after the PS's packet context. If none of the
  595. // components need additional context area, then this area is not included.
  596. //
  597. // MediaSpecificInfo - used to hold packet priority for MPs that allow packet
  598. // priority to be specified. Included in the proto reserved area only if
  599. // the lower MP supports priority queueing. Immediately follows the
  600. // packet context struct if included
  601. //
  602. // SubmittedToScheduler - some packets bypass the scheduler. These should not
  603. // be submitted to the scheduler's completion routine.
  604. //
  605. typedef struct _PS_SEND_PACKET_CONTEXT
  606. {
  607. PACKET_INFO_BLOCK Info;
  608. PNDIS_PACKET OriginalPacket;
  609. SINGLE_LIST_ENTRY FreeList;
  610. PGPC_CLIENT_VC Vc;
  611. } PS_SEND_PACKET_CONTEXT, *PPS_SEND_PACKET_CONTEXT;
  612. typedef struct _PS_RECV_PACKET_CONTEXT
  613. {
  614. PNDIS_PACKET OriginalPacket;
  615. } PS_RECV_PACKET_CONTEXT, *PPS_RECV_PACKET_CONTEXT;
  616. //
  617. // Ndis requires a minimum of 8 bytes for the MediaSpecific parameters.
  618. // We'll create a dummy media specific parmeter block:
  619. //
  620. typedef struct _PS_MEDIA_PARAMETERS{
  621. CO_MEDIA_PARAMETERS StdMediaParameters;
  622. UCHAR LinkId[6]; // Used by NdisWan
  623. NDIS_STRING InstanceName;
  624. } PS_MEDIA_PARAMETERS, *PPS_MEDIA_PARAMETERS;
  625. typedef struct _RUNNING_AVERAGE {
  626. ULONG *Elements;
  627. ULONG Index;
  628. ULONG Sum;
  629. ULONG Size;
  630. } RUNNING_AVERAGE, *PRUNNING_AVERAGE;
  631. #if CBQ
  632. //
  633. // Context used by AddCfInfo for "ClassMap" to be sent back
  634. // to the GPC.
  635. //
  636. typedef struct _CLASS_MAP_CONTEXT_BLK {
  637. PADAPTER Adapter;
  638. PPS_CLASS_MAP_CONTEXT ComponentContext;
  639. PPS_WAN_LINK WanLink;
  640. } CLASS_MAP_CONTEXT_BLK, *PCLASS_MAP_CONTEXT_BLK;
  641. #endif
  642. typedef struct _PS_INTERFACE_INDEX {
  643. PADAPTER Adapter;
  644. PPS_WAN_LINK WanLink;
  645. } PS_INTERFACE_INDEX_CONTEXT, *PPS_INTERFACE_INDEX_CONTEXT;
  646. //
  647. // define for determing if media is LAN oriented
  648. //
  649. #define NDIS_MEDIA_LAN( _adpt ) (( _adpt )->MediaType == NdisMedium802_3 || \
  650. ( _adpt )->MediaType == NdisMedium802_5 || \
  651. ( _adpt )->MediaType == NdisMediumFddi || \
  652. ( _adpt )->MediaType == NdisMediumDix)
  653. //
  654. // global vars (not based on a device instance)
  655. //
  656. extern ULONG InitShutdownMask;
  657. extern ULONG AdapterCount;
  658. extern ULONG DriverRefCount;
  659. extern BOOLEAN WMIInitialized;
  660. extern DRIVER_STATE gDriverState;
  661. extern LIST_ENTRY AdapterList;
  662. extern LIST_ENTRY PsComponentList;
  663. extern LIST_ENTRY PsProfileList;
  664. extern NDIS_HANDLE ClientProtocolHandle;
  665. extern NDIS_HANDLE CallMgrProtocolHandle;
  666. extern NDIS_HANDLE MpWrapperHandle;
  667. extern NDIS_HANDLE LmDriverHandle;
  668. extern NDIS_HANDLE PsDeviceHandle;
  669. extern PDRIVER_OBJECT PsDriverObject;
  670. extern PDEVICE_OBJECT PsDeviceObject;
  671. extern HANDLE PsDeviceHandle;
  672. extern NPAGED_LOOKASIDE_LIST NdisRequestLL;
  673. extern NPAGED_LOOKASIDE_LIST AdapterVcLL;
  674. extern NPAGED_LOOKASIDE_LIST ClientVcLL;
  675. extern NPAGED_LOOKASIDE_LIST GpcClientVcLL;
  676. extern NDIS_EVENT DriverUnloadEvent;
  677. extern NDIS_STRING PsDriverName;
  678. extern NDIS_STRING PsSymbolicName;
  679. extern NDIS_STRING PsMpName;
  680. extern NDIS_STRING WanPrefix;
  681. extern NDIS_STRING VcPrefix;
  682. extern NDIS_STRING MachineRegistryKey;
  683. extern PSI_INFO TbConformerInfo;
  684. extern PSI_INFO ShaperInfo;
  685. extern PSI_INFO DrrSequencerInfo;
  686. extern PSI_INFO SchedulerStubInfo;
  687. extern PSI_INFO TimeStmpInfo;
  688. extern PS_PROFILE DefaultSchedulerConfig;
  689. extern PS_PROCS PsProcs;
  690. extern ULONG gEnableAvgStats;
  691. extern ULONG gEnableWindowAdjustment;
  692. extern NDIS_STRING gsEnableWindowAdjustment;
  693. // Global locks
  694. extern PS_SPIN_LOCK AdapterListLock;
  695. extern PS_SPIN_LOCK DriverUnloadLock;
  696. // Timer
  697. extern ULONG gTimerResolutionActualTime;
  698. extern ULONG gTimerSet;
  699. //
  700. // ZAW
  701. //
  702. extern NDIS_EVENT gZAWEvent;
  703. extern ULONG gZAWState;
  704. #define ZAW_STATE_READY 0
  705. #define ZAW_STATE_IN_USE 1
  706. // GPC Interface
  707. #define PS_QOS_CF 0x00000001
  708. #define PS_CLASS_MAP_CF 0x00000002
  709. #define GPC_NO_MATCH (ULONG)-1
  710. extern GPC_EXPORTED_CALLS GpcEntries;
  711. extern GPC_HANDLE GpcQosClientHandle;
  712. #if CBQ
  713. extern GPC_HANDLE GpcClassMapClientHandle;
  714. #endif
  715. extern PS_DEVICE_STATE DeviceState;
  716. extern PDRIVER_DISPATCH DispatchTable[IRP_MJ_MAXIMUM_FUNCTION];
  717. //
  718. // NULL Component hacks for now [ShreeM]
  719. //
  720. extern PS_RECEIVE_PACKET TimeStmpRecvPacket;
  721. extern PS_RECEIVE_INDICATION TimeStmpRecvIndication;
  722. //
  723. // This is the RawLinkSpeed below which we trigger DRR
  724. //
  725. #define MAX_LINK_SPEED_FOR_DRR 7075 //( 56.6 * 1000 / 8) // 56.6 kbps converted to bytes/sec
  726. #endif/* _GLOBALS_ */
  727. /* end globals.h */