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.

1510 lines
53 KiB

  1. #include <precomp.h>
  2. #define MODULE_NUMBER MODULE_NDIS
  3. #define _FILENUMBER 'SIDN'
  4. RCA_PROTOCOL_CONTEXT GlobalContext;
  5. NDIS_STATUS
  6. RCACoNdisInitialize(
  7. IN PRCA_CO_NDIS_HANDLERS pHandlers,
  8. IN ULONG ulInitTimeout
  9. )
  10. /*++
  11. Routine Description:
  12. Initializes the Co-NDIS client.
  13. Arguments:
  14. pHandlers - Pointer to RCA_CO_NDIS_HANDLERS structure containing pointers
  15. to functions that will be called in response to various events.
  16. ulInitTimeout - Number of milliseconds to allow initialization to proceed. If
  17. it has not completed in this time, it will abort.
  18. Return value:
  19. NDIS_STATUS_SUCCESS if all went OK, NDIS_STATUS_FAILURE in the case of a timeout,
  20. or some other pertinent error code otherwise.
  21. --*/
  22. {
  23. NDIS_STATUS Status;
  24. PRCA_PROTOCOL_CONTEXT pProtocolContext = &GlobalContext;
  25. RCADEBUGP(RCA_INFO, ("RCACoNdisInitialize: Enter\n"));
  26. do {
  27. NDIS_PROTOCOL_CHARACTERISTICS RCAProtocolCharacteristics;
  28. RCADEBUGP(RCA_LOUD, ("RCACoNdisInitialize: Protocol context block is at 0x%x\n", pProtocolContext));
  29. //
  30. // Initialize the protocol context.
  31. //
  32. NdisZeroMemory(pProtocolContext, sizeof(RCA_PROTOCOL_CONTEXT));
  33. #if DBG
  34. pProtocolContext->rca_sig = rca_signature;
  35. #endif
  36. NdisAllocateSpinLock(&pProtocolContext->SpinLock);
  37. RCAInitBlockStruc(&pProtocolContext->BindingInfo.Block);
  38. //
  39. // Copy the handlers passed to us.
  40. //
  41. RtlCopyMemory(&pProtocolContext->Handlers, pHandlers, sizeof(RCA_CO_NDIS_HANDLERS));
  42. //
  43. // Set up our protocol characteristics and register as an NDIS protocol.
  44. //
  45. NdisZeroMemory (&RCAProtocolCharacteristics, sizeof(NDIS_PROTOCOL_CHARACTERISTICS));
  46. RCAProtocolCharacteristics.MajorNdisVersion = NDIS_MAJOR_VERSION;
  47. RCAProtocolCharacteristics.MinorNdisVersion = NDIS_MINOR_VERSION;
  48. RCAProtocolCharacteristics.Filler = 0;
  49. RCAProtocolCharacteristics.Flags = NDIS_PROTOCOL_BIND_ALL_CO;
  50. RCAProtocolCharacteristics.CoAfRegisterNotifyHandler = RCANotifyAfRegistration;
  51. RCAProtocolCharacteristics.OpenAdapterCompleteHandler = RCAOpenAdapterComplete;
  52. RCAProtocolCharacteristics.CloseAdapterCompleteHandler = RCACloseAdapterComplete;
  53. RCAProtocolCharacteristics.TransferDataCompleteHandler = RCATransferDataComplete;
  54. RCAProtocolCharacteristics.ResetCompleteHandler = RCAResetComplete;
  55. RCAProtocolCharacteristics.SendCompleteHandler = RCASendComplete;
  56. RCAProtocolCharacteristics.RequestCompleteHandler = RCARequestComplete;
  57. RCAProtocolCharacteristics.ReceiveHandler = RCAReceive;
  58. RCAProtocolCharacteristics.ReceiveCompleteHandler = RCAReceiveComplete;
  59. RCAProtocolCharacteristics.ReceivePacketHandler = RCAReceivePacket;
  60. RCAProtocolCharacteristics.StatusHandler = RCAStatus;
  61. RCAProtocolCharacteristics.StatusCompleteHandler = RCAStatusComplete;
  62. RCAProtocolCharacteristics.BindAdapterHandler = RCABindAdapter;
  63. RCAProtocolCharacteristics.UnbindAdapterHandler = RCAUnbindAdapter;
  64. RCAProtocolCharacteristics.PnPEventHandler = RCAPnPEventHandler;
  65. RCAProtocolCharacteristics.UnloadHandler = NULL;
  66. RCAProtocolCharacteristics.CoStatusHandler = RCACoStatus;
  67. RCAProtocolCharacteristics.CoReceivePacketHandler = RCACoReceivePacket;
  68. RCAProtocolCharacteristics.CoSendCompleteHandler = RCACoSendComplete;
  69. NdisInitUnicodeString(&(RCAProtocolCharacteristics.Name), RCA_CL_NAME);
  70. NdisRegisterProtocol(&Status,
  71. &pProtocolContext->RCAClProtocolHandle,
  72. &RCAProtocolCharacteristics,
  73. sizeof(RCAProtocolCharacteristics));
  74. if (Status != NDIS_STATUS_SUCCESS) {
  75. RCADEBUGP(RCA_ERROR, ("RCACoNdisInitialize: "
  76. "Failed to register as an NDIS Protocol - status == 0x%x\n",
  77. Status));
  78. break;
  79. }
  80. //
  81. // Block waiting for indications/bindings to complete.
  82. //
  83. RCABlockTimeOut(&pProtocolContext->BindingInfo.Block, ulInitTimeout, &Status);
  84. if (Status == STATUS_TIMEOUT) {
  85. Status = NDIS_STATUS_FAILURE;
  86. RCADEBUGP(RCA_ERROR, ("RCACoNdisInitialize: "
  87. "Initialization timed out, setting Status = NDIS_STATUS_FAILURE\n"));
  88. break;
  89. }
  90. } while (FALSE);
  91. if (Status != NDIS_STATUS_SUCCESS) {
  92. //
  93. // Cleanup / bail out.
  94. //
  95. RCACoNdisUninitialize();
  96. }
  97. RCADEBUGP(RCA_INFO, ("RCACoNdisInitialize: Exit - Returning status 0x%x\n", Status));
  98. return Status;
  99. }
  100. VOID
  101. RCACoNdisUninitialize(
  102. )
  103. /*++
  104. Routine Description:
  105. Uninitializes the Co-NDIS client and frees up any resources used by it.
  106. Arguments:
  107. (None)
  108. Return value:
  109. (None)
  110. --*/
  111. {
  112. PRCA_PROTOCOL_CONTEXT pProtocolContext = &GlobalContext;
  113. NDIS_STATUS Status;
  114. RCADEBUGP(RCA_INFO, ("RCACoNdisUninitialize: Enter\n"));
  115. //
  116. // Deregister our protocol.
  117. //
  118. if (pProtocolContext->RCAClProtocolHandle != (NDIS_HANDLE)NULL) {
  119. NdisDeregisterProtocol(&Status, pProtocolContext->RCAClProtocolHandle);
  120. }
  121. RCADEBUGP(RCA_INFO, ("RCACoNdisUninitialize: Exit\n"));
  122. }
  123. NDIS_STATUS
  124. RCAPnPSetPower(
  125. IN PRCA_ADAPTER pAdapter,
  126. IN PNET_PNP_EVENT NetPnPEvent
  127. )
  128. {
  129. PNET_DEVICE_POWER_STATE pPowerState;
  130. NDIS_STATUS Status;
  131. RCADEBUGP(RCA_INFO, ("RCAPnPSetPower: enter\n"));
  132. pPowerState = (PNET_DEVICE_POWER_STATE)NetPnPEvent->Buffer;
  133. switch (*pPowerState) {
  134. case NetDeviceStateD0:
  135. Status = NDIS_STATUS_SUCCESS;
  136. break;
  137. default:
  138. Status = NDIS_STATUS_NOT_SUPPORTED;
  139. };
  140. RCADEBUGP(RCA_INFO, ("RCAPnPSetPower: exit\n"));
  141. return Status;
  142. }
  143. NDIS_STATUS
  144. RCAPnPQueryPower(
  145. IN PRCA_ADAPTER pAdapter,
  146. IN PNET_PNP_EVENT NetPnPEvent
  147. )
  148. {
  149. RCADEBUGP(RCA_INFO, ("RCAPnPQueryPower: enter\n"));
  150. RCADEBUGP(RCA_INFO, ("RCAPnPQueryPower: exit\n"));
  151. return (NDIS_STATUS_SUCCESS);
  152. }
  153. NDIS_STATUS
  154. RCAPnPQueryRemoveDevice(
  155. IN PRCA_ADAPTER pAdapter,
  156. IN PNET_PNP_EVENT NetPnPEvent
  157. )
  158. {
  159. RCADEBUGP(RCA_INFO, ("RCAPnPQueryRemoveDevice: enter\n"));
  160. RCADEBUGP(RCA_INFO, ("RCAPnPQueryRemoveDevice: exit\n"));
  161. return (NDIS_STATUS_SUCCESS);
  162. }
  163. NDIS_STATUS
  164. RCAPnPCancelRemoveDevice(
  165. IN PRCA_ADAPTER pAdapter,
  166. IN PNET_PNP_EVENT NetPnPEvent
  167. )
  168. {
  169. RCADEBUGP(RCA_INFO, ("RCAPnPCancelRemoveDevice: enter\n"));
  170. RCADEBUGP(RCA_INFO, ("RCAPnPCancelRemoveDevice: exit\n"));
  171. return (NDIS_STATUS_SUCCESS);
  172. }
  173. NDIS_STATUS
  174. RCAPnPEventBindsComplete(
  175. IN PRCA_ADAPTER pAdapter,
  176. IN PNET_PNP_EVENT NetPnPEvent
  177. )
  178. {
  179. PRCA_PROTOCOL_CONTEXT pProtocolContext = &GlobalContext;
  180. NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
  181. RCADEBUGP(RCA_INFO, ("RCAPnPEventBindsComplete: enter\n"));
  182. ACQUIRE_SPIN_LOCK(&pProtocolContext->SpinLock);
  183. RCADEBUGP(RCA_LOUD, ("RCAPnPEventBindsComplete: Acquired global protocol context lock\n"));
  184. pProtocolContext->BindingInfo.BindingsComplete = TRUE;
  185. if (pProtocolContext->BindingInfo.SAPCnt == pProtocolContext->BindingInfo.AdapterCnt) {
  186. RCADEBUGP(RCA_INFO, ("RCAPnPEventBindsComplete: Unblocking RCACoNdisInitialize(), Counts == %d\n",
  187. pProtocolContext->BindingInfo.AdapterCnt));
  188. RCASignal(&pProtocolContext->BindingInfo.Block, Status);
  189. } else {
  190. RCADEBUGP(RCA_INFO, ("RCAPnPEventBindsComplete: "
  191. "Not unblocking RCACoNdisInitialize()- SAPCnt == %d, AdapterCnt == %d\n",
  192. pProtocolContext->BindingInfo.SAPCnt, pProtocolContext->BindingInfo.AdapterCnt));
  193. }
  194. RELEASE_SPIN_LOCK(&pProtocolContext->SpinLock);
  195. RCADEBUGP(RCA_LOUD, ("RCAPnPEventBindsComplete: Released global protocol context lock\n"));
  196. RCADEBUGP(RCA_INFO, ("RCAPnPEventBindsComplete: exit\n"));
  197. return NDIS_STATUS_SUCCESS;
  198. }
  199. NDIS_STATUS
  200. RCAPnPEventHandler(
  201. IN NDIS_HANDLE ProtocolBindingContext,
  202. IN PNET_PNP_EVENT NetPnPEvent
  203. )
  204. /*++
  205. Routine Description:
  206. Called by NDIS in to indicate a PNP event.
  207. Arguments:
  208. ProtocolBindingContext - Actually a pointer to the adapter structure
  209. NetPnPEvent - Pointer to the event
  210. Return value:
  211. NDIS_STATUS_SUCCESS for those events we support, NDIS_STATUS_NOT_SUPPORTED for those we don't.
  212. --*/
  213. {
  214. NDIS_STATUS Status;
  215. PRCA_ADAPTER pAdapter;
  216. RCADEBUGP(RCA_INFO, ("RCAPnPEventHandler: enter\n"));
  217. pAdapter = (PRCA_ADAPTER)ProtocolBindingContext;
  218. switch(NetPnPEvent->NetEvent) {
  219. case NetEventSetPower:
  220. Status = RCAPnPSetPower(pAdapter, NetPnPEvent);
  221. break;
  222. case NetEventQueryPower:
  223. Status = RCAPnPQueryPower(pAdapter, NetPnPEvent);
  224. break;
  225. case NetEventQueryRemoveDevice:
  226. Status = RCAPnPQueryRemoveDevice(pAdapter, NetPnPEvent);
  227. break;
  228. case NetEventCancelRemoveDevice:
  229. Status = RCAPnPCancelRemoveDevice(pAdapter, NetPnPEvent);
  230. break;
  231. case NetEventBindsComplete:
  232. Status = RCAPnPEventBindsComplete(pAdapter, NetPnPEvent);
  233. break;
  234. default:
  235. Status = NDIS_STATUS_NOT_SUPPORTED;
  236. };
  237. RCADEBUGP(RCA_INFO, ("RCAPnPEventHandler: exit, returning %x\n", Status));
  238. return Status;
  239. }
  240. VOID
  241. RCABindAdapter(
  242. OUT PNDIS_STATUS pStatus,
  243. IN NDIS_HANDLE BindContext,
  244. IN PNDIS_STRING DeviceName,
  245. IN PVOID SystemSpecific1,
  246. IN PVOID SystemSpecific2
  247. )
  248. /*++
  249. Routine Description:
  250. Entry point that gets called by NDIS when an adapter appears on the
  251. system.
  252. Arguments:
  253. pStatus - place for our Return Value
  254. BindContext - to be used if we call NdisCompleteBindAdapter; we don't
  255. DeviceName - Name of the adapter to be bound to
  256. SystemSpecific1 - Name of the protocol-specific entry in this adapter's
  257. registry section
  258. SystemSpecific2 - Not used
  259. Return Value:
  260. None. We set *pStatus to NDIS_STATUS_SUCCESS if everything goes off well,
  261. otherwise an NDIS error status.
  262. --*/
  263. {
  264. PRCA_PROTOCOL_CONTEXT pProtocolContext = &GlobalContext;
  265. PRCA_ADAPTER *ppNextAdapter;
  266. NDIS_STATUS OpenError;
  267. UINT SelectedIndex;
  268. PRCA_ADAPTER pAdapter;
  269. NDIS_MEDIUM Media[] = {NdisMediumAtm, NdisMediumCoWan}; // This should be more generic
  270. NDIS_STATUS Status;
  271. RCADEBUGP(RCA_INFO,("RCABindAdapter: Enter\n"));
  272. do
  273. {
  274. //
  275. // Allocate adapter structure.
  276. //
  277. RCAAllocMem(pAdapter, RCA_ADAPTER, sizeof(RCA_ADAPTER));
  278. if (pAdapter == (PRCA_ADAPTER)NULL) {
  279. RCADEBUGP(RCA_ERROR, ("RCABindAdapter: Could not allocate memory for adapter, "
  280. "setting status to NDIS_STATUS_RESOURCES\n"));
  281. Status = NDIS_STATUS_RESOURCES;
  282. break;
  283. }
  284. RCADEBUGP(RCA_INFO, ("RCABindAdapter: New adapter allocated at 0x%x\n", pAdapter));
  285. //
  286. // Initialize the new adapter structure
  287. //
  288. NdisZeroMemory(pAdapter, sizeof(RCA_ADAPTER));
  289. #if DBG
  290. pAdapter->rca_sig = rca_signature;
  291. #endif
  292. RCAInitBlockStruc(&pAdapter->Block);
  293. NdisAllocateSpinLock(&pAdapter->SpinLock);
  294. NdisInitializeWorkItem(&pAdapter->DeactivateWorkItem,
  295. RCADeactivateAdapterWorker,
  296. (PVOID)pAdapter);
  297. RCAInitBlockStruc(&pAdapter->DeactivateBlock);
  298. //
  299. // Link the adapter into the global list.
  300. //
  301. ACQUIRE_SPIN_LOCK(&pProtocolContext->SpinLock);
  302. RCADEBUGP(RCA_LOUD, ("RCABindAdapter: Acquired global protocol spinlock\n"));
  303. //
  304. // Now ppNextAdapter points to the new adapter's would-be predecessor's
  305. // Next pointer; chain the new adapter to follow this predecessor:
  306. //
  307. LinkDoubleAtHead(pProtocolContext->AdapterList, pAdapter, NextAdapter, PrevAdapter);
  308. RELEASE_SPIN_LOCK(&pProtocolContext->SpinLock);
  309. RCADEBUGP(RCA_LOUD, ("RCABindAdapter: Released global protocol spinlock\n"));
  310. //
  311. // Allocate send packet and buffer pools
  312. //
  313. NdisAllocatePacketPoolEx(&Status,
  314. &pAdapter->SendPacketPool,
  315. MIN_PACKETS_POOL,
  316. MAX_PACKETS_POOL-MIN_PACKETS_POOL,
  317. sizeof(PKT_RSVD));
  318. if (Status == NDIS_STATUS_SUCCESS)
  319. {
  320. NdisAllocateBufferPool(&Status,
  321. &pAdapter->SendBufferPool,
  322. MAX_PACKETS_POOL);
  323. if (Status != NDIS_STATUS_SUCCESS)
  324. {
  325. RCADEBUGP(RCA_ERROR, ("RCABindAdapter: "
  326. "Failed to allocate send buffer bool, freeing packet pool, status == 0x%x\n", Status));
  327. NdisFreePacketPool(pAdapter->SendPacketPool);
  328. }
  329. } else {
  330. RCADEBUGP(RCA_ERROR, ("RCABindAdapter: Failed to allocate send packet pool, status == 0x%x\n", Status));
  331. }
  332. if (Status == NDIS_STATUS_SUCCESS)
  333. {
  334. //
  335. // Allocate receive packet and buffer pools
  336. //
  337. NdisAllocatePacketPoolEx(&Status,
  338. &pAdapter->RecvPacketPool,
  339. MIN_PACKETS_POOL,
  340. MAX_PACKETS_POOL-MIN_PACKETS_POOL,
  341. sizeof(PKT_RSVD));
  342. if (Status == NDIS_STATUS_SUCCESS)
  343. {
  344. NdisAllocateBufferPool(&Status,
  345. &pAdapter->RecvBufferPool,
  346. MAX_PACKETS_POOL);
  347. if (Status != NDIS_STATUS_SUCCESS)
  348. {
  349. RCADEBUGP(RCA_ERROR, ("RCABindAdapter: Failed to allocate receive buffer pool, freeing other pools, status == 0x%x\n", Status));
  350. NdisFreePacketPool(pAdapter->SendPacketPool);
  351. NdisFreeBufferPool(pAdapter->SendBufferPool);
  352. NdisFreePacketPool(pAdapter->RecvPacketPool);
  353. }
  354. } else {
  355. RCADEBUGP(RCA_ERROR, ("RCABindAdapter: Failed to allocate receive packet pool, freeing send pools, status == 0x%x\n", Status));
  356. NdisFreePacketPool(pAdapter->SendPacketPool);
  357. NdisFreeBufferPool(pAdapter->SendBufferPool);
  358. }
  359. }
  360. if (Status == NDIS_STATUS_SUCCESS) {
  361. RCADEBUGP(RCA_LOUD, ("RCABindAdapter: About to open Adapter %ws\n", DeviceName));
  362. NdisOpenAdapter(&Status,
  363. &OpenError,
  364. &pAdapter->NdisBindingHandle,
  365. &SelectedIndex,
  366. Media,
  367. 2,
  368. pProtocolContext->RCAClProtocolHandle,
  369. (NDIS_HANDLE)pAdapter,
  370. DeviceName,
  371. 0,
  372. NULL);
  373. if (Status == NDIS_STATUS_PENDING) {
  374. RCADEBUGP(RCA_LOUD, ("RCABindAdapter: NdisOpenAdapter returned NDIS_STATUS_PENDING, "
  375. "about to block\n"));
  376. RCABlock(&pAdapter->Block, &Status);
  377. RCADEBUGP(RCA_LOUD, ("RCABindAdapter: Unblocked waiting for NdisOpenAdapter to complete\n"));
  378. }
  379. if (Status != NDIS_STATUS_SUCCESS) {
  380. RCADEBUGP(RCA_ERROR, ("RCABindAdapter: Failed to open adapter - Status == 0x%x\n", Status));
  381. NdisFreePacketPool(pAdapter->SendPacketPool);
  382. NdisFreeBufferPool(pAdapter->SendBufferPool);
  383. NdisFreePacketPool(pAdapter->RecvPacketPool);
  384. NdisFreeBufferPool(pAdapter->RecvBufferPool);
  385. }
  386. }
  387. } while (FALSE);
  388. if (Status != NDIS_STATUS_SUCCESS) {
  389. //
  390. // We had some sort of error. Clean up and free up.
  391. //
  392. RCADEBUGP(RCA_ERROR, ("RCABindAdapter: Bad status - 0x%x\n", Status));
  393. if (pAdapter != (PRCA_ADAPTER)NULL)
  394. {
  395. RCAInitBlockStruc(&pAdapter->Block);
  396. if (pAdapter->NdisBindingHandle != (NDIS_HANDLE)NULL)
  397. {
  398. NdisCloseAdapter(&Status, pAdapter->NdisBindingHandle);
  399. if (Status == NDIS_STATUS_PENDING)
  400. {
  401. RCABlock(&pAdapter->Block, &Status);
  402. }
  403. ACQUIRE_SPIN_LOCK(&pProtocolContext->SpinLock);
  404. RCADEBUGP(RCA_LOUD, ("RCABindAdapter: Acquired global protocol spinlock\n"));
  405. pProtocolContext->BindingInfo.AdapterCnt--;
  406. RCADEBUGP(RCA_INFO, ("RCABindAdapter: Decremented adapter count, current value == %d\n", pProtocolContext->BindingInfo.AdapterCnt));
  407. RELEASE_SPIN_LOCK(&pProtocolContext->SpinLock);
  408. RCADEBUGP(RCA_LOUD, ("RCABindAdapter: Released global protocol spinlock\n"));
  409. }
  410. ACQUIRE_SPIN_LOCK(&pProtocolContext->SpinLock);
  411. RCADEBUGP(RCA_LOUD, ("RCABindAdapter: Acquired global protocol spinlock\n"));
  412. UnlinkDouble(pAdapter, NextAdapter, PrevAdapter);
  413. RELEASE_SPIN_LOCK(&pProtocolContext->SpinLock);
  414. RCADEBUGP(RCA_LOUD, ("RCABindAdapter: Released global protocol spinlock\n"));
  415. NdisFreeSpinLock(&pAdapter->Lock);
  416. RCAFreeMem(pAdapter);
  417. pAdapter = NULL;
  418. }
  419. Status = NDIS_STATUS_FAILURE;
  420. }
  421. *pStatus = Status;
  422. }
  423. VOID
  424. RCAOpenAdaperComplete(
  425. IN NDIS_HANDLE BindingContext,
  426. IN NDIS_STATUS Status,
  427. IN NDIS_STATUS OpenErrorStatus
  428. )
  429. /*++
  430. Routine Description
  431. Our OpenAdapter completion handler. We signal whoever opened the
  432. adapter.
  433. Arguments
  434. BindingContext - A pointer to a RCA_ADAPTER structure.
  435. Status - Status of open attempt.
  436. OpenErrorStatus - Additional status information.
  437. Return Value:
  438. None
  439. --*/
  440. {
  441. PRCA_ADAPTER pAdapter;
  442. RCADEBUGP(RCA_INFO, ("RCAOpenAdapterComplete: Enter\n"));
  443. pAdapter = (PRCA_ADAPTER)BindingContext;
  444. RCAStructAssert(pAdapter, rca);
  445. RCASignal(&pAdapter->Block, Status);
  446. RCADEBUGP(RCA_INFO, ("RCAOpenAdapterComplete: Exit\n"));
  447. }
  448. VOID
  449. RCADeactivateAdapterWorker(
  450. IN PNDIS_WORK_ITEM pWorkItem,
  451. IN PVOID Context
  452. )
  453. /*++
  454. Routine Description:
  455. This routine is called by a worker thread when a work item is scheduled to deactivate
  456. an adapter.
  457. Arguments:
  458. pWorkItem - Pointer to the work item structure used to schedule this work item
  459. Context - Actually a pointer to the RCA_ADAPTER structure for the adapter that
  460. will be deactivated.
  461. Return Value:
  462. (None)
  463. --*/
  464. {
  465. PRCA_ADAPTER pAdapter = (PRCA_ADAPTER) Context;
  466. RCADEBUGP(RCA_INFO, ("RCADeactivateAdapterWorker: Enter - Context == 0x%x\n", Context));
  467. //
  468. // Wait for all AF registrations to complete. There is a window of opportunity for us
  469. // to be here even though we may not be done in RCANotifyAfRegistration() i.e. between
  470. // the call to NdisClOpenAddressFamily() and the end of the function.
  471. //
  472. ACQUIRE_SPIN_LOCK(&pAdapter->SpinLock);
  473. while (pAdapter->AfRegisteringCount != 0) {
  474. NDIS_STATUS DummyStatus;
  475. RELEASE_SPIN_LOCK(&pAdapter->SpinLock);
  476. RCABlock(&pAdapter->AfRegisterBlock, &DummyStatus);
  477. ACQUIRE_SPIN_LOCK(&pAdapter->SpinLock);
  478. }
  479. RELEASE_SPIN_LOCK(&pAdapter->SpinLock);
  480. RCADeactivateAdapter(pAdapter);
  481. RCASignal(&pAdapter->DeactivateBlock, NDIS_STATUS_SUCCESS);
  482. RCA_CLEAR_ADAPTER_FLAG_LOCKED(pAdapter, RCA_ADAPTERFLAGS_DEACTIVATE_IN_PROGRESS);
  483. RCADEBUGP(RCA_INFO, ("RCADeactivateAdapterWorker: Exit"));
  484. }
  485. VOID
  486. RCADeactivateAdapter(
  487. IN PRCA_ADAPTER pAdapter
  488. )
  489. /*++
  490. Routine Description:
  491. Free all VCs on this adapter.
  492. Arguments:
  493. pAdapter - points to the Adapter the VCs are listed off
  494. Calling Seqence
  495. Called from RCACmUnbindAdapter to ensure we're all clear
  496. before deallocating an adapter structure
  497. Return Value:
  498. None
  499. --*/
  500. {
  501. PRCA_VC pVc, pNextVc;
  502. NDIS_STATUS Status;
  503. PRCA_PROTOCOL_CONTEXT pProtocolContext = &GlobalContext;
  504. RCADEBUGP(RCA_INFO, ("RCADeactivateAdapter: Enter - pAdapter 0x%x\n", pAdapter));
  505. //
  506. // Deregister Sap handle so we get no more incoming calls.
  507. //
  508. if (pAdapter->NdisSapHandle != NULL)
  509. {
  510. RCAInitBlockStruc(&pAdapter->Block);
  511. Status = NdisClDeregisterSap(pAdapter->NdisSapHandle);
  512. RCA_SET_ADAPTER_FLAG_LOCKED(pAdapter, RCA_ADAPTERFLAGS_DEREG_SAP);
  513. if (NDIS_STATUS_PENDING == Status)
  514. {
  515. RCABlock(&pAdapter->Block, &Status);
  516. }
  517. pAdapter->NdisSapHandle = NULL;
  518. RCA_SET_ADAPTER_FLAG_LOCKED(pAdapter, RCA_ADAPTERFLAGS_DEREG_SAP_COMPLETE);
  519. }
  520. ACQUIRE_SPIN_LOCK(&pAdapter->SpinLock);
  521. if (pAdapter->VcList) {
  522. pAdapter->BlockedOnClose = TRUE;
  523. RCAInitBlockStruc(&pAdapter->CloseBlock);
  524. }
  525. for (pVc = pAdapter->VcList; pVc != NULL; pVc = pNextVc)
  526. {
  527. pNextVc = pVc->NextVcOnAdapter;
  528. if (pVc->Flags & VC_ACTIVE)
  529. {
  530. RELEASE_SPIN_LOCK(&pAdapter->SpinLock);
  531. RCACoNdisCloseCallOnVcNoWait((PVOID)pVc);
  532. //
  533. // Call the VC Close callback if necessary.
  534. //
  535. ACQUIRE_SPIN_LOCK(&pVc->SpinLock);
  536. if ((pVc->ClientReceiveContext || pVc->ClientSendContext) &&
  537. (pProtocolContext->Handlers.VcCloseCallback)) {
  538. //
  539. // Release the spin lock here because this callback will very likely
  540. // call RCACoNdisReleaseXXxVcContext() etc which will want the lock.
  541. //
  542. // There is a teensy tiny race here - if someone releases the VC context
  543. // between when we release the lock and when we call the callback, we
  544. // could be in trouble.
  545. //
  546. RELEASE_SPIN_LOCK(&pVc->SpinLock);
  547. pProtocolContext->Handlers.VcCloseCallback((PVOID)pVc,
  548. pVc->ClientReceiveContext,
  549. pVc->ClientSendContext);
  550. } else {
  551. RELEASE_SPIN_LOCK(&pVc->SpinLock);
  552. }
  553. ACQUIRE_SPIN_LOCK(&pAdapter->SpinLock);
  554. }
  555. }
  556. RELEASE_SPIN_LOCK(&pAdapter->SpinLock);
  557. //
  558. // Deregister Af handle
  559. //
  560. if (pAdapter->NdisAfHandle)
  561. {
  562. RCAInitBlockStruc(&pAdapter->Block);
  563. Status = NdisClCloseAddressFamily(pAdapter->NdisAfHandle);
  564. RCA_SET_ADAPTER_FLAG_LOCKED(pAdapter, RCA_ADAPTERFLAGS_CLOSE_AF);
  565. if (Status == NDIS_STATUS_PENDING)
  566. {
  567. RCABlock(&pAdapter->Block, &Status);
  568. }
  569. pAdapter->NdisAfHandle = NULL;
  570. RCA_SET_ADAPTER_FLAG_LOCKED(pAdapter, RCA_ADAPTERFLAGS_CLOSE_AF_COMPLETE);
  571. }
  572. //
  573. // Block waiting for the actual VCs to be deleted, if any.
  574. //
  575. if (pAdapter->BlockedOnClose) {
  576. RCABlock(&pAdapter->CloseBlock, &Status);
  577. pAdapter->BlockedOnClose = FALSE;
  578. }
  579. RCA_SET_ADAPTER_FLAG_LOCKED(pAdapter, RCA_ADAPTERFLAGS_DEACTIVATE_COMPLETE);
  580. RCADEBUGP(RCA_LOUD, ("RCADeactivateAdapter: Exit\n"));
  581. }
  582. VOID
  583. RCAUnbindAdapter(
  584. OUT PNDIS_STATUS pStatus,
  585. IN NDIS_HANDLE ProtocolBindContext,
  586. IN PNDIS_HANDLE UnbindContext
  587. )
  588. /*++
  589. Routine Description:
  590. Our entry point called by NDIS when we need to destroy an existing
  591. adapter binding.
  592. Close and clean up the adapter.
  593. Arguments:
  594. pStatus - where we return the status of this call
  595. ProtocolBindContext - actually a pointer to the Adapter structure
  596. UnbindContext - we should pass this value in NdisCompleteUnbindAdapter
  597. Return Value:
  598. None; *pStatus contains the result code.
  599. --*/
  600. {
  601. PRCA_PROTOCOL_CONTEXT pProtocolContext = &GlobalContext;
  602. PRCA_ADAPTER *ppNextAdapter;
  603. PRCA_ADAPTER pAdapter;
  604. NDIS_STATUS Status;
  605. pAdapter = (PRCA_ADAPTER)ProtocolBindContext;
  606. RCADEBUGP(RCA_LOUD, ("RCAUnbindAdapter: Enter - pAdapter 0x%x, UnbindContext 0x%x\n",
  607. pAdapter, UnbindContext));
  608. //
  609. // Deactivate Adapter - This may already be in progress by a worker thread in response
  610. // to an OID_CO_AF_CLOSE.
  611. //
  612. ACQUIRE_SPIN_LOCK(&pAdapter->SpinLock);
  613. pAdapter->AdapterFlags |= RCA_ADAPTERFLAGS_UNBIND_IN_PROGRESS;
  614. while (pAdapter->AfRegisteringCount != 0) {
  615. RELEASE_SPIN_LOCK(&pAdapter->SpinLock);
  616. RCABlock(&pAdapter->AfRegisterBlock, &Status);
  617. ACQUIRE_SPIN_LOCK(&pAdapter->SpinLock);
  618. }
  619. if (pAdapter->AdapterFlags & RCA_ADAPTERFLAGS_DEACTIVATE_IN_PROGRESS) {
  620. RELEASE_SPIN_LOCK(&pAdapter->SpinLock);
  621. //
  622. // RCADeactivateAdapter() will be called by the worker thread,
  623. // just wait for it to complete.
  624. //
  625. RCABlock(&pAdapter->DeactivateBlock, &Status);
  626. } else if (pAdapter->AdapterFlags & RCA_ADAPTERFLAGS_DEACTIVATE_COMPLETE) {
  627. RELEASE_SPIN_LOCK(&pAdapter->SpinLock);
  628. //
  629. // Already deactivated, nothing to do.
  630. //
  631. } else {
  632. pAdapter->AdapterFlags |= RCA_ADAPTERFLAGS_DEACTIVATE_IN_PROGRESS;
  633. RELEASE_SPIN_LOCK(&pAdapter->SpinLock);
  634. //
  635. // Close Sap, Close Vcs and Close Af
  636. //
  637. RCADeactivateAdapter(pAdapter);
  638. RCASignal(&pAdapter->DeactivateBlock, NDIS_STATUS_SUCCESS);
  639. RCA_CLEAR_ADAPTER_FLAG_LOCKED(pAdapter, RCA_ADAPTERFLAGS_DEACTIVATE_IN_PROGRESS);
  640. }
  641. RCAInitBlockStruc (&pAdapter->Block);
  642. RCADEBUGP(RCA_LOUD, ("RCAUnbindAdapter: Calling NdisCloseAdapter\n"));
  643. NdisCloseAdapter(&Status, pAdapter->NdisBindingHandle);
  644. if (Status == NDIS_STATUS_PENDING)
  645. {
  646. RCABlock(&pAdapter->Block, &Status);
  647. }
  648. ACQUIRE_SPIN_LOCK(&pProtocolContext->SpinLock);
  649. RCADEBUGP(RCA_LOUD, ("RCAUnbindAdapter: Acquired global protocol context lock\n"));
  650. pProtocolContext->BindingInfo.AdapterCnt--;
  651. RCADEBUGP(RCA_INFO, ("RCAUnbindAdapter: Decremented adapter count, current value == %d\n", pProtocolContext->BindingInfo.AdapterCnt));
  652. RELEASE_SPIN_LOCK(&pProtocolContext->SpinLock);
  653. RCADEBUGP(RCA_LOUD, ("RCAUnbindAdapter: Released global protocol context lock\n"));
  654. if (pAdapter->VcList != NULL) {
  655. RCADEBUGP(RCA_LOUD, ("RCAUnbindAdapter: VcList not null, pAdapter is 0x%x\n", pAdapter));
  656. DbgBreakPoint();
  657. }
  658. // Delist and free the adapters from our Global info
  659. ACQUIRE_SPIN_LOCK(&pProtocolContext->SpinLock);
  660. RCADEBUGP(RCA_LOUD, ("RCAUnbindAdapter: Acquired global protocol context lock\n"));
  661. UnlinkDouble(pAdapter, NextAdapter, PrevAdapter);
  662. RELEASE_SPIN_LOCK(&pProtocolContext->SpinLock);
  663. RCADEBUGP(RCA_LOUD, ("RCAUnbindAdapter: Released global protocol context lock\n"));
  664. if (pAdapter->SendPacketPool != NULL)
  665. {
  666. NdisFreePacketPool(pAdapter->SendPacketPool);
  667. }
  668. if (pAdapter->SendBufferPool != NULL)
  669. {
  670. NdisFreeBufferPool(pAdapter->SendBufferPool);
  671. }
  672. if (pAdapter->RecvPacketPool != NULL)
  673. {
  674. NdisFreePacketPool(pAdapter->RecvPacketPool);
  675. }
  676. if (pAdapter->RecvBufferPool != NULL)
  677. {
  678. NdisFreeBufferPool(pAdapter->RecvBufferPool);
  679. }
  680. RCA_SET_ADAPTER_FLAG_LOCKED(pAdapter, RCA_ADAPTERFLAGS_UNBIND_COMPLETE);
  681. RCA_CLEAR_ADAPTER_FLAG_LOCKED(pAdapter, RCA_ADAPTERFLAGS_UNBIND_IN_PROGRESS);
  682. RCAFreeMem(pAdapter);
  683. RCADEBUGP(RCA_INFO, ("RCADeAllocateAdapter: exit\n"));
  684. *pStatus = NDIS_STATUS_SUCCESS;
  685. }
  686. VOID
  687. RCAOpenAdapterComplete(
  688. IN NDIS_HANDLE BindingContext,
  689. IN NDIS_STATUS Status,
  690. IN NDIS_STATUS OpenErrorStatus
  691. )
  692. /*++
  693. Routine Description
  694. Our OpenAdapter completion handler. We signal whoever opened the
  695. adapter.
  696. Arguments
  697. BindingContext - A pointer to a RCA_ADAPTER structure.
  698. Status - Status of open attempt.
  699. OpenErrorStatus - Additional status information.
  700. Return Value:
  701. None
  702. --*/
  703. {
  704. PRCA_PROTOCOL_CONTEXT pProtocolContext = &GlobalContext;
  705. PRCA_ADAPTER pAdapter;
  706. pAdapter = (PRCA_ADAPTER)BindingContext;
  707. RCAStructAssert(pAdapter, rca);
  708. if (Status == NDIS_STATUS_SUCCESS) {
  709. ACQUIRE_SPIN_LOCK(&pProtocolContext->SpinLock);
  710. RCADEBUGP(RCA_LOUD, ("RCAOpenAdapterComplete: Acquired global protocol context lock\n"));
  711. pProtocolContext->BindingInfo.AdapterCnt++;
  712. RCADEBUGP(RCA_INFO, ("RCAOpenAdapterComplete: Incremented adapter count, current value == %d\n", pProtocolContext->BindingInfo.AdapterCnt));
  713. RELEASE_SPIN_LOCK(&pProtocolContext->SpinLock);
  714. RCADEBUGP(RCA_LOUD, ("RCAOpenAdapterComplete: Released global protocol context lock\n"));
  715. }
  716. RCASignal(&pAdapter->Block, Status);
  717. }
  718. VOID
  719. RCACloseAdapterComplete(
  720. IN NDIS_HANDLE BindingContext,
  721. IN NDIS_STATUS Status
  722. )
  723. /*++
  724. Routine Description
  725. Our CloseAdapter completion handler. We signal whoever closed the
  726. adapter.
  727. Arguments
  728. BindingContext - A pointer to a RCA_ADAPTER structure.
  729. Status - Status of close attempt.
  730. Return Value:
  731. None
  732. --*/
  733. {
  734. PRCA_ADAPTER pAdapter;
  735. pAdapter = (PRCA_ADAPTER)BindingContext;
  736. RCAStructAssert(pAdapter, rca);
  737. RCAAssert(Status == NDIS_STATUS_SUCCESS);
  738. RCASignal(&pAdapter->Block, Status);
  739. }
  740. VOID
  741. RCANotifyAfRegistration(
  742. IN NDIS_HANDLE BindingContext,
  743. IN PCO_ADDRESS_FAMILY pFamily
  744. )
  745. /*++
  746. Routine Description:
  747. We get called here each time a call manager registers an address family.
  748. This is where we open the address family if it's the Proxy.
  749. Arguments:
  750. RCABindingContext - our pointer to an adapter
  751. pFamily - The AF that's been registered
  752. Return Value:
  753. None
  754. --*/
  755. {
  756. PRCA_PROTOCOL_CONTEXT pProtocolContext = &GlobalContext;
  757. NDIS_CLIENT_CHARACTERISTICS RCAClientCharacteristics;
  758. PRCA_ADAPTER pAdapter;
  759. PCO_SAP Sap;
  760. NDIS_STATUS Status;
  761. UCHAR SapBuf[sizeof(CO_SAP) + sizeof(RCA_SAP_STRING)];
  762. #if DBG
  763. KIRQL EntryIrql;
  764. #endif
  765. RCA_GET_ENTRY_IRQL(EntryIrql);
  766. RCADEBUGP(RCA_LOUD,("RCANotifyAfRegistration: Enter - Adapter 0x%x, AF 0x%x\n",
  767. BindingContext, pFamily->AddressFamily));
  768. pAdapter = (PRCA_ADAPTER)BindingContext;
  769. if ((pFamily->AddressFamily != CO_ADDRESS_FAMILY_TAPI) ||
  770. (pAdapter->NdisAfHandle != NULL))
  771. {
  772. //
  773. // Not Proxy or already bound -- do nothing
  774. //
  775. return;
  776. }
  777. RCADEBUGP(RCA_LOUD, ("RCANotifyAfRegistration: Opening Proxy AF\n"));
  778. //
  779. // Check that the adapter is not being unbound.
  780. //
  781. ACQUIRE_SPIN_LOCK(&pAdapter->SpinLock);
  782. if ((pAdapter->AdapterFlags & RCA_ADAPTERFLAGS_UNBIND_IN_PROGRESS) ||
  783. (pAdapter->AdapterFlags & RCA_ADAPTERFLAGS_UNBIND_COMPLETE) ||
  784. (pAdapter->AdapterFlags & RCA_ADAPTERFLAGS_DEACTIVATE_IN_PROGRESS) ||
  785. (pAdapter->AdapterFlags & RCA_ADAPTERFLAGS_DEACTIVATE_COMPLETE)) {
  786. RELEASE_SPIN_LOCK(&pAdapter->SpinLock);
  787. RCADEBUGP(RCA_INFO, ("RCANotifyAfRegistration: Adapter is being unbound - bailing\n"));
  788. return;
  789. }
  790. if (pAdapter->AfRegisteringCount == 0) {
  791. RCAInitBlockStruc(&pAdapter->AfRegisterBlock);
  792. }
  793. pAdapter->AfRegisteringCount++;
  794. pAdapter->OldAdapterFlags = pAdapter->AdapterFlags;
  795. pAdapter->AdapterFlags = 0;
  796. RELEASE_SPIN_LOCK(&pAdapter->SpinLock);
  797. do
  798. {
  799. //
  800. // Do the client open on the address family
  801. //
  802. NdisZeroMemory (&RCAClientCharacteristics, sizeof(NDIS_CLIENT_CHARACTERISTICS));
  803. RCAClientCharacteristics.MajorVersion = NDIS_MAJOR_VERSION;
  804. RCAClientCharacteristics.MinorVersion = NDIS_MINOR_VERSION;
  805. RCAClientCharacteristics.Reserved = 0;
  806. RCAClientCharacteristics.ClCreateVcHandler = RCACreateVc;
  807. RCAClientCharacteristics.ClDeleteVcHandler = RCADeleteVc;
  808. RCAClientCharacteristics.ClRequestHandler = RCARequest;
  809. RCAClientCharacteristics.ClRequestCompleteHandler = RCACoRequestComplete;
  810. RCAClientCharacteristics.ClOpenAfCompleteHandler = RCAOpenAfComplete;
  811. RCAClientCharacteristics.ClCloseAfCompleteHandler = RCACloseAfComplete;
  812. RCAClientCharacteristics.ClRegisterSapCompleteHandler = RCARegisterSapComplete;
  813. RCAClientCharacteristics.ClDeregisterSapCompleteHandler = RCADeregisterSapComplete;
  814. RCAClientCharacteristics.ClCloseCallCompleteHandler = RCACloseCallComplete;
  815. RCAClientCharacteristics.ClIncomingCallHandler = RCAIncomingCall;
  816. RCAClientCharacteristics.ClIncomingCallQoSChangeHandler = RCAIncomingCallQosChange;
  817. RCAClientCharacteristics.ClIncomingCloseCallHandler = RCAIncomingCloseCall;
  818. RCAClientCharacteristics.ClCallConnectedHandler = RCACallConnected;
  819. RCADEBUGP(RCA_INFO,(" NotifyAfRegistration -- NdisClOpenAddressFamily\n"));
  820. RCAInitBlockStruc(&pAdapter->Block);
  821. Status = NdisClOpenAddressFamily(pAdapter->NdisBindingHandle,
  822. pFamily,
  823. (NDIS_HANDLE)pAdapter,
  824. &RCAClientCharacteristics,
  825. sizeof(NDIS_CLIENT_CHARACTERISTICS),
  826. &pAdapter->NdisAfHandle);
  827. if (Status == NDIS_STATUS_PENDING)
  828. {
  829. RCABlock(&pAdapter->Block, &Status);
  830. }
  831. if (Status != NDIS_STATUS_SUCCESS)
  832. {
  833. //
  834. // Open AF failure.
  835. //
  836. RCADEBUGP(RCA_ERROR, ("RCANotifyAfRegistration -- open AF failure, status == 0x%x\n", Status));
  837. break;
  838. }
  839. InterlockedIncrement(&pAdapter->AfOpenCount);
  840. RCADEBUGP(RCA_LOUD, ("RCANotifyAfRegistration -- calling RCARegisterSap\n"));
  841. RCAInitBlockStruc(&pAdapter->Block);
  842. Sap = (PCO_SAP)SapBuf;
  843. // Sap->SapType = SAP_TYPE_NSAP;
  844. Sap->SapLength = sizeof(SapBuf);
  845. RtlCopyMemory(&Sap->Sap, RCA_SAP_STRING, sizeof(RCA_SAP_STRING));
  846. Status = NdisClRegisterSap(pAdapter->NdisAfHandle,
  847. pAdapter,
  848. Sap,
  849. &pAdapter->NdisSapHandle);
  850. if (Status == NDIS_STATUS_PENDING)
  851. {
  852. RCABlock(&pAdapter->Block, &Status);
  853. }
  854. if (Status != NDIS_STATUS_SUCCESS)
  855. {
  856. //
  857. // So we opned the AF, but the CM didn't let us register our SAP.
  858. //
  859. RCADEBUGP(RCA_ERROR, ("RCANotifyAfRegistration - "
  860. "RCARegisterSap on NdisAfHandle 0x%x and pAdapter 0x%x "
  861. "failed with status 0x%x\n",
  862. pAdapter->NdisAfHandle, pAdapter, Status));
  863. //
  864. // Close AF
  865. //
  866. RCAInitBlockStruc(&pAdapter->Block);
  867. Status = NdisClCloseAddressFamily(pAdapter->NdisAfHandle);
  868. if (Status == NDIS_STATUS_PENDING)
  869. {
  870. RCABlock(&pAdapter->Block, &Status);
  871. }
  872. break;
  873. }
  874. ACQUIRE_SPIN_LOCK(&pProtocolContext->SpinLock);
  875. RCADEBUGP(RCA_LOUD, ("RCANotifyAfRegistration: Acquired global protocol context lock\n"));
  876. pProtocolContext->BindingInfo.SAPCnt++;
  877. RCADEBUGP(RCA_INFO, ("RCANotifyAfRegistration: "
  878. "Incremented SAP count, current value == %d\n", pProtocolContext->BindingInfo.SAPCnt));
  879. if (pProtocolContext->BindingInfo.BindingsComplete &&
  880. (pProtocolContext->BindingInfo.SAPCnt == pProtocolContext->BindingInfo.AdapterCnt)) {
  881. RCADEBUGP(RCA_INFO, ("RCANotifyAfRegistration: Unblocking RCACoNdisInitialize(), counts == %d\n",
  882. pProtocolContext->BindingInfo.AdapterCnt));
  883. RCASignal(&pProtocolContext->BindingInfo.Block, Status);
  884. } else {
  885. RCADEBUGP(RCA_INFO, ("RCANotifyAfRegistration: Not unblocking RCACoNdisInitialize() - SAPCnt == %d, AdapterCnt == %d\n",
  886. pProtocolContext->BindingInfo.SAPCnt,
  887. pProtocolContext->BindingInfo.AdapterCnt));
  888. }
  889. RELEASE_SPIN_LOCK(&pProtocolContext->SpinLock);
  890. RCADEBUGP(RCA_LOUD, ("RCANotifyAfRegistration: Released global protocol context lock\n"));
  891. } while (FALSE);
  892. ACQUIRE_SPIN_LOCK(&pAdapter->SpinLock);
  893. pAdapter->AfRegisteringCount--;
  894. if (pAdapter->AfRegisteringCount == 0) {
  895. RCASignal(&pAdapter->AfRegisterBlock, NDIS_STATUS_SUCCESS);
  896. }
  897. RELEASE_SPIN_LOCK(&pAdapter->SpinLock);
  898. RCA_CHECK_EXIT_IRQL(EntryIrql);
  899. RCADEBUGP(RCA_INFO, ("RCANotifyAfRegistration: Exit\n"));
  900. }
  901. VOID
  902. RCAOpenAfComplete(
  903. IN NDIS_STATUS Status,
  904. IN NDIS_HANDLE ProtocolAfContext,
  905. IN NDIS_HANDLE NdisAfHandle
  906. )
  907. {
  908. PRCA_ADAPTER pAdapter;
  909. RCADEBUGP(RCA_INFO,("RCAOpenAfComplete: Enter - Status = 0X%x, AfHandle = 0X%x\n",
  910. Status, NdisAfHandle));
  911. pAdapter = (PRCA_ADAPTER)ProtocolAfContext;
  912. RCAStructAssert(pAdapter, rca);
  913. if (NDIS_STATUS_SUCCESS == Status)
  914. {
  915. pAdapter->NdisAfHandle = NdisAfHandle;
  916. }
  917. RCASignal(&pAdapter->Block, Status);
  918. RCADEBUGP(RCA_INFO, ("RCAOpenAfComplete: Exit\n"));
  919. }
  920. VOID
  921. RCACloseAfComplete(
  922. IN NDIS_STATUS Status,
  923. IN NDIS_HANDLE ProtocolAfContext
  924. )
  925. {
  926. PRCA_ADAPTER pAdapter;
  927. RCADEBUGP(RCA_INFO, ("RCACloseAfComplete: Enter\n"));
  928. pAdapter = (PRCA_ADAPTER)ProtocolAfContext;
  929. pAdapter->NdisAfHandle = NULL;
  930. RCASignal(&pAdapter->Block, Status);
  931. RCADEBUGP(RCA_INFO, ("RCACloseAfComplete: Exit\n"));
  932. }
  933. VOID
  934. RCARegisterSapComplete(
  935. IN NDIS_STATUS Status,
  936. IN NDIS_HANDLE ProtocolSapContext,
  937. IN PCO_SAP pSap,
  938. IN NDIS_HANDLE NdisSapHandle
  939. )
  940. /*++
  941. Routine Description:
  942. This routine is called to indicate completion of a call to
  943. NdisClRegisterSap. If the call was successful, save the
  944. allocated NdisSapHandle in our SAP structure.
  945. Arguments:
  946. Status - Status of Register SAP
  947. ProtocolSapContext - Pointer to our SAP structure
  948. pSap - SAP information we'd passed in the call
  949. NdisSapHandle - SAP Handle
  950. Return Value:
  951. None
  952. --*/
  953. {
  954. PRCA_ADAPTER pAdapter;
  955. RCADEBUGP(RCA_INFO, ("RCARegisterSapComplete: Enter\n"));
  956. pAdapter = (PRCA_ADAPTER)ProtocolSapContext;
  957. if (Status == NDIS_STATUS_SUCCESS)
  958. {
  959. pAdapter->NdisSapHandle = NdisSapHandle;
  960. }
  961. RCASignal(&pAdapter->Block, Status);
  962. RCADEBUGP(RCA_INFO, ("RCARegisterSapComplete: Exit\n"));
  963. }
  964. VOID
  965. RCADeregisterSapComplete(
  966. IN NDIS_STATUS Status,
  967. IN NDIS_HANDLE ProtocolSapContext
  968. )
  969. {
  970. PRCA_ADAPTER pAdapter;
  971. RCADEBUGP(RCA_LOUD,("RCADeregisterSapComplete: Enter\n"));
  972. pAdapter = (PRCA_ADAPTER)ProtocolSapContext;
  973. pAdapter->NdisSapHandle = NULL;
  974. RCASignal(&pAdapter->Block, Status);
  975. RCADEBUGP(RCA_LOUD,("RCADeregisterSapComplete: Exit\n"));
  976. }
  977. //
  978. // Dummy NDIS functions
  979. //
  980. VOID
  981. RCATransferDataComplete(
  982. IN NDIS_HANDLE ProtocolBindingContext,
  983. IN PNDIS_PACKET Packet,
  984. IN NDIS_STATUS Status,
  985. IN UINT BytesTransferred)
  986. {
  987. RCAAssert(FALSE);
  988. }
  989. VOID
  990. RCAResetComplete(
  991. IN NDIS_HANDLE ProtocolBindingContext,
  992. IN NDIS_STATUS Status
  993. )
  994. {
  995. RCAAssert(FALSE);
  996. }
  997. VOID
  998. RCARequestComplete(
  999. IN NDIS_HANDLE ProtocolBindingContext,
  1000. IN PNDIS_REQUEST NdisRequest,
  1001. IN NDIS_STATUS Status
  1002. )
  1003. {
  1004. }
  1005. NDIS_STATUS
  1006. RCAReceive(
  1007. IN NDIS_HANDLE ProtocolBindingContext,
  1008. IN NDIS_HANDLE MacReceiveContext,
  1009. IN PVOID HeaderBuffer,
  1010. IN UINT HeaderBufferSize,
  1011. IN PVOID LookAheadBuffer,
  1012. IN UINT LookAheadBufferSize,
  1013. IN UINT PacketSize
  1014. )
  1015. {
  1016. RCAAssert(FALSE);
  1017. return(NDIS_STATUS_FAILURE);
  1018. }
  1019. INT
  1020. RCAReceivePacket(
  1021. IN NDIS_HANDLE ProtocolBindingContext,
  1022. IN PNDIS_PACKET Packet
  1023. )
  1024. {
  1025. RCAAssert(FALSE);
  1026. return(0);
  1027. }
  1028. VOID
  1029. RCAStatus(
  1030. IN NDIS_HANDLE ProtocolBindingContext,
  1031. IN NDIS_STATUS GeneralStatus,
  1032. IN PVOID StatusBuffer,
  1033. IN UINT StatusBufferSize)
  1034. {
  1035. }
  1036. VOID
  1037. RCAStatusComplete(
  1038. IN NDIS_HANDLE ProtocolBindingContext
  1039. )
  1040. {
  1041. }
  1042. VOID
  1043. RCACoStatus(
  1044. IN NDIS_HANDLE ProtocolBindingContext,
  1045. IN NDIS_HANDLE ProtocolVcContext OPTIONAL,
  1046. IN NDIS_STATUS GeneralStatus,
  1047. IN PVOID StatusBuffer,
  1048. IN UINT StatusBufferSize)
  1049. {
  1050. RCADEBUGP(RCA_INFO, (" RCACoStatus: Bind Ctx 0x%x, Status 0x%x\n",
  1051. ProtocolBindingContext, GeneralStatus));
  1052. }
  1053. VOID
  1054. RCASendComplete(
  1055. IN NDIS_HANDLE ProtocolBindingContext,
  1056. IN PNDIS_PACKET Packet,
  1057. IN NDIS_STATUS Status
  1058. )
  1059. {
  1060. RCAAssert(TRUE);
  1061. }
  1062. VOID
  1063. RCAModifyCallQosComplete(
  1064. IN NDIS_STATUS status,
  1065. IN NDIS_HANDLE ProtocolVcContext,
  1066. IN PCO_CALL_PARAMETERS CallParameters
  1067. )
  1068. {
  1069. RCAAssert(TRUE);
  1070. }
  1071. VOID
  1072. RCAAddPartyComplete(
  1073. IN NDIS_STATUS status,
  1074. IN NDIS_HANDLE ProtocolPartyContext,
  1075. IN NDIS_HANDLE NdisPartyHandle,
  1076. IN PCO_CALL_PARAMETERS CallParameters
  1077. )
  1078. {
  1079. RCAAssert(FALSE);
  1080. }
  1081. VOID
  1082. RCADropPartyComplete(
  1083. IN NDIS_STATUS status,
  1084. IN NDIS_HANDLE ProtocolPartyContext
  1085. )
  1086. {
  1087. RCAAssert(FALSE);
  1088. }
  1089. VOID
  1090. RCAIncomingCallQosChange(
  1091. IN NDIS_HANDLE ProtocolVcContext,
  1092. IN PCO_CALL_PARAMETERS CallParameters
  1093. )
  1094. {
  1095. RCAAssert(TRUE);
  1096. }
  1097. VOID
  1098. RCAIncomingDropParty(
  1099. IN NDIS_STATUS DropStatus,
  1100. IN NDIS_HANDLE ProtocolPartyContext,
  1101. IN PVOID CloseData OPTIONAL,
  1102. IN UINT Size OPTIONAL)
  1103. {
  1104. RCAAssert(TRUE);
  1105. }
  1106. VOID
  1107. RCACoRequestComplete(
  1108. IN NDIS_STATUS NdisStatus,
  1109. IN NDIS_HANDLE ProtocolAfContext,
  1110. IN NDIS_HANDLE ProtocolVcContext OPTIONAL,
  1111. IN NDIS_HANDLE ProtocolPartyContext OPTIONAL,
  1112. IN OUT PNDIS_REQUEST NdisRequest
  1113. )
  1114. {
  1115. RCADEBUGP(RCA_INFO, ("RCACoRequestComplete: Enter\n"));
  1116. RCADEBUGP(RCA_INFO, ("RCACoRequestComplete: Exit\n"));
  1117. }