On Tue, Nov 06, 2007 at 02:33:53AM -0800, akpm@linux-foundation.org wrote:
[mmotm.git] / drivers / net / e1000 / e1000_ethtool.c
blobe25b339eb5bd9538ab9cd11ecb6651e97faf4b6a
1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2006 Intel Corporation.
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.
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.
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.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
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
27 *******************************************************************************/
29 /* ethtool support for e1000 */
31 #include "e1000.h"
32 #include <asm/uaccess.h>
34 struct e1000_stats {
35 char stat_string[ETH_GSTRING_LEN];
36 int sizeof_stat;
37 int stat_offset;
40 #define E1000_STAT(m) FIELD_SIZEOF(struct e1000_adapter, m), \
41 offsetof(struct e1000_adapter, m)
42 #define E1000_NETDEV_STAT(m) FIELD_SIZEOF(struct net_device, m), \
43 offsetof(struct net_device, m)
44 static const struct e1000_stats e1000_gstrings_stats[] = {
45 { "rx_packets", E1000_STAT(stats.gprc) },
46 { "tx_packets", E1000_STAT(stats.gptc) },
47 { "rx_bytes", E1000_STAT(stats.gorcl) },
48 { "tx_bytes", E1000_STAT(stats.gotcl) },
49 { "rx_broadcast", E1000_STAT(stats.bprc) },
50 { "tx_broadcast", E1000_STAT(stats.bptc) },
51 { "rx_multicast", E1000_STAT(stats.mprc) },
52 { "tx_multicast", E1000_STAT(stats.mptc) },
53 { "rx_errors", E1000_STAT(stats.rxerrc) },
54 { "tx_errors", E1000_STAT(stats.txerrc) },
55 { "tx_dropped", E1000_NETDEV_STAT(stats.tx_dropped) },
56 { "multicast", E1000_STAT(stats.mprc) },
57 { "collisions", E1000_STAT(stats.colc) },
58 { "rx_length_errors", E1000_STAT(stats.rlerrc) },
59 { "rx_over_errors", E1000_NETDEV_STAT(stats.rx_over_errors) },
60 { "rx_crc_errors", E1000_STAT(stats.crcerrs) },
61 { "rx_frame_errors", E1000_NETDEV_STAT(stats.rx_frame_errors) },
62 { "rx_no_buffer_count", E1000_STAT(stats.rnbc) },
63 { "rx_missed_errors", E1000_STAT(stats.mpc) },
64 { "tx_aborted_errors", E1000_STAT(stats.ecol) },
65 { "tx_carrier_errors", E1000_STAT(stats.tncrs) },
66 { "tx_fifo_errors", E1000_NETDEV_STAT(stats.tx_fifo_errors) },
67 { "tx_heartbeat_errors", E1000_NETDEV_STAT(stats.tx_heartbeat_errors) },
68 { "tx_window_errors", E1000_STAT(stats.latecol) },
69 { "tx_abort_late_coll", E1000_STAT(stats.latecol) },
70 { "tx_deferred_ok", E1000_STAT(stats.dc) },
71 { "tx_single_coll_ok", E1000_STAT(stats.scc) },
72 { "tx_multi_coll_ok", E1000_STAT(stats.mcc) },
73 { "tx_timeout_count", E1000_STAT(tx_timeout_count) },
74 { "tx_restart_queue", E1000_STAT(restart_queue) },
75 { "rx_long_length_errors", E1000_STAT(stats.roc) },
76 { "rx_short_length_errors", E1000_STAT(stats.ruc) },
77 { "rx_align_errors", E1000_STAT(stats.algnerrc) },
78 { "tx_tcp_seg_good", E1000_STAT(stats.tsctc) },
79 { "tx_tcp_seg_failed", E1000_STAT(stats.tsctfc) },
80 { "rx_flow_control_xon", E1000_STAT(stats.xonrxc) },
81 { "rx_flow_control_xoff", E1000_STAT(stats.xoffrxc) },
82 { "tx_flow_control_xon", E1000_STAT(stats.xontxc) },
83 { "tx_flow_control_xoff", E1000_STAT(stats.xofftxc) },
84 { "rx_long_byte_count", E1000_STAT(stats.gorcl) },
85 { "rx_csum_offload_good", E1000_STAT(hw_csum_good) },
86 { "rx_csum_offload_errors", E1000_STAT(hw_csum_err) },
87 { "alloc_rx_buff_failed", E1000_STAT(alloc_rx_buff_failed) },
88 { "tx_smbus", E1000_STAT(stats.mgptc) },
89 { "rx_smbus", E1000_STAT(stats.mgprc) },
90 { "dropped_smbus", E1000_STAT(stats.mgpdc) },
93 #define E1000_QUEUE_STATS_LEN 0
94 #define E1000_GLOBAL_STATS_LEN ARRAY_SIZE(e1000_gstrings_stats)
95 #define E1000_STATS_LEN (E1000_GLOBAL_STATS_LEN + E1000_QUEUE_STATS_LEN)
96 static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = {
97 "Register test (offline)", "Eeprom test (offline)",
98 "Interrupt test (offline)", "Loopback test (offline)",
99 "Link test (on/offline)"
101 #define E1000_TEST_LEN ARRAY_SIZE(e1000_gstrings_test)
103 static int e1000_get_settings(struct net_device *netdev,
104 struct ethtool_cmd *ecmd)
106 struct e1000_adapter *adapter = netdev_priv(netdev);
107 struct e1000_hw *hw = &adapter->hw;
109 if (hw->media_type == e1000_media_type_copper) {
111 ecmd->supported = (SUPPORTED_10baseT_Half |
112 SUPPORTED_10baseT_Full |
113 SUPPORTED_100baseT_Half |
114 SUPPORTED_100baseT_Full |
115 SUPPORTED_1000baseT_Full|
116 SUPPORTED_Autoneg |
117 SUPPORTED_TP);
118 ecmd->advertising = ADVERTISED_TP;
120 if (hw->autoneg == 1) {
121 ecmd->advertising |= ADVERTISED_Autoneg;
122 /* the e1000 autoneg seems to match ethtool nicely */
123 ecmd->advertising |= hw->autoneg_advertised;
126 ecmd->port = PORT_TP;
127 ecmd->phy_address = hw->phy_addr;
129 if (hw->mac_type == e1000_82543)
130 ecmd->transceiver = XCVR_EXTERNAL;
131 else
132 ecmd->transceiver = XCVR_INTERNAL;
134 } else {
135 ecmd->supported = (SUPPORTED_1000baseT_Full |
136 SUPPORTED_FIBRE |
137 SUPPORTED_Autoneg);
139 ecmd->advertising = (ADVERTISED_1000baseT_Full |
140 ADVERTISED_FIBRE |
141 ADVERTISED_Autoneg);
143 ecmd->port = PORT_FIBRE;
145 if (hw->mac_type >= e1000_82545)
146 ecmd->transceiver = XCVR_INTERNAL;
147 else
148 ecmd->transceiver = XCVR_EXTERNAL;
151 if (er32(STATUS) & E1000_STATUS_LU) {
153 e1000_get_speed_and_duplex(hw, &adapter->link_speed,
154 &adapter->link_duplex);
155 ecmd->speed = adapter->link_speed;
157 /* unfortunatly FULL_DUPLEX != DUPLEX_FULL
158 * and HALF_DUPLEX != DUPLEX_HALF */
160 if (adapter->link_duplex == FULL_DUPLEX)
161 ecmd->duplex = DUPLEX_FULL;
162 else
163 ecmd->duplex = DUPLEX_HALF;
164 } else {
165 ecmd->speed = -1;
166 ecmd->duplex = -1;
169 ecmd->autoneg = ((hw->media_type == e1000_media_type_fiber) ||
170 hw->autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE;
171 return 0;
174 static int e1000_set_settings(struct net_device *netdev,
175 struct ethtool_cmd *ecmd)
177 struct e1000_adapter *adapter = netdev_priv(netdev);
178 struct e1000_hw *hw = &adapter->hw;
180 while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
181 msleep(1);
183 if (ecmd->autoneg == AUTONEG_ENABLE) {
184 hw->autoneg = 1;
185 if (hw->media_type == e1000_media_type_fiber)
186 hw->autoneg_advertised = ADVERTISED_1000baseT_Full |
187 ADVERTISED_FIBRE |
188 ADVERTISED_Autoneg;
189 else
190 hw->autoneg_advertised = ecmd->advertising |
191 ADVERTISED_TP |
192 ADVERTISED_Autoneg;
193 ecmd->advertising = hw->autoneg_advertised;
194 } else
195 if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) {
196 clear_bit(__E1000_RESETTING, &adapter->flags);
197 return -EINVAL;
200 /* reset the link */
202 if (netif_running(adapter->netdev)) {
203 e1000_down(adapter);
204 e1000_up(adapter);
205 } else
206 e1000_reset(adapter);
208 clear_bit(__E1000_RESETTING, &adapter->flags);
209 return 0;
212 static void e1000_get_pauseparam(struct net_device *netdev,
213 struct ethtool_pauseparam *pause)
215 struct e1000_adapter *adapter = netdev_priv(netdev);
216 struct e1000_hw *hw = &adapter->hw;
218 pause->autoneg =
219 (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
221 if (hw->fc == E1000_FC_RX_PAUSE)
222 pause->rx_pause = 1;
223 else if (hw->fc == E1000_FC_TX_PAUSE)
224 pause->tx_pause = 1;
225 else if (hw->fc == E1000_FC_FULL) {
226 pause->rx_pause = 1;
227 pause->tx_pause = 1;
231 static int e1000_set_pauseparam(struct net_device *netdev,
232 struct ethtool_pauseparam *pause)
234 struct e1000_adapter *adapter = netdev_priv(netdev);
235 struct e1000_hw *hw = &adapter->hw;
236 int retval = 0;
238 adapter->fc_autoneg = pause->autoneg;
240 while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
241 msleep(1);
243 if (pause->rx_pause && pause->tx_pause)
244 hw->fc = E1000_FC_FULL;
245 else if (pause->rx_pause && !pause->tx_pause)
246 hw->fc = E1000_FC_RX_PAUSE;
247 else if (!pause->rx_pause && pause->tx_pause)
248 hw->fc = E1000_FC_TX_PAUSE;
249 else if (!pause->rx_pause && !pause->tx_pause)
250 hw->fc = E1000_FC_NONE;
252 hw->original_fc = hw->fc;
254 if (adapter->fc_autoneg == AUTONEG_ENABLE) {
255 if (netif_running(adapter->netdev)) {
256 e1000_down(adapter);
257 e1000_up(adapter);
258 } else
259 e1000_reset(adapter);
260 } else
261 retval = ((hw->media_type == e1000_media_type_fiber) ?
262 e1000_setup_link(hw) : e1000_force_mac_fc(hw));
264 clear_bit(__E1000_RESETTING, &adapter->flags);
265 return retval;
268 static u32 e1000_get_rx_csum(struct net_device *netdev)
270 struct e1000_adapter *adapter = netdev_priv(netdev);
271 return adapter->rx_csum;
274 static int e1000_set_rx_csum(struct net_device *netdev, u32 data)
276 struct e1000_adapter *adapter = netdev_priv(netdev);
277 adapter->rx_csum = data;
279 if (netif_running(netdev))
280 e1000_reinit_locked(adapter);
281 else
282 e1000_reset(adapter);
283 return 0;
286 static u32 e1000_get_tx_csum(struct net_device *netdev)
288 return (netdev->features & NETIF_F_HW_CSUM) != 0;
291 static int e1000_set_tx_csum(struct net_device *netdev, u32 data)
293 struct e1000_adapter *adapter = netdev_priv(netdev);
294 struct e1000_hw *hw = &adapter->hw;
296 if (hw->mac_type < e1000_82543) {
297 if (!data)
298 return -EINVAL;
299 return 0;
302 if (data)
303 netdev->features |= NETIF_F_HW_CSUM;
304 else
305 netdev->features &= ~NETIF_F_HW_CSUM;
307 return 0;
310 static int e1000_set_tso(struct net_device *netdev, u32 data)
312 struct e1000_adapter *adapter = netdev_priv(netdev);
313 struct e1000_hw *hw = &adapter->hw;
315 if ((hw->mac_type < e1000_82544) ||
316 (hw->mac_type == e1000_82547))
317 return data ? -EINVAL : 0;
319 if (data)
320 netdev->features |= NETIF_F_TSO;
321 else
322 netdev->features &= ~NETIF_F_TSO;
324 netdev->features &= ~NETIF_F_TSO6;
326 DPRINTK(PROBE, INFO, "TSO is %s\n", data ? "Enabled" : "Disabled");
327 adapter->tso_force = true;
328 return 0;
331 static u32 e1000_get_msglevel(struct net_device *netdev)
333 struct e1000_adapter *adapter = netdev_priv(netdev);
334 return adapter->msg_enable;
337 static void e1000_set_msglevel(struct net_device *netdev, u32 data)
339 struct e1000_adapter *adapter = netdev_priv(netdev);
340 adapter->msg_enable = data;
343 static int e1000_get_regs_len(struct net_device *netdev)
345 #define E1000_REGS_LEN 32
346 return E1000_REGS_LEN * sizeof(u32);
349 static void e1000_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
350 void *p)
352 struct e1000_adapter *adapter = netdev_priv(netdev);
353 struct e1000_hw *hw = &adapter->hw;
354 u32 *regs_buff = p;
355 u16 phy_data;
357 memset(p, 0, E1000_REGS_LEN * sizeof(u32));
359 regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id;
361 regs_buff[0] = er32(CTRL);
362 regs_buff[1] = er32(STATUS);
364 regs_buff[2] = er32(RCTL);
365 regs_buff[3] = er32(RDLEN);
366 regs_buff[4] = er32(RDH);
367 regs_buff[5] = er32(RDT);
368 regs_buff[6] = er32(RDTR);
370 regs_buff[7] = er32(TCTL);
371 regs_buff[8] = er32(TDLEN);
372 regs_buff[9] = er32(TDH);
373 regs_buff[10] = er32(TDT);
374 regs_buff[11] = er32(TIDV);
376 regs_buff[12] = hw->phy_type; /* PHY type (IGP=1, M88=0) */
377 if (hw->phy_type == e1000_phy_igp) {
378 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
379 IGP01E1000_PHY_AGC_A);
380 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_A &
381 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
382 regs_buff[13] = (u32)phy_data; /* cable length */
383 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
384 IGP01E1000_PHY_AGC_B);
385 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_B &
386 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
387 regs_buff[14] = (u32)phy_data; /* cable length */
388 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
389 IGP01E1000_PHY_AGC_C);
390 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_C &
391 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
392 regs_buff[15] = (u32)phy_data; /* cable length */
393 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
394 IGP01E1000_PHY_AGC_D);
395 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_D &
396 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
397 regs_buff[16] = (u32)phy_data; /* cable length */
398 regs_buff[17] = 0; /* extended 10bt distance (not needed) */
399 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0);
400 e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS &
401 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
402 regs_buff[18] = (u32)phy_data; /* cable polarity */
403 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
404 IGP01E1000_PHY_PCS_INIT_REG);
405 e1000_read_phy_reg(hw, IGP01E1000_PHY_PCS_INIT_REG &
406 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
407 regs_buff[19] = (u32)phy_data; /* cable polarity */
408 regs_buff[20] = 0; /* polarity correction enabled (always) */
409 regs_buff[22] = 0; /* phy receive errors (unavailable) */
410 regs_buff[23] = regs_buff[18]; /* mdix mode */
411 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0);
412 } else {
413 e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
414 regs_buff[13] = (u32)phy_data; /* cable length */
415 regs_buff[14] = 0; /* Dummy (to align w/ IGP phy reg dump) */
416 regs_buff[15] = 0; /* Dummy (to align w/ IGP phy reg dump) */
417 regs_buff[16] = 0; /* Dummy (to align w/ IGP phy reg dump) */
418 e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
419 regs_buff[17] = (u32)phy_data; /* extended 10bt distance */
420 regs_buff[18] = regs_buff[13]; /* cable polarity */
421 regs_buff[19] = 0; /* Dummy (to align w/ IGP phy reg dump) */
422 regs_buff[20] = regs_buff[17]; /* polarity correction */
423 /* phy receive errors */
424 regs_buff[22] = adapter->phy_stats.receive_errors;
425 regs_buff[23] = regs_buff[13]; /* mdix mode */
427 regs_buff[21] = adapter->phy_stats.idle_errors; /* phy idle errors */
428 e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data);
429 regs_buff[24] = (u32)phy_data; /* phy local receiver status */
430 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */
431 if (hw->mac_type >= e1000_82540 &&
432 hw->media_type == e1000_media_type_copper) {
433 regs_buff[26] = er32(MANC);
437 static int e1000_get_eeprom_len(struct net_device *netdev)
439 struct e1000_adapter *adapter = netdev_priv(netdev);
440 struct e1000_hw *hw = &adapter->hw;
442 return hw->eeprom.word_size * 2;
445 static int e1000_get_eeprom(struct net_device *netdev,
446 struct ethtool_eeprom *eeprom, u8 *bytes)
448 struct e1000_adapter *adapter = netdev_priv(netdev);
449 struct e1000_hw *hw = &adapter->hw;
450 u16 *eeprom_buff;
451 int first_word, last_word;
452 int ret_val = 0;
453 u16 i;
455 if (eeprom->len == 0)
456 return -EINVAL;
458 eeprom->magic = hw->vendor_id | (hw->device_id << 16);
460 first_word = eeprom->offset >> 1;
461 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
463 eeprom_buff = kmalloc(sizeof(u16) *
464 (last_word - first_word + 1), GFP_KERNEL);
465 if (!eeprom_buff)
466 return -ENOMEM;
468 if (hw->eeprom.type == e1000_eeprom_spi)
469 ret_val = e1000_read_eeprom(hw, first_word,
470 last_word - first_word + 1,
471 eeprom_buff);
472 else {
473 for (i = 0; i < last_word - first_word + 1; i++) {
474 ret_val = e1000_read_eeprom(hw, first_word + i, 1,
475 &eeprom_buff[i]);
476 if (ret_val)
477 break;
481 /* Device's eeprom is always little-endian, word addressable */
482 for (i = 0; i < last_word - first_word + 1; i++)
483 le16_to_cpus(&eeprom_buff[i]);
485 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1),
486 eeprom->len);
487 kfree(eeprom_buff);
489 return ret_val;
492 static int e1000_set_eeprom(struct net_device *netdev,
493 struct ethtool_eeprom *eeprom, u8 *bytes)
495 struct e1000_adapter *adapter = netdev_priv(netdev);
496 struct e1000_hw *hw = &adapter->hw;
497 u16 *eeprom_buff;
498 void *ptr;
499 int max_len, first_word, last_word, ret_val = 0;
500 u16 i;
502 if (eeprom->len == 0)
503 return -EOPNOTSUPP;
505 if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16)))
506 return -EFAULT;
508 max_len = hw->eeprom.word_size * 2;
510 first_word = eeprom->offset >> 1;
511 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
512 eeprom_buff = kmalloc(max_len, GFP_KERNEL);
513 if (!eeprom_buff)
514 return -ENOMEM;
516 ptr = (void *)eeprom_buff;
518 if (eeprom->offset & 1) {
519 /* need read/modify/write of first changed EEPROM word */
520 /* only the second byte of the word is being modified */
521 ret_val = e1000_read_eeprom(hw, first_word, 1,
522 &eeprom_buff[0]);
523 ptr++;
525 if (((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) {
526 /* need read/modify/write of last changed EEPROM word */
527 /* only the first byte of the word is being modified */
528 ret_val = e1000_read_eeprom(hw, last_word, 1,
529 &eeprom_buff[last_word - first_word]);
532 /* Device's eeprom is always little-endian, word addressable */
533 for (i = 0; i < last_word - first_word + 1; i++)
534 le16_to_cpus(&eeprom_buff[i]);
536 memcpy(ptr, bytes, eeprom->len);
538 for (i = 0; i < last_word - first_word + 1; i++)
539 eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]);
541 ret_val = e1000_write_eeprom(hw, first_word,
542 last_word - first_word + 1, eeprom_buff);
544 /* Update the checksum over the first part of the EEPROM if needed */
545 if ((ret_val == 0) && (first_word <= EEPROM_CHECKSUM_REG))
546 e1000_update_eeprom_checksum(hw);
548 kfree(eeprom_buff);
549 return ret_val;
552 static void e1000_get_drvinfo(struct net_device *netdev,
553 struct ethtool_drvinfo *drvinfo)
555 struct e1000_adapter *adapter = netdev_priv(netdev);
556 char firmware_version[32];
558 strncpy(drvinfo->driver, e1000_driver_name, 32);
559 strncpy(drvinfo->version, e1000_driver_version, 32);
561 sprintf(firmware_version, "N/A");
562 strncpy(drvinfo->fw_version, firmware_version, 32);
563 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
564 drvinfo->regdump_len = e1000_get_regs_len(netdev);
565 drvinfo->eedump_len = e1000_get_eeprom_len(netdev);
568 static void e1000_get_ringparam(struct net_device *netdev,
569 struct ethtool_ringparam *ring)
571 struct e1000_adapter *adapter = netdev_priv(netdev);
572 struct e1000_hw *hw = &adapter->hw;
573 e1000_mac_type mac_type = hw->mac_type;
574 struct e1000_tx_ring *txdr = adapter->tx_ring;
575 struct e1000_rx_ring *rxdr = adapter->rx_ring;
577 ring->rx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_RXD :
578 E1000_MAX_82544_RXD;
579 ring->tx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_TXD :
580 E1000_MAX_82544_TXD;
581 ring->rx_mini_max_pending = 0;
582 ring->rx_jumbo_max_pending = 0;
583 ring->rx_pending = rxdr->count;
584 ring->tx_pending = txdr->count;
585 ring->rx_mini_pending = 0;
586 ring->rx_jumbo_pending = 0;
589 static int e1000_set_ringparam(struct net_device *netdev,
590 struct ethtool_ringparam *ring)
592 struct e1000_adapter *adapter = netdev_priv(netdev);
593 struct e1000_hw *hw = &adapter->hw;
594 e1000_mac_type mac_type = hw->mac_type;
595 struct e1000_tx_ring *txdr, *tx_old;
596 struct e1000_rx_ring *rxdr, *rx_old;
597 int i, err;
599 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
600 return -EINVAL;
602 while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
603 msleep(1);
605 if (netif_running(adapter->netdev))
606 e1000_down(adapter);
608 tx_old = adapter->tx_ring;
609 rx_old = adapter->rx_ring;
611 err = -ENOMEM;
612 txdr = kcalloc(adapter->num_tx_queues, sizeof(struct e1000_tx_ring), GFP_KERNEL);
613 if (!txdr)
614 goto err_alloc_tx;
616 rxdr = kcalloc(adapter->num_rx_queues, sizeof(struct e1000_rx_ring), GFP_KERNEL);
617 if (!rxdr)
618 goto err_alloc_rx;
620 adapter->tx_ring = txdr;
621 adapter->rx_ring = rxdr;
623 rxdr->count = max(ring->rx_pending,(u32)E1000_MIN_RXD);
624 rxdr->count = min(rxdr->count,(u32)(mac_type < e1000_82544 ?
625 E1000_MAX_RXD : E1000_MAX_82544_RXD));
626 rxdr->count = ALIGN(rxdr->count, REQ_RX_DESCRIPTOR_MULTIPLE);
628 txdr->count = max(ring->tx_pending,(u32)E1000_MIN_TXD);
629 txdr->count = min(txdr->count,(u32)(mac_type < e1000_82544 ?
630 E1000_MAX_TXD : E1000_MAX_82544_TXD));
631 txdr->count = ALIGN(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
633 for (i = 0; i < adapter->num_tx_queues; i++)
634 txdr[i].count = txdr->count;
635 for (i = 0; i < adapter->num_rx_queues; i++)
636 rxdr[i].count = rxdr->count;
638 if (netif_running(adapter->netdev)) {
639 /* Try to get new resources before deleting old */
640 err = e1000_setup_all_rx_resources(adapter);
641 if (err)
642 goto err_setup_rx;
643 err = e1000_setup_all_tx_resources(adapter);
644 if (err)
645 goto err_setup_tx;
647 /* save the new, restore the old in order to free it,
648 * then restore the new back again */
650 adapter->rx_ring = rx_old;
651 adapter->tx_ring = tx_old;
652 e1000_free_all_rx_resources(adapter);
653 e1000_free_all_tx_resources(adapter);
654 kfree(tx_old);
655 kfree(rx_old);
656 adapter->rx_ring = rxdr;
657 adapter->tx_ring = txdr;
658 err = e1000_up(adapter);
659 if (err)
660 goto err_setup;
663 clear_bit(__E1000_RESETTING, &adapter->flags);
664 return 0;
665 err_setup_tx:
666 e1000_free_all_rx_resources(adapter);
667 err_setup_rx:
668 adapter->rx_ring = rx_old;
669 adapter->tx_ring = tx_old;
670 kfree(rxdr);
671 err_alloc_rx:
672 kfree(txdr);
673 err_alloc_tx:
674 e1000_up(adapter);
675 err_setup:
676 clear_bit(__E1000_RESETTING, &adapter->flags);
677 return err;
680 static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data, int reg,
681 u32 mask, u32 write)
683 struct e1000_hw *hw = &adapter->hw;
684 static const u32 test[] =
685 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
686 u8 __iomem *address = hw->hw_addr + reg;
687 u32 read;
688 int i;
690 for (i = 0; i < ARRAY_SIZE(test); i++) {
691 writel(write & test[i], address);
692 read = readl(address);
693 if (read != (write & test[i] & mask)) {
694 DPRINTK(DRV, ERR, "pattern test reg %04X failed: "
695 "got 0x%08X expected 0x%08X\n",
696 reg, read, (write & test[i] & mask));
697 *data = reg;
698 return true;
701 return false;
704 static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data, int reg,
705 u32 mask, u32 write)
707 struct e1000_hw *hw = &adapter->hw;
708 u8 __iomem *address = hw->hw_addr + reg;
709 u32 read;
711 writel(write & mask, address);
712 read = readl(address);
713 if ((read & mask) != (write & mask)) {
714 DPRINTK(DRV, ERR, "set/check reg %04X test failed: "
715 "got 0x%08X expected 0x%08X\n",
716 reg, (read & mask), (write & mask));
717 *data = reg;
718 return true;
720 return false;
723 #define REG_PATTERN_TEST(reg, mask, write) \
724 do { \
725 if (reg_pattern_test(adapter, data, \
726 (hw->mac_type >= e1000_82543) \
727 ? E1000_##reg : E1000_82542_##reg, \
728 mask, write)) \
729 return 1; \
730 } while (0)
732 #define REG_SET_AND_CHECK(reg, mask, write) \
733 do { \
734 if (reg_set_and_check(adapter, data, \
735 (hw->mac_type >= e1000_82543) \
736 ? E1000_##reg : E1000_82542_##reg, \
737 mask, write)) \
738 return 1; \
739 } while (0)
741 static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
743 u32 value, before, after;
744 u32 i, toggle;
745 struct e1000_hw *hw = &adapter->hw;
747 /* The status register is Read Only, so a write should fail.
748 * Some bits that get toggled are ignored.
751 /* there are several bits on newer hardware that are r/w */
752 toggle = 0xFFFFF833;
754 before = er32(STATUS);
755 value = (er32(STATUS) & toggle);
756 ew32(STATUS, toggle);
757 after = er32(STATUS) & toggle;
758 if (value != after) {
759 DPRINTK(DRV, ERR, "failed STATUS register test got: "
760 "0x%08X expected: 0x%08X\n", after, value);
761 *data = 1;
762 return 1;
764 /* restore previous status */
765 ew32(STATUS, before);
767 REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
768 REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF);
769 REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF);
770 REG_PATTERN_TEST(VET, 0x0000FFFF, 0xFFFFFFFF);
772 REG_PATTERN_TEST(RDTR, 0x0000FFFF, 0xFFFFFFFF);
773 REG_PATTERN_TEST(RDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
774 REG_PATTERN_TEST(RDLEN, 0x000FFF80, 0x000FFFFF);
775 REG_PATTERN_TEST(RDH, 0x0000FFFF, 0x0000FFFF);
776 REG_PATTERN_TEST(RDT, 0x0000FFFF, 0x0000FFFF);
777 REG_PATTERN_TEST(FCRTH, 0x0000FFF8, 0x0000FFF8);
778 REG_PATTERN_TEST(FCTTV, 0x0000FFFF, 0x0000FFFF);
779 REG_PATTERN_TEST(TIPG, 0x3FFFFFFF, 0x3FFFFFFF);
780 REG_PATTERN_TEST(TDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
781 REG_PATTERN_TEST(TDLEN, 0x000FFF80, 0x000FFFFF);
783 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000);
785 before = 0x06DFB3FE;
786 REG_SET_AND_CHECK(RCTL, before, 0x003FFFFB);
787 REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000);
789 if (hw->mac_type >= e1000_82543) {
791 REG_SET_AND_CHECK(RCTL, before, 0xFFFFFFFF);
792 REG_PATTERN_TEST(RDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
793 REG_PATTERN_TEST(TXCW, 0xC000FFFF, 0x0000FFFF);
794 REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
795 REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF);
796 value = E1000_RAR_ENTRIES;
797 for (i = 0; i < value; i++) {
798 REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF,
799 0xFFFFFFFF);
802 } else {
804 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x01FFFFFF);
805 REG_PATTERN_TEST(RDBAL, 0xFFFFF000, 0xFFFFFFFF);
806 REG_PATTERN_TEST(TXCW, 0x0000FFFF, 0x0000FFFF);
807 REG_PATTERN_TEST(TDBAL, 0xFFFFF000, 0xFFFFFFFF);
811 value = E1000_MC_TBL_SIZE;
812 for (i = 0; i < value; i++)
813 REG_PATTERN_TEST(MTA + (i << 2), 0xFFFFFFFF, 0xFFFFFFFF);
815 *data = 0;
816 return 0;
819 static int e1000_eeprom_test(struct e1000_adapter *adapter, u64 *data)
821 struct e1000_hw *hw = &adapter->hw;
822 u16 temp;
823 u16 checksum = 0;
824 u16 i;
826 *data = 0;
827 /* Read and add up the contents of the EEPROM */
828 for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) {
829 if ((e1000_read_eeprom(hw, i, 1, &temp)) < 0) {
830 *data = 1;
831 break;
833 checksum += temp;
836 /* If Checksum is not Correct return error else test passed */
837 if ((checksum != (u16)EEPROM_SUM) && !(*data))
838 *data = 2;
840 return *data;
843 static irqreturn_t e1000_test_intr(int irq, void *data)
845 struct net_device *netdev = (struct net_device *)data;
846 struct e1000_adapter *adapter = netdev_priv(netdev);
847 struct e1000_hw *hw = &adapter->hw;
849 adapter->test_icr |= er32(ICR);
851 return IRQ_HANDLED;
854 static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
856 struct net_device *netdev = adapter->netdev;
857 u32 mask, i = 0;
858 bool shared_int = true;
859 u32 irq = adapter->pdev->irq;
860 struct e1000_hw *hw = &adapter->hw;
862 *data = 0;
864 /* NOTE: we don't test MSI interrupts here, yet */
865 /* Hook up test interrupt handler just for this test */
866 if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED, netdev->name,
867 netdev))
868 shared_int = false;
869 else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED,
870 netdev->name, netdev)) {
871 *data = 1;
872 return -1;
874 DPRINTK(HW, INFO, "testing %s interrupt\n",
875 (shared_int ? "shared" : "unshared"));
877 /* Disable all the interrupts */
878 ew32(IMC, 0xFFFFFFFF);
879 msleep(10);
881 /* Test each interrupt */
882 for (; i < 10; i++) {
884 /* Interrupt to test */
885 mask = 1 << i;
887 if (!shared_int) {
888 /* Disable the interrupt to be reported in
889 * the cause register and then force the same
890 * interrupt and see if one gets posted. If
891 * an interrupt was posted to the bus, the
892 * test failed.
894 adapter->test_icr = 0;
895 ew32(IMC, mask);
896 ew32(ICS, mask);
897 msleep(10);
899 if (adapter->test_icr & mask) {
900 *data = 3;
901 break;
905 /* Enable the interrupt to be reported in
906 * the cause register and then force the same
907 * interrupt and see if one gets posted. If
908 * an interrupt was not posted to the bus, the
909 * test failed.
911 adapter->test_icr = 0;
912 ew32(IMS, mask);
913 ew32(ICS, mask);
914 msleep(10);
916 if (!(adapter->test_icr & mask)) {
917 *data = 4;
918 break;
921 if (!shared_int) {
922 /* Disable the other interrupts to be reported in
923 * the cause register and then force the other
924 * interrupts and see if any get posted. If
925 * an interrupt was posted to the bus, the
926 * test failed.
928 adapter->test_icr = 0;
929 ew32(IMC, ~mask & 0x00007FFF);
930 ew32(ICS, ~mask & 0x00007FFF);
931 msleep(10);
933 if (adapter->test_icr) {
934 *data = 5;
935 break;
940 /* Disable all the interrupts */
941 ew32(IMC, 0xFFFFFFFF);
942 msleep(10);
944 /* Unhook test interrupt handler */
945 free_irq(irq, netdev);
947 return *data;
950 static void e1000_free_desc_rings(struct e1000_adapter *adapter)
952 struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
953 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
954 struct pci_dev *pdev = adapter->pdev;
955 int i;
957 if (txdr->desc && txdr->buffer_info) {
958 for (i = 0; i < txdr->count; i++) {
959 if (txdr->buffer_info[i].dma)
960 pci_unmap_single(pdev, txdr->buffer_info[i].dma,
961 txdr->buffer_info[i].length,
962 PCI_DMA_TODEVICE);
963 if (txdr->buffer_info[i].skb)
964 dev_kfree_skb(txdr->buffer_info[i].skb);
968 if (rxdr->desc && rxdr->buffer_info) {
969 for (i = 0; i < rxdr->count; i++) {
970 if (rxdr->buffer_info[i].dma)
971 pci_unmap_single(pdev, rxdr->buffer_info[i].dma,
972 rxdr->buffer_info[i].length,
973 PCI_DMA_FROMDEVICE);
974 if (rxdr->buffer_info[i].skb)
975 dev_kfree_skb(rxdr->buffer_info[i].skb);
979 if (txdr->desc) {
980 pci_free_consistent(pdev, txdr->size, txdr->desc, txdr->dma);
981 txdr->desc = NULL;
983 if (rxdr->desc) {
984 pci_free_consistent(pdev, rxdr->size, rxdr->desc, rxdr->dma);
985 rxdr->desc = NULL;
988 kfree(txdr->buffer_info);
989 txdr->buffer_info = NULL;
990 kfree(rxdr->buffer_info);
991 rxdr->buffer_info = NULL;
993 return;
996 static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
998 struct e1000_hw *hw = &adapter->hw;
999 struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
1000 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
1001 struct pci_dev *pdev = adapter->pdev;
1002 u32 rctl;
1003 int i, ret_val;
1005 /* Setup Tx descriptor ring and Tx buffers */
1007 if (!txdr->count)
1008 txdr->count = E1000_DEFAULT_TXD;
1010 txdr->buffer_info = kcalloc(txdr->count, sizeof(struct e1000_buffer),
1011 GFP_KERNEL);
1012 if (!txdr->buffer_info) {
1013 ret_val = 1;
1014 goto err_nomem;
1017 txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
1018 txdr->size = ALIGN(txdr->size, 4096);
1019 txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
1020 if (!txdr->desc) {
1021 ret_val = 2;
1022 goto err_nomem;
1024 memset(txdr->desc, 0, txdr->size);
1025 txdr->next_to_use = txdr->next_to_clean = 0;
1027 ew32(TDBAL, ((u64)txdr->dma & 0x00000000FFFFFFFF));
1028 ew32(TDBAH, ((u64)txdr->dma >> 32));
1029 ew32(TDLEN, txdr->count * sizeof(struct e1000_tx_desc));
1030 ew32(TDH, 0);
1031 ew32(TDT, 0);
1032 ew32(TCTL, E1000_TCTL_PSP | E1000_TCTL_EN |
1033 E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT |
1034 E1000_FDX_COLLISION_DISTANCE << E1000_COLD_SHIFT);
1036 for (i = 0; i < txdr->count; i++) {
1037 struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*txdr, i);
1038 struct sk_buff *skb;
1039 unsigned int size = 1024;
1041 skb = alloc_skb(size, GFP_KERNEL);
1042 if (!skb) {
1043 ret_val = 3;
1044 goto err_nomem;
1046 skb_put(skb, size);
1047 txdr->buffer_info[i].skb = skb;
1048 txdr->buffer_info[i].length = skb->len;
1049 txdr->buffer_info[i].dma =
1050 pci_map_single(pdev, skb->data, skb->len,
1051 PCI_DMA_TODEVICE);
1052 tx_desc->buffer_addr = cpu_to_le64(txdr->buffer_info[i].dma);
1053 tx_desc->lower.data = cpu_to_le32(skb->len);
1054 tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP |
1055 E1000_TXD_CMD_IFCS |
1056 E1000_TXD_CMD_RPS);
1057 tx_desc->upper.data = 0;
1060 /* Setup Rx descriptor ring and Rx buffers */
1062 if (!rxdr->count)
1063 rxdr->count = E1000_DEFAULT_RXD;
1065 rxdr->buffer_info = kcalloc(rxdr->count, sizeof(struct e1000_buffer),
1066 GFP_KERNEL);
1067 if (!rxdr->buffer_info) {
1068 ret_val = 4;
1069 goto err_nomem;
1072 rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc);
1073 rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
1074 if (!rxdr->desc) {
1075 ret_val = 5;
1076 goto err_nomem;
1078 memset(rxdr->desc, 0, rxdr->size);
1079 rxdr->next_to_use = rxdr->next_to_clean = 0;
1081 rctl = er32(RCTL);
1082 ew32(RCTL, rctl & ~E1000_RCTL_EN);
1083 ew32(RDBAL, ((u64)rxdr->dma & 0xFFFFFFFF));
1084 ew32(RDBAH, ((u64)rxdr->dma >> 32));
1085 ew32(RDLEN, rxdr->size);
1086 ew32(RDH, 0);
1087 ew32(RDT, 0);
1088 rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 |
1089 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
1090 (hw->mc_filter_type << E1000_RCTL_MO_SHIFT);
1091 ew32(RCTL, rctl);
1093 for (i = 0; i < rxdr->count; i++) {
1094 struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i);
1095 struct sk_buff *skb;
1097 skb = alloc_skb(E1000_RXBUFFER_2048 + NET_IP_ALIGN, GFP_KERNEL);
1098 if (!skb) {
1099 ret_val = 6;
1100 goto err_nomem;
1102 skb_reserve(skb, NET_IP_ALIGN);
1103 rxdr->buffer_info[i].skb = skb;
1104 rxdr->buffer_info[i].length = E1000_RXBUFFER_2048;
1105 rxdr->buffer_info[i].dma =
1106 pci_map_single(pdev, skb->data, E1000_RXBUFFER_2048,
1107 PCI_DMA_FROMDEVICE);
1108 rx_desc->buffer_addr = cpu_to_le64(rxdr->buffer_info[i].dma);
1109 memset(skb->data, 0x00, skb->len);
1112 return 0;
1114 err_nomem:
1115 e1000_free_desc_rings(adapter);
1116 return ret_val;
1119 static void e1000_phy_disable_receiver(struct e1000_adapter *adapter)
1121 struct e1000_hw *hw = &adapter->hw;
1123 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1124 e1000_write_phy_reg(hw, 29, 0x001F);
1125 e1000_write_phy_reg(hw, 30, 0x8FFC);
1126 e1000_write_phy_reg(hw, 29, 0x001A);
1127 e1000_write_phy_reg(hw, 30, 0x8FF0);
1130 static void e1000_phy_reset_clk_and_crs(struct e1000_adapter *adapter)
1132 struct e1000_hw *hw = &adapter->hw;
1133 u16 phy_reg;
1135 /* Because we reset the PHY above, we need to re-force TX_CLK in the
1136 * Extended PHY Specific Control Register to 25MHz clock. This
1137 * value defaults back to a 2.5MHz clock when the PHY is reset.
1139 e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg);
1140 phy_reg |= M88E1000_EPSCR_TX_CLK_25;
1141 e1000_write_phy_reg(hw,
1142 M88E1000_EXT_PHY_SPEC_CTRL, phy_reg);
1144 /* In addition, because of the s/w reset above, we need to enable
1145 * CRS on TX. This must be set for both full and half duplex
1146 * operation.
1148 e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_reg);
1149 phy_reg |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
1150 e1000_write_phy_reg(hw,
1151 M88E1000_PHY_SPEC_CTRL, phy_reg);
1154 static int e1000_nonintegrated_phy_loopback(struct e1000_adapter *adapter)
1156 struct e1000_hw *hw = &adapter->hw;
1157 u32 ctrl_reg;
1158 u16 phy_reg;
1160 /* Setup the Device Control Register for PHY loopback test. */
1162 ctrl_reg = er32(CTRL);
1163 ctrl_reg |= (E1000_CTRL_ILOS | /* Invert Loss-Of-Signal */
1164 E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1165 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1166 E1000_CTRL_SPD_1000 | /* Force Speed to 1000 */
1167 E1000_CTRL_FD); /* Force Duplex to FULL */
1169 ew32(CTRL, ctrl_reg);
1171 /* Read the PHY Specific Control Register (0x10) */
1172 e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_reg);
1174 /* Clear Auto-Crossover bits in PHY Specific Control Register
1175 * (bits 6:5).
1177 phy_reg &= ~M88E1000_PSCR_AUTO_X_MODE;
1178 e1000_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_reg);
1180 /* Perform software reset on the PHY */
1181 e1000_phy_reset(hw);
1183 /* Have to setup TX_CLK and TX_CRS after software reset */
1184 e1000_phy_reset_clk_and_crs(adapter);
1186 e1000_write_phy_reg(hw, PHY_CTRL, 0x8100);
1188 /* Wait for reset to complete. */
1189 udelay(500);
1191 /* Have to setup TX_CLK and TX_CRS after software reset */
1192 e1000_phy_reset_clk_and_crs(adapter);
1194 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1195 e1000_phy_disable_receiver(adapter);
1197 /* Set the loopback bit in the PHY control register. */
1198 e1000_read_phy_reg(hw, PHY_CTRL, &phy_reg);
1199 phy_reg |= MII_CR_LOOPBACK;
1200 e1000_write_phy_reg(hw, PHY_CTRL, phy_reg);
1202 /* Setup TX_CLK and TX_CRS one more time. */
1203 e1000_phy_reset_clk_and_crs(adapter);
1205 /* Check Phy Configuration */
1206 e1000_read_phy_reg(hw, PHY_CTRL, &phy_reg);
1207 if (phy_reg != 0x4100)
1208 return 9;
1210 e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg);
1211 if (phy_reg != 0x0070)
1212 return 10;
1214 e1000_read_phy_reg(hw, 29, &phy_reg);
1215 if (phy_reg != 0x001A)
1216 return 11;
1218 return 0;
1221 static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1223 struct e1000_hw *hw = &adapter->hw;
1224 u32 ctrl_reg = 0;
1225 u32 stat_reg = 0;
1227 hw->autoneg = false;
1229 if (hw->phy_type == e1000_phy_m88) {
1230 /* Auto-MDI/MDIX Off */
1231 e1000_write_phy_reg(hw,
1232 M88E1000_PHY_SPEC_CTRL, 0x0808);
1233 /* reset to update Auto-MDI/MDIX */
1234 e1000_write_phy_reg(hw, PHY_CTRL, 0x9140);
1235 /* autoneg off */
1236 e1000_write_phy_reg(hw, PHY_CTRL, 0x8140);
1239 ctrl_reg = er32(CTRL);
1241 /* force 1000, set loopback */
1242 e1000_write_phy_reg(hw, PHY_CTRL, 0x4140);
1244 /* Now set up the MAC to the same speed/duplex as the PHY. */
1245 ctrl_reg = er32(CTRL);
1246 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
1247 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1248 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1249 E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
1250 E1000_CTRL_FD); /* Force Duplex to FULL */
1252 if (hw->media_type == e1000_media_type_copper &&
1253 hw->phy_type == e1000_phy_m88)
1254 ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
1255 else {
1256 /* Set the ILOS bit on the fiber Nic is half
1257 * duplex link is detected. */
1258 stat_reg = er32(STATUS);
1259 if ((stat_reg & E1000_STATUS_FD) == 0)
1260 ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
1263 ew32(CTRL, ctrl_reg);
1265 /* Disable the receiver on the PHY so when a cable is plugged in, the
1266 * PHY does not begin to autoneg when a cable is reconnected to the NIC.
1268 if (hw->phy_type == e1000_phy_m88)
1269 e1000_phy_disable_receiver(adapter);
1271 udelay(500);
1273 return 0;
1276 static int e1000_set_phy_loopback(struct e1000_adapter *adapter)
1278 struct e1000_hw *hw = &adapter->hw;
1279 u16 phy_reg = 0;
1280 u16 count = 0;
1282 switch (hw->mac_type) {
1283 case e1000_82543:
1284 if (hw->media_type == e1000_media_type_copper) {
1285 /* Attempt to setup Loopback mode on Non-integrated PHY.
1286 * Some PHY registers get corrupted at random, so
1287 * attempt this 10 times.
1289 while (e1000_nonintegrated_phy_loopback(adapter) &&
1290 count++ < 10);
1291 if (count < 11)
1292 return 0;
1294 break;
1296 case e1000_82544:
1297 case e1000_82540:
1298 case e1000_82545:
1299 case e1000_82545_rev_3:
1300 case e1000_82546:
1301 case e1000_82546_rev_3:
1302 case e1000_82541:
1303 case e1000_82541_rev_2:
1304 case e1000_82547:
1305 case e1000_82547_rev_2:
1306 return e1000_integrated_phy_loopback(adapter);
1307 break;
1308 default:
1309 /* Default PHY loopback work is to read the MII
1310 * control register and assert bit 14 (loopback mode).
1312 e1000_read_phy_reg(hw, PHY_CTRL, &phy_reg);
1313 phy_reg |= MII_CR_LOOPBACK;
1314 e1000_write_phy_reg(hw, PHY_CTRL, phy_reg);
1315 return 0;
1316 break;
1319 return 8;
1322 static int e1000_setup_loopback_test(struct e1000_adapter *adapter)
1324 struct e1000_hw *hw = &adapter->hw;
1325 u32 rctl;
1327 if (hw->media_type == e1000_media_type_fiber ||
1328 hw->media_type == e1000_media_type_internal_serdes) {
1329 switch (hw->mac_type) {
1330 case e1000_82545:
1331 case e1000_82546:
1332 case e1000_82545_rev_3:
1333 case e1000_82546_rev_3:
1334 return e1000_set_phy_loopback(adapter);
1335 break;
1336 default:
1337 rctl = er32(RCTL);
1338 rctl |= E1000_RCTL_LBM_TCVR;
1339 ew32(RCTL, rctl);
1340 return 0;
1342 } else if (hw->media_type == e1000_media_type_copper)
1343 return e1000_set_phy_loopback(adapter);
1345 return 7;
1348 static void e1000_loopback_cleanup(struct e1000_adapter *adapter)
1350 struct e1000_hw *hw = &adapter->hw;
1351 u32 rctl;
1352 u16 phy_reg;
1354 rctl = er32(RCTL);
1355 rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
1356 ew32(RCTL, rctl);
1358 switch (hw->mac_type) {
1359 case e1000_82545:
1360 case e1000_82546:
1361 case e1000_82545_rev_3:
1362 case e1000_82546_rev_3:
1363 default:
1364 hw->autoneg = true;
1365 e1000_read_phy_reg(hw, PHY_CTRL, &phy_reg);
1366 if (phy_reg & MII_CR_LOOPBACK) {
1367 phy_reg &= ~MII_CR_LOOPBACK;
1368 e1000_write_phy_reg(hw, PHY_CTRL, phy_reg);
1369 e1000_phy_reset(hw);
1371 break;
1375 static void e1000_create_lbtest_frame(struct sk_buff *skb,
1376 unsigned int frame_size)
1378 memset(skb->data, 0xFF, frame_size);
1379 frame_size &= ~1;
1380 memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
1381 memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
1382 memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
1385 static int e1000_check_lbtest_frame(struct sk_buff *skb,
1386 unsigned int frame_size)
1388 frame_size &= ~1;
1389 if (*(skb->data + 3) == 0xFF) {
1390 if ((*(skb->data + frame_size / 2 + 10) == 0xBE) &&
1391 (*(skb->data + frame_size / 2 + 12) == 0xAF)) {
1392 return 0;
1395 return 13;
1398 static int e1000_run_loopback_test(struct e1000_adapter *adapter)
1400 struct e1000_hw *hw = &adapter->hw;
1401 struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
1402 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
1403 struct pci_dev *pdev = adapter->pdev;
1404 int i, j, k, l, lc, good_cnt, ret_val=0;
1405 unsigned long time;
1407 ew32(RDT, rxdr->count - 1);
1409 /* Calculate the loop count based on the largest descriptor ring
1410 * The idea is to wrap the largest ring a number of times using 64
1411 * send/receive pairs during each loop
1414 if (rxdr->count <= txdr->count)
1415 lc = ((txdr->count / 64) * 2) + 1;
1416 else
1417 lc = ((rxdr->count / 64) * 2) + 1;
1419 k = l = 0;
1420 for (j = 0; j <= lc; j++) { /* loop count loop */
1421 for (i = 0; i < 64; i++) { /* send the packets */
1422 e1000_create_lbtest_frame(txdr->buffer_info[i].skb,
1423 1024);
1424 pci_dma_sync_single_for_device(pdev,
1425 txdr->buffer_info[k].dma,
1426 txdr->buffer_info[k].length,
1427 PCI_DMA_TODEVICE);
1428 if (unlikely(++k == txdr->count)) k = 0;
1430 ew32(TDT, k);
1431 msleep(200);
1432 time = jiffies; /* set the start time for the receive */
1433 good_cnt = 0;
1434 do { /* receive the sent packets */
1435 pci_dma_sync_single_for_cpu(pdev,
1436 rxdr->buffer_info[l].dma,
1437 rxdr->buffer_info[l].length,
1438 PCI_DMA_FROMDEVICE);
1440 ret_val = e1000_check_lbtest_frame(
1441 rxdr->buffer_info[l].skb,
1442 1024);
1443 if (!ret_val)
1444 good_cnt++;
1445 if (unlikely(++l == rxdr->count)) l = 0;
1446 /* time + 20 msecs (200 msecs on 2.4) is more than
1447 * enough time to complete the receives, if it's
1448 * exceeded, break and error off
1450 } while (good_cnt < 64 && jiffies < (time + 20));
1451 if (good_cnt != 64) {
1452 ret_val = 13; /* ret_val is the same as mis-compare */
1453 break;
1455 if (jiffies >= (time + 2)) {
1456 ret_val = 14; /* error code for time out error */
1457 break;
1459 } /* end loop count loop */
1460 return ret_val;
1463 static int e1000_loopback_test(struct e1000_adapter *adapter, u64 *data)
1465 *data = e1000_setup_desc_rings(adapter);
1466 if (*data)
1467 goto out;
1468 *data = e1000_setup_loopback_test(adapter);
1469 if (*data)
1470 goto err_loopback;
1471 *data = e1000_run_loopback_test(adapter);
1472 e1000_loopback_cleanup(adapter);
1474 err_loopback:
1475 e1000_free_desc_rings(adapter);
1476 out:
1477 return *data;
1480 static int e1000_link_test(struct e1000_adapter *adapter, u64 *data)
1482 struct e1000_hw *hw = &adapter->hw;
1483 *data = 0;
1484 if (hw->media_type == e1000_media_type_internal_serdes) {
1485 int i = 0;
1486 hw->serdes_has_link = false;
1488 /* On some blade server designs, link establishment
1489 * could take as long as 2-3 minutes */
1490 do {
1491 e1000_check_for_link(hw);
1492 if (hw->serdes_has_link)
1493 return *data;
1494 msleep(20);
1495 } while (i++ < 3750);
1497 *data = 1;
1498 } else {
1499 e1000_check_for_link(hw);
1500 if (hw->autoneg) /* if auto_neg is set wait for it */
1501 msleep(4000);
1503 if (!(er32(STATUS) & E1000_STATUS_LU)) {
1504 *data = 1;
1507 return *data;
1510 static int e1000_get_sset_count(struct net_device *netdev, int sset)
1512 switch (sset) {
1513 case ETH_SS_TEST:
1514 return E1000_TEST_LEN;
1515 case ETH_SS_STATS:
1516 return E1000_STATS_LEN;
1517 default:
1518 return -EOPNOTSUPP;
1522 static void e1000_diag_test(struct net_device *netdev,
1523 struct ethtool_test *eth_test, u64 *data)
1525 struct e1000_adapter *adapter = netdev_priv(netdev);
1526 struct e1000_hw *hw = &adapter->hw;
1527 bool if_running = netif_running(netdev);
1529 set_bit(__E1000_TESTING, &adapter->flags);
1530 if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
1531 /* Offline tests */
1533 /* save speed, duplex, autoneg settings */
1534 u16 autoneg_advertised = hw->autoneg_advertised;
1535 u8 forced_speed_duplex = hw->forced_speed_duplex;
1536 u8 autoneg = hw->autoneg;
1538 DPRINTK(HW, INFO, "offline testing starting\n");
1540 /* Link test performed before hardware reset so autoneg doesn't
1541 * interfere with test result */
1542 if (e1000_link_test(adapter, &data[4]))
1543 eth_test->flags |= ETH_TEST_FL_FAILED;
1545 if (if_running)
1546 /* indicate we're in test mode */
1547 dev_close(netdev);
1548 else
1549 e1000_reset(adapter);
1551 if (e1000_reg_test(adapter, &data[0]))
1552 eth_test->flags |= ETH_TEST_FL_FAILED;
1554 e1000_reset(adapter);
1555 if (e1000_eeprom_test(adapter, &data[1]))
1556 eth_test->flags |= ETH_TEST_FL_FAILED;
1558 e1000_reset(adapter);
1559 if (e1000_intr_test(adapter, &data[2]))
1560 eth_test->flags |= ETH_TEST_FL_FAILED;
1562 e1000_reset(adapter);
1563 /* make sure the phy is powered up */
1564 e1000_power_up_phy(adapter);
1565 if (e1000_loopback_test(adapter, &data[3]))
1566 eth_test->flags |= ETH_TEST_FL_FAILED;
1568 /* restore speed, duplex, autoneg settings */
1569 hw->autoneg_advertised = autoneg_advertised;
1570 hw->forced_speed_duplex = forced_speed_duplex;
1571 hw->autoneg = autoneg;
1573 e1000_reset(adapter);
1574 clear_bit(__E1000_TESTING, &adapter->flags);
1575 if (if_running)
1576 dev_open(netdev);
1577 } else {
1578 DPRINTK(HW, INFO, "online testing starting\n");
1579 /* Online tests */
1580 if (e1000_link_test(adapter, &data[4]))
1581 eth_test->flags |= ETH_TEST_FL_FAILED;
1583 /* Online tests aren't run; pass by default */
1584 data[0] = 0;
1585 data[1] = 0;
1586 data[2] = 0;
1587 data[3] = 0;
1589 clear_bit(__E1000_TESTING, &adapter->flags);
1591 msleep_interruptible(4 * 1000);
1594 static int e1000_wol_exclusion(struct e1000_adapter *adapter,
1595 struct ethtool_wolinfo *wol)
1597 struct e1000_hw *hw = &adapter->hw;
1598 int retval = 1; /* fail by default */
1600 switch (hw->device_id) {
1601 case E1000_DEV_ID_82542:
1602 case E1000_DEV_ID_82543GC_FIBER:
1603 case E1000_DEV_ID_82543GC_COPPER:
1604 case E1000_DEV_ID_82544EI_FIBER:
1605 case E1000_DEV_ID_82546EB_QUAD_COPPER:
1606 case E1000_DEV_ID_82545EM_FIBER:
1607 case E1000_DEV_ID_82545EM_COPPER:
1608 case E1000_DEV_ID_82546GB_QUAD_COPPER:
1609 case E1000_DEV_ID_82546GB_PCIE:
1610 /* these don't support WoL at all */
1611 wol->supported = 0;
1612 break;
1613 case E1000_DEV_ID_82546EB_FIBER:
1614 case E1000_DEV_ID_82546GB_FIBER:
1615 /* Wake events not supported on port B */
1616 if (er32(STATUS) & E1000_STATUS_FUNC_1) {
1617 wol->supported = 0;
1618 break;
1620 /* return success for non excluded adapter ports */
1621 retval = 0;
1622 break;
1623 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
1624 /* quad port adapters only support WoL on port A */
1625 if (!adapter->quad_port_a) {
1626 wol->supported = 0;
1627 break;
1629 /* return success for non excluded adapter ports */
1630 retval = 0;
1631 break;
1632 default:
1633 /* dual port cards only support WoL on port A from now on
1634 * unless it was enabled in the eeprom for port B
1635 * so exclude FUNC_1 ports from having WoL enabled */
1636 if (er32(STATUS) & E1000_STATUS_FUNC_1 &&
1637 !adapter->eeprom_wol) {
1638 wol->supported = 0;
1639 break;
1642 retval = 0;
1645 return retval;
1648 static void e1000_get_wol(struct net_device *netdev,
1649 struct ethtool_wolinfo *wol)
1651 struct e1000_adapter *adapter = netdev_priv(netdev);
1652 struct e1000_hw *hw = &adapter->hw;
1654 wol->supported = WAKE_UCAST | WAKE_MCAST |
1655 WAKE_BCAST | WAKE_MAGIC;
1656 wol->wolopts = 0;
1658 /* this function will set ->supported = 0 and return 1 if wol is not
1659 * supported by this hardware */
1660 if (e1000_wol_exclusion(adapter, wol) ||
1661 !device_can_wakeup(&adapter->pdev->dev))
1662 return;
1664 /* apply any specific unsupported masks here */
1665 switch (hw->device_id) {
1666 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
1667 /* KSP3 does not suppport UCAST wake-ups */
1668 wol->supported &= ~WAKE_UCAST;
1670 if (adapter->wol & E1000_WUFC_EX)
1671 DPRINTK(DRV, ERR, "Interface does not support "
1672 "directed (unicast) frame wake-up packets\n");
1673 break;
1674 default:
1675 break;
1678 if (adapter->wol & E1000_WUFC_EX)
1679 wol->wolopts |= WAKE_UCAST;
1680 if (adapter->wol & E1000_WUFC_MC)
1681 wol->wolopts |= WAKE_MCAST;
1682 if (adapter->wol & E1000_WUFC_BC)
1683 wol->wolopts |= WAKE_BCAST;
1684 if (adapter->wol & E1000_WUFC_MAG)
1685 wol->wolopts |= WAKE_MAGIC;
1687 return;
1690 static int e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1692 struct e1000_adapter *adapter = netdev_priv(netdev);
1693 struct e1000_hw *hw = &adapter->hw;
1695 if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE))
1696 return -EOPNOTSUPP;
1698 if (e1000_wol_exclusion(adapter, wol) ||
1699 !device_can_wakeup(&adapter->pdev->dev))
1700 return wol->wolopts ? -EOPNOTSUPP : 0;
1702 switch (hw->device_id) {
1703 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
1704 if (wol->wolopts & WAKE_UCAST) {
1705 DPRINTK(DRV, ERR, "Interface does not support "
1706 "directed (unicast) frame wake-up packets\n");
1707 return -EOPNOTSUPP;
1709 break;
1710 default:
1711 break;
1714 /* these settings will always override what we currently have */
1715 adapter->wol = 0;
1717 if (wol->wolopts & WAKE_UCAST)
1718 adapter->wol |= E1000_WUFC_EX;
1719 if (wol->wolopts & WAKE_MCAST)
1720 adapter->wol |= E1000_WUFC_MC;
1721 if (wol->wolopts & WAKE_BCAST)
1722 adapter->wol |= E1000_WUFC_BC;
1723 if (wol->wolopts & WAKE_MAGIC)
1724 adapter->wol |= E1000_WUFC_MAG;
1726 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
1728 return 0;
1731 /* toggle LED 4 times per second = 2 "blinks" per second */
1732 #define E1000_ID_INTERVAL (HZ/4)
1734 /* bit defines for adapter->led_status */
1735 #define E1000_LED_ON 0
1737 static void e1000_led_blink_callback(unsigned long data)
1739 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
1740 struct e1000_hw *hw = &adapter->hw;
1742 if (test_and_change_bit(E1000_LED_ON, &adapter->led_status))
1743 e1000_led_off(hw);
1744 else
1745 e1000_led_on(hw);
1747 mod_timer(&adapter->blink_timer, jiffies + E1000_ID_INTERVAL);
1750 static int e1000_phys_id(struct net_device *netdev, u32 data)
1752 struct e1000_adapter *adapter = netdev_priv(netdev);
1753 struct e1000_hw *hw = &adapter->hw;
1755 if (!data)
1756 data = INT_MAX;
1758 if (!adapter->blink_timer.function) {
1759 init_timer(&adapter->blink_timer);
1760 adapter->blink_timer.function = e1000_led_blink_callback;
1761 adapter->blink_timer.data = (unsigned long)adapter;
1763 e1000_setup_led(hw);
1764 mod_timer(&adapter->blink_timer, jiffies);
1765 msleep_interruptible(data * 1000);
1766 del_timer_sync(&adapter->blink_timer);
1768 e1000_led_off(hw);
1769 clear_bit(E1000_LED_ON, &adapter->led_status);
1770 e1000_cleanup_led(hw);
1772 return 0;
1775 static int e1000_get_coalesce(struct net_device *netdev,
1776 struct ethtool_coalesce *ec)
1778 struct e1000_adapter *adapter = netdev_priv(netdev);
1780 if (adapter->hw.mac_type < e1000_82545)
1781 return -EOPNOTSUPP;
1783 if (adapter->itr_setting <= 3)
1784 ec->rx_coalesce_usecs = adapter->itr_setting;
1785 else
1786 ec->rx_coalesce_usecs = 1000000 / adapter->itr_setting;
1788 return 0;
1791 static int e1000_set_coalesce(struct net_device *netdev,
1792 struct ethtool_coalesce *ec)
1794 struct e1000_adapter *adapter = netdev_priv(netdev);
1795 struct e1000_hw *hw = &adapter->hw;
1797 if (hw->mac_type < e1000_82545)
1798 return -EOPNOTSUPP;
1800 if ((ec->rx_coalesce_usecs > E1000_MAX_ITR_USECS) ||
1801 ((ec->rx_coalesce_usecs > 3) &&
1802 (ec->rx_coalesce_usecs < E1000_MIN_ITR_USECS)) ||
1803 (ec->rx_coalesce_usecs == 2))
1804 return -EINVAL;
1806 if (ec->rx_coalesce_usecs <= 3) {
1807 adapter->itr = 20000;
1808 adapter->itr_setting = ec->rx_coalesce_usecs;
1809 } else {
1810 adapter->itr = (1000000 / ec->rx_coalesce_usecs);
1811 adapter->itr_setting = adapter->itr & ~3;
1814 if (adapter->itr_setting != 0)
1815 ew32(ITR, 1000000000 / (adapter->itr * 256));
1816 else
1817 ew32(ITR, 0);
1819 return 0;
1822 static int e1000_nway_reset(struct net_device *netdev)
1824 struct e1000_adapter *adapter = netdev_priv(netdev);
1825 if (netif_running(netdev))
1826 e1000_reinit_locked(adapter);
1827 return 0;
1830 static void e1000_get_ethtool_stats(struct net_device *netdev,
1831 struct ethtool_stats *stats, u64 *data)
1833 struct e1000_adapter *adapter = netdev_priv(netdev);
1834 int i;
1836 e1000_update_stats(adapter);
1837 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
1838 char *p = (char *)adapter+e1000_gstrings_stats[i].stat_offset;
1839 data[i] = (e1000_gstrings_stats[i].sizeof_stat ==
1840 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1842 /* BUG_ON(i != E1000_STATS_LEN); */
1845 static void e1000_get_strings(struct net_device *netdev, u32 stringset,
1846 u8 *data)
1848 u8 *p = data;
1849 int i;
1851 switch (stringset) {
1852 case ETH_SS_TEST:
1853 memcpy(data, *e1000_gstrings_test,
1854 sizeof(e1000_gstrings_test));
1855 break;
1856 case ETH_SS_STATS:
1857 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
1858 memcpy(p, e1000_gstrings_stats[i].stat_string,
1859 ETH_GSTRING_LEN);
1860 p += ETH_GSTRING_LEN;
1862 /* BUG_ON(p - data != E1000_STATS_LEN * ETH_GSTRING_LEN); */
1863 break;
1867 static const struct ethtool_ops e1000_ethtool_ops = {
1868 .get_settings = e1000_get_settings,
1869 .set_settings = e1000_set_settings,
1870 .get_drvinfo = e1000_get_drvinfo,
1871 .get_regs_len = e1000_get_regs_len,
1872 .get_regs = e1000_get_regs,
1873 .get_wol = e1000_get_wol,
1874 .set_wol = e1000_set_wol,
1875 .get_msglevel = e1000_get_msglevel,
1876 .set_msglevel = e1000_set_msglevel,
1877 .nway_reset = e1000_nway_reset,
1878 .get_link = ethtool_op_get_link,
1879 .get_eeprom_len = e1000_get_eeprom_len,
1880 .get_eeprom = e1000_get_eeprom,
1881 .set_eeprom = e1000_set_eeprom,
1882 .get_ringparam = e1000_get_ringparam,
1883 .set_ringparam = e1000_set_ringparam,
1884 .get_pauseparam = e1000_get_pauseparam,
1885 .set_pauseparam = e1000_set_pauseparam,
1886 .get_rx_csum = e1000_get_rx_csum,
1887 .set_rx_csum = e1000_set_rx_csum,
1888 .get_tx_csum = e1000_get_tx_csum,
1889 .set_tx_csum = e1000_set_tx_csum,
1890 .set_sg = ethtool_op_set_sg,
1891 .set_tso = e1000_set_tso,
1892 .self_test = e1000_diag_test,
1893 .get_strings = e1000_get_strings,
1894 .phys_id = e1000_phys_id,
1895 .get_ethtool_stats = e1000_get_ethtool_stats,
1896 .get_sset_count = e1000_get_sset_count,
1897 .get_coalesce = e1000_get_coalesce,
1898 .set_coalesce = e1000_set_coalesce,
1901 void e1000_set_ethtool_ops(struct net_device *netdev)
1903 SET_ETHTOOL_OPS(netdev, &e1000_ethtool_ops);