34 #include <linux/bitops.h>
35 #include <linux/types.h>
39 #include <linux/netdevice.h>
40 #include <linux/pci.h>
43 #include <linux/if_vlan.h>
49 #define e_dbg(format, arg...) \
50 netdev_dbg(hw->adapter->netdev, format, ## arg)
51 #define e_err(format, arg...) \
52 netdev_err(adapter->netdev, format, ## arg)
53 #define e_info(format, arg...) \
54 netdev_info(adapter->netdev, format, ## arg)
55 #define e_warn(format, arg...) \
56 netdev_warn(adapter->netdev, format, ## arg)
57 #define e_notice(format, arg...) \
58 netdev_notice(adapter->netdev, format, ## arg)
62 #define E1000E_INT_MODE_LEGACY 0
63 #define E1000E_INT_MODE_MSI 1
64 #define E1000E_INT_MODE_MSIX 2
67 #define E1000_DEFAULT_TXD 256
68 #define E1000_MAX_TXD 4096
69 #define E1000_MIN_TXD 64
71 #define E1000_DEFAULT_RXD 256
72 #define E1000_MAX_RXD 4096
73 #define E1000_MIN_RXD 64
75 #define E1000_MIN_ITR_USECS 10
76 #define E1000_MAX_ITR_USECS 10000
79 #define E1000_ERT_2048 0x100
81 #define E1000_FC_PAUSE_TIME 0x0680
85 #define E1000_RX_BUFFER_WRITE 16
87 #define AUTO_ALL_MODES 0
88 #define E1000_EEPROM_APME 0x0400
90 #define E1000_MNG_VLAN_NONE (-1)
93 #define PS_PAGE_BUFFERS (MAX_PS_BUFFERS - 1)
95 #define DEFAULT_JUMBO 9234
98 #define BM_PORT_CTRL_PAGE 769
100 #define PHY_UPPER_SHIFT 21
101 #define BM_PHY_REG(page, reg) \
102 (((reg) & MAX_PHY_REG_ADDRESS) |\
103 (((page) & 0xFFFF) << PHY_PAGE_SHIFT) |\
104 (((reg) & ~MAX_PHY_REG_ADDRESS) << (PHY_UPPER_SHIFT - PHY_PAGE_SHIFT)))
107 #define BM_PORT_GEN_CFG PHY_REG(BM_PORT_CTRL_PAGE, 17)
108 #define BM_RCTL PHY_REG(BM_WUC_PAGE, 0)
109 #define BM_WUC PHY_REG(BM_WUC_PAGE, 1)
110 #define BM_WUFC PHY_REG(BM_WUC_PAGE, 2)
111 #define BM_WUS PHY_REG(BM_WUC_PAGE, 3)
112 #define BM_RAR_L(_i) (BM_PHY_REG(BM_WUC_PAGE, 16 + ((_i) << 2)))
113 #define BM_RAR_M(_i) (BM_PHY_REG(BM_WUC_PAGE, 17 + ((_i) << 2)))
114 #define BM_RAR_H(_i) (BM_PHY_REG(BM_WUC_PAGE, 18 + ((_i) << 2)))
115 #define BM_RAR_CTRL(_i) (BM_PHY_REG(BM_WUC_PAGE, 19 + ((_i) << 2)))
116 #define BM_MTA(_i) (BM_PHY_REG(BM_WUC_PAGE, 128 + ((_i) << 1)))
118 #define BM_RCTL_UPE 0x0001
119 #define BM_RCTL_MPE 0x0002
120 #define BM_RCTL_MO_SHIFT 3
121 #define BM_RCTL_MO_MASK (3 << 3)
122 #define BM_RCTL_BAM 0x0020
123 #define BM_RCTL_PMCF 0x0040
124 #define BM_RCTL_RFCE 0x0080
126 #define HV_STATS_PAGE 778
127 #define HV_SCC_UPPER PHY_REG(HV_STATS_PAGE, 16)
128 #define HV_SCC_LOWER PHY_REG(HV_STATS_PAGE, 17)
129 #define HV_ECOL_UPPER PHY_REG(HV_STATS_PAGE, 18)
130 #define HV_ECOL_LOWER PHY_REG(HV_STATS_PAGE, 19)
131 #define HV_MCC_UPPER PHY_REG(HV_STATS_PAGE, 20)
132 #define HV_MCC_LOWER PHY_REG(HV_STATS_PAGE, 21)
133 #define HV_LATECOL_UPPER PHY_REG(HV_STATS_PAGE, 23)
134 #define HV_LATECOL_LOWER PHY_REG(HV_STATS_PAGE, 24)
135 #define HV_COLC_UPPER PHY_REG(HV_STATS_PAGE, 25)
136 #define HV_COLC_LOWER PHY_REG(HV_STATS_PAGE, 26)
137 #define HV_DC_UPPER PHY_REG(HV_STATS_PAGE, 27)
138 #define HV_DC_LOWER PHY_REG(HV_STATS_PAGE, 28)
139 #define HV_TNCRS_UPPER PHY_REG(HV_STATS_PAGE, 29)
140 #define HV_TNCRS_LOWER PHY_REG(HV_STATS_PAGE, 30)
142 #define E1000_FCRTV_PCH 0x05F40
145 #define BM_CS_STATUS 17
146 #define BM_CS_STATUS_LINK_UP 0x0400
147 #define BM_CS_STATUS_RESOLVED 0x0800
148 #define BM_CS_STATUS_SPEED_MASK 0xC000
149 #define BM_CS_STATUS_SPEED_1000 0x8000
152 #define HV_M_STATUS 26
153 #define HV_M_STATUS_AUTONEG_COMPLETE 0x1000
154 #define HV_M_STATUS_SPEED_MASK 0x0300
155 #define HV_M_STATUS_SPEED_1000 0x0200
156 #define HV_M_STATUS_LINK_UP 0x0040
158 #define E1000_ICH_FWSM_PCIM2PCI 0x01000000
159 #define E1000_ICH_FWSM_PCIM2PCI_COUNT 2000
162 #define LINK_TIMEOUT 100
168 #define E1000_CHECK_RESET_COUNT 25
170 #define DEFAULT_RDTR 0
171 #define DEFAULT_RADV 8
172 #define BURST_RDTR 0x20
173 #define BURST_RADV 0x20
181 #define E1000_TXDCTL_DMA_BURST_ENABLE \
182 (E1000_TXDCTL_GRAN | \
183 E1000_TXDCTL_COUNT_DESC | \
188 #define E1000_RXDCTL_DMA_BURST_ENABLE \
194 #define E1000_TIDV_FPD (1 << 31)
195 #define E1000_RDTR_FPD (1 << 31)
427 #define FLAG_HAS_AMT (1 << 0)
428 #define FLAG_HAS_FLASH (1 << 1)
429 #define FLAG_HAS_HW_VLAN_FILTER (1 << 2)
430 #define FLAG_HAS_WOL (1 << 3)
432 #define FLAG_HAS_CTRLEXT_ON_LOAD (1 << 5)
433 #define FLAG_HAS_SWSM_ON_LOAD (1 << 6)
434 #define FLAG_HAS_JUMBO_FRAMES (1 << 7)
435 #define FLAG_READ_ONLY_NVM (1 << 8)
436 #define FLAG_IS_ICH (1 << 9)
437 #define FLAG_HAS_MSIX (1 << 10)
438 #define FLAG_HAS_SMART_POWER_DOWN (1 << 11)
439 #define FLAG_IS_QUAD_PORT_A (1 << 12)
440 #define FLAG_IS_QUAD_PORT (1 << 13)
442 #define FLAG_APME_IN_WUC (1 << 15)
443 #define FLAG_APME_IN_CTRL3 (1 << 16)
444 #define FLAG_APME_CHECK_PORT_B (1 << 17)
445 #define FLAG_DISABLE_FC_PAUSE_TIME (1 << 18)
446 #define FLAG_NO_WAKE_UCAST (1 << 19)
447 #define FLAG_MNG_PT_ENABLED (1 << 20)
448 #define FLAG_RESET_OVERWRITES_LAA (1 << 21)
449 #define FLAG_TARC_SPEED_MODE_BIT (1 << 22)
450 #define FLAG_TARC_SET_BIT_ZERO (1 << 23)
451 #define FLAG_RX_NEEDS_RESTART (1 << 24)
452 #define FLAG_LSC_GIG_SPEED_DROP (1 << 25)
453 #define FLAG_SMART_POWER_DOWN (1 << 26)
454 #define FLAG_MSI_ENABLED (1 << 27)
456 #define FLAG_TSO_FORCE (1 << 29)
457 #define FLAG_RX_RESTART_NOW (1 << 30)
458 #define FLAG_MSI_TEST_FAILED (1 << 31)
460 #define FLAG2_CRC_STRIPPING (1 << 0)
461 #define FLAG2_HAS_PHY_WAKEUP (1 << 1)
462 #define FLAG2_IS_DISCARDING (1 << 2)
463 #define FLAG2_DISABLE_ASPM_L1 (1 << 3)
464 #define FLAG2_HAS_PHY_STATS (1 << 4)
465 #define FLAG2_HAS_EEE (1 << 5)
466 #define FLAG2_DMA_BURST (1 << 6)
467 #define FLAG2_DISABLE_ASPM_L0S (1 << 7)
468 #define FLAG2_DISABLE_AIM (1 << 8)
469 #define FLAG2_CHECK_PHY_HANG (1 << 9)
470 #define FLAG2_NO_DISABLE_RX (1 << 10)
471 #define FLAG2_PCIM2PCI_ARBITER_WA (1 << 11)
472 #define FLAG2_DFLT_CRC_STRIPPING (1 << 12)
474 #define E1000_RX_DESC_PS(R, i) \
475 (&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
476 #define E1000_RX_DESC_EXT(R, i) \
477 (&(((union e1000_rx_desc_extended *)((R).desc))[i]))
478 #define E1000_GET_DESC(R, i, type) (&(((struct type *)((R).desc))[i]))
479 #define E1000_TX_DESC(R, i) E1000_GET_DESC(R, i, e1000_tx_desc)
480 #define E1000_CONTEXT_DESC(R, i) E1000_GET_DESC(R, i, e1000_context_desc)
639 u32 usec_interval,
bool *success);
672 return hw->
phy.ops.reset(hw);
677 return hw->
phy.ops.read_reg(hw, offset, data);
682 return hw->
phy.ops.read_reg_locked(hw, offset, data);
687 return hw->
phy.ops.write_reg(hw, offset, data);
692 return hw->
phy.ops.write_reg_locked(hw, offset, data);
695 static inline s32 e1000_get_cable_length(
struct e1000_hw *hw)
697 return hw->
phy.ops.get_cable_length(hw);
710 static inline s32 e1000e_read_mac_addr(
struct e1000_hw *hw)
712 if (hw->
mac.ops.read_mac_addr)
713 return hw->
mac.ops.read_mac_addr(hw);
718 static inline s32 e1000_validate_nvm_checksum(
struct e1000_hw *hw)
720 return hw->
nvm.ops.validate(hw);
723 static inline s32 e1000e_update_nvm_checksum(
struct e1000_hw *hw)
725 return hw->
nvm.ops.update(hw);
730 return hw->
nvm.ops.read(hw, offset, words, data);
735 return hw->
nvm.ops.write(hw, offset, words, data);
738 static inline s32 e1000_get_phy_info(
struct e1000_hw *hw)
740 return hw->
phy.ops.get_info(hw);
752 #define er32(reg) __er32(hw, E1000_##reg)
766 static inline s32 __ew32_prepare(
struct e1000_hw *hw)
784 #define ew32(reg, val) __ew32(hw, E1000_##reg, (val))
786 #define e1e_flush() er32(STATUS)
788 #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) \
789 (__ew32((a), (reg + ((offset) << 2)), (value)))
791 #define E1000_READ_REG_ARRAY(a, reg, offset) \
792 (readl((a)->hw_addr + reg + ((offset) << 2)))