blob: 05388eb02bbc535dd3143a4a3b0795bd80197357 [file] [log] [blame]
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -07001/*
2 * Agere Systems Inc.
3 * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
4 *
Alan Cox64f93032009-06-10 17:30:41 +01005 * Copyright © 2005 Agere Systems Inc.
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -07006 * 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 *
Alan Cox64f93032009-06-10 17:30:41 +010023 * Copyright © 2005 Agere Systems Inc.
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -070024 * 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 *
Alan Cox64f93032009-06-10 17:30:41 +010044 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -070045 * 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 */
Alan Cox64f93032009-06-10 17:30:41 +010070#define NUM_DESC_PER_RING_TX 512 /* TX Do not change these values */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -070071#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
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700103/* Macros specific to the private adapter structure */
104#define MP_TCB_RESOURCES_AVAILABLE(_M) ((_M)->TxRing.nBusySend < NUM_TCB)
105#define MP_TCB_RESOURCES_NOT_AVAILABLE(_M) ((_M)->TxRing.nBusySend >= NUM_TCB)
106
107#define MP_SHOULD_FAIL_SEND(_M) ((_M)->Flags & fMP_ADAPTER_FAIL_SEND_MASK)
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700108
109/* Counters for error rate monitoring */
110typedef struct _MP_ERR_COUNTERS {
111 u32 PktCountTxPackets;
112 u32 PktCountTxErrors;
113 u32 TimerBasedTxErrors;
114 u32 PktCountLastError;
115 u32 ErredConsecPackets;
116} MP_ERR_COUNTERS, *PMP_ERR_COUNTERS;
117
118/* RFD (Receive Frame Descriptor) */
119typedef struct _MP_RFD {
120 struct list_head list_node;
121 struct sk_buff *Packet;
Alan Cox64f93032009-06-10 17:30:41 +0100122 u32 PacketSize; /* total size of receive frame */
Alan Cox9fa81092009-08-27 11:00:36 +0100123 u16 bufferindex;
124 u8 ringindex;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700125} MP_RFD, *PMP_RFD;
126
127/* Enum for Flow Control */
128typedef enum _eflow_control_t {
129 Both = 0,
130 TxOnly = 1,
131 RxOnly = 2,
132 None = 3
133} eFLOW_CONTROL_t, *PeFLOW_CONTROL_t;
134
135/* Struct to define some device statistics */
136typedef struct _ce_stats_t {
137 /* Link Input/Output stats */
Alan Cox64f93032009-06-10 17:30:41 +0100138 uint64_t ipackets; /* # of in packets */
139 uint64_t opackets; /* # of out packets */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700140
141 /* MIB II variables
142 *
143 * NOTE: atomic_t types are only guaranteed to store 24-bits; if we
144 * MUST have 32, then we'll need another way to perform atomic
145 * operations
146 */
Alan Cox64f93032009-06-10 17:30:41 +0100147 u32 unircv; /* # multicast packets received */
148 atomic_t unixmt; /* # multicast packets for Tx */
149 u32 multircv; /* # multicast packets received */
150 atomic_t multixmt; /* # multicast packets for Tx */
151 u32 brdcstrcv; /* # broadcast packets received */
152 atomic_t brdcstxmt; /* # broadcast packets for Tx */
153 u32 norcvbuf; /* # Rx packets discarded */
154 u32 noxmtbuf; /* # Tx packets discarded */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700155
156 /* Transciever state informations. */
157 u8 xcvr_addr;
158 u32 xcvr_id;
159
160 /* Tx Statistics. */
Alan Cox64f93032009-06-10 17:30:41 +0100161 u32 tx_uflo; /* Tx Underruns */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700162
163 u32 collisions;
164 u32 excessive_collisions;
165 u32 first_collision;
166 u32 late_collisions;
167 u32 max_pkt_error;
168 u32 tx_deferred;
169
170 /* Rx Statistics. */
Alan Cox64f93032009-06-10 17:30:41 +0100171 u32 rx_ov_flow; /* Rx Over Flow */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700172
173 u32 length_err;
174 u32 alignment_err;
175 u32 crc_err;
176 u32 code_violations;
177 u32 other_errors;
178
179#ifdef CONFIG_ET131X_DEBUG
180 u32 UnhandledInterruptsPerSec;
181 u32 RxDmaInterruptsPerSec;
182 u32 TxDmaInterruptsPerSec;
183 u32 WatchDogInterruptsPerSec;
184#endif /* CONFIG_ET131X_DEBUG */
185
186 u32 SynchrounousIterations;
187 INTERRUPT_t InterruptStatus;
188} CE_STATS_t, *PCE_STATS_t;
189
190/* The private adapter structure */
191struct et131x_adapter {
192 struct net_device *netdev;
193 struct pci_dev *pdev;
194
195 struct work_struct task;
196
197 /* Flags that indicate current state of the adapter */
198 u32 Flags;
199 u32 HwErrCount;
200
201 /* Configuration */
202 u8 PermanentAddress[ETH_ALEN];
203 u8 CurrentAddress[ETH_ALEN];
Alan Cox9fa81092009-08-27 11:00:36 +0100204 bool has_eeprom;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700205 u8 eepromData[2];
206
207 /* Spinlocks */
208 spinlock_t Lock;
209
210 spinlock_t TCBSendQLock;
211 spinlock_t TCBReadyQLock;
212 spinlock_t SendHWLock;
213 spinlock_t SendWaitLock;
214
215 spinlock_t RcvLock;
216 spinlock_t RcvPendLock;
217 spinlock_t FbrLock;
218
219 spinlock_t PHYLock;
220
221 /* Packet Filter and look ahead size */
222 u32 PacketFilter;
Alan Cox9fa81092009-08-27 11:00:36 +0100223 u32 linkspeed;
224 u32 duplex_mode;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700225
226 /* multicast list */
227 u32 MCAddressCount;
228 u8 MCList[NIC_MAX_MCAST_LIST][ETH_ALEN];
229
230 /* MAC test */
231 TXMAC_TXTEST_t TxMacTest;
232
233 /* Pointer to the device's PCI register space */
Alan Coxf3f415a2009-08-27 10:59:30 +0100234 ADDRESS_MAP_t __iomem *regs;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700235
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700236 /* Registry parameters */
Alan Cox64f93032009-06-10 17:30:41 +0100237 u8 SpeedDuplex; /* speed/duplex */
238 eFLOW_CONTROL_t RegistryFlowControl; /* for 802.3x flow control */
Alan Cox64f93032009-06-10 17:30:41 +0100239 u8 RegistryPhyComa; /* Phy Coma mode enable/disable */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700240
Alan Cox64f93032009-06-10 17:30:41 +0100241 u32 RegistryRxMemEnd; /* Size of internal rx memory */
Alan Cox64f93032009-06-10 17:30:41 +0100242 u32 RegistryJumboPacket; /* Max supported ethernet packet size */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700243
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700244 /* Validation helpers */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700245 u8 RegistryNMIDisable;
Alan Cox64f93032009-06-10 17:30:41 +0100246 u8 RegistryPhyLoopbk; /* Enable Phy loopback */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700247
248 /* Derived from the registry: */
Alan Cox64f93032009-06-10 17:30:41 +0100249 u8 AiForceDpx; /* duplex setting */
250 u16 AiForceSpeed; /* 'Speed', user over-ride of line speed */
251 eFLOW_CONTROL_t FlowControl; /* flow control validated by the far-end */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700252 enum {
253 NETIF_STATUS_INVALID = 0,
254 NETIF_STATUS_MEDIA_CONNECT,
255 NETIF_STATUS_MEDIA_DISCONNECT,
256 NETIF_STATUS_MAX
257 } MediaState;
258 u8 DriverNoPhyAccess;
259
260 /* Minimize init-time */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700261 struct timer_list ErrorTimer;
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700262 MP_POWER_MGMT PoMgmt;
263 INTERRUPT_t CachedMaskValue;
264
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700265 /* Xcvr status at last poll */
266 MI_BMSR_t Bmsr;
267
268 /* Tx Memory Variables */
269 TX_RING_t TxRing;
270
271 /* Rx Memory Variables */
272 RX_RING_t RxRing;
273
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700274 /* Loopback specifics */
Alan Cox64f93032009-06-10 17:30:41 +0100275 u8 ReplicaPhyLoopbk; /* Replica Enable */
276 u8 ReplicaPhyLoopbkPF; /* Replica Enable Pass/Fail */
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700277
278 /* Stats */
279 CE_STATS_t Stats;
280
281 struct net_device_stats net_stats;
282 struct net_device_stats net_stats_prev;
283};
284
Greg Kroah-Hartmancfb739b2008-04-03 17:30:53 -0700285#endif /* __ET131X_ADAPTER_H__ */