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