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.

1657 lines
39 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. priv.h
  5. Abstract:
  6. Common header file for ATM Epvc IM miniport.
  7. Author:
  8. ADube 03/23/2000
  9. Environment:
  10. Revision History:
  11. --*/
  12. #ifndef _PRIV_H
  13. #define _PRIV_H
  14. //advance declaration
  15. typedef struct _EPVC_I_MINIPORT _ADAPT, ADAPT, *PADAPT;
  16. typedef struct _EPVC_I_MINIPORT EPVC_I_MINIPORT, *PEPVC_I_MINIPORT ;
  17. typedef struct _EPVC_GLOBALS EPVC_GLOBALS, *PEPVC_GLOBALS;
  18. typedef struct _EPVC_ARP_PACKET EPVC_ARP_PACKET, *PEPVC_ARP_PACKET ;
  19. typedef struct _EPVC_NDIS_REQUEST EPVC_NDIS_REQUEST, *PEPVC_NDIS_REQUEST;
  20. extern LIST_ENTRY g_ProtocolList;
  21. //
  22. // Temp declarations
  23. //
  24. extern NDIS_HANDLE ProtHandle, DriverHandle;
  25. extern EPVC_GLOBALS EpvcGlobals;
  26. //--------------------------------------------------------------------------------
  27. // //
  28. // Driver Functions - Prototypes //
  29. // //
  30. // //
  31. //--------------------------------------------------------------------------------
  32. extern
  33. NTSTATUS
  34. DriverEntry(
  35. IN PDRIVER_OBJECT DriverObject,
  36. IN PUNICODE_STRING RegistryPath
  37. );
  38. extern
  39. VOID
  40. EpvcUnload(
  41. IN PDRIVER_OBJECT pDriverObject
  42. );
  43. //--------------------------------------------------------------------------------
  44. // //
  45. // Protocol Functions - Prototypes //
  46. // //
  47. // //
  48. //--------------------------------------------------------------------------------
  49. extern
  50. VOID
  51. EpvcResetComplete(
  52. IN NDIS_HANDLE ProtocolBindingContext,
  53. IN NDIS_STATUS Status
  54. );
  55. extern
  56. VOID
  57. PtStatus(
  58. IN NDIS_HANDLE ProtocolBindingContext,
  59. IN NDIS_STATUS GeneralStatus,
  60. IN PVOID StatusBuffer,
  61. IN UINT StatusBufferSize
  62. );
  63. extern
  64. VOID
  65. PtStatusComplete(
  66. IN NDIS_HANDLE ProtocolBindingContext
  67. );
  68. extern
  69. VOID
  70. PtTransferDataComplete(
  71. IN NDIS_HANDLE ProtocolBindingContext,
  72. IN PNDIS_PACKET Packet,
  73. IN NDIS_STATUS Status,
  74. IN UINT BytesTransferred
  75. );
  76. extern
  77. NDIS_STATUS
  78. PtReceive(
  79. IN NDIS_HANDLE ProtocolBindingContext,
  80. IN NDIS_HANDLE MacReceiveContext,
  81. IN PVOID HeaderBuffer,
  82. IN UINT HeaderBufferSize,
  83. IN PVOID LookAheadBuffer,
  84. IN UINT LookaheadBufferSize,
  85. IN UINT PacketSize
  86. );
  87. extern
  88. VOID
  89. PtReceiveComplete(
  90. IN NDIS_HANDLE ProtocolBindingContext
  91. );
  92. extern
  93. INT
  94. PtReceivePacket(
  95. IN NDIS_HANDLE ProtocolBindingContext,
  96. IN PNDIS_PACKET Packet
  97. );
  98. VOID
  99. EpvcUnload(
  100. IN PDRIVER_OBJECT DriverObject
  101. );
  102. extern
  103. VOID
  104. EpvcAfRegisterNotify(
  105. IN NDIS_HANDLE ProtocolBindingContext,
  106. IN PCO_ADDRESS_FAMILY AddressFamily
  107. );
  108. VOID
  109. epvcOidCloseAfWorkItem(
  110. IN PRM_OBJECT_HEADER pObj,
  111. IN NDIS_STATUS Status,
  112. IN PRM_STACK_RECORD pSR
  113. );
  114. //--------------------------------------------------------------------------------
  115. // //
  116. // Miniport Functions - Prototypes //
  117. // //
  118. // //
  119. //--------------------------------------------------------------------------------
  120. NDIS_STATUS
  121. MPTransferData(
  122. OUT PNDIS_PACKET Packet,
  123. OUT PUINT BytesTransferred,
  124. IN NDIS_HANDLE MiniportAdapterContext,
  125. IN NDIS_HANDLE MiniportReceiveContext,
  126. IN UINT ByteOffset,
  127. IN UINT BytesToTransfer
  128. );
  129. NDIS_STATUS
  130. MPReset(
  131. OUT PBOOLEAN AddressingReset,
  132. IN NDIS_HANDLE MiniportAdapterContext
  133. );
  134. #define DBGPRINT(Fmt) \
  135. { \
  136. DbgPrint("*** %s (%d) *** ", __FILE__, __LINE__); \
  137. DbgPrint (Fmt); \
  138. }
  139. #define NUM_PKTS_IN_POOL 256
  140. extern NDIS_PHYSICAL_ADDRESS HighestAcceptableMax;
  141. extern NDIS_HANDLE ProtHandle, DriverHandle;
  142. extern NDIS_MEDIUM MediumArray[1];
  143. //
  144. // Custom Macros to be used by the passthru driver
  145. //
  146. /*
  147. bool
  148. IsIMDeviceStateOn(
  149. PADAPT
  150. )
  151. */
  152. #define IsIMDeviceStateOn(_pP) ((_pP)->MPDeviceState == NdisDeviceStateD0 && (_pP)->PTDeviceState == NdisDeviceStateD0 )
  153. //--------------------------------------------------------------------------------
  154. // //
  155. // New stuff for atmepvc starts here //
  156. // //
  157. // //
  158. //--------------------------------------------------------------------------------
  159. //-----------------------------------------------------------------------------------
  160. // //
  161. // Arp Packet Parsing structs //
  162. // //
  163. //-----------------------------------------------------------------------------------
  164. //
  165. // Len of an Ethernet Header.
  166. //
  167. #define ARP_802_ADDR_LENGTH 6
  168. //
  169. // HwType should be one of the two below.
  170. //
  171. #define ARP_HW_ENET 1
  172. #define ARP_HW_802 6
  173. //
  174. // Ip Address
  175. //
  176. typedef ULONG IP_ADDR;
  177. #define ARP_ETYPE_ARP 0x806
  178. #define ARP_REQUEST 1
  179. #define ARP_RESPONSE 2
  180. #define ARP_HW_ENET 1
  181. #define IP_PROT_TYPE 0x800
  182. //
  183. // As these data structs are used to parse data off the wire.
  184. // make sure it is packed at 1
  185. //
  186. #pragma pack( push, enter_include1, 1 )
  187. //
  188. // The following object is a convenient way to
  189. // store and access an IEEE 48-bit MAC address.
  190. //
  191. typedef struct _MAC_ADDRESS
  192. {
  193. UCHAR Byte[ARP_802_ADDR_LENGTH];
  194. } MAC_ADDRESS, *PMAC_ADDRESS;
  195. //
  196. // Structure of the Ethernet Arp packet. The 14 byte ethernet header is not here.
  197. //
  198. typedef struct _EPVC_ETH_HEADER{
  199. MAC_ADDRESS eh_daddr;
  200. MAC_ADDRESS eh_saddr;
  201. USHORT eh_type;
  202. } EPVC_ETH_HEADER, *PEPVC_ETH_HEADER;
  203. // Structure of an ARP header.
  204. typedef struct _EPVC_ARP_BODY {
  205. USHORT hw; // Hardware address space. = 00 01
  206. USHORT pro; // Protocol address space. = 08 00
  207. UCHAR hlen; // Hardware address length. = 06
  208. UCHAR plen; // Protocol address length. = 04
  209. USHORT opcode; // Opcode.
  210. MAC_ADDRESS SenderHwAddr; // Source HW address.
  211. IP_ADDR SenderIpAddr; // Source protocol address.
  212. MAC_ADDRESS DestHwAddr; // Destination HW address.
  213. IP_ADDR DestIPAddr; // Destination protocol address.
  214. } EPVC_ARP_BODY, *PEPVC_ARP_BODY;
  215. //
  216. // Complete Arp Packet
  217. //
  218. typedef struct _EPVC_ARP_PACKET
  219. {
  220. //
  221. // The first fourteen bytes
  222. //
  223. EPVC_ETH_HEADER Header;
  224. //
  225. // The body of the Arp packets
  226. //
  227. EPVC_ARP_BODY Body;
  228. } EPVC_ARP_PACKET, *PEPVC_ARP_PACKET;
  229. //
  230. // This is the struct that is allocated
  231. // by the Rcv Code path if The Rcv packet
  232. // is to be copied into a local buffer
  233. //
  234. typedef struct _EPVC_IP_RCV_BUFFER
  235. {
  236. //
  237. // The Old Head in the Packet that was indicated
  238. // to our Rcv Handler
  239. //
  240. PNDIS_BUFFER pOldHead;
  241. //
  242. // The Old Tail in the Packet that was indiacated to
  243. // our Rcv Hnadler
  244. //
  245. PNDIS_BUFFER pOldTail;
  246. //
  247. // The actual Ethernet packet is copied into the
  248. // memory below
  249. //
  250. union
  251. {
  252. UCHAR Byte[MAX_ETHERNET_FRAME ];
  253. struct
  254. {
  255. EPVC_ETH_HEADER Eth;
  256. //
  257. // the ip portion of the packet begins here.
  258. //
  259. UCHAR ip[1];
  260. }Pkt;
  261. } u;
  262. } EPVC_IP_RCV_BUFFER, *PEPVC_IP_RCV_BUFFER;
  263. //* IP Header format.
  264. typedef struct IPHeader {
  265. UCHAR iph_verlen; // Version and length.
  266. UCHAR iph_tos; // Type of service.
  267. USHORT iph_length; // Total length of datagram.
  268. USHORT iph_id; // Identification.
  269. USHORT iph_offset; // Flags and fragment offset.
  270. UCHAR iph_ttl; // Time to live.
  271. UCHAR iph_protocol; // Protocol.
  272. USHORT iph_xsum; // Header checksum.
  273. IPAddr iph_src; // Source address.
  274. IPAddr iph_dest; // Destination address.
  275. } IPHeader;
  276. //
  277. // Restore the Pack value to the original
  278. //
  279. #pragma pack( pop, enter_include1 )
  280. //
  281. // The structure all the info required to process
  282. // an arp.
  283. //
  284. typedef struct _EPVC_ARP_CONTEXT
  285. {
  286. //
  287. // Data about the Ndis Packet
  288. //
  289. BOOLEAN fIsThisAnArp ;
  290. BOOLEAN Pad[3];
  291. PNDIS_BUFFER pFirstBuffer ;
  292. //
  293. // Data about the Current Ndis Buffer
  294. //
  295. UINT BufferLength ;
  296. //
  297. // Virtual Addresses'. Pointers to
  298. // the Header and the Body of the
  299. // Arp Pkt
  300. //
  301. PEPVC_ARP_PACKET pArpPkt;
  302. PEPVC_ETH_HEADER pEthHeader ;
  303. PEPVC_ARP_BODY pBody;
  304. }EPVC_ARP_CONTEXT, *PEPVC_ARP_CONTEXT;
  305. //
  306. // This is stored in the Packet Stack and should be of the
  307. // size of 2 Ulong_Ptrs
  308. //
  309. typedef union _EPVC_STACK_CONTEXT
  310. {
  311. struct
  312. {
  313. //
  314. // 1st containing the Buffer
  315. //
  316. PNDIS_BUFFER pOldHeadNdisBuffer;
  317. } ipv4Send;
  318. struct
  319. {
  320. PEPVC_IP_RCV_BUFFER pIpBuffer;
  321. } ipv4Recv;
  322. struct
  323. {
  324. //
  325. // Head and tail of the original packet . Used in recv
  326. //
  327. PNDIS_BUFFER pOldHead;
  328. PNDIS_BUFFER pOldTail;
  329. }EthLLC;
  330. struct
  331. {
  332. //
  333. // Keep track of the last NDIS buffer in original
  334. // chain of buffers in a sent packet, when we pad
  335. // the end of a runt packet.
  336. //
  337. PNDIS_BUFFER pOldLastNdisBuffer;
  338. }EthernetSend;
  339. } EPVC_STACK_CONTEXT, *PEPVC_STACK_CONTEXT;
  340. //
  341. // Protocol reserved part of the packet, only in case the
  342. // packet is allocated by us
  343. //
  344. typedef struct _EPVC_PKT_CONTEXT
  345. {
  346. //
  347. // Contains the miniport and the old ndis buffer
  348. //
  349. EPVC_STACK_CONTEXT Stack;
  350. //
  351. // Original packet which is being repackaged
  352. //
  353. PNDIS_PACKET pOriginalPacket;
  354. }EPVC_PKT_CONTEXT, *PEPVC_PKT_CONTEXT;
  355. //
  356. // This a struct that tracks a send packets
  357. // as it is sent down to physical miniport
  358. //
  359. typedef struct _EPVC_SEND_STRUCT
  360. {
  361. //
  362. // Old Ndis PAcket
  363. //
  364. PNDIS_PACKET pOldPacket;
  365. //
  366. // New Ndis Packet
  367. //
  368. PNDIS_PACKET pNewPacket;
  369. PNDIS_PACKET_STACK pPktStack;
  370. //
  371. // Are we using the Packet Stack
  372. //
  373. BOOLEAN fUsingStacks;
  374. //
  375. // is this an arp packet
  376. //
  377. BOOLEAN fIsThisAnArp;
  378. BOOLEAN fNonUnicastPacket;
  379. BOOLEAN fNotIPv4Pkt;
  380. //
  381. // Old Packet's first NdisBuffer (Head)
  382. //
  383. PNDIS_BUFFER pHeadOldNdisBuffer;
  384. //
  385. // Context to be set up in the packet
  386. //
  387. EPVC_PKT_CONTEXT Context;
  388. //
  389. // EpvcMiniport
  390. //
  391. PEPVC_I_MINIPORT pMiniport;
  392. } EPVC_SEND_STRUCT , *PEPVC_SEND_STRUCT ;
  393. typedef struct _EPVC_SEND_COMPLETE
  394. {
  395. PNDIS_PACKET_STACK pStack;
  396. PNDIS_PACKET pOrigPkt;
  397. PNDIS_PACKET pPacket;
  398. PEPVC_PKT_CONTEXT pPktContext;
  399. BOOLEAN fUsedPktStack ;
  400. PEPVC_STACK_CONTEXT pContext;
  401. } EPVC_SEND_COMPLETE, *PEPVC_SEND_COMPLETE;
  402. typedef struct _EPVC_RCV_STRUCT
  403. {
  404. //
  405. // pPacket that was indicated to us
  406. //
  407. PNDIS_PACKET pPacket;
  408. //
  409. // Packet that was allocated by us
  410. //
  411. PNDIS_PACKET pNewPacket;
  412. //
  413. // Packet STack, if stacks were used
  414. //
  415. PNDIS_PACKET_STACK pStack;
  416. //
  417. // This points to the context for the
  418. // Rcv Indication
  419. //
  420. PEPVC_PKT_CONTEXT pPktContext;
  421. //
  422. // Tells me if stacks were used
  423. //
  424. BOOLEAN fUsedPktStacks;
  425. //
  426. // Tels me if a stack still remains
  427. //
  428. BOOLEAN fRemaining;
  429. //
  430. // Was an LLC header a part of the indicated packet
  431. //
  432. BOOLEAN fLLCHeader;
  433. //
  434. // Old Packet Status
  435. //
  436. NDIS_STATUS OldPacketStatus;
  437. //
  438. // pNew Buffer that is allocated
  439. //
  440. PNDIS_BUFFER pNewBuffer;
  441. //
  442. // Start of valid data within the old packet
  443. //
  444. PUCHAR pStartOfValidData ;
  445. //
  446. // Number of bytes that were copied
  447. //
  448. ULONG BytesCopied;
  449. //
  450. // Contains some ndis buffers and the memory
  451. // where packets will be copied into
  452. //
  453. PEPVC_IP_RCV_BUFFER pIpBuffer;
  454. //
  455. // Local Memory where the rcvd packet
  456. // is copied into . - a part of ip buffer
  457. //
  458. PUCHAR pLocalMemory;
  459. } EPVC_RCV_STRUCT, *PEPVC_RCV_STRUCT;
  460. //--------------------------------------------------------------------------------
  461. // //
  462. // Structures used by the Protocol and miniport //
  463. // These need to declared before the Miniprot and the Protocol Blocks //
  464. // //
  465. //--------------------------------------------------------------------------------
  466. typedef VOID (*REQUEST_COMPLETION)(PEPVC_NDIS_REQUEST, NDIS_STATUS);
  467. // This structure is used when calling NdisRequest.
  468. //
  469. typedef struct _EPVC_NDIS_REQUEST
  470. {
  471. NDIS_REQUEST Request; // The NDIS request structure.
  472. NDIS_EVENT Event; // Event to signal when done.
  473. NDIS_STATUS Status; // Status of completed request.
  474. REQUEST_COMPLETION pFunc; // Completion function
  475. BOOLEAN fPendedRequest ; // Set to true if a pended request caused this request
  476. BOOLEAN fSet; // Was the orig. request a query
  477. USHORT Pad;
  478. PEPVC_I_MINIPORT pMiniport;
  479. } EPVC_NDIS_REQUEST, *PEPVC_NDIS_REQUEST;
  480. //------------------------------------------------------------------------------//
  481. // Structures used to wrap Ndis Wrapper structures //
  482. // //
  483. //------------------------------------------------------------------------------//
  484. //
  485. // The Ndis miniport's wrapper around the Packet Pool
  486. //
  487. typedef struct _EPVC_PACKET_POOL
  488. {
  489. ULONG AllocatedPackets;
  490. NDIS_HANDLE Handle;
  491. } EPVC_PACKET_POOL, *PEPVC_PACKET_POOL;
  492. //
  493. // The structure that defines the lookaside list used by this miniport
  494. //
  495. typedef struct _EPVC_NPAGED_LOOKASIDE_LIST
  496. {
  497. //
  498. // The lookaside list structure
  499. //
  500. NPAGED_LOOKASIDE_LIST List;
  501. //
  502. // The size of an individual buffer
  503. //
  504. ULONG Size;
  505. //
  506. // Outstanding Fragments - Interlocked access only
  507. //
  508. ULONG OutstandingPackets;
  509. //
  510. // Verifies if this lookaside list has been allocated
  511. //
  512. BOOLEAN bIsAllocated;
  513. UCHAR Pad[3];
  514. } EPVC_NPAGED_LOOKASIDE_LIST , *PEPVC_NPAGED_LOOKASIDE_LIST ;
  515. typedef
  516. VOID
  517. (*PEVPC_WORK_ITEM_FUNC)(
  518. PRM_OBJECT_HEADER,
  519. NDIS_STATUS,
  520. PRM_STACK_RECORD
  521. );
  522. typedef union _EPVC_WORK_ITEM_CONTEXT
  523. {
  524. struct
  525. {
  526. //
  527. // Oid for the request
  528. //
  529. NDIS_OID Oid;
  530. //
  531. // Currently the only data is 1 Dword long
  532. //
  533. ULONG Data;
  534. }Request;
  535. }EPVC_WORK_ITEM_CONTEXT, *PEPVC_WORK_ITEM_CONTEXT;
  536. typedef struct _EPVC_WORK_ITEM
  537. {
  538. //
  539. // Normal NdisWork Item - Do not move from
  540. // the top of this structure
  541. //
  542. NDIS_WORK_ITEM WorkItem;
  543. //
  544. // Miniport or Adapter to whom this adapter belongs
  545. //
  546. PRM_OBJECT_HEADER pParentObj;
  547. PEVPC_WORK_ITEM_FUNC pFn;
  548. //
  549. // Status of async task that was completed
  550. //
  551. NDIS_STATUS ReturnStatus;
  552. } EPVC_WORK_ITEM, *PEPVC_WORK_ITEM;
  553. //--------------------------------------------------------------------------------
  554. // //
  555. // Tasks used in the Atmepvc driver //
  556. // //
  557. // //
  558. //--------------------------------------------------------------------------------
  559. typedef enum _TASK_CAUSE
  560. {
  561. TaskCause_Invalid=0,
  562. TaskCause_NdisRequest,
  563. TaskCause_MediaConnect,
  564. TaskCause_MediaDisconnect,
  565. TaskCause_MiniportHalt,
  566. TaskCause_AfNotify,
  567. TaskCause_ProtocolUnbind,
  568. TaskCause_AfCloseRequest,
  569. TaskCause_ProtocolBind,
  570. TaskCause_IncomingClose
  571. } TASK_CAUSE, *PTASK_CAUSE;
  572. typedef struct
  573. {
  574. RM_TASK TskHdr;
  575. // Used to save the true return status (typically a failure status,
  576. // which we don't want to forget during async cleanup).
  577. //
  578. NDIS_STATUS ReturnStatus;
  579. } TASK_ADAPTERINIT, *PTASK_ADAPTERINIT;
  580. typedef struct
  581. {
  582. RM_TASK TskHdr;
  583. } TASK_ADAPTERACTIVATE, *PTASK_ADAPTERACTIVATE;
  584. typedef struct
  585. {
  586. RM_TASK TskHdr;
  587. NDIS_HANDLE pUnbindContext;
  588. TASK_CAUSE Cause;
  589. } TASK_ADAPTERSHUTDOWN, *PTASK_ADAPTERSHUTDOWN;
  590. typedef struct
  591. {
  592. RM_TASK TskHdr;
  593. NDIS_STATUS ReturnStatus;
  594. TASK_CAUSE Cause;
  595. PCO_ADDRESS_FAMILY pAf;
  596. union
  597. {
  598. PNDIS_REQUEST pRequest;
  599. NDIS_EVENT CompleteEvent;
  600. };
  601. } TASK_AF, *PTASK_AF;
  602. typedef struct _TASK_VC
  603. {
  604. RM_TASK TskHdr;
  605. NDIS_STATUS ReturnStatus;
  606. ULONG FailureState;
  607. TASK_CAUSE Cause;
  608. ULONG PacketFilter;
  609. } TASK_VC, *PTASK_VC;
  610. typedef struct _TASK_HALT
  611. {
  612. RM_TASK TskHdr;
  613. NDIS_EVENT CompleteEvent;
  614. }TASK_HALT, *PTASK_HALT;
  615. typedef struct _TASK_ARP
  616. {
  617. //
  618. // Rm Task associated with the Arp
  619. //
  620. RM_TASK TskHdr;
  621. //
  622. // Back pointer to the miniport
  623. //
  624. PEPVC_I_MINIPORT pMiniport;
  625. //
  626. // Timer to fire - this does the receive indication
  627. //
  628. NDIS_MINIPORT_TIMER Timer;
  629. //
  630. // Arp Packet that will be indicated up.
  631. //
  632. EPVC_ARP_PACKET Pkt;
  633. //
  634. // NdisPacket to wrap the ArpPkt
  635. //
  636. PNDIS_PACKET pNdisPacket;
  637. } TASK_ARP, *PTASK_ARP;
  638. //
  639. // EPVC_TASK is the union of all tasks structures used in atmepvc.
  640. // arpAllocateTask allocates memory of sizeof(EPVC_TASK), which is
  641. // guaranteed to be large enough to hold any task.
  642. //
  643. typedef union
  644. {
  645. RM_TASK TskHdr;
  646. TASK_ADAPTERINIT AdapterInit;
  647. TASK_ADAPTERACTIVATE AdapterActivate;
  648. TASK_ADAPTERSHUTDOWN AdapterShutdown;
  649. TASK_AF OpenAf;
  650. TASK_HALT MiniportHalt;
  651. TASK_ARP Arp;
  652. } EPVC_TASK, *PEPVC_TASK;
  653. //--------------------------------------------------------------------------------
  654. // //
  655. // Epvc Adapter block. //
  656. // There is one epvc_adapter per underlying adapter //
  657. // //
  658. //--------------------------------------------------------------------------------
  659. //
  660. // PRIMARY_STATE flags (in Hdr.State)
  661. //
  662. // PRIMARY_STATE is the primary state of the adapter.
  663. //
  664. #define EPVC_AD_PS_MASK 0x00f
  665. #define EPVC_AD_PS_DEINITED 0x000
  666. #define EPVC_AD_PS_INITED 0x001
  667. #define EPVC_AD_PS_FAILEDINIT 0x002
  668. #define EPVC_AD_PS_INITING 0x003
  669. #define EPVC_AD_PS_REINITING 0x004
  670. #define EPVC_AD_PS_DEINITING 0x005
  671. #define SET_AD_PRIMARY_STATE(_pAD, _IfState) \
  672. RM_SET_STATE(_pAD, EPVC_AD_PS_MASK, _IfState)
  673. #define CHECK_AD_PRIMARY_STATE(_pAD, _IfState) \
  674. RM_CHECK_STATE(_pAD, EPVC_AD_PS_MASK, _IfState)
  675. #define GET_AD_PRIMARY_STATE(_pAD) \
  676. RM_GET_STATE(_pAD, EPVC_AD_PS_MASK)
  677. //
  678. // ACTIVE_STATE flags (in Hdr.State)
  679. //
  680. // ACTIVE_STATE is a secondary state of the adapter.
  681. // Primary state takes precedence over secondary sate. For example,
  682. // the interface is REINITING and ACTIVE, one should not actively use the
  683. // interface.
  684. //
  685. // NOTE: When the primary state is INITED, the secondary state WILL be
  686. // ACTIVATED. It is thus usually only necessary to look at the primary state.
  687. //
  688. #define EPVC_AD_AS_MASK 0x0f0
  689. #define EPVC_AD_AS_DEACTIVATED 0x000
  690. #define EPVC_AD_AS_ACTIVATED 0x010
  691. #define EPVC_AD_AS_FAILEDACTIVATE 0x020
  692. #define EPVC_AD_AS_DEACTIVATING 0x030
  693. #define EPVC_AD_AS_ACTIVATING 0x040
  694. #define SET_AD_ACTIVE_STATE(_pAD, _IfState) \
  695. RM_SET_STATE(_pAD, EPVC_AD_AS_MASK, _IfState)
  696. #define CHECK_AD_ACTIVE_STATE(_pAD, _IfState) \
  697. RM_CHECK_STATE(_pAD, EPVC_AD_AS_MASK, _IfState)
  698. #define GET_AD_ACTIVE_STATE(_pAD) \
  699. RM_GET_STATE(_pAD, EPVC_AD_AS_MASK)
  700. #define EPVC_AD_INFO_AD_CLOSED 0X10000000
  701. typedef struct _EPVC_ADAPTER
  702. {
  703. RM_OBJECT_HEADER Hdr; // RM Object header
  704. RM_LOCK Lock; // RM Lock
  705. //
  706. // Flags
  707. //
  708. ULONG Flags;
  709. //
  710. // List of instantiated protocols
  711. //
  712. LIST_ENTRY PtListEntry;
  713. //
  714. // NDIS bind info.
  715. //
  716. struct
  717. {
  718. // Init/Deinit/Reinit task
  719. //
  720. PRM_TASK pPrimaryTask;
  721. // Activate/Deactivate task
  722. //
  723. PRM_TASK pSecondaryTask;
  724. //
  725. // Device Name of the adapter
  726. //
  727. NDIS_STRING DeviceName;
  728. NDIS_HANDLE BindingHandle; // To the lower miniport
  729. //
  730. // Bind Context - used in async completion of
  731. // the bind adapter routine
  732. //
  733. NDIS_HANDLE BindContext;
  734. //
  735. // pConfig Name - Only to be used in the context of the Bind adapter call.
  736. //
  737. PNDIS_STRING pEpvcConfigName;
  738. //
  739. // Copy of the ConfigName
  740. //
  741. NDIS_STRING EpvcConfigName;
  742. //
  743. // Device Name - Name of the underlying adapter
  744. //
  745. PNDIS_STRING pAdapterDeviceName;
  746. } bind;
  747. struct
  748. {
  749. CO_ADDRESS_FAMILY AddressFamily;
  750. }af;
  751. struct
  752. {
  753. //
  754. // Mac Address of the underlying adapter
  755. //
  756. MAC_ADDRESS MacAddress;
  757. //
  758. // Max AAL5 PAcket Size - used in determining Lookahead
  759. //
  760. ULONG MaxAAL5PacketSize;
  761. //
  762. // Link speed of the ATM adapter. We'll use the same link speed
  763. // for the miniport
  764. //
  765. NDIS_CO_LINK_SPEED LinkSpeed;
  766. //
  767. // Number of miniports instatiated by this adapter
  768. //
  769. ULONG NumberOfMiniports;
  770. //
  771. // MEdia State // default disconnected
  772. //
  773. NDIS_MEDIA_STATE MediaState;
  774. }info;
  775. // Group containing local ip addresses, of type EPVC_I_MINIPORT
  776. //
  777. RM_GROUP MiniportsGroup;
  778. }EPVC_ADAPTER, *PEPVC_ADAPTER;
  779. //------------------------------------------------------------------------------------
  780. // //
  781. // The Epvc ADapter Params is used as a constructor for the adapter block //
  782. // It contains all the parameters that are to be initialized in the adapter block //
  783. // //
  784. //------------------------------------------------------------------------------------
  785. typedef struct _EPVC_ADAPTER_PARAMS
  786. {
  787. PNDIS_STRING pDeviceName;
  788. PNDIS_STRING pEpvcConfigName;
  789. NDIS_HANDLE BindContext;
  790. }EPVC_ADAPTER_PARAMS, *PEPVC_ADAPTER_PARAMS;
  791. //------------------------------------------------------------------------------------
  792. // //
  793. // The Epvc Miniports Params is used as a constructor for the miniport block //
  794. // It contains all the parameters that are to be initialized in the miniport block //
  795. // //
  796. //------------------------------------------------------------------------------------
  797. typedef struct _EPVC_I_MINIPORT_PARAMS
  798. {
  799. PNDIS_STRING pDeviceName;
  800. PEPVC_ADAPTER pAdapter;
  801. ULONG CurLookAhead ;
  802. ULONG NumberOfMiniports;
  803. NDIS_CO_LINK_SPEED LinkSpeed;
  804. MAC_ADDRESS MacAddress;
  805. NDIS_MEDIA_STATE MediaState;
  806. }EPVC_I_MINIPORT_PARAMS, *PEPVC_I_MINIPORT_PARAMS ;
  807. //--------------------------------------------------------------------------------
  808. // //
  809. // Epvc Miniport block. //
  810. // //
  811. // There is one Miniport structure for each address family //
  812. // //
  813. //--------------------------------------------------------------------------------
  814. #define fMP_AddressFamilyOpened 0x00000001
  815. #define fMP_DevInstanceInitialized 0x00000010
  816. #define fMP_MiniportInitialized 0x00000020
  817. #define fMP_MiniportCancelInstance 0x00000080
  818. #define fMP_MiniportVcSetup 0x00000100
  819. #define fMP_MakeCallSucceeded 0x00000200
  820. #define fMP_WaitingForHalt 0x00000400
  821. //
  822. // Informational flags
  823. //
  824. #define fMP_InfoClosingCall 0x10000000
  825. #define fMP_InfoCallClosed 0x20000000
  826. #define fMP_InfoMakingCall 0x40000000
  827. #define fMP_InfoHalting 0x80000000
  828. #define fMP_InfoAfClosed 0x01000000
  829. typedef struct _EPVC_I_MINIPORT
  830. {
  831. RM_OBJECT_HEADER Hdr; // RM Object header
  832. RM_LOCK Lock; // RM Lock
  833. PEPVC_ADAPTER pAdapter;
  834. struct
  835. {
  836. //
  837. // Flags of the address family
  838. //
  839. ULONG AfFlags;
  840. //
  841. // Af Handle
  842. //
  843. NDIS_HANDLE AfHandle;
  844. //
  845. // Open/Close Miniport Task
  846. //
  847. PTASK_AF pAfTask;
  848. //
  849. // Close Address Family Workitem
  850. //
  851. EPVC_WORK_ITEM CloseAfWorkItem;
  852. //
  853. // CloseAF RequestTask
  854. //
  855. PTASK_AF pCloseAfTask;
  856. }af;
  857. struct
  858. {
  859. //
  860. // Task used in creating/deleting Vcs and Open/Close Make Calls
  861. //
  862. PTASK_VC pTaskVc;
  863. //
  864. // Vc Handle
  865. //
  866. NDIS_HANDLE VcHandle;
  867. //
  868. // Close Address Family Workitem
  869. //
  870. NDIS_WORK_ITEM PacketFilterWorkItem;
  871. //
  872. // New filter
  873. //
  874. ULONG NewFilter;
  875. //
  876. // Work item for CloseCall and Delete VC
  877. //
  878. EPVC_WORK_ITEM CallVcWorkItem;
  879. } vc;
  880. struct
  881. {
  882. //
  883. // Device Name
  884. //
  885. NDIS_STRING DeviceName;
  886. //
  887. // Ndis' context
  888. //
  889. NDIS_HANDLE MiniportAdapterHandle;
  890. //
  891. // Lookahead size
  892. //
  893. ULONG CurLookAhead;
  894. }ndis;
  895. struct
  896. {
  897. //
  898. // Task to Halt the miniport
  899. //
  900. PTASK_HALT pTaskHalt;
  901. //
  902. // Task to Init the miniport
  903. //
  904. PTASK_HALT pTaskInit;
  905. //
  906. // Halt Complete Event
  907. //
  908. NDIS_EVENT HaltCompleteEvent;
  909. //
  910. // DeInitialize Event used to wait for
  911. // InitializeHandler to compelte in
  912. // the CancelDevInst code path
  913. //
  914. NDIS_EVENT DeInitEvent;
  915. } pnp;
  916. //
  917. // Information used to keep state in the miniport
  918. //
  919. struct
  920. {
  921. //
  922. // Current Packet filter on this miniport instance
  923. //
  924. ULONG PacketFilter;
  925. //
  926. // Media State - Connected or disconnected
  927. //
  928. NDIS_MEDIA_STATE MediaState;
  929. //
  930. // Mac Address of the miniport
  931. //
  932. MAC_ADDRESS MacAddressEth;
  933. //
  934. // Fake Mac Address used in IP encapsulation
  935. //
  936. MAC_ADDRESS MacAddressDummy;
  937. //
  938. // Mac Address destination - used in indicating packets
  939. //
  940. MAC_ADDRESS MacAddressDest;
  941. //
  942. // Size of the header that will be attached to packets that are sent out
  943. // by the miniport
  944. //
  945. ULONG MaxHeaderLength;
  946. //
  947. // # of this miniport
  948. //
  949. ULONG NumberOfMiniports;
  950. //
  951. // Lookahead length
  952. //
  953. ULONG CurLookAhead;
  954. //
  955. // Muticast Info
  956. //
  957. MAC_ADDRESS McastAddrs[MCAST_LIST_SIZE];
  958. //
  959. // Number of MCast addresses present
  960. //
  961. ULONG McastAddrCount;
  962. //
  963. // Link Speed of the ATM adapter. We'll use it for our speed as well
  964. //
  965. ULONG LinkSpeed;
  966. //
  967. // Indicating Receives
  968. //
  969. BOOLEAN IndicateRcvComplete;
  970. }info;
  971. //
  972. // Mac Address of the miniport
  973. //
  974. MAC_ADDRESS MacAddressEth;
  975. //
  976. // Ethernet Header for incoming packets
  977. //
  978. EPVC_ETH_HEADER RcvEnetHeader;
  979. //
  980. // LLC Header, address and length
  981. //
  982. PUCHAR pLllcHeader;
  983. ULONG LlcHeaderLength;
  984. // Minimum length of an incoming packet
  985. //
  986. ULONG MinAcceptablePkt;
  987. // Maximum length of an incoming packet
  988. //
  989. ULONG MaxAcceptablePkt;
  990. struct
  991. {
  992. ULONG vpi;
  993. ULONG vci;
  994. ULONG MaxPacketSize;
  995. USHORT Gap;
  996. } config;
  997. ULONG Encap;
  998. BOOLEAN fAddLLCHeader;
  999. BOOLEAN fDoIpEncapsulation;
  1000. struct
  1001. {
  1002. ULONG FramesXmitOk;
  1003. ULONG FramesRecvOk;
  1004. ULONG RecvDropped;
  1005. }count;
  1006. struct
  1007. {
  1008. //
  1009. // Send and Recv Packet Pools
  1010. //
  1011. EPVC_PACKET_POOL Send;
  1012. EPVC_PACKET_POOL Recv;
  1013. } PktPool;
  1014. struct
  1015. {
  1016. EPVC_NPAGED_LOOKASIDE_LIST LookasideList;
  1017. PTASK_ARP pTask;
  1018. } arps;
  1019. struct
  1020. {
  1021. EPVC_NPAGED_LOOKASIDE_LIST LookasideList;
  1022. } rcv;
  1023. // This maintains miniport-wide information relevant to the send path.
  1024. //
  1025. struct
  1026. {
  1027. // Lock used exclusively for sending.
  1028. // Protects the following:
  1029. // ??? this->sendinfo.listPktsWaitingForHeaders
  1030. // ??? this->sendinfo.NumSendPacketsWaiting
  1031. // pLocalIp->sendinfo
  1032. // pDest->sendinfo
  1033. //
  1034. //
  1035. RM_LOCK Lock;
  1036. // List of send packets waiting for header buffers to become available.
  1037. //
  1038. LIST_ENTRY listPktsWaitingForHeaders;
  1039. // Length of the above list
  1040. //
  1041. UINT NumSendPacketsWaiting;
  1042. } sendinfo;
  1043. #if 0
  1044. //
  1045. // Temporary stuff
  1046. //
  1047. NDIS_HANDLE SendPacketPoolHandle;
  1048. NDIS_HANDLE RecvPacketPoolHandle;
  1049. NDIS_STATUS Status; // Open Status
  1050. NDIS_EVENT Event; // Used by bind/halt for Open/Close Adapter synch.
  1051. NDIS_MEDIUM Medium;
  1052. NDIS_REQUEST Request; // This is used to wrap a request coming down
  1053. // to us. This exploits the fact that requests
  1054. // are serialized down to us.
  1055. PULONG BytesNeeded;
  1056. PULONG BytesReadOrWritten;
  1057. BOOLEAN IndicateRcvComplete;
  1058. BOOLEAN OutstandingRequests; //True - if a request has been passed to the miniport below the IM protocol
  1059. BOOLEAN QueuedRequest; //True - if a request is queued with the IM miniport and needs to be either
  1060. // failed or sent to the miniport below the IM Protocol
  1061. BOOLEAN StandingBy; // True - When the miniport or protocol is transitioning from a D0 to Standby (>D0) State
  1062. // False - At all other times, - Flag is cleared after a transition to D0
  1063. NDIS_DEVICE_POWER_STATE MPDeviceState; // Miniport's Device State
  1064. NDIS_DEVICE_POWER_STATE PTDeviceState; // Protocol's Device State
  1065. BOOLEAN isSecondary; // Set if miniport is secondary of a bundle
  1066. NDIS_STRING BundleUniString; // Strores the bundleid
  1067. PADAPT pPrimaryAdapt; // Pointer to the primary
  1068. PADAPT pSecondaryAdapt; // Pointer to Secondary's structure
  1069. KSPIN_LOCK SpinLock; // Spin Lock to protect the global list
  1070. PADAPT Next;
  1071. #endif
  1072. }EPVC_I_MINIPORT, *PEPVC_I_MINIPORT;
  1073. //--------------------------------------------------------------------------------
  1074. // //
  1075. // Epvc Global Block. //
  1076. // //
  1077. // //
  1078. //--------------------------------------------------------------------------------
  1079. typedef struct _EPVC_GLOBALS
  1080. {
  1081. RM_OBJECT_HEADER Hdr;
  1082. RM_LOCK Lock;
  1083. // Driver global state
  1084. //
  1085. struct
  1086. {
  1087. // Handle to Driver Object for ATMEPVC
  1088. //
  1089. PVOID pDriverObject;
  1090. // Handle to the single device object representing this driver.
  1091. //
  1092. PVOID pDeviceObject;
  1093. //
  1094. // Registry path
  1095. //
  1096. PUNICODE_STRING pRegistryPath;
  1097. //
  1098. // Wrapper Handle
  1099. //
  1100. NDIS_HANDLE WrapperHandle;
  1101. //
  1102. // Protocol Handle
  1103. //
  1104. NDIS_HANDLE ProtocolHandle;
  1105. //
  1106. // Driver Handle
  1107. //
  1108. NDIS_HANDLE DriverHandle;
  1109. } driver;
  1110. struct
  1111. {
  1112. RM_GROUP Group;
  1113. } adapters;
  1114. struct
  1115. {
  1116. NDIS_CLIENT_CHARACTERISTICS CC;
  1117. }ndis;
  1118. } EPVC_GLOBALS, *PEPVC_GLOBALS;
  1119. //--------------------------------------------------------------------------------
  1120. // //
  1121. // Enumerated types . //
  1122. // //
  1123. // //
  1124. //--------------------------------------------------------------------------------
  1125. //
  1126. // This is an enumeration that is used in acquiring locks in a particular order.
  1127. // If lock A needs to be acquired before lock B, this enumeration will enforce the
  1128. // order
  1129. //
  1130. enum
  1131. {
  1132. LOCKLEVEL_GLOBAL=1, // Must start > 0.
  1133. LOCKLEVEL_ADAPTER,
  1134. LOCKLEVEL_MINIPORT,
  1135. LOCKLEVEL_SEND
  1136. };
  1137. // (debug only) Enumeration of types of associations.
  1138. //
  1139. enum
  1140. {
  1141. EPVC_ASSOC_AD_PRIMARY_TASK,
  1142. EPVC_ASSOC_ACTDEACT_AD_TASK,
  1143. EPVC_ASSOC_MINIPORT_OPEN_VC,
  1144. EPVC_ASSOC_MINIPORT_OPEN_AF,
  1145. EPVC_ASSOC_MINIPORT_ADAPTER_HANDLE,
  1146. EPVC_ASSOC_ADAPTER_MEDIA_WORKITEM,
  1147. EPVC_ASSOC_EXTLINK_PKT_TO_SEND,
  1148. EPVC_ASSOC_CLOSE_AF_WORKITEM,
  1149. EPVC_ASSOC_SET_FILTER_WORKITEM,
  1150. EPVC_ASSOC_EXTLINK_INDICATED_PKT,
  1151. EPVC_ASSOC_WORKITEM,
  1152. EPVC_ASSOC_MINIPORT_REQUEST
  1153. };
  1154. enum
  1155. {
  1156. IPV4_ENCAP_TYPE,
  1157. IPV4_LLC_SNAP_ENCAP_TYPE,
  1158. ETHERNET_ENCAP_TYPE,
  1159. ETHERNET_LLC_SNAP_ENCAP_TYPE
  1160. };
  1161. //--------------------------------------------------------------------------------
  1162. // //
  1163. // WorkItems //
  1164. // //
  1165. // //
  1166. //--------------------------------------------------------------------------------
  1167. typedef struct _EPVC_WORKITEM_MEDIA_EVENT
  1168. {
  1169. NDIS_WORK_ITEM WorkItem;
  1170. NDIS_STATUS State;
  1171. PEPVC_ADAPTER pAdapter;
  1172. }EPVC_WORKITEM_MEDIA_EVENT, *PEPVC_WORKITEM_MEDIA_EVENT;
  1173. typedef union
  1174. {
  1175. NDIS_WORK_ITEM WorkItem;
  1176. EPVC_WORKITEM_MEDIA_EVENT Media;
  1177. } EPVC_WORKITEM, *PEPVC_WORKITEM;
  1178. //
  1179. // Local declarations for reading the registry
  1180. //
  1181. typedef struct _MP_REG_ENTRY
  1182. {
  1183. NDIS_STRING RegName; // variable name text
  1184. BOOLEAN bRequired; // 1 -> required, 0 -> optional
  1185. UINT FieldOffset; // offset to MP_ADAPTER field
  1186. UINT FieldSize; // size (in bytes) of the field
  1187. UINT Default; // default value to use
  1188. UINT Min; // minimum value allowed
  1189. UINT Max; // maximum value allowed
  1190. } MP_REG_ENTRY, *PMP_REG_ENTRY;
  1191. #define NIC_NUM_REG_PARAMS (sizeof (NICRegTable) / sizeof(MP_REG_ENTRY))
  1192. #endif // _PRIV_H