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.

196 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. dlmacro.h
  5. Abstract:
  6. This module all c- macros of 802.2 data link driver.
  7. Author:
  8. Antti Saarenheimo (o-anttis) 17-MAY-1991
  9. Revision History:
  10. --*/
  11. //
  12. // This routine just swaps the bits within bytes of
  13. // a network address, used only for a fast address
  14. // swapping to ethernet frame
  15. //
  16. #define SwapCopy6( a, b ) (a)[0]=Swap[(b)[0]];\
  17. (a)[1]=Swap[(b)[1]];\
  18. (a)[2]=Swap[(b)[2]];\
  19. (a)[3]=Swap[(b)[3]];\
  20. (a)[4]=Swap[(b)[4]];\
  21. (a)[5]=Swap[(b)[5]]
  22. //
  23. // Copies and swaps the memory unconditionally
  24. //
  25. //VOID
  26. //SwappingMemCpy(
  27. // IN PUCHAR pDest,
  28. // IN PUCHAR pSrc,
  29. // IN UINT Len
  30. // )
  31. //
  32. #define SwappingMemCpy( pDest, pSrc, Len ) {\
  33. UINT i; \
  34. for (i = 0; i < Len; i++) \
  35. ((PUCHAR)pDest)[i] = Swap[ ((PUCHAR)pSrc)[i] ]; \
  36. }
  37. /*++
  38. VOID
  39. LlcResetPacket(
  40. IN OUT PLLC_NDIS_PACKET pNdisPacket
  41. )
  42. Routine Description:
  43. Function rets the private partion of a NDIS packet.
  44. Arguments:
  45. pNdisPacket -
  46. Return Value:
  47. None
  48. --*/
  49. #define ResetNdisPacket( pNdisPacket ) { \
  50. (pNdisPacket)->private.PhysicalCount = 0;\
  51. (pNdisPacket)->private.TotalLength = 0;\
  52. (pNdisPacket)->private.Head = 0;\
  53. (pNdisPacket)->private.Tail = 0;\
  54. (pNdisPacket)->private.Count = 0;\
  55. }
  56. /*++
  57. AllocateCompletionPacket(
  58. IN PLLC_OBJECT pLlcObject,
  59. IN UINT CompletionCode,
  60. IN PLLC_PACKET pPacket
  61. )
  62. Routine Description:
  63. The function inserts and initializes a command completion packet
  64. of an asynchronous command.
  65. Arguments:
  66. pLlcObject - LLC object (link, sap or direct)
  67. CompletionCode - command completion code returned to upper protocol
  68. Return Value:
  69. STATUS_SUCCESS
  70. DLC_STATUS_NO_MEMORY
  71. --*/
  72. #define AllocateCompletionPacket( pLlcObject, CompletionCode, pPacket ) {\
  73. pPacket->pBinding = pLlcObject->Gen.pLlcBinding; \
  74. pPacket->Data.Completion.CompletedCommand = (UCHAR)CompletionCode; \
  75. pPacket->Data.Completion.hClientHandle = pLlcObject->Gen.hClientHandle; \
  76. pPacket->pNext = pLlcObject->Gen.pCompletionPackets; \
  77. pLlcObject->Gen.pCompletionPackets = pPacket; \
  78. }
  79. #define RunStateMachineCommand( pLink, uiInput ) \
  80. RunStateMachine( (PDATA_LINK)pLink, (USHORT)uiInput, 0, 0 )
  81. //
  82. // VOID
  83. // ScheduleQueue(
  84. // IN PLIST_ENTRY ListHead
  85. // );
  86. //
  87. // The macro swaps the list element from the head to the tail
  88. // if there are more than one element in the list.
  89. //
  90. #define ScheduleQueue( ListHead ) \
  91. if ((ListHead)->Blink != (ListHead)->Flink) \
  92. { \
  93. PLIST_ENTRY pListEntry; \
  94. pListEntry = LlcRemoveHeadList( (ListHead) ); \
  95. LlcInsertTailList( (ListHead), pListEntry ); \
  96. }
  97. #define ReferenceObject( pStation ) (pStation)->Gen.ReferenceCount++
  98. //
  99. // We have made the most common functions macroes to
  100. // make the main code path as fast as possible.
  101. // With the debug switch we use their local versions.
  102. //
  103. #if LLC_DBG >= 2
  104. #define SEARCH_LINK( pAdapterContext, LanAddr, pLink ) \
  105. pLink = SearchLink( pAdapterContext, LanAddr )
  106. #else
  107. /*++
  108. SEARCH_LINK(
  109. IN PADAPTER_CONTEXT pAdapterContext,
  110. IN LAN802_ADDRESS LanAddr,
  111. IN PDATA_LINK pLink
  112. )
  113. Routine Description:
  114. The routine searches a link from the hash table.
  115. All links in the same hash node has been saved to a simple
  116. link list.
  117. Note: the full link address is actually 61 bits long =
  118. 7 (SSAP) + 7 (DSAP) + 47 (any non-broadcast source address).
  119. We save the address information into two ULONGs, that are used
  120. in the actual search. The hash key will be calculated by xoring
  121. all 8 bytes in the address.
  122. Arguments:
  123. pAdapterContext - MAC adapter context of data link driver
  124. LanAddr - the complete 64 bit address of link (48 bit source addr + saps)
  125. Return Value:
  126. PDATA_LINK - pointer to LLC link object or NULL if not found
  127. --*/
  128. #define SEARCH_LINK( pAdapterContext, LanAddr, pLink )\
  129. { \
  130. USHORT usHash; \
  131. usHash = \
  132. LanAddr.aus.Raw[0] ^ LanAddr.aus.Raw[1] ^ \
  133. LanAddr.aus.Raw[2] ^ LanAddr.aus.Raw[3]; \
  134. pLink = \
  135. pAdapterContext->aLinkHash[ \
  136. ((((PUCHAR)&usHash)[0] ^ ((PUCHAR)&usHash)[1]) % LINK_HASH_SIZE)]; \
  137. while (pLink != NULL && \
  138. (pLink->LinkAddr.ul.Low != LanAddr.ul.Low || \
  139. pLink->LinkAddr.ul.High != LanAddr.ul.High)) \
  140. { \
  141. pLink = pLink->pNextNode; \
  142. } \
  143. }
  144. #endif