Make all network interrupt service routines MPSAFE part 1/3.
[dragonfly.git] / sys / dev / netif / nv / adapter.h.patch
1 $DragonFly: src/sys/dev/netif/nv/Attic/adapter.h.patch,v 1.2 2005/04/04 18:45:07 joerg Exp $
2
3 --- adapter.h.orig      2005-03-12 10:59:18.000000000 +0100
4 +++ adapter.h   2005-04-02 20:23:52.000000000 +0200
5 @@ -35,13 +35,13 @@
6  #endif
7  #endif
8  
9 -//////////////////////////////////////////////////////////////////
10 -// For the set and get configuration calls.
11 +/****************************************************************/
12 +/* For the set and get configuration calls. */
13  typedef struct  _ADAPTER_CONFIG
14  {
15      NV_UINT32   ulFlags;
16  }   ADAPTER_CONFIG, *PADAPTER_CONFIG;
17 -//////////////////////////////////////////////////////////////////
18 +/****************************************************************/
19  
20  typedef struct _ADAPTER_WRITE_OFFLOAD
21  {
22 @@ -50,8 +50,8 @@
23  
24  } ADAPTER_WRITE_OFFLOAD;
25  
26 -//////////////////////////////////////////////////////////////////
27 -// For the ADAPTER_Write1 call.
28 +/****************************************************************/
29 +/* For the ADAPTER_Write1 call. */
30  /* This scatter gather list should be same as defined in ndis.h by MS.
31     For ULONG_PTR MS header file says that it will be of same size as
32     pointer. It has been defined to take care of casting between differenet
33 @@ -70,10 +70,10 @@
34  typedef struct _NVSCATTER_GATHER_LIST {
35      NV_UINT32       NumberOfElements;
36      NV_VOID         *Reserved;
37 -    NVSCATTER_GATHER_ELEMENT Elements[0];   // Made 0 sized element to remove MODS compilation error
38 -                                            // Elements[0] and Elements[] have the same effect. 
39 -                                            // sizeof(NVSCATTER_GATHER_LIST) is the same (value of 8) in both cases
40 -                                            // And both lead to Warning 4200 in MSVC
41 +    NVSCATTER_GATHER_ELEMENT Elements[0];   /* Made 0 sized element to remove MODS compilation error
42 +                                            ** Elements[0] and Elements[] have the same effect. 
43 +                                            ** sizeof(NVSCATTER_GATHER_LIST) is the same (value of 8) in both cases
44 +                                            ** And both lead to Warning 4200 in MSVC */
45  } NVSCATTER_GATHER_LIST, *PNVSCATTER_GATHER_LIST;
46  #ifndef linux
47  #pragma warning(default:4200)
48 @@ -89,8 +89,8 @@
49  }   ADAPTER_WRITE_DATA1, *PADAPTER_WRITE_DATA1;
50  
51  
52 -//////////////////////////////////////////////////////////////////
53 -// For the ADAPTER_Write call.
54 +/****************************************************************/
55 +/* For the ADAPTER_Write call. */
56  typedef struct  _ADAPTER_WRITE_ELEMENT
57  {
58      PNV_VOID   pPhysical;
59 @@ -106,9 +106,9 @@
60  #define ADAPTER_WRITE_OFFLOAD_BP_IPCHECKSUM      5
61  
62  
63 -// pvID is a value that will be passed back into OSAPI.pfnPacketWasSent
64 -// when the transmission completes. if pvID is NULL, the ADAPTER code
65 -// assumes the caller does not want the pfnPacketWasSent callback.
66 +/* pvID is a value that will be passed back into OSAPI.pfnPacketWasSent
67 +** when the transmission completes. if pvID is NULL, the ADAPTER code
68 +** assumes the caller does not want the pfnPacketWasSent callback. */
69  typedef struct  _ADAPTER_WRITE_DATA
70  {
71      NV_UINT32                   ulNumberOfElements;
72 @@ -118,12 +118,12 @@
73      ADAPTER_WRITE_OFFLOAD       *psOffload;
74      ADAPTER_WRITE_ELEMENT       sElement[100];
75  }   ADAPTER_WRITE_DATA, *PADAPTER_WRITE_DATA;
76 -//////////////////////////////////////////////////////////////////
77 +/****************************************************************/
78  
79  
80  
81 -//////////////////////////////////////////////////////////////////
82 -// For the ADAPTER_Read call.
83 +/****************************************************************/
84 +/* For the ADAPTER_Read call. */
85  typedef struct  _ADAPTER_READ_ELEMENT
86  {
87      PNV_VOID   pPhysical;
88 @@ -157,16 +157,16 @@
89  #define RDFLAG_CHK_RESERVED        7
90  
91  
92 -// The ulFilterMatch flag can be a logical OR of the following
93 +/* The ulFilterMatch flag can be a logical OR of the following */
94  #define ADREADFL_UNICAST_MATCH          0x00000001
95  #define ADREADFL_MULTICAST_MATCH        0x00000002
96  #define ADREADFL_BROADCAST_MATCH        0x00000004
97 -//////////////////////////////////////////////////////////////////
98 +/****************************************************************/
99  
100  
101  
102 -//////////////////////////////////////////////////////////////////
103 -// For the ADAPTER_GetPowerCapabilities call.
104 +/****************************************************************/
105 +/* For the ADAPTER_GetPowerCapabilities call. */
106  typedef struct  _ADAPTER_POWERCAPS
107  {
108      NV_UINT32   ulPowerFlags;
109 @@ -176,7 +176,7 @@
110      NV_SINT32     iMaxWakeUpPatterns;
111  }   ADAPTER_POWERCAPS, *PADAPTER_POWERCAPS;
112  
113 -// For the ADAPTER_GetPowerState and ADAPTER_SetPowerState call.
114 +/* For the ADAPTER_GetPowerState and ADAPTER_SetPowerState call. */
115  typedef struct  _ADAPTER_POWERSTATE
116  {
117      NV_UINT32   ulPowerFlags;
118 @@ -185,15 +185,15 @@
119      NV_UINT32   ulLinkChangeWakeUpFlags;
120  }   ADAPTER_POWERSTATE, *PADAPTER_POWERSTATE;
121  
122 -// Each of the flag fields in the POWERCAPS structure above can have
123 -// any of the following bitflags set giving the capabilites of the
124 -// adapter. In the case of the wake up fields, these flags mean that
125 -// wake up can happen from the specified power state.
126 -
127 -// For the POWERSTATE structure, the ulPowerFlags field should just
128 -// have one of these bits set to go to that particular power state.
129 -// The WakeUp fields can have one or more of these bits set to indicate
130 -// what states should be woken up from.
131 +/* Each of the flag fields in the POWERCAPS structure above can have
132 +** any of the following bitflags set giving the capabilites of the
133 +** adapter. In the case of the wake up fields, these flags mean that
134 +** wake up can happen from the specified power state. */
135 +
136 +/* For the POWERSTATE structure, the ulPowerFlags field should just
137 +** have one of these bits set to go to that particular power state.
138 +** The WakeUp fields can have one or more of these bits set to indicate
139 +** what states should be woken up from. */
140  #define POWER_STATE_D0          0x00000001
141  #define POWER_STATE_D1          0x00000002
142  #define POWER_STATE_D2          0x00000004
143 @@ -203,13 +203,13 @@
144                                  POWER_STATE_D1  | \
145                                  POWER_STATE_D2  | \
146                                  POWER_STATE_D3)
147 -//////////////////////////////////////////////////////////////////
148 +/****************************************************************/
149  
150  
151  
152 -//////////////////////////////////////////////////////////////////
153 -// The ADAPTER_GetPacketFilterCaps call returns a NV_UINT32 that can
154 -// have the following capability bits set.
155 +/****************************************************************/
156 +/* The ADAPTER_GetPacketFilterCaps call returns a NV_UINT32 that can
157 +** have the following capability bits set. */
158  #define ACCEPT_UNICAST_PACKETS      0x00000001
159  #define ACCEPT_MULTICAST_PACKETS    0x00000002
160  #define ACCEPT_BROADCAST_PACKETS    0x00000004
161 @@ -217,30 +217,30 @@
162  
163  #define ETH_LENGTH_OF_ADDRESS        6
164  
165 -// The ADAPTER_SetPacketFilter call uses this structure to know what
166 -// packet filter to set. The ulPacketFilter field can contain some
167 -// union of the bit flags above. The acMulticastMask array holds a
168 -// 48 bit MAC address mask with a 0 in every bit position that should
169 -// be ignored on compare and a 1 in every bit position that should
170 -// be taken into account when comparing to see if the destination
171 -// address of a packet should be accepted for multicast.
172 +/* The ADAPTER_SetPacketFilter call uses this structure to know what
173 +** packet filter to set. The ulPacketFilter field can contain some
174 +** union of the bit flags above. The acMulticastMask array holds a
175 +** 48 bit MAC address mask with a 0 in every bit position that should
176 +** be ignored on compare and a 1 in every bit position that should
177 +** be taken into account when comparing to see if the destination
178 +** address of a packet should be accepted for multicast. */
179  typedef struct  _PACKET_FILTER
180  {
181      NV_UINT32   ulFilterFlags;
182      NV_UINT8   acMulticastAddress[ETH_LENGTH_OF_ADDRESS];
183      NV_UINT8   acMulticastMask[ETH_LENGTH_OF_ADDRESS];
184  }   PACKET_FILTER, *PPACKET_FILTER;
185 -//////////////////////////////////////////////////////////////////
186 +/****************************************************************/
187  
188  
189 -//////////////////////////////////////////////////////////////////
190 -// A WAKE_UP_PATTERN is a 128-byte pattern that the adapter can
191 -// look for in incoming packets to decide when to wake up.  Higher-
192 -// level protocols can use this to, for example, wake up the
193 -// adapter whenever it sees an IP packet that is addressed to it.
194 -// A pattern consists of 128 bits of byte masks that indicate
195 -// which bytes in the packet are relevant to the pattern, plus
196 -// values for each byte.
197 +/****************************************************************/
198 +/* A WAKE_UP_PATTERN is a 128-byte pattern that the adapter can
199 +** look for in incoming packets to decide when to wake up.  Higher-
200 +** level protocols can use this to, for example, wake up the
201 +** adapter whenever it sees an IP packet that is addressed to it.
202 +** A pattern consists of 128 bits of byte masks that indicate
203 +** which bytes in the packet are relevant to the pattern, plus
204 +** values for each byte. */
205  #define WAKE_UP_PATTERN_SIZE 128
206  
207  typedef struct _WAKE_UP_PATTERN
208 @@ -251,10 +251,10 @@
209  
210  
211  
212 -//
213 -//
214 -// Adapter offload
215 -//
216 +/*
217 +**
218 +** Adapter offload
219 +*/
220  typedef struct _ADAPTER_OFFLOAD {
221  
222      NV_UINT32 Type;
223 @@ -266,13 +266,13 @@
224  #define ADAPTER_OFFLOAD_IEEE802_1P    0x00000002
225  #define ADAPTER_OFFLOAD_IEEE802_1PQ_PAD    0x00000004
226  
227 -//////////////////////////////////////////////////////////////////
228 +/****************************************************************/
229  
230 -//  CMNDATA_OS_ADAPTER
231 -//  Structure common to OS and Adapter layers
232 -//  Used for moving data from the OS layer to the adapter layer through SetCommonData 
233 -//  function call from OS layer to Adapter layer
234 -// 
235 +/*  CMNDATA_OS_ADAPTER
236 +**  Structure common to OS and Adapter layers
237 +**  Used for moving data from the OS layer to the adapter layer through SetCommonData 
238 +**  function call from OS layer to Adapter layer
239 +*/ 
240  
241  typedef struct  _CMNDATA_OS_ADAPTER
242  {
243 @@ -287,8 +287,8 @@
244      NV_UINT32           ulMediaIF;
245      NV_UINT32           bOemCustomEventRead;
246  
247 -    // Debug only right now
248 -    //!!! Beware mods is relying on the fields blow.
249 +    /* Debug only right now */
250 +    /*!!! Beware mods is relying on the fields blow. */
251      NV_UINT32           ulWatermarkTFBW;
252      NV_UINT32           ulBackoffRseed;
253      NV_UINT32           ulBackoffSlotTime;
254 @@ -298,8 +298,8 @@
255  } CMNDATA_OS_ADAPTER;
256  
257  
258 -//////////////////////////////////////////////////////////////////
259 -// The functional typedefs for the ADAPTER Api
260 +/****************************************************************/
261 +/* The functional typedefs for the ADAPTER Api */
262  typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_CLOSE)  (PNV_VOID pvContext, NV_UINT8 ucIsPowerDown);
263  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);
264  typedef NV_API_CALL NV_SINT32 (* PFN_ADAPTER_DEINIT)  (PNV_VOID pvContext, NV_UINT8 ucIsPowerDown);
265 @@ -364,10 +364,10 @@
266   
267  typedef struct  _ADAPTER_API
268  {
269 -    // The adapter context
270 +    /* The adapter context */
271      PNV_VOID                                   pADCX;
272  
273 -    // The adapter interface
274 +    /* The adapter interface */
275      PFN_ADAPTER_CLOSE                       pfnClose;
276      PFN_ADAPTER_INIT                        pfnInit;
277      PFN_ADAPTER_DEINIT                      pfnDeinit;
278 @@ -424,29 +424,29 @@
279      PFN_ADAPTER_SET_CHECKSUMOFFLOAD         pfnSetChecksumOffload;
280  
281  }   ADAPTER_API, *PADAPTER_API;
282 -//////////////////////////////////////////////////////////////////
283 +/****************************************************************/
284  
285  #define MAX_PACKET_TO_ACCUMULATE    16
286  
287  typedef struct _ADAPTER_OPEN_PARAMS
288  {
289 -    PNV_VOID pOSApi; //pointer to OSAPI structure passed from higher layer
290 -    PNV_VOID pvHardwareBaseAddress; //memory mapped address passed from higher layer
291 -    NV_UINT32 ulPollInterval; //poll interval in micro seconds. Used in polling mode
292 -    NV_UINT32 MaxDpcLoop; //Maximum number of times we loop to in function ADAPTER_HandleInterrupt
293 -    NV_UINT32 MaxRxPkt; //Maximum number of packet we process each time in function UpdateReceiveDescRingData
294 -    NV_UINT32 MaxTxPkt; //Maximum number of packet we process each time in function UpdateTransmitDescRingData
295 -    NV_UINT32 MaxRxPktToAccumulate; //maximum number of rx packet we accumulate in UpdateReceiveDescRingData before
296 -                                //indicating packets to OS.
297 -    NV_UINT32 SentPacketStatusSuccess; //Status returned from adapter layer to higher layer when packet was sent successfully
298 -    NV_UINT32 SentPacketStatusFailure; ////Status returned from adapter layer to higher layer when packet send was unsuccessful
299 -    NV_UINT32 SetForcedModeEveryNthRxPacket; //NOT USED: For experiment with descriptor based interrupt
300 -    NV_UINT32 SetForcedModeEveryNthTxPacket; //NOT USED: For experiment with descriptor based interrupt
301 -    NV_UINT32 RxForcedInterrupt; //NOT USED: For experiment with descriptor based interrupt
302 -    NV_UINT32 TxForcedInterrupt; //NOT USED: For experiment with descriptor based interrupt
303 -    NV_UINT32 DeviceId; //Of MAC
304 +    PNV_VOID pOSApi; /*pointer to OSAPI structure passed from higher layer */
305 +    PNV_VOID pvHardwareBaseAddress; /*memory mapped address passed from higher layer */
306 +    NV_UINT32 ulPollInterval; /*poll interval in micro seconds. Used in polling mode */
307 +    NV_UINT32 MaxDpcLoop; /*Maximum number of times we loop to in function ADAPTER_HandleInterrupt */
308 +    NV_UINT32 MaxRxPkt; /*Maximum number of packet we process each time in function UpdateReceiveDescRingData */
309 +    NV_UINT32 MaxTxPkt; /*Maximum number of packet we process each time in function UpdateTransmitDescRingData */
310 +    NV_UINT32 MaxRxPktToAccumulate; /*maximum number of rx packet we accumulate in UpdateReceiveDescRingData before */
311 +                                /*indicating packets to OS. */
312 +    NV_UINT32 SentPacketStatusSuccess; /*Status returned from adapter layer to higher layer when packet was sent successfully */
313 +    NV_UINT32 SentPacketStatusFailure; /***Status returned from adapter layer to higher layer when packet send was unsuccessful */
314 +    NV_UINT32 SetForcedModeEveryNthRxPacket; /*NOT USED: For experiment with descriptor based interrupt */
315 +    NV_UINT32 SetForcedModeEveryNthTxPacket; /*NOT USED: For experiment with descriptor based interrupt */
316 +    NV_UINT32 RxForcedInterrupt; /*NOT USED: For experiment with descriptor based interrupt */
317 +    NV_UINT32 TxForcedInterrupt; /*NOT USED: For experiment with descriptor based interrupt */
318 +    NV_UINT32 DeviceId; /*Of MAC */
319      NV_UINT32 DeviceType;
320 -    NV_UINT32 PollIntervalInusForThroughputMode; //Of MAC
321 +    NV_UINT32 PollIntervalInusForThroughputMode; /*Of MAC */
322      NV_UINT32 bASFEnabled;
323      NV_UINT32 ulDescriptorVersion;
324      NV_UINT32 ulMaxPacketSize;
325 @@ -464,24 +464,24 @@
326         NV_UINT32       PhyRdWrTimeoutInus;
327         NV_UINT32       PhyPowerdownOnClose;
328  
329 -    // Added for Bug 100715
330 +    /* Added for Bug 100715 */
331      NV_UINT32   bDisableMIIInterruptAndReadPhyStatus;
332  
333  }ADAPTER_OPEN_PARAMS, *PADAPTER_OPEN_PARAMS;
334  
335 -//////////////////////////////////////////////////////////////////
336 -// This is the one function in the adapter interface that is publicly
337 -// available. The rest of the interface is returned in the pAdapterApi.
338 -// The first argument needs to be cast to a OSAPI structure pointer.
339 -// The second argument should be cast to a ADPATER_API structure pointer.
340 +/****************************************************************/
341 +/* This is the one function in the adapter interface that is publicly
342 +** available. The rest of the interface is returned in the pAdapterApi.
343 +** The first argument needs to be cast to a OSAPI structure pointer.
344 +** The second argument should be cast to a ADPATER_API structure pointer. */
345  NV_API_CALL NV_SINT32 ADAPTER_Open (PADAPTER_OPEN_PARAMS pAdapterOpenParams, PNV_VOID *pvpAdapterApi, NV_UINT32 *pulPhyAddr);
346  
347 -//////////////////////////////////////////////////////////////////
348 +/****************************************************************/
349  
350  
351  
352 -//////////////////////////////////////////////////////////////////
353 -// Here are the error codes the adapter function calls return.
354 +/****************************************************************/
355 +/* Here are the error codes the adapter function calls return. */
356  #define ADAPTERERR_NONE                             0x0000
357  #define ADAPTERERR_COULD_NOT_ALLOC_CONTEXT          0x0001
358  #define ADAPTERERR_COULD_NOT_CREATE_CONTEXT         0x0002
359 @@ -489,12 +489,12 @@
360  #define ADAPTERERR_TRANSMIT_QUEUE_FULL              0x0004
361  #define ADAPTERERR_COULD_NOT_INIT_PHY               0x0005
362  #define ADAPTERERR_PHYS_SIZE_SMALL                    0x0006
363 -#define ADAPTERERR_ERROR                            0x0007  // Generic error
364 -//////////////////////////////////////////////////////////////////
365 +#define ADAPTERERR_ERROR                            0x0007  /* Generic error */
366 +/****************************************************************/
367  
368 -// This block moved from myadap.h
369 -// nFlag for Stop/Start ReceiverAndOrTransmitter can be an OR of
370 -// the following two flags
371 +/* This block moved from myadap.h
372 +** nFlag for Stop/Start ReceiverAndOrTransmitter can be an OR of
373 +** the following two flags */
374  #define AFFECT_RECEIVER     0x01
375  #define AFFECT_TRANSMITTER  0x02
376  
377 @@ -516,11 +516,11 @@
378  NV_SINT32 ADAPTER_WorkaroundTXHang(PNV_VOID pvContext);
379  #endif
380  
381 -//#define TRACK_INIT_TIME
382 +/*#define TRACK_INIT_TIME */
383  
384  #ifdef TRACK_INIT_TIME
385 -//This routine is defined in entry.c adapter doesn't link int64.lib
386 -//We defined here so that its easy to use it in phy as well as mswin
387 +/*This routine is defined in entry.c adapter doesn't link int64.lib
388 +**We defined here so that its easy to use it in phy as well as mswin */
389  
390  #define MAX_PRINT_INDEX        32
391  extern NV_VOID PrintTime(NV_UINT32 ulIndex);
392 @@ -529,7 +529,7 @@
393  #define PRINT_INIT_TIME(_a)
394  #endif
395  
396 -// Segmentation offload info
397 +/* Segmentation offload info */
398  #define DEVCAPS_SEGOL_BP_ENABLE       0   
399  #define DEVCAPS_SEGOL_BP_IPOPTIONS    1
400  #define DEVCAPS_SEGOL_BP_TCPOPTIONS   2
401 @@ -537,43 +537,43 @@
402  #define DEVCAPS_SEGOL_BP_SEGSIZE_HI   31
403  
404  
405 -// Checksum offload info
406 -// Byte 0 : V4 TX
407 +/* Checksum offload info */
408 +/* Byte 0 : V4 TX */
409  #define DEVCAPS_V4_TX_BP_IPOPTIONS      0
410  #define DEVCAPS_V4_TX_BP_TCPOPTIONS     1
411  #define DEVCAPS_V4_TX_BP_TCPCHECKSUM    2
412  #define DEVCAPS_V4_TX_BP_UDPCHECKSUM    3
413  #define DEVCAPS_V4_TX_BP_IPCHECKSUM     4
414  
415 -// Byte 0 : V4 RX
416 +/* Byte 0 : V4 RX */
417  #define DEVCAPS_V4_RX_BP_IPOPTIONS      8
418  #define DEVCAPS_V4_RX_BP_TCPOPTIONS     9
419  #define DEVCAPS_V4_RX_BP_TCPCHECKSUM    10
420  #define DEVCAPS_V4_RX_BP_UDPCHECKSUM    11
421  #define DEVCAPS_V4_RX_BP_IPCHECKSUM     12
422  
423 -// Byte 1 : V6 TX
424 +/* Byte 1 : V6 TX */
425  #define DEVCAPS_V6_TX_BP_IPOPTIONS      16
426  #define DEVCAPS_V6_TX_BP_TCPOPTIONS     17
427  #define DEVCAPS_V6_TX_BP_TCPCHECKSUM    18
428  #define DEVCAPS_V6_TX_BP_UDPCHECKSUM    19
429  
430 -// Byte 2 : V6 RX
431 +/* Byte 2 : V6 RX */
432  #define DEVCAPS_V6_RX_BP_IPOPTIONS      24
433  #define DEVCAPS_V6_RX_BP_TCPOPTIONS     25
434  #define DEVCAPS_V6_RX_BP_TCPCHECKSUM    26
435  #define DEVCAPS_V6_RX_BP_UDPCHECKSUM    27
436  
437  
438 -#define DESCR_VER_1         1       // MCP1, MCP2 and CK8 descriptor version
439 -#define DESCR_VER_2         2       // The decsriptor structure for CK8G
440 +#define DESCR_VER_1         1       /* MCP1, MCP2 and CK8 descriptor version */
441 +#define DESCR_VER_2         2       /* The decsriptor structure for CK8G */
442  
443 -// Get device and vendor IDs from 32 bit DeviceVendorID 
444 +/* Get device and vendor IDs from 32 bit DeviceVendorID */
445  #define GET_DEVICEID(x)   (((x) >> 16) & 0xFFFF)
446  #define GET_VENDORID(x)   ((x) & 0xFFFF)
447  
448  #ifdef __cplusplus
449 -} // extern "C"
450 +} /* extern "C" */
451  #endif
452  
453 -#endif // _ADAPTER_H_
454 +#endif /* _ADAPTER_H_ */