fp@2685: /* Intel(R) Gigabit Ethernet Linux driver
fp@2685: * Copyright(c) 2007-2014 Intel Corporation.
fp@2685: *
fp@2685: * This program is free software; you can redistribute it and/or modify it
fp@2685: * under the terms and conditions of the GNU General Public License,
fp@2685: * version 2, as published by the Free Software Foundation.
fp@2685: *
fp@2685: * This program is distributed in the hope it will be useful, but WITHOUT
fp@2685: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fp@2685: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
fp@2685: * more details.
fp@2685: *
fp@2685: * You should have received a copy of the GNU General Public License along with
fp@2685: * this program; if not, see .
fp@2685: *
fp@2685: * The full GNU General Public License is included in this distribution in
fp@2685: * the file called "COPYING".
fp@2685: *
fp@2685: * Contact Information:
fp@2685: * e1000-devel Mailing List
fp@2685: * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
fp@2685: */
fp@2685:
fp@2685: /* ethtool support for igb */
fp@2685:
fp@2685: #include
fp@2685: #include
fp@2685: #include
fp@2685: #include
fp@2685: #include
fp@2685: #include
fp@2685: #include
fp@2685: #include
fp@2685: #include
fp@2685: #include
fp@2685: #include
fp@2685: #include
fp@2685:
fp@2685: #include "igb.h"
fp@2685:
fp@2685: struct igb_stats {
fp@2685: char stat_string[ETH_GSTRING_LEN];
fp@2685: int sizeof_stat;
fp@2685: int stat_offset;
fp@2685: };
fp@2685:
fp@2685: #define IGB_STAT(_name, _stat) { \
fp@2685: .stat_string = _name, \
fp@2685: .sizeof_stat = FIELD_SIZEOF(struct igb_adapter, _stat), \
fp@2685: .stat_offset = offsetof(struct igb_adapter, _stat) \
fp@2685: }
fp@2685: static const struct igb_stats igb_gstrings_stats[] = {
fp@2685: IGB_STAT("rx_packets", stats.gprc),
fp@2685: IGB_STAT("tx_packets", stats.gptc),
fp@2685: IGB_STAT("rx_bytes", stats.gorc),
fp@2685: IGB_STAT("tx_bytes", stats.gotc),
fp@2685: IGB_STAT("rx_broadcast", stats.bprc),
fp@2685: IGB_STAT("tx_broadcast", stats.bptc),
fp@2685: IGB_STAT("rx_multicast", stats.mprc),
fp@2685: IGB_STAT("tx_multicast", stats.mptc),
fp@2685: IGB_STAT("multicast", stats.mprc),
fp@2685: IGB_STAT("collisions", stats.colc),
fp@2685: IGB_STAT("rx_crc_errors", stats.crcerrs),
fp@2685: IGB_STAT("rx_no_buffer_count", stats.rnbc),
fp@2685: IGB_STAT("rx_missed_errors", stats.mpc),
fp@2685: IGB_STAT("tx_aborted_errors", stats.ecol),
fp@2685: IGB_STAT("tx_carrier_errors", stats.tncrs),
fp@2685: IGB_STAT("tx_window_errors", stats.latecol),
fp@2685: IGB_STAT("tx_abort_late_coll", stats.latecol),
fp@2685: IGB_STAT("tx_deferred_ok", stats.dc),
fp@2685: IGB_STAT("tx_single_coll_ok", stats.scc),
fp@2685: IGB_STAT("tx_multi_coll_ok", stats.mcc),
fp@2685: IGB_STAT("tx_timeout_count", tx_timeout_count),
fp@2685: IGB_STAT("rx_long_length_errors", stats.roc),
fp@2685: IGB_STAT("rx_short_length_errors", stats.ruc),
fp@2685: IGB_STAT("rx_align_errors", stats.algnerrc),
fp@2685: IGB_STAT("tx_tcp_seg_good", stats.tsctc),
fp@2685: IGB_STAT("tx_tcp_seg_failed", stats.tsctfc),
fp@2685: IGB_STAT("rx_flow_control_xon", stats.xonrxc),
fp@2685: IGB_STAT("rx_flow_control_xoff", stats.xoffrxc),
fp@2685: IGB_STAT("tx_flow_control_xon", stats.xontxc),
fp@2685: IGB_STAT("tx_flow_control_xoff", stats.xofftxc),
fp@2685: IGB_STAT("rx_long_byte_count", stats.gorc),
fp@2685: IGB_STAT("tx_dma_out_of_sync", stats.doosync),
fp@2685: IGB_STAT("tx_smbus", stats.mgptc),
fp@2685: IGB_STAT("rx_smbus", stats.mgprc),
fp@2685: IGB_STAT("dropped_smbus", stats.mgpdc),
fp@2685: IGB_STAT("os2bmc_rx_by_bmc", stats.o2bgptc),
fp@2685: IGB_STAT("os2bmc_tx_by_bmc", stats.b2ospc),
fp@2685: IGB_STAT("os2bmc_tx_by_host", stats.o2bspc),
fp@2685: IGB_STAT("os2bmc_rx_by_host", stats.b2ogprc),
fp@2685: IGB_STAT("tx_hwtstamp_timeouts", tx_hwtstamp_timeouts),
fp@2685: IGB_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared),
fp@2685: };
fp@2685:
fp@2685: #define IGB_NETDEV_STAT(_net_stat) { \
fp@2685: .stat_string = __stringify(_net_stat), \
fp@2685: .sizeof_stat = FIELD_SIZEOF(struct rtnl_link_stats64, _net_stat), \
fp@2685: .stat_offset = offsetof(struct rtnl_link_stats64, _net_stat) \
fp@2685: }
fp@2685: static const struct igb_stats igb_gstrings_net_stats[] = {
fp@2685: IGB_NETDEV_STAT(rx_errors),
fp@2685: IGB_NETDEV_STAT(tx_errors),
fp@2685: IGB_NETDEV_STAT(tx_dropped),
fp@2685: IGB_NETDEV_STAT(rx_length_errors),
fp@2685: IGB_NETDEV_STAT(rx_over_errors),
fp@2685: IGB_NETDEV_STAT(rx_frame_errors),
fp@2685: IGB_NETDEV_STAT(rx_fifo_errors),
fp@2685: IGB_NETDEV_STAT(tx_fifo_errors),
fp@2685: IGB_NETDEV_STAT(tx_heartbeat_errors)
fp@2685: };
fp@2685:
fp@2685: #define IGB_GLOBAL_STATS_LEN \
fp@2685: (sizeof(igb_gstrings_stats) / sizeof(struct igb_stats))
fp@2685: #define IGB_NETDEV_STATS_LEN \
fp@2685: (sizeof(igb_gstrings_net_stats) / sizeof(struct igb_stats))
fp@2685: #define IGB_RX_QUEUE_STATS_LEN \
fp@2685: (sizeof(struct igb_rx_queue_stats) / sizeof(u64))
fp@2685:
fp@2685: #define IGB_TX_QUEUE_STATS_LEN 3 /* packets, bytes, restart_queue */
fp@2685:
fp@2685: #define IGB_QUEUE_STATS_LEN \
fp@2685: ((((struct igb_adapter *)netdev_priv(netdev))->num_rx_queues * \
fp@2685: IGB_RX_QUEUE_STATS_LEN) + \
fp@2685: (((struct igb_adapter *)netdev_priv(netdev))->num_tx_queues * \
fp@2685: IGB_TX_QUEUE_STATS_LEN))
fp@2685: #define IGB_STATS_LEN \
fp@2685: (IGB_GLOBAL_STATS_LEN + IGB_NETDEV_STATS_LEN + IGB_QUEUE_STATS_LEN)
fp@2685:
fp@2685: static const char igb_gstrings_test[][ETH_GSTRING_LEN] = {
fp@2685: "Register test (offline)", "Eeprom test (offline)",
fp@2685: "Interrupt test (offline)", "Loopback test (offline)",
fp@2685: "Link test (on/offline)"
fp@2685: };
fp@2685: #define IGB_TEST_LEN (sizeof(igb_gstrings_test) / ETH_GSTRING_LEN)
fp@2685:
fp@2685: static int igb_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
fp@2685: struct e1000_sfp_flags *eth_flags = &dev_spec->eth_flags;
fp@2685: u32 status;
fp@2685: u32 speed;
fp@2685:
fp@2685: status = rd32(E1000_STATUS);
fp@2685: if (hw->phy.media_type == e1000_media_type_copper) {
fp@2685:
fp@2685: ecmd->supported = (SUPPORTED_10baseT_Half |
fp@2685: SUPPORTED_10baseT_Full |
fp@2685: SUPPORTED_100baseT_Half |
fp@2685: SUPPORTED_100baseT_Full |
fp@2685: SUPPORTED_1000baseT_Full|
fp@2685: SUPPORTED_Autoneg |
fp@2685: SUPPORTED_TP |
fp@2685: SUPPORTED_Pause);
fp@2685: ecmd->advertising = ADVERTISED_TP;
fp@2685:
fp@2685: if (hw->mac.autoneg == 1) {
fp@2685: ecmd->advertising |= ADVERTISED_Autoneg;
fp@2685: /* the e1000 autoneg seems to match ethtool nicely */
fp@2685: ecmd->advertising |= hw->phy.autoneg_advertised;
fp@2685: }
fp@2685:
fp@2685: ecmd->port = PORT_TP;
fp@2685: ecmd->phy_address = hw->phy.addr;
fp@2685: ecmd->transceiver = XCVR_INTERNAL;
fp@2685: } else {
fp@2685: ecmd->supported = (SUPPORTED_FIBRE |
fp@2685: SUPPORTED_1000baseKX_Full |
fp@2685: SUPPORTED_Autoneg |
fp@2685: SUPPORTED_Pause);
fp@2685: ecmd->advertising = (ADVERTISED_FIBRE |
fp@2685: ADVERTISED_1000baseKX_Full);
fp@2685: if (hw->mac.type == e1000_i354) {
fp@2685: if ((hw->device_id ==
fp@2685: E1000_DEV_ID_I354_BACKPLANE_2_5GBPS) &&
fp@2685: !(status & E1000_STATUS_2P5_SKU_OVER)) {
fp@2685: ecmd->supported |= SUPPORTED_2500baseX_Full;
fp@2685: ecmd->supported &=
fp@2685: ~SUPPORTED_1000baseKX_Full;
fp@2685: ecmd->advertising |= ADVERTISED_2500baseX_Full;
fp@2685: ecmd->advertising &=
fp@2685: ~ADVERTISED_1000baseKX_Full;
fp@2685: }
fp@2685: }
fp@2685: if (eth_flags->e100_base_fx) {
fp@2685: ecmd->supported |= SUPPORTED_100baseT_Full;
fp@2685: ecmd->advertising |= ADVERTISED_100baseT_Full;
fp@2685: }
fp@2685: if (hw->mac.autoneg == 1)
fp@2685: ecmd->advertising |= ADVERTISED_Autoneg;
fp@2685:
fp@2685: ecmd->port = PORT_FIBRE;
fp@2685: ecmd->transceiver = XCVR_EXTERNAL;
fp@2685: }
fp@2685: if (hw->mac.autoneg != 1)
fp@2685: ecmd->advertising &= ~(ADVERTISED_Pause |
fp@2685: ADVERTISED_Asym_Pause);
fp@2685:
fp@2685: switch (hw->fc.requested_mode) {
fp@2685: case e1000_fc_full:
fp@2685: ecmd->advertising |= ADVERTISED_Pause;
fp@2685: break;
fp@2685: case e1000_fc_rx_pause:
fp@2685: ecmd->advertising |= (ADVERTISED_Pause |
fp@2685: ADVERTISED_Asym_Pause);
fp@2685: break;
fp@2685: case e1000_fc_tx_pause:
fp@2685: ecmd->advertising |= ADVERTISED_Asym_Pause;
fp@2685: break;
fp@2685: default:
fp@2685: ecmd->advertising &= ~(ADVERTISED_Pause |
fp@2685: ADVERTISED_Asym_Pause);
fp@2685: }
fp@2685: if (status & E1000_STATUS_LU) {
fp@2685: if ((status & E1000_STATUS_2P5_SKU) &&
fp@2685: !(status & E1000_STATUS_2P5_SKU_OVER)) {
fp@2685: speed = SPEED_2500;
fp@2685: } else if (status & E1000_STATUS_SPEED_1000) {
fp@2685: speed = SPEED_1000;
fp@2685: } else if (status & E1000_STATUS_SPEED_100) {
fp@2685: speed = SPEED_100;
fp@2685: } else {
fp@2685: speed = SPEED_10;
fp@2685: }
fp@2685: if ((status & E1000_STATUS_FD) ||
fp@2685: hw->phy.media_type != e1000_media_type_copper)
fp@2685: ecmd->duplex = DUPLEX_FULL;
fp@2685: else
fp@2685: ecmd->duplex = DUPLEX_HALF;
fp@2685: } else {
fp@2685: speed = SPEED_UNKNOWN;
fp@2685: ecmd->duplex = DUPLEX_UNKNOWN;
fp@2685: }
fp@2685: ethtool_cmd_speed_set(ecmd, speed);
fp@2685: if ((hw->phy.media_type == e1000_media_type_fiber) ||
fp@2685: hw->mac.autoneg)
fp@2685: ecmd->autoneg = AUTONEG_ENABLE;
fp@2685: else
fp@2685: ecmd->autoneg = AUTONEG_DISABLE;
fp@2685:
fp@2685: /* MDI-X => 2; MDI =>1; Invalid =>0 */
fp@2685: if (hw->phy.media_type == e1000_media_type_copper)
fp@2685: ecmd->eth_tp_mdix = hw->phy.is_mdix ? ETH_TP_MDI_X :
fp@2685: ETH_TP_MDI;
fp@2685: else
fp@2685: ecmd->eth_tp_mdix = ETH_TP_MDI_INVALID;
fp@2685:
fp@2685: if (hw->phy.mdix == AUTO_ALL_MODES)
fp@2685: ecmd->eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO;
fp@2685: else
fp@2685: ecmd->eth_tp_mdix_ctrl = hw->phy.mdix;
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static int igb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685:
fp@2685: /* When SoL/IDER sessions are active, autoneg/speed/duplex
fp@2685: * cannot be changed
fp@2685: */
fp@2685: if (igb_check_reset_block(hw)) {
fp@2685: dev_err(&adapter->pdev->dev,
fp@2685: "Cannot change link characteristics when SoL/IDER is active.\n");
fp@2685: return -EINVAL;
fp@2685: }
fp@2685:
fp@2685: /* MDI setting is only allowed when autoneg enabled because
fp@2685: * some hardware doesn't allow MDI setting when speed or
fp@2685: * duplex is forced.
fp@2685: */
fp@2685: if (ecmd->eth_tp_mdix_ctrl) {
fp@2685: if (hw->phy.media_type != e1000_media_type_copper)
fp@2685: return -EOPNOTSUPP;
fp@2685:
fp@2685: if ((ecmd->eth_tp_mdix_ctrl != ETH_TP_MDI_AUTO) &&
fp@2685: (ecmd->autoneg != AUTONEG_ENABLE)) {
fp@2685: dev_err(&adapter->pdev->dev, "forcing MDI/MDI-X state is not supported when link speed and/or duplex are forced\n");
fp@2685: return -EINVAL;
fp@2685: }
fp@2685: }
fp@2685:
fp@2685: while (test_and_set_bit(__IGB_RESETTING, &adapter->state))
fp@2685: usleep_range(1000, 2000);
fp@2685:
fp@2685: if (ecmd->autoneg == AUTONEG_ENABLE) {
fp@2685: hw->mac.autoneg = 1;
fp@2685: if (hw->phy.media_type == e1000_media_type_fiber) {
fp@2685: hw->phy.autoneg_advertised = ecmd->advertising |
fp@2685: ADVERTISED_FIBRE |
fp@2685: ADVERTISED_Autoneg;
fp@2685: switch (adapter->link_speed) {
fp@2685: case SPEED_2500:
fp@2685: hw->phy.autoneg_advertised =
fp@2685: ADVERTISED_2500baseX_Full;
fp@2685: break;
fp@2685: case SPEED_1000:
fp@2685: hw->phy.autoneg_advertised =
fp@2685: ADVERTISED_1000baseT_Full;
fp@2685: break;
fp@2685: case SPEED_100:
fp@2685: hw->phy.autoneg_advertised =
fp@2685: ADVERTISED_100baseT_Full;
fp@2685: break;
fp@2685: default:
fp@2685: break;
fp@2685: }
fp@2685: } else {
fp@2685: hw->phy.autoneg_advertised = ecmd->advertising |
fp@2685: ADVERTISED_TP |
fp@2685: ADVERTISED_Autoneg;
fp@2685: }
fp@2685: ecmd->advertising = hw->phy.autoneg_advertised;
fp@2685: if (adapter->fc_autoneg)
fp@2685: hw->fc.requested_mode = e1000_fc_default;
fp@2685: } else {
fp@2685: u32 speed = ethtool_cmd_speed(ecmd);
fp@2685: /* calling this overrides forced MDI setting */
fp@2685: if (igb_set_spd_dplx(adapter, speed, ecmd->duplex)) {
fp@2685: clear_bit(__IGB_RESETTING, &adapter->state);
fp@2685: return -EINVAL;
fp@2685: }
fp@2685: }
fp@2685:
fp@2685: /* MDI-X => 2; MDI => 1; Auto => 3 */
fp@2685: if (ecmd->eth_tp_mdix_ctrl) {
fp@2685: /* fix up the value for auto (3 => 0) as zero is mapped
fp@2685: * internally to auto
fp@2685: */
fp@2685: if (ecmd->eth_tp_mdix_ctrl == ETH_TP_MDI_AUTO)
fp@2685: hw->phy.mdix = AUTO_ALL_MODES;
fp@2685: else
fp@2685: hw->phy.mdix = ecmd->eth_tp_mdix_ctrl;
fp@2685: }
fp@2685:
fp@2685: /* reset the link */
fp@2685: if (netif_running(adapter->netdev)) {
fp@2685: igb_down(adapter);
fp@2685: igb_up(adapter);
fp@2685: } else
fp@2685: igb_reset(adapter);
fp@2685:
fp@2685: clear_bit(__IGB_RESETTING, &adapter->state);
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static u32 igb_get_link(struct net_device *netdev)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct e1000_mac_info *mac = &adapter->hw.mac;
fp@2685:
fp@2685: /* If the link is not reported up to netdev, interrupts are disabled,
fp@2685: * and so the physical link state may have changed since we last
fp@2685: * looked. Set get_link_status to make sure that the true link
fp@2685: * state is interrogated, rather than pulling a cached and possibly
fp@2685: * stale link state from the driver.
fp@2685: */
fp@2685: if (!netif_carrier_ok(netdev))
fp@2685: mac->get_link_status = 1;
fp@2685:
fp@2685: return igb_has_link(adapter);
fp@2685: }
fp@2685:
fp@2685: static void igb_get_pauseparam(struct net_device *netdev,
fp@2685: struct ethtool_pauseparam *pause)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685:
fp@2685: pause->autoneg =
fp@2685: (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
fp@2685:
fp@2685: if (hw->fc.current_mode == e1000_fc_rx_pause)
fp@2685: pause->rx_pause = 1;
fp@2685: else if (hw->fc.current_mode == e1000_fc_tx_pause)
fp@2685: pause->tx_pause = 1;
fp@2685: else if (hw->fc.current_mode == e1000_fc_full) {
fp@2685: pause->rx_pause = 1;
fp@2685: pause->tx_pause = 1;
fp@2685: }
fp@2685: }
fp@2685:
fp@2685: static int igb_set_pauseparam(struct net_device *netdev,
fp@2685: struct ethtool_pauseparam *pause)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: int retval = 0;
fp@2685:
fp@2685: /* 100basefx does not support setting link flow control */
fp@2685: if (hw->dev_spec._82575.eth_flags.e100_base_fx)
fp@2685: return -EINVAL;
fp@2685:
fp@2685: adapter->fc_autoneg = pause->autoneg;
fp@2685:
fp@2685: while (test_and_set_bit(__IGB_RESETTING, &adapter->state))
fp@2685: usleep_range(1000, 2000);
fp@2685:
fp@2685: if (adapter->fc_autoneg == AUTONEG_ENABLE) {
fp@2685: hw->fc.requested_mode = e1000_fc_default;
fp@2685: if (netif_running(adapter->netdev)) {
fp@2685: igb_down(adapter);
fp@2685: igb_up(adapter);
fp@2685: } else {
fp@2685: igb_reset(adapter);
fp@2685: }
fp@2685: } else {
fp@2685: if (pause->rx_pause && pause->tx_pause)
fp@2685: hw->fc.requested_mode = e1000_fc_full;
fp@2685: else if (pause->rx_pause && !pause->tx_pause)
fp@2685: hw->fc.requested_mode = e1000_fc_rx_pause;
fp@2685: else if (!pause->rx_pause && pause->tx_pause)
fp@2685: hw->fc.requested_mode = e1000_fc_tx_pause;
fp@2685: else if (!pause->rx_pause && !pause->tx_pause)
fp@2685: hw->fc.requested_mode = e1000_fc_none;
fp@2685:
fp@2685: hw->fc.current_mode = hw->fc.requested_mode;
fp@2685:
fp@2685: retval = ((hw->phy.media_type == e1000_media_type_copper) ?
fp@2685: igb_force_mac_fc(hw) : igb_setup_link(hw));
fp@2685: }
fp@2685:
fp@2685: clear_bit(__IGB_RESETTING, &adapter->state);
fp@2685: return retval;
fp@2685: }
fp@2685:
fp@2685: static u32 igb_get_msglevel(struct net_device *netdev)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: return adapter->msg_enable;
fp@2685: }
fp@2685:
fp@2685: static void igb_set_msglevel(struct net_device *netdev, u32 data)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: adapter->msg_enable = data;
fp@2685: }
fp@2685:
fp@2685: static int igb_get_regs_len(struct net_device *netdev)
fp@2685: {
fp@2685: #define IGB_REGS_LEN 739
fp@2685: return IGB_REGS_LEN * sizeof(u32);
fp@2685: }
fp@2685:
fp@2685: static void igb_get_regs(struct net_device *netdev,
fp@2685: struct ethtool_regs *regs, void *p)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: u32 *regs_buff = p;
fp@2685: u8 i;
fp@2685:
fp@2685: memset(p, 0, IGB_REGS_LEN * sizeof(u32));
fp@2685:
fp@2685: regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id;
fp@2685:
fp@2685: /* General Registers */
fp@2685: regs_buff[0] = rd32(E1000_CTRL);
fp@2685: regs_buff[1] = rd32(E1000_STATUS);
fp@2685: regs_buff[2] = rd32(E1000_CTRL_EXT);
fp@2685: regs_buff[3] = rd32(E1000_MDIC);
fp@2685: regs_buff[4] = rd32(E1000_SCTL);
fp@2685: regs_buff[5] = rd32(E1000_CONNSW);
fp@2685: regs_buff[6] = rd32(E1000_VET);
fp@2685: regs_buff[7] = rd32(E1000_LEDCTL);
fp@2685: regs_buff[8] = rd32(E1000_PBA);
fp@2685: regs_buff[9] = rd32(E1000_PBS);
fp@2685: regs_buff[10] = rd32(E1000_FRTIMER);
fp@2685: regs_buff[11] = rd32(E1000_TCPTIMER);
fp@2685:
fp@2685: /* NVM Register */
fp@2685: regs_buff[12] = rd32(E1000_EECD);
fp@2685:
fp@2685: /* Interrupt */
fp@2685: /* Reading EICS for EICR because they read the
fp@2685: * same but EICS does not clear on read
fp@2685: */
fp@2685: regs_buff[13] = rd32(E1000_EICS);
fp@2685: regs_buff[14] = rd32(E1000_EICS);
fp@2685: regs_buff[15] = rd32(E1000_EIMS);
fp@2685: regs_buff[16] = rd32(E1000_EIMC);
fp@2685: regs_buff[17] = rd32(E1000_EIAC);
fp@2685: regs_buff[18] = rd32(E1000_EIAM);
fp@2685: /* Reading ICS for ICR because they read the
fp@2685: * same but ICS does not clear on read
fp@2685: */
fp@2685: regs_buff[19] = rd32(E1000_ICS);
fp@2685: regs_buff[20] = rd32(E1000_ICS);
fp@2685: regs_buff[21] = rd32(E1000_IMS);
fp@2685: regs_buff[22] = rd32(E1000_IMC);
fp@2685: regs_buff[23] = rd32(E1000_IAC);
fp@2685: regs_buff[24] = rd32(E1000_IAM);
fp@2685: regs_buff[25] = rd32(E1000_IMIRVP);
fp@2685:
fp@2685: /* Flow Control */
fp@2685: regs_buff[26] = rd32(E1000_FCAL);
fp@2685: regs_buff[27] = rd32(E1000_FCAH);
fp@2685: regs_buff[28] = rd32(E1000_FCTTV);
fp@2685: regs_buff[29] = rd32(E1000_FCRTL);
fp@2685: regs_buff[30] = rd32(E1000_FCRTH);
fp@2685: regs_buff[31] = rd32(E1000_FCRTV);
fp@2685:
fp@2685: /* Receive */
fp@2685: regs_buff[32] = rd32(E1000_RCTL);
fp@2685: regs_buff[33] = rd32(E1000_RXCSUM);
fp@2685: regs_buff[34] = rd32(E1000_RLPML);
fp@2685: regs_buff[35] = rd32(E1000_RFCTL);
fp@2685: regs_buff[36] = rd32(E1000_MRQC);
fp@2685: regs_buff[37] = rd32(E1000_VT_CTL);
fp@2685:
fp@2685: /* Transmit */
fp@2685: regs_buff[38] = rd32(E1000_TCTL);
fp@2685: regs_buff[39] = rd32(E1000_TCTL_EXT);
fp@2685: regs_buff[40] = rd32(E1000_TIPG);
fp@2685: regs_buff[41] = rd32(E1000_DTXCTL);
fp@2685:
fp@2685: /* Wake Up */
fp@2685: regs_buff[42] = rd32(E1000_WUC);
fp@2685: regs_buff[43] = rd32(E1000_WUFC);
fp@2685: regs_buff[44] = rd32(E1000_WUS);
fp@2685: regs_buff[45] = rd32(E1000_IPAV);
fp@2685: regs_buff[46] = rd32(E1000_WUPL);
fp@2685:
fp@2685: /* MAC */
fp@2685: regs_buff[47] = rd32(E1000_PCS_CFG0);
fp@2685: regs_buff[48] = rd32(E1000_PCS_LCTL);
fp@2685: regs_buff[49] = rd32(E1000_PCS_LSTAT);
fp@2685: regs_buff[50] = rd32(E1000_PCS_ANADV);
fp@2685: regs_buff[51] = rd32(E1000_PCS_LPAB);
fp@2685: regs_buff[52] = rd32(E1000_PCS_NPTX);
fp@2685: regs_buff[53] = rd32(E1000_PCS_LPABNP);
fp@2685:
fp@2685: /* Statistics */
fp@2685: regs_buff[54] = adapter->stats.crcerrs;
fp@2685: regs_buff[55] = adapter->stats.algnerrc;
fp@2685: regs_buff[56] = adapter->stats.symerrs;
fp@2685: regs_buff[57] = adapter->stats.rxerrc;
fp@2685: regs_buff[58] = adapter->stats.mpc;
fp@2685: regs_buff[59] = adapter->stats.scc;
fp@2685: regs_buff[60] = adapter->stats.ecol;
fp@2685: regs_buff[61] = adapter->stats.mcc;
fp@2685: regs_buff[62] = adapter->stats.latecol;
fp@2685: regs_buff[63] = adapter->stats.colc;
fp@2685: regs_buff[64] = adapter->stats.dc;
fp@2685: regs_buff[65] = adapter->stats.tncrs;
fp@2685: regs_buff[66] = adapter->stats.sec;
fp@2685: regs_buff[67] = adapter->stats.htdpmc;
fp@2685: regs_buff[68] = adapter->stats.rlec;
fp@2685: regs_buff[69] = adapter->stats.xonrxc;
fp@2685: regs_buff[70] = adapter->stats.xontxc;
fp@2685: regs_buff[71] = adapter->stats.xoffrxc;
fp@2685: regs_buff[72] = adapter->stats.xofftxc;
fp@2685: regs_buff[73] = adapter->stats.fcruc;
fp@2685: regs_buff[74] = adapter->stats.prc64;
fp@2685: regs_buff[75] = adapter->stats.prc127;
fp@2685: regs_buff[76] = adapter->stats.prc255;
fp@2685: regs_buff[77] = adapter->stats.prc511;
fp@2685: regs_buff[78] = adapter->stats.prc1023;
fp@2685: regs_buff[79] = adapter->stats.prc1522;
fp@2685: regs_buff[80] = adapter->stats.gprc;
fp@2685: regs_buff[81] = adapter->stats.bprc;
fp@2685: regs_buff[82] = adapter->stats.mprc;
fp@2685: regs_buff[83] = adapter->stats.gptc;
fp@2685: regs_buff[84] = adapter->stats.gorc;
fp@2685: regs_buff[86] = adapter->stats.gotc;
fp@2685: regs_buff[88] = adapter->stats.rnbc;
fp@2685: regs_buff[89] = adapter->stats.ruc;
fp@2685: regs_buff[90] = adapter->stats.rfc;
fp@2685: regs_buff[91] = adapter->stats.roc;
fp@2685: regs_buff[92] = adapter->stats.rjc;
fp@2685: regs_buff[93] = adapter->stats.mgprc;
fp@2685: regs_buff[94] = adapter->stats.mgpdc;
fp@2685: regs_buff[95] = adapter->stats.mgptc;
fp@2685: regs_buff[96] = adapter->stats.tor;
fp@2685: regs_buff[98] = adapter->stats.tot;
fp@2685: regs_buff[100] = adapter->stats.tpr;
fp@2685: regs_buff[101] = adapter->stats.tpt;
fp@2685: regs_buff[102] = adapter->stats.ptc64;
fp@2685: regs_buff[103] = adapter->stats.ptc127;
fp@2685: regs_buff[104] = adapter->stats.ptc255;
fp@2685: regs_buff[105] = adapter->stats.ptc511;
fp@2685: regs_buff[106] = adapter->stats.ptc1023;
fp@2685: regs_buff[107] = adapter->stats.ptc1522;
fp@2685: regs_buff[108] = adapter->stats.mptc;
fp@2685: regs_buff[109] = adapter->stats.bptc;
fp@2685: regs_buff[110] = adapter->stats.tsctc;
fp@2685: regs_buff[111] = adapter->stats.iac;
fp@2685: regs_buff[112] = adapter->stats.rpthc;
fp@2685: regs_buff[113] = adapter->stats.hgptc;
fp@2685: regs_buff[114] = adapter->stats.hgorc;
fp@2685: regs_buff[116] = adapter->stats.hgotc;
fp@2685: regs_buff[118] = adapter->stats.lenerrs;
fp@2685: regs_buff[119] = adapter->stats.scvpc;
fp@2685: regs_buff[120] = adapter->stats.hrmpc;
fp@2685:
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[121 + i] = rd32(E1000_SRRCTL(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[125 + i] = rd32(E1000_PSRTYPE(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[129 + i] = rd32(E1000_RDBAL(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[133 + i] = rd32(E1000_RDBAH(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[137 + i] = rd32(E1000_RDLEN(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[141 + i] = rd32(E1000_RDH(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[145 + i] = rd32(E1000_RDT(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[149 + i] = rd32(E1000_RXDCTL(i));
fp@2685:
fp@2685: for (i = 0; i < 10; i++)
fp@2685: regs_buff[153 + i] = rd32(E1000_EITR(i));
fp@2685: for (i = 0; i < 8; i++)
fp@2685: regs_buff[163 + i] = rd32(E1000_IMIR(i));
fp@2685: for (i = 0; i < 8; i++)
fp@2685: regs_buff[171 + i] = rd32(E1000_IMIREXT(i));
fp@2685: for (i = 0; i < 16; i++)
fp@2685: regs_buff[179 + i] = rd32(E1000_RAL(i));
fp@2685: for (i = 0; i < 16; i++)
fp@2685: regs_buff[195 + i] = rd32(E1000_RAH(i));
fp@2685:
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[211 + i] = rd32(E1000_TDBAL(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[215 + i] = rd32(E1000_TDBAH(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[219 + i] = rd32(E1000_TDLEN(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[223 + i] = rd32(E1000_TDH(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[227 + i] = rd32(E1000_TDT(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[231 + i] = rd32(E1000_TXDCTL(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[235 + i] = rd32(E1000_TDWBAL(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[239 + i] = rd32(E1000_TDWBAH(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[243 + i] = rd32(E1000_DCA_TXCTRL(i));
fp@2685:
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[247 + i] = rd32(E1000_IP4AT_REG(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[251 + i] = rd32(E1000_IP6AT_REG(i));
fp@2685: for (i = 0; i < 32; i++)
fp@2685: regs_buff[255 + i] = rd32(E1000_WUPM_REG(i));
fp@2685: for (i = 0; i < 128; i++)
fp@2685: regs_buff[287 + i] = rd32(E1000_FFMT_REG(i));
fp@2685: for (i = 0; i < 128; i++)
fp@2685: regs_buff[415 + i] = rd32(E1000_FFVT_REG(i));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[543 + i] = rd32(E1000_FFLT_REG(i));
fp@2685:
fp@2685: regs_buff[547] = rd32(E1000_TDFH);
fp@2685: regs_buff[548] = rd32(E1000_TDFT);
fp@2685: regs_buff[549] = rd32(E1000_TDFHS);
fp@2685: regs_buff[550] = rd32(E1000_TDFPC);
fp@2685:
fp@2685: if (hw->mac.type > e1000_82580) {
fp@2685: regs_buff[551] = adapter->stats.o2bgptc;
fp@2685: regs_buff[552] = adapter->stats.b2ospc;
fp@2685: regs_buff[553] = adapter->stats.o2bspc;
fp@2685: regs_buff[554] = adapter->stats.b2ogprc;
fp@2685: }
fp@2685:
fp@2685: if (hw->mac.type != e1000_82576)
fp@2685: return;
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[555 + i] = rd32(E1000_SRRCTL(i + 4));
fp@2685: for (i = 0; i < 4; i++)
fp@2685: regs_buff[567 + i] = rd32(E1000_PSRTYPE(i + 4));
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[571 + i] = rd32(E1000_RDBAL(i + 4));
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[583 + i] = rd32(E1000_RDBAH(i + 4));
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[595 + i] = rd32(E1000_RDLEN(i + 4));
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[607 + i] = rd32(E1000_RDH(i + 4));
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[619 + i] = rd32(E1000_RDT(i + 4));
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[631 + i] = rd32(E1000_RXDCTL(i + 4));
fp@2685:
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[643 + i] = rd32(E1000_TDBAL(i + 4));
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[655 + i] = rd32(E1000_TDBAH(i + 4));
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[667 + i] = rd32(E1000_TDLEN(i + 4));
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[679 + i] = rd32(E1000_TDH(i + 4));
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[691 + i] = rd32(E1000_TDT(i + 4));
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[703 + i] = rd32(E1000_TXDCTL(i + 4));
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[715 + i] = rd32(E1000_TDWBAL(i + 4));
fp@2685: for (i = 0; i < 12; i++)
fp@2685: regs_buff[727 + i] = rd32(E1000_TDWBAH(i + 4));
fp@2685: }
fp@2685:
fp@2685: static int igb_get_eeprom_len(struct net_device *netdev)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: return adapter->hw.nvm.word_size * 2;
fp@2685: }
fp@2685:
fp@2685: static int igb_get_eeprom(struct net_device *netdev,
fp@2685: struct ethtool_eeprom *eeprom, u8 *bytes)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: u16 *eeprom_buff;
fp@2685: int first_word, last_word;
fp@2685: int ret_val = 0;
fp@2685: u16 i;
fp@2685:
fp@2685: if (eeprom->len == 0)
fp@2685: return -EINVAL;
fp@2685:
fp@2685: eeprom->magic = hw->vendor_id | (hw->device_id << 16);
fp@2685:
fp@2685: first_word = eeprom->offset >> 1;
fp@2685: last_word = (eeprom->offset + eeprom->len - 1) >> 1;
fp@2685:
fp@2685: eeprom_buff = kmalloc(sizeof(u16) *
fp@2685: (last_word - first_word + 1), GFP_KERNEL);
fp@2685: if (!eeprom_buff)
fp@2685: return -ENOMEM;
fp@2685:
fp@2685: if (hw->nvm.type == e1000_nvm_eeprom_spi)
fp@2685: ret_val = hw->nvm.ops.read(hw, first_word,
fp@2685: last_word - first_word + 1,
fp@2685: eeprom_buff);
fp@2685: else {
fp@2685: for (i = 0; i < last_word - first_word + 1; i++) {
fp@2685: ret_val = hw->nvm.ops.read(hw, first_word + i, 1,
fp@2685: &eeprom_buff[i]);
fp@2685: if (ret_val)
fp@2685: break;
fp@2685: }
fp@2685: }
fp@2685:
fp@2685: /* Device's eeprom is always little-endian, word addressable */
fp@2685: for (i = 0; i < last_word - first_word + 1; i++)
fp@2685: le16_to_cpus(&eeprom_buff[i]);
fp@2685:
fp@2685: memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1),
fp@2685: eeprom->len);
fp@2685: kfree(eeprom_buff);
fp@2685:
fp@2685: return ret_val;
fp@2685: }
fp@2685:
fp@2685: static int igb_set_eeprom(struct net_device *netdev,
fp@2685: struct ethtool_eeprom *eeprom, u8 *bytes)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: u16 *eeprom_buff;
fp@2685: void *ptr;
fp@2685: int max_len, first_word, last_word, ret_val = 0;
fp@2685: u16 i;
fp@2685:
fp@2685: if (eeprom->len == 0)
fp@2685: return -EOPNOTSUPP;
fp@2685:
fp@2685: if ((hw->mac.type >= e1000_i210) &&
fp@2685: !igb_get_flash_presence_i210(hw)) {
fp@2685: return -EOPNOTSUPP;
fp@2685: }
fp@2685:
fp@2685: if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16)))
fp@2685: return -EFAULT;
fp@2685:
fp@2685: max_len = hw->nvm.word_size * 2;
fp@2685:
fp@2685: first_word = eeprom->offset >> 1;
fp@2685: last_word = (eeprom->offset + eeprom->len - 1) >> 1;
fp@2685: eeprom_buff = kmalloc(max_len, GFP_KERNEL);
fp@2685: if (!eeprom_buff)
fp@2685: return -ENOMEM;
fp@2685:
fp@2685: ptr = (void *)eeprom_buff;
fp@2685:
fp@2685: if (eeprom->offset & 1) {
fp@2685: /* need read/modify/write of first changed EEPROM word
fp@2685: * only the second byte of the word is being modified
fp@2685: */
fp@2685: ret_val = hw->nvm.ops.read(hw, first_word, 1,
fp@2685: &eeprom_buff[0]);
fp@2685: ptr++;
fp@2685: }
fp@2685: if (((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) {
fp@2685: /* need read/modify/write of last changed EEPROM word
fp@2685: * only the first byte of the word is being modified
fp@2685: */
fp@2685: ret_val = hw->nvm.ops.read(hw, last_word, 1,
fp@2685: &eeprom_buff[last_word - first_word]);
fp@2685: }
fp@2685:
fp@2685: /* Device's eeprom is always little-endian, word addressable */
fp@2685: for (i = 0; i < last_word - first_word + 1; i++)
fp@2685: le16_to_cpus(&eeprom_buff[i]);
fp@2685:
fp@2685: memcpy(ptr, bytes, eeprom->len);
fp@2685:
fp@2685: for (i = 0; i < last_word - first_word + 1; i++)
fp@2685: eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]);
fp@2685:
fp@2685: ret_val = hw->nvm.ops.write(hw, first_word,
fp@2685: last_word - first_word + 1, eeprom_buff);
fp@2685:
fp@2685: /* Update the checksum if nvm write succeeded */
fp@2685: if (ret_val == 0)
fp@2685: hw->nvm.ops.update(hw);
fp@2685:
fp@2685: igb_set_fw_version(adapter);
fp@2685: kfree(eeprom_buff);
fp@2685: return ret_val;
fp@2685: }
fp@2685:
fp@2685: static void igb_get_drvinfo(struct net_device *netdev,
fp@2685: struct ethtool_drvinfo *drvinfo)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685:
fp@2685: strlcpy(drvinfo->driver, igb_driver_name, sizeof(drvinfo->driver));
fp@2685: strlcpy(drvinfo->version, igb_driver_version, sizeof(drvinfo->version));
fp@2685:
fp@2685: /* EEPROM image version # is reported as firmware version # for
fp@2685: * 82575 controllers
fp@2685: */
fp@2685: strlcpy(drvinfo->fw_version, adapter->fw_version,
fp@2685: sizeof(drvinfo->fw_version));
fp@2685: strlcpy(drvinfo->bus_info, pci_name(adapter->pdev),
fp@2685: sizeof(drvinfo->bus_info));
fp@2685: drvinfo->n_stats = IGB_STATS_LEN;
fp@2685: drvinfo->testinfo_len = IGB_TEST_LEN;
fp@2685: drvinfo->regdump_len = igb_get_regs_len(netdev);
fp@2685: drvinfo->eedump_len = igb_get_eeprom_len(netdev);
fp@2685: }
fp@2685:
fp@2685: static void igb_get_ringparam(struct net_device *netdev,
fp@2685: struct ethtool_ringparam *ring)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685:
fp@2685: ring->rx_max_pending = IGB_MAX_RXD;
fp@2685: ring->tx_max_pending = IGB_MAX_TXD;
fp@2685: ring->rx_pending = adapter->rx_ring_count;
fp@2685: ring->tx_pending = adapter->tx_ring_count;
fp@2685: }
fp@2685:
fp@2685: static int igb_set_ringparam(struct net_device *netdev,
fp@2685: struct ethtool_ringparam *ring)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct igb_ring *temp_ring;
fp@2685: int i, err = 0;
fp@2685: u16 new_rx_count, new_tx_count;
fp@2685:
fp@2685: if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
fp@2685: return -EINVAL;
fp@2685:
fp@2685: new_rx_count = min_t(u32, ring->rx_pending, IGB_MAX_RXD);
fp@2685: new_rx_count = max_t(u16, new_rx_count, IGB_MIN_RXD);
fp@2685: new_rx_count = ALIGN(new_rx_count, REQ_RX_DESCRIPTOR_MULTIPLE);
fp@2685:
fp@2685: new_tx_count = min_t(u32, ring->tx_pending, IGB_MAX_TXD);
fp@2685: new_tx_count = max_t(u16, new_tx_count, IGB_MIN_TXD);
fp@2685: new_tx_count = ALIGN(new_tx_count, REQ_TX_DESCRIPTOR_MULTIPLE);
fp@2685:
fp@2685: if ((new_tx_count == adapter->tx_ring_count) &&
fp@2685: (new_rx_count == adapter->rx_ring_count)) {
fp@2685: /* nothing to do */
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: while (test_and_set_bit(__IGB_RESETTING, &adapter->state))
fp@2685: usleep_range(1000, 2000);
fp@2685:
fp@2685: if (!netif_running(adapter->netdev)) {
fp@2685: for (i = 0; i < adapter->num_tx_queues; i++)
fp@2685: adapter->tx_ring[i]->count = new_tx_count;
fp@2685: for (i = 0; i < adapter->num_rx_queues; i++)
fp@2685: adapter->rx_ring[i]->count = new_rx_count;
fp@2685: adapter->tx_ring_count = new_tx_count;
fp@2685: adapter->rx_ring_count = new_rx_count;
fp@2685: goto clear_reset;
fp@2685: }
fp@2685:
fp@2685: if (adapter->num_tx_queues > adapter->num_rx_queues)
fp@2685: temp_ring = vmalloc(adapter->num_tx_queues *
fp@2685: sizeof(struct igb_ring));
fp@2685: else
fp@2685: temp_ring = vmalloc(adapter->num_rx_queues *
fp@2685: sizeof(struct igb_ring));
fp@2685:
fp@2685: if (!temp_ring) {
fp@2685: err = -ENOMEM;
fp@2685: goto clear_reset;
fp@2685: }
fp@2685:
fp@2685: igb_down(adapter);
fp@2685:
fp@2685: /* We can't just free everything and then setup again,
fp@2685: * because the ISRs in MSI-X mode get passed pointers
fp@2685: * to the Tx and Rx ring structs.
fp@2685: */
fp@2685: if (new_tx_count != adapter->tx_ring_count) {
fp@2685: for (i = 0; i < adapter->num_tx_queues; i++) {
fp@2685: memcpy(&temp_ring[i], adapter->tx_ring[i],
fp@2685: sizeof(struct igb_ring));
fp@2685:
fp@2685: temp_ring[i].count = new_tx_count;
fp@2685: err = igb_setup_tx_resources(&temp_ring[i]);
fp@2685: if (err) {
fp@2685: while (i) {
fp@2685: i--;
fp@2685: igb_free_tx_resources(&temp_ring[i]);
fp@2685: }
fp@2685: goto err_setup;
fp@2685: }
fp@2685: }
fp@2685:
fp@2685: for (i = 0; i < adapter->num_tx_queues; i++) {
fp@2685: igb_free_tx_resources(adapter->tx_ring[i]);
fp@2685:
fp@2685: memcpy(adapter->tx_ring[i], &temp_ring[i],
fp@2685: sizeof(struct igb_ring));
fp@2685: }
fp@2685:
fp@2685: adapter->tx_ring_count = new_tx_count;
fp@2685: }
fp@2685:
fp@2685: if (new_rx_count != adapter->rx_ring_count) {
fp@2685: for (i = 0; i < adapter->num_rx_queues; i++) {
fp@2685: memcpy(&temp_ring[i], adapter->rx_ring[i],
fp@2685: sizeof(struct igb_ring));
fp@2685:
fp@2685: temp_ring[i].count = new_rx_count;
fp@2685: err = igb_setup_rx_resources(&temp_ring[i]);
fp@2685: if (err) {
fp@2685: while (i) {
fp@2685: i--;
fp@2685: igb_free_rx_resources(&temp_ring[i]);
fp@2685: }
fp@2685: goto err_setup;
fp@2685: }
fp@2685:
fp@2685: }
fp@2685:
fp@2685: for (i = 0; i < adapter->num_rx_queues; i++) {
fp@2685: igb_free_rx_resources(adapter->rx_ring[i]);
fp@2685:
fp@2685: memcpy(adapter->rx_ring[i], &temp_ring[i],
fp@2685: sizeof(struct igb_ring));
fp@2685: }
fp@2685:
fp@2685: adapter->rx_ring_count = new_rx_count;
fp@2685: }
fp@2685: err_setup:
fp@2685: igb_up(adapter);
fp@2685: vfree(temp_ring);
fp@2685: clear_reset:
fp@2685: clear_bit(__IGB_RESETTING, &adapter->state);
fp@2685: return err;
fp@2685: }
fp@2685:
fp@2685: /* ethtool register test data */
fp@2685: struct igb_reg_test {
fp@2685: u16 reg;
fp@2685: u16 reg_offset;
fp@2685: u16 array_len;
fp@2685: u16 test_type;
fp@2685: u32 mask;
fp@2685: u32 write;
fp@2685: };
fp@2685:
fp@2685: /* In the hardware, registers are laid out either singly, in arrays
fp@2685: * spaced 0x100 bytes apart, or in contiguous tables. We assume
fp@2685: * most tests take place on arrays or single registers (handled
fp@2685: * as a single-element array) and special-case the tables.
fp@2685: * Table tests are always pattern tests.
fp@2685: *
fp@2685: * We also make provision for some required setup steps by specifying
fp@2685: * registers to be written without any read-back testing.
fp@2685: */
fp@2685:
fp@2685: #define PATTERN_TEST 1
fp@2685: #define SET_READ_TEST 2
fp@2685: #define WRITE_NO_TEST 3
fp@2685: #define TABLE32_TEST 4
fp@2685: #define TABLE64_TEST_LO 5
fp@2685: #define TABLE64_TEST_HI 6
fp@2685:
fp@2685: /* i210 reg test */
fp@2685: static struct igb_reg_test reg_test_i210[] = {
fp@2685: { E1000_FCAL, 0x100, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_FCAH, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
fp@2685: { E1000_FCT, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
fp@2685: { E1000_RDBAL(0), 0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_RDBAH(0), 0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RDLEN(0), 0x100, 4, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
fp@2685: /* RDH is read-only for i210, only test RDT. */
fp@2685: { E1000_RDT(0), 0x100, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_FCRTH, 0x100, 1, PATTERN_TEST, 0x0000FFF0, 0x0000FFF0 },
fp@2685: { E1000_FCTTV, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_TIPG, 0x100, 1, PATTERN_TEST, 0x3FFFFFFF, 0x3FFFFFFF },
fp@2685: { E1000_TDBAL(0), 0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_TDBAH(0), 0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_TDLEN(0), 0x100, 4, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
fp@2685: { E1000_TDT(0), 0x100, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0x04CFB0FE, 0x003FFFFB },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0x04CFB0FE, 0xFFFFFFFF },
fp@2685: { E1000_TCTL, 0x100, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
fp@2685: { E1000_RA, 0, 16, TABLE64_TEST_LO,
fp@2685: 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RA, 0, 16, TABLE64_TEST_HI,
fp@2685: 0x900FFFFF, 0xFFFFFFFF },
fp@2685: { E1000_MTA, 0, 128, TABLE32_TEST,
fp@2685: 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { 0, 0, 0, 0, 0 }
fp@2685: };
fp@2685:
fp@2685: /* i350 reg test */
fp@2685: static struct igb_reg_test reg_test_i350[] = {
fp@2685: { E1000_FCAL, 0x100, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_FCAH, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
fp@2685: { E1000_FCT, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
fp@2685: { E1000_VET, 0x100, 1, PATTERN_TEST, 0xFFFF0000, 0xFFFF0000 },
fp@2685: { E1000_RDBAL(0), 0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_RDBAH(0), 0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RDLEN(0), 0x100, 4, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
fp@2685: { E1000_RDBAL(4), 0x40, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_RDBAH(4), 0x40, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RDLEN(4), 0x40, 4, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
fp@2685: /* RDH is read-only for i350, only test RDT. */
fp@2685: { E1000_RDT(0), 0x100, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_RDT(4), 0x40, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_FCRTH, 0x100, 1, PATTERN_TEST, 0x0000FFF0, 0x0000FFF0 },
fp@2685: { E1000_FCTTV, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_TIPG, 0x100, 1, PATTERN_TEST, 0x3FFFFFFF, 0x3FFFFFFF },
fp@2685: { E1000_TDBAL(0), 0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_TDBAH(0), 0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_TDLEN(0), 0x100, 4, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
fp@2685: { E1000_TDBAL(4), 0x40, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_TDBAH(4), 0x40, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_TDLEN(4), 0x40, 4, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
fp@2685: { E1000_TDT(0), 0x100, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_TDT(4), 0x40, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0x04CFB0FE, 0x003FFFFB },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0x04CFB0FE, 0xFFFFFFFF },
fp@2685: { E1000_TCTL, 0x100, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
fp@2685: { E1000_RA, 0, 16, TABLE64_TEST_LO,
fp@2685: 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RA, 0, 16, TABLE64_TEST_HI,
fp@2685: 0xC3FFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RA2, 0, 16, TABLE64_TEST_LO,
fp@2685: 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RA2, 0, 16, TABLE64_TEST_HI,
fp@2685: 0xC3FFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_MTA, 0, 128, TABLE32_TEST,
fp@2685: 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { 0, 0, 0, 0 }
fp@2685: };
fp@2685:
fp@2685: /* 82580 reg test */
fp@2685: static struct igb_reg_test reg_test_82580[] = {
fp@2685: { E1000_FCAL, 0x100, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_FCAH, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
fp@2685: { E1000_FCT, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
fp@2685: { E1000_VET, 0x100, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RDBAL(0), 0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_RDBAH(0), 0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RDLEN(0), 0x100, 4, PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
fp@2685: { E1000_RDBAL(4), 0x40, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_RDBAH(4), 0x40, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RDLEN(4), 0x40, 4, PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
fp@2685: /* RDH is read-only for 82580, only test RDT. */
fp@2685: { E1000_RDT(0), 0x100, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_RDT(4), 0x40, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_FCRTH, 0x100, 1, PATTERN_TEST, 0x0000FFF0, 0x0000FFF0 },
fp@2685: { E1000_FCTTV, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_TIPG, 0x100, 1, PATTERN_TEST, 0x3FFFFFFF, 0x3FFFFFFF },
fp@2685: { E1000_TDBAL(0), 0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_TDBAH(0), 0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_TDLEN(0), 0x100, 4, PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
fp@2685: { E1000_TDBAL(4), 0x40, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_TDBAH(4), 0x40, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_TDLEN(4), 0x40, 4, PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
fp@2685: { E1000_TDT(0), 0x100, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_TDT(4), 0x40, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0x04CFB0FE, 0x003FFFFB },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0x04CFB0FE, 0xFFFFFFFF },
fp@2685: { E1000_TCTL, 0x100, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
fp@2685: { E1000_RA, 0, 16, TABLE64_TEST_LO,
fp@2685: 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RA, 0, 16, TABLE64_TEST_HI,
fp@2685: 0x83FFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RA2, 0, 8, TABLE64_TEST_LO,
fp@2685: 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RA2, 0, 8, TABLE64_TEST_HI,
fp@2685: 0x83FFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_MTA, 0, 128, TABLE32_TEST,
fp@2685: 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { 0, 0, 0, 0 }
fp@2685: };
fp@2685:
fp@2685: /* 82576 reg test */
fp@2685: static struct igb_reg_test reg_test_82576[] = {
fp@2685: { E1000_FCAL, 0x100, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_FCAH, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
fp@2685: { E1000_FCT, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
fp@2685: { E1000_VET, 0x100, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RDBAL(0), 0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_RDBAH(0), 0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RDLEN(0), 0x100, 4, PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
fp@2685: { E1000_RDBAL(4), 0x40, 12, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_RDBAH(4), 0x40, 12, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RDLEN(4), 0x40, 12, PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
fp@2685: /* Enable all RX queues before testing. */
fp@2685: { E1000_RXDCTL(0), 0x100, 4, WRITE_NO_TEST, 0,
fp@2685: E1000_RXDCTL_QUEUE_ENABLE },
fp@2685: { E1000_RXDCTL(4), 0x40, 12, WRITE_NO_TEST, 0,
fp@2685: E1000_RXDCTL_QUEUE_ENABLE },
fp@2685: /* RDH is read-only for 82576, only test RDT. */
fp@2685: { E1000_RDT(0), 0x100, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_RDT(4), 0x40, 12, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_RXDCTL(0), 0x100, 4, WRITE_NO_TEST, 0, 0 },
fp@2685: { E1000_RXDCTL(4), 0x40, 12, WRITE_NO_TEST, 0, 0 },
fp@2685: { E1000_FCRTH, 0x100, 1, PATTERN_TEST, 0x0000FFF0, 0x0000FFF0 },
fp@2685: { E1000_FCTTV, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_TIPG, 0x100, 1, PATTERN_TEST, 0x3FFFFFFF, 0x3FFFFFFF },
fp@2685: { E1000_TDBAL(0), 0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_TDBAH(0), 0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_TDLEN(0), 0x100, 4, PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
fp@2685: { E1000_TDBAL(4), 0x40, 12, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_TDBAH(4), 0x40, 12, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_TDLEN(4), 0x40, 12, PATTERN_TEST, 0x000FFFF0, 0x000FFFFF },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0x04CFB0FE, 0x003FFFFB },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0x04CFB0FE, 0xFFFFFFFF },
fp@2685: { E1000_TCTL, 0x100, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
fp@2685: { E1000_RA, 0, 16, TABLE64_TEST_LO, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RA, 0, 16, TABLE64_TEST_HI, 0x83FFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RA2, 0, 8, TABLE64_TEST_LO, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RA2, 0, 8, TABLE64_TEST_HI, 0x83FFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_MTA, 0, 128, TABLE32_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { 0, 0, 0, 0 }
fp@2685: };
fp@2685:
fp@2685: /* 82575 register test */
fp@2685: static struct igb_reg_test reg_test_82575[] = {
fp@2685: { E1000_FCAL, 0x100, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_FCAH, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
fp@2685: { E1000_FCT, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0xFFFFFFFF },
fp@2685: { E1000_VET, 0x100, 1, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RDBAL(0), 0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_RDBAH(0), 0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RDLEN(0), 0x100, 4, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
fp@2685: /* Enable all four RX queues before testing. */
fp@2685: { E1000_RXDCTL(0), 0x100, 4, WRITE_NO_TEST, 0,
fp@2685: E1000_RXDCTL_QUEUE_ENABLE },
fp@2685: /* RDH is read-only for 82575, only test RDT. */
fp@2685: { E1000_RDT(0), 0x100, 4, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_RXDCTL(0), 0x100, 4, WRITE_NO_TEST, 0, 0 },
fp@2685: { E1000_FCRTH, 0x100, 1, PATTERN_TEST, 0x0000FFF0, 0x0000FFF0 },
fp@2685: { E1000_FCTTV, 0x100, 1, PATTERN_TEST, 0x0000FFFF, 0x0000FFFF },
fp@2685: { E1000_TIPG, 0x100, 1, PATTERN_TEST, 0x3FFFFFFF, 0x3FFFFFFF },
fp@2685: { E1000_TDBAL(0), 0x100, 4, PATTERN_TEST, 0xFFFFFF80, 0xFFFFFFFF },
fp@2685: { E1000_TDBAH(0), 0x100, 4, PATTERN_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_TDLEN(0), 0x100, 4, PATTERN_TEST, 0x000FFF80, 0x000FFFFF },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0x04CFB3FE, 0x003FFFFB },
fp@2685: { E1000_RCTL, 0x100, 1, SET_READ_TEST, 0x04CFB3FE, 0xFFFFFFFF },
fp@2685: { E1000_TCTL, 0x100, 1, SET_READ_TEST, 0xFFFFFFFF, 0x00000000 },
fp@2685: { E1000_TXCW, 0x100, 1, PATTERN_TEST, 0xC000FFFF, 0x0000FFFF },
fp@2685: { E1000_RA, 0, 16, TABLE64_TEST_LO, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { E1000_RA, 0, 16, TABLE64_TEST_HI, 0x800FFFFF, 0xFFFFFFFF },
fp@2685: { E1000_MTA, 0, 128, TABLE32_TEST, 0xFFFFFFFF, 0xFFFFFFFF },
fp@2685: { 0, 0, 0, 0 }
fp@2685: };
fp@2685:
fp@2685: static bool reg_pattern_test(struct igb_adapter *adapter, u64 *data,
fp@2685: int reg, u32 mask, u32 write)
fp@2685: {
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: u32 pat, val;
fp@2685: static const u32 _test[] = {
fp@2685: 0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
fp@2685: for (pat = 0; pat < ARRAY_SIZE(_test); pat++) {
fp@2685: wr32(reg, (_test[pat] & write));
fp@2685: val = rd32(reg) & mask;
fp@2685: if (val != (_test[pat] & write & mask)) {
fp@2685: dev_err(&adapter->pdev->dev,
fp@2685: "pattern test reg %04X failed: got 0x%08X expected 0x%08X\n",
fp@2685: reg, val, (_test[pat] & write & mask));
fp@2685: *data = reg;
fp@2685: return true;
fp@2685: }
fp@2685: }
fp@2685:
fp@2685: return false;
fp@2685: }
fp@2685:
fp@2685: static bool reg_set_and_check(struct igb_adapter *adapter, u64 *data,
fp@2685: int reg, u32 mask, u32 write)
fp@2685: {
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: u32 val;
fp@2685:
fp@2685: wr32(reg, write & mask);
fp@2685: val = rd32(reg);
fp@2685: if ((write & mask) != (val & mask)) {
fp@2685: dev_err(&adapter->pdev->dev,
fp@2685: "set/check reg %04X test failed: got 0x%08X expected 0x%08X\n",
fp@2685: reg, (val & mask), (write & mask));
fp@2685: *data = reg;
fp@2685: return true;
fp@2685: }
fp@2685:
fp@2685: return false;
fp@2685: }
fp@2685:
fp@2685: #define REG_PATTERN_TEST(reg, mask, write) \
fp@2685: do { \
fp@2685: if (reg_pattern_test(adapter, data, reg, mask, write)) \
fp@2685: return 1; \
fp@2685: } while (0)
fp@2685:
fp@2685: #define REG_SET_AND_CHECK(reg, mask, write) \
fp@2685: do { \
fp@2685: if (reg_set_and_check(adapter, data, reg, mask, write)) \
fp@2685: return 1; \
fp@2685: } while (0)
fp@2685:
fp@2685: static int igb_reg_test(struct igb_adapter *adapter, u64 *data)
fp@2685: {
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: struct igb_reg_test *test;
fp@2685: u32 value, before, after;
fp@2685: u32 i, toggle;
fp@2685:
fp@2685: switch (adapter->hw.mac.type) {
fp@2685: case e1000_i350:
fp@2685: case e1000_i354:
fp@2685: test = reg_test_i350;
fp@2685: toggle = 0x7FEFF3FF;
fp@2685: break;
fp@2685: case e1000_i210:
fp@2685: case e1000_i211:
fp@2685: test = reg_test_i210;
fp@2685: toggle = 0x7FEFF3FF;
fp@2685: break;
fp@2685: case e1000_82580:
fp@2685: test = reg_test_82580;
fp@2685: toggle = 0x7FEFF3FF;
fp@2685: break;
fp@2685: case e1000_82576:
fp@2685: test = reg_test_82576;
fp@2685: toggle = 0x7FFFF3FF;
fp@2685: break;
fp@2685: default:
fp@2685: test = reg_test_82575;
fp@2685: toggle = 0x7FFFF3FF;
fp@2685: break;
fp@2685: }
fp@2685:
fp@2685: /* Because the status register is such a special case,
fp@2685: * we handle it separately from the rest of the register
fp@2685: * tests. Some bits are read-only, some toggle, and some
fp@2685: * are writable on newer MACs.
fp@2685: */
fp@2685: before = rd32(E1000_STATUS);
fp@2685: value = (rd32(E1000_STATUS) & toggle);
fp@2685: wr32(E1000_STATUS, toggle);
fp@2685: after = rd32(E1000_STATUS) & toggle;
fp@2685: if (value != after) {
fp@2685: dev_err(&adapter->pdev->dev,
fp@2685: "failed STATUS register test got: 0x%08X expected: 0x%08X\n",
fp@2685: after, value);
fp@2685: *data = 1;
fp@2685: return 1;
fp@2685: }
fp@2685: /* restore previous status */
fp@2685: wr32(E1000_STATUS, before);
fp@2685:
fp@2685: /* Perform the remainder of the register test, looping through
fp@2685: * the test table until we either fail or reach the null entry.
fp@2685: */
fp@2685: while (test->reg) {
fp@2685: for (i = 0; i < test->array_len; i++) {
fp@2685: switch (test->test_type) {
fp@2685: case PATTERN_TEST:
fp@2685: REG_PATTERN_TEST(test->reg +
fp@2685: (i * test->reg_offset),
fp@2685: test->mask,
fp@2685: test->write);
fp@2685: break;
fp@2685: case SET_READ_TEST:
fp@2685: REG_SET_AND_CHECK(test->reg +
fp@2685: (i * test->reg_offset),
fp@2685: test->mask,
fp@2685: test->write);
fp@2685: break;
fp@2685: case WRITE_NO_TEST:
fp@2685: writel(test->write,
fp@2685: (adapter->hw.hw_addr + test->reg)
fp@2685: + (i * test->reg_offset));
fp@2685: break;
fp@2685: case TABLE32_TEST:
fp@2685: REG_PATTERN_TEST(test->reg + (i * 4),
fp@2685: test->mask,
fp@2685: test->write);
fp@2685: break;
fp@2685: case TABLE64_TEST_LO:
fp@2685: REG_PATTERN_TEST(test->reg + (i * 8),
fp@2685: test->mask,
fp@2685: test->write);
fp@2685: break;
fp@2685: case TABLE64_TEST_HI:
fp@2685: REG_PATTERN_TEST((test->reg + 4) + (i * 8),
fp@2685: test->mask,
fp@2685: test->write);
fp@2685: break;
fp@2685: }
fp@2685: }
fp@2685: test++;
fp@2685: }
fp@2685:
fp@2685: *data = 0;
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static int igb_eeprom_test(struct igb_adapter *adapter, u64 *data)
fp@2685: {
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685:
fp@2685: *data = 0;
fp@2685:
fp@2685: /* Validate eeprom on all parts but flashless */
fp@2685: switch (hw->mac.type) {
fp@2685: case e1000_i210:
fp@2685: case e1000_i211:
fp@2685: if (igb_get_flash_presence_i210(hw)) {
fp@2685: if (adapter->hw.nvm.ops.validate(&adapter->hw) < 0)
fp@2685: *data = 2;
fp@2685: }
fp@2685: break;
fp@2685: default:
fp@2685: if (adapter->hw.nvm.ops.validate(&adapter->hw) < 0)
fp@2685: *data = 2;
fp@2685: break;
fp@2685: }
fp@2685:
fp@2685: return *data;
fp@2685: }
fp@2685:
fp@2685: static irqreturn_t igb_test_intr(int irq, void *data)
fp@2685: {
fp@2685: struct igb_adapter *adapter = (struct igb_adapter *) data;
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685:
fp@2685: adapter->test_icr |= rd32(E1000_ICR);
fp@2685:
fp@2685: return IRQ_HANDLED;
fp@2685: }
fp@2685:
fp@2685: static int igb_intr_test(struct igb_adapter *adapter, u64 *data)
fp@2685: {
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: struct net_device *netdev = adapter->netdev;
fp@2685: u32 mask, ics_mask, i = 0, shared_int = true;
fp@2685: u32 irq = adapter->pdev->irq;
fp@2685:
fp@2685: *data = 0;
fp@2685:
fp@2685: /* Hook up test interrupt handler just for this test */
fp@2685: if (adapter->flags & IGB_FLAG_HAS_MSIX) {
fp@2685: if (request_irq(adapter->msix_entries[0].vector,
fp@2685: igb_test_intr, 0, netdev->name, adapter)) {
fp@2685: *data = 1;
fp@2685: return -1;
fp@2685: }
fp@2685: } else if (adapter->flags & IGB_FLAG_HAS_MSI) {
fp@2685: shared_int = false;
fp@2685: if (request_irq(irq,
fp@2685: igb_test_intr, 0, netdev->name, adapter)) {
fp@2685: *data = 1;
fp@2685: return -1;
fp@2685: }
fp@2685: } else if (!request_irq(irq, igb_test_intr, IRQF_PROBE_SHARED,
fp@2685: netdev->name, adapter)) {
fp@2685: shared_int = false;
fp@2685: } else if (request_irq(irq, igb_test_intr, IRQF_SHARED,
fp@2685: netdev->name, adapter)) {
fp@2685: *data = 1;
fp@2685: return -1;
fp@2685: }
fp@2685: dev_info(&adapter->pdev->dev, "testing %s interrupt\n",
fp@2685: (shared_int ? "shared" : "unshared"));
fp@2685:
fp@2685: /* Disable all the interrupts */
fp@2685: wr32(E1000_IMC, ~0);
fp@2685: wrfl();
fp@2685: usleep_range(10000, 11000);
fp@2685:
fp@2685: /* Define all writable bits for ICS */
fp@2685: switch (hw->mac.type) {
fp@2685: case e1000_82575:
fp@2685: ics_mask = 0x37F47EDD;
fp@2685: break;
fp@2685: case e1000_82576:
fp@2685: ics_mask = 0x77D4FBFD;
fp@2685: break;
fp@2685: case e1000_82580:
fp@2685: ics_mask = 0x77DCFED5;
fp@2685: break;
fp@2685: case e1000_i350:
fp@2685: case e1000_i354:
fp@2685: case e1000_i210:
fp@2685: case e1000_i211:
fp@2685: ics_mask = 0x77DCFED5;
fp@2685: break;
fp@2685: default:
fp@2685: ics_mask = 0x7FFFFFFF;
fp@2685: break;
fp@2685: }
fp@2685:
fp@2685: /* Test each interrupt */
fp@2685: for (; i < 31; i++) {
fp@2685: /* Interrupt to test */
fp@2685: mask = 1 << i;
fp@2685:
fp@2685: if (!(mask & ics_mask))
fp@2685: continue;
fp@2685:
fp@2685: if (!shared_int) {
fp@2685: /* Disable the interrupt to be reported in
fp@2685: * the cause register and then force the same
fp@2685: * interrupt and see if one gets posted. If
fp@2685: * an interrupt was posted to the bus, the
fp@2685: * test failed.
fp@2685: */
fp@2685: adapter->test_icr = 0;
fp@2685:
fp@2685: /* Flush any pending interrupts */
fp@2685: wr32(E1000_ICR, ~0);
fp@2685:
fp@2685: wr32(E1000_IMC, mask);
fp@2685: wr32(E1000_ICS, mask);
fp@2685: wrfl();
fp@2685: usleep_range(10000, 11000);
fp@2685:
fp@2685: if (adapter->test_icr & mask) {
fp@2685: *data = 3;
fp@2685: break;
fp@2685: }
fp@2685: }
fp@2685:
fp@2685: /* Enable the interrupt to be reported in
fp@2685: * the cause register and then force the same
fp@2685: * interrupt and see if one gets posted. If
fp@2685: * an interrupt was not posted to the bus, the
fp@2685: * test failed.
fp@2685: */
fp@2685: adapter->test_icr = 0;
fp@2685:
fp@2685: /* Flush any pending interrupts */
fp@2685: wr32(E1000_ICR, ~0);
fp@2685:
fp@2685: wr32(E1000_IMS, mask);
fp@2685: wr32(E1000_ICS, mask);
fp@2685: wrfl();
fp@2685: usleep_range(10000, 11000);
fp@2685:
fp@2685: if (!(adapter->test_icr & mask)) {
fp@2685: *data = 4;
fp@2685: break;
fp@2685: }
fp@2685:
fp@2685: if (!shared_int) {
fp@2685: /* Disable the other interrupts to be reported in
fp@2685: * the cause register and then force the other
fp@2685: * interrupts and see if any get posted. If
fp@2685: * an interrupt was posted to the bus, the
fp@2685: * test failed.
fp@2685: */
fp@2685: adapter->test_icr = 0;
fp@2685:
fp@2685: /* Flush any pending interrupts */
fp@2685: wr32(E1000_ICR, ~0);
fp@2685:
fp@2685: wr32(E1000_IMC, ~mask);
fp@2685: wr32(E1000_ICS, ~mask);
fp@2685: wrfl();
fp@2685: usleep_range(10000, 11000);
fp@2685:
fp@2685: if (adapter->test_icr & mask) {
fp@2685: *data = 5;
fp@2685: break;
fp@2685: }
fp@2685: }
fp@2685: }
fp@2685:
fp@2685: /* Disable all the interrupts */
fp@2685: wr32(E1000_IMC, ~0);
fp@2685: wrfl();
fp@2685: usleep_range(10000, 11000);
fp@2685:
fp@2685: /* Unhook test interrupt handler */
fp@2685: if (adapter->flags & IGB_FLAG_HAS_MSIX)
fp@2685: free_irq(adapter->msix_entries[0].vector, adapter);
fp@2685: else
fp@2685: free_irq(irq, adapter);
fp@2685:
fp@2685: return *data;
fp@2685: }
fp@2685:
fp@2685: static void igb_free_desc_rings(struct igb_adapter *adapter)
fp@2685: {
fp@2685: igb_free_tx_resources(&adapter->test_tx_ring);
fp@2685: igb_free_rx_resources(&adapter->test_rx_ring);
fp@2685: }
fp@2685:
fp@2685: static int igb_setup_desc_rings(struct igb_adapter *adapter)
fp@2685: {
fp@2685: struct igb_ring *tx_ring = &adapter->test_tx_ring;
fp@2685: struct igb_ring *rx_ring = &adapter->test_rx_ring;
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: int ret_val;
fp@2685:
fp@2685: /* Setup Tx descriptor ring and Tx buffers */
fp@2685: tx_ring->count = IGB_DEFAULT_TXD;
fp@2685: tx_ring->dev = &adapter->pdev->dev;
fp@2685: tx_ring->netdev = adapter->netdev;
fp@2685: tx_ring->reg_idx = adapter->vfs_allocated_count;
fp@2685:
fp@2685: if (igb_setup_tx_resources(tx_ring)) {
fp@2685: ret_val = 1;
fp@2685: goto err_nomem;
fp@2685: }
fp@2685:
fp@2685: igb_setup_tctl(adapter);
fp@2685: igb_configure_tx_ring(adapter, tx_ring);
fp@2685:
fp@2685: /* Setup Rx descriptor ring and Rx buffers */
fp@2685: rx_ring->count = IGB_DEFAULT_RXD;
fp@2685: rx_ring->dev = &adapter->pdev->dev;
fp@2685: rx_ring->netdev = adapter->netdev;
fp@2685: rx_ring->reg_idx = adapter->vfs_allocated_count;
fp@2685:
fp@2685: if (igb_setup_rx_resources(rx_ring)) {
fp@2685: ret_val = 3;
fp@2685: goto err_nomem;
fp@2685: }
fp@2685:
fp@2685: /* set the default queue to queue 0 of PF */
fp@2685: wr32(E1000_MRQC, adapter->vfs_allocated_count << 3);
fp@2685:
fp@2685: /* enable receive ring */
fp@2685: igb_setup_rctl(adapter);
fp@2685: igb_configure_rx_ring(adapter, rx_ring);
fp@2685:
fp@2685: igb_alloc_rx_buffers(rx_ring, igb_desc_unused(rx_ring));
fp@2685:
fp@2685: return 0;
fp@2685:
fp@2685: err_nomem:
fp@2685: igb_free_desc_rings(adapter);
fp@2685: return ret_val;
fp@2685: }
fp@2685:
fp@2685: static void igb_phy_disable_receiver(struct igb_adapter *adapter)
fp@2685: {
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685:
fp@2685: /* Write out to PHY registers 29 and 30 to disable the Receiver. */
fp@2685: igb_write_phy_reg(hw, 29, 0x001F);
fp@2685: igb_write_phy_reg(hw, 30, 0x8FFC);
fp@2685: igb_write_phy_reg(hw, 29, 0x001A);
fp@2685: igb_write_phy_reg(hw, 30, 0x8FF0);
fp@2685: }
fp@2685:
fp@2685: static int igb_integrated_phy_loopback(struct igb_adapter *adapter)
fp@2685: {
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: u32 ctrl_reg = 0;
fp@2685:
fp@2685: hw->mac.autoneg = false;
fp@2685:
fp@2685: if (hw->phy.type == e1000_phy_m88) {
fp@2685: if (hw->phy.id != I210_I_PHY_ID) {
fp@2685: /* Auto-MDI/MDIX Off */
fp@2685: igb_write_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, 0x0808);
fp@2685: /* reset to update Auto-MDI/MDIX */
fp@2685: igb_write_phy_reg(hw, PHY_CONTROL, 0x9140);
fp@2685: /* autoneg off */
fp@2685: igb_write_phy_reg(hw, PHY_CONTROL, 0x8140);
fp@2685: } else {
fp@2685: /* force 1000, set loopback */
fp@2685: igb_write_phy_reg(hw, I347AT4_PAGE_SELECT, 0);
fp@2685: igb_write_phy_reg(hw, PHY_CONTROL, 0x4140);
fp@2685: }
fp@2685: } else if (hw->phy.type == e1000_phy_82580) {
fp@2685: /* enable MII loopback */
fp@2685: igb_write_phy_reg(hw, I82580_PHY_LBK_CTRL, 0x8041);
fp@2685: }
fp@2685:
fp@2685: /* add small delay to avoid loopback test failure */
fp@2685: msleep(50);
fp@2685:
fp@2685: /* force 1000, set loopback */
fp@2685: igb_write_phy_reg(hw, PHY_CONTROL, 0x4140);
fp@2685:
fp@2685: /* Now set up the MAC to the same speed/duplex as the PHY. */
fp@2685: ctrl_reg = rd32(E1000_CTRL);
fp@2685: ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
fp@2685: ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
fp@2685: E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
fp@2685: E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
fp@2685: E1000_CTRL_FD | /* Force Duplex to FULL */
fp@2685: E1000_CTRL_SLU); /* Set link up enable bit */
fp@2685:
fp@2685: if (hw->phy.type == e1000_phy_m88)
fp@2685: ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
fp@2685:
fp@2685: wr32(E1000_CTRL, ctrl_reg);
fp@2685:
fp@2685: /* Disable the receiver on the PHY so when a cable is plugged in, the
fp@2685: * PHY does not begin to autoneg when a cable is reconnected to the NIC.
fp@2685: */
fp@2685: if (hw->phy.type == e1000_phy_m88)
fp@2685: igb_phy_disable_receiver(adapter);
fp@2685:
fp@2685: mdelay(500);
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static int igb_set_phy_loopback(struct igb_adapter *adapter)
fp@2685: {
fp@2685: return igb_integrated_phy_loopback(adapter);
fp@2685: }
fp@2685:
fp@2685: static int igb_setup_loopback_test(struct igb_adapter *adapter)
fp@2685: {
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: u32 reg;
fp@2685:
fp@2685: reg = rd32(E1000_CTRL_EXT);
fp@2685:
fp@2685: /* use CTRL_EXT to identify link type as SGMII can appear as copper */
fp@2685: if (reg & E1000_CTRL_EXT_LINK_MODE_MASK) {
fp@2685: if ((hw->device_id == E1000_DEV_ID_DH89XXCC_SGMII) ||
fp@2685: (hw->device_id == E1000_DEV_ID_DH89XXCC_SERDES) ||
fp@2685: (hw->device_id == E1000_DEV_ID_DH89XXCC_BACKPLANE) ||
fp@2685: (hw->device_id == E1000_DEV_ID_DH89XXCC_SFP) ||
fp@2685: (hw->device_id == E1000_DEV_ID_I354_SGMII) ||
fp@2685: (hw->device_id == E1000_DEV_ID_I354_BACKPLANE_2_5GBPS)) {
fp@2685: /* Enable DH89xxCC MPHY for near end loopback */
fp@2685: reg = rd32(E1000_MPHY_ADDR_CTL);
fp@2685: reg = (reg & E1000_MPHY_ADDR_CTL_OFFSET_MASK) |
fp@2685: E1000_MPHY_PCS_CLK_REG_OFFSET;
fp@2685: wr32(E1000_MPHY_ADDR_CTL, reg);
fp@2685:
fp@2685: reg = rd32(E1000_MPHY_DATA);
fp@2685: reg |= E1000_MPHY_PCS_CLK_REG_DIGINELBEN;
fp@2685: wr32(E1000_MPHY_DATA, reg);
fp@2685: }
fp@2685:
fp@2685: reg = rd32(E1000_RCTL);
fp@2685: reg |= E1000_RCTL_LBM_TCVR;
fp@2685: wr32(E1000_RCTL, reg);
fp@2685:
fp@2685: wr32(E1000_SCTL, E1000_ENABLE_SERDES_LOOPBACK);
fp@2685:
fp@2685: reg = rd32(E1000_CTRL);
fp@2685: reg &= ~(E1000_CTRL_RFCE |
fp@2685: E1000_CTRL_TFCE |
fp@2685: E1000_CTRL_LRST);
fp@2685: reg |= E1000_CTRL_SLU |
fp@2685: E1000_CTRL_FD;
fp@2685: wr32(E1000_CTRL, reg);
fp@2685:
fp@2685: /* Unset switch control to serdes energy detect */
fp@2685: reg = rd32(E1000_CONNSW);
fp@2685: reg &= ~E1000_CONNSW_ENRGSRC;
fp@2685: wr32(E1000_CONNSW, reg);
fp@2685:
fp@2685: /* Unset sigdetect for SERDES loopback on
fp@2685: * 82580 and newer devices.
fp@2685: */
fp@2685: if (hw->mac.type >= e1000_82580) {
fp@2685: reg = rd32(E1000_PCS_CFG0);
fp@2685: reg |= E1000_PCS_CFG_IGN_SD;
fp@2685: wr32(E1000_PCS_CFG0, reg);
fp@2685: }
fp@2685:
fp@2685: /* Set PCS register for forced speed */
fp@2685: reg = rd32(E1000_PCS_LCTL);
fp@2685: reg &= ~E1000_PCS_LCTL_AN_ENABLE; /* Disable Autoneg*/
fp@2685: reg |= E1000_PCS_LCTL_FLV_LINK_UP | /* Force link up */
fp@2685: E1000_PCS_LCTL_FSV_1000 | /* Force 1000 */
fp@2685: E1000_PCS_LCTL_FDV_FULL | /* SerDes Full duplex */
fp@2685: E1000_PCS_LCTL_FSD | /* Force Speed */
fp@2685: E1000_PCS_LCTL_FORCE_LINK; /* Force Link */
fp@2685: wr32(E1000_PCS_LCTL, reg);
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: return igb_set_phy_loopback(adapter);
fp@2685: }
fp@2685:
fp@2685: static void igb_loopback_cleanup(struct igb_adapter *adapter)
fp@2685: {
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: u32 rctl;
fp@2685: u16 phy_reg;
fp@2685:
fp@2685: if ((hw->device_id == E1000_DEV_ID_DH89XXCC_SGMII) ||
fp@2685: (hw->device_id == E1000_DEV_ID_DH89XXCC_SERDES) ||
fp@2685: (hw->device_id == E1000_DEV_ID_DH89XXCC_BACKPLANE) ||
fp@2685: (hw->device_id == E1000_DEV_ID_DH89XXCC_SFP) ||
fp@2685: (hw->device_id == E1000_DEV_ID_I354_SGMII)) {
fp@2685: u32 reg;
fp@2685:
fp@2685: /* Disable near end loopback on DH89xxCC */
fp@2685: reg = rd32(E1000_MPHY_ADDR_CTL);
fp@2685: reg = (reg & E1000_MPHY_ADDR_CTL_OFFSET_MASK) |
fp@2685: E1000_MPHY_PCS_CLK_REG_OFFSET;
fp@2685: wr32(E1000_MPHY_ADDR_CTL, reg);
fp@2685:
fp@2685: reg = rd32(E1000_MPHY_DATA);
fp@2685: reg &= ~E1000_MPHY_PCS_CLK_REG_DIGINELBEN;
fp@2685: wr32(E1000_MPHY_DATA, reg);
fp@2685: }
fp@2685:
fp@2685: rctl = rd32(E1000_RCTL);
fp@2685: rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
fp@2685: wr32(E1000_RCTL, rctl);
fp@2685:
fp@2685: hw->mac.autoneg = true;
fp@2685: igb_read_phy_reg(hw, PHY_CONTROL, &phy_reg);
fp@2685: if (phy_reg & MII_CR_LOOPBACK) {
fp@2685: phy_reg &= ~MII_CR_LOOPBACK;
fp@2685: igb_write_phy_reg(hw, PHY_CONTROL, phy_reg);
fp@2685: igb_phy_sw_reset(hw);
fp@2685: }
fp@2685: }
fp@2685:
fp@2685: static void igb_create_lbtest_frame(struct sk_buff *skb,
fp@2685: unsigned int frame_size)
fp@2685: {
fp@2685: memset(skb->data, 0xFF, frame_size);
fp@2685: frame_size /= 2;
fp@2685: memset(&skb->data[frame_size], 0xAA, frame_size - 1);
fp@2685: memset(&skb->data[frame_size + 10], 0xBE, 1);
fp@2685: memset(&skb->data[frame_size + 12], 0xAF, 1);
fp@2685: }
fp@2685:
fp@2685: static int igb_check_lbtest_frame(struct igb_rx_buffer *rx_buffer,
fp@2685: unsigned int frame_size)
fp@2685: {
fp@2685: unsigned char *data;
fp@2685: bool match = true;
fp@2685:
fp@2685: frame_size >>= 1;
fp@2685:
fp@2685: data = kmap(rx_buffer->page);
fp@2685:
fp@2685: if (data[3] != 0xFF ||
fp@2685: data[frame_size + 10] != 0xBE ||
fp@2685: data[frame_size + 12] != 0xAF)
fp@2685: match = false;
fp@2685:
fp@2685: kunmap(rx_buffer->page);
fp@2685:
fp@2685: return match;
fp@2685: }
fp@2685:
fp@2685: static int igb_clean_test_rings(struct igb_ring *rx_ring,
fp@2685: struct igb_ring *tx_ring,
fp@2685: unsigned int size)
fp@2685: {
fp@2685: union e1000_adv_rx_desc *rx_desc;
fp@2685: struct igb_rx_buffer *rx_buffer_info;
fp@2685: struct igb_tx_buffer *tx_buffer_info;
fp@2685: u16 rx_ntc, tx_ntc, count = 0;
fp@2685:
fp@2685: /* initialize next to clean and descriptor values */
fp@2685: rx_ntc = rx_ring->next_to_clean;
fp@2685: tx_ntc = tx_ring->next_to_clean;
fp@2685: rx_desc = IGB_RX_DESC(rx_ring, rx_ntc);
fp@2685:
fp@2685: while (igb_test_staterr(rx_desc, E1000_RXD_STAT_DD)) {
fp@2685: /* check Rx buffer */
fp@2685: rx_buffer_info = &rx_ring->rx_buffer_info[rx_ntc];
fp@2685:
fp@2685: /* sync Rx buffer for CPU read */
fp@2685: dma_sync_single_for_cpu(rx_ring->dev,
fp@2685: rx_buffer_info->dma,
fp@2685: IGB_RX_BUFSZ,
fp@2685: DMA_FROM_DEVICE);
fp@2685:
fp@2685: /* verify contents of skb */
fp@2685: if (igb_check_lbtest_frame(rx_buffer_info, size))
fp@2685: count++;
fp@2685:
fp@2685: /* sync Rx buffer for device write */
fp@2685: dma_sync_single_for_device(rx_ring->dev,
fp@2685: rx_buffer_info->dma,
fp@2685: IGB_RX_BUFSZ,
fp@2685: DMA_FROM_DEVICE);
fp@2685:
fp@2685: /* unmap buffer on Tx side */
fp@2685: tx_buffer_info = &tx_ring->tx_buffer_info[tx_ntc];
fp@2685: igb_unmap_and_free_tx_resource(tx_ring, tx_buffer_info);
fp@2685:
fp@2685: /* increment Rx/Tx next to clean counters */
fp@2685: rx_ntc++;
fp@2685: if (rx_ntc == rx_ring->count)
fp@2685: rx_ntc = 0;
fp@2685: tx_ntc++;
fp@2685: if (tx_ntc == tx_ring->count)
fp@2685: tx_ntc = 0;
fp@2685:
fp@2685: /* fetch next descriptor */
fp@2685: rx_desc = IGB_RX_DESC(rx_ring, rx_ntc);
fp@2685: }
fp@2685:
fp@2685: netdev_tx_reset_queue(txring_txq(tx_ring));
fp@2685:
fp@2685: /* re-map buffers to ring, store next to clean values */
fp@2685: igb_alloc_rx_buffers(rx_ring, count);
fp@2685: rx_ring->next_to_clean = rx_ntc;
fp@2685: tx_ring->next_to_clean = tx_ntc;
fp@2685:
fp@2685: return count;
fp@2685: }
fp@2685:
fp@2685: static int igb_run_loopback_test(struct igb_adapter *adapter)
fp@2685: {
fp@2685: struct igb_ring *tx_ring = &adapter->test_tx_ring;
fp@2685: struct igb_ring *rx_ring = &adapter->test_rx_ring;
fp@2685: u16 i, j, lc, good_cnt;
fp@2685: int ret_val = 0;
fp@2685: unsigned int size = IGB_RX_HDR_LEN;
fp@2685: netdev_tx_t tx_ret_val;
fp@2685: struct sk_buff *skb;
fp@2685:
fp@2685: /* allocate test skb */
fp@2685: skb = alloc_skb(size, GFP_KERNEL);
fp@2685: if (!skb)
fp@2685: return 11;
fp@2685:
fp@2685: /* place data into test skb */
fp@2685: igb_create_lbtest_frame(skb, size);
fp@2685: skb_put(skb, size);
fp@2685:
fp@2685: /* Calculate the loop count based on the largest descriptor ring
fp@2685: * The idea is to wrap the largest ring a number of times using 64
fp@2685: * send/receive pairs during each loop
fp@2685: */
fp@2685:
fp@2685: if (rx_ring->count <= tx_ring->count)
fp@2685: lc = ((tx_ring->count / 64) * 2) + 1;
fp@2685: else
fp@2685: lc = ((rx_ring->count / 64) * 2) + 1;
fp@2685:
fp@2685: for (j = 0; j <= lc; j++) { /* loop count loop */
fp@2685: /* reset count of good packets */
fp@2685: good_cnt = 0;
fp@2685:
fp@2685: /* place 64 packets on the transmit queue*/
fp@2685: for (i = 0; i < 64; i++) {
fp@2685: skb_get(skb);
fp@2685: tx_ret_val = igb_xmit_frame_ring(skb, tx_ring);
fp@2685: if (tx_ret_val == NETDEV_TX_OK)
fp@2685: good_cnt++;
fp@2685: }
fp@2685:
fp@2685: if (good_cnt != 64) {
fp@2685: ret_val = 12;
fp@2685: break;
fp@2685: }
fp@2685:
fp@2685: /* allow 200 milliseconds for packets to go from Tx to Rx */
fp@2685: msleep(200);
fp@2685:
fp@2685: good_cnt = igb_clean_test_rings(rx_ring, tx_ring, size);
fp@2685: if (good_cnt != 64) {
fp@2685: ret_val = 13;
fp@2685: break;
fp@2685: }
fp@2685: } /* end loop count loop */
fp@2685:
fp@2685: /* free the original skb */
fp@2685: kfree_skb(skb);
fp@2685:
fp@2685: return ret_val;
fp@2685: }
fp@2685:
fp@2685: static int igb_loopback_test(struct igb_adapter *adapter, u64 *data)
fp@2685: {
fp@2685: /* PHY loopback cannot be performed if SoL/IDER
fp@2685: * sessions are active
fp@2685: */
fp@2685: if (igb_check_reset_block(&adapter->hw)) {
fp@2685: dev_err(&adapter->pdev->dev,
fp@2685: "Cannot do PHY loopback test when SoL/IDER is active.\n");
fp@2685: *data = 0;
fp@2685: goto out;
fp@2685: }
fp@2685:
fp@2685: if (adapter->hw.mac.type == e1000_i354) {
fp@2685: dev_info(&adapter->pdev->dev,
fp@2685: "Loopback test not supported on i354.\n");
fp@2685: *data = 0;
fp@2685: goto out;
fp@2685: }
fp@2685: *data = igb_setup_desc_rings(adapter);
fp@2685: if (*data)
fp@2685: goto out;
fp@2685: *data = igb_setup_loopback_test(adapter);
fp@2685: if (*data)
fp@2685: goto err_loopback;
fp@2685: *data = igb_run_loopback_test(adapter);
fp@2685: igb_loopback_cleanup(adapter);
fp@2685:
fp@2685: err_loopback:
fp@2685: igb_free_desc_rings(adapter);
fp@2685: out:
fp@2685: return *data;
fp@2685: }
fp@2685:
fp@2685: static int igb_link_test(struct igb_adapter *adapter, u64 *data)
fp@2685: {
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: *data = 0;
fp@2685: if (hw->phy.media_type == e1000_media_type_internal_serdes) {
fp@2685: int i = 0;
fp@2685:
fp@2685: hw->mac.serdes_has_link = false;
fp@2685:
fp@2685: /* On some blade server designs, link establishment
fp@2685: * could take as long as 2-3 minutes
fp@2685: */
fp@2685: do {
fp@2685: hw->mac.ops.check_for_link(&adapter->hw);
fp@2685: if (hw->mac.serdes_has_link)
fp@2685: return *data;
fp@2685: msleep(20);
fp@2685: } while (i++ < 3750);
fp@2685:
fp@2685: *data = 1;
fp@2685: } else {
fp@2685: hw->mac.ops.check_for_link(&adapter->hw);
fp@2685: if (hw->mac.autoneg)
fp@2685: msleep(5000);
fp@2685:
fp@2685: if (!(rd32(E1000_STATUS) & E1000_STATUS_LU))
fp@2685: *data = 1;
fp@2685: }
fp@2685: return *data;
fp@2685: }
fp@2685:
fp@2685: static void igb_diag_test(struct net_device *netdev,
fp@2685: struct ethtool_test *eth_test, u64 *data)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: u16 autoneg_advertised;
fp@2685: u8 forced_speed_duplex, autoneg;
fp@2685: bool if_running = netif_running(netdev);
fp@2685:
fp@2685: set_bit(__IGB_TESTING, &adapter->state);
fp@2685:
fp@2685: /* can't do offline tests on media switching devices */
fp@2685: if (adapter->hw.dev_spec._82575.mas_capable)
fp@2685: eth_test->flags &= ~ETH_TEST_FL_OFFLINE;
fp@2685: if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
fp@2685: /* Offline tests */
fp@2685:
fp@2685: /* save speed, duplex, autoneg settings */
fp@2685: autoneg_advertised = adapter->hw.phy.autoneg_advertised;
fp@2685: forced_speed_duplex = adapter->hw.mac.forced_speed_duplex;
fp@2685: autoneg = adapter->hw.mac.autoneg;
fp@2685:
fp@2685: dev_info(&adapter->pdev->dev, "offline testing starting\n");
fp@2685:
fp@2685: /* power up link for link test */
fp@2685: igb_power_up_link(adapter);
fp@2685:
fp@2685: /* Link test performed before hardware reset so autoneg doesn't
fp@2685: * interfere with test result
fp@2685: */
fp@2685: if (igb_link_test(adapter, &data[4]))
fp@2685: eth_test->flags |= ETH_TEST_FL_FAILED;
fp@2685:
fp@2685: if (if_running)
fp@2685: /* indicate we're in test mode */
fp@2685: dev_close(netdev);
fp@2685: else
fp@2685: igb_reset(adapter);
fp@2685:
fp@2685: if (igb_reg_test(adapter, &data[0]))
fp@2685: eth_test->flags |= ETH_TEST_FL_FAILED;
fp@2685:
fp@2685: igb_reset(adapter);
fp@2685: if (igb_eeprom_test(adapter, &data[1]))
fp@2685: eth_test->flags |= ETH_TEST_FL_FAILED;
fp@2685:
fp@2685: igb_reset(adapter);
fp@2685: if (igb_intr_test(adapter, &data[2]))
fp@2685: eth_test->flags |= ETH_TEST_FL_FAILED;
fp@2685:
fp@2685: igb_reset(adapter);
fp@2685: /* power up link for loopback test */
fp@2685: igb_power_up_link(adapter);
fp@2685: if (igb_loopback_test(adapter, &data[3]))
fp@2685: eth_test->flags |= ETH_TEST_FL_FAILED;
fp@2685:
fp@2685: /* restore speed, duplex, autoneg settings */
fp@2685: adapter->hw.phy.autoneg_advertised = autoneg_advertised;
fp@2685: adapter->hw.mac.forced_speed_duplex = forced_speed_duplex;
fp@2685: adapter->hw.mac.autoneg = autoneg;
fp@2685:
fp@2685: /* force this routine to wait until autoneg complete/timeout */
fp@2685: adapter->hw.phy.autoneg_wait_to_complete = true;
fp@2685: igb_reset(adapter);
fp@2685: adapter->hw.phy.autoneg_wait_to_complete = false;
fp@2685:
fp@2685: clear_bit(__IGB_TESTING, &adapter->state);
fp@2685: if (if_running)
fp@2685: dev_open(netdev);
fp@2685: } else {
fp@2685: dev_info(&adapter->pdev->dev, "online testing starting\n");
fp@2685:
fp@2685: /* PHY is powered down when interface is down */
fp@2685: if (if_running && igb_link_test(adapter, &data[4]))
fp@2685: eth_test->flags |= ETH_TEST_FL_FAILED;
fp@2685: else
fp@2685: data[4] = 0;
fp@2685:
fp@2685: /* Online tests aren't run; pass by default */
fp@2685: data[0] = 0;
fp@2685: data[1] = 0;
fp@2685: data[2] = 0;
fp@2685: data[3] = 0;
fp@2685:
fp@2685: clear_bit(__IGB_TESTING, &adapter->state);
fp@2685: }
fp@2685: msleep_interruptible(4 * 1000);
fp@2685: }
fp@2685:
fp@2685: static void igb_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685:
fp@2685: wol->wolopts = 0;
fp@2685:
fp@2685: if (!(adapter->flags & IGB_FLAG_WOL_SUPPORTED))
fp@2685: return;
fp@2685:
fp@2685: wol->supported = WAKE_UCAST | WAKE_MCAST |
fp@2685: WAKE_BCAST | WAKE_MAGIC |
fp@2685: WAKE_PHY;
fp@2685:
fp@2685: /* apply any specific unsupported masks here */
fp@2685: switch (adapter->hw.device_id) {
fp@2685: default:
fp@2685: break;
fp@2685: }
fp@2685:
fp@2685: if (adapter->wol & E1000_WUFC_EX)
fp@2685: wol->wolopts |= WAKE_UCAST;
fp@2685: if (adapter->wol & E1000_WUFC_MC)
fp@2685: wol->wolopts |= WAKE_MCAST;
fp@2685: if (adapter->wol & E1000_WUFC_BC)
fp@2685: wol->wolopts |= WAKE_BCAST;
fp@2685: if (adapter->wol & E1000_WUFC_MAG)
fp@2685: wol->wolopts |= WAKE_MAGIC;
fp@2685: if (adapter->wol & E1000_WUFC_LNKC)
fp@2685: wol->wolopts |= WAKE_PHY;
fp@2685: }
fp@2685:
fp@2685: static int igb_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685:
fp@2685: if (wol->wolopts & (WAKE_ARP | WAKE_MAGICSECURE))
fp@2685: return -EOPNOTSUPP;
fp@2685:
fp@2685: if (!(adapter->flags & IGB_FLAG_WOL_SUPPORTED))
fp@2685: return wol->wolopts ? -EOPNOTSUPP : 0;
fp@2685:
fp@2685: /* these settings will always override what we currently have */
fp@2685: adapter->wol = 0;
fp@2685:
fp@2685: if (wol->wolopts & WAKE_UCAST)
fp@2685: adapter->wol |= E1000_WUFC_EX;
fp@2685: if (wol->wolopts & WAKE_MCAST)
fp@2685: adapter->wol |= E1000_WUFC_MC;
fp@2685: if (wol->wolopts & WAKE_BCAST)
fp@2685: adapter->wol |= E1000_WUFC_BC;
fp@2685: if (wol->wolopts & WAKE_MAGIC)
fp@2685: adapter->wol |= E1000_WUFC_MAG;
fp@2685: if (wol->wolopts & WAKE_PHY)
fp@2685: adapter->wol |= E1000_WUFC_LNKC;
fp@2685: device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: /* bit defines for adapter->led_status */
fp@2685: #define IGB_LED_ON 0
fp@2685:
fp@2685: static int igb_set_phys_id(struct net_device *netdev,
fp@2685: enum ethtool_phys_id_state state)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685:
fp@2685: switch (state) {
fp@2685: case ETHTOOL_ID_ACTIVE:
fp@2685: igb_blink_led(hw);
fp@2685: return 2;
fp@2685: case ETHTOOL_ID_ON:
fp@2685: igb_blink_led(hw);
fp@2685: break;
fp@2685: case ETHTOOL_ID_OFF:
fp@2685: igb_led_off(hw);
fp@2685: break;
fp@2685: case ETHTOOL_ID_INACTIVE:
fp@2685: igb_led_off(hw);
fp@2685: clear_bit(IGB_LED_ON, &adapter->led_status);
fp@2685: igb_cleanup_led(hw);
fp@2685: break;
fp@2685: }
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static int igb_set_coalesce(struct net_device *netdev,
fp@2685: struct ethtool_coalesce *ec)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: int i;
fp@2685:
fp@2685: if ((ec->rx_coalesce_usecs > IGB_MAX_ITR_USECS) ||
fp@2685: ((ec->rx_coalesce_usecs > 3) &&
fp@2685: (ec->rx_coalesce_usecs < IGB_MIN_ITR_USECS)) ||
fp@2685: (ec->rx_coalesce_usecs == 2))
fp@2685: return -EINVAL;
fp@2685:
fp@2685: if ((ec->tx_coalesce_usecs > IGB_MAX_ITR_USECS) ||
fp@2685: ((ec->tx_coalesce_usecs > 3) &&
fp@2685: (ec->tx_coalesce_usecs < IGB_MIN_ITR_USECS)) ||
fp@2685: (ec->tx_coalesce_usecs == 2))
fp@2685: return -EINVAL;
fp@2685:
fp@2685: if ((adapter->flags & IGB_FLAG_QUEUE_PAIRS) && ec->tx_coalesce_usecs)
fp@2685: return -EINVAL;
fp@2685:
fp@2685: /* If ITR is disabled, disable DMAC */
fp@2685: if (ec->rx_coalesce_usecs == 0) {
fp@2685: if (adapter->flags & IGB_FLAG_DMAC)
fp@2685: adapter->flags &= ~IGB_FLAG_DMAC;
fp@2685: }
fp@2685:
fp@2685: /* convert to rate of irq's per second */
fp@2685: if (ec->rx_coalesce_usecs && ec->rx_coalesce_usecs <= 3)
fp@2685: adapter->rx_itr_setting = ec->rx_coalesce_usecs;
fp@2685: else
fp@2685: adapter->rx_itr_setting = ec->rx_coalesce_usecs << 2;
fp@2685:
fp@2685: /* convert to rate of irq's per second */
fp@2685: if (adapter->flags & IGB_FLAG_QUEUE_PAIRS)
fp@2685: adapter->tx_itr_setting = adapter->rx_itr_setting;
fp@2685: else if (ec->tx_coalesce_usecs && ec->tx_coalesce_usecs <= 3)
fp@2685: adapter->tx_itr_setting = ec->tx_coalesce_usecs;
fp@2685: else
fp@2685: adapter->tx_itr_setting = ec->tx_coalesce_usecs << 2;
fp@2685:
fp@2685: for (i = 0; i < adapter->num_q_vectors; i++) {
fp@2685: struct igb_q_vector *q_vector = adapter->q_vector[i];
fp@2685: q_vector->tx.work_limit = adapter->tx_work_limit;
fp@2685: if (q_vector->rx.ring)
fp@2685: q_vector->itr_val = adapter->rx_itr_setting;
fp@2685: else
fp@2685: q_vector->itr_val = adapter->tx_itr_setting;
fp@2685: if (q_vector->itr_val && q_vector->itr_val <= 3)
fp@2685: q_vector->itr_val = IGB_START_ITR;
fp@2685: q_vector->set_itr = 1;
fp@2685: }
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static int igb_get_coalesce(struct net_device *netdev,
fp@2685: struct ethtool_coalesce *ec)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685:
fp@2685: if (adapter->rx_itr_setting <= 3)
fp@2685: ec->rx_coalesce_usecs = adapter->rx_itr_setting;
fp@2685: else
fp@2685: ec->rx_coalesce_usecs = adapter->rx_itr_setting >> 2;
fp@2685:
fp@2685: if (!(adapter->flags & IGB_FLAG_QUEUE_PAIRS)) {
fp@2685: if (adapter->tx_itr_setting <= 3)
fp@2685: ec->tx_coalesce_usecs = adapter->tx_itr_setting;
fp@2685: else
fp@2685: ec->tx_coalesce_usecs = adapter->tx_itr_setting >> 2;
fp@2685: }
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static int igb_nway_reset(struct net_device *netdev)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: if (netif_running(netdev))
fp@2685: igb_reinit_locked(adapter);
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static int igb_get_sset_count(struct net_device *netdev, int sset)
fp@2685: {
fp@2685: switch (sset) {
fp@2685: case ETH_SS_STATS:
fp@2685: return IGB_STATS_LEN;
fp@2685: case ETH_SS_TEST:
fp@2685: return IGB_TEST_LEN;
fp@2685: default:
fp@2685: return -ENOTSUPP;
fp@2685: }
fp@2685: }
fp@2685:
fp@2685: static void igb_get_ethtool_stats(struct net_device *netdev,
fp@2685: struct ethtool_stats *stats, u64 *data)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct rtnl_link_stats64 *net_stats = &adapter->stats64;
fp@2685: unsigned int start;
fp@2685: struct igb_ring *ring;
fp@2685: int i, j;
fp@2685: char *p;
fp@2685:
fp@2685: spin_lock(&adapter->stats64_lock);
fp@2685: igb_update_stats(adapter, net_stats);
fp@2685:
fp@2685: for (i = 0; i < IGB_GLOBAL_STATS_LEN; i++) {
fp@2685: p = (char *)adapter + igb_gstrings_stats[i].stat_offset;
fp@2685: data[i] = (igb_gstrings_stats[i].sizeof_stat ==
fp@2685: sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
fp@2685: }
fp@2685: for (j = 0; j < IGB_NETDEV_STATS_LEN; j++, i++) {
fp@2685: p = (char *)net_stats + igb_gstrings_net_stats[j].stat_offset;
fp@2685: data[i] = (igb_gstrings_net_stats[j].sizeof_stat ==
fp@2685: sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
fp@2685: }
fp@2685: for (j = 0; j < adapter->num_tx_queues; j++) {
fp@2685: u64 restart2;
fp@2685:
fp@2685: ring = adapter->tx_ring[j];
fp@2685: do {
fp@2685: start = u64_stats_fetch_begin_irq(&ring->tx_syncp);
fp@2685: data[i] = ring->tx_stats.packets;
fp@2685: data[i+1] = ring->tx_stats.bytes;
fp@2685: data[i+2] = ring->tx_stats.restart_queue;
fp@2685: } while (u64_stats_fetch_retry_irq(&ring->tx_syncp, start));
fp@2685: do {
fp@2685: start = u64_stats_fetch_begin_irq(&ring->tx_syncp2);
fp@2685: restart2 = ring->tx_stats.restart_queue2;
fp@2685: } while (u64_stats_fetch_retry_irq(&ring->tx_syncp2, start));
fp@2685: data[i+2] += restart2;
fp@2685:
fp@2685: i += IGB_TX_QUEUE_STATS_LEN;
fp@2685: }
fp@2685: for (j = 0; j < adapter->num_rx_queues; j++) {
fp@2685: ring = adapter->rx_ring[j];
fp@2685: do {
fp@2685: start = u64_stats_fetch_begin_irq(&ring->rx_syncp);
fp@2685: data[i] = ring->rx_stats.packets;
fp@2685: data[i+1] = ring->rx_stats.bytes;
fp@2685: data[i+2] = ring->rx_stats.drops;
fp@2685: data[i+3] = ring->rx_stats.csum_err;
fp@2685: data[i+4] = ring->rx_stats.alloc_failed;
fp@2685: } while (u64_stats_fetch_retry_irq(&ring->rx_syncp, start));
fp@2685: i += IGB_RX_QUEUE_STATS_LEN;
fp@2685: }
fp@2685: spin_unlock(&adapter->stats64_lock);
fp@2685: }
fp@2685:
fp@2685: static void igb_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: u8 *p = data;
fp@2685: int i;
fp@2685:
fp@2685: switch (stringset) {
fp@2685: case ETH_SS_TEST:
fp@2685: memcpy(data, *igb_gstrings_test,
fp@2685: IGB_TEST_LEN*ETH_GSTRING_LEN);
fp@2685: break;
fp@2685: case ETH_SS_STATS:
fp@2685: for (i = 0; i < IGB_GLOBAL_STATS_LEN; i++) {
fp@2685: memcpy(p, igb_gstrings_stats[i].stat_string,
fp@2685: ETH_GSTRING_LEN);
fp@2685: p += ETH_GSTRING_LEN;
fp@2685: }
fp@2685: for (i = 0; i < IGB_NETDEV_STATS_LEN; i++) {
fp@2685: memcpy(p, igb_gstrings_net_stats[i].stat_string,
fp@2685: ETH_GSTRING_LEN);
fp@2685: p += ETH_GSTRING_LEN;
fp@2685: }
fp@2685: for (i = 0; i < adapter->num_tx_queues; i++) {
fp@2685: sprintf(p, "tx_queue_%u_packets", i);
fp@2685: p += ETH_GSTRING_LEN;
fp@2685: sprintf(p, "tx_queue_%u_bytes", i);
fp@2685: p += ETH_GSTRING_LEN;
fp@2685: sprintf(p, "tx_queue_%u_restart", i);
fp@2685: p += ETH_GSTRING_LEN;
fp@2685: }
fp@2685: for (i = 0; i < adapter->num_rx_queues; i++) {
fp@2685: sprintf(p, "rx_queue_%u_packets", i);
fp@2685: p += ETH_GSTRING_LEN;
fp@2685: sprintf(p, "rx_queue_%u_bytes", i);
fp@2685: p += ETH_GSTRING_LEN;
fp@2685: sprintf(p, "rx_queue_%u_drops", i);
fp@2685: p += ETH_GSTRING_LEN;
fp@2685: sprintf(p, "rx_queue_%u_csum_err", i);
fp@2685: p += ETH_GSTRING_LEN;
fp@2685: sprintf(p, "rx_queue_%u_alloc_failed", i);
fp@2685: p += ETH_GSTRING_LEN;
fp@2685: }
fp@2685: /* BUG_ON(p - data != IGB_STATS_LEN * ETH_GSTRING_LEN); */
fp@2685: break;
fp@2685: }
fp@2685: }
fp@2685:
fp@2685: static int igb_get_ts_info(struct net_device *dev,
fp@2685: struct ethtool_ts_info *info)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(dev);
fp@2685:
fp@2685: if (adapter->ptp_clock)
fp@2685: info->phc_index = ptp_clock_index(adapter->ptp_clock);
fp@2685: else
fp@2685: info->phc_index = -1;
fp@2685:
fp@2685: switch (adapter->hw.mac.type) {
fp@2685: case e1000_82575:
fp@2685: info->so_timestamping =
fp@2685: SOF_TIMESTAMPING_TX_SOFTWARE |
fp@2685: SOF_TIMESTAMPING_RX_SOFTWARE |
fp@2685: SOF_TIMESTAMPING_SOFTWARE;
fp@2685: return 0;
fp@2685: case e1000_82576:
fp@2685: case e1000_82580:
fp@2685: case e1000_i350:
fp@2685: case e1000_i354:
fp@2685: case e1000_i210:
fp@2685: case e1000_i211:
fp@2685: info->so_timestamping =
fp@2685: SOF_TIMESTAMPING_TX_SOFTWARE |
fp@2685: SOF_TIMESTAMPING_RX_SOFTWARE |
fp@2685: SOF_TIMESTAMPING_SOFTWARE |
fp@2685: SOF_TIMESTAMPING_TX_HARDWARE |
fp@2685: SOF_TIMESTAMPING_RX_HARDWARE |
fp@2685: SOF_TIMESTAMPING_RAW_HARDWARE;
fp@2685:
fp@2685: info->tx_types =
fp@2685: (1 << HWTSTAMP_TX_OFF) |
fp@2685: (1 << HWTSTAMP_TX_ON);
fp@2685:
fp@2685: info->rx_filters = 1 << HWTSTAMP_FILTER_NONE;
fp@2685:
fp@2685: /* 82576 does not support timestamping all packets. */
fp@2685: if (adapter->hw.mac.type >= e1000_82580)
fp@2685: info->rx_filters |= 1 << HWTSTAMP_FILTER_ALL;
fp@2685: else
fp@2685: info->rx_filters |=
fp@2685: (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |
fp@2685: (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) |
fp@2685: (1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) |
fp@2685: (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) |
fp@2685: (1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) |
fp@2685: (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) |
fp@2685: (1 << HWTSTAMP_FILTER_PTP_V2_EVENT);
fp@2685:
fp@2685: return 0;
fp@2685: default:
fp@2685: return -EOPNOTSUPP;
fp@2685: }
fp@2685: }
fp@2685:
fp@2685: static int igb_get_rss_hash_opts(struct igb_adapter *adapter,
fp@2685: struct ethtool_rxnfc *cmd)
fp@2685: {
fp@2685: cmd->data = 0;
fp@2685:
fp@2685: /* Report default options for RSS on igb */
fp@2685: switch (cmd->flow_type) {
fp@2685: case TCP_V4_FLOW:
fp@2685: cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
fp@2685: /* Fall through */
fp@2685: case UDP_V4_FLOW:
fp@2685: if (adapter->flags & IGB_FLAG_RSS_FIELD_IPV4_UDP)
fp@2685: cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
fp@2685: /* Fall through */
fp@2685: case SCTP_V4_FLOW:
fp@2685: case AH_ESP_V4_FLOW:
fp@2685: case AH_V4_FLOW:
fp@2685: case ESP_V4_FLOW:
fp@2685: case IPV4_FLOW:
fp@2685: cmd->data |= RXH_IP_SRC | RXH_IP_DST;
fp@2685: break;
fp@2685: case TCP_V6_FLOW:
fp@2685: cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
fp@2685: /* Fall through */
fp@2685: case UDP_V6_FLOW:
fp@2685: if (adapter->flags & IGB_FLAG_RSS_FIELD_IPV6_UDP)
fp@2685: cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
fp@2685: /* Fall through */
fp@2685: case SCTP_V6_FLOW:
fp@2685: case AH_ESP_V6_FLOW:
fp@2685: case AH_V6_FLOW:
fp@2685: case ESP_V6_FLOW:
fp@2685: case IPV6_FLOW:
fp@2685: cmd->data |= RXH_IP_SRC | RXH_IP_DST;
fp@2685: break;
fp@2685: default:
fp@2685: return -EINVAL;
fp@2685: }
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static int igb_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
fp@2685: u32 *rule_locs)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(dev);
fp@2685: int ret = -EOPNOTSUPP;
fp@2685:
fp@2685: switch (cmd->cmd) {
fp@2685: case ETHTOOL_GRXRINGS:
fp@2685: cmd->data = adapter->num_rx_queues;
fp@2685: ret = 0;
fp@2685: break;
fp@2685: case ETHTOOL_GRXFH:
fp@2685: ret = igb_get_rss_hash_opts(adapter, cmd);
fp@2685: break;
fp@2685: default:
fp@2685: break;
fp@2685: }
fp@2685:
fp@2685: return ret;
fp@2685: }
fp@2685:
fp@2685: #define UDP_RSS_FLAGS (IGB_FLAG_RSS_FIELD_IPV4_UDP | \
fp@2685: IGB_FLAG_RSS_FIELD_IPV6_UDP)
fp@2685: static int igb_set_rss_hash_opt(struct igb_adapter *adapter,
fp@2685: struct ethtool_rxnfc *nfc)
fp@2685: {
fp@2685: u32 flags = adapter->flags;
fp@2685:
fp@2685: /* RSS does not support anything other than hashing
fp@2685: * to queues on src and dst IPs and ports
fp@2685: */
fp@2685: if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST |
fp@2685: RXH_L4_B_0_1 | RXH_L4_B_2_3))
fp@2685: return -EINVAL;
fp@2685:
fp@2685: switch (nfc->flow_type) {
fp@2685: case TCP_V4_FLOW:
fp@2685: case TCP_V6_FLOW:
fp@2685: if (!(nfc->data & RXH_IP_SRC) ||
fp@2685: !(nfc->data & RXH_IP_DST) ||
fp@2685: !(nfc->data & RXH_L4_B_0_1) ||
fp@2685: !(nfc->data & RXH_L4_B_2_3))
fp@2685: return -EINVAL;
fp@2685: break;
fp@2685: case UDP_V4_FLOW:
fp@2685: if (!(nfc->data & RXH_IP_SRC) ||
fp@2685: !(nfc->data & RXH_IP_DST))
fp@2685: return -EINVAL;
fp@2685: switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
fp@2685: case 0:
fp@2685: flags &= ~IGB_FLAG_RSS_FIELD_IPV4_UDP;
fp@2685: break;
fp@2685: case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
fp@2685: flags |= IGB_FLAG_RSS_FIELD_IPV4_UDP;
fp@2685: break;
fp@2685: default:
fp@2685: return -EINVAL;
fp@2685: }
fp@2685: break;
fp@2685: case UDP_V6_FLOW:
fp@2685: if (!(nfc->data & RXH_IP_SRC) ||
fp@2685: !(nfc->data & RXH_IP_DST))
fp@2685: return -EINVAL;
fp@2685: switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) {
fp@2685: case 0:
fp@2685: flags &= ~IGB_FLAG_RSS_FIELD_IPV6_UDP;
fp@2685: break;
fp@2685: case (RXH_L4_B_0_1 | RXH_L4_B_2_3):
fp@2685: flags |= IGB_FLAG_RSS_FIELD_IPV6_UDP;
fp@2685: break;
fp@2685: default:
fp@2685: return -EINVAL;
fp@2685: }
fp@2685: break;
fp@2685: case AH_ESP_V4_FLOW:
fp@2685: case AH_V4_FLOW:
fp@2685: case ESP_V4_FLOW:
fp@2685: case SCTP_V4_FLOW:
fp@2685: case AH_ESP_V6_FLOW:
fp@2685: case AH_V6_FLOW:
fp@2685: case ESP_V6_FLOW:
fp@2685: case SCTP_V6_FLOW:
fp@2685: if (!(nfc->data & RXH_IP_SRC) ||
fp@2685: !(nfc->data & RXH_IP_DST) ||
fp@2685: (nfc->data & RXH_L4_B_0_1) ||
fp@2685: (nfc->data & RXH_L4_B_2_3))
fp@2685: return -EINVAL;
fp@2685: break;
fp@2685: default:
fp@2685: return -EINVAL;
fp@2685: }
fp@2685:
fp@2685: /* if we changed something we need to update flags */
fp@2685: if (flags != adapter->flags) {
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: u32 mrqc = rd32(E1000_MRQC);
fp@2685:
fp@2685: if ((flags & UDP_RSS_FLAGS) &&
fp@2685: !(adapter->flags & UDP_RSS_FLAGS))
fp@2685: dev_err(&adapter->pdev->dev,
fp@2685: "enabling UDP RSS: fragmented packets may arrive out of order to the stack above\n");
fp@2685:
fp@2685: adapter->flags = flags;
fp@2685:
fp@2685: /* Perform hash on these packet types */
fp@2685: mrqc |= E1000_MRQC_RSS_FIELD_IPV4 |
fp@2685: E1000_MRQC_RSS_FIELD_IPV4_TCP |
fp@2685: E1000_MRQC_RSS_FIELD_IPV6 |
fp@2685: E1000_MRQC_RSS_FIELD_IPV6_TCP;
fp@2685:
fp@2685: mrqc &= ~(E1000_MRQC_RSS_FIELD_IPV4_UDP |
fp@2685: E1000_MRQC_RSS_FIELD_IPV6_UDP);
fp@2685:
fp@2685: if (flags & IGB_FLAG_RSS_FIELD_IPV4_UDP)
fp@2685: mrqc |= E1000_MRQC_RSS_FIELD_IPV4_UDP;
fp@2685:
fp@2685: if (flags & IGB_FLAG_RSS_FIELD_IPV6_UDP)
fp@2685: mrqc |= E1000_MRQC_RSS_FIELD_IPV6_UDP;
fp@2685:
fp@2685: wr32(E1000_MRQC, mrqc);
fp@2685: }
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static int igb_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(dev);
fp@2685: int ret = -EOPNOTSUPP;
fp@2685:
fp@2685: switch (cmd->cmd) {
fp@2685: case ETHTOOL_SRXFH:
fp@2685: ret = igb_set_rss_hash_opt(adapter, cmd);
fp@2685: break;
fp@2685: default:
fp@2685: break;
fp@2685: }
fp@2685:
fp@2685: return ret;
fp@2685: }
fp@2685:
fp@2685: static int igb_get_eee(struct net_device *netdev, struct ethtool_eee *edata)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: u32 ret_val;
fp@2685: u16 phy_data;
fp@2685:
fp@2685: if ((hw->mac.type < e1000_i350) ||
fp@2685: (hw->phy.media_type != e1000_media_type_copper))
fp@2685: return -EOPNOTSUPP;
fp@2685:
fp@2685: edata->supported = (SUPPORTED_1000baseT_Full |
fp@2685: SUPPORTED_100baseT_Full);
fp@2685: if (!hw->dev_spec._82575.eee_disable)
fp@2685: edata->advertised =
fp@2685: mmd_eee_adv_to_ethtool_adv_t(adapter->eee_advert);
fp@2685:
fp@2685: /* The IPCNFG and EEER registers are not supported on I354. */
fp@2685: if (hw->mac.type == e1000_i354) {
fp@2685: igb_get_eee_status_i354(hw, (bool *)&edata->eee_active);
fp@2685: } else {
fp@2685: u32 eeer;
fp@2685:
fp@2685: eeer = rd32(E1000_EEER);
fp@2685:
fp@2685: /* EEE status on negotiated link */
fp@2685: if (eeer & E1000_EEER_EEE_NEG)
fp@2685: edata->eee_active = true;
fp@2685:
fp@2685: if (eeer & E1000_EEER_TX_LPI_EN)
fp@2685: edata->tx_lpi_enabled = true;
fp@2685: }
fp@2685:
fp@2685: /* EEE Link Partner Advertised */
fp@2685: switch (hw->mac.type) {
fp@2685: case e1000_i350:
fp@2685: ret_val = igb_read_emi_reg(hw, E1000_EEE_LP_ADV_ADDR_I350,
fp@2685: &phy_data);
fp@2685: if (ret_val)
fp@2685: return -ENODATA;
fp@2685:
fp@2685: edata->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(phy_data);
fp@2685: break;
fp@2685: case e1000_i354:
fp@2685: case e1000_i210:
fp@2685: case e1000_i211:
fp@2685: ret_val = igb_read_xmdio_reg(hw, E1000_EEE_LP_ADV_ADDR_I210,
fp@2685: E1000_EEE_LP_ADV_DEV_I210,
fp@2685: &phy_data);
fp@2685: if (ret_val)
fp@2685: return -ENODATA;
fp@2685:
fp@2685: edata->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(phy_data);
fp@2685:
fp@2685: break;
fp@2685: default:
fp@2685: break;
fp@2685: }
fp@2685:
fp@2685: edata->eee_enabled = !hw->dev_spec._82575.eee_disable;
fp@2685:
fp@2685: if ((hw->mac.type == e1000_i354) &&
fp@2685: (edata->eee_enabled))
fp@2685: edata->tx_lpi_enabled = true;
fp@2685:
fp@2685: /* Report correct negotiated EEE status for devices that
fp@2685: * wrongly report EEE at half-duplex
fp@2685: */
fp@2685: if (adapter->link_duplex == HALF_DUPLEX) {
fp@2685: edata->eee_enabled = false;
fp@2685: edata->eee_active = false;
fp@2685: edata->tx_lpi_enabled = false;
fp@2685: edata->advertised &= ~edata->advertised;
fp@2685: }
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static int igb_set_eee(struct net_device *netdev,
fp@2685: struct ethtool_eee *edata)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: struct ethtool_eee eee_curr;
fp@2685: bool adv1g_eee = true, adv100m_eee = true;
fp@2685: s32 ret_val;
fp@2685:
fp@2685: if ((hw->mac.type < e1000_i350) ||
fp@2685: (hw->phy.media_type != e1000_media_type_copper))
fp@2685: return -EOPNOTSUPP;
fp@2685:
fp@2685: memset(&eee_curr, 0, sizeof(struct ethtool_eee));
fp@2685:
fp@2685: ret_val = igb_get_eee(netdev, &eee_curr);
fp@2685: if (ret_val)
fp@2685: return ret_val;
fp@2685:
fp@2685: if (eee_curr.eee_enabled) {
fp@2685: if (eee_curr.tx_lpi_enabled != edata->tx_lpi_enabled) {
fp@2685: dev_err(&adapter->pdev->dev,
fp@2685: "Setting EEE tx-lpi is not supported\n");
fp@2685: return -EINVAL;
fp@2685: }
fp@2685:
fp@2685: /* Tx LPI timer is not implemented currently */
fp@2685: if (edata->tx_lpi_timer) {
fp@2685: dev_err(&adapter->pdev->dev,
fp@2685: "Setting EEE Tx LPI timer is not supported\n");
fp@2685: return -EINVAL;
fp@2685: }
fp@2685:
fp@2685: if (!edata->advertised || (edata->advertised &
fp@2685: ~(ADVERTISE_100_FULL | ADVERTISE_1000_FULL))) {
fp@2685: dev_err(&adapter->pdev->dev,
fp@2685: "EEE Advertisement supports only 100Tx and/or 100T full duplex\n");
fp@2685: return -EINVAL;
fp@2685: }
fp@2685: adv100m_eee = !!(edata->advertised & ADVERTISE_100_FULL);
fp@2685: adv1g_eee = !!(edata->advertised & ADVERTISE_1000_FULL);
fp@2685:
fp@2685: } else if (!edata->eee_enabled) {
fp@2685: dev_err(&adapter->pdev->dev,
fp@2685: "Setting EEE options are not supported with EEE disabled\n");
fp@2685: return -EINVAL;
fp@2685: }
fp@2685:
fp@2685: adapter->eee_advert = ethtool_adv_to_mmd_eee_adv_t(edata->advertised);
fp@2685: if (hw->dev_spec._82575.eee_disable != !edata->eee_enabled) {
fp@2685: hw->dev_spec._82575.eee_disable = !edata->eee_enabled;
fp@2685: adapter->flags |= IGB_FLAG_EEE;
fp@2685:
fp@2685: /* reset link */
fp@2685: if (netif_running(netdev))
fp@2685: igb_reinit_locked(adapter);
fp@2685: else
fp@2685: igb_reset(adapter);
fp@2685: }
fp@2685:
fp@2685: if (hw->mac.type == e1000_i354)
fp@2685: ret_val = igb_set_eee_i354(hw, adv1g_eee, adv100m_eee);
fp@2685: else
fp@2685: ret_val = igb_set_eee_i350(hw, adv1g_eee, adv100m_eee);
fp@2685:
fp@2685: if (ret_val) {
fp@2685: dev_err(&adapter->pdev->dev,
fp@2685: "Problem setting EEE advertisement options\n");
fp@2685: return -EINVAL;
fp@2685: }
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static int igb_get_module_info(struct net_device *netdev,
fp@2685: struct ethtool_modinfo *modinfo)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: u32 status = 0;
fp@2685: u16 sff8472_rev, addr_mode;
fp@2685: bool page_swap = false;
fp@2685:
fp@2685: if ((hw->phy.media_type == e1000_media_type_copper) ||
fp@2685: (hw->phy.media_type == e1000_media_type_unknown))
fp@2685: return -EOPNOTSUPP;
fp@2685:
fp@2685: /* Check whether we support SFF-8472 or not */
fp@2685: status = igb_read_phy_reg_i2c(hw, IGB_SFF_8472_COMP, &sff8472_rev);
fp@2685: if (status)
fp@2685: return -EIO;
fp@2685:
fp@2685: /* addressing mode is not supported */
fp@2685: status = igb_read_phy_reg_i2c(hw, IGB_SFF_8472_SWAP, &addr_mode);
fp@2685: if (status)
fp@2685: return -EIO;
fp@2685:
fp@2685: /* addressing mode is not supported */
fp@2685: if ((addr_mode & 0xFF) & IGB_SFF_ADDRESSING_MODE) {
fp@2685: hw_dbg("Address change required to access page 0xA2, but not supported. Please report the module type to the driver maintainers.\n");
fp@2685: page_swap = true;
fp@2685: }
fp@2685:
fp@2685: if ((sff8472_rev & 0xFF) == IGB_SFF_8472_UNSUP || page_swap) {
fp@2685: /* We have an SFP, but it does not support SFF-8472 */
fp@2685: modinfo->type = ETH_MODULE_SFF_8079;
fp@2685: modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN;
fp@2685: } else {
fp@2685: /* We have an SFP which supports a revision of SFF-8472 */
fp@2685: modinfo->type = ETH_MODULE_SFF_8472;
fp@2685: modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
fp@2685: }
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static int igb_get_module_eeprom(struct net_device *netdev,
fp@2685: struct ethtool_eeprom *ee, u8 *data)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: u32 status = 0;
fp@2685: u16 *dataword;
fp@2685: u16 first_word, last_word;
fp@2685: int i = 0;
fp@2685:
fp@2685: if (ee->len == 0)
fp@2685: return -EINVAL;
fp@2685:
fp@2685: first_word = ee->offset >> 1;
fp@2685: last_word = (ee->offset + ee->len - 1) >> 1;
fp@2685:
fp@2685: dataword = kmalloc(sizeof(u16) * (last_word - first_word + 1),
fp@2685: GFP_KERNEL);
fp@2685: if (!dataword)
fp@2685: return -ENOMEM;
fp@2685:
fp@2685: /* Read EEPROM block, SFF-8079/SFF-8472, word at a time */
fp@2685: for (i = 0; i < last_word - first_word + 1; i++) {
fp@2685: status = igb_read_phy_reg_i2c(hw, first_word + i, &dataword[i]);
fp@2685: if (status) {
fp@2685: /* Error occurred while reading module */
fp@2685: kfree(dataword);
fp@2685: return -EIO;
fp@2685: }
fp@2685:
fp@2685: be16_to_cpus(&dataword[i]);
fp@2685: }
fp@2685:
fp@2685: memcpy(data, (u8 *)dataword + (ee->offset & 1), ee->len);
fp@2685: kfree(dataword);
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static int igb_ethtool_begin(struct net_device *netdev)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: pm_runtime_get_sync(&adapter->pdev->dev);
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static void igb_ethtool_complete(struct net_device *netdev)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: pm_runtime_put(&adapter->pdev->dev);
fp@2685: }
fp@2685:
fp@2685: static u32 igb_get_rxfh_indir_size(struct net_device *netdev)
fp@2685: {
fp@2685: return IGB_RETA_SIZE;
fp@2685: }
fp@2685:
fp@2685: static int igb_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: int i;
fp@2685:
fp@2685: for (i = 0; i < IGB_RETA_SIZE; i++)
fp@2685: indir[i] = adapter->rss_indir_tbl[i];
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: void igb_write_rss_indir_tbl(struct igb_adapter *adapter)
fp@2685: {
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: u32 reg = E1000_RETA(0);
fp@2685: u32 shift = 0;
fp@2685: int i = 0;
fp@2685:
fp@2685: switch (hw->mac.type) {
fp@2685: case e1000_82575:
fp@2685: shift = 6;
fp@2685: break;
fp@2685: case e1000_82576:
fp@2685: /* 82576 supports 2 RSS queues for SR-IOV */
fp@2685: if (adapter->vfs_allocated_count)
fp@2685: shift = 3;
fp@2685: break;
fp@2685: default:
fp@2685: break;
fp@2685: }
fp@2685:
fp@2685: while (i < IGB_RETA_SIZE) {
fp@2685: u32 val = 0;
fp@2685: int j;
fp@2685:
fp@2685: for (j = 3; j >= 0; j--) {
fp@2685: val <<= 8;
fp@2685: val |= adapter->rss_indir_tbl[i + j];
fp@2685: }
fp@2685:
fp@2685: wr32(reg, val << shift);
fp@2685: reg += 4;
fp@2685: i += 4;
fp@2685: }
fp@2685: }
fp@2685:
fp@2685: static int igb_set_rxfh(struct net_device *netdev, const u32 *indir,
fp@2685: const u8 *key)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: int i;
fp@2685: u32 num_queues;
fp@2685:
fp@2685: num_queues = adapter->rss_queues;
fp@2685:
fp@2685: switch (hw->mac.type) {
fp@2685: case e1000_82576:
fp@2685: /* 82576 supports 2 RSS queues for SR-IOV */
fp@2685: if (adapter->vfs_allocated_count)
fp@2685: num_queues = 2;
fp@2685: break;
fp@2685: default:
fp@2685: break;
fp@2685: }
fp@2685:
fp@2685: /* Verify user input. */
fp@2685: for (i = 0; i < IGB_RETA_SIZE; i++)
fp@2685: if (indir[i] >= num_queues)
fp@2685: return -EINVAL;
fp@2685:
fp@2685:
fp@2685: for (i = 0; i < IGB_RETA_SIZE; i++)
fp@2685: adapter->rss_indir_tbl[i] = indir[i];
fp@2685:
fp@2685: igb_write_rss_indir_tbl(adapter);
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static unsigned int igb_max_channels(struct igb_adapter *adapter)
fp@2685: {
fp@2685: struct e1000_hw *hw = &adapter->hw;
fp@2685: unsigned int max_combined = 0;
fp@2685:
fp@2685: switch (hw->mac.type) {
fp@2685: case e1000_i211:
fp@2685: max_combined = IGB_MAX_RX_QUEUES_I211;
fp@2685: break;
fp@2685: case e1000_82575:
fp@2685: case e1000_i210:
fp@2685: max_combined = IGB_MAX_RX_QUEUES_82575;
fp@2685: break;
fp@2685: case e1000_i350:
fp@2685: if (!!adapter->vfs_allocated_count) {
fp@2685: max_combined = 1;
fp@2685: break;
fp@2685: }
fp@2685: /* fall through */
fp@2685: case e1000_82576:
fp@2685: if (!!adapter->vfs_allocated_count) {
fp@2685: max_combined = 2;
fp@2685: break;
fp@2685: }
fp@2685: /* fall through */
fp@2685: case e1000_82580:
fp@2685: case e1000_i354:
fp@2685: default:
fp@2685: max_combined = IGB_MAX_RX_QUEUES;
fp@2685: break;
fp@2685: }
fp@2685:
fp@2685: return max_combined;
fp@2685: }
fp@2685:
fp@2685: static void igb_get_channels(struct net_device *netdev,
fp@2685: struct ethtool_channels *ch)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685:
fp@2685: /* Report maximum channels */
fp@2685: ch->max_combined = igb_max_channels(adapter);
fp@2685:
fp@2685: /* Report info for other vector */
fp@2685: if (adapter->flags & IGB_FLAG_HAS_MSIX) {
fp@2685: ch->max_other = NON_Q_VECTORS;
fp@2685: ch->other_count = NON_Q_VECTORS;
fp@2685: }
fp@2685:
fp@2685: ch->combined_count = adapter->rss_queues;
fp@2685: }
fp@2685:
fp@2685: static int igb_set_channels(struct net_device *netdev,
fp@2685: struct ethtool_channels *ch)
fp@2685: {
fp@2685: struct igb_adapter *adapter = netdev_priv(netdev);
fp@2685: unsigned int count = ch->combined_count;
fp@2685:
fp@2685: /* Verify they are not requesting separate vectors */
fp@2685: if (!count || ch->rx_count || ch->tx_count)
fp@2685: return -EINVAL;
fp@2685:
fp@2685: /* Verify other_count is valid and has not been changed */
fp@2685: if (ch->other_count != NON_Q_VECTORS)
fp@2685: return -EINVAL;
fp@2685:
fp@2685: /* Verify the number of channels doesn't exceed hw limits */
fp@2685: if (count > igb_max_channels(adapter))
fp@2685: return -EINVAL;
fp@2685:
fp@2685: if (count != adapter->rss_queues) {
fp@2685: adapter->rss_queues = count;
fp@2685:
fp@2685: /* Hardware has to reinitialize queues and interrupts to
fp@2685: * match the new configuration.
fp@2685: */
fp@2685: return igb_reinit_queues(adapter);
fp@2685: }
fp@2685:
fp@2685: return 0;
fp@2685: }
fp@2685:
fp@2685: static const struct ethtool_ops igb_ethtool_ops = {
fp@2685: .get_settings = igb_get_settings,
fp@2685: .set_settings = igb_set_settings,
fp@2685: .get_drvinfo = igb_get_drvinfo,
fp@2685: .get_regs_len = igb_get_regs_len,
fp@2685: .get_regs = igb_get_regs,
fp@2685: .get_wol = igb_get_wol,
fp@2685: .set_wol = igb_set_wol,
fp@2685: .get_msglevel = igb_get_msglevel,
fp@2685: .set_msglevel = igb_set_msglevel,
fp@2685: .nway_reset = igb_nway_reset,
fp@2685: .get_link = igb_get_link,
fp@2685: .get_eeprom_len = igb_get_eeprom_len,
fp@2685: .get_eeprom = igb_get_eeprom,
fp@2685: .set_eeprom = igb_set_eeprom,
fp@2685: .get_ringparam = igb_get_ringparam,
fp@2685: .set_ringparam = igb_set_ringparam,
fp@2685: .get_pauseparam = igb_get_pauseparam,
fp@2685: .set_pauseparam = igb_set_pauseparam,
fp@2685: .self_test = igb_diag_test,
fp@2685: .get_strings = igb_get_strings,
fp@2685: .set_phys_id = igb_set_phys_id,
fp@2685: .get_sset_count = igb_get_sset_count,
fp@2685: .get_ethtool_stats = igb_get_ethtool_stats,
fp@2685: .get_coalesce = igb_get_coalesce,
fp@2685: .set_coalesce = igb_set_coalesce,
fp@2685: .get_ts_info = igb_get_ts_info,
fp@2685: .get_rxnfc = igb_get_rxnfc,
fp@2685: .set_rxnfc = igb_set_rxnfc,
fp@2685: .get_eee = igb_get_eee,
fp@2685: .set_eee = igb_set_eee,
fp@2685: .get_module_info = igb_get_module_info,
fp@2685: .get_module_eeprom = igb_get_module_eeprom,
fp@2685: .get_rxfh_indir_size = igb_get_rxfh_indir_size,
fp@2685: .get_rxfh = igb_get_rxfh,
fp@2685: .set_rxfh = igb_set_rxfh,
fp@2685: .get_channels = igb_get_channels,
fp@2685: .set_channels = igb_set_channels,
fp@2685: .begin = igb_ethtool_begin,
fp@2685: .complete = igb_ethtool_complete,
fp@2685: };
fp@2685:
fp@2685: void igb_set_ethtool_ops(struct net_device *netdev)
fp@2685: {
fp@2685: netdev->ethtool_ops = &igb_ethtool_ops;
fp@2685: }