staging: dst: fix coding style
[safe/jmp/linux-2.6] / drivers / staging / et131x / et131x_adapter.h
1 /*
2  * Agere Systems Inc.
3  * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
4  *
5  * Copyright © 2005 Agere Systems Inc.
6  * All rights reserved.
7  *   http://www.agere.com
8  *
9  *------------------------------------------------------------------------------
10  *
11  * et131x_adapter.h - Header which includes the private adapter structure, along
12  *                    with related support structures, macros, definitions, etc.
13  *
14  *------------------------------------------------------------------------------
15  *
16  * SOFTWARE LICENSE
17  *
18  * This software is provided subject to the following terms and conditions,
19  * which you should read carefully before using the software.  Using this
20  * software indicates your acceptance of these terms and conditions.  If you do
21  * not agree with these terms and conditions, do not use the software.
22  *
23  * Copyright © 2005 Agere Systems Inc.
24  * All rights reserved.
25  *
26  * Redistribution and use in source or binary forms, with or without
27  * modifications, are permitted provided that the following conditions are met:
28  *
29  * . Redistributions of source code must retain the above copyright notice, this
30  *    list of conditions and the following Disclaimer as comments in the code as
31  *    well as in the documentation and/or other materials provided with the
32  *    distribution.
33  *
34  * . Redistributions in binary form must reproduce the above copyright notice,
35  *    this list of conditions and the following Disclaimer in the documentation
36  *    and/or other materials provided with the distribution.
37  *
38  * . Neither the name of Agere Systems Inc. nor the names of the contributors
39  *    may be used to endorse or promote products derived from this software
40  *    without specific prior written permission.
41  *
42  * Disclaimer
43  *
44  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
45  * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
46  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  ANY
47  * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
48  * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
49  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
50  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
51  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
52  * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
53  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
54  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
55  * DAMAGE.
56  *
57  */
58
59 #ifndef __ET131X_ADAPTER_H__
60 #define __ET131X_ADAPTER_H__
61
62 #include "et1310_address_map.h"
63 #include "et1310_tx.h"
64 #include "et1310_rx.h"
65
66 /*
67  * Do not change these values: if changed, then change also in respective
68  * TXdma and Rxdma engines
69  */
70 #define NUM_DESC_PER_RING_TX         512        /* TX Do not change these values */
71 #define NUM_TCB                      64
72
73 /*
74  * These values are all superseded by registry entries to facilitate tuning.
75  * Once the desired performance has been achieved, the optimal registry values
76  * should be re-populated to these #defines:
77  */
78 #define NUM_TRAFFIC_CLASSES          1
79
80 /*
81  * There are three ways of counting errors - if there are more than X errors
82  * in Y packets (represented by the "SAMPLE" macros), if there are more than
83  * N errors in a S mSec time period (the "PERIOD" macros), or if there are
84  * consecutive packets with errors (CONSEC_ERRORED_THRESH).  This last covers
85  * for "Bursty" errors, and the errored packets may well not be contiguous,
86  * but several errors where the packet counter has changed by less than a
87  * small amount will cause this count to increment.
88  */
89 #define TX_PACKETS_IN_SAMPLE        10000
90 #define TX_MAX_ERRORS_IN_SAMPLE     50
91
92 #define TX_ERROR_PERIOD             1000
93 #define TX_MAX_ERRORS_IN_PERIOD     10
94
95 #define LINK_DETECTION_TIMER        5000
96
97 #define TX_CONSEC_RANGE             5
98 #define TX_CONSEC_ERRORED_THRESH    10
99
100 #define LO_MARK_PERCENT_FOR_PSR     15
101 #define LO_MARK_PERCENT_FOR_RX      15
102
103 /* Counters for error rate monitoring */
104 typedef struct _MP_ERR_COUNTERS {
105         u32 PktCountTxPackets;
106         u32 PktCountTxErrors;
107         u32 TimerBasedTxErrors;
108         u32 PktCountLastError;
109         u32 ErredConsecPackets;
110 } MP_ERR_COUNTERS, *PMP_ERR_COUNTERS;
111
112 /* RFD (Receive Frame Descriptor) */
113 typedef struct _MP_RFD {
114         struct list_head list_node;
115         struct sk_buff *Packet;
116         u32 PacketSize; /* total size of receive frame */
117         u16 bufferindex;
118         u8 ringindex;
119 } MP_RFD, *PMP_RFD;
120
121 /* Enum for Flow Control */
122 typedef enum _eflow_control_t {
123         Both = 0,
124         TxOnly = 1,
125         RxOnly = 2,
126         None = 3
127 } eFLOW_CONTROL_t, *PeFLOW_CONTROL_t;
128
129 /* Struct to define some device statistics */
130 typedef struct _ce_stats_t {
131         /* Link Input/Output stats */
132         uint64_t ipackets;      /* # of in packets */
133         uint64_t opackets;      /* # of out packets */
134
135         /* MIB II variables
136          *
137          * NOTE: atomic_t types are only guaranteed to store 24-bits; if we
138          * MUST have 32, then we'll need another way to perform atomic
139          * operations
140          */
141         u32 unircv;     /* # multicast packets received */
142         atomic_t unixmt;        /* # multicast packets for Tx */
143         u32 multircv;   /* # multicast packets received */
144         atomic_t multixmt;      /* # multicast packets for Tx */
145         u32 brdcstrcv;  /* # broadcast packets received */
146         atomic_t brdcstxmt;     /* # broadcast packets for Tx */
147         u32 norcvbuf;   /* # Rx packets discarded */
148         u32 noxmtbuf;   /* # Tx packets discarded */
149
150         /* Transciever state informations. */
151         u8 xcvr_addr;
152         u32 xcvr_id;
153
154         /* Tx Statistics. */
155         u32 tx_uflo;            /* Tx Underruns */
156
157         u32 collisions;
158         u32 excessive_collisions;
159         u32 first_collision;
160         u32 late_collisions;
161         u32 max_pkt_error;
162         u32 tx_deferred;
163
164         /* Rx Statistics. */
165         u32 rx_ov_flow; /* Rx Over Flow */
166
167         u32 length_err;
168         u32 alignment_err;
169         u32 crc_err;
170         u32 code_violations;
171         u32 other_errors;
172
173         u32 SynchrounousIterations;
174         u32 InterruptStatus;
175 } CE_STATS_t, *PCE_STATS_t;
176
177 /* The private adapter structure */
178 struct et131x_adapter {
179         struct net_device *netdev;
180         struct pci_dev *pdev;
181
182         struct work_struct task;
183
184         /* Flags that indicate current state of the adapter */
185         u32 Flags;
186         u32 HwErrCount;
187
188         /* Configuration  */
189         u8 PermanentAddress[ETH_ALEN];
190         u8 CurrentAddress[ETH_ALEN];
191         bool has_eeprom;
192         u8 eepromData[2];
193
194         /* Spinlocks */
195         spinlock_t Lock;
196
197         spinlock_t TCBSendQLock;
198         spinlock_t TCBReadyQLock;
199         spinlock_t SendHWLock;
200
201         spinlock_t RcvLock;
202         spinlock_t RcvPendLock;
203         spinlock_t FbrLock;
204
205         spinlock_t PHYLock;
206
207         /* Packet Filter and look ahead size */
208         u32 PacketFilter;
209         u32 linkspeed;
210         u32 duplex_mode;
211
212         /* multicast list */
213         u32 MCAddressCount;
214         u8 MCList[NIC_MAX_MCAST_LIST][ETH_ALEN];
215
216         /* MAC test */
217         TXMAC_TXTEST_t TxMacTest;
218
219         /* Pointer to the device's PCI register space */
220         ADDRESS_MAP_t __iomem *regs;
221
222         /* Registry parameters */
223         u8 SpeedDuplex;         /* speed/duplex */
224         eFLOW_CONTROL_t RegistryFlowControl;    /* for 802.3x flow control */
225         u8 RegistryPhyComa;     /* Phy Coma mode enable/disable */
226
227         u32 RegistryRxMemEnd;   /* Size of internal rx memory */
228         u32 RegistryJumboPacket;        /* Max supported ethernet packet size */
229
230
231         /* Derived from the registry: */
232         u8 AiForceDpx;          /* duplex setting */
233         u16 AiForceSpeed;               /* 'Speed', user over-ride of line speed */
234         eFLOW_CONTROL_t FlowControl;    /* flow control validated by the far-end */
235         enum {
236                 NETIF_STATUS_INVALID = 0,
237                 NETIF_STATUS_MEDIA_CONNECT,
238                 NETIF_STATUS_MEDIA_DISCONNECT,
239                 NETIF_STATUS_MAX
240         } MediaState;
241
242         /* Minimize init-time */
243         struct timer_list ErrorTimer;
244         MP_POWER_MGMT PoMgmt;
245         u32 CachedMaskValue;
246
247         /* Xcvr status at last poll */
248         MI_BMSR_t Bmsr;
249
250         /* Tx Memory Variables */
251         struct tx_ring tx_ring;
252
253         /* Rx Memory Variables */
254         RX_RING_t RxRing;
255
256         /* Loopback specifics */
257         u8 ReplicaPhyLoopbk;    /* Replica Enable */
258         u8 ReplicaPhyLoopbkPF;  /* Replica Enable Pass/Fail */
259
260         /* Stats */
261         CE_STATS_t Stats;
262
263         struct net_device_stats net_stats;
264         struct net_device_stats net_stats_prev;
265 };
266
267 #endif /* __ET131X_ADAPTER_H__ */