blob: fae585453463387ebb71d411be2c827ee359dbc7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2
3
4 Copyright(c) 1999 - 2004 Intel Corporation. All rights reserved.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 You should have received a copy of the GNU General Public License along with
17 this program; if not, write to the Free Software Foundation, Inc., 59
18 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 The full GNU General Public License is included in this distribution in the
21 file called LICENSE.
22
23 Contact Information:
24 Linux NICS <linux.nics@intel.com>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
26
27*******************************************************************************/
28
29/* ethtool support for e1000 */
30
31#include "e1000.h"
32
33#include <asm/uaccess.h>
34
35extern char e1000_driver_name[];
36extern char e1000_driver_version[];
37
38extern int e1000_up(struct e1000_adapter *adapter);
39extern void e1000_down(struct e1000_adapter *adapter);
40extern void e1000_reset(struct e1000_adapter *adapter);
41extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx);
42extern int e1000_setup_rx_resources(struct e1000_adapter *adapter);
43extern int e1000_setup_tx_resources(struct e1000_adapter *adapter);
44extern void e1000_free_rx_resources(struct e1000_adapter *adapter);
45extern void e1000_free_tx_resources(struct e1000_adapter *adapter);
46extern void e1000_update_stats(struct e1000_adapter *adapter);
47
48struct e1000_stats {
49 char stat_string[ETH_GSTRING_LEN];
50 int sizeof_stat;
51 int stat_offset;
52};
53
54#define E1000_STAT(m) sizeof(((struct e1000_adapter *)0)->m), \
55 offsetof(struct e1000_adapter, m)
56static const struct e1000_stats e1000_gstrings_stats[] = {
57 { "rx_packets", E1000_STAT(net_stats.rx_packets) },
58 { "tx_packets", E1000_STAT(net_stats.tx_packets) },
59 { "rx_bytes", E1000_STAT(net_stats.rx_bytes) },
60 { "tx_bytes", E1000_STAT(net_stats.tx_bytes) },
61 { "rx_errors", E1000_STAT(net_stats.rx_errors) },
62 { "tx_errors", E1000_STAT(net_stats.tx_errors) },
63 { "rx_dropped", E1000_STAT(net_stats.rx_dropped) },
64 { "tx_dropped", E1000_STAT(net_stats.tx_dropped) },
65 { "multicast", E1000_STAT(net_stats.multicast) },
66 { "collisions", E1000_STAT(net_stats.collisions) },
67 { "rx_length_errors", E1000_STAT(net_stats.rx_length_errors) },
68 { "rx_over_errors", E1000_STAT(net_stats.rx_over_errors) },
69 { "rx_crc_errors", E1000_STAT(net_stats.rx_crc_errors) },
70 { "rx_frame_errors", E1000_STAT(net_stats.rx_frame_errors) },
71 { "rx_fifo_errors", E1000_STAT(net_stats.rx_fifo_errors) },
72 { "rx_missed_errors", E1000_STAT(net_stats.rx_missed_errors) },
73 { "tx_aborted_errors", E1000_STAT(net_stats.tx_aborted_errors) },
74 { "tx_carrier_errors", E1000_STAT(net_stats.tx_carrier_errors) },
75 { "tx_fifo_errors", E1000_STAT(net_stats.tx_fifo_errors) },
76 { "tx_heartbeat_errors", E1000_STAT(net_stats.tx_heartbeat_errors) },
77 { "tx_window_errors", E1000_STAT(net_stats.tx_window_errors) },
78 { "tx_abort_late_coll", E1000_STAT(stats.latecol) },
79 { "tx_deferred_ok", E1000_STAT(stats.dc) },
80 { "tx_single_coll_ok", E1000_STAT(stats.scc) },
81 { "tx_multi_coll_ok", E1000_STAT(stats.mcc) },
82 { "rx_long_length_errors", E1000_STAT(stats.roc) },
83 { "rx_short_length_errors", E1000_STAT(stats.ruc) },
84 { "rx_align_errors", E1000_STAT(stats.algnerrc) },
85 { "tx_tcp_seg_good", E1000_STAT(stats.tsctc) },
86 { "tx_tcp_seg_failed", E1000_STAT(stats.tsctfc) },
87 { "rx_flow_control_xon", E1000_STAT(stats.xonrxc) },
88 { "rx_flow_control_xoff", E1000_STAT(stats.xoffrxc) },
89 { "tx_flow_control_xon", E1000_STAT(stats.xontxc) },
90 { "tx_flow_control_xoff", E1000_STAT(stats.xofftxc) },
91 { "rx_long_byte_count", E1000_STAT(stats.gorcl) },
92 { "rx_csum_offload_good", E1000_STAT(hw_csum_good) },
93 { "rx_csum_offload_errors", E1000_STAT(hw_csum_err) }
94};
95#define E1000_STATS_LEN \
96 sizeof(e1000_gstrings_stats) / sizeof(struct e1000_stats)
97static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = {
98 "Register test (offline)", "Eeprom test (offline)",
99 "Interrupt test (offline)", "Loopback test (offline)",
100 "Link test (on/offline)"
101};
102#define E1000_TEST_LEN sizeof(e1000_gstrings_test) / ETH_GSTRING_LEN
103
104static int
105e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
106{
107 struct e1000_adapter *adapter = netdev->priv;
108 struct e1000_hw *hw = &adapter->hw;
109
110 if(hw->media_type == e1000_media_type_copper) {
111
112 ecmd->supported = (SUPPORTED_10baseT_Half |
113 SUPPORTED_10baseT_Full |
114 SUPPORTED_100baseT_Half |
115 SUPPORTED_100baseT_Full |
116 SUPPORTED_1000baseT_Full|
117 SUPPORTED_Autoneg |
118 SUPPORTED_TP);
119
120 ecmd->advertising = ADVERTISED_TP;
121
122 if(hw->autoneg == 1) {
123 ecmd->advertising |= ADVERTISED_Autoneg;
124
125 /* the e1000 autoneg seems to match ethtool nicely */
126
127 ecmd->advertising |= hw->autoneg_advertised;
128 }
129
130 ecmd->port = PORT_TP;
131 ecmd->phy_address = hw->phy_addr;
132
133 if(hw->mac_type == e1000_82543)
134 ecmd->transceiver = XCVR_EXTERNAL;
135 else
136 ecmd->transceiver = XCVR_INTERNAL;
137
138 } else {
139 ecmd->supported = (SUPPORTED_1000baseT_Full |
140 SUPPORTED_FIBRE |
141 SUPPORTED_Autoneg);
142
143 ecmd->advertising = (SUPPORTED_1000baseT_Full |
144 SUPPORTED_FIBRE |
145 SUPPORTED_Autoneg);
146
147 ecmd->port = PORT_FIBRE;
148
149 if(hw->mac_type >= e1000_82545)
150 ecmd->transceiver = XCVR_INTERNAL;
151 else
152 ecmd->transceiver = XCVR_EXTERNAL;
153 }
154
155 if(netif_carrier_ok(adapter->netdev)) {
156
157 e1000_get_speed_and_duplex(hw, &adapter->link_speed,
158 &adapter->link_duplex);
159 ecmd->speed = adapter->link_speed;
160
161 /* unfortunatly FULL_DUPLEX != DUPLEX_FULL
162 * and HALF_DUPLEX != DUPLEX_HALF */
163
164 if(adapter->link_duplex == FULL_DUPLEX)
165 ecmd->duplex = DUPLEX_FULL;
166 else
167 ecmd->duplex = DUPLEX_HALF;
168 } else {
169 ecmd->speed = -1;
170 ecmd->duplex = -1;
171 }
172
173 ecmd->autoneg = ((hw->media_type == e1000_media_type_fiber) ||
174 hw->autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE;
175 return 0;
176}
177
178static int
179e1000_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
180{
181 struct e1000_adapter *adapter = netdev->priv;
182 struct e1000_hw *hw = &adapter->hw;
183
184 if(ecmd->autoneg == AUTONEG_ENABLE) {
185 hw->autoneg = 1;
186 hw->autoneg_advertised = 0x002F;
187 ecmd->advertising = 0x002F;
188 } else
189 if(e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex))
190 return -EINVAL;
191
192 /* reset the link */
193
194 if(netif_running(adapter->netdev)) {
195 e1000_down(adapter);
196 e1000_reset(adapter);
197 e1000_up(adapter);
198 } else
199 e1000_reset(adapter);
200
201 return 0;
202}
203
204static void
205e1000_get_pauseparam(struct net_device *netdev,
206 struct ethtool_pauseparam *pause)
207{
208 struct e1000_adapter *adapter = netdev->priv;
209 struct e1000_hw *hw = &adapter->hw;
210
211 pause->autoneg =
212 (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
213
214 if(hw->fc == e1000_fc_rx_pause)
215 pause->rx_pause = 1;
216 else if(hw->fc == e1000_fc_tx_pause)
217 pause->tx_pause = 1;
218 else if(hw->fc == e1000_fc_full) {
219 pause->rx_pause = 1;
220 pause->tx_pause = 1;
221 }
222}
223
224static int
225e1000_set_pauseparam(struct net_device *netdev,
226 struct ethtool_pauseparam *pause)
227{
228 struct e1000_adapter *adapter = netdev->priv;
229 struct e1000_hw *hw = &adapter->hw;
230
231 adapter->fc_autoneg = pause->autoneg;
232
233 if(pause->rx_pause && pause->tx_pause)
234 hw->fc = e1000_fc_full;
235 else if(pause->rx_pause && !pause->tx_pause)
236 hw->fc = e1000_fc_rx_pause;
237 else if(!pause->rx_pause && pause->tx_pause)
238 hw->fc = e1000_fc_tx_pause;
239 else if(!pause->rx_pause && !pause->tx_pause)
240 hw->fc = e1000_fc_none;
241
242 hw->original_fc = hw->fc;
243
244 if(adapter->fc_autoneg == AUTONEG_ENABLE) {
245 if(netif_running(adapter->netdev)) {
246 e1000_down(adapter);
247 e1000_up(adapter);
248 } else
249 e1000_reset(adapter);
250 }
251 else
252 return ((hw->media_type == e1000_media_type_fiber) ?
253 e1000_setup_link(hw) : e1000_force_mac_fc(hw));
254
255 return 0;
256}
257
258static uint32_t
259e1000_get_rx_csum(struct net_device *netdev)
260{
261 struct e1000_adapter *adapter = netdev->priv;
262 return adapter->rx_csum;
263}
264
265static int
266e1000_set_rx_csum(struct net_device *netdev, uint32_t data)
267{
268 struct e1000_adapter *adapter = netdev->priv;
269 adapter->rx_csum = data;
270
271 if(netif_running(netdev)) {
272 e1000_down(adapter);
273 e1000_up(adapter);
274 } else
275 e1000_reset(adapter);
276 return 0;
277}
278
279static uint32_t
280e1000_get_tx_csum(struct net_device *netdev)
281{
282 return (netdev->features & NETIF_F_HW_CSUM) != 0;
283}
284
285static int
286e1000_set_tx_csum(struct net_device *netdev, uint32_t data)
287{
288 struct e1000_adapter *adapter = netdev->priv;
289
290 if(adapter->hw.mac_type < e1000_82543) {
291 if (!data)
292 return -EINVAL;
293 return 0;
294 }
295
296 if (data)
297 netdev->features |= NETIF_F_HW_CSUM;
298 else
299 netdev->features &= ~NETIF_F_HW_CSUM;
300
301 return 0;
302}
303
304#ifdef NETIF_F_TSO
305static int
306e1000_set_tso(struct net_device *netdev, uint32_t data)
307{
308 struct e1000_adapter *adapter = netdev->priv;
309 if ((adapter->hw.mac_type < e1000_82544) ||
310 (adapter->hw.mac_type == e1000_82547))
311 return data ? -EINVAL : 0;
312
313 if (data)
314 netdev->features |= NETIF_F_TSO;
315 else
316 netdev->features &= ~NETIF_F_TSO;
317 return 0;
318}
319#endif /* NETIF_F_TSO */
320
321static uint32_t
322e1000_get_msglevel(struct net_device *netdev)
323{
324 struct e1000_adapter *adapter = netdev->priv;
325 return adapter->msg_enable;
326}
327
328static void
329e1000_set_msglevel(struct net_device *netdev, uint32_t data)
330{
331 struct e1000_adapter *adapter = netdev->priv;
332 adapter->msg_enable = data;
333}
334
335static int
336e1000_get_regs_len(struct net_device *netdev)
337{
338#define E1000_REGS_LEN 32
339 return E1000_REGS_LEN * sizeof(uint32_t);
340}
341
342static void
343e1000_get_regs(struct net_device *netdev,
344 struct ethtool_regs *regs, void *p)
345{
346 struct e1000_adapter *adapter = netdev->priv;
347 struct e1000_hw *hw = &adapter->hw;
348 uint32_t *regs_buff = p;
349 uint16_t phy_data;
350
351 memset(p, 0, E1000_REGS_LEN * sizeof(uint32_t));
352
353 regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id;
354
355 regs_buff[0] = E1000_READ_REG(hw, CTRL);
356 regs_buff[1] = E1000_READ_REG(hw, STATUS);
357
358 regs_buff[2] = E1000_READ_REG(hw, RCTL);
359 regs_buff[3] = E1000_READ_REG(hw, RDLEN);
360 regs_buff[4] = E1000_READ_REG(hw, RDH);
361 regs_buff[5] = E1000_READ_REG(hw, RDT);
362 regs_buff[6] = E1000_READ_REG(hw, RDTR);
363
364 regs_buff[7] = E1000_READ_REG(hw, TCTL);
365 regs_buff[8] = E1000_READ_REG(hw, TDLEN);
366 regs_buff[9] = E1000_READ_REG(hw, TDH);
367 regs_buff[10] = E1000_READ_REG(hw, TDT);
368 regs_buff[11] = E1000_READ_REG(hw, TIDV);
369
370 regs_buff[12] = adapter->hw.phy_type; /* PHY type (IGP=1, M88=0) */
371 if(hw->phy_type == e1000_phy_igp) {
372 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
373 IGP01E1000_PHY_AGC_A);
374 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_A &
375 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
376 regs_buff[13] = (uint32_t)phy_data; /* cable length */
377 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
378 IGP01E1000_PHY_AGC_B);
379 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_B &
380 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
381 regs_buff[14] = (uint32_t)phy_data; /* cable length */
382 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
383 IGP01E1000_PHY_AGC_C);
384 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_C &
385 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
386 regs_buff[15] = (uint32_t)phy_data; /* cable length */
387 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
388 IGP01E1000_PHY_AGC_D);
389 e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_D &
390 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
391 regs_buff[16] = (uint32_t)phy_data; /* cable length */
392 regs_buff[17] = 0; /* extended 10bt distance (not needed) */
393 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0);
394 e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS &
395 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
396 regs_buff[18] = (uint32_t)phy_data; /* cable polarity */
397 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
398 IGP01E1000_PHY_PCS_INIT_REG);
399 e1000_read_phy_reg(hw, IGP01E1000_PHY_PCS_INIT_REG &
400 IGP01E1000_PHY_PAGE_SELECT, &phy_data);
401 regs_buff[19] = (uint32_t)phy_data; /* cable polarity */
402 regs_buff[20] = 0; /* polarity correction enabled (always) */
403 regs_buff[22] = 0; /* phy receive errors (unavailable) */
404 regs_buff[23] = regs_buff[18]; /* mdix mode */
405 e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0);
406 } else {
407 e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
408 regs_buff[13] = (uint32_t)phy_data; /* cable length */
409 regs_buff[14] = 0; /* Dummy (to align w/ IGP phy reg dump) */
410 regs_buff[15] = 0; /* Dummy (to align w/ IGP phy reg dump) */
411 regs_buff[16] = 0; /* Dummy (to align w/ IGP phy reg dump) */
412 e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
413 regs_buff[17] = (uint32_t)phy_data; /* extended 10bt distance */
414 regs_buff[18] = regs_buff[13]; /* cable polarity */
415 regs_buff[19] = 0; /* Dummy (to align w/ IGP phy reg dump) */
416 regs_buff[20] = regs_buff[17]; /* polarity correction */
417 /* phy receive errors */
418 regs_buff[22] = adapter->phy_stats.receive_errors;
419 regs_buff[23] = regs_buff[13]; /* mdix mode */
420 }
421 regs_buff[21] = adapter->phy_stats.idle_errors; /* phy idle errors */
422 e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data);
423 regs_buff[24] = (uint32_t)phy_data; /* phy local receiver status */
424 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */
425 if(hw->mac_type >= e1000_82540 &&
426 hw->media_type == e1000_media_type_copper) {
427 regs_buff[26] = E1000_READ_REG(hw, MANC);
428 }
429}
430
431static int
432e1000_get_eeprom_len(struct net_device *netdev)
433{
434 struct e1000_adapter *adapter = netdev->priv;
435 return adapter->hw.eeprom.word_size * 2;
436}
437
438static int
439e1000_get_eeprom(struct net_device *netdev,
440 struct ethtool_eeprom *eeprom, uint8_t *bytes)
441{
442 struct e1000_adapter *adapter = netdev->priv;
443 struct e1000_hw *hw = &adapter->hw;
444 uint16_t *eeprom_buff;
445 int first_word, last_word;
446 int ret_val = 0;
447 uint16_t i;
448
449 if(eeprom->len == 0)
450 return -EINVAL;
451
452 eeprom->magic = hw->vendor_id | (hw->device_id << 16);
453
454 first_word = eeprom->offset >> 1;
455 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
456
457 eeprom_buff = kmalloc(sizeof(uint16_t) *
458 (last_word - first_word + 1), GFP_KERNEL);
459 if(!eeprom_buff)
460 return -ENOMEM;
461
462 if(hw->eeprom.type == e1000_eeprom_spi)
463 ret_val = e1000_read_eeprom(hw, first_word,
464 last_word - first_word + 1,
465 eeprom_buff);
466 else {
467 for (i = 0; i < last_word - first_word + 1; i++)
468 if((ret_val = e1000_read_eeprom(hw, first_word + i, 1,
469 &eeprom_buff[i])))
470 break;
471 }
472
473 /* Device's eeprom is always little-endian, word addressable */
474 for (i = 0; i < last_word - first_word + 1; i++)
475 le16_to_cpus(&eeprom_buff[i]);
476
477 memcpy(bytes, (uint8_t *)eeprom_buff + (eeprom->offset & 1),
478 eeprom->len);
479 kfree(eeprom_buff);
480
481 return ret_val;
482}
483
484static int
485e1000_set_eeprom(struct net_device *netdev,
486 struct ethtool_eeprom *eeprom, uint8_t *bytes)
487{
488 struct e1000_adapter *adapter = netdev->priv;
489 struct e1000_hw *hw = &adapter->hw;
490 uint16_t *eeprom_buff;
491 void *ptr;
492 int max_len, first_word, last_word, ret_val = 0;
493 uint16_t i;
494
495 if(eeprom->len == 0)
496 return -EOPNOTSUPP;
497
498 if(eeprom->magic != (hw->vendor_id | (hw->device_id << 16)))
499 return -EFAULT;
500
501 max_len = hw->eeprom.word_size * 2;
502
503 first_word = eeprom->offset >> 1;
504 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
505 eeprom_buff = kmalloc(max_len, GFP_KERNEL);
506 if(!eeprom_buff)
507 return -ENOMEM;
508
509 ptr = (void *)eeprom_buff;
510
511 if(eeprom->offset & 1) {
512 /* need read/modify/write of first changed EEPROM word */
513 /* only the second byte of the word is being modified */
514 ret_val = e1000_read_eeprom(hw, first_word, 1,
515 &eeprom_buff[0]);
516 ptr++;
517 }
518 if(((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) {
519 /* need read/modify/write of last changed EEPROM word */
520 /* only the first byte of the word is being modified */
521 ret_val = e1000_read_eeprom(hw, last_word, 1,
522 &eeprom_buff[last_word - first_word]);
523 }
524
525 /* Device's eeprom is always little-endian, word addressable */
526 for (i = 0; i < last_word - first_word + 1; i++)
527 le16_to_cpus(&eeprom_buff[i]);
528
529 memcpy(ptr, bytes, eeprom->len);
530
531 for (i = 0; i < last_word - first_word + 1; i++)
532 eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]);
533
534 ret_val = e1000_write_eeprom(hw, first_word,
535 last_word - first_word + 1, eeprom_buff);
536
537 /* Update the checksum over the first part of the EEPROM if needed */
538 if((ret_val == 0) && first_word <= EEPROM_CHECKSUM_REG)
539 e1000_update_eeprom_checksum(hw);
540
541 kfree(eeprom_buff);
542 return ret_val;
543}
544
545static void
546e1000_get_drvinfo(struct net_device *netdev,
547 struct ethtool_drvinfo *drvinfo)
548{
549 struct e1000_adapter *adapter = netdev->priv;
550
551 strncpy(drvinfo->driver, e1000_driver_name, 32);
552 strncpy(drvinfo->version, e1000_driver_version, 32);
553 strncpy(drvinfo->fw_version, "N/A", 32);
554 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
555 drvinfo->n_stats = E1000_STATS_LEN;
556 drvinfo->testinfo_len = E1000_TEST_LEN;
557 drvinfo->regdump_len = e1000_get_regs_len(netdev);
558 drvinfo->eedump_len = e1000_get_eeprom_len(netdev);
559}
560
561static void
562e1000_get_ringparam(struct net_device *netdev,
563 struct ethtool_ringparam *ring)
564{
565 struct e1000_adapter *adapter = netdev->priv;
566 e1000_mac_type mac_type = adapter->hw.mac_type;
567 struct e1000_desc_ring *txdr = &adapter->tx_ring;
568 struct e1000_desc_ring *rxdr = &adapter->rx_ring;
569
570 ring->rx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_RXD :
571 E1000_MAX_82544_RXD;
572 ring->tx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_TXD :
573 E1000_MAX_82544_TXD;
574 ring->rx_mini_max_pending = 0;
575 ring->rx_jumbo_max_pending = 0;
576 ring->rx_pending = rxdr->count;
577 ring->tx_pending = txdr->count;
578 ring->rx_mini_pending = 0;
579 ring->rx_jumbo_pending = 0;
580}
581
582static int
583e1000_set_ringparam(struct net_device *netdev,
584 struct ethtool_ringparam *ring)
585{
586 struct e1000_adapter *adapter = netdev->priv;
587 e1000_mac_type mac_type = adapter->hw.mac_type;
588 struct e1000_desc_ring *txdr = &adapter->tx_ring;
589 struct e1000_desc_ring *rxdr = &adapter->rx_ring;
590 struct e1000_desc_ring tx_old, tx_new, rx_old, rx_new;
591 int err;
592
593 tx_old = adapter->tx_ring;
594 rx_old = adapter->rx_ring;
595
596 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
597 return -EINVAL;
598
599 if(netif_running(adapter->netdev))
600 e1000_down(adapter);
601
602 rxdr->count = max(ring->rx_pending,(uint32_t)E1000_MIN_RXD);
603 rxdr->count = min(rxdr->count,(uint32_t)(mac_type < e1000_82544 ?
604 E1000_MAX_RXD : E1000_MAX_82544_RXD));
605 E1000_ROUNDUP(rxdr->count, REQ_RX_DESCRIPTOR_MULTIPLE);
606
607 txdr->count = max(ring->tx_pending,(uint32_t)E1000_MIN_TXD);
608 txdr->count = min(txdr->count,(uint32_t)(mac_type < e1000_82544 ?
609 E1000_MAX_TXD : E1000_MAX_82544_TXD));
610 E1000_ROUNDUP(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
611
612 if(netif_running(adapter->netdev)) {
613 /* Try to get new resources before deleting old */
614 if((err = e1000_setup_rx_resources(adapter)))
615 goto err_setup_rx;
616 if((err = e1000_setup_tx_resources(adapter)))
617 goto err_setup_tx;
618
619 /* save the new, restore the old in order to free it,
620 * then restore the new back again */
621
622 rx_new = adapter->rx_ring;
623 tx_new = adapter->tx_ring;
624 adapter->rx_ring = rx_old;
625 adapter->tx_ring = tx_old;
626 e1000_free_rx_resources(adapter);
627 e1000_free_tx_resources(adapter);
628 adapter->rx_ring = rx_new;
629 adapter->tx_ring = tx_new;
630 if((err = e1000_up(adapter)))
631 return err;
632 }
633
634 return 0;
635err_setup_tx:
636 e1000_free_rx_resources(adapter);
637err_setup_rx:
638 adapter->rx_ring = rx_old;
639 adapter->tx_ring = tx_old;
640 e1000_up(adapter);
641 return err;
642}
643
644#define REG_PATTERN_TEST(R, M, W) \
645{ \
646 uint32_t pat, value; \
647 uint32_t test[] = \
648 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; \
649 for(pat = 0; pat < sizeof(test)/sizeof(test[0]); pat++) { \
650 E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \
651 value = E1000_READ_REG(&adapter->hw, R); \
652 if(value != (test[pat] & W & M)) { \
653 *data = (adapter->hw.mac_type < e1000_82543) ? \
654 E1000_82542_##R : E1000_##R; \
655 return 1; \
656 } \
657 } \
658}
659
660#define REG_SET_AND_CHECK(R, M, W) \
661{ \
662 uint32_t value; \
663 E1000_WRITE_REG(&adapter->hw, R, W & M); \
664 value = E1000_READ_REG(&adapter->hw, R); \
665 if ((W & M) != (value & M)) { \
666 *data = (adapter->hw.mac_type < e1000_82543) ? \
667 E1000_82542_##R : E1000_##R; \
668 return 1; \
669 } \
670}
671
672static int
673e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
674{
675 uint32_t value;
676 uint32_t i;
677
678 /* The status register is Read Only, so a write should fail.
679 * Some bits that get toggled are ignored.
680 */
681 value = (E1000_READ_REG(&adapter->hw, STATUS) & (0xFFFFF833));
682 E1000_WRITE_REG(&adapter->hw, STATUS, (0xFFFFFFFF));
683 if(value != (E1000_READ_REG(&adapter->hw, STATUS) & (0xFFFFF833))) {
684 *data = 1;
685 return 1;
686 }
687
688 REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
689 REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF);
690 REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF);
691 REG_PATTERN_TEST(VET, 0x0000FFFF, 0xFFFFFFFF);
692 REG_PATTERN_TEST(RDTR, 0x0000FFFF, 0xFFFFFFFF);
693 REG_PATTERN_TEST(RDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
694 REG_PATTERN_TEST(RDLEN, 0x000FFF80, 0x000FFFFF);
695 REG_PATTERN_TEST(RDH, 0x0000FFFF, 0x0000FFFF);
696 REG_PATTERN_TEST(RDT, 0x0000FFFF, 0x0000FFFF);
697 REG_PATTERN_TEST(FCRTH, 0x0000FFF8, 0x0000FFF8);
698 REG_PATTERN_TEST(FCTTV, 0x0000FFFF, 0x0000FFFF);
699 REG_PATTERN_TEST(TIPG, 0x3FFFFFFF, 0x3FFFFFFF);
700 REG_PATTERN_TEST(TDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
701 REG_PATTERN_TEST(TDLEN, 0x000FFF80, 0x000FFFFF);
702
703 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000);
704 REG_SET_AND_CHECK(RCTL, 0x06DFB3FE, 0x003FFFFB);
705 REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000);
706
707 if(adapter->hw.mac_type >= e1000_82543) {
708
709 REG_SET_AND_CHECK(RCTL, 0x06DFB3FE, 0xFFFFFFFF);
710 REG_PATTERN_TEST(RDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
711 REG_PATTERN_TEST(TXCW, 0xC000FFFF, 0x0000FFFF);
712 REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
713 REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF);
714
715 for(i = 0; i < E1000_RAR_ENTRIES; i++) {
716 REG_PATTERN_TEST(RA + ((i << 1) << 2), 0xFFFFFFFF,
717 0xFFFFFFFF);
718 REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF,
719 0xFFFFFFFF);
720 }
721
722 } else {
723
724 REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x01FFFFFF);
725 REG_PATTERN_TEST(RDBAL, 0xFFFFF000, 0xFFFFFFFF);
726 REG_PATTERN_TEST(TXCW, 0x0000FFFF, 0x0000FFFF);
727 REG_PATTERN_TEST(TDBAL, 0xFFFFF000, 0xFFFFFFFF);
728
729 }
730
731 for(i = 0; i < E1000_MC_TBL_SIZE; i++)
732 REG_PATTERN_TEST(MTA + (i << 2), 0xFFFFFFFF, 0xFFFFFFFF);
733
734 *data = 0;
735 return 0;
736}
737
738static int
739e1000_eeprom_test(struct e1000_adapter *adapter, uint64_t *data)
740{
741 uint16_t temp;
742 uint16_t checksum = 0;
743 uint16_t i;
744
745 *data = 0;
746 /* Read and add up the contents of the EEPROM */
747 for(i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) {
748 if((e1000_read_eeprom(&adapter->hw, i, 1, &temp)) < 0) {
749 *data = 1;
750 break;
751 }
752 checksum += temp;
753 }
754
755 /* If Checksum is not Correct return error else test passed */
756 if((checksum != (uint16_t) EEPROM_SUM) && !(*data))
757 *data = 2;
758
759 return *data;
760}
761
762static irqreturn_t
763e1000_test_intr(int irq,
764 void *data,
765 struct pt_regs *regs)
766{
767 struct net_device *netdev = (struct net_device *) data;
768 struct e1000_adapter *adapter = netdev->priv;
769
770 adapter->test_icr |= E1000_READ_REG(&adapter->hw, ICR);
771
772 return IRQ_HANDLED;
773}
774
775static int
776e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
777{
778 struct net_device *netdev = adapter->netdev;
779 uint32_t mask, i=0, shared_int = TRUE;
780 uint32_t irq = adapter->pdev->irq;
781
782 *data = 0;
783
784 /* Hook up test interrupt handler just for this test */
785 if(!request_irq(irq, &e1000_test_intr, 0, netdev->name, netdev)) {
786 shared_int = FALSE;
787 } else if(request_irq(irq, &e1000_test_intr, SA_SHIRQ,
788 netdev->name, netdev)){
789 *data = 1;
790 return -1;
791 }
792
793 /* Disable all the interrupts */
794 E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF);
795 msec_delay(10);
796
797 /* Test each interrupt */
798 for(; i < 10; i++) {
799
800 /* Interrupt to test */
801 mask = 1 << i;
802
803 if(!shared_int) {
804 /* Disable the interrupt to be reported in
805 * the cause register and then force the same
806 * interrupt and see if one gets posted. If
807 * an interrupt was posted to the bus, the
808 * test failed.
809 */
810 adapter->test_icr = 0;
811 E1000_WRITE_REG(&adapter->hw, IMC, mask);
812 E1000_WRITE_REG(&adapter->hw, ICS, mask);
813 msec_delay(10);
814
815 if(adapter->test_icr & mask) {
816 *data = 3;
817 break;
818 }
819 }
820
821 /* Enable the interrupt to be reported in
822 * the cause register and then force the same
823 * interrupt and see if one gets posted. If
824 * an interrupt was not posted to the bus, the
825 * test failed.
826 */
827 adapter->test_icr = 0;
828 E1000_WRITE_REG(&adapter->hw, IMS, mask);
829 E1000_WRITE_REG(&adapter->hw, ICS, mask);
830 msec_delay(10);
831
832 if(!(adapter->test_icr & mask)) {
833 *data = 4;
834 break;
835 }
836
837 if(!shared_int) {
838 /* Disable the other interrupts to be reported in
839 * the cause register and then force the other
840 * interrupts and see if any get posted. If
841 * an interrupt was posted to the bus, the
842 * test failed.
843 */
844 adapter->test_icr = 0;
845 E1000_WRITE_REG(&adapter->hw, IMC,
846 (~mask & 0x00007FFF));
847 E1000_WRITE_REG(&adapter->hw, ICS,
848 (~mask & 0x00007FFF));
849 msec_delay(10);
850
851 if(adapter->test_icr) {
852 *data = 5;
853 break;
854 }
855 }
856 }
857
858 /* Disable all the interrupts */
859 E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF);
860 msec_delay(10);
861
862 /* Unhook test interrupt handler */
863 free_irq(irq, netdev);
864
865 return *data;
866}
867
868static void
869e1000_free_desc_rings(struct e1000_adapter *adapter)
870{
871 struct e1000_desc_ring *txdr = &adapter->test_tx_ring;
872 struct e1000_desc_ring *rxdr = &adapter->test_rx_ring;
873 struct pci_dev *pdev = adapter->pdev;
874 int i;
875
876 if(txdr->desc && txdr->buffer_info) {
877 for(i = 0; i < txdr->count; i++) {
878 if(txdr->buffer_info[i].dma)
879 pci_unmap_single(pdev, txdr->buffer_info[i].dma,
880 txdr->buffer_info[i].length,
881 PCI_DMA_TODEVICE);
882 if(txdr->buffer_info[i].skb)
883 dev_kfree_skb(txdr->buffer_info[i].skb);
884 }
885 }
886
887 if(rxdr->desc && rxdr->buffer_info) {
888 for(i = 0; i < rxdr->count; i++) {
889 if(rxdr->buffer_info[i].dma)
890 pci_unmap_single(pdev, rxdr->buffer_info[i].dma,
891 rxdr->buffer_info[i].length,
892 PCI_DMA_FROMDEVICE);
893 if(rxdr->buffer_info[i].skb)
894 dev_kfree_skb(rxdr->buffer_info[i].skb);
895 }
896 }
897
898 if(txdr->desc)
899 pci_free_consistent(pdev, txdr->size, txdr->desc, txdr->dma);
900 if(rxdr->desc)
901 pci_free_consistent(pdev, rxdr->size, rxdr->desc, rxdr->dma);
902
903 if(txdr->buffer_info)
904 kfree(txdr->buffer_info);
905 if(rxdr->buffer_info)
906 kfree(rxdr->buffer_info);
907
908 return;
909}
910
911static int
912e1000_setup_desc_rings(struct e1000_adapter *adapter)
913{
914 struct e1000_desc_ring *txdr = &adapter->test_tx_ring;
915 struct e1000_desc_ring *rxdr = &adapter->test_rx_ring;
916 struct pci_dev *pdev = adapter->pdev;
917 uint32_t rctl;
918 int size, i, ret_val;
919
920 /* Setup Tx descriptor ring and Tx buffers */
921
Malli Chilakalae4eff722005-04-28 19:38:30 -0700922 if(!txdr->count)
923 txdr->count = E1000_DEFAULT_TXD;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924
925 size = txdr->count * sizeof(struct e1000_buffer);
926 if(!(txdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
927 ret_val = 1;
928 goto err_nomem;
929 }
930 memset(txdr->buffer_info, 0, size);
931
932 txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
933 E1000_ROUNDUP(txdr->size, 4096);
934 if(!(txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma))) {
935 ret_val = 2;
936 goto err_nomem;
937 }
938 memset(txdr->desc, 0, txdr->size);
939 txdr->next_to_use = txdr->next_to_clean = 0;
940
941 E1000_WRITE_REG(&adapter->hw, TDBAL,
942 ((uint64_t) txdr->dma & 0x00000000FFFFFFFF));
943 E1000_WRITE_REG(&adapter->hw, TDBAH, ((uint64_t) txdr->dma >> 32));
944 E1000_WRITE_REG(&adapter->hw, TDLEN,
945 txdr->count * sizeof(struct e1000_tx_desc));
946 E1000_WRITE_REG(&adapter->hw, TDH, 0);
947 E1000_WRITE_REG(&adapter->hw, TDT, 0);
948 E1000_WRITE_REG(&adapter->hw, TCTL,
949 E1000_TCTL_PSP | E1000_TCTL_EN |
950 E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT |
951 E1000_FDX_COLLISION_DISTANCE << E1000_COLD_SHIFT);
952
953 for(i = 0; i < txdr->count; i++) {
954 struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*txdr, i);
955 struct sk_buff *skb;
956 unsigned int size = 1024;
957
958 if(!(skb = alloc_skb(size, GFP_KERNEL))) {
959 ret_val = 3;
960 goto err_nomem;
961 }
962 skb_put(skb, size);
963 txdr->buffer_info[i].skb = skb;
964 txdr->buffer_info[i].length = skb->len;
965 txdr->buffer_info[i].dma =
966 pci_map_single(pdev, skb->data, skb->len,
967 PCI_DMA_TODEVICE);
968 tx_desc->buffer_addr = cpu_to_le64(txdr->buffer_info[i].dma);
969 tx_desc->lower.data = cpu_to_le32(skb->len);
970 tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP |
971 E1000_TXD_CMD_IFCS |
972 E1000_TXD_CMD_RPS);
973 tx_desc->upper.data = 0;
974 }
975
976 /* Setup Rx descriptor ring and Rx buffers */
977
Malli Chilakalae4eff722005-04-28 19:38:30 -0700978 if(!rxdr->count)
979 rxdr->count = E1000_DEFAULT_RXD;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980
981 size = rxdr->count * sizeof(struct e1000_buffer);
982 if(!(rxdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
983 ret_val = 4;
984 goto err_nomem;
985 }
986 memset(rxdr->buffer_info, 0, size);
987
988 rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc);
989 if(!(rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma))) {
990 ret_val = 5;
991 goto err_nomem;
992 }
993 memset(rxdr->desc, 0, rxdr->size);
994 rxdr->next_to_use = rxdr->next_to_clean = 0;
995
996 rctl = E1000_READ_REG(&adapter->hw, RCTL);
997 E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_RCTL_EN);
998 E1000_WRITE_REG(&adapter->hw, RDBAL,
999 ((uint64_t) rxdr->dma & 0xFFFFFFFF));
1000 E1000_WRITE_REG(&adapter->hw, RDBAH, ((uint64_t) rxdr->dma >> 32));
1001 E1000_WRITE_REG(&adapter->hw, RDLEN, rxdr->size);
1002 E1000_WRITE_REG(&adapter->hw, RDH, 0);
1003 E1000_WRITE_REG(&adapter->hw, RDT, 0);
1004 rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 |
1005 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
1006 (adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT);
1007 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
1008
1009 for(i = 0; i < rxdr->count; i++) {
1010 struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i);
1011 struct sk_buff *skb;
1012
1013 if(!(skb = alloc_skb(E1000_RXBUFFER_2048 + NET_IP_ALIGN,
1014 GFP_KERNEL))) {
1015 ret_val = 6;
1016 goto err_nomem;
1017 }
1018 skb_reserve(skb, NET_IP_ALIGN);
1019 rxdr->buffer_info[i].skb = skb;
1020 rxdr->buffer_info[i].length = E1000_RXBUFFER_2048;
1021 rxdr->buffer_info[i].dma =
1022 pci_map_single(pdev, skb->data, E1000_RXBUFFER_2048,
1023 PCI_DMA_FROMDEVICE);
1024 rx_desc->buffer_addr = cpu_to_le64(rxdr->buffer_info[i].dma);
1025 memset(skb->data, 0x00, skb->len);
1026 }
1027
1028 return 0;
1029
1030err_nomem:
1031 e1000_free_desc_rings(adapter);
1032 return ret_val;
1033}
1034
1035static void
1036e1000_phy_disable_receiver(struct e1000_adapter *adapter)
1037{
1038 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1039 e1000_write_phy_reg(&adapter->hw, 29, 0x001F);
1040 e1000_write_phy_reg(&adapter->hw, 30, 0x8FFC);
1041 e1000_write_phy_reg(&adapter->hw, 29, 0x001A);
1042 e1000_write_phy_reg(&adapter->hw, 30, 0x8FF0);
1043}
1044
1045static void
1046e1000_phy_reset_clk_and_crs(struct e1000_adapter *adapter)
1047{
1048 uint16_t phy_reg;
1049
1050 /* Because we reset the PHY above, we need to re-force TX_CLK in the
1051 * Extended PHY Specific Control Register to 25MHz clock. This
1052 * value defaults back to a 2.5MHz clock when the PHY is reset.
1053 */
1054 e1000_read_phy_reg(&adapter->hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg);
1055 phy_reg |= M88E1000_EPSCR_TX_CLK_25;
1056 e1000_write_phy_reg(&adapter->hw,
1057 M88E1000_EXT_PHY_SPEC_CTRL, phy_reg);
1058
1059 /* In addition, because of the s/w reset above, we need to enable
1060 * CRS on TX. This must be set for both full and half duplex
1061 * operation.
1062 */
1063 e1000_read_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, &phy_reg);
1064 phy_reg |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
1065 e1000_write_phy_reg(&adapter->hw,
1066 M88E1000_PHY_SPEC_CTRL, phy_reg);
1067}
1068
1069static int
1070e1000_nonintegrated_phy_loopback(struct e1000_adapter *adapter)
1071{
1072 uint32_t ctrl_reg;
1073 uint16_t phy_reg;
1074
1075 /* Setup the Device Control Register for PHY loopback test. */
1076
1077 ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL);
1078 ctrl_reg |= (E1000_CTRL_ILOS | /* Invert Loss-Of-Signal */
1079 E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1080 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1081 E1000_CTRL_SPD_1000 | /* Force Speed to 1000 */
1082 E1000_CTRL_FD); /* Force Duplex to FULL */
1083
1084 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg);
1085
1086 /* Read the PHY Specific Control Register (0x10) */
1087 e1000_read_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, &phy_reg);
1088
1089 /* Clear Auto-Crossover bits in PHY Specific Control Register
1090 * (bits 6:5).
1091 */
1092 phy_reg &= ~M88E1000_PSCR_AUTO_X_MODE;
1093 e1000_write_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, phy_reg);
1094
1095 /* Perform software reset on the PHY */
1096 e1000_phy_reset(&adapter->hw);
1097
1098 /* Have to setup TX_CLK and TX_CRS after software reset */
1099 e1000_phy_reset_clk_and_crs(adapter);
1100
1101 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8100);
1102
1103 /* Wait for reset to complete. */
1104 udelay(500);
1105
1106 /* Have to setup TX_CLK and TX_CRS after software reset */
1107 e1000_phy_reset_clk_and_crs(adapter);
1108
1109 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1110 e1000_phy_disable_receiver(adapter);
1111
1112 /* Set the loopback bit in the PHY control register. */
1113 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
1114 phy_reg |= MII_CR_LOOPBACK;
1115 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg);
1116
1117 /* Setup TX_CLK and TX_CRS one more time. */
1118 e1000_phy_reset_clk_and_crs(adapter);
1119
1120 /* Check Phy Configuration */
1121 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
1122 if(phy_reg != 0x4100)
1123 return 9;
1124
1125 e1000_read_phy_reg(&adapter->hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg);
1126 if(phy_reg != 0x0070)
1127 return 10;
1128
1129 e1000_read_phy_reg(&adapter->hw, 29, &phy_reg);
1130 if(phy_reg != 0x001A)
1131 return 11;
1132
1133 return 0;
1134}
1135
1136static int
1137e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1138{
1139 uint32_t ctrl_reg = 0;
1140 uint32_t stat_reg = 0;
1141
1142 adapter->hw.autoneg = FALSE;
1143
1144 if(adapter->hw.phy_type == e1000_phy_m88) {
1145 /* Auto-MDI/MDIX Off */
1146 e1000_write_phy_reg(&adapter->hw,
1147 M88E1000_PHY_SPEC_CTRL, 0x0808);
1148 /* reset to update Auto-MDI/MDIX */
1149 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x9140);
1150 /* autoneg off */
1151 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8140);
1152 }
1153 /* force 1000, set loopback */
1154 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x4140);
1155
1156 /* Now set up the MAC to the same speed/duplex as the PHY. */
1157 ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL);
1158 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
1159 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1160 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1161 E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
1162 E1000_CTRL_FD); /* Force Duplex to FULL */
1163
1164 if(adapter->hw.media_type == e1000_media_type_copper &&
1165 adapter->hw.phy_type == e1000_phy_m88) {
1166 ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
1167 } else {
1168 /* Set the ILOS bit on the fiber Nic is half
1169 * duplex link is detected. */
1170 stat_reg = E1000_READ_REG(&adapter->hw, STATUS);
1171 if((stat_reg & E1000_STATUS_FD) == 0)
1172 ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
1173 }
1174
1175 E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg);
1176
1177 /* Disable the receiver on the PHY so when a cable is plugged in, the
1178 * PHY does not begin to autoneg when a cable is reconnected to the NIC.
1179 */
1180 if(adapter->hw.phy_type == e1000_phy_m88)
1181 e1000_phy_disable_receiver(adapter);
1182
1183 udelay(500);
1184
1185 return 0;
1186}
1187
1188static int
1189e1000_set_phy_loopback(struct e1000_adapter *adapter)
1190{
1191 uint16_t phy_reg = 0;
1192 uint16_t count = 0;
1193
1194 switch (adapter->hw.mac_type) {
1195 case e1000_82543:
1196 if(adapter->hw.media_type == e1000_media_type_copper) {
1197 /* Attempt to setup Loopback mode on Non-integrated PHY.
1198 * Some PHY registers get corrupted at random, so
1199 * attempt this 10 times.
1200 */
1201 while(e1000_nonintegrated_phy_loopback(adapter) &&
1202 count++ < 10);
1203 if(count < 11)
1204 return 0;
1205 }
1206 break;
1207
1208 case e1000_82544:
1209 case e1000_82540:
1210 case e1000_82545:
1211 case e1000_82545_rev_3:
1212 case e1000_82546:
1213 case e1000_82546_rev_3:
1214 case e1000_82541:
1215 case e1000_82541_rev_2:
1216 case e1000_82547:
1217 case e1000_82547_rev_2:
1218 return e1000_integrated_phy_loopback(adapter);
1219 break;
1220
1221 default:
1222 /* Default PHY loopback work is to read the MII
1223 * control register and assert bit 14 (loopback mode).
1224 */
1225 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
1226 phy_reg |= MII_CR_LOOPBACK;
1227 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg);
1228 return 0;
1229 break;
1230 }
1231
1232 return 8;
1233}
1234
1235static int
1236e1000_setup_loopback_test(struct e1000_adapter *adapter)
1237{
1238 uint32_t rctl;
1239
1240 if(adapter->hw.media_type == e1000_media_type_fiber ||
1241 adapter->hw.media_type == e1000_media_type_internal_serdes) {
1242 if(adapter->hw.mac_type == e1000_82545 ||
1243 adapter->hw.mac_type == e1000_82546 ||
1244 adapter->hw.mac_type == e1000_82545_rev_3 ||
1245 adapter->hw.mac_type == e1000_82546_rev_3)
1246 return e1000_set_phy_loopback(adapter);
1247 else {
1248 rctl = E1000_READ_REG(&adapter->hw, RCTL);
1249 rctl |= E1000_RCTL_LBM_TCVR;
1250 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
1251 return 0;
1252 }
1253 } else if(adapter->hw.media_type == e1000_media_type_copper)
1254 return e1000_set_phy_loopback(adapter);
1255
1256 return 7;
1257}
1258
1259static void
1260e1000_loopback_cleanup(struct e1000_adapter *adapter)
1261{
1262 uint32_t rctl;
1263 uint16_t phy_reg;
1264
1265 rctl = E1000_READ_REG(&adapter->hw, RCTL);
1266 rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
1267 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
1268
1269 if(adapter->hw.media_type == e1000_media_type_copper ||
1270 ((adapter->hw.media_type == e1000_media_type_fiber ||
1271 adapter->hw.media_type == e1000_media_type_internal_serdes) &&
1272 (adapter->hw.mac_type == e1000_82545 ||
1273 adapter->hw.mac_type == e1000_82546 ||
1274 adapter->hw.mac_type == e1000_82545_rev_3 ||
1275 adapter->hw.mac_type == e1000_82546_rev_3))) {
1276 adapter->hw.autoneg = TRUE;
1277 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
1278 if(phy_reg & MII_CR_LOOPBACK) {
1279 phy_reg &= ~MII_CR_LOOPBACK;
1280 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg);
1281 e1000_phy_reset(&adapter->hw);
1282 }
1283 }
1284}
1285
1286static void
1287e1000_create_lbtest_frame(struct sk_buff *skb, unsigned int frame_size)
1288{
1289 memset(skb->data, 0xFF, frame_size);
1290 frame_size = (frame_size % 2) ? (frame_size - 1) : frame_size;
1291 memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
1292 memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
1293 memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
1294}
1295
1296static int
1297e1000_check_lbtest_frame(struct sk_buff *skb, unsigned int frame_size)
1298{
1299 frame_size = (frame_size % 2) ? (frame_size - 1) : frame_size;
1300 if(*(skb->data + 3) == 0xFF) {
1301 if((*(skb->data + frame_size / 2 + 10) == 0xBE) &&
1302 (*(skb->data + frame_size / 2 + 12) == 0xAF)) {
1303 return 0;
1304 }
1305 }
1306 return 13;
1307}
1308
1309static int
1310e1000_run_loopback_test(struct e1000_adapter *adapter)
1311{
1312 struct e1000_desc_ring *txdr = &adapter->test_tx_ring;
1313 struct e1000_desc_ring *rxdr = &adapter->test_rx_ring;
1314 struct pci_dev *pdev = adapter->pdev;
Malli Chilakalae4eff722005-04-28 19:38:30 -07001315 int i, j, k, l, lc, good_cnt, ret_val=0;
1316 unsigned long time;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317
1318 E1000_WRITE_REG(&adapter->hw, RDT, rxdr->count - 1);
1319
Malli Chilakalae4eff722005-04-28 19:38:30 -07001320 /* Calculate the loop count based on the largest descriptor ring
1321 * The idea is to wrap the largest ring a number of times using 64
1322 * send/receive pairs during each loop
1323 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001324
Malli Chilakalae4eff722005-04-28 19:38:30 -07001325 if(rxdr->count <= txdr->count)
1326 lc = ((txdr->count / 64) * 2) + 1;
1327 else
1328 lc = ((rxdr->count / 64) * 2) + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001329
Malli Chilakalae4eff722005-04-28 19:38:30 -07001330 k = l = 0;
1331 for(j = 0; j <= lc; j++) { /* loop count loop */
1332 for(i = 0; i < 64; i++) { /* send the packets */
1333 e1000_create_lbtest_frame(txdr->buffer_info[i].skb,
1334 1024);
1335 pci_dma_sync_single_for_device(pdev,
1336 txdr->buffer_info[k].dma,
1337 txdr->buffer_info[k].length,
1338 PCI_DMA_TODEVICE);
1339 if(unlikely(++k == txdr->count)) k = 0;
1340 }
1341 E1000_WRITE_REG(&adapter->hw, TDT, k);
1342 msec_delay(200);
1343 time = jiffies; /* set the start time for the receive */
1344 good_cnt = 0;
1345 do { /* receive the sent packets */
1346 pci_dma_sync_single_for_cpu(pdev,
1347 rxdr->buffer_info[l].dma,
1348 rxdr->buffer_info[l].length,
1349 PCI_DMA_FROMDEVICE);
1350
1351 ret_val = e1000_check_lbtest_frame(
1352 rxdr->buffer_info[l].skb,
1353 1024);
1354 if(!ret_val)
1355 good_cnt++;
1356 if(unlikely(++l == rxdr->count)) l = 0;
1357 /* time + 20 msecs (200 msecs on 2.4) is more than
1358 * enough time to complete the receives, if it's
1359 * exceeded, break and error off
1360 */
1361 } while (good_cnt < 64 && jiffies < (time + 20));
1362 if(good_cnt != 64) {
1363 ret_val = 13; /* ret_val is the same as mis-compare */
1364 break;
1365 }
1366 if(jiffies >= (time + 2)) {
1367 ret_val = 14; /* error code for time out error */
1368 break;
1369 }
1370 } /* end loop count loop */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001371 return ret_val;
1372}
1373
1374static int
1375e1000_loopback_test(struct e1000_adapter *adapter, uint64_t *data)
1376{
1377 if((*data = e1000_setup_desc_rings(adapter))) goto err_loopback;
1378 if((*data = e1000_setup_loopback_test(adapter))) goto err_loopback;
1379 *data = e1000_run_loopback_test(adapter);
1380 e1000_loopback_cleanup(adapter);
1381 e1000_free_desc_rings(adapter);
1382err_loopback:
1383 return *data;
1384}
1385
1386static int
1387e1000_link_test(struct e1000_adapter *adapter, uint64_t *data)
1388{
1389 *data = 0;
1390
1391 if (adapter->hw.media_type == e1000_media_type_internal_serdes) {
1392 int i = 0;
1393 adapter->hw.serdes_link_down = TRUE;
1394
1395 /* on some blade server designs link establishment */
1396 /* could take as long as 2-3 minutes. */
1397 do {
1398 e1000_check_for_link(&adapter->hw);
1399 if (adapter->hw.serdes_link_down == FALSE)
1400 return *data;
1401 msec_delay(20);
1402 } while (i++ < 3750);
1403
1404 *data = 1;
1405 } else {
1406 e1000_check_for_link(&adapter->hw);
Malli Chilakalae4eff722005-04-28 19:38:30 -07001407 if(adapter->hw.autoneg) /* if auto_neg is set wait for it */
1408 msec_delay(4000);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001409
1410 if(!(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU)) {
1411 *data = 1;
1412 }
1413 }
1414 return *data;
1415}
1416
1417static int
1418e1000_diag_test_count(struct net_device *netdev)
1419{
1420 return E1000_TEST_LEN;
1421}
1422
1423static void
1424e1000_diag_test(struct net_device *netdev,
1425 struct ethtool_test *eth_test, uint64_t *data)
1426{
1427 struct e1000_adapter *adapter = netdev->priv;
1428 boolean_t if_running = netif_running(netdev);
1429
1430 if(eth_test->flags == ETH_TEST_FL_OFFLINE) {
1431 /* Offline tests */
1432
1433 /* save speed, duplex, autoneg settings */
1434 uint16_t autoneg_advertised = adapter->hw.autoneg_advertised;
1435 uint8_t forced_speed_duplex = adapter->hw.forced_speed_duplex;
1436 uint8_t autoneg = adapter->hw.autoneg;
1437
1438 /* Link test performed before hardware reset so autoneg doesn't
1439 * interfere with test result */
1440 if(e1000_link_test(adapter, &data[4]))
1441 eth_test->flags |= ETH_TEST_FL_FAILED;
1442
1443 if(if_running)
1444 e1000_down(adapter);
1445 else
1446 e1000_reset(adapter);
1447
1448 if(e1000_reg_test(adapter, &data[0]))
1449 eth_test->flags |= ETH_TEST_FL_FAILED;
1450
1451 e1000_reset(adapter);
1452 if(e1000_eeprom_test(adapter, &data[1]))
1453 eth_test->flags |= ETH_TEST_FL_FAILED;
1454
1455 e1000_reset(adapter);
1456 if(e1000_intr_test(adapter, &data[2]))
1457 eth_test->flags |= ETH_TEST_FL_FAILED;
1458
1459 e1000_reset(adapter);
1460 if(e1000_loopback_test(adapter, &data[3]))
1461 eth_test->flags |= ETH_TEST_FL_FAILED;
1462
1463 /* restore speed, duplex, autoneg settings */
1464 adapter->hw.autoneg_advertised = autoneg_advertised;
1465 adapter->hw.forced_speed_duplex = forced_speed_duplex;
1466 adapter->hw.autoneg = autoneg;
1467
1468 e1000_reset(adapter);
1469 if(if_running)
1470 e1000_up(adapter);
1471 } else {
1472 /* Online tests */
1473 if(e1000_link_test(adapter, &data[4]))
1474 eth_test->flags |= ETH_TEST_FL_FAILED;
1475
1476 /* Offline tests aren't run; pass by default */
1477 data[0] = 0;
1478 data[1] = 0;
1479 data[2] = 0;
1480 data[3] = 0;
1481 }
1482}
1483
1484static void
1485e1000_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1486{
1487 struct e1000_adapter *adapter = netdev->priv;
1488 struct e1000_hw *hw = &adapter->hw;
1489
1490 switch(adapter->hw.device_id) {
1491 case E1000_DEV_ID_82542:
1492 case E1000_DEV_ID_82543GC_FIBER:
1493 case E1000_DEV_ID_82543GC_COPPER:
1494 case E1000_DEV_ID_82544EI_FIBER:
1495 case E1000_DEV_ID_82546EB_QUAD_COPPER:
1496 case E1000_DEV_ID_82545EM_FIBER:
1497 case E1000_DEV_ID_82545EM_COPPER:
1498 wol->supported = 0;
1499 wol->wolopts = 0;
1500 return;
1501
1502 case E1000_DEV_ID_82546EB_FIBER:
1503 case E1000_DEV_ID_82546GB_FIBER:
1504 /* Wake events only supported on port A for dual fiber */
1505 if(E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1) {
1506 wol->supported = 0;
1507 wol->wolopts = 0;
1508 return;
1509 }
1510 /* Fall Through */
1511
1512 default:
1513 wol->supported = WAKE_UCAST | WAKE_MCAST |
1514 WAKE_BCAST | WAKE_MAGIC;
1515
1516 wol->wolopts = 0;
1517 if(adapter->wol & E1000_WUFC_EX)
1518 wol->wolopts |= WAKE_UCAST;
1519 if(adapter->wol & E1000_WUFC_MC)
1520 wol->wolopts |= WAKE_MCAST;
1521 if(adapter->wol & E1000_WUFC_BC)
1522 wol->wolopts |= WAKE_BCAST;
1523 if(adapter->wol & E1000_WUFC_MAG)
1524 wol->wolopts |= WAKE_MAGIC;
1525 return;
1526 }
1527}
1528
1529static int
1530e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1531{
1532 struct e1000_adapter *adapter = netdev->priv;
1533 struct e1000_hw *hw = &adapter->hw;
1534
1535 switch(adapter->hw.device_id) {
1536 case E1000_DEV_ID_82542:
1537 case E1000_DEV_ID_82543GC_FIBER:
1538 case E1000_DEV_ID_82543GC_COPPER:
1539 case E1000_DEV_ID_82544EI_FIBER:
1540 case E1000_DEV_ID_82546EB_QUAD_COPPER:
1541 case E1000_DEV_ID_82545EM_FIBER:
1542 case E1000_DEV_ID_82545EM_COPPER:
1543 return wol->wolopts ? -EOPNOTSUPP : 0;
1544
1545 case E1000_DEV_ID_82546EB_FIBER:
1546 case E1000_DEV_ID_82546GB_FIBER:
1547 /* Wake events only supported on port A for dual fiber */
1548 if(E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1)
1549 return wol->wolopts ? -EOPNOTSUPP : 0;
1550 /* Fall Through */
1551
1552 default:
1553 if(wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE))
1554 return -EOPNOTSUPP;
1555
1556 adapter->wol = 0;
1557
1558 if(wol->wolopts & WAKE_UCAST)
1559 adapter->wol |= E1000_WUFC_EX;
1560 if(wol->wolopts & WAKE_MCAST)
1561 adapter->wol |= E1000_WUFC_MC;
1562 if(wol->wolopts & WAKE_BCAST)
1563 adapter->wol |= E1000_WUFC_BC;
1564 if(wol->wolopts & WAKE_MAGIC)
1565 adapter->wol |= E1000_WUFC_MAG;
1566 }
1567
1568 return 0;
1569}
1570
1571/* toggle LED 4 times per second = 2 "blinks" per second */
1572#define E1000_ID_INTERVAL (HZ/4)
1573
1574/* bit defines for adapter->led_status */
1575#define E1000_LED_ON 0
1576
1577static void
1578e1000_led_blink_callback(unsigned long data)
1579{
1580 struct e1000_adapter *adapter = (struct e1000_adapter *) data;
1581
1582 if(test_and_change_bit(E1000_LED_ON, &adapter->led_status))
1583 e1000_led_off(&adapter->hw);
1584 else
1585 e1000_led_on(&adapter->hw);
1586
1587 mod_timer(&adapter->blink_timer, jiffies + E1000_ID_INTERVAL);
1588}
1589
1590static int
1591e1000_phys_id(struct net_device *netdev, uint32_t data)
1592{
1593 struct e1000_adapter *adapter = netdev->priv;
1594
1595 if(!data || data > (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ))
1596 data = (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ);
1597
1598 if(!adapter->blink_timer.function) {
1599 init_timer(&adapter->blink_timer);
1600 adapter->blink_timer.function = e1000_led_blink_callback;
1601 adapter->blink_timer.data = (unsigned long) adapter;
1602 }
1603
1604 e1000_setup_led(&adapter->hw);
1605 mod_timer(&adapter->blink_timer, jiffies);
1606
1607 msleep_interruptible(data * 1000);
1608 del_timer_sync(&adapter->blink_timer);
1609 e1000_led_off(&adapter->hw);
1610 clear_bit(E1000_LED_ON, &adapter->led_status);
1611 e1000_cleanup_led(&adapter->hw);
1612
1613 return 0;
1614}
1615
1616static int
1617e1000_nway_reset(struct net_device *netdev)
1618{
1619 struct e1000_adapter *adapter = netdev->priv;
1620 if(netif_running(netdev)) {
1621 e1000_down(adapter);
1622 e1000_up(adapter);
1623 }
1624 return 0;
1625}
1626
1627static int
1628e1000_get_stats_count(struct net_device *netdev)
1629{
1630 return E1000_STATS_LEN;
1631}
1632
1633static void
1634e1000_get_ethtool_stats(struct net_device *netdev,
1635 struct ethtool_stats *stats, uint64_t *data)
1636{
1637 struct e1000_adapter *adapter = netdev->priv;
1638 int i;
1639
1640 e1000_update_stats(adapter);
1641 for(i = 0; i < E1000_STATS_LEN; i++) {
1642 char *p = (char *)adapter+e1000_gstrings_stats[i].stat_offset;
1643 data[i] = (e1000_gstrings_stats[i].sizeof_stat ==
1644 sizeof(uint64_t)) ? *(uint64_t *)p : *(uint32_t *)p;
1645 }
1646}
1647
1648static void
1649e1000_get_strings(struct net_device *netdev, uint32_t stringset, uint8_t *data)
1650{
1651 int i;
1652
1653 switch(stringset) {
1654 case ETH_SS_TEST:
1655 memcpy(data, *e1000_gstrings_test,
1656 E1000_TEST_LEN*ETH_GSTRING_LEN);
1657 break;
1658 case ETH_SS_STATS:
1659 for (i=0; i < E1000_STATS_LEN; i++) {
1660 memcpy(data + i * ETH_GSTRING_LEN,
1661 e1000_gstrings_stats[i].stat_string,
1662 ETH_GSTRING_LEN);
1663 }
1664 break;
1665 }
1666}
1667
1668struct ethtool_ops e1000_ethtool_ops = {
1669 .get_settings = e1000_get_settings,
1670 .set_settings = e1000_set_settings,
1671 .get_drvinfo = e1000_get_drvinfo,
1672 .get_regs_len = e1000_get_regs_len,
1673 .get_regs = e1000_get_regs,
1674 .get_wol = e1000_get_wol,
1675 .set_wol = e1000_set_wol,
1676 .get_msglevel = e1000_get_msglevel,
1677 .set_msglevel = e1000_set_msglevel,
1678 .nway_reset = e1000_nway_reset,
1679 .get_link = ethtool_op_get_link,
1680 .get_eeprom_len = e1000_get_eeprom_len,
1681 .get_eeprom = e1000_get_eeprom,
1682 .set_eeprom = e1000_set_eeprom,
1683 .get_ringparam = e1000_get_ringparam,
1684 .set_ringparam = e1000_set_ringparam,
1685 .get_pauseparam = e1000_get_pauseparam,
1686 .set_pauseparam = e1000_set_pauseparam,
1687 .get_rx_csum = e1000_get_rx_csum,
1688 .set_rx_csum = e1000_set_rx_csum,
1689 .get_tx_csum = e1000_get_tx_csum,
1690 .set_tx_csum = e1000_set_tx_csum,
1691 .get_sg = ethtool_op_get_sg,
1692 .set_sg = ethtool_op_set_sg,
1693#ifdef NETIF_F_TSO
1694 .get_tso = ethtool_op_get_tso,
1695 .set_tso = e1000_set_tso,
1696#endif
1697 .self_test_count = e1000_diag_test_count,
1698 .self_test = e1000_diag_test,
1699 .get_strings = e1000_get_strings,
1700 .phys_id = e1000_phys_id,
1701 .get_stats_count = e1000_get_stats_count,
1702 .get_ethtool_stats = e1000_get_ethtool_stats,
1703};
1704
1705void e1000_set_ethtool_ops(struct net_device *netdev)
1706{
1707 SET_ETHTOOL_OPS(netdev, &e1000_ethtool_ops);
1708}