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.

3738 lines
98 KiB

  1. // Copyright (c) 1998-1999, Microsoft Corporation, all rights reserved
  2. //
  3. // priv.h
  4. //
  5. // IEEE 1394 NDIS mini-port/call-manager driver
  6. //
  7. // Main private header
  8. //
  9. // 12/28/1998 JosephJ Created (adapted from the l2tp project)
  10. //
  11. //
  12. //-----------------------------------------------------------------------------
  13. // Constants
  14. //-----------------------------------------------------------------------------
  15. extern ULONG g_IsochTag;
  16. extern LONG g_ulMedium;
  17. extern ULONGLONG g_ullOne;
  18. //
  19. // Add checks for #defines that are meant for special purposes and
  20. // should not be turned on for general use
  21. //
  22. #ifdef PKT_LOG
  23. #error
  24. #endif
  25. //-----------------------------------------------------------------------------
  26. // Advance Declarations and simple typedefs
  27. //-----------------------------------------------------------------------------
  28. // Forward declarations.
  29. //
  30. typedef union _VCCB VCCB;
  31. typedef struct _ADAPTERCB ADAPTERCB, *PADAPTERCB;
  32. typedef struct _RECVFIFO_VCCB RECVFIFO_VCCB, *PRECVFIFO_VCCB;
  33. typedef struct _ETHERNET_VCCB ETHERNET_VCCB, *PETHERNET_VCCB;
  34. typedef struct _RECV_FIFO_DATA RECV_FIFO_DATA, *PRECV_FIFO_DATA;
  35. typedef struct _ISOCH_DESCRIPTOR ISOCH_DESCRIPTOR, *PISOCH_DESCRIPTOR, **PPISOCH_DESCRIPTOR;
  36. typedef struct _TOPOLOGY_MAP TOPOLOGY_MAP, *PTOPOLOGY_MAP, **PPTOPOLOGY_MAP;
  37. typedef struct _CHANNEL_VCCB CHANNEL_VCCB, *PCHANNEL_VCCB;
  38. typedef struct _GASP_HEADER GASP_HEADER;
  39. typedef struct _NDIS1394_FRAGMENT_HEADER NDIS1394_FRAGMENT_HEADER, *PNDIS1394_FRAGMENT_HEADER;
  40. typedef struct _NDIS1394_REASSEMBLY_STRUCTURE NDIS1394_REASSEMBLY_STRUCTURE, *PNDIS1394_REASSEMBLY_STRUCTURE;
  41. typedef struct _REMOTE_NODE REMOTE_NODE, *PREMOTE_NODE;
  42. typedef union _NDIS1394_UNFRAGMENTED_HEADER NDIS1394_UNFRAGMENTED_HEADER, *PNDIS1394_UNFRAGMENTED_HEADER;
  43. typedef union _NIC_WORK_ITEM NIC_WORK_ITEM, *PNIC_WORK_ITEM;
  44. #define NIC1394_STATUS_INVALID_GENERATION ((NDIS_STATUS)STATUS_INVALID_GENERATION)
  45. //-----------------------------------------------------------------------------
  46. // Data types
  47. //-----------------------------------------------------------------------------
  48. //
  49. // This is a table of the Remote nodes and it is used to keep a track of the number of nodes
  50. // on the bus. To stop overflows, yhis structure is usally accessed by
  51. // NODE_ADDRESS.NA_Node_Number which is a 6 bit entity.
  52. //
  53. typedef struct _NODE_TABLE
  54. {
  55. PREMOTE_NODE RemoteNode[NIC1394_MAX_NUMBER_NODES];
  56. } NODE_TABLE, *PNODE_TABLE;
  57. typedef struct _GASP_HEADER
  58. {
  59. union
  60. {
  61. //
  62. // Ist Quadlet
  63. //
  64. struct
  65. {
  66. ULONG GH_Specifier_ID_Hi:16;
  67. ULONG GH_Source_ID:16;
  68. } Bitmap;
  69. struct
  70. {
  71. USHORT GH_Specifier_ID_Hi;
  72. USHORT GH_Source_ID;
  73. } u;
  74. struct
  75. {
  76. USHORT GH_Specifier_ID_Hi;
  77. NODE_ADDRESS GH_NodeAddress;
  78. } u1;
  79. ULONG GaspHeaderHigh;
  80. } FirstQuadlet;
  81. union
  82. {
  83. struct
  84. {
  85. ULONG GH_Version:24; // Bits 0-23
  86. ULONG GH_Specifier_ID_Lo:8; //Bits 24-31
  87. } Bitmap;
  88. ULONG GaspHeaderLow;
  89. } SecondQuadlet;
  90. } GASP_HEADER, *PGASP_HEADER;
  91. //
  92. // The Ndis miniport's wrapper around the Packet Pool
  93. //
  94. typedef struct _NIC_PACKET_POOL
  95. {
  96. ULONG AllocatedPackets;
  97. NDIS_HANDLE Handle;
  98. } NIC_PACKET_POOL, *PNIC_PACKET_POOL;
  99. //
  100. // The Ndis miniport's wrapper around the Packet Pool
  101. //
  102. typedef struct _NIC_BUFFER_POOL
  103. {
  104. ULONG AllocatedBuffers;
  105. NDIS_HANDLE Handle;
  106. } NIC_BUFFER_POOL, *PNIC_BUFFER_POOL;
  107. //
  108. // The structure that defines the lookaside list used by this miniport
  109. //
  110. typedef struct _NIC_NPAGED_LOOKASIDE_LIST
  111. {
  112. //
  113. // The lookaside list structure
  114. //
  115. NPAGED_LOOKASIDE_LIST List;
  116. //
  117. // The size of an individual buffer
  118. //
  119. ULONG Size;
  120. //
  121. // Outstanding Fragments - Interlocked access only
  122. //
  123. ULONG OutstandingPackets;
  124. //
  125. // Lookaside Lists are used for sends. So this is a maximum
  126. // send packet size that this lookaside list can handle
  127. //
  128. ULONG MaxSendSize;
  129. } NIC_NPAGED_LOOKASIDE_LIST , *PNIC_NPAGED_LOOKASIDE_LIST ;
  130. //
  131. // Structure used for references, Adapted from Ndis
  132. // The Event will be signalled when the refcount goes down to zero
  133. // The filed closing signifies that the object that the reference belongs to is
  134. // closing and it;s refernces will not be incremented anymore
  135. //
  136. typedef struct _REF
  137. {
  138. // NDIS_SPIN_LOCK SpinLock;
  139. ULONG ReferenceCount;
  140. BOOLEAN Closing;
  141. NDIS_EVENT RefZeroEvent;
  142. } REF, * PREF;
  143. typedef enum _EVENT_CODE
  144. {
  145. Nic1394EventCode_InvalidEventCode,
  146. Nic1394EventCode_NewNodeArrived,
  147. nic1394EventCode_BusReset,
  148. nic1394EventCode_FreedAddressRange,
  149. nic1394EventCode_ReassemblyTimerComplete,
  150. nic1394EventCode_QueryPowerLowPower
  151. } EVENT_CODE, *PEVENT_CODE;
  152. typedef struct _NIC1394_EVENT
  153. {
  154. NDIS_EVENT NdisEvent;
  155. EVENT_CODE EventCode;
  156. } NIC1394_EVENT, *PNIC1394_EVENT;
  157. typedef ENetAddr MAC_ADDRESS, *PMAC_ADDRESS;
  158. //
  159. // nic Spin lock structure. Keeps track of the file and line numer
  160. // that last touched the lock
  161. //
  162. #define LOCK_FILE_NAME_LEN 48
  163. typedef struct _NIC_SPIN_LOCK
  164. {
  165. #ifdef TRACK_LOCKS
  166. ULONG IsAcquired; // Internal tracking of lock state
  167. PKTHREAD OwnerThread; // thread that has the lock
  168. UCHAR TouchedByFileName[LOCK_FILE_NAME_LEN]; // File name which called Acquire Lock
  169. ULONG TouchedInLineNumber; // Line Number in the file
  170. #endif
  171. NDIS_SPIN_LOCK NdisLock; // Actual Lock
  172. } NIC_SPIN_LOCK, *PNIC_SPIN_LOCK;
  173. //
  174. // Statistics Structure - to be collected on a per adapter basis
  175. //
  176. typedef struct _NIC_SEND_RECV_STATS
  177. {
  178. ULONG ulSendNicSucess;
  179. ULONG ulSendBusSuccess;
  180. ULONG ulSendBusFail;
  181. ULONG ulSendNicFail;
  182. ULONG ulRecv;
  183. } NIC_SEND_RECV_STATS;
  184. //
  185. // These are stats that can be reset
  186. //
  187. typedef struct _RESETTABLE_STATS
  188. {
  189. ULONG ulNumOutstandingReassemblies;
  190. ULONG ulMaxOutstandingReassemblies;
  191. ULONG ulAbortedReassemblies;
  192. ULONG ulNumResetsIssued ;
  193. ULONG ulNumSends;
  194. ULONG ulNumSendsCompleted;
  195. ULONG ulNumBusSends;
  196. ULONG ulNumBusSendsCompleted;
  197. NIC_SEND_RECV_STATS Fifo;
  198. NIC_SEND_RECV_STATS Channel;
  199. } RESETTABLE_STATS, *PRESETTABLE_STATS;
  200. typedef struct _ADAPT_STATS
  201. {
  202. ULONG ulXmitOk;
  203. ULONG ulXmitError ;
  204. ULONG ulRcvOk ;
  205. ULONG ulRcvError ;
  206. ULONG ulNumResetsIssued ;
  207. ULONG ulNumResetCallbacks ;
  208. ULONG ulBCMIterations ;
  209. ULONG ulNumRemoteNodes;
  210. ULONG ulResetTime;
  211. RESETTABLE_STATS TempStats;
  212. } ADAPT_STATS, *PADAPT_STATS;
  213. //
  214. // Can be used to keep data in buckets of 10
  215. //
  216. typedef struct _STAT_BUCKET
  217. {
  218. ULONG Bucket[16];
  219. } STAT_BUCKET, *PSTAT_BUCKET;
  220. //
  221. // Generic structure to be used to serialize send and receives, workitems
  222. //
  223. typedef struct _NIC_SERIALIZATION
  224. {
  225. UINT PktsInQueue; // Number of packets in queue.
  226. BOOLEAN bTimerAlreadySet;
  227. BOOLEAN bInitialized;
  228. USHORT usPad;
  229. LIST_ENTRY Queue; // Serialized by adapter lock.
  230. union {
  231. NDIS_MINIPORT_TIMER Timer;
  232. NDIS_WORK_ITEM WorkItem;
  233. };
  234. NIC1394_EVENT CompleteEvent;
  235. } NIC_SERIALIZATION, *PNIC_SERIALIZATION;
  236. //
  237. // Each request to allocate and address range
  238. // returns certain values that need to be stored for the
  239. // request to free the address range. This structure contains
  240. // those values
  241. //
  242. typedef struct _ADDRESS_RANGE_CONTEXT
  243. {
  244. //
  245. // Handle returned by the bus driver
  246. //
  247. HANDLE hAddressRange;
  248. //
  249. // Address Range returnded by the bus driver
  250. //
  251. ADDRESS_RANGE AddressRange;
  252. //
  253. // Number of Address returned from the call to
  254. // allocate address range
  255. //
  256. ULONG AddressesReturned;
  257. //
  258. // Mdl used in allocate address range . can be NULL
  259. //
  260. PMDL pMdl;
  261. } ADDRESS_RANGE_CONTEXT, *PADDRESS_RANGE_CONTEXT;
  262. // This structure is the Per Pdo/ per RecvFIFOVc structure.
  263. // This will be included in every Pdo Strcuture. And should contain
  264. // the fields that are related to the recvFifo and the Pdo block
  265. //
  266. typedef struct _RECV_FIFO_DATA
  267. {
  268. //
  269. // Indicates whether the address range was allocated regardless of the Make
  270. // Call State (pending or success)
  271. //
  272. BOOLEAN AllocatedAddressRange;
  273. //
  274. // Recv Vc's related data structures
  275. //
  276. ADDRESS_RANGE VcAddressRange;
  277. // The Bus Driver's Handle to the Address ranges that
  278. // the Nic was allocated
  279. //
  280. HANDLE hAddressRange;
  281. // This is the number of address ranges that the bus driver
  282. // returned. For now, it is expected to be one.
  283. //
  284. UINT AddressesReturned;
  285. // The Recv Fifo Vc that this structure is associated with
  286. //
  287. PRECVFIFO_VCCB pRecvFIFOVc;
  288. // The Pdo Associated with this structure
  289. //
  290. //DEVICE_OBJECT *pPdo;
  291. } RECV_FIFO_DATA, *PRECV_FIFO_DATA;
  292. //
  293. // Flags for the Broadcast Channel
  294. //
  295. #define BCR_LocalHostIsIRM 0x00000001
  296. #define BCR_ChannelAllocated 0x00000002
  297. #define BCR_LocalHostBCRUpdated 0x00000004
  298. #define BCR_MakeCallPending 0x00000008
  299. #define BCR_Initialized 0x00000010
  300. #define BCR_BCMFailed 0x00000020 // Informational purposes only . Do not Test or REad
  301. #define BCR_InformingRemoteNodes 0x00000040
  302. #define BCR_BCMInProgress 0x00000100
  303. #define BCR_LastNodeRemoved 0x00000200
  304. #define BCR_Freed 0x00000400
  305. #define BCR_BCRNeedsToBeFreed 0x00000800
  306. #define BCR_NewNodeArrived 0x00001000
  307. #define BCR_NoNodesPresent 0x00002000
  308. //
  309. // This is information useful in maintaining the BCR
  310. // Broadcast Channels Register.
  311. //
  312. typedef struct _BROADCAST_CHANNEL_DATA
  313. {
  314. //
  315. // Flags
  316. //
  317. ULONG Flags;
  318. //
  319. // IRM;s BCR. This is the actual record of the bus's IRM. And is meant to indicate the current state
  320. //
  321. NETWORK_CHANNELSR IRM_BCR;
  322. //
  323. // Broadcast Channels Register for the local host. This is the one a remote node will write to and read from
  324. // pLocalBcRMdl points to this structure . This is Byteswapped to reppresent the BigEndian 1394 Bus Format
  325. //
  326. ULONG LocalHostBCRBigEndian;
  327. //
  328. // Mdl pointing to Local Host BCR. Other machines will write to this MDL.
  329. //
  330. PMDL pLocalBCRMdl;
  331. //
  332. // Data pointed to by the pRemoteBCRMdl and will copied to IRM_BCR. The data that will be read will
  333. // be in the BigEndian format Pointed to by RemoteBCRMDl
  334. //
  335. ULONG RemoteBCRMdlData;
  336. //
  337. // MDL pointing to Remote Nodes' BCR. This will be used in reading other machine's
  338. // BCR. This points to the RemoteBCRMdlData
  339. //
  340. PMDL pRemoteBCRMdl;
  341. //
  342. // Make a copy of the BCR that is used in informing other nodes
  343. // about this node's BCR when the local node is the IRM
  344. //
  345. ULONG AsyncWriteBCRBigEndian;
  346. PMDL pAsyncWriteBCRMdl;
  347. //
  348. // Local Node Address. This changes from Reset to Reset
  349. //
  350. NODE_ADDRESS LocalNodeAddress;
  351. ULONG LocalNodeNumber;
  352. //
  353. // Address Range Context needed for Broadcast Channels
  354. // Register
  355. //
  356. ADDRESS_RANGE_CONTEXT AddressRangeContext;
  357. //
  358. // Topology Buffer
  359. //
  360. PTOPOLOGY_MAP pTopologyMap;
  361. //
  362. // Event that the Make call will pend on for completion of the BCM
  363. //
  364. NIC1394_EVENT MakeCallWaitEvent;
  365. //
  366. // BoadcastChannelVc
  367. //
  368. PCHANNEL_VCCB pBroadcastChanneVc;
  369. //
  370. // Locally Allocated Channel Num. Is only valid when the
  371. //
  372. ULONG LocallyAllocatedChannel;
  373. //
  374. // The Generation at which the IRM was set. This can then be used to check the
  375. // validity of the IRM
  376. ULONG IrmGeneration;
  377. //
  378. // Event To specify that a new node has come in and waiting threads can continue
  379. //
  380. NIC1394_EVENT BCRWaitForNewRemoteNode;
  381. //
  382. // Event to synchronize the shutting down of the adapter and freeing the address range
  383. //
  384. NIC1394_EVENT BCRFreeAddressRange;
  385. } BROADCAST_CHANNEL_DATA, *PBROADCAST_CHANNEL_DATA;
  386. //
  387. // Flags for the PDO Control Block
  388. //
  389. #define PDO_NotValid 0x00000001
  390. #define PDO_Activated 0x00000002
  391. #define PDO_Removed 0x00000004
  392. #define PDO_BeingRemoved 0x00000008
  393. #define PDO_AllocateAddressRangeFailure 0x00000010
  394. #define PDO_AllocateAddressRangeSucceeded 0x00000020
  395. #define PDO_AddressRangeFreed 0x00000040
  396. #define PDO_AllocateAddressRangeFlags 0x000000F0
  397. #define PDO_ResetRegistered 0x00000100
  398. #define PDO_NotInsertedInTable 0x00000200 // Informational purposes
  399. typedef struct
  400. _REMOTE_NODE
  401. {
  402. // The Tag should MTAG_REMOTE_NODE
  403. //
  404. ULONG ulTag;
  405. //
  406. // The Vurrent Node Address
  407. //
  408. NODE_ADDRESS RemoteAddress;
  409. //
  410. // Ushort Gap
  411. //
  412. USHORT Gap;
  413. // The PDO itself
  414. //
  415. PDEVICE_OBJECT pPdo;
  416. // This is the pointer to the next field in the PDO
  417. //
  418. LIST_ENTRY linkPdo;
  419. // 64 bit Unique Id associated with a 1394 Node
  420. //
  421. UINT64 UniqueId;
  422. //
  423. // Enum1394 handle for the node
  424. //
  425. PVOID Enum1394NodeHandle;
  426. // flags can be one of the following. Essentially marks the PDO as
  427. // good or bad
  428. //
  429. ULONG ulFlags;
  430. // Back link to the Adapter that PDO hangs off
  431. //
  432. PADAPTERCB pAdapter;
  433. // The refcount associated with the Pdo
  434. //
  435. REF Ref;
  436. // This is the linked list of VCs, that are using the Pdo to preform
  437. //
  438. LIST_ENTRY VcList;
  439. // All the fields that are related to the Recv Fifo are present in this
  440. // structure
  441. //
  442. RECV_FIFO_DATA RecvFIFOData;
  443. //
  444. // Lock to synchronize all the reassembly operations in the Node
  445. //
  446. NIC_SPIN_LOCK ReassemblyLock;
  447. //
  448. // Linked list of Reassembly Structure
  449. //
  450. LIST_ENTRY ReassemblyList;
  451. // This structure maintains cached information about the remote node.
  452. //
  453. struct
  454. {
  455. UINT SpeedTo; // From GetMaxSpeedBetweenNodes.
  456. UINT MaxRec; // From the node's config ROM.
  457. UINT EffectiveMaxBufferSize; // Computed from the SpeedTo, MaxRec,
  458. // and local speed.
  459. } CachedCaps;
  460. //
  461. // Ethernet Address - to be used by the bridge to recognize packets
  462. // originating from this node. An MD5 Signature of the Euid
  463. //
  464. ENetAddr ENetAddress;
  465. }
  466. REMOTE_NODE, *PREMOTE_NODE, **PPREMOTE_NODE;
  467. //
  468. // These flags are common to the Adapter
  469. //
  470. //
  471. //fADAPTER_IndicatedMediaDisonnect - indicateds that the miniport has already
  472. // called NdisMIndicateStatus
  473. //
  474. #define fADAPTER_Halting 0x00000001
  475. #define fADAPTER_RegisteredWithEnumerator 0x00000002
  476. #define fADAPTER_FailedRegisteration 0x00000004
  477. #define fADAPTER_IndicatedMediaDisonnect 0x00000008
  478. #define fADAPTER_InvalidGenerationCount 0x00000010
  479. //#define fADAPTER_BCMWorkItem 0x00000020
  480. #define fADAPTER_RegisteredAF 0x00000040
  481. #define fADAPTER_Reset10Sec 0x00000080
  482. #define fADAPTER_FailedInit 0x00000100
  483. #define fADAPTER_VDOInactive 0x00000200
  484. #define fADAPTER_FreedRcvTimers 0x00001000 // debugging purposes
  485. #define fADAPTER_FreedTimers 0x00002000 // debugging purposes
  486. #define fADAPTER_DeletedLookasideLists 0x00004000 // debugging purposes
  487. #define fADAPTER_UpdateNodeTable 0x00008000 // set if no remote node for reassembly
  488. #define fADAPTER_DoStatusIndications 0x00010000 // if set, call NdisMIndicateStatus
  489. #define fADAPTER_DeletedWorkItems 0x00100000 // debugging purposes
  490. #define fADAPTER_NoMoreReassembly 0x00200000
  491. #define fADAPTER_RemoteNodeInThisBoot 0x00400000 //was a remote node in this boot
  492. #define fADAPTER_BridgeMode 0x00800000 // is the Adapter in bridge mode
  493. #define fADAPTER_LowPowerState 0x01000000 // adapter is in low power state
  494. // Adapter control block defining the state of a single L2TP mini-port
  495. // adapter. An adapter commonly supports multiple VPN devices. Adapter
  496. // blocks are allocated in MiniportInitialize and deallocated in MiniportHalt.
  497. //
  498. typedef struct
  499. _ADAPTERCB
  500. {
  501. // Set to MTAG_ADAPTERCB for easy identification in memory dumps and use
  502. // in assertions.
  503. //
  504. ULONG ulTag;
  505. // Next/prev adapter control block.
  506. LIST_ENTRY linkAdapter;
  507. // ACBF_* bit flags indicating various options. Access restrictions are
  508. // indicated for each individual flag. Many of these flags are set
  509. // permanently at initialization and so have no access limitation.
  510. //
  511. //
  512. ULONG ulFlags;
  513. //
  514. // List of PDO control blocks, each representing a remote
  515. // device.
  516. //
  517. LIST_ENTRY PDOList;
  518. //
  519. // Reference count on this control block. The reference pairs are:
  520. //
  521. //
  522. // Access is via ReferenceAdapter and DereferenceAdapter only.
  523. // Serialization is via interlocked operations.
  524. //
  525. LONG lRef;
  526. //
  527. // This is the adapter-wide lock, serializing access to everything except
  528. // to the contents of VCs, which are serialized by their own lock.
  529. //
  530. NDIS_SPIN_LOCK lock;
  531. //
  532. // Generation Count of the physical Bus 1394
  533. //
  534. UINT Generation;
  535. //
  536. // NDIS's handle for this mini-port adapter passed to us in
  537. // MiniportInitialize. This is passed back to various NdisXxx calls.
  538. //
  539. NDIS_HANDLE MiniportAdapterHandle;
  540. //
  541. // unique ID for the local host controller this adapter is representing
  542. //
  543. UINT64 UniqueId;
  544. //
  545. // List of address-family control blocks, each representing
  546. // an open address family binding.
  547. //
  548. LIST_ENTRY AFList;
  549. //
  550. // List of Recv-FIFO control blocks, each representing one
  551. // local receive FIFO.
  552. //
  553. PRECVFIFO_VCCB pRecvFIFOVc;
  554. //
  555. // This event is used to wake up the work Item that will complete
  556. // the RecvFIFO make call
  557. //
  558. NDIS_EVENT RecvFIFOEvent;
  559. //
  560. // The is the LocalHost information that is used in identifying
  561. // the local host. This contains the PDO and the Unique ID
  562. // for the Host and is a per Adapter quantity
  563. //
  564. PDEVICE_OBJECT pNextDeviceObject;
  565. // Stores information about the Hardware Status of the NIc
  566. //
  567. NDIS_HARDWARE_STATUS HardwareStatus;
  568. // Store the MediaConnectStatus that Ndis requests
  569. //
  570. NDIS_MEDIA_STATE MediaConnectStatus;
  571. // NodeAddress of the physical bus
  572. //
  573. NODE_ADDRESS NodeAddress;
  574. //
  575. // enum1394 handle for the adapter
  576. //
  577. PVOID EnumAdapterHandle;
  578. //
  579. // BCR Related Information is stored here
  580. //
  581. BROADCAST_CHANNEL_DATA BCRData;
  582. //
  583. // Bitmap Channnels allocated by this adapter
  584. //
  585. ULONGLONG ChannelsAllocatedByLocalHost;
  586. //
  587. // Speed - of the local network
  588. //
  589. ULONG SpeedMbps;
  590. //
  591. // Speed according to the 1394 speed codes
  592. //
  593. ULONG Speed;
  594. //
  595. // Gasp header that will bew inserted before every Broadcast write
  596. //
  597. GASP_HEADER GaspHeader;
  598. //
  599. // Lookaside List to handle packets of 2k
  600. //
  601. NIC_NPAGED_LOOKASIDE_LIST SendLookasideList2K;
  602. //
  603. // Small Lookaside list for packets less than 100 bytes
  604. //
  605. NIC_NPAGED_LOOKASIDE_LIST SendLookasideList100;
  606. //
  607. // Datagram Label Number - used in fragmentation
  608. //
  609. ULONG dgl;
  610. USHORT MaxRec;
  611. USHORT Gap;
  612. //
  613. // Node Table - Mapping of Node Address with RemoteNodes
  614. //
  615. NODE_TABLE NodeTable;
  616. //
  617. // Number of remote nodes present
  618. //
  619. ULONG NumRemoteNodes;
  620. //
  621. // Timer used for reassembly invalidation
  622. //
  623. NDIS_MINIPORT_TIMER ReassemblyTimer;
  624. //
  625. // Packet pool for loopback packets.
  626. //
  627. NIC_PACKET_POOL LoopbackPool;
  628. //
  629. // Buffer pool for loopback packets.
  630. //
  631. NDIS_HANDLE LoopbackBufferPool;
  632. //
  633. // Handle for the config rom that was added to the bus driver
  634. //
  635. HANDLE hCromData;
  636. //
  637. // WaitForRemoteNode - threads which need to wait for
  638. // the arrival of a remote node use this event
  639. //
  640. NIC1394_EVENT WaitForRemoteNode;
  641. //
  642. // Config Rom Mdl that points to the config rom string
  643. //
  644. PMDL pConfigRomMdl;
  645. PREMOTE_NODE pLastRemoteNode;
  646. //
  647. // Packet Log (used only for tracking packets).
  648. //
  649. PNIC1394_PKTLOG pPktLog;
  650. //
  651. // Per adapter stats
  652. //
  653. ADAPT_STATS AdaptStats;
  654. //
  655. // Read/WriteCapabilities
  656. //
  657. GET_LOCAL_HOST_INFO2 ReadWriteCaps;
  658. //
  659. // SCode - speed of the bus
  660. //
  661. ULONG SCode;
  662. //
  663. // Max packet size that this adapter can read
  664. //
  665. ULONG MaxSendBufferSize;
  666. ULONG MaxRecvBufferSize;
  667. ULONG CurrentLookahead;
  668. //
  669. // PacketFilter - Ethernet structs
  670. //
  671. PETHERNET_VCCB pEthernetVc;
  672. ULONG CurPacketFilter ;
  673. ULONG ProtocolOptions;
  674. MAC_ADDRESS McastAddrs[MCAST_LIST_SIZE];
  675. ULONG McastAddrCount;
  676. ULONG CurLookAhead ;
  677. MAC_ADDRESS MacAddressEth;
  678. //
  679. // ReceivePacket Serialization
  680. //
  681. NIC_SERIALIZATION SerRcv;
  682. NIC_SERIALIZATION SerSend;
  683. NIC_SERIALIZATION Status;
  684. NIC_SERIALIZATION Reassembly;
  685. NIC_SERIALIZATION LoadArp;
  686. //
  687. // Outstanding work Items
  688. ULONG OutstandingWorkItems;
  689. //
  690. // Outstanding Reassemblies
  691. //
  692. ULONG OutstandingReassemblies;
  693. //
  694. // Miniport Name
  695. //
  696. WCHAR AdapterName[ADAPTER_NAME_SIZE];
  697. //
  698. // Size of Name in Bytes
  699. //
  700. ULONG AdapterNameSize;
  701. //
  702. // Ioctl Sent to the Arp module
  703. //
  704. ARP1394_IOCTL_COMMAND ArpIoctl;
  705. //
  706. // Is Arp Started
  707. //
  708. BOOLEAN fIsArpStarted;
  709. //
  710. // Power State - informational use
  711. //
  712. NET_DEVICE_POWER_STATE PowerState;
  713. } ADAPTERCB, *PADAPTERCB;
  714. //
  715. // Address Family Flags
  716. //
  717. #define ACBF_Allocated 0x00000001
  718. #define ACBF_Initialized 0x00000002
  719. #define ACBF_ClosePending 0x00000100
  720. #define ACBF_CloseComplete 0x00000200
  721. // Address family control block, describing the state of an ndis address family.
  722. // Each block may have zero or more VCs associated with it.
  723. //
  724. typedef struct
  725. _AFCB
  726. {
  727. // Set to MTAG_AFCB for easy identification in memory dumps and use in
  728. // assertions.
  729. //
  730. ULONG ulTag;
  731. // ACBF_* bit flags indicating various options. Access restrictions are
  732. // indicated for each individual flag. Many of these flags are set
  733. // permanently at initialization and so have no access limitation.
  734. //
  735. //
  736. ULONG ulFlags;
  737. // Reference count on this control block. The reference pairs are:
  738. //
  739. // (a) A reference is added when this block is linked to the adapter's
  740. // list of af blocks, and removed when it is unlinked.
  741. //
  742. // (a) A reference is added when a call on a VCCB is created
  743. // removed when it is deleted.
  744. //
  745. // Access is via ReferenceTunnel and DereferenceTunnel only which use
  746. // 'ADAPTERCB.lockTunnels' for protection.
  747. //
  748. LONG lRef;
  749. // Links to the prev/next AFCB in the owning adapter's AF list.
  750. // Access to the list links is protected by 'ADAPTERCB.lock'.
  751. //
  752. LIST_ENTRY linkAFCB;
  753. // List of all VCs associated with this address family.
  754. // Access is protected by the adapter lock.
  755. //
  756. LIST_ENTRY AFVCList;
  757. // Back pointer to owning adapter's control block.
  758. //
  759. PADAPTERCB pAdapter;
  760. // NDIS's handle for our Address Family as passed to our CmOpenAfHandler
  761. // or NULL if none.
  762. //
  763. NDIS_HANDLE NdisAfHandle;
  764. }
  765. AFCB, *PAFCB;
  766. // Call statistics block.
  767. //
  768. typedef struct
  769. _CALLSTATS
  770. {
  771. // System time call reached established state. When the block is being
  772. // used for cumulative statistics of multiple calls, this is the number of
  773. // calls instead.
  774. //
  775. LONGLONG llCallUp;
  776. // Duration in seconds of now idle call.
  777. //
  778. ULONG ulSeconds;
  779. // Total data bytes received and sent.
  780. //
  781. ULONG ulDataBytesRecd;
  782. ULONG ulDataBytesSent;
  783. // Number of received packets indicated up.
  784. //
  785. ULONG ulRecdDataPackets;
  786. // TODO: add more stats if required.
  787. ULONG ulSentPkts;
  788. //
  789. // NDis Packet failures
  790. //
  791. ULONG ulSendFailures;
  792. //
  793. // Bus AsyncWrite or Stream failires
  794. //
  795. ULONG ulBusSendFailures;
  796. ULONG ulBusSendSuccess;
  797. }
  798. CALLSTATS;
  799. typedef
  800. NDIS_STATUS
  801. (*PFN_INITVCHANDLER) (
  802. VCCB *pVc
  803. );
  804. typedef
  805. NDIS_STATUS
  806. (*PFN_SENDPACKETHANDLER) (
  807. VCCB *pVc,
  808. NDIS_PACKET * pPacket
  809. );
  810. typedef
  811. NDIS_STATUS
  812. (*PFN_CLOSECALLHANDLER) (
  813. VCCB *pVc
  814. );
  815. typedef
  816. VOID
  817. (*PFN_RETURNHANDLER) (
  818. VCCB *pVc,
  819. PNDIS_PACKET *pPacket
  820. );
  821. // Table of vc-type-specific handler functions.
  822. //
  823. typedef struct _VC_HANDLERS
  824. {
  825. PFN_INITVCHANDLER MakeCallHandler;
  826. PFN_CLOSECALLHANDLER CloseCallHandler;
  827. PFN_SENDPACKETHANDLER SendPackets;
  828. } VC_HANDLERS;
  829. typedef enum _NIC1394_VC_TYPE
  830. {
  831. NIC1394_Invalid_Type,
  832. NIC1394_SendRecvChannel,
  833. NIC1394_RecvFIFO,
  834. NIC1394_SendFIFO,
  835. NIC1394_MultiChannel,
  836. NIC1394_Ethernet,
  837. NIC1394_SendChannel,
  838. NIC1394_RecvChannel,
  839. Nic1394_NoMoreVcTypes
  840. } NIC1394_VC_TYPE, *PNIC1394_VC_TYPE;
  841. // Virtual circuit control block header defining the state of a single VC that
  842. // is common to all the different types of VCs.
  843. //
  844. typedef struct
  845. _VCHDR
  846. {
  847. // Set to MTAG_VCCB_* for easy identification in memory dumps and use in
  848. // assertions.
  849. //
  850. ULONG ulTag;
  851. // The Pdo Block that will be used to perform all the operations for this Vc
  852. //
  853. //
  854. PREMOTE_NODE pRemoteNode;
  855. //
  856. // pLocalHostVdo - local host's VDO that will be used for all channel and
  857. // recv fifo allocations
  858. //
  859. PDEVICE_OBJECT pLocalHostVDO;
  860. // Links to the prev/next VCCB in the owning AF's control block.
  861. // Access is protected by 'ADAPTERCB.lock'.
  862. //
  863. LIST_ENTRY linkAFVcs;
  864. // The VCType and Destination of the call that has been set up on the VC
  865. // The VCType can be either Isoch or Async, Sends or Recieve. Each type
  866. // of VC has an address associated with it
  867. NIC1394_VC_TYPE VcType;
  868. // This stores the generation of the physical adapter. And should match the value
  869. // kept in the adapter block
  870. PUINT pGeneration;
  871. // VCBF_* bit flags indicating various options and states. Access is via
  872. // the interlocked ReadFlags/SetFlags/ClearFlags routines.
  873. //
  874. // VCBF_IndicateReceivedTime: Set if MakeCall caller sets the
  875. // MediaParameters.Flags RECEIVE_TIME_INDICATION flag requesting the
  876. // TimeReceived field of the NDIS packet be filled with a timestamp.
  877. //
  878. // VCBF_CallClosableByClient: Set when a call is in a state where
  879. // NicCmCloseCall requests to initiate clean-up should be accepted.
  880. // This may be set when VCBF_CallClosableByPeer is not, which means we
  881. // have indicated an incoming close to client and are waiting for him
  882. // to do a client close in response (in that weird CoNDIS way). The
  883. // flag is protected by 'lockV'.
  884. //
  885. // VCBF_VcCreated: Set when the VC has been created successfully. This is
  886. // the "creation" that occurs with the client, not the mini-port.
  887. // VCBF_VcActivated: Set when the VC has been activated successfully.
  888. // VCBM_VcState: Bit mask including each of the above 3 NDIS state flags.
  889. //
  890. // VCBF_VcDeleted: Set when the DeleteVC handler has been called on this
  891. // VC. This guards against NDPROXY double-deleting VCs which it has
  892. // been known to do.
  893. //
  894. // The pending bits below are mutually exclusive (except ClientClose which
  895. // may occur after but simultaneous with ClientOpen), and so require lock
  896. // protection by 'lockV':
  897. //
  898. // VCBF_ClientOpenPending: Set when client attempts to establish a call,
  899. // and the result is not yet known.
  900. // VCBF_ClientClosePending: Set when client attempts to close an
  901. // established call and the result is not yet known. Access is
  902. // protected by 'lockV'.
  903. // VCBM_Pending: Bit mask that includes each of the 4 pending flags.
  904. //
  905. // VCBF_ClientCloseCompletion: Set when client close completion is in
  906. // progress.
  907. //
  908. // VCBF_WaitCloseCall: Set when the client is expected to call our call
  909. // manager's CloseCall handler. This is strictly a debug aid.
  910. //
  911. // VCBF_FreedResources - VC This is a channel VC and because the last
  912. // node in the network was being removed, its resources have been freed
  913. ULONG ulFlags;
  914. #define VCBF_IndicateTimeReceived 0x00000001
  915. #define VCBF_CallClosableByClient 0x00000002
  916. #define VCBF_VcCreated 0x00000100
  917. #define VCBF_VcActivated 0x00000200
  918. #define VCBF_VcDispatchedCloseCall 0x00000400
  919. #define VCBF_MakeCallPending 0x00002000
  920. #define VCBF_CloseCallPending 0x00008000
  921. #define VCBF_VcDeleted 0x00010000
  922. #define VCBF_MakeCallFailed 0x00020000
  923. #define VCBF_CloseCallCompleted 0x00040000
  924. #define VCBF_WaitCloseCall 0x00200000
  925. #define VCBF_NewPdoIsActivatingFifo 0x01000000
  926. #define VCBF_PdoIsBeingRemoved 0x02000000
  927. #define VCBF_NeedsToAllocateChannel 0x04000000
  928. #define VCBF_GenerationWorkItem 0x10000000
  929. #define VCBF_AllocatedChannel 0x20000000
  930. #define VCBF_BroadcastVc 0x40000000
  931. #define VCBF_FreedResources 0x80000000
  932. #define VCBM_VcState 0x00000700
  933. #define VCBM_Pending 0x0000F000
  934. #define VCBM_NoActiveCall 0x000F0000
  935. #define VCBM_PdoFlags 0x0F000000
  936. // Back pointer to owning address family control block.
  937. //
  938. AFCB* pAF;
  939. // Reference count on the active call.
  940. // References may only be added
  941. // when the VCCB_VcActivated flag is set, and this is enforced by
  942. // ReferenceCall. The reference pairs are:
  943. //
  944. // (a) A reference is added when a VC is activated and removed when it is
  945. // de-activated.
  946. //
  947. // (b) A reference is added when the send handler accepts a packet.
  948. //
  949. // The field is accessed only by the ReferenceCall and DereferenceCall
  950. // routines, which protect the field with 'lock'.
  951. //
  952. REF CallRef;
  953. // Reference count on this VC control block. The reference pairs are:
  954. //
  955. // (a) NicCoCreateVc adds a reference that is removed by NicCoDeleteVc.
  956. // This covers all clients that learn of the VCCB via NDIS.
  957. //
  958. // The field is accessed only by the ReferenceVc and DereferenceVc
  959. // routines, which protect with Interlocked routines.
  960. //
  961. LONG lRef;
  962. //
  963. // This is a copy the parameters that are passed to the VC in
  964. // a Make Call. Each VC needs to keep a copy. This is stored here
  965. //
  966. NIC1394_MEDIA_PARAMETERS Nic1394MediaParams;
  967. // NDIS BOOKKEEPING ------------------------------------------------------
  968. // NDIS's handle for this VC passed to us in MiniportCoCreateVcHandler.
  969. // This is passed back to NDIS in various NdisXxx calls.
  970. //
  971. NDIS_HANDLE NdisVcHandle;
  972. // This linked list is used to designate all the VCs that are using a single PdoCb
  973. // The head of this list resides in a REMOTE_NODE. So that when a Pdo goes away, we can go and
  974. // close all the Vcs that are dependent on it. No RecvFIFO included
  975. LIST_ENTRY SinglePdoVcLink;
  976. // CALL SETUP ------------------------------------------------------------
  977. // Address of the call parameters passed down in CmMakeCall. This field
  978. // will only be valid until the NdisMCmMakeCallComplete notification for
  979. // the associated call is made, at which time it is reset to NULL. Access
  980. // is via Interlocked routines.
  981. //
  982. PCO_CALL_PARAMETERS pCallParameters;
  983. UINT MTU;
  984. // This is the initialize handler used to initialize the Vc
  985. // Each Vc has its own specific initialize handler so that all the
  986. // data structures that specific to it, can be filled
  987. //
  988. VC_HANDLERS VcHandlers;
  989. // STATISTICS ------------------------------------------------------------
  990. // Statistics for the current call. Access is protected by 'lock'.
  991. //
  992. CALLSTATS stats;
  993. // This is a pointer to the lock in the adapater
  994. // structure.
  995. PNDIS_SPIN_LOCK plock;
  996. //
  997. // MaxPayload that this VC will send in a single IRP
  998. // To be used in Lookaside lists
  999. //
  1000. ULONG MaxPayload;
  1001. }
  1002. VCHDR;
  1003. //
  1004. // Virtual circuit control block defining the state of a single SendFIFO VC.
  1005. //
  1006. typedef struct
  1007. _SENDFIFO_VCCB
  1008. {
  1009. // Common header for all types of VCs
  1010. //
  1011. VCHDR Hdr;
  1012. // Prev/next in the list of SendFIFO VCs for a particular destination
  1013. // PDO
  1014. //
  1015. LIST_ENTRY SendFIFOLink;
  1016. // SendFIFO-specific VC Info
  1017. //
  1018. NIC1394_FIFO_ADDRESS FifoAddress;
  1019. // Shortcuts to the Values we were passed in the Make call
  1020. // that activated the VC
  1021. //
  1022. // UINT MaxSendBlockSize;
  1023. UINT MaxSendSpeed;
  1024. } SENDFIFO_VCCB, *PSENDFIFO_VCCB;
  1025. // Virtual circuit control block defining the state of a single RecvFIFO VC.
  1026. //
  1027. typedef struct
  1028. _RECVFIFO_VCCB
  1029. {
  1030. // Common header for all types of VCs
  1031. //
  1032. VCHDR Hdr;
  1033. // Prev/next in the list of RecvFIFO VCs for a particular Recv FIFO
  1034. // address.
  1035. //
  1036. LIST_ENTRY RecvFIFOLink;
  1037. // Packet Pool Handle
  1038. //
  1039. NIC_PACKET_POOL PacketPool;
  1040. //NDIS_HANDLE PacketPoolHandle;
  1041. // Slist Header. All buffers are posted here, using Interlocked routines
  1042. //
  1043. SLIST_HEADER FifoSListHead;
  1044. // Slist Spin lock that protects the Slist
  1045. //
  1046. KSPIN_LOCK FifoSListSpinLock;
  1047. //
  1048. // Num Fifo Elements allocated
  1049. //
  1050. ULONG NumAllocatedFifos;
  1051. // Num of Fifo that have been indicated to the miniport
  1052. // Count of Fifo that the Nic has not returned to the bus driver
  1053. //
  1054. ULONG NumIndicatedFifos;
  1055. // This is the address range that is returned in the allocate
  1056. // address irb. Will be changed to a pointer or an array
  1057. //
  1058. ADDRESS_RANGE VcAddressRange;
  1059. // This is the number of address ranges that the bus driver
  1060. // returned. For now, it is expected to be one.
  1061. //
  1062. UINT AddressesReturned;
  1063. //
  1064. // Handle to the address range
  1065. //
  1066. HANDLE hAddressRange;
  1067. //
  1068. // Buffer pool
  1069. //
  1070. NIC_BUFFER_POOL BufferPool;
  1071. //NIC_WORK_ITEM FifoWorkItem;
  1072. BOOLEAN FifoWorkItemInProgress ;
  1073. UINT NumOfFifosInSlistInCloseCall;
  1074. } RECVFIFO_VCCB, *PRECVFIFO_VCCB;
  1075. // Virtual circuit control block defining the state of a single CHANNEL VC.
  1076. //
  1077. typedef struct
  1078. _CHANNEL_VCCB
  1079. {
  1080. // Common header for all types of VCs
  1081. //
  1082. VCHDR Hdr;
  1083. // Prev/next in the list of channel VCs for a particular destination
  1084. // channel
  1085. //
  1086. LIST_ENTRY ChannelLink;
  1087. // Channel-specific VC Info
  1088. //
  1089. UINT Channel;
  1090. // The speed at which this Channel will stream data
  1091. //
  1092. UINT Speed;
  1093. // Indicates the Sy field in packets that will indicated up
  1094. //
  1095. ULONG ulSynch;
  1096. // the Tag used in submitting asyncstream irps
  1097. //
  1098. ULONG ulTag;
  1099. // MaxBytesPerFrameRequested and available
  1100. //
  1101. ULONG MaxBytesPerFrameRequested;
  1102. ULONG BytesPerFrameAvailable;
  1103. // Handle to the Resources allocated
  1104. //
  1105. HANDLE hResource;
  1106. // Speeds Requested and speed returned
  1107. //
  1108. ULONG SpeedRequested;
  1109. ULONG SpeedSelected;
  1110. // Maximum Buffer Size
  1111. //
  1112. ULONG MaxBufferSize;
  1113. // Num of descriptors that were attached to the resources
  1114. //
  1115. ULONG NumDescriptors;
  1116. // Pointer to an array of isochDescriptors used in AttachBuffers
  1117. //
  1118. PISOCH_DESCRIPTOR pIsochDescriptor;
  1119. // PacketPool Handle
  1120. //
  1121. NIC_PACKET_POOL PacketPool;
  1122. //NDIS_HANDLE hPacketPoolHandle;
  1123. //
  1124. // Temporary
  1125. //
  1126. UINT PacketLength;
  1127. //
  1128. // Number of Isoch Descriptors that the Bus driver has indicated to the miniport
  1129. //
  1130. ULONG NumIndicatedIsochDesc;
  1131. //
  1132. // Event to signal that the last of the Isoch descriptors have
  1133. // been returned to the bus driver. Only set when Vc is closing (after IsochStop)
  1134. //
  1135. NDIS_EVENT LastDescReturned;
  1136. //
  1137. // Channel Map used in Multichannel Vcs
  1138. //
  1139. ULARGE_INTEGER uliChannelMap;
  1140. } CHANNEL_VCCB, *PCHANNEL_VCCB;
  1141. typedef struct
  1142. _ETHERNET_VCCB
  1143. {
  1144. // Common header for all types of VCs
  1145. //
  1146. VCHDR Hdr;
  1147. NIC_PACKET_POOL PacketPool;
  1148. } ETHERNET_VCCB, *PETHERNET_VCCB;
  1149. // The following union has enough space to hold any of the type-specific
  1150. // VC control blocks.
  1151. //
  1152. typedef union _VCCB
  1153. {
  1154. VCHDR Hdr;
  1155. CHANNEL_VCCB ChannelVc;
  1156. SENDFIFO_VCCB SendFIFOVc;
  1157. RECVFIFO_VCCB RecvFIFOVc;
  1158. ETHERNET_VCCB EthernetVc;
  1159. } VCCB, *PVCCB;
  1160. // The next structure is used when sending a packet, to store context
  1161. // information in an NdisPacket. These are pointers to the Vc and the Irb
  1162. // and are stored in the MiniportWrapperReserved field of the NdisPacket
  1163. // and has a limit of 2 PVOIDs
  1164. //
  1165. typedef union _PKT_CONTEXT
  1166. {
  1167. struct
  1168. {
  1169. PVCCB pVc;
  1170. PVOID pLookasideListBuffer;
  1171. } AsyncWrite;
  1172. struct
  1173. {
  1174. PVCCB pVc;
  1175. PVOID pLookasideListBuffer;
  1176. } AsyncStream;
  1177. //
  1178. // For receives make sure the first element is the Vc or we will break;
  1179. //
  1180. struct
  1181. {
  1182. PRECVFIFO_VCCB pRecvFIFOVc;
  1183. PADDRESS_FIFO pIndicatedFifo;
  1184. } AllocateAddressRange;
  1185. struct
  1186. {
  1187. PCHANNEL_VCCB pChannelVc;
  1188. PISOCH_DESCRIPTOR pIsochDescriptor;
  1189. } IsochListen;
  1190. struct
  1191. {
  1192. //
  1193. // First DWORD is the Vc
  1194. //
  1195. PVCCB pVc;
  1196. //
  1197. // Second is the isoch descriptor or Fifo
  1198. //
  1199. union
  1200. {
  1201. PISOCH_DESCRIPTOR pIsochDescriptor; // channels use isoch desc
  1202. PADDRESS_FIFO pIndicatedFifo; // fifo use AddressFifo
  1203. PVOID pCommon; // to be used in the common code path
  1204. } IndicatedStruct;
  1205. } Receive;
  1206. struct
  1207. {
  1208. PNDIS_PACKET pOrigPacket;
  1209. } EthernetSend;
  1210. } PKT_CONTEXT,*PPKT_CONTEXT,**PPPKT_CONTEXT;
  1211. typedef struct _NDIS1394_FRAGMENT_HEADER
  1212. {
  1213. union
  1214. {
  1215. struct
  1216. {
  1217. ULONG FH_fragment_offset:12;
  1218. ULONG FH_rsv_0:4;
  1219. ULONG FH_buffersize:12;
  1220. ULONG FH_rsv_1:2;
  1221. ULONG FH_lf:2;
  1222. } FirstQuadlet;
  1223. struct
  1224. {
  1225. ULONG FH_EtherType:16;
  1226. ULONG FH_buffersize:12;
  1227. ULONG FH_rsv_1:2;
  1228. ULONG FH_lf:2;
  1229. } FirstQuadlet_FirstFragment;
  1230. ULONG FH_High;
  1231. } u;
  1232. union
  1233. {
  1234. struct
  1235. {
  1236. ULONG FH_rsv:16;
  1237. ULONG FH_dgl:16;
  1238. } SecondQuadlet;
  1239. ULONG FH_Low;
  1240. } u1;
  1241. } NDIS1394_FRAGMENT_HEADER, *PNDIS1394_FRAGMENT_HEADER;
  1242. #define LOOKASIDE_HEADER_No_More_Framgents 1
  1243. #define LOOKASIDE_HEADER_SendPacketFrees 2
  1244. #define LOOKASIDE_HEADER_SendCompleteFrees 4
  1245. //
  1246. // This structure is used with the above flags to maintain state within the lookaside buffer
  1247. //
  1248. typedef union _LOOKASIDE_BUFFER_STATE
  1249. {
  1250. struct
  1251. {
  1252. USHORT Refcount;
  1253. USHORT Flags;
  1254. } u;
  1255. LONG FlagRefcount;
  1256. } LOOKASIDE_BUFFER_STATE, *PLOOKASIDE_BUFFER_STATE;
  1257. typedef enum _BUS_OPERATION
  1258. {
  1259. InvalidOperation,
  1260. AsyncWrite,
  1261. AsyncStream,
  1262. AddressRange,
  1263. IsochReceive
  1264. } BUS_OPERATION, *PBUS_OPERATION;
  1265. //
  1266. // This will be used as a local variable
  1267. // during a send operation and will
  1268. // keep all the state information
  1269. // regarding fragmentation
  1270. //
  1271. typedef struct _FRAGMENTATION_STRUCTURE
  1272. {
  1273. //
  1274. // Start of the buffer that will be used in the send.
  1275. // Usually from a lookaside list
  1276. //
  1277. PVOID pLookasideListBuffer;
  1278. //
  1279. // Fragment Length
  1280. //
  1281. ULONG FragmentLength ;
  1282. //
  1283. // Start of the this fragment to be used
  1284. //
  1285. PVOID pStartFragment;
  1286. //
  1287. // Specified if an async write or an asyncstream operation is occurring
  1288. //
  1289. BUS_OPERATION AsyncOp;
  1290. //
  1291. // LookasideBuffer associated with the fragmentation
  1292. //
  1293. PVOID pLookasideBuffer;
  1294. //
  1295. // Start of the next fragment
  1296. //
  1297. // PVOID pStartNextFragment;
  1298. //
  1299. // Length of each fragment
  1300. //
  1301. ULONG MaxFragmentLength;
  1302. //
  1303. // NumFragments that will be generated
  1304. //
  1305. ULONG NumFragmentsNeeded ;
  1306. //
  1307. // Current NdisBuffer which is being fragmented
  1308. //
  1309. PNDIS_BUFFER pCurrNdisBuffer;
  1310. //
  1311. // Length that needs to be copied in CurrNdisBuffer
  1312. //
  1313. ULONG NdisBufferLengthRemaining;
  1314. //
  1315. // Point to which copying has occurred in the pCurrNdisBuffer
  1316. //
  1317. PVOID pSourceAddressInNdisBuffer;
  1318. //
  1319. // UnFragment Header from this NdisPacket
  1320. //
  1321. NDIS1394_UNFRAGMENTED_HEADER UnfragmentedHeader;
  1322. //
  1323. // Fragmented Header to be used by all the fragments
  1324. // generated by this NdisPackets
  1325. //
  1326. NDIS1394_FRAGMENT_HEADER FragmentationHeader;
  1327. //
  1328. // Status of the lf field in the fragment header. Also serves as an
  1329. // implicit flag about the state of the fragmentation
  1330. //
  1331. NDIS1394_FRAGMENT_LF lf;
  1332. //
  1333. // Length of the Ip Datagram, to be used as the buffersize in fragment header
  1334. //
  1335. USHORT IPDatagramLength;
  1336. //
  1337. // An AsyncStream will have a gasp header as well . So the starting
  1338. // offset can either be either 8 or 16. Only applicable for fragmentation code path
  1339. //
  1340. ULONG TxHeaderSize;
  1341. //
  1342. // Pointer to the lookaside list that this buffer was allocated from
  1343. //
  1344. PNIC_NPAGED_LOOKASIDE_LIST pLookasideList;
  1345. //
  1346. // Adapter - local host
  1347. //
  1348. PADAPTERCB pAdapter;
  1349. //
  1350. // Pointer to the IRB to be used in the current fragment
  1351. //
  1352. PIRB pCurrentIrb;
  1353. //
  1354. // Current Fragment Number
  1355. //
  1356. ULONG CurrFragmentNum;
  1357. PVOID pStartOfFirstFragment;
  1358. }FRAGMENTATION_STRUCTURE, *PFRAGMENTATION_STRUCTURE;
  1359. typedef struct _LOOKASIDE_BUFFER_HEADER
  1360. {
  1361. //
  1362. // Refcount
  1363. //
  1364. ULONG OutstandingFragments;
  1365. //
  1366. // NumOfFragments generated by the NdisPacket So Far
  1367. //
  1368. ULONG FragmentsGenerated;
  1369. //
  1370. // Will this Buffer contain fragments
  1371. //
  1372. BOOLEAN IsFragmented;
  1373. //
  1374. // Pointer to the NdisPacket whose data is being transmitted
  1375. // by the lookaside buffer
  1376. //
  1377. PNDIS_PACKET pNdisPacket;
  1378. //
  1379. // pVc Pointer to the Vc on which the packet was indicated
  1380. // Used to complete the packet
  1381. //
  1382. PVCCB pVc;
  1383. //
  1384. // Pointer to the lookaside list that this buffer was allocated from
  1385. //
  1386. PNIC_NPAGED_LOOKASIDE_LIST pLookasideList;
  1387. //
  1388. // Bus Op AsyncStream or AsyncWrite.
  1389. // AsyncWrite reference the RemoteNode. AsuncWrite does not
  1390. //
  1391. BUS_OPERATION AsyncOp;
  1392. //
  1393. // Start of Data
  1394. //
  1395. PVOID pStartOfData;
  1396. } LOOKASIDE_BUFFER_HEADER, *PLOOKASIDE_BUFFER_HEADER;
  1397. typedef enum _ENUM_LOOKASIDE_LIST
  1398. {
  1399. NoLookasideList,
  1400. SendLookasideList100,
  1401. SendLookasideList2K,
  1402. } ENUM_LOOKASIDE_LIST, *PENUM_LOOKASIDE_LIST;
  1403. //
  1404. // Unfragmented Buffer
  1405. //
  1406. typedef struct _UNFRAGMENTED_BUFFER
  1407. {
  1408. LOOKASIDE_BUFFER_HEADER Header;
  1409. IRB Irb;
  1410. UCHAR Data [1];
  1411. } UNFRAGMENTED_BUFFER, *PUNFRAGMENTED_BUFFER;
  1412. #define PAYLOAD_100 100
  1413. //
  1414. // A simple packet with no fragmentation . This will primarily be used for the IP Acks and ARP req
  1415. //
  1416. typedef struct _PAYLOAD_100_LOOKASIDE_BUFFER
  1417. {
  1418. LOOKASIDE_BUFFER_HEADER Header;
  1419. IRB Irb;
  1420. UCHAR Data [PAYLOAD_100 + sizeof (GASP_HEADER)];
  1421. } PAYLOAD_100_LOOKASIDE_BUFFER;
  1422. //
  1423. // This lookaside will handle packets upto 2K.
  1424. //
  1425. // Calculate the theoretical maximum number of fragments that can occur for a
  1426. // a 2K Packet
  1427. //
  1428. #define PAYLOAD_2K ASYNC_PAYLOAD_400_RATE
  1429. #define NUM_FRAGMENT_2K ((PAYLOAD_2K/ASYNC_PAYLOAD_100_RATE) +1)
  1430. typedef struct _PAYLOAD_2K_LOOKASIDE_BUFFER
  1431. {
  1432. LOOKASIDE_BUFFER_HEADER Header;
  1433. //
  1434. // There can be a maximum of 2048 bytes in 1 Async Packet fragment
  1435. // on ASYNC_PAYLOAD_400 so this will cater to
  1436. // that, but it will be prepared for the worst
  1437. //
  1438. //
  1439. IRB Irb[NUM_FRAGMENT_2K];
  1440. //
  1441. // We get a data size large enough to handle 2048 bytes of data chopped up
  1442. // into the max num of fragments and leave room for header (fragmentation and Gasp)
  1443. // To access we'll just use simple pointer arithmetic
  1444. //
  1445. UCHAR Data[PAYLOAD_2K+ (NUM_FRAGMENT_2K *(sizeof (GASP_HEADER)+sizeof (NDIS1394_FRAGMENT_HEADER)))];
  1446. } PAYLOAD_2K_LOOKASIDE_BUFFER, *PPAYLOAD_2K_LOOKASIDE_BUFFER;
  1447. //
  1448. // The 1394 fragment that is passed down can have a gasp header, fragmentation header,
  1449. // unfragmented header. Define Types to format these headers so that we can make
  1450. // compiler do the pointer arithmetic for us.
  1451. //
  1452. typedef union _PACKET_FORMAT
  1453. {
  1454. struct
  1455. {
  1456. GASP_HEADER GaspHeader;
  1457. NDIS1394_FRAGMENT_HEADER FragmentHeader;
  1458. UCHAR Data[1];
  1459. } AsyncStreamFragmented;
  1460. struct
  1461. {
  1462. GASP_HEADER GaspHeader;
  1463. NDIS1394_UNFRAGMENTED_HEADER NonFragmentedHeader;
  1464. UCHAR Data[1];
  1465. } AsyncStreamNonFragmented;
  1466. struct
  1467. {
  1468. NDIS1394_FRAGMENT_HEADER FragmentHeader;
  1469. UCHAR Data[1];
  1470. } AsyncWriteFragmented;
  1471. struct
  1472. {
  1473. NDIS1394_UNFRAGMENTED_HEADER NonFragmentedHeader;
  1474. UCHAR Data[1];
  1475. }AsyncWriteNonFragmented;
  1476. struct
  1477. {
  1478. //
  1479. // Isoch receive header has a prefix, isoch header, gasp header
  1480. //
  1481. ULONG Prefix;
  1482. ISOCH_HEADER IsochHeader;
  1483. GASP_HEADER GaspHeader;
  1484. NDIS1394_UNFRAGMENTED_HEADER NonFragmentedHeader;
  1485. UCHAR Data[1];
  1486. } IsochReceiveNonFragmented;
  1487. struct
  1488. {
  1489. //
  1490. // Isoch receive header has a prefix, isoch header, gasp header
  1491. //
  1492. ULONG Prefix;
  1493. ISOCH_HEADER IsochHeader;
  1494. GASP_HEADER GaspHeader;
  1495. NDIS1394_FRAGMENT_HEADER FragmentHeader;
  1496. UCHAR Data[1];
  1497. }IsochReceiveFragmented;
  1498. }PACKET_FORMAT, DATA_FORMAT, *PPACKET_FORMAT, *PDATA_FORMAT;
  1499. //
  1500. // Used as an Info Struct for Out of Order Reassembly
  1501. //
  1502. typedef struct _REASSEMBLY_CURRENT_INFO
  1503. {
  1504. PMDL pCurrMdl;
  1505. PNDIS_BUFFER pCurrNdisBuffer;
  1506. PADDRESS_FIFO pCurrFifo;
  1507. PISOCH_DESCRIPTOR pCurrIsoch;
  1508. } REASSEMBLY_CURRENT_INFO, *PREASSEMBLY_CURRENT_INFO ;
  1509. typedef enum _REASSEMBLY_INSERT_TYPE
  1510. {
  1511. Unacceptable,
  1512. InsertAsFirst,
  1513. InsertInMiddle,
  1514. InsertAtEnd
  1515. }REASSEMBLY_INSERT_TYPE, *PREASSEMBLY_INSERT_TYPE;
  1516. //
  1517. // This is used as a descriptor for indicated fragments that are waiting for reassembly
  1518. //
  1519. typedef struct _FRAGMENT_DESCRIPTOR
  1520. {
  1521. ULONG Offset; // Offset of the incoming fragment
  1522. ULONG IPLength; // Length of the fragment
  1523. PNDIS_BUFFER pNdisBuffer; // NdisBufferpointing to actual data
  1524. PMDL pMdl; // Mdl that belongs to the bus
  1525. NDIS1394_FRAGMENT_HEADER FragHeader; // Fragment header of the Descriptor
  1526. union
  1527. {
  1528. PADDRESS_FIFO pFifo;
  1529. PISOCH_DESCRIPTOR pIsoch;
  1530. PVOID pCommon;
  1531. PSINGLE_LIST_ENTRY pListEntry;
  1532. }IndicatedStructure;
  1533. } FRAGMENT_DESCRIPTOR, *PFRAGMENT_DESCRIPTOR;
  1534. //
  1535. // Reassembly structure : An instance of the reassembly is created for
  1536. // every packet that is being reassembled. It contains all the relevant
  1537. // bookkeeping information
  1538. //
  1539. // This needs to be allocated from a lookaside list
  1540. // Each PDO will contain a list of all outstanding packets that are being reassembled/
  1541. //
  1542. //
  1543. // REASSEMBLY_NOT_TOUCHED - Each reassembly structure will be marked as Not touched
  1544. // in the timer routine. If the flag is not cleared by the next
  1545. // invocation of the timer, this structure will be freed
  1546. // REASSMEBLY_FREED - The structure is about to be thrown away.
  1547. #define REASSEMBLY_NOT_TOUCHED 1
  1548. #define REASSEMBLY_FREED 2
  1549. #define REASSEMBLY_ABORTED 4
  1550. typedef struct _NDIS1394_REASSEMBLY_STRUCTURE
  1551. {
  1552. //
  1553. // Reference Count - Interlocked access only
  1554. //
  1555. ULONG Ref;
  1556. //
  1557. // Next Reassembly Structure
  1558. //
  1559. LIST_ENTRY ReassemblyListEntry;
  1560. //
  1561. // Tag - used for memory validatation
  1562. //
  1563. ULONG Tag;
  1564. //
  1565. // Receive Operation
  1566. //
  1567. BUS_OPERATION ReceiveOp;
  1568. //
  1569. // Dgl - Datagram label. Unique for every reassembly structure gernerated by this local host
  1570. //
  1571. USHORT Dgl;
  1572. //
  1573. // Ether type of the reassembled packet . Populated in the first fragment
  1574. //
  1575. USHORT EtherType;
  1576. //
  1577. // pRemoteNode -> RemoteNode + Dgl are unique for each reassembly structure
  1578. //
  1579. PREMOTE_NODE pRemoteNode;
  1580. //
  1581. // Flags pertaining to the reassembly
  1582. //
  1583. ULONG Flags;
  1584. //
  1585. // ExpectedFragmentOffset is computed by the LAST Fragment's Offset +
  1586. // length of fragment. Does not account for gaps in the reassembled packet.
  1587. //
  1588. ULONG ExpectedFragmentOffset; // Last is based on offset, not time of indication
  1589. //
  1590. // Buffer Size - total length of the datagram being reassembled
  1591. //
  1592. ULONG BufferSize;
  1593. //
  1594. // Bytes Received So far
  1595. //
  1596. ULONG BytesRecvSoFar;
  1597. //
  1598. // Head NdisBuffer
  1599. //
  1600. PNDIS_BUFFER pHeadNdisBuffer;
  1601. //
  1602. // LastNdisBuffer that was appended to the packet
  1603. //
  1604. PNDIS_BUFFER pTailNdisBuffer;
  1605. //
  1606. // Mdl chain Head - pointing to the actual indicated fragment
  1607. //
  1608. PMDL pHeadMdl;
  1609. //
  1610. //Mdl Chain Tail - pointing to the last Mdl in the list
  1611. //
  1612. PMDL pTailMdl ;
  1613. //
  1614. // Packet that is being reassembled
  1615. //
  1616. PNDIS_PACKET pNdisPacket;
  1617. //
  1618. // NumOfFragmentsSoFar;
  1619. //
  1620. ULONG NumOfFragmentsSoFar;
  1621. //
  1622. // Pointer to the head of the MDL chain that the 1394 bus
  1623. // driver is indicating up. Will be used to return the buffers to
  1624. // the BusDriver
  1625. //
  1626. union
  1627. {
  1628. PADDRESS_FIFO pAddressFifo;
  1629. PISOCH_DESCRIPTOR pIsochDescriptor;
  1630. PVOID pCommon;
  1631. } Head;
  1632. //
  1633. // Last - Last Mdl that was appended to this packet in the reassembly structure
  1634. //
  1635. union
  1636. {
  1637. PADDRESS_FIFO pAddressFifo;
  1638. PISOCH_DESCRIPTOR pIsochDescriptor;
  1639. PVOID pCommon;
  1640. } Tail;
  1641. //
  1642. // Flag to signal if any out of order fragments were received. Default FALSE
  1643. //
  1644. BOOLEAN OutOfOrder;
  1645. //
  1646. // Flag to indicate if all fragments are completed . Default False
  1647. //
  1648. BOOLEAN fReassemblyComplete;
  1649. //
  1650. // Vc that this packet is being assembled for
  1651. //
  1652. PVCCB pVc;
  1653. //
  1654. // MaxIndex in the Fragment Table.
  1655. // At all times, MaxOffset points to an first empty element in the array
  1656. //
  1657. ULONG MaxOffsetTableIndex;
  1658. //
  1659. // FragmentOffset Table
  1660. //
  1661. FRAGMENT_DESCRIPTOR FragTable[MAX_ALLOWED_FRAGMENTS];
  1662. } NDIS1394_REASSEMBLY_STRUCTURE, *PDIS1394_REASSEMBLY_STRUCTURE, *PPDIS1394_REASSEMBLY_STRUCTURE;
  1663. //
  1664. // This structure is local to each Isoch descriptor or fifo that is indicated up
  1665. // to the nic1394 miniport. It stores all the local information extracted
  1666. // from the GASP header and Isoch Header
  1667. //
  1668. typedef struct
  1669. {
  1670. BUS_OPERATION RecvOp; // Fifo or Isoch Receive
  1671. PDATA_FORMAT p1394Data; // Start of 1394 pkt
  1672. ULONG Length1394; // Length of the 1394 data
  1673. PVOID pEncapHeader; // Points to start of frag/defrag encap header
  1674. ULONG DataLength; // length of the packet, from the EncapHeader
  1675. BOOLEAN fGasp; // Has GASP header
  1676. NDIS1394_UNFRAGMENTED_HEADER UnfragHeader; // Unfragmented header
  1677. NDIS1394_FRAGMENT_HEADER FragmentHeader; // Fragment Header
  1678. PGASP_HEADER pGaspHeader; // Gasp Header
  1679. PVOID pIndicatedData; // Data indicated up, includes the isoch header, unfrag headers
  1680. PMDL pMdl;
  1681. //
  1682. // Following information from the fragmented/unfragmented header...
  1683. //
  1684. BOOLEAN fFragmented; // Is fragmented
  1685. BOOLEAN fFirstFragment; // Is the First fragment
  1686. ULONG BufferSize;
  1687. ULONG FragmentOffset;
  1688. USHORT Dgl; // Dgl
  1689. ULONG lf; // Lf - Fragmented or not
  1690. ULONG EtherType; // Ethertype
  1691. PNDIS_BUFFER pNdisBuffer; // Ndis buffer - used to indicate data up.
  1692. PVOID pNdisBufferData; // Points to the start of the data that the Ndis Buffer points to
  1693. //
  1694. // Sender specific information here
  1695. //
  1696. USHORT SourceID;
  1697. PREMOTE_NODE pRemoteNode;
  1698. //
  1699. // Vc Specific Information here
  1700. //
  1701. PVCCB pVc;
  1702. PNIC_PACKET_POOL pPacketPool;
  1703. //
  1704. // Indication data
  1705. //
  1706. union
  1707. {
  1708. PADDRESS_FIFO pFifoContext;
  1709. PISOCH_DESCRIPTOR pIsochContext;
  1710. PVOID pCommon; // to be used in the common code path
  1711. }NdisPktContext;
  1712. } NIC_RECV_DATA_INFO, *PNIC_RECV_DATA_INFO;
  1713. //
  1714. // Fragment Header as defined in the IP/1394 spec. Each packet greater than the MaxPayload
  1715. // will be split up into fragments and this header will be attached.
  1716. //
  1717. #define FRAGMENT_HEADER_LF_UNFRAGMENTED 0
  1718. #define FRAGMENT_HEADER_LF_FIRST_FRAGMENT 1
  1719. #define FRAGMENT_HEADER_LF_LAST_FRAGMENT 2
  1720. #define FRAGMENT_HEADER_LF_INTERIOR_FRAGMENT 3
  1721. typedef struct _INDICATE_RSVD
  1722. {
  1723. PNDIS_PACKET pPacket;
  1724. PVCCB pVc;
  1725. PADAPTERCB pAdapter;
  1726. LIST_ENTRY Link;
  1727. ULONG Tag;
  1728. } INDICATE_RSVD, *PINDICATE_RSVD;
  1729. typedef struct _RSVD
  1730. {
  1731. UCHAR Mandatory[PROTOCOL_RESERVED_SIZE_IN_PACKET]; // mandatory ndis requirement
  1732. INDICATE_RSVD IndicateRsvd; // to be used as extra context
  1733. } RSVD, *PRSVD;
  1734. //
  1735. // Used only in Win9x as a context for the send timer routine
  1736. //
  1737. typedef struct _NDIS_SEND_CONTEXT
  1738. {
  1739. LIST_ENTRY Link;
  1740. PVCCB pVc;
  1741. }NDIS_SEND_CONTEXT, *PNDIS_SEND_CONTEXT;
  1742. typedef struct _NDIS_STATUS_CONTEXT
  1743. {
  1744. LIST_ENTRY Link;
  1745. IN NDIS_STATUS GeneralStatus;
  1746. IN PVOID StatusBuffer;
  1747. IN UINT StatusBufferSize;
  1748. }NDIS_STATUS_CONTEXT, *PNDIS_STATUS_CONTEXT;
  1749. //
  1750. // This is the Irb structure used by the Bus Driver.
  1751. // There is extra room allocated at the end for the miniport's Context
  1752. //
  1753. typedef struct _NDIS1394_IRB
  1754. {
  1755. //
  1756. // Original Irb used by the bus driver
  1757. //
  1758. IRB Irb;
  1759. //
  1760. // Adapter - local host -optional
  1761. //
  1762. PADAPTERCB pAdapter;
  1763. //
  1764. // remote node to which the Irp was sent - optional
  1765. //
  1766. PREMOTE_NODE pRemoteNode;
  1767. //
  1768. // VC for which the Irp was sent. - optional
  1769. //
  1770. PVCCB pVc;
  1771. //
  1772. // Context if any - optinal
  1773. //
  1774. PVOID Context;
  1775. }NDIS1394_IRB, *PNDIS1394_IRB;
  1776. //
  1777. // The following structure is used to log the cause of a Reference or Dereference.
  1778. // It is ignored unless LOG_REMOTE_NODE_REF is not zero
  1779. //
  1780. typedef enum _REMOTE_NODE_REF_CAUSE {
  1781. FindIrmAmongRemoteNodes,
  1782. InformAllRemoteNodesOfBCM,
  1783. UpdateNodeTable,
  1784. FindRemoteNodeFromAdapter,
  1785. SubmitIrp_Synch,
  1786. AddRemoteNode,
  1787. ReassemblyTimer,
  1788. GetRemoteNodeFromTable,
  1789. UpdateRemoteNodeCaps,
  1790. UpdateRemoteNodeTable,
  1791. UpdateLocalHostSpeed,
  1792. InitializeReassemblyStructure,
  1793. FreeAllPendingReassemblyStructures,
  1794. AsyncWriteSendPackets,
  1795. FindRemoteNodeFromAdapterFail,
  1796. RemoveRemoteNode,
  1797. ReassemblyTimer_Removing,
  1798. FreeReassembliesOnRemoteNode,
  1799. FillRemoteNodeInfo,
  1800. InsertFragmentInReassembly,
  1801. AsyncSendComplete,
  1802. } REMOTE_NODE_REF_CAUSE;
  1803. #pragma pack (push, 1)
  1804. typedef ULONG IP_ADDRESS;
  1805. //* Structure of an Ethernet header (taken from ip\arpdef.h).
  1806. typedef struct ENetHeader {
  1807. ENetAddr eh_daddr;
  1808. ENetAddr eh_saddr;
  1809. USHORT eh_type;
  1810. } ENetHeader;
  1811. // Structure of an Ethernet ARP packet.
  1812. //
  1813. typedef struct {
  1814. ENetHeader header;
  1815. USHORT hardware_type;
  1816. USHORT protocol_type;
  1817. UCHAR hw_addr_len;
  1818. UCHAR IP_addr_len;
  1819. USHORT opcode; // Opcode.
  1820. ENetAddr sender_hw_address;
  1821. IP_ADDRESS sender_IP_address;
  1822. ENetAddr target_hw_address;
  1823. IP_ADDRESS target_IP_address;
  1824. } ETH_ARP_PKT, *PETH_ARP_PKT;
  1825. #pragma pack (pop)
  1826. // These are ethernet arp specific constants
  1827. //
  1828. #define ARP_ETH_ETYPE_IP 0x800
  1829. #define ARP_ETH_ETYPE_ARP 0x806
  1830. #define ARP_ETH_REQUEST 1
  1831. #define ARP_ETH_RESPONSE 2
  1832. #define ARP_ETH_HW_ENET 1
  1833. #define ARP_ETH_HW_802 6
  1834. typedef enum _ARP_ACTION {
  1835. LoadArp = 1,
  1836. UnloadArp ,
  1837. UnloadArpNoRequest,
  1838. BindArp
  1839. }ARP_ACTION , *PARP_ACTION;
  1840. typedef struct _ARP_INFO{
  1841. //
  1842. // List entry to handle serialization of requests to ARP
  1843. //
  1844. LIST_ENTRY Link;
  1845. //
  1846. // Action to be done by the Arp module
  1847. //
  1848. ARP_ACTION Action;
  1849. //
  1850. // Request to be compeleted - optional
  1851. //
  1852. PNDIS_REQUEST pRequest;
  1853. } ARP_INFO, *PARP_INFO;
  1854. //-----------------------------------------------------------------------------
  1855. // Macros/inlines
  1856. //-----------------------------------------------------------------------------
  1857. // These basics are not in the DDK headers for some reason.
  1858. //
  1859. #define min( a, b ) (((a) < (b)) ? (a) : (b))
  1860. #define max( a, b ) (((a) > (b)) ? (a) : (b))
  1861. #define InsertBefore( pNewL, pL ) \
  1862. { \
  1863. (pNewL)->Flink = (pL); \
  1864. (pNewL)->Blink = (pL)->Blink; \
  1865. (pNewL)->Flink->Blink = (pNewL); \
  1866. (pNewL)->Blink->Flink = (pNewL); \
  1867. }
  1868. #define InsertAfter( pNewL, pL ) \
  1869. { \
  1870. (pNewL)->Flink = (pL)->Flink; \
  1871. (pNewL)->Blink = (pL); \
  1872. (pNewL)->Flink->Blink = (pNewL); \
  1873. (pNewL)->Blink->Flink = (pNewL); \
  1874. }
  1875. // Winsock-ish host/network byte order converters for short and long integers.
  1876. //
  1877. #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037)) || ((defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_FULL_VER > 13009175))
  1878. #define htons(x) _byteswap_ushort((USHORT)(x))
  1879. #define htonl(x) _byteswap_ulong((ULONG)(x))
  1880. #else
  1881. #define htons( a ) ((((a) & 0xFF00) >> 8) |\
  1882. (((a) & 0x00FF) << 8))
  1883. #define htonl( a ) ((((a) & 0xFF000000) >> 24) | \
  1884. (((a) & 0x00FF0000) >> 8) | \
  1885. (((a) & 0x0000FF00) << 8) | \
  1886. (((a) & 0x000000FF) << 24))
  1887. #endif
  1888. #define ntohs( a ) htons(a)
  1889. #define ntohl( a ) htonl(a)
  1890. // Place in a TRACE argument list to correspond with a format of "%d.%d.%d.%d"
  1891. // to print network byte-ordered IP address 'x' in human readable form.
  1892. //
  1893. #define IPADDRTRACE( x ) ((x) & 0x000000FF), \
  1894. (((x) >> 8) & 0x000000FF), \
  1895. (((x) >> 16) & 0x000000FF), \
  1896. (((x) >> 24) & 0x000000FF)
  1897. // Place in a TRACE argument list to correspond with a format of "%d" to print
  1898. // a percentage of two integers, or an average of two integers, or those
  1899. // values rounded.
  1900. //
  1901. #define PCTTRACE( n, d ) ((d) ? (((n) * 100) / (d)) : 0)
  1902. #define AVGTRACE( t, c ) ((c) ? ((t) / (c)) : 0)
  1903. #define PCTRNDTRACE( n, d ) ((d) ? (((((n) * 1000) / (d)) + 5) / 10) : 0)
  1904. #define AVGRNDTRACE( t, c ) ((c) ? (((((t) * 10) / (c)) + 5) / 10) : 0)
  1905. // All memory allocations and frees are done with these ALLOC_*/FREE_*
  1906. // macros/inlines to allow memory management scheme changes without global
  1907. // editing. For example, might choose to lump several lookaside lists of
  1908. // nearly equal sized items into a single list for efficiency.
  1909. //
  1910. // NdisFreeMemory requires the length of the allocation as an argument. NT
  1911. // currently doesn't use this for non-paged memory, but according to JameelH,
  1912. // Windows95 does. These inlines stash the length at the beginning of the
  1913. // allocation, providing the traditional malloc/free interface. The
  1914. // stash-area is a ULONGLONG so that all allocated blocks remain ULONGLONG
  1915. // aligned as they would be otherwise, preventing problems on Alphas.
  1916. //
  1917. __inline
  1918. VOID*
  1919. ALLOC_NONPAGED(
  1920. IN ULONG ulBufLength,
  1921. IN ULONG ulTag )
  1922. {
  1923. CHAR* pBuf;
  1924. NdisAllocateMemoryWithTag(
  1925. &pBuf, (UINT )(ulBufLength + MEMORY_ALLOCATION_ALIGNMENT), ulTag );
  1926. if (!pBuf)
  1927. {
  1928. return NULL;
  1929. }
  1930. ((ULONG* )pBuf)[ 0 ] = ulBufLength;
  1931. ((ULONG* )pBuf)[ 1 ] = ulTag;
  1932. return (pBuf + MEMORY_ALLOCATION_ALIGNMENT);
  1933. }
  1934. __inline
  1935. VOID
  1936. FREE_NONPAGED(
  1937. IN VOID* pBuf )
  1938. {
  1939. ULONG ulBufLen;
  1940. ulBufLen = *((ULONG* )(((CHAR* )pBuf) - MEMORY_ALLOCATION_ALIGNMENT));
  1941. NdisFreeMemory(
  1942. ((CHAR* )pBuf) - MEMORY_ALLOCATION_ALIGNMENT,
  1943. (UINT )(ulBufLen + MEMORY_ALLOCATION_ALIGNMENT),
  1944. 0 );
  1945. }
  1946. #define ALLOC_NDIS_WORK_ITEM( pA ) \
  1947. NdisAllocateFromNPagedLookasideList( &(pA)->llistWorkItems )
  1948. #define FREE_NDIS_WORK_ITEM( pA, pNwi ) \
  1949. NdisFreeToNPagedLookasideList( &(pA)->llistWorkItems, (pNwi) )
  1950. #define ALLOC_TIMERQITEM( pA ) \
  1951. NdisAllocateFromNPagedLookasideList( &(pA)->llistTimerQItems )
  1952. #define FREE_TIMERQITEM( pA, pTqi ) \
  1953. NdisFreeToNPagedLookasideList( &(pA)->llistTimerQItems, (pTqi) )
  1954. #define ALLOC_TUNNELCB( pA ) \
  1955. ALLOC_NONPAGED( sizeof(TUNNELCB), MTAG_TUNNELCB )
  1956. #define FREE_TUNNELCB( pA, pT ) \
  1957. FREE_NONPAGED( pT )
  1958. #define ALLOC_VCCB( pA ) \
  1959. ALLOC_NONPAGED( sizeof(VCCB), MTAG_VCCB )
  1960. #define FREE_VCCB( pA, pV ) \
  1961. FREE_NONPAGED( pV )
  1962. #define ALLOC_TIMERQ( pA ) \
  1963. ALLOC_NONPAGED( sizeof(TIMERQ), MTAG_TIMERQ )
  1964. #define FREE_TIMERQ( pA, pTq ) \
  1965. FREE_NONPAGED( pTq )
  1966. //
  1967. // Log packet macro
  1968. //
  1969. #ifdef PKT_LOG
  1970. #define NIC1394_ALLOC_PKTLOG(_pAdapter) \
  1971. nic1394AllocPktLog(_pAdapter)
  1972. #define NIC1394_DEALLOC_PKTLOG(_pAdapter) \
  1973. Nic1394DeallocPktLog(_pAdapter)
  1974. #define NIC1394_LOG_PKT(_pAdapter, _Flags, _SourceID, _DestID, _pvData, _cbData)\
  1975. (((_pAdapter)->pPktLog) ? \
  1976. Nic1394LogPkt( \
  1977. (_pAdapter)->pPktLog, \
  1978. (_Flags), \
  1979. (_SourceID), \
  1980. (_DestID), \
  1981. (_pvData), \
  1982. (_cbData) \
  1983. ) \
  1984. : 0)
  1985. #else
  1986. #define NIC1394_ALLOC_PKTLOG(_pAdapter)
  1987. #define NIC1394_DEALLOC_PKTLOG(_pAdapter)
  1988. #define NIC1394_LOG_PKT(_pAdapter, _Flags, _SourceID, _DestID, _pvData, _cbData)
  1989. #endif
  1990. #define NIC1394_LOGFLAGS_RECV_CHANNEL 0x00000001
  1991. #define NIC1394_LOGFLAGS_SEND_FIFO 0x00000010
  1992. #define NIC1394_LOGFLAGS_SEND_CHANNEL 0x00000011
  1993. #define NIC1394_LOGFLAGS_RECV_FIFO 0x00000100
  1994. #define NIC1394_LOGFLAGS_BCM_FAILED 0x00001000
  1995. #define NIC1394_LOGFLAGS_BCM_IS_IRM_TIMEOUT 0x00002000
  1996. #define NIC1394_LOGFLAGS_BCM_NOT_IRM_TIMEOUT 0x00004000
  1997. #define NIC1394_LOGFLAGS_BCM_IRM_NOT_FOUND 0x00008000
  1998. #if 0
  1999. //
  2000. // To get the MaxRec we extract the 0xf000 nibble
  2001. //
  2002. #define GET_MAXREC_FROM_BUSCAPS(_pBus, _pMaxRec) \
  2003. { \
  2004. ULONG _LitEnd = SWAPBYTES_ULONG(_pBus); \
  2005. _LitEnd = _LitEnd & 0xf000; \
  2006. _LitEnd = _LitEnd >> 12; \
  2007. *(_pBusRec) = _LitEnd; \
  2008. }
  2009. #endif
  2010. //
  2011. // To get the MaxRec we extract the 0xf000 nibble
  2012. //
  2013. #define GET_MAXREC_FROM_BUSCAPS(_Bus) (((_Bus) & 0xf00000) >> 20);
  2014. //-----------------------------------------------------------------------------
  2015. // F L A G S & L O C K S
  2016. //-----------------------------------------------------------------------------
  2017. //
  2018. // These macros are just present to make accessing the VC's flags easier
  2019. // and concentrate the implementations at one place
  2020. //
  2021. #define VC_TEST_FLAG(_V, _F) ((nicReadFlags(&(_V)->Hdr.ulFlags) & (_F))!= 0)
  2022. #define VC_SET_FLAG(_V, _F) (nicSetFlags(&(_V)->Hdr.ulFlags, (_F)))
  2023. #define VC_CLEAR_FLAGS(_V, _F) (nicClearFlags(&(_V)->Hdr.ulFlags , (_F)))
  2024. #define VC_TEST_FLAGS(_V, _F) ((nicReadFlags(&(_V)->Hdr.ulFlags) & (_F)) == (_F))
  2025. #define VC_READ_FLAGS(_V) ((nicReadFlags(&(_V)->Hdr.ulFlags)
  2026. #define VC_ACTIVE(_V) (((_V)->Hdr.ulFlags & (VCBF_CloseCallPending | VCBF_VcDeleted | VCBF_VcActivated |VCBF_MakeCallPending )) == VCBF_VcActivated)
  2027. #define REMOTE_NODE_TEST_FLAG(_P, _F ) ((nicReadFlags(&(_P)->ulFlags) & (_F))!= 0)
  2028. #define REMOTE_NODE_SET_FLAG(_P, _F) (nicSetFlags(&(_P)->ulFlags, (_F)))
  2029. #define REMOTE_NODE_CLEAR_FLAGS(_P, _F) (nicClearFlags(&(_P)->ulFlags , (_F)))
  2030. #define REMOTE_NODE_TEST_FLAGS(_P, _F) ((nicReadFlags(&(_P)->ulFlags) & (_F)) == (_F))
  2031. #define REMOTE_NODE_READ_FLAGS(_P) ((nicReadFlags(&(_P)->ulFlags)
  2032. #define REMOTE_NODE_ACTIVE(_P) (((_P)->ulFlags & (PDO_Activated | PDO_BeingRemoved)) == PDO_Activated)
  2033. #define ADAPTER_TEST_FLAG(_A, _F) ((nicReadFlags(&(_A)->ulFlags) & (_F))!= 0)
  2034. #define ADAPTER_SET_FLAG(_A, _F) (nicSetFlags(&(_A)->ulFlags, (_F)))
  2035. #define ADAPTER_CLEAR_FLAG(_A, _F) (nicClearFlags(&(_A)->ulFlags , (_F)))
  2036. #define ADAPTER_TEST_FLAGS(_A, _F) ((nicReadFlags(&(_A)->ulFlags) & (_F)) == (_F))
  2037. #define ADAPTER_READ_FLAGS(_A) ((nicReadFlags(&(_A)->ulFlags)
  2038. #define ADAPTER_ACTIVE(_A) ((((_A)->ulFlags) & fADAPTER_VDOInactive) != fADAPTER_VDOInactive)
  2039. #define BCR_TEST_FLAG(_A, _F) ((nicReadFlags(&(_A)->BCRData.Flags) & (_F))!= 0)
  2040. #define BCR_SET_FLAG(_A, _F) (nicSetFlags(&(_A)->BCRData.Flags, (_F)))
  2041. #define BCR_CLEAR_FLAG(_A, _F) (nicClearFlags(&(_A)->BCRData.Flags , (_F)))
  2042. #define BCR_CLEAR_ALL_FLAGS(_A) ((_A)->BCRData.Flags = 0)
  2043. #define BCR_TEST_FLAGS(_A, _F) ((nicReadFlags(&(_A)->BCRData.Flags) & (_F)) != 0)
  2044. #define BCR_READ_FLAGS(_A) ((nicReadFlags(&(_A)->BCRData.Flags)
  2045. #define BCR_IS_VALID(_B) ((_B)->NC_One == 1 && (_B)->NC_Valid ==1)
  2046. #define IS_A_BCR(_B) ((_B)->NC_One == 1 )
  2047. #define LOOKASIDE_HEADER_SET_FLAG(_H, _F) (nicSetFlags(&(_H)->State.u.Flags, (_F)))
  2048. #define LOOKASIDE_HEADER_TEST_FLAG(_H, _F) ((nicReadFlags(&(_H)->State.u.Flags) & (_F))!= 0)
  2049. #define REASSEMBLY_ACTIVE(_R) (((_R)->Flags & (REASSEMBLY_ABORTED | REASSEMBLY_FREED)) == 0)
  2050. #define REASSEMBLY_TEST_FLAG(_R,_F) ((nicReadFlags(&(_R)->Flags) & (_F))!= 0)
  2051. #define REASSEMBLY_SET_FLAG(_R,_F) (nicSetFlags(&(_R)->Flags, (_F)))
  2052. #define REASSEMBLY_CLEAR_FLAG(_R,_F) (nicClearFlags(&(_R)->Flags , (_F)))
  2053. #define NIC_GET_SYSTEM_ADDRESS_FOR_MDL(_M) MmGetSystemAddressForMdl(_M)
  2054. #define NIC_GET_BYTE_COUNT_FOR_MDL(_M) MmGetMdlByteCount(_M)
  2055. #define nicNdisBufferVirtualAddress(_N) NdisBufferVirtualAddress(_N)
  2056. #define nicNdisBufferLength(_N) NdisBufferLength(_N)
  2057. //
  2058. // These macros are used to assert that the IRQL level remains the same
  2059. // at the beginning and end of a function
  2060. //
  2061. #if DBG
  2062. #define STORE_CURRENT_IRQL UCHAR OldIrql = KeGetCurrentIrql();
  2063. #define MATCH_IRQL ASSERT (OldIrql == KeGetCurrentIrql() );
  2064. #else
  2065. #define STORE_CURRENT_IRQL
  2066. #define MATCH_IRQL
  2067. #endif // if DBG
  2068. #define nicInitializeCallRef(_pV) nicInitializeRef (&(_pV)->Hdr.CallRef);
  2069. #define nicCloseCallRef(_pV) nicCloseRef (&(_pV)->Hdr.CallRef);
  2070. //
  2071. // Macros used to acquire and release lock by the data structures (Vc, AF, Adapter)
  2072. // Right now, they all point to the same lock (i.e.) the lock in the Adapter structure
  2073. //
  2074. #define VC_ACQUIRE_LOCK(_pVc) NdisAcquireSpinLock (_pVc->Hdr.plock);
  2075. #define VC_RELEASE_LOCK(_pVc) NdisReleaseSpinLock (_pVc->Hdr.plock);
  2076. #define AF_ACQUIRE_LOCK(_pAF) NdisAcquireSpinLock (&_pAF->pAdapter->lock);
  2077. #define AF_RELEASE_LOCK(_pAF) NdisReleaseSpinLock (&_pAF->pAdapter->lock);
  2078. #define ADAPTER_ACQUIRE_LOCK(_pA) NdisAcquireSpinLock (&_pA->lock);
  2079. #define ADAPTER_RELEASE_LOCK(_pA) NdisReleaseSpinLock (&_pA->lock);
  2080. #define REMOTE_NODE_ACQUIRE_LOCK(_pP) NdisAcquireSpinLock (&_pP->pAdapter->lock);
  2081. #define REMOTE_NODE_RELEASE_LOCK(_pP) NdisReleaseSpinLock (&_pP->pAdapter->lock);
  2082. #define REASSEMBLY_ACQUIRE_LOCK(_R) REMOTE_NODE_REASSEMBLY_ACQUIRE_LOCK(_R->pRemoteNode);
  2083. #define REASSEMBLY_RELEASE_LOCK(_R) REMOTE_NODE_REASSEMBLY_RELEASE_LOCK(_R->pRemoteNode);
  2084. #ifdef TRACK_LOCKS
  2085. #define REMOTE_NODE_REASSEMBLY_ACQUIRE_LOCK(_Remote) \
  2086. nicAcquireSpinLock (&_Remote->ReassemblyLock , __FILE__ , __LINE__);
  2087. #define REMOTE_NODE_REASSEMBLY_RELEASE_LOCK(_Remote) \
  2088. nicReleaseSpinLock (&_Remote->ReassemblyLock , __FILE__ , __LINE__);
  2089. #else
  2090. #define REMOTE_NODE_REASSEMBLY_ACQUIRE_LOCK(_Remote) NdisAcquireSpinLock (&_Remote->ReassemblyLock.NdisLock);
  2091. #define REMOTE_NODE_REASSEMBLY_RELEASE_LOCK(_Remote) NdisReleaseSpinLock (&_Remote->ReassemblyLock.NdisLock);
  2092. #endif
  2093. #define REASSEMBLY_APPEND_FRAG_DESC(_pR, _Off, _Len) \
  2094. _pR->FragTable[_pR->MaxOffsetTableIndex].Offset =_Off; \
  2095. _pR->FragTable[_pR->MaxOffsetTableIndex].IPLength = _Len; \
  2096. _pR->MaxOffsetTableIndex++;
  2097. //-----------------------------------------------------------------------------
  2098. // S T A T S & F A I L U R E M A C R O S
  2099. //-----------------------------------------------------------------------------
  2100. // Used to distinguish stats collected that are collected in the various code paths
  2101. typedef enum
  2102. {
  2103. ChannelCodePath,
  2104. FifoCodePath,
  2105. ReceiveCodePath,
  2106. NoMoreCodePaths
  2107. };
  2108. #if TRACK_FAILURE
  2109. extern ULONG BusFailure;
  2110. extern ULONG MallocFailure;
  2111. extern ULONG IsochOverwrite;
  2112. extern ULONG MaxIndicatedFifos;
  2113. #define nicInitTrackFailure() BusFailure = 0;MallocFailure= 0;
  2114. #define nicIncrementBusFailure() NdisInterlockedIncrement(&BusFailure);
  2115. #define nicIncrementMallocFailure() NdisInterlockedIncrement(&MallocFailure);
  2116. #define nicIsochOverwritten() NdisInterlockedIncrement(&IsochOverwrite);
  2117. #define nicStatsRecordNumIndicatedFifos(_Num) \
  2118. { \
  2119. ULONG _N_ = (_Num); \
  2120. MaxIndicatedFifos = max((_N_), MaxIndicatedFifos); \
  2121. }
  2122. #define nicIncChannelSendMdl() NdisInterlockedIncrement(&MdlsAllocated[ChannelCodePath]);
  2123. #define nicIncFifoSendMdl() NdisInterlockedIncrement(&MdlsAllocated[FifoCodePath]);
  2124. #define nicDecChannelSendMdl() NdisInterlockedIncrement(&MdlsFreed[ChannelCodePath]);
  2125. #define nicDecFifoSendMdl() NdisInterlockedIncrement(&MdlsFreed[FifoCodePath]);
  2126. #define nicIncChannelRecvBuffer() NdisInterlockedIncrement(&NdisBufferAllocated[ChannelCodePath]);
  2127. #define nicIncFifoRecvBuffer() NdisInterlockedIncrement(&NdisBufferAllocated[FifoCodePath]);
  2128. #define nicDecChannelRecvBuffer() NdisInterlockedIncrement(&NdisBufferFreed[ChannelCodePath]);
  2129. #define nicDecFifoRecvBuffer() NdisInterlockedIncrement(&NdisBufferFreed[FifoCodePath]);
  2130. #define nicIncRecvBuffer(_bisFifo) \
  2131. { \
  2132. if (_bisFifo) \
  2133. { nicIncFifoRecvBuffer(); } \
  2134. else \
  2135. { nicIncChannelRecvBuffer();} \
  2136. }
  2137. #define nicDecRecvBuffer(_bisFifo) \
  2138. { \
  2139. if (_bisFifo) \
  2140. { nicDecFifoRecvBuffer(); } \
  2141. else \
  2142. { nicDecChannelRecvBuffer(); }\
  2143. }
  2144. #else
  2145. #define nicInitTrackFailure()
  2146. #define nicIncrementBusFailure()
  2147. #define nicIncrementMallocFailure()
  2148. #define nicIsochOverwritten()
  2149. #define nicStatsRecordNumIndicatedFifos(_Num)
  2150. #define nicIncChannelSendMdl()
  2151. #define nicIncFifoSendMdl()
  2152. #define nicDecChannelSendMdl()
  2153. #define nicDecFifoSendMdl()
  2154. #define nicFreeMdlRecordStat()
  2155. #endif
  2156. #define nicInitQueueStats()
  2157. #define nicSetCountInHistogram(_PktsInQueue, _Stats)
  2158. #define nicSetMax(_nicMax, _PktsInQueue)
  2159. #define nicIncrementRcvTimerCount()
  2160. #define nicIncrementSendTimerCount()
  2161. //
  2162. // Isoch descriptor macros - Used in the send/recv code path
  2163. //
  2164. typedef enum
  2165. {
  2166. IsochNext,
  2167. IsochTag,
  2168. IsochChannelVc,
  2169. MaxIsochContextIndex
  2170. } IsochContextIndex;
  2171. //
  2172. // The following structure is used to add more contexts to a work item.
  2173. // NOTE: the Adapter is passed in as the context always.
  2174. //
  2175. typedef union _NIC_WORK_ITEM
  2176. {
  2177. NDIS_WORK_ITEM NdisWorkItem;
  2178. struct{
  2179. NDIS_WORK_ITEM NdisWorkItem;
  2180. PNDIS_REQUEST pNdisRequest;
  2181. VCCB* pVc;
  2182. } RequestInfo;
  2183. struct{
  2184. NDIS_WORK_ITEM NdisWorkItem;
  2185. ULONG Start;
  2186. PNDIS_REQUEST pNdisRequest;
  2187. } StartArpInfo;
  2188. struct {
  2189. NDIS_WORK_ITEM NdisWorkItem;
  2190. } Fifo;
  2191. } NIC_WORK_ITEM, *PNIC_WORK_ITEM;
  2192. #define STORE_CHANNELVC_IN_DESCRIPTOR(_pI,_pVc) (_pI)->DeviceReserved[IsochChannelVc] =(ULONG_PTR) _pVc
  2193. #define GET_CHANNELVC_FROM_DESCRIPTOR(_pI) (_pI)->DeviceReserved[IsochChannelVc]
  2194. #define MARK_ISOCH_DESCRIPTOR_INDICATED(_pI) \
  2195. (_pI)->DeviceReserved[IsochTag] = (ULONG)NIC1394_TAG_INDICATED; \
  2196. (_pI)->DeviceReserved[IsochNext] = 0;
  2197. #define MARK_ISOCH_DESCRIPTOR_IN_REASSEMBLY(_pI) \
  2198. (_pI)->DeviceReserved[IsochTag] = (ULONG)NIC1394_TAG_REASSEMBLY;
  2199. #define CLEAR_DESCRIPTOR_OF_NDIS_TAG(_pI) \
  2200. (_pI)->DeviceReserved[IsochTag] = 0;
  2201. #define APPEND_ISOCH_DESCRIPTOR(_Old, _New) \
  2202. (_Old)->DeviceReserved[IsochNext] = (ULONG_PTR)&((_New)->DeviceReserved[IsochNext]);
  2203. #define NEXT_ISOCH_DESCRIPTOR(_pI) (_pI)->DeviceReserved[IsochNext]
  2204. #define CLEAR_DESCRIPTOR_NEXT(_pI) (_pI)->DeviceReserved[IsochNext] = 0;
  2205. #define GET_MDL_FROM_IRB(_pM, _pI, _Op) \
  2206. if (_Op==AsyncWrite) \
  2207. { \
  2208. _pM = _pI->u.AsyncWrite.Mdl; \
  2209. } \
  2210. else \
  2211. { \
  2212. ASSERT (_Op == AsyncStream); \
  2213. _pM = _pI->u.AsyncStream.Mdl ; \
  2214. }
  2215. //
  2216. // Macros used to walk a doubly linked list. Only macros that are not defined in ndis.h
  2217. // The List Next macro will work on Single and Doubly linked list as Flink is a common
  2218. // field name in both
  2219. //
  2220. /*
  2221. PLIST_ENTRY
  2222. ListNext (
  2223. IN PLIST_ENTRY
  2224. );
  2225. PSINGLE_LIST_ENTRY
  2226. ListNext (
  2227. IN PSINGLE_LIST_ENTRY
  2228. );
  2229. */
  2230. #define ListNext(_pL) (_pL)->Flink
  2231. /*
  2232. PLIST_ENTRY
  2233. ListPrev (
  2234. IN LIST_ENTRY *
  2235. );
  2236. */
  2237. #define ListPrev(_pL) (_pL)->Blink
  2238. #define OnlyElementInList(_pL) (_pL->Flink == _pL->Blink ? TRUE : FALSE)
  2239. #define BREAK(_TM_Mode, _String) \
  2240. { \
  2241. TRACE( TL_A, _TM_Mode, ( _String ) ); \
  2242. break; \
  2243. }
  2244. // USHORT
  2245. // SWAPBYTES_USHORT(USHORT Val )
  2246. //
  2247. #define SWAPBYTES_USHORT(Val) \
  2248. ((((Val) & 0xff) << 8) | (((Val) & 0xff00) >> 8))
  2249. // ULONG
  2250. // SWAPBYTES_ULONG(ULONG Val )
  2251. //
  2252. #define SWAPBYTES_ULONG(Val) \
  2253. ((((Val) & 0x000000ff) << 24) | \
  2254. (((Val) & 0x0000ff00) << 8) | \
  2255. (((Val) & 0x00ff0000) >> 8) | \
  2256. (((Val) & 0xff000000) >> 24) )
  2257. //
  2258. // nicRemoveEntry List
  2259. // Just add a check to make sure that we are actually pointing to a valid next
  2260. //
  2261. #define nicRemoveEntryList(_L) \
  2262. { \
  2263. ASSERT ((_L)->Flink != (_L)); \
  2264. RemoveEntryList (_L); \
  2265. }
  2266. //#define nicFreeToNPagedLookasideList(_L, _E) NdisFreeToNPagedLookasideList(_L, _E)
  2267. //#define nicDeleteLookasideList(_L) NdisDeleteNPagedLookasideList(_L)
  2268. //
  2269. // Timing Query Routines
  2270. //
  2271. #define nicQueryTickCount() \
  2272. LARGE_INTEGER TickStart; \
  2273. KeQueryTickCount(&TickStart);
  2274. #define nicPrintElapsedTicks(_s) \
  2275. { \
  2276. LARGE_INTEGER TickEnd, TickDiff; \
  2277. ULONG Increment = KeQueryTimeIncrement() ; \
  2278. KeQueryTickCount(&TickEnd); \
  2279. TickDiff.QuadPart = TickEnd.QuadPart - TickStart.QuadPart; \
  2280. TickDiff.QuadPart = (TickDiff.QuadPart * Increment); \
  2281. DbgPrint (_s); \
  2282. DbgPrint(" TickStart %x %x, Time End %x %x Time Diff %x %x Increment %x\n",TickStart.HighPart , TickStart.LowPart , TickEnd.HighPart, TickEnd.LowPart, TickDiff.HighPart, TickDiff.LowPart, Increment); \
  2283. }
  2284. #define nicEntryTimeStamp() \
  2285. UINT EntryMilliSec; \
  2286. EntryMilliSec= nicGetSystemTimeMilliSeconds();
  2287. #if DO_TIMESTAMPS
  2288. void
  2289. nicTimeStamp(
  2290. char *szFormatString,
  2291. UINT Val
  2292. );
  2293. #define TIMESTAMP(_FormatString) nicTimeStamp("TIMESTAMP %lu:%lu.%lu nic1394 " _FormatString "\n" , 0)
  2294. #define TIMESTAMP1(_FormatString, _Val) nicTimeStamp( "TIMESTAMP %lu:%lu.%lu ARP1394 " _FormatString "\n" , (_Val))
  2295. #else // !DO_TIMESTAMPS
  2296. #define TIMESTAMP(_FormatString)
  2297. #define TIMESTAMP1(_FormatString, _Val)
  2298. #endif // !DO_TIMESTAMPS
  2299. #if ENTRY_EXIT_TIME
  2300. #define TIMESTAMP_ENTRY(_String) TIMESTAMP(_String)
  2301. #define TIMESTAMP_EXIT(_String) TIMESTAMP(_String)
  2302. #else
  2303. #define TIMESTAMP_ENTRY(s);
  2304. #define TIMESTAMP_EXIT(s);
  2305. #endif
  2306. #if INIT_HALT_TIME
  2307. #define TIMESTAMP_INITIALIZE() TIMESTAMP("==>InitializeHandler");
  2308. #define TIMESTAMP_HALT() TIMESTAMP("<==Halt");
  2309. #else
  2310. #define TIMESTAMP_INITIALIZE()
  2311. #define TIMESTAMP_HALT()
  2312. #endif
  2313. //-----------------------------------------------------------------------------
  2314. // S T A T I S T I C M A C R O S
  2315. //-----------------------------------------------------------------------------
  2316. //
  2317. // Reasembly counts
  2318. //
  2319. #define nicReassemblyStarted(_pAdapter) \
  2320. { \
  2321. NdisInterlockedIncrement( &(_pAdapter->AdaptStats.TempStats.ulNumOutstandingReassemblies)); \
  2322. NdisInterlockedIncrement ( &(_pAdapter->Reassembly.PktsInQueue)); \
  2323. NdisInterlockedIncrement ( &(_pAdapter->OutstandingReassemblies));\
  2324. }
  2325. #define nicReassemblyCompleted(_A) \
  2326. { \
  2327. NdisInterlockedDecrement(&(_A->AdaptStats.TempStats.ulNumOutstandingReassemblies));\
  2328. NdisInterlockedDecrement(&(_A->Reassembly.PktsInQueue));\
  2329. NdisInterlockedDecrement ( &(_A->OutstandingReassemblies));\
  2330. }
  2331. #define nicReassemblyAborted(_A) \
  2332. { \
  2333. NdisInterlockedDecrement ( &(_A->OutstandingReassemblies)); \
  2334. NdisInterlockedIncrement (&(_A->AdaptStats.TempStats.ulAbortedReassemblies)); \
  2335. }
  2336. //
  2337. // Top level stat collection macros
  2338. //
  2339. #define nicIncrementRcvVcPktCount(_Vc, _Pkt) \
  2340. { \
  2341. if ((_Vc)->Hdr.VcType == NIC1394_RecvFIFO) \
  2342. { \
  2343. nicIncrementFifoRcvPktCount(_Vc, _Pkt); \
  2344. } \
  2345. else \
  2346. { \
  2347. nicIncrementChannelRcvPktCount(_Vc, _Pkt); \
  2348. } \
  2349. }
  2350. #define nicIncrementVcSendPktCount(_Vc, _Pkt) \
  2351. { \
  2352. if ((_Vc)->Hdr.VcType == NIC1394_SendFIFO) \
  2353. { \
  2354. nicIncrementFifoSendPktCount(_Vc, _Pkt); \
  2355. } \
  2356. else \
  2357. { \
  2358. nicIncrementChannelSendPktCount(_Vc, _Pkt); \
  2359. } \
  2360. }
  2361. #define nicIncrementVcSendFailures(_Vc, _Pkt) \
  2362. { \
  2363. if ((_Vc)->Hdr.VcType == NIC1394_SendFIFO) \
  2364. { \
  2365. nicIncrementFifoSendFailures(_Vc, _Pkt); \
  2366. } \
  2367. else \
  2368. { \
  2369. nicIncrementChannelSendFailures(_Vc, _Pkt); \
  2370. } \
  2371. }
  2372. #define nicIncrementVcBusSendFailures(_Vc, _Pkt) \
  2373. { \
  2374. if ((_Vc)->Hdr.VcType == NIC1394_SendFIFO) \
  2375. { \
  2376. nicIncrementFifoBusSendFailures(_Vc, _Pkt); \
  2377. } \
  2378. else \
  2379. { \
  2380. nicIncrementChannelBusSendFailures(_Vc, _Pkt); \
  2381. } \
  2382. }
  2383. #define nicIncrementVcBusSendSucess(_Vc, _Pkt) \
  2384. { \
  2385. if ((_Vc)->Hdr.VcType == NIC1394_SendFIFO) \
  2386. { \
  2387. nicIncrementFifoBusSendSucess(_Vc, _Pkt); \
  2388. } \
  2389. else \
  2390. { \
  2391. nicIncrementChannelBusSendSucess(_Vc, _Pkt); \
  2392. } \
  2393. }
  2394. //
  2395. // Fifo counts
  2396. //
  2397. #define nicIncrementFifoSendPktCount(_Vc, _Pkt) NdisInterlockedIncrement(&((_Vc)->Hdr.pAF->pAdapter->AdaptStats.TempStats.Fifo.ulSendNicSucess));
  2398. #define nicIncrementFifoSendFailures(_Vc, _Pkt) NdisInterlockedIncrement(&((_Vc)->Hdr.pAF->pAdapter->AdaptStats.TempStats.Fifo.ulSendNicFail));
  2399. #define nicIncrementFifoBusSendFailures(_Vc,_Pkt) NdisInterlockedIncrement(&((_Vc)->Hdr.pAF->pAdapter->AdaptStats.TempStats.Fifo.ulSendBusFail));
  2400. #define nicIncrementFifoBusSendSucess(_Vc,_Pkt) NdisInterlockedIncrement(&((_Vc)->Hdr.pAF->pAdapter->AdaptStats.TempStats.Fifo.ulSendBusSuccess));
  2401. #define nicIncrementFifoRcvPktCount(_Vc, _Pkt) NdisInterlockedIncrement(&((_Vc)->Hdr.pAF->pAdapter->AdaptStats.TempStats.Fifo.ulRecv));
  2402. //
  2403. // Channel Counts
  2404. //
  2405. #define nicIncrementChannelSendPktCount(_Vc, _Pkt) NdisInterlockedIncrement(&((_Vc)->Hdr.pAF->pAdapter->AdaptStats.TempStats.Channel.ulSendNicSucess));
  2406. #define nicIncrementChannelSendFailures(_Vc, _Pkt) NdisInterlockedIncrement(&((_Vc)->Hdr.pAF->pAdapter->AdaptStats.TempStats.Channel.ulSendNicFail));
  2407. #define nicIncrementChannelBusSendFailures(_Vc,_Pkt) NdisInterlockedIncrement(&((_Vc)->Hdr.pAF->pAdapter->AdaptStats.TempStats.Channel.ulSendBusFail));
  2408. #define nicIncrementChannelBusSendSucess(_Vc, _Pkt) NdisInterlockedIncrement(&((_Vc)->Hdr.pAF->pAdapter->AdaptStats.TempStats.Channel.ulSendBusSuccess));
  2409. #define nicIncrementChannelRcvPktCount(_Vc, _Pkt) NdisInterlockedIncrement(&((_Vc)->Hdr.pAF->pAdapter->AdaptStats.TempStats.Channel.ulRecv));
  2410. //
  2411. // Generic counts
  2412. //
  2413. #define nicIncrementSendCompletes(_Vc) NdisInterlockedIncrement(&((_Vc)->Hdr.pAF->pAdapter->AdaptStats.TempStats.ulNumSendsCompleted )); \
  2414. NdisInterlockedIncrement(&NicSendCompletes);
  2415. #define nicIncrementSends(_Vc) NdisInterlockedIncrement(&((_Vc)->Hdr.pAF->pAdapter->AdaptStats.TempStats.ulNumSends)); \
  2416. NdisInterlockedIncrement (&NicSends);
  2417. #define nicIncrementBusSends(_Vc) NdisInterlockedIncrement(&((_Vc)->Hdr.pAF->pAdapter->AdaptStats.TempStats.ulNumBusSends)); \
  2418. NdisInterlockedIncrement (&BusSends);
  2419. #define nicIncrementBusSendCompletes(_Vc) NdisInterlockedIncrement(&((_Vc)->Hdr.pAF->pAdapter->AdaptStats.TempStats.ulNumBusSendsCompleted )); \
  2420. NdisInterlockedIncrement(&BusSendCompletes);
  2421. //-----------------------------------------------------------------------------
  2422. // N I C E R R O R C O D E S
  2423. //-----------------------------------------------------------------------------
  2424. #define NIC_ERROR_CODE_INVALID_UNIQUE_ID_0 0xbad0000
  2425. #define NIC_ERROR_CODE_INVALID_UNIQUE_ID_FF 0xbadffff
  2426. //-----------------------------------------------------------------------------
  2427. // R E M O T E N O D E F U N C T I O N S
  2428. //-----------------------------------------------------------------------------
  2429. #if 0
  2430. VOID
  2431. NicMpNotifyHandler(
  2432. IN PDEVICE_OBJECT RemoteNodePhysicalDeviceObject,
  2433. IN PDEVICE_OBJECT LocalHostPhysicalDeviceObject,
  2434. IN ULONG UniqueId0,
  2435. IN ULONG UniqueId1,
  2436. IN NDIS1394ENUM_NOTIFY_CODE NotificationCode
  2437. );
  2438. #endif
  2439. NDIS_STATUS
  2440. nicInitializeRemoteNode(
  2441. OUT REMOTE_NODE **ppRemoteNode,
  2442. IN PDEVICE_OBJECT p1394DeviceObject,
  2443. IN UINT64 UniqueId
  2444. );
  2445. NTSTATUS
  2446. nicAddRemoteNode(
  2447. IN PVOID Nic1394AdapterContext, // Nic1394 handle for the local host adapter
  2448. IN PVOID Enum1394NodeHandle, // Enum1394 handle for the remote node
  2449. IN PDEVICE_OBJECT RemoteNodePhysicalDeviceObject, // physical device object for the remote node
  2450. IN ULONG UniqueId0, // unique ID Low for the remote node
  2451. IN ULONG UniqueId1, // unique ID High for the remote node
  2452. OUT PVOID * pNic1394NodeContext // Nic1394 context for the remote node
  2453. );
  2454. NTSTATUS
  2455. nicRemoveRemoteNode(
  2456. IN PVOID Nic1394NodeContext // Nic1394 context for the remote node
  2457. );
  2458. NDIS_STATUS
  2459. nicFindRemoteNodeFromAdapter(
  2460. IN PADAPTERCB pAdapter,
  2461. IN PDEVICE_OBJECT pRemotePdo,
  2462. IN UINT64 UniqueId,
  2463. IN OUT REMOTE_NODE ** ppRemoteNode
  2464. );
  2465. NDIS_STATUS
  2466. nicGetLocalHostPdoBlock (
  2467. IN PVCCB pVc,
  2468. IN OUT REMOTE_NODE **ppRemoteNode
  2469. );
  2470. NDIS_STATUS
  2471. nicRemoteNodeRemoveVcCleanUp (
  2472. IN PREMOTE_NODE pRemoteNode
  2473. );
  2474. UINT
  2475. nicNumOfActiveRemoteNodes(
  2476. IN PADAPTERCB pAdapter
  2477. );
  2478. BOOLEAN
  2479. nicReferenceRemoteNode (
  2480. IN REMOTE_NODE *pRemoteNode,
  2481. IN REMOTE_NODE_REF_CAUSE Cause
  2482. );
  2483. BOOLEAN
  2484. nicDereferenceRemoteNode (
  2485. IN REMOTE_NODE *pRemoteNode,
  2486. IN REMOTE_NODE_REF_CAUSE Cause
  2487. );
  2488. VOID
  2489. nicInitalizeRefRemoteNode(
  2490. IN REMOTE_NODE *pRemoteNode
  2491. );
  2492. BOOLEAN
  2493. nicCloseRefRemoteNode(
  2494. IN REMOTE_NODE *pRemoteNode
  2495. );
  2496. //-----------------------------------------------------------------------------
  2497. // U T I L I T Y F U N C T I O N S
  2498. //-----------------------------------------------------------------------------
  2499. VOID
  2500. nicCallCleanUp(
  2501. IN VCCB* pVc
  2502. );
  2503. VOID
  2504. nicClearFlags(
  2505. IN OUT ULONG* pulFlags,
  2506. IN ULONG ulMask
  2507. );
  2508. BOOLEAN
  2509. nicCloseRef(
  2510. IN PREF RefP
  2511. );
  2512. VOID
  2513. nicReferenceAdapter(
  2514. IN ADAPTERCB* pAdapter ,
  2515. IN PCHAR pDebugPrint
  2516. );
  2517. BOOLEAN
  2518. nicDereferenceCall(
  2519. IN VCCB* pVc,
  2520. IN PCHAR pDebugPrint
  2521. );
  2522. BOOLEAN
  2523. nicDereferenceRef(
  2524. IN PREF RefP,
  2525. IN PLONG pRefCount
  2526. );
  2527. VOID
  2528. nicDereferenceAdapter(
  2529. IN PADAPTERCB pAdapter,
  2530. IN PCHAR pDebugPrint
  2531. );
  2532. VOID
  2533. nicDereferenceVc(
  2534. IN VCCB* pVc
  2535. );
  2536. NDIS_STATUS
  2537. nicExecuteWork(
  2538. IN ADAPTERCB* pAdapter,
  2539. IN NDIS_PROC pProc,
  2540. IN PVOID pContext,
  2541. IN ULONG ulArg1,
  2542. IN ULONG ulArg2,
  2543. IN ULONG ulArg3,
  2544. IN ULONG ulArg4
  2545. );
  2546. VOID
  2547. nicInitializeRef(
  2548. IN PREF RefP
  2549. );
  2550. ULONG
  2551. nicReadFlags(
  2552. IN ULONG* pulFlags
  2553. );
  2554. VOID
  2555. nicReferenceAdapter(
  2556. IN ADAPTERCB* pAdapter,
  2557. IN PCHAR pDebugPrint
  2558. );
  2559. BOOLEAN
  2560. nicReferenceCall(
  2561. IN VCCB* pVc,
  2562. IN PCHAR pDebugPrint
  2563. );
  2564. BOOLEAN
  2565. nicReferenceRef(
  2566. IN PREF RefP,
  2567. OUT PLONG pNumber
  2568. );
  2569. VOID
  2570. nicReferenceVc(
  2571. IN VCCB* pVc
  2572. );
  2573. NDIS_STATUS
  2574. nicScheduleWork(
  2575. IN ADAPTERCB* pAdapter,
  2576. IN NDIS_PROC pProc,
  2577. IN PVOID pContext
  2578. );
  2579. VOID
  2580. nicSetFlags(
  2581. IN OUT ULONG* pulFlags,
  2582. IN ULONG ulMask
  2583. );
  2584. CHAR*
  2585. nicStrDup(
  2586. IN CHAR* psz
  2587. );
  2588. CHAR*
  2589. nicStrDupNdisString(
  2590. IN NDIS_STRING* pNdisString
  2591. );
  2592. CHAR*
  2593. nicStrDupSized(
  2594. IN CHAR* psz,
  2595. IN ULONG ulLength,
  2596. IN ULONG ulExtra
  2597. );
  2598. VOID
  2599. nicUpdateGlobalCallStats(
  2600. IN VCCB *pVc
  2601. );
  2602. NDIS_STATUS
  2603. NtStatusToNdisStatus (
  2604. NTSTATUS NtStatus
  2605. );
  2606. VOID
  2607. PrintNdisPacket (
  2608. ULONG TM_Comp,
  2609. PNDIS_PACKET pMyPacket
  2610. );
  2611. VOID
  2612. nicAllocatePacket(
  2613. OUT PNDIS_STATUS pNdisStatus,
  2614. OUT PNDIS_PACKET *ppNdisPacket,
  2615. IN PNIC_PACKET_POOL pPacketPool
  2616. );
  2617. VOID
  2618. nicFreePacket(
  2619. IN PNDIS_PACKET pNdisPacket,
  2620. IN PNIC_PACKET_POOL pPacketPool
  2621. );
  2622. VOID
  2623. nicFreePacketPool (
  2624. IN PNIC_PACKET_POOL pPacketPool
  2625. );
  2626. VOID
  2627. nicAcquireSpinLock (
  2628. IN PNIC_SPIN_LOCK pNicSpinLock,
  2629. IN PUCHAR FileName,
  2630. IN UINT LineNumber
  2631. );
  2632. VOID
  2633. nicReleaseSpinLock (
  2634. IN PNIC_SPIN_LOCK pNicSpinLock,
  2635. IN PUCHAR FileName,
  2636. IN UINT LineNumber
  2637. );
  2638. VOID
  2639. nicInitializeNicSpinLock (
  2640. IN PNIC_SPIN_LOCK pNicSpinLock
  2641. );
  2642. VOID
  2643. nicFreeNicSpinLock (
  2644. IN PNIC_SPIN_LOCK pNicSpinLock
  2645. );
  2646. VOID
  2647. nic1394DeallocPktLog(
  2648. IN ADAPTERCB* pAdapter
  2649. );
  2650. VOID
  2651. nic1394AllocPktLog(
  2652. IN ADAPTERCB* pAdapter
  2653. );
  2654. VOID
  2655. Nic1394LogPkt (
  2656. PNIC1394_PKTLOG pPktLog,
  2657. ULONG Flags,
  2658. ULONG SourceID,
  2659. ULONG DestID,
  2660. PVOID pvData,
  2661. ULONG cbData
  2662. );
  2663. VOID
  2664. Nic1394InitPktLog(
  2665. PNIC1394_PKTLOG pPktLog
  2666. );
  2667. ULONG
  2668. SwapBytesUlong(
  2669. IN ULONG Val
  2670. );
  2671. VOID
  2672. nicUpdatePacketState (
  2673. IN PNDIS_PACKET pPacket,
  2674. IN ULONG Tag
  2675. );
  2676. UINT
  2677. nicGetSystemTime(
  2678. VOID
  2679. );
  2680. UINT
  2681. nicGetSystemTimeMilliSeconds(
  2682. VOID
  2683. );
  2684. VOID
  2685. nicGetFakeMacAddress(
  2686. UINT64 *Euid,
  2687. MAC_ADDRESS *MacAddr
  2688. );
  2689. VOID
  2690. nicWriteErrorLog (
  2691. IN PADAPTERCB pAdapter,
  2692. IN NDIS_ERROR_CODE ErrorCode,
  2693. IN ULONG ErrorValue
  2694. );
  2695. NDIS_STATUS
  2696. nicScheduleWorkItem (
  2697. IN PADAPTERCB pAdapter,
  2698. IN PNDIS_WORK_ITEM pWorkItem
  2699. );
  2700. //-----------------------------------------------------------------------------
  2701. // G L O B A L V A R I A B L E S
  2702. //-----------------------------------------------------------------------------
  2703. UINT NumChannels;
  2704. //-----------------------------------------------------------------------------
  2705. // E N U M E R A T O R F U N C T I O N S
  2706. //-----------------------------------------------------------------------------
  2707. extern ENUM1394_REGISTER_DRIVER_HANDLER NdisEnum1394RegisterDriver;
  2708. extern ENUM1394_DEREGISTER_DRIVER_HANDLER NdisEnum1394DeregisterDriver;
  2709. extern ENUM1394_REGISTER_ADAPTER_HANDLER NdisEnum1394RegisterAdapter;
  2710. extern ENUM1394_DEREGISTER_ADAPTER_HANDLER NdisEnum1394DeregisterAdapter;
  2711. extern NIC1394_CHARACTERISTICS Nic1394Characteristics;
  2712. NTSTATUS
  2713. NicRegisterEnum1394(
  2714. IN PNDISENUM1394_CHARACTERISTICS NdisEnum1394Characteristcis
  2715. );
  2716. VOID
  2717. NicDeregisterEnum1394(
  2718. VOID
  2719. );
  2720. VOID
  2721. Nic1394Callback(
  2722. PVOID CallBackContext,
  2723. PVOID Source,
  2724. PVOID Characteristics
  2725. );
  2726. VOID
  2727. Nic1394RegisterAdapters(
  2728. VOID
  2729. );
  2730. NTSTATUS
  2731. Nic1394BusRequest(
  2732. PDEVICE_OBJECT DeviceObject,
  2733. PIRB Irb
  2734. );
  2735. NTSTATUS
  2736. Nic1394PassIrpDownTheStack(
  2737. IN PIRP pIrp,
  2738. IN PDEVICE_OBJECT pNextDeviceObject
  2739. );
  2740. NTSTATUS
  2741. Nic1394IrpCompletion(
  2742. IN PDEVICE_OBJECT DeviceObject,
  2743. IN PIRP Irp,
  2744. IN PVOID Context
  2745. );
  2746. VOID
  2747. nicDumpMdl (
  2748. IN PMDL pMdl,
  2749. IN ULONG LengthToPrint,
  2750. IN CHAR *str
  2751. );
  2752. VOID
  2753. nicDumpPkt (
  2754. IN PNDIS_PACKET pPacket,
  2755. CHAR * str
  2756. );
  2757. VOID
  2758. nicCheckForEthArps (
  2759. IN PNDIS_PACKET pPkt
  2760. );
  2761. VOID
  2762. nicGetMacAddressFromEuid (
  2763. UINT64 *pEuid,
  2764. MAC_ADDRESS *pMacAddr
  2765. );
  2766. VOID
  2767. nicInitializeLoadArpStruct(
  2768. PADAPTERCB pAdapter
  2769. );
  2770. extern PCALLBACK_OBJECT Nic1394CallbackObject;
  2771. extern PVOID Nic1394CallbackRegisterationHandle;
  2772. //-----------------------------------------------------------------------------
  2773. // S T A T I S T I C B U C K E T S
  2774. //-----------------------------------------------------------------------------
  2775. extern STAT_BUCKET SendStats;
  2776. extern STAT_BUCKET RcvStats;
  2777. extern ULONG nicMaxRcv;
  2778. extern ULONG nicMaxSend;
  2779. extern ULONG SendTimer; // In ms
  2780. extern ULONG RcvTimer; // In ms