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.

1247 lines
22 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. macros.h
  5. Abstract:
  6. Macros for the ATMARP module
  7. Author:
  8. Revision History:
  9. Who When What
  10. -------- -------- ----
  11. arvindm 05-20-96 created
  12. Notes:
  13. --*/
  14. #ifndef __ATMARP_MACROS_H_INCLUDED
  15. #define __ATMARP_MACROS_H_INCLUDED
  16. #include "atmarp.h"
  17. #define INCR_STAT(_x) NdisInterlockedIncrement(&(_x))
  18. #ifndef MAX
  19. /*++
  20. OPAQUE
  21. MAX(
  22. IN OPAQUE Fred,
  23. IN OPAQUE Shred
  24. )
  25. --*/
  26. #define MAX(Fred, Shred) (((Fred) > (Shred)) ? (Fred) : (Shred))
  27. #endif // MAX
  28. #ifndef MIN
  29. /*++
  30. OPAQUE
  31. MIN(
  32. IN OPAQUE Fred,
  33. IN OPAQUE Shred
  34. )
  35. --*/
  36. #define MIN(Fred, Shred) (((Fred) < (Shred)) ? (Fred) : (Shred))
  37. #endif // MIN
  38. /*++
  39. ULONG
  40. ATMARP_HASH(
  41. IN IP_ADDRESS IpAddress
  42. )
  43. --*/
  44. #define ATMARP_HASH(IpAddress) \
  45. (((ULONG)(IpAddress)) % ATMARP_TABLE_SIZE)
  46. /*++
  47. VOID
  48. AA_SET_FLAG(
  49. IN ULONG Flags,
  50. IN ULONG Mask,
  51. IN ULONG Val
  52. )
  53. --*/
  54. #define AA_SET_FLAG(Flags, Mask, Val) \
  55. (Flags) = ((Flags) & ~(Mask)) | (Val)
  56. /*++
  57. BOOLEAN
  58. AA_IS_FLAG_SET(
  59. IN ULONG Flags,
  60. IN ULONG Mask,
  61. IN ULONG Val
  62. )
  63. --*/
  64. #define AA_IS_FLAG_SET(Flags, Mask, Val) \
  65. (((Flags) & (Mask)) == (Val))
  66. #ifdef IPMCAST
  67. /*++
  68. VOID
  69. AAMC_SET_IF_STATE(
  70. IN PATMARP_INTERFACE _pIf,
  71. IN ULONG _NewState
  72. )
  73. Set the Multicast state for the specified Interface to the given value.
  74. --*/
  75. #define AAMC_SET_IF_STATE(_pIf, _NewState) \
  76. AA_SET_FLAG((_pIf)->Flags, AAMC_IF_STATE_MASK, (_NewState))
  77. /*++
  78. ULONG
  79. AAMC_IF_STATE(
  80. IN PATMARP_INTERFACE _pIf
  81. )
  82. Get the Multicast state for the specified Interface.
  83. --*/
  84. #define AAMC_IF_STATE(_pIf) ((_pIf)->Flags & AAMC_IF_STATE_MASK)
  85. #endif // IPMCAST
  86. /*++
  87. VOID
  88. AA_INIT_BLOCK_STRUCT(
  89. IN ATMARP_BLOCK *pBlock
  90. )
  91. --*/
  92. #define AA_INIT_BLOCK_STRUCT(pBlock) NdisInitializeEvent(&((pBlock)->Event))
  93. /*++
  94. NDIS_STATUS
  95. AA_WAIT_ON_BLOCK_STRUCT(
  96. IN ATMARP_BLOCK *pBlock
  97. )
  98. --*/
  99. #define AA_WAIT_ON_BLOCK_STRUCT(pBlock) \
  100. (NdisWaitEvent(&((pBlock)->Event), 0), (pBlock)->Status)
  101. /*++
  102. VOID
  103. AA_SIGNAL_BLOCK_STRUCT(
  104. IN ATMARP_BLOCK *pBlock,
  105. IN UINT Status
  106. )
  107. --*/
  108. #define AA_SIGNAL_BLOCK_STRUCT(pBlock, _Status) \
  109. { (pBlock)->Status = _Status; NdisSetEvent(&((pBlock)->Event)); }
  110. /*++
  111. VOID
  112. AA_FREE_BLOCK_STRUCT(
  113. IN ATMARP_BLOCK *pBlock
  114. )
  115. --*/
  116. #define AA_FREE_BLOCK_STRUCT(pBlock) // Nothing to be done here
  117. /*++
  118. VOID
  119. AA_INIT_LOCK(
  120. IN PNDIS_SPIN_LOCK pLock
  121. )
  122. --*/
  123. #if DBG_SPIN_LOCK
  124. #define AA_INIT_LOCK(pLock) \
  125. AtmArpAllocateSpinLock(pLock, _FILENUMBER, __LINE__)
  126. #else
  127. #define AA_INIT_LOCK(pLock) \
  128. NdisAllocateSpinLock(pLock)
  129. #endif // DBG_SPIN_LOCK
  130. /*++
  131. VOID
  132. AA_ACQUIRE_LOCK(
  133. IN PNDIS_SPIN_LOCK pLock
  134. )
  135. --*/
  136. #if DBG_SPIN_LOCK
  137. #define AA_ACQUIRE_LOCK(pLock) \
  138. AtmArpAcquireSpinLock(pLock, _FILENUMBER, __LINE__)
  139. #else
  140. #define AA_ACQUIRE_LOCK(pLock) \
  141. NdisAcquireSpinLock(pLock)
  142. #endif // DBG_SPIN_LOCK
  143. /*++
  144. VOID
  145. AA_ACQUIRE_LOCK_DPC(
  146. IN PNDIS_SPIN_LOCK pLock
  147. )
  148. --*/
  149. #if DBG_SPIN_LOCK
  150. #define AA_ACQUIRE_LOCK_DPC(pLock) \
  151. AtmArpAcquireSpinLock(pLock, _FILENUMBER, __LINE__)
  152. #else
  153. #define AA_ACQUIRE_LOCK_DPC(pLock) \
  154. NdisDprAcquireSpinLock(pLock)
  155. #endif // DBG_SPIN_LOCK
  156. /*++
  157. VOID
  158. AA_RELEASE_LOCK(
  159. IN PNDIS_SPIN_LOCK pLock
  160. )
  161. --*/
  162. #if DBG_SPIN_LOCK
  163. #define AA_RELEASE_LOCK(pLock) \
  164. AtmArpReleaseSpinLock(pLock, _FILENUMBER, __LINE__)
  165. #else
  166. #define AA_RELEASE_LOCK(pLock) \
  167. NdisReleaseSpinLock(pLock)
  168. #endif // DBG_SPIN_LOCK
  169. /*++
  170. VOID
  171. AA_RELEASE_LOCK_DPC(
  172. IN PNDIS_SPIN_LOCK pLock
  173. )
  174. --*/
  175. #if DBG_SPIN_LOCK
  176. #define AA_RELEASE_LOCK_DPC(pLock) \
  177. AtmArpReleaseSpinLock(pLock, _FILENUMBER, __LINE__)
  178. #else
  179. #define AA_RELEASE_LOCK_DPC(pLock) \
  180. NdisDprReleaseSpinLock(pLock)
  181. #endif // DBG_SPIN_LOCK
  182. /*++
  183. VOID
  184. AA_FREE_LOCK(
  185. IN PNDIS_SPIN_LOCK pLock
  186. )
  187. --*/
  188. #define AA_FREE_LOCK(pLock) \
  189. NdisFreeSpinLock(pLock)
  190. /*++
  191. VOID
  192. AA_INIT_IF_LOCK(
  193. IN PATMARP_INTERFACE pIf
  194. )
  195. --*/
  196. #define AA_INIT_IF_LOCK(pIf) \
  197. AA_INIT_LOCK(&((pIf)->InterfaceLock))
  198. /*++
  199. VOID
  200. AA_ACQUIRE_IF_LOCK(
  201. IN PATMARP_INTERFACE pIf
  202. )
  203. --*/
  204. #define AA_ACQUIRE_IF_LOCK(pIf) \
  205. AA_ACQUIRE_LOCK(&((pIf)->InterfaceLock))
  206. /*++
  207. VOID
  208. AA_ACQUIRE_IF_LOCK_DPC(
  209. IN PATMARP_INTERFACE pIf
  210. )
  211. --*/
  212. #define AA_ACQUIRE_IF_LOCK_DPC(pIf) \
  213. AA_ACQUIRE_LOCK_DPC(&((pIf)->InterfaceLock))
  214. /*++
  215. VOID
  216. AA_RELEASE_IF_LOCK(
  217. IN PATMARP_INTERFACE pIf
  218. )
  219. --*/
  220. #define AA_RELEASE_IF_LOCK(pIf) \
  221. AA_RELEASE_LOCK(&((pIf)->InterfaceLock))
  222. /*++
  223. VOID
  224. AA_RELEASE_IF_LOCK_DPC(
  225. IN PATMARP_INTERFACE pIf
  226. )
  227. --*/
  228. #define AA_RELEASE_IF_LOCK_DPC(pIf) \
  229. AA_RELEASE_LOCK_DPC(&((pIf)->InterfaceLock))
  230. /*++
  231. VOID
  232. AA_FREE_IF_LOCK(
  233. IN PATMARP_INTERFACE pIf
  234. )
  235. --*/
  236. #define AA_FREE_IF_LOCK(pIf) \
  237. AA_FREE_LOCK(&((pIf)->InterfaceLock))
  238. /*++
  239. VOID
  240. AA_INIT_IF_TABLE_LOCK(
  241. IN PATMARP_INTERFACE pIf
  242. )
  243. --*/
  244. #define AA_INIT_IF_TABLE_LOCK(pIf) \
  245. AA_INIT_LOCK(&((pIf)->ArpTableLock))
  246. /*++
  247. VOID
  248. AA_ACQUIRE_IF_TABLE_LOCK(
  249. IN PATMARP_INTERFACE pIf
  250. )
  251. --*/
  252. #define AA_ACQUIRE_IF_TABLE_LOCK(pIf) \
  253. AA_ACQUIRE_LOCK(&((pIf)->ArpTableLock))
  254. /*++
  255. VOID
  256. AA_ACQUIRE_IF_TABLE_LOCK_DPC(
  257. IN PATMARP_INTERFACE pIf
  258. )
  259. --*/
  260. #define AA_ACQUIRE_IF_TABLE_LOCK_DPC(pIf) \
  261. AA_ACQUIRE_LOCK_DPC(&((pIf)->ArpTableLock))
  262. /*++
  263. VOID
  264. AA_RELEASE_IF_TABLE_LOCK(
  265. IN PATMARP_INTERFACE pIf
  266. )
  267. --*/
  268. #define AA_RELEASE_IF_TABLE_LOCK(pIf) \
  269. AA_RELEASE_LOCK(&((pIf)->ArpTableLock))
  270. /*++
  271. VOID
  272. AA_RELEASE_IF_TABLE_LOCK_DPC(
  273. IN PATMARP_INTERFACE pIf
  274. )
  275. --*/
  276. #define AA_RELEASE_IF_TABLE_LOCK_DPC(pIf) \
  277. AA_RELEASE_LOCK_DPC(&((pIf)->ArpTableLock))
  278. /*++
  279. VOID
  280. AA_FREE_IF_TABLE_LOCK(
  281. IN PATMARP_INTERFACE pIf
  282. )
  283. --*/
  284. #define AA_FREE_IF_TABLE_LOCK(pIf) \
  285. AA_FREE_LOCK(&((pIf)->ArpTableLock))
  286. /*++
  287. VOID
  288. AA_INIT_IF_ATM_LIST_LOCK(
  289. IN PATMARP_INTERFACE pIf
  290. )
  291. --*/
  292. #define AA_INIT_IF_ATM_LIST_LOCK(pIf) \
  293. AA_INIT_LOCK(&((pIf)->AtmEntryListLock))
  294. /*++
  295. VOID
  296. AA_ACQUIRE_IF_ATM_LIST_LOCK(
  297. IN PATMARP_INTERFACE pIf
  298. )
  299. --*/
  300. #define AA_ACQUIRE_IF_ATM_LIST_LOCK(pIf) \
  301. AA_ACQUIRE_LOCK(&((pIf)->AtmEntryListLock))
  302. /*++
  303. VOID
  304. AA_ACQUIRE_IF_ATM_LIST_LOCK_DPC(
  305. IN PATMARP_INTERFACE pIf
  306. )
  307. --*/
  308. #define AA_ACQUIRE_IF_ATM_LIST_LOCK_DPC(pIf) \
  309. AA_ACQUIRE_LOCK_DPC(&((pIf)->AtmEntryListLock))
  310. /*++
  311. VOID
  312. AA_RELEASE_IF_ATM_LIST_LOCK(
  313. IN PATMARP_INTERFACE pIf
  314. )
  315. --*/
  316. #define AA_RELEASE_IF_ATM_LIST_LOCK(pIf) \
  317. AA_RELEASE_LOCK(&((pIf)->AtmEntryListLock))
  318. /*++
  319. VOID
  320. AA_RELEASE_IF_ATM_LIST_LOCK_DPC(
  321. IN PATMARP_INTERFACE pIf
  322. )
  323. --*/
  324. #define AA_RELEASE_IF_ATM_LIST_LOCK_DPC(pIf) \
  325. AA_RELEASE_LOCK_DPC(&((pIf)->AtmEntryListLock))
  326. /*++
  327. VOID
  328. AA_FREE_IF_ATM_LIST_LOCK(
  329. IN PATMARP_INTERFACE pIf
  330. )
  331. --*/
  332. #define AA_FREE_IF_ATM_LIST_LOCK(pIf) \
  333. AA_FREE_LOCK(&((pIf)->AtmEntryListLock))
  334. /*++
  335. VOID
  336. AA_INIT_IF_TIMER_LOCK(
  337. IN PATMARP_INTERFACE pIf
  338. )
  339. --*/
  340. #define AA_INIT_IF_TIMER_LOCK(pIf) \
  341. AA_INIT_LOCK(&((pIf)->TimerLock))
  342. /*++
  343. VOID
  344. AA_ACQUIRE_IF_TIMER_LOCK(
  345. IN PATMARP_INTERFACE pIf
  346. )
  347. --*/
  348. #define AA_ACQUIRE_IF_TIMER_LOCK(pIf) \
  349. AA_ACQUIRE_LOCK(&((pIf)->TimerLock))
  350. /*++
  351. VOID
  352. AA_ACQUIRE_IF_TIMER_LOCK_DPC(
  353. IN PATMARP_INTERFACE pIf
  354. )
  355. --*/
  356. #define AA_ACQUIRE_IF_TIMER_LOCK_DPC(pIf) \
  357. AA_ACQUIRE_LOCK_DPC(&((pIf)->TimerLock))
  358. /*++
  359. VOID
  360. AA_RELEASE_IF_TIMER_LOCK(
  361. IN PATMARP_INTERFACE pIf
  362. )
  363. --*/
  364. #define AA_RELEASE_IF_TIMER_LOCK(pIf) \
  365. AA_RELEASE_LOCK(&((pIf)->TimerLock))
  366. /*++
  367. VOID
  368. AA_RELEASE_IF_TIMER_LOCK_DPC(
  369. IN PATMARP_INTERFACE pIf
  370. )
  371. --*/
  372. #define AA_RELEASE_IF_TIMER_LOCK_DPC(pIf) \
  373. AA_RELEASE_LOCK_DPC(&((pIf)->TimerLock))
  374. /*++
  375. VOID
  376. AA_FREE_IF_TIMER_LOCK(
  377. IN PATMARP_INTERFACE pIf
  378. )
  379. --*/
  380. #define AA_FREE_IF_TIMER_LOCK(pIf) \
  381. AA_FREE_LOCK(&((pIf)->TimerLock))
  382. /*++
  383. VOID
  384. AA_INIT_VC_LOCK(
  385. IN PATMARP_VC pVc
  386. )
  387. --*/
  388. #define AA_INIT_VC_LOCK(pVc) \
  389. AA_INIT_LOCK(&((pVc)->Lock))
  390. /*++
  391. VOID
  392. AA_ACQUIRE_VC_LOCK(
  393. IN PATMARP_VC pVc
  394. )
  395. --*/
  396. #define AA_ACQUIRE_VC_LOCK(pVc) \
  397. AA_ACQUIRE_LOCK(&((pVc)->Lock))
  398. /*++
  399. VOID
  400. AA_ACQUIRE_VC_LOCK_DPC(
  401. IN PATMARP_VC pVc
  402. )
  403. --*/
  404. #define AA_ACQUIRE_VC_LOCK_DPC(pVc) \
  405. AA_ACQUIRE_LOCK_DPC(&((pVc)->Lock))
  406. /*++
  407. VOID
  408. AA_RELEASE_VC_LOCK(
  409. IN PATMARP_VC pVc
  410. )
  411. --*/
  412. #define AA_RELEASE_VC_LOCK(pVc) \
  413. AA_RELEASE_LOCK(&((pVc)->Lock))
  414. /*++
  415. VOID
  416. AA_RELEASE_VC_LOCK_DPC(
  417. IN PATMARP_VC pVc
  418. )
  419. --*/
  420. #define AA_RELEASE_VC_LOCK_DPC(pVc) \
  421. AA_RELEASE_LOCK_DPC(&((pVc)->Lock))
  422. /*++
  423. VOID
  424. AA_FREE_VC_LOCK(
  425. IN PATMARP_VC pVc
  426. )
  427. --*/
  428. #define AA_FREE_VC_LOCK(pVc) \
  429. AA_FREE_LOCK(&((pVc)->Lock))
  430. /*++
  431. VOID
  432. AA_INIT_AE_LOCK(
  433. IN PATMARP_ATM_ENTRY pAtmEntry
  434. )
  435. --*/
  436. #define AA_INIT_AE_LOCK(pAtmEntry) \
  437. AA_INIT_LOCK(&((pAtmEntry)->Lock))
  438. /*++
  439. VOID
  440. AA_ACQUIRE_AE_LOCK(
  441. IN PATMARP_ATM_ENTRY pAtmEntry
  442. )
  443. --*/
  444. #define AA_ACQUIRE_AE_LOCK(pAtmEntry) \
  445. AA_ACQUIRE_LOCK(&((pAtmEntry)->Lock))
  446. /*++
  447. VOID
  448. AA_ACQUIRE_AE_LOCK_DPC(
  449. IN PATMARP_ATM_ENTRY pAtmEntry
  450. )
  451. --*/
  452. #define AA_ACQUIRE_AE_LOCK_DPC(pAtmEntry) \
  453. AA_ACQUIRE_LOCK_DPC(&((pAtmEntry)->Lock))
  454. /*++
  455. VOID
  456. AA_RELEASE_AE_LOCK(
  457. IN PATMARP_ATM_ENTRY pAtmEntry
  458. )
  459. --*/
  460. #define AA_RELEASE_AE_LOCK(pAtmEntry) \
  461. AA_RELEASE_LOCK(&((pAtmEntry)->Lock))
  462. /*++
  463. VOID
  464. AA_RELEASE_AE_LOCK_DPC(
  465. IN PATMARP_ATM_ENTRY pAtmEntry
  466. )
  467. --*/
  468. #define AA_RELEASE_AE_LOCK_DPC(pAtmEntry) \
  469. AA_RELEASE_LOCK_DPC(&((pAtmEntry)->Lock))
  470. /*++
  471. VOID
  472. AA_FREE_AE_LOCK(
  473. IN PATMARP_ATM_ENTRY pAtmEntry
  474. )
  475. --*/
  476. #define AA_FREE_AE_LOCK(pAtmEntry) \
  477. AA_FREE_LOCK(&((pAtmEntry)->Lock))
  478. /*++
  479. VOID
  480. AA_INIT_IE_LOCK(
  481. IN PATMARP_IP_ENTRY pIpEntry
  482. )
  483. --*/
  484. #define AA_INIT_IE_LOCK(pIpEntry) \
  485. AA_INIT_LOCK(&((pIpEntry)->Lock))
  486. /*++
  487. VOID
  488. AA_ACQUIRE_IE_LOCK(
  489. IN PATMARP_IP_ENTRY pIpEntry
  490. )
  491. --*/
  492. #define AA_ACQUIRE_IE_LOCK(pIpEntry) \
  493. AA_ACQUIRE_LOCK(&((pIpEntry)->Lock))
  494. /*++
  495. VOID
  496. AA_ACQUIRE_IE_LOCK_DPC(
  497. IN PATMARP_IP_ENTRY pIpEntry
  498. )
  499. --*/
  500. #define AA_ACQUIRE_IE_LOCK_DPC(pIpEntry) \
  501. AA_ACQUIRE_LOCK_DPC(&((pIpEntry)->Lock))
  502. /*++
  503. VOID
  504. AA_RELEASE_IE_LOCK(
  505. IN PATMARP_IP_ENTRY pIpEntry
  506. )
  507. --*/
  508. #define AA_RELEASE_IE_LOCK(pIpEntry) \
  509. AA_RELEASE_LOCK(&((pIpEntry)->Lock))
  510. /*++
  511. VOID
  512. AA_RELEASE_IE_LOCK_DPC(
  513. IN PATMARP_IP_ENTRY pIpEntry
  514. )
  515. --*/
  516. #define AA_RELEASE_IE_LOCK_DPC(pIpEntry) \
  517. AA_RELEASE_LOCK_DPC(&((pIpEntry)->Lock))
  518. /*++
  519. VOID
  520. AA_FREE_IE_LOCK(
  521. IN PATMARP_IP_ENTRY pIpEntry
  522. )
  523. --*/
  524. #define AA_FREE_IE_LOCK(pIpEntry) \
  525. AA_FREE_LOCK(&((pIpEntry)->Lock))
  526. /*++
  527. VOID
  528. AA_INIT_GLOBAL_LOCK(
  529. IN PATMARP_GLOBALS pGlob
  530. )
  531. --*/
  532. #define AA_INIT_GLOBAL_LOCK(pGlob) \
  533. AA_INIT_LOCK(&((pGlob)->Lock))
  534. /*++
  535. VOID
  536. AA_ACQUIRE_GLOBAL_LOCK(
  537. IN PATMARP_GLOBALS pGlob
  538. )
  539. --*/
  540. #define AA_ACQUIRE_GLOBAL_LOCK(pGlob) \
  541. AA_ACQUIRE_LOCK(&((pGlob)->Lock))
  542. /*++
  543. VOID
  544. AA_RELEASE_GLOBAL_LOCK(
  545. IN PATMARP_GLOBALS pGlob
  546. )
  547. --*/
  548. #define AA_RELEASE_GLOBAL_LOCK(pGlob) \
  549. AA_RELEASE_LOCK(&((pGlob)->Lock))
  550. /*++
  551. VOID
  552. AA_FREE_GLOBAL_LOCK(
  553. IN PATMARP_GLOBALS pGlob
  554. )
  555. --*/
  556. #define AA_FREE_GLOBAL_LOCK(pGlob) \
  557. AA_FREE_LOCK(&((pGlob)->Lock))
  558. #ifdef ATMARP_WMI
  559. /*++
  560. VOID
  561. AA_INIT_IF_WMI_LOCK(
  562. IN PATMARP_INTERFACE pIf
  563. )
  564. --*/
  565. #define AA_INIT_IF_WMI_LOCK(pIf) \
  566. AA_INIT_LOCK(&((pIf)->WmiLock))
  567. /*++
  568. VOID
  569. AA_ACQUIRE_IF_WMI_LOCK(
  570. IN PATMARP_INTERFACE pIf
  571. )
  572. --*/
  573. #define AA_ACQUIRE_IF_WMI_LOCK(pIf) \
  574. AA_ACQUIRE_LOCK(&((pIf)->WmiLock))
  575. /*++
  576. VOID
  577. AA_ACQUIRE_IF_WMI_LOCK_DPC(
  578. IN PATMARP_INTERFACE pIf
  579. )
  580. --*/
  581. #define AA_ACQUIRE_IF_WMI_LOCK_DPC(pIf) \
  582. AA_ACQUIRE_LOCK_DPC(&((pIf)->WmiLock))
  583. /*++
  584. VOID
  585. AA_RELEASE_IF_WMI_LOCK(
  586. IN PATMARP_INTERFACE pIf
  587. )
  588. --*/
  589. #define AA_RELEASE_IF_WMI_LOCK(pIf) \
  590. AA_RELEASE_LOCK(&((pIf)->WmiLock))
  591. /*++
  592. VOID
  593. AA_RELEASE_IF_WMI_LOCK_DPC(
  594. IN PATMARP_INTERFACE pIf
  595. )
  596. --*/
  597. #define AA_RELEASE_IF_WMI_LOCK_DPC(pIf) \
  598. AA_RELEASE_LOCK_DPC(&((pIf)->WmiLock))
  599. /*++
  600. VOID
  601. AA_FREE_IF_WMI_LOCK(
  602. IN PATMARP_INTERFACE pIf
  603. )
  604. --*/
  605. #define AA_FREE_IF_WMI_LOCK(pIf) \
  606. AA_FREE_LOCK(&((pIf)->WmiLock))
  607. #endif // ATMARP_WMI
  608. /*++
  609. BOOLEAN
  610. AA_IS_VC_GOING_DOWN(
  611. IN PATMARP_VC pVc
  612. )
  613. Is the VC being closed, or marked for closing?
  614. --*/
  615. #define AA_IS_VC_GOING_DOWN(_pVc) \
  616. (((_pVc)->Flags & (AA_VC_CLOSE_STATE_CLOSING|AA_VC_CALL_STATE_CLOSE_IN_PROGRESS)) != 0)
  617. #if !BINARY_COMPATIBLE
  618. #define AA_ALLOC_FROM_POOL(_pVar, _StructType, _Size) \
  619. (_pVar) = (_StructType *)ExAllocatePoolWithTag(NonPagedPool, \
  620. (_Size), \
  621. 'CPRA')
  622. #define AA_FREE_TO_POOL(_pMem) ExFreePool((PVOID)(_pMem))
  623. #endif
  624. /*++
  625. VOID
  626. AA_ALLOC_MEM(
  627. IN POPAQUE pVar,
  628. IN OPAQUE StructureType,
  629. IN ULONG SizeOfStructure
  630. )
  631. --*/
  632. #if DBG
  633. #define AA_ALLOC_MEM(pVar, StructureType, SizeOfStructure) \
  634. pVar = (StructureType *)AaAuditAllocMem( \
  635. (PVOID)(&(pVar)), \
  636. (ULONG)(SizeOfStructure), \
  637. _FILENUMBER, \
  638. __LINE__ \
  639. );
  640. #else
  641. #define AA_ALLOC_MEM(pVar, StructureType, SizeOfStructure) \
  642. NdisAllocateMemoryWithTag((PVOID *)(&pVar), (ULONG)(SizeOfStructure), (ULONG)'CPRA');
  643. #endif // DBG
  644. /*++
  645. VOID
  646. AA_FREE_MEM(
  647. IN POPAQUE pMem
  648. )
  649. --*/
  650. #if DBG
  651. #define AA_FREE_MEM(pMem) AaAuditFreeMem((PVOID)(pMem));
  652. #else
  653. #define AA_FREE_MEM(pMem) NdisFreeMemory((PVOID)(pMem), 0, 0);
  654. #endif // DBG
  655. /*++
  656. VOID
  657. AA_SET_MEM(
  658. IN POPAQUE pMem,
  659. IN UCHAR bValue,
  660. IN ULONG NumberOfBytes
  661. )
  662. --*/
  663. #define AA_SET_MEM(pMem, bValue, NumberOfBytes) \
  664. AtmArpSetMemory((PUCHAR)(pMem), (bValue), (NumberOfBytes));
  665. /*++
  666. VOID
  667. AA_COPY_MEM(
  668. IN POPAQUE pDst,
  669. IN POPAQUE pSrc,
  670. IN ULONG NumberOfBytes
  671. )
  672. --*/
  673. #define AA_COPY_MEM(pDst, pSrc, NumberOfBytes) \
  674. NdisMoveMemory((PVOID)(pDst), (PVOID)(pSrc), NumberOfBytes);
  675. /*++
  676. ULONG
  677. AA_MEM_CMP(
  678. IN PVOID pString1,
  679. IN PVOID pString2,
  680. IN ULONG Length
  681. )
  682. --*/
  683. #define AA_MEM_CMP(pString1, pString2, Length) \
  684. AtmArpMemCmp((PUCHAR)(pString1), (PUCHAR)(pString2), (ULONG)(Length))
  685. /*++
  686. VOID
  687. AA_INIT_SYSTEM_TIMER(
  688. IN PNDIS_TIMER pTimer,
  689. IN PNDIS_TIMER_FUNCTON pFunc,
  690. IN PVOID Context
  691. )
  692. --*/
  693. #define AA_INIT_SYSTEM_TIMER(pTimer, pFunc, Context) \
  694. NdisInitializeTimer(pTimer, (PNDIS_TIMER_FUNCTION)(pFunc), (PVOID)Context)
  695. /*++
  696. VOID
  697. AA_START_SYSTEM_TIMER(
  698. IN PNDIS_TIMER pTimer,
  699. IN UINT PeriodInSeconds
  700. )
  701. --*/
  702. #define AA_START_SYSTEM_TIMER(pTimer, PeriodInSeconds) \
  703. NdisSetTimer(pTimer, (UINT)(PeriodInSeconds * 1000))
  704. /*++
  705. VOID
  706. AA_STOP_SYSTEM_TIMER(
  707. IN PNDIS_TIMER pTimer
  708. )
  709. --*/
  710. #define AA_STOP_SYSTEM_TIMER(pTimer) \
  711. { \
  712. BOOLEAN WasCancelled; \
  713. NdisCancelTimer(pTimer, &WasCancelled); \
  714. }
  715. /*++
  716. BOOLEAN
  717. AA_IS_TIMER_ACTIVE(
  718. IN PATMARP_TIMER pArpTimer
  719. )
  720. --*/
  721. #define AA_IS_TIMER_ACTIVE(pTmr) ((pTmr)->pTimerList != (PATMARP_TIMER_LIST)NULL)
  722. /*++
  723. ULONG
  724. AA_GET_TIMER_DURATION(
  725. IN PATMARP_TIMER pTimer
  726. )
  727. --*/
  728. #define AA_GET_TIMER_DURATION(pTmr) ((pTmr)->Duration)
  729. #ifndef NO_TIMER_MACRO
  730. /*++
  731. VOID
  732. AtmArpRefreshTimer(
  733. IN PATMARP_TIMER pTimer
  734. )
  735. --*/
  736. #define AtmArpRefreshTimer(_pTmr) \
  737. { \
  738. PATMARP_TIMER_LIST _pTimerList; \
  739. \
  740. if ((_pTimerList = (_pTmr)->pTimerList) != (PATMARP_TIMER_LIST)NULL) \
  741. { \
  742. (_pTmr)->LastRefreshTime = _pTimerList->CurrentTick; \
  743. } \
  744. }
  745. #endif // !NO_TIMER_MACRO
  746. /*++
  747. ULONG
  748. SECONDS_TO_LONG_TICKS(
  749. IN ULONG Seconds
  750. )
  751. Convert from seconds to "long duration timer ticks"
  752. --*/
  753. #define SECONDS_TO_LONG_TICKS(Seconds) ((Seconds)/10)
  754. /*++
  755. ULONG
  756. SECONDS_TO_SHORT_TICKS(
  757. IN ULONG Seconds
  758. )
  759. Convert from seconds to "short duration timer ticks"
  760. --*/
  761. #define SECONDS_TO_SHORT_TICKS(Seconds) (Seconds)
  762. /*++
  763. ULONG
  764. CELLS_TO_BYTES(
  765. IN ULONG NumberOfCells
  766. )
  767. Convert from cell count to byte count
  768. --*/
  769. #define CELLS_TO_BYTES(NumberOfCells) ((NumberOfCells) * 48)
  770. /*++
  771. ULONG
  772. BYTES_TO_CELLS(
  773. IN ULONG ByteCount
  774. )
  775. Convert from byte count to cell count
  776. --*/
  777. #define BYTES_TO_CELLS(ByteCount) ((ByteCount) / 48)
  778. /*++
  779. VOID
  780. AA_IF_STAT_INCR(
  781. IN PATMARP_INTERFACE pInterface,
  782. IN OPAQUE StatsCounter
  783. )
  784. Increment the specified StatsCounter on an Interface by 1.
  785. --*/
  786. #define AA_IF_STAT_INCR(pInterface, StatsCounter) \
  787. NdisInterlockedIncrement(&(pInterface->StatsCounter))
  788. /*++
  789. VOID
  790. AA_IF_STAT_ADD_LOCK(
  791. IN PATMARP_INTERFACE pInterface,
  792. IN OPAQUE StatsCounter,
  793. IN ULONG IncrValue
  794. )
  795. Increment the specified StatsCounter on an Interface by the specified IncrValue.
  796. Take a lock on the interface to do so.
  797. --*/
  798. #if DBG_SPIN_LOCK
  799. #define AA_IF_STAT_ADD_LOCK(pInterface, StatsCounter, IncrValue) \
  800. NdisInterlockedAddUlong(&(pInterface->StatsCounter), IncrValue, &(pInterface->InterfaceLock.NdisLock))
  801. #else
  802. #define AA_IF_STAT_ADD_LOCK(pInterface, StatsCounter, IncrValue) \
  803. NdisInterlockedAddUlong(&(pInterface->StatsCounter), IncrValue, &(pInterface->InterfaceLock))
  804. #endif // DBG_SPIN_LOCK
  805. /*++
  806. VOID
  807. AA_IF_STAT_ADD(
  808. IN PATMARP_INTERFACE pInterface,
  809. IN OPAQUE StatsCounter,
  810. IN ULONG IncrValue
  811. )
  812. Add to the specified StatsCounter on an Interface by the specified IncrValue.
  813. Use the more efficient InterlockedEcxhangeAdd instruction.
  814. --*/
  815. #if BINARY_COMPATIBLE
  816. #define AA_IF_STAT_ADD(pInterface, StatsCounter, IncrValue) \
  817. AA_IF_STAT_ADD_LOCK(pInterface, StatsCounter, IncrValue)
  818. #else // !BINARY_COMPATIBLE
  819. #define AA_IF_STAT_ADD(pInterface, StatsCounter, IncrValue) \
  820. InterlockedExchangeAdd(&(pInterface->StatsCounter), IncrValue)
  821. //((pInterface)->StatsCounter+=(IncrValue))
  822. #endif // !BINARY_COMPATIBLE
  823. /*++
  824. BOOLEAN
  825. AA_IS_BCAST_IP_ADDRESS(
  826. IN IP_ADDRESS Destination,
  827. IN PATMARP_INTERFACE pIf
  828. )
  829. Check if the given Destination is a broadcast IP address on the
  830. given Interface. Currently, we only check if the destination is
  831. the same as the (limited) broadcast address for the interface.
  832. TBD: extend this when we support addition of broadcast addresses
  833. to an interface.
  834. --*/
  835. #define AA_IS_BCAST_IP_ADDRESS(Destn, pIf) \
  836. (IP_ADDR_EQUAL((pIf)->BroadcastAddress, Destn))
  837. /*++
  838. BOOLEAN
  839. AA_FILTER_SPEC_MATCH(
  840. IN PATMARP_INTERFACE pInterface,
  841. IN PATMARP_FILTER_SPEC pSrc,
  842. IN PATMARP_FILTER_SPEC pDst
  843. )
  844. Check if the given filter spec matches a target filter spec, for the
  845. specified interface.
  846. --*/
  847. #define AA_FILTER_SPEC_MATCH(pIf, pSrc, pDst) \
  848. ( ((pIf)->pFilterMatchFunc == NULL_PAA_FILTER_SPEC_MATCH_FUNC) ? \
  849. TRUE: \
  850. (*((pIf)->pFilterMatchFunc))((PVOID)pIf, pSrc, pDst))
  851. /*++
  852. BOOLEAN
  853. AA_FLOW_SPEC_MATCH(
  854. IN PATMARP_INTERFACE pInterface,
  855. IN PATMARP_FLOW_SPEC pSrc,
  856. IN PATMARP_FLOW_SPEC pDst
  857. )
  858. Check if the given flow spec matches a target flow spec, for the
  859. specified interface.
  860. --*/
  861. #define AA_FLOW_SPEC_MATCH(pIf, pSrc, pDst) \
  862. ( ((pIf)->pFlowMatchFunc == NULL_PAA_FLOW_SPEC_MATCH_FUNC) ? \
  863. TRUE: \
  864. (*((pIf)->pFlowMatchFunc))((PVOID)pIf, pSrc, pDst))
  865. /*++
  866. VOID
  867. AA_GET_PACKET_SPECS(
  868. IN PATMARP_INTERFACE pInterface,
  869. IN PNDIS_PACKET pNdisPacket,
  870. OUT PATMARP_FLOW_INFO *ppFlowInfo,
  871. OUT PATMARP_FLOW_SPEC *ppFlowSpec,
  872. OUT PATMARP_FILTER_SPEC *ppFilterSpec
  873. )
  874. Get the flow and filter specs for the given packet
  875. --*/
  876. #define AA_GET_PACKET_SPECS(pIf, pPkt, ppFlowInfo, ppFlow, ppFilt) \
  877. { \
  878. if ((pIf)->pGetPacketSpecFunc != NULL_PAA_GET_PACKET_SPEC_FUNC) \
  879. { \
  880. (*((pIf)->pGetPacketSpecFunc)) \
  881. ((PVOID)(pIf), pPkt, ppFlowInfo, ppFlow, ppFilt); \
  882. } \
  883. else \
  884. { \
  885. *(ppFlowInfo) = NULL; \
  886. *(ppFlow) = &((pIf)->DefaultFlowSpec); \
  887. *(ppFilt) = &((pIf)->DefaultFilterSpec); \
  888. } \
  889. } \
  890. /*++
  891. VOID
  892. AA_GET_CONTROL_PACKET_SPECS(
  893. IN PATMARP_INTERFACE pInterface,
  894. OUT PATMARP_FLOW_SPEC *ppFlowSpec
  895. )
  896. --*/
  897. #define AA_GET_CONTROL_PACKET_SPECS(pIf, ppFlow) \
  898. *(ppFlow) = &((pIf)->DefaultFlowSpec);
  899. /*++
  900. BOOLEAN
  901. AA_IS_BEST_EFFORT_FLOW(
  902. IN PATMARP_FLOW_SPEC pFlowSpec
  903. )
  904. --*/
  905. #define AA_IS_BEST_EFFORT_FLOW(pFlowSpec) \
  906. (((pFlowSpec)->SendServiceType == SERVICETYPE_BESTEFFORT) && \
  907. ((pFlowSpec)->SendPeakBandwidth > 0))
  908. /*++
  909. VOID
  910. AA_SET_NEXT_PACKET(
  911. IN PNDIS_PACKET pNdisPacket,
  912. IN PNDIS_PACKET pNextPacket
  913. )
  914. --*/
  915. #define AA_SET_NEXT_PACKET(pPkt, pNext) \
  916. *((PNDIS_PACKET *)((pPkt)->MiniportReserved)) = (pNext);
  917. /*++
  918. PNDIS_PACKET
  919. AA_GET_NEXT_PACKET(
  920. IN PNDIS_PACKET pNdisPacket
  921. )
  922. --*/
  923. #define AA_GET_NEXT_PACKET(pPkt) \
  924. (*((PNDIS_PACKET *)((pPkt)->MiniportReserved)))
  925. /*++
  926. ULONG
  927. ROUND_UP(
  928. IN ULONG Val
  929. )
  930. Round up a value so that it becomes a multiple of 4.
  931. --*/
  932. #define ROUND_UP(Val) (((Val) + 3) & ~0x3)
  933. /*++
  934. ULONG
  935. ROUND_TO_8_BYTES(
  936. IN ULONG Val
  937. )
  938. Round up a value so that it becomes a multiple of 8.
  939. --*/
  940. #define ROUND_TO_8_BYTES(_Val) (((_Val) + 7) & ~7)
  941. #ifndef NET_SHORT
  942. #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037)) || ((defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_FULL_VER > 13009175))
  943. #define NET_SHORT(_x) _byteswap_ushort((USHORT)(_x))
  944. #else
  945. /*++
  946. USHORT
  947. NET_SHORT(
  948. IN USHORT Val
  949. )
  950. --*/
  951. #define NET_SHORT(Val) \
  952. ((((Val) & 0xff) << 8) | (((Val) & 0xff00) >> 8))
  953. #endif
  954. #define NET_TO_HOST_SHORT(Val) NET_SHORT(Val)
  955. #define HOST_TO_NET_SHORT(Val) NET_SHORT(Val)
  956. #endif // NET_SHORT
  957. #ifndef NET_LONG
  958. #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037)) || ((defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_FULL_VER > 13009175))
  959. #define NET_LONG(_x) _byteswap_ulong((ULONG)(_x))
  960. #else
  961. /*++
  962. ULONG
  963. NET_LONG(
  964. IN ULONG Val
  965. )
  966. --*/
  967. #define NET_LONG(Val) \
  968. ((((Val) & 0x000000ff) << 24) | \
  969. (((Val) & 0x0000ff00) << 8) | \
  970. (((Val) & 0x00ff0000) >> 8) | \
  971. (((Val) & 0xff000000) >> 24) )
  972. #endif
  973. #define NET_TO_HOST_LONG(Val) NET_LONG(Val)
  974. #define HOST_TO_NET_LONG(Val) NET_LONG(Val)
  975. #endif // NET_LONG
  976. /*++
  977. BOOLEAN
  978. AA_IS_TRANSIENT_FAILURE(
  979. IN NDIS_STATUS Status
  980. )
  981. Return TRUE if the given Status indicates a transient connection
  982. failure, otherwise return FALSE.
  983. --*/
  984. #define AA_IS_TRANSIENT_FAILURE(_Status) \
  985. ((_Status == NDIS_STATUS_RESOURCES) || \
  986. (_Status == NDIS_STATUS_CELLRATE_NOT_AVAILABLE) || \
  987. (_Status == NDIS_STATUS_INCOMPATABLE_QOS))
  988. /*++
  989. LONG
  990. AA_GET_RANDOM(
  991. IN LONG min,
  992. IN LONG max
  993. )
  994. --*/
  995. #define AA_GET_RANDOM(min, max) \
  996. (((LONG)AtmArpRandomNumber() % (LONG)(((max+1) - (min))) + (min)))
  997. #define AA_LOG_ERROR() // Nothing
  998. /*++
  999. BOOLEAN
  1000. AA_AE_IS_ALIVE(
  1001. IN PATMARP_ATM_ENTRY pAtmEntry
  1002. )
  1003. --*/
  1004. #define AA_AE_IS_ALIVE(pAtmEntry) \
  1005. (!AA_IS_FLAG_SET( \
  1006. (pAtmEntry)->Flags, \
  1007. AA_ATM_ENTRY_STATE_MASK, \
  1008. AA_ATM_ENTRY_IDLE))
  1009. /*++
  1010. BOOLEAN
  1011. AA_IE_ALIVE(
  1012. IN PATMARP_IP_ENTRY pIpEntry
  1013. )
  1014. --*/
  1015. #define AA_IE_IS_ALIVE(pIpEntry) \
  1016. (!AA_IS_FLAG_SET( \
  1017. (pIpEntry)->Flags, \
  1018. AA_IP_ENTRY_STATE_MASK, \
  1019. AA_IP_ENTRY_IDLE))
  1020. #endif // __ATMARP_MACROS_H_INCLUDED