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