devices/e1000/e1000_ethtool-2.6.20-orig.c
author Florian Pose <fp@igh-essen.com>
Tue, 05 Feb 2013 16:45:34 +0100
branchstable-1.5
changeset 2505 5ef3197e5e1f
parent 680 48c2dbc12bde
permissions -rw-r--r--
Added ecrt_slave_config_reg_so_entry_pos() to register non-unique entries.
680
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*******************************************************************************
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
  Intel PRO/1000 Linux driver
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
  Copyright(c) 1999 - 2006 Intel Corporation.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
  This program is free software; you can redistribute it and/or modify it
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
  under the terms and conditions of the GNU General Public License,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
  version 2, as published by the Free Software Foundation.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
  This program is distributed in the hope it will be useful, but WITHOUT
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
  more details.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
  You should have received a copy of the GNU General Public License along with
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
  this program; if not, write to the Free Software Foundation, Inc.,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
  The full GNU General Public License is included in this distribution in
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
  the file called "COPYING".
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
  Contact Information:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  Linux NICS <linux.nics@intel.com>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
*******************************************************************************/
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
/* ethtool support for e1000 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#include "e1000.h"
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
#include <asm/uaccess.h>
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
extern char e1000_driver_name[];
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
extern char e1000_driver_version[];
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
extern int e1000_up(struct e1000_adapter *adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
extern void e1000_down(struct e1000_adapter *adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
extern void e1000_reinit_locked(struct e1000_adapter *adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
extern void e1000_reset(struct e1000_adapter *adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
extern int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
extern int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
extern int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
extern void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
extern void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
extern void e1000_update_stats(struct e1000_adapter *adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
struct e1000_stats {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
	char stat_string[ETH_GSTRING_LEN];
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
	int sizeof_stat;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
	int stat_offset;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
};
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
#define E1000_STAT(m) sizeof(((struct e1000_adapter *)0)->m), \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
		      offsetof(struct e1000_adapter, m)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
static const struct e1000_stats e1000_gstrings_stats[] = {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
	{ "rx_packets", E1000_STAT(stats.gprc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
	{ "tx_packets", E1000_STAT(stats.gptc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
	{ "rx_bytes", E1000_STAT(stats.gorcl) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
	{ "tx_bytes", E1000_STAT(stats.gotcl) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
	{ "rx_broadcast", E1000_STAT(stats.bprc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
	{ "tx_broadcast", E1000_STAT(stats.bptc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
	{ "rx_multicast", E1000_STAT(stats.mprc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
	{ "tx_multicast", E1000_STAT(stats.mptc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
	{ "rx_errors", E1000_STAT(stats.rxerrc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
	{ "tx_errors", E1000_STAT(stats.txerrc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
	{ "tx_dropped", E1000_STAT(net_stats.tx_dropped) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
	{ "multicast", E1000_STAT(stats.mprc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
	{ "collisions", E1000_STAT(stats.colc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
	{ "rx_length_errors", E1000_STAT(stats.rlerrc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
	{ "rx_over_errors", E1000_STAT(net_stats.rx_over_errors) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
	{ "rx_crc_errors", E1000_STAT(stats.crcerrs) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
	{ "rx_frame_errors", E1000_STAT(net_stats.rx_frame_errors) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
	{ "rx_no_buffer_count", E1000_STAT(stats.rnbc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
	{ "rx_missed_errors", E1000_STAT(stats.mpc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
	{ "tx_aborted_errors", E1000_STAT(stats.ecol) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
	{ "tx_carrier_errors", E1000_STAT(stats.tncrs) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
	{ "tx_fifo_errors", E1000_STAT(net_stats.tx_fifo_errors) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
	{ "tx_heartbeat_errors", E1000_STAT(net_stats.tx_heartbeat_errors) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
	{ "tx_window_errors", E1000_STAT(stats.latecol) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
	{ "tx_abort_late_coll", E1000_STAT(stats.latecol) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
	{ "tx_deferred_ok", E1000_STAT(stats.dc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
	{ "tx_single_coll_ok", E1000_STAT(stats.scc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
	{ "tx_multi_coll_ok", E1000_STAT(stats.mcc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
	{ "tx_timeout_count", E1000_STAT(tx_timeout_count) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
	{ "tx_restart_queue", E1000_STAT(restart_queue) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
	{ "rx_long_length_errors", E1000_STAT(stats.roc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
	{ "rx_short_length_errors", E1000_STAT(stats.ruc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
	{ "rx_align_errors", E1000_STAT(stats.algnerrc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
	{ "tx_tcp_seg_good", E1000_STAT(stats.tsctc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
	{ "tx_tcp_seg_failed", E1000_STAT(stats.tsctfc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
	{ "rx_flow_control_xon", E1000_STAT(stats.xonrxc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
	{ "rx_flow_control_xoff", E1000_STAT(stats.xoffrxc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
	{ "tx_flow_control_xon", E1000_STAT(stats.xontxc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
	{ "tx_flow_control_xoff", E1000_STAT(stats.xofftxc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
	{ "rx_long_byte_count", E1000_STAT(stats.gorcl) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
	{ "rx_csum_offload_good", E1000_STAT(hw_csum_good) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
	{ "rx_csum_offload_errors", E1000_STAT(hw_csum_err) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
	{ "rx_header_split", E1000_STAT(rx_hdr_split) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
	{ "alloc_rx_buff_failed", E1000_STAT(alloc_rx_buff_failed) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
	{ "tx_smbus", E1000_STAT(stats.mgptc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
	{ "rx_smbus", E1000_STAT(stats.mgprc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
	{ "dropped_smbus", E1000_STAT(stats.mgpdc) },
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
};
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
#define E1000_QUEUE_STATS_LEN 0
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
#define E1000_GLOBAL_STATS_LEN	\
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
	sizeof(e1000_gstrings_stats) / sizeof(struct e1000_stats)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
#define E1000_STATS_LEN (E1000_GLOBAL_STATS_LEN + E1000_QUEUE_STATS_LEN)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
	"Register test  (offline)", "Eeprom test    (offline)",
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
	"Interrupt test (offline)", "Loopback test  (offline)",
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
	"Link test   (on/offline)"
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
};
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
#define E1000_TEST_LEN sizeof(e1000_gstrings_test) / ETH_GSTRING_LEN
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
	struct e1000_hw *hw = &adapter->hw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
	if (hw->media_type == e1000_media_type_copper) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
		ecmd->supported = (SUPPORTED_10baseT_Half |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
		                   SUPPORTED_10baseT_Full |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
		                   SUPPORTED_100baseT_Half |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
		                   SUPPORTED_100baseT_Full |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
		                   SUPPORTED_1000baseT_Full|
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
		                   SUPPORTED_Autoneg |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
		                   SUPPORTED_TP);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
		if (hw->phy_type == e1000_phy_ife)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
			ecmd->supported &= ~SUPPORTED_1000baseT_Full;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
		ecmd->advertising = ADVERTISED_TP;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
		if (hw->autoneg == 1) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
			ecmd->advertising |= ADVERTISED_Autoneg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
			/* the e1000 autoneg seems to match ethtool nicely */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
			ecmd->advertising |= hw->autoneg_advertised;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
		ecmd->port = PORT_TP;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
		ecmd->phy_address = hw->phy_addr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
		if (hw->mac_type == e1000_82543)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
			ecmd->transceiver = XCVR_EXTERNAL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
		else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
			ecmd->transceiver = XCVR_INTERNAL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
	} else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
		ecmd->supported   = (SUPPORTED_1000baseT_Full |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
				     SUPPORTED_FIBRE |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
				     SUPPORTED_Autoneg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
		ecmd->advertising = (ADVERTISED_1000baseT_Full |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
				     ADVERTISED_FIBRE |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
				     ADVERTISED_Autoneg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
		ecmd->port = PORT_FIBRE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
		if (hw->mac_type >= e1000_82545)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
			ecmd->transceiver = XCVR_INTERNAL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
		else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
			ecmd->transceiver = XCVR_EXTERNAL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
	if (netif_carrier_ok(adapter->netdev)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
		e1000_get_speed_and_duplex(hw, &adapter->link_speed,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
		                                   &adapter->link_duplex);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
		ecmd->speed = adapter->link_speed;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
		/* unfortunatly FULL_DUPLEX != DUPLEX_FULL
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
		 *          and HALF_DUPLEX != DUPLEX_HALF */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
		if (adapter->link_duplex == FULL_DUPLEX)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
			ecmd->duplex = DUPLEX_FULL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
		else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
			ecmd->duplex = DUPLEX_HALF;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
	} else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
		ecmd->speed = -1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
		ecmd->duplex = -1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
	ecmd->autoneg = ((hw->media_type == e1000_media_type_fiber) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
			 hw->autoneg) ? AUTONEG_ENABLE : AUTONEG_DISABLE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
	return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
e1000_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
	struct e1000_hw *hw = &adapter->hw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
	/* When SoL/IDER sessions are active, autoneg/speed/duplex
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
	 * cannot be changed */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
	if (e1000_check_phy_reset_block(hw)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
		DPRINTK(DRV, ERR, "Cannot change link characteristics "
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
		        "when SoL/IDER is active.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
		return -EINVAL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
	while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
		msleep(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
	if (ecmd->autoneg == AUTONEG_ENABLE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
		hw->autoneg = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
		if (hw->media_type == e1000_media_type_fiber)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
			hw->autoneg_advertised = ADVERTISED_1000baseT_Full |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
				     ADVERTISED_FIBRE |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
				     ADVERTISED_Autoneg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
		else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
			hw->autoneg_advertised = ecmd->advertising |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
			                         ADVERTISED_TP |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
			                         ADVERTISED_Autoneg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
		ecmd->advertising = hw->autoneg_advertised;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
	} else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
		if (e1000_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
			clear_bit(__E1000_RESETTING, &adapter->flags);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
			return -EINVAL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
	/* reset the link */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
	if (netif_running(adapter->netdev)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
		e1000_down(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
		e1000_up(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
	} else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
		e1000_reset(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
	clear_bit(__E1000_RESETTING, &adapter->flags);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
	return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
e1000_get_pauseparam(struct net_device *netdev,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
                     struct ethtool_pauseparam *pause)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
	struct e1000_hw *hw = &adapter->hw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
	pause->autoneg =
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
		(adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
	if (hw->fc == E1000_FC_RX_PAUSE)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
		pause->rx_pause = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
	else if (hw->fc == E1000_FC_TX_PAUSE)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
		pause->tx_pause = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
	else if (hw->fc == E1000_FC_FULL) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
		pause->rx_pause = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
		pause->tx_pause = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
e1000_set_pauseparam(struct net_device *netdev,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
                     struct ethtool_pauseparam *pause)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
	struct e1000_hw *hw = &adapter->hw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
	int retval = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
	adapter->fc_autoneg = pause->autoneg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
	while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
		msleep(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
	if (pause->rx_pause && pause->tx_pause)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
		hw->fc = E1000_FC_FULL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
	else if (pause->rx_pause && !pause->tx_pause)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
		hw->fc = E1000_FC_RX_PAUSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
	else if (!pause->rx_pause && pause->tx_pause)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
		hw->fc = E1000_FC_TX_PAUSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
	else if (!pause->rx_pause && !pause->tx_pause)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
		hw->fc = E1000_FC_NONE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
	hw->original_fc = hw->fc;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
	if (adapter->fc_autoneg == AUTONEG_ENABLE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
		if (netif_running(adapter->netdev)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
			e1000_down(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
			e1000_up(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
		} else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
			e1000_reset(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
	} else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
		retval = ((hw->media_type == e1000_media_type_fiber) ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
			  e1000_setup_link(hw) : e1000_force_mac_fc(hw));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
	clear_bit(__E1000_RESETTING, &adapter->flags);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
	return retval;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
static uint32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
e1000_get_rx_csum(struct net_device *netdev)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
	return adapter->rx_csum;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
e1000_set_rx_csum(struct net_device *netdev, uint32_t data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
	adapter->rx_csum = data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
	if (netif_running(netdev))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
		e1000_reinit_locked(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
	else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
		e1000_reset(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
	return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
static uint32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
e1000_get_tx_csum(struct net_device *netdev)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
	return (netdev->features & NETIF_F_HW_CSUM) != 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
e1000_set_tx_csum(struct net_device *netdev, uint32_t data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
	if (adapter->hw.mac_type < e1000_82543) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
		if (!data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
			return -EINVAL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
		return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
	if (data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
		netdev->features |= NETIF_F_HW_CSUM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
	else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
		netdev->features &= ~NETIF_F_HW_CSUM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
	return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
#ifdef NETIF_F_TSO
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
e1000_set_tso(struct net_device *netdev, uint32_t data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
	if ((adapter->hw.mac_type < e1000_82544) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
	    (adapter->hw.mac_type == e1000_82547))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
		return data ? -EINVAL : 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
	if (data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
		netdev->features |= NETIF_F_TSO;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
	else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
		netdev->features &= ~NETIF_F_TSO;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
#ifdef NETIF_F_TSO6
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
	if (data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
		netdev->features |= NETIF_F_TSO6;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
	else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
		netdev->features &= ~NETIF_F_TSO6;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
#endif
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
	DPRINTK(PROBE, INFO, "TSO is %s\n", data ? "Enabled" : "Disabled");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
	adapter->tso_force = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
	return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
#endif /* NETIF_F_TSO */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
static uint32_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
e1000_get_msglevel(struct net_device *netdev)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
	return adapter->msg_enable;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
e1000_set_msglevel(struct net_device *netdev, uint32_t data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
	adapter->msg_enable = data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
e1000_get_regs_len(struct net_device *netdev)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
#define E1000_REGS_LEN 32
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
	return E1000_REGS_LEN * sizeof(uint32_t);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
e1000_get_regs(struct net_device *netdev,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
	       struct ethtool_regs *regs, void *p)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
	struct e1000_hw *hw = &adapter->hw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
	uint32_t *regs_buff = p;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
	uint16_t phy_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
	memset(p, 0, E1000_REGS_LEN * sizeof(uint32_t));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
	regs->version = (1 << 24) | (hw->revision_id << 16) | hw->device_id;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
	regs_buff[0]  = E1000_READ_REG(hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
	regs_buff[1]  = E1000_READ_REG(hw, STATUS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
	regs_buff[2]  = E1000_READ_REG(hw, RCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
	regs_buff[3]  = E1000_READ_REG(hw, RDLEN);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
	regs_buff[4]  = E1000_READ_REG(hw, RDH);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
	regs_buff[5]  = E1000_READ_REG(hw, RDT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   409
	regs_buff[6]  = E1000_READ_REG(hw, RDTR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
	regs_buff[7]  = E1000_READ_REG(hw, TCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
	regs_buff[8]  = E1000_READ_REG(hw, TDLEN);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
	regs_buff[9]  = E1000_READ_REG(hw, TDH);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
	regs_buff[10] = E1000_READ_REG(hw, TDT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
	regs_buff[11] = E1000_READ_REG(hw, TIDV);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
	regs_buff[12] = adapter->hw.phy_type;  /* PHY type (IGP=1, M88=0) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
	if (hw->phy_type == e1000_phy_igp) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
		e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
				    IGP01E1000_PHY_AGC_A);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
		e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_A &
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
				   IGP01E1000_PHY_PAGE_SELECT, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
		regs_buff[13] = (uint32_t)phy_data; /* cable length */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
		e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
				    IGP01E1000_PHY_AGC_B);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
		e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_B &
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
				   IGP01E1000_PHY_PAGE_SELECT, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
		regs_buff[14] = (uint32_t)phy_data; /* cable length */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
		e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
				    IGP01E1000_PHY_AGC_C);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
		e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_C &
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
				   IGP01E1000_PHY_PAGE_SELECT, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
		regs_buff[15] = (uint32_t)phy_data; /* cable length */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
		e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
				    IGP01E1000_PHY_AGC_D);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
		e1000_read_phy_reg(hw, IGP01E1000_PHY_AGC_D &
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
				   IGP01E1000_PHY_PAGE_SELECT, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
		regs_buff[16] = (uint32_t)phy_data; /* cable length */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
		regs_buff[17] = 0; /* extended 10bt distance (not needed) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
		e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
		e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_STATUS &
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
				   IGP01E1000_PHY_PAGE_SELECT, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
		regs_buff[18] = (uint32_t)phy_data; /* cable polarity */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
		e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
				    IGP01E1000_PHY_PCS_INIT_REG);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
		e1000_read_phy_reg(hw, IGP01E1000_PHY_PCS_INIT_REG &
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
				   IGP01E1000_PHY_PAGE_SELECT, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
		regs_buff[19] = (uint32_t)phy_data; /* cable polarity */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
		regs_buff[20] = 0; /* polarity correction enabled (always) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
		regs_buff[22] = 0; /* phy receive errors (unavailable) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
		regs_buff[23] = regs_buff[18]; /* mdix mode */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
		e1000_write_phy_reg(hw, IGP01E1000_PHY_PAGE_SELECT, 0x0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
	} else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
		e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
		regs_buff[13] = (uint32_t)phy_data; /* cable length */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
		regs_buff[14] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
		regs_buff[15] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
		regs_buff[16] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
		e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
		regs_buff[17] = (uint32_t)phy_data; /* extended 10bt distance */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
		regs_buff[18] = regs_buff[13]; /* cable polarity */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
		regs_buff[19] = 0;  /* Dummy (to align w/ IGP phy reg dump) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
		regs_buff[20] = regs_buff[17]; /* polarity correction */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
		/* phy receive errors */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
		regs_buff[22] = adapter->phy_stats.receive_errors;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
		regs_buff[23] = regs_buff[13]; /* mdix mode */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
	regs_buff[21] = adapter->phy_stats.idle_errors;  /* phy idle errors */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
	e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
	regs_buff[24] = (uint32_t)phy_data;  /* phy local receiver status */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
	regs_buff[25] = regs_buff[24];  /* phy remote receiver status */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
	if (hw->mac_type >= e1000_82540 &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
	    hw->mac_type < e1000_82571 &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
	    hw->media_type == e1000_media_type_copper) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
		regs_buff[26] = E1000_READ_REG(hw, MANC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   479
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   480
e1000_get_eeprom_len(struct net_device *netdev)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   483
	return adapter->hw.eeprom.word_size * 2;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
e1000_get_eeprom(struct net_device *netdev,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
                      struct ethtool_eeprom *eeprom, uint8_t *bytes)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
	struct e1000_hw *hw = &adapter->hw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
	uint16_t *eeprom_buff;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
	int first_word, last_word;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
	int ret_val = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
	uint16_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
	if (eeprom->len == 0)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
		return -EINVAL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
	eeprom->magic = hw->vendor_id | (hw->device_id << 16);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
	first_word = eeprom->offset >> 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
	last_word = (eeprom->offset + eeprom->len - 1) >> 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
	eeprom_buff = kmalloc(sizeof(uint16_t) *
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
			(last_word - first_word + 1), GFP_KERNEL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
	if (!eeprom_buff)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
		return -ENOMEM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
	if (hw->eeprom.type == e1000_eeprom_spi)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
		ret_val = e1000_read_eeprom(hw, first_word,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
					    last_word - first_word + 1,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
					    eeprom_buff);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
	else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
		for (i = 0; i < last_word - first_word + 1; i++)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
			if ((ret_val = e1000_read_eeprom(hw, first_word + i, 1,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
							&eeprom_buff[i])))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
				break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
	/* Device's eeprom is always little-endian, word addressable */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
	for (i = 0; i < last_word - first_word + 1; i++)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
		le16_to_cpus(&eeprom_buff[i]);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
	memcpy(bytes, (uint8_t *)eeprom_buff + (eeprom->offset & 1),
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
			eeprom->len);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
	kfree(eeprom_buff);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
	return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
e1000_set_eeprom(struct net_device *netdev,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
                      struct ethtool_eeprom *eeprom, uint8_t *bytes)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
	struct e1000_hw *hw = &adapter->hw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   538
	uint16_t *eeprom_buff;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
	void *ptr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
	int max_len, first_word, last_word, ret_val = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
	uint16_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
	if (eeprom->len == 0)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
		return -EOPNOTSUPP;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
	if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16)))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
		return -EFAULT;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
	max_len = hw->eeprom.word_size * 2;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
	first_word = eeprom->offset >> 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
	last_word = (eeprom->offset + eeprom->len - 1) >> 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
	eeprom_buff = kmalloc(max_len, GFP_KERNEL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
	if (!eeprom_buff)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
		return -ENOMEM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
	ptr = (void *)eeprom_buff;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
	if (eeprom->offset & 1) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
		/* need read/modify/write of first changed EEPROM word */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
		/* only the second byte of the word is being modified */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
		ret_val = e1000_read_eeprom(hw, first_word, 1,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
					    &eeprom_buff[0]);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
		ptr++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
	if (((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
		/* need read/modify/write of last changed EEPROM word */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
		/* only the first byte of the word is being modified */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
		ret_val = e1000_read_eeprom(hw, last_word, 1,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
		                  &eeprom_buff[last_word - first_word]);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
	/* Device's eeprom is always little-endian, word addressable */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
	for (i = 0; i < last_word - first_word + 1; i++)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
		le16_to_cpus(&eeprom_buff[i]);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
	memcpy(ptr, bytes, eeprom->len);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
	for (i = 0; i < last_word - first_word + 1; i++)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
		eeprom_buff[i] = cpu_to_le16(eeprom_buff[i]);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
	ret_val = e1000_write_eeprom(hw, first_word,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
				     last_word - first_word + 1, eeprom_buff);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
	/* Update the checksum over the first part of the EEPROM if needed
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
	 * and flush shadow RAM for 82573 conrollers */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
	if ((ret_val == 0) && ((first_word <= EEPROM_CHECKSUM_REG) ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
				(hw->mac_type == e1000_82573)))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
		e1000_update_eeprom_checksum(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
	kfree(eeprom_buff);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
	return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
e1000_get_drvinfo(struct net_device *netdev,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
                       struct ethtool_drvinfo *drvinfo)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
	char firmware_version[32];
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
	uint16_t eeprom_data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
	strncpy(drvinfo->driver,  e1000_driver_name, 32);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
	strncpy(drvinfo->version, e1000_driver_version, 32);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
	/* EEPROM image version # is reported as firmware version # for
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
	 * 8257{1|2|3} controllers */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
	e1000_read_eeprom(&adapter->hw, 5, 1, &eeprom_data);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
	switch (adapter->hw.mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
	case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
	case e1000_82572:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
	case e1000_82573:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
	case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
	case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
		sprintf(firmware_version, "%d.%d-%d",
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
			(eeprom_data & 0xF000) >> 12,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
			(eeprom_data & 0x0FF0) >> 4,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
			eeprom_data & 0x000F);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
	default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
		sprintf(firmware_version, "N/A");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
	strncpy(drvinfo->fw_version, firmware_version, 32);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
	strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
	drvinfo->n_stats = E1000_STATS_LEN;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
	drvinfo->testinfo_len = E1000_TEST_LEN;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
	drvinfo->regdump_len = e1000_get_regs_len(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
	drvinfo->eedump_len = e1000_get_eeprom_len(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
e1000_get_ringparam(struct net_device *netdev,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
                    struct ethtool_ringparam *ring)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
	e1000_mac_type mac_type = adapter->hw.mac_type;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
	struct e1000_tx_ring *txdr = adapter->tx_ring;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
	struct e1000_rx_ring *rxdr = adapter->rx_ring;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
	ring->rx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_RXD :
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
		E1000_MAX_82544_RXD;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
	ring->tx_max_pending = (mac_type < e1000_82544) ? E1000_MAX_TXD :
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
		E1000_MAX_82544_TXD;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
	ring->rx_mini_max_pending = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
	ring->rx_jumbo_max_pending = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
	ring->rx_pending = rxdr->count;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
	ring->tx_pending = txdr->count;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
	ring->rx_mini_pending = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
	ring->rx_jumbo_pending = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
e1000_set_ringparam(struct net_device *netdev,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
                    struct ethtool_ringparam *ring)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
	e1000_mac_type mac_type = adapter->hw.mac_type;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
	struct e1000_tx_ring *txdr, *tx_old;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
	struct e1000_rx_ring *rxdr, *rx_old;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
	int i, err, tx_ring_size, rx_ring_size;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
	if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
		return -EINVAL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
	tx_ring_size = sizeof(struct e1000_tx_ring) * adapter->num_tx_queues;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
	rx_ring_size = sizeof(struct e1000_rx_ring) * adapter->num_rx_queues;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
	while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
		msleep(1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
	if (netif_running(adapter->netdev))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
		e1000_down(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
	tx_old = adapter->tx_ring;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
	rx_old = adapter->rx_ring;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
	err = -ENOMEM;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
	txdr = kzalloc(tx_ring_size, GFP_KERNEL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
	if (!txdr)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
		goto err_alloc_tx;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
	rxdr = kzalloc(rx_ring_size, GFP_KERNEL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
	if (!rxdr)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
		goto err_alloc_rx;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
	adapter->tx_ring = txdr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
	adapter->rx_ring = rxdr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
	rxdr->count = max(ring->rx_pending,(uint32_t)E1000_MIN_RXD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
	rxdr->count = min(rxdr->count,(uint32_t)(mac_type < e1000_82544 ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
		E1000_MAX_RXD : E1000_MAX_82544_RXD));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
	E1000_ROUNDUP(rxdr->count, REQ_RX_DESCRIPTOR_MULTIPLE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
	txdr->count = max(ring->tx_pending,(uint32_t)E1000_MIN_TXD);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
	txdr->count = min(txdr->count,(uint32_t)(mac_type < e1000_82544 ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
		E1000_MAX_TXD : E1000_MAX_82544_TXD));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
	E1000_ROUNDUP(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
	for (i = 0; i < adapter->num_tx_queues; i++)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
		txdr[i].count = txdr->count;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
	for (i = 0; i < adapter->num_rx_queues; i++)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
		rxdr[i].count = rxdr->count;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
	if (netif_running(adapter->netdev)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
		/* Try to get new resources before deleting old */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
		if ((err = e1000_setup_all_rx_resources(adapter)))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
			goto err_setup_rx;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
		if ((err = e1000_setup_all_tx_resources(adapter)))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
			goto err_setup_tx;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
		/* save the new, restore the old in order to free it,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
		 * then restore the new back again */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
		adapter->rx_ring = rx_old;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
		adapter->tx_ring = tx_old;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
		e1000_free_all_rx_resources(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
		e1000_free_all_tx_resources(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
		kfree(tx_old);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
		kfree(rx_old);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
		adapter->rx_ring = rxdr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
		adapter->tx_ring = txdr;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
		if ((err = e1000_up(adapter)))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
			goto err_setup;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
	clear_bit(__E1000_RESETTING, &adapter->flags);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
	return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
err_setup_tx:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
	e1000_free_all_rx_resources(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
err_setup_rx:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
	adapter->rx_ring = rx_old;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
	adapter->tx_ring = tx_old;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
	kfree(rxdr);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
err_alloc_rx:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
	kfree(txdr);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
err_alloc_tx:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
	e1000_up(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
err_setup:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
	clear_bit(__E1000_RESETTING, &adapter->flags);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
	return err;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
#define REG_PATTERN_TEST(R, M, W)                                              \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
{                                                                              \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
	uint32_t pat, value;                                                   \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
	uint32_t test[] =                                                      \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
		{0x5A5A5A5A, 0xA5A5A5A5, 0x00000000, 0xFFFFFFFF};              \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
	for (pat = 0; pat < sizeof(test)/sizeof(test[0]); pat++) {              \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
		E1000_WRITE_REG(&adapter->hw, R, (test[pat] & W));             \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
		value = E1000_READ_REG(&adapter->hw, R);                       \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
		if (value != (test[pat] & W & M)) {                             \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
			DPRINTK(DRV, ERR, "pattern test reg %04X failed: got " \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
			        "0x%08X expected 0x%08X\n",                    \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
			        E1000_##R, value, (test[pat] & W & M));        \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
			*data = (adapter->hw.mac_type < e1000_82543) ?         \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
				E1000_82542_##R : E1000_##R;                   \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
			return 1;                                              \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
		}                                                              \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
	}                                                                      \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
#define REG_SET_AND_CHECK(R, M, W)                                             \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
{                                                                              \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
	uint32_t value;                                                        \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
	E1000_WRITE_REG(&adapter->hw, R, W & M);                               \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
	value = E1000_READ_REG(&adapter->hw, R);                               \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
	if ((W & M) != (value & M)) {                                          \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
		DPRINTK(DRV, ERR, "set/check reg %04X test failed: got 0x%08X "\
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
		        "expected 0x%08X\n", E1000_##R, (value & M), (W & M)); \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
		*data = (adapter->hw.mac_type < e1000_82543) ?                 \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
			E1000_82542_##R : E1000_##R;                           \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
		return 1;                                                      \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
	}                                                                      \
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
e1000_reg_test(struct e1000_adapter *adapter, uint64_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
	uint32_t value, before, after;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
	uint32_t i, toggle;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
	/* The status register is Read Only, so a write should fail.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
	 * Some bits that get toggled are ignored.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
	 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
	switch (adapter->hw.mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
	/* there are several bits on newer hardware that are r/w */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
	case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
	case e1000_82572:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
	case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
		toggle = 0x7FFFF3FF;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
	case e1000_82573:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
	case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
		toggle = 0x7FFFF033;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
	default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
		toggle = 0xFFFFF833;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
	before = E1000_READ_REG(&adapter->hw, STATUS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
	value = (E1000_READ_REG(&adapter->hw, STATUS) & toggle);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
	E1000_WRITE_REG(&adapter->hw, STATUS, toggle);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
	after = E1000_READ_REG(&adapter->hw, STATUS) & toggle;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
	if (value != after) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
		DPRINTK(DRV, ERR, "failed STATUS register test got: "
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
		        "0x%08X expected: 0x%08X\n", after, value);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
		*data = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
		return 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
	/* restore previous status */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
	E1000_WRITE_REG(&adapter->hw, STATUS, before);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
	if (adapter->hw.mac_type != e1000_ich8lan) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
		REG_PATTERN_TEST(FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
		REG_PATTERN_TEST(FCAH, 0x0000FFFF, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
		REG_PATTERN_TEST(FCT, 0x0000FFFF, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
		REG_PATTERN_TEST(VET, 0x0000FFFF, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
	REG_PATTERN_TEST(RDTR, 0x0000FFFF, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
	REG_PATTERN_TEST(RDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
	REG_PATTERN_TEST(RDLEN, 0x000FFF80, 0x000FFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
	REG_PATTERN_TEST(RDH, 0x0000FFFF, 0x0000FFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
	REG_PATTERN_TEST(RDT, 0x0000FFFF, 0x0000FFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
	REG_PATTERN_TEST(FCRTH, 0x0000FFF8, 0x0000FFF8);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
	REG_PATTERN_TEST(FCTTV, 0x0000FFFF, 0x0000FFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
	REG_PATTERN_TEST(TIPG, 0x3FFFFFFF, 0x3FFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
	REG_PATTERN_TEST(TDBAH, 0xFFFFFFFF, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
	REG_PATTERN_TEST(TDLEN, 0x000FFF80, 0x000FFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
	REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x00000000);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
	before = (adapter->hw.mac_type == e1000_ich8lan ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
	          0x06C3B33E : 0x06DFB3FE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
	REG_SET_AND_CHECK(RCTL, before, 0x003FFFFB);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
	REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
	if (adapter->hw.mac_type >= e1000_82543) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
		REG_SET_AND_CHECK(RCTL, before, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
		REG_PATTERN_TEST(RDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
		if (adapter->hw.mac_type != e1000_ich8lan)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
			REG_PATTERN_TEST(TXCW, 0xC000FFFF, 0x0000FFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
		REG_PATTERN_TEST(TDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
		REG_PATTERN_TEST(TIDV, 0x0000FFFF, 0x0000FFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
		value = (adapter->hw.mac_type == e1000_ich8lan ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
		         E1000_RAR_ENTRIES_ICH8LAN : E1000_RAR_ENTRIES);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
		for (i = 0; i < value; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
			REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
			                 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
	} else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
		REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x01FFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
		REG_PATTERN_TEST(RDBAL, 0xFFFFF000, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
		REG_PATTERN_TEST(TXCW, 0x0000FFFF, 0x0000FFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
		REG_PATTERN_TEST(TDBAL, 0xFFFFF000, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
	value = (adapter->hw.mac_type == e1000_ich8lan ?
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
			E1000_MC_TBL_SIZE_ICH8LAN : E1000_MC_TBL_SIZE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
	for (i = 0; i < value; i++)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
		REG_PATTERN_TEST(MTA + (i << 2), 0xFFFFFFFF, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
	*data = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
	return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
e1000_eeprom_test(struct e1000_adapter *adapter, uint64_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
	uint16_t temp;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
	uint16_t checksum = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
	uint16_t i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
	*data = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
	/* Read and add up the contents of the EEPROM */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
	for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
		if ((e1000_read_eeprom(&adapter->hw, i, 1, &temp)) < 0) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
			*data = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
			break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
		checksum += temp;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
	/* If Checksum is not Correct return error else test passed */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
	if ((checksum != (uint16_t) EEPROM_SUM) && !(*data))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
		*data = 2;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
	return *data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
static irqreturn_t
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
e1000_test_intr(int irq, void *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
	struct net_device *netdev = (struct net_device *) data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
	adapter->test_icr |= E1000_READ_REG(&adapter->hw, ICR);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
	return IRQ_HANDLED;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
	struct net_device *netdev = adapter->netdev;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
	uint32_t mask, i=0, shared_int = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
	uint32_t irq = adapter->pdev->irq;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
	*data = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
	/* NOTE: we don't test MSI interrupts here, yet */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
	/* Hook up test interrupt handler just for this test */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
	if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED, netdev->name,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
	                 netdev))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
		shared_int = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
	else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
	         netdev->name, netdev)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
		*data = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
		return -1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
	DPRINTK(HW, INFO, "testing %s interrupt\n",
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
	        (shared_int ? "shared" : "unshared"));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
	/* Disable all the interrupts */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
	E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
	msleep(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
	/* Test each interrupt */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
	for (; i < 10; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
		if (adapter->hw.mac_type == e1000_ich8lan && i == 8)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
			continue;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
		/* Interrupt to test */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
		mask = 1 << i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
		if (!shared_int) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
			/* Disable the interrupt to be reported in
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
			 * the cause register and then force the same
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
			 * interrupt and see if one gets posted.  If
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
			 * an interrupt was posted to the bus, the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
			 * test failed.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
			 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
			adapter->test_icr = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
			E1000_WRITE_REG(&adapter->hw, IMC, mask);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
			E1000_WRITE_REG(&adapter->hw, ICS, mask);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
			msleep(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
			if (adapter->test_icr & mask) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
				*data = 3;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
				break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
			}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
		/* Enable the interrupt to be reported in
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
		 * the cause register and then force the same
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
		 * interrupt and see if one gets posted.  If
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
		 * an interrupt was not posted to the bus, the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
		 * test failed.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
		 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
		adapter->test_icr = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
		E1000_WRITE_REG(&adapter->hw, IMS, mask);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
		E1000_WRITE_REG(&adapter->hw, ICS, mask);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
		msleep(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
		if (!(adapter->test_icr & mask)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
			*data = 4;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
			break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
		if (!shared_int) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
			/* Disable the other interrupts to be reported in
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
			 * the cause register and then force the other
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
			 * interrupts and see if any get posted.  If
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
			 * an interrupt was posted to the bus, the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
			 * test failed.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
			 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
			adapter->test_icr = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
			E1000_WRITE_REG(&adapter->hw, IMC, ~mask & 0x00007FFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
			E1000_WRITE_REG(&adapter->hw, ICS, ~mask & 0x00007FFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
			msleep(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
			if (adapter->test_icr) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
				*data = 5;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
				break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
			}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
	/* Disable all the interrupts */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
	E1000_WRITE_REG(&adapter->hw, IMC, 0xFFFFFFFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
	msleep(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
	/* Unhook test interrupt handler */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
	free_irq(irq, netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
	return *data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
e1000_free_desc_rings(struct e1000_adapter *adapter)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
	struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
	struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
	struct pci_dev *pdev = adapter->pdev;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
	int i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
	if (txdr->desc && txdr->buffer_info) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
		for (i = 0; i < txdr->count; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
			if (txdr->buffer_info[i].dma)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
				pci_unmap_single(pdev, txdr->buffer_info[i].dma,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
						 txdr->buffer_info[i].length,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
						 PCI_DMA_TODEVICE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
			if (txdr->buffer_info[i].skb)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
				dev_kfree_skb(txdr->buffer_info[i].skb);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
	if (rxdr->desc && rxdr->buffer_info) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
		for (i = 0; i < rxdr->count; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
			if (rxdr->buffer_info[i].dma)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
				pci_unmap_single(pdev, rxdr->buffer_info[i].dma,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
						 rxdr->buffer_info[i].length,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
						 PCI_DMA_FROMDEVICE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
			if (rxdr->buffer_info[i].skb)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
				dev_kfree_skb(rxdr->buffer_info[i].skb);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
	if (txdr->desc) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
		pci_free_consistent(pdev, txdr->size, txdr->desc, txdr->dma);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
		txdr->desc = NULL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
	if (rxdr->desc) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
		pci_free_consistent(pdev, rxdr->size, rxdr->desc, rxdr->dma);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
		rxdr->desc = NULL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
	kfree(txdr->buffer_info);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
	txdr->buffer_info = NULL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
	kfree(rxdr->buffer_info);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
	rxdr->buffer_info = NULL;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
	return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
e1000_setup_desc_rings(struct e1000_adapter *adapter)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
	struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
	struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
	struct pci_dev *pdev = adapter->pdev;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
	uint32_t rctl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
	int size, i, ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
	/* Setup Tx descriptor ring and Tx buffers */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
	if (!txdr->count)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
		txdr->count = E1000_DEFAULT_TXD;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
	size = txdr->count * sizeof(struct e1000_buffer);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
	if (!(txdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
		ret_val = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
		goto err_nomem;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
	memset(txdr->buffer_info, 0, size);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
	txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
	E1000_ROUNDUP(txdr->size, 4096);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
	if (!(txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma))) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
		ret_val = 2;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
		goto err_nomem;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
	memset(txdr->desc, 0, txdr->size);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
	txdr->next_to_use = txdr->next_to_clean = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
	E1000_WRITE_REG(&adapter->hw, TDBAL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
			((uint64_t) txdr->dma & 0x00000000FFFFFFFF));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
	E1000_WRITE_REG(&adapter->hw, TDBAH, ((uint64_t) txdr->dma >> 32));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
	E1000_WRITE_REG(&adapter->hw, TDLEN,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
			txdr->count * sizeof(struct e1000_tx_desc));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
	E1000_WRITE_REG(&adapter->hw, TDH, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
	E1000_WRITE_REG(&adapter->hw, TDT, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
	E1000_WRITE_REG(&adapter->hw, TCTL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
			E1000_TCTL_PSP | E1000_TCTL_EN |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
			E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
			E1000_FDX_COLLISION_DISTANCE << E1000_COLD_SHIFT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
	for (i = 0; i < txdr->count; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
		struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*txdr, i);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
		struct sk_buff *skb;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
		unsigned int size = 1024;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
		if (!(skb = alloc_skb(size, GFP_KERNEL))) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
			ret_val = 3;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
			goto err_nomem;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
		skb_put(skb, size);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
		txdr->buffer_info[i].skb = skb;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
		txdr->buffer_info[i].length = skb->len;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
		txdr->buffer_info[i].dma =
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
			pci_map_single(pdev, skb->data, skb->len,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
				       PCI_DMA_TODEVICE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
		tx_desc->buffer_addr = cpu_to_le64(txdr->buffer_info[i].dma);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
		tx_desc->lower.data = cpu_to_le32(skb->len);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
		tx_desc->lower.data |= cpu_to_le32(E1000_TXD_CMD_EOP |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
						   E1000_TXD_CMD_IFCS |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
						   E1000_TXD_CMD_RPS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
		tx_desc->upper.data = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
	/* Setup Rx descriptor ring and Rx buffers */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
	if (!rxdr->count)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
		rxdr->count = E1000_DEFAULT_RXD;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
	size = rxdr->count * sizeof(struct e1000_buffer);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
	if (!(rxdr->buffer_info = kmalloc(size, GFP_KERNEL))) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
		ret_val = 4;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
		goto err_nomem;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
	memset(rxdr->buffer_info, 0, size);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
	rxdr->size = rxdr->count * sizeof(struct e1000_rx_desc);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
	if (!(rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma))) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
		ret_val = 5;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
		goto err_nomem;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
	memset(rxdr->desc, 0, rxdr->size);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
	rxdr->next_to_use = rxdr->next_to_clean = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
	rctl = E1000_READ_REG(&adapter->hw, RCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
	E1000_WRITE_REG(&adapter->hw, RCTL, rctl & ~E1000_RCTL_EN);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
	E1000_WRITE_REG(&adapter->hw, RDBAL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
			((uint64_t) rxdr->dma & 0xFFFFFFFF));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
	E1000_WRITE_REG(&adapter->hw, RDBAH, ((uint64_t) rxdr->dma >> 32));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
	E1000_WRITE_REG(&adapter->hw, RDLEN, rxdr->size);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
	E1000_WRITE_REG(&adapter->hw, RDH, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
	E1000_WRITE_REG(&adapter->hw, RDT, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
	rctl = E1000_RCTL_EN | E1000_RCTL_BAM | E1000_RCTL_SZ_2048 |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
		E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
		(adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
	E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
	for (i = 0; i < rxdr->count; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
		struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rxdr, i);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
		struct sk_buff *skb;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
		if (!(skb = alloc_skb(E1000_RXBUFFER_2048 + NET_IP_ALIGN,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
				GFP_KERNEL))) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
			ret_val = 6;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
			goto err_nomem;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
		skb_reserve(skb, NET_IP_ALIGN);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
		rxdr->buffer_info[i].skb = skb;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
		rxdr->buffer_info[i].length = E1000_RXBUFFER_2048;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
		rxdr->buffer_info[i].dma =
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
			pci_map_single(pdev, skb->data, E1000_RXBUFFER_2048,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
				       PCI_DMA_FROMDEVICE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
		rx_desc->buffer_addr = cpu_to_le64(rxdr->buffer_info[i].dma);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
		memset(skb->data, 0x00, skb->len);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
	return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
err_nomem:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
	e1000_free_desc_rings(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
	return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
e1000_phy_disable_receiver(struct e1000_adapter *adapter)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
	/* Write out to PHY registers 29 and 30 to disable the Receiver. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
	e1000_write_phy_reg(&adapter->hw, 29, 0x001F);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
	e1000_write_phy_reg(&adapter->hw, 30, 0x8FFC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
	e1000_write_phy_reg(&adapter->hw, 29, 0x001A);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
	e1000_write_phy_reg(&adapter->hw, 30, 0x8FF0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
e1000_phy_reset_clk_and_crs(struct e1000_adapter *adapter)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
	uint16_t phy_reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
	/* Because we reset the PHY above, we need to re-force TX_CLK in the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
	 * Extended PHY Specific Control Register to 25MHz clock.  This
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
	 * value defaults back to a 2.5MHz clock when the PHY is reset.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
	 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
	e1000_read_phy_reg(&adapter->hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
	phy_reg |= M88E1000_EPSCR_TX_CLK_25;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
	e1000_write_phy_reg(&adapter->hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
		M88E1000_EXT_PHY_SPEC_CTRL, phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
	/* In addition, because of the s/w reset above, we need to enable
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
	 * CRS on TX.  This must be set for both full and half duplex
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
	 * operation.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
	 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
	e1000_read_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, &phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
	phy_reg |= M88E1000_PSCR_ASSERT_CRS_ON_TX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
	e1000_write_phy_reg(&adapter->hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
		M88E1000_PHY_SPEC_CTRL, phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
e1000_nonintegrated_phy_loopback(struct e1000_adapter *adapter)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
	uint32_t ctrl_reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
	uint16_t phy_reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
	/* Setup the Device Control Register for PHY loopback test. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
	ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
	ctrl_reg |= (E1000_CTRL_ILOS |		/* Invert Loss-Of-Signal */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
		     E1000_CTRL_FRCSPD |	/* Set the Force Speed Bit */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
		     E1000_CTRL_FRCDPX |	/* Set the Force Duplex Bit */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
		     E1000_CTRL_SPD_1000 |	/* Force Speed to 1000 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
		     E1000_CTRL_FD);		/* Force Duplex to FULL */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
	E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
	/* Read the PHY Specific Control Register (0x10) */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
	e1000_read_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, &phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
	/* Clear Auto-Crossover bits in PHY Specific Control Register
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
	 * (bits 6:5).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
	 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
	phy_reg &= ~M88E1000_PSCR_AUTO_X_MODE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
	e1000_write_phy_reg(&adapter->hw, M88E1000_PHY_SPEC_CTRL, phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
	/* Perform software reset on the PHY */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
	e1000_phy_reset(&adapter->hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
	/* Have to setup TX_CLK and TX_CRS after software reset */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
	e1000_phy_reset_clk_and_crs(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
	e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
	/* Wait for reset to complete. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
	udelay(500);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
	/* Have to setup TX_CLK and TX_CRS after software reset */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
	e1000_phy_reset_clk_and_crs(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
	/* Write out to PHY registers 29 and 30 to disable the Receiver. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
	e1000_phy_disable_receiver(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
	/* Set the loopback bit in the PHY control register. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
	e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
	phy_reg |= MII_CR_LOOPBACK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
	e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
	/* Setup TX_CLK and TX_CRS one more time. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
	e1000_phy_reset_clk_and_crs(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
	/* Check Phy Configuration */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
	e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
	if (phy_reg != 0x4100)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
		 return 9;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
	e1000_read_phy_reg(&adapter->hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
	if (phy_reg != 0x0070)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
		return 10;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
	e1000_read_phy_reg(&adapter->hw, 29, &phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
	if (phy_reg != 0x001A)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
		return 11;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
	return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
	uint32_t ctrl_reg = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
	uint32_t stat_reg = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
	adapter->hw.autoneg = FALSE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
	if (adapter->hw.phy_type == e1000_phy_m88) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
		/* Auto-MDI/MDIX Off */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
		e1000_write_phy_reg(&adapter->hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
				    M88E1000_PHY_SPEC_CTRL, 0x0808);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
		/* reset to update Auto-MDI/MDIX */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
		e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x9140);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
		/* autoneg off */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
		e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x8140);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
	} else if (adapter->hw.phy_type == e1000_phy_gg82563)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
		e1000_write_phy_reg(&adapter->hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
		                    GG82563_PHY_KMRN_MODE_CTRL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
		                    0x1CC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
	ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
	if (adapter->hw.phy_type == e1000_phy_ife) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
		/* force 100, set loopback */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
		e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x6100);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
		/* Now set up the MAC to the same speed/duplex as the PHY. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
		ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
		ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
			     E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
			     E1000_CTRL_SPD_100 |/* Force Speed to 100 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
			     E1000_CTRL_FD);	 /* Force Duplex to FULL */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
	} else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
		/* force 1000, set loopback */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
		e1000_write_phy_reg(&adapter->hw, PHY_CTRL, 0x4140);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
		/* Now set up the MAC to the same speed/duplex as the PHY. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
		ctrl_reg = E1000_READ_REG(&adapter->hw, CTRL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
		ctrl_reg &= ~E1000_CTRL_SPD_SEL; /* Clear the speed sel bits */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
		ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
			     E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
			     E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
			     E1000_CTRL_FD);	 /* Force Duplex to FULL */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
	if (adapter->hw.media_type == e1000_media_type_copper &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
	   adapter->hw.phy_type == e1000_phy_m88)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
		ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
	else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
		/* Set the ILOS bit on the fiber Nic is half
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
		 * duplex link is detected. */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
		stat_reg = E1000_READ_REG(&adapter->hw, STATUS);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
		if ((stat_reg & E1000_STATUS_FD) == 0)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
			ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
	E1000_WRITE_REG(&adapter->hw, CTRL, ctrl_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
	/* Disable the receiver on the PHY so when a cable is plugged in, the
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
	 * PHY does not begin to autoneg when a cable is reconnected to the NIC.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
	 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
	if (adapter->hw.phy_type == e1000_phy_m88)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
		e1000_phy_disable_receiver(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
	udelay(500);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
	return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
e1000_set_phy_loopback(struct e1000_adapter *adapter)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
	uint16_t phy_reg = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
	uint16_t count = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
	switch (adapter->hw.mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
	case e1000_82543:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
		if (adapter->hw.media_type == e1000_media_type_copper) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
			/* Attempt to setup Loopback mode on Non-integrated PHY.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
			 * Some PHY registers get corrupted at random, so
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
			 * attempt this 10 times.
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
			 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
			while (e1000_nonintegrated_phy_loopback(adapter) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
			      count++ < 10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
			if (count < 11)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
				return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
	case e1000_82544:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
	case e1000_82540:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
	case e1000_82545:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
	case e1000_82545_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
	case e1000_82546:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
	case e1000_82546_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
	case e1000_82541:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
	case e1000_82541_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
	case e1000_82547:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
	case e1000_82547_rev_2:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
	case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
	case e1000_82572:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
	case e1000_82573:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
	case e1000_80003es2lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
	case e1000_ich8lan:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
		return e1000_integrated_phy_loopback(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
	default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
		/* Default PHY loopback work is to read the MII
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
		 * control register and assert bit 14 (loopback mode).
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
		 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
		e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
		phy_reg |= MII_CR_LOOPBACK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
		e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
		return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
	return 8;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
e1000_setup_loopback_test(struct e1000_adapter *adapter)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
	struct e1000_hw *hw = &adapter->hw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
	uint32_t rctl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
	if (hw->media_type == e1000_media_type_fiber ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
	    hw->media_type == e1000_media_type_internal_serdes) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
		switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
		case e1000_82545:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
		case e1000_82546:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
		case e1000_82545_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
		case e1000_82546_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
			return e1000_set_phy_loopback(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
			break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
		case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
		case e1000_82572:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
#define E1000_SERDES_LB_ON 0x410
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
			e1000_set_phy_loopback(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
			E1000_WRITE_REG(hw, SCTL, E1000_SERDES_LB_ON);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
			msleep(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
			return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
			break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
		default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
			rctl = E1000_READ_REG(hw, RCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
			rctl |= E1000_RCTL_LBM_TCVR;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
			E1000_WRITE_REG(hw, RCTL, rctl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
			return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
	} else if (hw->media_type == e1000_media_type_copper)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
		return e1000_set_phy_loopback(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
	return 7;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
e1000_loopback_cleanup(struct e1000_adapter *adapter)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
	struct e1000_hw *hw = &adapter->hw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
	uint32_t rctl;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
	uint16_t phy_reg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
	rctl = E1000_READ_REG(hw, RCTL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
	rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
	E1000_WRITE_REG(hw, RCTL, rctl);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
	switch (hw->mac_type) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
	case e1000_82571:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
	case e1000_82572:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
		if (hw->media_type == e1000_media_type_fiber ||
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
		    hw->media_type == e1000_media_type_internal_serdes) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
#define E1000_SERDES_LB_OFF 0x400
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
			E1000_WRITE_REG(hw, SCTL, E1000_SERDES_LB_OFF);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
			msleep(10);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
			break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
		/* Fall Through */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
	case e1000_82545:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
	case e1000_82546:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
	case e1000_82545_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
	case e1000_82546_rev_3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
	default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
		hw->autoneg = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
		if (hw->phy_type == e1000_phy_gg82563)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
			e1000_write_phy_reg(hw,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
					    GG82563_PHY_KMRN_MODE_CTRL,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
					    0x180);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
		e1000_read_phy_reg(hw, PHY_CTRL, &phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
		if (phy_reg & MII_CR_LOOPBACK) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
			phy_reg &= ~MII_CR_LOOPBACK;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
			e1000_write_phy_reg(hw, PHY_CTRL, phy_reg);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
			e1000_phy_reset(hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
e1000_create_lbtest_frame(struct sk_buff *skb, unsigned int frame_size)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
	memset(skb->data, 0xFF, frame_size);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
	frame_size &= ~1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
	memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
	memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
	memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
e1000_check_lbtest_frame(struct sk_buff *skb, unsigned int frame_size)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
	frame_size &= ~1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
	if (*(skb->data + 3) == 0xFF) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
		if ((*(skb->data + frame_size / 2 + 10) == 0xBE) &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
		   (*(skb->data + frame_size / 2 + 12) == 0xAF)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
			return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
	return 13;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
e1000_run_loopback_test(struct e1000_adapter *adapter)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
	struct e1000_tx_ring *txdr = &adapter->test_tx_ring;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
	struct e1000_rx_ring *rxdr = &adapter->test_rx_ring;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
	struct pci_dev *pdev = adapter->pdev;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
	int i, j, k, l, lc, good_cnt, ret_val=0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
	unsigned long time;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
	E1000_WRITE_REG(&adapter->hw, RDT, rxdr->count - 1);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
	/* Calculate the loop count based on the largest descriptor ring
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
	 * The idea is to wrap the largest ring a number of times using 64
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
	 * send/receive pairs during each loop
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
	 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
	if (rxdr->count <= txdr->count)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
		lc = ((txdr->count / 64) * 2) + 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
	else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
		lc = ((rxdr->count / 64) * 2) + 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
	k = l = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
	for (j = 0; j <= lc; j++) { /* loop count loop */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
		for (i = 0; i < 64; i++) { /* send the packets */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
			e1000_create_lbtest_frame(txdr->buffer_info[i].skb,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
					1024);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
			pci_dma_sync_single_for_device(pdev,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
					txdr->buffer_info[k].dma,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
				    	txdr->buffer_info[k].length,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
				    	PCI_DMA_TODEVICE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
			if (unlikely(++k == txdr->count)) k = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
		E1000_WRITE_REG(&adapter->hw, TDT, k);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
		msleep(200);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
		time = jiffies; /* set the start time for the receive */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
		good_cnt = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
		do { /* receive the sent packets */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
			pci_dma_sync_single_for_cpu(pdev,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
					rxdr->buffer_info[l].dma,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
				    	rxdr->buffer_info[l].length,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
				    	PCI_DMA_FROMDEVICE);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
			ret_val = e1000_check_lbtest_frame(
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
					rxdr->buffer_info[l].skb,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
				   	1024);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
			if (!ret_val)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
				good_cnt++;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
			if (unlikely(++l == rxdr->count)) l = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
			/* time + 20 msecs (200 msecs on 2.4) is more than
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
			 * enough time to complete the receives, if it's
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
			 * exceeded, break and error off
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
			 */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
		} while (good_cnt < 64 && jiffies < (time + 20));
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
		if (good_cnt != 64) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
			ret_val = 13; /* ret_val is the same as mis-compare */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
			break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
		if (jiffies >= (time + 2)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
			ret_val = 14; /* error code for time out error */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
			break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
	} /* end loop count loop */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
	return ret_val;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
e1000_loopback_test(struct e1000_adapter *adapter, uint64_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
	/* PHY loopback cannot be performed if SoL/IDER
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
	 * sessions are active */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
	if (e1000_check_phy_reset_block(&adapter->hw)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
		DPRINTK(DRV, ERR, "Cannot do PHY loopback test "
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
		        "when SoL/IDER is active.\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
		*data = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
		goto out;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
	if ((*data = e1000_setup_desc_rings(adapter)))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
		goto out;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
	if ((*data = e1000_setup_loopback_test(adapter)))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
		goto err_loopback;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
	*data = e1000_run_loopback_test(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
	e1000_loopback_cleanup(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
err_loopback:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
	e1000_free_desc_rings(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
out:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
	return *data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
e1000_link_test(struct e1000_adapter *adapter, uint64_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
	*data = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
	if (adapter->hw.media_type == e1000_media_type_internal_serdes) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
		int i = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
		adapter->hw.serdes_link_down = TRUE;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
		/* On some blade server designs, link establishment
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
		 * could take as long as 2-3 minutes */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
		do {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
			e1000_check_for_link(&adapter->hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
			if (adapter->hw.serdes_link_down == FALSE)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
				return *data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
			msleep(20);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
		} while (i++ < 3750);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
		*data = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
	} else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
		e1000_check_for_link(&adapter->hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
		if (adapter->hw.autoneg)  /* if auto_neg is set wait for it */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
			msleep(4000);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
		if (!(E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU)) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
			*data = 1;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
	return *data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
e1000_diag_test_count(struct net_device *netdev)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
	return E1000_TEST_LEN;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
extern void e1000_power_up_phy(struct e1000_adapter *);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
e1000_diag_test(struct net_device *netdev,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
		   struct ethtool_test *eth_test, uint64_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
	boolean_t if_running = netif_running(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
	set_bit(__E1000_TESTING, &adapter->flags);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
	if (eth_test->flags == ETH_TEST_FL_OFFLINE) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
		/* Offline tests */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
		/* save speed, duplex, autoneg settings */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
		uint16_t autoneg_advertised = adapter->hw.autoneg_advertised;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
		uint8_t forced_speed_duplex = adapter->hw.forced_speed_duplex;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
		uint8_t autoneg = adapter->hw.autoneg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
		DPRINTK(HW, INFO, "offline testing starting\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
		/* Link test performed before hardware reset so autoneg doesn't
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
		 * interfere with test result */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
		if (e1000_link_test(adapter, &data[4]))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
			eth_test->flags |= ETH_TEST_FL_FAILED;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
		if (if_running)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
			/* indicate we're in test mode */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
			dev_close(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
		else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
			e1000_reset(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
		if (e1000_reg_test(adapter, &data[0]))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
			eth_test->flags |= ETH_TEST_FL_FAILED;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
		e1000_reset(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
		if (e1000_eeprom_test(adapter, &data[1]))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
			eth_test->flags |= ETH_TEST_FL_FAILED;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
		e1000_reset(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
		if (e1000_intr_test(adapter, &data[2]))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
			eth_test->flags |= ETH_TEST_FL_FAILED;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
		e1000_reset(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
		/* make sure the phy is powered up */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
		e1000_power_up_phy(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
		if (e1000_loopback_test(adapter, &data[3]))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
			eth_test->flags |= ETH_TEST_FL_FAILED;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1674
		/* restore speed, duplex, autoneg settings */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1675
		adapter->hw.autoneg_advertised = autoneg_advertised;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
		adapter->hw.forced_speed_duplex = forced_speed_duplex;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1677
		adapter->hw.autoneg = autoneg;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
		e1000_reset(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
		clear_bit(__E1000_TESTING, &adapter->flags);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
		if (if_running)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
			dev_open(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
	} else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
		DPRINTK(HW, INFO, "online testing starting\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
		/* Online tests */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
		if (e1000_link_test(adapter, &data[4]))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
			eth_test->flags |= ETH_TEST_FL_FAILED;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
		/* Online tests aren't run; pass by default */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
		data[0] = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
		data[1] = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
		data[2] = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
		data[3] = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
		clear_bit(__E1000_TESTING, &adapter->flags);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
	msleep_interruptible(4 * 1000);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
static int e1000_wol_exclusion(struct e1000_adapter *adapter, struct ethtool_wolinfo *wol)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
	struct e1000_hw *hw = &adapter->hw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
	int retval = 1; /* fail by default */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
	switch (hw->device_id) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
	case E1000_DEV_ID_82542:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
	case E1000_DEV_ID_82543GC_FIBER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
	case E1000_DEV_ID_82543GC_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
	case E1000_DEV_ID_82544EI_FIBER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
	case E1000_DEV_ID_82546EB_QUAD_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
	case E1000_DEV_ID_82545EM_FIBER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
	case E1000_DEV_ID_82545EM_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
	case E1000_DEV_ID_82546GB_QUAD_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
	case E1000_DEV_ID_82546GB_PCIE:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
		/* these don't support WoL at all */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
		wol->supported = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
	case E1000_DEV_ID_82546EB_FIBER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
	case E1000_DEV_ID_82546GB_FIBER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
	case E1000_DEV_ID_82571EB_FIBER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
	case E1000_DEV_ID_82571EB_SERDES:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
	case E1000_DEV_ID_82571EB_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
		/* Wake events not supported on port B */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
		if (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
			wol->supported = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
			break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
		/* return success for non excluded adapter ports */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1729
		retval = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
	case E1000_DEV_ID_82571EB_QUAD_COPPER:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
	case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
	case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
		/* quad port adapters only support WoL on port A */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
		if (!adapter->quad_port_a) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
			wol->supported = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
			break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
		/* return success for non excluded adapter ports */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
		retval = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
	default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
		/* dual port cards only support WoL on port A from now on
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
		 * unless it was enabled in the eeprom for port B
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
		 * so exclude FUNC_1 ports from having WoL enabled */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
		if (E1000_READ_REG(hw, STATUS) & E1000_STATUS_FUNC_1 &&
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
		    !adapter->eeprom_wol) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
			wol->supported = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
			break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
		retval = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
	return retval;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
e1000_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
	wol->supported = WAKE_UCAST | WAKE_MCAST |
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
	                 WAKE_BCAST | WAKE_MAGIC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
	wol->wolopts = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
	/* this function will set ->supported = 0 and return 1 if wol is not
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
	 * supported by this hardware */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
	if (e1000_wol_exclusion(adapter, wol))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
		return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
	/* apply any specific unsupported masks here */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
	switch (adapter->hw.device_id) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
	case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
		/* KSP3 does not suppport UCAST wake-ups */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
		wol->supported &= ~WAKE_UCAST;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
		if (adapter->wol & E1000_WUFC_EX)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
			DPRINTK(DRV, ERR, "Interface does not support "
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
		        "directed (unicast) frame wake-up packets\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
	default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
	if (adapter->wol & E1000_WUFC_EX)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
		wol->wolopts |= WAKE_UCAST;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
	if (adapter->wol & E1000_WUFC_MC)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
		wol->wolopts |= WAKE_MCAST;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
	if (adapter->wol & E1000_WUFC_BC)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
		wol->wolopts |= WAKE_BCAST;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
	if (adapter->wol & E1000_WUFC_MAG)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
		wol->wolopts |= WAKE_MAGIC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
	return;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
e1000_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
	struct e1000_hw *hw = &adapter->hw;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
	if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
		return -EOPNOTSUPP;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
	if (e1000_wol_exclusion(adapter, wol))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
		return wol->wolopts ? -EOPNOTSUPP : 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
	switch (hw->device_id) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
	case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
		if (wol->wolopts & WAKE_UCAST) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
			DPRINTK(DRV, ERR, "Interface does not support "
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
		        "directed (unicast) frame wake-up packets\n");
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
			return -EOPNOTSUPP;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
	default:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
	/* these settings will always override what we currently have */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
	adapter->wol = 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
	if (wol->wolopts & WAKE_UCAST)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
		adapter->wol |= E1000_WUFC_EX;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
	if (wol->wolopts & WAKE_MCAST)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
		adapter->wol |= E1000_WUFC_MC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
	if (wol->wolopts & WAKE_BCAST)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
		adapter->wol |= E1000_WUFC_BC;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
	if (wol->wolopts & WAKE_MAGIC)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
		adapter->wol |= E1000_WUFC_MAG;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
	return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
/* toggle LED 4 times per second = 2 "blinks" per second */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
#define E1000_ID_INTERVAL	(HZ/4)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
/* bit defines for adapter->led_status */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
#define E1000_LED_ON		0
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
e1000_led_blink_callback(unsigned long data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
	if (test_and_change_bit(E1000_LED_ON, &adapter->led_status))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
		e1000_led_off(&adapter->hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
	else
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
		e1000_led_on(&adapter->hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
	mod_timer(&adapter->blink_timer, jiffies + E1000_ID_INTERVAL);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
e1000_phys_id(struct net_device *netdev, uint32_t data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
	if (!data || data > (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
		data = (uint32_t)(MAX_SCHEDULE_TIMEOUT / HZ);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
	if (adapter->hw.mac_type < e1000_82571) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
		if (!adapter->blink_timer.function) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
			init_timer(&adapter->blink_timer);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
			adapter->blink_timer.function = e1000_led_blink_callback;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
			adapter->blink_timer.data = (unsigned long) adapter;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
		e1000_setup_led(&adapter->hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
		mod_timer(&adapter->blink_timer, jiffies);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
		msleep_interruptible(data * 1000);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
		del_timer_sync(&adapter->blink_timer);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
	} else if (adapter->hw.phy_type == e1000_phy_ife) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
		if (!adapter->blink_timer.function) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
			init_timer(&adapter->blink_timer);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
			adapter->blink_timer.function = e1000_led_blink_callback;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
			adapter->blink_timer.data = (unsigned long) adapter;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
		mod_timer(&adapter->blink_timer, jiffies);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
		msleep_interruptible(data * 1000);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1882
		del_timer_sync(&adapter->blink_timer);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
		e1000_write_phy_reg(&(adapter->hw), IFE_PHY_SPECIAL_CONTROL_LED, 0);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
	} else {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
		e1000_blink_led_start(&adapter->hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
		msleep_interruptible(data * 1000);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
	e1000_led_off(&adapter->hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
	clear_bit(E1000_LED_ON, &adapter->led_status);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
	e1000_cleanup_led(&adapter->hw);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
	return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
e1000_nway_reset(struct net_device *netdev)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
	if (netif_running(netdev))
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
		e1000_reinit_locked(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
	return 0;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
static int
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
e1000_get_stats_count(struct net_device *netdev)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
	return E1000_STATS_LEN;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
e1000_get_ethtool_stats(struct net_device *netdev,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
		struct ethtool_stats *stats, uint64_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
	struct e1000_adapter *adapter = netdev_priv(netdev);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
	int i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
	e1000_update_stats(adapter);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
	for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
		char *p = (char *)adapter+e1000_gstrings_stats[i].stat_offset;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
		data[i] = (e1000_gstrings_stats[i].sizeof_stat ==
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
			sizeof(uint64_t)) ? *(uint64_t *)p : *(uint32_t *)p;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
/*	BUG_ON(i != E1000_STATS_LEN); */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
static void
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
e1000_get_strings(struct net_device *netdev, uint32_t stringset, uint8_t *data)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
	uint8_t *p = data;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
	int i;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
	switch (stringset) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
	case ETH_SS_TEST:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
		memcpy(data, *e1000_gstrings_test,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
			E1000_TEST_LEN*ETH_GSTRING_LEN);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
	case ETH_SS_STATS:
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
		for (i = 0; i < E1000_GLOBAL_STATS_LEN; i++) {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
			memcpy(p, e1000_gstrings_stats[i].stat_string,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
			       ETH_GSTRING_LEN);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
			p += ETH_GSTRING_LEN;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
		}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
/*		BUG_ON(p - data != E1000_STATS_LEN * ETH_GSTRING_LEN); */
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
		break;
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
	}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
}
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
static const struct ethtool_ops e1000_ethtool_ops = {
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
	.get_settings           = e1000_get_settings,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
	.set_settings           = e1000_set_settings,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
	.get_drvinfo            = e1000_get_drvinfo,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
	.get_regs_len           = e1000_get_regs_len,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
	.get_regs               = e1000_get_regs,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
	.get_wol                = e1000_get_wol,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
	.set_wol                = e1000_set_wol,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
	.get_msglevel           = e1000_get_msglevel,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
	.set_msglevel           = e1000_set_msglevel,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
	.nway_reset             = e1000_nway_reset,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
	.get_link               = ethtool_op_get_link,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
	.get_eeprom_len         = e1000_get_eeprom_len,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
	.get_eeprom             = e1000_get_eeprom,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
	.set_eeprom             = e1000_set_eeprom,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
	.get_ringparam          = e1000_get_ringparam,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
	.set_ringparam          = e1000_set_ringparam,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
	.get_pauseparam         = e1000_get_pauseparam,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
	.set_pauseparam         = e1000_set_pauseparam,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
	.get_rx_csum            = e1000_get_rx_csum,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
	.set_rx_csum            = e1000_set_rx_csum,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
	.get_tx_csum            = e1000_get_tx_csum,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
	.set_tx_csum            = e1000_set_tx_csum,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
	.get_sg                 = ethtool_op_get_sg,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
	.set_sg                 = ethtool_op_set_sg,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
#ifdef NETIF_F_TSO
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
	.get_tso                = ethtool_op_get_tso,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
	.set_tso                = e1000_set_tso,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
#endif
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
	.self_test_count        = e1000_diag_test_count,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
	.self_test              = e1000_diag_test,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
	.get_strings            = e1000_get_strings,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
	.phys_id                = e1000_phys_id,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
	.get_stats_count        = e1000_get_stats_count,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
	.get_ethtool_stats      = e1000_get_ethtool_stats,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
	.get_perm_addr          = ethtool_op_get_perm_addr,
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
};
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
void e1000_set_ethtool_ops(struct net_device *netdev)
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
{
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
	SET_ETHTOOL_OPS(netdev, &e1000_ethtool_ops);
48c2dbc12bde Added e1000 driver for 2.6.20.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
}