blob: e48956d924b0faff43c4c2156bc795c8e87b5b8a [file] [log] [blame]
Auke Kokbc7f75f2007-09-17 12:30:59 -07001/*******************************************************************************
2
3 Intel PRO/1000 Linux driver
Bruce Allanad680762008-03-28 09:15:03 -07004 Copyright(c) 1999 - 2008 Intel Corporation.
Auke Kokbc7f75f2007-09-17 12:30:59 -07005
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) },
Bruce Allan7c257692008-04-23 11:09:00 -070049 { "rx_bytes", E1000_STAT(stats.gorc) },
50 { "tx_bytes", E1000_STAT(stats.gotc) },
Auke Kokbc7f75f2007-09-17 12:30:59 -070051 { "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) },
Bruce Allan7c257692008-04-23 11:09:00 -070086 { "rx_long_byte_count", E1000_STAT(stats.gorc) },
Auke Kokbc7f75f2007-09-17 12:30:59 -070087 { "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
Alejandro Martinez Ruizc00acf42007-10-18 10:16:33 +020098#define E1000_GLOBAL_STATS_LEN ARRAY_SIZE(e1000_gstrings_stats)
Auke Kokbc7f75f2007-09-17 12:30:59 -070099#define E1000_STATS_LEN (E1000_GLOBAL_STATS_LEN)
100static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = {
101 "Register test (offline)", "Eeprom test (offline)",
102 "Interrupt test (offline)", "Loopback test (offline)",
103 "Link test (on/offline)"
104};
Bruce Allanad680762008-03-28 09:15:03 -0700105#define E1000_TEST_LEN ARRAY_SIZE(e1000_gstrings_test)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700106
107static int e1000_get_settings(struct net_device *netdev,
108 struct ethtool_cmd *ecmd)
109{
110 struct e1000_adapter *adapter = netdev_priv(netdev);
111 struct e1000_hw *hw = &adapter->hw;
Auke Kok369d7422007-10-15 14:30:59 -0700112 u32 status;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700113
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700114 if (hw->phy.media_type == e1000_media_type_copper) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700115
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
Auke Kok369d7422007-10-15 14:30:59 -0700150 status = er32(STATUS);
151 if (status & E1000_STATUS_LU) {
152 if (status & E1000_STATUS_SPEED_1000)
153 ecmd->speed = 1000;
154 else if (status & E1000_STATUS_SPEED_100)
155 ecmd->speed = 100;
156 else
157 ecmd->speed = 10;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700158
Auke Kok369d7422007-10-15 14:30:59 -0700159 if (status & E1000_STATUS_FD)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700160 ecmd->duplex = DUPLEX_FULL;
161 else
162 ecmd->duplex = DUPLEX_HALF;
163 } else {
164 ecmd->speed = -1;
165 ecmd->duplex = -1;
166 }
167
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700168 ecmd->autoneg = ((hw->phy.media_type == e1000_media_type_fiber) ||
Auke Kokbc7f75f2007-09-17 12:30:59 -0700169 hw->mac.autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE;
170 return 0;
171}
172
Auke Kok369d7422007-10-15 14:30:59 -0700173static u32 e1000_get_link(struct net_device *netdev)
174{
175 struct e1000_adapter *adapter = netdev_priv(netdev);
Bruce Allana20e4cf2008-11-21 17:01:35 -0800176
177 return e1000_has_link(adapter);
Auke Kok369d7422007-10-15 14:30:59 -0700178}
179
Auke Kokbc7f75f2007-09-17 12:30:59 -0700180static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
181{
182 struct e1000_mac_info *mac = &adapter->hw.mac;
183
184 mac->autoneg = 0;
185
186 /* Fiber NICs only allow 1000 gbps Full duplex */
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700187 if ((adapter->hw.phy.media_type == e1000_media_type_fiber) &&
Auke Kokbc7f75f2007-09-17 12:30:59 -0700188 spddplx != (SPEED_1000 + DUPLEX_FULL)) {
Jeff Kirsher44defeb2008-08-04 17:20:41 -0700189 e_err("Unsupported Speed/Duplex configuration\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700190 return -EINVAL;
191 }
192
193 switch (spddplx) {
194 case SPEED_10 + DUPLEX_HALF:
195 mac->forced_speed_duplex = ADVERTISE_10_HALF;
196 break;
197 case SPEED_10 + DUPLEX_FULL:
198 mac->forced_speed_duplex = ADVERTISE_10_FULL;
199 break;
200 case SPEED_100 + DUPLEX_HALF:
201 mac->forced_speed_duplex = ADVERTISE_100_HALF;
202 break;
203 case SPEED_100 + DUPLEX_FULL:
204 mac->forced_speed_duplex = ADVERTISE_100_FULL;
205 break;
206 case SPEED_1000 + DUPLEX_FULL:
207 mac->autoneg = 1;
208 adapter->hw.phy.autoneg_advertised = ADVERTISE_1000_FULL;
209 break;
210 case SPEED_1000 + DUPLEX_HALF: /* not supported */
211 default:
Jeff Kirsher44defeb2008-08-04 17:20:41 -0700212 e_err("Unsupported Speed/Duplex configuration\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700213 return -EINVAL;
214 }
215 return 0;
216}
217
218static int e1000_set_settings(struct net_device *netdev,
219 struct ethtool_cmd *ecmd)
220{
221 struct e1000_adapter *adapter = netdev_priv(netdev);
222 struct e1000_hw *hw = &adapter->hw;
223
Bruce Allanad680762008-03-28 09:15:03 -0700224 /*
225 * When SoL/IDER sessions are active, autoneg/speed/duplex
226 * cannot be changed
227 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700228 if (e1000_check_reset_block(hw)) {
Jeff Kirsher44defeb2008-08-04 17:20:41 -0700229 e_err("Cannot change link characteristics when SoL/IDER is "
230 "active.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700231 return -EINVAL;
232 }
233
234 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
235 msleep(1);
236
237 if (ecmd->autoneg == AUTONEG_ENABLE) {
238 hw->mac.autoneg = 1;
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700239 if (hw->phy.media_type == e1000_media_type_fiber)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700240 hw->phy.autoneg_advertised = ADVERTISED_1000baseT_Full |
241 ADVERTISED_FIBRE |
242 ADVERTISED_Autoneg;
243 else
244 hw->phy.autoneg_advertised = ecmd->advertising |
245 ADVERTISED_TP |
246 ADVERTISED_Autoneg;
247 ecmd->advertising = hw->phy.autoneg_advertised;
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700248 if (adapter->fc_autoneg)
Bruce Allan5c48ef3e22008-11-21 16:57:36 -0800249 hw->fc.requested_mode = e1000_fc_default;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700250 } else {
251 if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) {
252 clear_bit(__E1000_RESETTING, &adapter->state);
253 return -EINVAL;
254 }
255 }
256
257 /* reset the link */
258
259 if (netif_running(adapter->netdev)) {
260 e1000e_down(adapter);
261 e1000e_up(adapter);
262 } else {
263 e1000e_reset(adapter);
264 }
265
266 clear_bit(__E1000_RESETTING, &adapter->state);
267 return 0;
268}
269
270static void e1000_get_pauseparam(struct net_device *netdev,
271 struct ethtool_pauseparam *pause)
272{
273 struct e1000_adapter *adapter = netdev_priv(netdev);
274 struct e1000_hw *hw = &adapter->hw;
275
276 pause->autoneg =
277 (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
278
Bruce Allan5c48ef3e22008-11-21 16:57:36 -0800279 if (hw->fc.current_mode == e1000_fc_rx_pause) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700280 pause->rx_pause = 1;
Bruce Allan5c48ef3e22008-11-21 16:57:36 -0800281 } else if (hw->fc.current_mode == e1000_fc_tx_pause) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700282 pause->tx_pause = 1;
Bruce Allan5c48ef3e22008-11-21 16:57:36 -0800283 } else if (hw->fc.current_mode == e1000_fc_full) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700284 pause->rx_pause = 1;
285 pause->tx_pause = 1;
286 }
287}
288
289static int e1000_set_pauseparam(struct net_device *netdev,
290 struct ethtool_pauseparam *pause)
291{
292 struct e1000_adapter *adapter = netdev_priv(netdev);
293 struct e1000_hw *hw = &adapter->hw;
294 int retval = 0;
295
296 adapter->fc_autoneg = pause->autoneg;
297
298 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
299 msleep(1);
300
Auke Kokbc7f75f2007-09-17 12:30:59 -0700301 if (adapter->fc_autoneg == AUTONEG_ENABLE) {
Bruce Allan5c48ef3e22008-11-21 16:57:36 -0800302 hw->fc.requested_mode = e1000_fc_default;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700303 if (netif_running(adapter->netdev)) {
304 e1000e_down(adapter);
305 e1000e_up(adapter);
306 } else {
307 e1000e_reset(adapter);
308 }
309 } else {
Bruce Allan5c48ef3e22008-11-21 16:57:36 -0800310 if (pause->rx_pause && pause->tx_pause)
311 hw->fc.requested_mode = e1000_fc_full;
312 else if (pause->rx_pause && !pause->tx_pause)
313 hw->fc.requested_mode = e1000_fc_rx_pause;
314 else if (!pause->rx_pause && pause->tx_pause)
315 hw->fc.requested_mode = e1000_fc_tx_pause;
316 else if (!pause->rx_pause && !pause->tx_pause)
317 hw->fc.requested_mode = e1000_fc_none;
318
319 hw->fc.current_mode = hw->fc.requested_mode;
320
Jeff Kirsher318a94d2008-03-28 09:15:16 -0700321 retval = ((hw->phy.media_type == e1000_media_type_fiber) ?
Auke Kokbc7f75f2007-09-17 12:30:59 -0700322 hw->mac.ops.setup_link(hw) : e1000e_force_mac_fc(hw));
323 }
324
325 clear_bit(__E1000_RESETTING, &adapter->state);
326 return retval;
327}
328
329static u32 e1000_get_rx_csum(struct net_device *netdev)
330{
331 struct e1000_adapter *adapter = netdev_priv(netdev);
332 return (adapter->flags & FLAG_RX_CSUM_ENABLED);
333}
334
335static int e1000_set_rx_csum(struct net_device *netdev, u32 data)
336{
337 struct e1000_adapter *adapter = netdev_priv(netdev);
338
339 if (data)
340 adapter->flags |= FLAG_RX_CSUM_ENABLED;
341 else
342 adapter->flags &= ~FLAG_RX_CSUM_ENABLED;
343
344 if (netif_running(netdev))
345 e1000e_reinit_locked(adapter);
346 else
347 e1000e_reset(adapter);
348 return 0;
349}
350
351static u32 e1000_get_tx_csum(struct net_device *netdev)
352{
353 return ((netdev->features & NETIF_F_HW_CSUM) != 0);
354}
355
356static int e1000_set_tx_csum(struct net_device *netdev, u32 data)
357{
358 if (data)
359 netdev->features |= NETIF_F_HW_CSUM;
360 else
361 netdev->features &= ~NETIF_F_HW_CSUM;
362
363 return 0;
364}
365
366static int e1000_set_tso(struct net_device *netdev, u32 data)
367{
368 struct e1000_adapter *adapter = netdev_priv(netdev);
369
370 if (data) {
371 netdev->features |= NETIF_F_TSO;
372 netdev->features |= NETIF_F_TSO6;
373 } else {
374 netdev->features &= ~NETIF_F_TSO;
375 netdev->features &= ~NETIF_F_TSO6;
376 }
377
Jeff Kirsher44defeb2008-08-04 17:20:41 -0700378 e_info("TSO is %s\n", data ? "Enabled" : "Disabled");
Auke Kokbc7f75f2007-09-17 12:30:59 -0700379 adapter->flags |= FLAG_TSO_FORCE;
380 return 0;
381}
382
383static u32 e1000_get_msglevel(struct net_device *netdev)
384{
385 struct e1000_adapter *adapter = netdev_priv(netdev);
386 return adapter->msg_enable;
387}
388
389static void e1000_set_msglevel(struct net_device *netdev, u32 data)
390{
391 struct e1000_adapter *adapter = netdev_priv(netdev);
392 adapter->msg_enable = data;
393}
394
395static int e1000_get_regs_len(struct net_device *netdev)
396{
397#define E1000_REGS_LEN 32 /* overestimate */
398 return E1000_REGS_LEN * sizeof(u32);
399}
400
401static void e1000_get_regs(struct net_device *netdev,
402 struct ethtool_regs *regs, void *p)
403{
404 struct e1000_adapter *adapter = netdev_priv(netdev);
405 struct e1000_hw *hw = &adapter->hw;
406 u32 *regs_buff = p;
407 u16 phy_data;
408 u8 revision_id;
409
410 memset(p, 0, E1000_REGS_LEN * sizeof(u32));
411
412 pci_read_config_byte(adapter->pdev, PCI_REVISION_ID, &revision_id);
413
414 regs->version = (1 << 24) | (revision_id << 16) | adapter->pdev->device;
415
416 regs_buff[0] = er32(CTRL);
417 regs_buff[1] = er32(STATUS);
418
419 regs_buff[2] = er32(RCTL);
420 regs_buff[3] = er32(RDLEN);
421 regs_buff[4] = er32(RDH);
422 regs_buff[5] = er32(RDT);
423 regs_buff[6] = er32(RDTR);
424
425 regs_buff[7] = er32(TCTL);
426 regs_buff[8] = er32(TDLEN);
427 regs_buff[9] = er32(TDH);
428 regs_buff[10] = er32(TDT);
429 regs_buff[11] = er32(TIDV);
430
431 regs_buff[12] = adapter->hw.phy.type; /* PHY type (IGP=1, M88=0) */
Jesse Brandeburg23033fa2008-10-02 16:33:30 -0700432
433 /* ethtool doesn't use anything past this point, so all this
434 * code is likely legacy junk for apps that may or may not
435 * exist */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700436 if (hw->phy.type == e1000_phy_m88) {
437 e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
438 regs_buff[13] = (u32)phy_data; /* cable length */
439 regs_buff[14] = 0; /* Dummy (to align w/ IGP phy reg dump) */
440 regs_buff[15] = 0; /* Dummy (to align w/ IGP phy reg dump) */
441 regs_buff[16] = 0; /* Dummy (to align w/ IGP phy reg dump) */
442 e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
443 regs_buff[17] = (u32)phy_data; /* extended 10bt distance */
444 regs_buff[18] = regs_buff[13]; /* cable polarity */
445 regs_buff[19] = 0; /* Dummy (to align w/ IGP phy reg dump) */
446 regs_buff[20] = regs_buff[17]; /* polarity correction */
447 /* phy receive errors */
448 regs_buff[22] = adapter->phy_stats.receive_errors;
449 regs_buff[23] = regs_buff[13]; /* mdix mode */
450 }
Jesse Brandeburg23033fa2008-10-02 16:33:30 -0700451 regs_buff[21] = 0; /* was idle_errors */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700452 e1e_rphy(hw, PHY_1000T_STATUS, &phy_data);
453 regs_buff[24] = (u32)phy_data; /* phy local receiver status */
454 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */
455}
456
457static int e1000_get_eeprom_len(struct net_device *netdev)
458{
459 struct e1000_adapter *adapter = netdev_priv(netdev);
460 return adapter->hw.nvm.word_size * 2;
461}
462
463static int e1000_get_eeprom(struct net_device *netdev,
464 struct ethtool_eeprom *eeprom, u8 *bytes)
465{
466 struct e1000_adapter *adapter = netdev_priv(netdev);
467 struct e1000_hw *hw = &adapter->hw;
468 u16 *eeprom_buff;
469 int first_word;
470 int last_word;
471 int ret_val = 0;
472 u16 i;
473
474 if (eeprom->len == 0)
475 return -EINVAL;
476
477 eeprom->magic = adapter->pdev->vendor | (adapter->pdev->device << 16);
478
479 first_word = eeprom->offset >> 1;
480 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
481
482 eeprom_buff = kmalloc(sizeof(u16) *
483 (last_word - first_word + 1), GFP_KERNEL);
484 if (!eeprom_buff)
485 return -ENOMEM;
486
487 if (hw->nvm.type == e1000_nvm_eeprom_spi) {
488 ret_val = e1000_read_nvm(hw, first_word,
489 last_word - first_word + 1,
490 eeprom_buff);
491 } else {
492 for (i = 0; i < last_word - first_word + 1; i++) {
493 ret_val = e1000_read_nvm(hw, first_word + i, 1,
494 &eeprom_buff[i]);
Bruce Allane2434552008-11-21 17:02:41 -0800495 if (ret_val)
Auke Kokbc7f75f2007-09-17 12:30:59 -0700496 break;
497 }
498 }
499
Bruce Allane2434552008-11-21 17:02:41 -0800500 if (ret_val) {
501 /* a read error occurred, throw away the result */
502 memset(eeprom_buff, 0xff, sizeof(eeprom_buff));
503 } else {
504 /* Device's eeprom is always little-endian, word addressable */
505 for (i = 0; i < last_word - first_word + 1; i++)
506 le16_to_cpus(&eeprom_buff[i]);
507 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700508
509 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len);
510 kfree(eeprom_buff);
511
512 return ret_val;
513}
514
515static int e1000_set_eeprom(struct net_device *netdev,
516 struct ethtool_eeprom *eeprom, u8 *bytes)
517{
518 struct e1000_adapter *adapter = netdev_priv(netdev);
519 struct e1000_hw *hw = &adapter->hw;
520 u16 *eeprom_buff;
521 void *ptr;
522 int max_len;
523 int first_word;
524 int last_word;
525 int ret_val = 0;
526 u16 i;
527
528 if (eeprom->len == 0)
529 return -EOPNOTSUPP;
530
531 if (eeprom->magic != (adapter->pdev->vendor | (adapter->pdev->device << 16)))
532 return -EFAULT;
533
Bruce Allan4a770352008-10-01 17:18:35 -0700534 if (adapter->flags & FLAG_READ_ONLY_NVM)
535 return -EINVAL;
536
Auke Kokbc7f75f2007-09-17 12:30:59 -0700537 max_len = hw->nvm.word_size * 2;
538
539 first_word = eeprom->offset >> 1;
540 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
541 eeprom_buff = kmalloc(max_len, GFP_KERNEL);
542 if (!eeprom_buff)
543 return -ENOMEM;
544
545 ptr = (void *)eeprom_buff;
546
547 if (eeprom->offset & 1) {
548 /* need read/modify/write of first changed EEPROM word */
549 /* only the second byte of the word is being modified */
550 ret_val = e1000_read_nvm(hw, first_word, 1, &eeprom_buff[0]);
551 ptr++;
552 }
553 if (((eeprom->offset + eeprom->len) & 1) && (ret_val == 0))
554 /* need read/modify/write of last changed EEPROM word */
555 /* only the first byte of the word is being modified */
556 ret_val = e1000_read_nvm(hw, last_word, 1,
557 &eeprom_buff[last_word - first_word]);
558
Bruce Allane2434552008-11-21 17:02:41 -0800559 if (ret_val)
560 goto out;
561
Auke Kokbc7f75f2007-09-17 12:30:59 -0700562 /* Device's eeprom is always little-endian, word addressable */
563 for (i = 0; i < last_word - first_word + 1; i++)
564 le16_to_cpus(&eeprom_buff[i]);
565
566 memcpy(ptr, bytes, eeprom->len);
567
568 for (i = 0; i < last_word - first_word + 1; i++)
569 eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]);
570
571 ret_val = e1000_write_nvm(hw, first_word,
572 last_word - first_word + 1, eeprom_buff);
573
Bruce Allane2434552008-11-21 17:02:41 -0800574 if (ret_val)
575 goto out;
576
Bruce Allanad680762008-03-28 09:15:03 -0700577 /*
578 * Update the checksum over the first part of the EEPROM if needed
Bruce Allane2434552008-11-21 17:02:41 -0800579 * and flush shadow RAM for applicable controllers
Bruce Allanad680762008-03-28 09:15:03 -0700580 */
Bruce Allane2434552008-11-21 17:02:41 -0800581 if ((first_word <= NVM_CHECKSUM_REG) ||
582 (hw->mac.type == e1000_82574) || (hw->mac.type == e1000_82573))
583 ret_val = e1000e_update_nvm_checksum(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700584
Bruce Allane2434552008-11-21 17:02:41 -0800585out:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700586 kfree(eeprom_buff);
587 return ret_val;
588}
589
590static void e1000_get_drvinfo(struct net_device *netdev,
591 struct ethtool_drvinfo *drvinfo)
592{
593 struct e1000_adapter *adapter = netdev_priv(netdev);
594 char firmware_version[32];
Auke Kokbc7f75f2007-09-17 12:30:59 -0700595
596 strncpy(drvinfo->driver, e1000e_driver_name, 32);
597 strncpy(drvinfo->version, e1000e_driver_version, 32);
598
Bruce Allanad680762008-03-28 09:15:03 -0700599 /*
600 * EEPROM image version # is reported as firmware version # for
601 * PCI-E controllers
602 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700603 sprintf(firmware_version, "%d.%d-%d",
Bruce Allan84527592008-11-21 17:00:22 -0800604 (adapter->eeprom_vers & 0xF000) >> 12,
605 (adapter->eeprom_vers & 0x0FF0) >> 4,
606 (adapter->eeprom_vers & 0x000F));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700607
608 strncpy(drvinfo->fw_version, firmware_version, 32);
609 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700610 drvinfo->regdump_len = e1000_get_regs_len(netdev);
611 drvinfo->eedump_len = e1000_get_eeprom_len(netdev);
612}
613
614static void e1000_get_ringparam(struct net_device *netdev,
615 struct ethtool_ringparam *ring)
616{
617 struct e1000_adapter *adapter = netdev_priv(netdev);
618 struct e1000_ring *tx_ring = adapter->tx_ring;
619 struct e1000_ring *rx_ring = adapter->rx_ring;
620
621 ring->rx_max_pending = E1000_MAX_RXD;
622 ring->tx_max_pending = E1000_MAX_TXD;
623 ring->rx_mini_max_pending = 0;
624 ring->rx_jumbo_max_pending = 0;
625 ring->rx_pending = rx_ring->count;
626 ring->tx_pending = tx_ring->count;
627 ring->rx_mini_pending = 0;
628 ring->rx_jumbo_pending = 0;
629}
630
631static int e1000_set_ringparam(struct net_device *netdev,
632 struct ethtool_ringparam *ring)
633{
634 struct e1000_adapter *adapter = netdev_priv(netdev);
635 struct e1000_ring *tx_ring, *tx_old;
636 struct e1000_ring *rx_ring, *rx_old;
637 int err;
638
639 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
640 return -EINVAL;
641
642 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
643 msleep(1);
644
645 if (netif_running(adapter->netdev))
646 e1000e_down(adapter);
647
648 tx_old = adapter->tx_ring;
649 rx_old = adapter->rx_ring;
650
651 err = -ENOMEM;
652 tx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
653 if (!tx_ring)
654 goto err_alloc_tx;
Bruce Allancef8c792008-04-02 13:48:23 -0700655 /*
656 * use a memcpy to save any previously configured
657 * items like napi structs from having to be
658 * reinitialized
659 */
660 memcpy(tx_ring, tx_old, sizeof(struct e1000_ring));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700661
662 rx_ring = kzalloc(sizeof(struct e1000_ring), GFP_KERNEL);
663 if (!rx_ring)
664 goto err_alloc_rx;
Bruce Allancef8c792008-04-02 13:48:23 -0700665 memcpy(rx_ring, rx_old, sizeof(struct e1000_ring));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700666
667 adapter->tx_ring = tx_ring;
668 adapter->rx_ring = rx_ring;
669
670 rx_ring->count = max(ring->rx_pending, (u32)E1000_MIN_RXD);
671 rx_ring->count = min(rx_ring->count, (u32)(E1000_MAX_RXD));
672 rx_ring->count = ALIGN(rx_ring->count, REQ_RX_DESCRIPTOR_MULTIPLE);
673
674 tx_ring->count = max(ring->tx_pending, (u32)E1000_MIN_TXD);
675 tx_ring->count = min(tx_ring->count, (u32)(E1000_MAX_TXD));
676 tx_ring->count = ALIGN(tx_ring->count, REQ_TX_DESCRIPTOR_MULTIPLE);
677
678 if (netif_running(adapter->netdev)) {
679 /* Try to get new resources before deleting old */
680 err = e1000e_setup_rx_resources(adapter);
681 if (err)
682 goto err_setup_rx;
683 err = e1000e_setup_tx_resources(adapter);
684 if (err)
685 goto err_setup_tx;
686
Bruce Allanad680762008-03-28 09:15:03 -0700687 /*
688 * restore the old in order to free it,
689 * then add in the new
690 */
Auke Kokbc7f75f2007-09-17 12:30:59 -0700691 adapter->rx_ring = rx_old;
692 adapter->tx_ring = tx_old;
693 e1000e_free_rx_resources(adapter);
694 e1000e_free_tx_resources(adapter);
695 kfree(tx_old);
696 kfree(rx_old);
697 adapter->rx_ring = rx_ring;
698 adapter->tx_ring = tx_ring;
699 err = e1000e_up(adapter);
700 if (err)
701 goto err_setup;
702 }
703
704 clear_bit(__E1000_RESETTING, &adapter->state);
705 return 0;
706err_setup_tx:
707 e1000e_free_rx_resources(adapter);
708err_setup_rx:
709 adapter->rx_ring = rx_old;
710 adapter->tx_ring = tx_old;
711 kfree(rx_ring);
712err_alloc_rx:
713 kfree(tx_ring);
714err_alloc_tx:
715 e1000e_up(adapter);
716err_setup:
717 clear_bit(__E1000_RESETTING, &adapter->state);
718 return err;
719}
720
Bruce Allancef8c792008-04-02 13:48:23 -0700721static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data,
722 int reg, int offset, u32 mask, u32 write)
Joe Perches2a887192007-11-13 20:53:51 -0800723{
Bruce Allancef8c792008-04-02 13:48:23 -0700724 u32 pat, val;
Joe Perches2a887192007-11-13 20:53:51 -0800725 static const u32 test[] =
726 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
Bruce Allancef8c792008-04-02 13:48:23 -0700727 for (pat = 0; pat < ARRAY_SIZE(test); pat++) {
Joe Perches2a887192007-11-13 20:53:51 -0800728 E1000_WRITE_REG_ARRAY(&adapter->hw, reg, offset,
Bruce Allancef8c792008-04-02 13:48:23 -0700729 (test[pat] & write));
730 val = E1000_READ_REG_ARRAY(&adapter->hw, reg, offset);
731 if (val != (test[pat] & write & mask)) {
Jeff Kirsher44defeb2008-08-04 17:20:41 -0700732 e_err("pattern test reg %04X failed: got 0x%08X "
733 "expected 0x%08X\n", reg + offset, val,
734 (test[pat] & write & mask));
Joe Perches2a887192007-11-13 20:53:51 -0800735 *data = reg;
Bruce Allancef8c792008-04-02 13:48:23 -0700736 return 1;
Joe Perches2a887192007-11-13 20:53:51 -0800737 }
738 }
Bruce Allancef8c792008-04-02 13:48:23 -0700739 return 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700740}
741
Joe Perches2a887192007-11-13 20:53:51 -0800742static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data,
743 int reg, u32 mask, u32 write)
744{
Bruce Allancef8c792008-04-02 13:48:23 -0700745 u32 val;
Joe Perches2a887192007-11-13 20:53:51 -0800746 __ew32(&adapter->hw, reg, write & mask);
Bruce Allancef8c792008-04-02 13:48:23 -0700747 val = __er32(&adapter->hw, reg);
748 if ((write & mask) != (val & mask)) {
Jeff Kirsher44defeb2008-08-04 17:20:41 -0700749 e_err("set/check reg %04X test failed: got 0x%08X "
750 "expected 0x%08X\n", reg, (val & mask), (write & mask));
Joe Perches2a887192007-11-13 20:53:51 -0800751 *data = reg;
Bruce Allancef8c792008-04-02 13:48:23 -0700752 return 1;
Joe Perches2a887192007-11-13 20:53:51 -0800753 }
Bruce Allancef8c792008-04-02 13:48:23 -0700754 return 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700755}
Bruce Allancef8c792008-04-02 13:48:23 -0700756#define REG_PATTERN_TEST_ARRAY(reg, offset, mask, write) \
757 do { \
758 if (reg_pattern_test(adapter, data, reg, offset, mask, write)) \
759 return 1; \
Joe Perches2a887192007-11-13 20:53:51 -0800760 } while (0)
Bruce Allancef8c792008-04-02 13:48:23 -0700761#define REG_PATTERN_TEST(reg, mask, write) \
762 REG_PATTERN_TEST_ARRAY(reg, 0, mask, write)
Joe Perches2a887192007-11-13 20:53:51 -0800763
Bruce Allancef8c792008-04-02 13:48:23 -0700764#define REG_SET_AND_CHECK(reg, mask, write) \
765 do { \
766 if (reg_set_and_check(adapter, data, reg, mask, write)) \
767 return 1; \
Joe Perches2a887192007-11-13 20:53:51 -0800768 } while (0)
769
Auke Kokbc7f75f2007-09-17 12:30:59 -0700770static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
771{
772 struct e1000_hw *hw = &adapter->hw;
773 struct e1000_mac_info *mac = &adapter->hw.mac;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700774 u32 value;
775 u32 before;
776 u32 after;
777 u32 i;
778 u32 toggle;
779
Bruce Allanad680762008-03-28 09:15:03 -0700780 /*
781 * The status register is Read Only, so a write should fail.
Auke Kokbc7f75f2007-09-17 12:30:59 -0700782 * Some bits that get toggled are ignored.
783 */
784 switch (mac->type) {
785 /* there are several bits on newer hardware that are r/w */
786 case e1000_82571:
787 case e1000_82572:
788 case e1000_80003es2lan:
789 toggle = 0x7FFFF3FF;
790 break;
791 case e1000_82573:
Bruce Allan4662e822008-08-26 18:37:06 -0700792 case e1000_82574:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700793 case e1000_ich8lan:
794 case e1000_ich9lan:
Bruce Allanf4187b52008-08-26 18:36:50 -0700795 case e1000_ich10lan:
Auke Kokbc7f75f2007-09-17 12:30:59 -0700796 toggle = 0x7FFFF033;
797 break;
798 default:
799 toggle = 0xFFFFF833;
800 break;
801 }
802
803 before = er32(STATUS);
804 value = (er32(STATUS) & toggle);
805 ew32(STATUS, toggle);
806 after = er32(STATUS) & toggle;
807 if (value != after) {
Jeff Kirsher44defeb2008-08-04 17:20:41 -0700808 e_err("failed STATUS register test got: 0x%08X expected: "
809 "0x%08X\n", after, value);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700810 *data = 1;
811 return 1;
812 }
813 /* restore previous status */
814 ew32(STATUS, before);
815
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700816 if (!(adapter->flags & FLAG_IS_ICH)) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700817 REG_PATTERN_TEST(E1000_FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
818 REG_PATTERN_TEST(E1000_FCAH, 0x0000FFFF, 0xFFFFFFFF);
819 REG_PATTERN_TEST(E1000_FCT, 0x0000FFFF, 0xFFFFFFFF);
820 REG_PATTERN_TEST(E1000_VET, 0x0000FFFF, 0xFFFFFFFF);
821 }
822
823 REG_PATTERN_TEST(E1000_RDTR, 0x0000FFFF, 0xFFFFFFFF);
824 REG_PATTERN_TEST(E1000_RDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
825 REG_PATTERN_TEST(E1000_RDLEN, 0x000FFF80, 0x000FFFFF);
826 REG_PATTERN_TEST(E1000_RDH, 0x0000FFFF, 0x0000FFFF);
827 REG_PATTERN_TEST(E1000_RDT, 0x0000FFFF, 0x0000FFFF);
828 REG_PATTERN_TEST(E1000_FCRTH, 0x0000FFF8, 0x0000FFF8);
829 REG_PATTERN_TEST(E1000_FCTTV, 0x0000FFFF, 0x0000FFFF);
830 REG_PATTERN_TEST(E1000_TIPG, 0x3FFFFFFF, 0x3FFFFFFF);
831 REG_PATTERN_TEST(E1000_TDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
832 REG_PATTERN_TEST(E1000_TDLEN, 0x000FFF80, 0x000FFFFF);
833
834 REG_SET_AND_CHECK(E1000_RCTL, 0xFFFFFFFF, 0x00000000);
835
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700836 before = ((adapter->flags & FLAG_IS_ICH) ? 0x06C3B33E : 0x06DFB3FE);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700837 REG_SET_AND_CHECK(E1000_RCTL, before, 0x003FFFFB);
838 REG_SET_AND_CHECK(E1000_TCTL, 0xFFFFFFFF, 0x00000000);
839
Auke Kok86582512007-10-04 15:00:08 -0700840 REG_SET_AND_CHECK(E1000_RCTL, before, 0xFFFFFFFF);
841 REG_PATTERN_TEST(E1000_RDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
Bruce Allan97ac8ca2008-04-29 09:16:05 -0700842 if (!(adapter->flags & FLAG_IS_ICH))
Auke Kok86582512007-10-04 15:00:08 -0700843 REG_PATTERN_TEST(E1000_TXCW, 0xC000FFFF, 0x0000FFFF);
844 REG_PATTERN_TEST(E1000_TDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
845 REG_PATTERN_TEST(E1000_TIDV, 0x0000FFFF, 0x0000FFFF);
846 for (i = 0; i < mac->rar_entry_count; i++)
847 REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1),
Bruce Allanf4187b52008-08-26 18:36:50 -0700848 ((mac->type == e1000_ich10lan) ?
849 0x8007FFFF : 0x8003FFFF),
850 0xFFFFFFFF);
Auke Kokbc7f75f2007-09-17 12:30:59 -0700851
852 for (i = 0; i < mac->mta_reg_count; i++)
853 REG_PATTERN_TEST_ARRAY(E1000_MTA, i, 0xFFFFFFFF, 0xFFFFFFFF);
854
855 *data = 0;
856 return 0;
857}
858
859static int e1000_eeprom_test(struct e1000_adapter *adapter, u64 *data)
860{
861 u16 temp;
862 u16 checksum = 0;
863 u16 i;
864
865 *data = 0;
866 /* Read and add up the contents of the EEPROM */
867 for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
868 if ((e1000_read_nvm(&adapter->hw, i, 1, &temp)) < 0) {
869 *data = 1;
Bruce Allane2434552008-11-21 17:02:41 -0800870 return *data;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700871 }
872 checksum += temp;
873 }
874
875 /* If Checksum is not Correct return error else test passed */
876 if ((checksum != (u16) NVM_SUM) && !(*data))
877 *data = 2;
878
879 return *data;
880}
881
882static irqreturn_t e1000_test_intr(int irq, void *data)
883{
884 struct net_device *netdev = (struct net_device *) data;
885 struct e1000_adapter *adapter = netdev_priv(netdev);
886 struct e1000_hw *hw = &adapter->hw;
887
888 adapter->test_icr |= er32(ICR);
889
890 return IRQ_HANDLED;
891}
892
893static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
894{
895 struct net_device *netdev = adapter->netdev;
896 struct e1000_hw *hw = &adapter->hw;
897 u32 mask;
898 u32 shared_int = 1;
899 u32 irq = adapter->pdev->irq;
900 int i;
Bruce Allan4662e822008-08-26 18:37:06 -0700901 int ret_val = 0;
902 int int_mode = E1000E_INT_MODE_LEGACY;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700903
904 *data = 0;
905
Bruce Allan4662e822008-08-26 18:37:06 -0700906 /* NOTE: we don't test MSI/MSI-X interrupts here, yet */
907 if (adapter->int_mode == E1000E_INT_MODE_MSIX) {
908 int_mode = adapter->int_mode;
909 e1000e_reset_interrupt_capability(adapter);
910 adapter->int_mode = E1000E_INT_MODE_LEGACY;
911 e1000e_set_interrupt_capability(adapter);
912 }
Auke Kokbc7f75f2007-09-17 12:30:59 -0700913 /* Hook up test interrupt handler just for this test */
914 if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED, netdev->name,
915 netdev)) {
916 shared_int = 0;
917 } else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED,
918 netdev->name, netdev)) {
919 *data = 1;
Bruce Allan4662e822008-08-26 18:37:06 -0700920 ret_val = -1;
921 goto out;
Auke Kokbc7f75f2007-09-17 12:30:59 -0700922 }
Jeff Kirsher44defeb2008-08-04 17:20:41 -0700923 e_info("testing %s interrupt\n", (shared_int ? "shared" : "unshared"));
Auke Kokbc7f75f2007-09-17 12:30:59 -0700924
925 /* Disable all the interrupts */
926 ew32(IMC, 0xFFFFFFFF);
927 msleep(10);
928
929 /* Test each interrupt */
930 for (i = 0; i < 10; i++) {
Auke Kokbc7f75f2007-09-17 12:30:59 -0700931 /* Interrupt to test */
932 mask = 1 << i;
933
Bruce Allanf4187b52008-08-26 18:36:50 -0700934 if (adapter->flags & FLAG_IS_ICH) {
935 switch (mask) {
936 case E1000_ICR_RXSEQ:
937 continue;
938 case 0x00000100:
939 if (adapter->hw.mac.type == e1000_ich8lan ||
940 adapter->hw.mac.type == e1000_ich9lan)
941 continue;
942 break;
943 default:
944 break;
945 }
946 }
947
Auke Kokbc7f75f2007-09-17 12:30:59 -0700948 if (!shared_int) {
Bruce Allanad680762008-03-28 09:15:03 -0700949 /*
950 * Disable the interrupt to be reported in
Auke Kokbc7f75f2007-09-17 12:30:59 -0700951 * the cause register and then force the same
952 * interrupt and see if one gets posted. If
953 * an interrupt was posted to the bus, the
954 * test failed.
955 */
956 adapter->test_icr = 0;
957 ew32(IMC, mask);
958 ew32(ICS, mask);
959 msleep(10);
960
961 if (adapter->test_icr & mask) {
962 *data = 3;
963 break;
964 }
965 }
966
Bruce Allanad680762008-03-28 09:15:03 -0700967 /*
968 * Enable the interrupt to be reported in
Auke Kokbc7f75f2007-09-17 12:30:59 -0700969 * the cause register and then force the same
970 * interrupt and see if one gets posted. If
971 * an interrupt was not posted to the bus, the
972 * test failed.
973 */
974 adapter->test_icr = 0;
975 ew32(IMS, mask);
976 ew32(ICS, mask);
977 msleep(10);
978
979 if (!(adapter->test_icr & mask)) {
980 *data = 4;
981 break;
982 }
983
984 if (!shared_int) {
Bruce Allanad680762008-03-28 09:15:03 -0700985 /*
986 * Disable the other interrupts to be reported in
Auke Kokbc7f75f2007-09-17 12:30:59 -0700987 * the cause register and then force the other
988 * interrupts and see if any get posted. If
989 * an interrupt was posted to the bus, the
990 * test failed.
991 */
992 adapter->test_icr = 0;
993 ew32(IMC, ~mask & 0x00007FFF);
994 ew32(ICS, ~mask & 0x00007FFF);
995 msleep(10);
996
997 if (adapter->test_icr) {
998 *data = 5;
999 break;
1000 }
1001 }
1002 }
1003
1004 /* Disable all the interrupts */
1005 ew32(IMC, 0xFFFFFFFF);
1006 msleep(10);
1007
1008 /* Unhook test interrupt handler */
1009 free_irq(irq, netdev);
1010
Bruce Allan4662e822008-08-26 18:37:06 -07001011out:
1012 if (int_mode == E1000E_INT_MODE_MSIX) {
1013 e1000e_reset_interrupt_capability(adapter);
1014 adapter->int_mode = int_mode;
1015 e1000e_set_interrupt_capability(adapter);
1016 }
1017
1018 return ret_val;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001019}
1020
1021static void e1000_free_desc_rings(struct e1000_adapter *adapter)
1022{
1023 struct e1000_ring *tx_ring = &adapter->test_tx_ring;
1024 struct e1000_ring *rx_ring = &adapter->test_rx_ring;
1025 struct pci_dev *pdev = adapter->pdev;
1026 int i;
1027
1028 if (tx_ring->desc && tx_ring->buffer_info) {
1029 for (i = 0; i < tx_ring->count; i++) {
1030 if (tx_ring->buffer_info[i].dma)
1031 pci_unmap_single(pdev,
1032 tx_ring->buffer_info[i].dma,
1033 tx_ring->buffer_info[i].length,
1034 PCI_DMA_TODEVICE);
1035 if (tx_ring->buffer_info[i].skb)
1036 dev_kfree_skb(tx_ring->buffer_info[i].skb);
1037 }
1038 }
1039
1040 if (rx_ring->desc && rx_ring->buffer_info) {
1041 for (i = 0; i < rx_ring->count; i++) {
1042 if (rx_ring->buffer_info[i].dma)
1043 pci_unmap_single(pdev,
1044 rx_ring->buffer_info[i].dma,
1045 2048, PCI_DMA_FROMDEVICE);
1046 if (rx_ring->buffer_info[i].skb)
1047 dev_kfree_skb(rx_ring->buffer_info[i].skb);
1048 }
1049 }
1050
1051 if (tx_ring->desc) {
1052 dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc,
1053 tx_ring->dma);
1054 tx_ring->desc = NULL;
1055 }
1056 if (rx_ring->desc) {
1057 dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc,
1058 rx_ring->dma);
1059 rx_ring->desc = NULL;
1060 }
1061
1062 kfree(tx_ring->buffer_info);
1063 tx_ring->buffer_info = NULL;
1064 kfree(rx_ring->buffer_info);
1065 rx_ring->buffer_info = NULL;
1066}
1067
1068static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1069{
1070 struct e1000_ring *tx_ring = &adapter->test_tx_ring;
1071 struct e1000_ring *rx_ring = &adapter->test_rx_ring;
1072 struct pci_dev *pdev = adapter->pdev;
1073 struct e1000_hw *hw = &adapter->hw;
1074 u32 rctl;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001075 int i;
1076 int ret_val;
1077
1078 /* Setup Tx descriptor ring and Tx buffers */
1079
1080 if (!tx_ring->count)
1081 tx_ring->count = E1000_DEFAULT_TXD;
1082
Bruce Allancef8c792008-04-02 13:48:23 -07001083 tx_ring->buffer_info = kcalloc(tx_ring->count,
1084 sizeof(struct e1000_buffer),
1085 GFP_KERNEL);
1086 if (!(tx_ring->buffer_info)) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001087 ret_val = 1;
1088 goto err_nomem;
1089 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001090
1091 tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc);
1092 tx_ring->size = ALIGN(tx_ring->size, 4096);
1093 tx_ring->desc = dma_alloc_coherent(&pdev->dev, tx_ring->size,
1094 &tx_ring->dma, GFP_KERNEL);
1095 if (!tx_ring->desc) {
1096 ret_val = 2;
1097 goto err_nomem;
1098 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001099 tx_ring->next_to_use = 0;
1100 tx_ring->next_to_clean = 0;
1101
Bruce Allancef8c792008-04-02 13:48:23 -07001102 ew32(TDBAL, ((u64) tx_ring->dma & 0x00000000FFFFFFFF));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001103 ew32(TDBAH, ((u64) tx_ring->dma >> 32));
Bruce Allancef8c792008-04-02 13:48:23 -07001104 ew32(TDLEN, tx_ring->count * sizeof(struct e1000_tx_desc));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001105 ew32(TDH, 0);
1106 ew32(TDT, 0);
Bruce Allancef8c792008-04-02 13:48:23 -07001107 ew32(TCTL, E1000_TCTL_PSP | E1000_TCTL_EN | E1000_TCTL_MULR |
1108 E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT |
1109 E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001110
1111 for (i = 0; i < tx_ring->count; i++) {
1112 struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*tx_ring, i);
1113 struct sk_buff *skb;
1114 unsigned int skb_size = 1024;
1115
1116 skb = alloc_skb(skb_size, GFP_KERNEL);
1117 if (!skb) {
1118 ret_val = 3;
1119 goto err_nomem;
1120 }
1121 skb_put(skb, skb_size);
1122 tx_ring->buffer_info[i].skb = skb;
1123 tx_ring->buffer_info[i].length = skb->len;
1124 tx_ring->buffer_info[i].dma =
1125 pci_map_single(pdev, skb->data, skb->len,
1126 PCI_DMA_TODEVICE);
FUJITA Tomonori8d8bb392008-07-25 19:44:49 -07001127 if (pci_dma_mapping_error(pdev, tx_ring->buffer_info[i].dma)) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001128 ret_val = 4;
1129 goto err_nomem;
1130 }
Bruce Allancef8c792008-04-02 13:48:23 -07001131 tx_desc->buffer_addr = cpu_to_le64(tx_ring->buffer_info[i].dma);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001132 tx_desc->lower.data = cpu_to_le32(skb->len);
1133 tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP |
1134 E1000_TXD_CMD_IFCS |
Bruce Allancef8c792008-04-02 13:48:23 -07001135 E1000_TXD_CMD_RS);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001136 tx_desc->upper.data = 0;
1137 }
1138
1139 /* Setup Rx descriptor ring and Rx buffers */
1140
1141 if (!rx_ring->count)
1142 rx_ring->count = E1000_DEFAULT_RXD;
1143
Bruce Allancef8c792008-04-02 13:48:23 -07001144 rx_ring->buffer_info = kcalloc(rx_ring->count,
1145 sizeof(struct e1000_buffer),
1146 GFP_KERNEL);
1147 if (!(rx_ring->buffer_info)) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001148 ret_val = 5;
1149 goto err_nomem;
1150 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001151
1152 rx_ring->size = rx_ring->count * sizeof(struct e1000_rx_desc);
1153 rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size,
1154 &rx_ring->dma, GFP_KERNEL);
1155 if (!rx_ring->desc) {
1156 ret_val = 6;
1157 goto err_nomem;
1158 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001159 rx_ring->next_to_use = 0;
1160 rx_ring->next_to_clean = 0;
1161
1162 rctl = er32(RCTL);
1163 ew32(RCTL, rctl & ~E1000_RCTL_EN);
1164 ew32(RDBAL, ((u64) rx_ring->dma & 0xFFFFFFFF));
1165 ew32(RDBAH, ((u64) rx_ring->dma >> 32));
1166 ew32(RDLEN, rx_ring->size);
1167 ew32(RDH, 0);
1168 ew32(RDT, 0);
1169 rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 |
Bruce Allancef8c792008-04-02 13:48:23 -07001170 E1000_RCTL_UPE | E1000_RCTL_MPE | E1000_RCTL_LPE |
1171 E1000_RCTL_SBP | E1000_RCTL_SECRC |
Auke Kokbc7f75f2007-09-17 12:30:59 -07001172 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
1173 (adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
1174 ew32(RCTL, rctl);
1175
1176 for (i = 0; i < rx_ring->count; i++) {
1177 struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rx_ring, i);
1178 struct sk_buff *skb;
1179
1180 skb = alloc_skb(2048 + NET_IP_ALIGN, GFP_KERNEL);
1181 if (!skb) {
1182 ret_val = 7;
1183 goto err_nomem;
1184 }
1185 skb_reserve(skb, NET_IP_ALIGN);
1186 rx_ring->buffer_info[i].skb = skb;
1187 rx_ring->buffer_info[i].dma =
1188 pci_map_single(pdev, skb->data, 2048,
1189 PCI_DMA_FROMDEVICE);
FUJITA Tomonori8d8bb392008-07-25 19:44:49 -07001190 if (pci_dma_mapping_error(pdev, rx_ring->buffer_info[i].dma)) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001191 ret_val = 8;
1192 goto err_nomem;
1193 }
1194 rx_desc->buffer_addr =
1195 cpu_to_le64(rx_ring->buffer_info[i].dma);
1196 memset(skb->data, 0x00, skb->len);
1197 }
1198
1199 return 0;
1200
1201err_nomem:
1202 e1000_free_desc_rings(adapter);
1203 return ret_val;
1204}
1205
1206static void e1000_phy_disable_receiver(struct e1000_adapter *adapter)
1207{
1208 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1209 e1e_wphy(&adapter->hw, 29, 0x001F);
1210 e1e_wphy(&adapter->hw, 30, 0x8FFC);
1211 e1e_wphy(&adapter->hw, 29, 0x001A);
1212 e1e_wphy(&adapter->hw, 30, 0x8FF0);
1213}
1214
1215static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1216{
1217 struct e1000_hw *hw = &adapter->hw;
1218 u32 ctrl_reg = 0;
1219 u32 stat_reg = 0;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07001220 u16 phy_reg = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001221
Jeff Kirsher318a94d2008-03-28 09:15:16 -07001222 hw->mac.autoneg = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001223
Jeff Kirsher318a94d2008-03-28 09:15:16 -07001224 if (hw->phy.type == e1000_phy_m88) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001225 /* Auto-MDI/MDIX Off */
1226 e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, 0x0808);
1227 /* reset to update Auto-MDI/MDIX */
1228 e1e_wphy(hw, PHY_CONTROL, 0x9140);
1229 /* autoneg off */
1230 e1e_wphy(hw, PHY_CONTROL, 0x8140);
Jeff Kirsher318a94d2008-03-28 09:15:16 -07001231 } else if (hw->phy.type == e1000_phy_gg82563)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001232 e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x1CC);
1233
1234 ctrl_reg = er32(CTRL);
1235
Bruce Allancef8c792008-04-02 13:48:23 -07001236 switch (hw->phy.type) {
1237 case e1000_phy_ife:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001238 /* force 100, set loopback */
1239 e1e_wphy(hw, PHY_CONTROL, 0x6100);
1240
1241 /* Now set up the MAC to the same speed/duplex as the PHY. */
1242 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
1243 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1244 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1245 E1000_CTRL_SPD_100 |/* Force Speed to 100 */
1246 E1000_CTRL_FD); /* Force Duplex to FULL */
Bruce Allancef8c792008-04-02 13:48:23 -07001247 break;
Bruce Allan97ac8ca2008-04-29 09:16:05 -07001248 case e1000_phy_bm:
1249 /* Set Default MAC Interface speed to 1GB */
1250 e1e_rphy(hw, PHY_REG(2, 21), &phy_reg);
1251 phy_reg &= ~0x0007;
1252 phy_reg |= 0x006;
1253 e1e_wphy(hw, PHY_REG(2, 21), phy_reg);
1254 /* Assert SW reset for above settings to take effect */
1255 e1000e_commit_phy(hw);
1256 mdelay(1);
1257 /* Force Full Duplex */
1258 e1e_rphy(hw, PHY_REG(769, 16), &phy_reg);
1259 e1e_wphy(hw, PHY_REG(769, 16), phy_reg | 0x000C);
1260 /* Set Link Up (in force link) */
1261 e1e_rphy(hw, PHY_REG(776, 16), &phy_reg);
1262 e1e_wphy(hw, PHY_REG(776, 16), phy_reg | 0x0040);
1263 /* Force Link */
1264 e1e_rphy(hw, PHY_REG(769, 16), &phy_reg);
1265 e1e_wphy(hw, PHY_REG(769, 16), phy_reg | 0x0040);
1266 /* Set Early Link Enable */
1267 e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
1268 e1e_wphy(hw, PHY_REG(769, 20), phy_reg | 0x0400);
1269 /* fall through */
Bruce Allancef8c792008-04-02 13:48:23 -07001270 default:
Auke Kokbc7f75f2007-09-17 12:30:59 -07001271 /* force 1000, set loopback */
1272 e1e_wphy(hw, PHY_CONTROL, 0x4140);
Bruce Allancef8c792008-04-02 13:48:23 -07001273 mdelay(250);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001274
1275 /* Now set up the MAC to the same speed/duplex as the PHY. */
1276 ctrl_reg = er32(CTRL);
1277 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
1278 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1279 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1280 E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
1281 E1000_CTRL_FD); /* Force Duplex to FULL */
Bruce Allancef8c792008-04-02 13:48:23 -07001282
Bruce Allan97ac8ca2008-04-29 09:16:05 -07001283 if (adapter->flags & FLAG_IS_ICH)
Bruce Allancef8c792008-04-02 13:48:23 -07001284 ctrl_reg |= E1000_CTRL_SLU; /* Set Link Up */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001285 }
1286
Jeff Kirsher318a94d2008-03-28 09:15:16 -07001287 if (hw->phy.media_type == e1000_media_type_copper &&
1288 hw->phy.type == e1000_phy_m88) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001289 ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
1290 } else {
Bruce Allanad680762008-03-28 09:15:03 -07001291 /*
1292 * Set the ILOS bit on the fiber Nic if half duplex link is
1293 * detected.
1294 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001295 stat_reg = er32(STATUS);
1296 if ((stat_reg & E1000_STATUS_FD) == 0)
1297 ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
1298 }
1299
1300 ew32(CTRL, ctrl_reg);
1301
Bruce Allanad680762008-03-28 09:15:03 -07001302 /*
1303 * Disable the receiver on the PHY so when a cable is plugged in, the
Auke Kokbc7f75f2007-09-17 12:30:59 -07001304 * PHY does not begin to autoneg when a cable is reconnected to the NIC.
1305 */
Jeff Kirsher318a94d2008-03-28 09:15:16 -07001306 if (hw->phy.type == e1000_phy_m88)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001307 e1000_phy_disable_receiver(adapter);
1308
1309 udelay(500);
1310
1311 return 0;
1312}
1313
1314static int e1000_set_82571_fiber_loopback(struct e1000_adapter *adapter)
1315{
1316 struct e1000_hw *hw = &adapter->hw;
1317 u32 ctrl = er32(CTRL);
1318 int link = 0;
1319
1320 /* special requirements for 82571/82572 fiber adapters */
1321
Bruce Allanad680762008-03-28 09:15:03 -07001322 /*
1323 * jump through hoops to make sure link is up because serdes
1324 * link is hardwired up
1325 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001326 ctrl |= E1000_CTRL_SLU;
1327 ew32(CTRL, ctrl);
1328
1329 /* disable autoneg */
1330 ctrl = er32(TXCW);
1331 ctrl &= ~(1 << 31);
1332 ew32(TXCW, ctrl);
1333
1334 link = (er32(STATUS) & E1000_STATUS_LU);
1335
1336 if (!link) {
1337 /* set invert loss of signal */
1338 ctrl = er32(CTRL);
1339 ctrl |= E1000_CTRL_ILOS;
1340 ew32(CTRL, ctrl);
1341 }
1342
Bruce Allanad680762008-03-28 09:15:03 -07001343 /*
1344 * special write to serdes control register to enable SerDes analog
1345 * loopback
1346 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001347#define E1000_SERDES_LB_ON 0x410
1348 ew32(SCTL, E1000_SERDES_LB_ON);
1349 msleep(10);
1350
1351 return 0;
1352}
1353
1354/* only call this for fiber/serdes connections to es2lan */
1355static int e1000_set_es2lan_mac_loopback(struct e1000_adapter *adapter)
1356{
1357 struct e1000_hw *hw = &adapter->hw;
1358 u32 ctrlext = er32(CTRL_EXT);
1359 u32 ctrl = er32(CTRL);
1360
Bruce Allanad680762008-03-28 09:15:03 -07001361 /*
1362 * save CTRL_EXT to restore later, reuse an empty variable (unused
1363 * on mac_type 80003es2lan)
1364 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001365 adapter->tx_fifo_head = ctrlext;
1366
1367 /* clear the serdes mode bits, putting the device into mac loopback */
1368 ctrlext &= ~E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES;
1369 ew32(CTRL_EXT, ctrlext);
1370
1371 /* force speed to 1000/FD, link up */
1372 ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
1373 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX |
1374 E1000_CTRL_SPD_1000 | E1000_CTRL_FD);
1375 ew32(CTRL, ctrl);
1376
1377 /* set mac loopback */
1378 ctrl = er32(RCTL);
1379 ctrl |= E1000_RCTL_LBM_MAC;
1380 ew32(RCTL, ctrl);
1381
1382 /* set testing mode parameters (no need to reset later) */
1383#define KMRNCTRLSTA_OPMODE (0x1F << 16)
1384#define KMRNCTRLSTA_OPMODE_1GB_FD_GMII 0x0582
1385 ew32(KMRNCTRLSTA,
Bruce Allancef8c792008-04-02 13:48:23 -07001386 (KMRNCTRLSTA_OPMODE | KMRNCTRLSTA_OPMODE_1GB_FD_GMII));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001387
1388 return 0;
1389}
1390
1391static int e1000_setup_loopback_test(struct e1000_adapter *adapter)
1392{
1393 struct e1000_hw *hw = &adapter->hw;
1394 u32 rctl;
1395
Jeff Kirsher318a94d2008-03-28 09:15:16 -07001396 if (hw->phy.media_type == e1000_media_type_fiber ||
1397 hw->phy.media_type == e1000_media_type_internal_serdes) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001398 switch (hw->mac.type) {
1399 case e1000_80003es2lan:
1400 return e1000_set_es2lan_mac_loopback(adapter);
1401 break;
1402 case e1000_82571:
1403 case e1000_82572:
1404 return e1000_set_82571_fiber_loopback(adapter);
1405 break;
1406 default:
1407 rctl = er32(RCTL);
1408 rctl |= E1000_RCTL_LBM_TCVR;
1409 ew32(RCTL, rctl);
1410 return 0;
1411 }
Jeff Kirsher318a94d2008-03-28 09:15:16 -07001412 } else if (hw->phy.media_type == e1000_media_type_copper) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001413 return e1000_integrated_phy_loopback(adapter);
1414 }
1415
1416 return 7;
1417}
1418
1419static void e1000_loopback_cleanup(struct e1000_adapter *adapter)
1420{
1421 struct e1000_hw *hw = &adapter->hw;
1422 u32 rctl;
1423 u16 phy_reg;
1424
1425 rctl = er32(RCTL);
1426 rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
1427 ew32(RCTL, rctl);
1428
1429 switch (hw->mac.type) {
1430 case e1000_80003es2lan:
Jeff Kirsher318a94d2008-03-28 09:15:16 -07001431 if (hw->phy.media_type == e1000_media_type_fiber ||
1432 hw->phy.media_type == e1000_media_type_internal_serdes) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001433 /* restore CTRL_EXT, stealing space from tx_fifo_head */
Bruce Allanad680762008-03-28 09:15:03 -07001434 ew32(CTRL_EXT, adapter->tx_fifo_head);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001435 adapter->tx_fifo_head = 0;
1436 }
1437 /* fall through */
1438 case e1000_82571:
1439 case e1000_82572:
Jeff Kirsher318a94d2008-03-28 09:15:16 -07001440 if (hw->phy.media_type == e1000_media_type_fiber ||
1441 hw->phy.media_type == e1000_media_type_internal_serdes) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001442#define E1000_SERDES_LB_OFF 0x400
1443 ew32(SCTL, E1000_SERDES_LB_OFF);
1444 msleep(10);
1445 break;
1446 }
1447 /* Fall Through */
1448 default:
1449 hw->mac.autoneg = 1;
1450 if (hw->phy.type == e1000_phy_gg82563)
1451 e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x180);
1452 e1e_rphy(hw, PHY_CONTROL, &phy_reg);
1453 if (phy_reg & MII_CR_LOOPBACK) {
1454 phy_reg &= ~MII_CR_LOOPBACK;
1455 e1e_wphy(hw, PHY_CONTROL, phy_reg);
1456 e1000e_commit_phy(hw);
1457 }
1458 break;
1459 }
1460}
1461
1462static void e1000_create_lbtest_frame(struct sk_buff *skb,
1463 unsigned int frame_size)
1464{
1465 memset(skb->data, 0xFF, frame_size);
1466 frame_size &= ~1;
1467 memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
1468 memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
1469 memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
1470}
1471
1472static int e1000_check_lbtest_frame(struct sk_buff *skb,
1473 unsigned int frame_size)
1474{
1475 frame_size &= ~1;
1476 if (*(skb->data + 3) == 0xFF)
1477 if ((*(skb->data + frame_size / 2 + 10) == 0xBE) &&
1478 (*(skb->data + frame_size / 2 + 12) == 0xAF))
1479 return 0;
1480 return 13;
1481}
1482
1483static int e1000_run_loopback_test(struct e1000_adapter *adapter)
1484{
1485 struct e1000_ring *tx_ring = &adapter->test_tx_ring;
1486 struct e1000_ring *rx_ring = &adapter->test_rx_ring;
1487 struct pci_dev *pdev = adapter->pdev;
1488 struct e1000_hw *hw = &adapter->hw;
1489 int i, j, k, l;
1490 int lc;
1491 int good_cnt;
1492 int ret_val = 0;
1493 unsigned long time;
1494
1495 ew32(RDT, rx_ring->count - 1);
1496
Bruce Allanad680762008-03-28 09:15:03 -07001497 /*
1498 * Calculate the loop count based on the largest descriptor ring
Auke Kokbc7f75f2007-09-17 12:30:59 -07001499 * The idea is to wrap the largest ring a number of times using 64
1500 * send/receive pairs during each loop
1501 */
1502
1503 if (rx_ring->count <= tx_ring->count)
1504 lc = ((tx_ring->count / 64) * 2) + 1;
1505 else
1506 lc = ((rx_ring->count / 64) * 2) + 1;
1507
1508 k = 0;
1509 l = 0;
1510 for (j = 0; j <= lc; j++) { /* loop count loop */
1511 for (i = 0; i < 64; i++) { /* send the packets */
Bruce Allancef8c792008-04-02 13:48:23 -07001512 e1000_create_lbtest_frame(tx_ring->buffer_info[k].skb,
1513 1024);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001514 pci_dma_sync_single_for_device(pdev,
1515 tx_ring->buffer_info[k].dma,
1516 tx_ring->buffer_info[k].length,
1517 PCI_DMA_TODEVICE);
1518 k++;
1519 if (k == tx_ring->count)
1520 k = 0;
1521 }
1522 ew32(TDT, k);
1523 msleep(200);
1524 time = jiffies; /* set the start time for the receive */
1525 good_cnt = 0;
1526 do { /* receive the sent packets */
1527 pci_dma_sync_single_for_cpu(pdev,
1528 rx_ring->buffer_info[l].dma, 2048,
1529 PCI_DMA_FROMDEVICE);
1530
1531 ret_val = e1000_check_lbtest_frame(
1532 rx_ring->buffer_info[l].skb, 1024);
1533 if (!ret_val)
1534 good_cnt++;
1535 l++;
1536 if (l == rx_ring->count)
1537 l = 0;
Bruce Allanad680762008-03-28 09:15:03 -07001538 /*
1539 * time + 20 msecs (200 msecs on 2.4) is more than
Auke Kokbc7f75f2007-09-17 12:30:59 -07001540 * enough time to complete the receives, if it's
1541 * exceeded, break and error off
1542 */
1543 } while ((good_cnt < 64) && !time_after(jiffies, time + 20));
1544 if (good_cnt != 64) {
1545 ret_val = 13; /* ret_val is the same as mis-compare */
1546 break;
1547 }
Bruce Allancef8c792008-04-02 13:48:23 -07001548 if (jiffies >= (time + 20)) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001549 ret_val = 14; /* error code for time out error */
1550 break;
1551 }
1552 } /* end loop count loop */
1553 return ret_val;
1554}
1555
1556static int e1000_loopback_test(struct e1000_adapter *adapter, u64 *data)
1557{
Bruce Allanad680762008-03-28 09:15:03 -07001558 /*
1559 * PHY loopback cannot be performed if SoL/IDER
1560 * sessions are active
1561 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001562 if (e1000_check_reset_block(&adapter->hw)) {
Jeff Kirsher44defeb2008-08-04 17:20:41 -07001563 e_err("Cannot do PHY loopback test when SoL/IDER is active.\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001564 *data = 0;
1565 goto out;
1566 }
1567
1568 *data = e1000_setup_desc_rings(adapter);
Adrian Bunke2655222007-10-15 14:02:21 -07001569 if (*data)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001570 goto out;
1571
1572 *data = e1000_setup_loopback_test(adapter);
Adrian Bunke2655222007-10-15 14:02:21 -07001573 if (*data)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001574 goto err_loopback;
1575
1576 *data = e1000_run_loopback_test(adapter);
1577 e1000_loopback_cleanup(adapter);
1578
1579err_loopback:
1580 e1000_free_desc_rings(adapter);
1581out:
1582 return *data;
1583}
1584
1585static int e1000_link_test(struct e1000_adapter *adapter, u64 *data)
1586{
1587 struct e1000_hw *hw = &adapter->hw;
1588
1589 *data = 0;
Jeff Kirsher318a94d2008-03-28 09:15:16 -07001590 if (hw->phy.media_type == e1000_media_type_internal_serdes) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001591 int i = 0;
1592 hw->mac.serdes_has_link = 0;
1593
Bruce Allanad680762008-03-28 09:15:03 -07001594 /*
1595 * On some blade server designs, link establishment
1596 * could take as long as 2-3 minutes
1597 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001598 do {
1599 hw->mac.ops.check_for_link(hw);
1600 if (hw->mac.serdes_has_link)
1601 return *data;
1602 msleep(20);
1603 } while (i++ < 3750);
1604
1605 *data = 1;
1606 } else {
1607 hw->mac.ops.check_for_link(hw);
1608 if (hw->mac.autoneg)
1609 msleep(4000);
1610
1611 if (!(er32(STATUS) &
1612 E1000_STATUS_LU))
1613 *data = 1;
1614 }
1615 return *data;
1616}
1617
Jeff Garzikb9f2c042007-10-03 18:07:32 -07001618static int e1000e_get_sset_count(struct net_device *netdev, int sset)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001619{
Jeff Garzikb9f2c042007-10-03 18:07:32 -07001620 switch (sset) {
1621 case ETH_SS_TEST:
1622 return E1000_TEST_LEN;
1623 case ETH_SS_STATS:
1624 return E1000_STATS_LEN;
1625 default:
1626 return -EOPNOTSUPP;
1627 }
Auke Kokbc7f75f2007-09-17 12:30:59 -07001628}
1629
1630static void e1000_diag_test(struct net_device *netdev,
1631 struct ethtool_test *eth_test, u64 *data)
1632{
1633 struct e1000_adapter *adapter = netdev_priv(netdev);
1634 u16 autoneg_advertised;
1635 u8 forced_speed_duplex;
1636 u8 autoneg;
1637 bool if_running = netif_running(netdev);
1638
1639 set_bit(__E1000_TESTING, &adapter->state);
1640 if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
1641 /* Offline tests */
1642
1643 /* save speed, duplex, autoneg settings */
1644 autoneg_advertised = adapter->hw.phy.autoneg_advertised;
1645 forced_speed_duplex = adapter->hw.mac.forced_speed_duplex;
1646 autoneg = adapter->hw.mac.autoneg;
1647
Jeff Kirsher44defeb2008-08-04 17:20:41 -07001648 e_info("offline testing starting\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001649
Bruce Allanad680762008-03-28 09:15:03 -07001650 /*
1651 * Link test performed before hardware reset so autoneg doesn't
1652 * interfere with test result
1653 */
Auke Kokbc7f75f2007-09-17 12:30:59 -07001654 if (e1000_link_test(adapter, &data[4]))
1655 eth_test->flags |= ETH_TEST_FL_FAILED;
1656
1657 if (if_running)
1658 /* indicate we're in test mode */
1659 dev_close(netdev);
1660 else
1661 e1000e_reset(adapter);
1662
1663 if (e1000_reg_test(adapter, &data[0]))
1664 eth_test->flags |= ETH_TEST_FL_FAILED;
1665
1666 e1000e_reset(adapter);
1667 if (e1000_eeprom_test(adapter, &data[1]))
1668 eth_test->flags |= ETH_TEST_FL_FAILED;
1669
1670 e1000e_reset(adapter);
1671 if (e1000_intr_test(adapter, &data[2]))
1672 eth_test->flags |= ETH_TEST_FL_FAILED;
1673
1674 e1000e_reset(adapter);
1675 /* make sure the phy is powered up */
1676 e1000e_power_up_phy(adapter);
1677 if (e1000_loopback_test(adapter, &data[3]))
1678 eth_test->flags |= ETH_TEST_FL_FAILED;
1679
1680 /* restore speed, duplex, autoneg settings */
1681 adapter->hw.phy.autoneg_advertised = autoneg_advertised;
1682 adapter->hw.mac.forced_speed_duplex = forced_speed_duplex;
1683 adapter->hw.mac.autoneg = autoneg;
1684
1685 /* force this routine to wait until autoneg complete/timeout */
Jeff Kirsher318a94d2008-03-28 09:15:16 -07001686 adapter->hw.phy.autoneg_wait_to_complete = 1;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001687 e1000e_reset(adapter);
Jeff Kirsher318a94d2008-03-28 09:15:16 -07001688 adapter->hw.phy.autoneg_wait_to_complete = 0;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001689
1690 clear_bit(__E1000_TESTING, &adapter->state);
1691 if (if_running)
1692 dev_open(netdev);
1693 } else {
Jeff Kirsher44defeb2008-08-04 17:20:41 -07001694 e_info("online testing starting\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001695 /* Online tests */
1696 if (e1000_link_test(adapter, &data[4]))
1697 eth_test->flags |= ETH_TEST_FL_FAILED;
1698
1699 /* Online tests aren't run; pass by default */
1700 data[0] = 0;
1701 data[1] = 0;
1702 data[2] = 0;
1703 data[3] = 0;
1704
1705 clear_bit(__E1000_TESTING, &adapter->state);
1706 }
1707 msleep_interruptible(4 * 1000);
1708}
1709
1710static void e1000_get_wol(struct net_device *netdev,
1711 struct ethtool_wolinfo *wol)
1712{
1713 struct e1000_adapter *adapter = netdev_priv(netdev);
1714
1715 wol->supported = 0;
1716 wol->wolopts = 0;
1717
\"Rafael J. Wysocki\6ff68022008-11-12 09:52:32 +00001718 if (!(adapter->flags & FLAG_HAS_WOL) ||
1719 !device_can_wakeup(&adapter->pdev->dev))
Auke Kokbc7f75f2007-09-17 12:30:59 -07001720 return;
1721
1722 wol->supported = WAKE_UCAST | WAKE_MCAST |
Mitch Williamsefb90e42008-01-29 12:43:02 -08001723 WAKE_BCAST | WAKE_MAGIC |
1724 WAKE_PHY | WAKE_ARP;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001725
1726 /* apply any specific unsupported masks here */
1727 if (adapter->flags & FLAG_NO_WAKE_UCAST) {
1728 wol->supported &= ~WAKE_UCAST;
1729
1730 if (adapter->wol & E1000_WUFC_EX)
Jeff Kirsher44defeb2008-08-04 17:20:41 -07001731 e_err("Interface does not support directed (unicast) "
1732 "frame wake-up packets\n");
Auke Kokbc7f75f2007-09-17 12:30:59 -07001733 }
1734
1735 if (adapter->wol & E1000_WUFC_EX)
1736 wol->wolopts |= WAKE_UCAST;
1737 if (adapter->wol & E1000_WUFC_MC)
1738 wol->wolopts |= WAKE_MCAST;
1739 if (adapter->wol & E1000_WUFC_BC)
1740 wol->wolopts |= WAKE_BCAST;
1741 if (adapter->wol & E1000_WUFC_MAG)
1742 wol->wolopts |= WAKE_MAGIC;
Mitch Williamsefb90e42008-01-29 12:43:02 -08001743 if (adapter->wol & E1000_WUFC_LNKC)
1744 wol->wolopts |= WAKE_PHY;
1745 if (adapter->wol & E1000_WUFC_ARP)
1746 wol->wolopts |= WAKE_ARP;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001747}
1748
1749static int e1000_set_wol(struct net_device *netdev,
1750 struct ethtool_wolinfo *wol)
1751{
1752 struct e1000_adapter *adapter = netdev_priv(netdev);
1753
Mitch Williamsefb90e42008-01-29 12:43:02 -08001754 if (wol->wolopts & WAKE_MAGICSECURE)
Auke Kokbc7f75f2007-09-17 12:30:59 -07001755 return -EOPNOTSUPP;
1756
\"Rafael J. Wysocki\6ff68022008-11-12 09:52:32 +00001757 if (!(adapter->flags & FLAG_HAS_WOL) ||
1758 !device_can_wakeup(&adapter->pdev->dev))
Auke Kokbc7f75f2007-09-17 12:30:59 -07001759 return wol->wolopts ? -EOPNOTSUPP : 0;
1760
1761 /* these settings will always override what we currently have */
1762 adapter->wol = 0;
1763
1764 if (wol->wolopts & WAKE_UCAST)
1765 adapter->wol |= E1000_WUFC_EX;
1766 if (wol->wolopts & WAKE_MCAST)
1767 adapter->wol |= E1000_WUFC_MC;
1768 if (wol->wolopts & WAKE_BCAST)
1769 adapter->wol |= E1000_WUFC_BC;
1770 if (wol->wolopts & WAKE_MAGIC)
1771 adapter->wol |= E1000_WUFC_MAG;
Mitch Williamsefb90e42008-01-29 12:43:02 -08001772 if (wol->wolopts & WAKE_PHY)
1773 adapter->wol |= E1000_WUFC_LNKC;
1774 if (wol->wolopts & WAKE_ARP)
1775 adapter->wol |= E1000_WUFC_ARP;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001776
\"Rafael J. Wysocki\6ff68022008-11-12 09:52:32 +00001777 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
1778
Auke Kokbc7f75f2007-09-17 12:30:59 -07001779 return 0;
1780}
1781
1782/* toggle LED 4 times per second = 2 "blinks" per second */
1783#define E1000_ID_INTERVAL (HZ/4)
1784
1785/* bit defines for adapter->led_status */
1786#define E1000_LED_ON 0
1787
1788static void e1000_led_blink_callback(unsigned long data)
1789{
1790 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
1791
1792 if (test_and_change_bit(E1000_LED_ON, &adapter->led_status))
1793 adapter->hw.mac.ops.led_off(&adapter->hw);
1794 else
1795 adapter->hw.mac.ops.led_on(&adapter->hw);
1796
1797 mod_timer(&adapter->blink_timer, jiffies + E1000_ID_INTERVAL);
1798}
1799
1800static int e1000_phys_id(struct net_device *netdev, u32 data)
1801{
1802 struct e1000_adapter *adapter = netdev_priv(netdev);
Bruce Allan4662e822008-08-26 18:37:06 -07001803 struct e1000_hw *hw = &adapter->hw;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001804
Stephen Hemminger5a9147b2007-10-29 10:46:05 -07001805 if (!data)
1806 data = INT_MAX;
Auke Kokbc7f75f2007-09-17 12:30:59 -07001807
Bruce Allan4662e822008-08-26 18:37:06 -07001808 if ((hw->phy.type == e1000_phy_ife) ||
1809 (hw->mac.type == e1000_82574)) {
Auke Kokbc7f75f2007-09-17 12:30:59 -07001810 if (!adapter->blink_timer.function) {
1811 init_timer(&adapter->blink_timer);
1812 adapter->blink_timer.function =
1813 e1000_led_blink_callback;
1814 adapter->blink_timer.data = (unsigned long) adapter;
1815 }
1816 mod_timer(&adapter->blink_timer, jiffies);
1817 msleep_interruptible(data * 1000);
1818 del_timer_sync(&adapter->blink_timer);
Bruce Allan4662e822008-08-26 18:37:06 -07001819 if (hw->phy.type == e1000_phy_ife)
1820 e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001821 } else {
Bruce Allan4662e822008-08-26 18:37:06 -07001822 e1000e_blink_led(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001823 msleep_interruptible(data * 1000);
1824 }
1825
Bruce Allan4662e822008-08-26 18:37:06 -07001826 hw->mac.ops.led_off(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001827 clear_bit(E1000_LED_ON, &adapter->led_status);
Bruce Allan4662e822008-08-26 18:37:06 -07001828 hw->mac.ops.cleanup_led(hw);
Auke Kokbc7f75f2007-09-17 12:30:59 -07001829
1830 return 0;
1831}
1832
Auke Kokde5b3072008-04-23 11:09:08 -07001833static int e1000_get_coalesce(struct net_device *netdev,
1834 struct ethtool_coalesce *ec)
1835{
1836 struct e1000_adapter *adapter = netdev_priv(netdev);
1837
1838 if (adapter->itr_setting <= 3)
1839 ec->rx_coalesce_usecs = adapter->itr_setting;
1840 else
1841 ec->rx_coalesce_usecs = 1000000 / adapter->itr_setting;
1842
1843 return 0;
1844}
1845
1846static int e1000_set_coalesce(struct net_device *netdev,
1847 struct ethtool_coalesce *ec)
1848{
1849 struct e1000_adapter *adapter = netdev_priv(netdev);
1850 struct e1000_hw *hw = &adapter->hw;
1851
1852 if ((ec->rx_coalesce_usecs > E1000_MAX_ITR_USECS) ||
1853 ((ec->rx_coalesce_usecs > 3) &&
1854 (ec->rx_coalesce_usecs < E1000_MIN_ITR_USECS)) ||
1855 (ec->rx_coalesce_usecs == 2))
1856 return -EINVAL;
1857
1858 if (ec->rx_coalesce_usecs <= 3) {
1859 adapter->itr = 20000;
1860 adapter->itr_setting = ec->rx_coalesce_usecs;
1861 } else {
1862 adapter->itr = (1000000 / ec->rx_coalesce_usecs);
1863 adapter->itr_setting = adapter->itr & ~3;
1864 }
1865
1866 if (adapter->itr_setting != 0)
1867 ew32(ITR, 1000000000 / (adapter->itr * 256));
1868 else
1869 ew32(ITR, 0);
1870
1871 return 0;
1872}
1873
Auke Kokbc7f75f2007-09-17 12:30:59 -07001874static int e1000_nway_reset(struct net_device *netdev)
1875{
1876 struct e1000_adapter *adapter = netdev_priv(netdev);
1877 if (netif_running(netdev))
1878 e1000e_reinit_locked(adapter);
1879 return 0;
1880}
1881
Auke Kokbc7f75f2007-09-17 12:30:59 -07001882static void e1000_get_ethtool_stats(struct net_device *netdev,
1883 struct ethtool_stats *stats,
1884 u64 *data)
1885{
1886 struct e1000_adapter *adapter = netdev_priv(netdev);
1887 int i;
1888
1889 e1000e_update_stats(adapter);
1890 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
1891 char *p = (char *)adapter+e1000_gstrings_stats[i].stat_offset;
1892 data[i] = (e1000_gstrings_stats[i].sizeof_stat ==
1893 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
1894 }
1895}
1896
1897static void e1000_get_strings(struct net_device *netdev, u32 stringset,
1898 u8 *data)
1899{
1900 u8 *p = data;
1901 int i;
1902
1903 switch (stringset) {
1904 case ETH_SS_TEST:
Bruce Allanad680762008-03-28 09:15:03 -07001905 memcpy(data, *e1000_gstrings_test, sizeof(e1000_gstrings_test));
Auke Kokbc7f75f2007-09-17 12:30:59 -07001906 break;
1907 case ETH_SS_STATS:
1908 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
1909 memcpy(p, e1000_gstrings_stats[i].stat_string,
1910 ETH_GSTRING_LEN);
1911 p += ETH_GSTRING_LEN;
1912 }
1913 break;
1914 }
1915}
1916
1917static const struct ethtool_ops e1000_ethtool_ops = {
1918 .get_settings = e1000_get_settings,
1919 .set_settings = e1000_set_settings,
1920 .get_drvinfo = e1000_get_drvinfo,
1921 .get_regs_len = e1000_get_regs_len,
1922 .get_regs = e1000_get_regs,
1923 .get_wol = e1000_get_wol,
1924 .set_wol = e1000_set_wol,
1925 .get_msglevel = e1000_get_msglevel,
1926 .set_msglevel = e1000_set_msglevel,
1927 .nway_reset = e1000_nway_reset,
Auke Kok369d7422007-10-15 14:30:59 -07001928 .get_link = e1000_get_link,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001929 .get_eeprom_len = e1000_get_eeprom_len,
1930 .get_eeprom = e1000_get_eeprom,
1931 .set_eeprom = e1000_set_eeprom,
1932 .get_ringparam = e1000_get_ringparam,
1933 .set_ringparam = e1000_set_ringparam,
1934 .get_pauseparam = e1000_get_pauseparam,
1935 .set_pauseparam = e1000_set_pauseparam,
1936 .get_rx_csum = e1000_get_rx_csum,
1937 .set_rx_csum = e1000_set_rx_csum,
1938 .get_tx_csum = e1000_get_tx_csum,
1939 .set_tx_csum = e1000_set_tx_csum,
1940 .get_sg = ethtool_op_get_sg,
1941 .set_sg = ethtool_op_set_sg,
1942 .get_tso = ethtool_op_get_tso,
1943 .set_tso = e1000_set_tso,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001944 .self_test = e1000_diag_test,
1945 .get_strings = e1000_get_strings,
1946 .phys_id = e1000_phys_id,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001947 .get_ethtool_stats = e1000_get_ethtool_stats,
Jeff Garzikb9f2c042007-10-03 18:07:32 -07001948 .get_sset_count = e1000e_get_sset_count,
Auke Kokde5b3072008-04-23 11:09:08 -07001949 .get_coalesce = e1000_get_coalesce,
1950 .set_coalesce = e1000_set_coalesce,
Auke Kokbc7f75f2007-09-17 12:30:59 -07001951};
1952
1953void e1000e_set_ethtool_ops(struct net_device *netdev)
1954{
1955 SET_ETHTOOL_OPS(netdev, &e1000_ethtool_ops);
1956}