1dee1ad47SJeff Kirsher /******************************************************************************* 2dee1ad47SJeff Kirsher 3dee1ad47SJeff Kirsher Intel PRO/1000 Linux driver 4bf67044bSBruce Allan Copyright(c) 1999 - 2013 Intel Corporation. 5dee1ad47SJeff Kirsher 6dee1ad47SJeff Kirsher This program is free software; you can redistribute it and/or modify it 7dee1ad47SJeff Kirsher under the terms and conditions of the GNU General Public License, 8dee1ad47SJeff Kirsher version 2, as published by the Free Software Foundation. 9dee1ad47SJeff Kirsher 10dee1ad47SJeff Kirsher This program is distributed in the hope it will be useful, but WITHOUT 11dee1ad47SJeff Kirsher ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12dee1ad47SJeff Kirsher FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13dee1ad47SJeff Kirsher more details. 14dee1ad47SJeff Kirsher 15dee1ad47SJeff Kirsher You should have received a copy of the GNU General Public License along with 16dee1ad47SJeff Kirsher this program; if not, write to the Free Software Foundation, Inc., 17dee1ad47SJeff Kirsher 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 18dee1ad47SJeff Kirsher 19dee1ad47SJeff Kirsher The full GNU General Public License is included in this distribution in 20dee1ad47SJeff Kirsher the file called "COPYING". 21dee1ad47SJeff Kirsher 22dee1ad47SJeff Kirsher Contact Information: 23dee1ad47SJeff Kirsher Linux NICS <linux.nics@intel.com> 24dee1ad47SJeff Kirsher e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 25dee1ad47SJeff Kirsher Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 26dee1ad47SJeff Kirsher 27dee1ad47SJeff Kirsher *******************************************************************************/ 28dee1ad47SJeff Kirsher 29dee1ad47SJeff Kirsher /* Linux PRO/1000 Ethernet Driver main header file */ 30dee1ad47SJeff Kirsher 31dee1ad47SJeff Kirsher #ifndef _E1000_H_ 32dee1ad47SJeff Kirsher #define _E1000_H_ 33dee1ad47SJeff Kirsher 34dee1ad47SJeff Kirsher #include <linux/bitops.h> 35dee1ad47SJeff Kirsher #include <linux/types.h> 36dee1ad47SJeff Kirsher #include <linux/timer.h> 37dee1ad47SJeff Kirsher #include <linux/workqueue.h> 38dee1ad47SJeff Kirsher #include <linux/io.h> 39dee1ad47SJeff Kirsher #include <linux/netdevice.h> 40dee1ad47SJeff Kirsher #include <linux/pci.h> 41dee1ad47SJeff Kirsher #include <linux/pci-aspm.h> 42dee1ad47SJeff Kirsher #include <linux/crc32.h> 43dee1ad47SJeff Kirsher #include <linux/if_vlan.h> 44b67e1913SBruce Allan #include <linux/clocksource.h> 45b67e1913SBruce Allan #include <linux/net_tstamp.h> 46d89777bfSBruce Allan #include <linux/ptp_clock_kernel.h> 47d89777bfSBruce Allan #include <linux/ptp_classify.h> 48dee1ad47SJeff Kirsher #include "hw.h" 49dee1ad47SJeff Kirsher 50dee1ad47SJeff Kirsher struct e1000_info; 51dee1ad47SJeff Kirsher 52dee1ad47SJeff Kirsher #define e_dbg(format, arg...) \ 53dee1ad47SJeff Kirsher netdev_dbg(hw->adapter->netdev, format, ## arg) 54dee1ad47SJeff Kirsher #define e_err(format, arg...) \ 55dee1ad47SJeff Kirsher netdev_err(adapter->netdev, format, ## arg) 56dee1ad47SJeff Kirsher #define e_info(format, arg...) \ 57dee1ad47SJeff Kirsher netdev_info(adapter->netdev, format, ## arg) 58dee1ad47SJeff Kirsher #define e_warn(format, arg...) \ 59dee1ad47SJeff Kirsher netdev_warn(adapter->netdev, format, ## arg) 60dee1ad47SJeff Kirsher #define e_notice(format, arg...) \ 61dee1ad47SJeff Kirsher netdev_notice(adapter->netdev, format, ## arg) 62dee1ad47SJeff Kirsher 63dee1ad47SJeff Kirsher 64dee1ad47SJeff Kirsher /* Interrupt modes, as used by the IntMode parameter */ 65dee1ad47SJeff Kirsher #define E1000E_INT_MODE_LEGACY 0 66dee1ad47SJeff Kirsher #define E1000E_INT_MODE_MSI 1 67dee1ad47SJeff Kirsher #define E1000E_INT_MODE_MSIX 2 68dee1ad47SJeff Kirsher 69dee1ad47SJeff Kirsher /* Tx/Rx descriptor defines */ 70dee1ad47SJeff Kirsher #define E1000_DEFAULT_TXD 256 71dee1ad47SJeff Kirsher #define E1000_MAX_TXD 4096 72dee1ad47SJeff Kirsher #define E1000_MIN_TXD 64 73dee1ad47SJeff Kirsher 74dee1ad47SJeff Kirsher #define E1000_DEFAULT_RXD 256 75dee1ad47SJeff Kirsher #define E1000_MAX_RXD 4096 76dee1ad47SJeff Kirsher #define E1000_MIN_RXD 64 77dee1ad47SJeff Kirsher 78dee1ad47SJeff Kirsher #define E1000_MIN_ITR_USECS 10 /* 100000 irq/sec */ 79dee1ad47SJeff Kirsher #define E1000_MAX_ITR_USECS 10000 /* 100 irq/sec */ 80dee1ad47SJeff Kirsher 81dee1ad47SJeff Kirsher /* Early Receive defines */ 82dee1ad47SJeff Kirsher #define E1000_ERT_2048 0x100 83dee1ad47SJeff Kirsher 84dee1ad47SJeff Kirsher #define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */ 85dee1ad47SJeff Kirsher 86dee1ad47SJeff Kirsher /* How many Tx Descriptors do we need to call netif_wake_queue ? */ 87dee1ad47SJeff Kirsher /* How many Rx Buffers do we bundle into one write to the hardware ? */ 88dee1ad47SJeff Kirsher #define E1000_RX_BUFFER_WRITE 16 /* Must be power of 2 */ 89dee1ad47SJeff Kirsher 90dee1ad47SJeff Kirsher #define AUTO_ALL_MODES 0 91dee1ad47SJeff Kirsher #define E1000_EEPROM_APME 0x0400 92dee1ad47SJeff Kirsher 93dee1ad47SJeff Kirsher #define E1000_MNG_VLAN_NONE (-1) 94dee1ad47SJeff Kirsher 95dee1ad47SJeff Kirsher /* Number of packet split data buffers (not including the header buffer) */ 96dee1ad47SJeff Kirsher #define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1) 97dee1ad47SJeff Kirsher 98dee1ad47SJeff Kirsher #define DEFAULT_JUMBO 9234 99dee1ad47SJeff Kirsher 100dee1ad47SJeff Kirsher /* BM/HV Specific Registers */ 101dee1ad47SJeff Kirsher #define BM_PORT_CTRL_PAGE 769 102dee1ad47SJeff Kirsher 103dee1ad47SJeff Kirsher #define PHY_UPPER_SHIFT 21 104dee1ad47SJeff Kirsher #define BM_PHY_REG(page, reg) \ 105dee1ad47SJeff Kirsher (((reg) & MAX_PHY_REG_ADDRESS) |\ 106dee1ad47SJeff Kirsher (((page) & 0xFFFF) << PHY_PAGE_SHIFT) |\ 107dee1ad47SJeff Kirsher (((reg) & ~MAX_PHY_REG_ADDRESS) << (PHY_UPPER_SHIFT - PHY_PAGE_SHIFT))) 108dee1ad47SJeff Kirsher 109dee1ad47SJeff Kirsher /* PHY Wakeup Registers and defines */ 110dee1ad47SJeff Kirsher #define BM_PORT_GEN_CFG PHY_REG(BM_PORT_CTRL_PAGE, 17) 111dee1ad47SJeff Kirsher #define BM_RCTL PHY_REG(BM_WUC_PAGE, 0) 112dee1ad47SJeff Kirsher #define BM_WUC PHY_REG(BM_WUC_PAGE, 1) 113dee1ad47SJeff Kirsher #define BM_WUFC PHY_REG(BM_WUC_PAGE, 2) 114dee1ad47SJeff Kirsher #define BM_WUS PHY_REG(BM_WUC_PAGE, 3) 115dee1ad47SJeff Kirsher #define BM_RAR_L(_i) (BM_PHY_REG(BM_WUC_PAGE, 16 + ((_i) << 2))) 116dee1ad47SJeff Kirsher #define BM_RAR_M(_i) (BM_PHY_REG(BM_WUC_PAGE, 17 + ((_i) << 2))) 117dee1ad47SJeff Kirsher #define BM_RAR_H(_i) (BM_PHY_REG(BM_WUC_PAGE, 18 + ((_i) << 2))) 118dee1ad47SJeff Kirsher #define BM_RAR_CTRL(_i) (BM_PHY_REG(BM_WUC_PAGE, 19 + ((_i) << 2))) 119dee1ad47SJeff Kirsher #define BM_MTA(_i) (BM_PHY_REG(BM_WUC_PAGE, 128 + ((_i) << 1))) 120dee1ad47SJeff Kirsher 121dee1ad47SJeff Kirsher #define BM_RCTL_UPE 0x0001 /* Unicast Promiscuous Mode */ 122dee1ad47SJeff Kirsher #define BM_RCTL_MPE 0x0002 /* Multicast Promiscuous Mode */ 123dee1ad47SJeff Kirsher #define BM_RCTL_MO_SHIFT 3 /* Multicast Offset Shift */ 124dee1ad47SJeff Kirsher #define BM_RCTL_MO_MASK (3 << 3) /* Multicast Offset Mask */ 125dee1ad47SJeff Kirsher #define BM_RCTL_BAM 0x0020 /* Broadcast Accept Mode */ 126dee1ad47SJeff Kirsher #define BM_RCTL_PMCF 0x0040 /* Pass MAC Control Frames */ 127dee1ad47SJeff Kirsher #define BM_RCTL_RFCE 0x0080 /* Rx Flow Control Enable */ 128dee1ad47SJeff Kirsher 129dee1ad47SJeff Kirsher #define HV_STATS_PAGE 778 130dee1ad47SJeff Kirsher #define HV_SCC_UPPER PHY_REG(HV_STATS_PAGE, 16) /* Single Collision Count */ 131dee1ad47SJeff Kirsher #define HV_SCC_LOWER PHY_REG(HV_STATS_PAGE, 17) 132dee1ad47SJeff Kirsher #define HV_ECOL_UPPER PHY_REG(HV_STATS_PAGE, 18) /* Excessive Coll. Count */ 133dee1ad47SJeff Kirsher #define HV_ECOL_LOWER PHY_REG(HV_STATS_PAGE, 19) 134dee1ad47SJeff Kirsher #define HV_MCC_UPPER PHY_REG(HV_STATS_PAGE, 20) /* Multiple Coll. Count */ 135dee1ad47SJeff Kirsher #define HV_MCC_LOWER PHY_REG(HV_STATS_PAGE, 21) 136dee1ad47SJeff Kirsher #define HV_LATECOL_UPPER PHY_REG(HV_STATS_PAGE, 23) /* Late Collision Count */ 137dee1ad47SJeff Kirsher #define HV_LATECOL_LOWER PHY_REG(HV_STATS_PAGE, 24) 138dee1ad47SJeff Kirsher #define HV_COLC_UPPER PHY_REG(HV_STATS_PAGE, 25) /* Collision Count */ 139dee1ad47SJeff Kirsher #define HV_COLC_LOWER PHY_REG(HV_STATS_PAGE, 26) 140dee1ad47SJeff Kirsher #define HV_DC_UPPER PHY_REG(HV_STATS_PAGE, 27) /* Defer Count */ 141dee1ad47SJeff Kirsher #define HV_DC_LOWER PHY_REG(HV_STATS_PAGE, 28) 142dee1ad47SJeff Kirsher #define HV_TNCRS_UPPER PHY_REG(HV_STATS_PAGE, 29) /* Transmit with no CRS */ 143dee1ad47SJeff Kirsher #define HV_TNCRS_LOWER PHY_REG(HV_STATS_PAGE, 30) 144dee1ad47SJeff Kirsher 145dee1ad47SJeff Kirsher #define E1000_FCRTV_PCH 0x05F40 /* PCH Flow Control Refresh Timer Value */ 146dee1ad47SJeff Kirsher 147dee1ad47SJeff Kirsher /* BM PHY Copper Specific Status */ 148dee1ad47SJeff Kirsher #define BM_CS_STATUS 17 149dee1ad47SJeff Kirsher #define BM_CS_STATUS_LINK_UP 0x0400 150dee1ad47SJeff Kirsher #define BM_CS_STATUS_RESOLVED 0x0800 151dee1ad47SJeff Kirsher #define BM_CS_STATUS_SPEED_MASK 0xC000 152dee1ad47SJeff Kirsher #define BM_CS_STATUS_SPEED_1000 0x8000 153dee1ad47SJeff Kirsher 154dee1ad47SJeff Kirsher /* 82577 Mobile Phy Status Register */ 155dee1ad47SJeff Kirsher #define HV_M_STATUS 26 156dee1ad47SJeff Kirsher #define HV_M_STATUS_AUTONEG_COMPLETE 0x1000 157dee1ad47SJeff Kirsher #define HV_M_STATUS_SPEED_MASK 0x0300 158dee1ad47SJeff Kirsher #define HV_M_STATUS_SPEED_1000 0x0200 159dee1ad47SJeff Kirsher #define HV_M_STATUS_LINK_UP 0x0040 160dee1ad47SJeff Kirsher 161823dcd25SDavid S. Miller #define E1000_ICH_FWSM_PCIM2PCI 0x01000000 /* ME PCIm-to-PCI active */ 162823dcd25SDavid S. Miller #define E1000_ICH_FWSM_PCIM2PCI_COUNT 2000 163823dcd25SDavid S. Miller 164dee1ad47SJeff Kirsher /* Time to wait before putting the device into D3 if there's no link (in ms). */ 165dee1ad47SJeff Kirsher #define LINK_TIMEOUT 100 166dee1ad47SJeff Kirsher 167e921eb1aSBruce Allan /* Count for polling __E1000_RESET condition every 10-20msec. 168bb9e44d0SBruce Allan * Experimentation has shown the reset can take approximately 210msec. 169bb9e44d0SBruce Allan */ 170bb9e44d0SBruce Allan #define E1000_CHECK_RESET_COUNT 25 171bb9e44d0SBruce Allan 172dee1ad47SJeff Kirsher #define DEFAULT_RDTR 0 173dee1ad47SJeff Kirsher #define DEFAULT_RADV 8 174dee1ad47SJeff Kirsher #define BURST_RDTR 0x20 175dee1ad47SJeff Kirsher #define BURST_RADV 0x20 176dee1ad47SJeff Kirsher 177e921eb1aSBruce Allan /* in the case of WTHRESH, it appears at least the 82571/2 hardware 178dee1ad47SJeff Kirsher * writes back 4 descriptors when WTHRESH=5, and 3 descriptors when 1798edc0e62SHiroaki SHIMODA * WTHRESH=4, so a setting of 5 gives the most efficient bus 1808edc0e62SHiroaki SHIMODA * utilization but to avoid possible Tx stalls, set it to 1 181dee1ad47SJeff Kirsher */ 182dee1ad47SJeff Kirsher #define E1000_TXDCTL_DMA_BURST_ENABLE \ 183dee1ad47SJeff Kirsher (E1000_TXDCTL_GRAN | /* set descriptor granularity */ \ 184dee1ad47SJeff Kirsher E1000_TXDCTL_COUNT_DESC | \ 1858edc0e62SHiroaki SHIMODA (1 << 16) | /* wthresh must be +1 more than desired */\ 186dee1ad47SJeff Kirsher (1 << 8) | /* hthresh */ \ 187dee1ad47SJeff Kirsher 0x1f) /* pthresh */ 188dee1ad47SJeff Kirsher 189dee1ad47SJeff Kirsher #define E1000_RXDCTL_DMA_BURST_ENABLE \ 190dee1ad47SJeff Kirsher (0x01000000 | /* set descriptor granularity */ \ 191dee1ad47SJeff Kirsher (4 << 16) | /* set writeback threshold */ \ 192dee1ad47SJeff Kirsher (4 << 8) | /* set prefetch threshold */ \ 193dee1ad47SJeff Kirsher 0x20) /* set hthresh */ 194dee1ad47SJeff Kirsher 195dee1ad47SJeff Kirsher #define E1000_TIDV_FPD (1 << 31) 196dee1ad47SJeff Kirsher #define E1000_RDTR_FPD (1 << 31) 197dee1ad47SJeff Kirsher 198dee1ad47SJeff Kirsher enum e1000_boards { 199dee1ad47SJeff Kirsher board_82571, 200dee1ad47SJeff Kirsher board_82572, 201dee1ad47SJeff Kirsher board_82573, 202dee1ad47SJeff Kirsher board_82574, 203dee1ad47SJeff Kirsher board_82583, 204dee1ad47SJeff Kirsher board_80003es2lan, 205dee1ad47SJeff Kirsher board_ich8lan, 206dee1ad47SJeff Kirsher board_ich9lan, 207dee1ad47SJeff Kirsher board_ich10lan, 208dee1ad47SJeff Kirsher board_pchlan, 209dee1ad47SJeff Kirsher board_pch2lan, 2102fbe4526SBruce Allan board_pch_lpt, 211dee1ad47SJeff Kirsher }; 212dee1ad47SJeff Kirsher 213dee1ad47SJeff Kirsher struct e1000_ps_page { 214dee1ad47SJeff Kirsher struct page *page; 215dee1ad47SJeff Kirsher u64 dma; /* must be u64 - written to hw */ 216dee1ad47SJeff Kirsher }; 217dee1ad47SJeff Kirsher 218e921eb1aSBruce Allan /* wrappers around a pointer to a socket buffer, 219dee1ad47SJeff Kirsher * so a DMA handle can be stored along with the buffer 220dee1ad47SJeff Kirsher */ 221dee1ad47SJeff Kirsher struct e1000_buffer { 222dee1ad47SJeff Kirsher dma_addr_t dma; 223dee1ad47SJeff Kirsher struct sk_buff *skb; 224dee1ad47SJeff Kirsher union { 225dee1ad47SJeff Kirsher /* Tx */ 226dee1ad47SJeff Kirsher struct { 227dee1ad47SJeff Kirsher unsigned long time_stamp; 228dee1ad47SJeff Kirsher u16 length; 229dee1ad47SJeff Kirsher u16 next_to_watch; 230dee1ad47SJeff Kirsher unsigned int segs; 231dee1ad47SJeff Kirsher unsigned int bytecount; 232dee1ad47SJeff Kirsher u16 mapped_as_page; 233dee1ad47SJeff Kirsher }; 234dee1ad47SJeff Kirsher /* Rx */ 235dee1ad47SJeff Kirsher struct { 236dee1ad47SJeff Kirsher /* arrays of page information for packet split */ 237dee1ad47SJeff Kirsher struct e1000_ps_page *ps_pages; 238dee1ad47SJeff Kirsher struct page *page; 239dee1ad47SJeff Kirsher }; 240dee1ad47SJeff Kirsher }; 241dee1ad47SJeff Kirsher }; 242dee1ad47SJeff Kirsher 243dee1ad47SJeff Kirsher struct e1000_ring { 24455aa6985SBruce Allan struct e1000_adapter *adapter; /* back pointer to adapter */ 245dee1ad47SJeff Kirsher void *desc; /* pointer to ring memory */ 246dee1ad47SJeff Kirsher dma_addr_t dma; /* phys address of ring */ 247dee1ad47SJeff Kirsher unsigned int size; /* length of ring in bytes */ 248dee1ad47SJeff Kirsher unsigned int count; /* number of desc. in ring */ 249dee1ad47SJeff Kirsher 250dee1ad47SJeff Kirsher u16 next_to_use; 251dee1ad47SJeff Kirsher u16 next_to_clean; 252dee1ad47SJeff Kirsher 253c5083cf6SBruce Allan void __iomem *head; 254c5083cf6SBruce Allan void __iomem *tail; 255dee1ad47SJeff Kirsher 256dee1ad47SJeff Kirsher /* array of buffer information structs */ 257dee1ad47SJeff Kirsher struct e1000_buffer *buffer_info; 258dee1ad47SJeff Kirsher 259dee1ad47SJeff Kirsher char name[IFNAMSIZ + 5]; 260dee1ad47SJeff Kirsher u32 ims_val; 261dee1ad47SJeff Kirsher u32 itr_val; 262c5083cf6SBruce Allan void __iomem *itr_register; 263dee1ad47SJeff Kirsher int set_itr; 264dee1ad47SJeff Kirsher 265dee1ad47SJeff Kirsher struct sk_buff *rx_skb_top; 266dee1ad47SJeff Kirsher }; 267dee1ad47SJeff Kirsher 268dee1ad47SJeff Kirsher /* PHY register snapshot values */ 269dee1ad47SJeff Kirsher struct e1000_phy_regs { 270dee1ad47SJeff Kirsher u16 bmcr; /* basic mode control register */ 271dee1ad47SJeff Kirsher u16 bmsr; /* basic mode status register */ 272dee1ad47SJeff Kirsher u16 advertise; /* auto-negotiation advertisement */ 273dee1ad47SJeff Kirsher u16 lpa; /* link partner ability register */ 274dee1ad47SJeff Kirsher u16 expansion; /* auto-negotiation expansion reg */ 275dee1ad47SJeff Kirsher u16 ctrl1000; /* 1000BASE-T control register */ 276dee1ad47SJeff Kirsher u16 stat1000; /* 1000BASE-T status register */ 277dee1ad47SJeff Kirsher u16 estatus; /* extended status register */ 278dee1ad47SJeff Kirsher }; 279dee1ad47SJeff Kirsher 280dee1ad47SJeff Kirsher /* board specific private data structure */ 281dee1ad47SJeff Kirsher struct e1000_adapter { 282dee1ad47SJeff Kirsher struct timer_list watchdog_timer; 283dee1ad47SJeff Kirsher struct timer_list phy_info_timer; 284dee1ad47SJeff Kirsher struct timer_list blink_timer; 285dee1ad47SJeff Kirsher 286dee1ad47SJeff Kirsher struct work_struct reset_task; 287dee1ad47SJeff Kirsher struct work_struct watchdog_task; 288dee1ad47SJeff Kirsher 289dee1ad47SJeff Kirsher const struct e1000_info *ei; 290dee1ad47SJeff Kirsher 291dee1ad47SJeff Kirsher unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 292dee1ad47SJeff Kirsher u32 bd_number; 293dee1ad47SJeff Kirsher u32 rx_buffer_len; 294dee1ad47SJeff Kirsher u16 mng_vlan_id; 295dee1ad47SJeff Kirsher u16 link_speed; 296dee1ad47SJeff Kirsher u16 link_duplex; 297dee1ad47SJeff Kirsher u16 eeprom_vers; 298dee1ad47SJeff Kirsher 299dee1ad47SJeff Kirsher /* track device up/down/testing state */ 300dee1ad47SJeff Kirsher unsigned long state; 301dee1ad47SJeff Kirsher 302dee1ad47SJeff Kirsher /* Interrupt Throttle Rate */ 303dee1ad47SJeff Kirsher u32 itr; 304dee1ad47SJeff Kirsher u32 itr_setting; 305dee1ad47SJeff Kirsher u16 tx_itr; 306dee1ad47SJeff Kirsher u16 rx_itr; 307dee1ad47SJeff Kirsher 308e921eb1aSBruce Allan /* Tx */ 309dee1ad47SJeff Kirsher struct e1000_ring *tx_ring /* One per active queue */ 310dee1ad47SJeff Kirsher ____cacheline_aligned_in_smp; 311d821a4c4SBruce Allan u32 tx_fifo_limit; 312dee1ad47SJeff Kirsher 313dee1ad47SJeff Kirsher struct napi_struct napi; 314dee1ad47SJeff Kirsher 31594fb848bSBruce Allan unsigned int uncorr_errors; /* uncorrectable ECC errors */ 31694fb848bSBruce Allan unsigned int corr_errors; /* correctable ECC errors */ 317dee1ad47SJeff Kirsher unsigned int restart_queue; 318dee1ad47SJeff Kirsher u32 txd_cmd; 319dee1ad47SJeff Kirsher 320dee1ad47SJeff Kirsher bool detect_tx_hung; 32109357b00SJeff Kirsher bool tx_hang_recheck; 322dee1ad47SJeff Kirsher u8 tx_timeout_factor; 323dee1ad47SJeff Kirsher 324dee1ad47SJeff Kirsher u32 tx_int_delay; 325dee1ad47SJeff Kirsher u32 tx_abs_int_delay; 326dee1ad47SJeff Kirsher 327dee1ad47SJeff Kirsher unsigned int total_tx_bytes; 328dee1ad47SJeff Kirsher unsigned int total_tx_packets; 329dee1ad47SJeff Kirsher unsigned int total_rx_bytes; 330dee1ad47SJeff Kirsher unsigned int total_rx_packets; 331dee1ad47SJeff Kirsher 332dee1ad47SJeff Kirsher /* Tx stats */ 333dee1ad47SJeff Kirsher u64 tpt_old; 334dee1ad47SJeff Kirsher u64 colc_old; 335dee1ad47SJeff Kirsher u32 gotc; 336dee1ad47SJeff Kirsher u64 gotc_old; 337dee1ad47SJeff Kirsher u32 tx_timeout_count; 338dee1ad47SJeff Kirsher u32 tx_fifo_head; 339dee1ad47SJeff Kirsher u32 tx_head_addr; 340dee1ad47SJeff Kirsher u32 tx_fifo_size; 341dee1ad47SJeff Kirsher u32 tx_dma_failed; 342dee1ad47SJeff Kirsher 343e921eb1aSBruce Allan /* Rx */ 34455aa6985SBruce Allan bool (*clean_rx) (struct e1000_ring *ring, int *work_done, 34555aa6985SBruce Allan int work_to_do) ____cacheline_aligned_in_smp; 34655aa6985SBruce Allan void (*alloc_rx_buf) (struct e1000_ring *ring, int cleaned_count, 34755aa6985SBruce Allan gfp_t gfp); 348dee1ad47SJeff Kirsher struct e1000_ring *rx_ring; 349dee1ad47SJeff Kirsher 350dee1ad47SJeff Kirsher u32 rx_int_delay; 351dee1ad47SJeff Kirsher u32 rx_abs_int_delay; 352dee1ad47SJeff Kirsher 353dee1ad47SJeff Kirsher /* Rx stats */ 354dee1ad47SJeff Kirsher u64 hw_csum_err; 355dee1ad47SJeff Kirsher u64 hw_csum_good; 356dee1ad47SJeff Kirsher u64 rx_hdr_split; 357dee1ad47SJeff Kirsher u32 gorc; 358dee1ad47SJeff Kirsher u64 gorc_old; 359dee1ad47SJeff Kirsher u32 alloc_rx_buff_failed; 360dee1ad47SJeff Kirsher u32 rx_dma_failed; 361b67e1913SBruce Allan u32 rx_hwtstamp_cleared; 362dee1ad47SJeff Kirsher 363dee1ad47SJeff Kirsher unsigned int rx_ps_pages; 364dee1ad47SJeff Kirsher u16 rx_ps_bsize0; 365dee1ad47SJeff Kirsher u32 max_frame_size; 366dee1ad47SJeff Kirsher u32 min_frame_size; 367dee1ad47SJeff Kirsher 368dee1ad47SJeff Kirsher /* OS defined structs */ 369dee1ad47SJeff Kirsher struct net_device *netdev; 370dee1ad47SJeff Kirsher struct pci_dev *pdev; 371dee1ad47SJeff Kirsher 372dee1ad47SJeff Kirsher /* structs defined in e1000_hw.h */ 373dee1ad47SJeff Kirsher struct e1000_hw hw; 374dee1ad47SJeff Kirsher 375*9d57088bSBruce Allan spinlock_t stats64_lock; /* protects statistics counters */ 376dee1ad47SJeff Kirsher struct e1000_hw_stats stats; 377dee1ad47SJeff Kirsher struct e1000_phy_info phy_info; 378dee1ad47SJeff Kirsher struct e1000_phy_stats phy_stats; 379dee1ad47SJeff Kirsher 380dee1ad47SJeff Kirsher /* Snapshot of PHY registers */ 381dee1ad47SJeff Kirsher struct e1000_phy_regs phy_regs; 382dee1ad47SJeff Kirsher 383dee1ad47SJeff Kirsher struct e1000_ring test_tx_ring; 384dee1ad47SJeff Kirsher struct e1000_ring test_rx_ring; 385dee1ad47SJeff Kirsher u32 test_icr; 386dee1ad47SJeff Kirsher 387dee1ad47SJeff Kirsher u32 msg_enable; 388dee1ad47SJeff Kirsher unsigned int num_vectors; 389dee1ad47SJeff Kirsher struct msix_entry *msix_entries; 390dee1ad47SJeff Kirsher int int_mode; 391dee1ad47SJeff Kirsher u32 eiac_mask; 392dee1ad47SJeff Kirsher 393dee1ad47SJeff Kirsher u32 eeprom_wol; 394dee1ad47SJeff Kirsher u32 wol; 395dee1ad47SJeff Kirsher u32 pba; 396dee1ad47SJeff Kirsher u32 max_hw_frame_size; 397dee1ad47SJeff Kirsher 398dee1ad47SJeff Kirsher bool fc_autoneg; 399dee1ad47SJeff Kirsher 400dee1ad47SJeff Kirsher unsigned int flags; 401dee1ad47SJeff Kirsher unsigned int flags2; 402dee1ad47SJeff Kirsher struct work_struct downshift_task; 403dee1ad47SJeff Kirsher struct work_struct update_phy_task; 404dee1ad47SJeff Kirsher struct work_struct print_hang_task; 405dee1ad47SJeff Kirsher 406dee1ad47SJeff Kirsher bool idle_check; 407dee1ad47SJeff Kirsher int phy_hang_count; 40855aa6985SBruce Allan 40955aa6985SBruce Allan u16 tx_ring_count; 41055aa6985SBruce Allan u16 rx_ring_count; 411b67e1913SBruce Allan 412b67e1913SBruce Allan struct hwtstamp_config hwtstamp_config; 413b67e1913SBruce Allan struct delayed_work systim_overflow_work; 414b67e1913SBruce Allan struct sk_buff *tx_hwtstamp_skb; 415b67e1913SBruce Allan struct work_struct tx_hwtstamp_work; 416b67e1913SBruce Allan spinlock_t systim_lock; /* protects SYSTIML/H regsters */ 417b67e1913SBruce Allan struct cyclecounter cc; 418b67e1913SBruce Allan struct timecounter tc; 419d89777bfSBruce Allan struct ptp_clock *ptp_clock; 420d89777bfSBruce Allan struct ptp_clock_info ptp_clock_info; 421dee1ad47SJeff Kirsher }; 422dee1ad47SJeff Kirsher 423dee1ad47SJeff Kirsher struct e1000_info { 424dee1ad47SJeff Kirsher enum e1000_mac_type mac; 425dee1ad47SJeff Kirsher unsigned int flags; 426dee1ad47SJeff Kirsher unsigned int flags2; 427dee1ad47SJeff Kirsher u32 pba; 428dee1ad47SJeff Kirsher u32 max_hw_frame_size; 429dee1ad47SJeff Kirsher s32 (*get_variants)(struct e1000_adapter *); 4308ce9d6c7SJeff Kirsher const struct e1000_mac_operations *mac_ops; 4318ce9d6c7SJeff Kirsher const struct e1000_phy_operations *phy_ops; 4328ce9d6c7SJeff Kirsher const struct e1000_nvm_operations *nvm_ops; 433dee1ad47SJeff Kirsher }; 434dee1ad47SJeff Kirsher 435d89777bfSBruce Allan s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca); 436d89777bfSBruce Allan 437b67e1913SBruce Allan /* The system time is maintained by a 64-bit counter comprised of the 32-bit 438b67e1913SBruce Allan * SYSTIMH and SYSTIML registers. How the counter increments (and therefore 439b67e1913SBruce Allan * its resolution) is based on the contents of the TIMINCA register - it 440b67e1913SBruce Allan * increments every incperiod (bits 31:24) clock ticks by incvalue (bits 23:0). 441b67e1913SBruce Allan * For the best accuracy, the incperiod should be as small as possible. The 442b67e1913SBruce Allan * incvalue is scaled by a factor as large as possible (while still fitting 443b67e1913SBruce Allan * in bits 23:0) so that relatively small clock corrections can be made. 444b67e1913SBruce Allan * 445b67e1913SBruce Allan * As a result, a shift of INCVALUE_SHIFT_n is used to fit a value of 446b67e1913SBruce Allan * INCVALUE_n into the TIMINCA register allowing 32+8+(24-INCVALUE_SHIFT_n) 447b67e1913SBruce Allan * bits to count nanoseconds leaving the rest for fractional nonseconds. 448b67e1913SBruce Allan */ 449b67e1913SBruce Allan #define INCVALUE_96MHz 125 450b67e1913SBruce Allan #define INCVALUE_SHIFT_96MHz 17 451b67e1913SBruce Allan #define INCPERIOD_SHIFT_96MHz 2 452b67e1913SBruce Allan #define INCPERIOD_96MHz (12 >> INCPERIOD_SHIFT_96MHz) 453b67e1913SBruce Allan 454b67e1913SBruce Allan #define INCVALUE_25MHz 40 455b67e1913SBruce Allan #define INCVALUE_SHIFT_25MHz 18 456b67e1913SBruce Allan #define INCPERIOD_25MHz 1 457b67e1913SBruce Allan 458b67e1913SBruce Allan /* Another drawback of scaling the incvalue by a large factor is the 459b67e1913SBruce Allan * 64-bit SYSTIM register overflows more quickly. This is dealt with 460b67e1913SBruce Allan * by simply reading the clock before it overflows. 461b67e1913SBruce Allan * 462b67e1913SBruce Allan * Clock ns bits Overflows after 463b67e1913SBruce Allan * ~~~~~~ ~~~~~~~ ~~~~~~~~~~~~~~~ 464b67e1913SBruce Allan * 96MHz 47-bit 2^(47-INCPERIOD_SHIFT_96MHz) / 10^9 / 3600 = 9.77 hrs 465b67e1913SBruce Allan * 25MHz 46-bit 2^46 / 10^9 / 3600 = 19.55 hours 466b67e1913SBruce Allan */ 467b67e1913SBruce Allan #define E1000_SYSTIM_OVERFLOW_PERIOD (HZ * 60 * 60 * 4) 468b67e1913SBruce Allan 469dee1ad47SJeff Kirsher /* hardware capability, feature, and workaround flags */ 470dee1ad47SJeff Kirsher #define FLAG_HAS_AMT (1 << 0) 471dee1ad47SJeff Kirsher #define FLAG_HAS_FLASH (1 << 1) 472dee1ad47SJeff Kirsher #define FLAG_HAS_HW_VLAN_FILTER (1 << 2) 473dee1ad47SJeff Kirsher #define FLAG_HAS_WOL (1 << 3) 47479d4e908SBruce Allan /* reserved bit4 */ 475dee1ad47SJeff Kirsher #define FLAG_HAS_CTRLEXT_ON_LOAD (1 << 5) 476dee1ad47SJeff Kirsher #define FLAG_HAS_SWSM_ON_LOAD (1 << 6) 477dee1ad47SJeff Kirsher #define FLAG_HAS_JUMBO_FRAMES (1 << 7) 478dee1ad47SJeff Kirsher #define FLAG_READ_ONLY_NVM (1 << 8) 479dee1ad47SJeff Kirsher #define FLAG_IS_ICH (1 << 9) 480dee1ad47SJeff Kirsher #define FLAG_HAS_MSIX (1 << 10) 481dee1ad47SJeff Kirsher #define FLAG_HAS_SMART_POWER_DOWN (1 << 11) 482dee1ad47SJeff Kirsher #define FLAG_IS_QUAD_PORT_A (1 << 12) 483dee1ad47SJeff Kirsher #define FLAG_IS_QUAD_PORT (1 << 13) 484b67e1913SBruce Allan #define FLAG_HAS_HW_TIMESTAMP (1 << 14) 485dee1ad47SJeff Kirsher #define FLAG_APME_IN_WUC (1 << 15) 486dee1ad47SJeff Kirsher #define FLAG_APME_IN_CTRL3 (1 << 16) 487dee1ad47SJeff Kirsher #define FLAG_APME_CHECK_PORT_B (1 << 17) 488dee1ad47SJeff Kirsher #define FLAG_DISABLE_FC_PAUSE_TIME (1 << 18) 489dee1ad47SJeff Kirsher #define FLAG_NO_WAKE_UCAST (1 << 19) 490dee1ad47SJeff Kirsher #define FLAG_MNG_PT_ENABLED (1 << 20) 491dee1ad47SJeff Kirsher #define FLAG_RESET_OVERWRITES_LAA (1 << 21) 492dee1ad47SJeff Kirsher #define FLAG_TARC_SPEED_MODE_BIT (1 << 22) 493dee1ad47SJeff Kirsher #define FLAG_TARC_SET_BIT_ZERO (1 << 23) 494dee1ad47SJeff Kirsher #define FLAG_RX_NEEDS_RESTART (1 << 24) 495dee1ad47SJeff Kirsher #define FLAG_LSC_GIG_SPEED_DROP (1 << 25) 496dee1ad47SJeff Kirsher #define FLAG_SMART_POWER_DOWN (1 << 26) 497dee1ad47SJeff Kirsher #define FLAG_MSI_ENABLED (1 << 27) 498dc221294SBruce Allan /* reserved (1 << 28) */ 499dee1ad47SJeff Kirsher #define FLAG_TSO_FORCE (1 << 29) 50012d43f7dSBruce Allan #define FLAG_RESTART_NOW (1 << 30) 501dee1ad47SJeff Kirsher #define FLAG_MSI_TEST_FAILED (1 << 31) 502dee1ad47SJeff Kirsher 503dee1ad47SJeff Kirsher #define FLAG2_CRC_STRIPPING (1 << 0) 504dee1ad47SJeff Kirsher #define FLAG2_HAS_PHY_WAKEUP (1 << 1) 505dee1ad47SJeff Kirsher #define FLAG2_IS_DISCARDING (1 << 2) 506dee1ad47SJeff Kirsher #define FLAG2_DISABLE_ASPM_L1 (1 << 3) 507dee1ad47SJeff Kirsher #define FLAG2_HAS_PHY_STATS (1 << 4) 508dee1ad47SJeff Kirsher #define FLAG2_HAS_EEE (1 << 5) 509dee1ad47SJeff Kirsher #define FLAG2_DMA_BURST (1 << 6) 510dee1ad47SJeff Kirsher #define FLAG2_DISABLE_ASPM_L0S (1 << 7) 511dee1ad47SJeff Kirsher #define FLAG2_DISABLE_AIM (1 << 8) 512dee1ad47SJeff Kirsher #define FLAG2_CHECK_PHY_HANG (1 << 9) 513823dcd25SDavid S. Miller #define FLAG2_NO_DISABLE_RX (1 << 10) 514823dcd25SDavid S. Miller #define FLAG2_PCIM2PCI_ARBITER_WA (1 << 11) 5150184039aSBen Greear #define FLAG2_DFLT_CRC_STRIPPING (1 << 12) 516b67e1913SBruce Allan #define FLAG2_CHECK_RX_HWTSTAMP (1 << 13) 517dee1ad47SJeff Kirsher 518dee1ad47SJeff Kirsher #define E1000_RX_DESC_PS(R, i) \ 519dee1ad47SJeff Kirsher (&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) 5205f450212SBruce Allan #define E1000_RX_DESC_EXT(R, i) \ 5215f450212SBruce Allan (&(((union e1000_rx_desc_extended *)((R).desc))[i])) 522dee1ad47SJeff Kirsher #define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i])) 523dee1ad47SJeff Kirsher #define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc) 524dee1ad47SJeff Kirsher #define E1000_CONTEXT_DESC(R, i) E1000_GET_DESC(R, i, e1000_context_desc) 525dee1ad47SJeff Kirsher 526dee1ad47SJeff Kirsher enum e1000_state_t { 527dee1ad47SJeff Kirsher __E1000_TESTING, 528dee1ad47SJeff Kirsher __E1000_RESETTING, 529a90b412cSBruce Allan __E1000_ACCESS_SHARED_RESOURCE, 530dee1ad47SJeff Kirsher __E1000_DOWN 531dee1ad47SJeff Kirsher }; 532dee1ad47SJeff Kirsher 533dee1ad47SJeff Kirsher enum latency_range { 534dee1ad47SJeff Kirsher lowest_latency = 0, 535dee1ad47SJeff Kirsher low_latency = 1, 536dee1ad47SJeff Kirsher bulk_latency = 2, 537dee1ad47SJeff Kirsher latency_invalid = 255 538dee1ad47SJeff Kirsher }; 539dee1ad47SJeff Kirsher 540dee1ad47SJeff Kirsher extern char e1000e_driver_name[]; 541dee1ad47SJeff Kirsher extern const char e1000e_driver_version[]; 542dee1ad47SJeff Kirsher 543dee1ad47SJeff Kirsher extern void e1000e_check_options(struct e1000_adapter *adapter); 544dee1ad47SJeff Kirsher extern void e1000e_set_ethtool_ops(struct net_device *netdev); 545dee1ad47SJeff Kirsher 546dee1ad47SJeff Kirsher extern int e1000e_up(struct e1000_adapter *adapter); 547dee1ad47SJeff Kirsher extern void e1000e_down(struct e1000_adapter *adapter); 548dee1ad47SJeff Kirsher extern void e1000e_reinit_locked(struct e1000_adapter *adapter); 549dee1ad47SJeff Kirsher extern void e1000e_reset(struct e1000_adapter *adapter); 550dee1ad47SJeff Kirsher extern void e1000e_power_up_phy(struct e1000_adapter *adapter); 55155aa6985SBruce Allan extern int e1000e_setup_rx_resources(struct e1000_ring *ring); 55255aa6985SBruce Allan extern int e1000e_setup_tx_resources(struct e1000_ring *ring); 55355aa6985SBruce Allan extern void e1000e_free_rx_resources(struct e1000_ring *ring); 55455aa6985SBruce Allan extern void e1000e_free_tx_resources(struct e1000_ring *ring); 555dee1ad47SJeff Kirsher extern struct rtnl_link_stats64 *e1000e_get_stats64(struct net_device *netdev, 556dee1ad47SJeff Kirsher struct rtnl_link_stats64 557dee1ad47SJeff Kirsher *stats); 558dee1ad47SJeff Kirsher extern void e1000e_set_interrupt_capability(struct e1000_adapter *adapter); 559dee1ad47SJeff Kirsher extern void e1000e_reset_interrupt_capability(struct e1000_adapter *adapter); 560dee1ad47SJeff Kirsher extern void e1000e_get_hw_control(struct e1000_adapter *adapter); 561dee1ad47SJeff Kirsher extern void e1000e_release_hw_control(struct e1000_adapter *adapter); 56222a4cca2SMatthew Vick extern void e1000e_write_itr(struct e1000_adapter *adapter, u32 itr); 563dee1ad47SJeff Kirsher 564dee1ad47SJeff Kirsher extern unsigned int copybreak; 565dee1ad47SJeff Kirsher 5668ce9d6c7SJeff Kirsher extern const struct e1000_info e1000_82571_info; 5678ce9d6c7SJeff Kirsher extern const struct e1000_info e1000_82572_info; 5688ce9d6c7SJeff Kirsher extern const struct e1000_info e1000_82573_info; 5698ce9d6c7SJeff Kirsher extern const struct e1000_info e1000_82574_info; 5708ce9d6c7SJeff Kirsher extern const struct e1000_info e1000_82583_info; 5718ce9d6c7SJeff Kirsher extern const struct e1000_info e1000_ich8_info; 5728ce9d6c7SJeff Kirsher extern const struct e1000_info e1000_ich9_info; 5738ce9d6c7SJeff Kirsher extern const struct e1000_info e1000_ich10_info; 5748ce9d6c7SJeff Kirsher extern const struct e1000_info e1000_pch_info; 5758ce9d6c7SJeff Kirsher extern const struct e1000_info e1000_pch2_info; 5762fbe4526SBruce Allan extern const struct e1000_info e1000_pch_lpt_info; 5778ce9d6c7SJeff Kirsher extern const struct e1000_info e1000_es2_info; 578dee1ad47SJeff Kirsher 579dee1ad47SJeff Kirsher extern s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num, 580dee1ad47SJeff Kirsher u32 pba_num_size); 581dee1ad47SJeff Kirsher 582dee1ad47SJeff Kirsher extern s32 e1000e_commit_phy(struct e1000_hw *hw); 583dee1ad47SJeff Kirsher 584dee1ad47SJeff Kirsher extern bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw); 585dee1ad47SJeff Kirsher 586dee1ad47SJeff Kirsher extern bool e1000e_get_laa_state_82571(struct e1000_hw *hw); 587dee1ad47SJeff Kirsher extern void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state); 588dee1ad47SJeff Kirsher 589dee1ad47SJeff Kirsher extern void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw); 590dee1ad47SJeff Kirsher extern void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw, 591dee1ad47SJeff Kirsher bool state); 592dee1ad47SJeff Kirsher extern void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw); 593dee1ad47SJeff Kirsher extern void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw); 594dee1ad47SJeff Kirsher extern void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw); 595dee1ad47SJeff Kirsher extern void e1000_resume_workarounds_pchlan(struct e1000_hw *hw); 596dee1ad47SJeff Kirsher extern s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable); 597dee1ad47SJeff Kirsher extern s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable); 598dee1ad47SJeff Kirsher extern void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw); 599dee1ad47SJeff Kirsher 600dee1ad47SJeff Kirsher extern s32 e1000e_check_for_copper_link(struct e1000_hw *hw); 601dee1ad47SJeff Kirsher extern s32 e1000e_check_for_fiber_link(struct e1000_hw *hw); 602dee1ad47SJeff Kirsher extern s32 e1000e_check_for_serdes_link(struct e1000_hw *hw); 603dee1ad47SJeff Kirsher extern s32 e1000e_setup_led_generic(struct e1000_hw *hw); 604dee1ad47SJeff Kirsher extern s32 e1000e_cleanup_led_generic(struct e1000_hw *hw); 605dee1ad47SJeff Kirsher extern s32 e1000e_led_on_generic(struct e1000_hw *hw); 606dee1ad47SJeff Kirsher extern s32 e1000e_led_off_generic(struct e1000_hw *hw); 607dee1ad47SJeff Kirsher extern s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw); 608dee1ad47SJeff Kirsher extern void e1000_set_lan_id_multi_port_pcie(struct e1000_hw *hw); 609dee1ad47SJeff Kirsher extern void e1000_set_lan_id_single_port(struct e1000_hw *hw); 610dee1ad47SJeff Kirsher extern s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *duplex); 611dee1ad47SJeff Kirsher extern s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, u16 *duplex); 612dee1ad47SJeff Kirsher extern s32 e1000e_disable_pcie_master(struct e1000_hw *hw); 613dee1ad47SJeff Kirsher extern s32 e1000e_get_auto_rd_done(struct e1000_hw *hw); 614d1964eb1SBruce Allan extern s32 e1000e_id_led_init_generic(struct e1000_hw *hw); 615dee1ad47SJeff Kirsher extern void e1000e_clear_hw_cntrs_base(struct e1000_hw *hw); 616dee1ad47SJeff Kirsher extern s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw); 617dee1ad47SJeff Kirsher extern s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw); 618dee1ad47SJeff Kirsher extern s32 e1000e_copper_link_setup_igp(struct e1000_hw *hw); 6191a46b40fSBruce Allan extern s32 e1000e_setup_link_generic(struct e1000_hw *hw); 620dee1ad47SJeff Kirsher extern void e1000_clear_vfta_generic(struct e1000_hw *hw); 621dee1ad47SJeff Kirsher extern void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count); 622dee1ad47SJeff Kirsher extern void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw, 623dee1ad47SJeff Kirsher u8 *mc_addr_list, 624dee1ad47SJeff Kirsher u32 mc_addr_count); 62569e1e019SBruce Allan extern void e1000e_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index); 626dee1ad47SJeff Kirsher extern s32 e1000e_set_fc_watermarks(struct e1000_hw *hw); 627dee1ad47SJeff Kirsher extern void e1000e_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop); 628dee1ad47SJeff Kirsher extern s32 e1000e_get_hw_semaphore(struct e1000_hw *hw); 629dee1ad47SJeff Kirsher extern s32 e1000e_valid_led_default(struct e1000_hw *hw, u16 *data); 63057cde763SBruce Allan extern void e1000e_config_collision_dist_generic(struct e1000_hw *hw); 631dee1ad47SJeff Kirsher extern s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw); 632dee1ad47SJeff Kirsher extern s32 e1000e_force_mac_fc(struct e1000_hw *hw); 633dee1ad47SJeff Kirsher extern s32 e1000e_blink_led_generic(struct e1000_hw *hw); 634dee1ad47SJeff Kirsher extern void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value); 635dee1ad47SJeff Kirsher extern s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw); 636dee1ad47SJeff Kirsher extern void e1000e_reset_adaptive(struct e1000_hw *hw); 637dee1ad47SJeff Kirsher extern void e1000e_update_adaptive(struct e1000_hw *hw); 638dee1ad47SJeff Kirsher 639dee1ad47SJeff Kirsher extern s32 e1000e_setup_copper_link(struct e1000_hw *hw); 640dee1ad47SJeff Kirsher extern s32 e1000e_get_phy_id(struct e1000_hw *hw); 641dee1ad47SJeff Kirsher extern void e1000e_put_hw_semaphore(struct e1000_hw *hw); 642dee1ad47SJeff Kirsher extern s32 e1000e_check_reset_block_generic(struct e1000_hw *hw); 643dee1ad47SJeff Kirsher extern s32 e1000e_phy_force_speed_duplex_igp(struct e1000_hw *hw); 644dee1ad47SJeff Kirsher extern s32 e1000e_get_cable_length_igp_2(struct e1000_hw *hw); 645dee1ad47SJeff Kirsher extern s32 e1000e_get_phy_info_igp(struct e1000_hw *hw); 646dee1ad47SJeff Kirsher extern s32 e1000_set_page_igp(struct e1000_hw *hw, u16 page); 647dee1ad47SJeff Kirsher extern s32 e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data); 648dee1ad47SJeff Kirsher extern s32 e1000e_read_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, 649dee1ad47SJeff Kirsher u16 *data); 650dee1ad47SJeff Kirsher extern s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw); 651dee1ad47SJeff Kirsher extern s32 e1000e_set_d3_lplu_state(struct e1000_hw *hw, bool active); 652dee1ad47SJeff Kirsher extern s32 e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data); 653dee1ad47SJeff Kirsher extern s32 e1000e_write_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, 654dee1ad47SJeff Kirsher u16 data); 655dee1ad47SJeff Kirsher extern s32 e1000e_phy_sw_reset(struct e1000_hw *hw); 656dee1ad47SJeff Kirsher extern s32 e1000e_phy_force_speed_duplex_m88(struct e1000_hw *hw); 657dee1ad47SJeff Kirsher extern s32 e1000e_get_cfg_done(struct e1000_hw *hw); 658dee1ad47SJeff Kirsher extern s32 e1000e_get_cable_length_m88(struct e1000_hw *hw); 659dee1ad47SJeff Kirsher extern s32 e1000e_get_phy_info_m88(struct e1000_hw *hw); 660dee1ad47SJeff Kirsher extern s32 e1000e_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data); 661dee1ad47SJeff Kirsher extern s32 e1000e_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data); 662dee1ad47SJeff Kirsher extern s32 e1000e_phy_init_script_igp3(struct e1000_hw *hw); 663dee1ad47SJeff Kirsher extern enum e1000_phy_type e1000e_get_phy_type_from_id(u32 phy_id); 664dee1ad47SJeff Kirsher extern s32 e1000e_determine_phy_address(struct e1000_hw *hw); 665dee1ad47SJeff Kirsher extern s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data); 666dee1ad47SJeff Kirsher extern s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data); 667dee1ad47SJeff Kirsher extern s32 e1000_enable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, 668dee1ad47SJeff Kirsher u16 *phy_reg); 669dee1ad47SJeff Kirsher extern s32 e1000_disable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, 670dee1ad47SJeff Kirsher u16 *phy_reg); 671dee1ad47SJeff Kirsher extern s32 e1000e_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data); 672dee1ad47SJeff Kirsher extern s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data); 673dee1ad47SJeff Kirsher extern void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl); 674dee1ad47SJeff Kirsher extern s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data); 675dee1ad47SJeff Kirsher extern s32 e1000e_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, 676dee1ad47SJeff Kirsher u16 data); 677dee1ad47SJeff Kirsher extern s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data); 678dee1ad47SJeff Kirsher extern s32 e1000e_read_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, 679dee1ad47SJeff Kirsher u16 *data); 680dee1ad47SJeff Kirsher extern s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, 681dee1ad47SJeff Kirsher u32 usec_interval, bool *success); 682dee1ad47SJeff Kirsher extern s32 e1000e_phy_reset_dsp(struct e1000_hw *hw); 683dee1ad47SJeff Kirsher extern void e1000_power_up_phy_copper(struct e1000_hw *hw); 684dee1ad47SJeff Kirsher extern void e1000_power_down_phy_copper(struct e1000_hw *hw); 685dee1ad47SJeff Kirsher extern s32 e1000e_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data); 686dee1ad47SJeff Kirsher extern s32 e1000e_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data); 687dee1ad47SJeff Kirsher extern s32 e1000e_check_downshift(struct e1000_hw *hw); 688dee1ad47SJeff Kirsher extern s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data); 689dee1ad47SJeff Kirsher extern s32 e1000_read_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, 690dee1ad47SJeff Kirsher u16 *data); 691dee1ad47SJeff Kirsher extern s32 e1000_read_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, 692dee1ad47SJeff Kirsher u16 *data); 693dee1ad47SJeff Kirsher extern s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data); 694dee1ad47SJeff Kirsher extern s32 e1000_write_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, 695dee1ad47SJeff Kirsher u16 data); 696dee1ad47SJeff Kirsher extern s32 e1000_write_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, 697dee1ad47SJeff Kirsher u16 data); 698dee1ad47SJeff Kirsher extern s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw); 699dee1ad47SJeff Kirsher extern s32 e1000_copper_link_setup_82577(struct e1000_hw *hw); 700dee1ad47SJeff Kirsher extern s32 e1000_check_polarity_82577(struct e1000_hw *hw); 701dee1ad47SJeff Kirsher extern s32 e1000_get_phy_info_82577(struct e1000_hw *hw); 702dee1ad47SJeff Kirsher extern s32 e1000_phy_force_speed_duplex_82577(struct e1000_hw *hw); 703dee1ad47SJeff Kirsher extern s32 e1000_get_cable_length_82577(struct e1000_hw *hw); 704dee1ad47SJeff Kirsher 705dee1ad47SJeff Kirsher extern s32 e1000_check_polarity_m88(struct e1000_hw *hw); 706dee1ad47SJeff Kirsher extern s32 e1000_get_phy_info_ife(struct e1000_hw *hw); 707dee1ad47SJeff Kirsher extern s32 e1000_check_polarity_ife(struct e1000_hw *hw); 708dee1ad47SJeff Kirsher extern s32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw); 709dee1ad47SJeff Kirsher extern s32 e1000_check_polarity_igp(struct e1000_hw *hw); 710dee1ad47SJeff Kirsher extern bool e1000_check_phy_82574(struct e1000_hw *hw); 711203e4151SBruce Allan extern s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data); 712d89777bfSBruce Allan extern void e1000e_ptp_init(struct e1000_adapter *adapter); 713d89777bfSBruce Allan extern void e1000e_ptp_remove(struct e1000_adapter *adapter); 714dee1ad47SJeff Kirsher 715dee1ad47SJeff Kirsher static inline s32 e1000_phy_hw_reset(struct e1000_hw *hw) 716dee1ad47SJeff Kirsher { 717dee1ad47SJeff Kirsher return hw->phy.ops.reset(hw); 718dee1ad47SJeff Kirsher } 719dee1ad47SJeff Kirsher 720dee1ad47SJeff Kirsher static inline s32 e1e_rphy(struct e1000_hw *hw, u32 offset, u16 *data) 721dee1ad47SJeff Kirsher { 722dee1ad47SJeff Kirsher return hw->phy.ops.read_reg(hw, offset, data); 723dee1ad47SJeff Kirsher } 724dee1ad47SJeff Kirsher 725f1430d69SBruce Allan static inline s32 e1e_rphy_locked(struct e1000_hw *hw, u32 offset, u16 *data) 726f1430d69SBruce Allan { 727f1430d69SBruce Allan return hw->phy.ops.read_reg_locked(hw, offset, data); 728f1430d69SBruce Allan } 729f1430d69SBruce Allan 730dee1ad47SJeff Kirsher static inline s32 e1e_wphy(struct e1000_hw *hw, u32 offset, u16 data) 731dee1ad47SJeff Kirsher { 732dee1ad47SJeff Kirsher return hw->phy.ops.write_reg(hw, offset, data); 733dee1ad47SJeff Kirsher } 734dee1ad47SJeff Kirsher 735f1430d69SBruce Allan static inline s32 e1e_wphy_locked(struct e1000_hw *hw, u32 offset, u16 data) 736f1430d69SBruce Allan { 737f1430d69SBruce Allan return hw->phy.ops.write_reg_locked(hw, offset, data); 738f1430d69SBruce Allan } 739f1430d69SBruce Allan 740dee1ad47SJeff Kirsher static inline s32 e1000_get_cable_length(struct e1000_hw *hw) 741dee1ad47SJeff Kirsher { 742dee1ad47SJeff Kirsher return hw->phy.ops.get_cable_length(hw); 743dee1ad47SJeff Kirsher } 744dee1ad47SJeff Kirsher 745dee1ad47SJeff Kirsher extern s32 e1000e_acquire_nvm(struct e1000_hw *hw); 746dee1ad47SJeff Kirsher extern s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); 747dee1ad47SJeff Kirsher extern s32 e1000e_update_nvm_checksum_generic(struct e1000_hw *hw); 748dee1ad47SJeff Kirsher extern s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg); 749dee1ad47SJeff Kirsher extern s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); 750dee1ad47SJeff Kirsher extern s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw); 751dee1ad47SJeff Kirsher extern void e1000e_release_nvm(struct e1000_hw *hw); 752e85e3639SBruce Allan extern void e1000e_reload_nvm_generic(struct e1000_hw *hw); 753dee1ad47SJeff Kirsher extern s32 e1000_read_mac_addr_generic(struct e1000_hw *hw); 754dee1ad47SJeff Kirsher 755dee1ad47SJeff Kirsher static inline s32 e1000e_read_mac_addr(struct e1000_hw *hw) 756dee1ad47SJeff Kirsher { 757dee1ad47SJeff Kirsher if (hw->mac.ops.read_mac_addr) 758dee1ad47SJeff Kirsher return hw->mac.ops.read_mac_addr(hw); 759dee1ad47SJeff Kirsher 760dee1ad47SJeff Kirsher return e1000_read_mac_addr_generic(hw); 761dee1ad47SJeff Kirsher } 762dee1ad47SJeff Kirsher 763dee1ad47SJeff Kirsher static inline s32 e1000_validate_nvm_checksum(struct e1000_hw *hw) 764dee1ad47SJeff Kirsher { 765dee1ad47SJeff Kirsher return hw->nvm.ops.validate(hw); 766dee1ad47SJeff Kirsher } 767dee1ad47SJeff Kirsher 768dee1ad47SJeff Kirsher static inline s32 e1000e_update_nvm_checksum(struct e1000_hw *hw) 769dee1ad47SJeff Kirsher { 770dee1ad47SJeff Kirsher return hw->nvm.ops.update(hw); 771dee1ad47SJeff Kirsher } 772dee1ad47SJeff Kirsher 773dee1ad47SJeff Kirsher static inline s32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) 774dee1ad47SJeff Kirsher { 775dee1ad47SJeff Kirsher return hw->nvm.ops.read(hw, offset, words, data); 776dee1ad47SJeff Kirsher } 777dee1ad47SJeff Kirsher 778dee1ad47SJeff Kirsher static inline s32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) 779dee1ad47SJeff Kirsher { 780dee1ad47SJeff Kirsher return hw->nvm.ops.write(hw, offset, words, data); 781dee1ad47SJeff Kirsher } 782dee1ad47SJeff Kirsher 783dee1ad47SJeff Kirsher static inline s32 e1000_get_phy_info(struct e1000_hw *hw) 784dee1ad47SJeff Kirsher { 785dee1ad47SJeff Kirsher return hw->phy.ops.get_info(hw); 786dee1ad47SJeff Kirsher } 787dee1ad47SJeff Kirsher 788dee1ad47SJeff Kirsher extern bool e1000e_check_mng_mode_generic(struct e1000_hw *hw); 789dee1ad47SJeff Kirsher extern bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw); 790dee1ad47SJeff Kirsher extern s32 e1000e_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length); 791dee1ad47SJeff Kirsher 792dee1ad47SJeff Kirsher static inline u32 __er32(struct e1000_hw *hw, unsigned long reg) 793dee1ad47SJeff Kirsher { 794dee1ad47SJeff Kirsher return readl(hw->hw_addr + reg); 795dee1ad47SJeff Kirsher } 796dee1ad47SJeff Kirsher 797bdc125f7SBruce Allan #define er32(reg) __er32(hw, E1000_##reg) 798bdc125f7SBruce Allan 799bdc125f7SBruce Allan /** 800bdc125f7SBruce Allan * __ew32_prepare - prepare to write to MAC CSR register on certain parts 801bdc125f7SBruce Allan * @hw: pointer to the HW structure 802bdc125f7SBruce Allan * 803bdc125f7SBruce Allan * When updating the MAC CSR registers, the Manageability Engine (ME) could 804bdc125f7SBruce Allan * be accessing the registers at the same time. Normally, this is handled in 805bdc125f7SBruce Allan * h/w by an arbiter but on some parts there is a bug that acknowledges Host 806bdc125f7SBruce Allan * accesses later than it should which could result in the register to have 807bdc125f7SBruce Allan * an incorrect value. Workaround this by checking the FWSM register which 808bdc125f7SBruce Allan * has bit 24 set while ME is accessing MAC CSR registers, wait if it is set 809bdc125f7SBruce Allan * and try again a number of times. 810bdc125f7SBruce Allan **/ 811bdc125f7SBruce Allan static inline s32 __ew32_prepare(struct e1000_hw *hw) 812bdc125f7SBruce Allan { 813bdc125f7SBruce Allan s32 i = E1000_ICH_FWSM_PCIM2PCI_COUNT; 814bdc125f7SBruce Allan 815bdc125f7SBruce Allan while ((er32(FWSM) & E1000_ICH_FWSM_PCIM2PCI) && --i) 816bdc125f7SBruce Allan udelay(50); 817bdc125f7SBruce Allan 818bdc125f7SBruce Allan return i; 819bdc125f7SBruce Allan } 820bdc125f7SBruce Allan 821dee1ad47SJeff Kirsher static inline void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val) 822dee1ad47SJeff Kirsher { 823bdc125f7SBruce Allan if (hw->adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA) 824bdc125f7SBruce Allan __ew32_prepare(hw); 825bdc125f7SBruce Allan 826dee1ad47SJeff Kirsher writel(val, hw->hw_addr + reg); 827dee1ad47SJeff Kirsher } 828dee1ad47SJeff Kirsher 829bdc125f7SBruce Allan #define ew32(reg, val) __ew32(hw, E1000_##reg, (val)) 830bdc125f7SBruce Allan 831bdc125f7SBruce Allan #define e1e_flush() er32(STATUS) 832bdc125f7SBruce Allan 833bdc125f7SBruce Allan #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) \ 834bdc125f7SBruce Allan (__ew32((a), (reg + ((offset) << 2)), (value))) 835bdc125f7SBruce Allan 836bdc125f7SBruce Allan #define E1000_READ_REG_ARRAY(a, reg, offset) \ 837bdc125f7SBruce Allan (readl((a)->hw_addr + reg + ((offset) << 2))) 838bdc125f7SBruce Allan 839dee1ad47SJeff Kirsher #endif /* _E1000_H_ */ 840