Source code of Windows XP (NT5)
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.

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