Sync nv with FreeBSD and update the binary driver to 1.0-0310.
[dragonfly.git] / sys / contrib / dev / nv / adapter.h
1 /***************************************************************************\
2 |*                                                                           *|
3 |*       Copyright 2001-2004 NVIDIA Corporation.  All Rights Reserved.       *|
4 |*                                                                           *|
5 |*     THE INFORMATION CONTAINED HEREIN  IS PROPRIETARY AND CONFIDENTIAL     *|
6 |*     TO NVIDIA, CORPORATION.   USE,  REPRODUCTION OR DISCLOSURE TO ANY     *|
7 |*     THIRD PARTY IS SUBJECT TO WRITTEN PRE-APPROVAL BY NVIDIA, CORP.       *|
8 |*                                                                           *|
9 |*     THE INFORMATION CONTAINED HEREIN IS PROVIDED  "AS IS" WITHOUT         *|
10 |*     EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING ALL IMPLIED        *|
11 |*     WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A     *|
12 |*     PARTICULAR PURPOSE.                                                   *|
13 |*                                                                           *|
14 \***************************************************************************/ 
15
16 /*
17     FILE:   adapter.h
18     DATE:   2/7/00
19
20     This file contains the hardware interface to the ethernet adapter.
21 */
22
23 #ifndef _ADAPTER_H_
24 #define _ADAPTER_H_
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #define HDA_VERSION_STRING "HDR A: $Revision: #46 $"
31
32 #ifdef MODS_NETWORK_BUILD
33 #ifndef _DRVAPP_H_
34 #include "drvapp.h"
35 #endif
36 #endif
37
38 //////////////////////////////////////////////////////////////////
39 // For the set and get configuration calls.
40 typedef struct  _ADAPTER_CONFIG
41 {
42     NV_UINT32   ulFlags;
43 }   ADAPTER_CONFIG, *PADAPTER_CONFIG;
44 //////////////////////////////////////////////////////////////////
45
46 typedef struct _ADAPTER_WRITE_OFFLOAD
47 {
48     NV_UINT32   usBitmask;
49     NV_UINT32   ulMss;
50
51 } ADAPTER_WRITE_OFFLOAD;
52
53 //////////////////////////////////////////////////////////////////
54 // For the ADAPTER_Write1 call.
55 /* This scatter gather list should be same as defined in ndis.h by MS.
56    For ULONG_PTR MS header file says that it will be of same size as
57    pointer. It has been defined to take care of casting between differenet
58    sizes.
59 */
60 typedef struct _NVSCATTER_GATHER_ELEMENT {
61     NV_UINT32 PhysLow;
62     NV_UINT32 PhysHigh;
63     NV_UINT32 Length;
64     NV_VOID *Reserved;
65 } NVSCATTER_GATHER_ELEMENT, *PNVSCATTER_GATHER_ELEMENT;
66
67 #ifndef linux
68 #pragma warning(disable:4200)
69 #endif
70 typedef struct _NVSCATTER_GATHER_LIST {
71     NV_UINT32       NumberOfElements;
72     NV_VOID         *Reserved;
73     NVSCATTER_GATHER_ELEMENT Elements[0];   // Made 0 sized element to remove MODS compilation error
74                                             // Elements[0] and Elements[] have the same effect. 
75                                             // sizeof(NVSCATTER_GATHER_LIST) is the same (value of 8) in both cases
76                                             // And both lead to Warning 4200 in MSVC
77 } NVSCATTER_GATHER_LIST, *PNVSCATTER_GATHER_LIST;
78 #ifndef linux
79 #pragma warning(default:4200)
80 #endif
81
82 typedef struct  _ADAPTER_WRITE_DATA1
83 {
84     NV_UINT32                   ulTotalLength;
85     PNV_VOID                    pvID;
86     NV_UINT8                    uc8021pPriority;
87     ADAPTER_WRITE_OFFLOAD       *psOffload;
88     PNVSCATTER_GATHER_LIST      pNVSGL;
89 }   ADAPTER_WRITE_DATA1, *PADAPTER_WRITE_DATA1;
90
91
92 //////////////////////////////////////////////////////////////////
93 // For the ADAPTER_Write call.
94 typedef struct  _ADAPTER_WRITE_ELEMENT
95 {
96     PNV_VOID   pPhysical;
97     NV_UINT32   ulLength;
98 }   ADAPTER_WRITE_ELEMENT, *PADAPTER_WRITE_ELEMENT;
99
100
101 #define ADAPTER_WRITE_OFFLOAD_BP_SEGOFFLOAD      0
102 #define ADAPTER_WRITE_OFFLOAD_BP_IPV4CHECKSUM    1
103 #define ADAPTER_WRITE_OFFLOAD_BP_IPV6CHECKSUM    2
104 #define ADAPTER_WRITE_OFFLOAD_BP_TCPCHECKSUM     3
105 #define ADAPTER_WRITE_OFFLOAD_BP_UDPCHECKSUM     4
106 #define ADAPTER_WRITE_OFFLOAD_BP_IPCHECKSUM      5
107
108
109 // pvID is a value that will be passed back into OSAPI.pfnPacketWasSent
110 // when the transmission completes. if pvID is NULL, the ADAPTER code
111 // assumes the caller does not want the pfnPacketWasSent callback.
112 typedef struct  _ADAPTER_WRITE_DATA
113 {
114     NV_UINT32                   ulNumberOfElements;
115     NV_UINT32                   ulTotalLength;
116     PNV_VOID                    pvID;
117     NV_UINT8                    uc8021pPriority;
118     ADAPTER_WRITE_OFFLOAD       *psOffload;
119 #ifdef linux
120     ADAPTER_WRITE_ELEMENT       sElement[32];
121 #else
122     ADAPTER_WRITE_ELEMENT       sElement[100];
123 #endif
124 }   ADAPTER_WRITE_DATA, *PADAPTER_WRITE_DATA;
125 //////////////////////////////////////////////////////////////////
126
127
128
129 //////////////////////////////////////////////////////////////////
130 // For the ADAPTER_Read call.
131 typedef struct  _ADAPTER_READ_ELEMENT
132 {
133     PNV_VOID   pPhysical;
134     NV_UINT32   ulLength;
135 }   ADAPTER_READ_ELEMENT, *PADAPTER_READ_ELEMENT;
136
137 typedef struct _ADAPTER_READ_OFFLOAD
138 {
139     NV_UINT8  ucChecksumStatus;
140
141 } ADAPTER_READ_OFFLOAD;
142
143 typedef struct _ADAPTER_READ_DATA
144 {
145     NV_UINT32                   ulNumberOfElements;
146     NV_UINT32                   ulTotalLength;
147     PNV_VOID                    pvID;
148     NV_UINT32                   ulFilterMatch;
149     ADAPTER_READ_OFFLOAD        sOffload;
150     ADAPTER_READ_ELEMENT        sElement[10];
151 }   ADAPTER_READ_DATA, *PADAPTER_READ_DATA;
152
153
154 #define RDFLAG_CHK_NOCHECKSUM      0
155 #define RDFLAG_CHK_IPPASSTCPFAIL   1
156 #define RDFLAG_CHK_IPPASSUDPFAIL   2
157 #define RDFLAG_CHK_IPFAIL          3
158 #define RDFLAG_CHK_IPPASSNOTCPUDP  4
159 #define RDFLAG_CHK_IPPASSTCPPASS   5
160 #define RDFLAG_CHK_IPPASSUDPPASS   6
161 #define RDFLAG_CHK_RESERVED        7
162
163
164 // The ulFilterMatch flag can be a logical OR of the following
165 #define ADREADFL_UNICAST_MATCH          0x00000001
166 #define ADREADFL_MULTICAST_MATCH        0x00000002
167 #define ADREADFL_BROADCAST_MATCH        0x00000004
168 //////////////////////////////////////////////////////////////////
169
170
171
172 //////////////////////////////////////////////////////////////////
173 // For the ADAPTER_GetPowerCapabilities call.
174 typedef struct  _ADAPTER_POWERCAPS
175 {
176     NV_UINT32   ulPowerFlags;
177     NV_UINT32   ulMagicPacketWakeUpFlags;
178     NV_UINT32   ulPatternWakeUpFlags;
179     NV_UINT32   ulLinkChangeWakeUpFlags;
180     NV_SINT32     iMaxWakeUpPatterns;
181 }   ADAPTER_POWERCAPS, *PADAPTER_POWERCAPS;
182
183 // For the ADAPTER_GetPowerState and ADAPTER_SetPowerState call.
184 typedef struct  _ADAPTER_POWERSTATE
185 {
186     NV_UINT32   ulPowerFlags;
187     NV_UINT32   ulMagicPacketWakeUpFlags;
188     NV_UINT32   ulPatternWakeUpFlags;
189     NV_UINT32   ulLinkChangeWakeUpFlags;
190 }   ADAPTER_POWERSTATE, *PADAPTER_POWERSTATE;
191
192 // Each of the flag fields in the POWERCAPS structure above can have
193 // any of the following bitflags set giving the capabilites of the
194 // adapter. In the case of the wake up fields, these flags mean that
195 // wake up can happen from the specified power state.
196
197 // For the POWERSTATE structure, the ulPowerFlags field should just
198 // have one of these bits set to go to that particular power state.
199 // The WakeUp fields can have one or more of these bits set to indicate
200 // what states should be woken up from.
201 #define POWER_STATE_D0          0x00000001
202 #define POWER_STATE_D1          0x00000002
203 #define POWER_STATE_D2          0x00000004
204 #define POWER_STATE_D3          0x00000008
205
206 #define POWER_STATE_ALL         (POWER_STATE_D0 | \
207                                 POWER_STATE_D1  | \
208                                 POWER_STATE_D2  | \
209                                 POWER_STATE_D3)
210 //////////////////////////////////////////////////////////////////
211
212
213
214 //////////////////////////////////////////////////////////////////
215 // The ADAPTER_GetPacketFilterCaps call returns a NV_UINT32 that can
216 // have the following capability bits set.
217 #define ACCEPT_UNICAST_PACKETS      0x00000001
218 #define ACCEPT_MULTICAST_PACKETS    0x00000002
219 #define ACCEPT_BROADCAST_PACKETS    0x00000004
220 #define ACCEPT_ALL_PACKETS          0x00000008
221
222 #define ETH_LENGTH_OF_ADDRESS        6
223
224 // The ADAPTER_SetPacketFilter call uses this structure to know what
225 // packet filter to set. The ulPacketFilter field can contain some
226 // union of the bit flags above. The acMulticastMask array holds a
227 // 48 bit MAC address mask with a 0 in every bit position that should
228 // be ignored on compare and a 1 in every bit position that should
229 // be taken into account when comparing to see if the destination
230 // address of a packet should be accepted for multicast.
231 typedef struct  _PACKET_FILTER
232 {
233     NV_UINT32   ulFilterFlags;
234     NV_UINT8   acMulticastAddress[ETH_LENGTH_OF_ADDRESS];
235     NV_UINT8   acMulticastMask[ETH_LENGTH_OF_ADDRESS];
236 }   PACKET_FILTER, *PPACKET_FILTER;
237 //////////////////////////////////////////////////////////////////
238
239
240 //////////////////////////////////////////////////////////////////
241 // A WAKE_UP_PATTERN is a 128-byte pattern that the adapter can
242 // look for in incoming packets to decide when to wake up.  Higher-
243 // level protocols can use this to, for example, wake up the
244 // adapter whenever it sees an IP packet that is addressed to it.
245 // A pattern consists of 128 bits of byte masks that indicate
246 // which bytes in the packet are relevant to the pattern, plus
247 // values for each byte.
248 #define WAKE_UP_PATTERN_SIZE 128
249
250 typedef struct _WAKE_UP_PATTERN
251 {
252     NV_UINT32   aulByteMask[WAKE_UP_PATTERN_SIZE/32];
253     NV_UINT8   acData[WAKE_UP_PATTERN_SIZE];
254 }   WAKE_UP_PATTERN, *PWAKE_UP_PATTERN;
255
256
257
258 //
259 //
260 // Adapter offload
261 //
262 typedef struct _ADAPTER_OFFLOAD {
263
264     NV_UINT32 Type;
265     NV_UINT32 Value0;
266
267 } ADAPTER_OFFLOAD, *PADAPTER_OFFLOAD;
268
269 #define ADAPTER_OFFLOAD_VLAN        0x00000001
270 #define ADAPTER_OFFLOAD_IEEE802_1P    0x00000002
271 #define ADAPTER_OFFLOAD_IEEE802_1PQ_PAD    0x00000004
272
273 //////////////////////////////////////////////////////////////////
274
275 //  CMNDATA_OS_ADAPTER
276 //  Structure common to OS and Adapter layers
277 //  Used for moving data from the OS layer to the adapter layer through SetCommonData 
278 //  function call from OS layer to Adapter layer
279 // 
280
281 typedef struct  _CMNDATA_OS_ADAPTER
282 {
283 #ifndef linux
284     ASF_SEC0_BASE   sRegSec0Base;
285 #endif
286     NV_UINT32           bFPGA; 
287     NV_UINT32           ulFPGAEepromSize;
288     NV_UINT32           bChecksumOffloadEnable;
289     NV_UINT32           ulChecksumOffloadBM;
290     NV_UINT32           ulChecksumOffloadOS;
291     NV_UINT32           ulMediaIF;
292     NV_UINT32           bOemCustomEventRead;
293
294     // Debug only right now
295     //!!! Beware mods is relying on the fields blow.
296     NV_UINT32           ulWatermarkTFBW;
297     NV_UINT32           ulBackoffRseed;
298     NV_UINT32           ulBackoffSlotTime;
299     NV_UINT32           ulModeRegTxReadCompleteEnable;
300     NV_UINT32           ulFatalErrorRegister;
301
302 } CMNDATA_OS_ADAPTER;
303
304
305 //////////////////////////////////////////////////////////////////
306 // The functional typedefs for the ADAPTER Api
307 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_CLOSE)  (PNV_VOID pvContext, NV_UINT8 ucIsPowerDown);
308 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_INIT)  (PNV_VOID pvContext, NV_UINT16 usForcedSpeed, NV_UINT8 ucForceDpx, NV_UINT8 ucForceMode, NV_UINT8 ucAsyncMode, NV_UINT32 *puiLinkState);
309 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_DEINIT)  (PNV_VOID pvContext, NV_UINT8 ucIsPowerDown);
310 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_START)  (PNV_VOID pvContext);
311 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_STOP)   (PNV_VOID pvContext, NV_UINT8 ucIsPowerDown);
312 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_QUERY_WRITE_SLOTS) (PNV_VOID pvContext);
313 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_WRITE) (PNV_VOID pvContext, ADAPTER_WRITE_DATA *pADWriteData);
314 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_WRITE1) (PNV_VOID pvContext, ADAPTER_WRITE_DATA1 *pADWriteData1);
315 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_QUERY_INTERRUPT) (PNV_VOID pvContext);
316 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_HANDLE_INTERRUPT) (PNV_VOID pvContext);
317 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_DISABLE_INTERRUPTS) (PNV_VOID pvContext);
318 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_ENABLE_INTERRUPTS) (PNV_VOID pvContext);
319 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_CLEAR_INTERRUPTS) (PNV_VOID pvContext);
320 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_CLEAR_TX_DESC) (PNV_VOID pvContext);
321 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_GET_LINK_SPEED) (PNV_VOID pvContext);
322 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_GET_LINK_MODE) (PNV_VOID pvContext);
323 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_GET_LINK_STATE) (PNV_VOID pvContext, NV_UINT32 *pulLinkState);
324 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_IS_LINK_INITIALIZING) (PNV_VOID pvContext);
325 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_RESET_PHY_INIT_STATE) (PNV_VOID pvContext);
326 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_GET_TRANSMIT_QUEUE_SIZE) (PNV_VOID pvContext);
327 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_GET_RECEIVE_QUEUE_SIZE) (PNV_VOID pvContext);
328 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_GET_STATISTICS) (PNV_VOID pvContext, PADAPTER_STATS pADStats);
329 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_GET_POWER_CAPS) (PNV_VOID pvContext, PADAPTER_POWERCAPS pADPowerCaps);
330 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_GET_POWER_STATE) (PNV_VOID pvContext, PADAPTER_POWERSTATE pADPowerState);
331 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_SET_POWER_STATE) (PNV_VOID pvContext, PADAPTER_POWERSTATE pADPowerState);
332 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_SET_LOW_SPEED_FOR_PM) (PNV_VOID pvContext);
333 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_GET_PACKET_FILTER_CAPS) (PNV_VOID pvContext);
334 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_SET_PACKET_FILTER) (PNV_VOID pvContext, PPACKET_FILTER pPacketFilter);
335 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_SET_WAKE_UP_PATTERN) (PNV_VOID pvContext, NV_SINT32 iPattern, PWAKE_UP_PATTERN pPattern);
336 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_ENABLE_WAKE_UP_PATTERN) (PNV_VOID pvContext, NV_SINT32 iPattern, NV_SINT32 iEnable);
337 typedef NV_API_CALL NV_SINT32 (* PFN_SET_NODE_ADDRESS) (PNV_VOID pvContext, NV_UINT8 *pNodeAddress);
338 typedef NV_API_CALL NV_SINT32 (* PFN_GET_NODE_ADDRESS) (PNV_VOID pvContext, NV_UINT8 *pNodeAddress);
339 typedef NV_API_CALL NV_SINT32 (* PFN_GET_ADAPTER_INFO) (PNV_VOID pvContext, PNV_VOID pVoidPtr, NV_SINT32 iType, NV_SINT32 *piLength);
340 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_READ_PHY)  (PNV_VOID pvContext, NV_UINT32 ulPhyAddr, NV_UINT32 ulPhyReg, NV_UINT32 *pulValue);
341 typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_WRITE_PHY) (PNV_VOID pvContext, NV_UINT32 ulPhyAddr, NV_UINT32 ulPhyReg, NV_UINT32 ulValue);
342 typedef NV_API_CALL NV_VOID(* PFN_ADAPTER_SET_SPPED_DUPLEX) (PNV_VOID pvContext);
343 typedef NV_API_CALL NV_SINT32 (*PFN_REGISTER_OFFLOAD) (PNV_VOID pvContext,  PADAPTER_OFFLOAD pOffload);
344 typedef NV_API_CALL NV_SINT32 (*PFN_DEREGISTER_OFFLOAD) (PNV_VOID pvContext, PADAPTER_OFFLOAD pOffload);
345 typedef NV_API_CALL NV_SINT32 (*PFN_RX_BUFF_READY) (PNV_VOID pvContext, PMEMORY_BLOCK pMemBlock, PNV_VOID pvID);
346
347 #ifndef linux
348 typedef NV_SINT32 (*PFN_ADAPTER_ASF_SETUPREGISTERS) (PNV_VOID pvContext, NV_SINT32 bInitTime);
349 typedef NV_SINT32 (*PFN_ADAPTER_ASF_GETSEC0BASEADDRESS) (PNV_VOID pvContext, ASF_SEC0_BASE **ppsSec0Base);
350 typedef NV_SINT32 (*PFN_ADAPTER_ASF_SETSOURCEIPADDRESS) (PNV_VOID pvContext, NV_UINT8 *pucSrcIPAddress);
351 typedef NV_SINT32 (*PFN_ADAPTER_ASF_GETDESTIPADDRESS) (PNV_VOID pvContext, NV_UINT8 *pucDestIPAddress);
352 typedef NV_SINT32 (*PFN_ADAPTER_ASF_SETDESTIPADDRESS) (PNV_VOID pvContext, NV_UINT8 *pucDestIPAddress);
353 typedef NV_SINT32 (*PFN_ADAPTER_ASF_WRITEEEPROMANDSETUPREGISTERS) (PNV_VOID pvContext, NV_BOOLEAN bCompare, PNV_VOID pucValue, PNV_VOID pszSec0BaseMember, 
354                                       NV_UINT16 usCount, NV_UINT32 ulAddressOffset);
355
356 typedef NV_SINT32 (*PFN_ADAPTER_ASF_ISASFREADY) (PNV_VOID pvContext, ASF_ASFREADY *psASFReady);
357
358 typedef NV_SINT32 (*PFN_ADAPTER_ASF_SETDESTMACADDRESS) (PNV_VOID pvContext, NV_UINT8 *pucDestMACAddress);
359 typedef NV_SINT32 (*PFN_ADAPTER_ASF_GETSOURCEMACADDRESS) (PNV_VOID pvContext, NV_UINT8 *pucSrcMACAddress);
360
361 typedef NV_SINT32 (*PFN_ADAPTER_ASF_CHECK_FOR_EEPROM_PRESENCE)  (PNV_VOID pvContext);
362 #endif
363
364 typedef NV_API_CALL NV_VOID (*PFN_ADAPTER_SET_COMMONDATA) (PNV_VOID pvContext, CMNDATA_OS_ADAPTER *psOSAdpater);
365 typedef NV_API_CALL NV_VOID (*PFN_ADAPTER_SET_CHECKSUMOFFLOAD) (PNV_VOID pvContext, NV_UINT32 bSet);
366
367
368  
369 typedef struct  _ADAPTER_API
370 {
371     // The adapter context
372     PNV_VOID                                   pADCX;
373
374     // The adapter interface
375     PFN_ADAPTER_CLOSE                       pfnClose;
376     PFN_ADAPTER_INIT                        pfnInit;
377     PFN_ADAPTER_DEINIT                      pfnDeinit;
378     PFN_ADAPTER_START                       pfnStart;
379     PFN_ADAPTER_STOP                        pfnStop;
380     PFN_ADAPTER_QUERY_WRITE_SLOTS           pfnQueryWriteSlots;
381     PFN_ADAPTER_WRITE                       pfnWrite;
382     PFN_ADAPTER_WRITE1                      pfnWrite1;
383     PFN_ADAPTER_QUERY_INTERRUPT             pfnQueryInterrupt;
384     PFN_ADAPTER_HANDLE_INTERRUPT            pfnHandleInterrupt;
385     PFN_ADAPTER_DISABLE_INTERRUPTS          pfnDisableInterrupts;
386     PFN_ADAPTER_ENABLE_INTERRUPTS           pfnEnableInterrupts;
387     PFN_ADAPTER_CLEAR_INTERRUPTS            pfnClearInterrupts;
388     PFN_ADAPTER_CLEAR_TX_DESC                pfnClearTxDesc;
389     PFN_ADAPTER_GET_LINK_SPEED              pfnGetLinkSpeed;
390     PFN_ADAPTER_GET_LINK_MODE               pfnGetLinkMode;
391     PFN_ADAPTER_GET_LINK_STATE              pfnGetLinkState;
392     PFN_ADAPTER_IS_LINK_INITIALIZING        pfnIsLinkInitializing;
393     PFN_ADAPTER_RESET_PHY_INIT_STATE        pfnResetPhyInitState;
394     PFN_ADAPTER_GET_TRANSMIT_QUEUE_SIZE     pfnGetTransmitQueueSize;
395     PFN_ADAPTER_GET_RECEIVE_QUEUE_SIZE      pfnGetReceiveQueueSize;
396     PFN_ADAPTER_GET_STATISTICS              pfnGetStatistics;
397     PFN_ADAPTER_GET_POWER_CAPS              pfnGetPowerCaps;
398     PFN_ADAPTER_GET_POWER_STATE             pfnGetPowerState;
399     PFN_ADAPTER_SET_POWER_STATE             pfnSetPowerState;
400     PFN_ADAPTER_SET_LOW_SPEED_FOR_PM        pfnSetLowSpeedForPM;
401     PFN_ADAPTER_GET_PACKET_FILTER_CAPS      pfnGetPacketFilterCaps;
402     PFN_ADAPTER_SET_PACKET_FILTER           pfnSetPacketFilter;
403     PFN_ADAPTER_SET_WAKE_UP_PATTERN         pfnSetWakeUpPattern;
404     PFN_ADAPTER_ENABLE_WAKE_UP_PATTERN      pfnEnableWakeUpPattern;
405     PFN_SET_NODE_ADDRESS                    pfnSetNodeAddress;
406     PFN_GET_NODE_ADDRESS                    pfnGetNodeAddress;
407     PFN_GET_ADAPTER_INFO                    pfnGetAdapterInfo;
408     PFN_ADAPTER_SET_SPPED_DUPLEX            pfnSetSpeedDuplex;
409     PFN_ADAPTER_READ_PHY                    pfnReadPhy;
410     PFN_ADAPTER_WRITE_PHY                    pfnWritePhy;
411     PFN_REGISTER_OFFLOAD                    pfnRegisterOffload;
412     PFN_DEREGISTER_OFFLOAD                    pfnDeRegisterOffload;
413     PFN_RX_BUFF_READY                        pfnRxBuffReady;
414 #ifndef linux
415     PFN_ADAPTER_ASF_SETUPREGISTERS          pfnASFSetupRegisters;
416     PFN_ADAPTER_ASF_GETSEC0BASEADDRESS      pfnASFGetSec0BaseAddress;
417     PFN_ADAPTER_ASF_SETSOURCEIPADDRESS      pfnASFSetSourceIPAddress;
418     PFN_ADAPTER_ASF_GETDESTIPADDRESS        pfnASFGetDestIPAddress;
419     PFN_ADAPTER_ASF_SETDESTIPADDRESS        pfnASFSetDestIPAddress;
420     PFN_ADAPTER_ASF_WRITEEEPROMANDSETUPREGISTERS pfnASFWriteEEPROMAndSetupRegisters;
421     PFN_ADAPTER_ASF_SETDESTMACADDRESS       pfnASFSetDestMACAddress;
422     PFN_ADAPTER_ASF_GETSOURCEMACADDRESS     pfnASFGetSourceMACAddress;
423     PFN_ADAPTER_ASF_ISASFREADY              pfnASFIsASFReady;
424     PFN_ADAPTER_ASF_CHECK_FOR_EEPROM_PRESENCE pfnASFCheckForEepromPresence;
425 #endif
426     PFN_ADAPTER_SET_COMMONDATA              pfnSetCommonData;
427
428     PFN_ADAPTER_SET_CHECKSUMOFFLOAD         pfnSetChecksumOffload;
429
430 }   ADAPTER_API, *PADAPTER_API;
431 //////////////////////////////////////////////////////////////////
432
433 #define MAX_PACKET_TO_ACCUMULATE    16
434
435 typedef struct _ADAPTER_OPEN_PARAMS
436 {
437     PNV_VOID pOSApi; //pointer to OSAPI structure passed from higher layer
438     PNV_VOID pvHardwareBaseAddress; //memory mapped address passed from higher layer
439     NV_UINT32 ulPollInterval; //poll interval in micro seconds. Used in polling mode
440     NV_UINT32 MaxDpcLoop; //Maximum number of times we loop to in function ADAPTER_HandleInterrupt
441     NV_UINT32 MaxRxPkt; //Maximum number of packet we process each time in function UpdateReceiveDescRingData
442     NV_UINT32 MaxTxPkt; //Maximum number of packet we process each time in function UpdateTransmitDescRingData
443     NV_UINT32 MaxRxPktToAccumulate; //maximum number of rx packet we accumulate in UpdateReceiveDescRingData before
444                                 //indicating packets to OS.
445     NV_UINT32 SentPacketStatusSuccess; //Status returned from adapter layer to higher layer when packet was sent successfully
446     NV_UINT32 SentPacketStatusFailure; ////Status returned from adapter layer to higher layer when packet send was unsuccessful
447     NV_UINT32 SetForcedModeEveryNthRxPacket; //NOT USED: For experiment with descriptor based interrupt
448     NV_UINT32 SetForcedModeEveryNthTxPacket; //NOT USED: For experiment with descriptor based interrupt
449     NV_UINT32 RxForcedInterrupt; //NOT USED: For experiment with descriptor based interrupt
450     NV_UINT32 TxForcedInterrupt; //NOT USED: For experiment with descriptor based interrupt
451     NV_UINT32 DeviceId; //Of MAC
452     NV_UINT32 DeviceType;
453     NV_UINT32 PollIntervalInusForThroughputMode; //Of MAC
454     NV_UINT32 bASFEnabled;
455     NV_UINT32 ulDescriptorVersion;
456     NV_UINT32 ulMaxPacketSize;
457
458
459 #define MEDIA_IF_AUTO       0
460 #define MEDIA_IF_RGMII      1
461 #define MEDIA_IF_MII        2
462     NV_UINT32 ulMediaIF;
463
464         NV_UINT32       PhyPowerIsolationTimeoutInms;
465         NV_UINT32       PhyResetTimeoutInms;
466         NV_UINT32       PhyAutonegotiateTimeoutInms;
467         NV_UINT32       PhyLinkupTimeoutInms;
468         NV_UINT32       PhyRdWrTimeoutInus;
469         NV_UINT32       PhyPowerdownOnClose;
470
471     // Added for Bug 100715
472     NV_UINT32   bDisableMIIInterruptAndReadPhyStatus;
473
474 }ADAPTER_OPEN_PARAMS, *PADAPTER_OPEN_PARAMS;
475
476 //////////////////////////////////////////////////////////////////
477 // This is the one function in the adapter interface that is publicly
478 // available. The rest of the interface is returned in the pAdapterApi.
479 // The first argument needs to be cast to a OSAPI structure pointer.
480 // The second argument should be cast to a ADPATER_API structure pointer.
481 NV_API_CALL NV_SINT32 ADAPTER_Open (PADAPTER_OPEN_PARAMS pAdapterOpenParams, PNV_VOID *pvpAdapterApi, NV_UINT32 *pulPhyAddr);
482
483 //////////////////////////////////////////////////////////////////
484
485
486
487 //////////////////////////////////////////////////////////////////
488 // Here are the error codes the adapter function calls return.
489 #define ADAPTERERR_NONE                             0x0000
490 #define ADAPTERERR_COULD_NOT_ALLOC_CONTEXT          0x0001
491 #define ADAPTERERR_COULD_NOT_CREATE_CONTEXT         0x0002
492 #define ADAPTERERR_COULD_NOT_OPEN_PHY               0x0003
493 #define ADAPTERERR_TRANSMIT_QUEUE_FULL              0x0004
494 #define ADAPTERERR_COULD_NOT_INIT_PHY               0x0005
495 #define ADAPTERERR_PHYS_SIZE_SMALL                    0x0006
496 #define ADAPTERERR_ERROR                            0x0007  // Generic error
497 //////////////////////////////////////////////////////////////////
498
499 // This block moved from myadap.h
500 // nFlag for Stop/Start ReceiverAndOrTransmitter can be an OR of
501 // the following two flags
502 #define AFFECT_RECEIVER     0x01
503 #define AFFECT_TRANSMITTER  0x02
504
505 #define REDUCE_LENGTH_BY 48
506
507 #define EXTRA_WRITE_SLOT_TO_REDUCE_PER_SEND    4
508 #define MAX_TX_DESCS                    256 
509 #define MAX_TX_DESCS_VER2               (256 * 4)
510
511 typedef struct _TX_INFO_ADAP
512 {
513     NV_UINT32   NoOfDesc; 
514     PNV_VOID    pvVar2; 
515 }TX_INFO_ADAP, *PTX_INFO_ADAP;
516
517 #define WORKAROUND_FOR_MCP3_TX_STALL
518
519 #ifdef WORKAROUND_FOR_MCP3_TX_STALL
520 NV_SINT32 ADAPTER_WorkaroundTXHang(PNV_VOID pvContext);
521 #endif
522
523 //#define TRACK_INIT_TIME
524
525 #ifdef TRACK_INIT_TIME
526 //This routine is defined in entry.c adapter doesn't link int64.lib
527 //We defined here so that its easy to use it in phy as well as mswin
528
529 #define MAX_PRINT_INDEX        32
530 extern NV_VOID PrintTime(NV_UINT32 ulIndex);
531 #define PRINT_INIT_TIME(_a) PrintTime((_a))
532 #else
533 #define PRINT_INIT_TIME(_a)
534 #endif
535
536 // Segmentation offload info
537 #define DEVCAPS_SEGOL_BP_ENABLE       0   
538 #define DEVCAPS_SEGOL_BP_IPOPTIONS    1
539 #define DEVCAPS_SEGOL_BP_TCPOPTIONS   2
540 #define DEVCAPS_SEGOL_BP_SEGSIZE_LO   8
541 #define DEVCAPS_SEGOL_BP_SEGSIZE_HI   31
542
543
544 // Checksum offload info
545 // Byte 0 : V4 TX
546 #define DEVCAPS_V4_TX_BP_IPOPTIONS      0
547 #define DEVCAPS_V4_TX_BP_TCPOPTIONS     1
548 #define DEVCAPS_V4_TX_BP_TCPCHECKSUM    2
549 #define DEVCAPS_V4_TX_BP_UDPCHECKSUM    3
550 #define DEVCAPS_V4_TX_BP_IPCHECKSUM     4
551
552 // Byte 0 : V4 RX
553 #define DEVCAPS_V4_RX_BP_IPOPTIONS      8
554 #define DEVCAPS_V4_RX_BP_TCPOPTIONS     9
555 #define DEVCAPS_V4_RX_BP_TCPCHECKSUM    10
556 #define DEVCAPS_V4_RX_BP_UDPCHECKSUM    11
557 #define DEVCAPS_V4_RX_BP_IPCHECKSUM     12
558
559 // Byte 1 : V6 TX
560 #define DEVCAPS_V6_TX_BP_IPOPTIONS      16
561 #define DEVCAPS_V6_TX_BP_TCPOPTIONS     17
562 #define DEVCAPS_V6_TX_BP_TCPCHECKSUM    18
563 #define DEVCAPS_V6_TX_BP_UDPCHECKSUM    19
564
565 // Byte 2 : V6 RX
566 #define DEVCAPS_V6_RX_BP_IPOPTIONS      24
567 #define DEVCAPS_V6_RX_BP_TCPOPTIONS     25
568 #define DEVCAPS_V6_RX_BP_TCPCHECKSUM    26
569 #define DEVCAPS_V6_RX_BP_UDPCHECKSUM    27
570
571
572 #define DESCR_VER_1         1       // MCP1, MCP2 and CK8 descriptor version
573 #define DESCR_VER_2         2       // The decsriptor structure for CK8G
574
575 // Get device and vendor IDs from 32 bit DeviceVendorID 
576 #define GET_DEVICEID(x)   (((x) >> 16) & 0xFFFF)
577 #define GET_VENDORID(x)   ((x) & 0xFFFF)
578
579 #ifdef __cplusplus
580 } // extern "C"
581 #endif
582
583 #endif // _ADAPTER_H_