1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2006 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
29 /* ethtool support for e1000 */
33 #include <asm/uaccess.h>
35 extern char e1000_driver_name
[];
36 extern char e1000_driver_version
[];
38 extern int e1000_up(struct e1000_adapter
*adapter
);
39 extern void e1000_down(struct e1000_adapter
*adapter
);
40 extern void e1000_reinit_locked(struct e1000_adapter
*adapter
);
41 extern void e1000_reset(struct e1000_adapter
*adapter
);
42 extern int e1000_set_spd_dplx(struct e1000_adapter
*adapter
, uint16_t spddplx
);
43 extern int e1000_setup_all_rx_resources(struct e1000_adapter
*adapter
);
44 extern int e1000_setup_all_tx_resources(struct e1000_adapter
*adapter
);
45 extern void e1000_free_all_rx_resources(struct e1000_adapter
*adapter
);
46 extern void e1000_free_all_tx_resources(struct e1000_adapter
*adapter
);
47 extern void e1000_update_stats(struct e1000_adapter
*adapter
);
51 char stat_string
[ETH_GSTRING_LEN
];
56 #define E1000_STAT(m) sizeof(((struct e1000_adapter *)0)->m), \
57 offsetof(struct e1000_adapter, m)
58 static const struct e1000_stats e1000_gstrings_stats
[] = {
59 { "rx_packets", E1000_STAT(stats
.gprc
) },
60 { "tx_packets", E1000_STAT(stats
.gptc
) },
61 { "rx_bytes", E1000_STAT(stats
.gorcl
) },
62 { "tx_bytes", E1000_STAT(stats
.gotcl
) },
63 { "rx_broadcast", E1000_STAT(stats
.bprc
) },
64 { "tx_broadcast", E1000_STAT(stats
.bptc
) },
65 { "rx_multicast", E1000_STAT(stats
.mprc
) },
66 { "tx_multicast", E1000_STAT(stats
.mptc
) },
67 { "rx_errors", E1000_STAT(stats
.rxerrc
) },
68 { "tx_errors", E1000_STAT(stats
.txerrc
) },
69 { "tx_dropped", E1000_STAT(net_stats
.tx_dropped
) },
70 { "multicast", E1000_STAT(stats
.mprc
) },
71 { "collisions", E1000_STAT(stats
.colc
) },
72 { "rx_length_errors", E1000_STAT(stats
.rlerrc
) },
73 { "rx_over_errors", E1000_STAT(net_stats
.rx_over_errors
) },
74 { "rx_crc_errors", E1000_STAT(stats
.crcerrs
) },
75 { "rx_frame_errors", E1000_STAT(net_stats
.rx_frame_errors
) },
76 { "rx_no_buffer_count", E1000_STAT(stats
.rnbc
) },
77 { "rx_missed_errors", E1000_STAT(stats
.mpc
) },
78 { "tx_aborted_errors", E1000_STAT(stats
.ecol
) },
79 { "tx_carrier_errors", E1000_STAT(stats
.tncrs
) },
80 { "tx_fifo_errors", E1000_STAT(net_stats
.tx_fifo_errors
) },
81 { "tx_heartbeat_errors", E1000_STAT(net_stats
.tx_heartbeat_errors
) },
82 { "tx_window_errors", E1000_STAT(stats
.latecol
) },
83 { "tx_abort_late_coll", E1000_STAT(stats
.latecol
) },
84 { "tx_deferred_ok", E1000_STAT(stats
.dc
) },
85 { "tx_single_coll_ok", E1000_STAT(stats
.scc
) },
86 { "tx_multi_coll_ok", E1000_STAT(stats
.mcc
) },
87 { "tx_timeout_count", E1000_STAT(tx_timeout_count
) },
88 { "tx_restart_queue", E1000_STAT(restart_queue
) },
89 { "rx_long_length_errors", E1000_STAT(stats
.roc
) },
90 { "rx_short_length_errors", E1000_STAT(stats
.ruc
) },
91 { "rx_align_errors", E1000_STAT(stats
.algnerrc
) },
92 { "tx_tcp_seg_good", E1000_STAT(stats
.tsctc
) },
93 { "tx_tcp_seg_failed", E1000_STAT(stats
.tsctfc
) },
94 { "rx_flow_control_xon", E1000_STAT(stats
.xonrxc
) },
95 { "rx_flow_control_xoff", E1000_STAT(stats
.xoffrxc
) },
96 { "tx_flow_control_xon", E1000_STAT(stats
.xontxc
) },
97 { "tx_flow_control_xoff", E1000_STAT(stats
.xofftxc
) },
98 { "rx_long_byte_count", E1000_STAT(stats
.gorcl
) },
99 { "rx_csum_offload_good", E1000_STAT(hw_csum_good
) },
100 { "rx_csum_offload_errors", E1000_STAT(hw_csum_err
) },
101 { "rx_header_split", E1000_STAT(rx_hdr_split
) },
102 { "alloc_rx_buff_failed", E1000_STAT(alloc_rx_buff_failed
) },
103 { "tx_smbus", E1000_STAT(stats
.mgptc
) },
104 { "rx_smbus", E1000_STAT(stats
.mgprc
) },
105 { "dropped_smbus", E1000_STAT(stats
.mgpdc
) },
108 #define E1000_QUEUE_STATS_LEN 0
109 #define E1000_GLOBAL_STATS_LEN \
110 sizeof(e1000_gstrings_stats) / sizeof(struct e1000_stats)
111 #define E1000_STATS_LEN (E1000_GLOBAL_STATS_LEN + E1000_QUEUE_STATS_LEN)
112 static const char e1000_gstrings_test
[][ETH_GSTRING_LEN
] = {
113 "Register test (offline)", "Eeprom test (offline)",
114 "Interrupt test (offline)", "Loopback test (offline)",
115 "Link test (on/offline)"
117 #define E1000_TEST_LEN sizeof(e1000_gstrings_test) / ETH_GSTRING_LEN
120 e1000_get_settings(struct net_device
*netdev
, struct ethtool_cmd
*ecmd
)
122 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
123 struct e1000_hw
*hw
= &adapter
->hw
;
125 if (hw
->media_type
== e1000_media_type_copper
) {
127 ecmd
->supported
= (SUPPORTED_10baseT_Half
|
128 SUPPORTED_10baseT_Full
|
129 SUPPORTED_100baseT_Half
|
130 SUPPORTED_100baseT_Full
|
131 SUPPORTED_1000baseT_Full
|
134 if (hw
->phy_type
== e1000_phy_ife
)
135 ecmd
->supported
&= ~SUPPORTED_1000baseT_Full
;
136 ecmd
->advertising
= ADVERTISED_TP
;
138 if (hw
->autoneg
== 1) {
139 ecmd
->advertising
|= ADVERTISED_Autoneg
;
140 /* the e1000 autoneg seems to match ethtool nicely */
141 ecmd
->advertising
|= hw
->autoneg_advertised
;
144 ecmd
->port
= PORT_TP
;
145 ecmd
->phy_address
= hw
->phy_addr
;
147 if (hw
->mac_type
== e1000_82543
)
148 ecmd
->transceiver
= XCVR_EXTERNAL
;
150 ecmd
->transceiver
= XCVR_INTERNAL
;
153 ecmd
->supported
= (SUPPORTED_1000baseT_Full
|
157 ecmd
->advertising
= (ADVERTISED_1000baseT_Full
|
161 ecmd
->port
= PORT_FIBRE
;
163 if (hw
->mac_type
>= e1000_82545
)
164 ecmd
->transceiver
= XCVR_INTERNAL
;
166 ecmd
->transceiver
= XCVR_EXTERNAL
;
169 if (netif_carrier_ok(adapter
->netdev
)) {
171 e1000_get_speed_and_duplex(hw
, &adapter
->link_speed
,
172 &adapter
->link_duplex
);
173 ecmd
->speed
= adapter
->link_speed
;
175 /* unfortunatly FULL_DUPLEX != DUPLEX_FULL
176 * and HALF_DUPLEX != DUPLEX_HALF */
178 if (adapter
->link_duplex
== FULL_DUPLEX
)
179 ecmd
->duplex
= DUPLEX_FULL
;
181 ecmd
->duplex
= DUPLEX_HALF
;
187 ecmd
->autoneg
= ((hw
->media_type
== e1000_media_type_fiber
) ||
188 hw
->autoneg
) ? AUTONEG_ENABLE
: AUTONEG_DISABLE
;
193 e1000_set_settings(struct net_device
*netdev
, struct ethtool_cmd
*ecmd
)
195 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
196 struct e1000_hw
*hw
= &adapter
->hw
;
198 /* When SoL/IDER sessions are active, autoneg/speed/duplex
199 * cannot be changed */
200 if (e1000_check_phy_reset_block(hw
)) {
201 DPRINTK(DRV
, ERR
, "Cannot change link characteristics "
202 "when SoL/IDER is active.\n");
206 while (test_and_set_bit(__E1000_RESETTING
, &adapter
->flags
))
209 if (ecmd
->autoneg
== AUTONEG_ENABLE
) {
211 if (hw
->media_type
== e1000_media_type_fiber
)
212 hw
->autoneg_advertised
= ADVERTISED_1000baseT_Full
|
216 hw
->autoneg_advertised
= ecmd
->advertising
|
219 ecmd
->advertising
= hw
->autoneg_advertised
;
221 if (e1000_set_spd_dplx(adapter
, ecmd
->speed
+ ecmd
->duplex
)) {
222 clear_bit(__E1000_RESETTING
, &adapter
->flags
);
228 if (netif_running(adapter
->netdev
)) {
232 e1000_reset(adapter
);
234 clear_bit(__E1000_RESETTING
, &adapter
->flags
);
239 e1000_get_pauseparam(struct net_device
*netdev
,
240 struct ethtool_pauseparam
*pause
)
242 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
243 struct e1000_hw
*hw
= &adapter
->hw
;
246 (adapter
->fc_autoneg
? AUTONEG_ENABLE
: AUTONEG_DISABLE
);
248 if (hw
->fc
== E1000_FC_RX_PAUSE
)
250 else if (hw
->fc
== E1000_FC_TX_PAUSE
)
252 else if (hw
->fc
== E1000_FC_FULL
) {
259 e1000_set_pauseparam(struct net_device
*netdev
,
260 struct ethtool_pauseparam
*pause
)
262 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
263 struct e1000_hw
*hw
= &adapter
->hw
;
266 adapter
->fc_autoneg
= pause
->autoneg
;
268 while (test_and_set_bit(__E1000_RESETTING
, &adapter
->flags
))
271 if (pause
->rx_pause
&& pause
->tx_pause
)
272 hw
->fc
= E1000_FC_FULL
;
273 else if (pause
->rx_pause
&& !pause
->tx_pause
)
274 hw
->fc
= E1000_FC_RX_PAUSE
;
275 else if (!pause
->rx_pause
&& pause
->tx_pause
)
276 hw
->fc
= E1000_FC_TX_PAUSE
;
277 else if (!pause
->rx_pause
&& !pause
->tx_pause
)
278 hw
->fc
= E1000_FC_NONE
;
280 hw
->original_fc
= hw
->fc
;
282 if (adapter
->fc_autoneg
== AUTONEG_ENABLE
) {
283 if (netif_running(adapter
->netdev
)) {
287 e1000_reset(adapter
);
289 retval
= ((hw
->media_type
== e1000_media_type_fiber
) ?
290 e1000_setup_link(hw
) : e1000_force_mac_fc(hw
));
292 clear_bit(__E1000_RESETTING
, &adapter
->flags
);
297 e1000_get_rx_csum(struct net_device
*netdev
)
299 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
300 return adapter
->rx_csum
;
304 e1000_set_rx_csum(struct net_device
*netdev
, uint32_t data
)
306 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
307 adapter
->rx_csum
= data
;
309 if (netif_running(netdev
))
310 e1000_reinit_locked(adapter
);
312 e1000_reset(adapter
);
317 e1000_get_tx_csum(struct net_device
*netdev
)
319 return (netdev
->features
& NETIF_F_HW_CSUM
) != 0;
323 e1000_set_tx_csum(struct net_device
*netdev
, uint32_t data
)
325 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
327 if (adapter
->hw
.mac_type
< e1000_82543
) {
334 netdev
->features
|= NETIF_F_HW_CSUM
;
336 netdev
->features
&= ~NETIF_F_HW_CSUM
;
343 e1000_set_tso(struct net_device
*netdev
, uint32_t data
)
345 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
346 if ((adapter
->hw
.mac_type
< e1000_82544
) ||
347 (adapter
->hw
.mac_type
== e1000_82547
))
348 return data
? -EINVAL
: 0;
351 netdev
->features
|= NETIF_F_TSO
;
353 netdev
->features
&= ~NETIF_F_TSO
;
357 netdev
->features
|= NETIF_F_TSO6
;
359 netdev
->features
&= ~NETIF_F_TSO6
;
362 DPRINTK(PROBE
, INFO
, "TSO is %s\n", data
? "Enabled" : "Disabled");
363 adapter
->tso_force
= TRUE
;
366 #endif /* NETIF_F_TSO */
369 e1000_get_msglevel(struct net_device
*netdev
)
371 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
372 return adapter
->msg_enable
;
376 e1000_set_msglevel(struct net_device
*netdev
, uint32_t data
)
378 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
379 adapter
->msg_enable
= data
;
383 e1000_get_regs_len(struct net_device
*netdev
)
385 #define E1000_REGS_LEN 32
386 return E1000_REGS_LEN
* sizeof(uint32_t);
390 e1000_get_regs(struct net_device
*netdev
,
391 struct ethtool_regs
*regs
, void *p
)
393 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
394 struct e1000_hw
*hw
= &adapter
->hw
;
395 uint32_t *regs_buff
= p
;
398 memset(p
, 0, E1000_REGS_LEN
* sizeof(uint32_t));
400 regs
->version
= (1 << 24) | (hw
->revision_id
<< 16) | hw
->device_id
;
402 regs_buff
[0] = E1000_READ_REG(hw
, CTRL
);
403 regs_buff
[1] = E1000_READ_REG(hw
, STATUS
);
405 regs_buff
[2] = E1000_READ_REG(hw
, RCTL
);
406 regs_buff
[3] = E1000_READ_REG(hw
, RDLEN
);
407 regs_buff
[4] = E1000_READ_REG(hw
, RDH
);
408 regs_buff
[5] = E1000_READ_REG(hw
, RDT
);
409 regs_buff
[6] = E1000_READ_REG(hw
, RDTR
);
411 regs_buff
[7] = E1000_READ_REG(hw
, TCTL
);
412 regs_buff
[8] = E1000_READ_REG(hw
, TDLEN
);
413 regs_buff
[9] = E1000_READ_REG(hw
, TDH
);
414 regs_buff
[10] = E1000_READ_REG(hw
, TDT
);
415 regs_buff
[11] = E1000_READ_REG(hw
, TIDV
);
417 regs_buff
[12] = adapter
->hw
.phy_type
; /* PHY type (IGP=1, M88=0) */
418 if (hw
->phy_type
== e1000_phy_igp
) {
419 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PAGE_SELECT
,
420 IGP01E1000_PHY_AGC_A
);
421 e1000_read_phy_reg(hw
, IGP01E1000_PHY_AGC_A
&
422 IGP01E1000_PHY_PAGE_SELECT
, &phy_data
);
423 regs_buff
[13] = (uint32_t)phy_data
; /* cable length */
424 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PAGE_SELECT
,
425 IGP01E1000_PHY_AGC_B
);
426 e1000_read_phy_reg(hw
, IGP01E1000_PHY_AGC_B
&
427 IGP01E1000_PHY_PAGE_SELECT
, &phy_data
);
428 regs_buff
[14] = (uint32_t)phy_data
; /* cable length */
429 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PAGE_SELECT
,
430 IGP01E1000_PHY_AGC_C
);
431 e1000_read_phy_reg(hw
, IGP01E1000_PHY_AGC_C
&
432 IGP01E1000_PHY_PAGE_SELECT
, &phy_data
);
433 regs_buff
[15] = (uint32_t)phy_data
; /* cable length */
434 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PAGE_SELECT
,
435 IGP01E1000_PHY_AGC_D
);
436 e1000_read_phy_reg(hw
, IGP01E1000_PHY_AGC_D
&
437 IGP01E1000_PHY_PAGE_SELECT
, &phy_data
);
438 regs_buff
[16] = (uint32_t)phy_data
; /* cable length */
439 regs_buff
[17] = 0; /* extended 10bt distance (not needed) */
440 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PAGE_SELECT
, 0x0);
441 e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_STATUS
&
442 IGP01E1000_PHY_PAGE_SELECT
, &phy_data
);
443 regs_buff
[18] = (uint32_t)phy_data
; /* cable polarity */
444 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PAGE_SELECT
,
445 IGP01E1000_PHY_PCS_INIT_REG
);
446 e1000_read_phy_reg(hw
, IGP01E1000_PHY_PCS_INIT_REG
&
447 IGP01E1000_PHY_PAGE_SELECT
, &phy_data
);
448 regs_buff
[19] = (uint32_t)phy_data
; /* cable polarity */
449 regs_buff
[20] = 0; /* polarity correction enabled (always) */
450 regs_buff
[22] = 0; /* phy receive errors (unavailable) */
451 regs_buff
[23] = regs_buff
[18]; /* mdix mode */
452 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PAGE_SELECT
, 0x0);
454 e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_STATUS
, &phy_data
);
455 regs_buff
[13] = (uint32_t)phy_data
; /* cable length */
456 regs_buff
[14] = 0; /* Dummy (to align w/ IGP phy reg dump) */
457 regs_buff
[15] = 0; /* Dummy (to align w/ IGP phy reg dump) */
458 regs_buff
[16] = 0; /* Dummy (to align w/ IGP phy reg dump) */
459 e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, &phy_data
);
460 regs_buff
[17] = (uint32_t)phy_data
; /* extended 10bt distance */
461 regs_buff
[18] = regs_buff
[13]; /* cable polarity */
462 regs_buff
[19] = 0; /* Dummy (to align w/ IGP phy reg dump) */
463 regs_buff
[20] = regs_buff
[17]; /* polarity correction */
464 /* phy receive errors */
465 regs_buff
[22] = adapter
->phy_stats
.receive_errors
;
466 regs_buff
[23] = regs_buff
[13]; /* mdix mode */
468 regs_buff
[21] = adapter
->phy_stats
.idle_errors
; /* phy idle errors */
469 e1000_read_phy_reg(hw
, PHY_1000T_STATUS
, &phy_data
);
470 regs_buff
[24] = (uint32_t)phy_data
; /* phy local receiver status */
471 regs_buff
[25] = regs_buff
[24]; /* phy remote receiver status */
472 if (hw
->mac_type
>= e1000_82540
&&
473 hw
->mac_type
< e1000_82571
&&
474 hw
->media_type
== e1000_media_type_copper
) {
475 regs_buff
[26] = E1000_READ_REG(hw
, MANC
);
480 e1000_get_eeprom_len(struct net_device
*netdev
)
482 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
483 return adapter
->hw
.eeprom
.word_size
* 2;
487 e1000_get_eeprom(struct net_device
*netdev
,
488 struct ethtool_eeprom
*eeprom
, uint8_t *bytes
)
490 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
491 struct e1000_hw
*hw
= &adapter
->hw
;
492 uint16_t *eeprom_buff
;
493 int first_word
, last_word
;
497 if (eeprom
->len
== 0)
500 eeprom
->magic
= hw
->vendor_id
| (hw
->device_id
<< 16);
502 first_word
= eeprom
->offset
>> 1;
503 last_word
= (eeprom
->offset
+ eeprom
->len
- 1) >> 1;
505 eeprom_buff
= kmalloc(sizeof(uint16_t) *
506 (last_word
- first_word
+ 1), GFP_KERNEL
);
510 if (hw
->eeprom
.type
== e1000_eeprom_spi
)
511 ret_val
= e1000_read_eeprom(hw
, first_word
,
512 last_word
- first_word
+ 1,
515 for (i
= 0; i
< last_word
- first_word
+ 1; i
++)
516 if ((ret_val
= e1000_read_eeprom(hw
, first_word
+ i
, 1,
521 /* Device's eeprom is always little-endian, word addressable */
522 for (i
= 0; i
< last_word
- first_word
+ 1; i
++)
523 le16_to_cpus(&eeprom_buff
[i
]);
525 memcpy(bytes
, (uint8_t *)eeprom_buff
+ (eeprom
->offset
& 1),
533 e1000_set_eeprom(struct net_device
*netdev
,
534 struct ethtool_eeprom
*eeprom
, uint8_t *bytes
)
536 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
537 struct e1000_hw
*hw
= &adapter
->hw
;
538 uint16_t *eeprom_buff
;
540 int max_len
, first_word
, last_word
, ret_val
= 0;
543 if (eeprom
->len
== 0)
546 if (eeprom
->magic
!= (hw
->vendor_id
| (hw
->device_id
<< 16)))
549 max_len
= hw
->eeprom
.word_size
* 2;
551 first_word
= eeprom
->offset
>> 1;
552 last_word
= (eeprom
->offset
+ eeprom
->len
- 1) >> 1;
553 eeprom_buff
= kmalloc(max_len
, GFP_KERNEL
);
557 ptr
= (void *)eeprom_buff
;
559 if (eeprom
->offset
& 1) {
560 /* need read/modify/write of first changed EEPROM word */
561 /* only the second byte of the word is being modified */
562 ret_val
= e1000_read_eeprom(hw
, first_word
, 1,
566 if (((eeprom
->offset
+ eeprom
->len
) & 1) && (ret_val
== 0)) {
567 /* need read/modify/write of last changed EEPROM word */
568 /* only the first byte of the word is being modified */
569 ret_val
= e1000_read_eeprom(hw
, last_word
, 1,
570 &eeprom_buff
[last_word
- first_word
]);
573 /* Device's eeprom is always little-endian, word addressable */
574 for (i
= 0; i
< last_word
- first_word
+ 1; i
++)
575 le16_to_cpus(&eeprom_buff
[i
]);
577 memcpy(ptr
, bytes
, eeprom
->len
);
579 for (i
= 0; i
< last_word
- first_word
+ 1; i
++)
580 eeprom_buff
[i
] = cpu_to_le16(eeprom_buff
[i
]);
582 ret_val
= e1000_write_eeprom(hw
, first_word
,
583 last_word
- first_word
+ 1, eeprom_buff
);
585 /* Update the checksum over the first part of the EEPROM if needed
586 * and flush shadow RAM for 82573 conrollers */
587 if ((ret_val
== 0) && ((first_word
<= EEPROM_CHECKSUM_REG
) ||
588 (hw
->mac_type
== e1000_82573
)))
589 e1000_update_eeprom_checksum(hw
);
596 e1000_get_drvinfo(struct net_device
*netdev
,
597 struct ethtool_drvinfo
*drvinfo
)
599 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
600 char firmware_version
[32];
601 uint16_t eeprom_data
;
603 strncpy(drvinfo
->driver
, e1000_driver_name
, 32);
604 strncpy(drvinfo
->version
, e1000_driver_version
, 32);
606 /* EEPROM image version # is reported as firmware version # for
607 * 8257{1|2|3} controllers */
608 e1000_read_eeprom(&adapter
->hw
, 5, 1, &eeprom_data
);
609 switch (adapter
->hw
.mac_type
) {
613 case e1000_80003es2lan
:
615 sprintf(firmware_version
, "%d.%d-%d",
616 (eeprom_data
& 0xF000) >> 12,
617 (eeprom_data
& 0x0FF0) >> 4,
618 eeprom_data
& 0x000F);
621 sprintf(firmware_version
, "N/A");
624 strncpy(drvinfo
->fw_version
, firmware_version
, 32);
625 strncpy(drvinfo
->bus_info
, pci_name(adapter
->pdev
), 32);
626 drvinfo
->n_stats
= E1000_STATS_LEN
;
627 drvinfo
->testinfo_len
= E1000_TEST_LEN
;
628 drvinfo
->regdump_len
= e1000_get_regs_len(netdev
);
629 drvinfo
->eedump_len
= e1000_get_eeprom_len(netdev
);
633 e1000_get_ringparam(struct net_device
*netdev
,
634 struct ethtool_ringparam
*ring
)
636 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
637 e1000_mac_type mac_type
= adapter
->hw
.mac_type
;
638 struct e1000_tx_ring
*txdr
= adapter
->tx_ring
;
639 struct e1000_rx_ring
*rxdr
= adapter
->rx_ring
;
641 ring
->rx_max_pending
= (mac_type
< e1000_82544
) ? E1000_MAX_RXD
:
643 ring
->tx_max_pending
= (mac_type
< e1000_82544
) ? E1000_MAX_TXD
:
645 ring
->rx_mini_max_pending
= 0;
646 ring
->rx_jumbo_max_pending
= 0;
647 ring
->rx_pending
= rxdr
->count
;
648 ring
->tx_pending
= txdr
->count
;
649 ring
->rx_mini_pending
= 0;
650 ring
->rx_jumbo_pending
= 0;
654 e1000_set_ringparam(struct net_device
*netdev
,
655 struct ethtool_ringparam
*ring
)
657 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
658 e1000_mac_type mac_type
= adapter
->hw
.mac_type
;
659 struct e1000_tx_ring
*txdr
, *tx_old
;
660 struct e1000_rx_ring
*rxdr
, *rx_old
;
661 int i
, err
, tx_ring_size
, rx_ring_size
;
663 if ((ring
->rx_mini_pending
) || (ring
->rx_jumbo_pending
))
666 tx_ring_size
= sizeof(struct e1000_tx_ring
) * adapter
->num_tx_queues
;
667 rx_ring_size
= sizeof(struct e1000_rx_ring
) * adapter
->num_rx_queues
;
669 while (test_and_set_bit(__E1000_RESETTING
, &adapter
->flags
))
672 if (netif_running(adapter
->netdev
))
675 tx_old
= adapter
->tx_ring
;
676 rx_old
= adapter
->rx_ring
;
679 txdr
= kzalloc(tx_ring_size
, GFP_KERNEL
);
683 rxdr
= kzalloc(rx_ring_size
, GFP_KERNEL
);
687 adapter
->tx_ring
= txdr
;
688 adapter
->rx_ring
= rxdr
;
690 rxdr
->count
= max(ring
->rx_pending
,(uint32_t)E1000_MIN_RXD
);
691 rxdr
->count
= min(rxdr
->count
,(uint32_t)(mac_type
< e1000_82544
?
692 E1000_MAX_RXD
: E1000_MAX_82544_RXD
));
693 E1000_ROUNDUP(rxdr
->count
, REQ_RX_DESCRIPTOR_MULTIPLE
);
695 txdr
->count
= max(ring
->tx_pending
,(uint32_t)E1000_MIN_TXD
);
696 txdr
->count
= min(txdr
->count
,(uint32_t)(mac_type
< e1000_82544
?
697 E1000_MAX_TXD
: E1000_MAX_82544_TXD
));
698 E1000_ROUNDUP(txdr
->count
, REQ_TX_DESCRIPTOR_MULTIPLE
);
700 for (i
= 0; i
< adapter
->num_tx_queues
; i
++)
701 txdr
[i
].count
= txdr
->count
;
702 for (i
= 0; i
< adapter
->num_rx_queues
; i
++)
703 rxdr
[i
].count
= rxdr
->count
;
705 if (netif_running(adapter
->netdev
)) {
706 /* Try to get new resources before deleting old */
707 if ((err
= e1000_setup_all_rx_resources(adapter
)))
709 if ((err
= e1000_setup_all_tx_resources(adapter
)))
712 /* save the new, restore the old in order to free it,
713 * then restore the new back again */
715 adapter
->rx_ring
= rx_old
;
716 adapter
->tx_ring
= tx_old
;
717 e1000_free_all_rx_resources(adapter
);
718 e1000_free_all_tx_resources(adapter
);
721 adapter
->rx_ring
= rxdr
;
722 adapter
->tx_ring
= txdr
;
723 if ((err
= e1000_up(adapter
)))
727 clear_bit(__E1000_RESETTING
, &adapter
->flags
);
730 e1000_free_all_rx_resources(adapter
);
732 adapter
->rx_ring
= rx_old
;
733 adapter
->tx_ring
= tx_old
;
740 clear_bit(__E1000_RESETTING
, &adapter
->flags
);
744 #define REG_PATTERN_TEST(R, M, W) \
746 uint32_t pat, value; \
748 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF}; \
749 for (pat = 0; pat < sizeof(test)/sizeof(test[0]); pat++) { \
750 E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W)); \
751 value = E1000_READ_REG(&adapter->hw, R); \
752 if (value != (test[pat] & W & M)) { \
753 DPRINTK(DRV, ERR, "pattern test reg %04X failed: got " \
754 "0x%08X expected 0x%08X\n", \
755 E1000_##R, value, (test[pat] & W & M)); \
756 *data = (adapter->hw.mac_type < e1000_82543) ? \
757 E1000_82542_##R : E1000_##R; \
763 #define REG_SET_AND_CHECK(R, M, W) \
766 E1000_WRITE_REG(&adapter->hw, R, W & M); \
767 value = E1000_READ_REG(&adapter->hw, R); \
768 if ((W & M) != (value & M)) { \
769 DPRINTK(DRV, ERR, "set/check reg %04X test failed: got 0x%08X "\
770 "expected 0x%08X\n", E1000_##R, (value & M), (W & M)); \
771 *data = (adapter->hw.mac_type < e1000_82543) ? \
772 E1000_82542_##R : E1000_##R; \
778 e1000_reg_test(struct e1000_adapter
*adapter
, uint64_t *data
)
780 uint32_t value
, before
, after
;
783 /* The status register is Read Only, so a write should fail.
784 * Some bits that get toggled are ignored.
786 switch (adapter
->hw
.mac_type
) {
787 /* there are several bits on newer hardware that are r/w */
790 case e1000_80003es2lan
:
802 before
= E1000_READ_REG(&adapter
->hw
, STATUS
);
803 value
= (E1000_READ_REG(&adapter
->hw
, STATUS
) & toggle
);
804 E1000_WRITE_REG(&adapter
->hw
, STATUS
, toggle
);
805 after
= E1000_READ_REG(&adapter
->hw
, STATUS
) & toggle
;
806 if (value
!= after
) {
807 DPRINTK(DRV
, ERR
, "failed STATUS register test got: "
808 "0x%08X expected: 0x%08X\n", after
, value
);
812 /* restore previous status */
813 E1000_WRITE_REG(&adapter
->hw
, STATUS
, before
);
815 if (adapter
->hw
.mac_type
!= e1000_ich8lan
) {
816 REG_PATTERN_TEST(FCAL
, 0xFFFFFFFF, 0xFFFFFFFF);
817 REG_PATTERN_TEST(FCAH
, 0x0000FFFF, 0xFFFFFFFF);
818 REG_PATTERN_TEST(FCT
, 0x0000FFFF, 0xFFFFFFFF);
819 REG_PATTERN_TEST(VET
, 0x0000FFFF, 0xFFFFFFFF);
822 REG_PATTERN_TEST(RDTR
, 0x0000FFFF, 0xFFFFFFFF);
823 REG_PATTERN_TEST(RDBAH
, 0xFFFFFFFF, 0xFFFFFFFF);
824 REG_PATTERN_TEST(RDLEN
, 0x000FFF80, 0x000FFFFF);
825 REG_PATTERN_TEST(RDH
, 0x0000FFFF, 0x0000FFFF);
826 REG_PATTERN_TEST(RDT
, 0x0000FFFF, 0x0000FFFF);
827 REG_PATTERN_TEST(FCRTH
, 0x0000FFF8, 0x0000FFF8);
828 REG_PATTERN_TEST(FCTTV
, 0x0000FFFF, 0x0000FFFF);
829 REG_PATTERN_TEST(TIPG
, 0x3FFFFFFF, 0x3FFFFFFF);
830 REG_PATTERN_TEST(TDBAH
, 0xFFFFFFFF, 0xFFFFFFFF);
831 REG_PATTERN_TEST(TDLEN
, 0x000FFF80, 0x000FFFFF);
833 REG_SET_AND_CHECK(RCTL
, 0xFFFFFFFF, 0x00000000);
835 before
= (adapter
->hw
.mac_type
== e1000_ich8lan
?
836 0x06C3B33E : 0x06DFB3FE);
837 REG_SET_AND_CHECK(RCTL
, before
, 0x003FFFFB);
838 REG_SET_AND_CHECK(TCTL
, 0xFFFFFFFF, 0x00000000);
840 if (adapter
->hw
.mac_type
>= e1000_82543
) {
842 REG_SET_AND_CHECK(RCTL
, before
, 0xFFFFFFFF);
843 REG_PATTERN_TEST(RDBAL
, 0xFFFFFFF0, 0xFFFFFFFF);
844 if (adapter
->hw
.mac_type
!= e1000_ich8lan
)
845 REG_PATTERN_TEST(TXCW
, 0xC000FFFF, 0x0000FFFF);
846 REG_PATTERN_TEST(TDBAL
, 0xFFFFFFF0, 0xFFFFFFFF);
847 REG_PATTERN_TEST(TIDV
, 0x0000FFFF, 0x0000FFFF);
848 value
= (adapter
->hw
.mac_type
== e1000_ich8lan
?
849 E1000_RAR_ENTRIES_ICH8LAN
: E1000_RAR_ENTRIES
);
850 for (i
= 0; i
< value
; i
++) {
851 REG_PATTERN_TEST(RA
+ (((i
<< 1) + 1) << 2), 0x8003FFFF,
857 REG_SET_AND_CHECK(RCTL
, 0xFFFFFFFF, 0x01FFFFFF);
858 REG_PATTERN_TEST(RDBAL
, 0xFFFFF000, 0xFFFFFFFF);
859 REG_PATTERN_TEST(TXCW
, 0x0000FFFF, 0x0000FFFF);
860 REG_PATTERN_TEST(TDBAL
, 0xFFFFF000, 0xFFFFFFFF);
864 value
= (adapter
->hw
.mac_type
== e1000_ich8lan
?
865 E1000_MC_TBL_SIZE_ICH8LAN
: E1000_MC_TBL_SIZE
);
866 for (i
= 0; i
< value
; i
++)
867 REG_PATTERN_TEST(MTA
+ (i
<< 2), 0xFFFFFFFF, 0xFFFFFFFF);
874 e1000_eeprom_test(struct e1000_adapter
*adapter
, uint64_t *data
)
877 uint16_t checksum
= 0;
881 /* Read and add up the contents of the EEPROM */
882 for (i
= 0; i
< (EEPROM_CHECKSUM_REG
+ 1); i
++) {
883 if ((e1000_read_eeprom(&adapter
->hw
, i
, 1, &temp
)) < 0) {
890 /* If Checksum is not Correct return error else test passed */
891 if ((checksum
!= (uint16_t) EEPROM_SUM
) && !(*data
))
898 e1000_test_intr(int irq
, void *data
)
900 struct net_device
*netdev
= (struct net_device
*) data
;
901 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
903 adapter
->test_icr
|= E1000_READ_REG(&adapter
->hw
, ICR
);
909 e1000_intr_test(struct e1000_adapter
*adapter
, uint64_t *data
)
911 struct net_device
*netdev
= adapter
->netdev
;
912 uint32_t mask
, i
=0, shared_int
= TRUE
;
913 uint32_t irq
= adapter
->pdev
->irq
;
917 /* NOTE: we don't test MSI interrupts here, yet */
918 /* Hook up test interrupt handler just for this test */
919 if (!request_irq(irq
, &e1000_test_intr
, IRQF_PROBE_SHARED
, netdev
->name
,
922 else if (request_irq(irq
, &e1000_test_intr
, IRQF_SHARED
,
923 netdev
->name
, netdev
)) {
927 DPRINTK(HW
, INFO
, "testing %s interrupt\n",
928 (shared_int
? "shared" : "unshared"));
930 /* Disable all the interrupts */
931 E1000_WRITE_REG(&adapter
->hw
, IMC
, 0xFFFFFFFF);
934 /* Test each interrupt */
935 for (; i
< 10; i
++) {
937 if (adapter
->hw
.mac_type
== e1000_ich8lan
&& i
== 8)
940 /* Interrupt to test */
944 /* Disable the interrupt to be reported in
945 * the cause register and then force the same
946 * interrupt and see if one gets posted. If
947 * an interrupt was posted to the bus, the
950 adapter
->test_icr
= 0;
951 E1000_WRITE_REG(&adapter
->hw
, IMC
, mask
);
952 E1000_WRITE_REG(&adapter
->hw
, ICS
, mask
);
955 if (adapter
->test_icr
& mask
) {
961 /* Enable the interrupt to be reported in
962 * the cause register and then force the same
963 * interrupt and see if one gets posted. If
964 * an interrupt was not posted to the bus, the
967 adapter
->test_icr
= 0;
968 E1000_WRITE_REG(&adapter
->hw
, IMS
, mask
);
969 E1000_WRITE_REG(&adapter
->hw
, ICS
, mask
);
972 if (!(adapter
->test_icr
& mask
)) {
978 /* Disable the other interrupts to be reported in
979 * the cause register and then force the other
980 * interrupts and see if any get posted. If
981 * an interrupt was posted to the bus, the
984 adapter
->test_icr
= 0;
985 E1000_WRITE_REG(&adapter
->hw
, IMC
, ~mask
& 0x00007FFF);
986 E1000_WRITE_REG(&adapter
->hw
, ICS
, ~mask
& 0x00007FFF);
989 if (adapter
->test_icr
) {
996 /* Disable all the interrupts */
997 E1000_WRITE_REG(&adapter
->hw
, IMC
, 0xFFFFFFFF);
1000 /* Unhook test interrupt handler */
1001 free_irq(irq
, netdev
);
1007 e1000_free_desc_rings(struct e1000_adapter
*adapter
)
1009 struct e1000_tx_ring
*txdr
= &adapter
->test_tx_ring
;
1010 struct e1000_rx_ring
*rxdr
= &adapter
->test_rx_ring
;
1011 struct pci_dev
*pdev
= adapter
->pdev
;
1014 if (txdr
->desc
&& txdr
->buffer_info
) {
1015 for (i
= 0; i
< txdr
->count
; i
++) {
1016 if (txdr
->buffer_info
[i
].dma
)
1017 pci_unmap_single(pdev
, txdr
->buffer_info
[i
].dma
,
1018 txdr
->buffer_info
[i
].length
,
1020 if (txdr
->buffer_info
[i
].skb
)
1021 dev_kfree_skb(txdr
->buffer_info
[i
].skb
);
1025 if (rxdr
->desc
&& rxdr
->buffer_info
) {
1026 for (i
= 0; i
< rxdr
->count
; i
++) {
1027 if (rxdr
->buffer_info
[i
].dma
)
1028 pci_unmap_single(pdev
, rxdr
->buffer_info
[i
].dma
,
1029 rxdr
->buffer_info
[i
].length
,
1030 PCI_DMA_FROMDEVICE
);
1031 if (rxdr
->buffer_info
[i
].skb
)
1032 dev_kfree_skb(rxdr
->buffer_info
[i
].skb
);
1037 pci_free_consistent(pdev
, txdr
->size
, txdr
->desc
, txdr
->dma
);
1041 pci_free_consistent(pdev
, rxdr
->size
, rxdr
->desc
, rxdr
->dma
);
1045 kfree(txdr
->buffer_info
);
1046 txdr
->buffer_info
= NULL
;
1047 kfree(rxdr
->buffer_info
);
1048 rxdr
->buffer_info
= NULL
;
1054 e1000_setup_desc_rings(struct e1000_adapter
*adapter
)
1056 struct e1000_tx_ring
*txdr
= &adapter
->test_tx_ring
;
1057 struct e1000_rx_ring
*rxdr
= &adapter
->test_rx_ring
;
1058 struct pci_dev
*pdev
= adapter
->pdev
;
1060 int size
, i
, ret_val
;
1062 /* Setup Tx descriptor ring and Tx buffers */
1065 txdr
->count
= E1000_DEFAULT_TXD
;
1067 size
= txdr
->count
* sizeof(struct e1000_buffer
);
1068 if (!(txdr
->buffer_info
= kmalloc(size
, GFP_KERNEL
))) {
1072 memset(txdr
->buffer_info
, 0, size
);
1074 txdr
->size
= txdr
->count
* sizeof(struct e1000_tx_desc
);
1075 E1000_ROUNDUP(txdr
->size
, 4096);
1076 if (!(txdr
->desc
= pci_alloc_consistent(pdev
, txdr
->size
, &txdr
->dma
))) {
1080 memset(txdr
->desc
, 0, txdr
->size
);
1081 txdr
->next_to_use
= txdr
->next_to_clean
= 0;
1083 E1000_WRITE_REG(&adapter
->hw
, TDBAL
,
1084 ((uint64_t) txdr
->dma
& 0x00000000FFFFFFFF));
1085 E1000_WRITE_REG(&adapter
->hw
, TDBAH
, ((uint64_t) txdr
->dma
>> 32));
1086 E1000_WRITE_REG(&adapter
->hw
, TDLEN
,
1087 txdr
->count
* sizeof(struct e1000_tx_desc
));
1088 E1000_WRITE_REG(&adapter
->hw
, TDH
, 0);
1089 E1000_WRITE_REG(&adapter
->hw
, TDT
, 0);
1090 E1000_WRITE_REG(&adapter
->hw
, TCTL
,
1091 E1000_TCTL_PSP
| E1000_TCTL_EN
|
1092 E1000_COLLISION_THRESHOLD
<< E1000_CT_SHIFT
|
1093 E1000_FDX_COLLISION_DISTANCE
<< E1000_COLD_SHIFT
);
1095 for (i
= 0; i
< txdr
->count
; i
++) {
1096 struct e1000_tx_desc
*tx_desc
= E1000_TX_DESC(*txdr
, i
);
1097 struct sk_buff
*skb
;
1098 unsigned int size
= 1024;
1100 if (!(skb
= alloc_skb(size
, GFP_KERNEL
))) {
1105 txdr
->buffer_info
[i
].skb
= skb
;
1106 txdr
->buffer_info
[i
].length
= skb
->len
;
1107 txdr
->buffer_info
[i
].dma
=
1108 pci_map_single(pdev
, skb
->data
, skb
->len
,
1110 tx_desc
->buffer_addr
= cpu_to_le64(txdr
->buffer_info
[i
].dma
);
1111 tx_desc
->lower
.data
= cpu_to_le32(skb
->len
);
1112 tx_desc
->lower
.data
|= cpu_to_le32(E1000_TXD_CMD_EOP
|
1113 E1000_TXD_CMD_IFCS
|
1115 tx_desc
->upper
.data
= 0;
1118 /* Setup Rx descriptor ring and Rx buffers */
1121 rxdr
->count
= E1000_DEFAULT_RXD
;
1123 size
= rxdr
->count
* sizeof(struct e1000_buffer
);
1124 if (!(rxdr
->buffer_info
= kmalloc(size
, GFP_KERNEL
))) {
1128 memset(rxdr
->buffer_info
, 0, size
);
1130 rxdr
->size
= rxdr
->count
* sizeof(struct e1000_rx_desc
);
1131 if (!(rxdr
->desc
= pci_alloc_consistent(pdev
, rxdr
->size
, &rxdr
->dma
))) {
1135 memset(rxdr
->desc
, 0, rxdr
->size
);
1136 rxdr
->next_to_use
= rxdr
->next_to_clean
= 0;
1138 rctl
= E1000_READ_REG(&adapter
->hw
, RCTL
);
1139 E1000_WRITE_REG(&adapter
->hw
, RCTL
, rctl
& ~E1000_RCTL_EN
);
1140 E1000_WRITE_REG(&adapter
->hw
, RDBAL
,
1141 ((uint64_t) rxdr
->dma
& 0xFFFFFFFF));
1142 E1000_WRITE_REG(&adapter
->hw
, RDBAH
, ((uint64_t) rxdr
->dma
>> 32));
1143 E1000_WRITE_REG(&adapter
->hw
, RDLEN
, rxdr
->size
);
1144 E1000_WRITE_REG(&adapter
->hw
, RDH
, 0);
1145 E1000_WRITE_REG(&adapter
->hw
, RDT
, 0);
1146 rctl
= E1000_RCTL_EN
| E1000_RCTL_BAM
| E1000_RCTL_SZ_2048
|
1147 E1000_RCTL_LBM_NO
| E1000_RCTL_RDMTS_HALF
|
1148 (adapter
->hw
.mc_filter_type
<< E1000_RCTL_MO_SHIFT
);
1149 E1000_WRITE_REG(&adapter
->hw
, RCTL
, rctl
);
1151 for (i
= 0; i
< rxdr
->count
; i
++) {
1152 struct e1000_rx_desc
*rx_desc
= E1000_RX_DESC(*rxdr
, i
);
1153 struct sk_buff
*skb
;
1155 if (!(skb
= alloc_skb(E1000_RXBUFFER_2048
+ NET_IP_ALIGN
,
1160 skb_reserve(skb
, NET_IP_ALIGN
);
1161 rxdr
->buffer_info
[i
].skb
= skb
;
1162 rxdr
->buffer_info
[i
].length
= E1000_RXBUFFER_2048
;
1163 rxdr
->buffer_info
[i
].dma
=
1164 pci_map_single(pdev
, skb
->data
, E1000_RXBUFFER_2048
,
1165 PCI_DMA_FROMDEVICE
);
1166 rx_desc
->buffer_addr
= cpu_to_le64(rxdr
->buffer_info
[i
].dma
);
1167 memset(skb
->data
, 0x00, skb
->len
);
1173 e1000_free_desc_rings(adapter
);
1178 e1000_phy_disable_receiver(struct e1000_adapter
*adapter
)
1180 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1181 e1000_write_phy_reg(&adapter
->hw
, 29, 0x001F);
1182 e1000_write_phy_reg(&adapter
->hw
, 30, 0x8FFC);
1183 e1000_write_phy_reg(&adapter
->hw
, 29, 0x001A);
1184 e1000_write_phy_reg(&adapter
->hw
, 30, 0x8FF0);
1188 e1000_phy_reset_clk_and_crs(struct e1000_adapter
*adapter
)
1192 /* Because we reset the PHY above, we need to re-force TX_CLK in the
1193 * Extended PHY Specific Control Register to 25MHz clock. This
1194 * value defaults back to a 2.5MHz clock when the PHY is reset.
1196 e1000_read_phy_reg(&adapter
->hw
, M88E1000_EXT_PHY_SPEC_CTRL
, &phy_reg
);
1197 phy_reg
|= M88E1000_EPSCR_TX_CLK_25
;
1198 e1000_write_phy_reg(&adapter
->hw
,
1199 M88E1000_EXT_PHY_SPEC_CTRL
, phy_reg
);
1201 /* In addition, because of the s/w reset above, we need to enable
1202 * CRS on TX. This must be set for both full and half duplex
1205 e1000_read_phy_reg(&adapter
->hw
, M88E1000_PHY_SPEC_CTRL
, &phy_reg
);
1206 phy_reg
|= M88E1000_PSCR_ASSERT_CRS_ON_TX
;
1207 e1000_write_phy_reg(&adapter
->hw
,
1208 M88E1000_PHY_SPEC_CTRL
, phy_reg
);
1212 e1000_nonintegrated_phy_loopback(struct e1000_adapter
*adapter
)
1217 /* Setup the Device Control Register for PHY loopback test. */
1219 ctrl_reg
= E1000_READ_REG(&adapter
->hw
, CTRL
);
1220 ctrl_reg
|= (E1000_CTRL_ILOS
| /* Invert Loss-Of-Signal */
1221 E1000_CTRL_FRCSPD
| /* Set the Force Speed Bit */
1222 E1000_CTRL_FRCDPX
| /* Set the Force Duplex Bit */
1223 E1000_CTRL_SPD_1000
| /* Force Speed to 1000 */
1224 E1000_CTRL_FD
); /* Force Duplex to FULL */
1226 E1000_WRITE_REG(&adapter
->hw
, CTRL
, ctrl_reg
);
1228 /* Read the PHY Specific Control Register (0x10) */
1229 e1000_read_phy_reg(&adapter
->hw
, M88E1000_PHY_SPEC_CTRL
, &phy_reg
);
1231 /* Clear Auto-Crossover bits in PHY Specific Control Register
1234 phy_reg
&= ~M88E1000_PSCR_AUTO_X_MODE
;
1235 e1000_write_phy_reg(&adapter
->hw
, M88E1000_PHY_SPEC_CTRL
, phy_reg
);
1237 /* Perform software reset on the PHY */
1238 e1000_phy_reset(&adapter
->hw
);
1240 /* Have to setup TX_CLK and TX_CRS after software reset */
1241 e1000_phy_reset_clk_and_crs(adapter
);
1243 e1000_write_phy_reg(&adapter
->hw
, PHY_CTRL
, 0x8100);
1245 /* Wait for reset to complete. */
1248 /* Have to setup TX_CLK and TX_CRS after software reset */
1249 e1000_phy_reset_clk_and_crs(adapter
);
1251 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1252 e1000_phy_disable_receiver(adapter
);
1254 /* Set the loopback bit in the PHY control register. */
1255 e1000_read_phy_reg(&adapter
->hw
, PHY_CTRL
, &phy_reg
);
1256 phy_reg
|= MII_CR_LOOPBACK
;
1257 e1000_write_phy_reg(&adapter
->hw
, PHY_CTRL
, phy_reg
);
1259 /* Setup TX_CLK and TX_CRS one more time. */
1260 e1000_phy_reset_clk_and_crs(adapter
);
1262 /* Check Phy Configuration */
1263 e1000_read_phy_reg(&adapter
->hw
, PHY_CTRL
, &phy_reg
);
1264 if (phy_reg
!= 0x4100)
1267 e1000_read_phy_reg(&adapter
->hw
, M88E1000_EXT_PHY_SPEC_CTRL
, &phy_reg
);
1268 if (phy_reg
!= 0x0070)
1271 e1000_read_phy_reg(&adapter
->hw
, 29, &phy_reg
);
1272 if (phy_reg
!= 0x001A)
1279 e1000_integrated_phy_loopback(struct e1000_adapter
*adapter
)
1281 uint32_t ctrl_reg
= 0;
1282 uint32_t stat_reg
= 0;
1284 adapter
->hw
.autoneg
= FALSE
;
1286 if (adapter
->hw
.phy_type
== e1000_phy_m88
) {
1287 /* Auto-MDI/MDIX Off */
1288 e1000_write_phy_reg(&adapter
->hw
,
1289 M88E1000_PHY_SPEC_CTRL
, 0x0808);
1290 /* reset to update Auto-MDI/MDIX */
1291 e1000_write_phy_reg(&adapter
->hw
, PHY_CTRL
, 0x9140);
1293 e1000_write_phy_reg(&adapter
->hw
, PHY_CTRL
, 0x8140);
1294 } else if (adapter
->hw
.phy_type
== e1000_phy_gg82563
)
1295 e1000_write_phy_reg(&adapter
->hw
,
1296 GG82563_PHY_KMRN_MODE_CTRL
,
1299 ctrl_reg
= E1000_READ_REG(&adapter
->hw
, CTRL
);
1301 if (adapter
->hw
.phy_type
== e1000_phy_ife
) {
1302 /* force 100, set loopback */
1303 e1000_write_phy_reg(&adapter
->hw
, PHY_CTRL
, 0x6100);
1305 /* Now set up the MAC to the same speed/duplex as the PHY. */
1306 ctrl_reg
&= ~E1000_CTRL_SPD_SEL
; /* Clear the speed sel bits */
1307 ctrl_reg
|= (E1000_CTRL_FRCSPD
| /* Set the Force Speed Bit */
1308 E1000_CTRL_FRCDPX
| /* Set the Force Duplex Bit */
1309 E1000_CTRL_SPD_100
|/* Force Speed to 100 */
1310 E1000_CTRL_FD
); /* Force Duplex to FULL */
1312 /* force 1000, set loopback */
1313 e1000_write_phy_reg(&adapter
->hw
, PHY_CTRL
, 0x4140);
1315 /* Now set up the MAC to the same speed/duplex as the PHY. */
1316 ctrl_reg
= E1000_READ_REG(&adapter
->hw
, CTRL
);
1317 ctrl_reg
&= ~E1000_CTRL_SPD_SEL
; /* Clear the speed sel bits */
1318 ctrl_reg
|= (E1000_CTRL_FRCSPD
| /* Set the Force Speed Bit */
1319 E1000_CTRL_FRCDPX
| /* Set the Force Duplex Bit */
1320 E1000_CTRL_SPD_1000
|/* Force Speed to 1000 */
1321 E1000_CTRL_FD
); /* Force Duplex to FULL */
1324 if (adapter
->hw
.media_type
== e1000_media_type_copper
&&
1325 adapter
->hw
.phy_type
== e1000_phy_m88
)
1326 ctrl_reg
|= E1000_CTRL_ILOS
; /* Invert Loss of Signal */
1328 /* Set the ILOS bit on the fiber Nic is half
1329 * duplex link is detected. */
1330 stat_reg
= E1000_READ_REG(&adapter
->hw
, STATUS
);
1331 if ((stat_reg
& E1000_STATUS_FD
) == 0)
1332 ctrl_reg
|= (E1000_CTRL_ILOS
| E1000_CTRL_SLU
);
1335 E1000_WRITE_REG(&adapter
->hw
, CTRL
, ctrl_reg
);
1337 /* Disable the receiver on the PHY so when a cable is plugged in, the
1338 * PHY does not begin to autoneg when a cable is reconnected to the NIC.
1340 if (adapter
->hw
.phy_type
== e1000_phy_m88
)
1341 e1000_phy_disable_receiver(adapter
);
1349 e1000_set_phy_loopback(struct e1000_adapter
*adapter
)
1351 uint16_t phy_reg
= 0;
1354 switch (adapter
->hw
.mac_type
) {
1356 if (adapter
->hw
.media_type
== e1000_media_type_copper
) {
1357 /* Attempt to setup Loopback mode on Non-integrated PHY.
1358 * Some PHY registers get corrupted at random, so
1359 * attempt this 10 times.
1361 while (e1000_nonintegrated_phy_loopback(adapter
) &&
1371 case e1000_82545_rev_3
:
1373 case e1000_82546_rev_3
:
1375 case e1000_82541_rev_2
:
1377 case e1000_82547_rev_2
:
1381 case e1000_80003es2lan
:
1383 return e1000_integrated_phy_loopback(adapter
);
1387 /* Default PHY loopback work is to read the MII
1388 * control register and assert bit 14 (loopback mode).
1390 e1000_read_phy_reg(&adapter
->hw
, PHY_CTRL
, &phy_reg
);
1391 phy_reg
|= MII_CR_LOOPBACK
;
1392 e1000_write_phy_reg(&adapter
->hw
, PHY_CTRL
, phy_reg
);
1401 e1000_setup_loopback_test(struct e1000_adapter
*adapter
)
1403 struct e1000_hw
*hw
= &adapter
->hw
;
1406 if (hw
->media_type
== e1000_media_type_fiber
||
1407 hw
->media_type
== e1000_media_type_internal_serdes
) {
1408 switch (hw
->mac_type
) {
1411 case e1000_82545_rev_3
:
1412 case e1000_82546_rev_3
:
1413 return e1000_set_phy_loopback(adapter
);
1417 #define E1000_SERDES_LB_ON 0x410
1418 e1000_set_phy_loopback(adapter
);
1419 E1000_WRITE_REG(hw
, SCTL
, E1000_SERDES_LB_ON
);
1424 rctl
= E1000_READ_REG(hw
, RCTL
);
1425 rctl
|= E1000_RCTL_LBM_TCVR
;
1426 E1000_WRITE_REG(hw
, RCTL
, rctl
);
1429 } else if (hw
->media_type
== e1000_media_type_copper
)
1430 return e1000_set_phy_loopback(adapter
);
1436 e1000_loopback_cleanup(struct e1000_adapter
*adapter
)
1438 struct e1000_hw
*hw
= &adapter
->hw
;
1442 rctl
= E1000_READ_REG(hw
, RCTL
);
1443 rctl
&= ~(E1000_RCTL_LBM_TCVR
| E1000_RCTL_LBM_MAC
);
1444 E1000_WRITE_REG(hw
, RCTL
, rctl
);
1446 switch (hw
->mac_type
) {
1449 if (hw
->media_type
== e1000_media_type_fiber
||
1450 hw
->media_type
== e1000_media_type_internal_serdes
) {
1451 #define E1000_SERDES_LB_OFF 0x400
1452 E1000_WRITE_REG(hw
, SCTL
, E1000_SERDES_LB_OFF
);
1459 case e1000_82545_rev_3
:
1460 case e1000_82546_rev_3
:
1463 if (hw
->phy_type
== e1000_phy_gg82563
)
1464 e1000_write_phy_reg(hw
,
1465 GG82563_PHY_KMRN_MODE_CTRL
,
1467 e1000_read_phy_reg(hw
, PHY_CTRL
, &phy_reg
);
1468 if (phy_reg
& MII_CR_LOOPBACK
) {
1469 phy_reg
&= ~MII_CR_LOOPBACK
;
1470 e1000_write_phy_reg(hw
, PHY_CTRL
, phy_reg
);
1471 e1000_phy_reset(hw
);
1478 e1000_create_lbtest_frame(struct sk_buff
*skb
, unsigned int frame_size
)
1480 memset(skb
->data
, 0xFF, frame_size
);
1482 memset(&skb
->data
[frame_size
/ 2], 0xAA, frame_size
/ 2 - 1);
1483 memset(&skb
->data
[frame_size
/ 2 + 10], 0xBE, 1);
1484 memset(&skb
->data
[frame_size
/ 2 + 12], 0xAF, 1);
1488 e1000_check_lbtest_frame(struct sk_buff
*skb
, unsigned int frame_size
)
1491 if (*(skb
->data
+ 3) == 0xFF) {
1492 if ((*(skb
->data
+ frame_size
/ 2 + 10) == 0xBE) &&
1493 (*(skb
->data
+ frame_size
/ 2 + 12) == 0xAF)) {
1501 e1000_run_loopback_test(struct e1000_adapter
*adapter
)
1503 struct e1000_tx_ring
*txdr
= &adapter
->test_tx_ring
;
1504 struct e1000_rx_ring
*rxdr
= &adapter
->test_rx_ring
;
1505 struct pci_dev
*pdev
= adapter
->pdev
;
1506 int i
, j
, k
, l
, lc
, good_cnt
, ret_val
=0;
1509 E1000_WRITE_REG(&adapter
->hw
, RDT
, rxdr
->count
- 1);
1511 /* Calculate the loop count based on the largest descriptor ring
1512 * The idea is to wrap the largest ring a number of times using 64
1513 * send/receive pairs during each loop
1516 if (rxdr
->count
<= txdr
->count
)
1517 lc
= ((txdr
->count
/ 64) * 2) + 1;
1519 lc
= ((rxdr
->count
/ 64) * 2) + 1;
1522 for (j
= 0; j
<= lc
; j
++) { /* loop count loop */
1523 for (i
= 0; i
< 64; i
++) { /* send the packets */
1524 e1000_create_lbtest_frame(txdr
->buffer_info
[i
].skb
,
1526 pci_dma_sync_single_for_device(pdev
,
1527 txdr
->buffer_info
[k
].dma
,
1528 txdr
->buffer_info
[k
].length
,
1530 if (unlikely(++k
== txdr
->count
)) k
= 0;
1532 E1000_WRITE_REG(&adapter
->hw
, TDT
, k
);
1534 time
= jiffies
; /* set the start time for the receive */
1536 do { /* receive the sent packets */
1537 pci_dma_sync_single_for_cpu(pdev
,
1538 rxdr
->buffer_info
[l
].dma
,
1539 rxdr
->buffer_info
[l
].length
,
1540 PCI_DMA_FROMDEVICE
);
1542 ret_val
= e1000_check_lbtest_frame(
1543 rxdr
->buffer_info
[l
].skb
,
1547 if (unlikely(++l
== rxdr
->count
)) l
= 0;
1548 /* time + 20 msecs (200 msecs on 2.4) is more than
1549 * enough time to complete the receives, if it's
1550 * exceeded, break and error off
1552 } while (good_cnt
< 64 && jiffies
< (time
+ 20));
1553 if (good_cnt
!= 64) {
1554 ret_val
= 13; /* ret_val is the same as mis-compare */
1557 if (jiffies
>= (time
+ 2)) {
1558 ret_val
= 14; /* error code for time out error */
1561 } /* end loop count loop */
1566 e1000_loopback_test(struct e1000_adapter
*adapter
, uint64_t *data
)
1568 /* PHY loopback cannot be performed if SoL/IDER
1569 * sessions are active */
1570 if (e1000_check_phy_reset_block(&adapter
->hw
)) {
1571 DPRINTK(DRV
, ERR
, "Cannot do PHY loopback test "
1572 "when SoL/IDER is active.\n");
1577 if ((*data
= e1000_setup_desc_rings(adapter
)))
1579 if ((*data
= e1000_setup_loopback_test(adapter
)))
1581 *data
= e1000_run_loopback_test(adapter
);
1582 e1000_loopback_cleanup(adapter
);
1585 e1000_free_desc_rings(adapter
);
1591 e1000_link_test(struct e1000_adapter
*adapter
, uint64_t *data
)
1594 if (adapter
->hw
.media_type
== e1000_media_type_internal_serdes
) {
1596 adapter
->hw
.serdes_link_down
= TRUE
;
1598 /* On some blade server designs, link establishment
1599 * could take as long as 2-3 minutes */
1601 e1000_check_for_link(&adapter
->hw
);
1602 if (adapter
->hw
.serdes_link_down
== FALSE
)
1605 } while (i
++ < 3750);
1609 e1000_check_for_link(&adapter
->hw
);
1610 if (adapter
->hw
.autoneg
) /* if auto_neg is set wait for it */
1613 if (!(E1000_READ_REG(&adapter
->hw
, STATUS
) & E1000_STATUS_LU
)) {
1621 e1000_diag_test_count(struct net_device
*netdev
)
1623 return E1000_TEST_LEN
;
1626 extern void e1000_power_up_phy(struct e1000_adapter
*);
1629 e1000_diag_test(struct net_device
*netdev
,
1630 struct ethtool_test
*eth_test
, uint64_t *data
)
1632 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
1633 boolean_t if_running
= netif_running(netdev
);
1635 set_bit(__E1000_TESTING
, &adapter
->flags
);
1636 if (eth_test
->flags
== ETH_TEST_FL_OFFLINE
) {
1639 /* save speed, duplex, autoneg settings */
1640 uint16_t autoneg_advertised
= adapter
->hw
.autoneg_advertised
;
1641 uint8_t forced_speed_duplex
= adapter
->hw
.forced_speed_duplex
;
1642 uint8_t autoneg
= adapter
->hw
.autoneg
;
1644 DPRINTK(HW
, INFO
, "offline testing starting\n");
1646 /* Link test performed before hardware reset so autoneg doesn't
1647 * interfere with test result */
1648 if (e1000_link_test(adapter
, &data
[4]))
1649 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1652 /* indicate we're in test mode */
1655 e1000_reset(adapter
);
1657 if (e1000_reg_test(adapter
, &data
[0]))
1658 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1660 e1000_reset(adapter
);
1661 if (e1000_eeprom_test(adapter
, &data
[1]))
1662 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1664 e1000_reset(adapter
);
1665 if (e1000_intr_test(adapter
, &data
[2]))
1666 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1668 e1000_reset(adapter
);
1669 /* make sure the phy is powered up */
1670 e1000_power_up_phy(adapter
);
1671 if (e1000_loopback_test(adapter
, &data
[3]))
1672 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1674 /* restore speed, duplex, autoneg settings */
1675 adapter
->hw
.autoneg_advertised
= autoneg_advertised
;
1676 adapter
->hw
.forced_speed_duplex
= forced_speed_duplex
;
1677 adapter
->hw
.autoneg
= autoneg
;
1679 e1000_reset(adapter
);
1680 clear_bit(__E1000_TESTING
, &adapter
->flags
);
1684 DPRINTK(HW
, INFO
, "online testing starting\n");
1686 if (e1000_link_test(adapter
, &data
[4]))
1687 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1689 /* Online tests aren't run; pass by default */
1695 clear_bit(__E1000_TESTING
, &adapter
->flags
);
1697 msleep_interruptible(4 * 1000);
1700 static int e1000_wol_exclusion(struct e1000_adapter
*adapter
, struct ethtool_wolinfo
*wol
)
1702 struct e1000_hw
*hw
= &adapter
->hw
;
1703 int retval
= 1; /* fail by default */
1705 switch (hw
->device_id
) {
1706 case E1000_DEV_ID_82542
:
1707 case E1000_DEV_ID_82543GC_FIBER
:
1708 case E1000_DEV_ID_82543GC_COPPER
:
1709 case E1000_DEV_ID_82544EI_FIBER
:
1710 case E1000_DEV_ID_82546EB_QUAD_COPPER
:
1711 case E1000_DEV_ID_82545EM_FIBER
:
1712 case E1000_DEV_ID_82545EM_COPPER
:
1713 case E1000_DEV_ID_82546GB_QUAD_COPPER
:
1714 case E1000_DEV_ID_82546GB_PCIE
:
1715 /* these don't support WoL at all */
1718 case E1000_DEV_ID_82546EB_FIBER
:
1719 case E1000_DEV_ID_82546GB_FIBER
:
1720 case E1000_DEV_ID_82571EB_FIBER
:
1721 case E1000_DEV_ID_82571EB_SERDES
:
1722 case E1000_DEV_ID_82571EB_COPPER
:
1723 /* Wake events not supported on port B */
1724 if (E1000_READ_REG(hw
, STATUS
) & E1000_STATUS_FUNC_1
) {
1728 /* return success for non excluded adapter ports */
1731 case E1000_DEV_ID_82571EB_QUAD_COPPER
:
1732 case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE
:
1733 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3
:
1734 /* quad port adapters only support WoL on port A */
1735 if (!adapter
->quad_port_a
) {
1739 /* return success for non excluded adapter ports */
1743 /* dual port cards only support WoL on port A from now on
1744 * unless it was enabled in the eeprom for port B
1745 * so exclude FUNC_1 ports from having WoL enabled */
1746 if (E1000_READ_REG(hw
, STATUS
) & E1000_STATUS_FUNC_1
&&
1747 !adapter
->eeprom_wol
) {
1759 e1000_get_wol(struct net_device
*netdev
, struct ethtool_wolinfo
*wol
)
1761 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
1763 wol
->supported
= WAKE_UCAST
| WAKE_MCAST
|
1764 WAKE_BCAST
| WAKE_MAGIC
;
1767 /* this function will set ->supported = 0 and return 1 if wol is not
1768 * supported by this hardware */
1769 if (e1000_wol_exclusion(adapter
, wol
))
1772 /* apply any specific unsupported masks here */
1773 switch (adapter
->hw
.device_id
) {
1774 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3
:
1775 /* KSP3 does not suppport UCAST wake-ups */
1776 wol
->supported
&= ~WAKE_UCAST
;
1778 if (adapter
->wol
& E1000_WUFC_EX
)
1779 DPRINTK(DRV
, ERR
, "Interface does not support "
1780 "directed (unicast) frame wake-up packets\n");
1786 if (adapter
->wol
& E1000_WUFC_EX
)
1787 wol
->wolopts
|= WAKE_UCAST
;
1788 if (adapter
->wol
& E1000_WUFC_MC
)
1789 wol
->wolopts
|= WAKE_MCAST
;
1790 if (adapter
->wol
& E1000_WUFC_BC
)
1791 wol
->wolopts
|= WAKE_BCAST
;
1792 if (adapter
->wol
& E1000_WUFC_MAG
)
1793 wol
->wolopts
|= WAKE_MAGIC
;
1799 e1000_set_wol(struct net_device
*netdev
, struct ethtool_wolinfo
*wol
)
1801 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
1802 struct e1000_hw
*hw
= &adapter
->hw
;
1804 if (wol
->wolopts
& (WAKE_PHY
| WAKE_ARP
| WAKE_MAGICSECURE
))
1807 if (e1000_wol_exclusion(adapter
, wol
))
1808 return wol
->wolopts
? -EOPNOTSUPP
: 0;
1810 switch (hw
->device_id
) {
1811 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3
:
1812 if (wol
->wolopts
& WAKE_UCAST
) {
1813 DPRINTK(DRV
, ERR
, "Interface does not support "
1814 "directed (unicast) frame wake-up packets\n");
1822 /* these settings will always override what we currently have */
1825 if (wol
->wolopts
& WAKE_UCAST
)
1826 adapter
->wol
|= E1000_WUFC_EX
;
1827 if (wol
->wolopts
& WAKE_MCAST
)
1828 adapter
->wol
|= E1000_WUFC_MC
;
1829 if (wol
->wolopts
& WAKE_BCAST
)
1830 adapter
->wol
|= E1000_WUFC_BC
;
1831 if (wol
->wolopts
& WAKE_MAGIC
)
1832 adapter
->wol
|= E1000_WUFC_MAG
;
1837 /* toggle LED 4 times per second = 2 "blinks" per second */
1838 #define E1000_ID_INTERVAL (HZ/4)
1840 /* bit defines for adapter->led_status */
1841 #define E1000_LED_ON 0
1844 e1000_led_blink_callback(unsigned long data
)
1846 struct e1000_adapter
*adapter
= (struct e1000_adapter
*) data
;
1848 if (test_and_change_bit(E1000_LED_ON
, &adapter
->led_status
))
1849 e1000_led_off(&adapter
->hw
);
1851 e1000_led_on(&adapter
->hw
);
1853 mod_timer(&adapter
->blink_timer
, jiffies
+ E1000_ID_INTERVAL
);
1857 e1000_phys_id(struct net_device
*netdev
, uint32_t data
)
1859 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
1861 if (!data
|| data
> (uint32_t)(MAX_SCHEDULE_TIMEOUT
/ HZ
))
1862 data
= (uint32_t)(MAX_SCHEDULE_TIMEOUT
/ HZ
);
1864 if (adapter
->hw
.mac_type
< e1000_82571
) {
1865 if (!adapter
->blink_timer
.function
) {
1866 init_timer(&adapter
->blink_timer
);
1867 adapter
->blink_timer
.function
= e1000_led_blink_callback
;
1868 adapter
->blink_timer
.data
= (unsigned long) adapter
;
1870 e1000_setup_led(&adapter
->hw
);
1871 mod_timer(&adapter
->blink_timer
, jiffies
);
1872 msleep_interruptible(data
* 1000);
1873 del_timer_sync(&adapter
->blink_timer
);
1874 } else if (adapter
->hw
.phy_type
== e1000_phy_ife
) {
1875 if (!adapter
->blink_timer
.function
) {
1876 init_timer(&adapter
->blink_timer
);
1877 adapter
->blink_timer
.function
= e1000_led_blink_callback
;
1878 adapter
->blink_timer
.data
= (unsigned long) adapter
;
1880 mod_timer(&adapter
->blink_timer
, jiffies
);
1881 msleep_interruptible(data
* 1000);
1882 del_timer_sync(&adapter
->blink_timer
);
1883 e1000_write_phy_reg(&(adapter
->hw
), IFE_PHY_SPECIAL_CONTROL_LED
, 0);
1885 e1000_blink_led_start(&adapter
->hw
);
1886 msleep_interruptible(data
* 1000);
1889 e1000_led_off(&adapter
->hw
);
1890 clear_bit(E1000_LED_ON
, &adapter
->led_status
);
1891 e1000_cleanup_led(&adapter
->hw
);
1897 e1000_nway_reset(struct net_device
*netdev
)
1899 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
1900 if (netif_running(netdev
))
1901 e1000_reinit_locked(adapter
);
1906 e1000_get_stats_count(struct net_device
*netdev
)
1908 return E1000_STATS_LEN
;
1912 e1000_get_ethtool_stats(struct net_device
*netdev
,
1913 struct ethtool_stats
*stats
, uint64_t *data
)
1915 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
1918 e1000_update_stats(adapter
);
1919 for (i
= 0; i
< E1000_GLOBAL_STATS_LEN
; i
++) {
1920 char *p
= (char *)adapter
+e1000_gstrings_stats
[i
].stat_offset
;
1921 data
[i
] = (e1000_gstrings_stats
[i
].sizeof_stat
==
1922 sizeof(uint64_t)) ? *(uint64_t *)p
: *(uint32_t *)p
;
1924 /* BUG_ON(i != E1000_STATS_LEN); */
1928 e1000_get_strings(struct net_device
*netdev
, uint32_t stringset
, uint8_t *data
)
1933 switch (stringset
) {
1935 memcpy(data
, *e1000_gstrings_test
,
1936 E1000_TEST_LEN
*ETH_GSTRING_LEN
);
1939 for (i
= 0; i
< E1000_GLOBAL_STATS_LEN
; i
++) {
1940 memcpy(p
, e1000_gstrings_stats
[i
].stat_string
,
1942 p
+= ETH_GSTRING_LEN
;
1944 /* BUG_ON(p - data != E1000_STATS_LEN * ETH_GSTRING_LEN); */
1949 static const struct ethtool_ops e1000_ethtool_ops
= {
1950 .get_settings
= e1000_get_settings
,
1951 .set_settings
= e1000_set_settings
,
1952 .get_drvinfo
= e1000_get_drvinfo
,
1953 .get_regs_len
= e1000_get_regs_len
,
1954 .get_regs
= e1000_get_regs
,
1955 .get_wol
= e1000_get_wol
,
1956 .set_wol
= e1000_set_wol
,
1957 .get_msglevel
= e1000_get_msglevel
,
1958 .set_msglevel
= e1000_set_msglevel
,
1959 .nway_reset
= e1000_nway_reset
,
1960 .get_link
= ethtool_op_get_link
,
1961 .get_eeprom_len
= e1000_get_eeprom_len
,
1962 .get_eeprom
= e1000_get_eeprom
,
1963 .set_eeprom
= e1000_set_eeprom
,
1964 .get_ringparam
= e1000_get_ringparam
,
1965 .set_ringparam
= e1000_set_ringparam
,
1966 .get_pauseparam
= e1000_get_pauseparam
,
1967 .set_pauseparam
= e1000_set_pauseparam
,
1968 .get_rx_csum
= e1000_get_rx_csum
,
1969 .set_rx_csum
= e1000_set_rx_csum
,
1970 .get_tx_csum
= e1000_get_tx_csum
,
1971 .set_tx_csum
= e1000_set_tx_csum
,
1972 .get_sg
= ethtool_op_get_sg
,
1973 .set_sg
= ethtool_op_set_sg
,
1975 .get_tso
= ethtool_op_get_tso
,
1976 .set_tso
= e1000_set_tso
,
1978 .self_test_count
= e1000_diag_test_count
,
1979 .self_test
= e1000_diag_test
,
1980 .get_strings
= e1000_get_strings
,
1981 .phys_id
= e1000_phys_id
,
1982 .get_stats_count
= e1000_get_stats_count
,
1983 .get_ethtool_stats
= e1000_get_ethtool_stats
,
1984 .get_perm_addr
= ethtool_op_get_perm_addr
,
1987 void e1000_set_ethtool_ops(struct net_device
*netdev
)
1989 SET_ETHTOOL_OPS(netdev
, &e1000_ethtool_ops
);