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