Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | |
| 3 | Intel PRO/1000 Linux driver |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 4 | Copyright(c) 1999 - 2008 Intel Corporation. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it |
| 7 | under the terms and conditions of the GNU General Public License, |
| 8 | version 2, as published by the Free Software Foundation. |
| 9 | |
| 10 | This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License along with |
| 16 | this program; if not, write to the Free Software Foundation, Inc., |
| 17 | 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | |
| 19 | The full GNU General Public License is included in this distribution in |
| 20 | the file called "COPYING". |
| 21 | |
| 22 | Contact Information: |
| 23 | Linux NICS <linux.nics@intel.com> |
| 24 | e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
| 25 | Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 26 | |
| 27 | *******************************************************************************/ |
| 28 | |
| 29 | /* ethtool support for e1000 */ |
| 30 | |
| 31 | #include <linux/netdevice.h> |
| 32 | #include <linux/ethtool.h> |
| 33 | #include <linux/pci.h> |
| 34 | #include <linux/delay.h> |
| 35 | |
| 36 | #include "e1000.h" |
| 37 | |
| 38 | struct e1000_stats { |
| 39 | char stat_string[ETH_GSTRING_LEN]; |
| 40 | int sizeof_stat; |
| 41 | int stat_offset; |
| 42 | }; |
| 43 | |
| 44 | #define E1000_STAT(m) sizeof(((struct e1000_adapter *)0)->m), \ |
| 45 | offsetof(struct e1000_adapter, m) |
| 46 | static const struct e1000_stats e1000_gstrings_stats[] = { |
| 47 | { "rx_packets", E1000_STAT(stats.gprc) }, |
| 48 | { "tx_packets", E1000_STAT(stats.gptc) }, |
Bruce Allan | 7c25769 | 2008-04-23 11:09:00 -0700 | [diff] [blame] | 49 | { "rx_bytes", E1000_STAT(stats.gorc) }, |
| 50 | { "tx_bytes", E1000_STAT(stats.gotc) }, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 51 | { "rx_broadcast", E1000_STAT(stats.bprc) }, |
| 52 | { "tx_broadcast", E1000_STAT(stats.bptc) }, |
| 53 | { "rx_multicast", E1000_STAT(stats.mprc) }, |
| 54 | { "tx_multicast", E1000_STAT(stats.mptc) }, |
| 55 | { "rx_errors", E1000_STAT(net_stats.rx_errors) }, |
| 56 | { "tx_errors", E1000_STAT(net_stats.tx_errors) }, |
| 57 | { "tx_dropped", E1000_STAT(net_stats.tx_dropped) }, |
| 58 | { "multicast", E1000_STAT(stats.mprc) }, |
| 59 | { "collisions", E1000_STAT(stats.colc) }, |
| 60 | { "rx_length_errors", E1000_STAT(net_stats.rx_length_errors) }, |
| 61 | { "rx_over_errors", E1000_STAT(net_stats.rx_over_errors) }, |
| 62 | { "rx_crc_errors", E1000_STAT(stats.crcerrs) }, |
| 63 | { "rx_frame_errors", E1000_STAT(net_stats.rx_frame_errors) }, |
| 64 | { "rx_no_buffer_count", E1000_STAT(stats.rnbc) }, |
| 65 | { "rx_missed_errors", E1000_STAT(stats.mpc) }, |
| 66 | { "tx_aborted_errors", E1000_STAT(stats.ecol) }, |
| 67 | { "tx_carrier_errors", E1000_STAT(stats.tncrs) }, |
| 68 | { "tx_fifo_errors", E1000_STAT(net_stats.tx_fifo_errors) }, |
| 69 | { "tx_heartbeat_errors", E1000_STAT(net_stats.tx_heartbeat_errors) }, |
| 70 | { "tx_window_errors", E1000_STAT(stats.latecol) }, |
| 71 | { "tx_abort_late_coll", E1000_STAT(stats.latecol) }, |
| 72 | { "tx_deferred_ok", E1000_STAT(stats.dc) }, |
| 73 | { "tx_single_coll_ok", E1000_STAT(stats.scc) }, |
| 74 | { "tx_multi_coll_ok", E1000_STAT(stats.mcc) }, |
| 75 | { "tx_timeout_count", E1000_STAT(tx_timeout_count) }, |
| 76 | { "tx_restart_queue", E1000_STAT(restart_queue) }, |
| 77 | { "rx_long_length_errors", E1000_STAT(stats.roc) }, |
| 78 | { "rx_short_length_errors", E1000_STAT(stats.ruc) }, |
| 79 | { "rx_align_errors", E1000_STAT(stats.algnerrc) }, |
| 80 | { "tx_tcp_seg_good", E1000_STAT(stats.tsctc) }, |
| 81 | { "tx_tcp_seg_failed", E1000_STAT(stats.tsctfc) }, |
| 82 | { "rx_flow_control_xon", E1000_STAT(stats.xonrxc) }, |
| 83 | { "rx_flow_control_xoff", E1000_STAT(stats.xoffrxc) }, |
| 84 | { "tx_flow_control_xon", E1000_STAT(stats.xontxc) }, |
| 85 | { "tx_flow_control_xoff", E1000_STAT(stats.xofftxc) }, |
Bruce Allan | 7c25769 | 2008-04-23 11:09:00 -0700 | [diff] [blame] | 86 | { "rx_long_byte_count", E1000_STAT(stats.gorc) }, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 87 | { "rx_csum_offload_good", E1000_STAT(hw_csum_good) }, |
| 88 | { "rx_csum_offload_errors", E1000_STAT(hw_csum_err) }, |
| 89 | { "rx_header_split", E1000_STAT(rx_hdr_split) }, |
| 90 | { "alloc_rx_buff_failed", E1000_STAT(alloc_rx_buff_failed) }, |
| 91 | { "tx_smbus", E1000_STAT(stats.mgptc) }, |
| 92 | { "rx_smbus", E1000_STAT(stats.mgprc) }, |
| 93 | { "dropped_smbus", E1000_STAT(stats.mgpdc) }, |
| 94 | { "rx_dma_failed", E1000_STAT(rx_dma_failed) }, |
| 95 | { "tx_dma_failed", E1000_STAT(tx_dma_failed) }, |
| 96 | }; |
| 97 | |
Alejandro Martinez Ruiz | c00acf4 | 2007-10-18 10:16:33 +0200 | [diff] [blame] | 98 | #define E1000_GLOBAL_STATS_LEN ARRAY_SIZE(e1000_gstrings_stats) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 99 | #define E1000_STATS_LEN (E1000_GLOBAL_STATS_LEN) |
| 100 | static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = { |
| 101 | "Register test (offline)", "Eeprom test (offline)", |
| 102 | "Interrupt test (offline)", "Loopback test (offline)", |
| 103 | "Link test (on/offline)" |
| 104 | }; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 105 | #define E1000_TEST_LEN ARRAY_SIZE(e1000_gstrings_test) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 106 | |
| 107 | static int e1000_get_settings(struct net_device *netdev, |
| 108 | struct ethtool_cmd *ecmd) |
| 109 | { |
| 110 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 111 | struct e1000_hw *hw = &adapter->hw; |
Auke Kok | 369d742 | 2007-10-15 14:30:59 -0700 | [diff] [blame] | 112 | u32 status; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 113 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 114 | if (hw->phy.media_type == e1000_media_type_copper) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 115 | |
| 116 | ecmd->supported = (SUPPORTED_10baseT_Half | |
| 117 | SUPPORTED_10baseT_Full | |
| 118 | SUPPORTED_100baseT_Half | |
| 119 | SUPPORTED_100baseT_Full | |
| 120 | SUPPORTED_1000baseT_Full | |
| 121 | SUPPORTED_Autoneg | |
| 122 | SUPPORTED_TP); |
| 123 | if (hw->phy.type == e1000_phy_ife) |
| 124 | ecmd->supported &= ~SUPPORTED_1000baseT_Full; |
| 125 | ecmd->advertising = ADVERTISED_TP; |
| 126 | |
| 127 | if (hw->mac.autoneg == 1) { |
| 128 | ecmd->advertising |= ADVERTISED_Autoneg; |
| 129 | /* the e1000 autoneg seems to match ethtool nicely */ |
| 130 | ecmd->advertising |= hw->phy.autoneg_advertised; |
| 131 | } |
| 132 | |
| 133 | ecmd->port = PORT_TP; |
| 134 | ecmd->phy_address = hw->phy.addr; |
| 135 | ecmd->transceiver = XCVR_INTERNAL; |
| 136 | |
| 137 | } else { |
| 138 | ecmd->supported = (SUPPORTED_1000baseT_Full | |
| 139 | SUPPORTED_FIBRE | |
| 140 | SUPPORTED_Autoneg); |
| 141 | |
| 142 | ecmd->advertising = (ADVERTISED_1000baseT_Full | |
| 143 | ADVERTISED_FIBRE | |
| 144 | ADVERTISED_Autoneg); |
| 145 | |
| 146 | ecmd->port = PORT_FIBRE; |
| 147 | ecmd->transceiver = XCVR_EXTERNAL; |
| 148 | } |
| 149 | |
Auke Kok | 369d742 | 2007-10-15 14:30:59 -0700 | [diff] [blame] | 150 | status = er32(STATUS); |
| 151 | if (status & E1000_STATUS_LU) { |
| 152 | if (status & E1000_STATUS_SPEED_1000) |
| 153 | ecmd->speed = 1000; |
| 154 | else if (status & E1000_STATUS_SPEED_100) |
| 155 | ecmd->speed = 100; |
| 156 | else |
| 157 | ecmd->speed = 10; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 158 | |
Auke Kok | 369d742 | 2007-10-15 14:30:59 -0700 | [diff] [blame] | 159 | if (status & E1000_STATUS_FD) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 160 | ecmd->duplex = DUPLEX_FULL; |
| 161 | else |
| 162 | ecmd->duplex = DUPLEX_HALF; |
| 163 | } else { |
| 164 | ecmd->speed = -1; |
| 165 | ecmd->duplex = -1; |
| 166 | } |
| 167 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 168 | ecmd->autoneg = ((hw->phy.media_type == e1000_media_type_fiber) || |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 169 | hw->mac.autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE; |
| 170 | return 0; |
| 171 | } |
| 172 | |
Auke Kok | 369d742 | 2007-10-15 14:30:59 -0700 | [diff] [blame] | 173 | static u32 e1000_get_link(struct net_device *netdev) |
| 174 | { |
| 175 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 176 | struct e1000_hw *hw = &adapter->hw; |
| 177 | u32 status; |
| 178 | |
| 179 | status = er32(STATUS); |
Bruce Allan | 56e1f82 | 2008-08-08 18:35:44 -0700 | [diff] [blame] | 180 | return (status & E1000_STATUS_LU) ? 1 : 0; |
Auke Kok | 369d742 | 2007-10-15 14:30:59 -0700 | [diff] [blame] | 181 | } |
| 182 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 183 | static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx) |
| 184 | { |
| 185 | struct e1000_mac_info *mac = &adapter->hw.mac; |
| 186 | |
| 187 | mac->autoneg = 0; |
| 188 | |
| 189 | /* Fiber NICs only allow 1000 gbps Full duplex */ |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 190 | if ((adapter->hw.phy.media_type == e1000_media_type_fiber) && |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 191 | spddplx != (SPEED_1000 + DUPLEX_FULL)) { |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 192 | e_err("Unsupported Speed/Duplex configuration\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 193 | return -EINVAL; |
| 194 | } |
| 195 | |
| 196 | switch (spddplx) { |
| 197 | case SPEED_10 + DUPLEX_HALF: |
| 198 | mac->forced_speed_duplex = ADVERTISE_10_HALF; |
| 199 | break; |
| 200 | case SPEED_10 + DUPLEX_FULL: |
| 201 | mac->forced_speed_duplex = ADVERTISE_10_FULL; |
| 202 | break; |
| 203 | case SPEED_100 + DUPLEX_HALF: |
| 204 | mac->forced_speed_duplex = ADVERTISE_100_HALF; |
| 205 | break; |
| 206 | case SPEED_100 + DUPLEX_FULL: |
| 207 | mac->forced_speed_duplex = ADVERTISE_100_FULL; |
| 208 | break; |
| 209 | case SPEED_1000 + DUPLEX_FULL: |
| 210 | mac->autoneg = 1; |
| 211 | adapter->hw.phy.autoneg_advertised = ADVERTISE_1000_FULL; |
| 212 | break; |
| 213 | case SPEED_1000 + DUPLEX_HALF: /* not supported */ |
| 214 | default: |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 215 | e_err("Unsupported Speed/Duplex configuration\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 216 | return -EINVAL; |
| 217 | } |
| 218 | return 0; |
| 219 | } |
| 220 | |
| 221 | static int e1000_set_settings(struct net_device *netdev, |
| 222 | struct ethtool_cmd *ecmd) |
| 223 | { |
| 224 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 225 | struct e1000_hw *hw = &adapter->hw; |
| 226 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 227 | /* |
| 228 | * When SoL/IDER sessions are active, autoneg/speed/duplex |
| 229 | * cannot be changed |
| 230 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 231 | if (e1000_check_reset_block(hw)) { |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 232 | e_err("Cannot change link characteristics when SoL/IDER is " |
| 233 | "active.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 234 | return -EINVAL; |
| 235 | } |
| 236 | |
| 237 | while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) |
| 238 | msleep(1); |
| 239 | |
| 240 | if (ecmd->autoneg == AUTONEG_ENABLE) { |
| 241 | hw->mac.autoneg = 1; |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 242 | if (hw->phy.media_type == e1000_media_type_fiber) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 243 | hw->phy.autoneg_advertised = ADVERTISED_1000baseT_Full | |
| 244 | ADVERTISED_FIBRE | |
| 245 | ADVERTISED_Autoneg; |
| 246 | else |
| 247 | hw->phy.autoneg_advertised = ecmd->advertising | |
| 248 | ADVERTISED_TP | |
| 249 | ADVERTISED_Autoneg; |
| 250 | ecmd->advertising = hw->phy.autoneg_advertised; |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 251 | if (adapter->fc_autoneg) |
| 252 | hw->fc.original_type = e1000_fc_default; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 253 | } else { |
| 254 | if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) { |
| 255 | clear_bit(__E1000_RESETTING, &adapter->state); |
| 256 | return -EINVAL; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | /* reset the link */ |
| 261 | |
| 262 | if (netif_running(adapter->netdev)) { |
| 263 | e1000e_down(adapter); |
| 264 | e1000e_up(adapter); |
| 265 | } else { |
| 266 | e1000e_reset(adapter); |
| 267 | } |
| 268 | |
| 269 | clear_bit(__E1000_RESETTING, &adapter->state); |
| 270 | return 0; |
| 271 | } |
| 272 | |
| 273 | static void e1000_get_pauseparam(struct net_device *netdev, |
| 274 | struct ethtool_pauseparam *pause) |
| 275 | { |
| 276 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 277 | struct e1000_hw *hw = &adapter->hw; |
| 278 | |
| 279 | pause->autoneg = |
| 280 | (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE); |
| 281 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 282 | if (hw->fc.type == e1000_fc_rx_pause) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 283 | pause->rx_pause = 1; |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 284 | } else if (hw->fc.type == e1000_fc_tx_pause) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 285 | pause->tx_pause = 1; |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 286 | } else if (hw->fc.type == e1000_fc_full) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 287 | pause->rx_pause = 1; |
| 288 | pause->tx_pause = 1; |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | static int e1000_set_pauseparam(struct net_device *netdev, |
| 293 | struct ethtool_pauseparam *pause) |
| 294 | { |
| 295 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 296 | struct e1000_hw *hw = &adapter->hw; |
| 297 | int retval = 0; |
| 298 | |
| 299 | adapter->fc_autoneg = pause->autoneg; |
| 300 | |
| 301 | while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) |
| 302 | msleep(1); |
| 303 | |
| 304 | if (pause->rx_pause && pause->tx_pause) |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 305 | hw->fc.type = e1000_fc_full; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 306 | else if (pause->rx_pause && !pause->tx_pause) |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 307 | hw->fc.type = e1000_fc_rx_pause; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 308 | else if (!pause->rx_pause && pause->tx_pause) |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 309 | hw->fc.type = e1000_fc_tx_pause; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 310 | else if (!pause->rx_pause && !pause->tx_pause) |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 311 | hw->fc.type = e1000_fc_none; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 312 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 313 | hw->fc.original_type = hw->fc.type; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 314 | |
| 315 | if (adapter->fc_autoneg == AUTONEG_ENABLE) { |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 316 | hw->fc.type = e1000_fc_default; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 317 | if (netif_running(adapter->netdev)) { |
| 318 | e1000e_down(adapter); |
| 319 | e1000e_up(adapter); |
| 320 | } else { |
| 321 | e1000e_reset(adapter); |
| 322 | } |
| 323 | } else { |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 324 | retval = ((hw->phy.media_type == e1000_media_type_fiber) ? |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 325 | hw->mac.ops.setup_link(hw) : e1000e_force_mac_fc(hw)); |
| 326 | } |
| 327 | |
| 328 | clear_bit(__E1000_RESETTING, &adapter->state); |
| 329 | return retval; |
| 330 | } |
| 331 | |
| 332 | static u32 e1000_get_rx_csum(struct net_device *netdev) |
| 333 | { |
| 334 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 335 | return (adapter->flags & FLAG_RX_CSUM_ENABLED); |
| 336 | } |
| 337 | |
| 338 | static int e1000_set_rx_csum(struct net_device *netdev, u32 data) |
| 339 | { |
| 340 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 341 | |
| 342 | if (data) |
| 343 | adapter->flags |= FLAG_RX_CSUM_ENABLED; |
| 344 | else |
| 345 | adapter->flags &= ~FLAG_RX_CSUM_ENABLED; |
| 346 | |
| 347 | if (netif_running(netdev)) |
| 348 | e1000e_reinit_locked(adapter); |
| 349 | else |
| 350 | e1000e_reset(adapter); |
| 351 | return 0; |
| 352 | } |
| 353 | |
| 354 | static u32 e1000_get_tx_csum(struct net_device *netdev) |
| 355 | { |
| 356 | return ((netdev->features & NETIF_F_HW_CSUM) != 0); |
| 357 | } |
| 358 | |
| 359 | static int e1000_set_tx_csum(struct net_device *netdev, u32 data) |
| 360 | { |
| 361 | if (data) |
| 362 | netdev->features |= NETIF_F_HW_CSUM; |
| 363 | else |
| 364 | netdev->features &= ~NETIF_F_HW_CSUM; |
| 365 | |
| 366 | return 0; |
| 367 | } |
| 368 | |
| 369 | static int e1000_set_tso(struct net_device *netdev, u32 data) |
| 370 | { |
| 371 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 372 | |
| 373 | if (data) { |
| 374 | netdev->features |= NETIF_F_TSO; |
| 375 | netdev->features |= NETIF_F_TSO6; |
| 376 | } else { |
| 377 | netdev->features &= ~NETIF_F_TSO; |
| 378 | netdev->features &= ~NETIF_F_TSO6; |
| 379 | } |
| 380 | |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 381 | e_info("TSO is %s\n", data ? "Enabled" : "Disabled"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 382 | adapter->flags |= FLAG_TSO_FORCE; |
| 383 | return 0; |
| 384 | } |
| 385 | |
| 386 | static u32 e1000_get_msglevel(struct net_device *netdev) |
| 387 | { |
| 388 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 389 | return adapter->msg_enable; |
| 390 | } |
| 391 | |
| 392 | static void e1000_set_msglevel(struct net_device *netdev, u32 data) |
| 393 | { |
| 394 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 395 | adapter->msg_enable = data; |
| 396 | } |
| 397 | |
| 398 | static int e1000_get_regs_len(struct net_device *netdev) |
| 399 | { |
| 400 | #define E1000_REGS_LEN 32 /* overestimate */ |
| 401 | return E1000_REGS_LEN * sizeof(u32); |
| 402 | } |
| 403 | |
| 404 | static void e1000_get_regs(struct net_device *netdev, |
| 405 | struct ethtool_regs *regs, void *p) |
| 406 | { |
| 407 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 408 | struct e1000_hw *hw = &adapter->hw; |
| 409 | u32 *regs_buff = p; |
| 410 | u16 phy_data; |
| 411 | u8 revision_id; |
| 412 | |
| 413 | memset(p, 0, E1000_REGS_LEN * sizeof(u32)); |
| 414 | |
| 415 | pci_read_config_byte(adapter->pdev, PCI_REVISION_ID, &revision_id); |
| 416 | |
| 417 | regs->version = (1 << 24) | (revision_id << 16) | adapter->pdev->device; |
| 418 | |
| 419 | regs_buff[0] = er32(CTRL); |
| 420 | regs_buff[1] = er32(STATUS); |
| 421 | |
| 422 | regs_buff[2] = er32(RCTL); |
| 423 | regs_buff[3] = er32(RDLEN); |
| 424 | regs_buff[4] = er32(RDH); |
| 425 | regs_buff[5] = er32(RDT); |
| 426 | regs_buff[6] = er32(RDTR); |
| 427 | |
| 428 | regs_buff[7] = er32(TCTL); |
| 429 | regs_buff[8] = er32(TDLEN); |
| 430 | regs_buff[9] = er32(TDH); |
| 431 | regs_buff[10] = er32(TDT); |
| 432 | regs_buff[11] = er32(TIDV); |
| 433 | |
| 434 | regs_buff[12] = adapter->hw.phy.type; /* PHY type (IGP=1, M88=0) */ |
Jesse Brandeburg | 23033fa | 2008-10-02 16:33:30 -0700 | [diff] [blame^] | 435 | |
| 436 | /* ethtool doesn't use anything past this point, so all this |
| 437 | * code is likely legacy junk for apps that may or may not |
| 438 | * exist */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 439 | if (hw->phy.type == e1000_phy_m88) { |
| 440 | e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data); |
| 441 | regs_buff[13] = (u32)phy_data; /* cable length */ |
| 442 | regs_buff[14] = 0; /* Dummy (to align w/ IGP phy reg dump) */ |
| 443 | regs_buff[15] = 0; /* Dummy (to align w/ IGP phy reg dump) */ |
| 444 | regs_buff[16] = 0; /* Dummy (to align w/ IGP phy reg dump) */ |
| 445 | e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); |
| 446 | regs_buff[17] = (u32)phy_data; /* extended 10bt distance */ |
| 447 | regs_buff[18] = regs_buff[13]; /* cable polarity */ |
| 448 | regs_buff[19] = 0; /* Dummy (to align w/ IGP phy reg dump) */ |
| 449 | regs_buff[20] = regs_buff[17]; /* polarity correction */ |
| 450 | /* phy receive errors */ |
| 451 | regs_buff[22] = adapter->phy_stats.receive_errors; |
| 452 | regs_buff[23] = regs_buff[13]; /* mdix mode */ |
| 453 | } |
Jesse Brandeburg | 23033fa | 2008-10-02 16:33:30 -0700 | [diff] [blame^] | 454 | regs_buff[21] = 0; /* was idle_errors */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 455 | e1e_rphy(hw, PHY_1000T_STATUS, &phy_data); |
| 456 | regs_buff[24] = (u32)phy_data; /* phy local receiver status */ |
| 457 | regs_buff[25] = regs_buff[24]; /* phy remote receiver status */ |
| 458 | } |
| 459 | |
| 460 | static int e1000_get_eeprom_len(struct net_device *netdev) |
| 461 | { |
| 462 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 463 | return adapter->hw.nvm.word_size * 2; |
| 464 | } |
| 465 | |
| 466 | static int e1000_get_eeprom(struct net_device *netdev, |
| 467 | struct ethtool_eeprom *eeprom, u8 *bytes) |
| 468 | { |
| 469 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 470 | struct e1000_hw *hw = &adapter->hw; |
| 471 | u16 *eeprom_buff; |
| 472 | int first_word; |
| 473 | int last_word; |
| 474 | int ret_val = 0; |
| 475 | u16 i; |
| 476 | |
| 477 | if (eeprom->len == 0) |
| 478 | return -EINVAL; |
| 479 | |
| 480 | eeprom->magic = adapter->pdev->vendor | (adapter->pdev->device << 16); |
| 481 | |
| 482 | first_word = eeprom->offset >> 1; |
| 483 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 484 | |
| 485 | eeprom_buff = kmalloc(sizeof(u16) * |
| 486 | (last_word - first_word + 1), GFP_KERNEL); |
| 487 | if (!eeprom_buff) |
| 488 | return -ENOMEM; |
| 489 | |
| 490 | if (hw->nvm.type == e1000_nvm_eeprom_spi) { |
| 491 | ret_val = e1000_read_nvm(hw, first_word, |
| 492 | last_word - first_word + 1, |
| 493 | eeprom_buff); |
| 494 | } else { |
| 495 | for (i = 0; i < last_word - first_word + 1; i++) { |
| 496 | ret_val = e1000_read_nvm(hw, first_word + i, 1, |
| 497 | &eeprom_buff[i]); |
Kok, Auke | f227ec3 | 2008-04-29 11:18:55 -0700 | [diff] [blame] | 498 | if (ret_val) { |
| 499 | /* a read error occurred, throw away the |
| 500 | * result */ |
| 501 | memset(eeprom_buff, 0xff, sizeof(eeprom_buff)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 502 | break; |
Kok, Auke | f227ec3 | 2008-04-29 11:18:55 -0700 | [diff] [blame] | 503 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 504 | } |
| 505 | } |
| 506 | |
| 507 | /* Device's eeprom is always little-endian, word addressable */ |
| 508 | for (i = 0; i < last_word - first_word + 1; i++) |
| 509 | le16_to_cpus(&eeprom_buff[i]); |
| 510 | |
| 511 | memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len); |
| 512 | kfree(eeprom_buff); |
| 513 | |
| 514 | return ret_val; |
| 515 | } |
| 516 | |
| 517 | static int e1000_set_eeprom(struct net_device *netdev, |
| 518 | struct ethtool_eeprom *eeprom, u8 *bytes) |
| 519 | { |
| 520 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 521 | struct e1000_hw *hw = &adapter->hw; |
| 522 | u16 *eeprom_buff; |
| 523 | void *ptr; |
| 524 | int max_len; |
| 525 | int first_word; |
| 526 | int last_word; |
| 527 | int ret_val = 0; |
| 528 | u16 i; |
| 529 | |
| 530 | if (eeprom->len == 0) |
| 531 | return -EOPNOTSUPP; |
| 532 | |
| 533 | if (eeprom->magic != (adapter->pdev->vendor | (adapter->pdev->device << 16))) |
| 534 | return -EFAULT; |
| 535 | |
Bruce Allan | 4a77035 | 2008-10-01 17:18:35 -0700 | [diff] [blame] | 536 | if (adapter->flags & FLAG_READ_ONLY_NVM) |
| 537 | return -EINVAL; |
| 538 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 539 | max_len = hw->nvm.word_size * 2; |
| 540 | |
| 541 | first_word = eeprom->offset >> 1; |
| 542 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 543 | eeprom_buff = kmalloc(max_len, GFP_KERNEL); |
| 544 | if (!eeprom_buff) |
| 545 | return -ENOMEM; |
| 546 | |
| 547 | ptr = (void *)eeprom_buff; |
| 548 | |
| 549 | if (eeprom->offset & 1) { |
| 550 | /* need read/modify/write of first changed EEPROM word */ |
| 551 | /* only the second byte of the word is being modified */ |
| 552 | ret_val = e1000_read_nvm(hw, first_word, 1, &eeprom_buff[0]); |
| 553 | ptr++; |
| 554 | } |
| 555 | if (((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) |
| 556 | /* need read/modify/write of last changed EEPROM word */ |
| 557 | /* only the first byte of the word is being modified */ |
| 558 | ret_val = e1000_read_nvm(hw, last_word, 1, |
| 559 | &eeprom_buff[last_word - first_word]); |
| 560 | |
| 561 | /* Device's eeprom is always little-endian, word addressable */ |
| 562 | for (i = 0; i < last_word - first_word + 1; i++) |
| 563 | le16_to_cpus(&eeprom_buff[i]); |
| 564 | |
| 565 | memcpy(ptr, bytes, eeprom->len); |
| 566 | |
| 567 | for (i = 0; i < last_word - first_word + 1; i++) |
| 568 | eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]); |
| 569 | |
| 570 | ret_val = e1000_write_nvm(hw, first_word, |
| 571 | last_word - first_word + 1, eeprom_buff); |
| 572 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 573 | /* |
| 574 | * Update the checksum over the first part of the EEPROM if needed |
| 575 | * and flush shadow RAM for 82573 controllers |
| 576 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 577 | if ((ret_val == 0) && ((first_word <= NVM_CHECKSUM_REG) || |
| 578 | (hw->mac.type == e1000_82573))) |
| 579 | e1000e_update_nvm_checksum(hw); |
| 580 | |
| 581 | kfree(eeprom_buff); |
| 582 | return ret_val; |
| 583 | } |
| 584 | |
| 585 | static void e1000_get_drvinfo(struct net_device *netdev, |
| 586 | struct ethtool_drvinfo *drvinfo) |
| 587 | { |
| 588 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 589 | char firmware_version[32]; |
| 590 | u16 eeprom_data; |
| 591 | |
| 592 | strncpy(drvinfo->driver, e1000e_driver_name, 32); |
| 593 | strncpy(drvinfo->version, e1000e_driver_version, 32); |
| 594 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 595 | /* |
| 596 | * EEPROM image version # is reported as firmware version # for |
| 597 | * PCI-E controllers |
| 598 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 599 | e1000_read_nvm(&adapter->hw, 5, 1, &eeprom_data); |
| 600 | sprintf(firmware_version, "%d.%d-%d", |
| 601 | (eeprom_data & 0xF000) >> 12, |
| 602 | (eeprom_data & 0x0FF0) >> 4, |
| 603 | eeprom_data & 0x000F); |
| 604 | |
| 605 | strncpy(drvinfo->fw_version, firmware_version, 32); |
| 606 | strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 607 | drvinfo->regdump_len = e1000_get_regs_len(netdev); |
| 608 | drvinfo->eedump_len = e1000_get_eeprom_len(netdev); |
| 609 | } |
| 610 | |
| 611 | static void e1000_get_ringparam(struct net_device *netdev, |
| 612 | struct ethtool_ringparam *ring) |
| 613 | { |
| 614 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 615 | struct e1000_ring *tx_ring = adapter->tx_ring; |
| 616 | struct e1000_ring *rx_ring = adapter->rx_ring; |
| 617 | |
| 618 | ring->rx_max_pending = E1000_MAX_RXD; |
| 619 | ring->tx_max_pending = E1000_MAX_TXD; |
| 620 | ring->rx_mini_max_pending = 0; |
| 621 | ring->rx_jumbo_max_pending = 0; |
| 622 | ring->rx_pending = rx_ring->count; |
| 623 | ring->tx_pending = tx_ring->count; |
| 624 | ring->rx_mini_pending = 0; |
| 625 | ring->rx_jumbo_pending = 0; |
| 626 | } |
| 627 | |
| 628 | static int e1000_set_ringparam(struct net_device *netdev, |
| 629 | struct ethtool_ringparam *ring) |
| 630 | { |
| 631 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 632 | struct e1000_ring *tx_ring, *tx_old; |
| 633 | struct e1000_ring *rx_ring, *rx_old; |
| 634 | int err; |
| 635 | |
| 636 | if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) |
| 637 | return -EINVAL; |
| 638 | |
| 639 | while (test_and_set_bit(__E1000_RESETTING, &adapter->state)) |
| 640 | msleep(1); |
| 641 | |
| 642 | if (netif_running(adapter->netdev)) |
| 643 | e1000e_down(adapter); |
| 644 | |
| 645 | tx_old = adapter->tx_ring; |
| 646 | rx_old = adapter->rx_ring; |
| 647 | |
| 648 | err = -ENOMEM; |
| 649 | tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL); |
| 650 | if (!tx_ring) |
| 651 | goto err_alloc_tx; |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 652 | /* |
| 653 | * use a memcpy to save any previously configured |
| 654 | * items like napi structs from having to be |
| 655 | * reinitialized |
| 656 | */ |
| 657 | memcpy(tx_ring, tx_old, sizeof(struct e1000_ring)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 658 | |
| 659 | rx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL); |
| 660 | if (!rx_ring) |
| 661 | goto err_alloc_rx; |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 662 | memcpy(rx_ring, rx_old, sizeof(struct e1000_ring)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 663 | |
| 664 | adapter->tx_ring = tx_ring; |
| 665 | adapter->rx_ring = rx_ring; |
| 666 | |
| 667 | rx_ring->count = max(ring->rx_pending, (u32)E1000_MIN_RXD); |
| 668 | rx_ring->count = min(rx_ring->count, (u32)(E1000_MAX_RXD)); |
| 669 | rx_ring->count = ALIGN(rx_ring->count, REQ_RX_DESCRIPTOR_MULTIPLE); |
| 670 | |
| 671 | tx_ring->count = max(ring->tx_pending, (u32)E1000_MIN_TXD); |
| 672 | tx_ring->count = min(tx_ring->count, (u32)(E1000_MAX_TXD)); |
| 673 | tx_ring->count = ALIGN(tx_ring->count, REQ_TX_DESCRIPTOR_MULTIPLE); |
| 674 | |
| 675 | if (netif_running(adapter->netdev)) { |
| 676 | /* Try to get new resources before deleting old */ |
| 677 | err = e1000e_setup_rx_resources(adapter); |
| 678 | if (err) |
| 679 | goto err_setup_rx; |
| 680 | err = e1000e_setup_tx_resources(adapter); |
| 681 | if (err) |
| 682 | goto err_setup_tx; |
| 683 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 684 | /* |
| 685 | * restore the old in order to free it, |
| 686 | * then add in the new |
| 687 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 688 | adapter->rx_ring = rx_old; |
| 689 | adapter->tx_ring = tx_old; |
| 690 | e1000e_free_rx_resources(adapter); |
| 691 | e1000e_free_tx_resources(adapter); |
| 692 | kfree(tx_old); |
| 693 | kfree(rx_old); |
| 694 | adapter->rx_ring = rx_ring; |
| 695 | adapter->tx_ring = tx_ring; |
| 696 | err = e1000e_up(adapter); |
| 697 | if (err) |
| 698 | goto err_setup; |
| 699 | } |
| 700 | |
| 701 | clear_bit(__E1000_RESETTING, &adapter->state); |
| 702 | return 0; |
| 703 | err_setup_tx: |
| 704 | e1000e_free_rx_resources(adapter); |
| 705 | err_setup_rx: |
| 706 | adapter->rx_ring = rx_old; |
| 707 | adapter->tx_ring = tx_old; |
| 708 | kfree(rx_ring); |
| 709 | err_alloc_rx: |
| 710 | kfree(tx_ring); |
| 711 | err_alloc_tx: |
| 712 | e1000e_up(adapter); |
| 713 | err_setup: |
| 714 | clear_bit(__E1000_RESETTING, &adapter->state); |
| 715 | return err; |
| 716 | } |
| 717 | |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 718 | static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data, |
| 719 | int reg, int offset, u32 mask, u32 write) |
Joe Perches | 2a88719 | 2007-11-13 20:53:51 -0800 | [diff] [blame] | 720 | { |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 721 | u32 pat, val; |
Joe Perches | 2a88719 | 2007-11-13 20:53:51 -0800 | [diff] [blame] | 722 | static const u32 test[] = |
| 723 | {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 724 | for (pat = 0; pat < ARRAY_SIZE(test); pat++) { |
Joe Perches | 2a88719 | 2007-11-13 20:53:51 -0800 | [diff] [blame] | 725 | E1000_WRITE_REG_ARRAY(&adapter->hw, reg, offset, |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 726 | (test[pat] & write)); |
| 727 | val = E1000_READ_REG_ARRAY(&adapter->hw, reg, offset); |
| 728 | if (val != (test[pat] & write & mask)) { |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 729 | e_err("pattern test reg %04X failed: got 0x%08X " |
| 730 | "expected 0x%08X\n", reg + offset, val, |
| 731 | (test[pat] & write & mask)); |
Joe Perches | 2a88719 | 2007-11-13 20:53:51 -0800 | [diff] [blame] | 732 | *data = reg; |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 733 | return 1; |
Joe Perches | 2a88719 | 2007-11-13 20:53:51 -0800 | [diff] [blame] | 734 | } |
| 735 | } |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 736 | return 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 737 | } |
| 738 | |
Joe Perches | 2a88719 | 2007-11-13 20:53:51 -0800 | [diff] [blame] | 739 | static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data, |
| 740 | int reg, u32 mask, u32 write) |
| 741 | { |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 742 | u32 val; |
Joe Perches | 2a88719 | 2007-11-13 20:53:51 -0800 | [diff] [blame] | 743 | __ew32(&adapter->hw, reg, write & mask); |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 744 | val = __er32(&adapter->hw, reg); |
| 745 | if ((write & mask) != (val & mask)) { |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 746 | e_err("set/check reg %04X test failed: got 0x%08X " |
| 747 | "expected 0x%08X\n", reg, (val & mask), (write & mask)); |
Joe Perches | 2a88719 | 2007-11-13 20:53:51 -0800 | [diff] [blame] | 748 | *data = reg; |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 749 | return 1; |
Joe Perches | 2a88719 | 2007-11-13 20:53:51 -0800 | [diff] [blame] | 750 | } |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 751 | return 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 752 | } |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 753 | #define REG_PATTERN_TEST_ARRAY(reg, offset, mask, write) \ |
| 754 | do { \ |
| 755 | if (reg_pattern_test(adapter, data, reg, offset, mask, write)) \ |
| 756 | return 1; \ |
Joe Perches | 2a88719 | 2007-11-13 20:53:51 -0800 | [diff] [blame] | 757 | } while (0) |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 758 | #define REG_PATTERN_TEST(reg, mask, write) \ |
| 759 | REG_PATTERN_TEST_ARRAY(reg, 0, mask, write) |
Joe Perches | 2a88719 | 2007-11-13 20:53:51 -0800 | [diff] [blame] | 760 | |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 761 | #define REG_SET_AND_CHECK(reg, mask, write) \ |
| 762 | do { \ |
| 763 | if (reg_set_and_check(adapter, data, reg, mask, write)) \ |
| 764 | return 1; \ |
Joe Perches | 2a88719 | 2007-11-13 20:53:51 -0800 | [diff] [blame] | 765 | } while (0) |
| 766 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 767 | static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data) |
| 768 | { |
| 769 | struct e1000_hw *hw = &adapter->hw; |
| 770 | struct e1000_mac_info *mac = &adapter->hw.mac; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 771 | u32 value; |
| 772 | u32 before; |
| 773 | u32 after; |
| 774 | u32 i; |
| 775 | u32 toggle; |
| 776 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 777 | /* |
| 778 | * The status register is Read Only, so a write should fail. |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 779 | * Some bits that get toggled are ignored. |
| 780 | */ |
| 781 | switch (mac->type) { |
| 782 | /* there are several bits on newer hardware that are r/w */ |
| 783 | case e1000_82571: |
| 784 | case e1000_82572: |
| 785 | case e1000_80003es2lan: |
| 786 | toggle = 0x7FFFF3FF; |
| 787 | break; |
| 788 | case e1000_82573: |
| 789 | case e1000_ich8lan: |
| 790 | case e1000_ich9lan: |
| 791 | toggle = 0x7FFFF033; |
| 792 | break; |
| 793 | default: |
| 794 | toggle = 0xFFFFF833; |
| 795 | break; |
| 796 | } |
| 797 | |
| 798 | before = er32(STATUS); |
| 799 | value = (er32(STATUS) & toggle); |
| 800 | ew32(STATUS, toggle); |
| 801 | after = er32(STATUS) & toggle; |
| 802 | if (value != after) { |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 803 | e_err("failed STATUS register test got: 0x%08X expected: " |
| 804 | "0x%08X\n", after, value); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 805 | *data = 1; |
| 806 | return 1; |
| 807 | } |
| 808 | /* restore previous status */ |
| 809 | ew32(STATUS, before); |
| 810 | |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 811 | if (!(adapter->flags & FLAG_IS_ICH)) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 812 | REG_PATTERN_TEST(E1000_FCAL, 0xFFFFFFFF, 0xFFFFFFFF); |
| 813 | REG_PATTERN_TEST(E1000_FCAH, 0x0000FFFF, 0xFFFFFFFF); |
| 814 | REG_PATTERN_TEST(E1000_FCT, 0x0000FFFF, 0xFFFFFFFF); |
| 815 | REG_PATTERN_TEST(E1000_VET, 0x0000FFFF, 0xFFFFFFFF); |
| 816 | } |
| 817 | |
| 818 | REG_PATTERN_TEST(E1000_RDTR, 0x0000FFFF, 0xFFFFFFFF); |
| 819 | REG_PATTERN_TEST(E1000_RDBAH, 0xFFFFFFFF, 0xFFFFFFFF); |
| 820 | REG_PATTERN_TEST(E1000_RDLEN, 0x000FFF80, 0x000FFFFF); |
| 821 | REG_PATTERN_TEST(E1000_RDH, 0x0000FFFF, 0x0000FFFF); |
| 822 | REG_PATTERN_TEST(E1000_RDT, 0x0000FFFF, 0x0000FFFF); |
| 823 | REG_PATTERN_TEST(E1000_FCRTH, 0x0000FFF8, 0x0000FFF8); |
| 824 | REG_PATTERN_TEST(E1000_FCTTV, 0x0000FFFF, 0x0000FFFF); |
| 825 | REG_PATTERN_TEST(E1000_TIPG, 0x3FFFFFFF, 0x3FFFFFFF); |
| 826 | REG_PATTERN_TEST(E1000_TDBAH, 0xFFFFFFFF, 0xFFFFFFFF); |
| 827 | REG_PATTERN_TEST(E1000_TDLEN, 0x000FFF80, 0x000FFFFF); |
| 828 | |
| 829 | REG_SET_AND_CHECK(E1000_RCTL, 0xFFFFFFFF, 0x00000000); |
| 830 | |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 831 | before = ((adapter->flags & FLAG_IS_ICH) ? 0x06C3B33E : 0x06DFB3FE); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 832 | REG_SET_AND_CHECK(E1000_RCTL, before, 0x003FFFFB); |
| 833 | REG_SET_AND_CHECK(E1000_TCTL, 0xFFFFFFFF, 0x00000000); |
| 834 | |
Auke Kok | 8658251 | 2007-10-04 15:00:08 -0700 | [diff] [blame] | 835 | REG_SET_AND_CHECK(E1000_RCTL, before, 0xFFFFFFFF); |
| 836 | REG_PATTERN_TEST(E1000_RDBAL, 0xFFFFFFF0, 0xFFFFFFFF); |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 837 | if (!(adapter->flags & FLAG_IS_ICH)) |
Auke Kok | 8658251 | 2007-10-04 15:00:08 -0700 | [diff] [blame] | 838 | REG_PATTERN_TEST(E1000_TXCW, 0xC000FFFF, 0x0000FFFF); |
| 839 | REG_PATTERN_TEST(E1000_TDBAL, 0xFFFFFFF0, 0xFFFFFFFF); |
| 840 | REG_PATTERN_TEST(E1000_TIDV, 0x0000FFFF, 0x0000FFFF); |
| 841 | for (i = 0; i < mac->rar_entry_count; i++) |
| 842 | REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1), |
| 843 | 0x8003FFFF, 0xFFFFFFFF); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 844 | |
| 845 | for (i = 0; i < mac->mta_reg_count; i++) |
| 846 | REG_PATTERN_TEST_ARRAY(E1000_MTA, i, 0xFFFFFFFF, 0xFFFFFFFF); |
| 847 | |
| 848 | *data = 0; |
| 849 | return 0; |
| 850 | } |
| 851 | |
| 852 | static int e1000_eeprom_test(struct e1000_adapter *adapter, u64 *data) |
| 853 | { |
| 854 | u16 temp; |
| 855 | u16 checksum = 0; |
| 856 | u16 i; |
| 857 | |
| 858 | *data = 0; |
| 859 | /* Read and add up the contents of the EEPROM */ |
| 860 | for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) { |
| 861 | if ((e1000_read_nvm(&adapter->hw, i, 1, &temp)) < 0) { |
| 862 | *data = 1; |
| 863 | break; |
| 864 | } |
| 865 | checksum += temp; |
| 866 | } |
| 867 | |
| 868 | /* If Checksum is not Correct return error else test passed */ |
| 869 | if ((checksum != (u16) NVM_SUM) && !(*data)) |
| 870 | *data = 2; |
| 871 | |
| 872 | return *data; |
| 873 | } |
| 874 | |
| 875 | static irqreturn_t e1000_test_intr(int irq, void *data) |
| 876 | { |
| 877 | struct net_device *netdev = (struct net_device *) data; |
| 878 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 879 | struct e1000_hw *hw = &adapter->hw; |
| 880 | |
| 881 | adapter->test_icr |= er32(ICR); |
| 882 | |
| 883 | return IRQ_HANDLED; |
| 884 | } |
| 885 | |
| 886 | static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data) |
| 887 | { |
| 888 | struct net_device *netdev = adapter->netdev; |
| 889 | struct e1000_hw *hw = &adapter->hw; |
| 890 | u32 mask; |
| 891 | u32 shared_int = 1; |
| 892 | u32 irq = adapter->pdev->irq; |
| 893 | int i; |
| 894 | |
| 895 | *data = 0; |
| 896 | |
| 897 | /* NOTE: we don't test MSI interrupts here, yet */ |
| 898 | /* Hook up test interrupt handler just for this test */ |
| 899 | if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED, netdev->name, |
| 900 | netdev)) { |
| 901 | shared_int = 0; |
| 902 | } else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED, |
| 903 | netdev->name, netdev)) { |
| 904 | *data = 1; |
| 905 | return -1; |
| 906 | } |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 907 | e_info("testing %s interrupt\n", (shared_int ? "shared" : "unshared")); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 908 | |
| 909 | /* Disable all the interrupts */ |
| 910 | ew32(IMC, 0xFFFFFFFF); |
| 911 | msleep(10); |
| 912 | |
| 913 | /* Test each interrupt */ |
| 914 | for (i = 0; i < 10; i++) { |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 915 | if ((adapter->flags & FLAG_IS_ICH) && (i == 8)) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 916 | continue; |
| 917 | |
| 918 | /* Interrupt to test */ |
| 919 | mask = 1 << i; |
| 920 | |
| 921 | if (!shared_int) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 922 | /* |
| 923 | * Disable the interrupt to be reported in |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 924 | * the cause register and then force the same |
| 925 | * interrupt and see if one gets posted. If |
| 926 | * an interrupt was posted to the bus, the |
| 927 | * test failed. |
| 928 | */ |
| 929 | adapter->test_icr = 0; |
| 930 | ew32(IMC, mask); |
| 931 | ew32(ICS, mask); |
| 932 | msleep(10); |
| 933 | |
| 934 | if (adapter->test_icr & mask) { |
| 935 | *data = 3; |
| 936 | break; |
| 937 | } |
| 938 | } |
| 939 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 940 | /* |
| 941 | * Enable the interrupt to be reported in |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 942 | * the cause register and then force the same |
| 943 | * interrupt and see if one gets posted. If |
| 944 | * an interrupt was not posted to the bus, the |
| 945 | * test failed. |
| 946 | */ |
| 947 | adapter->test_icr = 0; |
| 948 | ew32(IMS, mask); |
| 949 | ew32(ICS, mask); |
| 950 | msleep(10); |
| 951 | |
| 952 | if (!(adapter->test_icr & mask)) { |
| 953 | *data = 4; |
| 954 | break; |
| 955 | } |
| 956 | |
| 957 | if (!shared_int) { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 958 | /* |
| 959 | * Disable the other interrupts to be reported in |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 960 | * the cause register and then force the other |
| 961 | * interrupts and see if any get posted. If |
| 962 | * an interrupt was posted to the bus, the |
| 963 | * test failed. |
| 964 | */ |
| 965 | adapter->test_icr = 0; |
| 966 | ew32(IMC, ~mask & 0x00007FFF); |
| 967 | ew32(ICS, ~mask & 0x00007FFF); |
| 968 | msleep(10); |
| 969 | |
| 970 | if (adapter->test_icr) { |
| 971 | *data = 5; |
| 972 | break; |
| 973 | } |
| 974 | } |
| 975 | } |
| 976 | |
| 977 | /* Disable all the interrupts */ |
| 978 | ew32(IMC, 0xFFFFFFFF); |
| 979 | msleep(10); |
| 980 | |
| 981 | /* Unhook test interrupt handler */ |
| 982 | free_irq(irq, netdev); |
| 983 | |
| 984 | return *data; |
| 985 | } |
| 986 | |
| 987 | static void e1000_free_desc_rings(struct e1000_adapter *adapter) |
| 988 | { |
| 989 | struct e1000_ring *tx_ring = &adapter->test_tx_ring; |
| 990 | struct e1000_ring *rx_ring = &adapter->test_rx_ring; |
| 991 | struct pci_dev *pdev = adapter->pdev; |
| 992 | int i; |
| 993 | |
| 994 | if (tx_ring->desc && tx_ring->buffer_info) { |
| 995 | for (i = 0; i < tx_ring->count; i++) { |
| 996 | if (tx_ring->buffer_info[i].dma) |
| 997 | pci_unmap_single(pdev, |
| 998 | tx_ring->buffer_info[i].dma, |
| 999 | tx_ring->buffer_info[i].length, |
| 1000 | PCI_DMA_TODEVICE); |
| 1001 | if (tx_ring->buffer_info[i].skb) |
| 1002 | dev_kfree_skb(tx_ring->buffer_info[i].skb); |
| 1003 | } |
| 1004 | } |
| 1005 | |
| 1006 | if (rx_ring->desc && rx_ring->buffer_info) { |
| 1007 | for (i = 0; i < rx_ring->count; i++) { |
| 1008 | if (rx_ring->buffer_info[i].dma) |
| 1009 | pci_unmap_single(pdev, |
| 1010 | rx_ring->buffer_info[i].dma, |
| 1011 | 2048, PCI_DMA_FROMDEVICE); |
| 1012 | if (rx_ring->buffer_info[i].skb) |
| 1013 | dev_kfree_skb(rx_ring->buffer_info[i].skb); |
| 1014 | } |
| 1015 | } |
| 1016 | |
| 1017 | if (tx_ring->desc) { |
| 1018 | dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc, |
| 1019 | tx_ring->dma); |
| 1020 | tx_ring->desc = NULL; |
| 1021 | } |
| 1022 | if (rx_ring->desc) { |
| 1023 | dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc, |
| 1024 | rx_ring->dma); |
| 1025 | rx_ring->desc = NULL; |
| 1026 | } |
| 1027 | |
| 1028 | kfree(tx_ring->buffer_info); |
| 1029 | tx_ring->buffer_info = NULL; |
| 1030 | kfree(rx_ring->buffer_info); |
| 1031 | rx_ring->buffer_info = NULL; |
| 1032 | } |
| 1033 | |
| 1034 | static int e1000_setup_desc_rings(struct e1000_adapter *adapter) |
| 1035 | { |
| 1036 | struct e1000_ring *tx_ring = &adapter->test_tx_ring; |
| 1037 | struct e1000_ring *rx_ring = &adapter->test_rx_ring; |
| 1038 | struct pci_dev *pdev = adapter->pdev; |
| 1039 | struct e1000_hw *hw = &adapter->hw; |
| 1040 | u32 rctl; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1041 | int i; |
| 1042 | int ret_val; |
| 1043 | |
| 1044 | /* Setup Tx descriptor ring and Tx buffers */ |
| 1045 | |
| 1046 | if (!tx_ring->count) |
| 1047 | tx_ring->count = E1000_DEFAULT_TXD; |
| 1048 | |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1049 | tx_ring->buffer_info = kcalloc(tx_ring->count, |
| 1050 | sizeof(struct e1000_buffer), |
| 1051 | GFP_KERNEL); |
| 1052 | if (!(tx_ring->buffer_info)) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1053 | ret_val = 1; |
| 1054 | goto err_nomem; |
| 1055 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1056 | |
| 1057 | tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc); |
| 1058 | tx_ring->size = ALIGN(tx_ring->size, 4096); |
| 1059 | tx_ring->desc = dma_alloc_coherent(&pdev->dev, tx_ring->size, |
| 1060 | &tx_ring->dma, GFP_KERNEL); |
| 1061 | if (!tx_ring->desc) { |
| 1062 | ret_val = 2; |
| 1063 | goto err_nomem; |
| 1064 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1065 | tx_ring->next_to_use = 0; |
| 1066 | tx_ring->next_to_clean = 0; |
| 1067 | |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1068 | ew32(TDBAL, ((u64) tx_ring->dma & 0x00000000FFFFFFFF)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1069 | ew32(TDBAH, ((u64) tx_ring->dma >> 32)); |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1070 | ew32(TDLEN, tx_ring->count * sizeof(struct e1000_tx_desc)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1071 | ew32(TDH, 0); |
| 1072 | ew32(TDT, 0); |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1073 | ew32(TCTL, E1000_TCTL_PSP | E1000_TCTL_EN | E1000_TCTL_MULR | |
| 1074 | E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT | |
| 1075 | E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1076 | |
| 1077 | for (i = 0; i < tx_ring->count; i++) { |
| 1078 | struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*tx_ring, i); |
| 1079 | struct sk_buff *skb; |
| 1080 | unsigned int skb_size = 1024; |
| 1081 | |
| 1082 | skb = alloc_skb(skb_size, GFP_KERNEL); |
| 1083 | if (!skb) { |
| 1084 | ret_val = 3; |
| 1085 | goto err_nomem; |
| 1086 | } |
| 1087 | skb_put(skb, skb_size); |
| 1088 | tx_ring->buffer_info[i].skb = skb; |
| 1089 | tx_ring->buffer_info[i].length = skb->len; |
| 1090 | tx_ring->buffer_info[i].dma = |
| 1091 | pci_map_single(pdev, skb->data, skb->len, |
| 1092 | PCI_DMA_TODEVICE); |
FUJITA Tomonori | 8d8bb39 | 2008-07-25 19:44:49 -0700 | [diff] [blame] | 1093 | if (pci_dma_mapping_error(pdev, tx_ring->buffer_info[i].dma)) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1094 | ret_val = 4; |
| 1095 | goto err_nomem; |
| 1096 | } |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1097 | tx_desc->buffer_addr = cpu_to_le64(tx_ring->buffer_info[i].dma); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1098 | tx_desc->lower.data = cpu_to_le32(skb->len); |
| 1099 | tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP | |
| 1100 | E1000_TXD_CMD_IFCS | |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1101 | E1000_TXD_CMD_RS); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1102 | tx_desc->upper.data = 0; |
| 1103 | } |
| 1104 | |
| 1105 | /* Setup Rx descriptor ring and Rx buffers */ |
| 1106 | |
| 1107 | if (!rx_ring->count) |
| 1108 | rx_ring->count = E1000_DEFAULT_RXD; |
| 1109 | |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1110 | rx_ring->buffer_info = kcalloc(rx_ring->count, |
| 1111 | sizeof(struct e1000_buffer), |
| 1112 | GFP_KERNEL); |
| 1113 | if (!(rx_ring->buffer_info)) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1114 | ret_val = 5; |
| 1115 | goto err_nomem; |
| 1116 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1117 | |
| 1118 | rx_ring->size = rx_ring->count * sizeof(struct e1000_rx_desc); |
| 1119 | rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size, |
| 1120 | &rx_ring->dma, GFP_KERNEL); |
| 1121 | if (!rx_ring->desc) { |
| 1122 | ret_val = 6; |
| 1123 | goto err_nomem; |
| 1124 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1125 | rx_ring->next_to_use = 0; |
| 1126 | rx_ring->next_to_clean = 0; |
| 1127 | |
| 1128 | rctl = er32(RCTL); |
| 1129 | ew32(RCTL, rctl & ~E1000_RCTL_EN); |
| 1130 | ew32(RDBAL, ((u64) rx_ring->dma & 0xFFFFFFFF)); |
| 1131 | ew32(RDBAH, ((u64) rx_ring->dma >> 32)); |
| 1132 | ew32(RDLEN, rx_ring->size); |
| 1133 | ew32(RDH, 0); |
| 1134 | ew32(RDT, 0); |
| 1135 | rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 | |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1136 | E1000_RCTL_UPE | E1000_RCTL_MPE | E1000_RCTL_LPE | |
| 1137 | E1000_RCTL_SBP | E1000_RCTL_SECRC | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1138 | E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF | |
| 1139 | (adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT); |
| 1140 | ew32(RCTL, rctl); |
| 1141 | |
| 1142 | for (i = 0; i < rx_ring->count; i++) { |
| 1143 | struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rx_ring, i); |
| 1144 | struct sk_buff *skb; |
| 1145 | |
| 1146 | skb = alloc_skb(2048 + NET_IP_ALIGN, GFP_KERNEL); |
| 1147 | if (!skb) { |
| 1148 | ret_val = 7; |
| 1149 | goto err_nomem; |
| 1150 | } |
| 1151 | skb_reserve(skb, NET_IP_ALIGN); |
| 1152 | rx_ring->buffer_info[i].skb = skb; |
| 1153 | rx_ring->buffer_info[i].dma = |
| 1154 | pci_map_single(pdev, skb->data, 2048, |
| 1155 | PCI_DMA_FROMDEVICE); |
FUJITA Tomonori | 8d8bb39 | 2008-07-25 19:44:49 -0700 | [diff] [blame] | 1156 | if (pci_dma_mapping_error(pdev, rx_ring->buffer_info[i].dma)) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1157 | ret_val = 8; |
| 1158 | goto err_nomem; |
| 1159 | } |
| 1160 | rx_desc->buffer_addr = |
| 1161 | cpu_to_le64(rx_ring->buffer_info[i].dma); |
| 1162 | memset(skb->data, 0x00, skb->len); |
| 1163 | } |
| 1164 | |
| 1165 | return 0; |
| 1166 | |
| 1167 | err_nomem: |
| 1168 | e1000_free_desc_rings(adapter); |
| 1169 | return ret_val; |
| 1170 | } |
| 1171 | |
| 1172 | static void e1000_phy_disable_receiver(struct e1000_adapter *adapter) |
| 1173 | { |
| 1174 | /* Write out to PHY registers 29 and 30 to disable the Receiver. */ |
| 1175 | e1e_wphy(&adapter->hw, 29, 0x001F); |
| 1176 | e1e_wphy(&adapter->hw, 30, 0x8FFC); |
| 1177 | e1e_wphy(&adapter->hw, 29, 0x001A); |
| 1178 | e1e_wphy(&adapter->hw, 30, 0x8FF0); |
| 1179 | } |
| 1180 | |
| 1181 | static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter) |
| 1182 | { |
| 1183 | struct e1000_hw *hw = &adapter->hw; |
| 1184 | u32 ctrl_reg = 0; |
| 1185 | u32 stat_reg = 0; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 1186 | u16 phy_reg = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1187 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 1188 | hw->mac.autoneg = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1189 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 1190 | if (hw->phy.type == e1000_phy_m88) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1191 | /* Auto-MDI/MDIX Off */ |
| 1192 | e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, 0x0808); |
| 1193 | /* reset to update Auto-MDI/MDIX */ |
| 1194 | e1e_wphy(hw, PHY_CONTROL, 0x9140); |
| 1195 | /* autoneg off */ |
| 1196 | e1e_wphy(hw, PHY_CONTROL, 0x8140); |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 1197 | } else if (hw->phy.type == e1000_phy_gg82563) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1198 | e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x1CC); |
| 1199 | |
| 1200 | ctrl_reg = er32(CTRL); |
| 1201 | |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1202 | switch (hw->phy.type) { |
| 1203 | case e1000_phy_ife: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1204 | /* force 100, set loopback */ |
| 1205 | e1e_wphy(hw, PHY_CONTROL, 0x6100); |
| 1206 | |
| 1207 | /* Now set up the MAC to the same speed/duplex as the PHY. */ |
| 1208 | ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */ |
| 1209 | ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */ |
| 1210 | E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */ |
| 1211 | E1000_CTRL_SPD_100 |/* Force Speed to 100 */ |
| 1212 | E1000_CTRL_FD); /* Force Duplex to FULL */ |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1213 | break; |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 1214 | case e1000_phy_bm: |
| 1215 | /* Set Default MAC Interface speed to 1GB */ |
| 1216 | e1e_rphy(hw, PHY_REG(2, 21), &phy_reg); |
| 1217 | phy_reg &= ~0x0007; |
| 1218 | phy_reg |= 0x006; |
| 1219 | e1e_wphy(hw, PHY_REG(2, 21), phy_reg); |
| 1220 | /* Assert SW reset for above settings to take effect */ |
| 1221 | e1000e_commit_phy(hw); |
| 1222 | mdelay(1); |
| 1223 | /* Force Full Duplex */ |
| 1224 | e1e_rphy(hw, PHY_REG(769, 16), &phy_reg); |
| 1225 | e1e_wphy(hw, PHY_REG(769, 16), phy_reg | 0x000C); |
| 1226 | /* Set Link Up (in force link) */ |
| 1227 | e1e_rphy(hw, PHY_REG(776, 16), &phy_reg); |
| 1228 | e1e_wphy(hw, PHY_REG(776, 16), phy_reg | 0x0040); |
| 1229 | /* Force Link */ |
| 1230 | e1e_rphy(hw, PHY_REG(769, 16), &phy_reg); |
| 1231 | e1e_wphy(hw, PHY_REG(769, 16), phy_reg | 0x0040); |
| 1232 | /* Set Early Link Enable */ |
| 1233 | e1e_rphy(hw, PHY_REG(769, 20), &phy_reg); |
| 1234 | e1e_wphy(hw, PHY_REG(769, 20), phy_reg | 0x0400); |
| 1235 | /* fall through */ |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1236 | default: |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1237 | /* force 1000, set loopback */ |
| 1238 | e1e_wphy(hw, PHY_CONTROL, 0x4140); |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1239 | mdelay(250); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1240 | |
| 1241 | /* Now set up the MAC to the same speed/duplex as the PHY. */ |
| 1242 | ctrl_reg = er32(CTRL); |
| 1243 | ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */ |
| 1244 | ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */ |
| 1245 | E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */ |
| 1246 | E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */ |
| 1247 | E1000_CTRL_FD); /* Force Duplex to FULL */ |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1248 | |
Bruce Allan | 97ac8ca | 2008-04-29 09:16:05 -0700 | [diff] [blame] | 1249 | if (adapter->flags & FLAG_IS_ICH) |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1250 | ctrl_reg |= E1000_CTRL_SLU; /* Set Link Up */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1251 | } |
| 1252 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 1253 | if (hw->phy.media_type == e1000_media_type_copper && |
| 1254 | hw->phy.type == e1000_phy_m88) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1255 | ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */ |
| 1256 | } else { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1257 | /* |
| 1258 | * Set the ILOS bit on the fiber Nic if half duplex link is |
| 1259 | * detected. |
| 1260 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1261 | stat_reg = er32(STATUS); |
| 1262 | if ((stat_reg & E1000_STATUS_FD) == 0) |
| 1263 | ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU); |
| 1264 | } |
| 1265 | |
| 1266 | ew32(CTRL, ctrl_reg); |
| 1267 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1268 | /* |
| 1269 | * Disable the receiver on the PHY so when a cable is plugged in, the |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1270 | * PHY does not begin to autoneg when a cable is reconnected to the NIC. |
| 1271 | */ |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 1272 | if (hw->phy.type == e1000_phy_m88) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1273 | e1000_phy_disable_receiver(adapter); |
| 1274 | |
| 1275 | udelay(500); |
| 1276 | |
| 1277 | return 0; |
| 1278 | } |
| 1279 | |
| 1280 | static int e1000_set_82571_fiber_loopback(struct e1000_adapter *adapter) |
| 1281 | { |
| 1282 | struct e1000_hw *hw = &adapter->hw; |
| 1283 | u32 ctrl = er32(CTRL); |
| 1284 | int link = 0; |
| 1285 | |
| 1286 | /* special requirements for 82571/82572 fiber adapters */ |
| 1287 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1288 | /* |
| 1289 | * jump through hoops to make sure link is up because serdes |
| 1290 | * link is hardwired up |
| 1291 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1292 | ctrl |= E1000_CTRL_SLU; |
| 1293 | ew32(CTRL, ctrl); |
| 1294 | |
| 1295 | /* disable autoneg */ |
| 1296 | ctrl = er32(TXCW); |
| 1297 | ctrl &= ~(1 << 31); |
| 1298 | ew32(TXCW, ctrl); |
| 1299 | |
| 1300 | link = (er32(STATUS) & E1000_STATUS_LU); |
| 1301 | |
| 1302 | if (!link) { |
| 1303 | /* set invert loss of signal */ |
| 1304 | ctrl = er32(CTRL); |
| 1305 | ctrl |= E1000_CTRL_ILOS; |
| 1306 | ew32(CTRL, ctrl); |
| 1307 | } |
| 1308 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1309 | /* |
| 1310 | * special write to serdes control register to enable SerDes analog |
| 1311 | * loopback |
| 1312 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1313 | #define E1000_SERDES_LB_ON 0x410 |
| 1314 | ew32(SCTL, E1000_SERDES_LB_ON); |
| 1315 | msleep(10); |
| 1316 | |
| 1317 | return 0; |
| 1318 | } |
| 1319 | |
| 1320 | /* only call this for fiber/serdes connections to es2lan */ |
| 1321 | static int e1000_set_es2lan_mac_loopback(struct e1000_adapter *adapter) |
| 1322 | { |
| 1323 | struct e1000_hw *hw = &adapter->hw; |
| 1324 | u32 ctrlext = er32(CTRL_EXT); |
| 1325 | u32 ctrl = er32(CTRL); |
| 1326 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1327 | /* |
| 1328 | * save CTRL_EXT to restore later, reuse an empty variable (unused |
| 1329 | * on mac_type 80003es2lan) |
| 1330 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1331 | adapter->tx_fifo_head = ctrlext; |
| 1332 | |
| 1333 | /* clear the serdes mode bits, putting the device into mac loopback */ |
| 1334 | ctrlext &= ~E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES; |
| 1335 | ew32(CTRL_EXT, ctrlext); |
| 1336 | |
| 1337 | /* force speed to 1000/FD, link up */ |
| 1338 | ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100); |
| 1339 | ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX | |
| 1340 | E1000_CTRL_SPD_1000 | E1000_CTRL_FD); |
| 1341 | ew32(CTRL, ctrl); |
| 1342 | |
| 1343 | /* set mac loopback */ |
| 1344 | ctrl = er32(RCTL); |
| 1345 | ctrl |= E1000_RCTL_LBM_MAC; |
| 1346 | ew32(RCTL, ctrl); |
| 1347 | |
| 1348 | /* set testing mode parameters (no need to reset later) */ |
| 1349 | #define KMRNCTRLSTA_OPMODE (0x1F << 16) |
| 1350 | #define KMRNCTRLSTA_OPMODE_1GB_FD_GMII 0x0582 |
| 1351 | ew32(KMRNCTRLSTA, |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1352 | (KMRNCTRLSTA_OPMODE | KMRNCTRLSTA_OPMODE_1GB_FD_GMII)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1353 | |
| 1354 | return 0; |
| 1355 | } |
| 1356 | |
| 1357 | static int e1000_setup_loopback_test(struct e1000_adapter *adapter) |
| 1358 | { |
| 1359 | struct e1000_hw *hw = &adapter->hw; |
| 1360 | u32 rctl; |
| 1361 | |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 1362 | if (hw->phy.media_type == e1000_media_type_fiber || |
| 1363 | hw->phy.media_type == e1000_media_type_internal_serdes) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1364 | switch (hw->mac.type) { |
| 1365 | case e1000_80003es2lan: |
| 1366 | return e1000_set_es2lan_mac_loopback(adapter); |
| 1367 | break; |
| 1368 | case e1000_82571: |
| 1369 | case e1000_82572: |
| 1370 | return e1000_set_82571_fiber_loopback(adapter); |
| 1371 | break; |
| 1372 | default: |
| 1373 | rctl = er32(RCTL); |
| 1374 | rctl |= E1000_RCTL_LBM_TCVR; |
| 1375 | ew32(RCTL, rctl); |
| 1376 | return 0; |
| 1377 | } |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 1378 | } else if (hw->phy.media_type == e1000_media_type_copper) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1379 | return e1000_integrated_phy_loopback(adapter); |
| 1380 | } |
| 1381 | |
| 1382 | return 7; |
| 1383 | } |
| 1384 | |
| 1385 | static void e1000_loopback_cleanup(struct e1000_adapter *adapter) |
| 1386 | { |
| 1387 | struct e1000_hw *hw = &adapter->hw; |
| 1388 | u32 rctl; |
| 1389 | u16 phy_reg; |
| 1390 | |
| 1391 | rctl = er32(RCTL); |
| 1392 | rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC); |
| 1393 | ew32(RCTL, rctl); |
| 1394 | |
| 1395 | switch (hw->mac.type) { |
| 1396 | case e1000_80003es2lan: |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 1397 | if (hw->phy.media_type == e1000_media_type_fiber || |
| 1398 | hw->phy.media_type == e1000_media_type_internal_serdes) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1399 | /* restore CTRL_EXT, stealing space from tx_fifo_head */ |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1400 | ew32(CTRL_EXT, adapter->tx_fifo_head); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1401 | adapter->tx_fifo_head = 0; |
| 1402 | } |
| 1403 | /* fall through */ |
| 1404 | case e1000_82571: |
| 1405 | case e1000_82572: |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 1406 | if (hw->phy.media_type == e1000_media_type_fiber || |
| 1407 | hw->phy.media_type == e1000_media_type_internal_serdes) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1408 | #define E1000_SERDES_LB_OFF 0x400 |
| 1409 | ew32(SCTL, E1000_SERDES_LB_OFF); |
| 1410 | msleep(10); |
| 1411 | break; |
| 1412 | } |
| 1413 | /* Fall Through */ |
| 1414 | default: |
| 1415 | hw->mac.autoneg = 1; |
| 1416 | if (hw->phy.type == e1000_phy_gg82563) |
| 1417 | e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x180); |
| 1418 | e1e_rphy(hw, PHY_CONTROL, &phy_reg); |
| 1419 | if (phy_reg & MII_CR_LOOPBACK) { |
| 1420 | phy_reg &= ~MII_CR_LOOPBACK; |
| 1421 | e1e_wphy(hw, PHY_CONTROL, phy_reg); |
| 1422 | e1000e_commit_phy(hw); |
| 1423 | } |
| 1424 | break; |
| 1425 | } |
| 1426 | } |
| 1427 | |
| 1428 | static void e1000_create_lbtest_frame(struct sk_buff *skb, |
| 1429 | unsigned int frame_size) |
| 1430 | { |
| 1431 | memset(skb->data, 0xFF, frame_size); |
| 1432 | frame_size &= ~1; |
| 1433 | memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1); |
| 1434 | memset(&skb->data[frame_size / 2 + 10], 0xBE, 1); |
| 1435 | memset(&skb->data[frame_size / 2 + 12], 0xAF, 1); |
| 1436 | } |
| 1437 | |
| 1438 | static int e1000_check_lbtest_frame(struct sk_buff *skb, |
| 1439 | unsigned int frame_size) |
| 1440 | { |
| 1441 | frame_size &= ~1; |
| 1442 | if (*(skb->data + 3) == 0xFF) |
| 1443 | if ((*(skb->data + frame_size / 2 + 10) == 0xBE) && |
| 1444 | (*(skb->data + frame_size / 2 + 12) == 0xAF)) |
| 1445 | return 0; |
| 1446 | return 13; |
| 1447 | } |
| 1448 | |
| 1449 | static int e1000_run_loopback_test(struct e1000_adapter *adapter) |
| 1450 | { |
| 1451 | struct e1000_ring *tx_ring = &adapter->test_tx_ring; |
| 1452 | struct e1000_ring *rx_ring = &adapter->test_rx_ring; |
| 1453 | struct pci_dev *pdev = adapter->pdev; |
| 1454 | struct e1000_hw *hw = &adapter->hw; |
| 1455 | int i, j, k, l; |
| 1456 | int lc; |
| 1457 | int good_cnt; |
| 1458 | int ret_val = 0; |
| 1459 | unsigned long time; |
| 1460 | |
| 1461 | ew32(RDT, rx_ring->count - 1); |
| 1462 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1463 | /* |
| 1464 | * Calculate the loop count based on the largest descriptor ring |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1465 | * The idea is to wrap the largest ring a number of times using 64 |
| 1466 | * send/receive pairs during each loop |
| 1467 | */ |
| 1468 | |
| 1469 | if (rx_ring->count <= tx_ring->count) |
| 1470 | lc = ((tx_ring->count / 64) * 2) + 1; |
| 1471 | else |
| 1472 | lc = ((rx_ring->count / 64) * 2) + 1; |
| 1473 | |
| 1474 | k = 0; |
| 1475 | l = 0; |
| 1476 | for (j = 0; j <= lc; j++) { /* loop count loop */ |
| 1477 | for (i = 0; i < 64; i++) { /* send the packets */ |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1478 | e1000_create_lbtest_frame(tx_ring->buffer_info[k].skb, |
| 1479 | 1024); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1480 | pci_dma_sync_single_for_device(pdev, |
| 1481 | tx_ring->buffer_info[k].dma, |
| 1482 | tx_ring->buffer_info[k].length, |
| 1483 | PCI_DMA_TODEVICE); |
| 1484 | k++; |
| 1485 | if (k == tx_ring->count) |
| 1486 | k = 0; |
| 1487 | } |
| 1488 | ew32(TDT, k); |
| 1489 | msleep(200); |
| 1490 | time = jiffies; /* set the start time for the receive */ |
| 1491 | good_cnt = 0; |
| 1492 | do { /* receive the sent packets */ |
| 1493 | pci_dma_sync_single_for_cpu(pdev, |
| 1494 | rx_ring->buffer_info[l].dma, 2048, |
| 1495 | PCI_DMA_FROMDEVICE); |
| 1496 | |
| 1497 | ret_val = e1000_check_lbtest_frame( |
| 1498 | rx_ring->buffer_info[l].skb, 1024); |
| 1499 | if (!ret_val) |
| 1500 | good_cnt++; |
| 1501 | l++; |
| 1502 | if (l == rx_ring->count) |
| 1503 | l = 0; |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1504 | /* |
| 1505 | * time + 20 msecs (200 msecs on 2.4) is more than |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1506 | * enough time to complete the receives, if it's |
| 1507 | * exceeded, break and error off |
| 1508 | */ |
| 1509 | } while ((good_cnt < 64) && !time_after(jiffies, time + 20)); |
| 1510 | if (good_cnt != 64) { |
| 1511 | ret_val = 13; /* ret_val is the same as mis-compare */ |
| 1512 | break; |
| 1513 | } |
Bruce Allan | cef8c79 | 2008-04-02 13:48:23 -0700 | [diff] [blame] | 1514 | if (jiffies >= (time + 20)) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1515 | ret_val = 14; /* error code for time out error */ |
| 1516 | break; |
| 1517 | } |
| 1518 | } /* end loop count loop */ |
| 1519 | return ret_val; |
| 1520 | } |
| 1521 | |
| 1522 | static int e1000_loopback_test(struct e1000_adapter *adapter, u64 *data) |
| 1523 | { |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1524 | /* |
| 1525 | * PHY loopback cannot be performed if SoL/IDER |
| 1526 | * sessions are active |
| 1527 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1528 | if (e1000_check_reset_block(&adapter->hw)) { |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 1529 | e_err("Cannot do PHY loopback test when SoL/IDER is active.\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1530 | *data = 0; |
| 1531 | goto out; |
| 1532 | } |
| 1533 | |
| 1534 | *data = e1000_setup_desc_rings(adapter); |
Adrian Bunk | e265522 | 2007-10-15 14:02:21 -0700 | [diff] [blame] | 1535 | if (*data) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1536 | goto out; |
| 1537 | |
| 1538 | *data = e1000_setup_loopback_test(adapter); |
Adrian Bunk | e265522 | 2007-10-15 14:02:21 -0700 | [diff] [blame] | 1539 | if (*data) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1540 | goto err_loopback; |
| 1541 | |
| 1542 | *data = e1000_run_loopback_test(adapter); |
| 1543 | e1000_loopback_cleanup(adapter); |
| 1544 | |
| 1545 | err_loopback: |
| 1546 | e1000_free_desc_rings(adapter); |
| 1547 | out: |
| 1548 | return *data; |
| 1549 | } |
| 1550 | |
| 1551 | static int e1000_link_test(struct e1000_adapter *adapter, u64 *data) |
| 1552 | { |
| 1553 | struct e1000_hw *hw = &adapter->hw; |
| 1554 | |
| 1555 | *data = 0; |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 1556 | if (hw->phy.media_type == e1000_media_type_internal_serdes) { |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1557 | int i = 0; |
| 1558 | hw->mac.serdes_has_link = 0; |
| 1559 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1560 | /* |
| 1561 | * On some blade server designs, link establishment |
| 1562 | * could take as long as 2-3 minutes |
| 1563 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1564 | do { |
| 1565 | hw->mac.ops.check_for_link(hw); |
| 1566 | if (hw->mac.serdes_has_link) |
| 1567 | return *data; |
| 1568 | msleep(20); |
| 1569 | } while (i++ < 3750); |
| 1570 | |
| 1571 | *data = 1; |
| 1572 | } else { |
| 1573 | hw->mac.ops.check_for_link(hw); |
| 1574 | if (hw->mac.autoneg) |
| 1575 | msleep(4000); |
| 1576 | |
| 1577 | if (!(er32(STATUS) & |
| 1578 | E1000_STATUS_LU)) |
| 1579 | *data = 1; |
| 1580 | } |
| 1581 | return *data; |
| 1582 | } |
| 1583 | |
Jeff Garzik | b9f2c04 | 2007-10-03 18:07:32 -0700 | [diff] [blame] | 1584 | static int e1000e_get_sset_count(struct net_device *netdev, int sset) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1585 | { |
Jeff Garzik | b9f2c04 | 2007-10-03 18:07:32 -0700 | [diff] [blame] | 1586 | switch (sset) { |
| 1587 | case ETH_SS_TEST: |
| 1588 | return E1000_TEST_LEN; |
| 1589 | case ETH_SS_STATS: |
| 1590 | return E1000_STATS_LEN; |
| 1591 | default: |
| 1592 | return -EOPNOTSUPP; |
| 1593 | } |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1594 | } |
| 1595 | |
| 1596 | static void e1000_diag_test(struct net_device *netdev, |
| 1597 | struct ethtool_test *eth_test, u64 *data) |
| 1598 | { |
| 1599 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 1600 | u16 autoneg_advertised; |
| 1601 | u8 forced_speed_duplex; |
| 1602 | u8 autoneg; |
| 1603 | bool if_running = netif_running(netdev); |
| 1604 | |
| 1605 | set_bit(__E1000_TESTING, &adapter->state); |
| 1606 | if (eth_test->flags == ETH_TEST_FL_OFFLINE) { |
| 1607 | /* Offline tests */ |
| 1608 | |
| 1609 | /* save speed, duplex, autoneg settings */ |
| 1610 | autoneg_advertised = adapter->hw.phy.autoneg_advertised; |
| 1611 | forced_speed_duplex = adapter->hw.mac.forced_speed_duplex; |
| 1612 | autoneg = adapter->hw.mac.autoneg; |
| 1613 | |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 1614 | e_info("offline testing starting\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1615 | |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1616 | /* |
| 1617 | * Link test performed before hardware reset so autoneg doesn't |
| 1618 | * interfere with test result |
| 1619 | */ |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1620 | if (e1000_link_test(adapter, &data[4])) |
| 1621 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 1622 | |
| 1623 | if (if_running) |
| 1624 | /* indicate we're in test mode */ |
| 1625 | dev_close(netdev); |
| 1626 | else |
| 1627 | e1000e_reset(adapter); |
| 1628 | |
| 1629 | if (e1000_reg_test(adapter, &data[0])) |
| 1630 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 1631 | |
| 1632 | e1000e_reset(adapter); |
| 1633 | if (e1000_eeprom_test(adapter, &data[1])) |
| 1634 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 1635 | |
| 1636 | e1000e_reset(adapter); |
| 1637 | if (e1000_intr_test(adapter, &data[2])) |
| 1638 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 1639 | |
| 1640 | e1000e_reset(adapter); |
| 1641 | /* make sure the phy is powered up */ |
| 1642 | e1000e_power_up_phy(adapter); |
| 1643 | if (e1000_loopback_test(adapter, &data[3])) |
| 1644 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 1645 | |
| 1646 | /* restore speed, duplex, autoneg settings */ |
| 1647 | adapter->hw.phy.autoneg_advertised = autoneg_advertised; |
| 1648 | adapter->hw.mac.forced_speed_duplex = forced_speed_duplex; |
| 1649 | adapter->hw.mac.autoneg = autoneg; |
| 1650 | |
| 1651 | /* force this routine to wait until autoneg complete/timeout */ |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 1652 | adapter->hw.phy.autoneg_wait_to_complete = 1; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1653 | e1000e_reset(adapter); |
Jeff Kirsher | 318a94d | 2008-03-28 09:15:16 -0700 | [diff] [blame] | 1654 | adapter->hw.phy.autoneg_wait_to_complete = 0; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1655 | |
| 1656 | clear_bit(__E1000_TESTING, &adapter->state); |
| 1657 | if (if_running) |
| 1658 | dev_open(netdev); |
| 1659 | } else { |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 1660 | e_info("online testing starting\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1661 | /* Online tests */ |
| 1662 | if (e1000_link_test(adapter, &data[4])) |
| 1663 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 1664 | |
| 1665 | /* Online tests aren't run; pass by default */ |
| 1666 | data[0] = 0; |
| 1667 | data[1] = 0; |
| 1668 | data[2] = 0; |
| 1669 | data[3] = 0; |
| 1670 | |
| 1671 | clear_bit(__E1000_TESTING, &adapter->state); |
| 1672 | } |
| 1673 | msleep_interruptible(4 * 1000); |
| 1674 | } |
| 1675 | |
| 1676 | static void e1000_get_wol(struct net_device *netdev, |
| 1677 | struct ethtool_wolinfo *wol) |
| 1678 | { |
| 1679 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 1680 | |
| 1681 | wol->supported = 0; |
| 1682 | wol->wolopts = 0; |
| 1683 | |
| 1684 | if (!(adapter->flags & FLAG_HAS_WOL)) |
| 1685 | return; |
| 1686 | |
| 1687 | wol->supported = WAKE_UCAST | WAKE_MCAST | |
Mitch Williams | efb90e4 | 2008-01-29 12:43:02 -0800 | [diff] [blame] | 1688 | WAKE_BCAST | WAKE_MAGIC | |
| 1689 | WAKE_PHY | WAKE_ARP; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1690 | |
| 1691 | /* apply any specific unsupported masks here */ |
| 1692 | if (adapter->flags & FLAG_NO_WAKE_UCAST) { |
| 1693 | wol->supported &= ~WAKE_UCAST; |
| 1694 | |
| 1695 | if (adapter->wol & E1000_WUFC_EX) |
Jeff Kirsher | 44defeb | 2008-08-04 17:20:41 -0700 | [diff] [blame] | 1696 | e_err("Interface does not support directed (unicast) " |
| 1697 | "frame wake-up packets\n"); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1698 | } |
| 1699 | |
| 1700 | if (adapter->wol & E1000_WUFC_EX) |
| 1701 | wol->wolopts |= WAKE_UCAST; |
| 1702 | if (adapter->wol & E1000_WUFC_MC) |
| 1703 | wol->wolopts |= WAKE_MCAST; |
| 1704 | if (adapter->wol & E1000_WUFC_BC) |
| 1705 | wol->wolopts |= WAKE_BCAST; |
| 1706 | if (adapter->wol & E1000_WUFC_MAG) |
| 1707 | wol->wolopts |= WAKE_MAGIC; |
Mitch Williams | efb90e4 | 2008-01-29 12:43:02 -0800 | [diff] [blame] | 1708 | if (adapter->wol & E1000_WUFC_LNKC) |
| 1709 | wol->wolopts |= WAKE_PHY; |
| 1710 | if (adapter->wol & E1000_WUFC_ARP) |
| 1711 | wol->wolopts |= WAKE_ARP; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1712 | } |
| 1713 | |
| 1714 | static int e1000_set_wol(struct net_device *netdev, |
| 1715 | struct ethtool_wolinfo *wol) |
| 1716 | { |
| 1717 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 1718 | |
Mitch Williams | efb90e4 | 2008-01-29 12:43:02 -0800 | [diff] [blame] | 1719 | if (wol->wolopts & WAKE_MAGICSECURE) |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1720 | return -EOPNOTSUPP; |
| 1721 | |
| 1722 | if (!(adapter->flags & FLAG_HAS_WOL)) |
| 1723 | return wol->wolopts ? -EOPNOTSUPP : 0; |
| 1724 | |
| 1725 | /* these settings will always override what we currently have */ |
| 1726 | adapter->wol = 0; |
| 1727 | |
| 1728 | if (wol->wolopts & WAKE_UCAST) |
| 1729 | adapter->wol |= E1000_WUFC_EX; |
| 1730 | if (wol->wolopts & WAKE_MCAST) |
| 1731 | adapter->wol |= E1000_WUFC_MC; |
| 1732 | if (wol->wolopts & WAKE_BCAST) |
| 1733 | adapter->wol |= E1000_WUFC_BC; |
| 1734 | if (wol->wolopts & WAKE_MAGIC) |
| 1735 | adapter->wol |= E1000_WUFC_MAG; |
Mitch Williams | efb90e4 | 2008-01-29 12:43:02 -0800 | [diff] [blame] | 1736 | if (wol->wolopts & WAKE_PHY) |
| 1737 | adapter->wol |= E1000_WUFC_LNKC; |
| 1738 | if (wol->wolopts & WAKE_ARP) |
| 1739 | adapter->wol |= E1000_WUFC_ARP; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1740 | |
| 1741 | return 0; |
| 1742 | } |
| 1743 | |
| 1744 | /* toggle LED 4 times per second = 2 "blinks" per second */ |
| 1745 | #define E1000_ID_INTERVAL (HZ/4) |
| 1746 | |
| 1747 | /* bit defines for adapter->led_status */ |
| 1748 | #define E1000_LED_ON 0 |
| 1749 | |
| 1750 | static void e1000_led_blink_callback(unsigned long data) |
| 1751 | { |
| 1752 | struct e1000_adapter *adapter = (struct e1000_adapter *) data; |
| 1753 | |
| 1754 | if (test_and_change_bit(E1000_LED_ON, &adapter->led_status)) |
| 1755 | adapter->hw.mac.ops.led_off(&adapter->hw); |
| 1756 | else |
| 1757 | adapter->hw.mac.ops.led_on(&adapter->hw); |
| 1758 | |
| 1759 | mod_timer(&adapter->blink_timer, jiffies + E1000_ID_INTERVAL); |
| 1760 | } |
| 1761 | |
| 1762 | static int e1000_phys_id(struct net_device *netdev, u32 data) |
| 1763 | { |
| 1764 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 1765 | |
Stephen Hemminger | 5a9147b | 2007-10-29 10:46:05 -0700 | [diff] [blame] | 1766 | if (!data) |
| 1767 | data = INT_MAX; |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1768 | |
| 1769 | if (adapter->hw.phy.type == e1000_phy_ife) { |
| 1770 | if (!adapter->blink_timer.function) { |
| 1771 | init_timer(&adapter->blink_timer); |
| 1772 | adapter->blink_timer.function = |
| 1773 | e1000_led_blink_callback; |
| 1774 | adapter->blink_timer.data = (unsigned long) adapter; |
| 1775 | } |
| 1776 | mod_timer(&adapter->blink_timer, jiffies); |
| 1777 | msleep_interruptible(data * 1000); |
| 1778 | del_timer_sync(&adapter->blink_timer); |
| 1779 | e1e_wphy(&adapter->hw, |
| 1780 | IFE_PHY_SPECIAL_CONTROL_LED, 0); |
| 1781 | } else { |
| 1782 | e1000e_blink_led(&adapter->hw); |
| 1783 | msleep_interruptible(data * 1000); |
| 1784 | } |
| 1785 | |
| 1786 | adapter->hw.mac.ops.led_off(&adapter->hw); |
| 1787 | clear_bit(E1000_LED_ON, &adapter->led_status); |
| 1788 | adapter->hw.mac.ops.cleanup_led(&adapter->hw); |
| 1789 | |
| 1790 | return 0; |
| 1791 | } |
| 1792 | |
Auke Kok | de5b307 | 2008-04-23 11:09:08 -0700 | [diff] [blame] | 1793 | static int e1000_get_coalesce(struct net_device *netdev, |
| 1794 | struct ethtool_coalesce *ec) |
| 1795 | { |
| 1796 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 1797 | |
| 1798 | if (adapter->itr_setting <= 3) |
| 1799 | ec->rx_coalesce_usecs = adapter->itr_setting; |
| 1800 | else |
| 1801 | ec->rx_coalesce_usecs = 1000000 / adapter->itr_setting; |
| 1802 | |
| 1803 | return 0; |
| 1804 | } |
| 1805 | |
| 1806 | static int e1000_set_coalesce(struct net_device *netdev, |
| 1807 | struct ethtool_coalesce *ec) |
| 1808 | { |
| 1809 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 1810 | struct e1000_hw *hw = &adapter->hw; |
| 1811 | |
| 1812 | if ((ec->rx_coalesce_usecs > E1000_MAX_ITR_USECS) || |
| 1813 | ((ec->rx_coalesce_usecs > 3) && |
| 1814 | (ec->rx_coalesce_usecs < E1000_MIN_ITR_USECS)) || |
| 1815 | (ec->rx_coalesce_usecs == 2)) |
| 1816 | return -EINVAL; |
| 1817 | |
| 1818 | if (ec->rx_coalesce_usecs <= 3) { |
| 1819 | adapter->itr = 20000; |
| 1820 | adapter->itr_setting = ec->rx_coalesce_usecs; |
| 1821 | } else { |
| 1822 | adapter->itr = (1000000 / ec->rx_coalesce_usecs); |
| 1823 | adapter->itr_setting = adapter->itr & ~3; |
| 1824 | } |
| 1825 | |
| 1826 | if (adapter->itr_setting != 0) |
| 1827 | ew32(ITR, 1000000000 / (adapter->itr * 256)); |
| 1828 | else |
| 1829 | ew32(ITR, 0); |
| 1830 | |
| 1831 | return 0; |
| 1832 | } |
| 1833 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1834 | static int e1000_nway_reset(struct net_device *netdev) |
| 1835 | { |
| 1836 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 1837 | if (netif_running(netdev)) |
| 1838 | e1000e_reinit_locked(adapter); |
| 1839 | return 0; |
| 1840 | } |
| 1841 | |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1842 | static void e1000_get_ethtool_stats(struct net_device *netdev, |
| 1843 | struct ethtool_stats *stats, |
| 1844 | u64 *data) |
| 1845 | { |
| 1846 | struct e1000_adapter *adapter = netdev_priv(netdev); |
| 1847 | int i; |
| 1848 | |
| 1849 | e1000e_update_stats(adapter); |
| 1850 | for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) { |
| 1851 | char *p = (char *)adapter+e1000_gstrings_stats[i].stat_offset; |
| 1852 | data[i] = (e1000_gstrings_stats[i].sizeof_stat == |
| 1853 | sizeof(u64)) ? *(u64 *)p : *(u32 *)p; |
| 1854 | } |
| 1855 | } |
| 1856 | |
| 1857 | static void e1000_get_strings(struct net_device *netdev, u32 stringset, |
| 1858 | u8 *data) |
| 1859 | { |
| 1860 | u8 *p = data; |
| 1861 | int i; |
| 1862 | |
| 1863 | switch (stringset) { |
| 1864 | case ETH_SS_TEST: |
Bruce Allan | ad68076 | 2008-03-28 09:15:03 -0700 | [diff] [blame] | 1865 | memcpy(data, *e1000_gstrings_test, sizeof(e1000_gstrings_test)); |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1866 | break; |
| 1867 | case ETH_SS_STATS: |
| 1868 | for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) { |
| 1869 | memcpy(p, e1000_gstrings_stats[i].stat_string, |
| 1870 | ETH_GSTRING_LEN); |
| 1871 | p += ETH_GSTRING_LEN; |
| 1872 | } |
| 1873 | break; |
| 1874 | } |
| 1875 | } |
| 1876 | |
| 1877 | static const struct ethtool_ops e1000_ethtool_ops = { |
| 1878 | .get_settings = e1000_get_settings, |
| 1879 | .set_settings = e1000_set_settings, |
| 1880 | .get_drvinfo = e1000_get_drvinfo, |
| 1881 | .get_regs_len = e1000_get_regs_len, |
| 1882 | .get_regs = e1000_get_regs, |
| 1883 | .get_wol = e1000_get_wol, |
| 1884 | .set_wol = e1000_set_wol, |
| 1885 | .get_msglevel = e1000_get_msglevel, |
| 1886 | .set_msglevel = e1000_set_msglevel, |
| 1887 | .nway_reset = e1000_nway_reset, |
Auke Kok | 369d742 | 2007-10-15 14:30:59 -0700 | [diff] [blame] | 1888 | .get_link = e1000_get_link, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1889 | .get_eeprom_len = e1000_get_eeprom_len, |
| 1890 | .get_eeprom = e1000_get_eeprom, |
| 1891 | .set_eeprom = e1000_set_eeprom, |
| 1892 | .get_ringparam = e1000_get_ringparam, |
| 1893 | .set_ringparam = e1000_set_ringparam, |
| 1894 | .get_pauseparam = e1000_get_pauseparam, |
| 1895 | .set_pauseparam = e1000_set_pauseparam, |
| 1896 | .get_rx_csum = e1000_get_rx_csum, |
| 1897 | .set_rx_csum = e1000_set_rx_csum, |
| 1898 | .get_tx_csum = e1000_get_tx_csum, |
| 1899 | .set_tx_csum = e1000_set_tx_csum, |
| 1900 | .get_sg = ethtool_op_get_sg, |
| 1901 | .set_sg = ethtool_op_set_sg, |
| 1902 | .get_tso = ethtool_op_get_tso, |
| 1903 | .set_tso = e1000_set_tso, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1904 | .self_test = e1000_diag_test, |
| 1905 | .get_strings = e1000_get_strings, |
| 1906 | .phys_id = e1000_phys_id, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1907 | .get_ethtool_stats = e1000_get_ethtool_stats, |
Jeff Garzik | b9f2c04 | 2007-10-03 18:07:32 -0700 | [diff] [blame] | 1908 | .get_sset_count = e1000e_get_sset_count, |
Auke Kok | de5b307 | 2008-04-23 11:09:08 -0700 | [diff] [blame] | 1909 | .get_coalesce = e1000_get_coalesce, |
| 1910 | .set_coalesce = e1000_set_coalesce, |
Auke Kok | bc7f75f | 2007-09-17 12:30:59 -0700 | [diff] [blame] | 1911 | }; |
| 1912 | |
| 1913 | void e1000e_set_ethtool_ops(struct net_device *netdev) |
| 1914 | { |
| 1915 | SET_ETHTOOL_OPS(netdev, &e1000_ethtool_ops); |
| 1916 | } |