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.

454 lines
14 KiB

  1. /*++
  2. Copyright (c) 1990-1998 Microsoft Corporation, All Rights Reserved.
  3. Module Name:
  4. atmsmdrv.h
  5. Abstract:
  6. ATM sample client driver header file.
  7. Note : We use one lock per interface. When there are more VC's per
  8. interface we could have a locking mechanism that is finer than this.
  9. Author:
  10. Anil Francis Thomas (10/98)
  11. Environment:
  12. Kernel
  13. Revision History:
  14. --*/
  15. #ifndef __ATMSMDRV_H_
  16. #define __ATMSMDRV_H_
  17. #define DEFAULT_NUM_PKTS_IN_POOL 512
  18. #define MAX_FREE_PKTS_TO_KEEP 512
  19. #define MAX_PKTS_AT_ONCE_ON_TIMER 25
  20. #define DEFAULT_TIMER_INTERVAL MIN_DELAY // in millisec
  21. #define ATM_SAMPLE_CLIENT_DEVICE_NAME L"\\Device\\ATMSampleClient"
  22. #define ATM_SAMPLE_CLIENT_SYMBOLIC_NAME L"\\DosDevices\\ATMSampleClient"
  23. //
  24. //
  25. //
  26. typedef struct _HwAddr {
  27. ATM_ADDRESS Address;
  28. PATM_ADDRESS SubAddress;
  29. } HW_ADDR, *PHW_ADDR;
  30. //
  31. // Flow Specifications for an ATM Connection. The structure
  32. // represents a bidirectional flow.
  33. //
  34. typedef struct _ATMSM_FLOW_SPEC
  35. {
  36. ULONG SendBandwidth; // Bytes/Sec
  37. ULONG SendMaxSize; // Bytes
  38. ULONG ReceiveBandwidth; // Bytes/Sec
  39. ULONG ReceiveMaxSize; // Bytes
  40. SERVICETYPE ServiceType;
  41. } ATMSM_FLOW_SPEC, *PATMSM_FLOW_SPEC;
  42. //
  43. // used for blocking request
  44. //
  45. typedef struct _ATMSM_BLOCK {
  46. NDIS_EVENT Event;
  47. NDIS_STATUS Status;
  48. } ATMSM_BLOCK, *PATMSM_BLOCK;
  49. #define INIT_BLOCK_STRUCT(pBlock) NdisInitializeEvent(&((pBlock)->Event))
  50. #define RESET_BLOCK_STRUCT(pBlock) NdisResetEvent(&((pBlock)->Event))
  51. #define WAIT_ON_BLOCK_STRUCT(pBlock) \
  52. (NdisWaitEvent(&((pBlock)->Event), 0), (pBlock)->Status)
  53. #define SIGNAL_BLOCK_STRUCT(pBlock, _Status) { \
  54. (pBlock)->Status = _Status; \
  55. NdisSetEvent(&((pBlock)->Event)); \
  56. }
  57. //
  58. // Some forward declarations
  59. //
  60. typedef struct _AtmSmPMPMember ATMSM_PMP_MEMBER, *PATMSM_PMP_MEMBER;
  61. typedef struct _AtmSmVc ATMSM_VC, *PATMSM_VC;
  62. typedef struct _AtmSmAdapter ATMSM_ADAPTER, *PATMSM_ADAPTER;
  63. //
  64. // used to represent a party in the point to multipoint call
  65. //
  66. typedef struct _AtmSmPMPMember{
  67. ULONG ulSignature;
  68. PATMSM_PMP_MEMBER pNext;
  69. PATMSM_VC pVc; // back pointer to the Vc
  70. ULONG ulFlags; // State and other info
  71. NDIS_HANDLE NdisPartyHandle;// NDIS handle for this leaf
  72. HW_ADDR HwAddr; // From CallingPartyAddress
  73. }ATMSM_PMP_MEMBER, *PATMSM_PMP_MEMBER;
  74. #define atmsm_member_signature 'MMMS'
  75. // Flags in ATMSM_PMP_MEMBER
  76. #define ATMSM_MEMBER_IDLE 0x00000001
  77. #define ATMSM_MEMBER_CONNECTING 0x00000002
  78. #define ATMSM_MEMBER_CONNECTED 0x00000004
  79. #define ATMSM_MEMBER_CLOSING 0x00000008
  80. #define ATMSM_MEMBER_STATES 0x0000000F
  81. #define ATMSM_MEMBER_DROP_TRIED 0x01000000
  82. #define ATMSM_MEMBER_INVALID 0x80000000 // Invalidated entry
  83. #define ATMSM_GET_MEMBER_STATE(_pMember) \
  84. (_pMember->ulFlags & ATMSM_MEMBER_STATES)
  85. #define ATMSM_SET_MEMBER_STATE(_pMember, _State) \
  86. (_pMember->ulFlags = ((_pMember->ulFlags & ~ATMSM_MEMBER_STATES) \
  87. | _State))
  88. #define ATMSM_IS_MEMBER_INVALID(_pMember) \
  89. (_pMember->ulFlags & ATMSM_MEMBER_INVALID)
  90. //
  91. // VC
  92. //
  93. // Reference count:
  94. // Incoming call (PP and PMP) VC 1 at create + 1 at call connect
  95. // Outgoing call (PP) 1 at create
  96. // Outgoing call (PMP) 1 at create + 1 for each Member
  97. //
  98. typedef struct _AtmSmVc
  99. {
  100. // Note Vc signature is used always
  101. ULONG ulSignature;
  102. ULONG VcType;
  103. LIST_ENTRY List;
  104. ULONG ulRefCount;
  105. ULONG ulFlags;
  106. NDIS_HANDLE NdisVcHandle;
  107. PATMSM_ADAPTER pAdapt;
  108. ULONG MaxSendSize;// From AAL parameters
  109. // the following is used in the case of unicast and incoming PMP call
  110. HW_ADDR HwAddr;
  111. // the following the IRP that initiated an outgoing call
  112. PIRP pConnectIrp;
  113. // the following are used for outgoing PMP calls
  114. ULONG ulNumTotalMembers;
  115. ULONG ulNumActiveMembers;
  116. ULONG ulNumConnectingMembers;
  117. ULONG ulNumDroppingMembers;
  118. PATMSM_PMP_MEMBER pPMPMembers;
  119. //
  120. // Send queue to hold packets when the Vc is connecting
  121. //
  122. PNDIS_PACKET pSendLastPkt; // cache the last packet for
  123. // adding to tail
  124. PNDIS_PACKET pSendPktNext;
  125. ULONG ulSendPktsCount;
  126. } ATMSM_VC, *PATMSM_VC;
  127. #define atmsm_vc_signature 'CVMS'
  128. #define atmsm_dead_vc_signature 'VAED'
  129. #define ATMSM_VC_IDLE 0x00000001 // outgoing
  130. #define ATMSM_VC_ACTIVE 0x00000002 // out\in
  131. #define ATMSM_VC_CALLPROCESSING 0x00000004 // in
  132. #define ATMSM_VC_SETUP_IN_PROGRESS 0x00000008 // out
  133. #define ATMSM_VC_ADDING_PARTIES 0x00000010 // out
  134. #define ATMSM_VC_CLOSING 0x00000020 // out\in
  135. #define ATMSM_VC_CLOSED 0x00000040 // out\in
  136. #define ATMSM_VC_NEED_CLOSING 0x00000080 // pmp out
  137. #define ATMSM_VC_STATES 0x000000FF
  138. #define ATMSM_GET_VC_STATE(_pVc) \
  139. (_pVc->ulFlags & ATMSM_VC_STATES)
  140. #define ATMSM_SET_VC_STATE(_pVc, _State) \
  141. (_pVc->ulFlags = ((_pVc->ulFlags & ~ATMSM_VC_STATES) \
  142. | _State))
  143. //
  144. // VC types:
  145. //
  146. #define VC_TYPE_INCOMING ((ULONG)1)
  147. #define VC_TYPE_PP_OUTGOING ((ULONG)2)
  148. #define VC_TYPE_PMP_OUTGOING ((ULONG)3)
  149. //
  150. // ADAPTER
  151. //
  152. // Reference count:
  153. // 1 at create +
  154. // 1 for Open AF +
  155. // 1 for each Vc +
  156. // 1 for each request
  157. //
  158. typedef struct _AtmSmAdapter {
  159. // Note adapter signature is used always
  160. ULONG ulSignature;
  161. PATMSM_ADAPTER pAdapterNext;
  162. ULONG ulRefCount; // reference count
  163. ULONG ulFlags; // Flags Opened,Closed etc
  164. NDIS_STRING BoundToAdapterName; // Adapter we are bound to
  165. NDIS_HANDLE NdisBindContext; // BindContext in BindAdapter
  166. NDIS_HANDLE UnbindContext; // UnBindContext in UnbindAdapter
  167. NDIS_HANDLE NdisBindingHandle; // To the Adapter
  168. NDIS_MEDIUM Medium;
  169. PNDIS_EVENT pCleanupEvent; // pointer to an event used in
  170. // Close Adapter
  171. ATMSM_BLOCK RequestBlock; // Used for making requests
  172. // AF related
  173. NDIS_HANDLE NdisAfHandle;
  174. CO_ADDRESS_FAMILY AddrFamily; // For use by NdisClOpenAddressFamily
  175. // Sap related
  176. NDIS_HANDLE NdisSapHandle;
  177. PCO_SAP pSap; // For use by NdisClRegisterSap
  178. ATMSM_FLOW_SPEC VCFlowSpec;
  179. // Lock used for manipulating Pools and packets
  180. NDIS_SPIN_LOCK AdapterLock;
  181. // Packet Pool Handle
  182. NDIS_HANDLE PacketPoolHandle;
  183. // Buffer Pool Handle
  184. NDIS_HANDLE BufferPoolHandle;
  185. LIST_ENTRY InactiveVcHead; // Created Vcs go here.
  186. LIST_ENTRY ActiveVcHead; // Vcs with active calls go here.
  187. ATM_ADDRESS ConfiguredAddress; // Configured address of the adapter
  188. NDIS_CO_LINK_SPEED LinkSpeed;
  189. ULONG MaxPacketSize;
  190. // used for recvs on this adapter
  191. PIRP pRecvIrp; // refers to the user request
  192. //
  193. // Recv queue (for buffering received packets)
  194. //
  195. PNDIS_PACKET pRecvLastPkt; // cache the last packet for
  196. // adding to tail
  197. PNDIS_PACKET pRecvPktNext;
  198. ULONG ulRecvPktsCount;
  199. // the timer object for returning packets that are queued
  200. NDIS_TIMER RecvTimerOb;
  201. //
  202. // Interface Properties
  203. //
  204. BOOLEAN fRecvTimerQueued;
  205. BOOLEAN fAdapterOpenedForRecv;
  206. UCHAR SelByte;
  207. } ATMSM_ADAPTER, *PATMSM_ADAPTER;
  208. #define atmsm_adapter_signature 'DAMS'
  209. #define atmsm_dead_adapter_signature 'DAED'
  210. // Values for ulFlags
  211. #define ADAPT_CREATED 0x00000001
  212. #define ADAPT_OPENED 0x00000002
  213. #define ADAPT_AF_OPENED 0x00000004
  214. #define ADAPT_SAP_REGISTERED 0x00000008
  215. #define ADAPT_SHUTTING_DOWN 0x00000010
  216. #define ADAPT_CLOSING 0x00000020
  217. #define ADAPT_ADDRESS_INVALID 0x00010000
  218. //
  219. // Structure used for representing Global Properties
  220. //
  221. typedef struct _AtmSmGlobal {
  222. ULONG ulSignature;
  223. // Initialization sequence flag
  224. ULONG ulInitSeqFlag;
  225. ULONG ulNumCreates;
  226. // Global Properties - maintained for reference (to return in Get calls)
  227. ULONG ulRecvDelay; // millisecs
  228. ULONG ulSendDelay; // millisecs
  229. ULONG ulSimulateSendPktLoss; // Percentage
  230. ULONG ulSimulateRecvPktLoss; // Percentage
  231. BOOLEAN fSimulateResLimit;
  232. BOOLEAN fDontRecv;
  233. BOOLEAN fDontSend;
  234. NDIS_HANDLE ProtHandle;
  235. NDIS_HANDLE MiniportHandle;
  236. PATMSM_ADAPTER pAdapterList;
  237. ULONG ulAdapterCount;
  238. PDRIVER_OBJECT pDriverObject;
  239. PDEVICE_OBJECT pDeviceObject;
  240. // General purpose Lock
  241. NDIS_SPIN_LOCK Lock;
  242. }ATMSM_GLOBAL, *PATMSM_GLOBAL;
  243. #define atmsm_global_signature 'LGMS'
  244. // values for ulInitSeqFlag
  245. #define CREATED_IO_DEVICE 0x00000001
  246. #define REGISTERED_SYM_NAME 0x00000002
  247. #define REGISTERED_WITH_NDIS 0x00000004
  248. //
  249. // If the adapter is opened for recvs,
  250. // received data is buffered for a while before returning to the
  251. // miniport. Buffers passed from the user mode is filled with
  252. // arriving data. If no buffers arrive user mode call pends.
  253. //
  254. //
  255. // Prototype of the routines handling DeviceIoCntrl
  256. //
  257. typedef NTSTATUS (*PATMSM_IOCTL_FUNCS)(
  258. PIRP pIrp,
  259. PIO_STACK_LOCATION pIrpSp
  260. );
  261. //
  262. // Protocol reserved part of the packet
  263. // This is used for packets send down to miniport below us.
  264. // The pNext is also used while holding these packets in
  265. // our queues (Free, Send, Recv). ulTime is used as the time
  266. // at which the packet was queued
  267. //
  268. typedef struct _ProtRsvd
  269. {
  270. ULONG ulTime; // in milliseconds
  271. PNDIS_PACKET pPktNext;
  272. PIRP pSendIrp;
  273. } PROTO_RSVD, *PPROTO_RSVD;
  274. #define GET_PROTO_RSVD(pPkt) \
  275. ((PPROTO_RSVD)(pPkt->ProtocolReserved))
  276. //
  277. // Some global data
  278. //
  279. extern ATMSM_GLOBAL AtmSmGlobal;
  280. extern ATM_BLLI_IE AtmSmDefaultBlli;
  281. extern ATM_BHLI_IE AtmSmDefaultBhli;
  282. extern ATMSM_FLOW_SPEC AtmSmDefaultVCFlowSpec;
  283. extern PATMSM_IOCTL_FUNCS AtmSmFuncProcessIoctl[ATMSM_MAX_FUNCTION_CODE+1];
  284. extern ULONG AtmSmIoctlTable[ATMSM_NUM_IOCTLS];
  285. #define BYTES_TO_CELLS(_b) ((_b)/48)
  286. //
  287. // Rounded-off size of generic Q.2931 IE header
  288. //
  289. #define ROUND_OFF(_size) (((_size) + 3) & ~0x4)
  290. #define SIZEOF_Q2931_IE ROUND_OFF(sizeof(Q2931_IE))
  291. #define SIZEOF_AAL_PARAMETERS_IE ROUND_OFF(sizeof(AAL_PARAMETERS_IE))
  292. #define SIZEOF_ATM_TRAFFIC_DESCR_IE ROUND_OFF(sizeof(ATM_TRAFFIC_DESCRIPTOR_IE))
  293. #define SIZEOF_ATM_BBC_IE ROUND_OFF(sizeof(ATM_BROADBAND_BEARER_CAPABILITY_IE))
  294. #define SIZEOF_ATM_BLLI_IE ROUND_OFF(sizeof(ATM_BLLI_IE))
  295. #define SIZEOF_ATM_QOS_IE ROUND_OFF(sizeof(ATM_QOS_CLASS_IE))
  296. //
  297. // Total space required for Information Elements in an outgoing call.
  298. //
  299. #define ATMSM_MAKE_CALL_IE_SPACE ( \
  300. SIZEOF_Q2931_IE + SIZEOF_AAL_PARAMETERS_IE + \
  301. SIZEOF_Q2931_IE + SIZEOF_ATM_TRAFFIC_DESCR_IE + \
  302. SIZEOF_Q2931_IE + SIZEOF_ATM_BBC_IE + \
  303. SIZEOF_Q2931_IE + SIZEOF_ATM_BLLI_IE + \
  304. SIZEOF_Q2931_IE + SIZEOF_ATM_QOS_IE )
  305. //
  306. // Total space required for Information Elements in an outgoing AddParty.
  307. //
  308. #define ATMSM_ADD_PARTY_IE_SPACE ( \
  309. SIZEOF_Q2931_IE + SIZEOF_AAL_PARAMETERS_IE + \
  310. SIZEOF_Q2931_IE + SIZEOF_ATM_BLLI_IE )
  311. //
  312. // Some defaults
  313. //
  314. #define DEFAULT_SEND_BANDWIDTH (ATM_USER_DATA_RATE_SONET_155*100/8)
  315. // Bytes/sec
  316. #define DEFAULT_RECV_BANDWIDTH 0
  317. #define DEFAULT_MAX_PACKET_SIZE 9180 // Bytes
  318. #define RECV_BUFFERING_TIME 500 // millisecs
  319. //
  320. // useful Macros
  321. //
  322. #define ACQUIRE_GLOBAL_LOCK() NdisAcquireSpinLock(&AtmSmGlobal.Lock)
  323. #define RELEASE_GLOBAL_LOCK() NdisReleaseSpinLock(&AtmSmGlobal.Lock)
  324. #define ACQUIRE_ADAPTER_GEN_LOCK(pA) NdisAcquireSpinLock(&pA->AdapterLock)
  325. #define RELEASE_ADAPTER_GEN_LOCK(pA) NdisReleaseSpinLock(&pA->AdapterLock)
  326. #define SET_ADAPTER_RECV_TIMER(pA, uiTimerDelay) { \
  327. NdisSetTimer(&pA->RecvTimerOb, \
  328. uiTimerDelay); \
  329. pA->fRecvTimerQueued = TRUE; \
  330. }
  331. #define CANCEL_ADAPTER_RECV_TIMER(pA, pfTimerCancelled) { \
  332. NdisCancelTimer(&pA->RecvTimerOb, \
  333. pfTimerCancelled); \
  334. pA->fRecvTimerQueued = FALSE; \
  335. }
  336. #endif