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.

371 lines
9.9 KiB

  1. /*++
  2. Copyright (c) 1990-1998 Microsoft Corporation, All Rights Reserved.
  3. Module Name:
  4. request.c
  5. Abstract:
  6. This module contains the request calls to the miniport driver below.
  7. Author:
  8. Anil Francis Thomas (10/98)
  9. Environment:
  10. Kernel
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. #define MODULE_ID MODULE_REQUEST
  16. NDIS_STATUS
  17. AtmSmCoRequest(
  18. IN NDIS_HANDLE ProtocolAfContext,
  19. IN NDIS_HANDLE ProtocolVcContext OPTIONAL,
  20. IN NDIS_HANDLE ProtocolPartyContext OPTIONAL,
  21. IN OUT PNDIS_REQUEST pNdisRequest
  22. )
  23. /*++
  24. Routine Description:
  25. This routine is called by NDIS when our Call Manager sends us an
  26. NDIS Request. NDIS Requests that are of significance to us are:
  27. - OID_CO_ADDRESS_CHANGE
  28. The set of addresses registered with the switch has changed,
  29. i.e. address registration is complete. We issue an NDIS Request
  30. ourselves to get the list of addresses registered.
  31. - OID_CO_AF_CLOSE
  32. The Call Manager wants us to shut down this Interface.
  33. We ignore all other OIDs.
  34. Arguments:
  35. ProtocolAfContext - Our context for the Address Family binding,
  36. which is a pointer to the ATMSM Interface.
  37. ProtocolVcContext - Our context for a VC, which is a pointer to
  38. an ATMSM VC structure.
  39. ProtocolPartyContext - Our context for a Party. Since we don't do
  40. PMP, this is ignored (must be NULL).
  41. pNdisRequest - Pointer to the NDIS Request.
  42. Return Value:
  43. NDIS_STATUS_SUCCESS if we recognized the OID
  44. --*/
  45. {
  46. PATMSM_ADAPTER pAdapt= (PATMSM_ADAPTER)ProtocolAfContext;
  47. BOOLEAN ValidAf;
  48. DbgInfo(("CallMgrRequest: Request %lx, Type %d, OID %x\n",
  49. pNdisRequest, pNdisRequest->RequestType,
  50. pNdisRequest->DATA.SET_INFORMATION.Oid));
  51. switch(pNdisRequest->DATA.SET_INFORMATION.Oid){
  52. case OID_CO_ADDRESS_CHANGE:
  53. DbgInfo(("Received: OID_CO_ADDRESS_CHANGE\n"));
  54. ACQUIRE_ADAPTER_GEN_LOCK(pAdapt);
  55. pAdapt->ulFlags |= ADAPT_ADDRESS_INVALID;
  56. ValidAf = ((pAdapt->ulFlags & ADAPT_AF_OPENED) != 0);
  57. RELEASE_ADAPTER_GEN_LOCK(pAdapt);
  58. if (ValidAf)
  59. AtmSmQueryAdapterATMAddresses(pAdapt);
  60. break;
  61. case OID_CO_AF_CLOSE:
  62. DbgInfo(("Received: OID_CO_AF_CLOSE\n"));
  63. if (AtmSmReferenceAdapter(pAdapt)){
  64. AtmSmShutdownAdapter(pAdapt);
  65. AtmSmDereferenceAdapter(pAdapt);
  66. }
  67. break;
  68. default:
  69. break;
  70. }
  71. return NDIS_STATUS_SUCCESS;
  72. }
  73. VOID
  74. AtmSmCoRequestComplete(
  75. IN NDIS_STATUS Status,
  76. IN NDIS_HANDLE ProtocolAfContext,
  77. IN NDIS_HANDLE ProtocolVcContext OPTIONAL,
  78. IN NDIS_HANDLE ProtocolPartyContext OPTIONAL,
  79. IN PNDIS_REQUEST pNdisRequest
  80. )
  81. /*++
  82. Routine Description:
  83. This routine is called by NDIS when a previous call to NdisCoRequest
  84. that had pended, is complete. We handle this based on the request
  85. we had sent, which has to be one of:
  86. - OID_CO_GET_ADDRESSES
  87. Get all addresses registered on the specified AF binding.
  88. Arguments:
  89. Status - Status of the Request.
  90. ProtocolAfContext - Our context for the Address Family binding,
  91. which is a pointer to the PATMSM_ADAPTER.
  92. ProtocolVcContext - Our context for a VC, which is a pointer to
  93. a VC structure.
  94. ProtocolPartyContext - Our context for a Party
  95. pNdisRequest - Pointer to the NDIS Request.
  96. Return Value:
  97. None
  98. --*/
  99. {
  100. PATMSM_ADAPTER pAdapt = (PATMSM_ADAPTER)ProtocolAfContext;
  101. DbgInfo(("CoRequestComplete: Request %lx, Type %d, OID %lx\n",
  102. pNdisRequest, pNdisRequest->RequestType,
  103. pNdisRequest->DATA.QUERY_INFORMATION.Oid));
  104. ACQUIRE_ADAPTER_GEN_LOCK(pAdapt);
  105. switch(pNdisRequest->DATA.SET_INFORMATION.Oid){
  106. case OID_CO_GET_ADDRESSES:
  107. if (NDIS_STATUS_SUCCESS == Status){
  108. PCO_ADDRESS_LIST pCoAddrList;
  109. UINT i;
  110. pCoAddrList = (PCO_ADDRESS_LIST)(pNdisRequest->DATA.
  111. QUERY_INFORMATION.InformationBuffer);
  112. ASSERT(pCoAddrList->NumberOfAddresses == 1);
  113. ASSERT(pCoAddrList->NumberOfAddressesAvailable == 1);
  114. DbgInfo(("CoRequestComplete: Configured address, %d/%d Size %d\n",
  115. pCoAddrList->NumberOfAddresses,
  116. pCoAddrList->NumberOfAddressesAvailable,
  117. pCoAddrList->AddressList.AddressSize));
  118. ASSERT(pCoAddrList->AddressList.AddressSize == (sizeof(CO_ADDRESS)
  119. + sizeof(ATM_ADDRESS)));
  120. NdisMoveMemory(&pAdapt->ConfiguredAddress,
  121. pCoAddrList->AddressList.Address,
  122. sizeof(ATM_ADDRESS));
  123. // set the selector byte
  124. pAdapt->ConfiguredAddress.Address[ATM_ADDRESS_LENGTH-1] =
  125. pAdapt->SelByte;
  126. pAdapt->ulFlags &= ~ADAPT_ADDRESS_INVALID;
  127. DbgInfo(("CoRequestComplete: Configured Address : "));
  128. DumpATMAddress(ATMSMD_ERR, "", &pAdapt->ConfiguredAddress);
  129. } else {
  130. DbgErr(("CoRequestComplete: CO_GET_ADDRESS Failed %lx\n", Status));
  131. }
  132. break;
  133. }
  134. RELEASE_ADAPTER_GEN_LOCK(pAdapt);
  135. AtmSmFreeMem(pNdisRequest);
  136. }
  137. VOID
  138. AtmSmSendAdapterNdisRequest(
  139. IN PATMSM_ADAPTER pAdapt,
  140. IN NDIS_OID Oid,
  141. IN PVOID pBuffer,
  142. IN ULONG BufferLength
  143. )
  144. /*++
  145. Routine Description:
  146. NDIS Request generator, for sending NDIS requests to the miniport.
  147. Arguments:
  148. pAdapt Ptr to Adapter
  149. Oid The parameter being queried
  150. pBuffer Points to parameter
  151. BufferLength Length of above
  152. Return Value:
  153. None
  154. --*/
  155. {
  156. NDIS_STATUS Status;
  157. PNDIS_REQUEST pRequest;
  158. AtmSmAllocMem(&pRequest, PNDIS_REQUEST, sizeof(NDIS_REQUEST));
  159. if (NULL == pRequest) {
  160. DbgErr(("AdapterRequest - Not enough memory\n"));
  161. return;
  162. }
  163. NdisZeroMemory(pRequest, sizeof(NDIS_REQUEST));
  164. //
  165. // Query for the line rate.
  166. //
  167. pRequest->DATA.QUERY_INFORMATION.Oid = Oid;
  168. pRequest->DATA.QUERY_INFORMATION.InformationBuffer = pBuffer;
  169. pRequest->DATA.QUERY_INFORMATION.InformationBufferLength = BufferLength;
  170. pRequest->DATA.QUERY_INFORMATION.BytesWritten = 0;
  171. pRequest->DATA.QUERY_INFORMATION.BytesNeeded = BufferLength;
  172. RESET_BLOCK_STRUCT(&pAdapt->RequestBlock);
  173. NdisRequest(&Status,
  174. pAdapt->NdisBindingHandle,
  175. pRequest);
  176. if (NDIS_STATUS_PENDING == Status) {
  177. Status = WAIT_ON_BLOCK_STRUCT(&pAdapt->RequestBlock);
  178. } else {
  179. AtmSmRequestComplete(
  180. pAdapt,
  181. pRequest,
  182. Status);
  183. }
  184. }
  185. VOID
  186. AtmSmRequestComplete(
  187. IN NDIS_HANDLE ProtocolBindingContext,
  188. IN PNDIS_REQUEST pRequest,
  189. IN NDIS_STATUS Status
  190. )
  191. /*++
  192. Routine Description:
  193. Completion of our call to NdisRequest(). Do some follow-up.
  194. Arguments:
  195. ProtocolBindingContext Pointer to Adapter
  196. pRequest The request that just completed
  197. Status Status of NdisRequest()
  198. Return Value:
  199. None
  200. --*/
  201. {
  202. PATMSM_ADAPTER pAdapt = (PATMSM_ADAPTER)ProtocolBindingContext;;
  203. switch (pRequest->DATA.QUERY_INFORMATION.Oid) {
  204. case OID_ATM_MAX_AAL5_PACKET_SIZE:
  205. if(NDIS_STATUS_SUCCESS != Status) {
  206. DbgWarn(("Failed to get Miniport MaxPacketSize. "
  207. "Status - %x\n", Status));
  208. pAdapt->MaxPacketSize = DEFAULT_MAX_PACKET_SIZE;
  209. }
  210. if (pAdapt->MaxPacketSize < pAdapt->VCFlowSpec.SendMaxSize) {
  211. pAdapt->VCFlowSpec.SendMaxSize =
  212. pAdapt->VCFlowSpec.ReceiveMaxSize = pAdapt->MaxPacketSize;
  213. }
  214. DbgInfo(("Miniport Max AAL5 Packet Size: %d (decimal)\n",
  215. pAdapt->MaxPacketSize));
  216. break;
  217. case OID_GEN_CO_LINK_SPEED: {
  218. PNDIS_CO_LINK_SPEED pLinkSpeed = &pAdapt->LinkSpeed;
  219. if(NDIS_STATUS_SUCCESS != Status) {
  220. DbgWarn(("Failed to get Miniport LinkSpeed. "
  221. "Status - %x\n", Status));
  222. pAdapt->LinkSpeed.Inbound = pAdapt->LinkSpeed.Outbound =
  223. DEFAULT_SEND_BANDWIDTH;
  224. }
  225. //
  226. // Convert to bytes/sec
  227. //
  228. pLinkSpeed->Outbound = (pLinkSpeed->Outbound * 100 / 8);
  229. pLinkSpeed->Inbound = (pLinkSpeed->Inbound * 100 / 8);
  230. if (pLinkSpeed->Outbound < pAdapt->VCFlowSpec.SendBandwidth) {
  231. pAdapt->VCFlowSpec.SendBandwidth = pLinkSpeed->Outbound;
  232. }
  233. if (pLinkSpeed->Inbound < pAdapt->VCFlowSpec.ReceiveBandwidth){
  234. pAdapt->VCFlowSpec.ReceiveBandwidth = pLinkSpeed->Inbound;
  235. }
  236. DbgInfo(("Miniport Link Speed (decimal, bytes/sec): In %d, "
  237. "Out %d\n", pLinkSpeed->Inbound, pLinkSpeed->Outbound));
  238. break;
  239. }
  240. default:
  241. ASSERT(FALSE);
  242. break;
  243. }
  244. AtmSmFreeMem(pRequest);
  245. SIGNAL_BLOCK_STRUCT(&pAdapt->RequestBlock , Status);
  246. }