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.

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