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.

555 lines
11 KiB

  1. /*++
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. PsStub.c
  5. Abstract:
  6. Scheduler stub. This module is the terminating module in the
  7. scheduling component stack. It just forwards packets on to the
  8. lower MP.
  9. Author:
  10. Environment:
  11. Kernel Mode
  12. Revision History:
  13. --*/
  14. #include "psched.h"
  15. #pragma hdrstop
  16. // The stub's pipe information
  17. typedef struct _PSSTUB_PIPE
  18. {
  19. // ContextInfo - Generic context info
  20. // Adapter - Pointer to adapter struct
  21. PS_PIPE_CONTEXT ContextInfo;
  22. PADAPTER Adapter;
  23. PSU_SEND_COMPLETE SendComplete;
  24. PPS_PIPE_CONTEXT SendCompletePipeContext;
  25. } PSSTUB_PIPE, *PPSSTUB_PIPE;
  26. // The stub's flow information
  27. typedef struct _PSSTUB_FLOW {
  28. // ContextInfo - Generic context info
  29. // AdapterVc - Pointer to adapter VC struct
  30. PS_FLOW_CONTEXT ContextInfo;
  31. PGPC_CLIENT_VC AdapterVc;
  32. } PSSTUB_FLOW, *PPSSTUB_FLOW;
  33. /* External */
  34. /* Static */
  35. /* Forward */
  36. NDIS_STATUS
  37. PsStubInitializePipe (
  38. IN HANDLE PsPipeContext,
  39. IN PPS_PIPE_PARAMETERS PipeParameters,
  40. IN PPS_PIPE_CONTEXT ComponentPipeContext,
  41. IN PPS_PROCS PsProcs,
  42. IN PPS_UPCALLS Upcalls
  43. );
  44. NDIS_STATUS
  45. PsStubModifyPipe (
  46. IN PPS_PIPE_CONTEXT PipeContext,
  47. IN PPS_PIPE_PARAMETERS PipeParameters
  48. );
  49. VOID
  50. PsStubDeletePipe (
  51. IN PPS_PIPE_CONTEXT PipeContext
  52. );
  53. NDIS_STATUS
  54. PsStubCreateFlow (
  55. IN PPS_PIPE_CONTEXT PipeContext,
  56. IN HANDLE PsFlowContext,
  57. IN PCO_CALL_PARAMETERS CallParameters,
  58. IN PPS_FLOW_CONTEXT ComponentFlowContext
  59. );
  60. NDIS_STATUS
  61. PsStubModifyFlow (
  62. IN PPS_PIPE_CONTEXT PipeContext,
  63. IN PPS_FLOW_CONTEXT FlowContext,
  64. IN PCO_CALL_PARAMETERS CallParameters
  65. );
  66. VOID
  67. PsStubDeleteFlow (
  68. IN PPS_PIPE_CONTEXT PipeContext,
  69. IN PPS_FLOW_CONTEXT FlowContext
  70. );
  71. VOID
  72. PsStubEmptyFlow (
  73. IN PPS_PIPE_CONTEXT PipeContext,
  74. IN PPS_FLOW_CONTEXT FlowContext
  75. );
  76. NDIS_STATUS
  77. PsStubCreateClassMap (
  78. IN PPS_PIPE_CONTEXT PipeContext,
  79. IN HANDLE PsClassMapContext,
  80. IN PTC_CLASS_MAP_FLOW ClassMap,
  81. IN PPS_CLASS_MAP_CONTEXT ComponentClassMapContext);
  82. NDIS_STATUS
  83. PsStubDeleteClassMap (
  84. IN PPS_PIPE_CONTEXT PipeContext,
  85. IN PPS_CLASS_MAP_CONTEXT ComponentClassMapContext);
  86. BOOLEAN
  87. PsStubSubmitPacket (
  88. IN PPS_PIPE_CONTEXT PipeContext,
  89. IN PPS_FLOW_CONTEXT FlowContext,
  90. IN PPS_CLASS_MAP_CONTEXT ClassMapContext,
  91. IN PPACKET_INFO_BLOCK Packet
  92. );
  93. VOID
  94. PsStubSetInformation (
  95. IN PPS_PIPE_CONTEXT ComponentPipeContext,
  96. IN PPS_FLOW_CONTEXT ComponentFlowContext,
  97. IN NDIS_OID Oid,
  98. IN ULONG Len,
  99. IN PVOID Data);
  100. VOID
  101. PsStubQueryInformation (
  102. IN PPS_PIPE_CONTEXT ComponentPipeContext,
  103. IN PPS_FLOW_CONTEXT ComponentFlowContext,
  104. IN NDIS_OID Oid,
  105. IN ULONG Len,
  106. IN PVOID Data,
  107. IN OUT PULONG BytesWritten,
  108. IN OUT PULONG BytesNeeded,
  109. IN OUT PNDIS_STATUS Status);
  110. /* End Forward */
  111. VOID
  112. InitializeSchedulerStub(
  113. PPSI_INFO Info)
  114. /*++
  115. Routine Description:
  116. Initialization routine for the stub. This routine just
  117. fills in the PSI_INFO struct and returns.
  118. Arguments:
  119. Info - Pointer to component interface info struct
  120. Return Values:
  121. NDIS_STATUS_SUCCESS
  122. --*/
  123. {
  124. Info->PipeContextLength = sizeof(PSSTUB_PIPE);
  125. Info->FlowContextLength = sizeof(PSSTUB_FLOW);
  126. Info->ClassMapContextLength = sizeof(PS_CLASS_MAP_CONTEXT);
  127. Info->InitializePipe = PsStubInitializePipe;
  128. Info->ModifyPipe = PsStubModifyPipe;
  129. Info->DeletePipe = PsStubDeletePipe;
  130. Info->CreateFlow = PsStubCreateFlow;
  131. Info->ModifyFlow = PsStubModifyFlow;
  132. Info->DeleteFlow = PsStubDeleteFlow;
  133. Info->EmptyFlow = PsStubEmptyFlow;
  134. Info->CreateClassMap = PsStubCreateClassMap;
  135. Info->DeleteClassMap = PsStubDeleteClassMap;
  136. Info->SubmitPacket = PsStubSubmitPacket;
  137. Info->ReceivePacket = NULL;
  138. Info->ReceiveIndication = NULL;
  139. Info->SetInformation = PsStubSetInformation;
  140. Info->QueryInformation = PsStubQueryInformation;
  141. } // InitializeSchedulerStub
  142. //
  143. // Unload routine: currently do nothing
  144. //
  145. void
  146. UnloadPsStub()
  147. {
  148. }
  149. VOID
  150. CleanupSchedulerStub(
  151. VOID)
  152. /*++
  153. Routine Description:
  154. Cleanup routine for stub.
  155. Arguments:
  156. Return Values:
  157. NDIS_STATUS_SUCCESS
  158. --*/
  159. {
  160. } // CleanupSchedulerStub
  161. NDIS_STATUS
  162. PsStubInitializePipe (
  163. IN HANDLE PsPipeContext,
  164. IN PPS_PIPE_PARAMETERS PipeParameters,
  165. IN PPS_PIPE_CONTEXT ComponentPipeContext,
  166. IN PPS_PROCS PsProcs,
  167. IN PPS_UPCALLS Upcalls
  168. )
  169. /*++
  170. Routine Description:
  171. Pipe initialization routine for stub.
  172. Arguments:
  173. PsPipeContext - PS pipe context value
  174. PipeParameters - Pointer to pipe parameters
  175. ComponentPipeContext - Pointer to this component's context area
  176. PsProcs - PS's support routines
  177. Upcalls - Previous component's upcall table
  178. Return Values:
  179. NDIS_STATUS_SUCCESS
  180. --*/
  181. {
  182. PPSSTUB_PIPE Pipe = (PPSSTUB_PIPE)ComponentPipeContext;
  183. Pipe->Adapter = (PADAPTER)PsPipeContext;
  184. if (Upcalls != NULL) {
  185. Pipe->SendComplete = Upcalls->SendComplete;
  186. Pipe->SendCompletePipeContext = Upcalls->PipeContext;
  187. }
  188. else {
  189. Pipe->SendComplete = NULL;
  190. }
  191. return NDIS_STATUS_SUCCESS;
  192. } // PsStubInitializePipe
  193. NDIS_STATUS
  194. PsStubModifyPipe (
  195. IN PPS_PIPE_CONTEXT PipeContext,
  196. IN PPS_PIPE_PARAMETERS PipeParameters
  197. )
  198. /*++
  199. Routine Description:
  200. Pipe parameter modification routine for stub.
  201. Arguments:
  202. PipeContext - Pointer to this component's pipe context area
  203. PipeParameters - Pointer to pipe parameters
  204. Return Values:
  205. NDIS_STATUS_SUCCESS
  206. --*/
  207. {
  208. PPSSTUB_PIPE Pipe = (PPSSTUB_PIPE)PipeContext;
  209. return NDIS_STATUS_SUCCESS;
  210. } // PsStubModifyPipe
  211. VOID
  212. PsStubDeletePipe (
  213. IN PPS_PIPE_CONTEXT PipeContext
  214. )
  215. /*++
  216. Routine Description:
  217. Pipe removal routine for stub.
  218. Arguments:
  219. PipeContext - Pointer to this component's pipe context area
  220. Return Values:
  221. --*/
  222. {
  223. } // PsStubDeletePipe
  224. NDIS_STATUS
  225. PsStubCreateFlow (
  226. IN PPS_PIPE_CONTEXT PipeContext,
  227. IN HANDLE PsFlowContext,
  228. IN PCO_CALL_PARAMETERS CallParameters,
  229. IN PPS_FLOW_CONTEXT ComponentFlowContext
  230. )
  231. /*++
  232. Routine Description:
  233. Flow creation routine for stub.
  234. Arguments:
  235. PipeContext - Pointer to this component's pipe context area
  236. PsFlowContext - PS flow context value
  237. CallParameters - Pointer to call parameters for flow
  238. ComponentFlowContext - Pointer to this component's flow context area
  239. Return Values:
  240. NDIS_STATUS_SUCCESS
  241. --*/
  242. {
  243. PPSSTUB_PIPE Pipe = (PPSSTUB_PIPE)PipeContext;
  244. PPSSTUB_FLOW Flow = (PPSSTUB_FLOW)ComponentFlowContext;
  245. Flow->AdapterVc = (PGPC_CLIENT_VC)PsFlowContext;
  246. Flow->AdapterVc->SendComplete = Pipe->SendComplete;
  247. Flow->AdapterVc->SendCompletePipeContext = Pipe->SendCompletePipeContext;
  248. return NDIS_STATUS_SUCCESS;
  249. } // PsStubCreateFlow
  250. NDIS_STATUS
  251. PsStubModifyFlow (
  252. IN PPS_PIPE_CONTEXT PipeContext,
  253. IN PPS_FLOW_CONTEXT FlowContext,
  254. IN PCO_CALL_PARAMETERS CallParameters
  255. )
  256. /*++
  257. Routine Description:
  258. Flow modification routine for stub.
  259. Arguments:
  260. PipeContext - Pointer to this component's pipe context area
  261. FlowContext - Pointer to this component's flow context area
  262. CallParameters - Pointer to call parameters for flow
  263. Return Values:
  264. NDIS_STATUS_SUCCESS
  265. --*/
  266. {
  267. return NDIS_STATUS_SUCCESS;
  268. } // PsStubModifyFlow
  269. VOID
  270. PsStubDeleteFlow (
  271. IN PPS_PIPE_CONTEXT PipeContext,
  272. IN PPS_FLOW_CONTEXT FlowContext
  273. )
  274. /*++
  275. Routine Description:
  276. Flow removal routine for token bucket conformer.
  277. Arguments:
  278. PipeContext - Pointer to this component's pipe context area
  279. FlowContext - Pointer to this component's flow context area
  280. Return Values:
  281. --*/
  282. {
  283. } // PsStubDeleteFlow
  284. VOID
  285. PsStubEmptyFlow (
  286. IN PPS_PIPE_CONTEXT PipeContext,
  287. IN PPS_FLOW_CONTEXT FlowContext
  288. )
  289. {
  290. }
  291. NDIS_STATUS
  292. PsStubCreateClassMap (
  293. IN PPS_PIPE_CONTEXT PipeContext,
  294. IN HANDLE PsClassMapContext,
  295. IN PTC_CLASS_MAP_FLOW ClassMap,
  296. IN PPS_CLASS_MAP_CONTEXT ComponentClassMapContext)
  297. {
  298. return NDIS_STATUS_SUCCESS;
  299. }
  300. NDIS_STATUS
  301. PsStubDeleteClassMap (
  302. IN PPS_PIPE_CONTEXT PipeContext,
  303. IN PPS_CLASS_MAP_CONTEXT ComponentClassMapContext)
  304. {
  305. return NDIS_STATUS_SUCCESS;
  306. }
  307. BOOLEAN
  308. PsStubSubmitPacket (
  309. IN PPS_PIPE_CONTEXT PipeContext,
  310. IN PPS_FLOW_CONTEXT FlowContext,
  311. IN PPS_CLASS_MAP_CONTEXT ClassMapContext,
  312. IN PPACKET_INFO_BLOCK PacketInfo
  313. )
  314. /*++
  315. Routine Description:
  316. Packet submission routine for stub.
  317. Arguments:
  318. PipeContext - Pointer to this component's pipe context area
  319. FlowContext - Pointer to this component's flow context area
  320. Packet - Pointer to packet
  321. Return Values:
  322. NDIS_ATATUS_SUCCESS
  323. --*/
  324. {
  325. PPSSTUB_FLOW Flow = (PPSSTUB_FLOW)FlowContext;
  326. PGPC_CLIENT_VC AdapterVc = Flow->AdapterVc;
  327. PADAPTER Adapter = AdapterVc->Adapter;
  328. PPS_SEND_PACKET_CONTEXT PktContext;
  329. LARGE_INTEGER PacketLength;
  330. PNDIS_PACKET Packet = PacketInfo->NdisPacket;
  331. PktContext = CONTAINING_RECORD(PacketInfo, PS_SEND_PACKET_CONTEXT, Info);
  332. PacketLength.QuadPart = (LONGLONG)PktContext->Info.PacketLength;
  333. //
  334. // update flow stats
  335. //
  336. AdapterVc->Stats.BytesTransmitted.QuadPart += PacketLength.QuadPart;
  337. AdapterVc->Stats.PacketsTransmitted ++;
  338. if(Adapter->MediaType != NdisMediumWan)
  339. {
  340. NdisSendPackets(Adapter->LowerMpHandle, &Packet, 1);
  341. }
  342. else{
  343. //
  344. // If it didn't have a VC, we wouldn't have called
  345. // through the PS.
  346. //
  347. if(AdapterVc->NdisWanVcHandle)
  348. {
  349. NdisCoSendPackets(AdapterVc->NdisWanVcHandle,
  350. &Packet,
  351. 1);
  352. }
  353. else
  354. {
  355. NdisSendPackets(Adapter->LowerMpHandle,
  356. &Packet,
  357. 1);
  358. }
  359. }
  360. return TRUE;
  361. } // PsStubSubmitPacket
  362. VOID
  363. PsStubSetInformation (
  364. IN PPS_PIPE_CONTEXT ComponentPipeContext,
  365. IN PPS_FLOW_CONTEXT ComponentFlowContext,
  366. IN NDIS_OID Oid,
  367. IN ULONG Len,
  368. IN PVOID Data)
  369. {
  370. }
  371. VOID
  372. PsStubQueryInformation (
  373. IN PPS_PIPE_CONTEXT ComponentPipeContext,
  374. IN PPS_FLOW_CONTEXT ComponentFlowContext,
  375. IN NDIS_OID Oid,
  376. IN ULONG Len,
  377. IN PVOID Data,
  378. IN OUT PULONG BytesWritten,
  379. IN OUT PULONG BytesNeeded,
  380. IN OUT PNDIS_STATUS Status)
  381. {
  382. *Status = NDIS_STATUS_SUCCESS;
  383. }