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