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.

412 lines
14 KiB

  1. /*++
  2. Copyright (c) 1992-1996 Microsoft Corporation
  3. Module Name:
  4. intf.h
  5. Abstract:
  6. This file contains the per-adapter (LIS) interface definition.
  7. Author:
  8. Jameel Hyder (jameelh@microsoft.com) July 1996
  9. Environment:
  10. Kernel mode
  11. Revision History:
  12. --*/
  13. #ifndef _INTF_
  14. #define _INTF_
  15. #define SERVICE_NAME L"AtmArpS"
  16. #define NUM_ARPS_DESC 128
  17. #define NUM_MARS_DESC 128
  18. #define MAX_DESC_MULTIPLE 10
  19. #define ARP_TABLE_SIZE 64 // Keep this as a power of 2. The ARP_HASH macro relies on it.
  20. #define MARS_TABLE_SIZE 32 // Keep this as a power of 2. The MARS_HASH macro relies on it.
  21. #define ARP_HASH(_ipaddr) ((((PUCHAR)&(_ipaddr))[3]) & (ARP_TABLE_SIZE - 1))
  22. #define MARS_HASH(_ipaddr) ((((PUCHAR)&(_ipaddr))[3]) & (MARS_TABLE_SIZE - 1))
  23. typedef struct _ArpVc ARP_VC, *PARP_VC;
  24. typedef struct _REG_ADDR_CTXT REG_ADDR_CTXT, *PREG_ADDR_CTXT;
  25. //
  26. // The protocol reserved area in the ndis packets.
  27. //
  28. typedef struct
  29. {
  30. LIST_ENTRY ReqList; // For queuing the packet into the KQUEUE
  31. SINGLE_LIST_ENTRY FreeList; // For queuing the packet into the SLIST
  32. PARP_VC Vc; // Owning Vc in case of queued packet
  33. USHORT Flags; // Misc. other information
  34. USHORT PktLen; // Length of incoming packet
  35. union {
  36. PNDIS_PACKET OriginalPkt;// When a packet is forwarded by the MARS
  37. PUCHAR PacketStart;// For MARS Control packets
  38. };
  39. } PROTOCOL_RESD, *PPROTOCOL_RESD;
  40. #define RESD_FLAG_MARS 0x0001 // Indicates that the packet is to be processed by MARS
  41. #define RESD_FLAG_MARS_PKT 0x0002 // Indicates that the packet is from the MARS pool
  42. #define RESD_FLAG_FREEBUF 0x0004 // Indicates that the buffer and associated memory must be
  43. // freed upon completion of the send.
  44. #define RESD_FLAG_KILL_CCVC 0x0010 // This isn't part of a packet. This is used
  45. // to queue a request to abort ClusterControlVc.
  46. #define RESD_FROM_PKT(_Pkt) (PPROTOCOL_RESD)((_Pkt)->ProtocolReserved)
  47. typedef UCHAR ATM_ADDR_TYPE;
  48. typedef struct _HwAddr
  49. {
  50. ATM_ADDRESS Address;
  51. PATM_ADDRESS SubAddress;
  52. } HW_ADDR, *PHW_ADDR;
  53. #define COMP_ATM_ADDR(_a1_, _a2_) (((_a1_)->AddressType == (_a2_)->AddressType) && \
  54. ((_a1_)->NumberOfDigits == (_a2_)->NumberOfDigits) && \
  55. COMP_MEM((_a1_)->Address, \
  56. (_a2_)->Address, \
  57. (_a1_)->NumberOfDigits))
  58. #define COPY_ATM_ADDR(_d_, _s_) \
  59. { \
  60. (_d_)->AddressType = (_s_)->AddressType; \
  61. (_d_)->NumberOfDigits = (_s_)->NumberOfDigits; \
  62. COPY_MEM((_d_)->Address, (_s_)->Address, (_s_)->NumberOfDigits); \
  63. }
  64. #define COMP_HW_ADDR(_a1_, _a2_) (((_a1_)->Address.AddressType == (_a2_)->Address.AddressType) && \
  65. ((_a1_)->Address.NumberOfDigits == (_a2_)->Address.NumberOfDigits) && \
  66. COMP_MEM((_a1_)->Address.Address, \
  67. (_a2_)->Address.Address, \
  68. (_a1_)->Address.NumberOfDigits) && \
  69. ((((_a1_)->SubAddress == NULL) && ((_a2_)->SubAddress == NULL)) || \
  70. ((((_a1_)->SubAddress != NULL) && ((_a2_)->SubAddress != NULL)) && \
  71. ((_a1_)->SubAddress->AddressType == (_a2_)->SubAddress->AddressType) &&\
  72. ((_a1_)->SubAddress->NumberOfDigits == (_a2_)->SubAddress->NumberOfDigits) &&\
  73. COMP_MEM((_a1_)->SubAddress->Address, \
  74. (_a2_)->SubAddress->Address, \
  75. (_a1_)->SubAddress->NumberOfDigits)))) \
  76. #define COPY_HW_ADDR(_d_, _s_) \
  77. { \
  78. (_d_)->Address.AddressType = (_s_)->Address.AddressType; \
  79. (_d_)->Address.NumberOfDigits = (_s_)->Address.NumberOfDigits; \
  80. COPY_MEM((_d_)->Address.Address, (_s_)->Address.Address, (_s_)->Address.NumberOfDigits); \
  81. if ((_s_)->SubAddress != NULL) \
  82. { \
  83. (_d_)->SubAddress->AddressType = (_s_)->SubAddress->AddressType; \
  84. (_d_)->SubAddress->NumberOfDigits = (_s_)->SubAddress->NumberOfDigits; \
  85. COPY_MEM((_d_)->SubAddress->Address, (_s_)->SubAddress->Address, (_s_)->SubAddress->NumberOfDigits);\
  86. } \
  87. }
  88. typedef struct _ENTRY_HDR
  89. {
  90. VOID * Next;
  91. VOID ** Prev;
  92. } ENTRY_HDR, *PENTRY_HDR;
  93. typedef struct _ArpEntry
  94. {
  95. ENTRY_HDR;
  96. HW_ADDR HwAddr; // HWADDR MUST FOLLOW ENTRY_HDR
  97. TIMER Timer;
  98. IPADDR IpAddr;
  99. PARP_VC Vc; // Pointer to the Vc (if active)
  100. UINT Age;
  101. } ARP_ENTRY, *PARP_ENTRY;
  102. #define FLUSH_TIME 60*MULTIPLIER // 60 minutes in 15s units
  103. #define ARP_AGE 20*MULTIPLIER // 20 minutes in 15s units
  104. #define REDIRECT_INTERVAL 1*MULTIPLIER // 1 minute
  105. #define ARP_BLOCK_VANILA (ENTRY_TYPE)0
  106. #define ARP_BLOCK_SUBADDR (ENTRY_TYPE)1
  107. #define MARS_CLUSTER_VANILA (ENTRY_TYPE)2
  108. #define MARS_CLUSTER_SUBADDR (ENTRY_TYPE)3
  109. #define MARS_GROUP (ENTRY_TYPE)4
  110. #define MARS_BLOCK_ENTRY (ENTRY_TYPE)5
  111. #define ARP_BLOCK_TYPES (ENTRY_TYPE)6
  112. #define BLOCK_ALLOC_SIZE PAGE_SIZE
  113. typedef UINT ENTRY_TYPE;
  114. typedef struct _ArpBlock
  115. {
  116. struct _ArpBlock * Next; // Link to next
  117. struct _ArpBlock ** Prev; // Link to previous
  118. struct _IntF * IntF; // Back pointer to the interface
  119. ENTRY_TYPE EntryType; // ARP_BLOCK_XXX
  120. UINT NumFree; // # of free ArpEntries in this block
  121. PENTRY_HDR FreeHead; // Head of the list of free Arp Entries
  122. } ARP_BLOCK, *PARP_BLOCK;
  123. //
  124. // Forward declaration
  125. //
  126. typedef struct _MARS_ENTRY MARS_ENTRY, *PMARS_ENTRY;
  127. typedef struct _MARS_VC MARS_VC, *PMARS_VC;
  128. typedef struct _MARS_FLOW_SPEC MARS_FLOW_SPEC, *PMARS_FLOW_SPEC;
  129. typedef struct _CLUSTER_MEMBER CLUSTER_MEMBER, *PCLUSTER_MEMBER;
  130. typedef struct _MCS_ENTRY MCS_ENTRY, *PMCS_ENTRY;
  131. //
  132. // Flow Specifications for an ATM Connection. The structure
  133. // represents a bidirectional flow.
  134. //
  135. typedef struct _MARS_FLOW_SPEC
  136. {
  137. ULONG SendBandwidth; // Bytes/Sec
  138. ULONG SendMaxSize; // Bytes
  139. ULONG ReceiveBandwidth; // Bytes/Sec
  140. ULONG ReceiveMaxSize; // Bytes
  141. SERVICETYPE ServiceType;
  142. } MARS_FLOW_SPEC, *PMARS_FLOW_SPEC;
  143. typedef struct _IntF
  144. {
  145. struct _IntF * Next;
  146. LONG RefCount;
  147. ULONG Flags;
  148. UNICODE_STRING InterfaceName; // Name of device bound to
  149. UNICODE_STRING FriendlyName; // Descriptive name of above
  150. UNICODE_STRING FileName; // Name of file where arp entries are stored
  151. UNICODE_STRING ConfigString; // Used to access registry
  152. //
  153. // Fields relating to NDIS.
  154. //
  155. NDIS_MEDIUM SupportedMedium; // For use in NdisOpenAdapter
  156. NDIS_HANDLE NdisBindingHandle; // Handle to the binding
  157. NDIS_HANDLE NdisAfHandle; // Handle to the registered Address Family
  158. union
  159. {
  160. NDIS_HANDLE NdisSapHandle; // Handle to the registered Sap
  161. NDIS_HANDLE NdisBindContext; // Valid only during BindAdapter call
  162. };
  163. CO_ADDRESS_FAMILY AddrFamily; // For use by NdisClOpenAddressFamily
  164. PCO_SAP Sap; // For use by NdisClRegisterSap
  165. LIST_ENTRY InactiveVcHead; // Created Vcs go here.
  166. LIST_ENTRY ActiveVcHead; // Vcs with active calls go here.
  167. #if DBG
  168. LIST_ENTRY FreeVcHead; // Freed Vcs go here - fo Debugging.
  169. #endif
  170. UCHAR SelByte; // Read as part of the configuration
  171. USHORT NumAllocedRegdAddresses; // # of registered atm addresses on this i/f
  172. USHORT NumAddressesRegd; // # of atm addresses successfully registered on this i/f
  173. ATM_ADDRESS ConfiguredAddress; // Configured address for this port
  174. UINT NumPendingDelAddresses; // Number of address pending deletion.
  175. PATM_ADDRESS RegAddresses; // Array of h/w addresses
  176. PREG_ADDR_CTXT pRegAddrCtxt; // Context used when registering
  177. // addresses.
  178. UINT NumCacheEntries;
  179. PARP_ENTRY ArpCache[ARP_TABLE_SIZE];
  180. // The list of arp entries that we know about
  181. ULONG LastVcId; // A server created id assigned to each incoming vc
  182. PTIMER ArpTimer; // Head of the timer-list for this interface
  183. KMUTEX ArpCacheMutex; // Protects the ArpCache and the ArpTimer
  184. KEVENT TimerThreadEvent; // Signal this to kill the timer thread
  185. TIMER FlushTimer; // Used to flush arp-cache to disk
  186. TIMER BlockTimer; // Used to age-out arp blocks
  187. PKEVENT CleanupEvent; // signalling when IntF is freed
  188. PKEVENT DelAddressesEvent; // signalling when addresses are deleted
  189. PARP_BLOCK PartialArpBlocks[ARP_BLOCK_TYPES];
  190. PARP_BLOCK UsedArpBlocks[ARP_BLOCK_TYPES];
  191. ARP_SERVER_STATISTICS ArpStats;
  192. LARGE_INTEGER StatisticsStartTimeStamp;
  193. //
  194. // Fields used by MARS
  195. //
  196. PMARS_ENTRY MarsCache[MARS_TABLE_SIZE];
  197. MARS_SERVER_STATISTICS MarsStats;
  198. PCLUSTER_MEMBER ClusterMembers; // List of Cluster members
  199. ULONG NumClusterMembers; // Size of above list
  200. PMCS_ENTRY pMcsList; // MCS configuration
  201. PMARS_VC ClusterControlVc; // Outgoing PMP for MARS control
  202. // and MCS data
  203. INT CCActiveParties; // Number of connected members
  204. INT CCAddingParties; // Number of AddParty()'s pending
  205. INT CCDroppingParties; // Number of DropParty()'s pending
  206. LIST_ENTRY CCPacketQueue; // Packets queued for sending on
  207. // the above VC.
  208. ULONG CSN; // ClusterSequenceNumber
  209. USHORT CMI; // ClusterMemberId
  210. ULONG MaxPacketSize; // Supported by miniport
  211. NDIS_CO_LINK_SPEED LinkSpeed; // Supported by miniport
  212. struct _MARS_FLOW_SPEC CCFlowSpec; // Flow params for ClusterControlVc
  213. TIMER MarsRedirectTimer; // For periodic MARS_REDIRECT
  214. KSPIN_LOCK Lock;
  215. } INTF, *PINTF;
  216. #define INTF_ADAPTER_OPENED 0x00000001 // Set after OpenAdapterComplete runs
  217. #define INTF_AF_OPENED 0x00000002 // Set after OpenAfComplete runs
  218. #define INTF_SAP_REGISTERED 0x00000008 // Set after RegisterSapComplete runs
  219. #define INTF_ADDRESS_VALID 0x00000010 // Set after OID_CO_ADDRESS_CHANGE is notified
  220. #define INTF_SENDING_ON_CC_VC 0x00001000 // Send in progress on ClusterControlVc
  221. #define INTF_STOPPING 0x40000000 // StopInterface in progress
  222. #define INTF_CLOSING 0x80000000 // Set after CloseAdapterComplete runs
  223. typedef struct _ArpVc
  224. {
  225. ULONG VcType; // Must be the first field in struct
  226. LIST_ENTRY List;
  227. USHORT RefCount;
  228. USHORT Flags;
  229. ULONG PendingSends;
  230. ULONG VcId;
  231. NDIS_HANDLE NdisVcHandle;
  232. PINTF IntF;
  233. ULONG MaxSendSize;// From AAL parameters
  234. PARP_ENTRY ArpEntry;
  235. HW_ADDR HwAddr; // From CallingPartyAddress
  236. } ARP_VC, *PARP_VC;
  237. #define ARPVC_ACTIVE 0x0001
  238. #define ARPVC_CALLPROCESSING 0x0002
  239. #define ARPVC_CLOSE_PENDING 0x4000
  240. #define ARPVC_CLOSING 0x8000
  241. //
  242. // VC types:
  243. //
  244. #define VC_TYPE_INCOMING ((ULONG)0)
  245. #define VC_TYPE_MARS_CC ((ULONG)1) // ClusterControlVc
  246. #define VC_TYPE_CHECK_REGADDR ((ULONG)2) // Transient vc to validate
  247. // a registered address.
  248. #define CLEANUP_DEAD_VC(_ArpEntry) \
  249. { \
  250. if (((_ArpEntry)->Vc != NULL) && (((_ArpEntry)->Vc->Flags & ARPVC_ACTIVE) == 0))\
  251. { \
  252. PARP_VC Vc = (_ArpEntry)->Vc; \
  253. \
  254. ArpSDereferenceVc(Vc, TRUE, FALSE); \
  255. (_ArpEntry)->Vc = NULL; \
  256. } \
  257. }
  258. //
  259. // Rounded-off size of generic Q.2931 IE header
  260. //
  261. #define ROUND_OFF(_size) (((_size) + 3) & ~0x4)
  262. #define SIZEOF_Q2931_IE ROUND_OFF(sizeof(Q2931_IE))
  263. #define SIZEOF_AAL_PARAMETERS_IE ROUND_OFF(sizeof(AAL_PARAMETERS_IE))
  264. #define SIZEOF_ATM_TRAFFIC_DESCR_IE ROUND_OFF(sizeof(ATM_TRAFFIC_DESCRIPTOR_IE))
  265. #define SIZEOF_ATM_BBC_IE ROUND_OFF(sizeof(ATM_BROADBAND_BEARER_CAPABILITY_IE))
  266. #define SIZEOF_ATM_BLLI_IE ROUND_OFF(sizeof(ATM_BLLI_IE))
  267. #define SIZEOF_ATM_QOS_IE ROUND_OFF(sizeof(ATM_QOS_CLASS_IE))
  268. //
  269. // Total space required for Information Elements in an outgoing call.
  270. //
  271. #define REGADDR_MAKE_CALL_IE_SPACE ( \
  272. SIZEOF_Q2931_IE + SIZEOF_AAL_PARAMETERS_IE + \
  273. SIZEOF_Q2931_IE + SIZEOF_ATM_TRAFFIC_DESCR_IE + \
  274. SIZEOF_Q2931_IE + SIZEOF_ATM_BBC_IE + \
  275. SIZEOF_Q2931_IE + SIZEOF_ATM_BLLI_IE + \
  276. SIZEOF_Q2931_IE + SIZEOF_ATM_QOS_IE )
  277. // REG_ADDR_CTXT stores context relating to validating and registering the
  278. // list of addresses that need to be explicitly registered. "Validating" consists
  279. // of making a call to the address *before* registering, to make sure that
  280. // no one *else* has registered the same address.
  281. // See 05/14/1999 notes.txt entry for details.
  282. //
  283. typedef struct _REG_ADDR_CTXT
  284. {
  285. ULONG VcType; // Must be the first field in struct
  286. NDIS_HANDLE NdisVcHandle; // NDIS VC handle used for makeing a call
  287. // to verify that the address is unused.
  288. ULONG Flags; // One or more of the following flags.
  289. #define REGADDRCTXT_RESTART 0x0001
  290. #define REGADDRCTXT_ABORT 0x0002
  291. #define REGADDRCTXT_MAKECALL_PENDING 0x0004
  292. #define REGADDRCTXT_CLOSECALL_PENDING 0x0008
  293. // TODO/WARNING -- the above flags are currently UNUSED.
  294. UINT RegAddrIndex; // Index of the address being registered.
  295. PINTF pIntF;
  296. // Request is for setting up an ndis request to add (register) a local address.
  297. //
  298. struct
  299. {
  300. NDIS_REQUEST NdisRequest;
  301. CO_ADDRESS CoAddress;
  302. ATM_ADDRESS AtmAddress;
  303. } Request;
  304. // CallParams and the following union are for setting up the validation call.
  305. //
  306. CO_CALL_PARAMETERS CallParams;
  307. // Call manager parameters, plus extra space for the ATM-specific stuff...
  308. //
  309. union
  310. {
  311. CO_CALL_MANAGER_PARAMETERS CmParams;
  312. UCHAR Buffer[ sizeof(CO_CALL_MANAGER_PARAMETERS)
  313. + sizeof(Q2931_CALLMGR_PARAMETERS) +
  314. REGADDR_MAKE_CALL_IE_SPACE];
  315. };
  316. } REG_ADDR_CTXT, *PREG_ADDR_CTXT;
  317. //
  318. // Temp structure used to store information read from the registry.
  319. //
  320. typedef struct _ATMARPS_CONFIG
  321. {
  322. UCHAR SelByte; // Selector Byte
  323. USHORT NumAllocedRegdAddresses;
  324. PATM_ADDRESS RegAddresses;
  325. PMCS_ENTRY pMcsList; // MCS configuration
  326. } ATMARPS_CONFIG, *PATMARPS_CONFIG;
  327. //
  328. // Some defaults
  329. //
  330. #define DEFAULT_SEND_BANDWIDTH (ATM_USER_DATA_RATE_SONET_155*100/8) // Bytes/sec
  331. #define DEFAULT_MAX_PACKET_SIZE 9180 // Bytes
  332. // Minimum tolerated MAX_PACKET_SIZE
  333. //
  334. #define ARPS_MIN_MAX_PKT_SIZE 9180 // Bytes
  335. #endif // _INTF_