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>
42 enum { NETDEV_STATS, E1000_STATS };
45 char stat_string[ETH_GSTRING_LEN];
51 #define E1000_STAT(str, m) { \
53 .type = E1000_STATS, \
54 .sizeof_stat = sizeof(((struct e1000_adapter *)0)->m), \
55 .stat_offset = offsetof(struct e1000_adapter, m) }
56 #define E1000_NETDEV_STAT(str, m) { \
58 .type = NETDEV_STATS, \
59 .sizeof_stat = sizeof(((struct rtnl_link_stats64 *)0)->m), \
60 .stat_offset = offsetof(struct rtnl_link_stats64, m) }
62 static const struct e1000_stats e1000_gstrings_stats[] = {
63 E1000_STAT("rx_packets", stats.gprc),
64 E1000_STAT("tx_packets", stats.gptc),
65 E1000_STAT("rx_bytes", stats.gorc),
66 E1000_STAT("tx_bytes", stats.gotc),
67 E1000_STAT("rx_broadcast", stats.bprc),
68 E1000_STAT("tx_broadcast", stats.bptc),
69 E1000_STAT("rx_multicast", stats.mprc),
70 E1000_STAT("tx_multicast", stats.mptc),
71 E1000_NETDEV_STAT("rx_errors", rx_errors),
72 E1000_NETDEV_STAT("tx_errors", tx_errors),
73 E1000_NETDEV_STAT("tx_dropped", tx_dropped),
74 E1000_STAT("multicast", stats.mprc),
75 E1000_STAT("collisions", stats.colc),
76 E1000_NETDEV_STAT("rx_length_errors", rx_length_errors),
77 E1000_NETDEV_STAT("rx_over_errors", rx_over_errors),
78 E1000_STAT("rx_crc_errors", stats.crcerrs),
79 E1000_NETDEV_STAT("rx_frame_errors", rx_frame_errors),
80 E1000_STAT("rx_no_buffer_count", stats.rnbc),
81 E1000_STAT("rx_missed_errors", stats.mpc),
82 E1000_STAT("tx_aborted_errors", stats.ecol),
83 E1000_STAT("tx_carrier_errors", stats.tncrs),
84 E1000_NETDEV_STAT("tx_fifo_errors", tx_fifo_errors),
85 E1000_NETDEV_STAT("tx_heartbeat_errors", tx_heartbeat_errors),
86 E1000_STAT("tx_window_errors", stats.latecol),
87 E1000_STAT("tx_abort_late_coll", stats.latecol),
88 E1000_STAT("tx_deferred_ok", stats.dc),
89 E1000_STAT("tx_single_coll_ok", stats.scc),
90 E1000_STAT("tx_multi_coll_ok", stats.mcc),
91 E1000_STAT("tx_timeout_count", tx_timeout_count),
92 E1000_STAT("tx_restart_queue", restart_queue),
93 E1000_STAT("rx_long_length_errors", stats.roc),
94 E1000_STAT("rx_short_length_errors", stats.ruc),
95 E1000_STAT("rx_align_errors", stats.algnerrc),
96 E1000_STAT("tx_tcp_seg_good", stats.tsctc),
97 E1000_STAT("tx_tcp_seg_failed", stats.tsctfc),
98 E1000_STAT("rx_flow_control_xon", stats.xonrxc),
99 E1000_STAT("rx_flow_control_xoff", stats.xoffrxc),
100 E1000_STAT("tx_flow_control_xon", stats.xontxc),
101 E1000_STAT("tx_flow_control_xoff", stats.xofftxc),
102 E1000_STAT("rx_csum_offload_good", hw_csum_good),
103 E1000_STAT("rx_csum_offload_errors", hw_csum_err),
104 E1000_STAT("rx_header_split", rx_hdr_split),
105 E1000_STAT("alloc_rx_buff_failed", alloc_rx_buff_failed),
106 E1000_STAT("tx_smbus", stats.mgptc),
107 E1000_STAT("rx_smbus", stats.mgprc),
108 E1000_STAT("dropped_smbus", stats.mgpdc),
109 E1000_STAT("rx_dma_failed", rx_dma_failed),
110 E1000_STAT("tx_dma_failed", tx_dma_failed),
111 E1000_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared),
112 E1000_STAT("uncorr_ecc_errors", uncorr_errors),
113 E1000_STAT("corr_ecc_errors", corr_errors),
116 #define E1000_GLOBAL_STATS_LEN ARRAY_SIZE(e1000_gstrings_stats)
117 #define E1000_STATS_LEN (E1000_GLOBAL_STATS_LEN)
118 static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = {
119 "Register test (offline)", "Eeprom test (offline)",
120 "Interrupt test (offline)", "Loopback test (offline)",
121 "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 : ETH_TP_MDI;
202 ecmd->eth_tp_mdix = ETH_TP_MDI_INVALID;
204 if (hw->phy.mdix == AUTO_ALL_MODES)
205 ecmd->eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO;
207 ecmd->eth_tp_mdix_ctrl = hw->phy.mdix;
212 static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx)
214 struct e1000_mac_info *mac = &adapter->hw.mac;
218 /* Make sure dplx is at most 1 bit and lsb of speed is not set
219 * for the switch() below to work
221 if ((spd & 1) || (dplx & ~1))
224 /* Fiber NICs only allow 1000 gbps Full duplex */
225 if ((adapter->hw.phy.media_type == e1000_media_type_fiber) &&
226 (spd != SPEED_1000) && (dplx != DUPLEX_FULL)) {
230 switch (spd + dplx) {
231 case SPEED_10 + DUPLEX_HALF:
232 mac->forced_speed_duplex = ADVERTISE_10_HALF;
234 case SPEED_10 + DUPLEX_FULL:
235 mac->forced_speed_duplex = ADVERTISE_10_FULL;
237 case SPEED_100 + DUPLEX_HALF:
238 mac->forced_speed_duplex = ADVERTISE_100_HALF;
240 case SPEED_100 + DUPLEX_FULL:
241 mac->forced_speed_duplex = ADVERTISE_100_FULL;
243 case SPEED_1000 + DUPLEX_FULL:
245 adapter->hw.phy.autoneg_advertised = ADVERTISE_1000_FULL;
247 case SPEED_1000 + DUPLEX_HALF: /* not supported */
252 /* clear MDI, MDI(-X) override is only allowed when autoneg enabled */
253 adapter->hw.phy.mdix = AUTO_ALL_MODES;
258 e_err("Unsupported Speed/Duplex configuration\n");
262 static int e1000_set_settings(struct net_device *netdev,
263 struct ethtool_cmd *ecmd)
265 struct e1000_adapter *adapter = netdev_priv(netdev);
266 struct e1000_hw *hw = &adapter->hw;
268 /* When SoL/IDER sessions are active, autoneg/speed/duplex
271 if (hw->phy.ops.check_reset_block &&
272 hw->phy.ops.check_reset_block(hw)) {
273 e_err("Cannot change link characteristics when SoL/IDER is active.\n");
277 /* MDI setting is only allowed when autoneg enabled because
278 * some hardware doesn't allow MDI setting when speed or
281 if (ecmd->eth_tp_mdix_ctrl) {
282 if (hw->phy.media_type != e1000_media_type_copper)
285 if ((ecmd->eth_tp_mdix_ctrl != ETH_TP_MDI_AUTO) &&
286 (ecmd->autoneg != AUTONEG_ENABLE)) {
287 e_err("forcing MDI/MDI-X state is not supported when link speed and/or duplex are forced\n");
292 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
293 usleep_range(1000, 2000);
295 if (ecmd->autoneg == AUTONEG_ENABLE) {
297 if (hw->phy.media_type == e1000_media_type_fiber)
298 hw->phy.autoneg_advertised = ADVERTISED_1000baseT_Full |
299 ADVERTISED_FIBRE | ADVERTISED_Autoneg;
301 hw->phy.autoneg_advertised = ecmd->advertising |
302 ADVERTISED_TP | ADVERTISED_Autoneg;
303 ecmd->advertising = hw->phy.autoneg_advertised;
304 if (adapter->fc_autoneg)
305 hw->fc.requested_mode = e1000_fc_default;
307 u32 speed = ethtool_cmd_speed(ecmd);
308 /* calling this overrides forced MDI setting */
309 if (e1000_set_spd_dplx(adapter, speed, ecmd->duplex)) {
310 clear_bit(__E1000_RESETTING, &adapter->state);
315 /* MDI-X => 2; MDI => 1; Auto => 3 */
316 if (ecmd->eth_tp_mdix_ctrl) {
317 /* fix up the value for auto (3 => 0) as zero is mapped
320 if (ecmd->eth_tp_mdix_ctrl == ETH_TP_MDI_AUTO)
321 hw->phy.mdix = AUTO_ALL_MODES;
323 hw->phy.mdix = ecmd->eth_tp_mdix_ctrl;
327 if (netif_running(adapter->netdev)) {
328 e1000e_down(adapter);
331 e1000e_reset(adapter);
334 clear_bit(__E1000_RESETTING, &adapter->state);
338 static void e1000_get_pauseparam(struct net_device *netdev,
339 struct ethtool_pauseparam *pause)
341 struct e1000_adapter *adapter = netdev_priv(netdev);
342 struct e1000_hw *hw = &adapter->hw;
345 (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
347 if (hw->fc.current_mode == e1000_fc_rx_pause) {
349 } else if (hw->fc.current_mode == e1000_fc_tx_pause) {
351 } else if (hw->fc.current_mode == e1000_fc_full) {
357 static int e1000_set_pauseparam(struct net_device *netdev,
358 struct ethtool_pauseparam *pause)
360 struct e1000_adapter *adapter = netdev_priv(netdev);
361 struct e1000_hw *hw = &adapter->hw;
364 adapter->fc_autoneg = pause->autoneg;
366 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
367 usleep_range(1000, 2000);
369 if (adapter->fc_autoneg == AUTONEG_ENABLE) {
370 hw->fc.requested_mode = e1000_fc_default;
371 if (netif_running(adapter->netdev)) {
372 e1000e_down(adapter);
375 e1000e_reset(adapter);
378 if (pause->rx_pause && pause->tx_pause)
379 hw->fc.requested_mode = e1000_fc_full;
380 else if (pause->rx_pause && !pause->tx_pause)
381 hw->fc.requested_mode = e1000_fc_rx_pause;
382 else if (!pause->rx_pause && pause->tx_pause)
383 hw->fc.requested_mode = e1000_fc_tx_pause;
384 else if (!pause->rx_pause && !pause->tx_pause)
385 hw->fc.requested_mode = e1000_fc_none;
387 hw->fc.current_mode = hw->fc.requested_mode;
389 if (hw->phy.media_type == e1000_media_type_fiber) {
390 retval = hw->mac.ops.setup_link(hw);
391 /* implicit goto out */
393 retval = e1000e_force_mac_fc(hw);
396 e1000e_set_fc_watermarks(hw);
401 clear_bit(__E1000_RESETTING, &adapter->state);
405 static u32 e1000_get_msglevel(struct net_device *netdev)
407 struct e1000_adapter *adapter = netdev_priv(netdev);
408 return adapter->msg_enable;
411 static void e1000_set_msglevel(struct net_device *netdev, u32 data)
413 struct e1000_adapter *adapter = netdev_priv(netdev);
414 adapter->msg_enable = data;
417 static int e1000_get_regs_len(struct net_device __always_unused *netdev)
419 #define E1000_REGS_LEN 32 /* overestimate */
420 return E1000_REGS_LEN * sizeof(u32);
423 static void e1000_get_regs(struct net_device *netdev,
424 struct ethtool_regs *regs, void *p)
426 struct e1000_adapter *adapter = netdev_priv(netdev);
427 struct e1000_hw *hw = &adapter->hw;
431 memset(p, 0, E1000_REGS_LEN * sizeof(u32));
433 regs->version = (1 << 24) | (adapter->pdev->revision << 16) |
434 adapter->pdev->device;
436 regs_buff[0] = er32(CTRL);
437 regs_buff[1] = er32(STATUS);
439 regs_buff[2] = er32(RCTL);
440 regs_buff[3] = er32(RDLEN(0));
441 regs_buff[4] = er32(RDH(0));
442 regs_buff[5] = er32(RDT(0));
443 regs_buff[6] = er32(RDTR);
445 regs_buff[7] = er32(TCTL);
446 regs_buff[8] = er32(TDLEN(0));
447 regs_buff[9] = er32(TDH(0));
448 regs_buff[10] = er32(TDT(0));
449 regs_buff[11] = er32(TIDV);
451 regs_buff[12] = adapter->hw.phy.type; /* PHY type (IGP=1, M88=0) */
453 /* ethtool doesn't use anything past this point, so all this
454 * code is likely legacy junk for apps that may or may not exist
456 if (hw->phy.type == e1000_phy_m88) {
457 e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
458 regs_buff[13] = (u32)phy_data; /* cable length */
459 regs_buff[14] = 0; /* Dummy (to align w/ IGP phy reg dump) */
460 regs_buff[15] = 0; /* Dummy (to align w/ IGP phy reg dump) */
461 regs_buff[16] = 0; /* Dummy (to align w/ IGP phy reg dump) */
462 e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
463 regs_buff[17] = (u32)phy_data; /* extended 10bt distance */
464 regs_buff[18] = regs_buff[13]; /* cable polarity */
465 regs_buff[19] = 0; /* Dummy (to align w/ IGP phy reg dump) */
466 regs_buff[20] = regs_buff[17]; /* polarity correction */
467 /* phy receive errors */
468 regs_buff[22] = adapter->phy_stats.receive_errors;
469 regs_buff[23] = regs_buff[13]; /* mdix mode */
471 regs_buff[21] = 0; /* was idle_errors */
472 e1e_rphy(hw, MII_STAT1000, &phy_data);
473 regs_buff[24] = (u32)phy_data; /* phy local receiver status */
474 regs_buff[25] = regs_buff[24]; /* phy remote receiver status */
477 static int e1000_get_eeprom_len(struct net_device *netdev)
479 struct e1000_adapter *adapter = netdev_priv(netdev);
480 return adapter->hw.nvm.word_size * 2;
483 static int e1000_get_eeprom(struct net_device *netdev,
484 struct ethtool_eeprom *eeprom, u8 *bytes)
486 struct e1000_adapter *adapter = netdev_priv(netdev);
487 struct e1000_hw *hw = &adapter->hw;
494 if (eeprom->len == 0)
497 eeprom->magic = adapter->pdev->vendor | (adapter->pdev->device << 16);
499 first_word = eeprom->offset >> 1;
500 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
502 eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1),
507 if (hw->nvm.type == e1000_nvm_eeprom_spi) {
508 ret_val = e1000_read_nvm(hw, first_word,
509 last_word - first_word + 1,
512 for (i = 0; i < last_word - first_word + 1; i++) {
513 ret_val = e1000_read_nvm(hw, first_word + i, 1,
521 /* a read error occurred, throw away the result */
522 memset(eeprom_buff, 0xff, sizeof(u16) *
523 (last_word - first_word + 1));
525 /* Device's eeprom is always little-endian, word addressable */
526 for (i = 0; i < last_word - first_word + 1; i++)
527 le16_to_cpus(&eeprom_buff[i]);
530 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len);
536 static int e1000_set_eeprom(struct net_device *netdev,
537 struct ethtool_eeprom *eeprom, u8 *bytes)
539 struct e1000_adapter *adapter = netdev_priv(netdev);
540 struct e1000_hw *hw = &adapter->hw;
549 if (eeprom->len == 0)
553 (adapter->pdev->vendor | (adapter->pdev->device << 16)))
556 if (adapter->flags & FLAG_READ_ONLY_NVM)
559 max_len = hw->nvm.word_size * 2;
561 first_word = eeprom->offset >> 1;
562 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
563 eeprom_buff = kmalloc(max_len, GFP_KERNEL);
567 ptr = (void *)eeprom_buff;
569 if (eeprom->offset & 1) {
570 /* need read/modify/write of first changed EEPROM word */
571 /* only the second byte of the word is being modified */
572 ret_val = e1000_read_nvm(hw, first_word, 1, &eeprom_buff[0]);
575 if (((eeprom->offset + eeprom->len) & 1) && (!ret_val))
576 /* need read/modify/write of last changed EEPROM word */
577 /* only the first byte of the word is being modified */
578 ret_val = e1000_read_nvm(hw, last_word, 1,
579 &eeprom_buff[last_word - first_word]);
584 /* Device's eeprom is always little-endian, word addressable */
585 for (i = 0; i < last_word - first_word + 1; i++)
586 le16_to_cpus(&eeprom_buff[i]);
588 memcpy(ptr, bytes, eeprom->len);
590 for (i = 0; i < last_word - first_word + 1; i++)
591 cpu_to_le16s(&eeprom_buff[i]);
593 ret_val = e1000_write_nvm(hw, first_word,
594 last_word - first_word + 1, eeprom_buff);
599 /* Update the checksum over the first part of the EEPROM if needed
600 * and flush shadow RAM for applicable controllers
602 if ((first_word <= NVM_CHECKSUM_REG) ||
603 (hw->mac.type == e1000_82583) ||
604 (hw->mac.type == e1000_82574) ||
605 (hw->mac.type == e1000_82573))
606 ret_val = e1000e_update_nvm_checksum(hw);
613 static void e1000_get_drvinfo(struct net_device *netdev,
614 struct ethtool_drvinfo *drvinfo)
616 struct e1000_adapter *adapter = netdev_priv(netdev);
618 strlcpy(drvinfo->driver, e1000e_driver_name, sizeof(drvinfo->driver));
619 strlcpy(drvinfo->version, e1000e_driver_version,
620 sizeof(drvinfo->version));
622 /* EEPROM image version # is reported as firmware version # for
625 snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
627 (adapter->eeprom_vers & 0xF000) >> 12,
628 (adapter->eeprom_vers & 0x0FF0) >> 4,
629 (adapter->eeprom_vers & 0x000F));
631 strlcpy(drvinfo->bus_info, pci_name(adapter->pdev),
632 sizeof(drvinfo->bus_info));
633 drvinfo->regdump_len = e1000_get_regs_len(netdev);
634 drvinfo->eedump_len = e1000_get_eeprom_len(netdev);
637 static void e1000_get_ringparam(struct net_device *netdev,
638 struct ethtool_ringparam *ring)
640 struct e1000_adapter *adapter = netdev_priv(netdev);
642 ring->rx_max_pending = E1000_MAX_RXD;
643 ring->tx_max_pending = E1000_MAX_TXD;
644 ring->rx_pending = adapter->rx_ring_count;
645 ring->tx_pending = adapter->tx_ring_count;
648 static int e1000_set_ringparam(struct net_device *netdev,
649 struct ethtool_ringparam *ring)
651 struct e1000_adapter *adapter = netdev_priv(netdev);
652 struct e1000_ring *temp_tx = NULL, *temp_rx = NULL;
653 int err = 0, size = sizeof(struct e1000_ring);
654 bool set_tx = false, set_rx = false;
655 u16 new_rx_count, new_tx_count;
657 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
660 new_rx_count = clamp_t(u32, ring->rx_pending, E1000_MIN_RXD,
662 new_rx_count = ALIGN(new_rx_count, REQ_RX_DESCRIPTOR_MULTIPLE);
664 new_tx_count = clamp_t(u32, ring->tx_pending, E1000_MIN_TXD,
666 new_tx_count = ALIGN(new_tx_count, REQ_TX_DESCRIPTOR_MULTIPLE);
668 if ((new_tx_count == adapter->tx_ring_count) &&
669 (new_rx_count == adapter->rx_ring_count))
673 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
674 usleep_range(1000, 2000);
676 if (!netif_running(adapter->netdev)) {
677 /* Set counts now and allocate resources during open() */
678 adapter->tx_ring->count = new_tx_count;
679 adapter->rx_ring->count = new_rx_count;
680 adapter->tx_ring_count = new_tx_count;
681 adapter->rx_ring_count = new_rx_count;
685 set_tx = (new_tx_count != adapter->tx_ring_count);
686 set_rx = (new_rx_count != adapter->rx_ring_count);
688 /* Allocate temporary storage for ring updates */
690 temp_tx = vmalloc(size);
697 temp_rx = vmalloc(size);
704 e1000e_down(adapter);
706 /* We can't just free everything and then setup again, because the
707 * ISRs in MSI-X mode get passed pointers to the Tx and Rx ring
708 * structs. First, attempt to allocate new resources...
711 memcpy(temp_tx, adapter->tx_ring, size);
712 temp_tx->count = new_tx_count;
713 err = e1000e_setup_tx_resources(temp_tx);
718 memcpy(temp_rx, adapter->rx_ring, size);
719 temp_rx->count = new_rx_count;
720 err = e1000e_setup_rx_resources(temp_rx);
725 /* ...then free the old resources and copy back any new ring data */
727 e1000e_free_tx_resources(adapter->tx_ring);
728 memcpy(adapter->tx_ring, temp_tx, size);
729 adapter->tx_ring_count = new_tx_count;
732 e1000e_free_rx_resources(adapter->rx_ring);
733 memcpy(adapter->rx_ring, temp_rx, size);
734 adapter->rx_ring_count = new_rx_count;
739 e1000e_free_tx_resources(temp_tx);
746 clear_bit(__E1000_RESETTING, &adapter->state);
750 static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data,
751 int reg, int offset, u32 mask, u32 write)
754 static const u32 test[] = {
755 0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF
757 for (pat = 0; pat < ARRAY_SIZE(test); pat++) {
758 E1000_WRITE_REG_ARRAY(&adapter->hw, reg, offset,
759 (test[pat] & write));
760 val = E1000_READ_REG_ARRAY(&adapter->hw, reg, offset);
761 if (val != (test[pat] & write & mask)) {
762 e_err("pattern test failed (reg 0x%05X): got 0x%08X expected 0x%08X\n",
763 reg + (offset << 2), val,
764 (test[pat] & write & mask));
772 static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data,
773 int reg, u32 mask, u32 write)
776 __ew32(&adapter->hw, reg, write & mask);
777 val = __er32(&adapter->hw, reg);
778 if ((write & mask) != (val & mask)) {
779 e_err("set/check test failed (reg 0x%05X): got 0x%08X expected 0x%08X\n",
780 reg, (val & mask), (write & mask));
787 #define REG_PATTERN_TEST_ARRAY(reg, offset, mask, write) \
789 if (reg_pattern_test(adapter, data, reg, offset, mask, write)) \
792 #define REG_PATTERN_TEST(reg, mask, write) \
793 REG_PATTERN_TEST_ARRAY(reg, 0, mask, write)
795 #define REG_SET_AND_CHECK(reg, mask, write) \
797 if (reg_set_and_check(adapter, data, reg, mask, write)) \
801 static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
803 struct e1000_hw *hw = &adapter->hw;
804 struct e1000_mac_info *mac = &adapter->hw.mac;
813 /* The status register is Read Only, so a write should fail.
814 * Some bits that get toggled are ignored. There are several bits
815 * on newer hardware that are r/w.
820 case e1000_80003es2lan:
828 before = er32(STATUS);
829 value = (er32(STATUS) & toggle);
830 ew32(STATUS, toggle);
831 after = er32(STATUS) & toggle;
832 if (value != after) {
833 e_err("failed STATUS register test got: 0x%08X expected: 0x%08X\n",
838 /* restore previous status */
839 ew32(STATUS, before);
841 if (!(adapter->flags & FLAG_IS_ICH)) {
842 REG_PATTERN_TEST(E1000_FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
843 REG_PATTERN_TEST(E1000_FCAH, 0x0000FFFF, 0xFFFFFFFF);
844 REG_PATTERN_TEST(E1000_FCT, 0x0000FFFF, 0xFFFFFFFF);
845 REG_PATTERN_TEST(E1000_VET, 0x0000FFFF, 0xFFFFFFFF);
848 REG_PATTERN_TEST(E1000_RDTR, 0x0000FFFF, 0xFFFFFFFF);
849 REG_PATTERN_TEST(E1000_RDBAH(0), 0xFFFFFFFF, 0xFFFFFFFF);
850 REG_PATTERN_TEST(E1000_RDLEN(0), 0x000FFF80, 0x000FFFFF);
851 REG_PATTERN_TEST(E1000_RDH(0), 0x0000FFFF, 0x0000FFFF);
852 REG_PATTERN_TEST(E1000_RDT(0), 0x0000FFFF, 0x0000FFFF);
853 REG_PATTERN_TEST(E1000_FCRTH, 0x0000FFF8, 0x0000FFF8);
854 REG_PATTERN_TEST(E1000_FCTTV, 0x0000FFFF, 0x0000FFFF);
855 REG_PATTERN_TEST(E1000_TIPG, 0x3FFFFFFF, 0x3FFFFFFF);
856 REG_PATTERN_TEST(E1000_TDBAH(0), 0xFFFFFFFF, 0xFFFFFFFF);
857 REG_PATTERN_TEST(E1000_TDLEN(0), 0x000FFF80, 0x000FFFFF);
859 REG_SET_AND_CHECK(E1000_RCTL, 0xFFFFFFFF, 0x00000000);
861 before = ((adapter->flags & FLAG_IS_ICH) ? 0x06C3B33E : 0x06DFB3FE);
862 REG_SET_AND_CHECK(E1000_RCTL, before, 0x003FFFFB);
863 REG_SET_AND_CHECK(E1000_TCTL, 0xFFFFFFFF, 0x00000000);
865 REG_SET_AND_CHECK(E1000_RCTL, before, 0xFFFFFFFF);
866 REG_PATTERN_TEST(E1000_RDBAL(0), 0xFFFFFFF0, 0xFFFFFFFF);
867 if (!(adapter->flags & FLAG_IS_ICH))
868 REG_PATTERN_TEST(E1000_TXCW, 0xC000FFFF, 0x0000FFFF);
869 REG_PATTERN_TEST(E1000_TDBAL(0), 0xFFFFFFF0, 0xFFFFFFFF);
870 REG_PATTERN_TEST(E1000_TIDV, 0x0000FFFF, 0x0000FFFF);
883 if (mac->type == e1000_pch_lpt)
884 wlock_mac = (er32(FWSM) & E1000_FWSM_WLOCK_MAC_MASK) >>
885 E1000_FWSM_WLOCK_MAC_SHIFT;
887 for (i = 0; i < mac->rar_entry_count; i++) {
888 if (mac->type == e1000_pch_lpt) {
889 /* Cannot test write-protected SHRAL[n] registers */
890 if ((wlock_mac == 1) || (wlock_mac && (i > wlock_mac)))
893 /* SHRAH[9] different than the others */
900 REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1), mask,
904 for (i = 0; i < mac->mta_reg_count; i++)
905 REG_PATTERN_TEST_ARRAY(E1000_MTA, i, 0xFFFFFFFF, 0xFFFFFFFF);
912 static int e1000_eeprom_test(struct e1000_adapter *adapter, u64 *data)
919 /* Read and add up the contents of the EEPROM */
920 for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
921 if ((e1000_read_nvm(&adapter->hw, i, 1, &temp)) < 0) {
928 /* If Checksum is not Correct return error else test passed */
929 if ((checksum != (u16)NVM_SUM) && !(*data))
935 static irqreturn_t e1000_test_intr(int __always_unused irq, void *data)
937 struct net_device *netdev = (struct net_device *)data;
938 struct e1000_adapter *adapter = netdev_priv(netdev);
939 struct e1000_hw *hw = &adapter->hw;
941 adapter->test_icr |= er32(ICR);
946 static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
948 struct net_device *netdev = adapter->netdev;
949 struct e1000_hw *hw = &adapter->hw;
952 u32 irq = adapter->pdev->irq;
955 int int_mode = E1000E_INT_MODE_LEGACY;
959 /* NOTE: we don't test MSI/MSI-X interrupts here, yet */
960 if (adapter->int_mode == E1000E_INT_MODE_MSIX) {
961 int_mode = adapter->int_mode;
962 e1000e_reset_interrupt_capability(adapter);
963 adapter->int_mode = E1000E_INT_MODE_LEGACY;
964 e1000e_set_interrupt_capability(adapter);
966 /* Hook up test interrupt handler just for this test */
967 if (!request_irq(irq, e1000_test_intr, IRQF_PROBE_SHARED, netdev->name,
970 } else if (request_irq(irq, e1000_test_intr, IRQF_SHARED, netdev->name,
976 e_info("testing %s interrupt\n", (shared_int ? "shared" : "unshared"));
978 /* Disable all the interrupts */
979 ew32(IMC, 0xFFFFFFFF);
981 usleep_range(10000, 20000);
983 /* Test each interrupt */
984 for (i = 0; i < 10; i++) {
985 /* Interrupt to test */
988 if (adapter->flags & FLAG_IS_ICH) {
990 case E1000_ICR_RXSEQ:
993 if (adapter->hw.mac.type == e1000_ich8lan ||
994 adapter->hw.mac.type == e1000_ich9lan)
1003 /* Disable the interrupt to be reported in
1004 * the cause register and then force the same
1005 * interrupt and see if one gets posted. If
1006 * an interrupt was posted to the bus, the
1009 adapter->test_icr = 0;
1013 usleep_range(10000, 20000);
1015 if (adapter->test_icr & mask) {
1021 /* Enable the interrupt to be reported in
1022 * the cause register and then force the same
1023 * interrupt and see if one gets posted. If
1024 * an interrupt was not posted to the bus, the
1027 adapter->test_icr = 0;
1031 usleep_range(10000, 20000);
1033 if (!(adapter->test_icr & mask)) {
1039 /* Disable the other interrupts to be reported in
1040 * the cause register and then force the other
1041 * interrupts and see if any get posted. If
1042 * an interrupt was posted to the bus, the
1045 adapter->test_icr = 0;
1046 ew32(IMC, ~mask & 0x00007FFF);
1047 ew32(ICS, ~mask & 0x00007FFF);
1049 usleep_range(10000, 20000);
1051 if (adapter->test_icr) {
1058 /* Disable all the interrupts */
1059 ew32(IMC, 0xFFFFFFFF);
1061 usleep_range(10000, 20000);
1063 /* Unhook test interrupt handler */
1064 free_irq(irq, netdev);
1067 if (int_mode == E1000E_INT_MODE_MSIX) {
1068 e1000e_reset_interrupt_capability(adapter);
1069 adapter->int_mode = int_mode;
1070 e1000e_set_interrupt_capability(adapter);
1076 static void e1000_free_desc_rings(struct e1000_adapter *adapter)
1078 struct e1000_ring *tx_ring = &adapter->test_tx_ring;
1079 struct e1000_ring *rx_ring = &adapter->test_rx_ring;
1080 struct pci_dev *pdev = adapter->pdev;
1081 struct e1000_buffer *buffer_info;
1084 if (tx_ring->desc && tx_ring->buffer_info) {
1085 for (i = 0; i < tx_ring->count; i++) {
1086 buffer_info = &tx_ring->buffer_info[i];
1088 if (buffer_info->dma)
1089 dma_unmap_single(&pdev->dev,
1091 buffer_info->length,
1093 if (buffer_info->skb)
1094 dev_kfree_skb(buffer_info->skb);
1098 if (rx_ring->desc && rx_ring->buffer_info) {
1099 for (i = 0; i < rx_ring->count; i++) {
1100 buffer_info = &rx_ring->buffer_info[i];
1102 if (buffer_info->dma)
1103 dma_unmap_single(&pdev->dev,
1105 2048, DMA_FROM_DEVICE);
1106 if (buffer_info->skb)
1107 dev_kfree_skb(buffer_info->skb);
1111 if (tx_ring->desc) {
1112 dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc,
1114 tx_ring->desc = NULL;
1116 if (rx_ring->desc) {
1117 dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc,
1119 rx_ring->desc = NULL;
1122 kfree(tx_ring->buffer_info);
1123 tx_ring->buffer_info = NULL;
1124 kfree(rx_ring->buffer_info);
1125 rx_ring->buffer_info = NULL;
1128 static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
1130 struct e1000_ring *tx_ring = &adapter->test_tx_ring;
1131 struct e1000_ring *rx_ring = &adapter->test_rx_ring;
1132 struct pci_dev *pdev = adapter->pdev;
1133 struct e1000_hw *hw = &adapter->hw;
1138 /* Setup Tx descriptor ring and Tx buffers */
1140 if (!tx_ring->count)
1141 tx_ring->count = E1000_DEFAULT_TXD;
1143 tx_ring->buffer_info = kcalloc(tx_ring->count,
1144 sizeof(struct e1000_buffer), GFP_KERNEL);
1145 if (!tx_ring->buffer_info) {
1150 tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc);
1151 tx_ring->size = ALIGN(tx_ring->size, 4096);
1152 tx_ring->desc = dma_alloc_coherent(&pdev->dev, tx_ring->size,
1153 &tx_ring->dma, GFP_KERNEL);
1154 if (!tx_ring->desc) {
1158 tx_ring->next_to_use = 0;
1159 tx_ring->next_to_clean = 0;
1161 ew32(TDBAL(0), ((u64)tx_ring->dma & 0x00000000FFFFFFFF));
1162 ew32(TDBAH(0), ((u64)tx_ring->dma >> 32));
1163 ew32(TDLEN(0), tx_ring->count * sizeof(struct e1000_tx_desc));
1166 ew32(TCTL, E1000_TCTL_PSP | E1000_TCTL_EN | E1000_TCTL_MULR |
1167 E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT |
1168 E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT);
1170 for (i = 0; i < tx_ring->count; i++) {
1171 struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*tx_ring, i);
1172 struct sk_buff *skb;
1173 unsigned int skb_size = 1024;
1175 skb = alloc_skb(skb_size, GFP_KERNEL);
1180 skb_put(skb, skb_size);
1181 tx_ring->buffer_info[i].skb = skb;
1182 tx_ring->buffer_info[i].length = skb->len;
1183 tx_ring->buffer_info[i].dma =
1184 dma_map_single(&pdev->dev, skb->data, skb->len,
1186 if (dma_mapping_error(&pdev->dev,
1187 tx_ring->buffer_info[i].dma)) {
1191 tx_desc->buffer_addr = cpu_to_le64(tx_ring->buffer_info[i].dma);
1192 tx_desc->lower.data = cpu_to_le32(skb->len);
1193 tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP |
1194 E1000_TXD_CMD_IFCS |
1196 tx_desc->upper.data = 0;
1199 /* Setup Rx descriptor ring and Rx buffers */
1201 if (!rx_ring->count)
1202 rx_ring->count = E1000_DEFAULT_RXD;
1204 rx_ring->buffer_info = kcalloc(rx_ring->count,
1205 sizeof(struct e1000_buffer), GFP_KERNEL);
1206 if (!rx_ring->buffer_info) {
1211 rx_ring->size = rx_ring->count * sizeof(union e1000_rx_desc_extended);
1212 rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size,
1213 &rx_ring->dma, GFP_KERNEL);
1214 if (!rx_ring->desc) {
1218 rx_ring->next_to_use = 0;
1219 rx_ring->next_to_clean = 0;
1222 if (!(adapter->flags2 & FLAG2_NO_DISABLE_RX))
1223 ew32(RCTL, rctl & ~E1000_RCTL_EN);
1224 ew32(RDBAL(0), ((u64)rx_ring->dma & 0xFFFFFFFF));
1225 ew32(RDBAH(0), ((u64)rx_ring->dma >> 32));
1226 ew32(RDLEN(0), rx_ring->size);
1229 rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 |
1230 E1000_RCTL_UPE | E1000_RCTL_MPE | E1000_RCTL_LPE |
1231 E1000_RCTL_SBP | E1000_RCTL_SECRC |
1232 E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
1233 (adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
1236 for (i = 0; i < rx_ring->count; i++) {
1237 union e1000_rx_desc_extended *rx_desc;
1238 struct sk_buff *skb;
1240 skb = alloc_skb(2048 + NET_IP_ALIGN, GFP_KERNEL);
1245 skb_reserve(skb, NET_IP_ALIGN);
1246 rx_ring->buffer_info[i].skb = skb;
1247 rx_ring->buffer_info[i].dma =
1248 dma_map_single(&pdev->dev, skb->data, 2048,
1250 if (dma_mapping_error(&pdev->dev,
1251 rx_ring->buffer_info[i].dma)) {
1255 rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
1256 rx_desc->read.buffer_addr =
1257 cpu_to_le64(rx_ring->buffer_info[i].dma);
1258 memset(skb->data, 0x00, skb->len);
1264 e1000_free_desc_rings(adapter);
1268 static void e1000_phy_disable_receiver(struct e1000_adapter *adapter)
1270 /* Write out to PHY registers 29 and 30 to disable the Receiver. */
1271 e1e_wphy(&adapter->hw, 29, 0x001F);
1272 e1e_wphy(&adapter->hw, 30, 0x8FFC);
1273 e1e_wphy(&adapter->hw, 29, 0x001A);
1274 e1e_wphy(&adapter->hw, 30, 0x8FF0);
1277 static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1279 struct e1000_hw *hw = &adapter->hw;
1284 hw->mac.autoneg = 0;
1286 if (hw->phy.type == e1000_phy_ife) {
1287 /* force 100, set loopback */
1288 e1e_wphy(hw, MII_BMCR, 0x6100);
1290 /* Now set up the MAC to the same speed/duplex as the PHY. */
1291 ctrl_reg = er32(CTRL);
1292 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
1293 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1294 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1295 E1000_CTRL_SPD_100 |/* Force Speed to 100 */
1296 E1000_CTRL_FD); /* Force Duplex to FULL */
1298 ew32(CTRL, ctrl_reg);
1305 /* Specific PHY configuration for loopback */
1306 switch (hw->phy.type) {
1308 /* Auto-MDI/MDIX Off */
1309 e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, 0x0808);
1310 /* reset to update Auto-MDI/MDIX */
1311 e1e_wphy(hw, MII_BMCR, 0x9140);
1313 e1e_wphy(hw, MII_BMCR, 0x8140);
1315 case e1000_phy_gg82563:
1316 e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x1CC);
1319 /* Set Default MAC Interface speed to 1GB */
1320 e1e_rphy(hw, PHY_REG(2, 21), &phy_reg);
1323 e1e_wphy(hw, PHY_REG(2, 21), phy_reg);
1324 /* Assert SW reset for above settings to take effect */
1325 hw->phy.ops.commit(hw);
1327 /* Force Full Duplex */
1328 e1e_rphy(hw, PHY_REG(769, 16), &phy_reg);
1329 e1e_wphy(hw, PHY_REG(769, 16), phy_reg | 0x000C);
1330 /* Set Link Up (in force link) */
1331 e1e_rphy(hw, PHY_REG(776, 16), &phy_reg);
1332 e1e_wphy(hw, PHY_REG(776, 16), phy_reg | 0x0040);
1334 e1e_rphy(hw, PHY_REG(769, 16), &phy_reg);
1335 e1e_wphy(hw, PHY_REG(769, 16), phy_reg | 0x0040);
1336 /* Set Early Link Enable */
1337 e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
1338 e1e_wphy(hw, PHY_REG(769, 20), phy_reg | 0x0400);
1340 case e1000_phy_82577:
1341 case e1000_phy_82578:
1342 /* Workaround: K1 must be disabled for stable 1Gbps operation */
1343 ret_val = hw->phy.ops.acquire(hw);
1345 e_err("Cannot setup 1Gbps loopback.\n");
1348 e1000_configure_k1_ich8lan(hw, false);
1349 hw->phy.ops.release(hw);
1351 case e1000_phy_82579:
1352 /* Disable PHY energy detect power down */
1353 e1e_rphy(hw, PHY_REG(0, 21), &phy_reg);
1354 e1e_wphy(hw, PHY_REG(0, 21), phy_reg & ~(1 << 3));
1355 /* Disable full chip energy detect */
1356 e1e_rphy(hw, PHY_REG(776, 18), &phy_reg);
1357 e1e_wphy(hw, PHY_REG(776, 18), phy_reg | 1);
1358 /* Enable loopback on the PHY */
1359 e1e_wphy(hw, I82577_PHY_LBK_CTRL, 0x8001);
1365 /* force 1000, set loopback */
1366 e1e_wphy(hw, MII_BMCR, 0x4140);
1369 /* Now set up the MAC to the same speed/duplex as the PHY. */
1370 ctrl_reg = er32(CTRL);
1371 ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
1372 ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
1373 E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
1374 E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
1375 E1000_CTRL_FD); /* Force Duplex to FULL */
1377 if (adapter->flags & FLAG_IS_ICH)
1378 ctrl_reg |= E1000_CTRL_SLU; /* Set Link Up */
1380 if (hw->phy.media_type == e1000_media_type_copper &&
1381 hw->phy.type == e1000_phy_m88) {
1382 ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
1384 /* Set the ILOS bit on the fiber Nic if half duplex link is
1387 if ((er32(STATUS) & E1000_STATUS_FD) == 0)
1388 ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
1391 ew32(CTRL, ctrl_reg);
1393 /* Disable the receiver on the PHY so when a cable is plugged in, the
1394 * PHY does not begin to autoneg when a cable is reconnected to the NIC.
1396 if (hw->phy.type == e1000_phy_m88)
1397 e1000_phy_disable_receiver(adapter);
1404 static int e1000_set_82571_fiber_loopback(struct e1000_adapter *adapter)
1406 struct e1000_hw *hw = &adapter->hw;
1407 u32 ctrl = er32(CTRL);
1410 /* special requirements for 82571/82572 fiber adapters */
1412 /* jump through hoops to make sure link is up because serdes
1413 * link is hardwired up
1415 ctrl |= E1000_CTRL_SLU;
1418 /* disable autoneg */
1423 link = (er32(STATUS) & E1000_STATUS_LU);
1426 /* set invert loss of signal */
1428 ctrl |= E1000_CTRL_ILOS;
1432 /* special write to serdes control register to enable SerDes analog
1435 #define E1000_SERDES_LB_ON 0x410
1436 ew32(SCTL, E1000_SERDES_LB_ON);
1438 usleep_range(10000, 20000);
1443 /* only call this for fiber/serdes connections to es2lan */
1444 static int e1000_set_es2lan_mac_loopback(struct e1000_adapter *adapter)
1446 struct e1000_hw *hw = &adapter->hw;
1447 u32 ctrlext = er32(CTRL_EXT);
1448 u32 ctrl = er32(CTRL);
1450 /* save CTRL_EXT to restore later, reuse an empty variable (unused
1451 * on mac_type 80003es2lan)
1453 adapter->tx_fifo_head = ctrlext;
1455 /* clear the serdes mode bits, putting the device into mac loopback */
1456 ctrlext &= ~E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES;
1457 ew32(CTRL_EXT, ctrlext);
1459 /* force speed to 1000/FD, link up */
1460 ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
1461 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX |
1462 E1000_CTRL_SPD_1000 | E1000_CTRL_FD);
1465 /* set mac loopback */
1467 ctrl |= E1000_RCTL_LBM_MAC;
1470 /* set testing mode parameters (no need to reset later) */
1471 #define KMRNCTRLSTA_OPMODE (0x1F << 16)
1472 #define KMRNCTRLSTA_OPMODE_1GB_FD_GMII 0x0582
1474 (KMRNCTRLSTA_OPMODE | KMRNCTRLSTA_OPMODE_1GB_FD_GMII));
1479 static int e1000_setup_loopback_test(struct e1000_adapter *adapter)
1481 struct e1000_hw *hw = &adapter->hw;
1484 if (hw->phy.media_type == e1000_media_type_fiber ||
1485 hw->phy.media_type == e1000_media_type_internal_serdes) {
1486 switch (hw->mac.type) {
1487 case e1000_80003es2lan:
1488 return e1000_set_es2lan_mac_loopback(adapter);
1492 return e1000_set_82571_fiber_loopback(adapter);
1496 rctl |= E1000_RCTL_LBM_TCVR;
1500 } else if (hw->phy.media_type == e1000_media_type_copper) {
1501 return e1000_integrated_phy_loopback(adapter);
1507 static void e1000_loopback_cleanup(struct e1000_adapter *adapter)
1509 struct e1000_hw *hw = &adapter->hw;
1514 rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
1517 switch (hw->mac.type) {
1518 case e1000_80003es2lan:
1519 if (hw->phy.media_type == e1000_media_type_fiber ||
1520 hw->phy.media_type == e1000_media_type_internal_serdes) {
1521 /* restore CTRL_EXT, stealing space from tx_fifo_head */
1522 ew32(CTRL_EXT, adapter->tx_fifo_head);
1523 adapter->tx_fifo_head = 0;
1528 if (hw->phy.media_type == e1000_media_type_fiber ||
1529 hw->phy.media_type == e1000_media_type_internal_serdes) {
1530 #define E1000_SERDES_LB_OFF 0x400
1531 ew32(SCTL, E1000_SERDES_LB_OFF);
1533 usleep_range(10000, 20000);
1538 hw->mac.autoneg = 1;
1539 if (hw->phy.type == e1000_phy_gg82563)
1540 e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x180);
1541 e1e_rphy(hw, MII_BMCR, &phy_reg);
1542 if (phy_reg & BMCR_LOOPBACK) {
1543 phy_reg &= ~BMCR_LOOPBACK;
1544 e1e_wphy(hw, MII_BMCR, phy_reg);
1545 if (hw->phy.ops.commit)
1546 hw->phy.ops.commit(hw);
1552 static void e1000_create_lbtest_frame(struct sk_buff *skb,
1553 unsigned int frame_size)
1555 memset(skb->data, 0xFF, frame_size);
1557 memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
1558 memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
1559 memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
1562 static int e1000_check_lbtest_frame(struct sk_buff *skb,
1563 unsigned int frame_size)
1566 if (*(skb->data + 3) == 0xFF)
1567 if ((*(skb->data + frame_size / 2 + 10) == 0xBE) &&
1568 (*(skb->data + frame_size / 2 + 12) == 0xAF))
1573 static int e1000_run_loopback_test(struct e1000_adapter *adapter)
1575 struct e1000_ring *tx_ring = &adapter->test_tx_ring;
1576 struct e1000_ring *rx_ring = &adapter->test_rx_ring;
1577 struct pci_dev *pdev = adapter->pdev;
1578 struct e1000_hw *hw = &adapter->hw;
1579 struct e1000_buffer *buffer_info;
1586 ew32(RDT(0), rx_ring->count - 1);
1588 /* Calculate the loop count based on the largest descriptor ring
1589 * The idea is to wrap the largest ring a number of times using 64
1590 * send/receive pairs during each loop
1593 if (rx_ring->count <= tx_ring->count)
1594 lc = ((tx_ring->count / 64) * 2) + 1;
1596 lc = ((rx_ring->count / 64) * 2) + 1;
1600 /* loop count loop */
1601 for (j = 0; j <= lc; j++) {
1602 /* send the packets */
1603 for (i = 0; i < 64; i++) {
1604 buffer_info = &tx_ring->buffer_info[k];
1606 e1000_create_lbtest_frame(buffer_info->skb, 1024);
1607 dma_sync_single_for_device(&pdev->dev,
1609 buffer_info->length,
1612 if (k == tx_ring->count)
1618 time = jiffies; /* set the start time for the receive */
1620 /* receive the sent packets */
1622 buffer_info = &rx_ring->buffer_info[l];
1624 dma_sync_single_for_cpu(&pdev->dev,
1625 buffer_info->dma, 2048,
1628 ret_val = e1000_check_lbtest_frame(buffer_info->skb,
1633 if (l == rx_ring->count)
1635 /* time + 20 msecs (200 msecs on 2.4) is more than
1636 * enough time to complete the receives, if it's
1637 * exceeded, break and error off
1639 } while ((good_cnt < 64) && !time_after(jiffies, time + 20));
1640 if (good_cnt != 64) {
1641 ret_val = 13; /* ret_val is the same as mis-compare */
1644 if (jiffies >= (time + 20)) {
1645 ret_val = 14; /* error code for time out error */
1652 static int e1000_loopback_test(struct e1000_adapter *adapter, u64 *data)
1654 struct e1000_hw *hw = &adapter->hw;
1656 /* PHY loopback cannot be performed if SoL/IDER sessions are active */
1657 if (hw->phy.ops.check_reset_block &&
1658 hw->phy.ops.check_reset_block(hw)) {
1659 e_err("Cannot do PHY loopback test when SoL/IDER is active.\n");
1664 *data = e1000_setup_desc_rings(adapter);
1668 *data = e1000_setup_loopback_test(adapter);
1672 *data = e1000_run_loopback_test(adapter);
1673 e1000_loopback_cleanup(adapter);
1676 e1000_free_desc_rings(adapter);
1681 static int e1000_link_test(struct e1000_adapter *adapter, u64 *data)
1683 struct e1000_hw *hw = &adapter->hw;
1686 if (hw->phy.media_type == e1000_media_type_internal_serdes) {
1688 hw->mac.serdes_has_link = false;
1690 /* On some blade server designs, link establishment
1691 * could take as long as 2-3 minutes
1694 hw->mac.ops.check_for_link(hw);
1695 if (hw->mac.serdes_has_link)
1698 } while (i++ < 3750);
1702 hw->mac.ops.check_for_link(hw);
1703 if (hw->mac.autoneg)
1704 /* On some Phy/switch combinations, link establishment
1705 * can take a few seconds more than expected.
1709 if (!(er32(STATUS) & E1000_STATUS_LU))
1715 static int e1000e_get_sset_count(struct net_device __always_unused *netdev,
1720 return E1000_TEST_LEN;
1722 return E1000_STATS_LEN;
1728 static void e1000_diag_test(struct net_device *netdev,
1729 struct ethtool_test *eth_test, u64 *data)
1731 struct e1000_adapter *adapter = netdev_priv(netdev);
1732 u16 autoneg_advertised;
1733 u8 forced_speed_duplex;
1735 bool if_running = netif_running(netdev);
1737 set_bit(__E1000_TESTING, &adapter->state);
1740 /* Get control of and reset hardware */
1741 if (adapter->flags & FLAG_HAS_AMT)
1742 e1000e_get_hw_control(adapter);
1744 e1000e_power_up_phy(adapter);
1746 adapter->hw.phy.autoneg_wait_to_complete = 1;
1747 e1000e_reset(adapter);
1748 adapter->hw.phy.autoneg_wait_to_complete = 0;
1751 if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
1754 /* save speed, duplex, autoneg settings */
1755 autoneg_advertised = adapter->hw.phy.autoneg_advertised;
1756 forced_speed_duplex = adapter->hw.mac.forced_speed_duplex;
1757 autoneg = adapter->hw.mac.autoneg;
1759 e_info("offline testing starting\n");
1762 /* indicate we're in test mode */
1765 if (e1000_reg_test(adapter, &data[0]))
1766 eth_test->flags |= ETH_TEST_FL_FAILED;
1768 e1000e_reset(adapter);
1769 if (e1000_eeprom_test(adapter, &data[1]))
1770 eth_test->flags |= ETH_TEST_FL_FAILED;
1772 e1000e_reset(adapter);
1773 if (e1000_intr_test(adapter, &data[2]))
1774 eth_test->flags |= ETH_TEST_FL_FAILED;
1776 e1000e_reset(adapter);
1777 if (e1000_loopback_test(adapter, &data[3]))
1778 eth_test->flags |= ETH_TEST_FL_FAILED;
1780 /* force this routine to wait until autoneg complete/timeout */
1781 adapter->hw.phy.autoneg_wait_to_complete = 1;
1782 e1000e_reset(adapter);
1783 adapter->hw.phy.autoneg_wait_to_complete = 0;
1785 if (e1000_link_test(adapter, &data[4]))
1786 eth_test->flags |= ETH_TEST_FL_FAILED;
1788 /* restore speed, duplex, autoneg settings */
1789 adapter->hw.phy.autoneg_advertised = autoneg_advertised;
1790 adapter->hw.mac.forced_speed_duplex = forced_speed_duplex;
1791 adapter->hw.mac.autoneg = autoneg;
1792 e1000e_reset(adapter);
1794 clear_bit(__E1000_TESTING, &adapter->state);
1800 e_info("online testing starting\n");
1802 /* register, eeprom, intr and loopback tests not run online */
1808 if (e1000_link_test(adapter, &data[4]))
1809 eth_test->flags |= ETH_TEST_FL_FAILED;
1811 clear_bit(__E1000_TESTING, &adapter->state);
1815 e1000e_reset(adapter);
1817 if (adapter->flags & FLAG_HAS_AMT)
1818 e1000e_release_hw_control(adapter);
1821 msleep_interruptible(4 * 1000);
1824 static void e1000_get_wol(struct net_device *netdev,
1825 struct ethtool_wolinfo *wol)
1827 struct e1000_adapter *adapter = netdev_priv(netdev);
1832 if (!(adapter->flags & FLAG_HAS_WOL) ||
1833 !device_can_wakeup(&adapter->pdev->dev))
1836 wol->supported = WAKE_UCAST | WAKE_MCAST |
1837 WAKE_BCAST | WAKE_MAGIC | WAKE_PHY;
1839 /* apply any specific unsupported masks here */
1840 if (adapter->flags & FLAG_NO_WAKE_UCAST) {
1841 wol->supported &= ~WAKE_UCAST;
1843 if (adapter->wol & E1000_WUFC_EX)
1844 e_err("Interface does not support directed (unicast) frame wake-up packets\n");
1847 if (adapter->wol & E1000_WUFC_EX)
1848 wol->wolopts |= WAKE_UCAST;
1849 if (adapter->wol & E1000_WUFC_MC)
1850 wol->wolopts |= WAKE_MCAST;
1851 if (adapter->wol & E1000_WUFC_BC)
1852 wol->wolopts |= WAKE_BCAST;
1853 if (adapter->wol & E1000_WUFC_MAG)
1854 wol->wolopts |= WAKE_MAGIC;
1855 if (adapter->wol & E1000_WUFC_LNKC)
1856 wol->wolopts |= WAKE_PHY;
1859 static int e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
1861 struct e1000_adapter *adapter = netdev_priv(netdev);
1863 if (!(adapter->flags & FLAG_HAS_WOL) ||
1864 !device_can_wakeup(&adapter->pdev->dev) ||
1865 (wol->wolopts & ~(WAKE_UCAST | WAKE_MCAST | WAKE_BCAST |
1866 WAKE_MAGIC | WAKE_PHY)))
1869 /* these settings will always override what we currently have */
1872 if (wol->wolopts & WAKE_UCAST)
1873 adapter->wol |= E1000_WUFC_EX;
1874 if (wol->wolopts & WAKE_MCAST)
1875 adapter->wol |= E1000_WUFC_MC;
1876 if (wol->wolopts & WAKE_BCAST)
1877 adapter->wol |= E1000_WUFC_BC;
1878 if (wol->wolopts & WAKE_MAGIC)
1879 adapter->wol |= E1000_WUFC_MAG;
1880 if (wol->wolopts & WAKE_PHY)
1881 adapter->wol |= E1000_WUFC_LNKC;
1883 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
1888 static int e1000_set_phys_id(struct net_device *netdev,
1889 enum ethtool_phys_id_state state)
1891 struct e1000_adapter *adapter = netdev_priv(netdev);
1892 struct e1000_hw *hw = &adapter->hw;
1895 case ETHTOOL_ID_ACTIVE:
1896 if (!hw->mac.ops.blink_led)
1897 return 2; /* cycle on/off twice per second */
1899 hw->mac.ops.blink_led(hw);
1902 case ETHTOOL_ID_INACTIVE:
1903 if (hw->phy.type == e1000_phy_ife)
1904 e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
1905 hw->mac.ops.led_off(hw);
1906 hw->mac.ops.cleanup_led(hw);
1910 hw->mac.ops.led_on(hw);
1913 case ETHTOOL_ID_OFF:
1914 hw->mac.ops.led_off(hw);
1920 static int e1000_get_coalesce(struct net_device *netdev,
1921 struct ethtool_coalesce *ec)
1923 struct e1000_adapter *adapter = netdev_priv(netdev);
1925 if (adapter->itr_setting <= 4)
1926 ec->rx_coalesce_usecs = adapter->itr_setting;
1928 ec->rx_coalesce_usecs = 1000000 / adapter->itr_setting;
1933 static int e1000_set_coalesce(struct net_device *netdev,
1934 struct ethtool_coalesce *ec)
1936 struct e1000_adapter *adapter = netdev_priv(netdev);
1938 if ((ec->rx_coalesce_usecs > E1000_MAX_ITR_USECS) ||
1939 ((ec->rx_coalesce_usecs > 4) &&
1940 (ec->rx_coalesce_usecs < E1000_MIN_ITR_USECS)) ||
1941 (ec->rx_coalesce_usecs == 2))
1944 if (ec->rx_coalesce_usecs == 4) {
1945 adapter->itr_setting = 4;
1946 adapter->itr = adapter->itr_setting;
1947 } else if (ec->rx_coalesce_usecs <= 3) {
1948 adapter->itr = 20000;
1949 adapter->itr_setting = ec->rx_coalesce_usecs;
1951 adapter->itr = (1000000 / ec->rx_coalesce_usecs);
1952 adapter->itr_setting = adapter->itr & ~3;
1955 if (adapter->itr_setting != 0)
1956 e1000e_write_itr(adapter, adapter->itr);
1958 e1000e_write_itr(adapter, 0);
1963 static int e1000_nway_reset(struct net_device *netdev)
1965 struct e1000_adapter *adapter = netdev_priv(netdev);
1967 if (!netif_running(netdev))
1970 if (!adapter->hw.mac.autoneg)
1973 e1000e_reinit_locked(adapter);
1978 static void e1000_get_ethtool_stats(struct net_device *netdev,
1979 struct ethtool_stats __always_unused *stats,
1982 struct e1000_adapter *adapter = netdev_priv(netdev);
1983 struct rtnl_link_stats64 net_stats;
1987 e1000e_get_stats64(netdev, &net_stats);
1988 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
1989 switch (e1000_gstrings_stats[i].type) {
1991 p = (char *)&net_stats +
1992 e1000_gstrings_stats[i].stat_offset;
1995 p = (char *)adapter +
1996 e1000_gstrings_stats[i].stat_offset;
2003 data[i] = (e1000_gstrings_stats[i].sizeof_stat ==
2004 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
2008 static void e1000_get_strings(struct net_device __always_unused *netdev,
2009 u32 stringset, u8 *data)
2014 switch (stringset) {
2016 memcpy(data, e1000_gstrings_test, sizeof(e1000_gstrings_test));
2019 for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
2020 memcpy(p, e1000_gstrings_stats[i].stat_string,
2022 p += ETH_GSTRING_LEN;
2028 static int e1000_get_rxnfc(struct net_device *netdev,
2029 struct ethtool_rxnfc *info,
2030 u32 __always_unused *rule_locs)
2034 switch (info->cmd) {
2035 case ETHTOOL_GRXFH: {
2036 struct e1000_adapter *adapter = netdev_priv(netdev);
2037 struct e1000_hw *hw = &adapter->hw;
2038 u32 mrqc = er32(MRQC);
2040 if (!(mrqc & E1000_MRQC_RSS_FIELD_MASK))
2043 switch (info->flow_type) {
2045 if (mrqc & E1000_MRQC_RSS_FIELD_IPV4_TCP)
2046 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
2050 case AH_ESP_V4_FLOW:
2052 if (mrqc & E1000_MRQC_RSS_FIELD_IPV4)
2053 info->data |= RXH_IP_SRC | RXH_IP_DST;
2056 if (mrqc & E1000_MRQC_RSS_FIELD_IPV6_TCP)
2057 info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
2061 case AH_ESP_V6_FLOW:
2063 if (mrqc & E1000_MRQC_RSS_FIELD_IPV6)
2064 info->data |= RXH_IP_SRC | RXH_IP_DST;
2076 static int e1000e_get_eee(struct net_device *netdev, struct ethtool_eee *edata)
2078 struct e1000_adapter *adapter = netdev_priv(netdev);
2079 struct e1000_hw *hw = &adapter->hw;
2080 u16 cap_addr, adv_addr, lpa_addr, pcs_stat_addr, phy_data, lpi_ctrl;
2081 u32 status, ret_val;
2083 if (!(adapter->flags & FLAG_IS_ICH) ||
2084 !(adapter->flags2 & FLAG2_HAS_EEE))
2087 switch (hw->phy.type) {
2088 case e1000_phy_82579:
2089 cap_addr = I82579_EEE_CAPABILITY;
2090 adv_addr = I82579_EEE_ADVERTISEMENT;
2091 lpa_addr = I82579_EEE_LP_ABILITY;
2092 pcs_stat_addr = I82579_EEE_PCS_STATUS;
2094 case e1000_phy_i217:
2095 cap_addr = I217_EEE_CAPABILITY;
2096 adv_addr = I217_EEE_ADVERTISEMENT;
2097 lpa_addr = I217_EEE_LP_ABILITY;
2098 pcs_stat_addr = I217_EEE_PCS_STATUS;
2104 ret_val = hw->phy.ops.acquire(hw);
2108 /* EEE Capability */
2109 ret_val = e1000_read_emi_reg_locked(hw, cap_addr, &phy_data);
2112 edata->supported = mmd_eee_cap_to_ethtool_sup_t(phy_data);
2114 /* EEE Advertised */
2115 ret_val = e1000_read_emi_reg_locked(hw, adv_addr, &phy_data);
2118 edata->advertised = mmd_eee_adv_to_ethtool_adv_t(phy_data);
2120 /* EEE Link Partner Advertised */
2121 ret_val = e1000_read_emi_reg_locked(hw, lpa_addr, &phy_data);
2124 edata->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(phy_data);
2126 /* EEE PCS Status */
2127 ret_val = e1000_read_emi_reg_locked(hw, pcs_stat_addr, &phy_data);
2128 if (hw->phy.type == e1000_phy_82579)
2132 hw->phy.ops.release(hw);
2136 e1e_rphy(hw, I82579_LPI_CTRL, &lpi_ctrl);
2137 status = er32(STATUS);
2139 /* Result of the EEE auto negotiation - there is no register that
2140 * has the status of the EEE negotiation so do a best-guess based
2141 * on whether both Tx and Rx LPI indications have been received or
2142 * base it on the link speed, the EEE advertised speeds on both ends
2143 * and the speeds on which EEE is enabled locally.
2145 if (((phy_data & E1000_EEE_TX_LPI_RCVD) &&
2146 (phy_data & E1000_EEE_RX_LPI_RCVD)) ||
2147 ((status & E1000_STATUS_SPEED_100) &&
2148 (edata->advertised & ADVERTISED_100baseT_Full) &&
2149 (edata->lp_advertised & ADVERTISED_100baseT_Full) &&
2150 (lpi_ctrl & I82579_LPI_CTRL_100_ENABLE)) ||
2151 ((status & E1000_STATUS_SPEED_1000) &&
2152 (edata->advertised & ADVERTISED_1000baseT_Full) &&
2153 (edata->lp_advertised & ADVERTISED_1000baseT_Full) &&
2154 (lpi_ctrl & I82579_LPI_CTRL_1000_ENABLE)))
2155 edata->eee_active = true;
2157 edata->eee_enabled = !hw->dev_spec.ich8lan.eee_disable;
2158 edata->tx_lpi_enabled = true;
2159 edata->tx_lpi_timer = er32(LPIC) >> E1000_LPIC_LPIET_SHIFT;
2164 static int e1000e_set_eee(struct net_device *netdev, struct ethtool_eee *edata)
2166 struct e1000_adapter *adapter = netdev_priv(netdev);
2167 struct e1000_hw *hw = &adapter->hw;
2168 struct ethtool_eee eee_curr;
2171 if (!(adapter->flags & FLAG_IS_ICH) ||
2172 !(adapter->flags2 & FLAG2_HAS_EEE))
2175 ret_val = e1000e_get_eee(netdev, &eee_curr);
2179 if (eee_curr.advertised != edata->advertised) {
2180 e_err("Setting EEE advertisement is not supported\n");
2184 if (eee_curr.tx_lpi_enabled != edata->tx_lpi_enabled) {
2185 e_err("Setting EEE tx-lpi is not supported\n");
2189 if (eee_curr.tx_lpi_timer != edata->tx_lpi_timer) {
2190 e_err("Setting EEE Tx LPI timer is not supported\n");
2194 if (hw->dev_spec.ich8lan.eee_disable != !edata->eee_enabled) {
2195 hw->dev_spec.ich8lan.eee_disable = !edata->eee_enabled;
2197 /* reset the link */
2198 if (netif_running(netdev))
2199 e1000e_reinit_locked(adapter);
2201 e1000e_reset(adapter);
2207 static int e1000e_get_ts_info(struct net_device *netdev,
2208 struct ethtool_ts_info *info)
2210 struct e1000_adapter *adapter = netdev_priv(netdev);
2212 ethtool_op_get_ts_info(netdev, info);
2214 if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP))
2217 info->so_timestamping |= (SOF_TIMESTAMPING_TX_HARDWARE |
2218 SOF_TIMESTAMPING_RX_HARDWARE |
2219 SOF_TIMESTAMPING_RAW_HARDWARE);
2221 info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON);
2223 info->rx_filters = ((1 << HWTSTAMP_FILTER_NONE) |
2224 (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
2225 (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
2226 (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) |
2227 (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) |
2228 (1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
2229 (1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) |
2230 (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) |
2231 (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) |
2232 (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) |
2233 (1 << HWTSTAMP_FILTER_ALL));
2235 if (adapter->ptp_clock)
2236 info->phc_index = ptp_clock_index(adapter->ptp_clock);
2241 static const struct ethtool_ops e1000_ethtool_ops = {
2242 .get_settings = e1000_get_settings,
2243 .set_settings = e1000_set_settings,
2244 .get_drvinfo = e1000_get_drvinfo,
2245 .get_regs_len = e1000_get_regs_len,
2246 .get_regs = e1000_get_regs,
2247 .get_wol = e1000_get_wol,
2248 .set_wol = e1000_set_wol,
2249 .get_msglevel = e1000_get_msglevel,
2250 .set_msglevel = e1000_set_msglevel,
2251 .nway_reset = e1000_nway_reset,
2252 .get_link = ethtool_op_get_link,
2253 .get_eeprom_len = e1000_get_eeprom_len,
2254 .get_eeprom = e1000_get_eeprom,
2255 .set_eeprom = e1000_set_eeprom,
2256 .get_ringparam = e1000_get_ringparam,
2257 .set_ringparam = e1000_set_ringparam,
2258 .get_pauseparam = e1000_get_pauseparam,
2259 .set_pauseparam = e1000_set_pauseparam,
2260 .self_test = e1000_diag_test,
2261 .get_strings = e1000_get_strings,
2262 .set_phys_id = e1000_set_phys_id,
2263 .get_ethtool_stats = e1000_get_ethtool_stats,
2264 .get_sset_count = e1000e_get_sset_count,
2265 .get_coalesce = e1000_get_coalesce,
2266 .set_coalesce = e1000_set_coalesce,
2267 .get_rxnfc = e1000_get_rxnfc,
2268 .get_ts_info = e1000e_get_ts_info,
2269 .get_eee = e1000e_get_eee,
2270 .set_eee = e1000e_set_eee,
2273 void e1000e_set_ethtool_ops(struct net_device *netdev)
2275 SET_ETHTOOL_OPS(netdev, &e1000_ethtool_ops);