e1000: Fixes for packet split related issues
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / net / e1000 / e1000_ethtool.c
blob183b583df1d70c799e5be0b2f18621045b998416
1 /*******************************************************************************
4 Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
9 any later version.
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
16 You should have received a copy of the GNU General Public License along with
17 this program; if not, write to the Free Software Foundation, Inc., 59
18 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 The full GNU General Public License is included in this distribution in the
21 file called LICENSE.
23 Contact Information:
24 Linux NICS <linux.nics@intel.com>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
29 /* ethtool support for e1000 */
31 #include "e1000.h"
33 #include <asm/uaccess.h>
35 extern char e1000_driver_name[];
36 extern char e1000_driver_version[];
38 extern int e1000_up(struct e1000_adapter *adapter);
39 extern void e1000_down(struct e1000_adapter *adapter);
40 extern void e1000_reset(struct e1000_adapter *adapter);
41 extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx);
42 extern int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
43 extern int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
44 extern void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
45 extern void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
46 extern void e1000_update_stats(struct e1000_adapter *adapter);
48 struct e1000_stats {
49 char stat_string[ETH_GSTRING_LEN];
50 int sizeof_stat;
51 int stat_offset;
54 #define E1000_STAT(m) sizeof(((struct e1000_adapter *)0)->m), \
55 offsetof(struct e1000_adapter, m)
56 static const struct e1000_stats e1000_gstrings_stats[] = {
57 { "rx_packets", E1000_STAT(net_stats.rx_packets) },
58 { "tx_packets", E1000_STAT(net_stats.tx_packets) },
59 { "rx_bytes", E1000_STAT(net_stats.rx_bytes) },
60 { "tx_bytes", E1000_STAT(net_stats.tx_bytes) },
61 { "rx_errors", E1000_STAT(net_stats.rx_errors) },
62 { "tx_errors", E1000_STAT(net_stats.tx_errors) },
63 { "rx_dropped", E1000_STAT(net_stats.rx_dropped) },
64 { "tx_dropped", E1000_STAT(net_stats.tx_dropped) },
65 { "multicast", E1000_STAT(net_stats.multicast) },
66 { "collisions", E1000_STAT(net_stats.collisions) },
67 { "rx_length_errors", E1000_STAT(net_stats.rx_length_errors) },
68 { "rx_over_errors", E1000_STAT(net_stats.rx_over_errors) },
69 { "rx_crc_errors", E1000_STAT(net_stats.rx_crc_errors) },
70 { "rx_frame_errors", E1000_STAT(net_stats.rx_frame_errors) },
71 { "rx_fifo_errors", E1000_STAT(net_stats.rx_fifo_errors) },
72 { "rx_no_buffer_count", E1000_STAT(stats.rnbc) },
73 { "rx_missed_errors", E1000_STAT(net_stats.rx_missed_errors) },
74 { "tx_aborted_errors", E1000_STAT(net_stats.tx_aborted_errors) },
75 { "tx_carrier_errors", E1000_STAT(net_stats.tx_carrier_errors) },
76 { "tx_fifo_errors", E1000_STAT(net_stats.tx_fifo_errors) },
77 { "tx_heartbeat_errors", E1000_STAT(net_stats.tx_heartbeat_errors) },
78 { "tx_window_errors", E1000_STAT(net_stats.tx_window_errors) },
79 { "tx_abort_late_coll", E1000_STAT(stats.latecol) },
80 { "tx_deferred_ok", E1000_STAT(stats.dc) },
81 { "tx_single_coll_ok", E1000_STAT(stats.scc) },
82 { "tx_multi_coll_ok", E1000_STAT(stats.mcc) },
83 { "rx_long_length_errors", E1000_STAT(stats.roc) },
84 { "rx_short_length_errors", E1000_STAT(stats.ruc) },
85 { "rx_align_errors", E1000_STAT(stats.algnerrc) },
86 { "tx_tcp_seg_good", E1000_STAT(stats.tsctc) },
87 { "tx_tcp_seg_failed", E1000_STAT(stats.tsctfc) },
88 { "rx_flow_control_xon", E1000_STAT(stats.xonrxc) },
89 { "rx_flow_control_xoff", E1000_STAT(stats.xoffrxc) },
90 { "tx_flow_control_xon", E1000_STAT(stats.xontxc) },
91 { "tx_flow_control_xoff", E1000_STAT(stats.xofftxc) },
92 { "rx_long_byte_count", E1000_STAT(stats.gorcl) },
93 { "rx_csum_offload_good", E1000_STAT(hw_csum_good) },
94 { "rx_csum_offload_errors", E1000_STAT(hw_csum_err) },
95 { "rx_header_split", E1000_STAT(rx_hdr_split) },
97 #define E1000_STATS_LEN \
98 sizeof(e1000_gstrings_stats) / sizeof(struct e1000_stats)
99 static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = {
100 "Register test (offline)", "Eeprom test (offline)",
101 "Interrupt test (offline)", "Loopback test (offline)",
102 "Link test (on/offline)"
104 #define E1000_TEST_LEN sizeof(e1000_gstrings_test) / ETH_GSTRING_LEN
106 static int
107 e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
109 struct e1000_adapter *adapter = netdev_priv(netdev);
110 struct e1000_hw *hw = &adapter->hw;
112 if(hw->media_type == e1000_media_type_copper) {
114 ecmd->supported = (SUPPORTED_10baseT_Half |
115 SUPPORTED_10baseT_Full |
116 SUPPORTED_100baseT_Half |
117 SUPPORTED_100baseT_Full |
118 SUPPORTED_1000baseT_Full|
119 SUPPORTED_Autoneg |
120 SUPPORTED_TP);
122 ecmd->advertising = ADVERTISED_TP;
124 if(hw->autoneg == 1) {
125 ecmd->advertising |= ADVERTISED_Autoneg;
127 /* the e1000 autoneg seems to match ethtool nicely */
129 ecmd->advertising |= hw->autoneg_advertised;
132 ecmd->port = PORT_TP;
133 ecmd->phy_address = hw->phy_addr;
135 if(hw->mac_type == e1000_82543)
136 ecmd->transceiver = XCVR_EXTERNAL;
137 else
138 ecmd->transceiver = XCVR_INTERNAL;
140 } else {
141 ecmd->supported = (SUPPORTED_1000baseT_Full |
142 SUPPORTED_FIBRE |
143 SUPPORTED_Autoneg);
145 ecmd->advertising = (ADVERTISED_1000baseT_Full |
146 ADVERTISED_FIBRE |
147 ADVERTISED_Autoneg);
149 ecmd->port = PORT_FIBRE;
151 if(hw->mac_type >= e1000_82545)
152 ecmd->transceiver = XCVR_INTERNAL;
153 else
154 ecmd->transceiver = XCVR_EXTERNAL;
157 if(netif_carrier_ok(adapter->netdev)) {
159 e1000_get_speed_and_duplex(hw, &adapter->link_speed,
160 &adapter->link_duplex);
161 ecmd->speed = adapter->link_speed;
163 /* unfortunatly FULL_DUPLEX != DUPLEX_FULL
164 * and HALF_DUPLEX != DUPLEX_HALF */
166 if(adapter->link_duplex == FULL_DUPLEX)
167 ecmd->duplex = DUPLEX_FULL;
168 else
169 ecmd->duplex = DUPLEX_HALF;
170 } else {
171 ecmd->speed = -1;
172 ecmd->duplex = -1;
175 ecmd->autoneg = ((hw->media_type == e1000_media_type_fiber) ||
176 hw->autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE;
177 return 0;
180 static int
181 e1000_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
183 struct e1000_adapter *adapter = netdev_priv(netdev);
184 struct e1000_hw *hw = &adapter->hw;
186 if(ecmd->autoneg == AUTONEG_ENABLE) {
187 hw->autoneg = 1;
188 if(hw->media_type == e1000_media_type_fiber)
189 hw->autoneg_advertised = ADVERTISED_1000baseT_Full |
190 ADVERTISED_FIBRE |
191 ADVERTISED_Autoneg;
192 else
193 hw->autoneg_advertised = ADVERTISED_10baseT_Half |
194 ADVERTISED_10baseT_Full |
195 ADVERTISED_100baseT_Half |
196 ADVERTISED_100baseT_Full |
197 ADVERTISED_1000baseT_Full|
198 ADVERTISED_Autoneg |
199 ADVERTISED_TP;
200 ecmd->advertising = hw->autoneg_advertised;
201 } else
202 if(e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex))
203 return -EINVAL;
205 /* reset the link */
207 if(netif_running(adapter->netdev)) {
208 e1000_down(adapter);
209 e1000_reset(adapter);
210 e1000_up(adapter);
211 } else
212 e1000_reset(adapter);
214 return 0;
217 static void
218 e1000_get_pauseparam(struct net_device *netdev,
219 struct ethtool_pauseparam *pause)
221 struct e1000_adapter *adapter = netdev_priv(netdev);
222 struct e1000_hw *hw = &adapter->hw;
224 pause->autoneg =
225 (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
227 if(hw->fc == e1000_fc_rx_pause)
228 pause->rx_pause = 1;
229 else if(hw->fc == e1000_fc_tx_pause)
230 pause->tx_pause = 1;
231 else if(hw->fc == e1000_fc_full) {
232 pause->rx_pause = 1;
233 pause->tx_pause = 1;
237 static int
238 e1000_set_pauseparam(struct net_device *netdev,
239 struct ethtool_pauseparam *pause)
241 struct e1000_adapter *adapter = netdev_priv(netdev);
242 struct e1000_hw *hw = &adapter->hw;
244 adapter->fc_autoneg = pause->autoneg;
246 if(pause->rx_pause && pause->tx_pause)
247 hw->fc = e1000_fc_full;
248 else if(pause->rx_pause && !pause->tx_pause)
249 hw->fc = e1000_fc_rx_pause;
250 else if(!pause->rx_pause && pause->tx_pause)
251 hw->fc = e1000_fc_tx_pause;
252 else if(!pause->rx_pause && !pause->tx_pause)
253 hw->fc = e1000_fc_none;
255 hw->original_fc = hw->fc;
257 if(adapter->fc_autoneg == AUTONEG_ENABLE) {
258 if(netif_running(adapter->netdev)) {
259 e1000_down(adapter);
260 e1000_up(adapter);
261 } else
262 e1000_reset(adapter);
264 else
265 return ((hw->media_type == e1000_media_type_fiber) ?
266 e1000_setup_link(hw) : e1000_force_mac_fc(hw));
268 return 0;
271 static uint32_t
272 e1000_get_rx_csum(struct net_device *netdev)
274 struct e1000_adapter *adapter = netdev_priv(netdev);
275 return adapter->rx_csum;
278 static int
279 e1000_set_rx_csum(struct net_device *netdev, uint32_t data)
281 struct e1000_adapter *adapter = netdev_priv(netdev);
282 adapter->rx_csum = data;
284 if(netif_running(netdev)) {
285 e1000_down(adapter);
286 e1000_up(adapter);
287 } else
288 e1000_reset(adapter);
289 return 0;
292 static uint32_t
293 e1000_get_tx_csum(struct net_device *netdev)
295 return (netdev->features & NETIF_F_HW_CSUM) != 0;
298 static int
299 e1000_set_tx_csum(struct net_device *netdev, uint32_t data)
301 struct e1000_adapter *adapter = netdev_priv(netdev);
303 if(adapter->hw.mac_type < e1000_82543) {
304 if (!data)
305 return -EINVAL;
306 return 0;
309 if (data)
310 netdev->features |= NETIF_F_HW_CSUM;
311 else
312 netdev->features &= ~NETIF_F_HW_CSUM;
314 return 0;
317 #ifdef NETIF_F_TSO
318 static int
319 e1000_set_tso(struct net_device *netdev, uint32_t data)
321 struct e1000_adapter *adapter = netdev_priv(netdev);
322 if((adapter->hw.mac_type < e1000_82544) ||
323 (adapter->hw.mac_type == e1000_82547))
324 return data ? -EINVAL : 0;
326 if (data)
327 netdev->features |= NETIF_F_TSO;
328 else
329 netdev->features &= ~NETIF_F_TSO;
330 return 0;
332 #endif /* NETIF_F_TSO */
334 static uint32_t
335 e1000_get_msglevel(struct net_device *netdev)
337 struct e1000_adapter *adapter = netdev_priv(netdev);
338 return adapter->msg_enable;
341 static void
342 e1000_set_msglevel(struct net_device *netdev, uint32_t data)
344 struct e1000_adapter *adapter = netdev_priv(netdev);
345 adapter->msg_enable = data;
348 static int
349 e1000_get_regs_len(struct net_device *netdev)
351 #define E1000_REGS_LEN 32
352 return E1000_REGS_LEN * sizeof(uint32_t);
355 static void
356 e1000_get_regs(struct net_device *netdev,
357 struct ethtool_regs *regs, void *p)
359 struct e1000_adapter *adapter = netdev_priv(netdev);
360 struct e1000_hw *hw = &adapter->hw;
361 uint32_t *regs_buff = p;
362 uint16_t phy_data;
364 memset(p, 0, E1000_REGS_LEN * sizeof(uint32_t));
366 regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id;
368 regs_buff[0] = E1000_READ_REG(hw, CTRL);
369 regs_buff[1] = E1000_READ_REG(hw, STATUS);
371 regs_buff[2] = E1000_READ_REG(hw, RCTL);
372 regs_buff[3] = E1000_READ_REG(hw, RDLEN);
373 regs_buff[4] = E1000_READ_REG(hw, RDH);
374 regs_buff[5] = E1000_READ_REG(hw, RDT);
375 regs_buff[6] = E1000_READ_REG(hw, RDTR);
377 regs_buff[7] = E1000_READ_REG(hw, TCTL);
378 regs_buff[8] = E1000_READ_REG(hw, TDLEN);
379 regs_buff[9] = E1000_READ_REG(hw, TDH);
380 regs_buff[10] = E1000_READ_REG(hw, TDT);
381 regs_buff[11] = E1000_READ_REG(hw, TIDV);
383 regs_buff[12] = adapter->hw.phy_type; /* PHY type (IGP=1, M88=0) */
384 if(hw->phy_type == e1000_phy_igp) {
385 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
386 IGP01E1000_PHY_AGC_A);
387 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_A &
388 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
389 regs_buff[13] = (uint32_t)phy_data; /* cable length */
390 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
391 IGP01E1000_PHY_AGC_B);
392 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_B &
393 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
394 regs_buff[14] = (uint32_t)phy_data; /* cable length */
395 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
396 IGP01E1000_PHY_AGC_C);
397 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_C &
398 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
399 regs_buff[15] = (uint32_t)phy_data; /* cable length */
400 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
401 IGP01E1000_PHY_AGC_D);
402 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_D &
403 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
404 regs_buff[16] = (uint32_t)phy_data; /* cable length */
405 regs_buff[17] = 0; /* extended 10bt distance (not needed) */
406 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0);
407 e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS &
408 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
409 regs_buff[18] = (uint32_t)phy_data; /* cable polarity */
410 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
411 IGP01E1000_PHY_PCS_INIT_REG);
412 e1000_read_phy_reg(hw, IGP01E1000_PHY_PCS_INIT_REG &
413 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
414 regs_buff[19] = (uint32_t)phy_data; /* cable polarity */
415 regs_buff[20] = 0; /* polarity correction enabled (always) */
416 regs_buff[22] = 0; /* phy receive errors (unavailable) */
417 regs_buff[23] = regs_buff[18]; /* mdix mode */
418 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0);
419 } else {
420 e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
421 regs_buff[13] = (uint32_t)phy_data; /* cable length */
422 regs_buff[14] = 0; /* Dummy (to align w/ IGP phy reg dump) */
423 regs_buff[15] = 0; /* Dummy (to align w/ IGP phy reg dump) */
424 regs_buff[16] = 0; /* Dummy (to align w/ IGP phy reg dump) */
425 e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
426 regs_buff[17] = (uint32_t)phy_data; /* extended 10bt distance */
427 regs_buff[18] = regs_buff[13]; /* cable polarity */
428 regs_buff[19] = 0; /* Dummy (to align w/ IGP phy reg dump) */
429 regs_buff[20] = regs_buff[17]; /* polarity correction */
430 /* phy receive errors */
431 regs_buff[22] = adapter->phy_stats.receive_errors;
432 regs_buff[23] = regs_buff[13]; /* mdix mode */
434 regs_buff[21] = adapter->phy_stats.idle_errors; /* phy idle errors */
435 e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data);
436 regs_buff[24] = (uint32_t)phy_data; /* phy local receiver status */
437 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */
438 if(hw->mac_type >= e1000_82540 &&
439 hw->media_type == e1000_media_type_copper) {
440 regs_buff[26] = E1000_READ_REG(hw, MANC);
444 static int
445 e1000_get_eeprom_len(struct net_device *netdev)
447 struct e1000_adapter *adapter = netdev_priv(netdev);
448 return adapter->hw.eeprom.word_size * 2;
451 static int
452 e1000_get_eeprom(struct net_device *netdev,
453 struct ethtool_eeprom *eeprom, uint8_t *bytes)
455 struct e1000_adapter *adapter = netdev_priv(netdev);
456 struct e1000_hw *hw = &adapter->hw;
457 uint16_t *eeprom_buff;
458 int first_word, last_word;
459 int ret_val = 0;
460 uint16_t i;
462 if(eeprom->len == 0)
463 return -EINVAL;
465 eeprom->magic = hw->vendor_id | (hw->device_id << 16);
467 first_word = eeprom->offset >> 1;
468 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
470 eeprom_buff = kmalloc(sizeof(uint16_t) *
471 (last_word - first_word + 1), GFP_KERNEL);
472 if(!eeprom_buff)
473 return -ENOMEM;
475 if(hw->eeprom.type == e1000_eeprom_spi)
476 ret_val = e1000_read_eeprom(hw, first_word,
477 last_word - first_word + 1,
478 eeprom_buff);
479 else {
480 for (i = 0; i < last_word - first_word + 1; i++)
481 if((ret_val = e1000_read_eeprom(hw, first_word + i, 1,
482 &eeprom_buff[i])))
483 break;
486 /* Device's eeprom is always little-endian, word addressable */
487 for (i = 0; i < last_word - first_word + 1; i++)
488 le16_to_cpus(&eeprom_buff[i]);
490 memcpy(bytes, (uint8_t *)eeprom_buff + (eeprom->offset & 1),
491 eeprom->len);
492 kfree(eeprom_buff);
494 return ret_val;
497 static int
498 e1000_set_eeprom(struct net_device *netdev,
499 struct ethtool_eeprom *eeprom, uint8_t *bytes)
501 struct e1000_adapter *adapter = netdev_priv(netdev);
502 struct e1000_hw *hw = &adapter->hw;
503 uint16_t *eeprom_buff;
504 void *ptr;
505 int max_len, first_word, last_word, ret_val = 0;
506 uint16_t i;
508 if(eeprom->len == 0)
509 return -EOPNOTSUPP;
511 if(eeprom->magic != (hw->vendor_id | (hw->device_id << 16)))
512 return -EFAULT;
514 max_len = hw->eeprom.word_size * 2;
516 first_word = eeprom->offset >> 1;
517 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
518 eeprom_buff = kmalloc(max_len, GFP_KERNEL);
519 if(!eeprom_buff)
520 return -ENOMEM;
522 ptr = (void *)eeprom_buff;
524 if(eeprom->offset & 1) {
525 /* need read/modify/write of first changed EEPROM word */
526 /* only the second byte of the word is being modified */
527 ret_val = e1000_read_eeprom(hw, first_word, 1,
528 &eeprom_buff[0]);
529 ptr++;
531 if(((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) {
532 /* need read/modify/write of last changed EEPROM word */
533 /* only the first byte of the word is being modified */
534 ret_val = e1000_read_eeprom(hw, last_word, 1,
535 &eeprom_buff[last_word - first_word]);
538 /* Device's eeprom is always little-endian, word addressable */
539 for (i = 0; i < last_word - first_word + 1; i++)
540 le16_to_cpus(&eeprom_buff[i]);
542 memcpy(ptr, bytes, eeprom->len);
544 for (i = 0; i < last_word - first_word + 1; i++)
545 eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]);
547 ret_val = e1000_write_eeprom(hw, first_word,
548 last_word - first_word + 1, eeprom_buff);
550 /* Update the checksum over the first part of the EEPROM if needed */
551 if((ret_val == 0) && first_word <= EEPROM_CHECKSUM_REG)
552 e1000_update_eeprom_checksum(hw);
554 kfree(eeprom_buff);
555 return ret_val;
558 static void
559 e1000_get_drvinfo(struct net_device *netdev,
560 struct ethtool_drvinfo *drvinfo)
562 struct e1000_adapter *adapter = netdev_priv(netdev);
564 strncpy(drvinfo->driver, e1000_driver_name, 32);
565 strncpy(drvinfo->version, e1000_driver_version, 32);
566 strncpy(drvinfo->fw_version, "N/A", 32);
567 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
568 drvinfo->n_stats = E1000_STATS_LEN;
569 drvinfo->testinfo_len = E1000_TEST_LEN;
570 drvinfo->regdump_len = e1000_get_regs_len(netdev);
571 drvinfo->eedump_len = e1000_get_eeprom_len(netdev);
574 static void
575 e1000_get_ringparam(struct net_device *netdev,
576 struct ethtool_ringparam *ring)
578 struct e1000_adapter *adapter = netdev_priv(netdev);
579 e1000_mac_type mac_type = adapter->hw.mac_type;
580 struct e1000_tx_ring *txdr = adapter->tx_ring;
581 struct e1000_rx_ring *rxdr = adapter->rx_ring;
583 ring->rx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_RXD :
584 E1000_MAX_82544_RXD;
585 ring->tx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_TXD :
586 E1000_MAX_82544_TXD;
587 ring->rx_mini_max_pending = 0;
588 ring->rx_jumbo_max_pending = 0;
589 ring->rx_pending = rxdr->count;
590 ring->tx_pending = txdr->count;
591 ring->rx_mini_pending = 0;
592 ring->rx_jumbo_pending = 0;
595 static int
596 e1000_set_ringparam(struct net_device *netdev,
597 struct ethtool_ringparam *ring)
599 struct e1000_adapter *adapter = netdev_priv(netdev);
600 e1000_mac_type mac_type = adapter->hw.mac_type;
601 struct e1000_tx_ring *txdr, *tx_old, *tx_new;
602 struct e1000_rx_ring *rxdr, *rx_old, *rx_new;
603 int i, err, tx_ring_size, rx_ring_size;
605 tx_ring_size = sizeof(struct e1000_tx_ring) * adapter->num_queues;
606 rx_ring_size = sizeof(struct e1000_rx_ring) * adapter->num_queues;
608 if (netif_running(adapter->netdev))
609 e1000_down(adapter);
611 tx_old = adapter->tx_ring;
612 rx_old = adapter->rx_ring;
614 adapter->tx_ring = kmalloc(tx_ring_size, GFP_KERNEL);
615 if (!adapter->tx_ring) {
616 err = -ENOMEM;
617 goto err_setup_rx;
619 memset(adapter->tx_ring, 0, tx_ring_size);
621 adapter->rx_ring = kmalloc(rx_ring_size, GFP_KERNEL);
622 if (!adapter->rx_ring) {
623 kfree(adapter->tx_ring);
624 err = -ENOMEM;
625 goto err_setup_rx;
627 memset(adapter->rx_ring, 0, rx_ring_size);
629 txdr = adapter->tx_ring;
630 rxdr = adapter->rx_ring;
632 if((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
633 return -EINVAL;
635 rxdr->count = max(ring->rx_pending,(uint32_t)E1000_MIN_RXD);
636 rxdr->count = min(rxdr->count,(uint32_t)(mac_type < e1000_82544 ?
637 E1000_MAX_RXD : E1000_MAX_82544_RXD));
638 E1000_ROUNDUP(rxdr->count, REQ_RX_DESCRIPTOR_MULTIPLE);
640 txdr->count = max(ring->tx_pending,(uint32_t)E1000_MIN_TXD);
641 txdr->count = min(txdr->count,(uint32_t)(mac_type < e1000_82544 ?
642 E1000_MAX_TXD : E1000_MAX_82544_TXD));
643 E1000_ROUNDUP(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
645 for (i = 0; i < adapter->num_queues; i++) {
646 txdr[i].count = txdr->count;
647 rxdr[i].count = rxdr->count;
650 if(netif_running(adapter->netdev)) {
651 /* Try to get new resources before deleting old */
652 if ((err = e1000_setup_all_rx_resources(adapter)))
653 goto err_setup_rx;
654 if ((err = e1000_setup_all_tx_resources(adapter)))
655 goto err_setup_tx;
657 /* save the new, restore the old in order to free it,
658 * then restore the new back again */
660 rx_new = adapter->rx_ring;
661 tx_new = adapter->tx_ring;
662 adapter->rx_ring = rx_old;
663 adapter->tx_ring = tx_old;
664 e1000_free_all_rx_resources(adapter);
665 e1000_free_all_tx_resources(adapter);
666 kfree(tx_old);
667 kfree(rx_old);
668 adapter->rx_ring = rx_new;
669 adapter->tx_ring = tx_new;
670 if((err = e1000_up(adapter)))
671 return err;
674 return 0;
675 err_setup_tx:
676 e1000_free_all_rx_resources(adapter);
677 err_setup_rx:
678 adapter->rx_ring = rx_old;
679 adapter->tx_ring = tx_old;
680 e1000_up(adapter);
681 return err;
684 #define REG_PATTERN_TEST(R, M, W) \
686 uint32_t pat, value; \
687 uint32_t test[] = \
688 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; \
689 for(pat = 0; pat < sizeof(test)/sizeof(test[0]); pat++) { \
690 E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \
691 value = E1000_READ_REG(&adapter->hw, R); \
692 if(value != (test[pat] & W & M)) { \
693 DPRINTK(DRV, ERR, "pattern test reg %04X failed: got " \
694 "0x%08X expected 0x%08X\n", \
695 E1000_##R, value, (test[pat] & W & M)); \
696 *data = (adapter->hw.mac_type < e1000_82543) ? \
697 E1000_82542_##R : E1000_##R; \
698 return 1; \
703 #define REG_SET_AND_CHECK(R, M, W) \
705 uint32_t value; \
706 E1000_WRITE_REG(&adapter->hw, R, W & M); \
707 value = E1000_READ_REG(&adapter->hw, R); \
708 if((W & M) != (value & M)) { \
709 DPRINTK(DRV, ERR, "set/check reg %04X test failed: got 0x%08X "\
710 "expected 0x%08X\n", E1000_##R, (value & M), (W & M)); \
711 *data = (adapter->hw.mac_type < e1000_82543) ? \
712 E1000_82542_##R : E1000_##R; \
713 return 1; \
717 static int
718 e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
720 uint32_t value, before, after;
721 uint32_t i, toggle;
723 /* The status register is Read Only, so a write should fail.
724 * Some bits that get toggled are ignored.
726 switch (adapter->hw.mac_type) {
727 /* there are several bits on newer hardware that are r/w */
728 case e1000_82571:
729 case e1000_82572:
730 toggle = 0x7FFFF3FF;
731 break;
732 case e1000_82573:
733 toggle = 0x7FFFF033;
734 break;
735 default:
736 toggle = 0xFFFFF833;
737 break;
740 before = E1000_READ_REG(&adapter->hw, STATUS);
741 value = (E1000_READ_REG(&adapter->hw, STATUS) & toggle);
742 E1000_WRITE_REG(&adapter->hw, STATUS, toggle);
743 after = E1000_READ_REG(&adapter->hw, STATUS) & toggle;
744 if(value != after) {
745 DPRINTK(DRV, ERR, "failed STATUS register test got: "
746 "0x%08X expected: 0x%08X\n", after, value);
747 *data = 1;
748 return 1;
750 /* restore previous status */
751 E1000_WRITE_REG(&adapter->hw, STATUS, before);
753 REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
754 REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF);
755 REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF);
756 REG_PATTERN_TEST(VET, 0x0000FFFF, 0xFFFFFFFF);
757 REG_PATTERN_TEST(RDTR, 0x0000FFFF, 0xFFFFFFFF);
758 REG_PATTERN_TEST(RDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
759 REG_PATTERN_TEST(RDLEN, 0x000FFF80, 0x000FFFFF);
760 REG_PATTERN_TEST(RDH, 0x0000FFFF, 0x0000FFFF);
761 REG_PATTERN_TEST(RDT, 0x0000FFFF, 0x0000FFFF);
762 REG_PATTERN_TEST(FCRTH, 0x0000FFF8, 0x0000FFF8);
763 REG_PATTERN_TEST(FCTTV, 0x0000FFFF, 0x0000FFFF);
764 REG_PATTERN_TEST(TIPG, 0x3FFFFFFF, 0x3FFFFFFF);
765 REG_PATTERN_TEST(TDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
766 REG_PATTERN_TEST(TDLEN, 0x000FFF80, 0x000FFFFF);
768 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000);
769 REG_SET_AND_CHECK(RCTL, 0x06DFB3FE, 0x003FFFFB);
770 REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000);
772 if(adapter->hw.mac_type >= e1000_82543) {
774 REG_SET_AND_CHECK(RCTL, 0x06DFB3FE, 0xFFFFFFFF);
775 REG_PATTERN_TEST(RDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
776 REG_PATTERN_TEST(TXCW, 0xC000FFFF, 0x0000FFFF);
777 REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
778 REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF);
780 for(i = 0; i < E1000_RAR_ENTRIES; i++) {
781 REG_PATTERN_TEST(RA + ((i << 1) << 2), 0xFFFFFFFF,
782 0xFFFFFFFF);
783 REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF,
784 0xFFFFFFFF);
787 } else {
789 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x01FFFFFF);
790 REG_PATTERN_TEST(RDBAL, 0xFFFFF000, 0xFFFFFFFF);
791 REG_PATTERN_TEST(TXCW, 0x0000FFFF, 0x0000FFFF);
792 REG_PATTERN_TEST(TDBAL, 0xFFFFF000, 0xFFFFFFFF);
796 for(i = 0; i < E1000_MC_TBL_SIZE; i++)
797 REG_PATTERN_TEST(MTA + (i << 2), 0xFFFFFFFF, 0xFFFFFFFF);
799 *data = 0;
800 return 0;
803 static int
804 e1000_eeprom_test(struct e1000_adapter *adapter, uint64_t *data)
806 uint16_t temp;
807 uint16_t checksum = 0;
808 uint16_t i;
810 *data = 0;
811 /* Read and add up the contents of the EEPROM */
812 for(i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) {
813 if((e1000_read_eeprom(&adapter->hw, i, 1, &temp)) < 0) {
814 *data = 1;
815 break;
817 checksum += temp;
820 /* If Checksum is not Correct return error else test passed */
821 if((checksum != (uint16_t) EEPROM_SUM) && !(*data))
822 *data = 2;
824 return *data;
827 static irqreturn_t
828 e1000_test_intr(int irq,
829 void *data,
830 struct pt_regs *regs)
832 struct net_device *netdev = (struct net_device *) data;
833 struct e1000_adapter *adapter = netdev_priv(netdev);
835 adapter->test_icr |= E1000_READ_REG(&adapter->hw, ICR);
837 return IRQ_HANDLED;
840 static int
841 e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
843 struct net_device *netdev = adapter->netdev;
844 uint32_t mask, i=0, shared_int = TRUE;
845 uint32_t irq = adapter->pdev->irq;
847 *data = 0;
849 /* Hook up test interrupt handler just for this test */
850 if(!request_irq(irq, &e1000_test_intr, 0, netdev->name, netdev)) {
851 shared_int = FALSE;
852 } else if(request_irq(irq, &e1000_test_intr, SA_SHIRQ,
853 netdev->name, netdev)){
854 *data = 1;
855 return -1;
858 /* Disable all the interrupts */
859 E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF);
860 msec_delay(10);
862 /* Test each interrupt */
863 for(; i < 10; i++) {
865 /* Interrupt to test */
866 mask = 1 << i;
868 if(!shared_int) {
869 /* Disable the interrupt to be reported in
870 * the cause register and then force the same
871 * interrupt and see if one gets posted. If
872 * an interrupt was posted to the bus, the
873 * test failed.
875 adapter->test_icr = 0;
876 E1000_WRITE_REG(&adapter->hw, IMC, mask);
877 E1000_WRITE_REG(&adapter->hw, ICS, mask);
878 msec_delay(10);
880 if(adapter->test_icr & mask) {
881 *data = 3;
882 break;
886 /* Enable the interrupt to be reported in
887 * the cause register and then force the same
888 * interrupt and see if one gets posted. If
889 * an interrupt was not posted to the bus, the
890 * test failed.
892 adapter->test_icr = 0;
893 E1000_WRITE_REG(&adapter->hw, IMS, mask);
894 E1000_WRITE_REG(&adapter->hw, ICS, mask);
895 msec_delay(10);
897 if(!(adapter->test_icr & mask)) {
898 *data = 4;
899 break;
902 if(!shared_int) {
903 /* Disable the other interrupts to be reported in
904 * the cause register and then force the other
905 * interrupts and see if any get posted. If
906 * an interrupt was posted to the bus, the
907 * test failed.
909 adapter->test_icr = 0;
910 E1000_WRITE_REG(&adapter->hw, IMC, ~mask & 0x00007FFF);
911 E1000_WRITE_REG(&adapter->hw, ICS, ~mask & 0x00007FFF);
912 msec_delay(10);
914 if(adapter->test_icr) {
915 *data = 5;
916 break;
921 /* Disable all the interrupts */
922 E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF);
923 msec_delay(10);
925 /* Unhook test interrupt handler */
926 free_irq(irq, netdev);
928 return *data;
931 static void
932 e1000_free_desc_rings(struct e1000_adapter *adapter)
934 struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
935 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
936 struct pci_dev *pdev = adapter->pdev;
937 int i;
939 if(txdr->desc && txdr->buffer_info) {
940 for(i = 0; i < txdr->count; i++) {
941 if(txdr->buffer_info[i].dma)
942 pci_unmap_single(pdev, txdr->buffer_info[i].dma,
943 txdr->buffer_info[i].length,
944 PCI_DMA_TODEVICE);
945 if(txdr->buffer_info[i].skb)
946 dev_kfree_skb(txdr->buffer_info[i].skb);
950 if(rxdr->desc && rxdr->buffer_info) {
951 for(i = 0; i < rxdr->count; i++) {
952 if(rxdr->buffer_info[i].dma)
953 pci_unmap_single(pdev, rxdr->buffer_info[i].dma,
954 rxdr->buffer_info[i].length,
955 PCI_DMA_FROMDEVICE);
956 if(rxdr->buffer_info[i].skb)
957 dev_kfree_skb(rxdr->buffer_info[i].skb);
961 if(txdr->desc)
962 pci_free_consistent(pdev, txdr->size, txdr->desc, txdr->dma);
963 if(rxdr->desc)
964 pci_free_consistent(pdev, rxdr->size, rxdr->desc, rxdr->dma);
966 if(txdr->buffer_info)
967 kfree(txdr->buffer_info);
968 if(rxdr->buffer_info)
969 kfree(rxdr->buffer_info);
971 return;
974 static int
975 e1000_setup_desc_rings(struct e1000_adapter *adapter)
977 struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
978 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
979 struct pci_dev *pdev = adapter->pdev;
980 uint32_t rctl;
981 int size, i, ret_val;
983 /* Setup Tx descriptor ring and Tx buffers */
985 if(!txdr->count)
986 txdr->count = E1000_DEFAULT_TXD;
988 size = txdr->count * sizeof(struct e1000_buffer);
989 if(!(txdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
990 ret_val = 1;
991 goto err_nomem;
993 memset(txdr->buffer_info, 0, size);
995 txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
996 E1000_ROUNDUP(txdr->size, 4096);
997 if(!(txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma))) {
998 ret_val = 2;
999 goto err_nomem;
1001 memset(txdr->desc, 0, txdr->size);
1002 txdr->next_to_use = txdr->next_to_clean = 0;
1004 E1000_WRITE_REG(&adapter->hw, TDBAL,
1005 ((uint64_t) txdr->dma & 0x00000000FFFFFFFF));
1006 E1000_WRITE_REG(&adapter->hw, TDBAH, ((uint64_t) txdr->dma >> 32));
1007 E1000_WRITE_REG(&adapter->hw, TDLEN,
1008 txdr->count * sizeof(struct e1000_tx_desc));
1009 E1000_WRITE_REG(&adapter->hw, TDH, 0);
1010 E1000_WRITE_REG(&adapter->hw, TDT, 0);
1011 E1000_WRITE_REG(&adapter->hw, TCTL,
1012 E1000_TCTL_PSP | E1000_TCTL_EN |
1013 E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT |
1014 E1000_FDX_COLLISION_DISTANCE << E1000_COLD_SHIFT);
1016 for(i = 0; i < txdr->count; i++) {
1017 struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*txdr, i);
1018 struct sk_buff *skb;
1019 unsigned int size = 1024;
1021 if(!(skb = alloc_skb(size, GFP_KERNEL))) {
1022 ret_val = 3;
1023 goto err_nomem;
1025 skb_put(skb, size);
1026 txdr->buffer_info[i].skb = skb;
1027 txdr->buffer_info[i].length = skb->len;
1028 txdr->buffer_info[i].dma =
1029 pci_map_single(pdev, skb->data, skb->len,
1030 PCI_DMA_TODEVICE);
1031 tx_desc->buffer_addr = cpu_to_le64(txdr->buffer_info[i].dma);
1032 tx_desc->lower.data = cpu_to_le32(skb->len);
1033 tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP |
1034 E1000_TXD_CMD_IFCS |
1035 E1000_TXD_CMD_RPS);
1036 tx_desc->upper.data = 0;
1039 /* Setup Rx descriptor ring and Rx buffers */
1041 if(!rxdr->count)
1042 rxdr->count = E1000_DEFAULT_RXD;
1044 size = rxdr->count * sizeof(struct e1000_buffer);
1045 if(!(rxdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
1046 ret_val = 4;
1047 goto err_nomem;
1049 memset(rxdr->buffer_info, 0, size);
1051 rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc);
1052 if(!(rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma))) {
1053 ret_val = 5;
1054 goto err_nomem;
1056 memset(rxdr->desc, 0, rxdr->size);
1057 rxdr->next_to_use = rxdr->next_to_clean = 0;
1059 rctl = E1000_READ_REG(&adapter->hw, RCTL);
1060 E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_RCTL_EN);
1061 E1000_WRITE_REG(&adapter->hw, RDBAL,
1062 ((uint64_t) rxdr->dma & 0xFFFFFFFF));
1063 E1000_WRITE_REG(&adapter->hw, RDBAH, ((uint64_t) rxdr->dma >> 32));
1064 E1000_WRITE_REG(&adapter->hw, RDLEN, rxdr->size);
1065 E1000_WRITE_REG(&adapter->hw, RDH, 0);
1066 E1000_WRITE_REG(&adapter->hw, RDT, 0);
1067 rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 |
1068 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
1069 (adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT);
1070 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
1072 for(i = 0; i < rxdr->count; i++) {
1073 struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i);
1074 struct sk_buff *skb;
1076 if(!(skb = alloc_skb(E1000_RXBUFFER_2048 + NET_IP_ALIGN,
1077 GFP_KERNEL))) {
1078 ret_val = 6;
1079 goto err_nomem;
1081 skb_reserve(skb, NET_IP_ALIGN);
1082 rxdr->buffer_info[i].skb = skb;
1083 rxdr->buffer_info[i].length = E1000_RXBUFFER_2048;
1084 rxdr->buffer_info[i].dma =
1085 pci_map_single(pdev, skb->data, E1000_RXBUFFER_2048,
1086 PCI_DMA_FROMDEVICE);
1087 rx_desc->buffer_addr = cpu_to_le64(rxdr->buffer_info[i].dma);
1088 memset(skb->data, 0x00, skb->len);
1091 return 0;
1093 err_nomem:
1094 e1000_free_desc_rings(adapter);
1095 return ret_val;
1098 static void
1099 e1000_phy_disable_receiver(struct e1000_adapter *adapter)
1101 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1102 e1000_write_phy_reg(&adapter->hw, 29, 0x001F);
1103 e1000_write_phy_reg(&adapter->hw, 30, 0x8FFC);
1104 e1000_write_phy_reg(&adapter->hw, 29, 0x001A);
1105 e1000_write_phy_reg(&adapter->hw, 30, 0x8FF0);
1108 static void
1109 e1000_phy_reset_clk_and_crs(struct e1000_adapter *adapter)
1111 uint16_t phy_reg;
1113 /* Because we reset the PHY above, we need to re-force TX_CLK in the
1114 * Extended PHY Specific Control Register to 25MHz clock. This
1115 * value defaults back to a 2.5MHz clock when the PHY is reset.
1117 e1000_read_phy_reg(&adapter->hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg);
1118 phy_reg |= M88E1000_EPSCR_TX_CLK_25;
1119 e1000_write_phy_reg(&adapter->hw,
1120 M88E1000_EXT_PHY_SPEC_CTRL, phy_reg);
1122 /* In addition, because of the s/w reset above, we need to enable
1123 * CRS on TX. This must be set for both full and half duplex
1124 * operation.
1126 e1000_read_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, &phy_reg);
1127 phy_reg |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
1128 e1000_write_phy_reg(&adapter->hw,
1129 M88E1000_PHY_SPEC_CTRL, phy_reg);
1132 static int
1133 e1000_nonintegrated_phy_loopback(struct e1000_adapter *adapter)
1135 uint32_t ctrl_reg;
1136 uint16_t phy_reg;
1138 /* Setup the Device Control Register for PHY loopback test. */
1140 ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL);
1141 ctrl_reg |= (E1000_CTRL_ILOS | /* Invert Loss-Of-Signal */
1142 E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1143 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1144 E1000_CTRL_SPD_1000 | /* Force Speed to 1000 */
1145 E1000_CTRL_FD); /* Force Duplex to FULL */
1147 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg);
1149 /* Read the PHY Specific Control Register (0x10) */
1150 e1000_read_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, &phy_reg);
1152 /* Clear Auto-Crossover bits in PHY Specific Control Register
1153 * (bits 6:5).
1155 phy_reg &= ~M88E1000_PSCR_AUTO_X_MODE;
1156 e1000_write_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, phy_reg);
1158 /* Perform software reset on the PHY */
1159 e1000_phy_reset(&adapter->hw);
1161 /* Have to setup TX_CLK and TX_CRS after software reset */
1162 e1000_phy_reset_clk_and_crs(adapter);
1164 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8100);
1166 /* Wait for reset to complete. */
1167 udelay(500);
1169 /* Have to setup TX_CLK and TX_CRS after software reset */
1170 e1000_phy_reset_clk_and_crs(adapter);
1172 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1173 e1000_phy_disable_receiver(adapter);
1175 /* Set the loopback bit in the PHY control register. */
1176 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
1177 phy_reg |= MII_CR_LOOPBACK;
1178 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg);
1180 /* Setup TX_CLK and TX_CRS one more time. */
1181 e1000_phy_reset_clk_and_crs(adapter);
1183 /* Check Phy Configuration */
1184 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
1185 if(phy_reg != 0x4100)
1186 return 9;
1188 e1000_read_phy_reg(&adapter->hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg);
1189 if(phy_reg != 0x0070)
1190 return 10;
1192 e1000_read_phy_reg(&adapter->hw, 29, &phy_reg);
1193 if(phy_reg != 0x001A)
1194 return 11;
1196 return 0;
1199 static int
1200 e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1202 uint32_t ctrl_reg = 0;
1203 uint32_t stat_reg = 0;
1205 adapter->hw.autoneg = FALSE;
1207 if(adapter->hw.phy_type == e1000_phy_m88) {
1208 /* Auto-MDI/MDIX Off */
1209 e1000_write_phy_reg(&adapter->hw,
1210 M88E1000_PHY_SPEC_CTRL, 0x0808);
1211 /* reset to update Auto-MDI/MDIX */
1212 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x9140);
1213 /* autoneg off */
1214 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8140);
1216 /* force 1000, set loopback */
1217 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x4140);
1219 /* Now set up the MAC to the same speed/duplex as the PHY. */
1220 ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL);
1221 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
1222 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1223 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1224 E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
1225 E1000_CTRL_FD); /* Force Duplex to FULL */
1227 if(adapter->hw.media_type == e1000_media_type_copper &&
1228 adapter->hw.phy_type == e1000_phy_m88) {
1229 ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
1230 } else {
1231 /* Set the ILOS bit on the fiber Nic is half
1232 * duplex link is detected. */
1233 stat_reg = E1000_READ_REG(&adapter->hw, STATUS);
1234 if((stat_reg & E1000_STATUS_FD) == 0)
1235 ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
1238 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg);
1240 /* Disable the receiver on the PHY so when a cable is plugged in, the
1241 * PHY does not begin to autoneg when a cable is reconnected to the NIC.
1243 if(adapter->hw.phy_type == e1000_phy_m88)
1244 e1000_phy_disable_receiver(adapter);
1246 udelay(500);
1248 return 0;
1251 static int
1252 e1000_set_phy_loopback(struct e1000_adapter *adapter)
1254 uint16_t phy_reg = 0;
1255 uint16_t count = 0;
1257 switch (adapter->hw.mac_type) {
1258 case e1000_82543:
1259 if(adapter->hw.media_type == e1000_media_type_copper) {
1260 /* Attempt to setup Loopback mode on Non-integrated PHY.
1261 * Some PHY registers get corrupted at random, so
1262 * attempt this 10 times.
1264 while(e1000_nonintegrated_phy_loopback(adapter) &&
1265 count++ < 10);
1266 if(count < 11)
1267 return 0;
1269 break;
1271 case e1000_82544:
1272 case e1000_82540:
1273 case e1000_82545:
1274 case e1000_82545_rev_3:
1275 case e1000_82546:
1276 case e1000_82546_rev_3:
1277 case e1000_82541:
1278 case e1000_82541_rev_2:
1279 case e1000_82547:
1280 case e1000_82547_rev_2:
1281 case e1000_82571:
1282 case e1000_82572:
1283 case e1000_82573:
1284 return e1000_integrated_phy_loopback(adapter);
1285 break;
1287 default:
1288 /* Default PHY loopback work is to read the MII
1289 * control register and assert bit 14 (loopback mode).
1291 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
1292 phy_reg |= MII_CR_LOOPBACK;
1293 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg);
1294 return 0;
1295 break;
1298 return 8;
1301 static int
1302 e1000_setup_loopback_test(struct e1000_adapter *adapter)
1304 uint32_t rctl;
1306 if(adapter->hw.media_type == e1000_media_type_fiber ||
1307 adapter->hw.media_type == e1000_media_type_internal_serdes) {
1308 if(adapter->hw.mac_type == e1000_82545 ||
1309 adapter->hw.mac_type == e1000_82546 ||
1310 adapter->hw.mac_type == e1000_82545_rev_3 ||
1311 adapter->hw.mac_type == e1000_82546_rev_3)
1312 return e1000_set_phy_loopback(adapter);
1313 else {
1314 rctl = E1000_READ_REG(&adapter->hw, RCTL);
1315 rctl |= E1000_RCTL_LBM_TCVR;
1316 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
1317 return 0;
1319 } else if(adapter->hw.media_type == e1000_media_type_copper)
1320 return e1000_set_phy_loopback(adapter);
1322 return 7;
1325 static void
1326 e1000_loopback_cleanup(struct e1000_adapter *adapter)
1328 uint32_t rctl;
1329 uint16_t phy_reg;
1331 rctl = E1000_READ_REG(&adapter->hw, RCTL);
1332 rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
1333 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
1335 if(adapter->hw.media_type == e1000_media_type_copper ||
1336 ((adapter->hw.media_type == e1000_media_type_fiber ||
1337 adapter->hw.media_type == e1000_media_type_internal_serdes) &&
1338 (adapter->hw.mac_type == e1000_82545 ||
1339 adapter->hw.mac_type == e1000_82546 ||
1340 adapter->hw.mac_type == e1000_82545_rev_3 ||
1341 adapter->hw.mac_type == e1000_82546_rev_3))) {
1342 adapter->hw.autoneg = TRUE;
1343 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
1344 if(phy_reg & MII_CR_LOOPBACK) {
1345 phy_reg &= ~MII_CR_LOOPBACK;
1346 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg);
1347 e1000_phy_reset(&adapter->hw);
1352 static void
1353 e1000_create_lbtest_frame(struct sk_buff *skb, unsigned int frame_size)
1355 memset(skb->data, 0xFF, frame_size);
1356 frame_size = (frame_size % 2) ? (frame_size - 1) : frame_size;
1357 memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
1358 memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
1359 memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
1362 static int
1363 e1000_check_lbtest_frame(struct sk_buff *skb, unsigned int frame_size)
1365 frame_size = (frame_size % 2) ? (frame_size - 1) : frame_size;
1366 if(*(skb->data + 3) == 0xFF) {
1367 if((*(skb->data + frame_size / 2 + 10) == 0xBE) &&
1368 (*(skb->data + frame_size / 2 + 12) == 0xAF)) {
1369 return 0;
1372 return 13;
1375 static int
1376 e1000_run_loopback_test(struct e1000_adapter *adapter)
1378 struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
1379 struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
1380 struct pci_dev *pdev = adapter->pdev;
1381 int i, j, k, l, lc, good_cnt, ret_val=0;
1382 unsigned long time;
1384 E1000_WRITE_REG(&adapter->hw, RDT, rxdr->count - 1);
1386 /* Calculate the loop count based on the largest descriptor ring
1387 * The idea is to wrap the largest ring a number of times using 64
1388 * send/receive pairs during each loop
1391 if(rxdr->count <= txdr->count)
1392 lc = ((txdr->count / 64) * 2) + 1;
1393 else
1394 lc = ((rxdr->count / 64) * 2) + 1;
1396 k = l = 0;
1397 for(j = 0; j <= lc; j++) { /* loop count loop */
1398 for(i = 0; i < 64; i++) { /* send the packets */
1399 e1000_create_lbtest_frame(txdr->buffer_info[i].skb,
1400 1024);
1401 pci_dma_sync_single_for_device(pdev,
1402 txdr->buffer_info[k].dma,
1403 txdr->buffer_info[k].length,
1404 PCI_DMA_TODEVICE);
1405 if(unlikely(++k == txdr->count)) k = 0;
1407 E1000_WRITE_REG(&adapter->hw, TDT, k);
1408 msec_delay(200);
1409 time = jiffies; /* set the start time for the receive */
1410 good_cnt = 0;
1411 do { /* receive the sent packets */
1412 pci_dma_sync_single_for_cpu(pdev,
1413 rxdr->buffer_info[l].dma,
1414 rxdr->buffer_info[l].length,
1415 PCI_DMA_FROMDEVICE);
1417 ret_val = e1000_check_lbtest_frame(
1418 rxdr->buffer_info[l].skb,
1419 1024);
1420 if(!ret_val)
1421 good_cnt++;
1422 if(unlikely(++l == rxdr->count)) l = 0;
1423 /* time + 20 msecs (200 msecs on 2.4) is more than
1424 * enough time to complete the receives, if it's
1425 * exceeded, break and error off
1427 } while (good_cnt < 64 && jiffies < (time + 20));
1428 if(good_cnt != 64) {
1429 ret_val = 13; /* ret_val is the same as mis-compare */
1430 break;
1432 if(jiffies >= (time + 2)) {
1433 ret_val = 14; /* error code for time out error */
1434 break;
1436 } /* end loop count loop */
1437 return ret_val;
1440 static int
1441 e1000_loopback_test(struct e1000_adapter *adapter, uint64_t *data)
1443 if((*data = e1000_setup_desc_rings(adapter))) goto err_loopback;
1444 if((*data = e1000_setup_loopback_test(adapter))) goto err_loopback;
1445 *data = e1000_run_loopback_test(adapter);
1446 e1000_loopback_cleanup(adapter);
1447 e1000_free_desc_rings(adapter);
1448 err_loopback:
1449 return *data;
1452 static int
1453 e1000_link_test(struct e1000_adapter *adapter, uint64_t *data)
1455 *data = 0;
1456 if (adapter->hw.media_type == e1000_media_type_internal_serdes) {
1457 int i = 0;
1458 adapter->hw.serdes_link_down = TRUE;
1460 /* On some blade server designs, link establishment
1461 * could take as long as 2-3 minutes */
1462 do {
1463 e1000_check_for_link(&adapter->hw);
1464 if (adapter->hw.serdes_link_down == FALSE)
1465 return *data;
1466 msec_delay(20);
1467 } while (i++ < 3750);
1469 *data = 1;
1470 } else {
1471 e1000_check_for_link(&adapter->hw);
1472 if(adapter->hw.autoneg) /* if auto_neg is set wait for it */
1473 msec_delay(4000);
1475 if(!(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU)) {
1476 *data = 1;
1479 return *data;
1482 static int
1483 e1000_diag_test_count(struct net_device *netdev)
1485 return E1000_TEST_LEN;
1488 static void
1489 e1000_diag_test(struct net_device *netdev,
1490 struct ethtool_test *eth_test, uint64_t *data)
1492 struct e1000_adapter *adapter = netdev_priv(netdev);
1493 boolean_t if_running = netif_running(netdev);
1495 if(eth_test->flags == ETH_TEST_FL_OFFLINE) {
1496 /* Offline tests */
1498 /* save speed, duplex, autoneg settings */
1499 uint16_t autoneg_advertised = adapter->hw.autoneg_advertised;
1500 uint8_t forced_speed_duplex = adapter->hw.forced_speed_duplex;
1501 uint8_t autoneg = adapter->hw.autoneg;
1503 /* Link test performed before hardware reset so autoneg doesn't
1504 * interfere with test result */
1505 if(e1000_link_test(adapter, &data[4]))
1506 eth_test->flags |= ETH_TEST_FL_FAILED;
1508 if(if_running)
1509 e1000_down(adapter);
1510 else
1511 e1000_reset(adapter);
1513 if(e1000_reg_test(adapter, &data[0]))
1514 eth_test->flags |= ETH_TEST_FL_FAILED;
1516 e1000_reset(adapter);
1517 if(e1000_eeprom_test(adapter, &data[1]))
1518 eth_test->flags |= ETH_TEST_FL_FAILED;
1520 e1000_reset(adapter);
1521 if(e1000_intr_test(adapter, &data[2]))
1522 eth_test->flags |= ETH_TEST_FL_FAILED;
1524 e1000_reset(adapter);
1525 if(e1000_loopback_test(adapter, &data[3]))
1526 eth_test->flags |= ETH_TEST_FL_FAILED;
1528 /* restore speed, duplex, autoneg settings */
1529 adapter->hw.autoneg_advertised = autoneg_advertised;
1530 adapter->hw.forced_speed_duplex = forced_speed_duplex;
1531 adapter->hw.autoneg = autoneg;
1533 e1000_reset(adapter);
1534 if(if_running)
1535 e1000_up(adapter);
1536 } else {
1537 /* Online tests */
1538 if(e1000_link_test(adapter, &data[4]))
1539 eth_test->flags |= ETH_TEST_FL_FAILED;
1541 /* Offline tests aren't run; pass by default */
1542 data[0] = 0;
1543 data[1] = 0;
1544 data[2] = 0;
1545 data[3] = 0;
1549 static void
1550 e1000_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1552 struct e1000_adapter *adapter = netdev_priv(netdev);
1553 struct e1000_hw *hw = &adapter->hw;
1555 switch(adapter->hw.device_id) {
1556 case E1000_DEV_ID_82542:
1557 case E1000_DEV_ID_82543GC_FIBER:
1558 case E1000_DEV_ID_82543GC_COPPER:
1559 case E1000_DEV_ID_82544EI_FIBER:
1560 case E1000_DEV_ID_82546EB_QUAD_COPPER:
1561 case E1000_DEV_ID_82545EM_FIBER:
1562 case E1000_DEV_ID_82545EM_COPPER:
1563 wol->supported = 0;
1564 wol->wolopts = 0;
1565 return;
1567 case E1000_DEV_ID_82546EB_FIBER:
1568 case E1000_DEV_ID_82546GB_FIBER:
1569 /* Wake events only supported on port A for dual fiber */
1570 if(E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1) {
1571 wol->supported = 0;
1572 wol->wolopts = 0;
1573 return;
1575 /* Fall Through */
1577 default:
1578 wol->supported = WAKE_UCAST | WAKE_MCAST |
1579 WAKE_BCAST | WAKE_MAGIC;
1581 wol->wolopts = 0;
1582 if(adapter->wol & E1000_WUFC_EX)
1583 wol->wolopts |= WAKE_UCAST;
1584 if(adapter->wol & E1000_WUFC_MC)
1585 wol->wolopts |= WAKE_MCAST;
1586 if(adapter->wol & E1000_WUFC_BC)
1587 wol->wolopts |= WAKE_BCAST;
1588 if(adapter->wol & E1000_WUFC_MAG)
1589 wol->wolopts |= WAKE_MAGIC;
1590 return;
1594 static int
1595 e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1597 struct e1000_adapter *adapter = netdev_priv(netdev);
1598 struct e1000_hw *hw = &adapter->hw;
1600 switch(adapter->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 return wol->wolopts ? -EOPNOTSUPP : 0;
1610 case E1000_DEV_ID_82546EB_FIBER:
1611 case E1000_DEV_ID_82546GB_FIBER:
1612 /* Wake events only supported on port A for dual fiber */
1613 if(E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)
1614 return wol->wolopts ? -EOPNOTSUPP : 0;
1615 /* Fall Through */
1617 default:
1618 if(wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE))
1619 return -EOPNOTSUPP;
1621 adapter->wol = 0;
1623 if(wol->wolopts & WAKE_UCAST)
1624 adapter->wol |= E1000_WUFC_EX;
1625 if(wol->wolopts & WAKE_MCAST)
1626 adapter->wol |= E1000_WUFC_MC;
1627 if(wol->wolopts & WAKE_BCAST)
1628 adapter->wol |= E1000_WUFC_BC;
1629 if(wol->wolopts & WAKE_MAGIC)
1630 adapter->wol |= E1000_WUFC_MAG;
1633 return 0;
1636 /* toggle LED 4 times per second = 2 "blinks" per second */
1637 #define E1000_ID_INTERVAL (HZ/4)
1639 /* bit defines for adapter->led_status */
1640 #define E1000_LED_ON 0
1642 static void
1643 e1000_led_blink_callback(unsigned long data)
1645 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
1647 if(test_and_change_bit(E1000_LED_ON, &adapter->led_status))
1648 e1000_led_off(&adapter->hw);
1649 else
1650 e1000_led_on(&adapter->hw);
1652 mod_timer(&adapter->blink_timer, jiffies + E1000_ID_INTERVAL);
1655 static int
1656 e1000_phys_id(struct net_device *netdev, uint32_t data)
1658 struct e1000_adapter *adapter = netdev_priv(netdev);
1660 if(!data || data > (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ))
1661 data = (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ);
1663 if(adapter->hw.mac_type < e1000_82571) {
1664 if(!adapter->blink_timer.function) {
1665 init_timer(&adapter->blink_timer);
1666 adapter->blink_timer.function = e1000_led_blink_callback;
1667 adapter->blink_timer.data = (unsigned long) adapter;
1669 e1000_setup_led(&adapter->hw);
1670 mod_timer(&adapter->blink_timer, jiffies);
1671 msleep_interruptible(data * 1000);
1672 del_timer_sync(&adapter->blink_timer);
1674 else {
1675 E1000_WRITE_REG(&adapter->hw, LEDCTL, (E1000_LEDCTL_LED2_BLINK_RATE |
1676 E1000_LEDCTL_LED1_BLINK | E1000_LEDCTL_LED2_BLINK |
1677 (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED2_MODE_SHIFT) |
1678 (E1000_LEDCTL_MODE_LINK_ACTIVITY << E1000_LEDCTL_LED1_MODE_SHIFT) |
1679 (E1000_LEDCTL_MODE_LED_OFF << E1000_LEDCTL_LED0_MODE_SHIFT)));
1680 msleep_interruptible(data * 1000);
1683 e1000_led_off(&adapter->hw);
1684 clear_bit(E1000_LED_ON, &adapter->led_status);
1685 e1000_cleanup_led(&adapter->hw);
1687 return 0;
1690 static int
1691 e1000_nway_reset(struct net_device *netdev)
1693 struct e1000_adapter *adapter = netdev_priv(netdev);
1694 if(netif_running(netdev)) {
1695 e1000_down(adapter);
1696 e1000_up(adapter);
1698 return 0;
1701 static int
1702 e1000_get_stats_count(struct net_device *netdev)
1704 return E1000_STATS_LEN;
1707 static void
1708 e1000_get_ethtool_stats(struct net_device *netdev,
1709 struct ethtool_stats *stats, uint64_t *data)
1711 struct e1000_adapter *adapter = netdev_priv(netdev);
1712 int i;
1714 e1000_update_stats(adapter);
1715 for(i = 0; i < E1000_STATS_LEN; i++) {
1716 char *p = (char *)adapter+e1000_gstrings_stats[i].stat_offset;
1717 data[i] = (e1000_gstrings_stats[i].sizeof_stat ==
1718 sizeof(uint64_t)) ? *(uint64_t *)p : *(uint32_t *)p;
1722 static void
1723 e1000_get_strings(struct net_device *netdev, uint32_t stringset, uint8_t *data)
1725 int i;
1727 switch(stringset) {
1728 case ETH_SS_TEST:
1729 memcpy(data, *e1000_gstrings_test,
1730 E1000_TEST_LEN*ETH_GSTRING_LEN);
1731 break;
1732 case ETH_SS_STATS:
1733 for (i=0; i < E1000_STATS_LEN; i++) {
1734 memcpy(data + i * ETH_GSTRING_LEN,
1735 e1000_gstrings_stats[i].stat_string,
1736 ETH_GSTRING_LEN);
1738 break;
1742 struct ethtool_ops e1000_ethtool_ops = {
1743 .get_settings = e1000_get_settings,
1744 .set_settings = e1000_set_settings,
1745 .get_drvinfo = e1000_get_drvinfo,
1746 .get_regs_len = e1000_get_regs_len,
1747 .get_regs = e1000_get_regs,
1748 .get_wol = e1000_get_wol,
1749 .set_wol = e1000_set_wol,
1750 .get_msglevel = e1000_get_msglevel,
1751 .set_msglevel = e1000_set_msglevel,
1752 .nway_reset = e1000_nway_reset,
1753 .get_link = ethtool_op_get_link,
1754 .get_eeprom_len = e1000_get_eeprom_len,
1755 .get_eeprom = e1000_get_eeprom,
1756 .set_eeprom = e1000_set_eeprom,
1757 .get_ringparam = e1000_get_ringparam,
1758 .set_ringparam = e1000_set_ringparam,
1759 .get_pauseparam = e1000_get_pauseparam,
1760 .set_pauseparam = e1000_set_pauseparam,
1761 .get_rx_csum = e1000_get_rx_csum,
1762 .set_rx_csum = e1000_set_rx_csum,
1763 .get_tx_csum = e1000_get_tx_csum,
1764 .set_tx_csum = e1000_set_tx_csum,
1765 .get_sg = ethtool_op_get_sg,
1766 .set_sg = ethtool_op_set_sg,
1767 #ifdef NETIF_F_TSO
1768 .get_tso = ethtool_op_get_tso,
1769 .set_tso = e1000_set_tso,
1770 #endif
1771 .self_test_count = e1000_diag_test_count,
1772 .self_test = e1000_diag_test,
1773 .get_strings = e1000_get_strings,
1774 .phys_id = e1000_phys_id,
1775 .get_stats_count = e1000_get_stats_count,
1776 .get_ethtool_stats = e1000_get_ethtool_stats,
1777 .get_perm_addr = ethtool_op_get_perm_addr,
1780 void e1000_set_ethtool_ops(struct net_device *netdev)
1782 SET_ETHTOOL_OPS(netdev, &e1000_ethtool_ops);