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.

254 lines
5.9 KiB

  1. /*++
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. status.c
  5. Abstract:
  6. status indications handled in here....
  7. Author:
  8. Charlie Wickham (charlwi) 20-Jun-1996
  9. Rajesh Sundaram (rajeshsu) 01-Aug-1998.
  10. Environment:
  11. Kernel Mode
  12. Revision History:
  13. --*/
  14. #include "psched.h"
  15. #pragma hdrstop
  16. /* External */
  17. /* Static */
  18. /* Forward */
  19. VOID
  20. ClStatusIndication(
  21. IN NDIS_HANDLE ProtocolBindingContext,
  22. IN NDIS_STATUS GeneralStatus,
  23. IN PVOID StatusBuffer,
  24. IN UINT StatusBufferSize
  25. );
  26. VOID
  27. ClStatusIndicationComplete(
  28. IN NDIS_HANDLE BindingContext
  29. );
  30. /* End Forward */
  31. VOID
  32. ClStatusIndication(
  33. IN NDIS_HANDLE ProtocolBindingContext,
  34. IN NDIS_STATUS GeneralStatus,
  35. IN PVOID StatusBuffer,
  36. IN UINT StatusBufferSize
  37. )
  38. /*++
  39. Routine Description:
  40. Called by the NIC via NdisIndicateStatus
  41. Arguments:
  42. See the DDK...
  43. Return Values:
  44. None
  45. --*/
  46. {
  47. PADAPTER Adapter = (PADAPTER)ProtocolBindingContext;
  48. NDIS_STATUS Status;
  49. ULONG ErrorLogData[2];
  50. PVOID Context;
  51. PsDbgOut(DBG_TRACE,
  52. DBG_PROTOCOL,
  53. ("(%08X) ClStatusIndication: Status %08X\n",
  54. Adapter,
  55. GeneralStatus));
  56. // General rule:
  57. // If our device is not ready, we cannot forward the status indication.
  58. // Yes - we care about the Media connect and link speed oids. We will
  59. // query for these OIDs when we get to D0.
  60. //
  61. // (i) Special case for media_status. <need to pass it up>
  62. // Condition is that:
  63. // (Adapter state is OFF, so we can't process it ourselves) AND
  64. // (Status indication is about 'connect' or 'disconnect') AND
  65. // (Adapter state is 'running') AND
  66. // (Adapter has a binding handle for the protocol above)
  67. // We will process fix our internal state when we wake up and go back to D0.
  68. if( (IsDeviceStateOn(Adapter) == FALSE) &&
  69. ((GeneralStatus == NDIS_STATUS_MEDIA_CONNECT) || (GeneralStatus == NDIS_STATUS_MEDIA_DISCONNECT)) &&
  70. (Adapter->PsMpState == AdapterStateRunning ) &&
  71. (Adapter->PsNdisHandle != NULL) )
  72. {
  73. NdisMIndicateStatus(Adapter->PsNdisHandle,
  74. GeneralStatus,
  75. StatusBuffer,
  76. StatusBufferSize );
  77. return;
  78. }
  79. // (ii) Special case for wan-line-down: <need to process it>
  80. // This is a special case for wan_line_down. Need to forward it even if the adapter is not in D0.
  81. if( (IsDeviceStateOn(Adapter) == FALSE) && (GeneralStatus != NDIS_STATUS_WAN_LINE_DOWN) )
  82. {
  83. return;
  84. }
  85. //
  86. // we cannot forward status indications until we have been called in our
  87. // MpInitialize handler. But we need to look at certain events even if we
  88. // are not called in the MpInitialize handler. Otherwise, we could lose these
  89. // indications.
  90. //
  91. switch(GeneralStatus)
  92. {
  93. case NDIS_STATUS_MEDIA_CONNECT:
  94. case NDIS_STATUS_LINK_SPEED_CHANGE:
  95. PsGetLinkSpeed(Adapter);
  96. break;
  97. case NDIS_STATUS_MEDIA_DISCONNECT:
  98. //
  99. // reset the link speed so definite rate flows can be
  100. // admitted.
  101. //
  102. Adapter->RawLinkSpeed = (ULONG)UNSPECIFIED_RATE;
  103. UpdateAdapterBandwidthParameters(Adapter);
  104. break;
  105. default:
  106. break;
  107. }
  108. //
  109. // Our virtual adapter has not been initialized. We cannot forward this indication.
  110. //
  111. if(Adapter->PsMpState != AdapterStateRunning || Adapter->PsNdisHandle == NULL)
  112. {
  113. return;
  114. }
  115. //
  116. // For these WAN related indications, we have to send them to wanarp
  117. // So, there is no point in looking at these if our virtual adapter has not been initialized.
  118. //
  119. switch(GeneralStatus)
  120. {
  121. case NDIS_STATUS_WAN_LINE_UP:
  122. {
  123. if(Adapter->ProtocolType == ARP_ETYPE_IP)
  124. {
  125. //
  126. // This will call NdisMIndicateStatus, so we have to return
  127. // directly.
  128. //
  129. Status = CreateInterfaceForNdisWan(Adapter,
  130. StatusBuffer,
  131. StatusBufferSize);
  132. return;
  133. }
  134. break;
  135. }
  136. case NDIS_STATUS_WAN_LINE_DOWN:
  137. //
  138. // NDISWAN link has been torn down.
  139. //
  140. if(Adapter->ProtocolType == ARP_ETYPE_IP)
  141. {
  142. DeleteInterfaceForNdisWan(Adapter,
  143. StatusBuffer,
  144. StatusBufferSize);
  145. return;
  146. }
  147. break;
  148. default:
  149. break;
  150. }
  151. //
  152. // now indicate the status to the upper layer.
  153. //
  154. NdisMIndicateStatus(Adapter->PsNdisHandle,
  155. GeneralStatus,
  156. StatusBuffer,
  157. StatusBufferSize );
  158. } // ClStatusIndication
  159. VOID
  160. ClStatusIndicationComplete(
  161. IN NDIS_HANDLE ProtocolBindingContext
  162. )
  163. /*++
  164. Routine Description:
  165. Called by the NIC via NdisIndicateStatusComplete
  166. Arguments:
  167. See the DDK...
  168. Return Values:
  169. None
  170. --*/
  171. {
  172. PADAPTER Adapter = (PADAPTER)ProtocolBindingContext;
  173. PsDbgOut(DBG_TRACE, DBG_PROTOCOL, ("(%08X) ClStatusIndicationComplete\n", Adapter));
  174. if ( Adapter->PsNdisHandle != NULL) {
  175. NdisMIndicateStatusComplete( Adapter->PsNdisHandle );
  176. }
  177. } // ClStatusIndication
  178. /* end status.c */