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