devices/e1000/e1000_main-2.6.22-ethercat.c
author Florian Pose <fp@igh-essen.com>
Wed, 30 Apr 2008 09:55:58 +0000
branchstable-1.3
changeset 1755 18141b8631be
parent 1754 e750b37597ad
child 1756 dbe4a4219aa5
permissions -rw-r--r--
Version 1.3.3-pre.
1754
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*******************************************************************************
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
  Intel PRO/1000 Linux driver
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
  Copyright(c) 1999 - 2006 Intel Corporation.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
  This program is free software; you can redistribute it and/or modify it
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
  under the terms and conditions of the GNU General Public License,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
  version 2, as published by the Free Software Foundation.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
  This program is distributed in the hope it will be useful, but WITHOUT
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
  more details.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
  You should have received a copy of the GNU General Public License along with
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
  this program; if not, write to the Free Software Foundation, Inc.,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
  The full GNU General Public License is included in this distribution in
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
  the file called "COPYING".
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
  Contact Information:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  Linux NICS <linux.nics@intel.com>
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
*******************************************************************************/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
#include "e1000-2.6.22-ethercat.h"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
#include <net/ip6_checksum.h>
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
char e1000_driver_name[] = "ec_e1000";
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
static char e1000_driver_string[] = "EtherCAT Intel(R) PRO/1000 Network Driver";
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
#ifndef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
#define DRIVERNAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
#else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
#define DRIVERNAPI "-NAPI"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
#define DRV_VERSION "7.3.20-k2"DRIVERNAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
char e1000_driver_version[] = DRV_VERSION;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
static char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
/* e1000_pci_tbl - PCI Device ID Table
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
 * Last entry must be all 0s
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
 * Macro expands to...
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
 *   {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
static struct pci_device_id e1000_pci_tbl[] = {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
	INTEL_E1000_ETHERNET_DEVICE(0x1000),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
	INTEL_E1000_ETHERNET_DEVICE(0x1001),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
	INTEL_E1000_ETHERNET_DEVICE(0x1004),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
	INTEL_E1000_ETHERNET_DEVICE(0x1008),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
	INTEL_E1000_ETHERNET_DEVICE(0x1009),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
	INTEL_E1000_ETHERNET_DEVICE(0x100C),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
	INTEL_E1000_ETHERNET_DEVICE(0x100D),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
	INTEL_E1000_ETHERNET_DEVICE(0x100E),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
	INTEL_E1000_ETHERNET_DEVICE(0x100F),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
	INTEL_E1000_ETHERNET_DEVICE(0x1010),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
	INTEL_E1000_ETHERNET_DEVICE(0x1011),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
	INTEL_E1000_ETHERNET_DEVICE(0x1012),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
	INTEL_E1000_ETHERNET_DEVICE(0x1013),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
	INTEL_E1000_ETHERNET_DEVICE(0x1014),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
	INTEL_E1000_ETHERNET_DEVICE(0x1015),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
	INTEL_E1000_ETHERNET_DEVICE(0x1016),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
	INTEL_E1000_ETHERNET_DEVICE(0x1017),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
	INTEL_E1000_ETHERNET_DEVICE(0x1018),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
	INTEL_E1000_ETHERNET_DEVICE(0x1019),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
	INTEL_E1000_ETHERNET_DEVICE(0x101A),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
	INTEL_E1000_ETHERNET_DEVICE(0x101D),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
	INTEL_E1000_ETHERNET_DEVICE(0x101E),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
	INTEL_E1000_ETHERNET_DEVICE(0x1026),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
	INTEL_E1000_ETHERNET_DEVICE(0x1027),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
	INTEL_E1000_ETHERNET_DEVICE(0x1028),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
	INTEL_E1000_ETHERNET_DEVICE(0x1049),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
	INTEL_E1000_ETHERNET_DEVICE(0x104A),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
	INTEL_E1000_ETHERNET_DEVICE(0x104B),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
	INTEL_E1000_ETHERNET_DEVICE(0x104C),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
	INTEL_E1000_ETHERNET_DEVICE(0x104D),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
	INTEL_E1000_ETHERNET_DEVICE(0x105E),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
	INTEL_E1000_ETHERNET_DEVICE(0x105F),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
	INTEL_E1000_ETHERNET_DEVICE(0x1060),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
	INTEL_E1000_ETHERNET_DEVICE(0x1075),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
	INTEL_E1000_ETHERNET_DEVICE(0x1076),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
	INTEL_E1000_ETHERNET_DEVICE(0x1077),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
	INTEL_E1000_ETHERNET_DEVICE(0x1078),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
	INTEL_E1000_ETHERNET_DEVICE(0x1079),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
	INTEL_E1000_ETHERNET_DEVICE(0x107A),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
	INTEL_E1000_ETHERNET_DEVICE(0x107B),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
	INTEL_E1000_ETHERNET_DEVICE(0x107C),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
	INTEL_E1000_ETHERNET_DEVICE(0x107D),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
	INTEL_E1000_ETHERNET_DEVICE(0x107E),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
	INTEL_E1000_ETHERNET_DEVICE(0x107F),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
	INTEL_E1000_ETHERNET_DEVICE(0x108A),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
	INTEL_E1000_ETHERNET_DEVICE(0x108B),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
	INTEL_E1000_ETHERNET_DEVICE(0x108C),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
	INTEL_E1000_ETHERNET_DEVICE(0x1096),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
	INTEL_E1000_ETHERNET_DEVICE(0x1098),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
	INTEL_E1000_ETHERNET_DEVICE(0x1099),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
	INTEL_E1000_ETHERNET_DEVICE(0x109A),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
	INTEL_E1000_ETHERNET_DEVICE(0x10A4),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
	INTEL_E1000_ETHERNET_DEVICE(0x10B5),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
	INTEL_E1000_ETHERNET_DEVICE(0x10B9),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
	INTEL_E1000_ETHERNET_DEVICE(0x10BA),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
	INTEL_E1000_ETHERNET_DEVICE(0x10BB),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
	INTEL_E1000_ETHERNET_DEVICE(0x10BC),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
	INTEL_E1000_ETHERNET_DEVICE(0x10C4),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
	INTEL_E1000_ETHERNET_DEVICE(0x10C5),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
	/* required last entry */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
	{0,}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
};
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
// do not auto-load driver
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
// MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
int e1000_up(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
void e1000_down(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
void e1000_reinit_locked(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
void e1000_reset(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
int e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
static int e1000_setup_tx_resources(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
                             struct e1000_tx_ring *txdr);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
static int e1000_setup_rx_resources(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
                             struct e1000_rx_ring *rxdr);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
static void e1000_free_tx_resources(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
                             struct e1000_tx_ring *tx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
static void e1000_free_rx_resources(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
                             struct e1000_rx_ring *rx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
void e1000_update_stats(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
static int e1000_init_module(void);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
static void e1000_exit_module(void);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
static void __devexit e1000_remove(struct pci_dev *pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
static int e1000_alloc_queues(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
static int e1000_sw_init(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
static int e1000_open(struct net_device *netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
static int e1000_close(struct net_device *netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
static void e1000_configure_tx(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
static void e1000_configure_rx(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
static void e1000_setup_rctl(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
static void e1000_clean_all_tx_rings(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
static void e1000_clean_all_rx_rings(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
static void e1000_clean_tx_ring(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
                                struct e1000_tx_ring *tx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
static void e1000_clean_rx_ring(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
                                struct e1000_rx_ring *rx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
static void e1000_set_multi(struct net_device *netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
static void e1000_update_phy_info(unsigned long data);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
static void e1000_watchdog(unsigned long data);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
static void e1000_82547_tx_fifo_stall(unsigned long data);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
static struct net_device_stats * e1000_get_stats(struct net_device *netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
static int e1000_change_mtu(struct net_device *netdev, int new_mtu);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
static int e1000_set_mac(struct net_device *netdev, void *p);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
void ec_poll(struct net_device *);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
static irqreturn_t e1000_intr(int irq, void *data);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
static irqreturn_t e1000_intr_msi(int irq, void *data);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
                                    struct e1000_tx_ring *tx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
static int e1000_clean(struct net_device *poll_dev, int *budget);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
                                    struct e1000_rx_ring *rx_ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
                                    int *work_done, int work_to_do);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
static boolean_t e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
                                       struct e1000_rx_ring *rx_ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
                                       int *work_done, int work_to_do);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
#else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
static boolean_t e1000_clean_rx_irq(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
                                    struct e1000_rx_ring *rx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
static boolean_t e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
                                       struct e1000_rx_ring *rx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
                                   struct e1000_rx_ring *rx_ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
				   int cleaned_count);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
                                      struct e1000_rx_ring *rx_ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
				      int cleaned_count);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
			   int cmd);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
void e1000_set_ethtool_ops(struct net_device *netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
static void e1000_enter_82542_rst(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
static void e1000_leave_82542_rst(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
static void e1000_tx_timeout(struct net_device *dev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
static void e1000_reset_task(struct work_struct *work);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
static void e1000_smartspeed(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
                                       struct sk_buff *skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
static void e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
static void e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
static void e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
static void e1000_restore_vlan(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
static int e1000_suspend(struct pci_dev *pdev, pm_message_t state);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
#ifdef CONFIG_PM
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
static int e1000_resume(struct pci_dev *pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
static void e1000_shutdown(struct pci_dev *pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
#ifdef CONFIG_NET_POLL_CONTROLLER
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
/* for netdump / net console */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
static void e1000_netpoll (struct net_device *netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
extern void e1000_check_options(struct e1000_adapter *adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
#define COPYBREAK_DEFAULT 256
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
static unsigned int copybreak __read_mostly = COPYBREAK_DEFAULT;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
module_param(copybreak, uint, 0644);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
MODULE_PARM_DESC(copybreak,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
	"Maximum size of packet that is copied to a new buffer on receive");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
                     pci_channel_state_t state);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
static void e1000_io_resume(struct pci_dev *pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
static struct pci_error_handlers e1000_err_handler = {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
	.error_detected = e1000_io_error_detected,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
	.slot_reset = e1000_io_slot_reset,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
	.resume = e1000_io_resume,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
};
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
static struct pci_driver e1000_driver = {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
	.name     = e1000_driver_name,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
	.id_table = e1000_pci_tbl,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
	.probe    = e1000_probe,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
	.remove   = __devexit_p(e1000_remove),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
#ifdef CONFIG_PM
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
	/* Power Managment Hooks */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
	.suspend  = e1000_suspend,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
	.resume   = e1000_resume,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
	.shutdown = e1000_shutdown,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
	.err_handler = &e1000_err_handler
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
};
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
MODULE_DESCRIPTION("EtherCAT-capable Intel(R) PRO/1000 Network Driver");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
MODULE_LICENSE("GPL");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
MODULE_VERSION(DRV_VERSION);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
static int debug = NETIF_MSG_DRV | NETIF_MSG_PROBE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
module_param(debug, int, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
 * e1000_init_module - Driver Registration Routine
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
 * e1000_init_module is the first routine called when the driver is
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
 * loaded. All it does is register with the PCI subsystem.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
static int __init
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
e1000_init_module(void)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
	int ret;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
	printk(KERN_INFO "%s - version %s\n",
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
	       e1000_driver_string, e1000_driver_version);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
	printk(KERN_INFO "%s\n", e1000_copyright);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
	ret = pci_register_driver(&e1000_driver);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
	if (copybreak != COPYBREAK_DEFAULT) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
		if (copybreak == 0)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
			printk(KERN_INFO "e1000: copybreak disabled\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
		else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
			printk(KERN_INFO "e1000: copybreak enabled for "
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
			       "packets <= %u bytes\n", copybreak);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
	return ret;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
module_init(e1000_init_module);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
 * e1000_exit_module - Driver Exit Cleanup Routine
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
 * e1000_exit_module is called just before the driver is removed
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
 * from memory.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
static void __exit
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
e1000_exit_module(void)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
	pci_unregister_driver(&e1000_driver);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
module_exit(e1000_exit_module);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
static int e1000_request_irq(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
	void (*handler) = &e1000_intr;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
	int irq_flags = IRQF_SHARED;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
	int err;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
	if (adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
		return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
	if (adapter->hw.mac_type >= e1000_82571) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
		adapter->have_msi = !pci_enable_msi(adapter->pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
		if (adapter->have_msi) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
			handler = &e1000_intr_msi;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
			irq_flags = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
	err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
	                  netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
	if (err) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
		if (adapter->have_msi)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
			pci_disable_msi(adapter->pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
		DPRINTK(PROBE, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
		        "Unable to allocate interrupt Error: %d\n", err);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
	return err;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
static void e1000_free_irq(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
	if (adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
		return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
	free_irq(adapter->pdev->irq, netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
	if (adapter->have_msi)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
		pci_disable_msi(adapter->pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
 * e1000_irq_disable - Mask off interrupt generation on the NIC
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
e1000_irq_disable(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
    if (adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
        return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
	atomic_inc(&adapter->irq_sem);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
	E1000_WRITE_REG(&adapter->hw, IMC, ~0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
	E1000_WRITE_FLUSH(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
	synchronize_irq(adapter->pdev->irq);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
 * e1000_irq_enable - Enable default interrupt generation settings
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
e1000_irq_enable(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
    if (adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
        return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
	if (likely(atomic_dec_and_test(&adapter->irq_sem))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
		E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
		E1000_WRITE_FLUSH(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
e1000_update_mng_vlan(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
	uint16_t vid = adapter->hw.mng_cookie.vlan_id;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
	uint16_t old_vid = adapter->mng_vlan_id;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
	if (adapter->vlgrp) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
		if (!vlan_group_get_device(adapter->vlgrp, vid)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
			if (adapter->hw.mng_cookie.status &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
				E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
				e1000_vlan_rx_add_vid(netdev, vid);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
				adapter->mng_vlan_id = vid;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
			} else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
				adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
			if ((old_vid != (uint16_t)E1000_MNG_VLAN_NONE) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
					(vid != old_vid) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
			    !vlan_group_get_device(adapter->vlgrp, old_vid))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
				e1000_vlan_rx_kill_vid(netdev, old_vid);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
		} else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
			adapter->mng_vlan_id = vid;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
 * e1000_release_hw_control - release control of the h/w to f/w
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
 * @adapter: address of board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
 * e1000_release_hw_control resets {CTRL_EXT|FWSM}:DRV_LOAD bit.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
 * For ASF and Pass Through versions of f/w this means that the
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
 * driver is no longer loaded. For AMT version (only with 82573) i
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
 * of the f/w this means that the network i/f is closed.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   409
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
e1000_release_hw_control(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
	uint32_t ctrl_ext;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
	uint32_t swsm;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
	/* Let firmware taken over control of h/w */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
	switch (adapter->hw.mac_type) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
	case e1000_82573:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
		swsm = E1000_READ_REG(&adapter->hw, SWSM);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
		E1000_WRITE_REG(&adapter->hw, SWSM,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
				swsm & ~E1000_SWSM_DRV_LOAD);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
	case e1000_82571:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
	case e1000_82572:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
	case e1000_80003es2lan:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
	case e1000_ich8lan:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
		ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
		E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
				ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
	default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
 * e1000_get_hw_control - get control of the h/w from f/w
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
 * @adapter: address of board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
 * e1000_get_hw_control sets {CTRL_EXT|FWSM}:DRV_LOAD bit.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
 * For ASF and Pass Through versions of f/w this means that
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
 * the driver is loaded. For AMT version (only with 82573)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
 * of the f/w this means that the network i/f is open.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
e1000_get_hw_control(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
	uint32_t ctrl_ext;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
	uint32_t swsm;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
	/* Let firmware know the driver has taken over */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
	switch (adapter->hw.mac_type) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
	case e1000_82573:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
		swsm = E1000_READ_REG(&adapter->hw, SWSM);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
		E1000_WRITE_REG(&adapter->hw, SWSM,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
				swsm | E1000_SWSM_DRV_LOAD);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
	case e1000_82571:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
	case e1000_82572:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
	case e1000_80003es2lan:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
	case e1000_ich8lan:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
		ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
		E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
				ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
	default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
e1000_init_manageability(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
	if (adapter->en_mng_pt) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   479
		uint32_t manc = E1000_READ_REG(&adapter->hw, MANC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   480
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
		/* disable hardware interception of ARP */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
		manc &= ~(E1000_MANC_ARP_EN);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   483
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
		/* enable receiving management packets to the host */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
		/* this will probably generate destination unreachable messages
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
		 * from the host OS, but the packets will be handled on SMBUS */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
		if (adapter->hw.has_manc2h) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
			uint32_t manc2h = E1000_READ_REG(&adapter->hw, MANC2H);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
			manc |= E1000_MANC_EN_MNG2HOST;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
#define E1000_MNG2HOST_PORT_623 (1 << 5)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
#define E1000_MNG2HOST_PORT_664 (1 << 6)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
			manc2h |= E1000_MNG2HOST_PORT_623;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
			manc2h |= E1000_MNG2HOST_PORT_664;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
			E1000_WRITE_REG(&adapter->hw, MANC2H, manc2h);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
		E1000_WRITE_REG(&adapter->hw, MANC, manc);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
e1000_release_manageability(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
	if (adapter->en_mng_pt) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
		uint32_t manc = E1000_READ_REG(&adapter->hw, MANC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
		/* re-enable hardware interception of ARP */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
		manc |= E1000_MANC_ARP_EN;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
		if (adapter->hw.has_manc2h)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
			manc &= ~E1000_MANC_EN_MNG2HOST;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
		/* don't explicitly have to mess with MANC2H since
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
		 * MANC has an enable disable that gates MANC2H */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
		E1000_WRITE_REG(&adapter->hw, MANC, manc);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
 * e1000_configure - configure the hardware for RX and TX
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
 * @adapter = private board structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
static void e1000_configure(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
	int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
	e1000_set_multi(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
	e1000_restore_vlan(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
	e1000_init_manageability(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
	e1000_configure_tx(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
	e1000_setup_rctl(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
	e1000_configure_rx(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   538
	/* call E1000_DESC_UNUSED which always leaves
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
	 * at least 1 descriptor unused to make sure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
	 * next_to_use != next_to_clean */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
	for (i = 0; i < adapter->num_rx_queues; i++) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
		struct e1000_rx_ring *ring = &adapter->rx_ring[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
		adapter->alloc_rx_buf(adapter, ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
		                      E1000_DESC_UNUSED(ring));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
	adapter->tx_queue_len = netdev->tx_queue_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
int e1000_up(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
	/* hardware has been reset, we need to reload some things */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
	e1000_configure(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
	clear_bit(__E1000_DOWN, &adapter->flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
	if (!adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
		netif_poll_enable(adapter->netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
        e1000_irq_enable(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
		/* fire a link change interrupt to start the watchdog */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
		E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_LSC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
    }
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
	return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
 * e1000_power_up_phy - restore link in case the phy was powered down
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
 * @adapter: address of board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
 * The phy may be powered down to save power and turn off link when the
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
 * driver is unloaded and wake on lan is not enabled (among others)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
 * *** this routine MUST be followed by a call to e1000_reset ***
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
void e1000_power_up_phy(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
	uint16_t mii_reg = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
	/* Just clear the power down bit to wake the phy back up */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
	if (adapter->hw.media_type == e1000_media_type_copper) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
		/* according to the manual, the phy will retain its
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
		 * settings across a power-down/up cycle */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
		e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
		mii_reg &= ~MII_CR_POWER_DOWN;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
		e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
static void e1000_power_down_phy(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
	/* Power down the PHY so no link is implied when interface is down *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
	 * The PHY cannot be powered down if any of the following is TRUE *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
	 * (a) WoL is enabled
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
	 * (b) AMT is active
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
	 * (c) SoL/IDER session is active */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
	if (!adapter->wol && adapter->hw.mac_type >= e1000_82540 &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
	   adapter->hw.media_type == e1000_media_type_copper) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
		uint16_t mii_reg = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
		switch (adapter->hw.mac_type) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
		case e1000_82540:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
		case e1000_82545:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
		case e1000_82545_rev_3:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
		case e1000_82546:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
		case e1000_82546_rev_3:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
		case e1000_82541:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
		case e1000_82541_rev_2:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
		case e1000_82547:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
		case e1000_82547_rev_2:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
			if (E1000_READ_REG(&adapter->hw, MANC) &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
			    E1000_MANC_SMBUS_EN)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
				goto out;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
		case e1000_82571:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
		case e1000_82572:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
		case e1000_82573:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
		case e1000_80003es2lan:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
		case e1000_ich8lan:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
			if (e1000_check_mng_mode(&adapter->hw) ||
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
			    e1000_check_phy_reset_block(&adapter->hw))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
				goto out;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
		default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
			goto out;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
		e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
		mii_reg |= MII_CR_POWER_DOWN;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
		e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
		mdelay(1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
out:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
	return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
e1000_down(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
	/* signal that we're down so the interrupt handler does not
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
	 * reschedule our watchdog timer */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
	set_bit(__E1000_DOWN, &adapter->flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
    if (!adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
		netif_poll_disable(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
		e1000_irq_disable(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
        del_timer_sync(&adapter->tx_fifo_stall_timer);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
        del_timer_sync(&adapter->watchdog_timer);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
        del_timer_sync(&adapter->phy_info_timer);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
	netdev->tx_queue_len = adapter->tx_queue_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
	adapter->link_speed = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
	adapter->link_duplex = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
	if (!adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
		netif_carrier_off(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
		netif_stop_queue(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
	e1000_reset(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
	e1000_clean_all_tx_rings(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
	e1000_clean_all_rx_rings(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
e1000_reinit_locked(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   675
	WARN_ON(in_interrupt());
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
	while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
		msleep(1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
	e1000_down(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
	e1000_up(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
	clear_bit(__E1000_RESETTING, &adapter->flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
e1000_reset(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
	uint32_t pba = 0, tx_space, min_tx_space, min_rx_space;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
	uint16_t fc_high_water_mark = E1000_FC_HIGH_DIFF;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
	boolean_t legacy_pba_adjust = FALSE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
	/* Repartition Pba for greater than 9k mtu
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
	 * To take effect CTRL.RST is required.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
	 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
	switch (adapter->hw.mac_type) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
	case e1000_82542_rev2_0:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
	case e1000_82542_rev2_1:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
	case e1000_82543:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
	case e1000_82544:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
	case e1000_82540:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
	case e1000_82541:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
	case e1000_82541_rev_2:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
		legacy_pba_adjust = TRUE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
		pba = E1000_PBA_48K;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
	case e1000_82545:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
	case e1000_82545_rev_3:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
	case e1000_82546:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
	case e1000_82546_rev_3:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
		pba = E1000_PBA_48K;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
	case e1000_82547:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
	case e1000_82547_rev_2:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
		legacy_pba_adjust = TRUE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
		pba = E1000_PBA_30K;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
	case e1000_82571:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
	case e1000_82572:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
	case e1000_80003es2lan:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
		pba = E1000_PBA_38K;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
	case e1000_82573:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
		pba = E1000_PBA_20K;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
	case e1000_ich8lan:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
		pba = E1000_PBA_8K;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
	case e1000_undefined:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
	case e1000_num_macs:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
	if (legacy_pba_adjust == TRUE) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
		if (adapter->netdev->mtu > E1000_RXBUFFER_8192)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
			pba -= 8; /* allocate more FIFO for Tx */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
		if (adapter->hw.mac_type == e1000_82547) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
			adapter->tx_fifo_head = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
			adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
			adapter->tx_fifo_size =
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
				(E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
			atomic_set(&adapter->tx_fifo_stall, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
	} else if (adapter->hw.max_frame_size > MAXIMUM_ETHERNET_FRAME_SIZE) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
		/* adjust PBA for jumbo frames */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
		E1000_WRITE_REG(&adapter->hw, PBA, pba);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
		/* To maintain wire speed transmits, the Tx FIFO should be
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
		 * large enough to accomodate two full transmit packets,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
		 * rounded up to the next 1KB and expressed in KB.  Likewise,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
		 * the Rx FIFO should be large enough to accomodate at least
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
		 * one full receive packet and is similarly rounded up and
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
		 * expressed in KB. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
		pba = E1000_READ_REG(&adapter->hw, PBA);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
		/* upper 16 bits has Tx packet buffer allocation size in KB */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
		tx_space = pba >> 16;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
		/* lower 16 bits has Rx packet buffer allocation size in KB */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
		pba &= 0xffff;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
		/* don't include ethernet FCS because hardware appends/strips */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
		min_rx_space = adapter->netdev->mtu + ENET_HEADER_SIZE +
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
		               VLAN_TAG_SIZE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
		min_tx_space = min_rx_space;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
		min_tx_space *= 2;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
		min_tx_space = ALIGN(min_tx_space, 1024);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
		min_tx_space >>= 10;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
		min_rx_space = ALIGN(min_rx_space, 1024);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
		min_rx_space >>= 10;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
		/* If current Tx allocation is less than the min Tx FIFO size,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
		 * and the min Tx FIFO size is less than the current Rx FIFO
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
		 * allocation, take space away from current Rx allocation */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
		if (tx_space < min_tx_space &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
		    ((min_tx_space - tx_space) < pba)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
			pba = pba - (min_tx_space - tx_space);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
			/* PCI/PCIx hardware has PBA alignment constraints */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
			switch (adapter->hw.mac_type) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
			case e1000_82545 ... e1000_82546_rev_3:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
				pba &= ~(E1000_PBA_8K - 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
			default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
			/* if short on rx space, rx wins and must trump tx
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
			 * adjustment or use Early Receive if available */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
			if (pba < min_rx_space) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
				switch (adapter->hw.mac_type) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
				case e1000_82573:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
					/* ERT enabled in e1000_configure_rx */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
					break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
				default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
					pba = min_rx_space;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
					break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
				}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
	E1000_WRITE_REG(&adapter->hw, PBA, pba);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
	/* flow control settings */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
	/* Set the FC high water mark to 90% of the FIFO size.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
	 * Required to clear last 3 LSB */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
	fc_high_water_mark = ((pba * 9216)/10) & 0xFFF8;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
	/* We can't use 90% on small FIFOs because the remainder
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
	 * would be less than 1 full frame.  In this case, we size
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
	 * it to allow at least a full frame above the high water
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
	 *  mark. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
	if (pba < E1000_PBA_16K)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
		fc_high_water_mark = (pba * 1024) - 1600;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
	adapter->hw.fc_high_water = fc_high_water_mark;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
	adapter->hw.fc_low_water = fc_high_water_mark - 8;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
	if (adapter->hw.mac_type == e1000_80003es2lan)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
		adapter->hw.fc_pause_time = 0xFFFF;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
	else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
		adapter->hw.fc_pause_time = E1000_FC_PAUSE_TIME;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
	adapter->hw.fc_send_xon = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
	adapter->hw.fc = adapter->hw.original_fc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
	/* Allow time for pending master requests to run */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
	e1000_reset_hw(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
	if (adapter->hw.mac_type >= e1000_82544)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
		E1000_WRITE_REG(&adapter->hw, WUC, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
	if (e1000_init_hw(&adapter->hw))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
		DPRINTK(PROBE, ERR, "Hardware Error\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
	e1000_update_mng_vlan(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
	/* if (adapter->hwflags & HWFLAGS_PHY_PWR_BIT) { */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
	if (adapter->hw.mac_type >= e1000_82544 &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
	    adapter->hw.mac_type <= e1000_82547_rev_2 &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
	    adapter->hw.autoneg == 1 &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
	    adapter->hw.autoneg_advertised == ADVERTISE_1000_FULL) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
		uint32_t ctrl = E1000_READ_REG(&adapter->hw, CTRL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
		/* clear phy power management bit if we are in gig only mode,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
		 * which if enabled will attempt negotiation to 100Mb, which
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
		 * can cause a loss of link at power off or driver unload */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
		ctrl &= ~E1000_CTRL_SWDPIN3;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
		E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
	/* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
	E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
	e1000_reset_adaptive(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
	e1000_phy_get_info(&adapter->hw, &adapter->phy_info);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
	if (!adapter->smart_power_down &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
	    (adapter->hw.mac_type == e1000_82571 ||
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
	     adapter->hw.mac_type == e1000_82572)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
		uint16_t phy_data = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
		/* speed up time to link by disabling smart power down, ignore
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
		 * the return value of this function because there is nothing
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
		 * different we would do if it failed */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
		e1000_read_phy_reg(&adapter->hw, IGP02E1000_PHY_POWER_MGMT,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
		                   &phy_data);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
		phy_data &= ~IGP02E1000_PM_SPD;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
		e1000_write_phy_reg(&adapter->hw, IGP02E1000_PHY_POWER_MGMT,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
		                    phy_data);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
	e1000_release_manageability(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
 * e1000_probe - Device Initialization Routine
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
 * @pdev: PCI device information struct
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
 * @ent: entry in e1000_pci_tbl
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
 * Returns 0 on success, negative on failure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
 * e1000_probe initializes an adapter identified by a pci_dev structure.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
 * The OS initialization, configuring of the adapter private structure,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
 * and a hardware reset occur.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
static int __devinit
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
e1000_probe(struct pci_dev *pdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
            const struct pci_device_id *ent)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
	struct net_device *netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
	struct e1000_adapter *adapter;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
	unsigned long mmio_start, mmio_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
	unsigned long flash_start, flash_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
	static int cards_found = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
	static int global_quad_port_a = 0; /* global ksp3 port a indication */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
	int i, err, pci_using_dac;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
	uint16_t eeprom_data = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
	uint16_t eeprom_apme_mask = E1000_EEPROM_APME;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
	if ((err = pci_enable_device(pdev)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
		return err;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
	if (!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK)) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
	    !(err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
		pci_using_dac = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
	} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
		if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
		    (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
			E1000_ERR("No usable DMA configuration, aborting\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
			goto err_dma;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
		pci_using_dac = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
	if ((err = pci_request_regions(pdev, e1000_driver_name)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
		goto err_pci_reg;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
	pci_set_master(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
	err = -ENOMEM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
	netdev = alloc_etherdev(sizeof(struct e1000_adapter));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
	if (!netdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
		goto err_alloc_etherdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
	SET_MODULE_OWNER(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
	SET_NETDEV_DEV(netdev, &pdev->dev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
	pci_set_drvdata(pdev, netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
	adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
	adapter->netdev = netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
	adapter->pdev = pdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
	adapter->hw.back = adapter;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
	adapter->msg_enable = (1 << debug) - 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
	mmio_start = pci_resource_start(pdev, BAR_0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
	mmio_len = pci_resource_len(pdev, BAR_0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
	err = -EIO;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
	adapter->hw.hw_addr = ioremap(mmio_start, mmio_len);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
	if (!adapter->hw.hw_addr)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
		goto err_ioremap;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
	for (i = BAR_1; i <= BAR_5; i++) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
		if (pci_resource_len(pdev, i) == 0)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
			continue;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
		if (pci_resource_flags(pdev, i) & IORESOURCE_IO) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
			adapter->hw.io_base = pci_resource_start(pdev, i);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
	netdev->open = &e1000_open;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
	netdev->stop = &e1000_close;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
	netdev->hard_start_xmit = &e1000_xmit_frame;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
	netdev->get_stats = &e1000_get_stats;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
	netdev->set_multicast_list = &e1000_set_multi;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
	netdev->set_mac_address = &e1000_set_mac;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
	netdev->change_mtu = &e1000_change_mtu;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
	netdev->do_ioctl = &e1000_ioctl;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
	e1000_set_ethtool_ops(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
	netdev->tx_timeout = &e1000_tx_timeout;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
	netdev->watchdog_timeo = 5 * HZ;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
	netdev->poll = &e1000_clean;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
	netdev->weight = 64;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
	netdev->vlan_rx_register = e1000_vlan_rx_register;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
	netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
	netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
#ifdef CONFIG_NET_POLL_CONTROLLER
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
	netdev->poll_controller = e1000_netpoll;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
	strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
	netdev->mem_start = mmio_start;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
	netdev->mem_end = mmio_start + mmio_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
	netdev->base_addr = adapter->hw.io_base;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
	adapter->bd_number = cards_found;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
	/* setup the private structure */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
	if ((err = e1000_sw_init(adapter)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
		goto err_sw_init;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
	err = -EIO;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
	/* Flash BAR mapping must happen after e1000_sw_init
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
	 * because it depends on mac_type */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
	if ((adapter->hw.mac_type == e1000_ich8lan) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
	   (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
		flash_start = pci_resource_start(pdev, 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
		flash_len = pci_resource_len(pdev, 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
		adapter->hw.flash_address = ioremap(flash_start, flash_len);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
		if (!adapter->hw.flash_address)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
			goto err_flashmap;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
	if (e1000_check_phy_reset_block(&adapter->hw))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
		DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
	if (adapter->hw.mac_type >= e1000_82543) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
		netdev->features = NETIF_F_SG |
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
				   NETIF_F_HW_CSUM |
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
				   NETIF_F_HW_VLAN_TX |
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
				   NETIF_F_HW_VLAN_RX |
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
				   NETIF_F_HW_VLAN_FILTER;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
		if (adapter->hw.mac_type == e1000_ich8lan)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
			netdev->features &= ~NETIF_F_HW_VLAN_FILTER;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
	if ((adapter->hw.mac_type >= e1000_82544) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
	   (adapter->hw.mac_type != e1000_82547))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
		netdev->features |= NETIF_F_TSO;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
	if (adapter->hw.mac_type > e1000_82547_rev_2)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
		netdev->features |= NETIF_F_TSO6;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
	if (pci_using_dac)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
		netdev->features |= NETIF_F_HIGHDMA;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
	netdev->features |= NETIF_F_LLTX;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
	adapter->en_mng_pt = e1000_enable_mng_pass_thru(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
	/* initialize eeprom parameters */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
	if (e1000_init_eeprom_params(&adapter->hw)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
		E1000_ERR("EEPROM initialization failed\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
		goto err_eeprom;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
	/* before reading the EEPROM, reset the controller to
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
	 * put the device in a known good starting state */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
	e1000_reset_hw(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
	/* make sure the EEPROM is good */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
	if (e1000_validate_eeprom_checksum(&adapter->hw) < 0) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
		DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
		goto err_eeprom;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
	/* copy the MAC address out of the EEPROM */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
	if (e1000_read_mac_addr(&adapter->hw))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
		DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
	memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
	memcpy(netdev->perm_addr, adapter->hw.mac_addr, netdev->addr_len);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
	if (!is_valid_ether_addr(netdev->perm_addr)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
		DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
		goto err_eeprom;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
	e1000_get_bus_info(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
	init_timer(&adapter->tx_fifo_stall_timer);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
	adapter->tx_fifo_stall_timer.function = &e1000_82547_tx_fifo_stall;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
	adapter->tx_fifo_stall_timer.data = (unsigned long) adapter;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
	init_timer(&adapter->watchdog_timer);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
	adapter->watchdog_timer.function = &e1000_watchdog;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
	adapter->watchdog_timer.data = (unsigned long) adapter;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
	init_timer(&adapter->phy_info_timer);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
	adapter->phy_info_timer.function = &e1000_update_phy_info;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
	adapter->phy_info_timer.data = (unsigned long) adapter;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
	INIT_WORK(&adapter->reset_task, e1000_reset_task);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
	e1000_check_options(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
	/* Initial Wake on LAN setting
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
	 * If APM wake is enabled in the EEPROM,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
	 * enable the ACPI Magic Packet filter
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
	 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
	switch (adapter->hw.mac_type) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
	case e1000_82542_rev2_0:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
	case e1000_82542_rev2_1:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
	case e1000_82543:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
	case e1000_82544:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
		e1000_read_eeprom(&adapter->hw,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
			EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
		eeprom_apme_mask = E1000_EEPROM_82544_APM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
	case e1000_ich8lan:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
		e1000_read_eeprom(&adapter->hw,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
			EEPROM_INIT_CONTROL1_REG, 1, &eeprom_data);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
		eeprom_apme_mask = E1000_EEPROM_ICH8_APME;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
	case e1000_82546:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
	case e1000_82546_rev_3:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
	case e1000_82571:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
	case e1000_80003es2lan:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
		if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1){
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
			e1000_read_eeprom(&adapter->hw,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
				EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
		/* Fall Through */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
	default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
		e1000_read_eeprom(&adapter->hw,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
			EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
	if (eeprom_data & eeprom_apme_mask)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
		adapter->eeprom_wol |= E1000_WUFC_MAG;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
	/* now that we have the eeprom settings, apply the special cases
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
	 * where the eeprom may be wrong or the board simply won't support
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
	 * wake on lan on a particular port */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
	switch (pdev->device) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
	case E1000_DEV_ID_82546GB_PCIE:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
		adapter->eeprom_wol = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
	case E1000_DEV_ID_82546EB_FIBER:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
	case E1000_DEV_ID_82546GB_FIBER:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
	case E1000_DEV_ID_82571EB_FIBER:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
		/* Wake events only supported on port A for dual fiber
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
		 * regardless of eeprom setting */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
		if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
			adapter->eeprom_wol = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
	case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
	case E1000_DEV_ID_82571EB_QUAD_COPPER:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
	case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
		/* if quad port adapter, disable WoL on all but port A */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
		if (global_quad_port_a != 0)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
			adapter->eeprom_wol = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
		else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
			adapter->quad_port_a = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
		/* Reset for multiple quad port adapters */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
		if (++global_quad_port_a == 4)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
			global_quad_port_a = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
	/* initialize the wol settings based on the eeprom settings */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
	adapter->wol = adapter->eeprom_wol;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
	/* print bus type/speed/width info */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
	{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
	struct e1000_hw *hw = &adapter->hw;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
	DPRINTK(PROBE, INFO, "(PCI%s:%s:%s) ",
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
		((hw->bus_type == e1000_bus_type_pcix) ? "-X" :
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
		 (hw->bus_type == e1000_bus_type_pci_express ? " Express":"")),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
		((hw->bus_speed == e1000_bus_speed_2500) ? "2.5Gb/s" :
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
		 (hw->bus_speed == e1000_bus_speed_133) ? "133MHz" :
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
		 (hw->bus_speed == e1000_bus_speed_120) ? "120MHz" :
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
		 (hw->bus_speed == e1000_bus_speed_100) ? "100MHz" :
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
		 (hw->bus_speed == e1000_bus_speed_66) ? "66MHz" : "33MHz"),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
		((hw->bus_width == e1000_bus_width_64) ? "64-bit" :
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
		 (hw->bus_width == e1000_bus_width_pciex_4) ? "Width x4" :
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
		 (hw->bus_width == e1000_bus_width_pciex_1) ? "Width x1" :
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
		 "32-bit"));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
	for (i = 0; i < 6; i++)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
		printk("%2.2x%c", netdev->dev_addr[i], i == 5 ? '\n' : ':');
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
	/* reset the hardware with the new settings */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
	e1000_reset(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
	/* If the controller is 82573 and f/w is AMT, do not set
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
	 * DRV_LOAD until the interface is up.  For all other cases,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
	 * let the f/w know that the h/w is now under the control
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
	 * of the driver. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
	if (adapter->hw.mac_type != e1000_82573 ||
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
	    !e1000_check_mng_mode(&adapter->hw))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
		e1000_get_hw_control(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
	// offer device to EtherCAT master module
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
	if (ecdev_offer(netdev, ec_poll, THIS_MODULE, &adapter->ecdev)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
		DPRINTK(PROBE, ERR, "Failed to offer device.\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
		goto err_register;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
	if (adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
		if (ecdev_open(adapter->ecdev)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
			ecdev_withdraw(adapter->ecdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
			goto err_register;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
	} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
		/* tell the stack to leave us alone until e1000_open() is called */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
		netif_carrier_off(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
		netif_stop_queue(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
		netif_poll_disable(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
		strcpy(netdev->name, "eth%d");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
		if ((err = register_netdev(netdev)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
			goto err_register;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
	DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
	cards_found++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
	return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
err_register:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
	e1000_release_hw_control(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
err_eeprom:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
	if (!e1000_check_phy_reset_block(&adapter->hw))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
		e1000_phy_hw_reset(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
	if (adapter->hw.flash_address)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
		iounmap(adapter->hw.flash_address);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
err_flashmap:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
	for (i = 0; i < adapter->num_rx_queues; i++)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
		dev_put(&adapter->polling_netdev[i]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
	kfree(adapter->tx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
	kfree(adapter->rx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
	kfree(adapter->polling_netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
err_sw_init:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
	iounmap(adapter->hw.hw_addr);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
err_ioremap:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
	free_netdev(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
err_alloc_etherdev:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
	pci_release_regions(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
err_pci_reg:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
err_dma:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
	pci_disable_device(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
	return err;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
 * e1000_remove - Device Removal Routine
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
 * @pdev: PCI device information struct
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
 * e1000_remove is called by the PCI subsystem to alert the driver
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
 * that it should release a PCI device.  The could be caused by a
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
 * Hot-Plug event, or because the driver is going to be removed from
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
 * memory.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
static void __devexit
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
e1000_remove(struct pci_dev *pdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
	struct net_device *netdev = pci_get_drvdata(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
	int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
	cancel_work_sync(&adapter->reset_task);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
	e1000_release_manageability(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
	/* Release control of h/w to f/w.  If f/w is AMT enabled, this
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
	 * would have already happened in close and is redundant. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
	e1000_release_hw_control(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
	if (adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
		ecdev_close(adapter->ecdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
		ecdev_withdraw(adapter->ecdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
	} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
		unregister_netdev(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
	for (i = 0; i < adapter->num_rx_queues; i++)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
		dev_put(&adapter->polling_netdev[i]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
	if (!e1000_check_phy_reset_block(&adapter->hw))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
		e1000_phy_hw_reset(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
	kfree(adapter->tx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
	kfree(adapter->rx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
	kfree(adapter->polling_netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
	iounmap(adapter->hw.hw_addr);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
	if (adapter->hw.flash_address)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
		iounmap(adapter->hw.flash_address);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
	pci_release_regions(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
	free_netdev(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
	pci_disable_device(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
 * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
 * @adapter: board private structure to initialize
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
 * e1000_sw_init initializes the Adapter private data structure.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
 * Fields are initialized based on PCI device information and
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
 * OS network device settings (MTU size).
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
static int __devinit
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
e1000_sw_init(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
	struct e1000_hw *hw = &adapter->hw;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
	struct pci_dev *pdev = adapter->pdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
	int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
	/* PCI config space info */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
	hw->vendor_id = pdev->vendor;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
	hw->device_id = pdev->device;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
	hw->subsystem_vendor_id = pdev->subsystem_vendor;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
	hw->subsystem_id = pdev->subsystem_device;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
	pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
	pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
	adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
	adapter->rx_ps_bsize0 = E1000_RXBUFFER_128;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
	hw->max_frame_size = netdev->mtu +
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
			     ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
	hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
	/* identify the MAC */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
	if (e1000_set_mac_type(hw)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
		DPRINTK(PROBE, ERR, "Unknown MAC Type\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
		return -EIO;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
	switch (hw->mac_type) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
	default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
	case e1000_82541:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
	case e1000_82547:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
	case e1000_82541_rev_2:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
	case e1000_82547_rev_2:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
		hw->phy_init_script = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
	e1000_set_media_type(hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
	hw->wait_autoneg_complete = FALSE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
	hw->tbi_compatibility_en = TRUE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
	hw->adaptive_ifs = TRUE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
	/* Copper options */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
	if (hw->media_type == e1000_media_type_copper) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
		hw->mdix = AUTO_ALL_MODES;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
		hw->disable_polarity_correction = FALSE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
		hw->master_slave = E1000_MASTER_SLAVE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
	adapter->num_tx_queues = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
	adapter->num_rx_queues = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
	if (e1000_alloc_queues(adapter)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
		DPRINTK(PROBE, ERR, "Unable to allocate memory for queues\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
		return -ENOMEM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
	for (i = 0; i < adapter->num_rx_queues; i++) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
		adapter->polling_netdev[i].priv = adapter;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
		adapter->polling_netdev[i].poll = &e1000_clean;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
		adapter->polling_netdev[i].weight = 64;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
		dev_hold(&adapter->polling_netdev[i]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
		set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
	spin_lock_init(&adapter->tx_queue_lock);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
	/* Explicitly disable IRQ since the NIC can be in any state. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
	atomic_set(&adapter->irq_sem, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
	e1000_irq_disable(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
	spin_lock_init(&adapter->stats_lock);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
	set_bit(__E1000_DOWN, &adapter->flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
	return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
 * e1000_alloc_queues - Allocate memory for all rings
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
 * @adapter: board private structure to initialize
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
 * We allocate one ring per queue at run-time since we don't know the
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
 * number of queues at compile-time.  The polling_netdev array is
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
 * intended for Multiqueue, but should work fine with a single queue.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
static int __devinit
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
e1000_alloc_queues(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
	adapter->tx_ring = kcalloc(adapter->num_tx_queues,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
	                           sizeof(struct e1000_tx_ring), GFP_KERNEL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
	if (!adapter->tx_ring)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
		return -ENOMEM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
	adapter->rx_ring = kcalloc(adapter->num_rx_queues,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
	                           sizeof(struct e1000_rx_ring), GFP_KERNEL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
	if (!adapter->rx_ring) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
		kfree(adapter->tx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
		return -ENOMEM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
	adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
	                                  sizeof(struct net_device),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
	                                  GFP_KERNEL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
	if (!adapter->polling_netdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
		kfree(adapter->tx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
		kfree(adapter->rx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
		return -ENOMEM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
	return E1000_SUCCESS;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
 * e1000_open - Called when a network interface is made active
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
 * @netdev: network interface device structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
 * Returns 0 on success, negative value on failure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
 * The open entry point is called when a network interface is made
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
 * active by the system (IFF_UP).  At this point all resources needed
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
 * for transmit and receive operations are allocated, the interrupt
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
 * handler is registered with the OS, the watchdog timer is started,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
 * and the stack is notified that the interface is ready.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
e1000_open(struct net_device *netdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
	int err;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
	/* disallow open during test */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
	if (test_bit(__E1000_TESTING, &adapter->flags))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
		return -EBUSY;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
	/* allocate transmit descriptors */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
	err = e1000_setup_all_tx_resources(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
	if (err)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
		goto err_setup_tx;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
	/* allocate receive descriptors */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
	err = e1000_setup_all_rx_resources(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
	if (err)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
		goto err_setup_rx;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
	e1000_power_up_phy(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
	adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
	if ((adapter->hw.mng_cookie.status &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
		e1000_update_mng_vlan(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
	/* If AMT is enabled, let the firmware know that the network
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
	 * interface is now open */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
	if (adapter->hw.mac_type == e1000_82573 &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
	    e1000_check_mng_mode(&adapter->hw))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
		e1000_get_hw_control(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
	/* before we allocate an interrupt, we must be ready to handle it.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
	 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
	 * as soon as we call pci_request_irq, so we have to setup our
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
	 * clean_rx handler before we do so.  */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
	e1000_configure(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
	err = e1000_request_irq(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
	if (err)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
		goto err_req_irq;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
	/* From here on the code is the same as e1000_up() */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
	clear_bit(__E1000_DOWN, &adapter->flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
    if (!adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
		netif_poll_enable(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
	e1000_irq_enable(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
	/* fire a link status change interrupt to start the watchdog */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
	E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_LSC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
	return E1000_SUCCESS;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
err_req_irq:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
	e1000_release_hw_control(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
	e1000_power_down_phy(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
	e1000_free_all_rx_resources(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
err_setup_rx:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
	e1000_free_all_tx_resources(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
err_setup_tx:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
	e1000_reset(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
	return err;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
 * e1000_close - Disables a network interface
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
 * @netdev: network interface device structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
 * Returns 0, this is not allowed to fail
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
 * The close entry point is called when an interface is de-activated
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
 * by the OS.  The hardware is still under the drivers control, but
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
 * needs to be disabled.  A global MAC reset is issued to stop the
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
 * hardware, and all transmit and receive resources are freed.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
e1000_close(struct net_device *netdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
	WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
	e1000_down(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
	e1000_power_down_phy(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
	e1000_free_irq(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
	e1000_free_all_tx_resources(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
	e1000_free_all_rx_resources(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
	/* kill manageability vlan ID if supported, but not if a vlan with
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
	 * the same ID is registered on the host OS (let 8021q kill it) */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
	if ((adapter->hw.mng_cookie.status &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
	     !(adapter->vlgrp &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
	       vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
		e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
	/* If AMT is enabled, let the firmware know that the network
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
	 * interface is now closed */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
	if (adapter->hw.mac_type == e1000_82573 &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
	    e1000_check_mng_mode(&adapter->hw))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
		e1000_release_hw_control(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
	return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
 * e1000_check_64k_bound - check that memory doesn't cross 64kB boundary
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1547
 * @adapter: address of board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1548
 * @start: address of beginning of memory
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1549
 * @len: length of memory
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
static boolean_t
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
e1000_check_64k_bound(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
		      void *start, unsigned long len)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
	unsigned long begin = (unsigned long) start;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
	unsigned long end = begin + len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
	/* First rev 82545 and 82546 need to not allow any memory
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
	 * write location to cross 64k boundary due to errata 23 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
	if (adapter->hw.mac_type == e1000_82545 ||
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
	    adapter->hw.mac_type == e1000_82546) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
		return ((begin ^ (end - 1)) >> 16) != 0 ? FALSE : TRUE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
	return TRUE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
 * e1000_setup_tx_resources - allocate Tx resources (Descriptors)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
 * @txdr:    tx descriptor ring (for a specific queue) to setup
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
 * Return 0 on success, negative on failure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
e1000_setup_tx_resources(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
                         struct e1000_tx_ring *txdr)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
	struct pci_dev *pdev = adapter->pdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
	int size;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
	size = sizeof(struct e1000_buffer) * txdr->count;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
	txdr->buffer_info = vmalloc(size);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
	if (!txdr->buffer_info) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
		DPRINTK(PROBE, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
		"Unable to allocate memory for the transmit descriptor ring\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
		return -ENOMEM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
	memset(txdr->buffer_info, 0, size);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
	/* round up to nearest 4K */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
	txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
	txdr->size = ALIGN(txdr->size, 4096);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
	txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
	if (!txdr->desc) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
setup_tx_desc_die:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
		vfree(txdr->buffer_info);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
		DPRINTK(PROBE, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
		"Unable to allocate memory for the transmit descriptor ring\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
		return -ENOMEM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
	/* Fix for errata 23, can't cross 64kB boundary */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
	if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
		void *olddesc = txdr->desc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
		dma_addr_t olddma = txdr->dma;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
		DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes "
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
				     "at %p\n", txdr->size, txdr->desc);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
		/* Try again, without freeing the previous */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
		txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
		/* Failed allocation, critical failure */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
		if (!txdr->desc) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
			pci_free_consistent(pdev, txdr->size, olddesc, olddma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
			goto setup_tx_desc_die;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
		if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
			/* give up */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
			pci_free_consistent(pdev, txdr->size, txdr->desc,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
					    txdr->dma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
			pci_free_consistent(pdev, txdr->size, olddesc, olddma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
			DPRINTK(PROBE, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
				"Unable to allocate aligned memory "
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
				"for the transmit descriptor ring\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
			vfree(txdr->buffer_info);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
			return -ENOMEM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
		} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
			/* Free old allocation, new allocation was successful */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
			pci_free_consistent(pdev, txdr->size, olddesc, olddma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
	memset(txdr->desc, 0, txdr->size);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
	txdr->next_to_use = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
	txdr->next_to_clean = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
	spin_lock_init(&txdr->tx_lock);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
	return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
 * e1000_setup_all_tx_resources - wrapper to allocate Tx resources
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
 * 				  (Descriptors) for all queues
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
 * Return 0 on success, negative on failure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
e1000_setup_all_tx_resources(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
	int i, err = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
	for (i = 0; i < adapter->num_tx_queues; i++) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
		err = e1000_setup_tx_resources(adapter, &adapter->tx_ring[i]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
		if (err) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
			DPRINTK(PROBE, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
				"Allocation for Tx Queue %u failed\n", i);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
			for (i-- ; i >= 0; i--)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
				e1000_free_tx_resources(adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
							&adapter->tx_ring[i]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
	return err;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
 * e1000_configure_tx - Configure 8254x Transmit Unit after Reset
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1674
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1675
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
 * Configure the Tx unit of the MAC after a reset.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1677
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
e1000_configure_tx(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
	uint64_t tdba;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
	struct e1000_hw *hw = &adapter->hw;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
	uint32_t tdlen, tctl, tipg, tarc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
	uint32_t ipgr1, ipgr2;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
	/* Setup the HW Tx Head and Tail descriptor pointers */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
	switch (adapter->num_tx_queues) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
	case 1:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
	default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
		tdba = adapter->tx_ring[0].dma;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
		tdlen = adapter->tx_ring[0].count *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
			sizeof(struct e1000_tx_desc);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
		E1000_WRITE_REG(hw, TDLEN, tdlen);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
		E1000_WRITE_REG(hw, TDBAH, (tdba >> 32));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
		E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
		E1000_WRITE_REG(hw, TDT, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
		E1000_WRITE_REG(hw, TDH, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
		adapter->tx_ring[0].tdh = ((hw->mac_type >= e1000_82543) ? E1000_TDH : E1000_82542_TDH);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
		adapter->tx_ring[0].tdt = ((hw->mac_type >= e1000_82543) ? E1000_TDT : E1000_82542_TDT);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
	/* Set the default values for the Tx Inter Packet Gap timer */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
	if (adapter->hw.mac_type <= e1000_82547_rev_2 &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
	    (hw->media_type == e1000_media_type_fiber ||
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
	     hw->media_type == e1000_media_type_internal_serdes))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
		tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
	else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
		tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
	switch (hw->mac_type) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
	case e1000_82542_rev2_0:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
	case e1000_82542_rev2_1:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
		tipg = DEFAULT_82542_TIPG_IPGT;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
		ipgr1 = DEFAULT_82542_TIPG_IPGR1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
		ipgr2 = DEFAULT_82542_TIPG_IPGR2;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
	case e1000_80003es2lan:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
		ipgr1 = DEFAULT_82543_TIPG_IPGR1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
		ipgr2 = DEFAULT_80003ES2LAN_TIPG_IPGR2;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
	default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
		ipgr1 = DEFAULT_82543_TIPG_IPGR1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
		ipgr2 = DEFAULT_82543_TIPG_IPGR2;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1729
	tipg |= ipgr1 << E1000_TIPG_IPGR1_SHIFT;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
	tipg |= ipgr2 << E1000_TIPG_IPGR2_SHIFT;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
	E1000_WRITE_REG(hw, TIPG, tipg);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
	/* Set the Tx Interrupt Delay register */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
	E1000_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
	if (hw->mac_type >= e1000_82540)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
		E1000_WRITE_REG(hw, TADV, adapter->tx_abs_int_delay);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
	/* Program the Transmit Control Register */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
	tctl = E1000_READ_REG(hw, TCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
	tctl &= ~E1000_TCTL_CT;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
	tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
		(E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
	if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
		tarc = E1000_READ_REG(hw, TARC0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
		/* set the speed mode bit, we'll clear it if we're not at
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
		 * gigabit link later */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
		tarc |= (1 << 21);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
		E1000_WRITE_REG(hw, TARC0, tarc);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
	} else if (hw->mac_type == e1000_80003es2lan) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
		tarc = E1000_READ_REG(hw, TARC0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
		tarc |= 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
		E1000_WRITE_REG(hw, TARC0, tarc);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
		tarc = E1000_READ_REG(hw, TARC1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
		tarc |= 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
		E1000_WRITE_REG(hw, TARC1, tarc);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
	e1000_config_collision_dist(hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
	/* Setup Transmit Descriptor Settings for eop descriptor */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
	adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
	/* only set IDE if we are delaying interrupts using the timers */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
	if (adapter->tx_int_delay)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
		adapter->txd_cmd |= E1000_TXD_CMD_IDE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
	if (hw->mac_type < e1000_82543)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
		adapter->txd_cmd |= E1000_TXD_CMD_RPS;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
	else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
		adapter->txd_cmd |= E1000_TXD_CMD_RS;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
	/* Cache if we're 82544 running in PCI-X because we'll
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
	 * need this to apply a workaround later in the send path. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
	if (hw->mac_type == e1000_82544 &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
	    hw->bus_type == e1000_bus_type_pcix)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
		adapter->pcix_82544 = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
	E1000_WRITE_REG(hw, TCTL, tctl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
 * e1000_setup_rx_resources - allocate Rx resources (Descriptors)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
 * @rxdr:    rx descriptor ring (for a specific queue) to setup
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
 * Returns 0 on success, negative on failure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
e1000_setup_rx_resources(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
                         struct e1000_rx_ring *rxdr)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
	struct pci_dev *pdev = adapter->pdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
	int size, desc_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
	size = sizeof(struct e1000_buffer) * rxdr->count;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
	rxdr->buffer_info = vmalloc(size);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
	if (!rxdr->buffer_info) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
		DPRINTK(PROBE, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
		"Unable to allocate memory for the receive descriptor ring\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
		return -ENOMEM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
	memset(rxdr->buffer_info, 0, size);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
	rxdr->ps_page = kcalloc(rxdr->count, sizeof(struct e1000_ps_page),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
	                        GFP_KERNEL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
	if (!rxdr->ps_page) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
		vfree(rxdr->buffer_info);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
		DPRINTK(PROBE, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
		"Unable to allocate memory for the receive descriptor ring\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
		return -ENOMEM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
	rxdr->ps_page_dma = kcalloc(rxdr->count,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
	                            sizeof(struct e1000_ps_page_dma),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
	                            GFP_KERNEL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
	if (!rxdr->ps_page_dma) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
		vfree(rxdr->buffer_info);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
		kfree(rxdr->ps_page);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
		DPRINTK(PROBE, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
		"Unable to allocate memory for the receive descriptor ring\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
		return -ENOMEM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
	if (adapter->hw.mac_type <= e1000_82547_rev_2)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
		desc_len = sizeof(struct e1000_rx_desc);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
	else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
		desc_len = sizeof(union e1000_rx_desc_packet_split);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
	/* Round up to nearest 4K */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
	rxdr->size = rxdr->count * desc_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
	rxdr->size = ALIGN(rxdr->size, 4096);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
	rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
	if (!rxdr->desc) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
		DPRINTK(PROBE, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
		"Unable to allocate memory for the receive descriptor ring\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
setup_rx_desc_die:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
		vfree(rxdr->buffer_info);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
		kfree(rxdr->ps_page);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
		kfree(rxdr->ps_page_dma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
		return -ENOMEM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
	/* Fix for errata 23, can't cross 64kB boundary */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
	if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
		void *olddesc = rxdr->desc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
		dma_addr_t olddma = rxdr->dma;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
		DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes "
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
				     "at %p\n", rxdr->size, rxdr->desc);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
		/* Try again, without freeing the previous */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
		rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
		/* Failed allocation, critical failure */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
		if (!rxdr->desc) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
			pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
			DPRINTK(PROBE, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
				"Unable to allocate memory "
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
				"for the receive descriptor ring\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
			goto setup_rx_desc_die;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
		if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
			/* give up */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
			pci_free_consistent(pdev, rxdr->size, rxdr->desc,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
					    rxdr->dma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
			pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
			DPRINTK(PROBE, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
				"Unable to allocate aligned memory "
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
				"for the receive descriptor ring\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
			goto setup_rx_desc_die;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
		} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
			/* Free old allocation, new allocation was successful */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
			pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1882
	memset(rxdr->desc, 0, rxdr->size);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
	rxdr->next_to_clean = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
	rxdr->next_to_use = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
	return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
 * e1000_setup_all_rx_resources - wrapper to allocate Rx resources
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
 * 				  (Descriptors) for all queues
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
 * Return 0 on success, negative on failure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
e1000_setup_all_rx_resources(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
	int i, err = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
	for (i = 0; i < adapter->num_rx_queues; i++) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
		err = e1000_setup_rx_resources(adapter, &adapter->rx_ring[i]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
		if (err) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
			DPRINTK(PROBE, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
				"Allocation for Rx Queue %u failed\n", i);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
			for (i-- ; i >= 0; i--)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
				e1000_free_rx_resources(adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
							&adapter->rx_ring[i]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
	return err;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
 * e1000_setup_rctl - configure the receive control registers
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
 * @adapter: Board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
#define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
			(((S) & (PAGE_SIZE - 1)) ? 1 : 0))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
e1000_setup_rctl(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
	uint32_t rctl, rfctl;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
	uint32_t psrctl = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
	uint32_t pages = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
	rctl = E1000_READ_REG(&adapter->hw, RCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
	rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
	rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
		E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
		(adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
	if (adapter->hw.tbi_compatibility_on == 1)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
		rctl |= E1000_RCTL_SBP;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
	else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
		rctl &= ~E1000_RCTL_SBP;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
	if (adapter->netdev->mtu <= ETH_DATA_LEN)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
		rctl &= ~E1000_RCTL_LPE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
	else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
		rctl |= E1000_RCTL_LPE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
	/* Setup buffer sizes */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
	rctl &= ~E1000_RCTL_SZ_4096;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
	rctl |= E1000_RCTL_BSEX;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
	switch (adapter->rx_buffer_len) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
		case E1000_RXBUFFER_256:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
			rctl |= E1000_RCTL_SZ_256;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
			rctl &= ~E1000_RCTL_BSEX;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
		case E1000_RXBUFFER_512:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
			rctl |= E1000_RCTL_SZ_512;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
			rctl &= ~E1000_RCTL_BSEX;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
		case E1000_RXBUFFER_1024:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
			rctl |= E1000_RCTL_SZ_1024;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
			rctl &= ~E1000_RCTL_BSEX;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
		case E1000_RXBUFFER_2048:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
		default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
			rctl |= E1000_RCTL_SZ_2048;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
			rctl &= ~E1000_RCTL_BSEX;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
		case E1000_RXBUFFER_4096:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
			rctl |= E1000_RCTL_SZ_4096;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
		case E1000_RXBUFFER_8192:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
			rctl |= E1000_RCTL_SZ_8192;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
		case E1000_RXBUFFER_16384:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
			rctl |= E1000_RCTL_SZ_16384;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
	/* 82571 and greater support packet-split where the protocol
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
	 * header is placed in skb->data and the packet data is
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
	 * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
	 * In the case of a non-split, skb->data is linearly filled,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
	 * followed by the page buffers.  Therefore, skb->data is
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
	 * sized to hold the largest protocol header.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
	 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1991
	/* allocations using alloc_page take too long for regular MTU
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
	 * so only enable packet split for jumbo frames */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1993
	pages = PAGE_USE_COUNT(adapter->netdev->mtu);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
	if ((adapter->hw.mac_type >= e1000_82571) && (pages <= 3) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
	    PAGE_SIZE <= 16384 && (rctl & E1000_RCTL_LPE))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
		adapter->rx_ps_pages = pages;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
	else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
		adapter->rx_ps_pages = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
	if (adapter->rx_ps_pages) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
		/* Configure extra packet-split registers */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
		rfctl = E1000_READ_REG(&adapter->hw, RFCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
		rfctl |= E1000_RFCTL_EXTEN;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
		/* disable packet split support for IPv6 extension headers,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
		 * because some malformed IPv6 headers can hang the RX */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
		rfctl |= (E1000_RFCTL_IPV6_EX_DIS |
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
		          E1000_RFCTL_NEW_IPV6_EXT_DIS);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
		E1000_WRITE_REG(&adapter->hw, RFCTL, rfctl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
		rctl |= E1000_RCTL_DTYP_PS;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
		psrctl |= adapter->rx_ps_bsize0 >>
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
			E1000_PSRCTL_BSIZE0_SHIFT;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2015
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
		switch (adapter->rx_ps_pages) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
		case 3:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
			psrctl |= PAGE_SIZE <<
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
				E1000_PSRCTL_BSIZE3_SHIFT;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
		case 2:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
			psrctl |= PAGE_SIZE <<
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
				E1000_PSRCTL_BSIZE2_SHIFT;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
		case 1:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
			psrctl |= PAGE_SIZE >>
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
				E1000_PSRCTL_BSIZE1_SHIFT;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
		E1000_WRITE_REG(&adapter->hw, PSRCTL, psrctl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
	E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
 * e1000_configure_rx - Configure 8254x Receive Unit after Reset
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
 * Configure the Rx unit of the MAC after a reset.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
e1000_configure_rx(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
	uint64_t rdba;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
	struct e1000_hw *hw = &adapter->hw;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
	uint32_t rdlen, rctl, rxcsum, ctrl_ext;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
	if (adapter->rx_ps_pages) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
		/* this is a 32 byte descriptor */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
		rdlen = adapter->rx_ring[0].count *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
			sizeof(union e1000_rx_desc_packet_split);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
		adapter->clean_rx = e1000_clean_rx_irq_ps;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
		adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
	} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
		rdlen = adapter->rx_ring[0].count *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
			sizeof(struct e1000_rx_desc);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
		adapter->clean_rx = e1000_clean_rx_irq;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
		adapter->alloc_rx_buf = e1000_alloc_rx_buffers;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
	/* disable receives while setting up the descriptors */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
	rctl = E1000_READ_REG(hw, RCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
	E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
	/* set the Receive Delay Timer Register */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2067
	E1000_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2069
	if (hw->mac_type >= e1000_82540) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
		E1000_WRITE_REG(hw, RADV, adapter->rx_abs_int_delay);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
		if (adapter->itr_setting != 0)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2072
			E1000_WRITE_REG(hw, ITR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2073
				1000000000 / (adapter->itr * 256));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2075
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
	if (hw->mac_type >= e1000_82571) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
		ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
		/* Reset delay timers after every interrupt */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
		ctrl_ext |= E1000_CTRL_EXT_INT_TIMER_CLR;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
		/* Auto-Mask interrupts upon ICR access */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2082
		ctrl_ext |= E1000_CTRL_EXT_IAME;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
		E1000_WRITE_REG(hw, IAM, 0xffffffff);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
		E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
		E1000_WRITE_FLUSH(hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
	/* Setup the HW Rx Head and Tail Descriptor Pointers and
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
	 * the Base and Length of the Rx Descriptor Ring */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
	switch (adapter->num_rx_queues) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
	case 1:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
	default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
		rdba = adapter->rx_ring[0].dma;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
		E1000_WRITE_REG(hw, RDLEN, rdlen);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
		E1000_WRITE_REG(hw, RDBAH, (rdba >> 32));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
		E1000_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
		E1000_WRITE_REG(hw, RDT, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
		E1000_WRITE_REG(hw, RDH, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
		adapter->rx_ring[0].rdh = ((hw->mac_type >= e1000_82543) ? E1000_RDH : E1000_82542_RDH);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
		adapter->rx_ring[0].rdt = ((hw->mac_type >= e1000_82543) ? E1000_RDT : E1000_82542_RDT);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
	/* Enable 82543 Receive Checksum Offload for TCP and UDP */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
	if (hw->mac_type >= e1000_82543) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
		rxcsum = E1000_READ_REG(hw, RXCSUM);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2108
		if (adapter->rx_csum == TRUE) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
			rxcsum |= E1000_RXCSUM_TUOFL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
			/* Enable 82571 IPv4 payload checksum for UDP fragments
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
			 * Must be used in conjunction with packet-split. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
			if ((hw->mac_type >= e1000_82571) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
			    (adapter->rx_ps_pages)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
				rxcsum |= E1000_RXCSUM_IPPCSE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2117
		} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2118
			rxcsum &= ~E1000_RXCSUM_TUOFL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
			/* don't need to clear IPPCSE as it defaults to 0 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2120
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
		E1000_WRITE_REG(hw, RXCSUM, rxcsum);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
	/* enable early receives on 82573, only takes effect if using > 2048
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
	 * byte total frame size.  for example only for jumbo frames */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
#define E1000_ERT_2048 0x100
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
	if (hw->mac_type == e1000_82573)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
		E1000_WRITE_REG(hw, ERT, E1000_ERT_2048);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2129
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
	/* Enable Receives */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
	E1000_WRITE_REG(hw, RCTL, rctl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2135
 * e1000_free_tx_resources - Free Tx Resources per Queue
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2137
 * @tx_ring: Tx descriptor ring for a specific queue
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
 * Free all transmit software resources
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
e1000_free_tx_resources(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
                        struct e1000_tx_ring *tx_ring)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
	struct pci_dev *pdev = adapter->pdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2148
	e1000_clean_tx_ring(adapter, tx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2149
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2150
	vfree(tx_ring->buffer_info);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
	tx_ring->buffer_info = NULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2153
	pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2154
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
	tx_ring->desc = NULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2157
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
 * e1000_free_all_tx_resources - Free Tx Resources for All Queues
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
 * Free all transmit software resources
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2164
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
e1000_free_all_tx_resources(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2167
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
	int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2170
	for (i = 0; i < adapter->num_tx_queues; i++)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2171
		e1000_free_tx_resources(adapter, &adapter->tx_ring[i]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2172
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2173
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2174
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2176
			struct e1000_buffer *buffer_info)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2177
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
	if (adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2179
		return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2180
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
	if (buffer_info->dma) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2182
		pci_unmap_page(adapter->pdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
				buffer_info->dma,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
				buffer_info->length,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2185
				PCI_DMA_TODEVICE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
		buffer_info->dma = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
	if (buffer_info->skb) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2189
		dev_kfree_skb_any(buffer_info->skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2190
		buffer_info->skb = NULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2192
	/* buffer_info must be completely set up in the transmit path */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2195
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
 * e1000_clean_tx_ring - Free Tx Buffers
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2198
 * @tx_ring: ring to be cleaned
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2199
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
e1000_clean_tx_ring(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
                    struct e1000_tx_ring *tx_ring)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
	struct e1000_buffer *buffer_info;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2206
	unsigned long size;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
	unsigned int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
	/* Free all the Tx ring sk_buffs */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
	for (i = 0; i < tx_ring->count; i++) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
		buffer_info = &tx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
		e1000_unmap_and_free_tx_resource(adapter, buffer_info);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2214
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2216
	size = sizeof(struct e1000_buffer) * tx_ring->count;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
	memset(tx_ring->buffer_info, 0, size);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2219
	/* Zero out the descriptor ring */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2221
	memset(tx_ring->desc, 0, tx_ring->size);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
	tx_ring->next_to_use = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2224
	tx_ring->next_to_clean = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
	tx_ring->last_tx_tso = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2226
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2227
	writel(0, adapter->hw.hw_addr + tx_ring->tdh);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
	writel(0, adapter->hw.hw_addr + tx_ring->tdt);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
 * e1000_clean_all_tx_rings - Free Tx Buffers for all queues
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
e1000_clean_all_tx_rings(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
	int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2241
	for (i = 0; i < adapter->num_tx_queues; i++)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
		e1000_clean_tx_ring(adapter, &adapter->tx_ring[i]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2244
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2246
 * e1000_free_rx_resources - Free Rx Resources
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2247
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2248
 * @rx_ring: ring to clean the resources from
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
 * Free all receive software resources
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
e1000_free_rx_resources(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
                        struct e1000_rx_ring *rx_ring)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2256
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
	struct pci_dev *pdev = adapter->pdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
	e1000_clean_rx_ring(adapter, rx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
	vfree(rx_ring->buffer_info);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
	rx_ring->buffer_info = NULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
	kfree(rx_ring->ps_page);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
	rx_ring->ps_page = NULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
	kfree(rx_ring->ps_page_dma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
	rx_ring->ps_page_dma = NULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
	pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
	rx_ring->desc = NULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
 * e1000_free_all_rx_resources - Free Rx Resources for All Queues
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
 * Free all receive software resources
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2279
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2280
void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
e1000_free_all_rx_resources(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2283
	int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
	for (i = 0; i < adapter->num_rx_queues; i++)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
		e1000_free_rx_resources(adapter, &adapter->rx_ring[i]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2287
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
 * e1000_clean_rx_ring - Free Rx Buffers per Queue
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2292
 * @rx_ring: ring to free buffers from
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
e1000_clean_rx_ring(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
                    struct e1000_rx_ring *rx_ring)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
	struct e1000_buffer *buffer_info;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2300
	struct e1000_ps_page *ps_page;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
	struct e1000_ps_page_dma *ps_page_dma;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
	struct pci_dev *pdev = adapter->pdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
	unsigned long size;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
	unsigned int i, j;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2305
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
	/* Free all the Rx ring sk_buffs */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
	for (i = 0; i < rx_ring->count; i++) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
		buffer_info = &rx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
		if (buffer_info->skb) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
			pci_unmap_single(pdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
					 buffer_info->dma,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
					 buffer_info->length,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
					 PCI_DMA_FROMDEVICE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2314
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2315
			dev_kfree_skb(buffer_info->skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2316
			buffer_info->skb = NULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2317
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2318
		ps_page = &rx_ring->ps_page[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2319
		ps_page_dma = &rx_ring->ps_page_dma[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2320
		for (j = 0; j < adapter->rx_ps_pages; j++) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2321
			if (!ps_page->ps_page[j]) break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2322
			pci_unmap_page(pdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2323
				       ps_page_dma->ps_page_dma[j],
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
				       PAGE_SIZE, PCI_DMA_FROMDEVICE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2325
			ps_page_dma->ps_page_dma[j] = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
			put_page(ps_page->ps_page[j]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
			ps_page->ps_page[j] = NULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2330
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
	size = sizeof(struct e1000_buffer) * rx_ring->count;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
	memset(rx_ring->buffer_info, 0, size);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
	size = sizeof(struct e1000_ps_page) * rx_ring->count;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
	memset(rx_ring->ps_page, 0, size);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
	size = sizeof(struct e1000_ps_page_dma) * rx_ring->count;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
	memset(rx_ring->ps_page_dma, 0, size);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2338
	/* Zero out the descriptor ring */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2339
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
	memset(rx_ring->desc, 0, rx_ring->size);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2342
	rx_ring->next_to_clean = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2343
	rx_ring->next_to_use = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
	writel(0, adapter->hw.hw_addr + rx_ring->rdh);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
	writel(0, adapter->hw.hw_addr + rx_ring->rdt);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2349
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
 * e1000_clean_all_rx_rings - Free Rx Buffers for all queues
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
e1000_clean_all_rx_rings(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
	int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2358
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
	for (i = 0; i < adapter->num_rx_queues; i++)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
		e1000_clean_rx_ring(adapter, &adapter->rx_ring[i]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
/* The 82542 2.0 (revision 2) needs to have the receive unit in reset
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
 * and memory write and invalidate disabled for certain operations
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2367
e1000_enter_82542_rst(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2370
	uint32_t rctl;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
	e1000_pci_clear_mwi(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
	rctl = E1000_READ_REG(&adapter->hw, RCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2375
	rctl |= E1000_RCTL_RST;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
	E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2377
	E1000_WRITE_FLUSH(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2378
	mdelay(5);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
	if (!adapter->ecdev && netif_running(netdev))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
		e1000_clean_all_rx_rings(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
e1000_leave_82542_rst(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2386
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2387
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2388
	uint32_t rctl;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2389
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
	rctl = E1000_READ_REG(&adapter->hw, RCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
	rctl &= ~E1000_RCTL_RST;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2392
	E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2393
	E1000_WRITE_FLUSH(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2394
	mdelay(5);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
	if (adapter->hw.pci_cmd_word & PCI_COMMAND_INVALIDATE)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
		e1000_pci_set_mwi(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
	if (!adapter->netdev && netif_running(netdev)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2400
		/* No need to loop, because 82542 supports only 1 queue */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2401
		struct e1000_rx_ring *ring = &adapter->rx_ring[0];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
		e1000_configure_rx(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2403
		adapter->alloc_rx_buf(adapter, ring, E1000_DESC_UNUSED(ring));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2404
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
 * e1000_set_mac - Change the Ethernet Address of the NIC
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
 * @netdev: network interface device structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
 * @p: pointer to an address structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
 * Returns 0 on success, negative on failure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
e1000_set_mac(struct net_device *netdev, void *p)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2418
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
	struct sockaddr *addr = p;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
	if (!is_valid_ether_addr(addr->sa_data))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2422
		return -EADDRNOTAVAIL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
	/* 82542 2.0 needs to be in reset to write receive address registers */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
	if (adapter->hw.mac_type == e1000_82542_rev2_0)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
		e1000_enter_82542_rst(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
	memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
	e1000_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
	/* With 82571 controllers, LAA may be overwritten (with the default)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
	 * due to controller reset from the other port. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
	if (adapter->hw.mac_type == e1000_82571) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2437
		/* activate the work around */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2438
		adapter->hw.laa_is_present = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2440
		/* Hold a copy of the LAA in RAR[14] This is done so that
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
		 * between the time RAR[0] gets clobbered  and the time it
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2442
		 * gets fixed (in e1000_watchdog), the actual LAA is in one
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
		 * of the RARs and no incoming packets directed to this port
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
		 * are dropped. Eventaully the LAA will be in RAR[0] and
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2445
		 * RAR[14] */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2446
		e1000_rar_set(&adapter->hw, adapter->hw.mac_addr,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2447
					E1000_RAR_ENTRIES - 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2448
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
	if (adapter->hw.mac_type == e1000_82542_rev2_0)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
		e1000_leave_82542_rst(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2452
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
	return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2455
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
 * e1000_set_multi - Multicast and Promiscuous mode set
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
 * @netdev: network interface device structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
 * The set_multi entry point is called whenever the multicast address
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2461
 * list or the network interface flags are updated.  This routine is
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
 * responsible for configuring the hardware for proper multicast,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
 * promiscuous mode, and all-multi behavior.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
e1000_set_multi(struct net_device *netdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2470
	struct e1000_hw *hw = &adapter->hw;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2471
	struct dev_mc_list *mc_ptr;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2472
	uint32_t rctl;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2473
	uint32_t hash_value;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2474
	int i, rar_entries = E1000_RAR_ENTRIES;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2475
	int mta_reg_count = (hw->mac_type == e1000_ich8lan) ?
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2476
				E1000_NUM_MTA_REGISTERS_ICH8LAN :
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
				E1000_NUM_MTA_REGISTERS;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2478
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
	if (adapter->hw.mac_type == e1000_ich8lan)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2480
		rar_entries = E1000_RAR_ENTRIES_ICH8LAN;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
	/* reserve RAR[14] for LAA over-write work-around */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2483
	if (adapter->hw.mac_type == e1000_82571)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2484
		rar_entries--;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2485
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
	/* Check for Promiscuous and All Multicast modes */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2487
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2488
	rctl = E1000_READ_REG(hw, RCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2489
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2490
	if (netdev->flags & IFF_PROMISC) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
		rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
	} else if (netdev->flags & IFF_ALLMULTI) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
		rctl |= E1000_RCTL_MPE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
		rctl &= ~E1000_RCTL_UPE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
	} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2496
		rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2498
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2499
	E1000_WRITE_REG(hw, RCTL, rctl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
	/* 82542 2.0 needs to be in reset to write receive address registers */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2502
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2503
	if (hw->mac_type == e1000_82542_rev2_0)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2504
		e1000_enter_82542_rst(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2505
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
	/* load the first 14 multicast address into the exact filters 1-14
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2507
	 * RAR 0 is used for the station MAC adddress
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2508
	 * if there are not 14 addresses, go ahead and clear the filters
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2509
	 * -- with 82571 controllers only 0-13 entries are filled here
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2510
	 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
	mc_ptr = netdev->mc_list;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2512
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2513
	for (i = 1; i < rar_entries; i++) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2514
		if (mc_ptr) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
			e1000_rar_set(hw, mc_ptr->dmi_addr, i);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
			mc_ptr = mc_ptr->next;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
		} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2518
			E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2519
			E1000_WRITE_FLUSH(hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
			E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2521
			E1000_WRITE_FLUSH(hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2522
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2525
	/* clear the old settings from the multicast hash table */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
	for (i = 0; i < mta_reg_count; i++) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2528
		E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2529
		E1000_WRITE_FLUSH(hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2531
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2532
	/* load any remaining addresses into the hash table */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2533
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
	for (; mc_ptr; mc_ptr = mc_ptr->next) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2535
		hash_value = e1000_hash_mc_addr(hw, mc_ptr->dmi_addr);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2536
		e1000_mta_set(hw, hash_value);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2537
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2538
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2539
	if (hw->mac_type == e1000_82542_rev2_0)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2540
		e1000_leave_82542_rst(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2541
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2542
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2543
/* Need to wait a few seconds after link up to get diagnostic information from
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2544
 * the phy */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2545
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2546
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2547
e1000_update_phy_info(unsigned long data)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2548
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2549
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2550
	e1000_phy_get_info(&adapter->hw, &adapter->phy_info);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2551
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2552
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2553
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2554
 * e1000_82547_tx_fifo_stall - Timer Call-back
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2555
 * @data: pointer to adapter cast into an unsigned long
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2556
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2557
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2558
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2559
e1000_82547_tx_fifo_stall(unsigned long data)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2560
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2561
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2562
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
	uint32_t tctl;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2564
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2565
	if (atomic_read(&adapter->tx_fifo_stall)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2566
		if ((E1000_READ_REG(&adapter->hw, TDT) ==
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2567
		    E1000_READ_REG(&adapter->hw, TDH)) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
		   (E1000_READ_REG(&adapter->hw, TDFT) ==
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2569
		    E1000_READ_REG(&adapter->hw, TDFH)) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2570
		   (E1000_READ_REG(&adapter->hw, TDFTS) ==
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2571
		    E1000_READ_REG(&adapter->hw, TDFHS))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2572
			tctl = E1000_READ_REG(&adapter->hw, TCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
			E1000_WRITE_REG(&adapter->hw, TCTL,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2574
					tctl & ~E1000_TCTL_EN);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2575
			E1000_WRITE_REG(&adapter->hw, TDFT,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2576
					adapter->tx_head_addr);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2577
			E1000_WRITE_REG(&adapter->hw, TDFH,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2578
					adapter->tx_head_addr);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2579
			E1000_WRITE_REG(&adapter->hw, TDFTS,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2580
					adapter->tx_head_addr);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2581
			E1000_WRITE_REG(&adapter->hw, TDFHS,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2582
					adapter->tx_head_addr);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2583
			E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2584
			E1000_WRITE_FLUSH(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2585
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2586
			adapter->tx_fifo_head = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2587
			atomic_set(&adapter->tx_fifo_stall, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
			if (!adapter->ecdev) netif_wake_queue(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2589
		} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2590
			if (!adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
				mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2592
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2593
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2594
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2595
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2596
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2597
 * e1000_watchdog - Timer Call-back
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
 * @data: pointer to adapter cast into an unsigned long
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2599
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2601
e1000_watchdog(unsigned long data)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2602
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2604
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2605
	struct e1000_tx_ring *txdr = adapter->tx_ring;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2606
	uint32_t link, tctl;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2607
	int32_t ret_val;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2608
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2609
	ret_val = e1000_check_for_link(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2610
	if ((ret_val == E1000_ERR_PHY) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2611
	    (adapter->hw.phy_type == e1000_phy_igp_3) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2612
	    (E1000_READ_REG(&adapter->hw, CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2613
		/* See e1000_kumeran_lock_loss_workaround() */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
		DPRINTK(LINK, INFO,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2615
			"Gigabit has been disabled, downgrading speed\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2617
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2618
	if (adapter->hw.mac_type == e1000_82573) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2619
		e1000_enable_tx_pkt_filtering(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2620
		if (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2621
			e1000_update_mng_vlan(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2622
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2623
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
	if ((adapter->hw.media_type == e1000_media_type_internal_serdes) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2625
	   !(E1000_READ_REG(&adapter->hw, TXCW) & E1000_TXCW_ANE))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
		link = !adapter->hw.serdes_link_down;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2627
	else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
		link = E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2629
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
	if (link) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
		if ((adapter->ecdev && !ecdev_get_link(adapter->ecdev))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
				|| (!adapter->ecdev && !netif_carrier_ok(netdev))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2633
			uint32_t ctrl;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
			boolean_t txb2b = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
			e1000_get_speed_and_duplex(&adapter->hw,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
			                           &adapter->link_speed,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2637
			                           &adapter->link_duplex);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
			ctrl = E1000_READ_REG(&adapter->hw, CTRL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2640
			DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s, "
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
			        "Flow Control: %s\n",
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
			        adapter->link_speed,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2643
			        adapter->link_duplex == FULL_DUPLEX ?
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2644
			        "Full Duplex" : "Half Duplex",
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2645
			        ((ctrl & E1000_CTRL_TFCE) && (ctrl &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2646
			        E1000_CTRL_RFCE)) ? "RX/TX" : ((ctrl &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2647
			        E1000_CTRL_RFCE) ? "RX" : ((ctrl &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2648
			        E1000_CTRL_TFCE) ? "TX" : "None" )));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2649
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2650
			/* tweak tx_queue_len according to speed/duplex
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2651
			 * and adjust the timeout factor */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2652
			netdev->tx_queue_len = adapter->tx_queue_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
			adapter->tx_timeout_factor = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
			switch (adapter->link_speed) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2655
			case SPEED_10:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
				txb2b = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
				netdev->tx_queue_len = 10;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2658
				adapter->tx_timeout_factor = 8;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2659
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2660
			case SPEED_100:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2661
				txb2b = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2662
				netdev->tx_queue_len = 100;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2663
				/* maybe add some timeout factor ? */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2664
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2665
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2666
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2667
			if ((adapter->hw.mac_type == e1000_82571 ||
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2668
			     adapter->hw.mac_type == e1000_82572) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
			    txb2b == 0) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
				uint32_t tarc0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
				tarc0 = E1000_READ_REG(&adapter->hw, TARC0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
				tarc0 &= ~(1 << 21);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
				E1000_WRITE_REG(&adapter->hw, TARC0, tarc0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2674
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2676
			/* disable TSO for pcie and 10/100 speeds, to avoid
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2677
			 * some hardware issues */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
			if (!adapter->tso_force &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2679
			    adapter->hw.bus_type == e1000_bus_type_pci_express){
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2680
				switch (adapter->link_speed) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2681
				case SPEED_10:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
				case SPEED_100:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
					DPRINTK(PROBE,INFO,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2684
				        "10/100 speed: disabling TSO\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2685
					netdev->features &= ~NETIF_F_TSO;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2686
					netdev->features &= ~NETIF_F_TSO6;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2687
					break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2688
				case SPEED_1000:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
					netdev->features |= NETIF_F_TSO;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2690
					netdev->features |= NETIF_F_TSO6;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2691
					break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2692
				default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2693
					/* oops */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2694
					break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2695
				}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2696
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2697
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
			/* enable transmits in the hardware, need to do this
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2699
			 * after setting TARC0 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2700
			tctl = E1000_READ_REG(&adapter->hw, TCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
			tctl |= E1000_TCTL_EN;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2702
			E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2703
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2704
			if (adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2705
				ecdev_set_link(adapter->ecdev, 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2706
			} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2707
				netif_carrier_on(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2708
				netif_wake_queue(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2709
				mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2710
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2711
			adapter->smartspeed = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
		} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2713
			/* make sure the receive unit is started */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2714
			if (adapter->hw.rx_needs_kicking) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
				struct e1000_hw *hw = &adapter->hw;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2716
				uint32_t rctl = E1000_READ_REG(hw, RCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
				E1000_WRITE_REG(hw, RCTL, rctl | E1000_RCTL_EN);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2718
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2719
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
	} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2721
		if ((adapter->ecdev && ecdev_get_link(adapter->ecdev))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2722
				|| (!adapter->ecdev && netif_carrier_ok(netdev))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
			adapter->link_speed = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2724
			adapter->link_duplex = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2725
			DPRINTK(LINK, INFO, "NIC Link is Down\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
			if (adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
				ecdev_set_link(adapter->ecdev, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2728
			} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2729
				netif_carrier_off(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
				netif_stop_queue(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2731
				mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2732
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
			/* 80003ES2LAN workaround--
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2735
			 * For packet buffer work-around on link down event;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2736
			 * disable receives in the ISR and
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2737
			 * reset device here in the watchdog
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2738
			 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
			if (adapter->hw.mac_type == e1000_80003es2lan)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2740
				/* reset device */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2741
				schedule_work(&adapter->reset_task);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2742
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2743
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2744
		e1000_smartspeed(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2745
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2747
	e1000_update_stats(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
	adapter->hw.tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
	adapter->tpt_old = adapter->stats.tpt;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
	adapter->hw.collision_delta = adapter->stats.colc - adapter->colc_old;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2752
	adapter->colc_old = adapter->stats.colc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2753
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
	adapter->gorcl = adapter->stats.gorcl - adapter->gorcl_old;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
	adapter->gorcl_old = adapter->stats.gorcl;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
	adapter->gotcl = adapter->stats.gotcl - adapter->gotcl_old;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2757
	adapter->gotcl_old = adapter->stats.gotcl;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2758
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
	e1000_update_adaptive(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2761
	if (!adapter->ecdev && !netif_carrier_ok(netdev)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2762
		if (E1000_DESC_UNUSED(txdr) + 1 < txdr->count) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
			/* We've lost link, so the controller stops DMA,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
			 * but we've got queued Tx work that's never going
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2765
			 * to get done, so reset controller to flush Tx.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2766
			 * (Do the reset outside of interrupt context). */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
			adapter->tx_timeout_count++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2768
			schedule_work(&adapter->reset_task);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2769
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2770
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2772
	/* Cause software interrupt to ensure rx ring is cleaned */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
	E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
	/* Force detection of hung controller every watchdog period */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
	if (!adapter->ecdev) adapter->detect_tx_hung = TRUE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2778
	/* With 82571 controllers, LAA may be overwritten due to controller
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2779
	 * reset from the other port. Set the appropriate LAA in RAR[0] */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
	if (adapter->hw.mac_type == e1000_82571 && adapter->hw.laa_is_present)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2781
		e1000_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2783
	/* Reset the timer */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
	if (!adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
		mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 2 * HZ));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2788
enum latency_range {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
	lowest_latency = 0,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
	low_latency = 1,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2791
	bulk_latency = 2,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
	latency_invalid = 255
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
};
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
 * e1000_update_itr - update the dynamic ITR value based on statistics
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2797
 *      Stores a new ITR value based on packets and byte
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2798
 *      counts during the last interrupt.  The advantage of per interrupt
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
 *      computation is faster updates and more accurate ITR for the current
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
 *      traffic pattern.  Constants in this function were computed
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
 *      based on theoretical maximum wire speed and thresholds were set based
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
 *      on testing data as well as attempting to minimize response time
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2803
 *      while increasing bulk throughput.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
 *      this functionality is controlled by the InterruptThrottleRate module
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
 *      parameter (see e1000_param.c)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2806
 * @adapter: pointer to adapter
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2807
 * @itr_setting: current adapter->itr
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
 * @packets: the number of packets during this measurement interval
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2809
 * @bytes: the number of bytes during this measurement interval
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2810
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
                                   uint16_t itr_setting,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
                                   int packets,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2814
                                   int bytes)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2815
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2816
	unsigned int retval = itr_setting;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2817
	struct e1000_hw *hw = &adapter->hw;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2818
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2819
	if (unlikely(hw->mac_type < e1000_82540))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2820
		goto update_itr_done;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2821
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2822
	if (packets == 0)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
		goto update_itr_done;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2825
	switch (itr_setting) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2826
	case lowest_latency:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
		/* jumbo frames get bulk treatment*/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
		if (bytes/packets > 8000)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2829
			retval = bulk_latency;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2830
		else if ((packets < 5) && (bytes > 512))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
			retval = low_latency;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
	case low_latency:  /* 50 usec aka 20000 ints/s */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2834
		if (bytes > 10000) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
			/* jumbo frames need bulk latency setting */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2836
			if (bytes/packets > 8000)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2837
				retval = bulk_latency;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2838
			else if ((packets < 10) || ((bytes/packets) > 1200))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2839
				retval = bulk_latency;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2840
			else if ((packets > 35))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
				retval = lowest_latency;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2842
		} else if (bytes/packets > 2000)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2843
			retval = bulk_latency;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
		else if (packets <= 2 && bytes < 512)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
			retval = lowest_latency;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2846
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2847
	case bulk_latency: /* 250 usec aka 4000 ints/s */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
		if (bytes > 25000) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2849
			if (packets > 35)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2850
				retval = low_latency;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2851
		} else if (bytes < 6000) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
			retval = low_latency;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2854
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2855
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2856
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2857
update_itr_done:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2858
	return retval;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
static void e1000_set_itr(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2862
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2863
	struct e1000_hw *hw = &adapter->hw;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
	uint16_t current_itr;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
	uint32_t new_itr = adapter->itr;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2866
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2867
	if (unlikely(hw->mac_type < e1000_82540))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
		return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2869
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2870
	/* for non-gigabit speeds, just fix the interrupt rate at 4000 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2871
	if (unlikely(adapter->link_speed != SPEED_1000)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2872
		current_itr = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2873
		new_itr = 4000;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2874
		goto set_itr_now;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2876
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2877
	adapter->tx_itr = e1000_update_itr(adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2878
	                            adapter->tx_itr,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2879
	                            adapter->total_tx_packets,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2880
	                            adapter->total_tx_bytes);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
	/* conservative mode (itr 3) eliminates the lowest_latency setting */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
	if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
		adapter->tx_itr = low_latency;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
	adapter->rx_itr = e1000_update_itr(adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2886
	                            adapter->rx_itr,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2887
	                            adapter->total_rx_packets,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2888
	                            adapter->total_rx_bytes);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2889
	/* conservative mode (itr 3) eliminates the lowest_latency setting */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2890
	if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2891
		adapter->rx_itr = low_latency;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2892
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2893
	current_itr = max(adapter->rx_itr, adapter->tx_itr);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2894
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2895
	switch (current_itr) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2896
	/* counts and packets in update_itr are dependent on these numbers */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
	case lowest_latency:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2898
		new_itr = 70000;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2899
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
	case low_latency:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
		new_itr = 20000; /* aka hwitr = ~200 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2902
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2903
	case bulk_latency:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
		new_itr = 4000;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
	default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2909
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2910
set_itr_now:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
	if (new_itr != adapter->itr) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2912
		/* this attempts to bias the interrupt rate towards Bulk
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2913
		 * by adding intermediate steps when interrupt rate is
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2914
		 * increasing */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2915
		new_itr = new_itr > adapter->itr ?
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
		             min(adapter->itr + (new_itr >> 2), new_itr) :
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2917
		             new_itr;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2918
		adapter->itr = new_itr;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
		E1000_WRITE_REG(hw, ITR, 1000000000 / (new_itr * 256));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2920
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2921
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
	return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2923
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2924
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2925
#define E1000_TX_FLAGS_CSUM		0x00000001
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2926
#define E1000_TX_FLAGS_VLAN		0x00000002
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
#define E1000_TX_FLAGS_TSO		0x00000004
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2928
#define E1000_TX_FLAGS_IPV4		0x00000008
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
#define E1000_TX_FLAGS_VLAN_MASK	0xffff0000
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
#define E1000_TX_FLAGS_VLAN_SHIFT	16
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2931
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
          struct sk_buff *skb)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
	struct e1000_context_desc *context_desc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2937
	struct e1000_buffer *buffer_info;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
	unsigned int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
	uint32_t cmd_length = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
	uint16_t ipcse = 0, tucse, mss;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
	uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
	int err;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
	if (skb_is_gso(skb)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
		if (skb_header_cloned(skb)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2946
			err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
			if (err)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2948
				return err;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2949
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2951
		hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
		mss = skb_shinfo(skb)->gso_size;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
		if (skb->protocol == htons(ETH_P_IP)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
			struct iphdr *iph = ip_hdr(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
			iph->tot_len = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
			iph->check = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
			tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2958
								 iph->daddr, 0,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2959
								 IPPROTO_TCP,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2960
								 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2961
			cmd_length = E1000_TXD_CMD_IP;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
			ipcse = skb_transport_offset(skb) - 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
		} else if (skb->protocol == htons(ETH_P_IPV6)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2964
			ipv6_hdr(skb)->payload_len = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
			tcp_hdr(skb)->check =
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
				~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
						 &ipv6_hdr(skb)->daddr,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
						 0, IPPROTO_TCP, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2969
			ipcse = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
		ipcss = skb_network_offset(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
		ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
		tucss = skb_transport_offset(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
		tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
		tucse = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2976
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2977
		cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2978
			       E1000_TXD_CMD_TCP | (skb->len - (hdr_len)));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2979
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2980
		i = tx_ring->next_to_use;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2981
		context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2982
		buffer_info = &tx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2983
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
		context_desc->lower_setup.ip_fields.ipcss  = ipcss;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
		context_desc->lower_setup.ip_fields.ipcso  = ipcso;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2986
		context_desc->lower_setup.ip_fields.ipcse  = cpu_to_le16(ipcse);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
		context_desc->upper_setup.tcp_fields.tucss = tucss;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
		context_desc->upper_setup.tcp_fields.tucso = tucso;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2989
		context_desc->upper_setup.tcp_fields.tucse = cpu_to_le16(tucse);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2990
		context_desc->tcp_seg_setup.fields.mss     = cpu_to_le16(mss);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
		context_desc->tcp_seg_setup.fields.hdr_len = hdr_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
		context_desc->cmd_and_length = cpu_to_le32(cmd_length);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
		buffer_info->time_stamp = jiffies;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
		buffer_info->next_to_watch = i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
		if (++i == tx_ring->count) i = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
		tx_ring->next_to_use = i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
		return TRUE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3001
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
	return FALSE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3004
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3005
static boolean_t
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3006
e1000_tx_csum(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
              struct sk_buff *skb)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3008
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3009
	struct e1000_context_desc *context_desc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
	struct e1000_buffer *buffer_info;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
	unsigned int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3012
	uint8_t css;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3013
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3014
	if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3015
		css = skb_transport_offset(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3016
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3017
		i = tx_ring->next_to_use;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3018
		buffer_info = &tx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3019
		context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3020
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3021
		context_desc->lower_setup.ip_config = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
		context_desc->upper_setup.tcp_fields.tucss = css;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3023
		context_desc->upper_setup.tcp_fields.tucso =
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3024
			css + skb->csum_offset;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
		context_desc->upper_setup.tcp_fields.tucse = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3026
		context_desc->tcp_seg_setup.data = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3027
		context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3029
		buffer_info->time_stamp = jiffies;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3030
		buffer_info->next_to_watch = i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3031
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3032
		if (unlikely(++i == tx_ring->count)) i = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
		tx_ring->next_to_use = i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
		return TRUE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3036
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
	return FALSE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3041
#define E1000_MAX_TXD_PWR	12
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3042
#define E1000_MAX_DATA_PER_TXD	(1<<E1000_MAX_TXD_PWR)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3044
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3045
e1000_tx_map(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
             struct sk_buff *skb, unsigned int first, unsigned int max_per_txd,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3047
             unsigned int nr_frags, unsigned int mss)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
	struct e1000_buffer *buffer_info;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3050
	unsigned int len = skb->len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3051
	unsigned int offset = 0, size, count = 0, i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3052
	unsigned int f;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3053
	len -= skb->data_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3054
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3055
	i = tx_ring->next_to_use;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3056
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3057
	while (len) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3058
		buffer_info = &tx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3059
		size = min(len, max_per_txd);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3060
		/* Workaround for Controller erratum --
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3061
		 * descriptor for non-tso packet in a linear SKB that follows a
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3062
		 * tso gets written back prematurely before the data is fully
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3063
		 * DMA'd to the controller */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3064
		if (!skb->data_len && tx_ring->last_tx_tso &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3065
		    !skb_is_gso(skb)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
			tx_ring->last_tx_tso = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3067
			size -= 4;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3070
		/* Workaround for premature desc write-backs
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3071
		 * in TSO mode.  Append 4-byte sentinel desc */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
		if (unlikely(mss && !nr_frags && size == len && size > 8))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3073
			size -= 4;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3074
		/* work-around for errata 10 and it applies
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3075
		 * to all controllers in PCI-X mode
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3076
		 * The fix is to make sure that the first descriptor of a
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3077
		 * packet is smaller than 2048 - 16 - 16 (or 2016) bytes
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
		 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3079
		if (unlikely((adapter->hw.bus_type == e1000_bus_type_pcix) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
		                (size > 2015) && count == 0))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3081
		        size = 2015;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3082
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
		/* Workaround for potential 82544 hang in PCI-X.  Avoid
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3084
		 * terminating buffers within evenly-aligned dwords. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3085
		if (unlikely(adapter->pcix_82544 &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
		   !((unsigned long)(skb->data + offset + size - 1) & 4) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3087
		   size > 4))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3088
			size -= 4;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3090
		buffer_info->length = size;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3091
		buffer_info->dma =
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
			pci_map_single(adapter->pdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
				skb->data + offset,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
				size,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
				PCI_DMA_TODEVICE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3096
		buffer_info->time_stamp = jiffies;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
		buffer_info->next_to_watch = i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3098
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3099
		len -= size;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
		offset += size;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
		count++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
		if (unlikely(++i == tx_ring->count)) i = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3103
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
	for (f = 0; f < nr_frags; f++) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
		struct skb_frag_struct *frag;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3107
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
		frag = &skb_shinfo(skb)->frags[f];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3109
		len = frag->size;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
		offset = frag->page_offset;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3111
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3112
		while (len) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3113
			buffer_info = &tx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3114
			size = min(len, max_per_txd);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3115
			/* Workaround for premature desc write-backs
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3116
			 * in TSO mode.  Append 4-byte sentinel desc */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3117
			if (unlikely(mss && f == (nr_frags-1) && size == len && size > 8))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3118
				size -= 4;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3119
			/* Workaround for potential 82544 hang in PCI-X.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3120
			 * Avoid terminating buffers within evenly-aligned
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
			 * dwords. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3122
			if (unlikely(adapter->pcix_82544 &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3123
			   !((unsigned long)(frag->page+offset+size-1) & 4) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
			   size > 4))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
				size -= 4;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3127
			buffer_info->length = size;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3128
			buffer_info->dma =
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3129
				pci_map_page(adapter->pdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
					frag->page,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3131
					offset,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3132
					size,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3133
					PCI_DMA_TODEVICE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
			buffer_info->time_stamp = jiffies;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3135
			buffer_info->next_to_watch = i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
			len -= size;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
			offset += size;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3139
			count++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
			if (unlikely(++i == tx_ring->count)) i = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3142
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3143
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
	i = (i == 0) ? tx_ring->count - 1 : i - 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
	tx_ring->buffer_info[i].skb = skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
	tx_ring->buffer_info[first].next_to_watch = i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3148
	return count;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3151
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3152
e1000_tx_queue(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
               int tx_flags, int count)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3154
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3155
	struct e1000_tx_desc *tx_desc = NULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3156
	struct e1000_buffer *buffer_info;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
	uint32_t txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3158
	unsigned int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3159
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3160
	if (likely(tx_flags & E1000_TX_FLAGS_TSO)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3161
		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D |
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3162
		             E1000_TXD_CMD_TSE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3163
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3164
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3165
		if (likely(tx_flags & E1000_TX_FLAGS_IPV4))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3166
			txd_upper |= E1000_TXD_POPTS_IXSM << 8;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3167
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3168
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3169
	if (likely(tx_flags & E1000_TX_FLAGS_CSUM)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3170
		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3172
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3173
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
	if (unlikely(tx_flags & E1000_TX_FLAGS_VLAN)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3175
		txd_lower |= E1000_TXD_CMD_VLE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3176
		txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3177
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3178
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3179
	i = tx_ring->next_to_use;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3180
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
	while (count--) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
		buffer_info = &tx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3183
		tx_desc = E1000_TX_DESC(*tx_ring, i);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
		tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3185
		tx_desc->lower.data =
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
			cpu_to_le32(txd_lower | buffer_info->length);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3187
		tx_desc->upper.data = cpu_to_le32(txd_upper);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
		if (unlikely(++i == tx_ring->count)) i = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3190
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
	tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
	/* Force memory writes to complete before letting h/w
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
	 * know there are new descriptors to fetch.  (Only
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3195
	 * applicable for weak-ordered memory model archs,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
	 * such as IA-64). */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
	wmb();
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3198
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
	tx_ring->next_to_use = i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3200
	writel(i, adapter->hw.hw_addr + tx_ring->tdt);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3201
	/* we need this if more than one processor can write to our tail
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3202
	 * at a time, it syncronizes IO on IA64/Altix systems */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3203
	mmiowb();
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3204
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3205
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3206
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3207
 * 82547 workaround to avoid controller hang in half-duplex environment.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3208
 * The workaround is to avoid queuing a large packet that would span
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3209
 * the internal Tx FIFO ring boundary by notifying the stack to resend
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3210
 * the packet at a later time.  This gives the Tx FIFO an opportunity to
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
 * flush all packets.  When that occurs, we reset the Tx FIFO pointers
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3212
 * to the beginning of the Tx FIFO.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3213
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3214
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3215
#define E1000_FIFO_HDR			0x10
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3216
#define E1000_82547_PAD_LEN		0x3E0
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3217
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
e1000_82547_fifo_workaround(struct e1000_adapter *adapter, struct sk_buff *skb)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3220
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
	uint32_t fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3222
	uint32_t skb_fifo_len = skb->len + E1000_FIFO_HDR;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
	skb_fifo_len = ALIGN(skb_fifo_len, E1000_FIFO_HDR);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
	if (adapter->link_duplex != HALF_DUPLEX)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
		goto no_fifo_stall_required;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
	if (atomic_read(&adapter->tx_fifo_stall))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
		return 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
	if (skb_fifo_len >= (E1000_82547_PAD_LEN + fifo_space)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
		atomic_set(&adapter->tx_fifo_stall, 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3234
		return 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3235
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3236
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3237
no_fifo_stall_required:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
	adapter->tx_fifo_head += skb_fifo_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
	if (adapter->tx_fifo_head >= adapter->tx_fifo_size)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3240
		adapter->tx_fifo_head -= adapter->tx_fifo_size;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
	return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3242
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3243
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
#define MINIMUM_DHCP_PACKET_SIZE 282
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3245
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3248
	struct e1000_hw *hw =  &adapter->hw;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
	uint16_t length, offset;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3250
	if (vlan_tx_tag_present(skb)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
		if (!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
			( adapter->hw.mng_cookie.status &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3253
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
			return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3255
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
	if (skb->len > MINIMUM_DHCP_PACKET_SIZE) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
		struct ethhdr *eth = (struct ethhdr *) skb->data;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3258
		if ((htons(ETH_P_IP) == eth->h_proto)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3259
			const struct iphdr *ip =
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
				(struct iphdr *)((uint8_t *)skb->data+14);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
			if (IPPROTO_UDP == ip->protocol) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
				struct udphdr *udp =
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3263
					(struct udphdr *)((uint8_t *)ip +
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3264
						(ip->ihl << 2));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3265
				if (ntohs(udp->dest) == 67) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3266
					offset = (uint8_t *)udp + 8 - skb->data;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3267
					length = skb->len - offset;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
					return e1000_mng_write_dhcp_info(hw,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
							(uint8_t *)udp + 8,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
							length);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3272
				}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3273
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3274
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3275
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3276
	return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3277
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3278
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
static int __e1000_maybe_stop_tx(struct net_device *netdev, int size)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3280
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3281
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
	struct e1000_tx_ring *tx_ring = adapter->tx_ring;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3284
	netif_stop_queue(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3285
	/* Herbert's original patch had:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
	 *  smp_mb__after_netif_stop_queue();
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
	 * but since that doesn't exist yet, just open code it. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3288
	smp_mb();
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3289
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
	/* We need to check again in a case another CPU has just
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3291
	 * made room available. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
	if (likely(E1000_DESC_UNUSED(tx_ring) < size))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
		return -EBUSY;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
	/* A reprieve! */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
	netif_start_queue(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3297
	++adapter->restart_queue;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3298
	return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3300
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3301
static int e1000_maybe_stop_tx(struct net_device *netdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3302
                               struct e1000_tx_ring *tx_ring, int size)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
	if (likely(E1000_DESC_UNUSED(tx_ring) >= size))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3305
		return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3306
	return __e1000_maybe_stop_tx(netdev, size);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3308
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3309
#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3310
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3311
e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3312
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3314
	struct e1000_tx_ring *tx_ring;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3315
	unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3316
	unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3317
	unsigned int tx_flags = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
	unsigned int len = skb->len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3319
	unsigned long flags = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3320
	unsigned int nr_frags = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
	unsigned int mss = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3322
	int count = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
	int tso;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
	unsigned int f;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
	len -= skb->data_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3327
	/* This goes back to the question of how to logically map a tx queue
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
	 * to a flow.  Right now, performance is impacted slightly negatively
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
	 * if using multiple tx queues.  If the stack breaks away from a
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3330
	 * single qdisc implementation, we can look at this again. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
	tx_ring = adapter->tx_ring;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3332
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
	if (unlikely(skb->len <= 0)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3334
		if (!adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3335
			dev_kfree_skb_any(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3336
		return NETDEV_TX_OK;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
	/* 82571 and newer doesn't need the workaround that limited descriptor
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3340
	 * length to 4kB */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3341
	if (adapter->hw.mac_type >= e1000_82571)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3342
		max_per_txd = 8192;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3343
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3344
	mss = skb_shinfo(skb)->gso_size;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3345
	/* The controller does a simple calculation to
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3346
	 * make sure there is enough room in the FIFO before
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
	 * initiating the DMA for each buffer.  The calc is:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3348
	 * 4 = ceil(buffer len/mss).  To make sure we don't
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3349
	 * overrun the FIFO, adjust the max buffer len if mss
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3350
	 * drops. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3351
	if (mss) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
		uint8_t hdr_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
		max_per_txd = min(mss << 2, max_per_txd);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3354
		max_txd_pwr = fls(max_per_txd) - 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3356
		/* TSO Workaround for 82571/2/3 Controllers -- if skb->data
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
		* points to just header, pull a few bytes of payload from
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3358
		* frags into skb->data */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3359
		hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
		if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
			switch (adapter->hw.mac_type) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
				unsigned int pull_size;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
			case e1000_82544:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3364
				/* Make sure we have room to chop off 4 bytes,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3365
				 * and that the end alignment will work out to
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3366
				 * this hardware's requirements
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3367
				 * NOTE: this is a TSO only workaround
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
				 * if end byte alignment not correct move us
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3369
				 * into the next dword */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
				if ((unsigned long)(skb_tail_pointer(skb) - 1) & 4)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
					break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3372
				/* fall through */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
			case e1000_82571:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3374
			case e1000_82572:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3375
			case e1000_82573:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3376
			case e1000_ich8lan:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3377
				pull_size = min((unsigned int)4, skb->data_len);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3378
				if (!__pskb_pull_tail(skb, pull_size)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
					DPRINTK(DRV, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3380
						"__pskb_pull_tail failed.\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
					dev_kfree_skb_any(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3382
					return NETDEV_TX_OK;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3383
				}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3384
				len = skb->len - skb->data_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3386
			default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
				/* do nothing */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3391
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3392
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
	/* reserve a descriptor for the offload context */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
	if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3395
		count++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3396
	count++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3398
	/* Controller Erratum workaround */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3399
	if (!skb->data_len && tx_ring->last_tx_tso && !skb_is_gso(skb))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
		count++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
	count += TXD_USE_COUNT(len, max_txd_pwr);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3403
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3404
	if (adapter->pcix_82544)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3405
		count++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3406
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3407
	/* work-around for errata 10 and it applies to all controllers
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3408
	 * in PCI-X mode, so add one more descriptor to the count
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3409
	 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3410
	if (unlikely((adapter->hw.bus_type == e1000_bus_type_pcix) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3411
			(len > 2015)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3412
		count++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3413
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3414
	nr_frags = skb_shinfo(skb)->nr_frags;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3415
	for (f = 0; f < nr_frags; f++)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3416
		count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3417
				       max_txd_pwr);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
	if (adapter->pcix_82544)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
		count += nr_frags;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3421
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
	if (adapter->hw.tx_pkt_filtering &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
	    (adapter->hw.mac_type == e1000_82573))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3424
		e1000_transfer_dhcp_info(adapter, skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3425
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3426
	if (!adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3427
		if (!spin_trylock_irqsave(&tx_ring->tx_lock, flags))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
			/* Collision - tell upper layer to requeue */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
			return NETDEV_TX_LOCKED;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3431
	/* need: count + 2 desc gap to keep tail from touching
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3432
	 * head, otherwise try next time */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3433
	if (unlikely(e1000_maybe_stop_tx(netdev, tx_ring, count + 2))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3434
		spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3435
		return NETDEV_TX_BUSY;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3436
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3437
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3438
	if (unlikely(adapter->hw.mac_type == e1000_82547)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
		if (unlikely(e1000_82547_fifo_workaround(adapter, skb))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
			if (!adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3441
				netif_stop_queue(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3442
				mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3443
				spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3444
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3445
			return NETDEV_TX_BUSY;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3446
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3449
	if (unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3450
		tx_flags |= E1000_TX_FLAGS_VLAN;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
		tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3452
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3453
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3454
	first = tx_ring->next_to_use;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3455
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3456
	tso = e1000_tso(adapter, tx_ring, skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3457
	if (tso < 0) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3458
		if (!adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
			dev_kfree_skb_any(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
			spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
		return NETDEV_TX_OK;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3463
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3464
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3465
	if (likely(tso)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3466
		tx_ring->last_tx_tso = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
		tx_flags |= E1000_TX_FLAGS_TSO;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
	} else if (likely(e1000_tx_csum(adapter, tx_ring, skb)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
		tx_flags |= E1000_TX_FLAGS_CSUM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
	/* Old method was to assume IPv4 packet by default if TSO was enabled.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
	 * 82571 hardware supports TSO capabilities for IPv6 as well...
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
	 * no longer assume, we must. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3474
	if (likely(skb->protocol == htons(ETH_P_IP)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
		tx_flags |= E1000_TX_FLAGS_IPV4;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3476
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
	e1000_tx_queue(adapter, tx_ring, tx_flags,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
	               e1000_tx_map(adapter, tx_ring, skb, first,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
	                            max_per_txd, nr_frags, mss));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
	netdev->trans_start = jiffies;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
	if (!adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3484
		/* Make sure there is space in the ring for the next send. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3485
		e1000_maybe_stop_tx(netdev, tx_ring, MAX_SKB_FRAGS + 2);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3486
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3487
		spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
	return NETDEV_TX_OK;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3491
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
 * e1000_tx_timeout - Respond to a Tx Hang
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
 * @netdev: network interface device structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3497
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3498
e1000_tx_timeout(struct net_device *netdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3500
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3502
	/* Do the reset outside of interrupt context */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
	adapter->tx_timeout_count++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3504
	schedule_work(&adapter->reset_task);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3505
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3507
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
e1000_reset_task(struct work_struct *work)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3510
	struct e1000_adapter *adapter =
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3511
		container_of(work, struct e1000_adapter, reset_task);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3512
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3513
	e1000_reinit_locked(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3515
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3516
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
 * e1000_get_stats - Get System Network Statistics
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3518
 * @netdev: network interface device structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
 * Returns the address of the device statistics structure.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3521
 * The statistics are actually updated from the timer callback.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3522
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3523
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3524
static struct net_device_stats *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
e1000_get_stats(struct net_device *netdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3527
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3529
	/* only return the current stats */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3530
	return &adapter->net_stats;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3532
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
 * e1000_change_mtu - Change the Maximum Transfer Unit
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3535
 * @netdev: network interface device structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
 * @new_mtu: new value for maximum frame size
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3537
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
 * Returns 0 on success, negative on failure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3542
e1000_change_mtu(struct net_device *netdev, int new_mtu)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
	int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
	uint16_t eeprom_data = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
	if (adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
		return -EBUSY;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
	if ((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
	    (max_frame > MAX_JUMBO_FRAME_SIZE)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
		DPRINTK(PROBE, ERR, "Invalid MTU setting\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3554
		return -EINVAL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
	/* Adapter-specific max frame size limits. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
	switch (adapter->hw.mac_type) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
	case e1000_undefined ... e1000_82542_rev2_1:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
	case e1000_ich8lan:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
		if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
			DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
			return -EINVAL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3565
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3566
	case e1000_82573:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3567
		/* Jumbo Frames not supported if:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
		 * - this is not an 82573L device
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
		 * - ASPM is enabled in any way (0x1A bits 3:2) */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3570
		e1000_read_eeprom(&adapter->hw, EEPROM_INIT_3GIO_3, 1,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3571
		                  &eeprom_data);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3572
		if ((adapter->hw.device_id != E1000_DEV_ID_82573L) ||
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
		    (eeprom_data & EEPROM_WORD1A_ASPM_MASK)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3574
			if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
				DPRINTK(PROBE, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3576
			            	"Jumbo Frames not supported.\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3577
				return -EINVAL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3578
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3579
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3580
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
		/* ERT will be enabled later to enable wire speed receives */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
		/* fall through to get support */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3584
	case e1000_82571:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3585
	case e1000_82572:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3586
	case e1000_80003es2lan:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3587
#define MAX_STD_JUMBO_FRAME_SIZE 9234
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3588
		if (max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3589
			DPRINTK(PROBE, ERR, "MTU > 9216 not supported.\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3590
			return -EINVAL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
	default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3594
		/* Capable of supporting up to MAX_JUMBO_FRAME_SIZE limit. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3596
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3597
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
	/* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
	 * means we reserve 2 more, this pushes us to allocate from the next
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
	 * larger slab size
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3601
	 * i.e. RXBUFFER_2048 --> size-4096 slab */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3602
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
	if (max_frame <= E1000_RXBUFFER_256)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
		adapter->rx_buffer_len = E1000_RXBUFFER_256;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3605
	else if (max_frame <= E1000_RXBUFFER_512)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
		adapter->rx_buffer_len = E1000_RXBUFFER_512;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
	else if (max_frame <= E1000_RXBUFFER_1024)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
		adapter->rx_buffer_len = E1000_RXBUFFER_1024;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3609
	else if (max_frame <= E1000_RXBUFFER_2048)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3610
		adapter->rx_buffer_len = E1000_RXBUFFER_2048;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
	else if (max_frame <= E1000_RXBUFFER_4096)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3612
		adapter->rx_buffer_len = E1000_RXBUFFER_4096;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3613
	else if (max_frame <= E1000_RXBUFFER_8192)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3614
		adapter->rx_buffer_len = E1000_RXBUFFER_8192;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3615
	else if (max_frame <= E1000_RXBUFFER_16384)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3616
		adapter->rx_buffer_len = E1000_RXBUFFER_16384;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3617
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
	/* adjust allocation if LPE protects us, and we aren't using SBP */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3619
	if (!adapter->hw.tbi_compatibility_on &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
	    ((max_frame == MAXIMUM_ETHERNET_FRAME_SIZE) ||
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3621
	     (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
		adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
	netdev->mtu = new_mtu;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3625
	adapter->hw.max_frame_size = max_frame;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3627
	if (netif_running(netdev))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3628
		e1000_reinit_locked(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3630
	return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3631
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3633
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3634
 * e1000_update_stats - Update the board statistics counters
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3637
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
e1000_update_stats(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
	struct e1000_hw *hw = &adapter->hw;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
	struct pci_dev *pdev = adapter->pdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3643
	unsigned long flags = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3644
	uint16_t phy_tmp;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3645
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
#define PHY_IDLE_ERROR_COUNT_MASK 0x00FF
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
	/*
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3649
	 * Prevent stats update while adapter is being reset, or if the pci
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3650
	 * connection is down.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
	 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
	if (adapter->link_speed == 0)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3653
		return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3654
	if (pci_channel_offline(pdev))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
		return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
	if (!adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
		spin_lock_irqsave(&adapter->stats_lock, flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3660
	/* these counters are modified from e1000_adjust_tbi_stats,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3661
	 * called from the interrupt context, so they must only
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
	 * be written while holding adapter->stats_lock
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
	 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3664
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
	adapter->stats.crcerrs += E1000_READ_REG(hw, CRCERRS);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3666
	adapter->stats.gprc += E1000_READ_REG(hw, GPRC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3667
	adapter->stats.gorcl += E1000_READ_REG(hw, GORCL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3668
	adapter->stats.gorch += E1000_READ_REG(hw, GORCH);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3669
	adapter->stats.bprc += E1000_READ_REG(hw, BPRC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
	adapter->stats.mprc += E1000_READ_REG(hw, MPRC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
	adapter->stats.roc += E1000_READ_REG(hw, ROC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3672
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3673
	if (adapter->hw.mac_type != e1000_ich8lan) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3674
		adapter->stats.prc64 += E1000_READ_REG(hw, PRC64);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3675
		adapter->stats.prc127 += E1000_READ_REG(hw, PRC127);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
		adapter->stats.prc255 += E1000_READ_REG(hw, PRC255);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3677
		adapter->stats.prc511 += E1000_READ_REG(hw, PRC511);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
		adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
		adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
	adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
	adapter->stats.mpc += E1000_READ_REG(hw, MPC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
	adapter->stats.scc += E1000_READ_REG(hw, SCC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
	adapter->stats.ecol += E1000_READ_REG(hw, ECOL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3686
	adapter->stats.mcc += E1000_READ_REG(hw, MCC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3687
	adapter->stats.latecol += E1000_READ_REG(hw, LATECOL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
	adapter->stats.dc += E1000_READ_REG(hw, DC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
	adapter->stats.sec += E1000_READ_REG(hw, SEC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3690
	adapter->stats.rlec += E1000_READ_REG(hw, RLEC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
	adapter->stats.xonrxc += E1000_READ_REG(hw, XONRXC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
	adapter->stats.xontxc += E1000_READ_REG(hw, XONTXC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3693
	adapter->stats.xoffrxc += E1000_READ_REG(hw, XOFFRXC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
	adapter->stats.xofftxc += E1000_READ_REG(hw, XOFFTXC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3695
	adapter->stats.fcruc += E1000_READ_REG(hw, FCRUC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
	adapter->stats.gptc += E1000_READ_REG(hw, GPTC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3697
	adapter->stats.gotcl += E1000_READ_REG(hw, GOTCL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3698
	adapter->stats.gotch += E1000_READ_REG(hw, GOTCH);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3699
	adapter->stats.rnbc += E1000_READ_REG(hw, RNBC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3700
	adapter->stats.ruc += E1000_READ_REG(hw, RUC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3701
	adapter->stats.rfc += E1000_READ_REG(hw, RFC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
	adapter->stats.rjc += E1000_READ_REG(hw, RJC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3703
	adapter->stats.torl += E1000_READ_REG(hw, TORL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
	adapter->stats.torh += E1000_READ_REG(hw, TORH);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
	adapter->stats.totl += E1000_READ_REG(hw, TOTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3706
	adapter->stats.toth += E1000_READ_REG(hw, TOTH);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
	adapter->stats.tpr += E1000_READ_REG(hw, TPR);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3708
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
	if (adapter->hw.mac_type != e1000_ich8lan) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
		adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3711
		adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
		adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3713
		adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3714
		adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
		adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3717
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
	adapter->stats.mptc += E1000_READ_REG(hw, MPTC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3719
	adapter->stats.bptc += E1000_READ_REG(hw, BPTC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
	/* used for adaptive IFS */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3723
	hw->tx_packet_delta = E1000_READ_REG(hw, TPT);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
	adapter->stats.tpt += hw->tx_packet_delta;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
	hw->collision_delta = E1000_READ_REG(hw, COLC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3726
	adapter->stats.colc += hw->collision_delta;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3727
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
	if (hw->mac_type >= e1000_82543) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
		adapter->stats.algnerrc += E1000_READ_REG(hw, ALGNERRC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
		adapter->stats.rxerrc += E1000_READ_REG(hw, RXERRC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3731
		adapter->stats.tncrs += E1000_READ_REG(hw, TNCRS);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
		adapter->stats.cexterr += E1000_READ_REG(hw, CEXTERR);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
		adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3734
		adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
	if (hw->mac_type > e1000_82547_rev_2) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
		adapter->stats.iac += E1000_READ_REG(hw, IAC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
		adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
		if (adapter->hw.mac_type != e1000_ich8lan) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
			adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
			adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
			adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
			adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3745
			adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
			adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
			adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3751
	/* Fill out the OS statistics structure */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
	adapter->net_stats.rx_packets = adapter->stats.gprc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3753
	adapter->net_stats.tx_packets = adapter->stats.gptc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3754
	adapter->net_stats.rx_bytes = adapter->stats.gorcl;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
	adapter->net_stats.tx_bytes = adapter->stats.gotcl;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
	adapter->net_stats.multicast = adapter->stats.mprc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
	adapter->net_stats.collisions = adapter->stats.colc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3759
	/* Rx Errors */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3760
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
	/* RLEC on some newer hardware can be incorrect so build
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3762
	* our own version based on RUC and ROC */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
	adapter->net_stats.rx_errors = adapter->stats.rxerrc +
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
		adapter->stats.crcerrs + adapter->stats.algnerrc +
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3765
		adapter->stats.ruc + adapter->stats.roc +
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3766
		adapter->stats.cexterr;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3767
	adapter->stats.rlerrc = adapter->stats.ruc + adapter->stats.roc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3768
	adapter->net_stats.rx_length_errors = adapter->stats.rlerrc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3769
	adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3770
	adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
	adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3773
	/* Tx Errors */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3774
	adapter->stats.txerrc = adapter->stats.ecol + adapter->stats.latecol;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3775
	adapter->net_stats.tx_errors = adapter->stats.txerrc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
	adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
	adapter->net_stats.tx_window_errors = adapter->stats.latecol;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3778
	adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
	if (adapter->hw.bad_tx_carr_stats_fd &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3780
	    adapter->link_duplex == FULL_DUPLEX) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3781
		adapter->net_stats.tx_carrier_errors = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3782
		adapter->stats.tncrs = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3783
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3785
	/* Tx Dropped needs to be maintained elsewhere */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
	/* Phy Stats */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
	if (hw->media_type == e1000_media_type_copper) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3789
		if ((adapter->link_speed == SPEED_1000) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3790
		   (!e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3791
			phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3792
			adapter->phy_stats.idle_errors += phy_tmp;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3793
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3795
		if ((hw->mac_type <= e1000_82546) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
		   (hw->phy_type == e1000_phy_m88) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
		   !e1000_read_phy_reg(hw, M88E1000_RX_ERR_CNTR, &phy_tmp))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3798
			adapter->phy_stats.receive_errors += phy_tmp;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3799
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3801
	/* Management Stats */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
	if (adapter->hw.has_smbus) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3803
		adapter->stats.mgptc += E1000_READ_REG(hw, MGTPTC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
		adapter->stats.mgprc += E1000_READ_REG(hw, MGTPRC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
		adapter->stats.mgpdc += E1000_READ_REG(hw, MGTPDC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3806
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3807
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
	if (!adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3809
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3810
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3811
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3812
void ec_poll(struct net_device *netdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3813
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3814
    struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
    if (jiffies - adapter->ec_watchdog_jiffies >= 2 * HZ) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3817
        e1000_watchdog((unsigned long) adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3818
        adapter->ec_watchdog_jiffies = jiffies;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
    }
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3820
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3821
#ifdef CONFIG_PCI_MSI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3822
	e1000_intr_msi(0, netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3823
#else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3824
    e1000_intr(0, netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3825
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3826
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3828
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3829
 * e1000_intr_msi - Interrupt Handler
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
 * @irq: interrupt number
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
 * @data: pointer to a network interface device structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3833
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3834
static irqreturn_t
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3835
e1000_intr_msi(int irq, void *data)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3836
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
	struct net_device *netdev = data;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3838
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
	struct e1000_hw *hw = &adapter->hw;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3840
	int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3842
	int ec_work_done = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3843
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
	uint32_t icr = E1000_READ_REG(hw, ICR);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3846
	if (adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3847
		for (i = 0; i < E1000_MAX_INTR; i++)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3848
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3849
			if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3850
							&ec_work_done, 100) &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3851
						!e1000_clean_tx_irq(adapter, adapter->tx_ring)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3852
#else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3853
			if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3854
						!e1000_clean_tx_irq(adapter, adapter->tx_ring)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3855
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3856
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3857
	} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3858
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3859
		/* read ICR disables interrupts using IAM, so keep up with our
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3860
		 * enable/disable accounting */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
		atomic_inc(&adapter->irq_sem);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3862
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3863
		if (icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3864
			hw->get_link_status = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3865
			/* 80003ES2LAN workaround-- For packet buffer work-around on
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3866
			 * link down event; disable receives here in the ISR and reset
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
			 * adapter in watchdog */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3868
			if (netif_carrier_ok(netdev) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3869
					(adapter->hw.mac_type == e1000_80003es2lan)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3870
				/* disable receives */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
				uint32_t rctl = E1000_READ_REG(hw, RCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
				E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3873
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
			/* guard against interrupt when we're going down */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3875
			if (!test_bit(__E1000_DOWN, &adapter->flags))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3876
				mod_timer(&adapter->watchdog_timer, jiffies + 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3877
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3880
		if (likely(netif_rx_schedule_prep(netdev))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
			adapter->total_tx_bytes = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
			adapter->total_tx_packets = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3883
			adapter->total_rx_bytes = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3884
			adapter->total_rx_packets = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3885
			__netif_rx_schedule(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3886
		} else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3887
			e1000_irq_enable(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
#else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3889
		adapter->total_tx_bytes = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3890
		adapter->total_rx_bytes = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3891
		adapter->total_tx_packets = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3892
		adapter->total_rx_packets = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3893
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3894
		for (i = 0; i < E1000_MAX_INTR; i++)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3895
			if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
						!e1000_clean_tx_irq(adapter, adapter->tx_ring)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3897
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
		if (likely(adapter->itr_setting & 3))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
			e1000_set_itr(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
	return IRQ_HANDLED;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3905
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3906
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3907
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
 * e1000_intr - Interrupt Handler
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
 * @irq: interrupt number
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
 * @data: pointer to a network interface device structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
static irqreturn_t
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3914
e1000_intr(int irq, void *data)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3916
	struct net_device *netdev = data;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
	struct e1000_hw *hw = &adapter->hw;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3919
	uint32_t rctl, icr = E1000_READ_REG(hw, ICR);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3920
	int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3921
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3922
	int ec_work_done = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3923
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3924
	if (unlikely(!icr))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3925
		return IRQ_NONE;  /* Not our interrupt */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3926
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3927
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
	/* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
	 * not set, then the adapter didn't send an interrupt */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3930
	if (unlikely(hw->mac_type >= e1000_82571 &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3931
	             !(icr & E1000_ICR_INT_ASSERTED)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3932
		return IRQ_NONE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3933
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3934
	/* Interrupt Auto-Mask...upon reading ICR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3935
	 * interrupts are masked.  No need for the
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3936
	 * IMC write, but it does mean we should
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3937
	 * account for it ASAP. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3938
	if (!adapter->ecdev && likely(hw->mac_type >= e1000_82571))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3939
		atomic_inc(&adapter->irq_sem);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3940
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3941
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3942
	if (!adapter->ecdev && unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3943
		hw->get_link_status = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3944
		/* 80003ES2LAN workaround--
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3945
		 * For packet buffer work-around on link down event;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3946
		 * disable receives here in the ISR and
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3947
		 * reset adapter in watchdog
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3948
		 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3949
		if (netif_carrier_ok(netdev) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3950
		    (adapter->hw.mac_type == e1000_80003es2lan)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3951
			/* disable receives */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3952
			rctl = E1000_READ_REG(hw, RCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3953
			E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3954
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3955
		/* guard against interrupt when we're going down */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3956
		if (!test_bit(__E1000_DOWN, &adapter->flags))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3957
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3958
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3959
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3960
	if (adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3961
		for (i = 0; i < E1000_MAX_INTR; i++)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3962
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3963
			if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3964
                            &ec_work_done, 100) &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3965
						!e1000_clean_tx_irq(adapter, adapter->tx_ring)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3966
#else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3967
			if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3968
						!e1000_clean_tx_irq(adapter, adapter->tx_ring)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3969
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3970
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3971
	} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3972
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3973
		if (unlikely(hw->mac_type < e1000_82571)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3974
			/* disable interrupts, without the synchronize_irq bit */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3975
			atomic_inc(&adapter->irq_sem);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3976
			E1000_WRITE_REG(hw, IMC, ~0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3977
			E1000_WRITE_FLUSH(hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3978
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3979
		if (likely(netif_rx_schedule_prep(netdev))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3980
			adapter->total_tx_bytes = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3981
			adapter->total_tx_packets = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3982
			adapter->total_rx_bytes = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3983
			adapter->total_rx_packets = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3984
			__netif_rx_schedule(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3985
		} else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3986
			/* this really should not happen! if it does it is basically a
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3987
			 * bug, but not a hard error, so enable ints and continue */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3988
			e1000_irq_enable(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3989
#else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3990
		/* Writing IMC and IMS is needed for 82547.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3991
		 * Due to Hub Link bus being occupied, an interrupt
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3992
		 * de-assertion message is not able to be sent.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3993
		 * When an interrupt assertion message is generated later,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3994
		 * two messages are re-ordered and sent out.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3995
		 * That causes APIC to think 82547 is in de-assertion
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3996
		 * state, while 82547 is in assertion state, resulting
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3997
		 * in dead lock. Writing IMC forces 82547 into
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3998
		 * de-assertion state.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3999
		 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4000
		if (hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4001
			atomic_inc(&adapter->irq_sem);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4002
			E1000_WRITE_REG(hw, IMC, ~0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4003
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4004
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4005
		adapter->total_tx_bytes = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4006
		adapter->total_rx_bytes = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4007
		adapter->total_tx_packets = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4008
		adapter->total_rx_packets = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4009
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4010
		for (i = 0; i < E1000_MAX_INTR; i++)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4011
			if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4012
						!e1000_clean_tx_irq(adapter, adapter->tx_ring)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4013
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4014
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4015
		if (likely(adapter->itr_setting & 3))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4016
			e1000_set_itr(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4017
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4018
		if (hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4019
			e1000_irq_enable(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4020
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4021
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4022
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4023
	return IRQ_HANDLED;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4024
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4025
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4026
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4027
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4028
 * e1000_clean - NAPI Rx polling callback
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4029
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4030
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4031
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4032
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4033
e1000_clean(struct net_device *poll_dev, int *budget) // EtherCAT: never called
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4034
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4035
	struct e1000_adapter *adapter;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4036
	int work_to_do = min(*budget, poll_dev->quota);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4037
	int tx_cleaned = 0, work_done = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4038
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4039
	/* Must NOT use netdev_priv macro here. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4040
	adapter = poll_dev->priv;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4041
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4042
	/* Keep link state information with original netdev */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4043
	if (!netif_carrier_ok(poll_dev))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4044
		goto quit_polling;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4045
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4046
	/* e1000_clean is called per-cpu.  This lock protects
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4047
	 * tx_ring[0] from being cleaned by multiple cpus
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4048
	 * simultaneously.  A failure obtaining the lock means
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4049
	 * tx_ring[0] is currently being cleaned anyway. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4050
	if (spin_trylock(&adapter->tx_queue_lock)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4051
		tx_cleaned = e1000_clean_tx_irq(adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4052
		                                &adapter->tx_ring[0]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4053
		spin_unlock(&adapter->tx_queue_lock);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4054
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4055
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4056
	adapter->clean_rx(adapter, &adapter->rx_ring[0],
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4057
	                  &work_done, work_to_do);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4058
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4059
	*budget -= work_done;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4060
	poll_dev->quota -= work_done;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4061
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4062
	/* If no Tx and not enough Rx work done, exit the polling mode */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4063
	if ((!tx_cleaned && (work_done == 0)) ||
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4064
	   !netif_running(poll_dev)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4065
quit_polling:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4066
		if (likely(adapter->itr_setting & 3))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4067
			e1000_set_itr(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4068
		netif_rx_complete(poll_dev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4069
		e1000_irq_enable(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4070
		return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4071
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4072
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4073
	return 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4074
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4075
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4076
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4077
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4078
 * e1000_clean_tx_irq - Reclaim resources after transmit completes
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4079
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4080
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4081
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4082
static boolean_t
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4083
e1000_clean_tx_irq(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4084
                   struct e1000_tx_ring *tx_ring)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4085
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4086
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4087
	struct e1000_tx_desc *tx_desc, *eop_desc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4088
	struct e1000_buffer *buffer_info;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4089
	unsigned int i, eop;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4090
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4091
	unsigned int count = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4092
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4093
	boolean_t cleaned = FALSE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4094
	unsigned int total_tx_bytes=0, total_tx_packets=0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4095
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4096
	i = tx_ring->next_to_clean;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4097
	eop = tx_ring->buffer_info[i].next_to_watch;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4098
	eop_desc = E1000_TX_DESC(*tx_ring, eop);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4099
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4100
	while (eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4101
		for (cleaned = FALSE; !cleaned; ) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4102
			tx_desc = E1000_TX_DESC(*tx_ring, i);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4103
			buffer_info = &tx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4104
			cleaned = (i == eop);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4105
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4106
			if (cleaned) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4107
				struct sk_buff *skb = buffer_info->skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4108
				unsigned int segs, bytecount;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4109
				segs = skb_shinfo(skb)->gso_segs ?: 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4110
				/* multiply data chunks by size of headers */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4111
				bytecount = ((segs - 1) * skb_headlen(skb)) +
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4112
				            skb->len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4113
				total_tx_packets += segs;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4114
				total_tx_bytes += bytecount;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4115
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4116
			e1000_unmap_and_free_tx_resource(adapter, buffer_info);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4117
			tx_desc->upper.data = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4118
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4119
			if (unlikely(++i == tx_ring->count)) i = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4120
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4121
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4122
		eop = tx_ring->buffer_info[i].next_to_watch;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4123
		eop_desc = E1000_TX_DESC(*tx_ring, eop);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4124
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4125
#define E1000_TX_WEIGHT 64
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4126
		/* weight of a sort for tx, to avoid endless transmit cleanup */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4127
		if (count++ == E1000_TX_WEIGHT) break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4128
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4129
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4130
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4131
	tx_ring->next_to_clean = i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4132
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4133
#define TX_WAKE_THRESHOLD 32
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4134
	if (!adapter->ecdev && unlikely(cleaned && netif_carrier_ok(netdev) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4135
		     E1000_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4136
		/* Make sure that anybody stopping the queue after this
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4137
		 * sees the new next_to_clean.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4138
		 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4139
		smp_mb();
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4140
		if (netif_queue_stopped(netdev)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4141
			netif_wake_queue(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4142
			++adapter->restart_queue;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4143
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4144
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4145
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4146
	if (!adapter->ecdev && adapter->detect_tx_hung) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4147
		/* Detect a transmit hang in hardware, this serializes the
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4148
		 * check with the clearing of time_stamp and movement of i */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4149
		adapter->detect_tx_hung = FALSE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4150
		if (tx_ring->buffer_info[eop].dma &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4151
		    time_after(jiffies, tx_ring->buffer_info[eop].time_stamp +
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4152
		               (adapter->tx_timeout_factor * HZ))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4153
		    && !(E1000_READ_REG(&adapter->hw, STATUS) &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4154
		         E1000_STATUS_TXOFF)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4155
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4156
			/* detected Tx unit hang */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4157
			DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4158
					"  Tx Queue             <%lu>\n"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4159
					"  TDH                  <%x>\n"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4160
					"  TDT                  <%x>\n"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4161
					"  next_to_use          <%x>\n"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4162
					"  next_to_clean        <%x>\n"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4163
					"buffer_info[next_to_clean]\n"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4164
					"  time_stamp           <%lx>\n"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4165
					"  next_to_watch        <%x>\n"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4166
					"  jiffies              <%lx>\n"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4167
					"  next_to_watch.status <%x>\n",
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4168
				(unsigned long)((tx_ring - adapter->tx_ring) /
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4169
					sizeof(struct e1000_tx_ring)),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4170
				readl(adapter->hw.hw_addr + tx_ring->tdh),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4171
				readl(adapter->hw.hw_addr + tx_ring->tdt),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4172
				tx_ring->next_to_use,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4173
				tx_ring->next_to_clean,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4174
				tx_ring->buffer_info[eop].time_stamp,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4175
				eop,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4176
				jiffies,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4177
				eop_desc->upper.fields.status);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4178
			netif_stop_queue(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4179
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4180
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4181
	adapter->total_tx_bytes += total_tx_bytes;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4182
	adapter->total_tx_packets += total_tx_packets;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4183
	return cleaned;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4184
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4185
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4186
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4187
 * e1000_rx_checksum - Receive Checksum Offload for 82543
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4188
 * @adapter:     board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4189
 * @status_err:  receive descriptor status and error fields
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4190
 * @csum:        receive descriptor csum field
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4191
 * @sk_buff:     socket buffer with received data
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4192
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4193
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4194
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4195
e1000_rx_checksum(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4196
		  uint32_t status_err, uint32_t csum,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4197
		  struct sk_buff *skb)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4198
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4199
	uint16_t status = (uint16_t)status_err;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4200
	uint8_t errors = (uint8_t)(status_err >> 24);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4201
	skb->ip_summed = CHECKSUM_NONE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4202
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4203
	/* 82543 or newer only */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4204
	if (unlikely(adapter->hw.mac_type < e1000_82543)) return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4205
	/* Ignore Checksum bit is set */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4206
	if (unlikely(status & E1000_RXD_STAT_IXSM)) return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4207
	/* TCP/UDP checksum error bit is set */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4208
	if (unlikely(errors & E1000_RXD_ERR_TCPE)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4209
		/* let the stack verify checksum errors */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4210
		adapter->hw_csum_err++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4211
		return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4212
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4213
	/* TCP/UDP Checksum has not been calculated */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4214
	if (adapter->hw.mac_type <= e1000_82547_rev_2) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4215
		if (!(status & E1000_RXD_STAT_TCPCS))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4216
			return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4217
	} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4218
		if (!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4219
			return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4220
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4221
	/* It must be a TCP or UDP packet with a valid checksum */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4222
	if (likely(status & E1000_RXD_STAT_TCPCS)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4223
		/* TCP checksum is good */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4224
		skb->ip_summed = CHECKSUM_UNNECESSARY;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4225
	} else if (adapter->hw.mac_type > e1000_82547_rev_2) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4226
		/* IP fragment with UDP payload */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4227
		/* Hardware complements the payload checksum, so we undo it
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4228
		 * and then put the value in host order for further stack use.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4229
		 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4230
		csum = ntohl(csum ^ 0xFFFF);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4231
		skb->csum = csum;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4232
		skb->ip_summed = CHECKSUM_COMPLETE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4233
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4234
	adapter->hw_csum_good++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4235
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4236
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4237
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4238
 * e1000_clean_rx_irq - Send received data up the network stack; legacy
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4239
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4240
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4241
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4242
static boolean_t
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4243
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4244
e1000_clean_rx_irq(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4245
                   struct e1000_rx_ring *rx_ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4246
                   int *work_done, int work_to_do)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4247
#else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4248
e1000_clean_rx_irq(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4249
                   struct e1000_rx_ring *rx_ring)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4250
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4251
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4252
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4253
	struct pci_dev *pdev = adapter->pdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4254
	struct e1000_rx_desc *rx_desc, *next_rxd;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4255
	struct e1000_buffer *buffer_info, *next_buffer;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4256
	unsigned long flags;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4257
	uint32_t length;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4258
	uint8_t last_byte;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4259
	unsigned int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4260
	int cleaned_count = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4261
	boolean_t cleaned = FALSE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4262
	unsigned int total_rx_bytes=0, total_rx_packets=0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4263
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4264
	i = rx_ring->next_to_clean;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4265
	rx_desc = E1000_RX_DESC(*rx_ring, i);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4266
	buffer_info = &rx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4267
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4268
	while (rx_desc->status & E1000_RXD_STAT_DD) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4269
		struct sk_buff *skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4270
		u8 status;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4271
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4272
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4273
		if (*work_done >= work_to_do)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4274
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4275
		(*work_done)++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4276
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4277
		status = rx_desc->status;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4278
		skb = buffer_info->skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4279
		if (!adapter->ecdev) buffer_info->skb = NULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4280
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4281
		prefetch(skb->data - NET_IP_ALIGN);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4282
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4283
		if (++i == rx_ring->count) i = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4284
		next_rxd = E1000_RX_DESC(*rx_ring, i);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4285
		prefetch(next_rxd);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4286
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4287
		next_buffer = &rx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4288
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4289
		cleaned = TRUE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4290
		cleaned_count++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4291
		pci_unmap_single(pdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4292
		                 buffer_info->dma,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4293
		                 buffer_info->length,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4294
		                 PCI_DMA_FROMDEVICE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4295
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4296
		length = le16_to_cpu(rx_desc->length);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4297
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4298
		if (unlikely(!(status & E1000_RXD_STAT_EOP))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4299
			/* All receives must fit into a single buffer */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4300
			E1000_DBG("%s: Receive packet consumed multiple"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4301
				  " buffers\n", netdev->name);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4302
			/* recycle */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4303
			buffer_info->skb = skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4304
			goto next_desc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4305
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4306
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4307
		if (!adapter->ecdev &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4308
                unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4309
			last_byte = *(skb->data + length - 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4310
			if (TBI_ACCEPT(&adapter->hw, status,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4311
			              rx_desc->errors, length, last_byte)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4312
				spin_lock_irqsave(&adapter->stats_lock, flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4313
				e1000_tbi_adjust_stats(&adapter->hw,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4314
				                       &adapter->stats,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4315
				                       length, skb->data);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4316
				spin_unlock_irqrestore(&adapter->stats_lock,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4317
				                       flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4318
				length--;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4319
			} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4320
				/* recycle */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4321
				buffer_info->skb = skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4322
				goto next_desc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4323
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4324
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4325
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4326
		/* adjust length to remove Ethernet CRC, this must be
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4327
		 * done after the TBI_ACCEPT workaround above */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4328
		length -= 4;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4329
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4330
		/* probably a little skewed due to removing CRC */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4331
		total_rx_bytes += length;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4332
		total_rx_packets++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4333
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4334
		/* code added for copybreak, this should improve
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4335
		 * performance for small packets with large amounts
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4336
		 * of reassembly being done in the stack */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4337
		if (!adapter->ecdev && length < copybreak) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4338
			struct sk_buff *new_skb =
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4339
			    netdev_alloc_skb(netdev, length + NET_IP_ALIGN);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4340
			if (new_skb) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4341
				skb_reserve(new_skb, NET_IP_ALIGN);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4342
				skb_copy_to_linear_data_offset(new_skb,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4343
							       -NET_IP_ALIGN,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4344
							       (skb->data -
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4345
							        NET_IP_ALIGN),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4346
							       (length +
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4347
							        NET_IP_ALIGN));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4348
				/* save the skb in buffer_info as good */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4349
				buffer_info->skb = skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4350
				skb = new_skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4351
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4352
			/* else just continue with the old one */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4353
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4354
		/* end copybreak code */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4355
		skb_put(skb, length);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4356
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4357
		/* Receive Checksum Offload */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4358
		e1000_rx_checksum(adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4359
				  (uint32_t)(status) |
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4360
				  ((uint32_t)(rx_desc->errors) << 24),
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4361
				  le16_to_cpu(rx_desc->csum), skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4362
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4363
		if (adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4364
			ecdev_receive(adapter->ecdev, skb->data, length);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4365
		} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4366
			skb->protocol = eth_type_trans(skb, netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4367
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4368
			if (unlikely(adapter->vlgrp &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4369
						(status & E1000_RXD_STAT_VP))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4370
				vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4371
						le16_to_cpu(rx_desc->special) &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4372
						E1000_RXD_SPC_VLAN_MASK);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4373
			} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4374
				netif_receive_skb(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4375
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4376
#else /* CONFIG_E1000_NAPI */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4377
			if (unlikely(adapter->vlgrp &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4378
						(status & E1000_RXD_STAT_VP))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4379
				vlan_hwaccel_rx(skb, adapter->vlgrp,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4380
						le16_to_cpu(rx_desc->special) &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4381
						E1000_RXD_SPC_VLAN_MASK);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4382
			} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4383
				netif_rx(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4384
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4385
#endif /* CONFIG_E1000_NAPI */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4386
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4387
		netdev->last_rx = jiffies;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4388
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4389
next_desc:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4390
		rx_desc->status = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4391
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4392
		/* return some buffers to hardware, one at a time is too slow */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4393
		if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4394
			adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4395
			cleaned_count = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4396
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4397
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4398
		/* use prefetched values */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4399
		rx_desc = next_rxd;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4400
		buffer_info = next_buffer;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4401
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4402
	rx_ring->next_to_clean = i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4403
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4404
	cleaned_count = E1000_DESC_UNUSED(rx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4405
	if (cleaned_count)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4406
		adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4407
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4408
	adapter->total_rx_packets += total_rx_packets;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4409
	adapter->total_rx_bytes += total_rx_bytes;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4410
	return cleaned;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4411
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4412
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4413
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4414
 * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4415
 * @adapter: board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4416
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4417
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4418
static boolean_t
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4419
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4420
e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4421
                      struct e1000_rx_ring *rx_ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4422
                      int *work_done, int work_to_do)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4423
#else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4424
e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4425
                      struct e1000_rx_ring *rx_ring)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4426
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4427
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4428
	union e1000_rx_desc_packet_split *rx_desc, *next_rxd;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4429
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4430
	struct pci_dev *pdev = adapter->pdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4431
	struct e1000_buffer *buffer_info, *next_buffer;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4432
	struct e1000_ps_page *ps_page;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4433
	struct e1000_ps_page_dma *ps_page_dma;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4434
	struct sk_buff *skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4435
	unsigned int i, j;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4436
	uint32_t length, staterr;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4437
	int cleaned_count = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4438
	boolean_t cleaned = FALSE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4439
	unsigned int total_rx_bytes=0, total_rx_packets=0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4440
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4441
	i = rx_ring->next_to_clean;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4442
	rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4443
	staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4444
	buffer_info = &rx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4445
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4446
	while (staterr & E1000_RXD_STAT_DD) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4447
		ps_page = &rx_ring->ps_page[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4448
		ps_page_dma = &rx_ring->ps_page_dma[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4449
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4450
		if (unlikely(*work_done >= work_to_do))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4451
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4452
		(*work_done)++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4453
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4454
		skb = buffer_info->skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4455
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4456
		/* in the packet split case this is header only */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4457
		prefetch(skb->data - NET_IP_ALIGN);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4458
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4459
		if (++i == rx_ring->count) i = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4460
		next_rxd = E1000_RX_DESC_PS(*rx_ring, i);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4461
		prefetch(next_rxd);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4462
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4463
		next_buffer = &rx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4464
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4465
		cleaned = TRUE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4466
		cleaned_count++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4467
		pci_unmap_single(pdev, buffer_info->dma,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4468
				 buffer_info->length,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4469
				 PCI_DMA_FROMDEVICE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4470
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4471
		if (unlikely(!(staterr & E1000_RXD_STAT_EOP))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4472
			E1000_DBG("%s: Packet Split buffers didn't pick up"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4473
				  " the full packet\n", netdev->name);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4474
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4475
			goto next_desc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4476
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4477
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4478
		if (unlikely(staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4479
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4480
			goto next_desc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4481
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4482
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4483
		length = le16_to_cpu(rx_desc->wb.middle.length0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4484
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4485
		if (unlikely(!length)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4486
			E1000_DBG("%s: Last part of the packet spanning"
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4487
				  " multiple descriptors\n", netdev->name);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4488
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4489
			goto next_desc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4490
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4491
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4492
		/* Good Receive */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4493
		skb_put(skb, length);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4494
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4495
		{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4496
		/* this looks ugly, but it seems compiler issues make it
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4497
		   more efficient than reusing j */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4498
		int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4499
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4500
		/* page alloc/put takes too long and effects small packet
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4501
		 * throughput, so unsplit small packets and save the alloc/put*/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4502
		if (l1 && (l1 <= copybreak) && ((length + l1) <= adapter->rx_ps_bsize0)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4503
			u8 *vaddr;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4504
			/* there is no documentation about how to call
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4505
			 * kmap_atomic, so we can't hold the mapping
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4506
			 * very long */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4507
			pci_dma_sync_single_for_cpu(pdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4508
				ps_page_dma->ps_page_dma[0],
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4509
				PAGE_SIZE,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4510
				PCI_DMA_FROMDEVICE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4511
			vaddr = kmap_atomic(ps_page->ps_page[0],
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4512
			                    KM_SKB_DATA_SOFTIRQ);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4513
			memcpy(skb_tail_pointer(skb), vaddr, l1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4514
			kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4515
			pci_dma_sync_single_for_device(pdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4516
				ps_page_dma->ps_page_dma[0],
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4517
				PAGE_SIZE, PCI_DMA_FROMDEVICE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4518
			/* remove the CRC */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4519
			l1 -= 4;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4520
			skb_put(skb, l1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4521
			goto copydone;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4522
		} /* if */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4523
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4524
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4525
		for (j = 0; j < adapter->rx_ps_pages; j++) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4526
			if (!(length= le16_to_cpu(rx_desc->wb.upper.length[j])))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4527
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4528
			pci_unmap_page(pdev, ps_page_dma->ps_page_dma[j],
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4529
					PAGE_SIZE, PCI_DMA_FROMDEVICE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4530
			ps_page_dma->ps_page_dma[j] = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4531
			skb_fill_page_desc(skb, j, ps_page->ps_page[j], 0,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4532
			                   length);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4533
			ps_page->ps_page[j] = NULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4534
			skb->len += length;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4535
			skb->data_len += length;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4536
			skb->truesize += length;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4537
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4538
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4539
		/* strip the ethernet crc, problem is we're using pages now so
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4540
		 * this whole operation can get a little cpu intensive */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4541
		pskb_trim(skb, skb->len - 4);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4542
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4543
copydone:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4544
		total_rx_bytes += skb->len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4545
		total_rx_packets++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4546
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4547
		e1000_rx_checksum(adapter, staterr,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4548
				  le16_to_cpu(rx_desc->wb.lower.hi_dword.csum_ip.csum), skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4549
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4550
		if (likely(rx_desc->wb.upper.header_status &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4551
			   cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4552
			adapter->rx_hdr_split++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4553
		if (adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4554
			ecdev_receive(adapter->ecdev, skb->data, length);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4555
		} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4556
			skb->protocol = eth_type_trans(skb, netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4557
#ifdef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4558
			if (unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4559
				vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4560
						le16_to_cpu(rx_desc->wb.middle.vlan) &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4561
						E1000_RXD_SPC_VLAN_MASK);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4562
			} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4563
				netif_receive_skb(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4564
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4565
#else /* CONFIG_E1000_NAPI */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4566
			if (unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4567
				vlan_hwaccel_rx(skb, adapter->vlgrp,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4568
						le16_to_cpu(rx_desc->wb.middle.vlan) &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4569
						E1000_RXD_SPC_VLAN_MASK);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4570
			} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4571
				netif_rx(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4572
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4573
#endif /* CONFIG_E1000_NAPI */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4574
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4575
		netdev->last_rx = jiffies;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4576
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4577
next_desc:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4578
		rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4579
		if (!adapter->ecdev) buffer_info->skb = NULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4580
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4581
		/* return some buffers to hardware, one at a time is too slow */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4582
		if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4583
			adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4584
			cleaned_count = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4585
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4586
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4587
		/* use prefetched values */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4588
		rx_desc = next_rxd;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4589
		buffer_info = next_buffer;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4590
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4591
		staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4592
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4593
	rx_ring->next_to_clean = i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4594
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4595
	cleaned_count = E1000_DESC_UNUSED(rx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4596
	if (cleaned_count)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4597
		adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4598
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4599
	adapter->total_rx_packets += total_rx_packets;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4600
	adapter->total_rx_bytes += total_rx_bytes;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4601
	return cleaned;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4602
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4603
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4604
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4605
 * e1000_alloc_rx_buffers - Replace used receive buffers; legacy & extended
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4606
 * @adapter: address of board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4607
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4608
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4609
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4610
e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4611
                       struct e1000_rx_ring *rx_ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4612
		       int cleaned_count)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4613
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4614
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4615
	struct pci_dev *pdev = adapter->pdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4616
	struct e1000_rx_desc *rx_desc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4617
	struct e1000_buffer *buffer_info;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4618
	struct sk_buff *skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4619
	unsigned int i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4620
	unsigned int bufsz = adapter->rx_buffer_len + NET_IP_ALIGN;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4621
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4622
	i = rx_ring->next_to_use;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4623
	buffer_info = &rx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4624
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4625
	while (cleaned_count--) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4626
		skb = buffer_info->skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4627
		if (skb) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4628
			skb_trim(skb, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4629
			goto map_skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4630
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4631
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4632
		skb = netdev_alloc_skb(netdev, bufsz);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4633
		if (unlikely(!skb)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4634
			/* Better luck next round */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4635
			adapter->alloc_rx_buff_failed++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4636
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4637
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4638
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4639
		/* Fix for errata 23, can't cross 64kB boundary */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4640
		if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4641
			struct sk_buff *oldskb = skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4642
			DPRINTK(RX_ERR, ERR, "skb align check failed: %u bytes "
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4643
					     "at %p\n", bufsz, skb->data);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4644
			/* Try again, without freeing the previous */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4645
			skb = netdev_alloc_skb(netdev, bufsz);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4646
			/* Failed allocation, critical failure */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4647
			if (!skb) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4648
				dev_kfree_skb(oldskb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4649
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4650
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4651
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4652
			if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4653
				/* give up */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4654
				dev_kfree_skb(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4655
				dev_kfree_skb(oldskb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4656
				break; /* while !buffer_info->skb */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4657
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4658
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4659
			/* Use new allocation */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4660
			dev_kfree_skb(oldskb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4661
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4662
		/* Make buffer alignment 2 beyond a 16 byte boundary
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4663
		 * this will result in a 16 byte aligned IP header after
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4664
		 * the 14 byte MAC header is removed
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4665
		 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4666
		skb_reserve(skb, NET_IP_ALIGN);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4667
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4668
		buffer_info->skb = skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4669
		buffer_info->length = adapter->rx_buffer_len;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4670
map_skb:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4671
		buffer_info->dma = pci_map_single(pdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4672
						  skb->data,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4673
						  adapter->rx_buffer_len,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4674
						  PCI_DMA_FROMDEVICE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4675
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4676
		/* Fix for errata 23, can't cross 64kB boundary */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4677
		if (!e1000_check_64k_bound(adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4678
					(void *)(unsigned long)buffer_info->dma,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4679
					adapter->rx_buffer_len)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4680
			DPRINTK(RX_ERR, ERR,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4681
				"dma align check failed: %u bytes at %p\n",
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4682
				adapter->rx_buffer_len,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4683
				(void *)(unsigned long)buffer_info->dma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4684
			if (!adapter->ecdev) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4685
                dev_kfree_skb(skb);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4686
				buffer_info->skb = NULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4687
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4688
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4689
			pci_unmap_single(pdev, buffer_info->dma,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4690
					 adapter->rx_buffer_len,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4691
					 PCI_DMA_FROMDEVICE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4692
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4693
			break; /* while !buffer_info->skb */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4694
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4695
		rx_desc = E1000_RX_DESC(*rx_ring, i);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4696
		rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4697
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4698
		if (unlikely(++i == rx_ring->count))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4699
			i = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4700
		buffer_info = &rx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4701
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4702
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4703
	if (likely(rx_ring->next_to_use != i)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4704
		rx_ring->next_to_use = i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4705
		if (unlikely(i-- == 0))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4706
			i = (rx_ring->count - 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4707
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4708
		/* Force memory writes to complete before letting h/w
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4709
		 * know there are new descriptors to fetch.  (Only
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4710
		 * applicable for weak-ordered memory model archs,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4711
		 * such as IA-64). */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4712
		wmb();
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4713
		writel(i, adapter->hw.hw_addr + rx_ring->rdt);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4714
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4715
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4716
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4717
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4718
 * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4719
 * @adapter: address of board private structure
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4720
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4721
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4722
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4723
e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4724
                          struct e1000_rx_ring *rx_ring,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4725
			  int cleaned_count)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4726
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4727
	struct net_device *netdev = adapter->netdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4728
	struct pci_dev *pdev = adapter->pdev;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4729
	union e1000_rx_desc_packet_split *rx_desc;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4730
	struct e1000_buffer *buffer_info;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4731
	struct e1000_ps_page *ps_page;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4732
	struct e1000_ps_page_dma *ps_page_dma;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4733
	struct sk_buff *skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4734
	unsigned int i, j;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4735
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4736
	i = rx_ring->next_to_use;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4737
	buffer_info = &rx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4738
	ps_page = &rx_ring->ps_page[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4739
	ps_page_dma = &rx_ring->ps_page_dma[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4740
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4741
	while (cleaned_count--) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4742
		rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4743
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4744
		for (j = 0; j < PS_PAGE_BUFFERS; j++) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4745
			if (j < adapter->rx_ps_pages) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4746
				if (likely(!ps_page->ps_page[j])) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4747
					ps_page->ps_page[j] =
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4748
						alloc_page(GFP_ATOMIC);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4749
					if (unlikely(!ps_page->ps_page[j])) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4750
						adapter->alloc_rx_buff_failed++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4751
						goto no_buffers;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4752
					}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4753
					ps_page_dma->ps_page_dma[j] =
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4754
						pci_map_page(pdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4755
							    ps_page->ps_page[j],
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4756
							    0, PAGE_SIZE,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4757
							    PCI_DMA_FROMDEVICE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4758
				}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4759
				/* Refresh the desc even if buffer_addrs didn't
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4760
				 * change because each write-back erases
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4761
				 * this info.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4762
				 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4763
				rx_desc->read.buffer_addr[j+1] =
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4764
				     cpu_to_le64(ps_page_dma->ps_page_dma[j]);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4765
			} else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4766
				rx_desc->read.buffer_addr[j+1] = ~0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4767
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4768
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4769
		skb = netdev_alloc_skb(netdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4770
		                       adapter->rx_ps_bsize0 + NET_IP_ALIGN);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4771
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4772
		if (unlikely(!skb)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4773
			adapter->alloc_rx_buff_failed++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4774
			break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4775
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4776
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4777
		/* Make buffer alignment 2 beyond a 16 byte boundary
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4778
		 * this will result in a 16 byte aligned IP header after
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4779
		 * the 14 byte MAC header is removed
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4780
		 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4781
		skb_reserve(skb, NET_IP_ALIGN);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4782
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4783
		buffer_info->skb = skb;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4784
		buffer_info->length = adapter->rx_ps_bsize0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4785
		buffer_info->dma = pci_map_single(pdev, skb->data,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4786
						  adapter->rx_ps_bsize0,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4787
						  PCI_DMA_FROMDEVICE);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4788
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4789
		rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4790
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4791
		if (unlikely(++i == rx_ring->count)) i = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4792
		buffer_info = &rx_ring->buffer_info[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4793
		ps_page = &rx_ring->ps_page[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4794
		ps_page_dma = &rx_ring->ps_page_dma[i];
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4795
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4796
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4797
no_buffers:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4798
	if (likely(rx_ring->next_to_use != i)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4799
		rx_ring->next_to_use = i;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4800
		if (unlikely(i-- == 0)) i = (rx_ring->count - 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4801
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4802
		/* Force memory writes to complete before letting h/w
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4803
		 * know there are new descriptors to fetch.  (Only
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4804
		 * applicable for weak-ordered memory model archs,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4805
		 * such as IA-64). */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4806
		wmb();
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4807
		/* Hardware increments by 16 bytes, but packet split
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4808
		 * descriptors are 32 bytes...so we increment tail
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4809
		 * twice as much.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4810
		 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4811
		writel(i<<1, adapter->hw.hw_addr + rx_ring->rdt);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4812
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4813
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4814
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4815
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4816
 * e1000_smartspeed - Workaround for SmartSpeed on 82541 and 82547 controllers.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4817
 * @adapter:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4818
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4819
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4820
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4821
e1000_smartspeed(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4822
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4823
	uint16_t phy_status;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4824
	uint16_t phy_ctrl;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4825
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4826
	if ((adapter->hw.phy_type != e1000_phy_igp) || !adapter->hw.autoneg ||
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4827
	   !(adapter->hw.autoneg_advertised & ADVERTISE_1000_FULL))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4828
		return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4829
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4830
	if (adapter->smartspeed == 0) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4831
		/* If Master/Slave config fault is asserted twice,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4832
		 * we assume back-to-back */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4833
		e1000_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4834
		if (!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4835
		e1000_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4836
		if (!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4837
		e1000_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4838
		if (phy_ctrl & CR_1000T_MS_ENABLE) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4839
			phy_ctrl &= ~CR_1000T_MS_ENABLE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4840
			e1000_write_phy_reg(&adapter->hw, PHY_1000T_CTRL,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4841
					    phy_ctrl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4842
			adapter->smartspeed++;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4843
			if (!e1000_phy_setup_autoneg(&adapter->hw) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4844
			   !e1000_read_phy_reg(&adapter->hw, PHY_CTRL,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4845
				   	       &phy_ctrl)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4846
				phy_ctrl |= (MII_CR_AUTO_NEG_EN |
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4847
					     MII_CR_RESTART_AUTO_NEG);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4848
				e1000_write_phy_reg(&adapter->hw, PHY_CTRL,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4849
						    phy_ctrl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4850
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4851
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4852
		return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4853
	} else if (adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4854
		/* If still no link, perhaps using 2/3 pair cable */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4855
		e1000_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4856
		phy_ctrl |= CR_1000T_MS_ENABLE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4857
		e1000_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, phy_ctrl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4858
		if (!e1000_phy_setup_autoneg(&adapter->hw) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4859
		   !e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_ctrl)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4860
			phy_ctrl |= (MII_CR_AUTO_NEG_EN |
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4861
				     MII_CR_RESTART_AUTO_NEG);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4862
			e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_ctrl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4863
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4864
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4865
	/* Restart process after E1000_SMARTSPEED_MAX iterations */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4866
	if (adapter->smartspeed++ == E1000_SMARTSPEED_MAX)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4867
		adapter->smartspeed = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4868
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4869
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4870
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4871
 * e1000_ioctl -
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4872
 * @netdev:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4873
 * @ifreq:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4874
 * @cmd:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4875
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4876
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4877
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4878
e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4879
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4880
	switch (cmd) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4881
	case SIOCGMIIPHY:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4882
	case SIOCGMIIREG:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4883
	case SIOCSMIIREG:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4884
		return e1000_mii_ioctl(netdev, ifr, cmd);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4885
	default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4886
		return -EOPNOTSUPP;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4887
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4888
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4889
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4890
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4891
 * e1000_mii_ioctl -
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4892
 * @netdev:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4893
 * @ifreq:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4894
 * @cmd:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4895
 **/
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4896
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4897
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4898
e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4899
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4900
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4901
	struct mii_ioctl_data *data = if_mii(ifr);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4902
	int retval;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4903
	uint16_t mii_reg;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4904
	uint16_t spddplx;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4905
	unsigned long flags;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4906
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4907
	if (adapter->hw.media_type != e1000_media_type_copper)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4908
		return -EOPNOTSUPP;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4909
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4910
	switch (cmd) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4911
	case SIOCGMIIPHY:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4912
		data->phy_id = adapter->hw.phy_addr;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4913
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4914
	case SIOCGMIIREG:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4915
		if (adapter->ecdev || !capable(CAP_NET_ADMIN))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4916
			return -EPERM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4917
		spin_lock_irqsave(&adapter->stats_lock, flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4918
		if (e1000_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4919
				   &data->val_out)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4920
			spin_unlock_irqrestore(&adapter->stats_lock, flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4921
			return -EIO;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4922
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4923
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4924
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4925
	case SIOCSMIIREG:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4926
		if (adapter->ecdev || !capable(CAP_NET_ADMIN))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4927
			return -EPERM;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4928
		if (data->reg_num & ~(0x1F))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4929
			return -EFAULT;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4930
		mii_reg = data->val_in;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4931
		spin_lock_irqsave(&adapter->stats_lock, flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4932
		if (e1000_write_phy_reg(&adapter->hw, data->reg_num,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4933
					mii_reg)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4934
			spin_unlock_irqrestore(&adapter->stats_lock, flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4935
			return -EIO;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4936
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4937
		if (adapter->hw.media_type == e1000_media_type_copper) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4938
			switch (data->reg_num) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4939
			case PHY_CTRL:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4940
				if (mii_reg & MII_CR_POWER_DOWN)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4941
					break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4942
				if (mii_reg & MII_CR_AUTO_NEG_EN) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4943
					adapter->hw.autoneg = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4944
					adapter->hw.autoneg_advertised = 0x2F;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4945
				} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4946
					if (mii_reg & 0x40)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4947
						spddplx = SPEED_1000;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4948
					else if (mii_reg & 0x2000)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4949
						spddplx = SPEED_100;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4950
					else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4951
						spddplx = SPEED_10;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4952
					spddplx += (mii_reg & 0x100)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4953
						   ? DUPLEX_FULL :
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4954
						   DUPLEX_HALF;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4955
					retval = e1000_set_spd_dplx(adapter,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4956
								    spddplx);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4957
					if (retval) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4958
						spin_unlock_irqrestore(
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4959
							&adapter->stats_lock,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4960
							flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4961
						return retval;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4962
					}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4963
				}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4964
				if (netif_running(adapter->netdev))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4965
					e1000_reinit_locked(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4966
				else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4967
					e1000_reset(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4968
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4969
			case M88E1000_PHY_SPEC_CTRL:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4970
			case M88E1000_EXT_PHY_SPEC_CTRL:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4971
				if (e1000_phy_reset(&adapter->hw)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4972
					spin_unlock_irqrestore(
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4973
						&adapter->stats_lock, flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4974
					return -EIO;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4975
				}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4976
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4977
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4978
		} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4979
			switch (data->reg_num) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4980
			case PHY_CTRL:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4981
				if (mii_reg & MII_CR_POWER_DOWN)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4982
					break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4983
				if (netif_running(adapter->netdev))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4984
					e1000_reinit_locked(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4985
				else
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4986
					e1000_reset(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4987
				break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4988
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4989
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4990
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4991
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4992
	default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4993
		return -EOPNOTSUPP;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4994
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4995
	return E1000_SUCCESS;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4996
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4997
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4998
void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4999
e1000_pci_set_mwi(struct e1000_hw *hw)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5000
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5001
	struct e1000_adapter *adapter = hw->back;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5002
	int ret_val = pci_set_mwi(adapter->pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5003
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5004
	if (ret_val)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5005
		DPRINTK(PROBE, ERR, "Error in setting MWI\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5006
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5007
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5008
void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5009
e1000_pci_clear_mwi(struct e1000_hw *hw)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5010
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5011
	struct e1000_adapter *adapter = hw->back;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5012
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5013
	pci_clear_mwi(adapter->pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5014
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5015
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5016
void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5017
e1000_read_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5018
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5019
	struct e1000_adapter *adapter = hw->back;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5020
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5021
	pci_read_config_word(adapter->pdev, reg, value);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5022
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5023
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5024
void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5025
e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5026
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5027
	struct e1000_adapter *adapter = hw->back;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5028
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5029
	pci_write_config_word(adapter->pdev, reg, *value);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5030
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5031
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5032
int32_t
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5033
e1000_read_pcie_cap_reg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5034
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5035
    struct e1000_adapter *adapter = hw->back;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5036
    uint16_t cap_offset;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5037
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5038
    cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5039
    if (!cap_offset)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5040
        return -E1000_ERR_CONFIG;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5041
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5042
    pci_read_config_word(adapter->pdev, cap_offset + reg, value);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5043
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5044
    return E1000_SUCCESS;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5045
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5046
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5047
void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5048
e1000_io_write(struct e1000_hw *hw, unsigned long port, uint32_t value)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5049
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5050
	outl(value, port);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5051
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5052
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5053
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5054
e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5055
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5056
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5057
	uint32_t ctrl, rctl;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5058
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5059
	e1000_irq_disable(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5060
	adapter->vlgrp = grp;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5061
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5062
	if (grp) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5063
		/* enable VLAN tag insert/strip */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5064
		ctrl = E1000_READ_REG(&adapter->hw, CTRL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5065
		ctrl |= E1000_CTRL_VME;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5066
		E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5067
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5068
		if (adapter->hw.mac_type != e1000_ich8lan) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5069
			/* enable VLAN receive filtering */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5070
			rctl = E1000_READ_REG(&adapter->hw, RCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5071
			rctl |= E1000_RCTL_VFE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5072
			rctl &= ~E1000_RCTL_CFIEN;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5073
			E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5074
			e1000_update_mng_vlan(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5075
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5076
	} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5077
		/* disable VLAN tag insert/strip */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5078
		ctrl = E1000_READ_REG(&adapter->hw, CTRL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5079
		ctrl &= ~E1000_CTRL_VME;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5080
		E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5081
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5082
		if (adapter->hw.mac_type != e1000_ich8lan) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5083
			/* disable VLAN filtering */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5084
			rctl = E1000_READ_REG(&adapter->hw, RCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5085
			rctl &= ~E1000_RCTL_VFE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5086
			E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5087
			if (adapter->mng_vlan_id !=
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5088
			    (uint16_t)E1000_MNG_VLAN_NONE) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5089
				e1000_vlan_rx_kill_vid(netdev,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5090
				                       adapter->mng_vlan_id);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5091
				adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5092
			}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5093
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5094
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5095
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5096
	e1000_irq_enable(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5097
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5098
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5099
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5100
e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5101
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5102
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5103
	uint32_t vfta, index;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5104
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5105
	if ((adapter->hw.mng_cookie.status &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5106
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5107
	    (vid == adapter->mng_vlan_id))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5108
		return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5109
	/* add VID to filter table */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5110
	index = (vid >> 5) & 0x7F;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5111
	vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5112
	vfta |= (1 << (vid & 0x1F));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5113
	e1000_write_vfta(&adapter->hw, index, vfta);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5114
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5115
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5116
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5117
e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5118
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5119
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5120
	uint32_t vfta, index;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5121
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5122
	e1000_irq_disable(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5123
	vlan_group_set_device(adapter->vlgrp, vid, NULL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5124
	e1000_irq_enable(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5125
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5126
	if ((adapter->hw.mng_cookie.status &
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5127
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5128
	    (vid == adapter->mng_vlan_id)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5129
		/* release control to f/w */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5130
		e1000_release_hw_control(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5131
		return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5132
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5133
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5134
	/* remove VID from filter table */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5135
	index = (vid >> 5) & 0x7F;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5136
	vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5137
	vfta &= ~(1 << (vid & 0x1F));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5138
	e1000_write_vfta(&adapter->hw, index, vfta);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5139
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5140
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5141
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5142
e1000_restore_vlan(struct e1000_adapter *adapter)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5143
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5144
	e1000_vlan_rx_register(adapter->netdev, adapter->vlgrp);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5145
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5146
	if (adapter->vlgrp) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5147
		uint16_t vid;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5148
		for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5149
			if (!vlan_group_get_device(adapter->vlgrp, vid))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5150
				continue;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5151
			e1000_vlan_rx_add_vid(adapter->netdev, vid);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5152
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5153
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5154
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5155
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5156
int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5157
e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5158
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5159
	adapter->hw.autoneg = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5160
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5161
	/* Fiber NICs only allow 1000 gbps Full duplex */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5162
	if ((adapter->hw.media_type == e1000_media_type_fiber) &&
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5163
		spddplx != (SPEED_1000 + DUPLEX_FULL)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5164
		DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5165
		return -EINVAL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5166
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5167
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5168
	switch (spddplx) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5169
	case SPEED_10 + DUPLEX_HALF:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5170
		adapter->hw.forced_speed_duplex = e1000_10_half;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5171
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5172
	case SPEED_10 + DUPLEX_FULL:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5173
		adapter->hw.forced_speed_duplex = e1000_10_full;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5174
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5175
	case SPEED_100 + DUPLEX_HALF:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5176
		adapter->hw.forced_speed_duplex = e1000_100_half;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5177
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5178
	case SPEED_100 + DUPLEX_FULL:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5179
		adapter->hw.forced_speed_duplex = e1000_100_full;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5180
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5181
	case SPEED_1000 + DUPLEX_FULL:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5182
		adapter->hw.autoneg = 1;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5183
		adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5184
		break;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5185
	case SPEED_1000 + DUPLEX_HALF: /* not supported */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5186
	default:
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5187
		DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5188
		return -EINVAL;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5189
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5190
	return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5191
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5192
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5193
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5194
e1000_suspend(struct pci_dev *pdev, pm_message_t state)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5195
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5196
	struct net_device *netdev = pci_get_drvdata(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5197
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5198
	uint32_t ctrl, ctrl_ext, rctl, status;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5199
	uint32_t wufc = adapter->wol;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5200
#ifdef CONFIG_PM
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5201
	int retval = 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5202
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5203
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5204
	if (adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5205
		return -EBUSY;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5206
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5207
	netif_device_detach(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5208
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5209
	if (netif_running(netdev)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5210
		WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5211
		e1000_down(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5212
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5213
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5214
#ifdef CONFIG_PM
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5215
	retval = pci_save_state(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5216
	if (retval)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5217
		return retval;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5218
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5219
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5220
	status = E1000_READ_REG(&adapter->hw, STATUS);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5221
	if (status & E1000_STATUS_LU)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5222
		wufc &= ~E1000_WUFC_LNKC;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5223
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5224
	if (wufc) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5225
		e1000_setup_rctl(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5226
		e1000_set_multi(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5227
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5228
		/* turn on all-multi mode if wake on multicast is enabled */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5229
		if (wufc & E1000_WUFC_MC) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5230
			rctl = E1000_READ_REG(&adapter->hw, RCTL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5231
			rctl |= E1000_RCTL_MPE;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5232
			E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5233
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5234
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5235
		if (adapter->hw.mac_type >= e1000_82540) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5236
			ctrl = E1000_READ_REG(&adapter->hw, CTRL);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5237
			/* advertise wake from D3Cold */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5238
			#define E1000_CTRL_ADVD3WUC 0x00100000
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5239
			/* phy power management enable */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5240
			#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5241
			ctrl |= E1000_CTRL_ADVD3WUC |
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5242
				E1000_CTRL_EN_PHY_PWR_MGMT;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5243
			E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5244
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5245
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5246
		if (adapter->hw.media_type == e1000_media_type_fiber ||
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5247
		   adapter->hw.media_type == e1000_media_type_internal_serdes) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5248
			/* keep the laser running in D3 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5249
			ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5250
			ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5251
			E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5252
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5253
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5254
		/* Allow time for pending master requests to run */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5255
		e1000_disable_pciex_master(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5256
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5257
		E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5258
		E1000_WRITE_REG(&adapter->hw, WUFC, wufc);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5259
		pci_enable_wake(pdev, PCI_D3hot, 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5260
		pci_enable_wake(pdev, PCI_D3cold, 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5261
	} else {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5262
		E1000_WRITE_REG(&adapter->hw, WUC, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5263
		E1000_WRITE_REG(&adapter->hw, WUFC, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5264
		pci_enable_wake(pdev, PCI_D3hot, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5265
		pci_enable_wake(pdev, PCI_D3cold, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5266
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5267
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5268
	e1000_release_manageability(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5269
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5270
	/* make sure adapter isn't asleep if manageability is enabled */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5271
	if (adapter->en_mng_pt) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5272
		pci_enable_wake(pdev, PCI_D3hot, 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5273
		pci_enable_wake(pdev, PCI_D3cold, 1);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5274
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5275
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5276
	if (adapter->hw.phy_type == e1000_phy_igp_3)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5277
		e1000_phy_powerdown_workaround(&adapter->hw);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5278
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5279
	if (netif_running(netdev))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5280
		e1000_free_irq(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5281
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5282
	/* Release control of h/w to f/w.  If f/w is AMT enabled, this
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5283
	 * would have already happened in close and is redundant. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5284
	e1000_release_hw_control(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5285
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5286
	pci_disable_device(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5287
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5288
	pci_set_power_state(pdev, pci_choose_state(pdev, state));
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5289
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5290
	return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5291
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5292
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5293
#ifdef CONFIG_PM
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5294
static int
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5295
e1000_resume(struct pci_dev *pdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5296
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5297
	struct net_device *netdev = pci_get_drvdata(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5298
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5299
	uint32_t err;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5300
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5301
	if (adapter->ecdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5302
		return -EBUSY;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5303
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5304
	pci_set_power_state(pdev, PCI_D0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5305
	pci_restore_state(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5306
	if ((err = pci_enable_device(pdev))) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5307
		printk(KERN_ERR "e1000: Cannot enable PCI device from suspend\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5308
		return err;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5309
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5310
	pci_set_master(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5311
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5312
	pci_enable_wake(pdev, PCI_D3hot, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5313
	pci_enable_wake(pdev, PCI_D3cold, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5314
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5315
	if (netif_running(netdev) && (err = e1000_request_irq(adapter)))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5316
		return err;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5317
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5318
	e1000_power_up_phy(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5319
	e1000_reset(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5320
	E1000_WRITE_REG(&adapter->hw, WUS, ~0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5321
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5322
	e1000_init_manageability(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5323
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5324
	if (netif_running(netdev))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5325
		e1000_up(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5326
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5327
	if (!adapter->ecdev) netif_device_attach(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5328
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5329
	/* If the controller is 82573 and f/w is AMT, do not set
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5330
	 * DRV_LOAD until the interface is up.  For all other cases,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5331
	 * let the f/w know that the h/w is now under the control
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5332
	 * of the driver. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5333
	if (adapter->hw.mac_type != e1000_82573 ||
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5334
	    !e1000_check_mng_mode(&adapter->hw))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5335
		e1000_get_hw_control(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5336
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5337
	return 0;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5338
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5339
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5340
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5341
static void e1000_shutdown(struct pci_dev *pdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5342
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5343
	e1000_suspend(pdev, PMSG_SUSPEND);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5344
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5345
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5346
#ifdef CONFIG_NET_POLL_CONTROLLER
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5347
/*
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5348
 * Polling 'interrupt' - used by things like netconsole to send skbs
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5349
 * without having to re-enable interrupts. It's not called while
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5350
 * the interrupt routine is executing.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5351
 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5352
static void
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5353
e1000_netpoll(struct net_device *netdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5354
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5355
	struct e1000_adapter *adapter = netdev_priv(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5356
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5357
	disable_irq(adapter->pdev->irq);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5358
	e1000_intr(adapter->pdev->irq, netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5359
	e1000_clean_tx_irq(adapter, adapter->tx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5360
#ifndef CONFIG_E1000_NAPI
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5361
	adapter->clean_rx(adapter, adapter->rx_ring);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5362
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5363
	enable_irq(adapter->pdev->irq);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5364
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5365
#endif
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5366
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5367
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5368
 * e1000_io_error_detected - called when PCI error is detected
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5369
 * @pdev: Pointer to PCI device
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5370
 * @state: The current pci conneection state
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5371
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5372
 * This function is called after a PCI bus error affecting
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5373
 * this device has been detected.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5374
 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5375
static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5376
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5377
	struct net_device *netdev = pci_get_drvdata(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5378
	struct e1000_adapter *adapter = netdev->priv;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5379
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5380
	netif_device_detach(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5381
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5382
	if (netif_running(netdev))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5383
		e1000_down(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5384
	pci_disable_device(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5385
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5386
	/* Request a slot slot reset. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5387
	return PCI_ERS_RESULT_NEED_RESET;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5388
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5389
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5390
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5391
 * e1000_io_slot_reset - called after the pci bus has been reset.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5392
 * @pdev: Pointer to PCI device
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5393
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5394
 * Restart the card from scratch, as if from a cold-boot. Implementation
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5395
 * resembles the first-half of the e1000_resume routine.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5396
 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5397
static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5398
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5399
	struct net_device *netdev = pci_get_drvdata(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5400
	struct e1000_adapter *adapter = netdev->priv;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5401
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5402
	if (pci_enable_device(pdev)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5403
		printk(KERN_ERR "e1000: Cannot re-enable PCI device after reset.\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5404
		return PCI_ERS_RESULT_DISCONNECT;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5405
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5406
	pci_set_master(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5407
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5408
	pci_enable_wake(pdev, PCI_D3hot, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5409
	pci_enable_wake(pdev, PCI_D3cold, 0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5410
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5411
	e1000_reset(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5412
	E1000_WRITE_REG(&adapter->hw, WUS, ~0);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5413
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5414
	return PCI_ERS_RESULT_RECOVERED;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5415
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5416
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5417
/**
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5418
 * e1000_io_resume - called when traffic can start flowing again.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5419
 * @pdev: Pointer to PCI device
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5420
 *
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5421
 * This callback is called when the error recovery driver tells us that
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5422
 * its OK to resume normal operation. Implementation resembles the
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5423
 * second-half of the e1000_resume routine.
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5424
 */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5425
static void e1000_io_resume(struct pci_dev *pdev)
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5426
{
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5427
	struct net_device *netdev = pci_get_drvdata(pdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5428
	struct e1000_adapter *adapter = netdev->priv;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5429
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5430
	e1000_init_manageability(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5431
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5432
	if (netif_running(netdev)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5433
		if (e1000_up(adapter)) {
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5434
			printk("e1000: can't bring device back up after reset\n");
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5435
			return;
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5436
		}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5437
	}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5438
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5439
	netif_device_attach(netdev);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5440
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5441
	/* If the controller is 82573 and f/w is AMT, do not set
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5442
	 * DRV_LOAD until the interface is up.  For all other cases,
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5443
	 * let the f/w know that the h/w is now under the control
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5444
	 * of the driver. */
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5445
	if (adapter->hw.mac_type != e1000_82573 ||
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5446
	    !e1000_check_mng_mode(&adapter->hw))
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5447
		e1000_get_hw_control(adapter);
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5448
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5449
}
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5450
e750b37597ad Added e1000 driver for kernel 2.6.22.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5451
/* e1000_main.c */