devices/e1000e/ethtool-3.4-ethercat.c
author Florian Pose <fp@igh-essen.com>
Fri, 16 Sep 2016 12:35:09 +0200
branchstable-1.5
changeset 2658 7690a5df7539
parent 2491 5e9221a78855
permissions -rw-r--r--
Use SYNC0 + SYNC1 cycle times for cyclic start time generation.
2491
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*******************************************************************************
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
  Intel PRO/1000 Linux driver
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
  Copyright(c) 1999 - 2012 Intel Corporation.
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
  This program is free software; you can redistribute it and/or modify it
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
  under the terms and conditions of the GNU General Public License,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
  version 2, as published by the Free Software Foundation.
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
  This program is distributed in the hope it will be useful, but WITHOUT
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
  more details.
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
  You should have received a copy of the GNU General Public License along with
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
  this program; if not, write to the Free Software Foundation, Inc.,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
  The full GNU General Public License is included in this distribution in
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
  the file called "COPYING".
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
  Contact Information:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  Linux NICS <linux.nics@intel.com>
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
*******************************************************************************/
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
/* ethtool support for e1000 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#include <linux/netdevice.h>
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
#include <linux/interrupt.h>
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
#include <linux/ethtool.h>
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
#include <linux/pci.h>
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
#include <linux/slab.h>
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
#include <linux/delay.h>
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
#include <linux/vmalloc.h>
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
#include "e1000-3.4-ethercat.h"
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
enum {NETDEV_STATS, E1000_STATS};
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
struct e1000_stats {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
	char stat_string[ETH_GSTRING_LEN];
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
	int type;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
	int sizeof_stat;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
	int stat_offset;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
};
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
#define E1000_STAT(str, m) { \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
		.stat_string = str, \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
		.type = E1000_STATS, \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
		.sizeof_stat = sizeof(((struct e1000_adapter *)0)->m), \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
		.stat_offset = offsetof(struct e1000_adapter, m) }
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
#define E1000_NETDEV_STAT(str, m) { \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
		.stat_string = str, \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
		.type = NETDEV_STATS, \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
		.sizeof_stat = sizeof(((struct rtnl_link_stats64 *)0)->m), \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
		.stat_offset = offsetof(struct rtnl_link_stats64, m) }
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
static const struct e1000_stats e1000_gstrings_stats[] = {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
	E1000_STAT("rx_packets", stats.gprc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
	E1000_STAT("tx_packets", stats.gptc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
	E1000_STAT("rx_bytes", stats.gorc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
	E1000_STAT("tx_bytes", stats.gotc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
	E1000_STAT("rx_broadcast", stats.bprc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
	E1000_STAT("tx_broadcast", stats.bptc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
	E1000_STAT("rx_multicast", stats.mprc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
	E1000_STAT("tx_multicast", stats.mptc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
	E1000_NETDEV_STAT("rx_errors", rx_errors),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
	E1000_NETDEV_STAT("tx_errors", tx_errors),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
	E1000_NETDEV_STAT("tx_dropped", tx_dropped),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
	E1000_STAT("multicast", stats.mprc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
	E1000_STAT("collisions", stats.colc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
	E1000_NETDEV_STAT("rx_length_errors", rx_length_errors),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
	E1000_NETDEV_STAT("rx_over_errors", rx_over_errors),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
	E1000_STAT("rx_crc_errors", stats.crcerrs),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
	E1000_NETDEV_STAT("rx_frame_errors", rx_frame_errors),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
	E1000_STAT("rx_no_buffer_count", stats.rnbc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
	E1000_STAT("rx_missed_errors", stats.mpc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
	E1000_STAT("tx_aborted_errors", stats.ecol),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
	E1000_STAT("tx_carrier_errors", stats.tncrs),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
	E1000_NETDEV_STAT("tx_fifo_errors", tx_fifo_errors),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
	E1000_NETDEV_STAT("tx_heartbeat_errors", tx_heartbeat_errors),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
	E1000_STAT("tx_window_errors", stats.latecol),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
	E1000_STAT("tx_abort_late_coll", stats.latecol),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
	E1000_STAT("tx_deferred_ok", stats.dc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
	E1000_STAT("tx_single_coll_ok", stats.scc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
	E1000_STAT("tx_multi_coll_ok", stats.mcc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
	E1000_STAT("tx_timeout_count", tx_timeout_count),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
	E1000_STAT("tx_restart_queue", restart_queue),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
	E1000_STAT("rx_long_length_errors", stats.roc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
	E1000_STAT("rx_short_length_errors", stats.ruc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
	E1000_STAT("rx_align_errors", stats.algnerrc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
	E1000_STAT("tx_tcp_seg_good", stats.tsctc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
	E1000_STAT("tx_tcp_seg_failed", stats.tsctfc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
	E1000_STAT("rx_flow_control_xon", stats.xonrxc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
	E1000_STAT("rx_flow_control_xoff", stats.xoffrxc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
	E1000_STAT("tx_flow_control_xon", stats.xontxc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
	E1000_STAT("tx_flow_control_xoff", stats.xofftxc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
	E1000_STAT("rx_long_byte_count", stats.gorc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
	E1000_STAT("rx_csum_offload_good", hw_csum_good),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
	E1000_STAT("rx_csum_offload_errors", hw_csum_err),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
	E1000_STAT("rx_header_split", rx_hdr_split),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
	E1000_STAT("alloc_rx_buff_failed", alloc_rx_buff_failed),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
	E1000_STAT("tx_smbus", stats.mgptc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
	E1000_STAT("rx_smbus", stats.mgprc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
	E1000_STAT("dropped_smbus", stats.mgpdc),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
	E1000_STAT("rx_dma_failed", rx_dma_failed),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
	E1000_STAT("tx_dma_failed", tx_dma_failed),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
};
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
#define E1000_GLOBAL_STATS_LEN	ARRAY_SIZE(e1000_gstrings_stats)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
#define E1000_STATS_LEN (E1000_GLOBAL_STATS_LEN)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
	"Register test  (offline)", "Eeprom test    (offline)",
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
	"Interrupt test (offline)", "Loopback test  (offline)",
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
	"Link test   (on/offline)"
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
};
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
#define E1000_TEST_LEN ARRAY_SIZE(e1000_gstrings_test)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
static int e1000_get_settings(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
			      struct ethtool_cmd *ecmd)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
	u32 speed;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
	if (hw->phy.media_type == e1000_media_type_copper) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
		ecmd->supported = (SUPPORTED_10baseT_Half |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
				   SUPPORTED_10baseT_Full |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
				   SUPPORTED_100baseT_Half |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
				   SUPPORTED_100baseT_Full |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
				   SUPPORTED_1000baseT_Full |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
				   SUPPORTED_Autoneg |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
				   SUPPORTED_TP);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
		if (hw->phy.type == e1000_phy_ife)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
			ecmd->supported &= ~SUPPORTED_1000baseT_Full;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
		ecmd->advertising = ADVERTISED_TP;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
		if (hw->mac.autoneg == 1) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
			ecmd->advertising |= ADVERTISED_Autoneg;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
			/* the e1000 autoneg seems to match ethtool nicely */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
			ecmd->advertising |= hw->phy.autoneg_advertised;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
		ecmd->port = PORT_TP;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
		ecmd->phy_address = hw->phy.addr;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
		ecmd->transceiver = XCVR_INTERNAL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
	} else {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
		ecmd->supported   = (SUPPORTED_1000baseT_Full |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
				     SUPPORTED_FIBRE |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
				     SUPPORTED_Autoneg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
		ecmd->advertising = (ADVERTISED_1000baseT_Full |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
				     ADVERTISED_FIBRE |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
				     ADVERTISED_Autoneg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
		ecmd->port = PORT_FIBRE;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
		ecmd->transceiver = XCVR_EXTERNAL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
	speed = -1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
	ecmd->duplex = -1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
	if (netif_running(netdev)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
		if (netif_carrier_ok(netdev)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
			speed = adapter->link_speed;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
			ecmd->duplex = adapter->link_duplex - 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
	} else {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
		u32 status = er32(STATUS);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
		if (status & E1000_STATUS_LU) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
			if (status & E1000_STATUS_SPEED_1000)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
				speed = SPEED_1000;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
			else if (status & E1000_STATUS_SPEED_100)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
				speed = SPEED_100;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
			else
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
				speed = SPEED_10;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
			if (status & E1000_STATUS_FD)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
				ecmd->duplex = DUPLEX_FULL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
			else
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
				ecmd->duplex = DUPLEX_HALF;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
	ethtool_cmd_speed_set(ecmd, speed);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
	ecmd->autoneg = ((hw->phy.media_type == e1000_media_type_fiber) ||
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
			 hw->mac.autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
	/* MDI-X => 2; MDI =>1; Invalid =>0 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
	if ((hw->phy.media_type == e1000_media_type_copper) &&
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
	    netif_carrier_ok(netdev))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
		ecmd->eth_tp_mdix = hw->phy.is_mdix ? ETH_TP_MDI_X :
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
		                                      ETH_TP_MDI;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
	else
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
		ecmd->eth_tp_mdix = ETH_TP_MDI_INVALID;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
static int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
	struct e1000_mac_info *mac = &adapter->hw.mac;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
	mac->autoneg = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
	/* Make sure dplx is at most 1 bit and lsb of speed is not set
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
	 * for the switch() below to work */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
	if ((spd & 1) || (dplx & ~1))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
		goto err_inval;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
	/* Fiber NICs only allow 1000 gbps Full duplex */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
	if ((adapter->hw.phy.media_type == e1000_media_type_fiber) &&
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
	    spd != SPEED_1000 &&
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
	    dplx != DUPLEX_FULL) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
		goto err_inval;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
	switch (spd + dplx) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
	case SPEED_10 + DUPLEX_HALF:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
		mac->forced_speed_duplex = ADVERTISE_10_HALF;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
	case SPEED_10 + DUPLEX_FULL:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
		mac->forced_speed_duplex = ADVERTISE_10_FULL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
	case SPEED_100 + DUPLEX_HALF:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
		mac->forced_speed_duplex = ADVERTISE_100_HALF;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
	case SPEED_100 + DUPLEX_FULL:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
		mac->forced_speed_duplex = ADVERTISE_100_FULL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
	case SPEED_1000 + DUPLEX_FULL:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
		mac->autoneg = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
		adapter->hw.phy.autoneg_advertised = ADVERTISE_1000_FULL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
	case SPEED_1000 + DUPLEX_HALF: /* not supported */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
	default:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
		goto err_inval;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
err_inval:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
	e_err("Unsupported Speed/Duplex configuration\n");
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
	return -EINVAL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
static int e1000_set_settings(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
			      struct ethtool_cmd *ecmd)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
	/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
	 * When SoL/IDER sessions are active, autoneg/speed/duplex
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
	 * cannot be changed
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
	 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
	if (hw->phy.ops.check_reset_block &&
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
	    hw->phy.ops.check_reset_block(hw)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
		e_err("Cannot change link characteristics when SoL/IDER is "
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
		      "active.\n");
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
		return -EINVAL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
	while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
		usleep_range(1000, 2000);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
	if (ecmd->autoneg == AUTONEG_ENABLE) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
		hw->mac.autoneg = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
		if (hw->phy.media_type == e1000_media_type_fiber)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
			hw->phy.autoneg_advertised = ADVERTISED_1000baseT_Full |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
						     ADVERTISED_FIBRE |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
						     ADVERTISED_Autoneg;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
		else
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
			hw->phy.autoneg_advertised = ecmd->advertising |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
						     ADVERTISED_TP |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
						     ADVERTISED_Autoneg;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
		ecmd->advertising = hw->phy.autoneg_advertised;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
		if (adapter->fc_autoneg)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
			hw->fc.requested_mode = e1000_fc_default;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
	} else {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
		u32 speed = ethtool_cmd_speed(ecmd);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
		if (e1000_set_spd_dplx(adapter, speed, ecmd->duplex)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
			clear_bit(__E1000_RESETTING, &adapter->state);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
			return -EINVAL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
	/* reset the link */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
	if (netif_running(adapter->netdev)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
		e1000e_down(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
		e1000e_up(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
	} else {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
		e1000e_reset(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
	clear_bit(__E1000_RESETTING, &adapter->state);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
static void e1000_get_pauseparam(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
				 struct ethtool_pauseparam *pause)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
	pause->autoneg =
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
		(adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
	if (hw->fc.current_mode == e1000_fc_rx_pause) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
		pause->rx_pause = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
	} else if (hw->fc.current_mode == e1000_fc_tx_pause) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
		pause->tx_pause = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
	} else if (hw->fc.current_mode == e1000_fc_full) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
		pause->rx_pause = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
		pause->tx_pause = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
static int e1000_set_pauseparam(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
				struct ethtool_pauseparam *pause)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
	int retval = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
	adapter->fc_autoneg = pause->autoneg;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
	while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
		usleep_range(1000, 2000);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
	if (adapter->fc_autoneg == AUTONEG_ENABLE) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
		hw->fc.requested_mode = e1000_fc_default;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
		if (netif_running(adapter->netdev)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
			e1000e_down(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
			e1000e_up(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
		} else {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
			e1000e_reset(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
	} else {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
		if (pause->rx_pause && pause->tx_pause)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
			hw->fc.requested_mode = e1000_fc_full;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
		else if (pause->rx_pause && !pause->tx_pause)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
			hw->fc.requested_mode = e1000_fc_rx_pause;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
		else if (!pause->rx_pause && pause->tx_pause)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
			hw->fc.requested_mode = e1000_fc_tx_pause;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
		else if (!pause->rx_pause && !pause->tx_pause)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
			hw->fc.requested_mode = e1000_fc_none;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
		hw->fc.current_mode = hw->fc.requested_mode;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
		if (hw->phy.media_type == e1000_media_type_fiber) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
			retval = hw->mac.ops.setup_link(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
			/* implicit goto out */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
		} else {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
			retval = e1000e_force_mac_fc(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
			if (retval)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
				goto out;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
			e1000e_set_fc_watermarks(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
out:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
	clear_bit(__E1000_RESETTING, &adapter->state);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
	return retval;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
static u32 e1000_get_msglevel(struct net_device *netdev)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
	return adapter->msg_enable;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
static void e1000_set_msglevel(struct net_device *netdev, u32 data)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
	adapter->msg_enable = data;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
static int e1000_get_regs_len(struct net_device *netdev)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
#define E1000_REGS_LEN 32 /* overestimate */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
	return E1000_REGS_LEN * sizeof(u32);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
static void e1000_get_regs(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
			   struct ethtool_regs *regs, void *p)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
	u32 *regs_buff = p;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
	u16 phy_data;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
	memset(p, 0, E1000_REGS_LEN * sizeof(u32));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
	regs->version = (1 << 24) | (adapter->pdev->revision << 16) |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
			adapter->pdev->device;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
	regs_buff[0]  = er32(CTRL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
	regs_buff[1]  = er32(STATUS);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
	regs_buff[2]  = er32(RCTL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
	regs_buff[3]  = er32(RDLEN);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
	regs_buff[4]  = er32(RDH);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   409
	regs_buff[5]  = er32(RDT);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
	regs_buff[6]  = er32(RDTR);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
	regs_buff[7]  = er32(TCTL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
	regs_buff[8]  = er32(TDLEN);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
	regs_buff[9]  = er32(TDH);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
	regs_buff[10] = er32(TDT);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
	regs_buff[11] = er32(TIDV);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
	regs_buff[12] = adapter->hw.phy.type;  /* PHY type (IGP=1, M88=0) */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
	/* ethtool doesn't use anything past this point, so all this
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
	 * code is likely legacy junk for apps that may or may not
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
	 * exist */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
	if (hw->phy.type == e1000_phy_m88) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
		e1e_rphy(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
		regs_buff[13] = (u32)phy_data; /* cable length */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
		regs_buff[14] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
		regs_buff[15] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
		regs_buff[16] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
		e1e_rphy(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
		regs_buff[17] = (u32)phy_data; /* extended 10bt distance */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
		regs_buff[18] = regs_buff[13]; /* cable polarity */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
		regs_buff[19] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
		regs_buff[20] = regs_buff[17]; /* polarity correction */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
		/* phy receive errors */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
		regs_buff[22] = adapter->phy_stats.receive_errors;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
		regs_buff[23] = regs_buff[13]; /* mdix mode */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
	regs_buff[21] = 0; /* was idle_errors */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
	e1e_rphy(hw, PHY_1000T_STATUS, &phy_data);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
	regs_buff[24] = (u32)phy_data;  /* phy local receiver status */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
	regs_buff[25] = regs_buff[24];  /* phy remote receiver status */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
static int e1000_get_eeprom_len(struct net_device *netdev)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
	return adapter->hw.nvm.word_size * 2;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
static int e1000_get_eeprom(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
			    struct ethtool_eeprom *eeprom, u8 *bytes)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
	u16 *eeprom_buff;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
	int first_word;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
	int last_word;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
	int ret_val = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
	u16 i;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
	if (eeprom->len == 0)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
		return -EINVAL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
	eeprom->magic = adapter->pdev->vendor | (adapter->pdev->device << 16);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
	first_word = eeprom->offset >> 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
	last_word = (eeprom->offset + eeprom->len - 1) >> 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
	eeprom_buff = kmalloc(sizeof(u16) *
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
			(last_word - first_word + 1), GFP_KERNEL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
	if (!eeprom_buff)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
		return -ENOMEM;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
	if (hw->nvm.type == e1000_nvm_eeprom_spi) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
		ret_val = e1000_read_nvm(hw, first_word,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
					 last_word - first_word + 1,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
					 eeprom_buff);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
	} else {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   479
		for (i = 0; i < last_word - first_word + 1; i++) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   480
			ret_val = e1000_read_nvm(hw, first_word + i, 1,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
						      &eeprom_buff[i]);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
			if (ret_val)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   483
				break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
	if (ret_val) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
		/* a read error occurred, throw away the result */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
		memset(eeprom_buff, 0xff, sizeof(u16) *
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
		       (last_word - first_word + 1));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
	} else {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
		/* Device's eeprom is always little-endian, word addressable */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
		for (i = 0; i < last_word - first_word + 1; i++)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
			le16_to_cpus(&eeprom_buff[i]);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
	memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
	kfree(eeprom_buff);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
	return ret_val;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
static int e1000_set_eeprom(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
			    struct ethtool_eeprom *eeprom, u8 *bytes)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
	u16 *eeprom_buff;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
	void *ptr;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
	int max_len;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
	int first_word;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
	int last_word;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
	int ret_val = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
	u16 i;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
	if (eeprom->len == 0)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
		return -EOPNOTSUPP;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
	if (eeprom->magic != (adapter->pdev->vendor | (adapter->pdev->device << 16)))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
		return -EFAULT;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
	if (adapter->flags & FLAG_READ_ONLY_NVM)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
		return -EINVAL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
	max_len = hw->nvm.word_size * 2;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
	first_word = eeprom->offset >> 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
	last_word = (eeprom->offset + eeprom->len - 1) >> 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
	eeprom_buff = kmalloc(max_len, GFP_KERNEL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
	if (!eeprom_buff)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
		return -ENOMEM;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
	ptr = (void *)eeprom_buff;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
	if (eeprom->offset & 1) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
		/* need read/modify/write of first changed EEPROM word */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
		/* only the second byte of the word is being modified */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   538
		ret_val = e1000_read_nvm(hw, first_word, 1, &eeprom_buff[0]);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
		ptr++;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
	if (((eeprom->offset + eeprom->len) & 1) && (!ret_val))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
		/* need read/modify/write of last changed EEPROM word */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
		/* only the first byte of the word is being modified */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
		ret_val = e1000_read_nvm(hw, last_word, 1,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
				  &eeprom_buff[last_word - first_word]);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
	if (ret_val)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
		goto out;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
	/* Device's eeprom is always little-endian, word addressable */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
	for (i = 0; i < last_word - first_word + 1; i++)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
		le16_to_cpus(&eeprom_buff[i]);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
	memcpy(ptr, bytes, eeprom->len);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
	for (i = 0; i < last_word - first_word + 1; i++)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
		cpu_to_le16s(&eeprom_buff[i]);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
	ret_val = e1000_write_nvm(hw, first_word,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
				  last_word - first_word + 1, eeprom_buff);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
	if (ret_val)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
		goto out;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
	/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
	 * Update the checksum over the first part of the EEPROM if needed
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
	 * and flush shadow RAM for applicable controllers
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
	 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
	if ((first_word <= NVM_CHECKSUM_REG) ||
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
	    (hw->mac.type == e1000_82583) ||
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
	    (hw->mac.type == e1000_82574) ||
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
	    (hw->mac.type == e1000_82573))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
		ret_val = e1000e_update_nvm_checksum(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
out:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
	kfree(eeprom_buff);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
	return ret_val;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
static void e1000_get_drvinfo(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
			      struct ethtool_drvinfo *drvinfo)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
	strlcpy(drvinfo->driver,  e1000e_driver_name,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
		sizeof(drvinfo->driver));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
	strlcpy(drvinfo->version, e1000e_driver_version,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
		sizeof(drvinfo->version));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
	/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
	 * EEPROM image version # is reported as firmware version # for
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
	 * PCI-E controllers
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
	 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
	snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
		"%d.%d-%d",
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
		(adapter->eeprom_vers & 0xF000) >> 12,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
		(adapter->eeprom_vers & 0x0FF0) >> 4,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
		(adapter->eeprom_vers & 0x000F));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
	strlcpy(drvinfo->bus_info, pci_name(adapter->pdev),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
		sizeof(drvinfo->bus_info));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
	drvinfo->regdump_len = e1000_get_regs_len(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
	drvinfo->eedump_len = e1000_get_eeprom_len(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
static void e1000_get_ringparam(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
				struct ethtool_ringparam *ring)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
	ring->rx_max_pending = E1000_MAX_RXD;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
	ring->tx_max_pending = E1000_MAX_TXD;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
	ring->rx_pending = adapter->rx_ring_count;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
	ring->tx_pending = adapter->tx_ring_count;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
static int e1000_set_ringparam(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
			       struct ethtool_ringparam *ring)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
	struct e1000_ring *temp_tx = NULL, *temp_rx = NULL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
	int err = 0, size = sizeof(struct e1000_ring);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
	bool set_tx = false, set_rx = false;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
	u16 new_rx_count, new_tx_count;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
	if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
		return -EINVAL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
	new_rx_count = clamp_t(u32, ring->rx_pending, E1000_MIN_RXD,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
			       E1000_MAX_RXD);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
	new_rx_count = ALIGN(new_rx_count, REQ_RX_DESCRIPTOR_MULTIPLE);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
	new_tx_count = clamp_t(u32, ring->tx_pending, E1000_MIN_TXD,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
			       E1000_MAX_TXD);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
	new_tx_count = ALIGN(new_tx_count, REQ_TX_DESCRIPTOR_MULTIPLE);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
	if ((new_tx_count == adapter->tx_ring_count) &&
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
	    (new_rx_count == adapter->rx_ring_count))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
		/* nothing to do */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
		return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
	while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
		usleep_range(1000, 2000);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
	if (!netif_running(adapter->netdev)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
		/* Set counts now and allocate resources during open() */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
		adapter->tx_ring->count = new_tx_count;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
		adapter->rx_ring->count = new_rx_count;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
		adapter->tx_ring_count = new_tx_count;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
		adapter->rx_ring_count = new_rx_count;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
		goto clear_reset;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
	set_tx = (new_tx_count != adapter->tx_ring_count);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
	set_rx = (new_rx_count != adapter->rx_ring_count);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
	/* Allocate temporary storage for ring updates */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
	if (set_tx) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
		temp_tx = vmalloc(size);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
		if (!temp_tx) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
			err = -ENOMEM;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
			goto free_temp;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
	if (set_rx) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
		temp_rx = vmalloc(size);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
		if (!temp_rx) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
			err = -ENOMEM;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
			goto free_temp;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
	e1000e_down(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
	/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
	 * We can't just free everything and then setup again, because the
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
	 * ISRs in MSI-X mode get passed pointers to the Tx and Rx ring
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
	 * structs.  First, attempt to allocate new resources...
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
	 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
	if (set_tx) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
		memcpy(temp_tx, adapter->tx_ring, size);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
		temp_tx->count = new_tx_count;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
		err = e1000e_setup_tx_resources(temp_tx);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
		if (err)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
			goto err_setup;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
	if (set_rx) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
		memcpy(temp_rx, adapter->rx_ring, size);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
		temp_rx->count = new_rx_count;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
		err = e1000e_setup_rx_resources(temp_rx);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
		if (err)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
			goto err_setup_rx;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
	/* ...then free the old resources and copy back any new ring data */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
	if (set_tx) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
		e1000e_free_tx_resources(adapter->tx_ring);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
		memcpy(adapter->tx_ring, temp_tx, size);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
		adapter->tx_ring_count = new_tx_count;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
	if (set_rx) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
		e1000e_free_rx_resources(adapter->rx_ring);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
		memcpy(adapter->rx_ring, temp_rx, size);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
		adapter->rx_ring_count = new_rx_count;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
err_setup_rx:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
	if (err && set_tx)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
		e1000e_free_tx_resources(temp_tx);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
err_setup:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
	e1000e_up(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
free_temp:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
	vfree(temp_tx);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
	vfree(temp_rx);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
clear_reset:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
	clear_bit(__E1000_RESETTING, &adapter->state);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
	return err;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
			     int reg, int offset, u32 mask, u32 write)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
	u32 pat, val;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
	static const u32 test[] = {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
		0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
	for (pat = 0; pat < ARRAY_SIZE(test); pat++) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
		E1000_WRITE_REG_ARRAY(&adapter->hw, reg, offset,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
				      (test[pat] & write));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
		val = E1000_READ_REG_ARRAY(&adapter->hw, reg, offset);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
		if (val != (test[pat] & write & mask)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
			e_err("pattern test reg %04X failed: got 0x%08X "
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
			      "expected 0x%08X\n", reg + offset, val,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
			      (test[pat] & write & mask));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
			*data = reg;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
			return 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
			      int reg, u32 mask, u32 write)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
	u32 val;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
	__ew32(&adapter->hw, reg, write & mask);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
	val = __er32(&adapter->hw, reg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
	if ((write & mask) != (val & mask)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
		e_err("set/check reg %04X test failed: got 0x%08X "
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
		      "expected 0x%08X\n", reg, (val & mask), (write & mask));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
		*data = reg;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
		return 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
#define REG_PATTERN_TEST_ARRAY(reg, offset, mask, write)                       \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
	do {                                                                   \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
		if (reg_pattern_test(adapter, data, reg, offset, mask, write)) \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
			return 1;                                              \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
	} while (0)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
#define REG_PATTERN_TEST(reg, mask, write)                                     \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
	REG_PATTERN_TEST_ARRAY(reg, 0, mask, write)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
#define REG_SET_AND_CHECK(reg, mask, write)                                    \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
	do {                                                                   \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
		if (reg_set_and_check(adapter, data, reg, mask, write))        \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
			return 1;                                              \
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
	} while (0)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
	struct e1000_mac_info *mac = &adapter->hw.mac;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
	u32 value;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
	u32 before;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
	u32 after;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
	u32 i;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
	u32 toggle;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
	u32 mask;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
	/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
	 * The status register is Read Only, so a write should fail.
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
	 * Some bits that get toggled are ignored.
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
	 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
	switch (mac->type) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
	/* there are several bits on newer hardware that are r/w */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
	case e1000_82571:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
	case e1000_82572:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
	case e1000_80003es2lan:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
		toggle = 0x7FFFF3FF;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
        default:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
		toggle = 0x7FFFF033;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
	before = er32(STATUS);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
	value = (er32(STATUS) & toggle);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
	ew32(STATUS, toggle);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
	after = er32(STATUS) & toggle;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
	if (value != after) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
		e_err("failed STATUS register test got: 0x%08X expected: "
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
		      "0x%08X\n", after, value);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
		*data = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
		return 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
	/* restore previous status */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
	ew32(STATUS, before);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
	if (!(adapter->flags & FLAG_IS_ICH)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
		REG_PATTERN_TEST(E1000_FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
		REG_PATTERN_TEST(E1000_FCAH, 0x0000FFFF, 0xFFFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
		REG_PATTERN_TEST(E1000_FCT, 0x0000FFFF, 0xFFFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
		REG_PATTERN_TEST(E1000_VET, 0x0000FFFF, 0xFFFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
	REG_PATTERN_TEST(E1000_RDTR, 0x0000FFFF, 0xFFFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
	REG_PATTERN_TEST(E1000_RDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
	REG_PATTERN_TEST(E1000_RDLEN, 0x000FFF80, 0x000FFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
	REG_PATTERN_TEST(E1000_RDH, 0x0000FFFF, 0x0000FFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
	REG_PATTERN_TEST(E1000_RDT, 0x0000FFFF, 0x0000FFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
	REG_PATTERN_TEST(E1000_FCRTH, 0x0000FFF8, 0x0000FFF8);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
	REG_PATTERN_TEST(E1000_FCTTV, 0x0000FFFF, 0x0000FFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
	REG_PATTERN_TEST(E1000_TIPG, 0x3FFFFFFF, 0x3FFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
	REG_PATTERN_TEST(E1000_TDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
	REG_PATTERN_TEST(E1000_TDLEN, 0x000FFF80, 0x000FFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
	REG_SET_AND_CHECK(E1000_RCTL, 0xFFFFFFFF, 0x00000000);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
	before = ((adapter->flags & FLAG_IS_ICH) ? 0x06C3B33E : 0x06DFB3FE);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
	REG_SET_AND_CHECK(E1000_RCTL, before, 0x003FFFFB);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
	REG_SET_AND_CHECK(E1000_TCTL, 0xFFFFFFFF, 0x00000000);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
	REG_SET_AND_CHECK(E1000_RCTL, before, 0xFFFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
	REG_PATTERN_TEST(E1000_RDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
	if (!(adapter->flags & FLAG_IS_ICH))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
		REG_PATTERN_TEST(E1000_TXCW, 0xC000FFFF, 0x0000FFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
	REG_PATTERN_TEST(E1000_TDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
	REG_PATTERN_TEST(E1000_TIDV, 0x0000FFFF, 0x0000FFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
	mask = 0x8003FFFF;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
	switch (mac->type) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
	case e1000_ich10lan:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
	case e1000_pchlan:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
	case e1000_pch2lan:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
		mask |= (1 << 18);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
	default:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
	for (i = 0; i < mac->rar_entry_count; i++)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
		REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
		                       mask, 0xFFFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
	for (i = 0; i < mac->mta_reg_count; i++)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
		REG_PATTERN_TEST_ARRAY(E1000_MTA, i, 0xFFFFFFFF, 0xFFFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
	*data = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
static int e1000_eeprom_test(struct e1000_adapter *adapter, u64 *data)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
	u16 temp;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
	u16 checksum = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
	u16 i;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
	*data = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
	/* Read and add up the contents of the EEPROM */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
	for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
		if ((e1000_read_nvm(&adapter->hw, i, 1, &temp)) < 0) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
			*data = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
			return *data;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
		checksum += temp;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
	/* If Checksum is not Correct return error else test passed */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
	if ((checksum != (u16) NVM_SUM) && !(*data))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
		*data = 2;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
	return *data;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
static irqreturn_t e1000_test_intr(int irq, void *data)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
	struct net_device *netdev = (struct net_device *) data;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
	adapter->test_icr |= er32(ICR);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
	return IRQ_HANDLED;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
	struct net_device *netdev = adapter->netdev;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
	u32 mask;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
	u32 shared_int = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
	u32 irq = adapter->pdev->irq;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
	int i;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
	int ret_val = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
	int int_mode = E1000E_INT_MODE_LEGACY;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
	*data = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
	/* NOTE: we don't test MSI/MSI-X interrupts here, yet */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
	if (adapter->int_mode == E1000E_INT_MODE_MSIX) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
		int_mode = adapter->int_mode;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
		e1000e_reset_interrupt_capability(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
		adapter->int_mode = E1000E_INT_MODE_LEGACY;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
		e1000e_set_interrupt_capability(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
	/* Hook up test interrupt handler just for this test */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
	if (!request_irq(irq, e1000_test_intr, IRQF_PROBE_SHARED, netdev->name,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
			 netdev)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
		shared_int = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
	} else if (request_irq(irq, e1000_test_intr, IRQF_SHARED,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
		 netdev->name, netdev)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
		*data = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
		ret_val = -1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
		goto out;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
	e_info("testing %s interrupt\n", (shared_int ? "shared" : "unshared"));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
	/* Disable all the interrupts */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
	ew32(IMC, 0xFFFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
	e1e_flush();
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
	usleep_range(10000, 20000);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
	/* Test each interrupt */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
	for (i = 0; i < 10; i++) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
		/* Interrupt to test */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
		mask = 1 << i;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
		if (adapter->flags & FLAG_IS_ICH) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
			switch (mask) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
			case E1000_ICR_RXSEQ:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
				continue;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
			case 0x00000100:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
				if (adapter->hw.mac.type == e1000_ich8lan ||
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
				    adapter->hw.mac.type == e1000_ich9lan)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
					continue;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
				break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
			default:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
				break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
			}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
		if (!shared_int) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
			/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
			 * Disable the interrupt to be reported in
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
			 * the cause register and then force the same
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
			 * interrupt and see if one gets posted.  If
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
			 * an interrupt was posted to the bus, the
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
			 * test failed.
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
			 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
			adapter->test_icr = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
			ew32(IMC, mask);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
			ew32(ICS, mask);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
			e1e_flush();
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
			usleep_range(10000, 20000);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
			if (adapter->test_icr & mask) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
				*data = 3;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
				break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
			}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
		/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
		 * Enable the interrupt to be reported in
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
		 * the cause register and then force the same
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
		 * interrupt and see if one gets posted.  If
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
		 * an interrupt was not posted to the bus, the
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
		 * test failed.
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
		 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
		adapter->test_icr = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
		ew32(IMS, mask);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
		ew32(ICS, mask);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
		e1e_flush();
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
		usleep_range(10000, 20000);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
		if (!(adapter->test_icr & mask)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
			*data = 4;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
			break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
		if (!shared_int) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
			/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
			 * Disable the other interrupts to be reported in
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
			 * the cause register and then force the other
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
			 * interrupts and see if any get posted.  If
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
			 * an interrupt was posted to the bus, the
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
			 * test failed.
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
			 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
			adapter->test_icr = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
			ew32(IMC, ~mask & 0x00007FFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
			ew32(ICS, ~mask & 0x00007FFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
			e1e_flush();
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
			usleep_range(10000, 20000);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
			if (adapter->test_icr) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
				*data = 5;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
				break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
			}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
	/* Disable all the interrupts */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
	ew32(IMC, 0xFFFFFFFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
	e1e_flush();
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
	usleep_range(10000, 20000);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
	/* Unhook test interrupt handler */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
	free_irq(irq, netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
out:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
	if (int_mode == E1000E_INT_MODE_MSIX) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
		e1000e_reset_interrupt_capability(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
		adapter->int_mode = int_mode;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
		e1000e_set_interrupt_capability(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
	return ret_val;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
static void e1000_free_desc_rings(struct e1000_adapter *adapter)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
	struct e1000_ring *tx_ring = &adapter->test_tx_ring;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
	struct e1000_ring *rx_ring = &adapter->test_rx_ring;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
	struct pci_dev *pdev = adapter->pdev;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
	int i;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
	if (tx_ring->desc && tx_ring->buffer_info) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
		for (i = 0; i < tx_ring->count; i++) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
			if (tx_ring->buffer_info[i].dma)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
				dma_unmap_single(&pdev->dev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
					tx_ring->buffer_info[i].dma,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
					tx_ring->buffer_info[i].length,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
					DMA_TO_DEVICE);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
			if (tx_ring->buffer_info[i].skb)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
				dev_kfree_skb(tx_ring->buffer_info[i].skb);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
	if (rx_ring->desc && rx_ring->buffer_info) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
		for (i = 0; i < rx_ring->count; i++) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
			if (rx_ring->buffer_info[i].dma)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
				dma_unmap_single(&pdev->dev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
					rx_ring->buffer_info[i].dma,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
					2048, DMA_FROM_DEVICE);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
			if (rx_ring->buffer_info[i].skb)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
				dev_kfree_skb(rx_ring->buffer_info[i].skb);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
	if (tx_ring->desc) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
		dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
				  tx_ring->dma);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
		tx_ring->desc = NULL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
	if (rx_ring->desc) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
		dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
				  rx_ring->dma);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
		rx_ring->desc = NULL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
	kfree(tx_ring->buffer_info);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
	tx_ring->buffer_info = NULL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
	kfree(rx_ring->buffer_info);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
	rx_ring->buffer_info = NULL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
static int e1000_setup_desc_rings(struct e1000_adapter *adapter)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
	struct e1000_ring *tx_ring = &adapter->test_tx_ring;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
	struct e1000_ring *rx_ring = &adapter->test_rx_ring;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
	struct pci_dev *pdev = adapter->pdev;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
	u32 rctl;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
	int i;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
	int ret_val;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
	/* Setup Tx descriptor ring and Tx buffers */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
	if (!tx_ring->count)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
		tx_ring->count = E1000_DEFAULT_TXD;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
	tx_ring->buffer_info = kcalloc(tx_ring->count,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
				       sizeof(struct e1000_buffer),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
				       GFP_KERNEL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
	if (!tx_ring->buffer_info) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
		ret_val = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
		goto err_nomem;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
	tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
	tx_ring->size = ALIGN(tx_ring->size, 4096);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
	tx_ring->desc = dma_alloc_coherent(&pdev->dev, tx_ring->size,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
					   &tx_ring->dma, GFP_KERNEL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
	if (!tx_ring->desc) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
		ret_val = 2;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
		goto err_nomem;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
	tx_ring->next_to_use = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
	tx_ring->next_to_clean = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
	ew32(TDBAL, ((u64) tx_ring->dma & 0x00000000FFFFFFFF));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
	ew32(TDBAH, ((u64) tx_ring->dma >> 32));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
	ew32(TDLEN, tx_ring->count * sizeof(struct e1000_tx_desc));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
	ew32(TDH, 0);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
	ew32(TDT, 0);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
	ew32(TCTL, E1000_TCTL_PSP | E1000_TCTL_EN | E1000_TCTL_MULR |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
	     E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
	     E1000_COLLISION_DISTANCE << E1000_COLD_SHIFT);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
	for (i = 0; i < tx_ring->count; i++) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
		struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*tx_ring, i);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
		struct sk_buff *skb;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
		unsigned int skb_size = 1024;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
		skb = alloc_skb(skb_size, GFP_KERNEL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
		if (!skb) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
			ret_val = 3;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
			goto err_nomem;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
		skb_put(skb, skb_size);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
		tx_ring->buffer_info[i].skb = skb;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
		tx_ring->buffer_info[i].length = skb->len;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
		tx_ring->buffer_info[i].dma =
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
			dma_map_single(&pdev->dev, skb->data, skb->len,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
				       DMA_TO_DEVICE);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
		if (dma_mapping_error(&pdev->dev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
				      tx_ring->buffer_info[i].dma)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
			ret_val = 4;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
			goto err_nomem;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
		tx_desc->buffer_addr = cpu_to_le64(tx_ring->buffer_info[i].dma);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
		tx_desc->lower.data = cpu_to_le32(skb->len);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
		tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
						   E1000_TXD_CMD_IFCS |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
						   E1000_TXD_CMD_RS);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
		tx_desc->upper.data = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
	/* Setup Rx descriptor ring and Rx buffers */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
	if (!rx_ring->count)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
		rx_ring->count = E1000_DEFAULT_RXD;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
	rx_ring->buffer_info = kcalloc(rx_ring->count,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
				       sizeof(struct e1000_buffer),
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
				       GFP_KERNEL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
	if (!rx_ring->buffer_info) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
		ret_val = 5;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
		goto err_nomem;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
	rx_ring->size = rx_ring->count * sizeof(union e1000_rx_desc_extended);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
	rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
					   &rx_ring->dma, GFP_KERNEL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
	if (!rx_ring->desc) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
		ret_val = 6;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
		goto err_nomem;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
	rx_ring->next_to_use = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
	rx_ring->next_to_clean = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
	rctl = er32(RCTL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
	if (!(adapter->flags2 & FLAG2_NO_DISABLE_RX))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
		ew32(RCTL, rctl & ~E1000_RCTL_EN);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
	ew32(RDBAL, ((u64) rx_ring->dma & 0xFFFFFFFF));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
	ew32(RDBAH, ((u64) rx_ring->dma >> 32));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
	ew32(RDLEN, rx_ring->size);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
	ew32(RDH, 0);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
	ew32(RDT, 0);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
	rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
		E1000_RCTL_UPE | E1000_RCTL_MPE | E1000_RCTL_LPE |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
		E1000_RCTL_SBP | E1000_RCTL_SECRC |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
		E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
		(adapter->hw.mac.mc_filter_type << E1000_RCTL_MO_SHIFT);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
	ew32(RCTL, rctl);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
	for (i = 0; i < rx_ring->count; i++) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
		union e1000_rx_desc_extended *rx_desc;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
		struct sk_buff *skb;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
		skb = alloc_skb(2048 + NET_IP_ALIGN, GFP_KERNEL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
		if (!skb) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
			ret_val = 7;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
			goto err_nomem;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
		skb_reserve(skb, NET_IP_ALIGN);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
		rx_ring->buffer_info[i].skb = skb;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
		rx_ring->buffer_info[i].dma =
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
			dma_map_single(&pdev->dev, skb->data, 2048,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
				       DMA_FROM_DEVICE);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
		if (dma_mapping_error(&pdev->dev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
				      rx_ring->buffer_info[i].dma)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
			ret_val = 8;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
			goto err_nomem;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
		rx_desc = E1000_RX_DESC_EXT(*rx_ring, i);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
		rx_desc->read.buffer_addr =
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
		    cpu_to_le64(rx_ring->buffer_info[i].dma);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
		memset(skb->data, 0x00, skb->len);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
err_nomem:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
	e1000_free_desc_rings(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
	return ret_val;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
static void e1000_phy_disable_receiver(struct e1000_adapter *adapter)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
	/* Write out to PHY registers 29 and 30 to disable the Receiver. */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
	e1e_wphy(&adapter->hw, 29, 0x001F);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
	e1e_wphy(&adapter->hw, 30, 0x8FFC);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
	e1e_wphy(&adapter->hw, 29, 0x001A);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
	e1e_wphy(&adapter->hw, 30, 0x8FF0);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
	u32 ctrl_reg = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
	u16 phy_reg = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
	s32 ret_val = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
	hw->mac.autoneg = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
	if (hw->phy.type == e1000_phy_ife) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
		/* force 100, set loopback */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
		e1e_wphy(hw, PHY_CONTROL, 0x6100);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
		/* Now set up the MAC to the same speed/duplex as the PHY. */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
		ctrl_reg = er32(CTRL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
		ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
		ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
			     E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
			     E1000_CTRL_SPD_100 |/* Force Speed to 100 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
			     E1000_CTRL_FD);	 /* Force Duplex to FULL */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
		ew32(CTRL, ctrl_reg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
		e1e_flush();
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
		udelay(500);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
		return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
	/* Specific PHY configuration for loopback */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
	switch (hw->phy.type) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
	case e1000_phy_m88:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
		/* Auto-MDI/MDIX Off */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
		e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, 0x0808);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
		/* reset to update Auto-MDI/MDIX */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
		e1e_wphy(hw, PHY_CONTROL, 0x9140);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
		/* autoneg off */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
		e1e_wphy(hw, PHY_CONTROL, 0x8140);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
	case e1000_phy_gg82563:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
		e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x1CC);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
	case e1000_phy_bm:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
		/* Set Default MAC Interface speed to 1GB */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
		e1e_rphy(hw, PHY_REG(2, 21), &phy_reg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
		phy_reg &= ~0x0007;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
		phy_reg |= 0x006;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
		e1e_wphy(hw, PHY_REG(2, 21), phy_reg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
		/* Assert SW reset for above settings to take effect */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
		e1000e_commit_phy(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
		mdelay(1);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
		/* Force Full Duplex */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
		e1e_rphy(hw, PHY_REG(769, 16), &phy_reg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
		e1e_wphy(hw, PHY_REG(769, 16), phy_reg | 0x000C);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
		/* Set Link Up (in force link) */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
		e1e_rphy(hw, PHY_REG(776, 16), &phy_reg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
		e1e_wphy(hw, PHY_REG(776, 16), phy_reg | 0x0040);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
		/* Force Link */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
		e1e_rphy(hw, PHY_REG(769, 16), &phy_reg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
		e1e_wphy(hw, PHY_REG(769, 16), phy_reg | 0x0040);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
		/* Set Early Link Enable */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
		e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
		e1e_wphy(hw, PHY_REG(769, 20), phy_reg | 0x0400);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
	case e1000_phy_82577:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
	case e1000_phy_82578:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
		/* Workaround: K1 must be disabled for stable 1Gbps operation */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
		ret_val = hw->phy.ops.acquire(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
		if (ret_val) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
			e_err("Cannot setup 1Gbps loopback.\n");
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
			return ret_val;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
		e1000_configure_k1_ich8lan(hw, false);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
		hw->phy.ops.release(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
	case e1000_phy_82579:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
		/* Disable PHY energy detect power down */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
		e1e_rphy(hw, PHY_REG(0, 21), &phy_reg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
		e1e_wphy(hw, PHY_REG(0, 21), phy_reg & ~(1 << 3));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
		/* Disable full chip energy detect */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
		e1e_rphy(hw, PHY_REG(776, 18), &phy_reg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
		e1e_wphy(hw, PHY_REG(776, 18), phy_reg | 1);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
		/* Enable loopback on the PHY */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
#define I82577_PHY_LBK_CTRL          19
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
		e1e_wphy(hw, I82577_PHY_LBK_CTRL, 0x8001);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
	default:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
	/* force 1000, set loopback */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
	e1e_wphy(hw, PHY_CONTROL, 0x4140);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
	mdelay(250);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
	/* Now set up the MAC to the same speed/duplex as the PHY. */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
	ctrl_reg = er32(CTRL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
	ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
	ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
		     E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
		     E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
		     E1000_CTRL_FD);	 /* Force Duplex to FULL */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
	if (adapter->flags & FLAG_IS_ICH)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
		ctrl_reg |= E1000_CTRL_SLU;	/* Set Link Up */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
	if (hw->phy.media_type == e1000_media_type_copper &&
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
	    hw->phy.type == e1000_phy_m88) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
		ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
	} else {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
		/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
		 * Set the ILOS bit on the fiber Nic if half duplex link is
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
		 * detected.
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
		 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
		if ((er32(STATUS) & E1000_STATUS_FD) == 0)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
			ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
	ew32(CTRL, ctrl_reg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
	/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
	 * Disable the receiver on the PHY so when a cable is plugged in, the
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
	 * PHY does not begin to autoneg when a cable is reconnected to the NIC.
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
	 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
	if (hw->phy.type == e1000_phy_m88)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
		e1000_phy_disable_receiver(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
	udelay(500);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
static int e1000_set_82571_fiber_loopback(struct e1000_adapter *adapter)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
	u32 ctrl = er32(CTRL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
	int link = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
	/* special requirements for 82571/82572 fiber adapters */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
	/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
	 * jump through hoops to make sure link is up because serdes
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
	 * link is hardwired up
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
	 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
	ctrl |= E1000_CTRL_SLU;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
	ew32(CTRL, ctrl);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
	/* disable autoneg */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
	ctrl = er32(TXCW);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
	ctrl &= ~(1 << 31);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
	ew32(TXCW, ctrl);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
	link = (er32(STATUS) & E1000_STATUS_LU);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
	if (!link) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
		/* set invert loss of signal */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
		ctrl = er32(CTRL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
		ctrl |= E1000_CTRL_ILOS;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
		ew32(CTRL, ctrl);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
	/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
	 * special write to serdes control register to enable SerDes analog
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
	 * loopback
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
	 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
#define E1000_SERDES_LB_ON 0x410
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
	ew32(SCTL, E1000_SERDES_LB_ON);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
	e1e_flush();
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
	usleep_range(10000, 20000);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
/* only call this for fiber/serdes connections to es2lan */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
static int e1000_set_es2lan_mac_loopback(struct e1000_adapter *adapter)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
	u32 ctrlext = er32(CTRL_EXT);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
	u32 ctrl = er32(CTRL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
	/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
	 * save CTRL_EXT to restore later, reuse an empty variable (unused
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
	 * on mac_type 80003es2lan)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
	 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
	adapter->tx_fifo_head = ctrlext;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
	/* clear the serdes mode bits, putting the device into mac loopback */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
	ctrlext &= ~E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
	ew32(CTRL_EXT, ctrlext);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
	/* force speed to 1000/FD, link up */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
	ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
	ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
		 E1000_CTRL_SPD_1000 | E1000_CTRL_FD);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
	ew32(CTRL, ctrl);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
	/* set mac loopback */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
	ctrl = er32(RCTL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
	ctrl |= E1000_RCTL_LBM_MAC;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
	ew32(RCTL, ctrl);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
	/* set testing mode parameters (no need to reset later) */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
#define KMRNCTRLSTA_OPMODE (0x1F << 16)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
#define KMRNCTRLSTA_OPMODE_1GB_FD_GMII 0x0582
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
	ew32(KMRNCTRLSTA,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
	     (KMRNCTRLSTA_OPMODE | KMRNCTRLSTA_OPMODE_1GB_FD_GMII));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
static int e1000_setup_loopback_test(struct e1000_adapter *adapter)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
	u32 rctl;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
	if (hw->phy.media_type == e1000_media_type_fiber ||
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
	    hw->phy.media_type == e1000_media_type_internal_serdes) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
		switch (hw->mac.type) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
		case e1000_80003es2lan:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
			return e1000_set_es2lan_mac_loopback(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
			break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
		case e1000_82571:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
		case e1000_82572:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
			return e1000_set_82571_fiber_loopback(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
			break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
		default:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
			rctl = er32(RCTL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
			rctl |= E1000_RCTL_LBM_TCVR;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
			ew32(RCTL, rctl);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
			return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
	} else if (hw->phy.media_type == e1000_media_type_copper) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
		return e1000_integrated_phy_loopback(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
	return 7;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
static void e1000_loopback_cleanup(struct e1000_adapter *adapter)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
	u32 rctl;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
	u16 phy_reg;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
	rctl = er32(RCTL);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
	rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
	ew32(RCTL, rctl);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
	switch (hw->mac.type) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
	case e1000_80003es2lan:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
		if (hw->phy.media_type == e1000_media_type_fiber ||
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
		    hw->phy.media_type == e1000_media_type_internal_serdes) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
			/* restore CTRL_EXT, stealing space from tx_fifo_head */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
			ew32(CTRL_EXT, adapter->tx_fifo_head);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
			adapter->tx_fifo_head = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
		/* fall through */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
	case e1000_82571:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
	case e1000_82572:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
		if (hw->phy.media_type == e1000_media_type_fiber ||
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
		    hw->phy.media_type == e1000_media_type_internal_serdes) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
#define E1000_SERDES_LB_OFF 0x400
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
			ew32(SCTL, E1000_SERDES_LB_OFF);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
			e1e_flush();
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
			usleep_range(10000, 20000);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
			break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
		/* Fall Through */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
	default:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
		hw->mac.autoneg = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
		if (hw->phy.type == e1000_phy_gg82563)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
			e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x180);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
		e1e_rphy(hw, PHY_CONTROL, &phy_reg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
		if (phy_reg & MII_CR_LOOPBACK) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
			phy_reg &= ~MII_CR_LOOPBACK;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
			e1e_wphy(hw, PHY_CONTROL, phy_reg);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
			e1000e_commit_phy(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
static void e1000_create_lbtest_frame(struct sk_buff *skb,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
				      unsigned int frame_size)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
	memset(skb->data, 0xFF, frame_size);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
	frame_size &= ~1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
	memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
	memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
	memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
static int e1000_check_lbtest_frame(struct sk_buff *skb,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
				    unsigned int frame_size)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
	frame_size &= ~1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
	if (*(skb->data + 3) == 0xFF)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
		if ((*(skb->data + frame_size / 2 + 10) == 0xBE) &&
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
		   (*(skb->data + frame_size / 2 + 12) == 0xAF))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
			return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
	return 13;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
static int e1000_run_loopback_test(struct e1000_adapter *adapter)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
	struct e1000_ring *tx_ring = &adapter->test_tx_ring;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
	struct e1000_ring *rx_ring = &adapter->test_rx_ring;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
	struct pci_dev *pdev = adapter->pdev;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
	int i, j, k, l;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
	int lc;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
	int good_cnt;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
	int ret_val = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
	unsigned long time;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
	ew32(RDT, rx_ring->count - 1);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
	/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
	 * Calculate the loop count based on the largest descriptor ring
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
	 * The idea is to wrap the largest ring a number of times using 64
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
	 * send/receive pairs during each loop
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
	 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
	if (rx_ring->count <= tx_ring->count)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
		lc = ((tx_ring->count / 64) * 2) + 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
	else
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
		lc = ((rx_ring->count / 64) * 2) + 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
	k = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
	l = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
	for (j = 0; j <= lc; j++) { /* loop count loop */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
		for (i = 0; i < 64; i++) { /* send the packets */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
			e1000_create_lbtest_frame(tx_ring->buffer_info[k].skb,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
						  1024);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
			dma_sync_single_for_device(&pdev->dev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
					tx_ring->buffer_info[k].dma,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
					tx_ring->buffer_info[k].length,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
					DMA_TO_DEVICE);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
			k++;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
			if (k == tx_ring->count)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
				k = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
		ew32(TDT, k);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
		e1e_flush();
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
		msleep(200);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
		time = jiffies; /* set the start time for the receive */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
		good_cnt = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
		do { /* receive the sent packets */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
			dma_sync_single_for_cpu(&pdev->dev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
					rx_ring->buffer_info[l].dma, 2048,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
					DMA_FROM_DEVICE);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
			ret_val = e1000_check_lbtest_frame(
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
					rx_ring->buffer_info[l].skb, 1024);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
			if (!ret_val)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
				good_cnt++;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
			l++;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
			if (l == rx_ring->count)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
				l = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
			/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
			 * time + 20 msecs (200 msecs on 2.4) is more than
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
			 * enough time to complete the receives, if it's
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
			 * exceeded, break and error off
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
			 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
		} while ((good_cnt < 64) && !time_after(jiffies, time + 20));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
		if (good_cnt != 64) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
			ret_val = 13; /* ret_val is the same as mis-compare */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
			break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
		if (jiffies >= (time + 20)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
			ret_val = 14; /* error code for time out error */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
			break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
	} /* end loop count loop */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
	return ret_val;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
static int e1000_loopback_test(struct e1000_adapter *adapter, u64 *data)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
	/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
	 * PHY loopback cannot be performed if SoL/IDER
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
	 * sessions are active
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
	 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
	if (hw->phy.ops.check_reset_block &&
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
	    hw->phy.ops.check_reset_block(hw)) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
		e_err("Cannot do PHY loopback test when SoL/IDER is active.\n");
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
		*data = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
		goto out;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
	*data = e1000_setup_desc_rings(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
	if (*data)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
		goto out;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
	*data = e1000_setup_loopback_test(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
	if (*data)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
		goto err_loopback;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
	*data = e1000_run_loopback_test(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
	e1000_loopback_cleanup(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
err_loopback:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
	e1000_free_desc_rings(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
out:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
	return *data;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
static int e1000_link_test(struct e1000_adapter *adapter, u64 *data)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
	*data = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
	if (hw->phy.media_type == e1000_media_type_internal_serdes) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
		int i = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
		hw->mac.serdes_has_link = false;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
		/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
		 * On some blade server designs, link establishment
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
		 * could take as long as 2-3 minutes
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
		 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
		do {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
			hw->mac.ops.check_for_link(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
			if (hw->mac.serdes_has_link)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
				return *data;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
			msleep(20);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
		} while (i++ < 3750);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
		*data = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
	} else {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
		hw->mac.ops.check_for_link(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
		if (hw->mac.autoneg)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
			/*
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
			 * On some Phy/switch combinations, link establishment
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
			 * can take a few seconds more than expected.
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
			 */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
			msleep(5000);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
		if (!(er32(STATUS) & E1000_STATUS_LU))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
			*data = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
	return *data;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
static int e1000e_get_sset_count(struct net_device *netdev, int sset)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
	switch (sset) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
	case ETH_SS_TEST:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
		return E1000_TEST_LEN;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
	case ETH_SS_STATS:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1674
		return E1000_STATS_LEN;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1675
	default:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
		return -EOPNOTSUPP;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1677
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
static void e1000_diag_test(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
			    struct ethtool_test *eth_test, u64 *data)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
	u16 autoneg_advertised;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
	u8 forced_speed_duplex;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
	u8 autoneg;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
	bool if_running = netif_running(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
	set_bit(__E1000_TESTING, &adapter->state);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
	if (!if_running) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
		/* Get control of and reset hardware */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
		if (adapter->flags & FLAG_HAS_AMT)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
			e1000e_get_hw_control(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
		e1000e_power_up_phy(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
		adapter->hw.phy.autoneg_wait_to_complete = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
		e1000e_reset(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
		adapter->hw.phy.autoneg_wait_to_complete = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
	if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
		/* Offline tests */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
		/* save speed, duplex, autoneg settings */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
		autoneg_advertised = adapter->hw.phy.autoneg_advertised;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
		forced_speed_duplex = adapter->hw.mac.forced_speed_duplex;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
		autoneg = adapter->hw.mac.autoneg;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
		e_info("offline testing starting\n");
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
		if (if_running)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
			/* indicate we're in test mode */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
			dev_close(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
		if (e1000_reg_test(adapter, &data[0]))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
			eth_test->flags |= ETH_TEST_FL_FAILED;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
		e1000e_reset(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
		if (e1000_eeprom_test(adapter, &data[1]))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
			eth_test->flags |= ETH_TEST_FL_FAILED;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
		e1000e_reset(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
		if (e1000_intr_test(adapter, &data[2]))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
			eth_test->flags |= ETH_TEST_FL_FAILED;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
		e1000e_reset(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1729
		if (e1000_loopback_test(adapter, &data[3]))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
			eth_test->flags |= ETH_TEST_FL_FAILED;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
		/* force this routine to wait until autoneg complete/timeout */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
		adapter->hw.phy.autoneg_wait_to_complete = 1;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
		e1000e_reset(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
		adapter->hw.phy.autoneg_wait_to_complete = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
		if (e1000_link_test(adapter, &data[4]))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
			eth_test->flags |= ETH_TEST_FL_FAILED;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
		/* restore speed, duplex, autoneg settings */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
		adapter->hw.phy.autoneg_advertised = autoneg_advertised;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
		adapter->hw.mac.forced_speed_duplex = forced_speed_duplex;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
		adapter->hw.mac.autoneg = autoneg;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
		e1000e_reset(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
		clear_bit(__E1000_TESTING, &adapter->state);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
		if (if_running)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
			dev_open(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
	} else {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
		/* Online tests */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
		e_info("online testing starting\n");
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
		/* register, eeprom, intr and loopback tests not run online */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
		data[0] = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
		data[1] = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
		data[2] = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
		data[3] = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
		if (e1000_link_test(adapter, &data[4]))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
			eth_test->flags |= ETH_TEST_FL_FAILED;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
		clear_bit(__E1000_TESTING, &adapter->state);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
	if (!if_running) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
		e1000e_reset(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
		if (adapter->flags & FLAG_HAS_AMT)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
			e1000e_release_hw_control(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
	msleep_interruptible(4 * 1000);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
static void e1000_get_wol(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
			  struct ethtool_wolinfo *wol)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
	wol->supported = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
	wol->wolopts = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
	if (!(adapter->flags & FLAG_HAS_WOL) ||
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
	    !device_can_wakeup(&adapter->pdev->dev))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
		return;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
	wol->supported = WAKE_UCAST | WAKE_MCAST |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
	    WAKE_BCAST | WAKE_MAGIC | WAKE_PHY;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
	/* apply any specific unsupported masks here */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
	if (adapter->flags & FLAG_NO_WAKE_UCAST) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
		wol->supported &= ~WAKE_UCAST;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
		if (adapter->wol & E1000_WUFC_EX)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
			e_err("Interface does not support directed (unicast) "
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
			      "frame wake-up packets\n");
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
	if (adapter->wol & E1000_WUFC_EX)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
		wol->wolopts |= WAKE_UCAST;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
	if (adapter->wol & E1000_WUFC_MC)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
		wol->wolopts |= WAKE_MCAST;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
	if (adapter->wol & E1000_WUFC_BC)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
		wol->wolopts |= WAKE_BCAST;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
	if (adapter->wol & E1000_WUFC_MAG)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
		wol->wolopts |= WAKE_MAGIC;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
	if (adapter->wol & E1000_WUFC_LNKC)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
		wol->wolopts |= WAKE_PHY;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
static int e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
	if (!(adapter->flags & FLAG_HAS_WOL) ||
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
	    !device_can_wakeup(&adapter->pdev->dev) ||
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
	    (wol->wolopts & ~(WAKE_UCAST | WAKE_MCAST | WAKE_BCAST |
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
			      WAKE_MAGIC | WAKE_PHY)))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
		return -EOPNOTSUPP;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
	/* these settings will always override what we currently have */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
	adapter->wol = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
	if (wol->wolopts & WAKE_UCAST)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
		adapter->wol |= E1000_WUFC_EX;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
	if (wol->wolopts & WAKE_MCAST)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
		adapter->wol |= E1000_WUFC_MC;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
	if (wol->wolopts & WAKE_BCAST)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
		adapter->wol |= E1000_WUFC_BC;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
	if (wol->wolopts & WAKE_MAGIC)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
		adapter->wol |= E1000_WUFC_MAG;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
	if (wol->wolopts & WAKE_PHY)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
		adapter->wol |= E1000_WUFC_LNKC;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
	device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
static int e1000_set_phys_id(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
			     enum ethtool_phys_id_state state)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
	switch (state) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
	case ETHTOOL_ID_ACTIVE:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
		if (!hw->mac.ops.blink_led)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
			return 2;	/* cycle on/off twice per second */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
		hw->mac.ops.blink_led(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
	case ETHTOOL_ID_INACTIVE:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
		if (hw->phy.type == e1000_phy_ife)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
			e1e_wphy(hw, IFE_PHY_SPECIAL_CONTROL_LED, 0);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
		hw->mac.ops.led_off(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
		hw->mac.ops.cleanup_led(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
	case ETHTOOL_ID_ON:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
		hw->mac.ops.led_on(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
	case ETHTOOL_ID_OFF:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
		hw->mac.ops.led_off(hw);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
static int e1000_get_coalesce(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
			      struct ethtool_coalesce *ec)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
	if (adapter->itr_setting <= 4)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
		ec->rx_coalesce_usecs = adapter->itr_setting;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
	else
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
		ec->rx_coalesce_usecs = 1000000 / adapter->itr_setting;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1882
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
static int e1000_set_coalesce(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
			      struct ethtool_coalesce *ec)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
	struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
	if ((ec->rx_coalesce_usecs > E1000_MAX_ITR_USECS) ||
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
	    ((ec->rx_coalesce_usecs > 4) &&
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
	     (ec->rx_coalesce_usecs < E1000_MIN_ITR_USECS)) ||
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
	    (ec->rx_coalesce_usecs == 2))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
		return -EINVAL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
	if (ec->rx_coalesce_usecs == 4) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
		adapter->itr = adapter->itr_setting = 4;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
	} else if (ec->rx_coalesce_usecs <= 3) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
		adapter->itr = 20000;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
		adapter->itr_setting = ec->rx_coalesce_usecs;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
	} else {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
		adapter->itr = (1000000 / ec->rx_coalesce_usecs);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
		adapter->itr_setting = adapter->itr & ~3;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
	if (adapter->itr_setting != 0)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
		ew32(ITR, 1000000000 / (adapter->itr * 256));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
	else
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
		ew32(ITR, 0);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
static int e1000_nway_reset(struct net_device *netdev)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
	if (!netif_running(netdev))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
		return -EAGAIN;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
	if (!adapter->hw.mac.autoneg)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
		return -EINVAL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
	e1000e_reinit_locked(adapter);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
	return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
static void e1000_get_ethtool_stats(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
				    struct ethtool_stats *stats,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
				    u64 *data)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
	struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
	struct rtnl_link_stats64 net_stats;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
	int i;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
	char *p = NULL;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
	e1000e_get_stats64(netdev, &net_stats);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
	for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
		switch (e1000_gstrings_stats[i].type) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
		case NETDEV_STATS:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
			p = (char *) &net_stats +
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
					e1000_gstrings_stats[i].stat_offset;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
			break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
		case E1000_STATS:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
			p = (char *) adapter +
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
					e1000_gstrings_stats[i].stat_offset;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
			break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
		default:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
			data[i] = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
			continue;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
		data[i] = (e1000_gstrings_stats[i].sizeof_stat ==
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
			sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
static void e1000_get_strings(struct net_device *netdev, u32 stringset,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
			      u8 *data)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
	u8 *p = data;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
	int i;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
	switch (stringset) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
	case ETH_SS_TEST:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
		memcpy(data, e1000_gstrings_test, sizeof(e1000_gstrings_test));
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
	case ETH_SS_STATS:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
		for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
			memcpy(p, e1000_gstrings_stats[i].stat_string,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
			       ETH_GSTRING_LEN);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
			p += ETH_GSTRING_LEN;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
		break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
static int e1000_get_rxnfc(struct net_device *netdev,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
			   struct ethtool_rxnfc *info, u32 *rule_locs)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
	info->data = 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
	switch (info->cmd) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
	case ETHTOOL_GRXFH: {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
		struct e1000_adapter *adapter = netdev_priv(netdev);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
		struct e1000_hw *hw = &adapter->hw;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
		u32 mrqc = er32(MRQC);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1991
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
		if (!(mrqc & E1000_MRQC_RSS_FIELD_MASK))
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1993
			return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
		switch (info->flow_type) {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
		case TCP_V4_FLOW:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
			if (mrqc & E1000_MRQC_RSS_FIELD_IPV4_TCP)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
				info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
			/* fall through */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
		case UDP_V4_FLOW:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
		case SCTP_V4_FLOW:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
		case AH_ESP_V4_FLOW:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
		case IPV4_FLOW:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
			if (mrqc & E1000_MRQC_RSS_FIELD_IPV4)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
				info->data |= RXH_IP_SRC | RXH_IP_DST;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
			break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
		case TCP_V6_FLOW:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
			if (mrqc & E1000_MRQC_RSS_FIELD_IPV6_TCP)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
				info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
			/* fall through */
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
		case UDP_V6_FLOW:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
		case SCTP_V6_FLOW:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
		case AH_ESP_V6_FLOW:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
		case IPV6_FLOW:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2015
			if (mrqc & E1000_MRQC_RSS_FIELD_IPV6)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
				info->data |= RXH_IP_SRC | RXH_IP_DST;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
			break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
		default:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
			break;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
		}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
		return 0;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
	default:
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
		return -EOPNOTSUPP;
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
	}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
}
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
static const struct ethtool_ops e1000_ethtool_ops = {
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
	.get_settings		= e1000_get_settings,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
	.set_settings		= e1000_set_settings,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
	.get_drvinfo		= e1000_get_drvinfo,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
	.get_regs_len		= e1000_get_regs_len,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
	.get_regs		= e1000_get_regs,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
	.get_wol		= e1000_get_wol,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
	.set_wol		= e1000_set_wol,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
	.get_msglevel		= e1000_get_msglevel,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
	.set_msglevel		= e1000_set_msglevel,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
	.nway_reset		= e1000_nway_reset,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
	.get_link		= ethtool_op_get_link,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
	.get_eeprom_len		= e1000_get_eeprom_len,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
	.get_eeprom		= e1000_get_eeprom,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
	.set_eeprom		= e1000_set_eeprom,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
	.get_ringparam		= e1000_get_ringparam,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
	.set_ringparam		= e1000_set_ringparam,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
	.get_pauseparam		= e1000_get_pauseparam,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
	.set_pauseparam		= e1000_set_pauseparam,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
	.self_test		= e1000_diag_test,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
	.get_strings		= e1000_get_strings,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
	.set_phys_id		= e1000_set_phys_id,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
	.get_ethtool_stats	= e1000_get_ethtool_stats,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
	.get_sset_count		= e1000e_get_sset_count,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
	.get_coalesce		= e1000_get_coalesce,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
	.set_coalesce		= e1000_set_coalesce,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
	.get_rxnfc		= e1000_get_rxnfc,
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
};
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
void e1000e_set_ethtool_ops(struct net_device *netdev)
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
{
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
	SET_ETHTOOL_OPS(netdev, &e1000_ethtool_ops);
5e9221a78855 Added e1000e driver for kernel 3.4.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
}