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 int e1000_up(struct e1000_adapter
*adapter
);
36 extern void e1000_down(struct e1000_adapter
*adapter
);
37 extern void e1000_reinit_locked(struct e1000_adapter
*adapter
);
38 extern void e1000_reset(struct e1000_adapter
*adapter
);
39 extern int e1000_set_spd_dplx(struct e1000_adapter
*adapter
, u16 spddplx
);
40 extern int e1000_setup_all_rx_resources(struct e1000_adapter
*adapter
);
41 extern int e1000_setup_all_tx_resources(struct e1000_adapter
*adapter
);
42 extern void e1000_free_all_rx_resources(struct e1000_adapter
*adapter
);
43 extern void e1000_free_all_tx_resources(struct e1000_adapter
*adapter
);
44 extern void e1000_update_stats(struct e1000_adapter
*adapter
);
48 char stat_string
[ETH_GSTRING_LEN
];
53 #define E1000_STAT(m) FIELD_SIZEOF(struct e1000_adapter, m), \
54 offsetof(struct e1000_adapter, m)
55 static const struct e1000_stats e1000_gstrings_stats
[] = {
56 { "rx_packets", E1000_STAT(stats
.gprc
) },
57 { "tx_packets", E1000_STAT(stats
.gptc
) },
58 { "rx_bytes", E1000_STAT(stats
.gorcl
) },
59 { "tx_bytes", E1000_STAT(stats
.gotcl
) },
60 { "rx_broadcast", E1000_STAT(stats
.bprc
) },
61 { "tx_broadcast", E1000_STAT(stats
.bptc
) },
62 { "rx_multicast", E1000_STAT(stats
.mprc
) },
63 { "tx_multicast", E1000_STAT(stats
.mptc
) },
64 { "rx_errors", E1000_STAT(stats
.rxerrc
) },
65 { "tx_errors", E1000_STAT(stats
.txerrc
) },
66 { "tx_dropped", E1000_STAT(net_stats
.tx_dropped
) },
67 { "multicast", E1000_STAT(stats
.mprc
) },
68 { "collisions", E1000_STAT(stats
.colc
) },
69 { "rx_length_errors", E1000_STAT(stats
.rlerrc
) },
70 { "rx_over_errors", E1000_STAT(net_stats
.rx_over_errors
) },
71 { "rx_crc_errors", E1000_STAT(stats
.crcerrs
) },
72 { "rx_frame_errors", E1000_STAT(net_stats
.rx_frame_errors
) },
73 { "rx_no_buffer_count", E1000_STAT(stats
.rnbc
) },
74 { "rx_missed_errors", E1000_STAT(stats
.mpc
) },
75 { "tx_aborted_errors", E1000_STAT(stats
.ecol
) },
76 { "tx_carrier_errors", E1000_STAT(stats
.tncrs
) },
77 { "tx_fifo_errors", E1000_STAT(net_stats
.tx_fifo_errors
) },
78 { "tx_heartbeat_errors", E1000_STAT(net_stats
.tx_heartbeat_errors
) },
79 { "tx_window_errors", E1000_STAT(stats
.latecol
) },
80 { "tx_abort_late_coll", E1000_STAT(stats
.latecol
) },
81 { "tx_deferred_ok", E1000_STAT(stats
.dc
) },
82 { "tx_single_coll_ok", E1000_STAT(stats
.scc
) },
83 { "tx_multi_coll_ok", E1000_STAT(stats
.mcc
) },
84 { "tx_timeout_count", E1000_STAT(tx_timeout_count
) },
85 { "tx_restart_queue", E1000_STAT(restart_queue
) },
86 { "rx_long_length_errors", E1000_STAT(stats
.roc
) },
87 { "rx_short_length_errors", E1000_STAT(stats
.ruc
) },
88 { "rx_align_errors", E1000_STAT(stats
.algnerrc
) },
89 { "tx_tcp_seg_good", E1000_STAT(stats
.tsctc
) },
90 { "tx_tcp_seg_failed", E1000_STAT(stats
.tsctfc
) },
91 { "rx_flow_control_xon", E1000_STAT(stats
.xonrxc
) },
92 { "rx_flow_control_xoff", E1000_STAT(stats
.xoffrxc
) },
93 { "tx_flow_control_xon", E1000_STAT(stats
.xontxc
) },
94 { "tx_flow_control_xoff", E1000_STAT(stats
.xofftxc
) },
95 { "rx_long_byte_count", E1000_STAT(stats
.gorcl
) },
96 { "rx_csum_offload_good", E1000_STAT(hw_csum_good
) },
97 { "rx_csum_offload_errors", E1000_STAT(hw_csum_err
) },
98 { "rx_header_split", E1000_STAT(rx_hdr_split
) },
99 { "alloc_rx_buff_failed", E1000_STAT(alloc_rx_buff_failed
) },
100 { "tx_smbus", E1000_STAT(stats
.mgptc
) },
101 { "rx_smbus", E1000_STAT(stats
.mgprc
) },
102 { "dropped_smbus", E1000_STAT(stats
.mgpdc
) },
105 #define E1000_QUEUE_STATS_LEN 0
106 #define E1000_GLOBAL_STATS_LEN ARRAY_SIZE(e1000_gstrings_stats)
107 #define E1000_STATS_LEN (E1000_GLOBAL_STATS_LEN + E1000_QUEUE_STATS_LEN)
108 static const char e1000_gstrings_test
[][ETH_GSTRING_LEN
] = {
109 "Register test (offline)", "Eeprom test (offline)",
110 "Interrupt test (offline)", "Loopback test (offline)",
111 "Link test (on/offline)"
113 #define E1000_TEST_LEN ARRAY_SIZE(e1000_gstrings_test)
115 static int e1000_get_settings(struct net_device
*netdev
,
116 struct ethtool_cmd
*ecmd
)
118 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
119 struct e1000_hw
*hw
= &adapter
->hw
;
121 if (hw
->media_type
== e1000_media_type_copper
) {
123 ecmd
->supported
= (SUPPORTED_10baseT_Half
|
124 SUPPORTED_10baseT_Full
|
125 SUPPORTED_100baseT_Half
|
126 SUPPORTED_100baseT_Full
|
127 SUPPORTED_1000baseT_Full
|
130 if (hw
->phy_type
== e1000_phy_ife
)
131 ecmd
->supported
&= ~SUPPORTED_1000baseT_Full
;
132 ecmd
->advertising
= ADVERTISED_TP
;
134 if (hw
->autoneg
== 1) {
135 ecmd
->advertising
|= ADVERTISED_Autoneg
;
136 /* the e1000 autoneg seems to match ethtool nicely */
137 ecmd
->advertising
|= hw
->autoneg_advertised
;
140 ecmd
->port
= PORT_TP
;
141 ecmd
->phy_address
= hw
->phy_addr
;
143 if (hw
->mac_type
== e1000_82543
)
144 ecmd
->transceiver
= XCVR_EXTERNAL
;
146 ecmd
->transceiver
= XCVR_INTERNAL
;
149 ecmd
->supported
= (SUPPORTED_1000baseT_Full
|
153 ecmd
->advertising
= (ADVERTISED_1000baseT_Full
|
157 ecmd
->port
= PORT_FIBRE
;
159 if (hw
->mac_type
>= e1000_82545
)
160 ecmd
->transceiver
= XCVR_INTERNAL
;
162 ecmd
->transceiver
= XCVR_EXTERNAL
;
165 if (E1000_READ_REG(&adapter
->hw
, STATUS
) & E1000_STATUS_LU
) {
167 e1000_get_speed_and_duplex(hw
, &adapter
->link_speed
,
168 &adapter
->link_duplex
);
169 ecmd
->speed
= adapter
->link_speed
;
171 /* unfortunatly FULL_DUPLEX != DUPLEX_FULL
172 * and HALF_DUPLEX != DUPLEX_HALF */
174 if (adapter
->link_duplex
== FULL_DUPLEX
)
175 ecmd
->duplex
= DUPLEX_FULL
;
177 ecmd
->duplex
= DUPLEX_HALF
;
183 ecmd
->autoneg
= ((hw
->media_type
== e1000_media_type_fiber
) ||
184 hw
->autoneg
) ? AUTONEG_ENABLE
: AUTONEG_DISABLE
;
188 static int e1000_set_settings(struct net_device
*netdev
,
189 struct ethtool_cmd
*ecmd
)
191 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
192 struct e1000_hw
*hw
= &adapter
->hw
;
194 /* When SoL/IDER sessions are active, autoneg/speed/duplex
195 * cannot be changed */
196 if (e1000_check_phy_reset_block(hw
)) {
197 DPRINTK(DRV
, ERR
, "Cannot change link characteristics "
198 "when SoL/IDER is active.\n");
202 while (test_and_set_bit(__E1000_RESETTING
, &adapter
->flags
))
205 if (ecmd
->autoneg
== AUTONEG_ENABLE
) {
207 if (hw
->media_type
== e1000_media_type_fiber
)
208 hw
->autoneg_advertised
= ADVERTISED_1000baseT_Full
|
212 hw
->autoneg_advertised
= ecmd
->advertising
|
215 ecmd
->advertising
= hw
->autoneg_advertised
;
217 if (e1000_set_spd_dplx(adapter
, ecmd
->speed
+ ecmd
->duplex
)) {
218 clear_bit(__E1000_RESETTING
, &adapter
->flags
);
224 if (netif_running(adapter
->netdev
)) {
228 e1000_reset(adapter
);
230 clear_bit(__E1000_RESETTING
, &adapter
->flags
);
234 static void e1000_get_pauseparam(struct net_device
*netdev
,
235 struct ethtool_pauseparam
*pause
)
237 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
238 struct e1000_hw
*hw
= &adapter
->hw
;
241 (adapter
->fc_autoneg
? AUTONEG_ENABLE
: AUTONEG_DISABLE
);
243 if (hw
->fc
== E1000_FC_RX_PAUSE
)
245 else if (hw
->fc
== E1000_FC_TX_PAUSE
)
247 else if (hw
->fc
== E1000_FC_FULL
) {
253 static int e1000_set_pauseparam(struct net_device
*netdev
,
254 struct ethtool_pauseparam
*pause
)
256 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
257 struct e1000_hw
*hw
= &adapter
->hw
;
260 adapter
->fc_autoneg
= pause
->autoneg
;
262 while (test_and_set_bit(__E1000_RESETTING
, &adapter
->flags
))
265 if (pause
->rx_pause
&& pause
->tx_pause
)
266 hw
->fc
= E1000_FC_FULL
;
267 else if (pause
->rx_pause
&& !pause
->tx_pause
)
268 hw
->fc
= E1000_FC_RX_PAUSE
;
269 else if (!pause
->rx_pause
&& pause
->tx_pause
)
270 hw
->fc
= E1000_FC_TX_PAUSE
;
271 else if (!pause
->rx_pause
&& !pause
->tx_pause
)
272 hw
->fc
= E1000_FC_NONE
;
274 hw
->original_fc
= hw
->fc
;
276 if (adapter
->fc_autoneg
== AUTONEG_ENABLE
) {
277 if (netif_running(adapter
->netdev
)) {
281 e1000_reset(adapter
);
283 retval
= ((hw
->media_type
== e1000_media_type_fiber
) ?
284 e1000_setup_link(hw
) : e1000_force_mac_fc(hw
));
286 clear_bit(__E1000_RESETTING
, &adapter
->flags
);
290 static u32
e1000_get_rx_csum(struct net_device
*netdev
)
292 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
293 return adapter
->rx_csum
;
296 static int e1000_set_rx_csum(struct net_device
*netdev
, u32 data
)
298 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
299 adapter
->rx_csum
= data
;
301 if (netif_running(netdev
))
302 e1000_reinit_locked(adapter
);
304 e1000_reset(adapter
);
308 static u32
e1000_get_tx_csum(struct net_device
*netdev
)
310 return (netdev
->features
& NETIF_F_HW_CSUM
) != 0;
313 static int e1000_set_tx_csum(struct net_device
*netdev
, u32 data
)
315 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
317 if (adapter
->hw
.mac_type
< e1000_82543
) {
324 netdev
->features
|= NETIF_F_HW_CSUM
;
326 netdev
->features
&= ~NETIF_F_HW_CSUM
;
331 static int e1000_set_tso(struct net_device
*netdev
, u32 data
)
333 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
334 if ((adapter
->hw
.mac_type
< e1000_82544
) ||
335 (adapter
->hw
.mac_type
== e1000_82547
))
336 return data
? -EINVAL
: 0;
339 netdev
->features
|= NETIF_F_TSO
;
341 netdev
->features
&= ~NETIF_F_TSO
;
343 if (data
&& (adapter
->hw
.mac_type
> e1000_82547_rev_2
))
344 netdev
->features
|= NETIF_F_TSO6
;
346 netdev
->features
&= ~NETIF_F_TSO6
;
348 DPRINTK(PROBE
, INFO
, "TSO is %s\n", data
? "Enabled" : "Disabled");
349 adapter
->tso_force
= true;
353 static u32
e1000_get_msglevel(struct net_device
*netdev
)
355 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
356 return adapter
->msg_enable
;
359 static void e1000_set_msglevel(struct net_device
*netdev
, u32 data
)
361 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
362 adapter
->msg_enable
= data
;
365 static int e1000_get_regs_len(struct net_device
*netdev
)
367 #define E1000_REGS_LEN 32
368 return E1000_REGS_LEN
* sizeof(u32
);
371 static void e1000_get_regs(struct net_device
*netdev
, struct ethtool_regs
*regs
,
374 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
375 struct e1000_hw
*hw
= &adapter
->hw
;
379 memset(p
, 0, E1000_REGS_LEN
* sizeof(u32
));
381 regs
->version
= (1 << 24) | (hw
->revision_id
<< 16) | hw
->device_id
;
383 regs_buff
[0] = E1000_READ_REG(hw
, CTRL
);
384 regs_buff
[1] = E1000_READ_REG(hw
, STATUS
);
386 regs_buff
[2] = E1000_READ_REG(hw
, RCTL
);
387 regs_buff
[3] = E1000_READ_REG(hw
, RDLEN
);
388 regs_buff
[4] = E1000_READ_REG(hw
, RDH
);
389 regs_buff
[5] = E1000_READ_REG(hw
, RDT
);
390 regs_buff
[6] = E1000_READ_REG(hw
, RDTR
);
392 regs_buff
[7] = E1000_READ_REG(hw
, TCTL
);
393 regs_buff
[8] = E1000_READ_REG(hw
, TDLEN
);
394 regs_buff
[9] = E1000_READ_REG(hw
, TDH
);
395 regs_buff
[10] = E1000_READ_REG(hw
, TDT
);
396 regs_buff
[11] = E1000_READ_REG(hw
, TIDV
);
398 regs_buff
[12] = adapter
->hw
.phy_type
; /* PHY type (IGP=1, M88=0) */
399 if (hw
->phy_type
== e1000_phy_igp
) {
400 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PAGE_SELECT
,
401 IGP01E1000_PHY_AGC_A
);
402 e1000_read_phy_reg(hw
, IGP01E1000_PHY_AGC_A
&
403 IGP01E1000_PHY_PAGE_SELECT
, &phy_data
);
404 regs_buff
[13] = (u32
)phy_data
; /* cable length */
405 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PAGE_SELECT
,
406 IGP01E1000_PHY_AGC_B
);
407 e1000_read_phy_reg(hw
, IGP01E1000_PHY_AGC_B
&
408 IGP01E1000_PHY_PAGE_SELECT
, &phy_data
);
409 regs_buff
[14] = (u32
)phy_data
; /* cable length */
410 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PAGE_SELECT
,
411 IGP01E1000_PHY_AGC_C
);
412 e1000_read_phy_reg(hw
, IGP01E1000_PHY_AGC_C
&
413 IGP01E1000_PHY_PAGE_SELECT
, &phy_data
);
414 regs_buff
[15] = (u32
)phy_data
; /* cable length */
415 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PAGE_SELECT
,
416 IGP01E1000_PHY_AGC_D
);
417 e1000_read_phy_reg(hw
, IGP01E1000_PHY_AGC_D
&
418 IGP01E1000_PHY_PAGE_SELECT
, &phy_data
);
419 regs_buff
[16] = (u32
)phy_data
; /* cable length */
420 regs_buff
[17] = 0; /* extended 10bt distance (not needed) */
421 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PAGE_SELECT
, 0x0);
422 e1000_read_phy_reg(hw
, IGP01E1000_PHY_PORT_STATUS
&
423 IGP01E1000_PHY_PAGE_SELECT
, &phy_data
);
424 regs_buff
[18] = (u32
)phy_data
; /* cable polarity */
425 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PAGE_SELECT
,
426 IGP01E1000_PHY_PCS_INIT_REG
);
427 e1000_read_phy_reg(hw
, IGP01E1000_PHY_PCS_INIT_REG
&
428 IGP01E1000_PHY_PAGE_SELECT
, &phy_data
);
429 regs_buff
[19] = (u32
)phy_data
; /* cable polarity */
430 regs_buff
[20] = 0; /* polarity correction enabled (always) */
431 regs_buff
[22] = 0; /* phy receive errors (unavailable) */
432 regs_buff
[23] = regs_buff
[18]; /* mdix mode */
433 e1000_write_phy_reg(hw
, IGP01E1000_PHY_PAGE_SELECT
, 0x0);
435 e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_STATUS
, &phy_data
);
436 regs_buff
[13] = (u32
)phy_data
; /* cable length */
437 regs_buff
[14] = 0; /* Dummy (to align w/ IGP phy reg dump) */
438 regs_buff
[15] = 0; /* Dummy (to align w/ IGP phy reg dump) */
439 regs_buff
[16] = 0; /* Dummy (to align w/ IGP phy reg dump) */
440 e1000_read_phy_reg(hw
, M88E1000_PHY_SPEC_CTRL
, &phy_data
);
441 regs_buff
[17] = (u32
)phy_data
; /* extended 10bt distance */
442 regs_buff
[18] = regs_buff
[13]; /* cable polarity */
443 regs_buff
[19] = 0; /* Dummy (to align w/ IGP phy reg dump) */
444 regs_buff
[20] = regs_buff
[17]; /* polarity correction */
445 /* phy receive errors */
446 regs_buff
[22] = adapter
->phy_stats
.receive_errors
;
447 regs_buff
[23] = regs_buff
[13]; /* mdix mode */
449 regs_buff
[21] = adapter
->phy_stats
.idle_errors
; /* phy idle errors */
450 e1000_read_phy_reg(hw
, PHY_1000T_STATUS
, &phy_data
);
451 regs_buff
[24] = (u32
)phy_data
; /* phy local receiver status */
452 regs_buff
[25] = regs_buff
[24]; /* phy remote receiver status */
453 if (hw
->mac_type
>= e1000_82540
&&
454 hw
->mac_type
< e1000_82571
&&
455 hw
->media_type
== e1000_media_type_copper
) {
456 regs_buff
[26] = E1000_READ_REG(hw
, MANC
);
460 static int e1000_get_eeprom_len(struct net_device
*netdev
)
462 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
463 return adapter
->hw
.eeprom
.word_size
* 2;
466 static int e1000_get_eeprom(struct net_device
*netdev
,
467 struct ethtool_eeprom
*eeprom
, u8
*bytes
)
469 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
470 struct e1000_hw
*hw
= &adapter
->hw
;
472 int first_word
, last_word
;
476 if (eeprom
->len
== 0)
479 eeprom
->magic
= hw
->vendor_id
| (hw
->device_id
<< 16);
481 first_word
= eeprom
->offset
>> 1;
482 last_word
= (eeprom
->offset
+ eeprom
->len
- 1) >> 1;
484 eeprom_buff
= kmalloc(sizeof(u16
) *
485 (last_word
- first_word
+ 1), GFP_KERNEL
);
489 if (hw
->eeprom
.type
== e1000_eeprom_spi
)
490 ret_val
= e1000_read_eeprom(hw
, first_word
,
491 last_word
- first_word
+ 1,
494 for (i
= 0; i
< last_word
- first_word
+ 1; i
++)
495 if ((ret_val
= e1000_read_eeprom(hw
, first_word
+ i
, 1,
500 /* Device's eeprom is always little-endian, word addressable */
501 for (i
= 0; i
< last_word
- first_word
+ 1; i
++)
502 le16_to_cpus(&eeprom_buff
[i
]);
504 memcpy(bytes
, (u8
*)eeprom_buff
+ (eeprom
->offset
& 1),
511 static int e1000_set_eeprom(struct net_device
*netdev
,
512 struct ethtool_eeprom
*eeprom
, u8
*bytes
)
514 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
515 struct e1000_hw
*hw
= &adapter
->hw
;
518 int max_len
, first_word
, last_word
, ret_val
= 0;
521 if (eeprom
->len
== 0)
524 if (eeprom
->magic
!= (hw
->vendor_id
| (hw
->device_id
<< 16)))
527 max_len
= hw
->eeprom
.word_size
* 2;
529 first_word
= eeprom
->offset
>> 1;
530 last_word
= (eeprom
->offset
+ eeprom
->len
- 1) >> 1;
531 eeprom_buff
= kmalloc(max_len
, GFP_KERNEL
);
535 ptr
= (void *)eeprom_buff
;
537 if (eeprom
->offset
& 1) {
538 /* need read/modify/write of first changed EEPROM word */
539 /* only the second byte of the word is being modified */
540 ret_val
= e1000_read_eeprom(hw
, first_word
, 1,
544 if (((eeprom
->offset
+ eeprom
->len
) & 1) && (ret_val
== 0)) {
545 /* need read/modify/write of last changed EEPROM word */
546 /* only the first byte of the word is being modified */
547 ret_val
= e1000_read_eeprom(hw
, last_word
, 1,
548 &eeprom_buff
[last_word
- first_word
]);
551 /* Device's eeprom is always little-endian, word addressable */
552 for (i
= 0; i
< last_word
- first_word
+ 1; i
++)
553 le16_to_cpus(&eeprom_buff
[i
]);
555 memcpy(ptr
, bytes
, eeprom
->len
);
557 for (i
= 0; i
< last_word
- first_word
+ 1; i
++)
558 eeprom_buff
[i
] = cpu_to_le16(eeprom_buff
[i
]);
560 ret_val
= e1000_write_eeprom(hw
, first_word
,
561 last_word
- first_word
+ 1, eeprom_buff
);
563 /* Update the checksum over the first part of the EEPROM if needed
564 * and flush shadow RAM for 82573 conrollers */
565 if ((ret_val
== 0) && ((first_word
<= EEPROM_CHECKSUM_REG
) ||
566 (hw
->mac_type
== e1000_82573
)))
567 e1000_update_eeprom_checksum(hw
);
573 static void e1000_get_drvinfo(struct net_device
*netdev
,
574 struct ethtool_drvinfo
*drvinfo
)
576 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
577 char firmware_version
[32];
580 strncpy(drvinfo
->driver
, e1000_driver_name
, 32);
581 strncpy(drvinfo
->version
, e1000_driver_version
, 32);
583 /* EEPROM image version # is reported as firmware version # for
584 * 8257{1|2|3} controllers */
585 e1000_read_eeprom(&adapter
->hw
, 5, 1, &eeprom_data
);
586 switch (adapter
->hw
.mac_type
) {
590 case e1000_80003es2lan
:
592 sprintf(firmware_version
, "%d.%d-%d",
593 (eeprom_data
& 0xF000) >> 12,
594 (eeprom_data
& 0x0FF0) >> 4,
595 eeprom_data
& 0x000F);
598 sprintf(firmware_version
, "N/A");
601 strncpy(drvinfo
->fw_version
, firmware_version
, 32);
602 strncpy(drvinfo
->bus_info
, pci_name(adapter
->pdev
), 32);
603 drvinfo
->regdump_len
= e1000_get_regs_len(netdev
);
604 drvinfo
->eedump_len
= e1000_get_eeprom_len(netdev
);
607 static void e1000_get_ringparam(struct net_device
*netdev
,
608 struct ethtool_ringparam
*ring
)
610 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
611 e1000_mac_type mac_type
= adapter
->hw
.mac_type
;
612 struct e1000_tx_ring
*txdr
= adapter
->tx_ring
;
613 struct e1000_rx_ring
*rxdr
= adapter
->rx_ring
;
615 ring
->rx_max_pending
= (mac_type
< e1000_82544
) ? E1000_MAX_RXD
:
617 ring
->tx_max_pending
= (mac_type
< e1000_82544
) ? E1000_MAX_TXD
:
619 ring
->rx_mini_max_pending
= 0;
620 ring
->rx_jumbo_max_pending
= 0;
621 ring
->rx_pending
= rxdr
->count
;
622 ring
->tx_pending
= txdr
->count
;
623 ring
->rx_mini_pending
= 0;
624 ring
->rx_jumbo_pending
= 0;
627 static int e1000_set_ringparam(struct net_device
*netdev
,
628 struct ethtool_ringparam
*ring
)
630 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
631 e1000_mac_type mac_type
= adapter
->hw
.mac_type
;
632 struct e1000_tx_ring
*txdr
, *tx_old
;
633 struct e1000_rx_ring
*rxdr
, *rx_old
;
636 if ((ring
->rx_mini_pending
) || (ring
->rx_jumbo_pending
))
639 while (test_and_set_bit(__E1000_RESETTING
, &adapter
->flags
))
642 if (netif_running(adapter
->netdev
))
645 tx_old
= adapter
->tx_ring
;
646 rx_old
= adapter
->rx_ring
;
649 txdr
= kcalloc(adapter
->num_tx_queues
, sizeof(struct e1000_tx_ring
), GFP_KERNEL
);
653 rxdr
= kcalloc(adapter
->num_rx_queues
, sizeof(struct e1000_rx_ring
), GFP_KERNEL
);
657 adapter
->tx_ring
= txdr
;
658 adapter
->rx_ring
= rxdr
;
660 rxdr
->count
= max(ring
->rx_pending
,(u32
)E1000_MIN_RXD
);
661 rxdr
->count
= min(rxdr
->count
,(u32
)(mac_type
< e1000_82544
?
662 E1000_MAX_RXD
: E1000_MAX_82544_RXD
));
663 rxdr
->count
= ALIGN(rxdr
->count
, REQ_RX_DESCRIPTOR_MULTIPLE
);
665 txdr
->count
= max(ring
->tx_pending
,(u32
)E1000_MIN_TXD
);
666 txdr
->count
= min(txdr
->count
,(u32
)(mac_type
< e1000_82544
?
667 E1000_MAX_TXD
: E1000_MAX_82544_TXD
));
668 txdr
->count
= ALIGN(txdr
->count
, REQ_TX_DESCRIPTOR_MULTIPLE
);
670 for (i
= 0; i
< adapter
->num_tx_queues
; i
++)
671 txdr
[i
].count
= txdr
->count
;
672 for (i
= 0; i
< adapter
->num_rx_queues
; i
++)
673 rxdr
[i
].count
= rxdr
->count
;
675 if (netif_running(adapter
->netdev
)) {
676 /* Try to get new resources before deleting old */
677 if ((err
= e1000_setup_all_rx_resources(adapter
)))
679 if ((err
= e1000_setup_all_tx_resources(adapter
)))
682 /* save the new, restore the old in order to free it,
683 * then restore the new back again */
685 adapter
->rx_ring
= rx_old
;
686 adapter
->tx_ring
= tx_old
;
687 e1000_free_all_rx_resources(adapter
);
688 e1000_free_all_tx_resources(adapter
);
691 adapter
->rx_ring
= rxdr
;
692 adapter
->tx_ring
= txdr
;
693 if ((err
= e1000_up(adapter
)))
697 clear_bit(__E1000_RESETTING
, &adapter
->flags
);
700 e1000_free_all_rx_resources(adapter
);
702 adapter
->rx_ring
= rx_old
;
703 adapter
->tx_ring
= tx_old
;
710 clear_bit(__E1000_RESETTING
, &adapter
->flags
);
714 static bool reg_pattern_test(struct e1000_adapter
*adapter
, u64
*data
, int reg
,
717 static const u32 test
[] =
718 {0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
719 u8 __iomem
*address
= adapter
->hw
.hw_addr
+ reg
;
723 for (i
= 0; i
< ARRAY_SIZE(test
); i
++) {
724 writel(write
& test
[i
], address
);
725 read
= readl(address
);
726 if (read
!= (write
& test
[i
] & mask
)) {
727 DPRINTK(DRV
, ERR
, "pattern test reg %04X failed: "
728 "got 0x%08X expected 0x%08X\n",
729 reg
, read
, (write
& test
[i
] & mask
));
737 static bool reg_set_and_check(struct e1000_adapter
*adapter
, u64
*data
, int reg
,
740 u8 __iomem
*address
= adapter
->hw
.hw_addr
+ reg
;
743 writel(write
& mask
, address
);
744 read
= readl(address
);
745 if ((read
& mask
) != (write
& mask
)) {
746 DPRINTK(DRV
, ERR
, "set/check reg %04X test failed: "
747 "got 0x%08X expected 0x%08X\n",
748 reg
, (read
& mask
), (write
& mask
));
755 #define REG_PATTERN_TEST(reg, mask, write) \
757 if (reg_pattern_test(adapter, data, \
758 (adapter->hw.mac_type >= e1000_82543) \
759 ? E1000_##reg : E1000_82542_##reg, \
764 #define REG_SET_AND_CHECK(reg, mask, write) \
766 if (reg_set_and_check(adapter, data, \
767 (adapter->hw.mac_type >= e1000_82543) \
768 ? E1000_##reg : E1000_82542_##reg, \
773 static int e1000_reg_test(struct e1000_adapter
*adapter
, u64
*data
)
775 u32 value
, before
, after
;
778 /* The status register is Read Only, so a write should fail.
779 * Some bits that get toggled are ignored.
781 switch (adapter
->hw
.mac_type
) {
782 /* there are several bits on newer hardware that are r/w */
785 case e1000_80003es2lan
:
797 before
= E1000_READ_REG(&adapter
->hw
, STATUS
);
798 value
= (E1000_READ_REG(&adapter
->hw
, STATUS
) & toggle
);
799 E1000_WRITE_REG(&adapter
->hw
, STATUS
, toggle
);
800 after
= E1000_READ_REG(&adapter
->hw
, STATUS
) & toggle
;
801 if (value
!= after
) {
802 DPRINTK(DRV
, ERR
, "failed STATUS register test got: "
803 "0x%08X expected: 0x%08X\n", after
, value
);
807 /* restore previous status */
808 E1000_WRITE_REG(&adapter
->hw
, STATUS
, before
);
810 if (adapter
->hw
.mac_type
!= e1000_ich8lan
) {
811 REG_PATTERN_TEST(FCAL
, 0xFFFFFFFF, 0xFFFFFFFF);
812 REG_PATTERN_TEST(FCAH
, 0x0000FFFF, 0xFFFFFFFF);
813 REG_PATTERN_TEST(FCT
, 0x0000FFFF, 0xFFFFFFFF);
814 REG_PATTERN_TEST(VET
, 0x0000FFFF, 0xFFFFFFFF);
817 REG_PATTERN_TEST(RDTR
, 0x0000FFFF, 0xFFFFFFFF);
818 REG_PATTERN_TEST(RDBAH
, 0xFFFFFFFF, 0xFFFFFFFF);
819 REG_PATTERN_TEST(RDLEN
, 0x000FFF80, 0x000FFFFF);
820 REG_PATTERN_TEST(RDH
, 0x0000FFFF, 0x0000FFFF);
821 REG_PATTERN_TEST(RDT
, 0x0000FFFF, 0x0000FFFF);
822 REG_PATTERN_TEST(FCRTH
, 0x0000FFF8, 0x0000FFF8);
823 REG_PATTERN_TEST(FCTTV
, 0x0000FFFF, 0x0000FFFF);
824 REG_PATTERN_TEST(TIPG
, 0x3FFFFFFF, 0x3FFFFFFF);
825 REG_PATTERN_TEST(TDBAH
, 0xFFFFFFFF, 0xFFFFFFFF);
826 REG_PATTERN_TEST(TDLEN
, 0x000FFF80, 0x000FFFFF);
828 REG_SET_AND_CHECK(RCTL
, 0xFFFFFFFF, 0x00000000);
830 before
= (adapter
->hw
.mac_type
== e1000_ich8lan
?
831 0x06C3B33E : 0x06DFB3FE);
832 REG_SET_AND_CHECK(RCTL
, before
, 0x003FFFFB);
833 REG_SET_AND_CHECK(TCTL
, 0xFFFFFFFF, 0x00000000);
835 if (adapter
->hw
.mac_type
>= e1000_82543
) {
837 REG_SET_AND_CHECK(RCTL
, before
, 0xFFFFFFFF);
838 REG_PATTERN_TEST(RDBAL
, 0xFFFFFFF0, 0xFFFFFFFF);
839 if (adapter
->hw
.mac_type
!= e1000_ich8lan
)
840 REG_PATTERN_TEST(TXCW
, 0xC000FFFF, 0x0000FFFF);
841 REG_PATTERN_TEST(TDBAL
, 0xFFFFFFF0, 0xFFFFFFFF);
842 REG_PATTERN_TEST(TIDV
, 0x0000FFFF, 0x0000FFFF);
843 value
= (adapter
->hw
.mac_type
== e1000_ich8lan
?
844 E1000_RAR_ENTRIES_ICH8LAN
: E1000_RAR_ENTRIES
);
845 for (i
= 0; i
< value
; i
++) {
846 REG_PATTERN_TEST(RA
+ (((i
<< 1) + 1) << 2), 0x8003FFFF,
852 REG_SET_AND_CHECK(RCTL
, 0xFFFFFFFF, 0x01FFFFFF);
853 REG_PATTERN_TEST(RDBAL
, 0xFFFFF000, 0xFFFFFFFF);
854 REG_PATTERN_TEST(TXCW
, 0x0000FFFF, 0x0000FFFF);
855 REG_PATTERN_TEST(TDBAL
, 0xFFFFF000, 0xFFFFFFFF);
859 value
= (adapter
->hw
.mac_type
== e1000_ich8lan
?
860 E1000_MC_TBL_SIZE_ICH8LAN
: E1000_MC_TBL_SIZE
);
861 for (i
= 0; i
< value
; i
++)
862 REG_PATTERN_TEST(MTA
+ (i
<< 2), 0xFFFFFFFF, 0xFFFFFFFF);
868 static int e1000_eeprom_test(struct e1000_adapter
*adapter
, u64
*data
)
875 /* Read and add up the contents of the EEPROM */
876 for (i
= 0; i
< (EEPROM_CHECKSUM_REG
+ 1); i
++) {
877 if ((e1000_read_eeprom(&adapter
->hw
, i
, 1, &temp
)) < 0) {
884 /* If Checksum is not Correct return error else test passed */
885 if ((checksum
!= (u16
) EEPROM_SUM
) && !(*data
))
891 static irqreturn_t
e1000_test_intr(int irq
, void *data
)
893 struct net_device
*netdev
= (struct net_device
*) data
;
894 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
896 adapter
->test_icr
|= E1000_READ_REG(&adapter
->hw
, ICR
);
901 static int e1000_intr_test(struct e1000_adapter
*adapter
, u64
*data
)
903 struct net_device
*netdev
= adapter
->netdev
;
905 bool shared_int
= true;
906 u32 irq
= adapter
->pdev
->irq
;
910 /* NOTE: we don't test MSI interrupts here, yet */
911 /* Hook up test interrupt handler just for this test */
912 if (!request_irq(irq
, &e1000_test_intr
, IRQF_PROBE_SHARED
, netdev
->name
,
915 else if (request_irq(irq
, &e1000_test_intr
, IRQF_SHARED
,
916 netdev
->name
, netdev
)) {
920 DPRINTK(HW
, INFO
, "testing %s interrupt\n",
921 (shared_int
? "shared" : "unshared"));
923 /* Disable all the interrupts */
924 E1000_WRITE_REG(&adapter
->hw
, IMC
, 0xFFFFFFFF);
927 /* Test each interrupt */
928 for (; i
< 10; i
++) {
930 if (adapter
->hw
.mac_type
== e1000_ich8lan
&& i
== 8)
933 /* Interrupt to test */
937 /* Disable the interrupt to be reported in
938 * the cause register and then force the same
939 * interrupt and see if one gets posted. If
940 * an interrupt was posted to the bus, the
943 adapter
->test_icr
= 0;
944 E1000_WRITE_REG(&adapter
->hw
, IMC
, mask
);
945 E1000_WRITE_REG(&adapter
->hw
, ICS
, mask
);
948 if (adapter
->test_icr
& mask
) {
954 /* Enable the interrupt to be reported in
955 * the cause register and then force the same
956 * interrupt and see if one gets posted. If
957 * an interrupt was not posted to the bus, the
960 adapter
->test_icr
= 0;
961 E1000_WRITE_REG(&adapter
->hw
, IMS
, mask
);
962 E1000_WRITE_REG(&adapter
->hw
, ICS
, mask
);
965 if (!(adapter
->test_icr
& mask
)) {
971 /* Disable the other interrupts to be reported in
972 * the cause register and then force the other
973 * interrupts and see if any get posted. If
974 * an interrupt was posted to the bus, the
977 adapter
->test_icr
= 0;
978 E1000_WRITE_REG(&adapter
->hw
, IMC
, ~mask
& 0x00007FFF);
979 E1000_WRITE_REG(&adapter
->hw
, ICS
, ~mask
& 0x00007FFF);
982 if (adapter
->test_icr
) {
989 /* Disable all the interrupts */
990 E1000_WRITE_REG(&adapter
->hw
, IMC
, 0xFFFFFFFF);
993 /* Unhook test interrupt handler */
994 free_irq(irq
, netdev
);
999 static void e1000_free_desc_rings(struct e1000_adapter
*adapter
)
1001 struct e1000_tx_ring
*txdr
= &adapter
->test_tx_ring
;
1002 struct e1000_rx_ring
*rxdr
= &adapter
->test_rx_ring
;
1003 struct pci_dev
*pdev
= adapter
->pdev
;
1006 if (txdr
->desc
&& txdr
->buffer_info
) {
1007 for (i
= 0; i
< txdr
->count
; i
++) {
1008 if (txdr
->buffer_info
[i
].dma
)
1009 pci_unmap_single(pdev
, txdr
->buffer_info
[i
].dma
,
1010 txdr
->buffer_info
[i
].length
,
1012 if (txdr
->buffer_info
[i
].skb
)
1013 dev_kfree_skb(txdr
->buffer_info
[i
].skb
);
1017 if (rxdr
->desc
&& rxdr
->buffer_info
) {
1018 for (i
= 0; i
< rxdr
->count
; i
++) {
1019 if (rxdr
->buffer_info
[i
].dma
)
1020 pci_unmap_single(pdev
, rxdr
->buffer_info
[i
].dma
,
1021 rxdr
->buffer_info
[i
].length
,
1022 PCI_DMA_FROMDEVICE
);
1023 if (rxdr
->buffer_info
[i
].skb
)
1024 dev_kfree_skb(rxdr
->buffer_info
[i
].skb
);
1029 pci_free_consistent(pdev
, txdr
->size
, txdr
->desc
, txdr
->dma
);
1033 pci_free_consistent(pdev
, rxdr
->size
, rxdr
->desc
, rxdr
->dma
);
1037 kfree(txdr
->buffer_info
);
1038 txdr
->buffer_info
= NULL
;
1039 kfree(rxdr
->buffer_info
);
1040 rxdr
->buffer_info
= NULL
;
1045 static int e1000_setup_desc_rings(struct e1000_adapter
*adapter
)
1047 struct e1000_tx_ring
*txdr
= &adapter
->test_tx_ring
;
1048 struct e1000_rx_ring
*rxdr
= &adapter
->test_rx_ring
;
1049 struct pci_dev
*pdev
= adapter
->pdev
;
1053 /* Setup Tx descriptor ring and Tx buffers */
1056 txdr
->count
= E1000_DEFAULT_TXD
;
1058 if (!(txdr
->buffer_info
= kcalloc(txdr
->count
,
1059 sizeof(struct e1000_buffer
),
1065 txdr
->size
= txdr
->count
* sizeof(struct e1000_tx_desc
);
1066 txdr
->size
= ALIGN(txdr
->size
, 4096);
1067 if (!(txdr
->desc
= pci_alloc_consistent(pdev
, txdr
->size
,
1072 memset(txdr
->desc
, 0, txdr
->size
);
1073 txdr
->next_to_use
= txdr
->next_to_clean
= 0;
1075 E1000_WRITE_REG(&adapter
->hw
, TDBAL
,
1076 ((u64
) txdr
->dma
& 0x00000000FFFFFFFF));
1077 E1000_WRITE_REG(&adapter
->hw
, TDBAH
, ((u64
) txdr
->dma
>> 32));
1078 E1000_WRITE_REG(&adapter
->hw
, TDLEN
,
1079 txdr
->count
* sizeof(struct e1000_tx_desc
));
1080 E1000_WRITE_REG(&adapter
->hw
, TDH
, 0);
1081 E1000_WRITE_REG(&adapter
->hw
, TDT
, 0);
1082 E1000_WRITE_REG(&adapter
->hw
, TCTL
,
1083 E1000_TCTL_PSP
| E1000_TCTL_EN
|
1084 E1000_COLLISION_THRESHOLD
<< E1000_CT_SHIFT
|
1085 E1000_FDX_COLLISION_DISTANCE
<< E1000_COLD_SHIFT
);
1087 for (i
= 0; i
< txdr
->count
; i
++) {
1088 struct e1000_tx_desc
*tx_desc
= E1000_TX_DESC(*txdr
, i
);
1089 struct sk_buff
*skb
;
1090 unsigned int size
= 1024;
1092 if (!(skb
= alloc_skb(size
, GFP_KERNEL
))) {
1097 txdr
->buffer_info
[i
].skb
= skb
;
1098 txdr
->buffer_info
[i
].length
= skb
->len
;
1099 txdr
->buffer_info
[i
].dma
=
1100 pci_map_single(pdev
, skb
->data
, skb
->len
,
1102 tx_desc
->buffer_addr
= cpu_to_le64(txdr
->buffer_info
[i
].dma
);
1103 tx_desc
->lower
.data
= cpu_to_le32(skb
->len
);
1104 tx_desc
->lower
.data
|= cpu_to_le32(E1000_TXD_CMD_EOP
|
1105 E1000_TXD_CMD_IFCS
|
1107 tx_desc
->upper
.data
= 0;
1110 /* Setup Rx descriptor ring and Rx buffers */
1113 rxdr
->count
= E1000_DEFAULT_RXD
;
1115 if (!(rxdr
->buffer_info
= kcalloc(rxdr
->count
,
1116 sizeof(struct e1000_buffer
),
1122 rxdr
->size
= rxdr
->count
* sizeof(struct e1000_rx_desc
);
1123 if (!(rxdr
->desc
= pci_alloc_consistent(pdev
, rxdr
->size
, &rxdr
->dma
))) {
1127 memset(rxdr
->desc
, 0, rxdr
->size
);
1128 rxdr
->next_to_use
= rxdr
->next_to_clean
= 0;
1130 rctl
= E1000_READ_REG(&adapter
->hw
, RCTL
);
1131 E1000_WRITE_REG(&adapter
->hw
, RCTL
, rctl
& ~E1000_RCTL_EN
);
1132 E1000_WRITE_REG(&adapter
->hw
, RDBAL
,
1133 ((u64
) rxdr
->dma
& 0xFFFFFFFF));
1134 E1000_WRITE_REG(&adapter
->hw
, RDBAH
, ((u64
) rxdr
->dma
>> 32));
1135 E1000_WRITE_REG(&adapter
->hw
, RDLEN
, rxdr
->size
);
1136 E1000_WRITE_REG(&adapter
->hw
, RDH
, 0);
1137 E1000_WRITE_REG(&adapter
->hw
, RDT
, 0);
1138 rctl
= E1000_RCTL_EN
| E1000_RCTL_BAM
| E1000_RCTL_SZ_2048
|
1139 E1000_RCTL_LBM_NO
| E1000_RCTL_RDMTS_HALF
|
1140 (adapter
->hw
.mc_filter_type
<< E1000_RCTL_MO_SHIFT
);
1141 E1000_WRITE_REG(&adapter
->hw
, RCTL
, rctl
);
1143 for (i
= 0; i
< rxdr
->count
; i
++) {
1144 struct e1000_rx_desc
*rx_desc
= E1000_RX_DESC(*rxdr
, i
);
1145 struct sk_buff
*skb
;
1147 if (!(skb
= alloc_skb(E1000_RXBUFFER_2048
+ NET_IP_ALIGN
,
1152 skb_reserve(skb
, NET_IP_ALIGN
);
1153 rxdr
->buffer_info
[i
].skb
= skb
;
1154 rxdr
->buffer_info
[i
].length
= E1000_RXBUFFER_2048
;
1155 rxdr
->buffer_info
[i
].dma
=
1156 pci_map_single(pdev
, skb
->data
, E1000_RXBUFFER_2048
,
1157 PCI_DMA_FROMDEVICE
);
1158 rx_desc
->buffer_addr
= cpu_to_le64(rxdr
->buffer_info
[i
].dma
);
1159 memset(skb
->data
, 0x00, skb
->len
);
1165 e1000_free_desc_rings(adapter
);
1169 static void e1000_phy_disable_receiver(struct e1000_adapter
*adapter
)
1171 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1172 e1000_write_phy_reg(&adapter
->hw
, 29, 0x001F);
1173 e1000_write_phy_reg(&adapter
->hw
, 30, 0x8FFC);
1174 e1000_write_phy_reg(&adapter
->hw
, 29, 0x001A);
1175 e1000_write_phy_reg(&adapter
->hw
, 30, 0x8FF0);
1178 static void e1000_phy_reset_clk_and_crs(struct e1000_adapter
*adapter
)
1182 /* Because we reset the PHY above, we need to re-force TX_CLK in the
1183 * Extended PHY Specific Control Register to 25MHz clock. This
1184 * value defaults back to a 2.5MHz clock when the PHY is reset.
1186 e1000_read_phy_reg(&adapter
->hw
, M88E1000_EXT_PHY_SPEC_CTRL
, &phy_reg
);
1187 phy_reg
|= M88E1000_EPSCR_TX_CLK_25
;
1188 e1000_write_phy_reg(&adapter
->hw
,
1189 M88E1000_EXT_PHY_SPEC_CTRL
, phy_reg
);
1191 /* In addition, because of the s/w reset above, we need to enable
1192 * CRS on TX. This must be set for both full and half duplex
1195 e1000_read_phy_reg(&adapter
->hw
, M88E1000_PHY_SPEC_CTRL
, &phy_reg
);
1196 phy_reg
|= M88E1000_PSCR_ASSERT_CRS_ON_TX
;
1197 e1000_write_phy_reg(&adapter
->hw
,
1198 M88E1000_PHY_SPEC_CTRL
, phy_reg
);
1201 static int e1000_nonintegrated_phy_loopback(struct e1000_adapter
*adapter
)
1206 /* Setup the Device Control Register for PHY loopback test. */
1208 ctrl_reg
= E1000_READ_REG(&adapter
->hw
, CTRL
);
1209 ctrl_reg
|= (E1000_CTRL_ILOS
| /* Invert Loss-Of-Signal */
1210 E1000_CTRL_FRCSPD
| /* Set the Force Speed Bit */
1211 E1000_CTRL_FRCDPX
| /* Set the Force Duplex Bit */
1212 E1000_CTRL_SPD_1000
| /* Force Speed to 1000 */
1213 E1000_CTRL_FD
); /* Force Duplex to FULL */
1215 E1000_WRITE_REG(&adapter
->hw
, CTRL
, ctrl_reg
);
1217 /* Read the PHY Specific Control Register (0x10) */
1218 e1000_read_phy_reg(&adapter
->hw
, M88E1000_PHY_SPEC_CTRL
, &phy_reg
);
1220 /* Clear Auto-Crossover bits in PHY Specific Control Register
1223 phy_reg
&= ~M88E1000_PSCR_AUTO_X_MODE
;
1224 e1000_write_phy_reg(&adapter
->hw
, M88E1000_PHY_SPEC_CTRL
, phy_reg
);
1226 /* Perform software reset on the PHY */
1227 e1000_phy_reset(&adapter
->hw
);
1229 /* Have to setup TX_CLK and TX_CRS after software reset */
1230 e1000_phy_reset_clk_and_crs(adapter
);
1232 e1000_write_phy_reg(&adapter
->hw
, PHY_CTRL
, 0x8100);
1234 /* Wait for reset to complete. */
1237 /* Have to setup TX_CLK and TX_CRS after software reset */
1238 e1000_phy_reset_clk_and_crs(adapter
);
1240 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1241 e1000_phy_disable_receiver(adapter
);
1243 /* Set the loopback bit in the PHY control register. */
1244 e1000_read_phy_reg(&adapter
->hw
, PHY_CTRL
, &phy_reg
);
1245 phy_reg
|= MII_CR_LOOPBACK
;
1246 e1000_write_phy_reg(&adapter
->hw
, PHY_CTRL
, phy_reg
);
1248 /* Setup TX_CLK and TX_CRS one more time. */
1249 e1000_phy_reset_clk_and_crs(adapter
);
1251 /* Check Phy Configuration */
1252 e1000_read_phy_reg(&adapter
->hw
, PHY_CTRL
, &phy_reg
);
1253 if (phy_reg
!= 0x4100)
1256 e1000_read_phy_reg(&adapter
->hw
, M88E1000_EXT_PHY_SPEC_CTRL
, &phy_reg
);
1257 if (phy_reg
!= 0x0070)
1260 e1000_read_phy_reg(&adapter
->hw
, 29, &phy_reg
);
1261 if (phy_reg
!= 0x001A)
1267 static int e1000_integrated_phy_loopback(struct e1000_adapter
*adapter
)
1272 adapter
->hw
.autoneg
= false;
1274 if (adapter
->hw
.phy_type
== e1000_phy_m88
) {
1275 /* Auto-MDI/MDIX Off */
1276 e1000_write_phy_reg(&adapter
->hw
,
1277 M88E1000_PHY_SPEC_CTRL
, 0x0808);
1278 /* reset to update Auto-MDI/MDIX */
1279 e1000_write_phy_reg(&adapter
->hw
, PHY_CTRL
, 0x9140);
1281 e1000_write_phy_reg(&adapter
->hw
, PHY_CTRL
, 0x8140);
1282 } else if (adapter
->hw
.phy_type
== e1000_phy_gg82563
)
1283 e1000_write_phy_reg(&adapter
->hw
,
1284 GG82563_PHY_KMRN_MODE_CTRL
,
1287 ctrl_reg
= E1000_READ_REG(&adapter
->hw
, CTRL
);
1289 if (adapter
->hw
.phy_type
== e1000_phy_ife
) {
1290 /* force 100, set loopback */
1291 e1000_write_phy_reg(&adapter
->hw
, PHY_CTRL
, 0x6100);
1293 /* Now set up the MAC to the same speed/duplex as the PHY. */
1294 ctrl_reg
&= ~E1000_CTRL_SPD_SEL
; /* Clear the speed sel bits */
1295 ctrl_reg
|= (E1000_CTRL_FRCSPD
| /* Set the Force Speed Bit */
1296 E1000_CTRL_FRCDPX
| /* Set the Force Duplex Bit */
1297 E1000_CTRL_SPD_100
|/* Force Speed to 100 */
1298 E1000_CTRL_FD
); /* Force Duplex to FULL */
1300 /* force 1000, set loopback */
1301 e1000_write_phy_reg(&adapter
->hw
, PHY_CTRL
, 0x4140);
1303 /* Now set up the MAC to the same speed/duplex as the PHY. */
1304 ctrl_reg
= E1000_READ_REG(&adapter
->hw
, CTRL
);
1305 ctrl_reg
&= ~E1000_CTRL_SPD_SEL
; /* Clear the speed sel bits */
1306 ctrl_reg
|= (E1000_CTRL_FRCSPD
| /* Set the Force Speed Bit */
1307 E1000_CTRL_FRCDPX
| /* Set the Force Duplex Bit */
1308 E1000_CTRL_SPD_1000
|/* Force Speed to 1000 */
1309 E1000_CTRL_FD
); /* Force Duplex to FULL */
1312 if (adapter
->hw
.media_type
== e1000_media_type_copper
&&
1313 adapter
->hw
.phy_type
== e1000_phy_m88
)
1314 ctrl_reg
|= E1000_CTRL_ILOS
; /* Invert Loss of Signal */
1316 /* Set the ILOS bit on the fiber Nic is half
1317 * duplex link is detected. */
1318 stat_reg
= E1000_READ_REG(&adapter
->hw
, STATUS
);
1319 if ((stat_reg
& E1000_STATUS_FD
) == 0)
1320 ctrl_reg
|= (E1000_CTRL_ILOS
| E1000_CTRL_SLU
);
1323 E1000_WRITE_REG(&adapter
->hw
, CTRL
, ctrl_reg
);
1325 /* Disable the receiver on the PHY so when a cable is plugged in, the
1326 * PHY does not begin to autoneg when a cable is reconnected to the NIC.
1328 if (adapter
->hw
.phy_type
== e1000_phy_m88
)
1329 e1000_phy_disable_receiver(adapter
);
1336 static int e1000_set_phy_loopback(struct e1000_adapter
*adapter
)
1341 switch (adapter
->hw
.mac_type
) {
1343 if (adapter
->hw
.media_type
== e1000_media_type_copper
) {
1344 /* Attempt to setup Loopback mode on Non-integrated PHY.
1345 * Some PHY registers get corrupted at random, so
1346 * attempt this 10 times.
1348 while (e1000_nonintegrated_phy_loopback(adapter
) &&
1358 case e1000_82545_rev_3
:
1360 case e1000_82546_rev_3
:
1362 case e1000_82541_rev_2
:
1364 case e1000_82547_rev_2
:
1368 case e1000_80003es2lan
:
1370 return e1000_integrated_phy_loopback(adapter
);
1374 /* Default PHY loopback work is to read the MII
1375 * control register and assert bit 14 (loopback mode).
1377 e1000_read_phy_reg(&adapter
->hw
, PHY_CTRL
, &phy_reg
);
1378 phy_reg
|= MII_CR_LOOPBACK
;
1379 e1000_write_phy_reg(&adapter
->hw
, PHY_CTRL
, phy_reg
);
1387 static int e1000_setup_loopback_test(struct e1000_adapter
*adapter
)
1389 struct e1000_hw
*hw
= &adapter
->hw
;
1392 if (hw
->media_type
== e1000_media_type_fiber
||
1393 hw
->media_type
== e1000_media_type_internal_serdes
) {
1394 switch (hw
->mac_type
) {
1397 case e1000_82545_rev_3
:
1398 case e1000_82546_rev_3
:
1399 return e1000_set_phy_loopback(adapter
);
1403 #define E1000_SERDES_LB_ON 0x410
1404 e1000_set_phy_loopback(adapter
);
1405 E1000_WRITE_REG(hw
, SCTL
, E1000_SERDES_LB_ON
);
1410 rctl
= E1000_READ_REG(hw
, RCTL
);
1411 rctl
|= E1000_RCTL_LBM_TCVR
;
1412 E1000_WRITE_REG(hw
, RCTL
, rctl
);
1415 } else if (hw
->media_type
== e1000_media_type_copper
)
1416 return e1000_set_phy_loopback(adapter
);
1421 static void e1000_loopback_cleanup(struct e1000_adapter
*adapter
)
1423 struct e1000_hw
*hw
= &adapter
->hw
;
1427 rctl
= E1000_READ_REG(hw
, RCTL
);
1428 rctl
&= ~(E1000_RCTL_LBM_TCVR
| E1000_RCTL_LBM_MAC
);
1429 E1000_WRITE_REG(hw
, RCTL
, rctl
);
1431 switch (hw
->mac_type
) {
1434 if (hw
->media_type
== e1000_media_type_fiber
||
1435 hw
->media_type
== e1000_media_type_internal_serdes
) {
1436 #define E1000_SERDES_LB_OFF 0x400
1437 E1000_WRITE_REG(hw
, SCTL
, E1000_SERDES_LB_OFF
);
1444 case e1000_82545_rev_3
:
1445 case e1000_82546_rev_3
:
1448 if (hw
->phy_type
== e1000_phy_gg82563
)
1449 e1000_write_phy_reg(hw
,
1450 GG82563_PHY_KMRN_MODE_CTRL
,
1452 e1000_read_phy_reg(hw
, PHY_CTRL
, &phy_reg
);
1453 if (phy_reg
& MII_CR_LOOPBACK
) {
1454 phy_reg
&= ~MII_CR_LOOPBACK
;
1455 e1000_write_phy_reg(hw
, PHY_CTRL
, phy_reg
);
1456 e1000_phy_reset(hw
);
1462 static void e1000_create_lbtest_frame(struct sk_buff
*skb
,
1463 unsigned int frame_size
)
1465 memset(skb
->data
, 0xFF, frame_size
);
1467 memset(&skb
->data
[frame_size
/ 2], 0xAA, frame_size
/ 2 - 1);
1468 memset(&skb
->data
[frame_size
/ 2 + 10], 0xBE, 1);
1469 memset(&skb
->data
[frame_size
/ 2 + 12], 0xAF, 1);
1472 static int e1000_check_lbtest_frame(struct sk_buff
*skb
,
1473 unsigned int frame_size
)
1476 if (*(skb
->data
+ 3) == 0xFF) {
1477 if ((*(skb
->data
+ frame_size
/ 2 + 10) == 0xBE) &&
1478 (*(skb
->data
+ frame_size
/ 2 + 12) == 0xAF)) {
1485 static int e1000_run_loopback_test(struct e1000_adapter
*adapter
)
1487 struct e1000_tx_ring
*txdr
= &adapter
->test_tx_ring
;
1488 struct e1000_rx_ring
*rxdr
= &adapter
->test_rx_ring
;
1489 struct pci_dev
*pdev
= adapter
->pdev
;
1490 int i
, j
, k
, l
, lc
, good_cnt
, ret_val
=0;
1493 E1000_WRITE_REG(&adapter
->hw
, RDT
, rxdr
->count
- 1);
1495 /* Calculate the loop count based on the largest descriptor ring
1496 * The idea is to wrap the largest ring a number of times using 64
1497 * send/receive pairs during each loop
1500 if (rxdr
->count
<= txdr
->count
)
1501 lc
= ((txdr
->count
/ 64) * 2) + 1;
1503 lc
= ((rxdr
->count
/ 64) * 2) + 1;
1506 for (j
= 0; j
<= lc
; j
++) { /* loop count loop */
1507 for (i
= 0; i
< 64; i
++) { /* send the packets */
1508 e1000_create_lbtest_frame(txdr
->buffer_info
[i
].skb
,
1510 pci_dma_sync_single_for_device(pdev
,
1511 txdr
->buffer_info
[k
].dma
,
1512 txdr
->buffer_info
[k
].length
,
1514 if (unlikely(++k
== txdr
->count
)) k
= 0;
1516 E1000_WRITE_REG(&adapter
->hw
, TDT
, k
);
1518 time
= jiffies
; /* set the start time for the receive */
1520 do { /* receive the sent packets */
1521 pci_dma_sync_single_for_cpu(pdev
,
1522 rxdr
->buffer_info
[l
].dma
,
1523 rxdr
->buffer_info
[l
].length
,
1524 PCI_DMA_FROMDEVICE
);
1526 ret_val
= e1000_check_lbtest_frame(
1527 rxdr
->buffer_info
[l
].skb
,
1531 if (unlikely(++l
== rxdr
->count
)) l
= 0;
1532 /* time + 20 msecs (200 msecs on 2.4) is more than
1533 * enough time to complete the receives, if it's
1534 * exceeded, break and error off
1536 } while (good_cnt
< 64 && jiffies
< (time
+ 20));
1537 if (good_cnt
!= 64) {
1538 ret_val
= 13; /* ret_val is the same as mis-compare */
1541 if (jiffies
>= (time
+ 2)) {
1542 ret_val
= 14; /* error code for time out error */
1545 } /* end loop count loop */
1549 static int e1000_loopback_test(struct e1000_adapter
*adapter
, u64
*data
)
1551 /* PHY loopback cannot be performed if SoL/IDER
1552 * sessions are active */
1553 if (e1000_check_phy_reset_block(&adapter
->hw
)) {
1554 DPRINTK(DRV
, ERR
, "Cannot do PHY loopback test "
1555 "when SoL/IDER is active.\n");
1560 if ((*data
= e1000_setup_desc_rings(adapter
)))
1562 if ((*data
= e1000_setup_loopback_test(adapter
)))
1564 *data
= e1000_run_loopback_test(adapter
);
1565 e1000_loopback_cleanup(adapter
);
1568 e1000_free_desc_rings(adapter
);
1573 static int e1000_link_test(struct e1000_adapter
*adapter
, u64
*data
)
1576 if (adapter
->hw
.media_type
== e1000_media_type_internal_serdes
) {
1578 adapter
->hw
.serdes_link_down
= true;
1580 /* On some blade server designs, link establishment
1581 * could take as long as 2-3 minutes */
1583 e1000_check_for_link(&adapter
->hw
);
1584 if (!adapter
->hw
.serdes_link_down
)
1587 } while (i
++ < 3750);
1591 e1000_check_for_link(&adapter
->hw
);
1592 if (adapter
->hw
.autoneg
) /* if auto_neg is set wait for it */
1595 if (!(E1000_READ_REG(&adapter
->hw
, STATUS
) & E1000_STATUS_LU
)) {
1602 static int e1000_get_sset_count(struct net_device
*netdev
, int sset
)
1606 return E1000_TEST_LEN
;
1608 return E1000_STATS_LEN
;
1614 static void e1000_diag_test(struct net_device
*netdev
,
1615 struct ethtool_test
*eth_test
, u64
*data
)
1617 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
1618 bool if_running
= netif_running(netdev
);
1620 set_bit(__E1000_TESTING
, &adapter
->flags
);
1621 if (eth_test
->flags
== ETH_TEST_FL_OFFLINE
) {
1624 /* save speed, duplex, autoneg settings */
1625 u16 autoneg_advertised
= adapter
->hw
.autoneg_advertised
;
1626 u8 forced_speed_duplex
= adapter
->hw
.forced_speed_duplex
;
1627 u8 autoneg
= adapter
->hw
.autoneg
;
1629 DPRINTK(HW
, INFO
, "offline testing starting\n");
1631 /* Link test performed before hardware reset so autoneg doesn't
1632 * interfere with test result */
1633 if (e1000_link_test(adapter
, &data
[4]))
1634 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1637 /* indicate we're in test mode */
1640 e1000_reset(adapter
);
1642 if (e1000_reg_test(adapter
, &data
[0]))
1643 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1645 e1000_reset(adapter
);
1646 if (e1000_eeprom_test(adapter
, &data
[1]))
1647 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1649 e1000_reset(adapter
);
1650 if (e1000_intr_test(adapter
, &data
[2]))
1651 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1653 e1000_reset(adapter
);
1654 /* make sure the phy is powered up */
1655 e1000_power_up_phy(adapter
);
1656 if (e1000_loopback_test(adapter
, &data
[3]))
1657 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1659 /* restore speed, duplex, autoneg settings */
1660 adapter
->hw
.autoneg_advertised
= autoneg_advertised
;
1661 adapter
->hw
.forced_speed_duplex
= forced_speed_duplex
;
1662 adapter
->hw
.autoneg
= autoneg
;
1664 e1000_reset(adapter
);
1665 clear_bit(__E1000_TESTING
, &adapter
->flags
);
1669 DPRINTK(HW
, INFO
, "online testing starting\n");
1671 if (e1000_link_test(adapter
, &data
[4]))
1672 eth_test
->flags
|= ETH_TEST_FL_FAILED
;
1674 /* Online tests aren't run; pass by default */
1680 clear_bit(__E1000_TESTING
, &adapter
->flags
);
1682 msleep_interruptible(4 * 1000);
1685 static int e1000_wol_exclusion(struct e1000_adapter
*adapter
,
1686 struct ethtool_wolinfo
*wol
)
1688 struct e1000_hw
*hw
= &adapter
->hw
;
1689 int retval
= 1; /* fail by default */
1691 switch (hw
->device_id
) {
1692 case E1000_DEV_ID_82542
:
1693 case E1000_DEV_ID_82543GC_FIBER
:
1694 case E1000_DEV_ID_82543GC_COPPER
:
1695 case E1000_DEV_ID_82544EI_FIBER
:
1696 case E1000_DEV_ID_82546EB_QUAD_COPPER
:
1697 case E1000_DEV_ID_82545EM_FIBER
:
1698 case E1000_DEV_ID_82545EM_COPPER
:
1699 case E1000_DEV_ID_82546GB_QUAD_COPPER
:
1700 case E1000_DEV_ID_82546GB_PCIE
:
1701 case E1000_DEV_ID_82571EB_SERDES_QUAD
:
1702 /* these don't support WoL at all */
1705 case E1000_DEV_ID_82546EB_FIBER
:
1706 case E1000_DEV_ID_82546GB_FIBER
:
1707 case E1000_DEV_ID_82571EB_FIBER
:
1708 case E1000_DEV_ID_82571EB_SERDES
:
1709 case E1000_DEV_ID_82571EB_COPPER
:
1710 /* Wake events not supported on port B */
1711 if (E1000_READ_REG(hw
, STATUS
) & E1000_STATUS_FUNC_1
) {
1715 /* return success for non excluded adapter ports */
1718 case E1000_DEV_ID_82571EB_QUAD_COPPER
:
1719 case E1000_DEV_ID_82571EB_QUAD_FIBER
:
1720 case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE
:
1721 case E1000_DEV_ID_82571PT_QUAD_COPPER
:
1722 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3
:
1723 /* quad port adapters only support WoL on port A */
1724 if (!adapter
->quad_port_a
) {
1728 /* return success for non excluded adapter ports */
1732 /* dual port cards only support WoL on port A from now on
1733 * unless it was enabled in the eeprom for port B
1734 * so exclude FUNC_1 ports from having WoL enabled */
1735 if (E1000_READ_REG(hw
, STATUS
) & E1000_STATUS_FUNC_1
&&
1736 !adapter
->eeprom_wol
) {
1747 static void e1000_get_wol(struct net_device
*netdev
,
1748 struct ethtool_wolinfo
*wol
)
1750 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
1752 wol
->supported
= WAKE_UCAST
| WAKE_MCAST
|
1753 WAKE_BCAST
| WAKE_MAGIC
;
1756 /* this function will set ->supported = 0 and return 1 if wol is not
1757 * supported by this hardware */
1758 if (e1000_wol_exclusion(adapter
, wol
))
1761 /* apply any specific unsupported masks here */
1762 switch (adapter
->hw
.device_id
) {
1763 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3
:
1764 /* KSP3 does not suppport UCAST wake-ups */
1765 wol
->supported
&= ~WAKE_UCAST
;
1767 if (adapter
->wol
& E1000_WUFC_EX
)
1768 DPRINTK(DRV
, ERR
, "Interface does not support "
1769 "directed (unicast) frame wake-up packets\n");
1775 if (adapter
->wol
& E1000_WUFC_EX
)
1776 wol
->wolopts
|= WAKE_UCAST
;
1777 if (adapter
->wol
& E1000_WUFC_MC
)
1778 wol
->wolopts
|= WAKE_MCAST
;
1779 if (adapter
->wol
& E1000_WUFC_BC
)
1780 wol
->wolopts
|= WAKE_BCAST
;
1781 if (adapter
->wol
& E1000_WUFC_MAG
)
1782 wol
->wolopts
|= WAKE_MAGIC
;
1787 static int e1000_set_wol(struct net_device
*netdev
, struct ethtool_wolinfo
*wol
)
1789 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
1790 struct e1000_hw
*hw
= &adapter
->hw
;
1792 if (wol
->wolopts
& (WAKE_PHY
| WAKE_ARP
| WAKE_MAGICSECURE
))
1795 if (e1000_wol_exclusion(adapter
, wol
))
1796 return wol
->wolopts
? -EOPNOTSUPP
: 0;
1798 switch (hw
->device_id
) {
1799 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3
:
1800 if (wol
->wolopts
& WAKE_UCAST
) {
1801 DPRINTK(DRV
, ERR
, "Interface does not support "
1802 "directed (unicast) frame wake-up packets\n");
1810 /* these settings will always override what we currently have */
1813 if (wol
->wolopts
& WAKE_UCAST
)
1814 adapter
->wol
|= E1000_WUFC_EX
;
1815 if (wol
->wolopts
& WAKE_MCAST
)
1816 adapter
->wol
|= E1000_WUFC_MC
;
1817 if (wol
->wolopts
& WAKE_BCAST
)
1818 adapter
->wol
|= E1000_WUFC_BC
;
1819 if (wol
->wolopts
& WAKE_MAGIC
)
1820 adapter
->wol
|= E1000_WUFC_MAG
;
1825 /* toggle LED 4 times per second = 2 "blinks" per second */
1826 #define E1000_ID_INTERVAL (HZ/4)
1828 /* bit defines for adapter->led_status */
1829 #define E1000_LED_ON 0
1831 static void e1000_led_blink_callback(unsigned long data
)
1833 struct e1000_adapter
*adapter
= (struct e1000_adapter
*) data
;
1835 if (test_and_change_bit(E1000_LED_ON
, &adapter
->led_status
))
1836 e1000_led_off(&adapter
->hw
);
1838 e1000_led_on(&adapter
->hw
);
1840 mod_timer(&adapter
->blink_timer
, jiffies
+ E1000_ID_INTERVAL
);
1843 static int e1000_phys_id(struct net_device
*netdev
, u32 data
)
1845 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
1850 if (adapter
->hw
.mac_type
< e1000_82571
) {
1851 if (!adapter
->blink_timer
.function
) {
1852 init_timer(&adapter
->blink_timer
);
1853 adapter
->blink_timer
.function
= e1000_led_blink_callback
;
1854 adapter
->blink_timer
.data
= (unsigned long) adapter
;
1856 e1000_setup_led(&adapter
->hw
);
1857 mod_timer(&adapter
->blink_timer
, jiffies
);
1858 msleep_interruptible(data
* 1000);
1859 del_timer_sync(&adapter
->blink_timer
);
1860 } else if (adapter
->hw
.phy_type
== e1000_phy_ife
) {
1861 if (!adapter
->blink_timer
.function
) {
1862 init_timer(&adapter
->blink_timer
);
1863 adapter
->blink_timer
.function
= e1000_led_blink_callback
;
1864 adapter
->blink_timer
.data
= (unsigned long) adapter
;
1866 mod_timer(&adapter
->blink_timer
, jiffies
);
1867 msleep_interruptible(data
* 1000);
1868 del_timer_sync(&adapter
->blink_timer
);
1869 e1000_write_phy_reg(&(adapter
->hw
), IFE_PHY_SPECIAL_CONTROL_LED
, 0);
1871 e1000_blink_led_start(&adapter
->hw
);
1872 msleep_interruptible(data
* 1000);
1875 e1000_led_off(&adapter
->hw
);
1876 clear_bit(E1000_LED_ON
, &adapter
->led_status
);
1877 e1000_cleanup_led(&adapter
->hw
);
1882 static int e1000_nway_reset(struct net_device
*netdev
)
1884 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
1885 if (netif_running(netdev
))
1886 e1000_reinit_locked(adapter
);
1890 static void e1000_get_ethtool_stats(struct net_device
*netdev
,
1891 struct ethtool_stats
*stats
, u64
*data
)
1893 struct e1000_adapter
*adapter
= netdev_priv(netdev
);
1896 e1000_update_stats(adapter
);
1897 for (i
= 0; i
< E1000_GLOBAL_STATS_LEN
; i
++) {
1898 char *p
= (char *)adapter
+e1000_gstrings_stats
[i
].stat_offset
;
1899 data
[i
] = (e1000_gstrings_stats
[i
].sizeof_stat
==
1900 sizeof(u64
)) ? *(u64
*)p
: *(u32
*)p
;
1902 /* BUG_ON(i != E1000_STATS_LEN); */
1905 static void e1000_get_strings(struct net_device
*netdev
, u32 stringset
,
1911 switch (stringset
) {
1913 memcpy(data
, *e1000_gstrings_test
,
1914 sizeof(e1000_gstrings_test
));
1917 for (i
= 0; i
< E1000_GLOBAL_STATS_LEN
; i
++) {
1918 memcpy(p
, e1000_gstrings_stats
[i
].stat_string
,
1920 p
+= ETH_GSTRING_LEN
;
1922 /* BUG_ON(p - data != E1000_STATS_LEN * ETH_GSTRING_LEN); */
1927 static const struct ethtool_ops e1000_ethtool_ops
= {
1928 .get_settings
= e1000_get_settings
,
1929 .set_settings
= e1000_set_settings
,
1930 .get_drvinfo
= e1000_get_drvinfo
,
1931 .get_regs_len
= e1000_get_regs_len
,
1932 .get_regs
= e1000_get_regs
,
1933 .get_wol
= e1000_get_wol
,
1934 .set_wol
= e1000_set_wol
,
1935 .get_msglevel
= e1000_get_msglevel
,
1936 .set_msglevel
= e1000_set_msglevel
,
1937 .nway_reset
= e1000_nway_reset
,
1938 .get_link
= ethtool_op_get_link
,
1939 .get_eeprom_len
= e1000_get_eeprom_len
,
1940 .get_eeprom
= e1000_get_eeprom
,
1941 .set_eeprom
= e1000_set_eeprom
,
1942 .get_ringparam
= e1000_get_ringparam
,
1943 .set_ringparam
= e1000_set_ringparam
,
1944 .get_pauseparam
= e1000_get_pauseparam
,
1945 .set_pauseparam
= e1000_set_pauseparam
,
1946 .get_rx_csum
= e1000_get_rx_csum
,
1947 .set_rx_csum
= e1000_set_rx_csum
,
1948 .get_tx_csum
= e1000_get_tx_csum
,
1949 .set_tx_csum
= e1000_set_tx_csum
,
1950 .set_sg
= ethtool_op_set_sg
,
1951 .set_tso
= e1000_set_tso
,
1952 .self_test
= e1000_diag_test
,
1953 .get_strings
= e1000_get_strings
,
1954 .phys_id
= e1000_phys_id
,
1955 .get_ethtool_stats
= e1000_get_ethtool_stats
,
1956 .get_sset_count
= e1000_get_sset_count
,
1959 void e1000_set_ethtool_ops(struct net_device
*netdev
)
1961 SET_ETHTOOL_OPS(netdev
, &e1000_ethtool_ops
);