Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

875 lines
26 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. mp.h
  5. Abstract:
  6. Miniport generic portion header file
  7. Revision History:
  8. Who When What
  9. -------- -------- ----------------------------------------------
  10. DChen 03-04-99 created
  11. Notes:
  12. --*/
  13. #ifndef _MP_H
  14. #define _MP_H
  15. #ifdef NDIS50_MINIPORT
  16. #define MP_NDIS_MAJOR_VERSION 5
  17. #define MP_NDIS_MINOR_VERSION 0
  18. #endif
  19. #ifdef NDIS51_MINIPORT
  20. #define MP_NDIS_MAJOR_VERSION 5
  21. #define MP_NDIS_MINOR_VERSION 1
  22. #endif
  23. #define ALIGN_16 16
  24. #ifndef MIN
  25. #define MIN(a, b) ((a) > (b) ? b: a)
  26. #endif
  27. //--------------------------------------
  28. // Queue structure and macros
  29. //--------------------------------------
  30. typedef struct _QUEUE_ENTRY
  31. {
  32. struct _QUEUE_ENTRY *Next;
  33. } QUEUE_ENTRY, *PQUEUE_ENTRY;
  34. typedef struct _QUEUE_HEADER
  35. {
  36. PQUEUE_ENTRY Head;
  37. PQUEUE_ENTRY Tail;
  38. } QUEUE_HEADER, *PQUEUE_HEADER;
  39. #define InitializeQueueHeader(QueueHeader) \
  40. { \
  41. (QueueHeader)->Head = (QueueHeader)->Tail = NULL; \
  42. }
  43. #define IsQueueEmpty(QueueHeader) ((QueueHeader)->Head == NULL)
  44. #define RemoveHeadQueue(QueueHeader) \
  45. (QueueHeader)->Head; \
  46. { \
  47. PQUEUE_ENTRY pNext; \
  48. ASSERT((QueueHeader)->Head); \
  49. pNext = (QueueHeader)->Head->Next; \
  50. (QueueHeader)->Head = pNext; \
  51. if (pNext == NULL) \
  52. (QueueHeader)->Tail = NULL; \
  53. }
  54. #define InsertHeadQueue(QueueHeader, QueueEntry) \
  55. { \
  56. ((PQUEUE_ENTRY)QueueEntry)->Next = (QueueHeader)->Head; \
  57. (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry); \
  58. if ((QueueHeader)->Tail == NULL) \
  59. (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry); \
  60. }
  61. #define InsertTailQueue(QueueHeader, QueueEntry) \
  62. { \
  63. ((PQUEUE_ENTRY)QueueEntry)->Next = NULL; \
  64. if ((QueueHeader)->Tail) \
  65. (QueueHeader)->Tail->Next = (PQUEUE_ENTRY)(QueueEntry); \
  66. else \
  67. (QueueHeader)->Head = (PQUEUE_ENTRY)(QueueEntry); \
  68. (QueueHeader)->Tail = (PQUEUE_ENTRY)(QueueEntry); \
  69. }
  70. //--------------------------------------
  71. // Common fragment list structure
  72. // Identical to the scatter gather frag list structure
  73. // This is created to simplify the NIC-specific portion code
  74. //--------------------------------------
  75. #define MP_FRAG_ELEMENT SCATTER_GATHER_ELEMENT
  76. #define PMP_FRAG_ELEMENT PSCATTER_GATHER_ELEMENT
  77. typedef struct _MP_FRAG_LIST {
  78. ULONG NumberOfElements;
  79. ULONG_PTR Reserved;
  80. MP_FRAG_ELEMENT Elements[NIC_MAX_PHYS_BUF_COUNT];
  81. } MP_FRAG_LIST, *PMP_FRAG_LIST;
  82. //--------------------------------------
  83. // Some utility macros
  84. //--------------------------------------
  85. #ifndef min
  86. #define min(_a, _b) (((_a) < (_b)) ? (_a) : (_b))
  87. #endif
  88. #ifndef max
  89. #define max(_a, _b) (((_a) > (_b)) ? (_a) : (_b))
  90. #endif
  91. #define MP_ALIGNMEM(_p, _align) ((_align == 0) ? (_p) : ((((ULONG_PTR)(_p) % _align) == 0) ? (_p) : ((PUCHAR)(_p) + _align)))
  92. #define MP_ALIGNMEM_PHYS(_p, _align) ((_align == 0) ? (_p) : ((((ULONG)(_p) % _align) == 0) ? (_p) : ((ULONG)(_p) + _align)))
  93. #define MP_ALIGNMEM_PA(_p, _align) ((_align == 0) ? (_p).QuadPart : ((((_p).QuadPart % _align) == 0) ? (_p).QuadPart : ((_p).QuadPart + _align)))
  94. #define GetListHeadEntry(ListHead) ((ListHead)->Flink)
  95. #define GetListTailEntry(ListHead) ((ListHead)->Blink)
  96. #define GetListFLink(ListEntry) ((ListEntry)->Flink)
  97. #define IsSListEmpty(ListHead) (((PSINGLE_LIST_ENTRY)ListHead)->Next == NULL)
  98. #define MP_EXIT goto exit
  99. //--------------------------------------
  100. // Memory manipulation macros
  101. //--------------------------------------
  102. /*++
  103. VOID
  104. MP_MEMSET(
  105. IN PVOID Pointer,
  106. IN ULONG Length,
  107. IN UCHAR Value
  108. )
  109. --*/
  110. #define MP_MEMSET(Pointer, Length, Value) NdisFillMemory(Pointer, Length, Value)
  111. /*++
  112. VOID
  113. MP_MEMCOPY(
  114. IN POPAQUE Destn,
  115. IN POPAQUE Source,
  116. IN ULONG Length
  117. )
  118. --*/
  119. #define MP_MEMCOPY(Destn, Source, Length) NdisMoveMemory((Destn), (Source), (Length))
  120. /*++
  121. ULONG
  122. MP_MEMCOPY(
  123. IN PVOID Destn,
  124. IN PVOID Source,
  125. IN ULONG Length
  126. )
  127. --*/
  128. #define MPMemCmp(Destn, Source, Length) \
  129. RtlCompareMemory((PUCHAR)(Destn), (PUCHAR)(Source), (ULONG)(Length))
  130. #if DBG
  131. /*++
  132. PVOID
  133. MP_ALLOCMEM(
  134. IN ULONG Size
  135. )
  136. --*/
  137. #define MP_ALLOCMEM(pptr, size, flags, highest) \
  138. MPAuditAllocMem(pptr, size, flags, highest, _FILENUMBER, __LINE__);
  139. #define MP_ALLOCMEMTAG(pptr, size) \
  140. MPAuditAllocMemTag(pptr, size, _FILENUMBER, __LINE__);
  141. /*++
  142. VOID
  143. MP_FREEMEM(
  144. IN PVOID Pointer
  145. )
  146. --*/
  147. #define MP_FREEMEM(ptr, size, flags) MPAuditFreeMem(ptr, size, flags)
  148. #else // DBG
  149. #define MP_ALLOCMEM(pptr, size, flags, highest) \
  150. NdisAllocateMemory(pptr, size, flags, highest)
  151. #define MP_ALLOCMEMTAG(pptr, size) \
  152. NdisAllocateMemoryWithTag(pptr, size, NIC_TAG)
  153. #define MP_FREEMEM(ptr, size, flags) NdisFreeMemory(ptr, size, flags)
  154. #endif
  155. #define MP_FREE_NDIS_STRING(str) \
  156. MP_FREEMEM((str)->Buffer, (str)->MaximumLength, 0); \
  157. (str)->Length = 0; \
  158. (str)->MaximumLength = 0; \
  159. (str)->Buffer = NULL;
  160. //--------------------------------------
  161. // Macros for flag and ref count operations
  162. //--------------------------------------
  163. #define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
  164. #define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
  165. #define MP_CLEAR_FLAGS(_M) ((_M)->Flags = 0)
  166. #define MP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0)
  167. #define MP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))
  168. #define MP_INC_REF(_A) NdisInterlockedIncrement(&(_A)->RefCount)
  169. #define MP_DEC_REF(_A) NdisInterlockedDecrement(&(_A)->RefCount); ASSERT(_A->RefCount >= 0)
  170. #define MP_GET_REF(_A) ((_A)->RefCount)
  171. #define MP_INC_RCV_REF(_A) ((_A)->RcvRefCount++)
  172. #define MP_DEC_RCV_REF(_A) ((_A)->RcvRefCount--)
  173. #define MP_GET_RCV_REF(_A) ((_A)->RcvRefCount)
  174. #define MP_LBFO_INC_REF(_A) NdisInterlockedIncrement(&(_A)->RefCountLBFO)
  175. #define MP_LBFO_DEC_REF(_A) NdisInterlockedDecrement(&(_A)->RefCountLBFO); ASSERT(_A->RefCountLBFO >= 0)
  176. #define MP_LBFO_GET_REF(_A) ((_A)->RefCountLBFO)
  177. //--------------------------------------
  178. // Coalesce Tx buffer for local data copying
  179. //--------------------------------------
  180. typedef struct _MP_TXBUF
  181. {
  182. SINGLE_LIST_ENTRY SList;
  183. PNDIS_BUFFER NdisBuffer;
  184. ULONG AllocSize;
  185. PVOID AllocVa;
  186. NDIS_PHYSICAL_ADDRESS AllocPa;
  187. PUCHAR pBuffer;
  188. NDIS_PHYSICAL_ADDRESS BufferPa;
  189. ULONG BufferSize;
  190. } MP_TXBUF, *PMP_TXBUF;
  191. //--------------------------------------
  192. // TCB (Transmit Control Block)
  193. //--------------------------------------
  194. typedef struct _MP_TCB
  195. {
  196. struct _MP_TCB *Next;
  197. ULONG Flags;
  198. ULONG Count;
  199. PNDIS_PACKET Packet;
  200. PMP_TXBUF MpTxBuf;
  201. PHW_TCB HwTcb; // ptr to HW TCB VA
  202. ULONG HwTcbPhys; // ptr to HW TCB PA
  203. PHW_TCB PrevHwTcb; // ptr to previous HW TCB VA
  204. PTBD_STRUC HwTbd; // ptr to first TBD
  205. ULONG HwTbdPhys; // ptr to first TBD PA
  206. ULONG PhysBufCount;
  207. ULONG BufferCount;
  208. PNDIS_BUFFER FirstBuffer;
  209. ULONG PacketLength;
  210. } MP_TCB, *PMP_TCB;
  211. //--------------------------------------
  212. // RFD (Receive Frame Descriptor)
  213. //--------------------------------------
  214. typedef struct _MP_RFD
  215. {
  216. LIST_ENTRY List;
  217. PNDIS_PACKET NdisPacket;
  218. PNDIS_BUFFER NdisBuffer; // Pointer to Buffer
  219. PHW_RFD HwRfd; // ptr to hardware RFD
  220. NDIS_PHYSICAL_ADDRESS HwRfdPa; // physical address of RFD
  221. ULONG HwRfdPhys; // lower part of HwRfdPa
  222. ULONG Flags;
  223. UINT PacketSize; // total size of receive frame
  224. } MP_RFD, *PMP_RFD;
  225. //--------------------------------------
  226. // Structure for pended OIS query request
  227. //--------------------------------------
  228. typedef struct _MP_QUERY_REQUEST
  229. {
  230. IN NDIS_OID Oid;
  231. IN PVOID InformationBuffer;
  232. IN ULONG InformationBufferLength;
  233. OUT PULONG BytesWritten;
  234. OUT PULONG BytesNeeded;
  235. } MP_QUERY_REQUEST, *PMP_QUERY_REQUEST;
  236. //--------------------------------------
  237. // Structure for pended OIS set request
  238. //--------------------------------------
  239. typedef struct _MP_SET_REQUEST
  240. {
  241. IN NDIS_OID Oid;
  242. IN PVOID InformationBuffer;
  243. IN ULONG InformationBufferLength;
  244. OUT PULONG BytesRead;
  245. OUT PULONG BytesNeeded;
  246. } MP_SET_REQUEST, *PMP_SET_REQUEST;
  247. //--------------------------------------
  248. // Structure for Power Management Info
  249. //--------------------------------------
  250. typedef struct _MP_POWER_MGMT
  251. {
  252. // List of Wake Up Patterns
  253. LIST_ENTRY PatternList;
  254. // IP address
  255. union
  256. {
  257. IPAddr u32;
  258. UCHAR u8[4];
  259. }IPAddress;
  260. // Number of outstanding Rcv Packet.
  261. UINT OutstandingRecv;
  262. // Current Power state of the adapter
  263. UINT PowerState;
  264. // Is PME_En on this adapter
  265. BOOLEAN PME_En;
  266. // Wake-up capabailities of the adapter
  267. BOOLEAN bWakeFromD0;
  268. BOOLEAN bWakeFromD1;
  269. BOOLEAN bWakeFromD2;
  270. BOOLEAN bWakeFromD3Hot;
  271. BOOLEAN bWakeFromD3Aux;
  272. // Pad
  273. BOOLEAN Pad[2];
  274. } MP_POWER_MGMT, *PMP_POWER_MGMT;
  275. typedef struct _MP_WAKE_PATTERN
  276. {
  277. // Link to the next Pattern
  278. LIST_ENTRY linkListEntry;
  279. // E100 specific signature of the pattern
  280. ULONG Signature;
  281. // Size of this allocation
  282. ULONG AllocationSize;
  283. // Pattern - This contains the NDIS_PM_PACKET_PATTERN
  284. UCHAR Pattern[1];
  285. } MP_WAKE_PATTERN , *PMP_WAKE_PATTERN ;
  286. //--------------------------------------
  287. // Macros specific to miniport adapter structure
  288. //--------------------------------------
  289. #define MP_TCB_RESOURCES_AVAIABLE(_M) ((_M)->nBusySend < (_M)->NumTcb)
  290. #define MP_SHOULD_FAIL_SEND(_M) ((_M)->Flags & fMP_ADAPTER_FAIL_SEND_MASK)
  291. #define MP_IS_NOT_READY(_M) ((_M)->Flags & fMP_ADAPTER_NOT_READY_MASK)
  292. #define MP_IS_READY(_M) !((_M)->Flags & fMP_ADAPTER_NOT_READY_MASK)
  293. #define MP_SET_PACKET_RFD(_p, _rfd) *((PMP_RFD *)&(_p)->MiniportReserved[0]) = _rfd
  294. #define MP_GET_PACKET_RFD(_p) *((PMP_RFD *)&(_p)->MiniportReserved[0])
  295. #define MP_GET_PACKET_MR(_p) (&(_p)->MiniportReserved[0])
  296. #define MP_SET_HARDWARE_ERROR(adapter) MP_SET_FLAG(adapter, fMP_ADAPTER_HARDWARE_ERROR)
  297. #define MP_SET_NON_RECOVER_ERROR(adapter) MP_SET_FLAG(adapter, fMP_ADAPTER_NON_RECOVER_ERROR)
  298. #define MP_OFFSET(field) ((UINT)FIELD_OFFSET(MP_ADAPTER,field))
  299. #define MP_SIZE(field) sizeof(((PMP_ADAPTER)0)->field)
  300. #if OFFLOAD
  301. // The offload capabilities of the miniport
  302. typedef struct _NIC_TASK_OFFLOAD
  303. {
  304. ULONG ChecksumOffload:1;
  305. ULONG LargeSendOffload:1;
  306. ULONG IpSecOffload:1;
  307. }NIC_TASK_OFFLOAD;
  308. // Checksum offload capabilities
  309. typedef struct _NIC_CHECKSUM_OFFLOAD
  310. {
  311. ULONG DoXmitTcpChecksum:1;
  312. ULONG DoRcvTcpChecksum:1;
  313. ULONG DoXmitUdpChecksum:1;
  314. ULONG DoRcvUdpChecksum:1;
  315. ULONG DoXmitIpChecksum:1;
  316. ULONG DoRcvIpChecksum:1;
  317. }NIC_CHECKSUM_OFFLOAD;
  318. // LargeSend offload information
  319. typedef struct _NIC_LARGE_SEND_OFFLOAD
  320. {
  321. NDIS_TASK_TCP_LARGE_SEND LargeSendInfo;
  322. }NIC_LARGE_SEND_OFFLOAD;
  323. // IpSec offload information
  324. //
  325. // shared memory for offloading
  326. typedef struct _OFFLOAD_SHARED_MEM
  327. {
  328. PVOID StartVa;
  329. NDIS_PHYSICAL_ADDRESS PhyAddr;
  330. }OFFLOAD_SHARED_MEM;
  331. #endif
  332. //--------------------------------------
  333. // The miniport adapter structure
  334. //--------------------------------------
  335. typedef struct _MP_ADAPTER MP_ADAPTER, *PMP_ADAPTER;
  336. typedef struct _MP_ADAPTER
  337. {
  338. LIST_ENTRY List;
  339. // Handle given by NDIS when the Adapter registered itself.
  340. NDIS_HANDLE AdapterHandle;
  341. //flags
  342. ULONG Flags;
  343. // configuration
  344. UCHAR PermanentAddress[ETH_LENGTH_OF_ADDRESS];
  345. UCHAR CurrentAddress[ETH_LENGTH_OF_ADDRESS];
  346. BOOLEAN bOverrideAddress;
  347. NDIS_EVENT ExitEvent;
  348. // SEND
  349. PMP_TCB CurrSendHead;
  350. PMP_TCB CurrSendTail;
  351. LONG nBusySend;
  352. LONG nWaitSend;
  353. LONG nCancelSend;
  354. QUEUE_HEADER SendWaitQueue;
  355. QUEUE_HEADER SendCancelQueue;
  356. SINGLE_LIST_ENTRY SendBufList;
  357. LONG NumTcb; // Total number of TCBs
  358. LONG RegNumTcb; // 'NumTcb'
  359. LONG NumTbd;
  360. LONG NumBuffers;
  361. NDIS_HANDLE SendBufferPool;
  362. PUCHAR MpTcbMem;
  363. ULONG MpTcbMemSize;
  364. PUCHAR MpTxBufMem;
  365. ULONG MpTxBufMemSize;
  366. PUCHAR HwSendMemAllocVa;
  367. ULONG HwSendMemAllocSize;
  368. NDIS_PHYSICAL_ADDRESS HwSendMemAllocPa;
  369. // Map register variables (for win9x)
  370. UINT CurrMapRegHead;
  371. UINT CurrMapRegTail;
  372. // command unit status flags
  373. BOOLEAN TransmitIdle;
  374. BOOLEAN ResumeWait;
  375. // RECV
  376. LIST_ENTRY RecvList;
  377. LIST_ENTRY RecvPendList;
  378. LONG nReadyRecv;
  379. LONG RefCount;
  380. LONG NumRfd;
  381. LONG CurrNumRfd;
  382. LONG MaxNumRfd;
  383. ULONG HwRfdSize;
  384. BOOLEAN bAllocNewRfd;
  385. LONG RfdShrinkCount;
  386. NDIS_HANDLE RecvPacketPool;
  387. NDIS_HANDLE RecvBufferPool;
  388. // spin locks
  389. NDIS_SPIN_LOCK Lock;
  390. // lookaside lists
  391. NPAGED_LOOKASIDE_LIST RecvLookaside;
  392. // Packet Filter and look ahead size.
  393. ULONG PacketFilter;
  394. ULONG ulLookAhead;
  395. USHORT usLinkSpeed;
  396. USHORT usDuplexMode;
  397. // multicast list
  398. UINT MCAddressCount;
  399. UCHAR MCList[NIC_MAX_MCAST_LIST][ETH_LENGTH_OF_ADDRESS];
  400. // Packet counts
  401. ULONG64 GoodTransmits;
  402. ULONG64 GoodReceives;
  403. ULONG NumTxSinceLastAdjust;
  404. // Count of transmit errors
  405. ULONG TxAbortExcessCollisions;
  406. ULONG TxLateCollisions;
  407. ULONG TxDmaUnderrun;
  408. ULONG TxLostCRS;
  409. ULONG TxOKButDeferred;
  410. ULONG OneRetry;
  411. ULONG MoreThanOneRetry;
  412. ULONG TotalRetries;
  413. // Count of receive errors
  414. ULONG RcvCrcErrors;
  415. ULONG RcvAlignmentErrors;
  416. ULONG RcvResourceErrors;
  417. ULONG RcvDmaOverrunErrors;
  418. ULONG RcvCdtFrames;
  419. ULONG RcvRuntErrors;
  420. ULONG IoBaseAddress;
  421. ULONG IoRange;
  422. ULONG InterruptLevel;
  423. NDIS_PHYSICAL_ADDRESS MemPhysAddress;
  424. PVOID PortOffset;
  425. PHW_CSR CSRAddress;
  426. NDIS_MINIPORT_INTERRUPT Interrupt;
  427. // Revision ID
  428. UCHAR RevsionID;
  429. USHORT SubVendorID;
  430. USHORT SubSystemID;
  431. ULONG CacheFillSize;
  432. ULONG Debug;
  433. PUCHAR HwMiscMemAllocVa;
  434. ULONG HwMiscMemAllocSize;
  435. NDIS_PHYSICAL_ADDRESS HwMiscMemAllocPa;
  436. PSELF_TEST_STRUC SelfTest; // 82558 SelfTest
  437. ULONG SelfTestPhys;
  438. PNON_TRANSMIT_CB NonTxCmdBlock; // 82558 (non transmit) Command Block
  439. ULONG NonTxCmdBlockPhys;
  440. PDUMP_AREA_STRUC DumpSpace; // 82558 dump buffer area
  441. ULONG DumpSpacePhys;
  442. PERR_COUNT_STRUC StatsCounters;
  443. ULONG StatsCounterPhys;
  444. UINT PhyAddress; // Address of the phy component
  445. UCHAR Connector; // 0=Auto, 1=TPE, 2=MII
  446. USHORT AiTxFifo; // TX FIFO Threshold
  447. USHORT AiRxFifo; // RX FIFO Threshold
  448. UCHAR AiTxDmaCount; // Tx dma count
  449. UCHAR AiRxDmaCount; // Rx dma count
  450. UCHAR AiUnderrunRetry; // The underrun retry mechanism
  451. UCHAR AiForceDpx; // duplex setting
  452. USHORT AiTempSpeed; // 'Speed', user over-ride of line speed
  453. USHORT AiThreshold; // 'Threshold', Transmit Threshold
  454. BOOLEAN MWIEnable; // Memory Write Invalidate bit in the PCI command word
  455. UCHAR Congest; // Enables congestion control
  456. UCHAR SpeedDuplex; // New reg value for speed/duplex
  457. NDIS_MEDIA_STATE MediaState;
  458. NDIS_DEVICE_POWER_STATE CurrentPowerState;
  459. NDIS_DEVICE_POWER_STATE NextPowerState;
  460. UCHAR OldParameterField;
  461. // WMI support
  462. ULONG CustomDriverSet;
  463. ULONG HwErrCount;
  464. // Minimize init-time
  465. BOOLEAN bQueryPending;
  466. BOOLEAN bSetPending;
  467. BOOLEAN bResetPending;
  468. NDIS_MINIPORT_TIMER LinkDetectionTimer;
  469. MP_QUERY_REQUEST QueryRequest;
  470. MP_SET_REQUEST SetRequest;
  471. BOOLEAN bLinkDetectionWait;
  472. BOOLEAN bLookForLink;
  473. UCHAR CurrentScanPhyIndex;
  474. UCHAR LinkDetectionWaitCount;
  475. UCHAR FoundPhyAt;
  476. USHORT EepromAddressSize;
  477. MP_POWER_MGMT PoMgmt;
  478. #if LBFO
  479. PMP_ADAPTER PrimaryAdapter;
  480. LONG NumSecondary;
  481. PMP_ADAPTER NextSecondary;
  482. NDIS_SPIN_LOCK LockLBFO;
  483. LONG RefCountLBFO;
  484. NDIS_STRING BundleId; // BundleId
  485. #endif
  486. NDIS_SPIN_LOCK SendLock;
  487. NDIS_SPIN_LOCK RcvLock;
  488. ULONG RcvRefCount; // number of packets that have not been returned back
  489. NDIS_EVENT AllPacketsReturnedEvent;
  490. #if OFFLOAD
  491. // Add for checksum offloading
  492. ULONG SharedMemRefCount;
  493. ULONG OffloadSharedMemSize;
  494. OFFLOAD_SHARED_MEM OffloadSharedMem;
  495. NIC_TASK_OFFLOAD NicTaskOffload;
  496. NIC_CHECKSUM_OFFLOAD NicChecksumOffload;
  497. NDIS_TASK_TCP_LARGE_SEND LargeSendInfo;
  498. BOOLEAN OffloadEnable;
  499. NDIS_ENCAPSULATION_FORMAT EncapsulationFormat;
  500. #endif
  501. } MP_ADAPTER, *PMP_ADAPTER;
  502. //--------------------------------------
  503. // Stall execution and wait with timeout
  504. //--------------------------------------
  505. /*++
  506. _condition - condition to wait for
  507. _timeout_ms - timeout value in milliseconds
  508. _result - TRUE if condition becomes true before it times out
  509. --*/
  510. #define MP_STALL_AND_WAIT(_condition, _timeout_ms, _result) \
  511. { \
  512. int counter; \
  513. _result = FALSE; \
  514. for(counter = _timeout_ms * 50; counter != 0; counter--) \
  515. { \
  516. if(_condition) \
  517. { \
  518. _result = TRUE; \
  519. break; \
  520. } \
  521. NdisStallExecution(20); \
  522. } \
  523. }
  524. __inline VOID MP_STALL_EXECUTION(
  525. IN UINT MsecDelay)
  526. {
  527. // Delay in 100 usec increments
  528. MsecDelay *= 10;
  529. while (MsecDelay)
  530. {
  531. NdisStallExecution(100);
  532. MsecDelay--;
  533. }
  534. }
  535. #if LBFO
  536. #define MP_GET_ADAPTER_HANDLE(_A) (_A)->PrimaryAdapter->AdapterHandle
  537. typedef struct _MP_GLOBAL_DATA
  538. {
  539. LIST_ENTRY AdapterList;
  540. NDIS_SPIN_LOCK Lock;
  541. ULONG ulIndex;
  542. } MP_GLOBAL_DATA, *PMP_GLOBAL_DATA;
  543. #else
  544. #define MP_GET_ADAPTER_HANDLE(_A) (_A)->AdapterHandle
  545. #endif
  546. __inline NDIS_STATUS MP_GET_STATUS_FROM_FLAGS(PMP_ADAPTER Adapter)
  547. {
  548. NDIS_STATUS Status = NDIS_STATUS_FAILURE;
  549. if(MP_TEST_FLAG(Adapter, fMP_ADAPTER_RESET_IN_PROGRESS))
  550. {
  551. Status = NDIS_STATUS_RESET_IN_PROGRESS;
  552. }
  553. else if(MP_TEST_FLAG(Adapter, fMP_ADAPTER_HARDWARE_ERROR))
  554. {
  555. Status = NDIS_STATUS_DEVICE_FAILED;
  556. }
  557. else if(MP_TEST_FLAG(Adapter, fMP_ADAPTER_NO_CABLE))
  558. {
  559. Status = NDIS_STATUS_NO_CABLE;
  560. }
  561. return Status;
  562. }
  563. //--------------------------------------
  564. // Miniport routines in MP_MAIN.C
  565. //--------------------------------------
  566. NDIS_STATUS DriverEntry(
  567. IN PDRIVER_OBJECT DriverObject,
  568. IN PUNICODE_STRING RegistryPath);
  569. VOID MPAllocateComplete(
  570. NDIS_HANDLE MiniportAdapterContext,
  571. IN PVOID VirtualAddress,
  572. IN PNDIS_PHYSICAL_ADDRESS PhysicalAddress,
  573. IN ULONG Length,
  574. IN PVOID Context);
  575. BOOLEAN MPCheckForHang(
  576. IN NDIS_HANDLE MiniportAdapterContext);
  577. VOID MPHalt(
  578. IN NDIS_HANDLE MiniportAdapterContext);
  579. NDIS_STATUS MPInitialize(
  580. OUT PNDIS_STATUS OpenErrorStatus,
  581. OUT PUINT SelectedMediumIndex,
  582. IN PNDIS_MEDIUM MediumArray,
  583. IN UINT MediumArraySize,
  584. IN NDIS_HANDLE MiniportAdapterHandle,
  585. IN NDIS_HANDLE WrapperConfigurationContext);
  586. VOID MPHandleInterrupt(
  587. IN NDIS_HANDLE MiniportAdapterContext);
  588. VOID MPIsr(
  589. OUT PBOOLEAN InterruptRecognized,
  590. OUT PBOOLEAN QueueMiniportHandleInterrupt,
  591. IN NDIS_HANDLE MiniportAdapterContext);
  592. NDIS_STATUS MPQueryInformation(
  593. IN NDIS_HANDLE MiniportAdapterContext,
  594. IN NDIS_OID Oid,
  595. IN PVOID InformationBuffer,
  596. IN ULONG InformationBufferLength,
  597. OUT PULONG BytesWritten,
  598. OUT PULONG BytesNeeded);
  599. NDIS_STATUS MPReset(
  600. OUT PBOOLEAN AddressingReset,
  601. IN NDIS_HANDLE MiniportAdapterContext);
  602. VOID MPReturnPacket(
  603. IN NDIS_HANDLE MiniportAdapterContext,
  604. IN PNDIS_PACKET Packet);
  605. VOID MPSendPackets(
  606. IN NDIS_HANDLE MiniportAdapterContext,
  607. IN PPNDIS_PACKET PacketArray,
  608. IN UINT NumberOfPackets);
  609. NDIS_STATUS MPSetInformation(
  610. IN NDIS_HANDLE MiniportAdapterContext,
  611. IN NDIS_OID Oid,
  612. IN PVOID InformationBuffer,
  613. IN ULONG InformationBufferLength,
  614. OUT PULONG BytesRead,
  615. OUT PULONG BytesNeeded);
  616. VOID MPShutdown(
  617. IN NDIS_HANDLE MiniportAdapterContext);
  618. #ifdef NDIS51_MINIPORT
  619. VOID MPCancelSendPackets(
  620. IN NDIS_HANDLE MiniportAdapterContext,
  621. IN PVOID CancelId);
  622. VOID MPPnPEventNotify(
  623. IN NDIS_HANDLE MiniportAdapterContext,
  624. IN NDIS_DEVICE_PNP_EVENT PnPEvent,
  625. IN PVOID InformationBuffer,
  626. IN ULONG InformationBufferLength);
  627. #endif
  628. NDIS_STATUS
  629. MPSetPowerD0Private (
  630. IN MP_ADAPTER* pAdapter
  631. );
  632. VOID
  633. MPSetPowerLowPrivate(
  634. PMP_ADAPTER Adapter
  635. );
  636. VOID
  637. MpExtractPMInfoFromPciSpace(
  638. PMP_ADAPTER pAdapter,
  639. PUCHAR pPciConfig
  640. );
  641. VOID
  642. HwSetWakeUpConfigure(
  643. IN PMP_ADAPTER pAdapter,
  644. PUCHAR pPoMgmtConfigType,
  645. UINT WakeUpParameter
  646. );
  647. BOOLEAN
  648. MPIsPoMgmtSupported(
  649. IN PMP_ADAPTER pAdapter
  650. );
  651. VOID
  652. NICIssueSelectiveReset(
  653. PMP_ADAPTER Adapter);
  654. NDIS_STATUS
  655. MPCalculateE100PatternForFilter (
  656. IN PUCHAR pFrame,
  657. IN ULONG FrameLength,
  658. IN PUCHAR pMask,
  659. IN ULONG MaskLength,
  660. OUT PULONG pSignature
  661. );
  662. VOID
  663. MPRemoveAllWakeUpPatterns(
  664. PMP_ADAPTER pAdapter
  665. );
  666. #if LBFO
  667. VOID MPUnload(IN PDRIVER_OBJECT DriverObject);
  668. VOID MpAddAdapterToList(PMP_ADAPTER Adapter);
  669. VOID MpRemoveAdapterFromList(PMP_ADAPTER Adapter);
  670. VOID MpPromoteSecondary(PMP_ADAPTER Adapter);
  671. #endif
  672. //
  673. // Define different functions depending on OFFLOAD is on or not
  674. //
  675. #if OFFLOAD
  676. #define MpSendPacketsHandler MPOffloadSendPackets
  677. #define MP_FREE_SEND_PACKET_FUN(Adapter, pMpTcb) MP_OFFLOAD_FREE_SEND_PACKET(Adapter, pMpTcb)
  678. #define MpSendPacketFun(Adapter, Packet, bFromQueue) MpOffloadSendPacket(Adapter, Packet, bFromQueue)
  679. #else
  680. #define MpSendPacketsHandler MPSendPackets
  681. #define MP_FREE_SEND_PACKET_FUN(Adapter, pMpTcb) MP_FREE_SEND_PACKET(Adapter, pMpTcb)
  682. #define MpSendPacketFun(Adapter, Packet, bFromQueue) MpSendPacket(Adapter, Packet,bFromQueue)
  683. #endif // end OFFLOAD
  684. #endif // _MP_H