1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2013 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 */
31 #include <linux/netdevice.h>
32 #include <linux/interrupt.h>
33 #include <linux/ethtool.h>
34 #include <linux/pci.h>
35 #include <linux/slab.h>
36 #include <linux/delay.h>
37 #include <linux/vmalloc.h>
38 #include <linux/mdio.h>
39 #include <linux/pm_runtime.h>
43 enum {NETDEV_STATS, E1000_STATS};
46 char stat_string[ETH_GSTRING_LEN];
52 #define E1000_STAT(str, m) { \
54 .type = E1000_STATS, \
55 .sizeof_stat = sizeof(((struct e1000_adapter *)0)->m), \
56 .stat_offset = offsetof(struct e1000_adapter, m) }
57 #define E1000_NETDEV_STAT(str, m) { \
59 .type = NETDEV_STATS, \
60 .sizeof_stat = sizeof(((struct rtnl_link_stats64 *)0)->m), \
61 .stat_offset = offsetof(struct rtnl_link_stats64, m) }
63 static const struct e1000_stats e1000_gstrings_stats[] = {
64 E1000_STAT("rx_packets", stats.gprc),
65 E1000_STAT("tx_packets", stats.gptc),
66 E1000_STAT("rx_bytes", stats.gorc),
67 E1000_STAT("tx_bytes", stats.gotc),
68 E1000_STAT("rx_broadcast", stats.bprc),
69 E1000_STAT("tx_broadcast", stats.bptc),
70 E1000_STAT("rx_multicast", stats.mprc),
71 E1000_STAT("tx_multicast", stats.mptc),
72 E1000_NETDEV_STAT("rx_errors", rx_errors),
73 E1000_NETDEV_STAT("tx_errors", tx_errors),
74 E1000_NETDEV_STAT("tx_dropped", tx_dropped),
75 E1000_STAT("multicast", stats.mprc),
76 E1000_STAT("collisions", stats.colc),
77 E1000_NETDEV_STAT("rx_length_errors", rx_length_errors),
78 E1000_NETDEV_STAT("rx_over_errors", rx_over_errors),
79 E1000_STAT("rx_crc_errors", stats.crcerrs),
80 E1000_NETDEV_STAT("rx_frame_errors", rx_frame_errors),
81 E1000_STAT("rx_no_buffer_count", stats.rnbc),
82 E1000_STAT("rx_missed_errors", stats.mpc),
83 E1000_STAT("tx_aborted_errors", stats.ecol),
84 E1000_STAT("tx_carrier_errors", stats.tncrs),
85 E1000_NETDEV_STAT("tx_fifo_errors", tx_fifo_errors),
86 E1000_NETDEV_STAT("tx_heartbeat_errors", tx_heartbeat_errors),
87 E1000_STAT("tx_window_errors", stats.latecol),
88 E1000_STAT("tx_abort_late_coll", stats.latecol),
89 E1000_STAT("tx_deferred_ok", stats.dc),
90 E1000_STAT("tx_single_coll_ok", stats.scc),
91 E1000_STAT("tx_multi_coll_ok", stats.mcc),
92 E1000_STAT("tx_timeout_count", tx_timeout_count),
93 E1000_STAT("tx_restart_queue", restart_queue),
94 E1000_STAT("rx_long_length_errors", stats.roc),
95 E1000_STAT("rx_short_length_errors", stats.ruc),
96 E1000_STAT("rx_align_errors", stats.algnerrc),
97 E1000_STAT("tx_tcp_seg_good", stats.tsctc),
98 E1000_STAT("tx_tcp_seg_failed", stats.tsctfc),
99 E1000_STAT("rx_flow_control_xon", stats.xonrxc),
100 E1000_STAT("rx_flow_control_xoff", stats.xoffrxc),
101 E1000_STAT("tx_flow_control_xon", stats.xontxc),
102 E1000_STAT("tx_flow_control_xoff", stats.xofftxc),
103 E1000_STAT("rx_csum_offload_good", hw_csum_good),
104 E1000_STAT("rx_csum_offload_errors", hw_csum_err),
105 E1000_STAT("rx_header_split", rx_hdr_split),
106 E1000_STAT("alloc_rx_buff_failed", alloc_rx_buff_failed),
107 E1000_STAT("tx_smbus", stats.mgptc),
108 E1000_STAT("rx_smbus", stats.mgprc),
109 E1000_STAT("dropped_smbus", stats.mgpdc),
110 E1000_STAT("rx_dma_failed", rx_dma_failed),
111 E1000_STAT("tx_dma_failed", tx_dma_failed),
112 E1000_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared),
113 E1000_STAT("uncorr_ecc_errors", uncorr_errors),
114 E1000_STAT("corr_ecc_errors", corr_errors),
117 #define E1000_GLOBAL_STATS_LEN ARRAY_SIZE(e1000_gstrings_stats)
118 #define E1000_STATS_LEN (E1000_GLOBAL_STATS_LEN)
119 static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = {
120 "Register test (offline)", "Eeprom test (offline)",
121 "Interrupt test (offline)", "Loopback test (offline)",
122 "Link test (on/offline)"
124 #define E1000_TEST_LEN ARRAY_SIZE(e1000_gstrings_test)
126 static int e1000_get_settings(struct net_device *netdev,
127 struct ethtool_cmd *ecmd)
129 struct e1000_adapter *adapter = netdev_priv(netdev);
130 struct e1000_hw *hw = &adapter->hw;
133 if (hw->phy.media_type == e1000_media_type_copper) {
134 ecmd->supported = (SUPPORTED_10baseT_Half |
135 SUPPORTED_10baseT_Full |
136 SUPPORTED_100baseT_Half |
137 SUPPORTED_100baseT_Full |
138 SUPPORTED_1000baseT_Full |
141 if (hw->phy.type == e1000_phy_ife)
142 ecmd->supported &= ~SUPPORTED_1000baseT_Full;
143 ecmd->advertising = ADVERTISED_TP;
145 if (hw->mac.autoneg == 1) {
146 ecmd->advertising |= ADVERTISED_Autoneg;
147 /* the e1000 autoneg seems to match ethtool nicely */
148 ecmd->advertising |= hw->phy.autoneg_advertised;
151 ecmd->port = PORT_TP;
152 ecmd->phy_address = hw->phy.addr;
153 ecmd->transceiver = XCVR_INTERNAL;
156 ecmd->supported = (SUPPORTED_1000baseT_Full |
160 ecmd->advertising = (ADVERTISED_1000baseT_Full |
164 ecmd->port = PORT_FIBRE;
165 ecmd->transceiver = XCVR_EXTERNAL;
171 if (netif_running(netdev)) {
172 if (netif_carrier_ok(netdev)) {
173 speed = adapter->link_speed;
174 ecmd->duplex = adapter->link_duplex - 1;
177 u32 status = er32(STATUS);
178 if (status & E1000_STATUS_LU) {
179 if (status & E1000_STATUS_SPEED_1000)
181 else if (status & E1000_STATUS_SPEED_100)
186 if (status & E1000_STATUS_FD)
187 ecmd->duplex = DUPLEX_FULL;
189 ecmd->duplex = DUPLEX_HALF;
193 ethtool_cmd_speed_set(ecmd, speed);
194 ecmd->autoneg = ((hw->phy.media_type == e1000_media_type_fiber) ||
195 hw->mac.autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE;
197 /* MDI-X => 2; MDI =>1; Invalid =>0 */
198 if ((hw->phy.media_type == e1000_media_type_copper) &&
199 netif_carrier_ok(netdev))
200 ecmd->eth_tp_mdix = hw->phy.is_mdix ? ETH_TP_MDI_X :
203 ecmd->eth_tp_mdix = ETH_TP_MDI_INVALID;
205 if (hw->phy.mdix == AUTO_ALL_MODES)
206 ecmd->eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO;
208 ecmd->eth_tp_mdix_ctrl = hw->phy.mdix;
213 static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx)
215 struct e1000_mac_info *mac = &adapter->hw.mac;
219 /* Make sure dplx is at most 1 bit and lsb of speed is not set
220 * for the switch() below to work
222 if ((spd & 1) || (dplx & ~1))
225 /* Fiber NICs only allow 1000 gbps Full duplex */
226 if ((adapter->hw.phy.media_type == e1000_media_type_fiber) &&
228 dplx != DUPLEX_FULL) {
232 switch (spd + dplx) {
233 case SPEED_10 + DUPLEX_HALF:
234 mac->forced_speed_duplex = ADVERTISE_10_HALF;
236 case SPEED_10 + DUPLEX_FULL:
237 mac->forced_speed_duplex = ADVERTISE_10_FULL;
239 case SPEED_100 + DUPLEX_HALF:
240 mac->forced_speed_duplex = ADVERTISE_100_HALF;
242 case SPEED_100 + DUPLEX_FULL:
243 mac->forced_speed_duplex = ADVERTISE_100_FULL;
245 case SPEED_1000 + DUPLEX_FULL:
247 adapter->hw.phy.autoneg_advertised = ADVERTISE_1000_FULL;
249 case SPEED_1000 + DUPLEX_HALF: /* not supported */
254 /* clear MDI, MDI(-X) override is only allowed when autoneg enabled */
255 adapter->hw.phy.mdix = AUTO_ALL_MODES;
260 e_err("Unsupported Speed/Duplex configuration\n");
264 static int e1000_set_settings(struct net_device *netdev,
265 struct ethtool_cmd *ecmd)
267 struct e1000_adapter *adapter = netdev_priv(netdev);
268 struct e1000_hw *hw = &adapter->hw;
270 /* When SoL/IDER sessions are active, autoneg/speed/duplex
273 if (hw->phy.ops.check_reset_block &&
274 hw->phy.ops.check_reset_block(hw)) {
275 e_err("Cannot change link characteristics when SoL/IDER is active.\n");
279 /* MDI setting is only allowed when autoneg enabled because
280 * some hardware doesn't allow MDI setting when speed or
283 if (ecmd->eth_tp_mdix_ctrl) {
284 if (hw->phy.media_type != e1000_media_type_copper)
287 if ((ecmd->eth_tp_mdix_ctrl != ETH_TP_MDI_AUTO) &&
288 (ecmd->autoneg != AUTONEG_ENABLE)) {
289 e_err("forcing MDI/MDI-X state is not supported when link speed and/or duplex are forced\n");
294 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
295 usleep_range(1000, 2000);
297 if (ecmd->autoneg == AUTONEG_ENABLE) {
299 if (hw->phy.media_type == e1000_media_type_fiber)
300 hw->phy.autoneg_advertised = ADVERTISED_1000baseT_Full |
304 hw->phy.autoneg_advertised = ecmd->advertising |
307 ecmd->advertising = hw->phy.autoneg_advertised;
308 if (adapter->fc_autoneg)
309 hw->fc.requested_mode = e1000_fc_default;
311 u32 speed = ethtool_cmd_speed(ecmd);
312 /* calling this overrides forced MDI setting */
313 if (e1000_set_spd_dplx(adapter, speed, ecmd->duplex)) {
314 clear_bit(__E1000_RESETTING, &adapter->state);
319 /* MDI-X => 2; MDI => 1; Auto => 3 */
320 if (ecmd->eth_tp_mdix_ctrl) {
321 /* fix up the value for auto (3 => 0) as zero is mapped
324 if (ecmd->eth_tp_mdix_ctrl == ETH_TP_MDI_AUTO)
325 hw->phy.mdix = AUTO_ALL_MODES;
327 hw->phy.mdix = ecmd->eth_tp_mdix_ctrl;
331 if (netif_running(adapter->netdev)) {
332 e1000e_down(adapter);
335 e1000e_reset(adapter);
338 clear_bit(__E1000_RESETTING, &adapter->state);
342 static void e1000_get_pauseparam(struct net_device *netdev,
343 struct ethtool_pauseparam *pause)
345 struct e1000_adapter *adapter = netdev_priv(netdev);
346 struct e1000_hw *hw = &adapter->hw;
349 (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
351 if (hw->fc.current_mode == e1000_fc_rx_pause) {
353 } else if (hw->fc.current_mode == e1000_fc_tx_pause) {
355 } else if (hw->fc.current_mode == e1000_fc_full) {
361 static int e1000_set_pauseparam(struct net_device *netdev,
362 struct ethtool_pauseparam *pause)
364 struct e1000_adapter *adapter = netdev_priv(netdev);
365 struct e1000_hw *hw = &adapter->hw;
368 adapter->fc_autoneg = pause->autoneg;
370 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
371 usleep_range(1000, 2000);
373 if (adapter->fc_autoneg == AUTONEG_ENABLE) {
374 hw->fc.requested_mode = e1000_fc_default;
375 if (netif_running(adapter->netdev)) {
376 e1000e_down(adapter);
379 e1000e_reset(adapter);
382 if (pause->rx_pause && pause->tx_pause)
383 hw->fc.requested_mode = e1000_fc_full;
384 else if (pause->rx_pause && !pause->tx_pause)
385 hw->fc.requested_mode = e1000_fc_rx_pause;
386 else if (!pause->rx_pause && pause->tx_pause)
387 hw->fc.requested_mode = e1000_fc_tx_pause;
388 else if (!pause->rx_pause && !pause->tx_pause)
389 hw->fc.requested_mode = e1000_fc_none;
391 hw->fc.current_mode = hw->fc.requested_mode;
393 if (hw->phy.media_type == e1000_media_type_fiber) {
394 retval = hw->mac.ops.setup_link(hw);
395 /* implicit goto out */
397 retval = e1000e_force_mac_fc(hw);
400 e1000e_set_fc_watermarks(hw);
405 clear_bit(__E1000_RESETTING, &adapter->state);
409 static u32 e1000_get_msglevel(struct net_device *netdev)
411 struct e1000_adapter *adapter = netdev_priv(netdev);
412 return adapter->msg_enable;
415 static void e1000_set_msglevel(struct net_device *netdev, u32 data)
417 struct e1000_adapter *adapter = netdev_priv(netdev);
418 adapter->msg_enable = data;
421 static int e1000_get_regs_len(struct net_device __always_unused *netdev)
423 #define E1000_REGS_LEN 32 /* overestimate */
424 return E1000_REGS_LEN * sizeof(u32);
427 static void e1000_get_regs(struct net_device *netdev,
428 struct ethtool_regs *regs, void *p)
430 struct e1000_adapter *adapter = netdev_priv(netdev);
431 struct e1000_hw *hw = &adapter->hw;
435 memset(p, 0, E1000_REGS_LEN * sizeof(u32));
437 regs->version = (1 << 24) | (adapter->pdev->revision << 16) |
438 adapter->pdev->device;
440 regs_buff[0] = er32(CTRL);
441 regs_buff[1] = er32(STATUS);
443 regs_buff[2] = er32(RCTL);
444 regs_buff[3] = er32(RDLEN(0));
445 regs_buff[4] = er32(RDH(0));
446 regs_buff[5] = er32(RDT(0));
447 regs_buff[6] = er32(RDTR);
449 regs_buff[7] = er32(TCTL);
450 regs_buff[8] = er32(TDLEN(0));
451 regs_buff[9] = er32(TDH(0));
452 regs_buff[10] = er32(TDT(0));
453 regs_buff[11] = er32(TIDV);
455 regs_buff[12] = adapter->hw.phy.type; /* PHY type (IGP=1, M88=0) */
457 /* ethtool doesn't use anything past this point, so all this
458 * code is likely legacy junk for apps that may or may not exist
460 if (hw->phy.type == e1000_phy_m88) {
461 e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
462 regs_buff[13] = (u32)phy_data; /* cable length */
463 regs_buff[14] = 0; /* Dummy (to align w/ IGP phy reg dump) */
464 regs_buff[15] = 0; /* Dummy (to align w/ IGP phy reg dump) */
465 regs_buff[16] = 0; /* Dummy (to align w/ IGP phy reg dump) */
466 e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
467 regs_buff[17] = (u32)phy_data; /* extended 10bt distance */
468 regs_buff[18] = regs_buff[13]; /* cable polarity */
469 regs_buff[19] = 0; /* Dummy (to align w/ IGP phy reg dump) */
470 regs_buff[20] = regs_buff[17]; /* polarity correction */
471 /* phy receive errors */
472 regs_buff[22] = adapter->phy_stats.receive_errors;
473 regs_buff[23] = regs_buff[13]; /* mdix mode */
475 regs_buff[21] = 0; /* was idle_errors */
476 e1e_rphy(hw, MII_STAT1000, &phy_data);
477 regs_buff[24] = (u32)phy_data; /* phy local receiver status */
478 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */
481 static int e1000_get_eeprom_len(struct net_device *netdev)
483 struct e1000_adapter *adapter = netdev_priv(netdev);
484 return adapter->hw.nvm.word_size * 2;
487 static int e1000_get_eeprom(struct net_device *netdev,
488 struct ethtool_eeprom *eeprom, u8 *bytes)
490 struct e1000_adapter *adapter = netdev_priv(netdev);
491 struct e1000_hw *hw = &adapter->hw;
498 if (eeprom->len == 0)
501 eeprom->magic = adapter->pdev->vendor | (adapter->pdev->device << 16);
503 first_word = eeprom->offset >> 1;
504 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
506 eeprom_buff = kmalloc(sizeof(u16) *
507 (last_word - first_word + 1), GFP_KERNEL);
511 if (hw->nvm.type == e1000_nvm_eeprom_spi) {
512 ret_val = e1000_read_nvm(hw, first_word,
513 last_word - first_word + 1,
516 for (i = 0; i < last_word - first_word + 1; i++) {
517 ret_val = e1000_read_nvm(hw, first_word + i, 1,
525 /* a read error occurred, throw away the result */
526 memset(eeprom_buff, 0xff, sizeof(u16) *
527 (last_word - first_word + 1));
529 /* Device's eeprom is always little-endian, word addressable */
530 for (i = 0; i < last_word - first_word + 1; i++)
531 le16_to_cpus(&eeprom_buff[i]);
534 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len);
540 static int e1000_set_eeprom(struct net_device *netdev,
541 struct ethtool_eeprom *eeprom, u8 *bytes)
543 struct e1000_adapter *adapter = netdev_priv(netdev);
544 struct e1000_hw *hw = &adapter->hw;
553 if (eeprom->len == 0)
556 if (eeprom->magic != (adapter->pdev->vendor | (adapter->pdev->device << 16)))
559 if (adapter->flags & FLAG_READ_ONLY_NVM)
562 max_len = hw->nvm.word_size * 2;
564 first_word = eeprom->offset >> 1;
565 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
566 eeprom_buff = kmalloc(max_len, GFP_KERNEL);
570 ptr = (void *)eeprom_buff;
572 if (eeprom->offset & 1) {
573 /* need read/modify/write of first changed EEPROM word */
574 /* only the second byte of the word is being modified */
575 ret_val = e1000_read_nvm(hw, first_word, 1, &eeprom_buff[0]);
578 if (((eeprom->offset + eeprom->len) & 1) && (!ret_val))
579 /* need read/modify/write of last changed EEPROM word */
580 /* only the first byte of the word is being modified */
581 ret_val = e1000_read_nvm(hw, last_word, 1,
582 &eeprom_buff[last_word - first_word]);
587 /* Device's eeprom is always little-endian, word addressable */
588 for (i = 0; i < last_word - first_word + 1; i++)
589 le16_to_cpus(&eeprom_buff[i]);
591 memcpy(ptr, bytes, eeprom->len);
593 for (i = 0; i < last_word - first_word + 1; i++)
594 cpu_to_le16s(&eeprom_buff[i]);
596 ret_val = e1000_write_nvm(hw, first_word,
597 last_word - first_word + 1, eeprom_buff);
602 /* Update the checksum over the first part of the EEPROM if needed
603 * and flush shadow RAM for applicable controllers
605 if ((first_word <= NVM_CHECKSUM_REG) ||
606 (hw->mac.type == e1000_82583) ||
607 (hw->mac.type == e1000_82574) ||
608 (hw->mac.type == e1000_82573))
609 ret_val = e1000e_update_nvm_checksum(hw);
616 static void e1000_get_drvinfo(struct net_device *netdev,
617 struct ethtool_drvinfo *drvinfo)
619 struct e1000_adapter *adapter = netdev_priv(netdev);
621 strlcpy(drvinfo->driver, e1000e_driver_name,
622 sizeof(drvinfo->driver));
623 strlcpy(drvinfo->version, e1000e_driver_version,
624 sizeof(drvinfo->version));
626 /* EEPROM image version # is reported as firmware version # for
629 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
631 (adapter->eeprom_vers & 0xF000) >> 12,
632 (adapter->eeprom_vers & 0x0FF0) >> 4,
633 (adapter->eeprom_vers & 0x000F));
635 strlcpy(drvinfo->bus_info, pci_name(adapter->pdev),
636 sizeof(drvinfo->bus_info));
637 drvinfo->regdump_len = e1000_get_regs_len(netdev);
638 drvinfo->eedump_len = e1000_get_eeprom_len(netdev);
641 static void e1000_get_ringparam(struct net_device *netdev,
642 struct ethtool_ringparam *ring)
644 struct e1000_adapter *adapter = netdev_priv(netdev);
646 ring->rx_max_pending = E1000_MAX_RXD;
647 ring->tx_max_pending = E1000_MAX_TXD;
648 ring->rx_pending = adapter->rx_ring_count;
649 ring->tx_pending = adapter->tx_ring_count;
652 static int e1000_set_ringparam(struct net_device *netdev,
653 struct ethtool_ringparam *ring)
655 struct e1000_adapter *adapter = netdev_priv(netdev);
656 struct e1000_ring *temp_tx = NULL, *temp_rx = NULL;
657 int err = 0, size = sizeof(struct e1000_ring);
658 bool set_tx = false, set_rx = false;
659 u16 new_rx_count, new_tx_count;
661 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
664 new_rx_count = clamp_t(u32, ring->rx_pending, E1000_MIN_RXD,
666 new_rx_count = ALIGN(new_rx_count, REQ_RX_DESCRIPTOR_MULTIPLE);
668 new_tx_count = clamp_t(u32, ring->tx_pending, E1000_MIN_TXD,
670 new_tx_count = ALIGN(new_tx_count, REQ_TX_DESCRIPTOR_MULTIPLE);
672 if ((new_tx_count == adapter->tx_ring_count) &&
673 (new_rx_count == adapter->rx_ring_count))
677 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
678 usleep_range(1000, 2000);
680 if (!netif_running(adapter->netdev)) {
681 /* Set counts now and allocate resources during open() */
682 adapter->tx_ring->count = new_tx_count;
683 adapter->rx_ring->count = new_rx_count;
684 adapter->tx_ring_count = new_tx_count;
685 adapter->rx_ring_count = new_rx_count;
689 set_tx = (new_tx_count != adapter->tx_ring_count);
690 set_rx = (new_rx_count != adapter->rx_ring_count);
692 /* Allocate temporary storage for ring updates */
694 temp_tx = vmalloc(size);
701 temp_rx = vmalloc(size);
708 e1000e_down(adapter);
710 /* We can't just free everything and then setup again, because the
711 * ISRs in MSI-X mode get passed pointers to the Tx and Rx ring
712 * structs. First, attempt to allocate new resources...
715 memcpy(temp_tx, adapter->tx_ring, size);
716 temp_tx->count = new_tx_count;
717 err = e1000e_setup_tx_resources(temp_tx);
722 memcpy(temp_rx, adapter->rx_ring, size);
723 temp_rx->count = new_rx_count;
724 err = e1000e_setup_rx_resources(temp_rx);
729 /* ...then free the old resources and copy back any new ring data */
731 e1000e_free_tx_resources(adapter->tx_ring);
732 memcpy(adapter->tx_ring, temp_tx, size);
733 adapter->tx_ring_count = new_tx_count;
736 e1000e_free_rx_resources(adapter->rx_ring);
737 memcpy(adapter->rx_ring, temp_rx, size);
738 adapter->rx_ring_count = new_rx_count;
743 e1000e_free_tx_resources(temp_tx);
750 clear_bit(__E1000_RESETTING, &adapter->state);
754 static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data,
755 int reg, int offset, u32 mask, u32 write)
758 static const u32 test[] = {
759 0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
760 for (pat = 0; pat < ARRAY_SIZE(test); pat++) {
761 E1000_WRITE_REG_ARRAY(&adapter->hw, reg, offset,
762 (test[pat] & write));
763 val = E1000_READ_REG_ARRAY(&adapter->hw, reg, offset);
764 if (val != (test[pat] & write & mask)) {
765 e_err("pattern test failed (reg 0x%05X): got 0x%08X expected 0x%08X\n",
766 reg + (offset << 2), val,
767 (test[pat] & write & mask));
775 static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data,
776 int reg, u32 mask, u32 write)
779 __ew32(&adapter->hw, reg, write & mask);
780 val = __er32(&adapter->hw, reg);
781 if ((write & mask) != (val & mask)) {
782 e_err("set/check test failed (reg 0x%05X): got 0x%08X expected 0x%08X\n",
783 reg, (val & mask), (write & mask));
789 #define REG_PATTERN_TEST_ARRAY(reg, offset, mask, write) \
791 if (reg_pattern_test(adapter, data, reg, offset, mask, write)) \
794 #define REG_PATTERN_TEST(reg, mask, write) \
795 REG_PATTERN_TEST_ARRAY(reg, 0, mask, write)
797 #define REG_SET_AND_CHECK(reg, mask, write) \
799 if (reg_set_and_check(adapter, data, reg, mask, write)) \
803 static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
805 struct e1000_hw *hw = &adapter->hw;
806 struct e1000_mac_info *mac = &adapter->hw.mac;
815 /* The status register is Read Only, so a write should fail.
816 * Some bits that get toggled are ignored.
819 /* there are several bits on newer hardware that are r/w */
822 case e1000_80003es2lan:
830 before = er32(STATUS);
831 value = (er32(STATUS) & toggle);
832 ew32(STATUS, toggle);
833 after = er32(STATUS) & toggle;
834 if (value != after) {
835 e_err("failed STATUS register test got: 0x%08X expected: 0x%08X\n",
840 /* restore previous status */
841 ew32(STATUS, before);
843 if (!(adapter->flags & FLAG_IS_ICH)) {
844 REG_PATTERN_TEST(E1000_FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
845 REG_PATTERN_TEST(E1000_FCAH, 0x0000FFFF, 0xFFFFFFFF);
846 REG_PATTERN_TEST(E1000_FCT, 0x0000FFFF, 0xFFFFFFFF);
847 REG_PATTERN_TEST(E1000_VET, 0x0000FFFF, 0xFFFFFFFF);
850 REG_PATTERN_TEST(E1000_RDTR, 0x0000FFFF, 0xFFFFFFFF);
851 REG_PATTERN_TEST(E1000_RDBAH(0), 0xFFFFFFFF, 0xFFFFFFFF);
852 REG_PATTERN_TEST(E1000_RDLEN(0), 0x000FFF80, 0x000FFFFF);
853 REG_PATTERN_TEST(E1000_RDH(0), 0x0000FFFF, 0x0000FFFF);
854 REG_PATTERN_TEST(E1000_RDT(0), 0x0000FFFF, 0x0000FFFF);
855 REG_PATTERN_TEST(E1000_FCRTH, 0x0000FFF8, 0x0000FFF8);
856 REG_PATTERN_TEST(E1000_FCTTV, 0x0000FFFF, 0x0000FFFF);
857 REG_PATTERN_TEST(E1000_TIPG, 0x3FFFFFFF, 0x3FFFFFFF);
858 REG_PATTERN_TEST(E1000_TDBAH(0), 0xFFFFFFFF, 0xFFFFFFFF);
859 REG_PATTERN_TEST(E1000_TDLEN(0), 0x000FFF80, 0x000FFFFF);
861 REG_SET_AND_CHECK(E1000_RCTL, 0xFFFFFFFF, 0x00000000);
863 before = ((adapter->flags & FLAG_IS_ICH) ? 0x06C3B33E : 0x06DFB3FE);
864 REG_SET_AND_CHECK(E1000_RCTL, before, 0x003FFFFB);
865 REG_SET_AND_CHECK(E1000_TCTL, 0xFFFFFFFF, 0x00000000);
867 REG_SET_AND_CHECK(E1000_RCTL, before, 0xFFFFFFFF);
868 REG_PATTERN_TEST(E1000_RDBAL(0), 0xFFFFFFF0, 0xFFFFFFFF);
869 if (!(adapter->flags & FLAG_IS_ICH))
870 REG_PATTERN_TEST(E1000_TXCW, 0xC000FFFF, 0x0000FFFF);
871 REG_PATTERN_TEST(E1000_TDBAL(0), 0xFFFFFFF0, 0xFFFFFFFF);
872 REG_PATTERN_TEST(E1000_TIDV, 0x0000FFFF, 0x0000FFFF);
885 if (mac->type == e1000_pch_lpt)
886 wlock_mac = (er32(FWSM) & E1000_FWSM_WLOCK_MAC_MASK) >>
887 E1000_FWSM_WLOCK_MAC_SHIFT;
889 for (i = 0; i < mac->rar_entry_count; i++) {
890 if (mac->type == e1000_pch_lpt) {
891 /* Cannot test write-protected SHRAL[n] registers */
892 if ((wlock_mac == 1) || (wlock_mac && (i > wlock_mac)))
895 /* SHRAH[9] different than the others */
902 REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1), mask,
906 for (i = 0; i < mac->mta_reg_count; i++)
907 REG_PATTERN_TEST_ARRAY(E1000_MTA, i, 0xFFFFFFFF, 0xFFFFFFFF);
914 static int e1000_eeprom_test(struct e1000_adapter *adapter, u64 *data)
921 /* Read and add up the contents of the EEPROM */
922 for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
923 if ((e1000_read_nvm(&adapter->hw, i, 1, &temp)) < 0) {
930 /* If Checksum is not Correct return error else test passed */
931 if ((checksum != (u16) NVM_SUM) && !(*data))
937 static irqreturn_t e1000_test_intr(int __always_unused irq, void *data)
939 struct net_device *netdev = (struct net_device *) data;
940 struct e1000_adapter *adapter = netdev_priv(netdev);
941 struct e1000_hw *hw = &adapter->hw;
943 adapter->test_icr |= er32(ICR);
948 static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
950 struct net_device *netdev = adapter->netdev;
951 struct e1000_hw *hw = &adapter->hw;
954 u32 irq = adapter->pdev->irq;
957 int int_mode = E1000E_INT_MODE_LEGACY;
961 /* NOTE: we don't test MSI/MSI-X interrupts here, yet */
962 if (adapter->int_mode == E1000E_INT_MODE_MSIX) {
963 int_mode = adapter->int_mode;
964 e1000e_reset_interrupt_capability(adapter);
965 adapter->int_mode = E1000E_INT_MODE_LEGACY;
966 e1000e_set_interrupt_capability(adapter);
968 /* Hook up test interrupt handler just for this test */
969 if (!request_irq(irq, e1000_test_intr, IRQF_PROBE_SHARED, netdev->name,
972 } else if (request_irq(irq, e1000_test_intr, IRQF_SHARED,
973 netdev->name, netdev)) {
978 e_info("testing %s interrupt\n", (shared_int ? "shared" : "unshared"));
980 /* Disable all the interrupts */
981 ew32(IMC, 0xFFFFFFFF);
983 usleep_range(10000, 20000);
985 /* Test each interrupt */
986 for (i = 0; i < 10; i++) {
987 /* Interrupt to test */
990 if (adapter->flags & FLAG_IS_ICH) {
992 case E1000_ICR_RXSEQ:
995 if (adapter->hw.mac.type == e1000_ich8lan ||
996 adapter->hw.mac.type == e1000_ich9lan)
1005 /* Disable the interrupt to be reported in
1006 * the cause register and then force the same
1007 * interrupt and see if one gets posted. If
1008 * an interrupt was posted to the bus, the
1011 adapter->test_icr = 0;
1015 usleep_range(10000, 20000);
1017 if (adapter->test_icr & mask) {
1023 /* Enable the interrupt to be reported in
1024 * the cause register and then force the same
1025 * interrupt and see if one gets posted. If
1026 * an interrupt was not posted to the bus, the
1029 adapter->test_icr = 0;
1033 usleep_range(10000, 20000);
1035 if (!(adapter->test_icr & mask)) {
1041 /* Disable the other interrupts to be reported in
1042 * the cause register and then force the other
1043 * interrupts and see if any get posted. If
1044 * an interrupt was posted to the bus, the
1047 adapter->test_icr = 0;
1048 ew32(IMC, ~mask & 0x00007FFF);
1049 ew32(ICS, ~mask & 0x00007FFF);
1051 usleep_range(10000, 20000);
1053 if (adapter->test_icr) {
1060 /* Disable all the interrupts */
1061 ew32(IMC, 0xFFFFFFFF);
1063 usleep_range(10000, 20000);
1065 /* Unhook test interrupt handler */
1066 free_irq(irq, netdev);
1069 if (int_mode == E1000E_INT_MODE_MSIX) {
1070 e1000e_reset_interrupt_capability(adapter);
1071 adapter->int_mode = int_mode;
1072 e1000e_set_interrupt_capability(adapter);
1078 static void e1000_free_desc_rings(struct e1000_adapter *adapter)
1080 struct e1000_ring *tx_ring = &adapter->test_tx_ring;
1081 struct e1000_ring *rx_ring = &adapter->test_rx_ring;
1082 struct pci_dev *pdev = adapter->pdev;
1085 if (tx_ring->desc && tx_ring->buffer_info) {
1086 for (i = 0; i < tx_ring->count; i++) {
1087 if (tx_ring->buffer_info[i].dma)
1088 dma_unmap_single(&pdev->dev,
1089 tx_ring->buffer_info[i].dma,
1090 tx_ring->buffer_info[i].length,
1092 if (tx_ring->buffer_info[i].skb)
1093 dev_kfree_skb(tx_ring->buffer_info[i].skb);
1097 if (rx_ring->desc && rx_ring->buffer_info) {
1098 for (i = 0; i < rx_ring->count; i++) {
1099 if (rx_ring->buffer_info[i].dma)
1100 dma_unmap_single(&pdev->dev,
1101 rx_ring->buffer_info[i].dma,
1102 2048, DMA_FROM_DEVICE);
1103 if (rx_ring->buffer_info[i].skb)
1104 dev_kfree_skb(rx_ring->buffer_info[i].skb);
1108 if (tx_ring->desc) {
1109 dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc,
1111 tx_ring->desc = NULL;
1113 if (rx_ring->desc) {
1114 dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc,
1116 rx_ring->desc = NULL;
1119 kfree(tx_ring->buffer_info);
1120 tx_ring->buffer_info = NULL;
1121 kfree(rx_ring->buffer_info);
1122 rx_ring->buffer_info = NULL;
1125 static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1127 struct e1000_ring *tx_ring = &adapter->test_tx_ring;
1128 struct e1000_ring *rx_ring = &adapter->test_rx_ring;
1129 struct pci_dev *pdev = adapter->pdev;
1130 struct e1000_hw *hw = &adapter->hw;
1135 /* Setup Tx descriptor ring and Tx buffers */
1137 if (!tx_ring->count)
1138 tx_ring->count = E1000_DEFAULT_TXD;
1140 tx_ring->buffer_info = kcalloc(tx_ring->count,
1141 sizeof(struct e1000_buffer),
1143 if (!tx_ring->buffer_info) {
1148 tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc);
1149 tx_ring->size = ALIGN(tx_ring->size, 4096);
1150 tx_ring->desc = dma_alloc_coherent(&pdev->dev, tx_ring->size,
1151 &tx_ring->dma, GFP_KERNEL);
1152 if (!tx_ring->desc) {
1156 tx_ring->next_to_use = 0;
1157 tx_ring->next_to_clean = 0;
1159 ew32(TDBAL(0), ((u64) tx_ring->dma & 0x00000000FFFFFFFF));
1160 ew32(TDBAH(0), ((u64) tx_ring->dma >> 32));
1161 ew32(TDLEN(0), tx_ring->count * sizeof(struct e1000_tx_desc));
1164 ew32(TCTL, E1000_TCTL_PSP | E1000_TCTL_EN | E1000_TCTL_MULR |
1165 E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT |
1166 E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT);
1168 for (i = 0; i < tx_ring->count; i++) {
1169 struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*tx_ring, i);
1170 struct sk_buff *skb;
1171 unsigned int skb_size = 1024;
1173 skb = alloc_skb(skb_size, GFP_KERNEL);
1178 skb_put(skb, skb_size);
1179 tx_ring->buffer_info[i].skb = skb;
1180 tx_ring->buffer_info[i].length = skb->len;
1181 tx_ring->buffer_info[i].dma =
1182 dma_map_single(&pdev->dev, skb->data, skb->len,
1184 if (dma_mapping_error(&pdev->dev,
1185 tx_ring->buffer_info[i].dma)) {
1189 tx_desc->buffer_addr = cpu_to_le64(tx_ring->buffer_info[i].dma);
1190 tx_desc->lower.data = cpu_to_le32(skb->len);
1191 tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP |
1192 E1000_TXD_CMD_IFCS |
1194 tx_desc->upper.data = 0;
1197 /* Setup Rx descriptor ring and Rx buffers */
1199 if (!rx_ring->count)
1200 rx_ring->count = E1000_DEFAULT_RXD;
1202 rx_ring->buffer_info = kcalloc(rx_ring->count,
1203 sizeof(struct e1000_buffer),
1205 if (!rx_ring->buffer_info) {
1210 rx_ring->size = rx_ring->count * sizeof(union e1000_rx_desc_extended);
1211 rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size,
1212 &rx_ring->dma, GFP_KERNEL);
1213 if (!rx_ring->desc) {
1217 rx_ring->next_to_use = 0;
1218 rx_ring->next_to_clean = 0;
1221 if (!(adapter->flags2 & FLAG2_NO_DISABLE_RX))
1222 ew32(RCTL, rctl & ~E1000_RCTL_EN);
1223 ew32(RDBAL(0), ((u64) rx_ring->dma & 0xFFFFFFFF));
1224 ew32(RDBAH(0), ((u64) rx_ring->dma >> 32));
1225 ew32(RDLEN(0), rx_ring->size);
1228 rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 |
1229 E1000_RCTL_UPE | E1000_RCTL_MPE | E1000_RCTL_LPE |
1230 E1000_RCTL_SBP | E1000_RCTL_SECRC |
1231 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
1232 (adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
1235 for (i = 0; i < rx_ring->count; i++) {
1236 union e1000_rx_desc_extended *rx_desc;
1237 struct sk_buff *skb;
1239 skb = alloc_skb(2048 + NET_IP_ALIGN, GFP_KERNEL);
1244 skb_reserve(skb, NET_IP_ALIGN);
1245 rx_ring->buffer_info[i].skb = skb;
1246 rx_ring->buffer_info[i].dma =
1247 dma_map_single(&pdev->dev, skb->data, 2048,
1249 if (dma_mapping_error(&pdev->dev,
1250 rx_ring->buffer_info[i].dma)) {
1254 rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
1255 rx_desc->read.buffer_addr =
1256 cpu_to_le64(rx_ring->buffer_info[i].dma);
1257 memset(skb->data, 0x00, skb->len);
1263 e1000_free_desc_rings(adapter);
1267 static void e1000_phy_disable_receiver(struct e1000_adapter *adapter)
1269 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1270 e1e_wphy(&adapter->hw, 29, 0x001F);
1271 e1e_wphy(&adapter->hw, 30, 0x8FFC);
1272 e1e_wphy(&adapter->hw, 29, 0x001A);
1273 e1e_wphy(&adapter->hw, 30, 0x8FF0);
1276 static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1278 struct e1000_hw *hw = &adapter->hw;
1283 hw->mac.autoneg = 0;
1285 if (hw->phy.type == e1000_phy_ife) {
1286 /* force 100, set loopback */
1287 e1e_wphy(hw, MII_BMCR, 0x6100);
1289 /* Now set up the MAC to the same speed/duplex as the PHY. */
1290 ctrl_reg = er32(CTRL);
1291 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
1292 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1293 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1294 E1000_CTRL_SPD_100 |/* Force Speed to 100 */
1295 E1000_CTRL_FD); /* Force Duplex to FULL */
1297 ew32(CTRL, ctrl_reg);
1304 /* Specific PHY configuration for loopback */
1305 switch (hw->phy.type) {
1307 /* Auto-MDI/MDIX Off */
1308 e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, 0x0808);
1309 /* reset to update Auto-MDI/MDIX */
1310 e1e_wphy(hw, MII_BMCR, 0x9140);
1312 e1e_wphy(hw, MII_BMCR, 0x8140);
1314 case e1000_phy_gg82563:
1315 e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x1CC);
1318 /* Set Default MAC Interface speed to 1GB */
1319 e1e_rphy(hw, PHY_REG(2, 21), &phy_reg);
1322 e1e_wphy(hw, PHY_REG(2, 21), phy_reg);
1323 /* Assert SW reset for above settings to take effect */
1324 hw->phy.ops.commit(hw);
1326 /* Force Full Duplex */
1327 e1e_rphy(hw, PHY_REG(769, 16), &phy_reg);
1328 e1e_wphy(hw, PHY_REG(769, 16), phy_reg | 0x000C);
1329 /* Set Link Up (in force link) */
1330 e1e_rphy(hw, PHY_REG(776, 16), &phy_reg);
1331 e1e_wphy(hw, PHY_REG(776, 16), phy_reg | 0x0040);
1333 e1e_rphy(hw, PHY_REG(769, 16), &phy_reg);
1334 e1e_wphy(hw, PHY_REG(769, 16), phy_reg | 0x0040);
1335 /* Set Early Link Enable */
1336 e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
1337 e1e_wphy(hw, PHY_REG(769, 20), phy_reg | 0x0400);
1339 case e1000_phy_82577:
1340 case e1000_phy_82578:
1341 /* Workaround: K1 must be disabled for stable 1Gbps operation */
1342 ret_val = hw->phy.ops.acquire(hw);
1344 e_err("Cannot setup 1Gbps loopback.\n");
1347 e1000_configure_k1_ich8lan(hw, false);
1348 hw->phy.ops.release(hw);
1350 case e1000_phy_82579:
1351 /* Disable PHY energy detect power down */
1352 e1e_rphy(hw, PHY_REG(0, 21), &phy_reg);
1353 e1e_wphy(hw, PHY_REG(0, 21), phy_reg & ~(1 << 3));
1354 /* Disable full chip energy detect */
1355 e1e_rphy(hw, PHY_REG(776, 18), &phy_reg);
1356 e1e_wphy(hw, PHY_REG(776, 18), phy_reg | 1);
1357 /* Enable loopback on the PHY */
1358 e1e_wphy(hw, I82577_PHY_LBK_CTRL, 0x8001);
1364 /* force 1000, set loopback */
1365 e1e_wphy(hw, MII_BMCR, 0x4140);
1368 /* Now set up the MAC to the same speed/duplex as the PHY. */
1369 ctrl_reg = er32(CTRL);
1370 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
1371 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1372 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1373 E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
1374 E1000_CTRL_FD); /* Force Duplex to FULL */
1376 if (adapter->flags & FLAG_IS_ICH)
1377 ctrl_reg |= E1000_CTRL_SLU; /* Set Link Up */
1379 if (hw->phy.media_type == e1000_media_type_copper &&
1380 hw->phy.type == e1000_phy_m88) {
1381 ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
1383 /* Set the ILOS bit on the fiber Nic if half duplex link is
1386 if ((er32(STATUS) & E1000_STATUS_FD) == 0)
1387 ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
1390 ew32(CTRL, ctrl_reg);
1392 /* Disable the receiver on the PHY so when a cable is plugged in, the
1393 * PHY does not begin to autoneg when a cable is reconnected to the NIC.
1395 if (hw->phy.type == e1000_phy_m88)
1396 e1000_phy_disable_receiver(adapter);
1403 static int e1000_set_82571_fiber_loopback(struct e1000_adapter *adapter)
1405 struct e1000_hw *hw = &adapter->hw;
1406 u32 ctrl = er32(CTRL);
1409 /* special requirements for 82571/82572 fiber adapters */
1411 /* jump through hoops to make sure link is up because serdes
1412 * link is hardwired up
1414 ctrl |= E1000_CTRL_SLU;
1417 /* disable autoneg */
1422 link = (er32(STATUS) & E1000_STATUS_LU);
1425 /* set invert loss of signal */
1427 ctrl |= E1000_CTRL_ILOS;
1431 /* special write to serdes control register to enable SerDes analog
1434 #define E1000_SERDES_LB_ON 0x410
1435 ew32(SCTL, E1000_SERDES_LB_ON);
1437 usleep_range(10000, 20000);
1442 /* only call this for fiber/serdes connections to es2lan */
1443 static int e1000_set_es2lan_mac_loopback(struct e1000_adapter *adapter)
1445 struct e1000_hw *hw = &adapter->hw;
1446 u32 ctrlext = er32(CTRL_EXT);
1447 u32 ctrl = er32(CTRL);
1449 /* save CTRL_EXT to restore later, reuse an empty variable (unused
1450 * on mac_type 80003es2lan)
1452 adapter->tx_fifo_head = ctrlext;
1454 /* clear the serdes mode bits, putting the device into mac loopback */
1455 ctrlext &= ~E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES;
1456 ew32(CTRL_EXT, ctrlext);
1458 /* force speed to 1000/FD, link up */
1459 ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
1460 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX |
1461 E1000_CTRL_SPD_1000 | E1000_CTRL_FD);
1464 /* set mac loopback */
1466 ctrl |= E1000_RCTL_LBM_MAC;
1469 /* set testing mode parameters (no need to reset later) */
1470 #define KMRNCTRLSTA_OPMODE (0x1F << 16)
1471 #define KMRNCTRLSTA_OPMODE_1GB_FD_GMII 0x0582
1473 (KMRNCTRLSTA_OPMODE | KMRNCTRLSTA_OPMODE_1GB_FD_GMII));
1478 static int e1000_setup_loopback_test(struct e1000_adapter *adapter)
1480 struct e1000_hw *hw = &adapter->hw;
1483 if (hw->phy.media_type == e1000_media_type_fiber ||
1484 hw->phy.media_type == e1000_media_type_internal_serdes) {
1485 switch (hw->mac.type) {
1486 case e1000_80003es2lan:
1487 return e1000_set_es2lan_mac_loopback(adapter);
1491 return e1000_set_82571_fiber_loopback(adapter);
1495 rctl |= E1000_RCTL_LBM_TCVR;
1499 } else if (hw->phy.media_type == e1000_media_type_copper) {
1500 return e1000_integrated_phy_loopback(adapter);
1506 static void e1000_loopback_cleanup(struct e1000_adapter *adapter)
1508 struct e1000_hw *hw = &adapter->hw;
1513 rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
1516 switch (hw->mac.type) {
1517 case e1000_80003es2lan:
1518 if (hw->phy.media_type == e1000_media_type_fiber ||
1519 hw->phy.media_type == e1000_media_type_internal_serdes) {
1520 /* restore CTRL_EXT, stealing space from tx_fifo_head */
1521 ew32(CTRL_EXT, adapter->tx_fifo_head);
1522 adapter->tx_fifo_head = 0;
1527 if (hw->phy.media_type == e1000_media_type_fiber ||
1528 hw->phy.media_type == e1000_media_type_internal_serdes) {
1529 #define E1000_SERDES_LB_OFF 0x400
1530 ew32(SCTL, E1000_SERDES_LB_OFF);
1532 usleep_range(10000, 20000);
1537 hw->mac.autoneg = 1;
1538 if (hw->phy.type == e1000_phy_gg82563)
1539 e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x180);
1540 e1e_rphy(hw, MII_BMCR, &phy_reg);
1541 if (phy_reg & BMCR_LOOPBACK) {
1542 phy_reg &= ~BMCR_LOOPBACK;
1543 e1e_wphy(hw, MII_BMCR, phy_reg);
1544 if (hw->phy.ops.commit)
1545 hw->phy.ops.commit(hw);
1551 static void e1000_create_lbtest_frame(struct sk_buff *skb,
1552 unsigned int frame_size)
1554 memset(skb->data, 0xFF, frame_size);
1556 memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
1557 memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
1558 memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
1561 static int e1000_check_lbtest_frame(struct sk_buff *skb,
1562 unsigned int frame_size)
1565 if (*(skb->data + 3) == 0xFF)
1566 if ((*(skb->data + frame_size / 2 + 10) == 0xBE) &&
1567 (*(skb->data + frame_size / 2 + 12) == 0xAF))
1572 static int e1000_run_loopback_test(struct e1000_adapter *adapter)
1574 struct e1000_ring *tx_ring = &adapter->test_tx_ring;
1575 struct e1000_ring *rx_ring = &adapter->test_rx_ring;
1576 struct pci_dev *pdev = adapter->pdev;
1577 struct e1000_hw *hw = &adapter->hw;
1584 ew32(RDT(0), rx_ring->count - 1);
1586 /* Calculate the loop count based on the largest descriptor ring
1587 * The idea is to wrap the largest ring a number of times using 64
1588 * send/receive pairs during each loop
1591 if (rx_ring->count <= tx_ring->count)
1592 lc = ((tx_ring->count / 64) * 2) + 1;
1594 lc = ((rx_ring->count / 64) * 2) + 1;
1598 for (j = 0; j <= lc; j++) { /* loop count loop */
1599 for (i = 0; i < 64; i++) { /* send the packets */
1600 e1000_create_lbtest_frame(tx_ring->buffer_info[k].skb,
1602 dma_sync_single_for_device(&pdev->dev,
1603 tx_ring->buffer_info[k].dma,
1604 tx_ring->buffer_info[k].length,
1607 if (k == tx_ring->count)
1613 time = jiffies; /* set the start time for the receive */
1615 do { /* receive the sent packets */
1616 dma_sync_single_for_cpu(&pdev->dev,
1617 rx_ring->buffer_info[l].dma, 2048,
1620 ret_val = e1000_check_lbtest_frame(
1621 rx_ring->buffer_info[l].skb, 1024);
1625 if (l == rx_ring->count)
1627 /* time + 20 msecs (200 msecs on 2.4) is more than
1628 * enough time to complete the receives, if it's
1629 * exceeded, break and error off
1631 } while ((good_cnt < 64) && !time_after(jiffies, time + 20));
1632 if (good_cnt != 64) {
1633 ret_val = 13; /* ret_val is the same as mis-compare */
1636 if (jiffies >= (time + 20)) {
1637 ret_val = 14; /* error code for time out error */
1640 } /* end loop count loop */
1644 static int e1000_loopback_test(struct e1000_adapter *adapter, u64 *data)
1646 struct e1000_hw *hw = &adapter->hw;
1648 /* PHY loopback cannot be performed if SoL/IDER sessions are active */
1649 if (hw->phy.ops.check_reset_block &&
1650 hw->phy.ops.check_reset_block(hw)) {
1651 e_err("Cannot do PHY loopback test when SoL/IDER is active.\n");
1656 *data = e1000_setup_desc_rings(adapter);
1660 *data = e1000_setup_loopback_test(adapter);
1664 *data = e1000_run_loopback_test(adapter);
1665 e1000_loopback_cleanup(adapter);
1668 e1000_free_desc_rings(adapter);
1673 static int e1000_link_test(struct e1000_adapter *adapter, u64 *data)
1675 struct e1000_hw *hw = &adapter->hw;
1678 if (hw->phy.media_type == e1000_media_type_internal_serdes) {
1680 hw->mac.serdes_has_link = false;
1682 /* On some blade server designs, link establishment
1683 * could take as long as 2-3 minutes
1686 hw->mac.ops.check_for_link(hw);
1687 if (hw->mac.serdes_has_link)
1690 } while (i++ < 3750);
1694 hw->mac.ops.check_for_link(hw);
1695 if (hw->mac.autoneg)
1696 /* On some Phy/switch combinations, link establishment
1697 * can take a few seconds more than expected.
1701 if (!(er32(STATUS) & E1000_STATUS_LU))
1707 static int e1000e_get_sset_count(struct net_device __always_unused *netdev,
1712 return E1000_TEST_LEN;
1714 return E1000_STATS_LEN;
1720 static void e1000_diag_test(struct net_device *netdev,
1721 struct ethtool_test *eth_test, u64 *data)
1723 struct e1000_adapter *adapter = netdev_priv(netdev);
1724 u16 autoneg_advertised;
1725 u8 forced_speed_duplex;
1727 bool if_running = netif_running(netdev);
1729 set_bit(__E1000_TESTING, &adapter->state);
1732 /* Get control of and reset hardware */
1733 if (adapter->flags & FLAG_HAS_AMT)
1734 e1000e_get_hw_control(adapter);
1736 e1000e_power_up_phy(adapter);
1738 adapter->hw.phy.autoneg_wait_to_complete = 1;
1739 e1000e_reset(adapter);
1740 adapter->hw.phy.autoneg_wait_to_complete = 0;
1743 if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
1746 /* save speed, duplex, autoneg settings */
1747 autoneg_advertised = adapter->hw.phy.autoneg_advertised;
1748 forced_speed_duplex = adapter->hw.mac.forced_speed_duplex;
1749 autoneg = adapter->hw.mac.autoneg;
1751 e_info("offline testing starting\n");
1754 /* indicate we're in test mode */
1757 if (e1000_reg_test(adapter, &data[0]))
1758 eth_test->flags |= ETH_TEST_FL_FAILED;
1760 e1000e_reset(adapter);
1761 if (e1000_eeprom_test(adapter, &data[1]))
1762 eth_test->flags |= ETH_TEST_FL_FAILED;
1764 e1000e_reset(adapter);
1765 if (e1000_intr_test(adapter, &data[2]))
1766 eth_test->flags |= ETH_TEST_FL_FAILED;
1768 e1000e_reset(adapter);
1769 if (e1000_loopback_test(adapter, &data[3]))
1770 eth_test->flags |= ETH_TEST_FL_FAILED;
1772 /* force this routine to wait until autoneg complete/timeout */
1773 adapter->hw.phy.autoneg_wait_to_complete = 1;
1774 e1000e_reset(adapter);
1775 adapter->hw.phy.autoneg_wait_to_complete = 0;
1777 if (e1000_link_test(adapter, &data[4]))
1778 eth_test->flags |= ETH_TEST_FL_FAILED;
1780 /* restore speed, duplex, autoneg settings */
1781 adapter->hw.phy.autoneg_advertised = autoneg_advertised;
1782 adapter->hw.mac.forced_speed_duplex = forced_speed_duplex;
1783 adapter->hw.mac.autoneg = autoneg;
1784 e1000e_reset(adapter);
1786 clear_bit(__E1000_TESTING, &adapter->state);
1792 e_info("online testing starting\n");
1794 /* register, eeprom, intr and loopback tests not run online */
1800 if (e1000_link_test(adapter, &data[4]))
1801 eth_test->flags |= ETH_TEST_FL_FAILED;
1803 clear_bit(__E1000_TESTING, &adapter->state);
1807 e1000e_reset(adapter);
1809 if (adapter->flags & FLAG_HAS_AMT)
1810 e1000e_release_hw_control(adapter);
1813 msleep_interruptible(4 * 1000);
1816 static void e1000_get_wol(struct net_device *netdev,
1817 struct ethtool_wolinfo *wol)
1819 struct e1000_adapter *adapter = netdev_priv(netdev);
1824 if (!(adapter->flags & FLAG_HAS_WOL) ||
1825 !device_can_wakeup(&adapter->pdev->dev))
1828 wol->supported = WAKE_UCAST | WAKE_MCAST |
1829 WAKE_BCAST | WAKE_MAGIC | WAKE_PHY;
1831 /* apply any specific unsupported masks here */
1832 if (adapter->flags & FLAG_NO_WAKE_UCAST) {
1833 wol->supported &= ~WAKE_UCAST;
1835 if (adapter->wol & E1000_WUFC_EX)
1836 e_err("Interface does not support directed (unicast) frame wake-up packets\n");
1839 if (adapter->wol & E1000_WUFC_EX)
1840 wol->wolopts |= WAKE_UCAST;
1841 if (adapter->wol & E1000_WUFC_MC)
1842 wol->wolopts |= WAKE_MCAST;
1843 if (adapter->wol & E1000_WUFC_BC)
1844 wol->wolopts |= WAKE_BCAST;
1845 if (adapter->wol & E1000_WUFC_MAG)
1846 wol->wolopts |= WAKE_MAGIC;
1847 if (adapter->wol & E1000_WUFC_LNKC)
1848 wol->wolopts |= WAKE_PHY;
1851 static int e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1853 struct e1000_adapter *adapter = netdev_priv(netdev);
1855 if (!(adapter->flags & FLAG_HAS_WOL) ||
1856 !device_can_wakeup(&adapter->pdev->dev) ||
1857 (wol->wolopts & ~(WAKE_UCAST | WAKE_MCAST | WAKE_BCAST |
1858 WAKE_MAGIC | WAKE_PHY)))
1861 /* these settings will always override what we currently have */
1864 if (wol->wolopts & WAKE_UCAST)
1865 adapter->wol |= E1000_WUFC_EX;
1866 if (wol->wolopts & WAKE_MCAST)
1867 adapter->wol |= E1000_WUFC_MC;
1868 if (wol->wolopts & WAKE_BCAST)
1869 adapter->wol |= E1000_WUFC_BC;
1870 if (wol->wolopts & WAKE_MAGIC)
1871 adapter->wol |= E1000_WUFC_MAG;
1872 if (wol->wolopts & WAKE_PHY)
1873 adapter->wol |= E1000_WUFC_LNKC;
1875 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
1880 static int e1000_set_phys_id(struct net_device *netdev,
1881 enum ethtool_phys_id_state state)
1883 struct e1000_adapter *adapter = netdev_priv(netdev);
1884 struct e1000_hw *hw = &adapter->hw;
1887 case ETHTOOL_ID_ACTIVE:
1888 if (!hw->mac.ops.blink_led)
1889 return 2; /* cycle on/off twice per second */
1891 hw->mac.ops.blink_led(hw);
1894 case ETHTOOL_ID_INACTIVE:
1895 if (hw->phy.type == e1000_phy_ife)
1896 e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
1897 hw->mac.ops.led_off(hw);
1898 hw->mac.ops.cleanup_led(hw);
1902 hw->mac.ops.led_on(hw);
1905 case ETHTOOL_ID_OFF:
1906 hw->mac.ops.led_off(hw);
1912 static int e1000_get_coalesce(struct net_device *netdev,
1913 struct ethtool_coalesce *ec)
1915 struct e1000_adapter *adapter = netdev_priv(netdev);
1917 if (adapter->itr_setting <= 4)
1918 ec->rx_coalesce_usecs = adapter->itr_setting;
1920 ec->rx_coalesce_usecs = 1000000 / adapter->itr_setting;
1925 static int e1000_set_coalesce(struct net_device *netdev,
1926 struct ethtool_coalesce *ec)
1928 struct e1000_adapter *adapter = netdev_priv(netdev);
1930 if ((ec->rx_coalesce_usecs > E1000_MAX_ITR_USECS) ||
1931 ((ec->rx_coalesce_usecs > 4) &&
1932 (ec->rx_coalesce_usecs < E1000_MIN_ITR_USECS)) ||
1933 (ec->rx_coalesce_usecs == 2))
1936 if (ec->rx_coalesce_usecs == 4) {
1937 adapter->itr_setting = 4;
1938 adapter->itr = adapter->itr_setting;
1939 } else if (ec->rx_coalesce_usecs <= 3) {
1940 adapter->itr = 20000;
1941 adapter->itr_setting = ec->rx_coalesce_usecs;
1943 adapter->itr = (1000000 / ec->rx_coalesce_usecs);
1944 adapter->itr_setting = adapter->itr & ~3;
1947 if (adapter->itr_setting != 0)
1948 e1000e_write_itr(adapter, adapter->itr);
1950 e1000e_write_itr(adapter, 0);
1955 static int e1000_nway_reset(struct net_device *netdev)
1957 struct e1000_adapter *adapter = netdev_priv(netdev);
1959 if (!netif_running(netdev))
1962 if (!adapter->hw.mac.autoneg)
1965 e1000e_reinit_locked(adapter);
1970 static void e1000_get_ethtool_stats(struct net_device *netdev,
1971 struct ethtool_stats __always_unused *stats,
1974 struct e1000_adapter *adapter = netdev_priv(netdev);
1975 struct rtnl_link_stats64 net_stats;
1979 e1000e_get_stats64(netdev, &net_stats);
1980 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
1981 switch (e1000_gstrings_stats[i].type) {
1983 p = (char *) &net_stats +
1984 e1000_gstrings_stats[i].stat_offset;
1987 p = (char *) adapter +
1988 e1000_gstrings_stats[i].stat_offset;
1995 data[i] = (e1000_gstrings_stats[i].sizeof_stat ==
1996 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
2000 static void e1000_get_strings(struct net_device __always_unused *netdev,
2001 u32 stringset, u8 *data)
2006 switch (stringset) {
2008 memcpy(data, e1000_gstrings_test, sizeof(e1000_gstrings_test));
2011 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
2012 memcpy(p, e1000_gstrings_stats[i].stat_string,
2014 p += ETH_GSTRING_LEN;
2020 static int e1000_get_rxnfc(struct net_device *netdev,
2021 struct ethtool_rxnfc *info,
2022 u32 __always_unused *rule_locs)
2026 switch (info->cmd) {
2027 case ETHTOOL_GRXFH: {
2028 struct e1000_adapter *adapter = netdev_priv(netdev);
2029 struct e1000_hw *hw = &adapter->hw;
2030 u32 mrqc = er32(MRQC);
2032 if (!(mrqc & E1000_MRQC_RSS_FIELD_MASK))
2035 switch (info->flow_type) {
2037 if (mrqc & E1000_MRQC_RSS_FIELD_IPV4_TCP)
2038 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
2042 case AH_ESP_V4_FLOW:
2044 if (mrqc & E1000_MRQC_RSS_FIELD_IPV4)
2045 info->data |= RXH_IP_SRC | RXH_IP_DST;
2048 if (mrqc & E1000_MRQC_RSS_FIELD_IPV6_TCP)
2049 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
2053 case AH_ESP_V6_FLOW:
2055 if (mrqc & E1000_MRQC_RSS_FIELD_IPV6)
2056 info->data |= RXH_IP_SRC | RXH_IP_DST;
2068 static int e1000e_get_eee(struct net_device *netdev, struct ethtool_eee *edata)
2070 struct e1000_adapter *adapter = netdev_priv(netdev);
2071 struct e1000_hw *hw = &adapter->hw;
2072 u16 cap_addr, adv_addr, lpa_addr, pcs_stat_addr, phy_data, lpi_ctrl;
2073 u32 status, ret_val;
2075 if (!(adapter->flags & FLAG_IS_ICH) ||
2076 !(adapter->flags2 & FLAG2_HAS_EEE))
2079 switch (hw->phy.type) {
2080 case e1000_phy_82579:
2081 cap_addr = I82579_EEE_CAPABILITY;
2082 adv_addr = I82579_EEE_ADVERTISEMENT;
2083 lpa_addr = I82579_EEE_LP_ABILITY;
2084 pcs_stat_addr = I82579_EEE_PCS_STATUS;
2086 case e1000_phy_i217:
2087 cap_addr = I217_EEE_CAPABILITY;
2088 adv_addr = I217_EEE_ADVERTISEMENT;
2089 lpa_addr = I217_EEE_LP_ABILITY;
2090 pcs_stat_addr = I217_EEE_PCS_STATUS;
2096 ret_val = hw->phy.ops.acquire(hw);
2100 /* EEE Capability */
2101 ret_val = e1000_read_emi_reg_locked(hw, cap_addr, &phy_data);
2104 edata->supported = mmd_eee_cap_to_ethtool_sup_t(phy_data);
2106 /* EEE Advertised */
2107 ret_val = e1000_read_emi_reg_locked(hw, adv_addr, &phy_data);
2110 edata->advertised = mmd_eee_adv_to_ethtool_adv_t(phy_data);
2112 /* EEE Link Partner Advertised */
2113 ret_val = e1000_read_emi_reg_locked(hw, lpa_addr, &phy_data);
2116 edata->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(phy_data);
2118 /* EEE PCS Status */
2119 ret_val = e1000_read_emi_reg_locked(hw, pcs_stat_addr, &phy_data);
2120 if (hw->phy.type == e1000_phy_82579)
2124 hw->phy.ops.release(hw);
2128 e1e_rphy(hw, I82579_LPI_CTRL, &lpi_ctrl);
2129 status = er32(STATUS);
2131 /* Result of the EEE auto negotiation - there is no register that
2132 * has the status of the EEE negotiation so do a best-guess based
2133 * on whether both Tx and Rx LPI indications have been received or
2134 * base it on the link speed, the EEE advertised speeds on both ends
2135 * and the speeds on which EEE is enabled locally.
2137 if (((phy_data & E1000_EEE_TX_LPI_RCVD) &&
2138 (phy_data & E1000_EEE_RX_LPI_RCVD)) ||
2139 ((status & E1000_STATUS_SPEED_100) &&
2140 (edata->advertised & ADVERTISED_100baseT_Full) &&
2141 (edata->lp_advertised & ADVERTISED_100baseT_Full) &&
2142 (lpi_ctrl & I82579_LPI_CTRL_100_ENABLE)) ||
2143 ((status & E1000_STATUS_SPEED_1000) &&
2144 (edata->advertised & ADVERTISED_1000baseT_Full) &&
2145 (edata->lp_advertised & ADVERTISED_1000baseT_Full) &&
2146 (lpi_ctrl & I82579_LPI_CTRL_1000_ENABLE)))
2147 edata->eee_active = true;
2149 edata->eee_enabled = !hw->dev_spec.ich8lan.eee_disable;
2150 edata->tx_lpi_enabled = true;
2151 edata->tx_lpi_timer = er32(LPIC) >> E1000_LPIC_LPIET_SHIFT;
2156 static int e1000e_set_eee(struct net_device *netdev, struct ethtool_eee *edata)
2158 struct e1000_adapter *adapter = netdev_priv(netdev);
2159 struct e1000_hw *hw = &adapter->hw;
2160 struct ethtool_eee eee_curr;
2163 if (!(adapter->flags & FLAG_IS_ICH) ||
2164 !(adapter->flags2 & FLAG2_HAS_EEE))
2167 ret_val = e1000e_get_eee(netdev, &eee_curr);
2171 if (eee_curr.advertised != edata->advertised) {
2172 e_err("Setting EEE advertisement is not supported\n");
2176 if (eee_curr.tx_lpi_enabled != edata->tx_lpi_enabled) {
2177 e_err("Setting EEE tx-lpi is not supported\n");
2181 if (eee_curr.tx_lpi_timer != edata->tx_lpi_timer) {
2182 e_err("Setting EEE Tx LPI timer is not supported\n");
2186 if (hw->dev_spec.ich8lan.eee_disable != !edata->eee_enabled) {
2187 hw->dev_spec.ich8lan.eee_disable = !edata->eee_enabled;
2189 /* reset the link */
2190 if (netif_running(netdev))
2191 e1000e_reinit_locked(adapter);
2193 e1000e_reset(adapter);
2199 static int e1000e_get_ts_info(struct net_device *netdev,
2200 struct ethtool_ts_info *info)
2202 struct e1000_adapter *adapter = netdev_priv(netdev);
2204 ethtool_op_get_ts_info(netdev, info);
2206 if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP))
2209 info->so_timestamping |= (SOF_TIMESTAMPING_TX_HARDWARE |
2210 SOF_TIMESTAMPING_RX_HARDWARE |
2211 SOF_TIMESTAMPING_RAW_HARDWARE);
2213 info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON);
2215 info->rx_filters = ((1 << HWTSTAMP_FILTER_NONE) |
2216 (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
2217 (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
2218 (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) |
2219 (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) |
2220 (1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
2221 (1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) |
2222 (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
2223 (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
2224 (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) |
2225 (1 << HWTSTAMP_FILTER_ALL));
2227 if (adapter->ptp_clock)
2228 info->phc_index = ptp_clock_index(adapter->ptp_clock);
2233 static int e1000e_ethtool_begin(struct net_device *netdev)
2235 return pm_runtime_get_sync(netdev->dev.parent);
2238 static void e1000e_ethtool_complete(struct net_device *netdev)
2240 pm_runtime_put_sync(netdev->dev.parent);
2243 static const struct ethtool_ops e1000_ethtool_ops = {
2244 .begin = e1000e_ethtool_begin,
2245 .complete = e1000e_ethtool_complete,
2246 .get_settings = e1000_get_settings,
2247 .set_settings = e1000_set_settings,
2248 .get_drvinfo = e1000_get_drvinfo,
2249 .get_regs_len = e1000_get_regs_len,
2250 .get_regs = e1000_get_regs,
2251 .get_wol = e1000_get_wol,
2252 .set_wol = e1000_set_wol,
2253 .get_msglevel = e1000_get_msglevel,
2254 .set_msglevel = e1000_set_msglevel,
2255 .nway_reset = e1000_nway_reset,
2256 .get_link = ethtool_op_get_link,
2257 .get_eeprom_len = e1000_get_eeprom_len,
2258 .get_eeprom = e1000_get_eeprom,
2259 .set_eeprom = e1000_set_eeprom,
2260 .get_ringparam = e1000_get_ringparam,
2261 .set_ringparam = e1000_set_ringparam,
2262 .get_pauseparam = e1000_get_pauseparam,
2263 .set_pauseparam = e1000_set_pauseparam,
2264 .self_test = e1000_diag_test,
2265 .get_strings = e1000_get_strings,
2266 .set_phys_id = e1000_set_phys_id,
2267 .get_ethtool_stats = e1000_get_ethtool_stats,
2268 .get_sset_count = e1000e_get_sset_count,
2269 .get_coalesce = e1000_get_coalesce,
2270 .set_coalesce = e1000_set_coalesce,
2271 .get_rxnfc = e1000_get_rxnfc,
2272 .get_ts_info = e1000e_get_ts_info,
2273 .get_eee = e1000e_get_eee,
2274 .set_eee = e1000e_set_eee,
2277 void e1000e_set_ethtool_ops(struct net_device *netdev)
2279 SET_ETHTOOL_OPS(netdev, &e1000_ethtool_ops);