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.

1008 lines
31 KiB

  1. /*++
  2. Copyright (c) 1997 FORE Systems, Inc.
  3. Copyright (c) 1997 Microsoft Corporation
  4. Module Name:
  5. atmlane.h
  6. Abstract:
  7. Author:
  8. Larry Cleeton, FORE Systems (v-lcleet@microsoft.com, lrc@fore.com)
  9. Environment:
  10. Kernel mode
  11. Revision History:
  12. --*/
  13. #ifndef __ATMLANE_ATMLANE_H
  14. #define __ATMLANE_ATMLANE_H
  15. //
  16. // Configuration defaults and stuff
  17. //
  18. #define DEF_HEADER_BUF_SIZE LANE_HEADERSIZE
  19. #define DEF_HDRBUF_GROW_SIZE 50 // these used for packet pad buffers also
  20. #define DEF_MAX_HEADER_BUFS 300
  21. #define DEF_PROTOCOL_BUF_SIZE sizeof(LANE_CONTROL_FRAME)
  22. #define DEF_MAX_PROTOCOL_BUFS 100
  23. #define MCAST_LIST_SIZE 32
  24. #define FAST_VC_TIMEOUT 30 // seconds
  25. //
  26. // The registry parameter strings
  27. //
  28. #define ATMLANE_LINKNAME_STRING L"\\DosDevices\\AtmLane"
  29. #define ATMLANE_NTDEVICE_STRING L"\\Device\\AtmLane"
  30. #define ATMLANE_PROTOCOL_STRING L"AtmLane"
  31. #define ATMLANE_USELECS_STRING L"UseLecs"
  32. #define ATMLANE_DISCOVERLECS_STRING L"DiscoverLecs"
  33. #define ATMLANE_LECSADDR_STRING L"LecsAddr"
  34. #define ATMLANE_ELANLIST_STRING L"ElanList"
  35. #define ATMLANE_DEVICE_STRING L"Device"
  36. #define ATMLANE_ELANNAME_STRING L"ElanName"
  37. #define ATMLANE_LANTYPE_STRING L"LanType"
  38. #define ATMLANE_MAXFRAMESIZE_STRING L"MaxFrameSizeCode"
  39. #define ATMLANE_LESADDR_STRING L"LesAddr"
  40. #define ATMLANE_UPPERBINDINGS_STRING L"UpperBindings"
  41. // Deprecated registry keys:
  42. // #define ATMLANE_MACADDR_STRING L"MacAddr"
  43. // #define ATMLANE_HEADERBUFSIZE_STRING L"HeaderBufSize"
  44. // #define ATMLANE_MAXHEADERBUFS_STRING L"MaxHeaderBufs"
  45. // #define ATMLANE_MAXPROTOCOLBUFS_STRING L"MaxProtocolBufs"
  46. // #define ATMLANE_DATADIRECTPCR_STRING L"DataDirectPCR"
  47. //
  48. // MAC table size
  49. // Current sized at 256.
  50. // Hash function currently uses byte 5 of MAC Address as index.
  51. // Some research at Digital has shown it to be the best byte to use.
  52. //
  53. #define ATMLANE_MAC_TABLE_SIZE 256
  54. //
  55. // Some misc defaults
  56. //
  57. #define ATMLANE_DEF_MAX_AAL5_PDU_SIZE ((64*1024)-1)
  58. //
  59. // Timer configuration.
  60. //
  61. #define ALT_MAX_TIMER_SHORT_DURATION 60 // Seconds
  62. #define ALT_MAX_TIMER_LONG_DURATION (30*60) // Seconds
  63. #define ALT_SHORT_DURATION_TIMER_PERIOD 1 // Second
  64. #define ALT_LONG_DURATION_TIMER_PERIOD 10 // Seconds
  65. //
  66. // Foward References
  67. //
  68. struct _ATMLANE_VC;
  69. struct _ATMLANE_ATM_ENTRY;
  70. struct _ATMLANE_ELAN;
  71. struct _ATMLANE_ADAPTER;
  72. //
  73. // Blocking data structure.
  74. //
  75. typedef struct _ATMLANE_BLOCK
  76. {
  77. NDIS_EVENT Event;
  78. NDIS_STATUS Status;
  79. } ATMLANE_BLOCK, *PATMLANE_BLOCK;
  80. //
  81. // The following object is a convenient way to
  82. // store and access an IEEE 48-bit MAC address.
  83. //
  84. typedef struct _MAC_ADDRESS
  85. {
  86. UCHAR Byte[6];
  87. }
  88. MAC_ADDRESS,
  89. *PMAC_ADDRESS;
  90. //
  91. // Packet context data in ProtocolReserved area of
  92. // NDIS Packet header owned by ATMLANE.
  93. //
  94. typedef struct _SEND_PACKET_RESERVED
  95. {
  96. #if DBG
  97. ULONG Signature;
  98. PNDIS_PACKET pNextInSendList;
  99. #endif
  100. ULONG Flags;
  101. PNDIS_PACKET pOrigNdisPacket;
  102. ULONG OrigBufferCount;
  103. ULONG OrigPacketLength;
  104. ULONG WrappedBufferCount;
  105. PNDIS_PACKET pNextNdisPacket;
  106. #if PROTECT_PACKETS
  107. ATMLANE_LOCK Lock;
  108. NDIS_STATUS CompletionStatus;
  109. #endif // PROTECT_PACKETS
  110. }
  111. SEND_PACKET_RESERVED,
  112. *PSEND_PACKET_RESERVED;
  113. //
  114. // Packet context data in MiniportReserved area of
  115. // NDIS packet header owned by ATMLANE.
  116. //
  117. typedef struct _RECV_PACKET_RESERVED
  118. {
  119. ULONG Flags;
  120. PNDIS_PACKET pNdisPacket;
  121. }
  122. RECV_PACKET_RESERVED,
  123. *PRECV_PACKET_RESERVED;
  124. //
  125. // Definitions of Flags in both (SEND/RECV)_PACKET_RESERVED.
  126. //
  127. #define PACKET_RESERVED_OWNER_MASK 0x00000007
  128. #define PACKET_RESERVED_OWNER_PROTOCOL 0x00000001
  129. #define PACKET_RESERVED_OWNER_ATMLANE 0x00000002
  130. #define PACKET_RESERVED_OWNER_MINIPORT 0x00000004
  131. #if PROTECT_PACKETS
  132. #define PACKET_RESERVED_COSENDRETURNED 0x10000000
  133. #define PACKET_RESERVED_COMPLETED 0x01000000
  134. #endif // PROTECT_PACKETS
  135. #define PSEND_RSVD(_pPkt) \
  136. ((PSEND_PACKET_RESERVED)(&((_pPkt)->ProtocolReserved)))
  137. #define ZERO_SEND_RSVD(_pPkt) \
  138. NdisZeroMemory(&((_pPkt)->ProtocolReserved), sizeof(SEND_PACKET_RESERVED))
  139. //
  140. // ------------------------ Global Data Object ------------------------
  141. //
  142. typedef struct _ATMLANE_GLOBALS
  143. {
  144. #if DBG
  145. ULONG atmlane_globals_sig; // debug signature
  146. #endif
  147. ATMLANE_LOCK GlobalLock; // global data lock
  148. ATMLANE_BLOCK Block;
  149. NDIS_HANDLE NdisWrapperHandle; // returned by NdisMInitializeWrapper
  150. NDIS_HANDLE MiniportDriverHandle; // returned by NdisIMRegisterLayeredMiniport
  151. NDIS_HANDLE NdisProtocolHandle; // returned by NdisRegisterProtocol
  152. LIST_ENTRY AdapterList; // list of bound adapters
  153. PDRIVER_OBJECT pDriverObject; // our driver object
  154. PDEVICE_OBJECT pSpecialDeviceObject; // special protocol ioctl device object ptr
  155. NDIS_HANDLE SpecialNdisDeviceHandle;// special protocol ioctl device handle
  156. }
  157. ATMLANE_GLOBALS,
  158. *PATMLANE_GLOBALS;
  159. #if DBG
  160. #define atmlane_globals_signature 'LGLA'
  161. #endif
  162. //
  163. // ------------------------ Timer Management ------------------------
  164. //
  165. struct _ATMLANE_TIMER ;
  166. struct _ATMLANE_TIMER_LIST ;
  167. //
  168. // Timeout Handler prototype
  169. //
  170. typedef
  171. VOID
  172. (*ATMLANE_TIMEOUT_HANDLER)(
  173. IN struct _ATMLANE_TIMER * pTimer,
  174. IN PVOID ContextPtr
  175. );
  176. //
  177. // An ATMLANE_TIMER structure is used to keep track of each timer
  178. // in the ATMLANE module.
  179. //
  180. typedef struct _ATMLANE_TIMER
  181. {
  182. struct _ATMLANE_TIMER * pNextTimer;
  183. struct _ATMLANE_TIMER * pPrevTimer;
  184. struct _ATMLANE_TIMER * pNextExpiredTimer; // Used to chain expired timers
  185. struct _ATMLANE_TIMER_LIST * pTimerList; // NULL iff this timer is inactive
  186. ULONG Duration; // In seconds
  187. ULONG LastRefreshTime;
  188. ATMLANE_TIMEOUT_HANDLER TimeoutHandler;
  189. PVOID ContextPtr; // To be passed to timeout handler
  190. } ATMLANE_TIMER, *PATMLANE_TIMER;
  191. //
  192. // NULL pointer to ATMLANE Timer
  193. //
  194. #define NULL_PATMLANE_TIMER ((PATMLANE_TIMER)NULL)
  195. //
  196. // Control structure for a timer wheel. This contains all information
  197. // about the class of timers that it implements.
  198. //
  199. typedef struct _ATMLANE_TIMER_LIST
  200. {
  201. #if DBG
  202. ULONG atmlane_timerlist_sig;
  203. #endif // DBG
  204. PATMLANE_TIMER pTimers; // List of timers
  205. ULONG TimerListSize; // Length of above
  206. ULONG CurrentTick; // Index into above
  207. ULONG TimerCount; // Number of running timers
  208. ULONG MaxTimer; // Max timeout value for this
  209. NDIS_TIMER NdisTimer; // System support
  210. UINT TimerPeriod; // Interval between ticks
  211. PVOID ListContext; // Used as a back pointer to the
  212. // Interface structure
  213. } ATMLANE_TIMER_LIST, *PATMLANE_TIMER_LIST;
  214. #if DBG
  215. #define atmlane_timerlist_signature 'LTLA'
  216. #endif // DBG
  217. //
  218. // Timer Classes
  219. //
  220. typedef enum
  221. {
  222. ALT_CLASS_SHORT_DURATION,
  223. ALT_CLASS_LONG_DURATION,
  224. ALT_CLASS_MAX
  225. } ATMLANE_TIMER_CLASS;
  226. //
  227. // ------------------------ ATMLANE SAP --------------------------------
  228. //
  229. // Each of these structures maintains information about an individual SAP
  230. // associated with an ELAN. Each ELAN registers 3 SAPs.
  231. // - Incoming Control Distribute VC
  232. // - Incoming Data Direct VCs
  233. // - Incoming Multicast Forward VC
  234. //
  235. typedef struct _ATMLANE_SAP
  236. {
  237. #if DBG
  238. ULONG atmlane_sap_sig;
  239. #endif
  240. struct _ATMLANE_ELAN * pElan ; // back pointer
  241. NDIS_HANDLE NdisSapHandle;
  242. ULONG Flags; // state information
  243. ULONG LaneType; // LES\BUS\DATA
  244. PCO_SAP pInfo; // SAP characteristics.
  245. }
  246. ATMLANE_SAP,
  247. *PATMLANE_SAP;
  248. #if DBG
  249. #define atmlane_sap_signature 'PSLA'
  250. #endif
  251. //
  252. // NULL pointer to ATMLANE SAP
  253. //
  254. #define NULL_PATMLANE_SAP ((PATMLANE_SAP)NULL)
  255. //
  256. // Definitions for Flags in ATMLANE SAP
  257. //
  258. //
  259. // Bits 0 to 3 contain the SAP-registration state.
  260. //
  261. #define SAP_REG_STATE_MASK 0x0000000f
  262. #define SAP_REG_STATE_IDLE 0x00000000
  263. #define SAP_REG_STATE_REGISTERING 0x00000001 // Sent RegisterSap
  264. #define SAP_REG_STATE_REGISTERED 0x00000002 // RegisterSap completed
  265. #define SAP_REG_STATE_DEREGISTERING 0x00000004 // Sent DeregisterSap
  266. //
  267. // ---- ATMLANE Buffer Tracker ----
  268. //
  269. // Keeps track of allocation information for a pool of buffers. A list
  270. // of these structures is used to maintain info about a dynamically
  271. // growable pool of buffers (e.g. for LANE data packet header buffers)
  272. //
  273. typedef struct _ATMLANE_BUFFER_TRACKER
  274. {
  275. struct _ATMLANE_BUFFER_TRACKER * pNext; // in a list of trackers
  276. NDIS_HANDLE NdisHandle; // for Buffer Pool
  277. PUCHAR pPoolStart; // start of memory chunk allocated
  278. // from the system
  279. } ATMLANE_BUFFER_TRACKER, *PATMLANE_BUFFER_TRACKER;
  280. //
  281. // NULL pointer to ATMARP Buffer tracker structure
  282. //
  283. #define NULL_PATMLANE_BUFFER_TRACKER ((PATMLANE_BUFFER_TRACKER)NULL)
  284. //
  285. // ------------------------ ATM Address Entry ------------------------
  286. //
  287. // All information about an ATM destination and the VCs associated
  288. // with it. One of these entries is used for a given ATM Address
  289. // with the exception of LANE services ATM Addresses
  290. //
  291. // It is deleted when all references (see below) to this entry are gone.
  292. //
  293. // One Data Direct VC can associated with this entry. One or more ARP Table
  294. // Entries could point to this entry, because more than one MAC address
  295. // could map to this ATM address.
  296. //
  297. // Reference Count: we add one to the RefCount for each of the following:
  298. // - Each VC associated with the entry.
  299. // - Each MAC Entry that points to it.
  300. // - BusTimer active.
  301. // - FlushTimer active.
  302. // - For the duration that another structure points to it.
  303. //
  304. typedef struct _ATMLANE_ATM_ENTRY
  305. {
  306. #if DBG
  307. ULONG atmlane_atm_sig; // Signature for debugging
  308. #endif
  309. struct _ATMLANE_ATM_ENTRY * pNext; // Next entry on this elan
  310. ULONG RefCount; // References to this struct
  311. ULONG Flags; // State information
  312. ULONG Type; // Type of entry
  313. ATMLANE_LOCK AeLock;
  314. struct _ATMLANE_ELAN * pElan; // Back pointer to parent
  315. struct _ATMLANE_VC * pVcList; // List of VCs to this address
  316. struct _ATMLANE_VC * pVcIncoming; // Optional incoming VC if server
  317. struct _ATMLANE_MAC_ENTRY * pMacEntryList; // List of MAC entries that
  318. // point to this entry
  319. ATM_ADDRESS AtmAddress; // ATM Address of this entry
  320. PATMLANE_TIMER FlushTimer; // Flush protocol timer
  321. ULONG FlushTid; // Transaction ID of Flush Request
  322. }
  323. ATMLANE_ATM_ENTRY,
  324. *PATMLANE_ATM_ENTRY;
  325. #if DBG
  326. #define atmlane_atm_signature 'EALA'
  327. #endif
  328. //
  329. // NULL pointer to ATMLANE ATM ENTRY
  330. //
  331. #define NULL_PATMLANE_ATM_ENTRY ((PATMLANE_ATM_ENTRY)NULL)
  332. //
  333. // Definitions for Flags in ATMLANE ATM ENTRY
  334. //
  335. //
  336. // Bits 0-4 contain the state of an ATM Entry.
  337. //
  338. #define ATM_ENTRY_STATE_MASK 0x00000007
  339. #define ATM_ENTRY_IDLE 0x00000000 // Just created
  340. #define ATM_ENTRY_VALID 0x00000001 // Installed into the database
  341. #define ATM_ENTRY_CONNECTED 0x00000002 // VC connected
  342. #define ATM_ENTRY_CLOSING 0x00000004 // entry is about to go away
  343. #define ATM_ENTRY_CALLINPROGRESS 0x00000010 // Call underway
  344. #define ATM_ENTRY_WILL_ABORT 0x80000000 // Preparing to abort this
  345. //
  346. // Definitions for Type in ATMLANE ATM ENTRY
  347. //
  348. #define ATM_ENTRY_TYPE_PEER 0
  349. #define ATM_ENTRY_TYPE_LECS 1
  350. #define ATM_ENTRY_TYPE_LES 2
  351. #define ATM_ENTRY_TYPE_BUS 3
  352. //
  353. // ------------------------ MAC (ARP Table) Entry ------------------------
  354. //
  355. // Contains information about one remote MAC address.
  356. //
  357. // It is assumed that each MAC address resolves to exactly on ATM address.
  358. // So there is at most one ARP Table entry for a given MAC address.
  359. //
  360. // The MAC entry participates in two lists:
  361. // (1) A list of all entries that hash to the same bucket in the ARP Table.
  362. // (2) A list of all entries that resolve to the same ATM address.
  363. //
  364. // Reference Count: We add one to its ref count for each of the following:
  365. // - For the duration an active timer exists on this entry.
  366. // - For the duration the entry belongs to the list of MAC entries linked
  367. // to an ATM entry.
  368. //
  369. typedef struct _ATMLANE_MAC_ENTRY
  370. {
  371. #if DBG
  372. ULONG atmlane_mac_sig; // Signature for debugging
  373. #endif
  374. struct _ATMLANE_MAC_ENTRY * pNextEntry; // Next in hash list
  375. struct _ATMLANE_MAC_ENTRY * pNextToAtm; // List of entries pointing to
  376. // the save ATM Entry
  377. ULONG RefCount; // References to this struct
  378. ULONG Flags; // State and Type information
  379. ATMLANE_LOCK MeLock; // Lock for this structure
  380. MAC_ADDRESS MacAddress; // MAC Address
  381. ULONG MacAddrType; // Type of Addr (MAC vs RD)
  382. struct _ATMLANE_ELAN * pElan; // Back pointer to Elan
  383. PATMLANE_ATM_ENTRY pAtmEntry; // Pointer to ATM entry
  384. ATMLANE_TIMER Timer; // For ARP and Aging
  385. ATMLANE_TIMER FlushTimer; // For Flushing
  386. ULONG RetriesLeft; // Number of ARP retries left
  387. PNDIS_PACKET PacketList; // Packet list
  388. ULONG PacketListCount; // Number packets queued
  389. NDIS_TIMER BusTimer; // For metering Bus Sends
  390. ULONG BusyTime; // For metering Bus Sends
  391. ULONG LimitTime; // For metering Bus Sends
  392. ULONG IncrTime; // For metering Bus Sends
  393. ULONG FlushTid; // TID of outstanding flush
  394. ULONG ArpTid; // TID of outstanding arp
  395. }
  396. ATMLANE_MAC_ENTRY,
  397. *PATMLANE_MAC_ENTRY;
  398. #if DBG
  399. #define atmlane_mac_signature 'EMLA'
  400. #endif
  401. //
  402. // NULL pointer to ATMLANE MAC ENTRY
  403. //
  404. #define NULL_PATMLANE_MAC_ENTRY ((PATMLANE_MAC_ENTRY)NULL)
  405. //
  406. // Definitions for Flags in ATMLANE MAC ENTRY
  407. //
  408. #define MAC_ENTRY_STATE_MASK 0x0000007F
  409. #define MAC_ENTRY_NEW 0x00000001 // Brand new
  410. #define MAC_ENTRY_ARPING 0x00000002 // Running ARP protocol
  411. #define MAC_ENTRY_RESOLVED 0x00000004 // Calling
  412. #define MAC_ENTRY_FLUSHING 0x00000008 // Flushing
  413. #define MAC_ENTRY_ACTIVE 0x00000010 // Connected
  414. #define MAC_ENTRY_AGED 0x00000020 // Aged Out
  415. #define MAC_ENTRY_ABORTING 0x00000040 // Aborting
  416. #define MAC_ENTRY_BROADCAST 0x00010000 // Is broadcast address (BUS)
  417. #define MAC_ENTRY_BUS_TIMER 0x00040000 // BUS timer running
  418. #define MAC_ENTRY_USED_FOR_SEND 0x00080000 // Was used for send
  419. //
  420. // ------------------------ ATMLANE Virtual Circuit (VC) ---------------------
  421. //
  422. // One of these is used for each call terminated at the ELAN.
  423. // Creation and deletion of this structure is linked to NdisCoCreateVc and
  424. // NdisCoDeleteVc.
  425. //
  426. typedef struct _ATMLANE_VC
  427. {
  428. #if DBG
  429. ULONG atmlane_vc_sig; // Signature for debuging
  430. #endif
  431. struct _ATMLANE_VC * pNextVc; // Next VC in list
  432. ULONG RefCount; // References to this struct
  433. ULONG OutstandingSends; // Packets pending CoSendComplete
  434. ATMLANE_LOCK VcLock;
  435. ULONG Flags; // State and Type information
  436. ULONG LaneType; // LANE type of VC
  437. NDIS_HANDLE NdisVcHandle; // NDIS handle for this VC
  438. struct _ATMLANE_ELAN * pElan; // Back pointer to parent Elan
  439. PATMLANE_ATM_ENTRY pAtmEntry; // Back pointer to ATM Entry
  440. ATMLANE_TIMER AgingTimer; // Aging Timer
  441. ULONG AgingTime; // Aging Time
  442. ATMLANE_TIMER ReadyTimer; // Ready Timer
  443. ULONG RetriesLeft; // retries left
  444. ATM_ADDRESS CallingAtmAddress; // Calling party ATM Address
  445. // in call for this VC
  446. ULONG ReceiveActivity; // non-zero if receive activity seen
  447. }
  448. ATMLANE_VC,
  449. *PATMLANE_VC;
  450. #if DBG
  451. #define atmlane_vc_signature 'CVLA'
  452. #endif
  453. //
  454. // NULL pointer to ATMLANE VC
  455. //
  456. #define NULL_PATMLANE_VC ((PATMLANE_VC)NULL)
  457. //
  458. // Definitions for ATMLANE VC flags. The following information is kept
  459. // here:
  460. // - Is this VC an SVC or PVC
  461. // - Is this created (owned) by an Elan or the Call Manager
  462. // - Call State: Incoming in progress, Outgoing in progress, Active,
  463. // - LANE Ready state
  464. // - Close in progress
  465. //
  466. // Bits 0-1 for svc vs pvc type
  467. #define VC_TYPE_MASK 0x00000003
  468. #define VC_TYPE_UNUSED 0x00000000
  469. #define VC_TYPE_SVC 0x00000001
  470. #define VC_TYPE_PVC 0x00000002
  471. // Bits 2-3 for "Owner"
  472. #define VC_OWNER_MASK 0x0000000C
  473. #define VC_OWNER_IS_UNKNOWN 0x00000000
  474. #define VC_OWNER_IS_ATMLANE 0x00000004 // NdisClCreateVc done
  475. #define VC_OWNER_IS_CALLMGR 0x00000008 // CreateVcHandler done
  476. // Bits 4-7 for Call State
  477. #define VC_CALL_STATE_MASK 0x000000F0
  478. #define VC_CALL_STATE_IDLE 0x00000000
  479. #define VC_CALL_STATE_INCOMING_IN_PROGRESS 0x00000010 // Wait for CallConnected
  480. #define VC_CALL_STATE_OUTGOING_IN_PROGRESS 0x00000020 // Wait for MakeCallCmpl
  481. #define VC_CALL_STATE_ACTIVE 0x00000040
  482. #define VC_CALL_STATE_CLOSE_IN_PROGRESS 0x00000080 // Wait for CloseCallCmpl
  483. // Bits 8-9 to indicate waiting for LANE Ready state
  484. #define VC_READY_STATE_MASK 0x00000300
  485. #define VC_READY_WAIT 0x00000100
  486. #define VC_READY_INDICATED 0x00000200
  487. // Bit 10 to indicate whether we are closing this VC
  488. #define VC_CLOSE_STATE_MASK 0x00000400
  489. #define VC_CLOSE_STATE_CLOSING 0x00000400
  490. // Bit 12 to indicate whether we have seen an incoming close
  491. #define VC_SEEN_INCOMING_CLOSE 0x00001000
  492. //
  493. // Definitions for LaneType
  494. //
  495. #define VC_LANE_TYPE_UNKNOWN 0
  496. #define VC_LANE_TYPE_CONFIG_DIRECT 1 // LECS Connection (bidirectional)
  497. #define VC_LANE_TYPE_CONTROL_DIRECT 2 // LES Connection (bidirectional)
  498. #define VC_LANE_TYPE_CONTROL_DISTRIBUTE 3 // LES Connection (uni,incoming)
  499. #define VC_LANE_TYPE_DATA_DIRECT 4 // LEC Connection (bidirectional)
  500. #define VC_LANE_TYPE_MULTI_SEND 5 // BUS Connection (bidirectional)
  501. #define VC_LANE_TYPE_MULTI_FORWARD 6 // BUS Connection (uni,incoming)
  502. //
  503. // ------------------------ ELAN Event Object ------------------
  504. //
  505. typedef struct _ATMLANE_EVENT
  506. {
  507. ULONG Event; // Latest state-related event
  508. NDIS_STATUS EventStatus; // Status related to current event
  509. LIST_ENTRY Link; // event queue link
  510. }
  511. ATMLANE_EVENT,
  512. *PATMLANE_EVENT;
  513. //
  514. // ------------------------ ELAN Delayed Event Object ----------
  515. //
  516. typedef struct _ATMLANE_DELAYED_EVENT
  517. {
  518. struct _ATMLANE_EVENT DelayedEvent; // event info
  519. struct _ATMLANE_ELAN * pElan; // target ELAN for this event
  520. NDIS_TIMER DelayTimer; // To implement the delay
  521. }
  522. ATMLANE_DELAYED_EVENT,
  523. *PATMLANE_DELAYED_EVENT;
  524. //
  525. // ------------------------ ELAN Object ------------------------
  526. //
  527. //
  528. // ELAN object represents an ELAN instance and it's
  529. // corresponding virtual miniport adapter.
  530. //
  531. typedef struct _ATMLANE_ELAN
  532. {
  533. #if DBG
  534. ULONG atmlane_elan_sig;
  535. #endif // DBG
  536. LIST_ENTRY Link; // for adapter's elan list
  537. ATMLANE_LOCK ElanLock; // Mutex for elan struct
  538. ATMLANE_BLOCK Block;
  539. ULONG RefCount; // references to this elan
  540. ULONG AdminState; // Desired state of this elan
  541. ULONG State; // (Actual) State of this elan
  542. LIST_ENTRY EventQueue; // Event queue
  543. NDIS_WORK_ITEM EventWorkItem; // For event handling
  544. ULONG RetriesLeft; // For retry handling
  545. ATMLANE_TIMER Timer; // Timer for svr call & request timeouts
  546. NDIS_WORK_ITEM NdisWorkItem; // For scheduling a passive-level thread
  547. ULONG Flags; // Misc state information
  548. PATMLANE_DELAYED_EVENT pDelayedEvent; // Event to be queued in a while
  549. //
  550. // ------ Adapter related ----
  551. //
  552. struct _ATMLANE_ADAPTER * pAdapter; // back pointer to adapter parent
  553. NDIS_HANDLE NdisAdapterHandle; // cached adapter handle
  554. //
  555. // ------ Call Manager related ----
  556. //
  557. NDIS_HANDLE NdisAfHandle; // handle to call manager
  558. ULONG AtmInterfaceUp; // The ATM interface is considered
  559. // "up" after ILMI addr reg is over
  560. ATMLANE_SAP LesSap; // Control Distribute SAP
  561. ATMLANE_SAP BusSap; // Multicast Forward SAP
  562. ATMLANE_SAP DataSap; // Data Direct SAP
  563. ULONG SapsRegistered; // Number of Saps registered
  564. ATMLANE_BLOCK AfBlock; // Used to block shutdown while
  565. // AF open is in progress
  566. //
  567. // ------ Virtual Miniport related ----
  568. //
  569. NDIS_HANDLE MiniportAdapterHandle;// Virtual Miniport NDIS handle
  570. NDIS_STRING CfgDeviceName; // Miniport netcard driver name
  571. ULONG CurLookAhead; // Current established lookahead size
  572. ULONG CurPacketFilter; // Current packet filter bits
  573. ULONG FramesXmitGood;
  574. ULONG FramesRecvGood;
  575. ATMLANE_BLOCK InitBlock; // Used to block while IMInit
  576. // is in progress
  577. //
  578. // ------ Timer data ----
  579. //
  580. ATMLANE_TIMER_LIST TimerList[ALT_CLASS_MAX];
  581. ATMLANE_LOCK TimerLock; // Mutex for timer structures
  582. //
  583. // ----- LECS Configuration Parameters ----
  584. //
  585. BOOLEAN CfgUseLecs;
  586. BOOLEAN CfgDiscoverLecs;
  587. ATM_ADDRESS CfgLecsAddress;
  588. //
  589. // ----- ELAN Configuration Parameters ----
  590. //
  591. NDIS_STRING CfgBindName;
  592. NDIS_STRING CfgElanName;
  593. ULONG CfgLanType;
  594. ULONG CfgMaxFrameSizeCode;
  595. ATM_ADDRESS CfgLesAddress;
  596. //
  597. // ----- ELAN Run-Time Parameters ----
  598. //
  599. ULONG ElanNumber; // logical Elan number
  600. ATM_ADDRESS AtmAddress; // (C1) - LE Client's ATM Address
  601. UCHAR LanType; // (C2) - LAN Type
  602. UCHAR MaxFrameSizeCode; // (C3) - Maximum Data Frame Size Code
  603. ULONG MaxFrameSize; // - Maximum Data Frame Size Value
  604. USHORT LecId; // (C14) - LE Client Identifier
  605. UCHAR ElanName[LANE_ELANNAME_SIZE_MAX]; // (C5) - ELAN Name
  606. UCHAR ElanNameSize; // Size of above
  607. MAC_ADDRESS MacAddressEth; // (C6) - Elan's MAC Address (Eth/802.3 format)
  608. MAC_ADDRESS MacAddressTr; // Elan's MAC Address (802.5 format)
  609. ULONG ControlTimeout; // (C7) - Control Time-out
  610. ATM_ADDRESS LesAddress; // (C9) - LE Server ATM Address
  611. ULONG MaxUnkFrameCount; // (C10) - Maximum Unknown Frame Count
  612. ULONG MaxUnkFrameTime; // (C11) - Maximum Unknown Frame Time
  613. ULONG LimitTime; // Precalculated values for
  614. ULONG IncrTime; // limiting bus traffic
  615. ULONG VccTimeout; // (C12) - VCC Time-out Period
  616. ULONG MaxRetryCount; // (C13) - Maximum Retry Count
  617. MAC_ADDRESS McastAddrs[MCAST_LIST_SIZE]; // (C15) - Multicast MAC Addresses
  618. ULONG McastAddrCount; // Number of above
  619. ULONG AgingTime; // (C17) - Aging Time
  620. ULONG ForwardDelayTime; // (C18) - Forward Delay Time
  621. ULONG TopologyChange; // (C19) - Topology Change
  622. ULONG ArpResponseTime; // (C20) - Expected LE_ARP Response Time
  623. ULONG FlushTimeout; // (C21) - Flush Time-out
  624. ULONG PathSwitchingDelay; // (C22) - Path Switching Delay
  625. ULONG LocalSegmentId; // (C23) - Local Segment ID
  626. ULONG McastSendVcType; // (C24) - Mcast Send VCC Type (ignored)
  627. ULONG McastSendVcAvgRate; // (C25) - Mcast Send Avg Rate (ignored)
  628. ULONG McastSendVcPeakRate;// (C26) - Mcast Send Peak Rate (ignored)
  629. ULONG ConnComplTimer; // (C28) - Connection Completion Timer
  630. ULONG TransactionId; // LANE Control Frame Tid
  631. ATM_ADDRESS LecsAddress; // LECS ATM Address
  632. ATM_ADDRESS BusAddress; // BUS ATM Address
  633. ULONG MinFrameSize; // Minimum LANE frame size
  634. NDIS_STATUS LastEventCode; // Used to avoid repeated event logging
  635. //
  636. // ----- Buffer Management: Header buffers and Protocol buffers ----
  637. //
  638. ATMLANE_LOCK HeaderBufferLock; // Mutex for header buffers
  639. PNDIS_BUFFER HeaderBufList; // Free list of header buffers
  640. ULONG HeaderBufSize; // Size of each header buffer
  641. ULONG RealHeaderBufSize; // Above size rounded up to mult of 4
  642. ULONG MaxHeaderBufs; // Max header buffers we can allocate
  643. ULONG CurHeaderBufs; // Current header buffers allocated
  644. PATMLANE_BUFFER_TRACKER pHeaderTrkList; // Info about allocated header buffers
  645. PNDIS_BUFFER PadBufList;
  646. ULONG PadBufSize; // Size of pad buffers
  647. ULONG MaxPadBufs; // Max pad buffers we can allocate
  648. ULONG CurPadBufs; // Current pad buffers allocated
  649. PATMLANE_BUFFER_TRACKER pPadTrkList; // Info about allocated pad buffers
  650. NDIS_HANDLE ProtocolPacketPool; // Handle for Packet pool
  651. NDIS_HANDLE ProtocolBufferPool; // Handle for Buffer pool
  652. PUCHAR ProtocolBufList; // Free list of protocol buffers (for
  653. // LANE control packets)
  654. PUCHAR ProtocolBufTracker; // Start of chunk of memory used for
  655. // the above.
  656. ULONG ProtocolBufSize; // Size of each protocol buffer
  657. ULONG MaxProtocolBufs; // Number of protocol buffers
  658. NDIS_HANDLE TransmitPacketPool; // Handle for transmit packet pool
  659. NDIS_HANDLE ReceivePacketPool; // Handle for receive packet pool
  660. NDIS_HANDLE ReceiveBufferPool; // Handle for receive buffer pool
  661. #if PKT_HDR_COUNTS
  662. ULONG XmitPktCount;
  663. ULONG RecvPktCount;
  664. ULONG ProtPktCount;
  665. #endif // PKT_HDR_COUNTS
  666. #if SENDLIST
  667. PNDIS_PACKET pSendList;
  668. NDIS_SPIN_LOCK SendListLock;
  669. #endif // SENDLIST
  670. //
  671. // ----- MAC Entry Cache ----- (C16)
  672. //
  673. PATMLANE_MAC_ENTRY * pMacTable; // (C16) LE_ARP Cache
  674. ULONG NumMacEntries; // Count of entries in cache
  675. ATMLANE_LOCK MacTableLock; // Mutex for above table
  676. //
  677. // ----- Connection Cache -----
  678. //
  679. PATMLANE_ATM_ENTRY pLecsAtmEntry; // LE Configuration Server
  680. PATMLANE_ATM_ENTRY pLesAtmEntry; // LAN Emulation Server
  681. PATMLANE_ATM_ENTRY pBusAtmEntry; // Broadcast & Unknown Server
  682. PATMLANE_ATM_ENTRY pAtmEntryList; // List of all ATM Entries
  683. ULONG NumAtmEntries; // Count of entries
  684. ATMLANE_LOCK AtmEntryListLock; // Mutex for above list
  685. }
  686. ATMLANE_ELAN,
  687. *PATMLANE_ELAN;
  688. #if DBG
  689. #define atmlane_elan_signature 'LELA'
  690. #endif
  691. //
  692. // NULL pointer to ATMLANE ELAN
  693. //
  694. #define NULL_PATMLANE_ELAN ((PATMLANE_ELAN)NULL)
  695. //
  696. // Definitions of ATMLANE ELAN States.
  697. //
  698. #define ELAN_STATE_ALLOCATED 0
  699. #define ELAN_STATE_INIT 1
  700. #define ELAN_STATE_LECS_CONNECT_ILMI 2
  701. #define ELAN_STATE_LECS_CONNECT_WKA 3
  702. #define ELAN_STATE_LECS_CONNECT_PVC 4
  703. #define ELAN_STATE_LECS_CONNECT_CFG 5
  704. #define ELAN_STATE_CONFIGURE 6
  705. #define ELAN_STATE_LES_CONNECT 7
  706. #define ELAN_STATE_JOIN 8
  707. #define ELAN_STATE_BUS_CONNECT 9
  708. #define ELAN_STATE_OPERATIONAL 10
  709. #define ELAN_STATE_SHUTDOWN 11
  710. //
  711. // Definitions of ATMLANE Elan Flags
  712. //
  713. //
  714. // Bits 0 thru 3 define the current LECS Connect attempt
  715. //
  716. #define ELAN_LECS_MASK 0x0000000f
  717. #define ELAN_LECS_ILMI 0x00000001
  718. #define ELAN_LECS_WKA 0x00000002
  719. #define ELAN_LECS_PVC 0x00000004
  720. #define ELAN_LECS_CFG 0x00000008
  721. //
  722. // Bit 4 & 5 define the virtual miniport state
  723. //
  724. #define ELAN_MINIPORT_INITIALIZED 0x00000010
  725. #define ELAN_MINIPORT_OPERATIONAL 0x00000020
  726. //
  727. // Bit 6 defines event work item scheduling state
  728. //
  729. #define ELAN_EVENT_WORK_ITEM_SET 0x00000040
  730. //
  731. // Bit 7 specifies if we want to restart this ELAN
  732. //
  733. #define ELAN_NEEDS_RESTART 0x00000080
  734. #define ELAN_SAW_AF_CLOSE 0x00000100
  735. //
  736. // Bit 9 defines whether there is a pending IMInitializeDeviceInstance
  737. // on the ELAN, i.e. we expect to see a MiniportInitialize.
  738. //
  739. #define ELAN_MINIPORT_INIT_PENDING 0x00000200
  740. //
  741. // Bit 10 defines whether we are in the process of opening
  742. // an AF handle.
  743. //
  744. #define ELAN_OPENING_AF 0x00000400
  745. //
  746. // This bit indicates whether this ELAN is being deallocated.
  747. //
  748. #define ELAN_DEALLOCATING 0x80000000
  749. //
  750. // Elan events
  751. //
  752. #define ELAN_EVENT_START 1
  753. #define ELAN_EVENT_NEW_ATM_ADDRESS 2
  754. #define ELAN_EVENT_GOT_ILMI_LECS_ADDR 3
  755. #define ELAN_EVENT_SVR_CALL_COMPLETE 4
  756. #define ELAN_EVENT_CONFIGURE_RESPONSE 5
  757. #define ELAN_EVENT_SAPS_REGISTERED 6
  758. #define ELAN_EVENT_JOIN_RESPONSE 7
  759. #define ELAN_EVENT_ARP_RESPONSE 8
  760. #define ELAN_EVENT_BUS_CALL_CLOSED 9
  761. #define ELAN_EVENT_LES_CALL_CLOSED 10
  762. #define ELAN_EVENT_LECS_CALL_CLOSED 11
  763. #define ELAN_EVENT_RESTART 12
  764. #define ELAN_EVENT_STOP 13
  765. //
  766. // Event status codes - use NDIS status codes
  767. // but make up one for timeout
  768. //
  769. #define NDIS_STATUS_TIMEOUT ((NDIS_STATUS)STATUS_TIMEOUT)
  770. //
  771. // ------------------------ ElanName Object ------------------------
  772. //
  773. typedef struct _ATMLANE_NAME
  774. {
  775. struct _ATMLANE_NAME * pNext;
  776. NDIS_STRING Name;
  777. } ATMLANE_NAME,
  778. *PATMLANE_NAME;
  779. //
  780. // ------------------------ Adapter Object ------------------------
  781. //
  782. //
  783. // Adapter object represents an actual ATM adapter.
  784. //
  785. typedef struct _ATMLANE_ADAPTER
  786. {
  787. #if DBG
  788. ULONG atmlane_adapter_sig;
  789. #endif
  790. //
  791. // Reference count and lock to protect this object.
  792. //
  793. ULONG RefCount;
  794. ATMLANE_LOCK AdapterLock;
  795. //
  796. // State
  797. //
  798. ULONG Flags;
  799. //
  800. // Block data structure for blocking threads during adapter requests.
  801. //
  802. ATMLANE_BLOCK Block;
  803. //
  804. // Link for global adapter list.
  805. //
  806. LIST_ENTRY Link;
  807. //
  808. // Adapter handle and such.
  809. //
  810. NDIS_HANDLE NdisAdapterHandle;
  811. NDIS_HANDLE BindContext;
  812. NDIS_HANDLE UnbindContext;
  813. //
  814. // Protocol configuration handle and string for opening it.
  815. //
  816. NDIS_STRING ConfigString;
  817. //
  818. // Adapter parameters acquired from miniport
  819. //
  820. MAC_ADDRESS MacAddress;
  821. ULONG MaxAAL5PacketSize;
  822. NDIS_CO_LINK_SPEED LinkSpeed;
  823. //
  824. // Adapter configuration parameters.
  825. // These only exist on Memphis/Win98.
  826. //
  827. BOOLEAN RunningOnMemphis;
  828. NDIS_STRING CfgUpperBindings;
  829. PATMLANE_NAME UpperBindingsList;
  830. NDIS_STRING CfgElanName;
  831. PATMLANE_NAME ElanNameList;
  832. //
  833. // List of created ELANs.
  834. //
  835. LIST_ENTRY ElanList;
  836. UINT ElanCount;
  837. //
  838. // Used to block Unbind while bootstrapping ELANs.
  839. //
  840. ATMLANE_BLOCK UnbindBlock;
  841. //
  842. // Used to block AF notification while querying the ATM adapter.
  843. //
  844. ATMLANE_BLOCK OpenBlock;
  845. //
  846. // Name of device. Used to protect against multiple calls to our
  847. // BindAdapter handler for the same device.
  848. //
  849. NDIS_STRING DeviceName;
  850. }
  851. ATMLANE_ADAPTER,
  852. *PATMLANE_ADAPTER;
  853. #if DBG
  854. #define atmlane_adapter_signature 'DALA'
  855. #endif
  856. //
  857. // NULL pointer to ATMLANE Adapter
  858. //
  859. #define NULL_PATMLANE_ADAPTER ((PATMLANE_ADAPTER)NULL)
  860. //
  861. // Definitions for Adapter State Flags
  862. //
  863. #define ADAPTER_FLAGS_AF_NOTIFIED 0x00000001
  864. #define ADAPTER_FLAGS_UNBINDING 0x00000002
  865. #define ADAPTER_FLAGS_UNBIND_COMPLETE_PENDING 0x00000004
  866. #define ADAPTER_FLAGS_CLOSE_IN_PROGRESS 0x00000008
  867. #define ADAPTER_FLAGS_BOOTSTRAP_IN_PROGRESS 0x00000010
  868. #define ADAPTER_FLAGS_OPEN_IN_PROGRESS 0x00000100
  869. #define ADAPTER_FLAGS_DEALLOCATING 0x80000000
  870. #endif // __ATMLANE_ATMLANE_H