Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Agere Systems Inc. |
| 3 | * 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs |
| 4 | * |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 5 | * Copyright © 2005 Agere Systems Inc. |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 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 | * |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 23 | * Copyright © 2005 Agere Systems Inc. |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 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 | * |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 44 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 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 | */ |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 70 | #define NUM_DESC_PER_RING_TX 512 /* TX Do not change these values */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 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 | |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 80 | #define TX_ERROR_PERIOD 1000 |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 81 | |
| 82 | #define LO_MARK_PERCENT_FOR_PSR 15 |
| 83 | #define LO_MARK_PERCENT_FOR_RX 15 |
| 84 | |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 85 | /* RFD (Receive Frame Descriptor) */ |
| 86 | typedef struct _MP_RFD { |
| 87 | struct list_head list_node; |
| 88 | struct sk_buff *Packet; |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 89 | u32 PacketSize; /* total size of receive frame */ |
Alan Cox | 9fa8109 | 2009-08-27 11:00:36 +0100 | [diff] [blame] | 90 | u16 bufferindex; |
| 91 | u8 ringindex; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 92 | } MP_RFD, *PMP_RFD; |
| 93 | |
| 94 | /* Enum for Flow Control */ |
| 95 | typedef enum _eflow_control_t { |
| 96 | Both = 0, |
| 97 | TxOnly = 1, |
| 98 | RxOnly = 2, |
| 99 | None = 3 |
| 100 | } eFLOW_CONTROL_t, *PeFLOW_CONTROL_t; |
| 101 | |
| 102 | /* Struct to define some device statistics */ |
| 103 | typedef struct _ce_stats_t { |
| 104 | /* Link Input/Output stats */ |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 105 | uint64_t ipackets; /* # of in packets */ |
| 106 | uint64_t opackets; /* # of out packets */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 107 | |
| 108 | /* MIB II variables |
| 109 | * |
| 110 | * NOTE: atomic_t types are only guaranteed to store 24-bits; if we |
| 111 | * MUST have 32, then we'll need another way to perform atomic |
| 112 | * operations |
| 113 | */ |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 114 | u32 unircv; /* # multicast packets received */ |
| 115 | atomic_t unixmt; /* # multicast packets for Tx */ |
| 116 | u32 multircv; /* # multicast packets received */ |
| 117 | atomic_t multixmt; /* # multicast packets for Tx */ |
| 118 | u32 brdcstrcv; /* # broadcast packets received */ |
| 119 | atomic_t brdcstxmt; /* # broadcast packets for Tx */ |
| 120 | u32 norcvbuf; /* # Rx packets discarded */ |
| 121 | u32 noxmtbuf; /* # Tx packets discarded */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 122 | |
| 123 | /* Transciever state informations. */ |
| 124 | u8 xcvr_addr; |
| 125 | u32 xcvr_id; |
| 126 | |
| 127 | /* Tx Statistics. */ |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 128 | u32 tx_uflo; /* Tx Underruns */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 129 | |
| 130 | u32 collisions; |
| 131 | u32 excessive_collisions; |
| 132 | u32 first_collision; |
| 133 | u32 late_collisions; |
| 134 | u32 max_pkt_error; |
| 135 | u32 tx_deferred; |
| 136 | |
| 137 | /* Rx Statistics. */ |
André Goddard Rosa | bbc9a99 | 2009-11-14 13:09:06 -0200 | [diff] [blame] | 138 | u32 rx_ov_flow; /* Rx Overflow */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 139 | |
| 140 | u32 length_err; |
| 141 | u32 alignment_err; |
| 142 | u32 crc_err; |
| 143 | u32 code_violations; |
| 144 | u32 other_errors; |
| 145 | |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 146 | u32 SynchrounousIterations; |
Alan Cox | 2211b73 | 2009-08-27 11:02:12 +0100 | [diff] [blame] | 147 | u32 InterruptStatus; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 148 | } CE_STATS_t, *PCE_STATS_t; |
| 149 | |
Alan Cox | 69ea5fc | 2010-01-18 15:34:24 +0000 | [diff] [blame] | 150 | typedef struct _MP_POWER_MGMT { |
| 151 | /* variable putting the phy into coma mode when boot up with no cable |
| 152 | * plugged in after 5 seconds |
| 153 | */ |
| 154 | u8 TransPhyComaModeOnBoot; |
| 155 | |
| 156 | /* Next two used to save power information at power down. This |
| 157 | * information will be used during power up to set up parts of Power |
| 158 | * Management in JAGCore |
| 159 | */ |
| 160 | u16 PowerDownSpeed; |
| 161 | u8 PowerDownDuplex; |
| 162 | } MP_POWER_MGMT, *PMP_POWER_MGMT; |
| 163 | |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 164 | /* The private adapter structure */ |
| 165 | struct et131x_adapter { |
| 166 | struct net_device *netdev; |
| 167 | struct pci_dev *pdev; |
| 168 | |
| 169 | struct work_struct task; |
| 170 | |
| 171 | /* Flags that indicate current state of the adapter */ |
| 172 | u32 Flags; |
| 173 | u32 HwErrCount; |
| 174 | |
| 175 | /* Configuration */ |
| 176 | u8 PermanentAddress[ETH_ALEN]; |
| 177 | u8 CurrentAddress[ETH_ALEN]; |
Alan Cox | 9fa8109 | 2009-08-27 11:00:36 +0100 | [diff] [blame] | 178 | bool has_eeprom; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 179 | u8 eepromData[2]; |
| 180 | |
| 181 | /* Spinlocks */ |
| 182 | spinlock_t Lock; |
| 183 | |
| 184 | spinlock_t TCBSendQLock; |
| 185 | spinlock_t TCBReadyQLock; |
| 186 | spinlock_t SendHWLock; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 187 | |
| 188 | spinlock_t RcvLock; |
| 189 | spinlock_t RcvPendLock; |
| 190 | spinlock_t FbrLock; |
| 191 | |
| 192 | spinlock_t PHYLock; |
| 193 | |
| 194 | /* Packet Filter and look ahead size */ |
| 195 | u32 PacketFilter; |
Alan Cox | 9fa8109 | 2009-08-27 11:00:36 +0100 | [diff] [blame] | 196 | u32 linkspeed; |
| 197 | u32 duplex_mode; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 198 | |
| 199 | /* multicast list */ |
| 200 | u32 MCAddressCount; |
| 201 | u8 MCList[NIC_MAX_MCAST_LIST][ETH_ALEN]; |
| 202 | |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 203 | /* Pointer to the device's PCI register space */ |
Alan Cox | f3f415a | 2009-08-27 10:59:30 +0100 | [diff] [blame] | 204 | ADDRESS_MAP_t __iomem *regs; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 205 | |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 206 | /* Registry parameters */ |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 207 | u8 SpeedDuplex; /* speed/duplex */ |
| 208 | eFLOW_CONTROL_t RegistryFlowControl; /* for 802.3x flow control */ |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 209 | u8 RegistryPhyComa; /* Phy Coma mode enable/disable */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 210 | |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 211 | u32 RegistryRxMemEnd; /* Size of internal rx memory */ |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 212 | u32 RegistryJumboPacket; /* Max supported ethernet packet size */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 213 | |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 214 | |
| 215 | /* Derived from the registry: */ |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 216 | u8 AiForceDpx; /* duplex setting */ |
| 217 | u16 AiForceSpeed; /* 'Speed', user over-ride of line speed */ |
| 218 | eFLOW_CONTROL_t FlowControl; /* flow control validated by the far-end */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 219 | enum { |
| 220 | NETIF_STATUS_INVALID = 0, |
| 221 | NETIF_STATUS_MEDIA_CONNECT, |
| 222 | NETIF_STATUS_MEDIA_DISCONNECT, |
| 223 | NETIF_STATUS_MAX |
| 224 | } MediaState; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 225 | |
| 226 | /* Minimize init-time */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 227 | struct timer_list ErrorTimer; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 228 | MP_POWER_MGMT PoMgmt; |
Alan Cox | 2211b73 | 2009-08-27 11:02:12 +0100 | [diff] [blame] | 229 | u32 CachedMaskValue; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 230 | |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 231 | /* Xcvr status at last poll */ |
| 232 | MI_BMSR_t Bmsr; |
| 233 | |
| 234 | /* Tx Memory Variables */ |
Alan Cox | b711b2e | 2009-10-06 15:48:33 +0100 | [diff] [blame] | 235 | struct tx_ring tx_ring; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 236 | |
| 237 | /* Rx Memory Variables */ |
Alan Cox | 8f12785 | 2010-01-18 15:34:07 +0000 | [diff] [blame] | 238 | struct rx_ring rx_ring; |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 239 | |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 240 | /* Loopback specifics */ |
Alan Cox | 64f9303 | 2009-06-10 17:30:41 +0100 | [diff] [blame] | 241 | u8 ReplicaPhyLoopbk; /* Replica Enable */ |
| 242 | u8 ReplicaPhyLoopbkPF; /* Replica Enable Pass/Fail */ |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 243 | |
| 244 | /* Stats */ |
| 245 | CE_STATS_t Stats; |
| 246 | |
| 247 | struct net_device_stats net_stats; |
| 248 | struct net_device_stats net_stats_prev; |
| 249 | }; |
| 250 | |
Greg Kroah-Hartman | cfb739b | 2008-04-03 17:30:53 -0700 | [diff] [blame] | 251 | #endif /* __ET131X_ADAPTER_H__ */ |