3 * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs
5 * Copyright © 2005 Agere Systems Inc.
9 *------------------------------------------------------------------------------
11 * et131x_adapter.h - Header which includes the private adapter structure, along
12 * with related support structures, macros, definitions, etc.
14 *------------------------------------------------------------------------------
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.
23 * Copyright © 2005 Agere Systems Inc.
24 * All rights reserved.
26 * Redistribution and use in source or binary forms, with or without
27 * modifications, are permitted provided that the following conditions are met:
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
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.
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.
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
59 #ifndef __ET131X_ADAPTER_H__
60 #define __ET131X_ADAPTER_H__
62 #include "et1310_address_map.h"
63 #include "et1310_tx.h"
64 #include "et1310_rx.h"
67 * Do not change these values: if changed, then change also in respective
68 * TXdma and Rxdma engines
70 #define NUM_DESC_PER_RING_TX 512 /* TX Do not change these values */
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:
78 #define NUM_TRAFFIC_CLASSES 1
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.
89 #define TX_PACKETS_IN_SAMPLE 10000
90 #define TX_MAX_ERRORS_IN_SAMPLE 50
92 #define TX_ERROR_PERIOD 1000
93 #define TX_MAX_ERRORS_IN_PERIOD 10
95 #define LINK_DETECTION_TIMER 5000
97 #define TX_CONSEC_RANGE 5
98 #define TX_CONSEC_ERRORED_THRESH 10
100 #define LO_MARK_PERCENT_FOR_PSR 15
101 #define LO_MARK_PERCENT_FOR_RX 15
103 /* Macros for flag and ref count operations */
104 #define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
105 #define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
106 #define MP_CLEAR_FLAGS(_M) ((_M)->Flags = 0)
107 #define MP_TEST_FLAG(_M, _F) (((_M)->Flags & (_F)) != 0)
108 #define MP_TEST_FLAGS(_M, _F) (((_M)->Flags & (_F)) == (_F))
109 #define MP_IS_FLAG_CLEAR(_M, _F) (((_M)->Flags & (_F)) == 0)
111 /* Macros specific to the private adapter structure */
112 #define MP_TCB_RESOURCES_AVAILABLE(_M) ((_M)->TxRing.nBusySend < NUM_TCB)
113 #define MP_TCB_RESOURCES_NOT_AVAILABLE(_M) ((_M)->TxRing.nBusySend >= NUM_TCB)
115 #define MP_SHOULD_FAIL_SEND(_M) ((_M)->Flags & fMP_ADAPTER_FAIL_SEND_MASK)
116 #define MP_IS_NOT_READY(_M) ((_M)->Flags & fMP_ADAPTER_NOT_READY_MASK)
117 #define MP_IS_READY(_M) (!((_M)->Flags & fMP_ADAPTER_NOT_READY_MASK))
119 #define MP_HAS_CABLE(_M) (!((_M)->Flags & fMP_ADAPTER_NO_CABLE))
120 #define MP_LINK_DETECTED(_M) (!((_M)->Flags & fMP_ADAPTER_LINK_DETECTION))
122 /* Counters for error rate monitoring */
123 typedef struct _MP_ERR_COUNTERS {
124 u32 PktCountTxPackets;
125 u32 PktCountTxErrors;
126 u32 TimerBasedTxErrors;
127 u32 PktCountLastError;
128 u32 ErredConsecPackets;
129 } MP_ERR_COUNTERS, *PMP_ERR_COUNTERS;
131 /* RFD (Receive Frame Descriptor) */
132 typedef struct _MP_RFD {
133 struct list_head list_node;
134 struct sk_buff *Packet;
135 u32 PacketSize; /* total size of receive frame */
140 /* Enum for Flow Control */
141 typedef enum _eflow_control_t {
146 } eFLOW_CONTROL_t, *PeFLOW_CONTROL_t;
148 /* Struct to define some device statistics */
149 typedef struct _ce_stats_t {
150 /* Link Input/Output stats */
151 uint64_t ipackets; /* # of in packets */
152 uint64_t opackets; /* # of out packets */
156 * NOTE: atomic_t types are only guaranteed to store 24-bits; if we
157 * MUST have 32, then we'll need another way to perform atomic
160 u32 unircv; /* # multicast packets received */
161 atomic_t unixmt; /* # multicast packets for Tx */
162 u32 multircv; /* # multicast packets received */
163 atomic_t multixmt; /* # multicast packets for Tx */
164 u32 brdcstrcv; /* # broadcast packets received */
165 atomic_t brdcstxmt; /* # broadcast packets for Tx */
166 u32 norcvbuf; /* # Rx packets discarded */
167 u32 noxmtbuf; /* # Tx packets discarded */
169 /* Transciever state informations. */
174 u32 tx_uflo; /* Tx Underruns */
177 u32 excessive_collisions;
184 u32 rx_ov_flow; /* Rx Over Flow */
192 #ifdef CONFIG_ET131X_DEBUG
193 u32 UnhandledInterruptsPerSec;
194 u32 RxDmaInterruptsPerSec;
195 u32 TxDmaInterruptsPerSec;
196 u32 WatchDogInterruptsPerSec;
197 #endif /* CONFIG_ET131X_DEBUG */
199 u32 SynchrounousIterations;
200 INTERRUPT_t InterruptStatus;
201 } CE_STATS_t, *PCE_STATS_t;
203 /* The private adapter structure */
204 struct et131x_adapter {
205 struct net_device *netdev;
206 struct pci_dev *pdev;
208 struct work_struct task;
210 /* Flags that indicate current state of the adapter */
215 u8 PermanentAddress[ETH_ALEN];
216 u8 CurrentAddress[ETH_ALEN];
217 bool bOverrideAddress;
224 spinlock_t TCBSendQLock;
225 spinlock_t TCBReadyQLock;
226 spinlock_t SendHWLock;
227 spinlock_t SendWaitLock;
230 spinlock_t RcvPendLock;
235 /* Packet Filter and look ahead size */
245 u8 MCList[NIC_MAX_MCAST_LIST][ETH_ALEN];
248 TXMAC_TXTEST_t TxMacTest;
250 /* Pointer to the device's PCI register space */
251 ADDRESS_MAP_t __iomem *regs;
253 /* Registry parameters */
254 u8 SpeedDuplex; /* speed/duplex */
255 eFLOW_CONTROL_t RegistryFlowControl; /* for 802.3x flow control */
256 u8 RegistryPhyComa; /* Phy Coma mode enable/disable */
258 u32 RegistryRxMemEnd; /* Size of internal rx memory */
259 u32 RegistryJumboPacket; /* Max supported ethernet packet size */
261 /* Validation helpers */
262 u8 RegistryNMIDisable;
263 u8 RegistryPhyLoopbk; /* Enable Phy loopback */
265 /* Derived from the registry: */
266 u8 AiForceDpx; /* duplex setting */
267 u16 AiForceSpeed; /* 'Speed', user over-ride of line speed */
268 eFLOW_CONTROL_t FlowControl; /* flow control validated by the far-end */
270 NETIF_STATUS_INVALID = 0,
271 NETIF_STATUS_MEDIA_CONNECT,
272 NETIF_STATUS_MEDIA_DISCONNECT,
275 u8 DriverNoPhyAccess;
277 /* Minimize init-time */
281 struct timer_list ErrorTimer;
282 bool bLinkTimerActive;
283 MP_POWER_MGMT PoMgmt;
284 INTERRUPT_t CachedMaskValue;
286 /* Xcvr status at last poll */
289 /* Tx Memory Variables */
292 /* Rx Memory Variables */
295 /* ET1310 register Access */
296 JAGCORE_ACCESS_REGS JagCoreRegs;
297 PCI_CFG_SPACE_REGS PciCfgRegs;
299 /* Loopback specifics */
300 u8 ReplicaPhyLoopbk; /* Replica Enable */
301 u8 ReplicaPhyLoopbkPF; /* Replica Enable Pass/Fail */
306 struct net_device_stats net_stats;
307 struct net_device_stats net_stats_prev;
310 #endif /* __ET131X_ADAPTER_H__ */