devices/e1000/e1000_main-2.6.26-ethercat.c
author Florian Pose <fp@igh-essen.com>
Tue, 12 Feb 2013 15:46:43 +0100
branchstable-1.5
changeset 2522 ec403cf308eb
parent 2471 fc64a4b1ec1a
child 2582 87e502828b3f
permissions -rw-r--r--
Updated Doxygen documentation.
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*******************************************************************************
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
  Intel PRO/1000 Linux driver
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
  Copyright(c) 1999 - 2006 Intel Corporation.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
  This program is free software; you can redistribute it and/or modify it
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
  under the terms and conditions of the GNU General Public License,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
  version 2, as published by the Free Software Foundation.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
  This program is distributed in the hope it will be useful, but WITHOUT
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
  more details.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
  You should have received a copy of the GNU General Public License along with
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
  this program; if not, write to the Free Software Foundation, Inc.,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
  The full GNU General Public License is included in this distribution in
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
  the file called "COPYING".
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
  Contact Information:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  Linux NICS <linux.nics@intel.com>
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
  vim: noexpandtab
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
*******************************************************************************/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
#include "e1000-2.6.26-ethercat.h"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
#include <net/ip6_checksum.h>
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
char e1000_driver_name[] = "ec_e1000";
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
static char e1000_driver_string[] = "EtherCAT Intel(R) PRO/1000 Network Driver";
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
#ifndef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
#define DRIVERNAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
#define DRIVERNAPI "-NAPI"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
#define DRV_VERSION "7.3.20-k2"DRIVERNAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
const char e1000_driver_version[] = DRV_VERSION;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation.";
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
/* e1000_pci_tbl - PCI Device ID Table
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
 * Last entry must be all 0s
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
 * Macro expands to...
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
 *   {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
#ifdef CONFIG_E1000E_ENABLED
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
  #define PCIE(x) 
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
  #define PCIE(x) x,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
static struct pci_device_id e1000_pci_tbl[] = {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
	INTEL_E1000_ETHERNET_DEVICE(0x1000),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
	INTEL_E1000_ETHERNET_DEVICE(0x1001),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
	INTEL_E1000_ETHERNET_DEVICE(0x1004),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
	INTEL_E1000_ETHERNET_DEVICE(0x1008),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
	INTEL_E1000_ETHERNET_DEVICE(0x1009),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
	INTEL_E1000_ETHERNET_DEVICE(0x100C),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
	INTEL_E1000_ETHERNET_DEVICE(0x100D),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
	INTEL_E1000_ETHERNET_DEVICE(0x100E),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
	INTEL_E1000_ETHERNET_DEVICE(0x100F),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
	INTEL_E1000_ETHERNET_DEVICE(0x1010),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
	INTEL_E1000_ETHERNET_DEVICE(0x1011),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
	INTEL_E1000_ETHERNET_DEVICE(0x1012),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
	INTEL_E1000_ETHERNET_DEVICE(0x1013),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
	INTEL_E1000_ETHERNET_DEVICE(0x1014),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
	INTEL_E1000_ETHERNET_DEVICE(0x1015),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
	INTEL_E1000_ETHERNET_DEVICE(0x1016),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
	INTEL_E1000_ETHERNET_DEVICE(0x1017),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
	INTEL_E1000_ETHERNET_DEVICE(0x1018),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
	INTEL_E1000_ETHERNET_DEVICE(0x1019),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
	INTEL_E1000_ETHERNET_DEVICE(0x101A),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
	INTEL_E1000_ETHERNET_DEVICE(0x101D),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
	INTEL_E1000_ETHERNET_DEVICE(0x101E),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
	INTEL_E1000_ETHERNET_DEVICE(0x1026),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
	INTEL_E1000_ETHERNET_DEVICE(0x1027),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
	INTEL_E1000_ETHERNET_DEVICE(0x1028),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x1049))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x104A))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x104B))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    87
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x104C))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x104D))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x105E))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x105F))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x1060))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    92
	INTEL_E1000_ETHERNET_DEVICE(0x1075),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    93
	INTEL_E1000_ETHERNET_DEVICE(0x1076),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    94
	INTEL_E1000_ETHERNET_DEVICE(0x1077),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    95
	INTEL_E1000_ETHERNET_DEVICE(0x1078),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    96
	INTEL_E1000_ETHERNET_DEVICE(0x1079),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
	INTEL_E1000_ETHERNET_DEVICE(0x107A),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
	INTEL_E1000_ETHERNET_DEVICE(0x107B),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
	INTEL_E1000_ETHERNET_DEVICE(0x107C),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x107D))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x107E))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x107F))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
	INTEL_E1000_ETHERNET_DEVICE(0x108A),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   104
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x108B))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   105
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x108C))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   106
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x1096))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   107
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x1098))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
	INTEL_E1000_ETHERNET_DEVICE(0x1099),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x109A))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   110
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x10A4))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   111
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x10A5))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
	INTEL_E1000_ETHERNET_DEVICE(0x10B5),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x10B9))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x10BA))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x10BB))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x10BC))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x10C4))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x10C5))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x10D5))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x10D9))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
PCIE(	INTEL_E1000_ETHERNET_DEVICE(0x10DA))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
	/* required last entry */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
	{0,}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
};
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
// do not auto-load driver
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
// MODULE_DEVICE_TABLE(pci, e1000_pci_tbl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
int e1000_up(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
void e1000_down(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
void e1000_reinit_locked(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
void e1000_reset(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
int e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
int e1000_setup_all_tx_resources(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
int e1000_setup_all_rx_resources(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
void e1000_free_all_tx_resources(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
void e1000_free_all_rx_resources(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
static int e1000_setup_tx_resources(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
                             struct e1000_tx_ring *txdr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
static int e1000_setup_rx_resources(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
                             struct e1000_rx_ring *rxdr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
static void e1000_free_tx_resources(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
                             struct e1000_tx_ring *tx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
static void e1000_free_rx_resources(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
                             struct e1000_rx_ring *rx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
void e1000_update_stats(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
static int e1000_init_module(void);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
static void e1000_exit_module(void);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   150
static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   151
static void __devexit e1000_remove(struct pci_dev *pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   152
static int e1000_alloc_queues(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
static int e1000_sw_init(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   154
static int e1000_open(struct net_device *netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
static int e1000_close(struct net_device *netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   156
static void e1000_configure_tx(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
static void e1000_configure_rx(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   158
static void e1000_setup_rctl(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   159
static void e1000_clean_all_tx_rings(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   160
static void e1000_clean_all_rx_rings(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   161
static void e1000_clean_tx_ring(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   162
                                struct e1000_tx_ring *tx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   163
static void e1000_clean_rx_ring(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
                                struct e1000_rx_ring *rx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
static void e1000_set_rx_mode(struct net_device *netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
static void e1000_update_phy_info(unsigned long data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
static void e1000_watchdog(unsigned long data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
static void e1000_82547_tx_fifo_stall(unsigned long data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
static struct net_device_stats * e1000_get_stats(struct net_device *netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   171
static int e1000_change_mtu(struct net_device *netdev, int new_mtu);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   172
static int e1000_set_mac(struct net_device *netdev, void *p);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   173
void ec_poll(struct net_device *);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   174
static irqreturn_t e1000_intr(int irq, void *data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   175
static irqreturn_t e1000_intr_msi(int irq, void *data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   176
static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   177
			       struct e1000_tx_ring *tx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   178
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
static int e1000_clean(struct napi_struct *napi, int budget);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
			       struct e1000_rx_ring *rx_ring,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
			       int *work_done, int work_to_do);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
				  struct e1000_rx_ring *rx_ring,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
				  int *work_done, int work_to_do);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
			       struct e1000_rx_ring *rx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
static bool e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
				  struct e1000_rx_ring *rx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   191
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   192
static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
                                   struct e1000_rx_ring *rx_ring,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
				   int cleaned_count);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
static void e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
                                      struct e1000_rx_ring *rx_ring,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
				      int cleaned_count);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   199
static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
			   int cmd);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
static void e1000_enter_82542_rst(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
static void e1000_leave_82542_rst(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
static void e1000_tx_timeout(struct net_device *dev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
static void e1000_reset_task(struct work_struct *work);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
static void e1000_smartspeed(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   206
static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   207
                                       struct sk_buff *skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   208
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   209
static void e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   210
static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   211
static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   212
static void e1000_restore_vlan(struct e1000_adapter *adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   213
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
static int e1000_suspend(struct pci_dev *pdev, pm_message_t state);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   215
#ifdef CONFIG_PM
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   216
static int e1000_resume(struct pci_dev *pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
static void e1000_shutdown(struct pci_dev *pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
#ifdef CONFIG_NET_POLL_CONTROLLER
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
/* for netdump / net console */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   222
static void e1000_netpoll (struct net_device *netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   223
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   224
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   225
#define COPYBREAK_DEFAULT 256
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   226
static unsigned int copybreak __read_mostly = COPYBREAK_DEFAULT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   227
module_param(copybreak, uint, 0644);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   228
MODULE_PARM_DESC(copybreak,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   229
	"Maximum size of packet that is copied to a new buffer on receive");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   230
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   231
static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   232
                     pci_channel_state_t state);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   233
static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   234
static void e1000_io_resume(struct pci_dev *pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   235
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   236
static struct pci_error_handlers e1000_err_handler = {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   237
	.error_detected = e1000_io_error_detected,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   238
	.slot_reset = e1000_io_slot_reset,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   239
	.resume = e1000_io_resume,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   240
};
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   241
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   242
static struct pci_driver e1000_driver = {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   243
	.name     = e1000_driver_name,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   244
	.id_table = e1000_pci_tbl,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   245
	.probe    = e1000_probe,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   246
	.remove   = __devexit_p(e1000_remove),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   247
#ifdef CONFIG_PM
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   248
	/* Power Managment Hooks */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   249
	.suspend  = e1000_suspend,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   250
	.resume   = e1000_resume,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   251
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   252
	.shutdown = e1000_shutdown,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   253
	.err_handler = &e1000_err_handler
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   254
};
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   255
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   256
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   257
MODULE_DESCRIPTION("EtherCAT-capable Intel(R) PRO/1000 Network Driver");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   258
MODULE_LICENSE("GPL");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   259
MODULE_VERSION(DRV_VERSION);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   260
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   261
static int debug = NETIF_MSG_DRV | NETIF_MSG_PROBE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   262
module_param(debug, int, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   263
MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   264
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   265
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   266
 * e1000_init_module - Driver Registration Routine
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   267
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   268
 * e1000_init_module is the first routine called when the driver is
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
 * loaded. All it does is register with the PCI subsystem.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   270
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   271
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   272
static int __init
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   273
e1000_init_module(void)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   274
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   275
	int ret;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   276
	printk(KERN_INFO "%s - version %s\n",
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   277
	       e1000_driver_string, e1000_driver_version);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   278
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   279
	printk(KERN_INFO "%s\n", e1000_copyright);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   280
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   281
	ret = pci_register_driver(&e1000_driver);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   282
	if (copybreak != COPYBREAK_DEFAULT) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   283
		if (copybreak == 0)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
			printk(KERN_INFO "e1000: copybreak disabled\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
		else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
			printk(KERN_INFO "e1000: copybreak enabled for "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
			       "packets <= %u bytes\n", copybreak);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   289
	return ret;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   292
module_init(e1000_init_module);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   293
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   294
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   295
 * e1000_exit_module - Driver Exit Cleanup Routine
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   296
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   297
 * e1000_exit_module is called just before the driver is removed
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
 * from memory.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   299
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   300
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
static void __exit
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
e1000_exit_module(void)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
	pci_unregister_driver(&e1000_driver);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
module_exit(e1000_exit_module);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   308
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
static int e1000_request_irq(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   310
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   311
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   312
	irq_handler_t handler = e1000_intr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   313
	int irq_flags = IRQF_SHARED;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   314
	int err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   315
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   316
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   317
		return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   319
	if (adapter->hw.mac_type >= e1000_82571) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
		adapter->have_msi = !pci_enable_msi(adapter->pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
		if (adapter->have_msi) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
			handler = e1000_intr_msi;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
			irq_flags = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   325
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   326
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
	err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
	                  netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
	if (err) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
		if (adapter->have_msi)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
			pci_disable_msi(adapter->pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   332
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   333
		        "Unable to allocate interrupt Error: %d\n", err);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   334
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   335
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   336
	return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   337
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   338
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   339
static void e1000_free_irq(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   340
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   341
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   342
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   343
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   344
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   345
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   346
	free_irq(adapter->pdev->irq, netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   347
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   348
	if (adapter->have_msi)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   349
		pci_disable_msi(adapter->pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   350
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   351
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   352
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   353
 * e1000_irq_disable - Mask off interrupt generation on the NIC
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   354
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   355
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   356
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   357
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   358
e1000_irq_disable(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   359
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   360
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   361
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   362
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   363
	E1000_WRITE_REG(&adapter->hw, IMC, ~0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   364
	E1000_WRITE_FLUSH(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   365
	synchronize_irq(adapter->pdev->irq);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   366
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   367
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   368
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   369
 * e1000_irq_enable - Enable default interrupt generation settings
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   370
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   371
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   372
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   373
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   374
e1000_irq_enable(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   375
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   376
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   377
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   378
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   379
	E1000_WRITE_REG(&adapter->hw, IMS, IMS_ENABLE_MASK);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   380
	E1000_WRITE_FLUSH(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   381
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   382
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   383
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   384
e1000_update_mng_vlan(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   385
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   386
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   387
	u16 vid = adapter->hw.mng_cookie.vlan_id;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   388
	u16 old_vid = adapter->mng_vlan_id;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   389
	if (adapter->vlgrp) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   390
		if (!vlan_group_get_device(adapter->vlgrp, vid)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   391
			if (adapter->hw.mng_cookie.status &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   392
				E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   393
				e1000_vlan_rx_add_vid(netdev, vid);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   394
				adapter->mng_vlan_id = vid;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   395
			} else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   396
				adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   397
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   398
			if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   399
					(vid != old_vid) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   400
			    !vlan_group_get_device(adapter->vlgrp, old_vid))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   401
				e1000_vlan_rx_kill_vid(netdev, old_vid);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   402
		} else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   403
			adapter->mng_vlan_id = vid;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   404
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   405
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   406
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   407
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   408
 * e1000_release_hw_control - release control of the h/w to f/w
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   409
 * @adapter: address of board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   410
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   411
 * e1000_release_hw_control resets {CTRL_EXT|FWSM}:DRV_LOAD bit.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   412
 * For ASF and Pass Through versions of f/w this means that the
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   413
 * driver is no longer loaded. For AMT version (only with 82573) i
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   414
 * of the f/w this means that the network i/f is closed.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   415
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   416
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   417
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   418
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   419
e1000_release_hw_control(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   420
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   421
	u32 ctrl_ext;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   422
	u32 swsm;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   423
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   424
	/* Let firmware taken over control of h/w */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   425
	switch (adapter->hw.mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   426
	case e1000_82573:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   427
		swsm = E1000_READ_REG(&adapter->hw, SWSM);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   428
		E1000_WRITE_REG(&adapter->hw, SWSM,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   429
				swsm & ~E1000_SWSM_DRV_LOAD);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   430
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   431
	case e1000_82571:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   432
	case e1000_82572:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   433
	case e1000_80003es2lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   434
	case e1000_ich8lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   435
		ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   436
		E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   437
				ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   438
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   439
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   440
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   441
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   442
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   443
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   444
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   445
 * e1000_get_hw_control - get control of the h/w from f/w
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   446
 * @adapter: address of board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   447
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   448
 * e1000_get_hw_control sets {CTRL_EXT|FWSM}:DRV_LOAD bit.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   449
 * For ASF and Pass Through versions of f/w this means that
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   450
 * the driver is loaded. For AMT version (only with 82573)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   451
 * of the f/w this means that the network i/f is open.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   452
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   453
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   454
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   455
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   456
e1000_get_hw_control(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   457
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   458
	u32 ctrl_ext;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   459
	u32 swsm;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   460
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   461
	/* Let firmware know the driver has taken over */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   462
	switch (adapter->hw.mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   463
	case e1000_82573:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   464
		swsm = E1000_READ_REG(&adapter->hw, SWSM);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   465
		E1000_WRITE_REG(&adapter->hw, SWSM,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   466
				swsm | E1000_SWSM_DRV_LOAD);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   467
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   468
	case e1000_82571:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   469
	case e1000_82572:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   470
	case e1000_80003es2lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   471
	case e1000_ich8lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   472
		ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   473
		E1000_WRITE_REG(&adapter->hw, CTRL_EXT,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   474
				ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   475
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   476
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   477
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   478
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   479
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   480
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   481
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   482
e1000_init_manageability(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   483
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   484
	if (adapter->en_mng_pt) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   485
		u32 manc = E1000_READ_REG(&adapter->hw, MANC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   486
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   487
		/* disable hardware interception of ARP */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   488
		manc &= ~(E1000_MANC_ARP_EN);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   489
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   490
		/* enable receiving management packets to the host */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   491
		/* this will probably generate destination unreachable messages
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   492
		 * from the host OS, but the packets will be handled on SMBUS */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   493
		if (adapter->hw.has_manc2h) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   494
			u32 manc2h = E1000_READ_REG(&adapter->hw, MANC2H);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   495
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   496
			manc |= E1000_MANC_EN_MNG2HOST;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   497
#define E1000_MNG2HOST_PORT_623 (1 << 5)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   498
#define E1000_MNG2HOST_PORT_664 (1 << 6)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   499
			manc2h |= E1000_MNG2HOST_PORT_623;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   500
			manc2h |= E1000_MNG2HOST_PORT_664;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   501
			E1000_WRITE_REG(&adapter->hw, MANC2H, manc2h);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   502
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   503
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   504
		E1000_WRITE_REG(&adapter->hw, MANC, manc);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   505
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   506
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   507
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   508
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   509
e1000_release_manageability(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   510
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   511
	if (adapter->en_mng_pt) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   512
		u32 manc = E1000_READ_REG(&adapter->hw, MANC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   513
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   514
		/* re-enable hardware interception of ARP */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   515
		manc |= E1000_MANC_ARP_EN;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   516
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   517
		if (adapter->hw.has_manc2h)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   518
			manc &= ~E1000_MANC_EN_MNG2HOST;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   519
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   520
		/* don't explicitly have to mess with MANC2H since
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   521
		 * MANC has an enable disable that gates MANC2H */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   522
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   523
		E1000_WRITE_REG(&adapter->hw, MANC, manc);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   524
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   525
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   526
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   527
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   528
 * e1000_configure - configure the hardware for RX and TX
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   529
 * @adapter = private board structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   530
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   531
static void e1000_configure(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   532
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   533
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   534
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   535
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   536
	e1000_set_rx_mode(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   537
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   538
	e1000_restore_vlan(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   539
	e1000_init_manageability(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   540
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   541
	e1000_configure_tx(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   542
	e1000_setup_rctl(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   543
	e1000_configure_rx(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   544
	/* call E1000_DESC_UNUSED which always leaves
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   545
	 * at least 1 descriptor unused to make sure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   546
	 * next_to_use != next_to_clean */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   547
	for (i = 0; i < adapter->num_rx_queues; i++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   548
		struct e1000_rx_ring *ring = &adapter->rx_ring[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   549
		if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   550
			/* fill rx ring completely! */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   551
			adapter->alloc_rx_buf(adapter, ring, ring->count);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   552
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   553
            /* this one leaves the last ring element unallocated! */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   554
			adapter->alloc_rx_buf(adapter, ring,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   555
					E1000_DESC_UNUSED(ring));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   556
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   557
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   558
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   559
	adapter->tx_queue_len = netdev->tx_queue_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   560
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   561
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   562
int e1000_up(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   563
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   564
	/* hardware has been reset, we need to reload some things */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   565
	e1000_configure(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   566
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   567
	clear_bit(__E1000_DOWN, &adapter->flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   568
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   569
	if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   570
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   571
		napi_enable(&adapter->napi);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   572
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   573
		e1000_irq_enable(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   574
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   575
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   576
	/* fire a link change interrupt to start the watchdog */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   577
	if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   578
		E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_LSC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   579
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   580
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   581
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   582
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   583
 * e1000_power_up_phy - restore link in case the phy was powered down
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   584
 * @adapter: address of board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   585
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   586
 * The phy may be powered down to save power and turn off link when the
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   587
 * driver is unloaded and wake on lan is not enabled (among others)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   588
 * *** this routine MUST be followed by a call to e1000_reset ***
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   589
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   590
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   591
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   592
void e1000_power_up_phy(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   593
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   594
	u16 mii_reg = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   595
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   596
	/* Just clear the power down bit to wake the phy back up */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   597
	if (adapter->hw.media_type == e1000_media_type_copper) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   598
		/* according to the manual, the phy will retain its
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   599
		 * settings across a power-down/up cycle */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   600
		e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   601
		mii_reg &= ~MII_CR_POWER_DOWN;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   602
		e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   603
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   604
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   605
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   606
static void e1000_power_down_phy(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   607
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   608
	/* Power down the PHY so no link is implied when interface is down *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   609
	 * The PHY cannot be powered down if any of the following is true *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   610
	 * (a) WoL is enabled
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   611
	 * (b) AMT is active
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   612
	 * (c) SoL/IDER session is active */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   613
	if (!adapter->wol && adapter->hw.mac_type >= e1000_82540 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   614
	   adapter->hw.media_type == e1000_media_type_copper) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   615
		u16 mii_reg = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   616
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   617
		switch (adapter->hw.mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   618
		case e1000_82540:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   619
		case e1000_82545:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   620
		case e1000_82545_rev_3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   621
		case e1000_82546:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   622
		case e1000_82546_rev_3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   623
		case e1000_82541:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   624
		case e1000_82541_rev_2:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   625
		case e1000_82547:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   626
		case e1000_82547_rev_2:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   627
			if (E1000_READ_REG(&adapter->hw, MANC) &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   628
			    E1000_MANC_SMBUS_EN)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   629
				goto out;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   630
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   631
		case e1000_82571:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   632
		case e1000_82572:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   633
		case e1000_82573:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   634
		case e1000_80003es2lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   635
		case e1000_ich8lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   636
			if (e1000_check_mng_mode(&adapter->hw) ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   637
			    e1000_check_phy_reset_block(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   638
				goto out;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   639
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   640
		default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   641
			goto out;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   642
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   643
		e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &mii_reg);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   644
		mii_reg |= MII_CR_POWER_DOWN;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   645
		e1000_write_phy_reg(&adapter->hw, PHY_CTRL, mii_reg);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   646
		mdelay(1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   647
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   648
out:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   649
	return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   650
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   651
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   652
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   653
e1000_down(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   654
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   655
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   656
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   657
	/* signal that we're down so the interrupt handler does not
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   658
	 * reschedule our watchdog timer */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   659
	set_bit(__E1000_DOWN, &adapter->flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   660
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   661
	if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   662
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   663
		napi_disable(&adapter->napi);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   664
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   665
		e1000_irq_disable(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   666
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   667
		del_timer_sync(&adapter->tx_fifo_stall_timer);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   668
		del_timer_sync(&adapter->watchdog_timer);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   669
		del_timer_sync(&adapter->phy_info_timer);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   670
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   671
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   672
	netdev->tx_queue_len = adapter->tx_queue_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   673
	adapter->link_speed = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   674
	adapter->link_duplex = 0;
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
   675
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   676
	if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   677
		netif_carrier_off(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   678
		netif_stop_queue(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   679
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   680
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   681
	e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   682
	e1000_clean_all_tx_rings(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   683
	e1000_clean_all_rx_rings(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   684
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   685
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   686
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   687
e1000_reinit_locked(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   688
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   689
	WARN_ON(in_interrupt());
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   690
	while (test_and_set_bit(__E1000_RESETTING, &adapter->flags))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   691
		msleep(1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   692
	e1000_down(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   693
	e1000_up(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   694
	clear_bit(__E1000_RESETTING, &adapter->flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   695
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   696
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   697
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   698
e1000_reset(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   699
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   700
	u32 pba = 0, tx_space, min_tx_space, min_rx_space;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   701
	u16 fc_high_water_mark = E1000_FC_HIGH_DIFF;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   702
	bool legacy_pba_adjust = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   703
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   704
	/* Repartition Pba for greater than 9k mtu
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   705
	 * To take effect CTRL.RST is required.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   706
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   707
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   708
	switch (adapter->hw.mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   709
	case e1000_82542_rev2_0:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   710
	case e1000_82542_rev2_1:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   711
	case e1000_82543:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   712
	case e1000_82544:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   713
	case e1000_82540:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   714
	case e1000_82541:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   715
	case e1000_82541_rev_2:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   716
		legacy_pba_adjust = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   717
		pba = E1000_PBA_48K;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   718
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   719
	case e1000_82545:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   720
	case e1000_82545_rev_3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   721
	case e1000_82546:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   722
	case e1000_82546_rev_3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   723
		pba = E1000_PBA_48K;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   724
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   725
	case e1000_82547:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   726
	case e1000_82547_rev_2:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   727
		legacy_pba_adjust = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   728
		pba = E1000_PBA_30K;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   729
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   730
	case e1000_82571:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   731
	case e1000_82572:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   732
	case e1000_80003es2lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   733
		pba = E1000_PBA_38K;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   734
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   735
	case e1000_82573:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   736
		pba = E1000_PBA_20K;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   737
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   738
	case e1000_ich8lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   739
		pba = E1000_PBA_8K;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   740
	case e1000_undefined:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   741
	case e1000_num_macs:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   742
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   743
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   744
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   745
	if (legacy_pba_adjust) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   746
		if (adapter->netdev->mtu > E1000_RXBUFFER_8192)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   747
			pba -= 8; /* allocate more FIFO for Tx */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   748
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   749
		if (adapter->hw.mac_type == e1000_82547) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   750
			adapter->tx_fifo_head = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   751
			adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   752
			adapter->tx_fifo_size =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   753
				(E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   754
			atomic_set(&adapter->tx_fifo_stall, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   755
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   756
	} else if (adapter->hw.max_frame_size > MAXIMUM_ETHERNET_FRAME_SIZE) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   757
		/* adjust PBA for jumbo frames */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   758
		E1000_WRITE_REG(&adapter->hw, PBA, pba);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   759
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   760
		/* To maintain wire speed transmits, the Tx FIFO should be
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   761
		 * large enough to accomodate two full transmit packets,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   762
		 * rounded up to the next 1KB and expressed in KB.  Likewise,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   763
		 * the Rx FIFO should be large enough to accomodate at least
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   764
		 * one full receive packet and is similarly rounded up and
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   765
		 * expressed in KB. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   766
		pba = E1000_READ_REG(&adapter->hw, PBA);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   767
		/* upper 16 bits has Tx packet buffer allocation size in KB */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   768
		tx_space = pba >> 16;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   769
		/* lower 16 bits has Rx packet buffer allocation size in KB */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   770
		pba &= 0xffff;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   771
		/* don't include ethernet FCS because hardware appends/strips */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   772
		min_rx_space = adapter->netdev->mtu + ENET_HEADER_SIZE +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   773
		               VLAN_TAG_SIZE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   774
		min_tx_space = min_rx_space;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   775
		min_tx_space *= 2;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   776
		min_tx_space = ALIGN(min_tx_space, 1024);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   777
		min_tx_space >>= 10;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   778
		min_rx_space = ALIGN(min_rx_space, 1024);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   779
		min_rx_space >>= 10;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   780
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   781
		/* If current Tx allocation is less than the min Tx FIFO size,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   782
		 * and the min Tx FIFO size is less than the current Rx FIFO
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   783
		 * allocation, take space away from current Rx allocation */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   784
		if (tx_space < min_tx_space &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   785
		    ((min_tx_space - tx_space) < pba)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   786
			pba = pba - (min_tx_space - tx_space);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   787
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   788
			/* PCI/PCIx hardware has PBA alignment constraints */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   789
			switch (adapter->hw.mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   790
			case e1000_82545 ... e1000_82546_rev_3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   791
				pba &= ~(E1000_PBA_8K - 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   792
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   793
			default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   794
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   795
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   796
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   797
			/* if short on rx space, rx wins and must trump tx
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   798
			 * adjustment or use Early Receive if available */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   799
			if (pba < min_rx_space) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   800
				switch (adapter->hw.mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   801
				case e1000_82573:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   802
					/* ERT enabled in e1000_configure_rx */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   803
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   804
				default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   805
					pba = min_rx_space;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   806
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   807
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   808
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   809
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   810
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   811
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   812
	E1000_WRITE_REG(&adapter->hw, PBA, pba);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   813
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   814
	/* flow control settings */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   815
	/* Set the FC high water mark to 90% of the FIFO size.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   816
	 * Required to clear last 3 LSB */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   817
	fc_high_water_mark = ((pba * 9216)/10) & 0xFFF8;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   818
	/* We can't use 90% on small FIFOs because the remainder
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   819
	 * would be less than 1 full frame.  In this case, we size
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   820
	 * it to allow at least a full frame above the high water
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   821
	 *  mark. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   822
	if (pba < E1000_PBA_16K)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   823
		fc_high_water_mark = (pba * 1024) - 1600;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   824
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   825
	adapter->hw.fc_high_water = fc_high_water_mark;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   826
	adapter->hw.fc_low_water = fc_high_water_mark - 8;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   827
	if (adapter->hw.mac_type == e1000_80003es2lan)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   828
		adapter->hw.fc_pause_time = 0xFFFF;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   829
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   830
		adapter->hw.fc_pause_time = E1000_FC_PAUSE_TIME;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   831
	adapter->hw.fc_send_xon = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   832
	adapter->hw.fc = adapter->hw.original_fc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   833
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   834
	/* Allow time for pending master requests to run */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   835
	e1000_reset_hw(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   836
	if (adapter->hw.mac_type >= e1000_82544)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   837
		E1000_WRITE_REG(&adapter->hw, WUC, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   838
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   839
	if (e1000_init_hw(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   840
		DPRINTK(PROBE, ERR, "Hardware Error\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   841
	e1000_update_mng_vlan(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   842
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   843
	/* if (adapter->hwflags & HWFLAGS_PHY_PWR_BIT) { */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   844
	if (adapter->hw.mac_type >= e1000_82544 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   845
	    adapter->hw.mac_type <= e1000_82547_rev_2 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   846
	    adapter->hw.autoneg == 1 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   847
	    adapter->hw.autoneg_advertised == ADVERTISE_1000_FULL) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   848
		u32 ctrl = E1000_READ_REG(&adapter->hw, CTRL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   849
		/* clear phy power management bit if we are in gig only mode,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   850
		 * which if enabled will attempt negotiation to 100Mb, which
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   851
		 * can cause a loss of link at power off or driver unload */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   852
		ctrl &= ~E1000_CTRL_SWDPIN3;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   853
		E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   854
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   855
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   856
	/* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   857
	E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   858
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   859
	e1000_reset_adaptive(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   860
	e1000_phy_get_info(&adapter->hw, &adapter->phy_info);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   861
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   862
	if (!adapter->smart_power_down &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   863
	    (adapter->hw.mac_type == e1000_82571 ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   864
	     adapter->hw.mac_type == e1000_82572)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   865
		u16 phy_data = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   866
		/* speed up time to link by disabling smart power down, ignore
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   867
		 * the return value of this function because there is nothing
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   868
		 * different we would do if it failed */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   869
		e1000_read_phy_reg(&adapter->hw, IGP02E1000_PHY_POWER_MGMT,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   870
		                   &phy_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   871
		phy_data &= ~IGP02E1000_PM_SPD;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   872
		e1000_write_phy_reg(&adapter->hw, IGP02E1000_PHY_POWER_MGMT,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   873
		                    phy_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   874
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   875
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   876
	e1000_release_manageability(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   877
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   878
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   879
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   880
 *  Dump the eeprom for users having checksum issues
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   881
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   882
static void e1000_dump_eeprom(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   883
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   884
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   885
	struct ethtool_eeprom eeprom;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   886
	const struct ethtool_ops *ops = netdev->ethtool_ops;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   887
	u8 *data;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   888
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   889
	u16 csum_old, csum_new = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   890
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   891
	eeprom.len = ops->get_eeprom_len(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   892
	eeprom.offset = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   893
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   894
	data = kmalloc(eeprom.len, GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   895
	if (!data) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   896
		printk(KERN_ERR "Unable to allocate memory to dump EEPROM"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   897
		       " data\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   898
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   899
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   900
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   901
	ops->get_eeprom(netdev, &eeprom, data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   902
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   903
	csum_old = (data[EEPROM_CHECKSUM_REG * 2]) +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   904
		   (data[EEPROM_CHECKSUM_REG * 2 + 1] << 8);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   905
	for (i = 0; i < EEPROM_CHECKSUM_REG * 2; i += 2)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   906
		csum_new += data[i] + (data[i + 1] << 8);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   907
	csum_new = EEPROM_SUM - csum_new;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   908
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   909
	printk(KERN_ERR "/*********************/\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   910
	printk(KERN_ERR "Current EEPROM Checksum : 0x%04x\n", csum_old);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   911
	printk(KERN_ERR "Calculated              : 0x%04x\n", csum_new);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   912
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   913
	printk(KERN_ERR "Offset    Values\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   914
	printk(KERN_ERR "========  ======\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   915
	print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1, data, 128, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   916
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   917
	printk(KERN_ERR "Include this output when contacting your support "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   918
	       "provider.\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   919
	printk(KERN_ERR "This is not a software error! Something bad "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   920
	       "happened to your hardware or\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   921
	printk(KERN_ERR "EEPROM image. Ignoring this "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   922
	       "problem could result in further problems,\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   923
	printk(KERN_ERR "possibly loss of data, corruption or system hangs!\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   924
	printk(KERN_ERR "The MAC Address will be reset to 00:00:00:00:00:00, "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   925
	       "which is invalid\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   926
	printk(KERN_ERR "and requires you to set the proper MAC "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   927
	       "address manually before continuing\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   928
	printk(KERN_ERR "to enable this network device.\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   929
	printk(KERN_ERR "Please inspect the EEPROM dump and report the issue "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   930
	       "to your hardware vendor\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   931
	printk(KERN_ERR "or Intel Customer Support: linux-nics@intel.com\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   932
	printk(KERN_ERR "/*********************/\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   933
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   934
	kfree(data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   935
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   936
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   937
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   938
 * e1000_probe - Device Initialization Routine
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   939
 * @pdev: PCI device information struct
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   940
 * @ent: entry in e1000_pci_tbl
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   941
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   942
 * Returns 0 on success, negative on failure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   943
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   944
 * e1000_probe initializes an adapter identified by a pci_dev structure.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   945
 * The OS initialization, configuring of the adapter private structure,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   946
 * and a hardware reset occur.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   947
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   948
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   949
static int __devinit
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   950
e1000_probe(struct pci_dev *pdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   951
            const struct pci_device_id *ent)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   952
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   953
	struct net_device *netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   954
	struct e1000_adapter *adapter;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   955
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   956
	static int cards_found = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   957
	static int global_quad_port_a = 0; /* global ksp3 port a indication */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   958
	int i, err, pci_using_dac;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   959
	u16 eeprom_data = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   960
	u16 eeprom_apme_mask = E1000_EEPROM_APME;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   961
	DECLARE_MAC_BUF(mac);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   962
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   963
	if ((err = pci_enable_device(pdev)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   964
		return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   965
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   966
	if (!(err = pci_set_dma_mask(pdev, DMA_64BIT_MASK)) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   967
	    !(err = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   968
		pci_using_dac = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   969
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   970
		if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   971
		    (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   972
			E1000_ERR("No usable DMA configuration, aborting\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   973
			goto err_dma;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   974
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   975
		pci_using_dac = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   976
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   977
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   978
	if ((err = pci_request_regions(pdev, e1000_driver_name)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   979
		goto err_pci_reg;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   980
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   981
	pci_set_master(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   982
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   983
	err = -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   984
	netdev = alloc_etherdev(sizeof(struct e1000_adapter));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   985
	if (!netdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   986
		goto err_alloc_etherdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   987
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   988
	SET_NETDEV_DEV(netdev, &pdev->dev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   989
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   990
	pci_set_drvdata(pdev, netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   991
	adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   992
	adapter->netdev = netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   993
	adapter->pdev = pdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   994
	adapter->hw.back = adapter;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   995
	adapter->msg_enable = (1 << debug) - 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   996
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   997
	err = -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   998
	adapter->hw.hw_addr = ioremap(pci_resource_start(pdev, BAR_0),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   999
				      pci_resource_len(pdev, BAR_0));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1000
	if (!adapter->hw.hw_addr)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1001
		goto err_ioremap;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1002
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1003
	for (i = BAR_1; i <= BAR_5; i++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1004
		if (pci_resource_len(pdev, i) == 0)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1005
			continue;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1006
		if (pci_resource_flags(pdev, i) & IORESOURCE_IO) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1007
			adapter->hw.io_base = pci_resource_start(pdev, i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1008
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1009
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1010
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1011
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1012
	netdev->open = &e1000_open;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1013
	netdev->stop = &e1000_close;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1014
	netdev->hard_start_xmit = &e1000_xmit_frame;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1015
	netdev->get_stats = &e1000_get_stats;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1016
	netdev->set_rx_mode = &e1000_set_rx_mode;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1017
	netdev->set_mac_address = &e1000_set_mac;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1018
	netdev->change_mtu = &e1000_change_mtu;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1019
	netdev->do_ioctl = &e1000_ioctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1020
	e1000_set_ethtool_ops(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1021
	netdev->tx_timeout = &e1000_tx_timeout;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1022
	netdev->watchdog_timeo = 5 * HZ;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1023
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1024
	netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1025
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1026
	netdev->vlan_rx_register = e1000_vlan_rx_register;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1027
	netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1028
	netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1029
#ifdef CONFIG_NET_POLL_CONTROLLER
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1030
	netdev->poll_controller = e1000_netpoll;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1031
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1032
	strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1033
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1034
	adapter->bd_number = cards_found;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1035
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1036
	/* setup the private structure */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1037
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1038
	if ((err = e1000_sw_init(adapter)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1039
		goto err_sw_init;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1040
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1041
	err = -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1042
	/* Flash BAR mapping must happen after e1000_sw_init
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1043
	 * because it depends on mac_type */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1044
	if ((adapter->hw.mac_type == e1000_ich8lan) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1045
	   (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1046
		adapter->hw.flash_address =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1047
			ioremap(pci_resource_start(pdev, 1),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1048
				pci_resource_len(pdev, 1));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1049
		if (!adapter->hw.flash_address)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1050
			goto err_flashmap;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1051
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1052
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1053
	if (e1000_check_phy_reset_block(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1054
		DPRINTK(PROBE, INFO, "PHY reset is blocked due to SOL/IDER session.\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1055
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1056
	if (adapter->hw.mac_type >= e1000_82543) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1057
		netdev->features = NETIF_F_SG |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1058
				   NETIF_F_HW_CSUM |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1059
				   NETIF_F_HW_VLAN_TX |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1060
				   NETIF_F_HW_VLAN_RX |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1061
				   NETIF_F_HW_VLAN_FILTER;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1062
		if (adapter->hw.mac_type == e1000_ich8lan)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1063
			netdev->features &= ~NETIF_F_HW_VLAN_FILTER;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1064
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1065
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1066
	if ((adapter->hw.mac_type >= e1000_82544) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1067
	   (adapter->hw.mac_type != e1000_82547))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1068
		netdev->features |= NETIF_F_TSO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1069
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1070
	if (adapter->hw.mac_type > e1000_82547_rev_2)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1071
		netdev->features |= NETIF_F_TSO6;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1072
	if (pci_using_dac)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1073
		netdev->features |= NETIF_F_HIGHDMA;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1074
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1075
	netdev->features |= NETIF_F_LLTX;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1076
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1077
	adapter->en_mng_pt = e1000_enable_mng_pass_thru(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1078
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1079
	/* initialize eeprom parameters */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1080
	if (e1000_init_eeprom_params(&adapter->hw)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1081
		E1000_ERR("EEPROM initialization failed\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1082
		goto err_eeprom;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1083
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1084
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1085
	/* before reading the EEPROM, reset the controller to
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1086
	 * put the device in a known good starting state */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1087
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1088
	e1000_reset_hw(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1089
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1090
	/* make sure the EEPROM is good */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1091
	if (e1000_validate_eeprom_checksum(&adapter->hw) < 0) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1092
		DPRINTK(PROBE, ERR, "The EEPROM Checksum Is Not Valid\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1093
		e1000_dump_eeprom(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1094
		/*
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1095
		 * set MAC address to all zeroes to invalidate and temporary
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1096
		 * disable this device for the user. This blocks regular
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1097
		 * traffic while still permitting ethtool ioctls from reaching
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1098
		 * the hardware as well as allowing the user to run the
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1099
		 * interface after manually setting a hw addr using
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1100
		 * `ip set address`
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1101
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1102
		memset(adapter->hw.mac_addr, 0, netdev->addr_len);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1103
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1104
		/* copy the MAC address out of the EEPROM */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1105
		if (e1000_read_mac_addr(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1106
			DPRINTK(PROBE, ERR, "EEPROM Read Error\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1107
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1108
	/* don't block initalization here due to bad MAC address */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1109
	memcpy(netdev->dev_addr, adapter->hw.mac_addr, netdev->addr_len);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1110
	memcpy(netdev->perm_addr, adapter->hw.mac_addr, netdev->addr_len);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1111
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1112
	if (!is_valid_ether_addr(netdev->perm_addr))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1113
		DPRINTK(PROBE, ERR, "Invalid MAC Address\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1114
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1115
	e1000_get_bus_info(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1116
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1117
	init_timer(&adapter->tx_fifo_stall_timer);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1118
	adapter->tx_fifo_stall_timer.function = &e1000_82547_tx_fifo_stall;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1119
	adapter->tx_fifo_stall_timer.data = (unsigned long) adapter;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1120
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1121
	init_timer(&adapter->watchdog_timer);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1122
	adapter->watchdog_timer.function = &e1000_watchdog;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1123
	adapter->watchdog_timer.data = (unsigned long) adapter;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1124
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1125
	init_timer(&adapter->phy_info_timer);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1126
	adapter->phy_info_timer.function = &e1000_update_phy_info;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1127
	adapter->phy_info_timer.data = (unsigned long) adapter;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1128
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1129
	INIT_WORK(&adapter->reset_task, e1000_reset_task);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1130
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1131
	e1000_check_options(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1132
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1133
	/* Initial Wake on LAN setting
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1134
	 * If APM wake is enabled in the EEPROM,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1135
	 * enable the ACPI Magic Packet filter
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1136
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1137
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1138
	switch (adapter->hw.mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1139
	case e1000_82542_rev2_0:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1140
	case e1000_82542_rev2_1:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1141
	case e1000_82543:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1142
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1143
	case e1000_82544:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1144
		e1000_read_eeprom(&adapter->hw,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1145
			EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1146
		eeprom_apme_mask = E1000_EEPROM_82544_APM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1147
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1148
	case e1000_ich8lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1149
		e1000_read_eeprom(&adapter->hw,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1150
			EEPROM_INIT_CONTROL1_REG, 1, &eeprom_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1151
		eeprom_apme_mask = E1000_EEPROM_ICH8_APME;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1152
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1153
	case e1000_82546:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1154
	case e1000_82546_rev_3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1155
	case e1000_82571:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1156
	case e1000_80003es2lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1157
		if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1){
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1158
			e1000_read_eeprom(&adapter->hw,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1159
				EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1160
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1161
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1162
		/* Fall Through */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1163
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1164
		e1000_read_eeprom(&adapter->hw,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1165
			EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1166
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1167
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1168
	if (eeprom_data & eeprom_apme_mask)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1169
		adapter->eeprom_wol |= E1000_WUFC_MAG;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1170
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1171
	/* now that we have the eeprom settings, apply the special cases
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1172
	 * where the eeprom may be wrong or the board simply won't support
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1173
	 * wake on lan on a particular port */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1174
	switch (pdev->device) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1175
	case E1000_DEV_ID_82546GB_PCIE:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1176
		adapter->eeprom_wol = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1177
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1178
	case E1000_DEV_ID_82546EB_FIBER:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1179
	case E1000_DEV_ID_82546GB_FIBER:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1180
	case E1000_DEV_ID_82571EB_FIBER:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1181
		/* Wake events only supported on port A for dual fiber
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1182
		 * regardless of eeprom setting */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1183
		if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1184
			adapter->eeprom_wol = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1185
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1186
	case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1187
	case E1000_DEV_ID_82571EB_QUAD_COPPER:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1188
	case E1000_DEV_ID_82571EB_QUAD_FIBER:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1189
	case E1000_DEV_ID_82571EB_QUAD_COPPER_LOWPROFILE:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1190
	case E1000_DEV_ID_82571PT_QUAD_COPPER:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1191
		/* if quad port adapter, disable WoL on all but port A */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1192
		if (global_quad_port_a != 0)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1193
			adapter->eeprom_wol = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1194
		else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1195
			adapter->quad_port_a = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1196
		/* Reset for multiple quad port adapters */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1197
		if (++global_quad_port_a == 4)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1198
			global_quad_port_a = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1199
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1200
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1201
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1202
	/* initialize the wol settings based on the eeprom settings */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1203
	adapter->wol = adapter->eeprom_wol;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1204
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1205
	/* print bus type/speed/width info */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1206
	{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1207
	struct e1000_hw *hw = &adapter->hw;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1208
	DPRINTK(PROBE, INFO, "(PCI%s:%s:%s) ",
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1209
		((hw->bus_type == e1000_bus_type_pcix) ? "-X" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1210
		 (hw->bus_type == e1000_bus_type_pci_express ? " Express":"")),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1211
		((hw->bus_speed == e1000_bus_speed_2500) ? "2.5Gb/s" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1212
		 (hw->bus_speed == e1000_bus_speed_133) ? "133MHz" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1213
		 (hw->bus_speed == e1000_bus_speed_120) ? "120MHz" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1214
		 (hw->bus_speed == e1000_bus_speed_100) ? "100MHz" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1215
		 (hw->bus_speed == e1000_bus_speed_66) ? "66MHz" : "33MHz"),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1216
		((hw->bus_width == e1000_bus_width_64) ? "64-bit" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1217
		 (hw->bus_width == e1000_bus_width_pciex_4) ? "Width x4" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1218
		 (hw->bus_width == e1000_bus_width_pciex_1) ? "Width x1" :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1219
		 "32-bit"));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1220
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1221
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1222
	printk("%s\n", print_mac(mac, netdev->dev_addr));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1223
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1224
	if (adapter->hw.bus_type == e1000_bus_type_pci_express) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1225
		DPRINTK(PROBE, WARNING, "This device (id %04x:%04x) will no "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1226
			"longer be supported by this driver in the future.\n",
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1227
			pdev->vendor, pdev->device);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1228
		DPRINTK(PROBE, WARNING, "please use the \"e1000e\" "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1229
			"driver instead.\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1230
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1231
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1232
	/* reset the hardware with the new settings */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1233
	e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1234
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1235
	/* If the controller is 82573 and f/w is AMT, do not set
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1236
	 * DRV_LOAD until the interface is up.  For all other cases,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1237
	 * let the f/w know that the h/w is now under the control
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1238
	 * of the driver. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1239
	if (adapter->hw.mac_type != e1000_82573 ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1240
	    !e1000_check_mng_mode(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1241
		e1000_get_hw_control(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1242
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1243
	// offer device to EtherCAT master module
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1244
	adapter->ecdev = ecdev_offer(netdev, ec_poll, THIS_MODULE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1245
	if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1246
		if (ecdev_open(adapter->ecdev)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1247
			ecdev_withdraw(adapter->ecdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1248
			goto err_register;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1249
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1250
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1251
		/* tell the stack to leave us alone until e1000_open() is called */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1252
		netif_carrier_off(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1253
		netif_stop_queue(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1254
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1255
		strcpy(netdev->name, "eth%d");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1256
		if ((err = register_netdev(netdev)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1257
			goto err_register;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1258
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1259
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1260
	DPRINTK(PROBE, INFO, "Intel(R) PRO/1000 Network Connection\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1261
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1262
	cards_found++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1263
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1264
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1265
err_register:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1266
	e1000_release_hw_control(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1267
err_eeprom:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1268
	if (!e1000_check_phy_reset_block(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1269
		e1000_phy_hw_reset(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1270
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1271
	if (adapter->hw.flash_address)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1272
		iounmap(adapter->hw.flash_address);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1273
err_flashmap:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1274
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1275
	for (i = 0; i < adapter->num_rx_queues; i++)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1276
		dev_put(&adapter->polling_netdev[i]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1277
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1278
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1279
	kfree(adapter->tx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1280
	kfree(adapter->rx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1281
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1282
	kfree(adapter->polling_netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1283
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1284
err_sw_init:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1285
	iounmap(adapter->hw.hw_addr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1286
err_ioremap:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1287
	free_netdev(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1288
err_alloc_etherdev:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1289
	pci_release_regions(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1290
err_pci_reg:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1291
err_dma:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1292
	pci_disable_device(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1293
	return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1294
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1295
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1296
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1297
 * e1000_remove - Device Removal Routine
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1298
 * @pdev: PCI device information struct
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1299
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1300
 * e1000_remove is called by the PCI subsystem to alert the driver
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1301
 * that it should release a PCI device.  The could be caused by a
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1302
 * Hot-Plug event, or because the driver is going to be removed from
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1303
 * memory.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1304
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1305
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1306
static void __devexit
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1307
e1000_remove(struct pci_dev *pdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1308
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1309
	struct net_device *netdev = pci_get_drvdata(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1310
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1311
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1312
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1313
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1314
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1315
	cancel_work_sync(&adapter->reset_task);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1316
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1317
	e1000_release_manageability(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1318
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1319
	/* Release control of h/w to f/w.  If f/w is AMT enabled, this
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1320
	 * would have already happened in close and is redundant. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1321
	e1000_release_hw_control(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1322
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1323
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1324
	for (i = 0; i < adapter->num_rx_queues; i++)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1325
		dev_put(&adapter->polling_netdev[i]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1326
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1327
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1328
	if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1329
		ecdev_close(adapter->ecdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1330
		ecdev_withdraw(adapter->ecdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1331
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1332
		unregister_netdev(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1333
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1334
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1335
	if (!e1000_check_phy_reset_block(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1336
		e1000_phy_hw_reset(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1337
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1338
	kfree(adapter->tx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1339
	kfree(adapter->rx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1340
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1341
	kfree(adapter->polling_netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1342
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1343
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1344
	iounmap(adapter->hw.hw_addr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1345
	if (adapter->hw.flash_address)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1346
		iounmap(adapter->hw.flash_address);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1347
	pci_release_regions(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1348
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1349
	free_netdev(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1350
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1351
	pci_disable_device(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1352
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1353
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1354
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1355
 * e1000_sw_init - Initialize general software structures (struct e1000_adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1356
 * @adapter: board private structure to initialize
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1357
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1358
 * e1000_sw_init initializes the Adapter private data structure.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1359
 * Fields are initialized based on PCI device information and
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1360
 * OS network device settings (MTU size).
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1361
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1362
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1363
static int __devinit
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1364
e1000_sw_init(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1365
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1366
	struct e1000_hw *hw = &adapter->hw;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1367
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1368
	struct pci_dev *pdev = adapter->pdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1369
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1370
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1371
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1372
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1373
	/* PCI config space info */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1374
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1375
	hw->vendor_id = pdev->vendor;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1376
	hw->device_id = pdev->device;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1377
	hw->subsystem_vendor_id = pdev->subsystem_vendor;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1378
	hw->subsystem_id = pdev->subsystem_device;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1379
	hw->revision_id = pdev->revision;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1380
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1381
	pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1382
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1383
	adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1384
	adapter->rx_ps_bsize0 = E1000_RXBUFFER_128;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1385
	hw->max_frame_size = netdev->mtu +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1386
			     ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1387
	hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1388
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1389
	/* identify the MAC */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1390
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1391
	if (e1000_set_mac_type(hw)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1392
		DPRINTK(PROBE, ERR, "Unknown MAC Type\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1393
		return -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1394
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1395
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1396
	switch (hw->mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1397
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1398
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1399
	case e1000_82541:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1400
	case e1000_82547:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1401
	case e1000_82541_rev_2:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1402
	case e1000_82547_rev_2:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1403
		hw->phy_init_script = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1404
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1405
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1406
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1407
	e1000_set_media_type(hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1408
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1409
	hw->wait_autoneg_complete = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1410
	hw->tbi_compatibility_en = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1411
	hw->adaptive_ifs = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1412
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1413
	/* Copper options */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1414
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1415
	if (hw->media_type == e1000_media_type_copper) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1416
		hw->mdix = AUTO_ALL_MODES;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1417
		hw->disable_polarity_correction = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1418
		hw->master_slave = E1000_MASTER_SLAVE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1419
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1420
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1421
	adapter->num_tx_queues = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1422
	adapter->num_rx_queues = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1423
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1424
	if (e1000_alloc_queues(adapter)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1425
		DPRINTK(PROBE, ERR, "Unable to allocate memory for queues\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1426
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1427
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1428
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1429
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1430
	for (i = 0; i < adapter->num_rx_queues; i++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1431
		adapter->polling_netdev[i].priv = adapter;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1432
		dev_hold(&adapter->polling_netdev[i]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1433
		set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1434
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1435
	spin_lock_init(&adapter->tx_queue_lock);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1436
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1437
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1438
	/* Explicitly disable IRQ since the NIC can be in any state. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1439
	e1000_irq_disable(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1440
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1441
	spin_lock_init(&adapter->stats_lock);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1442
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1443
	set_bit(__E1000_DOWN, &adapter->flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1444
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1445
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1446
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1447
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1448
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1449
 * e1000_alloc_queues - Allocate memory for all rings
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1450
 * @adapter: board private structure to initialize
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1451
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1452
 * We allocate one ring per queue at run-time since we don't know the
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1453
 * number of queues at compile-time.  The polling_netdev array is
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1454
 * intended for Multiqueue, but should work fine with a single queue.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1455
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1456
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1457
static int __devinit
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1458
e1000_alloc_queues(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1459
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1460
	adapter->tx_ring = kcalloc(adapter->num_tx_queues,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1461
	                           sizeof(struct e1000_tx_ring), GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1462
	if (!adapter->tx_ring)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1463
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1464
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1465
	adapter->rx_ring = kcalloc(adapter->num_rx_queues,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1466
	                           sizeof(struct e1000_rx_ring), GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1467
	if (!adapter->rx_ring) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1468
		kfree(adapter->tx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1469
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1470
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1471
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1472
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1473
	adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1474
	                                  sizeof(struct net_device),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1475
	                                  GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1476
	if (!adapter->polling_netdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1477
		kfree(adapter->tx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1478
		kfree(adapter->rx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1479
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1480
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1481
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1482
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1483
	return E1000_SUCCESS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1484
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1485
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1486
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1487
 * e1000_open - Called when a network interface is made active
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1488
 * @netdev: network interface device structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1489
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1490
 * Returns 0 on success, negative value on failure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1491
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1492
 * The open entry point is called when a network interface is made
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1493
 * active by the system (IFF_UP).  At this point all resources needed
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1494
 * for transmit and receive operations are allocated, the interrupt
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1495
 * handler is registered with the OS, the watchdog timer is started,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1496
 * and the stack is notified that the interface is ready.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1497
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1498
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1499
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1500
e1000_open(struct net_device *netdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1501
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1502
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1503
	int err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1504
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1505
	/* disallow open during test */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1506
	if (test_bit(__E1000_TESTING, &adapter->flags))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1507
		return -EBUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1508
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1509
	/* allocate transmit descriptors */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1510
	err = e1000_setup_all_tx_resources(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1511
	if (err)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1512
		goto err_setup_tx;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1513
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1514
	/* allocate receive descriptors */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1515
	err = e1000_setup_all_rx_resources(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1516
	if (err)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1517
		goto err_setup_rx;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1518
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1519
	e1000_power_up_phy(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1520
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1521
	adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1522
	if ((adapter->hw.mng_cookie.status &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1523
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1524
		e1000_update_mng_vlan(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1525
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1526
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1527
	/* If AMT is enabled, let the firmware know that the network
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1528
	 * interface is now open */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1529
	if (adapter->hw.mac_type == e1000_82573 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1530
	    e1000_check_mng_mode(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1531
		e1000_get_hw_control(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1532
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1533
	/* before we allocate an interrupt, we must be ready to handle it.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1534
	 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1535
	 * as soon as we call pci_request_irq, so we have to setup our
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1536
	 * clean_rx handler before we do so.  */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1537
	e1000_configure(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1538
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1539
	err = e1000_request_irq(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1540
	if (err)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1541
		goto err_req_irq;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1542
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1543
	/* From here on the code is the same as e1000_up() */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1544
	clear_bit(__E1000_DOWN, &adapter->flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1545
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1546
#ifdef CONFIG_E1000_NAPI
2469
634ba3b1eb95 Fixed possible segfault in e1000_open() function.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
  1547
	if (!adapter->ecdev) {
634ba3b1eb95 Fixed possible segfault in e1000_open() function.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
  1548
		napi_enable(&adapter->napi);
634ba3b1eb95 Fixed possible segfault in e1000_open() function.
Florian Pose <fp@igh-essen.com>
parents: 2421
diff changeset
  1549
	}
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1550
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1551
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1552
	e1000_irq_enable(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1553
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1554
	/* fire a link status change interrupt to start the watchdog */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1555
	E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_LSC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1556
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1557
	return E1000_SUCCESS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1558
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1559
err_req_irq:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1560
	e1000_release_hw_control(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1561
	e1000_power_down_phy(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1562
	e1000_free_all_rx_resources(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1563
err_setup_rx:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1564
	e1000_free_all_tx_resources(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1565
err_setup_tx:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1566
	e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1567
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1568
	return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1569
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1570
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1571
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1572
 * e1000_close - Disables a network interface
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1573
 * @netdev: network interface device structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1574
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1575
 * Returns 0, this is not allowed to fail
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1576
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1577
 * The close entry point is called when an interface is de-activated
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1578
 * by the OS.  The hardware is still under the drivers control, but
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1579
 * needs to be disabled.  A global MAC reset is issued to stop the
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1580
 * hardware, and all transmit and receive resources are freed.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1581
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1582
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1583
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1584
e1000_close(struct net_device *netdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1585
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1586
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1587
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1588
	WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1589
	e1000_down(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1590
	e1000_power_down_phy(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1591
	e1000_free_irq(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1592
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1593
	e1000_free_all_tx_resources(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1594
	e1000_free_all_rx_resources(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1595
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1596
	/* kill manageability vlan ID if supported, but not if a vlan with
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1597
	 * the same ID is registered on the host OS (let 8021q kill it) */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1598
	if ((adapter->hw.mng_cookie.status &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1599
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1600
	     !(adapter->vlgrp &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1601
	       vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1602
		e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1603
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1604
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1605
	/* If AMT is enabled, let the firmware know that the network
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1606
	 * interface is now closed */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1607
	if (adapter->hw.mac_type == e1000_82573 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1608
	    e1000_check_mng_mode(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1609
		e1000_release_hw_control(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1610
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1611
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1612
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1613
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1614
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1615
 * e1000_check_64k_bound - check that memory doesn't cross 64kB boundary
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1616
 * @adapter: address of board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1617
 * @start: address of beginning of memory
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1618
 * @len: length of memory
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1619
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1620
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1621
e1000_check_64k_bound(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1622
		      void *start, unsigned long len)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1623
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1624
	unsigned long begin = (unsigned long) start;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1625
	unsigned long end = begin + len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1626
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1627
	/* First rev 82545 and 82546 need to not allow any memory
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1628
	 * write location to cross 64k boundary due to errata 23 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1629
	if (adapter->hw.mac_type == e1000_82545 ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1630
	    adapter->hw.mac_type == e1000_82546) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1631
		return ((begin ^ (end - 1)) >> 16) != 0 ? false : true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1632
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1633
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1634
	return true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1635
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1636
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1637
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1638
 * e1000_setup_tx_resources - allocate Tx resources (Descriptors)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1639
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1640
 * @txdr:    tx descriptor ring (for a specific queue) to setup
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1641
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1642
 * Return 0 on success, negative on failure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1643
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1644
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1645
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1646
e1000_setup_tx_resources(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1647
                         struct e1000_tx_ring *txdr)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1648
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1649
	struct pci_dev *pdev = adapter->pdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1650
	int size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1651
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1652
	size = sizeof(struct e1000_buffer) * txdr->count;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1653
	txdr->buffer_info = vmalloc(size);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1654
	if (!txdr->buffer_info) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1655
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1656
		"Unable to allocate memory for the transmit descriptor ring\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1657
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1658
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1659
	memset(txdr->buffer_info, 0, size);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1660
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1661
	/* round up to nearest 4K */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1662
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1663
	txdr->size = txdr->count * sizeof(struct e1000_tx_desc);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1664
	txdr->size = ALIGN(txdr->size, 4096);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1665
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1666
	txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1667
	if (!txdr->desc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1668
setup_tx_desc_die:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1669
		vfree(txdr->buffer_info);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1670
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1671
		"Unable to allocate memory for the transmit descriptor ring\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1672
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1673
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1674
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1675
	/* Fix for errata 23, can't cross 64kB boundary */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1676
	if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1677
		void *olddesc = txdr->desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1678
		dma_addr_t olddma = txdr->dma;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1679
		DPRINTK(TX_ERR, ERR, "txdr align check failed: %u bytes "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1680
				     "at %p\n", txdr->size, txdr->desc);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1681
		/* Try again, without freeing the previous */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1682
		txdr->desc = pci_alloc_consistent(pdev, txdr->size, &txdr->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1683
		/* Failed allocation, critical failure */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1684
		if (!txdr->desc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1685
			pci_free_consistent(pdev, txdr->size, olddesc, olddma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1686
			goto setup_tx_desc_die;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1687
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1688
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1689
		if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1690
			/* give up */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1691
			pci_free_consistent(pdev, txdr->size, txdr->desc,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1692
					    txdr->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1693
			pci_free_consistent(pdev, txdr->size, olddesc, olddma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1694
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1695
				"Unable to allocate aligned memory "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1696
				"for the transmit descriptor ring\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1697
			vfree(txdr->buffer_info);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1698
			return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1699
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1700
			/* Free old allocation, new allocation was successful */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1701
			pci_free_consistent(pdev, txdr->size, olddesc, olddma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1702
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1703
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1704
	memset(txdr->desc, 0, txdr->size);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1705
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1706
	txdr->next_to_use = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1707
	txdr->next_to_clean = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1708
	spin_lock_init(&txdr->tx_lock);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1709
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1710
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1711
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1712
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1713
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1714
 * e1000_setup_all_tx_resources - wrapper to allocate Tx resources
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1715
 * 				  (Descriptors) for all queues
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1716
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1717
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1718
 * Return 0 on success, negative on failure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1719
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1720
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1721
int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1722
e1000_setup_all_tx_resources(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1723
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1724
	int i, err = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1725
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1726
	for (i = 0; i < adapter->num_tx_queues; i++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1727
		err = e1000_setup_tx_resources(adapter, &adapter->tx_ring[i]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1728
		if (err) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1729
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1730
				"Allocation for Tx Queue %u failed\n", i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1731
			for (i-- ; i >= 0; i--)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1732
				e1000_free_tx_resources(adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1733
							&adapter->tx_ring[i]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1734
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1735
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1736
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1737
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1738
	return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1739
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1740
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1741
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1742
 * e1000_configure_tx - Configure 8254x Transmit Unit after Reset
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1743
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1744
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1745
 * Configure the Tx unit of the MAC after a reset.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1746
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1747
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1748
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1749
e1000_configure_tx(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1750
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1751
	u64 tdba;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1752
	struct e1000_hw *hw = &adapter->hw;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1753
	u32 tdlen, tctl, tipg, tarc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1754
	u32 ipgr1, ipgr2;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1755
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1756
	/* Setup the HW Tx Head and Tail descriptor pointers */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1757
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1758
	switch (adapter->num_tx_queues) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1759
	case 1:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1760
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1761
		tdba = adapter->tx_ring[0].dma;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1762
		tdlen = adapter->tx_ring[0].count *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1763
			sizeof(struct e1000_tx_desc);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1764
		E1000_WRITE_REG(hw, TDLEN, tdlen);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1765
		E1000_WRITE_REG(hw, TDBAH, (tdba >> 32));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1766
		E1000_WRITE_REG(hw, TDBAL, (tdba & 0x00000000ffffffffULL));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1767
		E1000_WRITE_REG(hw, TDT, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1768
		E1000_WRITE_REG(hw, TDH, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1769
		adapter->tx_ring[0].tdh = ((hw->mac_type >= e1000_82543) ? E1000_TDH : E1000_82542_TDH);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1770
		adapter->tx_ring[0].tdt = ((hw->mac_type >= e1000_82543) ? E1000_TDT : E1000_82542_TDT);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1771
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1772
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1773
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1774
	/* Set the default values for the Tx Inter Packet Gap timer */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1775
	if (adapter->hw.mac_type <= e1000_82547_rev_2 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1776
	    (hw->media_type == e1000_media_type_fiber ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1777
	     hw->media_type == e1000_media_type_internal_serdes))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1778
		tipg = DEFAULT_82543_TIPG_IPGT_FIBER;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1779
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1780
		tipg = DEFAULT_82543_TIPG_IPGT_COPPER;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1781
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1782
	switch (hw->mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1783
	case e1000_82542_rev2_0:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1784
	case e1000_82542_rev2_1:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1785
		tipg = DEFAULT_82542_TIPG_IPGT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1786
		ipgr1 = DEFAULT_82542_TIPG_IPGR1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1787
		ipgr2 = DEFAULT_82542_TIPG_IPGR2;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1788
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1789
	case e1000_80003es2lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1790
		ipgr1 = DEFAULT_82543_TIPG_IPGR1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1791
		ipgr2 = DEFAULT_80003ES2LAN_TIPG_IPGR2;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1792
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1793
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1794
		ipgr1 = DEFAULT_82543_TIPG_IPGR1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1795
		ipgr2 = DEFAULT_82543_TIPG_IPGR2;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1796
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1797
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1798
	tipg |= ipgr1 << E1000_TIPG_IPGR1_SHIFT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1799
	tipg |= ipgr2 << E1000_TIPG_IPGR2_SHIFT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1800
	E1000_WRITE_REG(hw, TIPG, tipg);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1801
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1802
	/* Set the Tx Interrupt Delay register */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1803
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1804
	E1000_WRITE_REG(hw, TIDV, adapter->tx_int_delay);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1805
	if (hw->mac_type >= e1000_82540)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1806
		E1000_WRITE_REG(hw, TADV, adapter->tx_abs_int_delay);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1807
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1808
	/* Program the Transmit Control Register */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1809
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1810
	tctl = E1000_READ_REG(hw, TCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1811
	tctl &= ~E1000_TCTL_CT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1812
	tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1813
		(E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1814
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1815
	if (hw->mac_type == e1000_82571 || hw->mac_type == e1000_82572) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1816
		tarc = E1000_READ_REG(hw, TARC0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1817
		/* set the speed mode bit, we'll clear it if we're not at
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1818
		 * gigabit link later */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1819
		tarc |= (1 << 21);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1820
		E1000_WRITE_REG(hw, TARC0, tarc);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1821
	} else if (hw->mac_type == e1000_80003es2lan) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1822
		tarc = E1000_READ_REG(hw, TARC0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1823
		tarc |= 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1824
		E1000_WRITE_REG(hw, TARC0, tarc);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1825
		tarc = E1000_READ_REG(hw, TARC1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1826
		tarc |= 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1827
		E1000_WRITE_REG(hw, TARC1, tarc);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1828
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1829
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1830
	e1000_config_collision_dist(hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1831
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1832
	/* Setup Transmit Descriptor Settings for eop descriptor */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1833
	adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1834
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1835
	/* only set IDE if we are delaying interrupts using the timers */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1836
	if (adapter->tx_int_delay)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1837
		adapter->txd_cmd |= E1000_TXD_CMD_IDE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1838
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1839
	if (hw->mac_type < e1000_82543)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1840
		adapter->txd_cmd |= E1000_TXD_CMD_RPS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1841
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1842
		adapter->txd_cmd |= E1000_TXD_CMD_RS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1843
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1844
	/* Cache if we're 82544 running in PCI-X because we'll
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1845
	 * need this to apply a workaround later in the send path. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1846
	if (hw->mac_type == e1000_82544 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1847
	    hw->bus_type == e1000_bus_type_pcix)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1848
		adapter->pcix_82544 = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1849
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1850
	E1000_WRITE_REG(hw, TCTL, tctl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1851
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1852
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1853
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1854
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1855
 * e1000_setup_rx_resources - allocate Rx resources (Descriptors)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1856
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1857
 * @rxdr:    rx descriptor ring (for a specific queue) to setup
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1858
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1859
 * Returns 0 on success, negative on failure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1860
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1861
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1862
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1863
e1000_setup_rx_resources(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1864
                         struct e1000_rx_ring *rxdr)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1865
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1866
	struct pci_dev *pdev = adapter->pdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1867
	int size, desc_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1868
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1869
	size = sizeof(struct e1000_buffer) * rxdr->count;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1870
	rxdr->buffer_info = vmalloc(size);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1871
	if (!rxdr->buffer_info) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1872
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1873
		"Unable to allocate memory for the receive descriptor ring\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1874
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1875
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1876
	memset(rxdr->buffer_info, 0, size);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1877
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1878
	rxdr->ps_page = kcalloc(rxdr->count, sizeof(struct e1000_ps_page),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1879
	                        GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1880
	if (!rxdr->ps_page) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1881
		vfree(rxdr->buffer_info);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1882
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1883
		"Unable to allocate memory for the receive descriptor ring\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1884
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1885
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1886
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1887
	rxdr->ps_page_dma = kcalloc(rxdr->count,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1888
	                            sizeof(struct e1000_ps_page_dma),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1889
	                            GFP_KERNEL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1890
	if (!rxdr->ps_page_dma) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1891
		vfree(rxdr->buffer_info);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1892
		kfree(rxdr->ps_page);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1893
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1894
		"Unable to allocate memory for the receive descriptor ring\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1895
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1896
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1897
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1898
	if (adapter->hw.mac_type <= e1000_82547_rev_2)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1899
		desc_len = sizeof(struct e1000_rx_desc);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1900
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1901
		desc_len = sizeof(union e1000_rx_desc_packet_split);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1902
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1903
	/* Round up to nearest 4K */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1904
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1905
	rxdr->size = rxdr->count * desc_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1906
	rxdr->size = ALIGN(rxdr->size, 4096);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1907
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1908
	rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1909
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1910
	if (!rxdr->desc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1911
		DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1912
		"Unable to allocate memory for the receive descriptor ring\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1913
setup_rx_desc_die:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1914
		vfree(rxdr->buffer_info);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1915
		kfree(rxdr->ps_page);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1916
		kfree(rxdr->ps_page_dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1917
		return -ENOMEM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1918
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1919
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1920
	/* Fix for errata 23, can't cross 64kB boundary */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1921
	if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1922
		void *olddesc = rxdr->desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1923
		dma_addr_t olddma = rxdr->dma;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1924
		DPRINTK(RX_ERR, ERR, "rxdr align check failed: %u bytes "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1925
				     "at %p\n", rxdr->size, rxdr->desc);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1926
		/* Try again, without freeing the previous */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1927
		rxdr->desc = pci_alloc_consistent(pdev, rxdr->size, &rxdr->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1928
		/* Failed allocation, critical failure */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1929
		if (!rxdr->desc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1930
			pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1931
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1932
				"Unable to allocate memory "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1933
				"for the receive descriptor ring\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1934
			goto setup_rx_desc_die;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1935
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1936
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1937
		if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1938
			/* give up */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1939
			pci_free_consistent(pdev, rxdr->size, rxdr->desc,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1940
					    rxdr->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1941
			pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1942
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1943
				"Unable to allocate aligned memory "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1944
				"for the receive descriptor ring\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1945
			goto setup_rx_desc_die;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1946
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1947
			/* Free old allocation, new allocation was successful */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1948
			pci_free_consistent(pdev, rxdr->size, olddesc, olddma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1949
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1950
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1951
	memset(rxdr->desc, 0, rxdr->size);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1952
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1953
	rxdr->next_to_clean = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1954
	rxdr->next_to_use = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1955
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1956
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1957
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1958
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1959
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1960
 * e1000_setup_all_rx_resources - wrapper to allocate Rx resources
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1961
 * 				  (Descriptors) for all queues
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1962
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1963
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1964
 * Return 0 on success, negative on failure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1965
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1966
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1967
int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1968
e1000_setup_all_rx_resources(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1969
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1970
	int i, err = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1971
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1972
	for (i = 0; i < adapter->num_rx_queues; i++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1973
		err = e1000_setup_rx_resources(adapter, &adapter->rx_ring[i]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1974
		if (err) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1975
			DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1976
				"Allocation for Rx Queue %u failed\n", i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1977
			for (i-- ; i >= 0; i--)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1978
				e1000_free_rx_resources(adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1979
							&adapter->rx_ring[i]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1980
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1981
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1982
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1983
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1984
	return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1985
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1986
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1987
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1988
 * e1000_setup_rctl - configure the receive control registers
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1989
 * @adapter: Board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1990
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1991
#define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1992
			(((S) & (PAGE_SIZE - 1)) ? 1 : 0))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1993
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1994
e1000_setup_rctl(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1995
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1996
	u32 rctl, rfctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1997
	u32 psrctl = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1998
#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  1999
	u32 pages = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2000
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2001
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2002
	rctl = E1000_READ_REG(&adapter->hw, RCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2003
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2004
	rctl &= ~(3 << E1000_RCTL_MO_SHIFT);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2005
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2006
	rctl |= E1000_RCTL_EN | E1000_RCTL_BAM |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2007
		E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2008
		(adapter->hw.mc_filter_type << E1000_RCTL_MO_SHIFT);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2009
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2010
	if (adapter->hw.tbi_compatibility_on == 1)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2011
		rctl |= E1000_RCTL_SBP;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2012
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2013
		rctl &= ~E1000_RCTL_SBP;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2014
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2015
	if (adapter->netdev->mtu <= ETH_DATA_LEN)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2016
		rctl &= ~E1000_RCTL_LPE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2017
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2018
		rctl |= E1000_RCTL_LPE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2019
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2020
	/* Setup buffer sizes */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2021
	rctl &= ~E1000_RCTL_SZ_4096;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2022
	rctl |= E1000_RCTL_BSEX;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2023
	switch (adapter->rx_buffer_len) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2024
		case E1000_RXBUFFER_256:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2025
			rctl |= E1000_RCTL_SZ_256;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2026
			rctl &= ~E1000_RCTL_BSEX;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2027
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2028
		case E1000_RXBUFFER_512:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2029
			rctl |= E1000_RCTL_SZ_512;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2030
			rctl &= ~E1000_RCTL_BSEX;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2031
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2032
		case E1000_RXBUFFER_1024:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2033
			rctl |= E1000_RCTL_SZ_1024;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2034
			rctl &= ~E1000_RCTL_BSEX;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2035
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2036
		case E1000_RXBUFFER_2048:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2037
		default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2038
			rctl |= E1000_RCTL_SZ_2048;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2039
			rctl &= ~E1000_RCTL_BSEX;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2040
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2041
		case E1000_RXBUFFER_4096:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2042
			rctl |= E1000_RCTL_SZ_4096;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2043
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2044
		case E1000_RXBUFFER_8192:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2045
			rctl |= E1000_RCTL_SZ_8192;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2046
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2047
		case E1000_RXBUFFER_16384:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2048
			rctl |= E1000_RCTL_SZ_16384;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2049
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2050
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2051
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2052
#ifndef CONFIG_E1000_DISABLE_PACKET_SPLIT
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2053
	/* 82571 and greater support packet-split where the protocol
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2054
	 * header is placed in skb->data and the packet data is
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2055
	 * placed in pages hanging off of skb_shinfo(skb)->nr_frags.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2056
	 * In the case of a non-split, skb->data is linearly filled,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2057
	 * followed by the page buffers.  Therefore, skb->data is
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2058
	 * sized to hold the largest protocol header.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2059
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2060
	/* allocations using alloc_page take too long for regular MTU
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2061
	 * so only enable packet split for jumbo frames */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2062
	pages = PAGE_USE_COUNT(adapter->netdev->mtu);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2063
	if ((adapter->hw.mac_type >= e1000_82571) && (pages <= 3) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2064
	    PAGE_SIZE <= 16384 && (rctl & E1000_RCTL_LPE))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2065
		adapter->rx_ps_pages = pages;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2066
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2067
		adapter->rx_ps_pages = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2068
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2069
	if (adapter->rx_ps_pages) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2070
		/* Configure extra packet-split registers */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2071
		rfctl = E1000_READ_REG(&adapter->hw, RFCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2072
		rfctl |= E1000_RFCTL_EXTEN;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2073
		/* disable packet split support for IPv6 extension headers,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2074
		 * because some malformed IPv6 headers can hang the RX */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2075
		rfctl |= (E1000_RFCTL_IPV6_EX_DIS |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2076
		          E1000_RFCTL_NEW_IPV6_EXT_DIS);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2077
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2078
		E1000_WRITE_REG(&adapter->hw, RFCTL, rfctl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2079
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2080
		rctl |= E1000_RCTL_DTYP_PS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2081
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2082
		psrctl |= adapter->rx_ps_bsize0 >>
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2083
			E1000_PSRCTL_BSIZE0_SHIFT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2084
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2085
		switch (adapter->rx_ps_pages) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2086
		case 3:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2087
			psrctl |= PAGE_SIZE <<
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2088
				E1000_PSRCTL_BSIZE3_SHIFT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2089
		case 2:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2090
			psrctl |= PAGE_SIZE <<
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2091
				E1000_PSRCTL_BSIZE2_SHIFT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2092
		case 1:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2093
			psrctl |= PAGE_SIZE >>
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2094
				E1000_PSRCTL_BSIZE1_SHIFT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2095
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2096
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2097
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2098
		E1000_WRITE_REG(&adapter->hw, PSRCTL, psrctl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2099
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2100
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2101
	E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2102
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2103
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2104
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2105
 * e1000_configure_rx - Configure 8254x Receive Unit after Reset
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2106
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2107
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2108
 * Configure the Rx unit of the MAC after a reset.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2109
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2110
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2111
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2112
e1000_configure_rx(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2113
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2114
	u64 rdba;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2115
	struct e1000_hw *hw = &adapter->hw;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2116
	u32 rdlen, rctl, rxcsum, ctrl_ext;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2117
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2118
	if (adapter->rx_ps_pages) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2119
		/* this is a 32 byte descriptor */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2120
		rdlen = adapter->rx_ring[0].count *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2121
			sizeof(union e1000_rx_desc_packet_split);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2122
		adapter->clean_rx = e1000_clean_rx_irq_ps;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2123
		adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2124
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2125
		rdlen = adapter->rx_ring[0].count *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2126
			sizeof(struct e1000_rx_desc);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2127
		adapter->clean_rx = e1000_clean_rx_irq;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2128
		adapter->alloc_rx_buf = e1000_alloc_rx_buffers;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2129
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2130
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2131
	/* disable receives while setting up the descriptors */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2132
	rctl = E1000_READ_REG(hw, RCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2133
	E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2134
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2135
	/* set the Receive Delay Timer Register */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2136
	E1000_WRITE_REG(hw, RDTR, adapter->rx_int_delay);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2137
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2138
	if (hw->mac_type >= e1000_82540) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2139
		E1000_WRITE_REG(hw, RADV, adapter->rx_abs_int_delay);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2140
		if (adapter->itr_setting != 0)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2141
			E1000_WRITE_REG(hw, ITR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2142
				1000000000 / (adapter->itr * 256));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2143
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2144
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2145
	if (hw->mac_type >= e1000_82571) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2146
		ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2147
		/* Reset delay timers after every interrupt */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2148
		ctrl_ext |= E1000_CTRL_EXT_INT_TIMER_CLR;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2149
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2150
		/* Auto-Mask interrupts upon ICR access */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2151
		ctrl_ext |= E1000_CTRL_EXT_IAME;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2152
		E1000_WRITE_REG(hw, IAM, 0xffffffff);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2153
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2154
		E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2155
		E1000_WRITE_FLUSH(hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2156
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2157
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2158
	/* Setup the HW Rx Head and Tail Descriptor Pointers and
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2159
	 * the Base and Length of the Rx Descriptor Ring */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2160
	switch (adapter->num_rx_queues) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2161
	case 1:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2162
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2163
		rdba = adapter->rx_ring[0].dma;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2164
		E1000_WRITE_REG(hw, RDLEN, rdlen);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2165
		E1000_WRITE_REG(hw, RDBAH, (rdba >> 32));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2166
		E1000_WRITE_REG(hw, RDBAL, (rdba & 0x00000000ffffffffULL));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2167
		E1000_WRITE_REG(hw, RDT, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2168
		E1000_WRITE_REG(hw, RDH, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2169
		adapter->rx_ring[0].rdh = ((hw->mac_type >= e1000_82543) ? E1000_RDH : E1000_82542_RDH);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2170
		adapter->rx_ring[0].rdt = ((hw->mac_type >= e1000_82543) ? E1000_RDT : E1000_82542_RDT);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2171
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2172
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2173
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2174
	/* Enable 82543 Receive Checksum Offload for TCP and UDP */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2175
	if (hw->mac_type >= e1000_82543) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2176
		rxcsum = E1000_READ_REG(hw, RXCSUM);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2177
		if (adapter->rx_csum) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2178
			rxcsum |= E1000_RXCSUM_TUOFL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2179
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2180
			/* Enable 82571 IPv4 payload checksum for UDP fragments
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2181
			 * Must be used in conjunction with packet-split. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2182
			if ((hw->mac_type >= e1000_82571) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2183
			    (adapter->rx_ps_pages)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2184
				rxcsum |= E1000_RXCSUM_IPPCSE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2185
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2186
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2187
			rxcsum &= ~E1000_RXCSUM_TUOFL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2188
			/* don't need to clear IPPCSE as it defaults to 0 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2189
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2190
		E1000_WRITE_REG(hw, RXCSUM, rxcsum);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2191
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2192
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2193
	/* enable early receives on 82573, only takes effect if using > 2048
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2194
	 * byte total frame size.  for example only for jumbo frames */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2195
#define E1000_ERT_2048 0x100
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2196
	if (hw->mac_type == e1000_82573)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2197
		E1000_WRITE_REG(hw, ERT, E1000_ERT_2048);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2198
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2199
	/* Enable Receives */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2200
	E1000_WRITE_REG(hw, RCTL, rctl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2201
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2202
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2203
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2204
 * e1000_free_tx_resources - Free Tx Resources per Queue
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2205
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2206
 * @tx_ring: Tx descriptor ring for a specific queue
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2207
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2208
 * Free all transmit software resources
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2209
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2210
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2211
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2212
e1000_free_tx_resources(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2213
                        struct e1000_tx_ring *tx_ring)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2214
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2215
	struct pci_dev *pdev = adapter->pdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2216
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2217
	e1000_clean_tx_ring(adapter, tx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2218
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2219
	vfree(tx_ring->buffer_info);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2220
	tx_ring->buffer_info = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2221
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2222
	pci_free_consistent(pdev, tx_ring->size, tx_ring->desc, tx_ring->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2223
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2224
	tx_ring->desc = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2225
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2226
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2227
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2228
 * e1000_free_all_tx_resources - Free Tx Resources for All Queues
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2229
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2230
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2231
 * Free all transmit software resources
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2232
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2233
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2234
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2235
e1000_free_all_tx_resources(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2236
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2237
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2238
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2239
	for (i = 0; i < adapter->num_tx_queues; i++)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2240
		e1000_free_tx_resources(adapter, &adapter->tx_ring[i]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2241
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2242
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2243
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2244
e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2245
			struct e1000_buffer *buffer_info)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2246
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2247
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2248
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2249
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2250
	if (buffer_info->dma) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2251
		pci_unmap_page(adapter->pdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2252
				buffer_info->dma,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2253
				buffer_info->length,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2254
				PCI_DMA_TODEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2255
		buffer_info->dma = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2256
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2257
	if (buffer_info->skb) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2258
		dev_kfree_skb_any(buffer_info->skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2259
		buffer_info->skb = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2260
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2261
	/* buffer_info must be completely set up in the transmit path */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2262
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2263
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2264
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2265
 * e1000_clean_tx_ring - Free Tx Buffers
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2266
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2267
 * @tx_ring: ring to be cleaned
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2268
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2269
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2270
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2271
e1000_clean_tx_ring(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2272
                    struct e1000_tx_ring *tx_ring)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2273
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2274
	struct e1000_buffer *buffer_info;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2275
	unsigned long size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2276
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2277
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2278
	/* Free all the Tx ring sk_buffs */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2279
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2280
	for (i = 0; i < tx_ring->count; i++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2281
		buffer_info = &tx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2282
		e1000_unmap_and_free_tx_resource(adapter, buffer_info);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2283
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2284
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2285
	size = sizeof(struct e1000_buffer) * tx_ring->count;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2286
	memset(tx_ring->buffer_info, 0, size);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2287
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2288
	/* Zero out the descriptor ring */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2289
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2290
	memset(tx_ring->desc, 0, tx_ring->size);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2291
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2292
	tx_ring->next_to_use = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2293
	tx_ring->next_to_clean = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2294
	tx_ring->last_tx_tso = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2295
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2296
	writel(0, adapter->hw.hw_addr + tx_ring->tdh);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2297
	writel(0, adapter->hw.hw_addr + tx_ring->tdt);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2298
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2299
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2300
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2301
 * e1000_clean_all_tx_rings - Free Tx Buffers for all queues
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2302
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2303
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2304
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2305
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2306
e1000_clean_all_tx_rings(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2307
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2308
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2309
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2310
	for (i = 0; i < adapter->num_tx_queues; i++)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2311
		e1000_clean_tx_ring(adapter, &adapter->tx_ring[i]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2312
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2313
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2314
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2315
 * e1000_free_rx_resources - Free Rx Resources
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2316
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2317
 * @rx_ring: ring to clean the resources from
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2318
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2319
 * Free all receive software resources
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2320
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2321
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2322
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2323
e1000_free_rx_resources(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2324
                        struct e1000_rx_ring *rx_ring)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2325
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2326
	struct pci_dev *pdev = adapter->pdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2327
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2328
	e1000_clean_rx_ring(adapter, rx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2329
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2330
	vfree(rx_ring->buffer_info);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2331
	rx_ring->buffer_info = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2332
	kfree(rx_ring->ps_page);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2333
	rx_ring->ps_page = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2334
	kfree(rx_ring->ps_page_dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2335
	rx_ring->ps_page_dma = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2336
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2337
	pci_free_consistent(pdev, rx_ring->size, rx_ring->desc, rx_ring->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2338
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2339
	rx_ring->desc = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2340
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2341
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2342
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2343
 * e1000_free_all_rx_resources - Free Rx Resources for All Queues
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2344
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2345
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2346
 * Free all receive software resources
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2347
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2348
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2349
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2350
e1000_free_all_rx_resources(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2351
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2352
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2353
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2354
	for (i = 0; i < adapter->num_rx_queues; i++)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2355
		e1000_free_rx_resources(adapter, &adapter->rx_ring[i]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2356
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2357
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2358
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2359
 * e1000_clean_rx_ring - Free Rx Buffers per Queue
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2360
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2361
 * @rx_ring: ring to free buffers from
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2362
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2363
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2364
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2365
e1000_clean_rx_ring(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2366
                    struct e1000_rx_ring *rx_ring)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2367
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2368
	struct e1000_buffer *buffer_info;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2369
	struct e1000_ps_page *ps_page;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2370
	struct e1000_ps_page_dma *ps_page_dma;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2371
	struct pci_dev *pdev = adapter->pdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2372
	unsigned long size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2373
	unsigned int i, j;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2374
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2375
	/* Free all the Rx ring sk_buffs */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2376
	for (i = 0; i < rx_ring->count; i++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2377
		buffer_info = &rx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2378
		if (buffer_info->skb) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2379
			pci_unmap_single(pdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2380
					 buffer_info->dma,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2381
					 buffer_info->length,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2382
					 PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2383
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2384
			dev_kfree_skb(buffer_info->skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2385
			buffer_info->skb = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2386
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2387
		ps_page = &rx_ring->ps_page[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2388
		ps_page_dma = &rx_ring->ps_page_dma[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2389
		for (j = 0; j < adapter->rx_ps_pages; j++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2390
			if (!ps_page->ps_page[j]) break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2391
			pci_unmap_page(pdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2392
				       ps_page_dma->ps_page_dma[j],
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2393
				       PAGE_SIZE, PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2394
			ps_page_dma->ps_page_dma[j] = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2395
			put_page(ps_page->ps_page[j]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2396
			ps_page->ps_page[j] = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2397
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2398
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2399
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2400
	size = sizeof(struct e1000_buffer) * rx_ring->count;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2401
	memset(rx_ring->buffer_info, 0, size);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2402
	size = sizeof(struct e1000_ps_page) * rx_ring->count;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2403
	memset(rx_ring->ps_page, 0, size);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2404
	size = sizeof(struct e1000_ps_page_dma) * rx_ring->count;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2405
	memset(rx_ring->ps_page_dma, 0, size);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2406
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2407
	/* Zero out the descriptor ring */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2408
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2409
	memset(rx_ring->desc, 0, rx_ring->size);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2410
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2411
	rx_ring->next_to_clean = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2412
	rx_ring->next_to_use = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2413
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2414
	writel(0, adapter->hw.hw_addr + rx_ring->rdh);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2415
	writel(0, adapter->hw.hw_addr + rx_ring->rdt);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2416
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2417
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2418
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2419
 * e1000_clean_all_rx_rings - Free Rx Buffers for all queues
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2420
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2421
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2422
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2423
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2424
e1000_clean_all_rx_rings(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2425
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2426
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2427
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2428
	for (i = 0; i < adapter->num_rx_queues; i++)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2429
		e1000_clean_rx_ring(adapter, &adapter->rx_ring[i]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2430
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2431
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2432
/* The 82542 2.0 (revision 2) needs to have the receive unit in reset
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2433
 * and memory write and invalidate disabled for certain operations
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2434
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2435
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2436
e1000_enter_82542_rst(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2437
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2438
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2439
	u32 rctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2440
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2441
	e1000_pci_clear_mwi(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2442
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2443
	rctl = E1000_READ_REG(&adapter->hw, RCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2444
	rctl |= E1000_RCTL_RST;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2445
	E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2446
	E1000_WRITE_FLUSH(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2447
	mdelay(5);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2448
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2449
	if (!adapter->ecdev && netif_running(netdev))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2450
		e1000_clean_all_rx_rings(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2451
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2452
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2453
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2454
e1000_leave_82542_rst(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2455
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2456
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2457
	u32 rctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2458
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2459
	rctl = E1000_READ_REG(&adapter->hw, RCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2460
	rctl &= ~E1000_RCTL_RST;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2461
	E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2462
	E1000_WRITE_FLUSH(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2463
	mdelay(5);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2464
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2465
	if (adapter->hw.pci_cmd_word & PCI_COMMAND_INVALIDATE)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2466
		e1000_pci_set_mwi(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2467
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2468
	if (!adapter->netdev && netif_running(netdev)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2469
		/* No need to loop, because 82542 supports only 1 queue */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2470
		struct e1000_rx_ring *ring = &adapter->rx_ring[0];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2471
		e1000_configure_rx(adapter);
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
  2472
		if (adapter->ecdev) {
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2473
			/* fill rx ring completely! */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2474
			adapter->alloc_rx_buf(adapter, ring, ring->count);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2475
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2476
            /* this one leaves the last ring element unallocated! */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2477
			adapter->alloc_rx_buf(adapter, ring, E1000_DESC_UNUSED(ring));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2478
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2479
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2480
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2481
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2482
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2483
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2484
 * e1000_set_mac - Change the Ethernet Address of the NIC
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2485
 * @netdev: network interface device structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2486
 * @p: pointer to an address structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2487
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2488
 * Returns 0 on success, negative on failure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2489
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2490
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2491
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2492
e1000_set_mac(struct net_device *netdev, void *p)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2493
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2494
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2495
	struct sockaddr *addr = p;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2496
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2497
	if (!is_valid_ether_addr(addr->sa_data))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2498
		return -EADDRNOTAVAIL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2499
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2500
	/* 82542 2.0 needs to be in reset to write receive address registers */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2501
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2502
	if (adapter->hw.mac_type == e1000_82542_rev2_0)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2503
		e1000_enter_82542_rst(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2504
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2505
	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2506
	memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2507
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2508
	e1000_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2509
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2510
	/* With 82571 controllers, LAA may be overwritten (with the default)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2511
	 * due to controller reset from the other port. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2512
	if (adapter->hw.mac_type == e1000_82571) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2513
		/* activate the work around */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2514
		adapter->hw.laa_is_present = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2515
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2516
		/* Hold a copy of the LAA in RAR[14] This is done so that
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2517
		 * between the time RAR[0] gets clobbered  and the time it
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2518
		 * gets fixed (in e1000_watchdog), the actual LAA is in one
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2519
		 * of the RARs and no incoming packets directed to this port
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2520
		 * are dropped. Eventaully the LAA will be in RAR[0] and
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2521
		 * RAR[14] */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2522
		e1000_rar_set(&adapter->hw, adapter->hw.mac_addr,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2523
					E1000_RAR_ENTRIES - 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2524
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2525
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2526
	if (adapter->hw.mac_type == e1000_82542_rev2_0)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2527
		e1000_leave_82542_rst(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2528
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2529
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2530
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2531
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2532
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2533
 * e1000_set_rx_mode - Secondary Unicast, Multicast and Promiscuous mode set
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2534
 * @netdev: network interface device structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2535
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2536
 * The set_rx_mode entry point is called whenever the unicast or multicast
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2537
 * address lists or the network interface flags are updated. This routine is
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2538
 * responsible for configuring the hardware for proper unicast, multicast,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2539
 * promiscuous mode, and all-multi behavior.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2540
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2541
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2542
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2543
e1000_set_rx_mode(struct net_device *netdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2544
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2545
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2546
	struct e1000_hw *hw = &adapter->hw;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2547
	struct dev_addr_list *uc_ptr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2548
	struct dev_addr_list *mc_ptr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2549
	u32 rctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2550
	u32 hash_value;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2551
	int i, rar_entries = E1000_RAR_ENTRIES;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2552
	int mta_reg_count = (hw->mac_type == e1000_ich8lan) ?
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2553
				E1000_NUM_MTA_REGISTERS_ICH8LAN :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2554
				E1000_NUM_MTA_REGISTERS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2555
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2556
	if (adapter->hw.mac_type == e1000_ich8lan)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2557
		rar_entries = E1000_RAR_ENTRIES_ICH8LAN;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2558
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2559
	/* reserve RAR[14] for LAA over-write work-around */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2560
	if (adapter->hw.mac_type == e1000_82571)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2561
		rar_entries--;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2562
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2563
	/* Check for Promiscuous and All Multicast modes */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2564
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2565
	rctl = E1000_READ_REG(hw, RCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2566
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2567
	if (netdev->flags & IFF_PROMISC) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2568
		rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2569
	} else if (netdev->flags & IFF_ALLMULTI) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2570
		rctl |= E1000_RCTL_MPE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2571
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2572
		rctl &= ~E1000_RCTL_MPE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2573
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2574
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2575
	uc_ptr = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2576
	if (netdev->uc_count > rar_entries - 1) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2577
		rctl |= E1000_RCTL_UPE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2578
	} else if (!(netdev->flags & IFF_PROMISC)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2579
		rctl &= ~E1000_RCTL_UPE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2580
		uc_ptr = netdev->uc_list;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2581
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2582
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2583
	E1000_WRITE_REG(hw, RCTL, rctl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2584
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2585
	/* 82542 2.0 needs to be in reset to write receive address registers */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2586
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2587
	if (hw->mac_type == e1000_82542_rev2_0)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2588
		e1000_enter_82542_rst(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2589
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2590
	/* load the first 14 addresses into the exact filters 1-14. Unicast
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2591
	 * addresses take precedence to avoid disabling unicast filtering
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2592
	 * when possible.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2593
	 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2594
	 * RAR 0 is used for the station MAC adddress
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2595
	 * if there are not 14 addresses, go ahead and clear the filters
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2596
	 * -- with 82571 controllers only 0-13 entries are filled here
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2597
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2598
	mc_ptr = netdev->mc_list;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2599
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2600
	for (i = 1; i < rar_entries; i++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2601
		if (uc_ptr) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2602
			e1000_rar_set(hw, uc_ptr->da_addr, i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2603
			uc_ptr = uc_ptr->next;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2604
		} else if (mc_ptr) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2605
			e1000_rar_set(hw, mc_ptr->da_addr, i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2606
			mc_ptr = mc_ptr->next;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2607
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2608
			E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2609
			E1000_WRITE_FLUSH(hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2610
			E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2611
			E1000_WRITE_FLUSH(hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2612
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2613
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2614
	WARN_ON(uc_ptr != NULL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2615
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2616
	/* clear the old settings from the multicast hash table */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2617
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2618
	for (i = 0; i < mta_reg_count; i++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2619
		E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2620
		E1000_WRITE_FLUSH(hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2621
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2622
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2623
	/* load any remaining addresses into the hash table */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2624
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2625
	for (; mc_ptr; mc_ptr = mc_ptr->next) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2626
		hash_value = e1000_hash_mc_addr(hw, mc_ptr->da_addr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2627
		e1000_mta_set(hw, hash_value);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2628
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2629
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2630
	if (hw->mac_type == e1000_82542_rev2_0)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2631
		e1000_leave_82542_rst(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2632
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2633
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2634
/* Need to wait a few seconds after link up to get diagnostic information from
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2635
 * the phy */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2636
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2637
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2638
e1000_update_phy_info(unsigned long data)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2639
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2640
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2641
	e1000_phy_get_info(&adapter->hw, &adapter->phy_info);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2642
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2643
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2644
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2645
 * e1000_82547_tx_fifo_stall - Timer Call-back
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2646
 * @data: pointer to adapter cast into an unsigned long
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2647
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2648
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2649
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2650
e1000_82547_tx_fifo_stall(unsigned long data)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2651
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2652
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2653
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2654
	u32 tctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2655
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2656
	if (atomic_read(&adapter->tx_fifo_stall)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2657
		if ((E1000_READ_REG(&adapter->hw, TDT) ==
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2658
		    E1000_READ_REG(&adapter->hw, TDH)) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2659
		   (E1000_READ_REG(&adapter->hw, TDFT) ==
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2660
		    E1000_READ_REG(&adapter->hw, TDFH)) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2661
		   (E1000_READ_REG(&adapter->hw, TDFTS) ==
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2662
		    E1000_READ_REG(&adapter->hw, TDFHS))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2663
			tctl = E1000_READ_REG(&adapter->hw, TCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2664
			E1000_WRITE_REG(&adapter->hw, TCTL,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2665
					tctl & ~E1000_TCTL_EN);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2666
			E1000_WRITE_REG(&adapter->hw, TDFT,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2667
					adapter->tx_head_addr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2668
			E1000_WRITE_REG(&adapter->hw, TDFH,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2669
					adapter->tx_head_addr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2670
			E1000_WRITE_REG(&adapter->hw, TDFTS,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2671
					adapter->tx_head_addr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2672
			E1000_WRITE_REG(&adapter->hw, TDFHS,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2673
					adapter->tx_head_addr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2674
			E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2675
			E1000_WRITE_FLUSH(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2676
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2677
			adapter->tx_fifo_head = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2678
			atomic_set(&adapter->tx_fifo_stall, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2679
			if (!adapter->ecdev) netif_wake_queue(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2680
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2681
			if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2682
				mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2683
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2684
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2685
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2686
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2687
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2688
 * e1000_watchdog - Timer Call-back
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2689
 * @data: pointer to adapter cast into an unsigned long
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2690
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2691
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2692
e1000_watchdog(unsigned long data)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2693
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2694
	struct e1000_adapter *adapter = (struct e1000_adapter *) data;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2695
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2696
	struct e1000_tx_ring *txdr = adapter->tx_ring;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2697
	u32 link, tctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2698
	s32 ret_val;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2699
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2700
	ret_val = e1000_check_for_link(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2701
	if ((ret_val == E1000_ERR_PHY) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2702
	    (adapter->hw.phy_type == e1000_phy_igp_3) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2703
	    (E1000_READ_REG(&adapter->hw, CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2704
		/* See e1000_kumeran_lock_loss_workaround() */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2705
		DPRINTK(LINK, INFO,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2706
			"Gigabit has been disabled, downgrading speed\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2707
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2708
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2709
	if (adapter->hw.mac_type == e1000_82573) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2710
		e1000_enable_tx_pkt_filtering(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2711
		if (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2712
			e1000_update_mng_vlan(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2713
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2714
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2715
	if ((adapter->hw.media_type == e1000_media_type_internal_serdes) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2716
	   !(E1000_READ_REG(&adapter->hw, TXCW) & E1000_TXCW_ANE))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2717
		link = !adapter->hw.serdes_link_down;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2718
	else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2719
		link = E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_LU;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2720
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2721
	if (link) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2722
		if ((adapter->ecdev && !ecdev_get_link(adapter->ecdev))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2723
				|| (!adapter->ecdev && !netif_carrier_ok(netdev))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2724
			u32 ctrl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2725
			bool txb2b = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2726
			e1000_get_speed_and_duplex(&adapter->hw,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2727
			                           &adapter->link_speed,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2728
			                           &adapter->link_duplex);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2729
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2730
			ctrl = E1000_READ_REG(&adapter->hw, CTRL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2731
			DPRINTK(LINK, INFO, "NIC Link is Up %d Mbps %s, "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2732
			        "Flow Control: %s\n",
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2733
			        adapter->link_speed,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2734
			        adapter->link_duplex == FULL_DUPLEX ?
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2735
			        "Full Duplex" : "Half Duplex",
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2736
			        ((ctrl & E1000_CTRL_TFCE) && (ctrl &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2737
			        E1000_CTRL_RFCE)) ? "RX/TX" : ((ctrl &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2738
			        E1000_CTRL_RFCE) ? "RX" : ((ctrl &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2739
			        E1000_CTRL_TFCE) ? "TX" : "None" )));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2740
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2741
			/* tweak tx_queue_len according to speed/duplex
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2742
			 * and adjust the timeout factor */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2743
			netdev->tx_queue_len = adapter->tx_queue_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2744
			adapter->tx_timeout_factor = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2745
			switch (adapter->link_speed) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2746
			case SPEED_10:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2747
				txb2b = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2748
				netdev->tx_queue_len = 10;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2749
				adapter->tx_timeout_factor = 8;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2750
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2751
			case SPEED_100:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2752
				txb2b = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2753
				netdev->tx_queue_len = 100;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2754
				/* maybe add some timeout factor ? */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2755
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2756
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2757
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2758
			if ((adapter->hw.mac_type == e1000_82571 ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2759
			     adapter->hw.mac_type == e1000_82572) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2760
			    !txb2b) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2761
				u32 tarc0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2762
				tarc0 = E1000_READ_REG(&adapter->hw, TARC0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2763
				tarc0 &= ~(1 << 21);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2764
				E1000_WRITE_REG(&adapter->hw, TARC0, tarc0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2765
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2766
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2767
			/* disable TSO for pcie and 10/100 speeds, to avoid
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2768
			 * some hardware issues */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2769
			if (!adapter->tso_force &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2770
			    adapter->hw.bus_type == e1000_bus_type_pci_express){
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2771
				switch (adapter->link_speed) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2772
				case SPEED_10:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2773
				case SPEED_100:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2774
					DPRINTK(PROBE,INFO,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2775
				        "10/100 speed: disabling TSO\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2776
					netdev->features &= ~NETIF_F_TSO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2777
					netdev->features &= ~NETIF_F_TSO6;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2778
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2779
				case SPEED_1000:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2780
					netdev->features |= NETIF_F_TSO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2781
					netdev->features |= NETIF_F_TSO6;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2782
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2783
				default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2784
					/* oops */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2785
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2786
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2787
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2788
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2789
			/* enable transmits in the hardware, need to do this
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2790
			 * after setting TARC0 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2791
			tctl = E1000_READ_REG(&adapter->hw, TCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2792
			tctl |= E1000_TCTL_EN;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2793
			E1000_WRITE_REG(&adapter->hw, TCTL, tctl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2794
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2795
			if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2796
				ecdev_set_link(adapter->ecdev, 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2797
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2798
				netif_carrier_on(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2799
				netif_wake_queue(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2800
				mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2801
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2802
			adapter->smartspeed = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2803
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2804
			/* make sure the receive unit is started */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2805
			if (adapter->hw.rx_needs_kicking) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2806
				struct e1000_hw *hw = &adapter->hw;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2807
				u32 rctl = E1000_READ_REG(hw, RCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2808
				E1000_WRITE_REG(hw, RCTL, rctl | E1000_RCTL_EN);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2809
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2810
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2811
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2812
		if ((adapter->ecdev && ecdev_get_link(adapter->ecdev))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2813
				|| (!adapter->ecdev && netif_carrier_ok(netdev))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2814
			adapter->link_speed = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2815
			adapter->link_duplex = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2816
			DPRINTK(LINK, INFO, "NIC Link is Down\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2817
			if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2818
				ecdev_set_link(adapter->ecdev, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2819
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2820
				netif_carrier_off(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2821
				netif_stop_queue(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2822
				mod_timer(&adapter->phy_info_timer, round_jiffies(jiffies + 2 * HZ));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2823
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2824
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2825
			/* 80003ES2LAN workaround--
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2826
			 * For packet buffer work-around on link down event;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2827
			 * disable receives in the ISR and
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2828
			 * reset device here in the watchdog
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2829
			 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2830
			if (adapter->hw.mac_type == e1000_80003es2lan)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2831
				/* reset device */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2832
				schedule_work(&adapter->reset_task);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2833
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2834
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2835
		e1000_smartspeed(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2836
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2837
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2838
	e1000_update_stats(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2839
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2840
	adapter->hw.tx_packet_delta = adapter->stats.tpt - adapter->tpt_old;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2841
	adapter->tpt_old = adapter->stats.tpt;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2842
	adapter->hw.collision_delta = adapter->stats.colc - adapter->colc_old;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2843
	adapter->colc_old = adapter->stats.colc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2844
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2845
	adapter->gorcl = adapter->stats.gorcl - adapter->gorcl_old;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2846
	adapter->gorcl_old = adapter->stats.gorcl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2847
	adapter->gotcl = adapter->stats.gotcl - adapter->gotcl_old;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2848
	adapter->gotcl_old = adapter->stats.gotcl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2849
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2850
	e1000_update_adaptive(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2851
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2852
	if (!adapter->ecdev && !netif_carrier_ok(netdev)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2853
		if (E1000_DESC_UNUSED(txdr) + 1 < txdr->count) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2854
			/* We've lost link, so the controller stops DMA,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2855
			 * but we've got queued Tx work that's never going
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2856
			 * to get done, so reset controller to flush Tx.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2857
			 * (Do the reset outside of interrupt context). */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2858
			adapter->tx_timeout_count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2859
			schedule_work(&adapter->reset_task);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2860
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2861
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2862
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2863
	/* Cause software interrupt to ensure rx ring is cleaned */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2864
	E1000_WRITE_REG(&adapter->hw, ICS, E1000_ICS_RXDMT0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2865
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2866
	/* Force detection of hung controller every watchdog period */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2867
	if (!adapter->ecdev) adapter->detect_tx_hung = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2868
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2869
	/* With 82571 controllers, LAA may be overwritten due to controller
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2870
	 * reset from the other port. Set the appropriate LAA in RAR[0] */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2871
	if (adapter->hw.mac_type == e1000_82571 && adapter->hw.laa_is_present)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2872
		e1000_rar_set(&adapter->hw, adapter->hw.mac_addr, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2873
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2874
	/* Reset the timer */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2875
	if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2876
		mod_timer(&adapter->watchdog_timer, round_jiffies(jiffies + 2 * HZ));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2877
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2878
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2879
enum latency_range {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2880
	lowest_latency = 0,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2881
	low_latency = 1,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2882
	bulk_latency = 2,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2883
	latency_invalid = 255
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2884
};
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2885
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2886
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2887
 * e1000_update_itr - update the dynamic ITR value based on statistics
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2888
 *      Stores a new ITR value based on packets and byte
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2889
 *      counts during the last interrupt.  The advantage of per interrupt
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2890
 *      computation is faster updates and more accurate ITR for the current
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2891
 *      traffic pattern.  Constants in this function were computed
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2892
 *      based on theoretical maximum wire speed and thresholds were set based
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2893
 *      on testing data as well as attempting to minimize response time
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2894
 *      while increasing bulk throughput.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2895
 *      this functionality is controlled by the InterruptThrottleRate module
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2896
 *      parameter (see e1000_param.c)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2897
 * @adapter: pointer to adapter
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2898
 * @itr_setting: current adapter->itr
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2899
 * @packets: the number of packets during this measurement interval
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2900
 * @bytes: the number of bytes during this measurement interval
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2901
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2902
static unsigned int e1000_update_itr(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2903
                                   u16 itr_setting,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2904
                                   int packets,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2905
                                   int bytes)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2906
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2907
	unsigned int retval = itr_setting;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2908
	struct e1000_hw *hw = &adapter->hw;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2909
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2910
	if (unlikely(hw->mac_type < e1000_82540))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2911
		goto update_itr_done;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2912
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2913
	if (packets == 0)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2914
		goto update_itr_done;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2915
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2916
	switch (itr_setting) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2917
	case lowest_latency:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2918
		/* jumbo frames get bulk treatment*/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2919
		if (bytes/packets > 8000)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2920
			retval = bulk_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2921
		else if ((packets < 5) && (bytes > 512))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2922
			retval = low_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2923
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2924
	case low_latency:  /* 50 usec aka 20000 ints/s */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2925
		if (bytes > 10000) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2926
			/* jumbo frames need bulk latency setting */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2927
			if (bytes/packets > 8000)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2928
				retval = bulk_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2929
			else if ((packets < 10) || ((bytes/packets) > 1200))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2930
				retval = bulk_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2931
			else if ((packets > 35))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2932
				retval = lowest_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2933
		} else if (bytes/packets > 2000)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2934
			retval = bulk_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2935
		else if (packets <= 2 && bytes < 512)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2936
			retval = lowest_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2937
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2938
	case bulk_latency: /* 250 usec aka 4000 ints/s */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2939
		if (bytes > 25000) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2940
			if (packets > 35)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2941
				retval = low_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2942
		} else if (bytes < 6000) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2943
			retval = low_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2944
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2945
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2946
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2947
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2948
update_itr_done:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2949
	return retval;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2950
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2951
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2952
static void e1000_set_itr(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2953
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2954
	struct e1000_hw *hw = &adapter->hw;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2955
	u16 current_itr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2956
	u32 new_itr = adapter->itr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2957
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2958
	if (unlikely(hw->mac_type < e1000_82540))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2959
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2960
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2961
	/* for non-gigabit speeds, just fix the interrupt rate at 4000 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2962
	if (unlikely(adapter->link_speed != SPEED_1000)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2963
		current_itr = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2964
		new_itr = 4000;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2965
		goto set_itr_now;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2966
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2967
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2968
	adapter->tx_itr = e1000_update_itr(adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2969
	                            adapter->tx_itr,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2970
	                            adapter->total_tx_packets,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2971
	                            adapter->total_tx_bytes);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2972
	/* conservative mode (itr 3) eliminates the lowest_latency setting */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2973
	if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2974
		adapter->tx_itr = low_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2975
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2976
	adapter->rx_itr = e1000_update_itr(adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2977
	                            adapter->rx_itr,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2978
	                            adapter->total_rx_packets,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2979
	                            adapter->total_rx_bytes);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2980
	/* conservative mode (itr 3) eliminates the lowest_latency setting */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2981
	if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2982
		adapter->rx_itr = low_latency;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2983
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2984
	current_itr = max(adapter->rx_itr, adapter->tx_itr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2985
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2986
	switch (current_itr) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2987
	/* counts and packets in update_itr are dependent on these numbers */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2988
	case lowest_latency:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2989
		new_itr = 70000;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2990
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2991
	case low_latency:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2992
		new_itr = 20000; /* aka hwitr = ~200 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2993
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2994
	case bulk_latency:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2995
		new_itr = 4000;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2996
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2997
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2998
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  2999
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3000
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3001
set_itr_now:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3002
	if (new_itr != adapter->itr) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3003
		/* this attempts to bias the interrupt rate towards Bulk
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3004
		 * by adding intermediate steps when interrupt rate is
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3005
		 * increasing */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3006
		new_itr = new_itr > adapter->itr ?
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3007
		             min(adapter->itr + (new_itr >> 2), new_itr) :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3008
		             new_itr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3009
		adapter->itr = new_itr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3010
		E1000_WRITE_REG(hw, ITR, 1000000000 / (new_itr * 256));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3011
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3012
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3013
	return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3014
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3015
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3016
#define E1000_TX_FLAGS_CSUM		0x00000001
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3017
#define E1000_TX_FLAGS_VLAN		0x00000002
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3018
#define E1000_TX_FLAGS_TSO		0x00000004
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3019
#define E1000_TX_FLAGS_IPV4		0x00000008
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3020
#define E1000_TX_FLAGS_VLAN_MASK	0xffff0000
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3021
#define E1000_TX_FLAGS_VLAN_SHIFT	16
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3022
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3023
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3024
e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3025
          struct sk_buff *skb)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3026
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3027
	struct e1000_context_desc *context_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3028
	struct e1000_buffer *buffer_info;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3029
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3030
	u32 cmd_length = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3031
	u16 ipcse = 0, tucse, mss;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3032
	u8 ipcss, ipcso, tucss, tucso, hdr_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3033
	int err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3034
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3035
	if (skb_is_gso(skb)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3036
		if (skb_header_cloned(skb)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3037
			err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3038
			if (err)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3039
				return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3040
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3041
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3042
		hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3043
		mss = skb_shinfo(skb)->gso_size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3044
		if (skb->protocol == htons(ETH_P_IP)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3045
			struct iphdr *iph = ip_hdr(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3046
			iph->tot_len = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3047
			iph->check = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3048
			tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3049
								 iph->daddr, 0,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3050
								 IPPROTO_TCP,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3051
								 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3052
			cmd_length = E1000_TXD_CMD_IP;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3053
			ipcse = skb_transport_offset(skb) - 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3054
		} else if (skb->protocol == htons(ETH_P_IPV6)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3055
			ipv6_hdr(skb)->payload_len = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3056
			tcp_hdr(skb)->check =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3057
				~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3058
						 &ipv6_hdr(skb)->daddr,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3059
						 0, IPPROTO_TCP, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3060
			ipcse = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3061
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3062
		ipcss = skb_network_offset(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3063
		ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3064
		tucss = skb_transport_offset(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3065
		tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3066
		tucse = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3067
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3068
		cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3069
			       E1000_TXD_CMD_TCP | (skb->len - (hdr_len)));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3070
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3071
		i = tx_ring->next_to_use;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3072
		context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3073
		buffer_info = &tx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3074
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3075
		context_desc->lower_setup.ip_fields.ipcss  = ipcss;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3076
		context_desc->lower_setup.ip_fields.ipcso  = ipcso;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3077
		context_desc->lower_setup.ip_fields.ipcse  = cpu_to_le16(ipcse);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3078
		context_desc->upper_setup.tcp_fields.tucss = tucss;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3079
		context_desc->upper_setup.tcp_fields.tucso = tucso;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3080
		context_desc->upper_setup.tcp_fields.tucse = cpu_to_le16(tucse);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3081
		context_desc->tcp_seg_setup.fields.mss     = cpu_to_le16(mss);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3082
		context_desc->tcp_seg_setup.fields.hdr_len = hdr_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3083
		context_desc->cmd_and_length = cpu_to_le32(cmd_length);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3084
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3085
		buffer_info->time_stamp = jiffies;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3086
		buffer_info->next_to_watch = i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3087
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3088
		if (++i == tx_ring->count) i = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3089
		tx_ring->next_to_use = i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3090
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3091
		return true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3092
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3093
	return false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3094
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3095
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3096
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3097
e1000_tx_csum(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3098
              struct sk_buff *skb)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3099
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3100
	struct e1000_context_desc *context_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3101
	struct e1000_buffer *buffer_info;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3102
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3103
	u8 css;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3104
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3105
	if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3106
		css = skb_transport_offset(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3107
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3108
		i = tx_ring->next_to_use;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3109
		buffer_info = &tx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3110
		context_desc = E1000_CONTEXT_DESC(*tx_ring, i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3111
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3112
		context_desc->lower_setup.ip_config = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3113
		context_desc->upper_setup.tcp_fields.tucss = css;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3114
		context_desc->upper_setup.tcp_fields.tucso =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3115
			css + skb->csum_offset;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3116
		context_desc->upper_setup.tcp_fields.tucse = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3117
		context_desc->tcp_seg_setup.data = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3118
		context_desc->cmd_and_length = cpu_to_le32(E1000_TXD_CMD_DEXT);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3119
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3120
		buffer_info->time_stamp = jiffies;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3121
		buffer_info->next_to_watch = i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3122
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3123
		if (unlikely(++i == tx_ring->count)) i = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3124
		tx_ring->next_to_use = i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3125
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3126
		return true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3127
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3128
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3129
	return false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3130
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3131
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3132
#define E1000_MAX_TXD_PWR	12
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3133
#define E1000_MAX_DATA_PER_TXD	(1<<E1000_MAX_TXD_PWR)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3134
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3135
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3136
e1000_tx_map(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3137
             struct sk_buff *skb, unsigned int first, unsigned int max_per_txd,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3138
             unsigned int nr_frags, unsigned int mss)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3139
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3140
	struct e1000_buffer *buffer_info;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3141
	unsigned int len = skb->len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3142
	unsigned int offset = 0, size, count = 0, i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3143
	unsigned int f;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3144
	len -= skb->data_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3145
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3146
	i = tx_ring->next_to_use;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3147
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3148
	while (len) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3149
		buffer_info = &tx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3150
		size = min(len, max_per_txd);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3151
		/* Workaround for Controller erratum --
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3152
		 * descriptor for non-tso packet in a linear SKB that follows a
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3153
		 * tso gets written back prematurely before the data is fully
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3154
		 * DMA'd to the controller */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3155
		if (!skb->data_len && tx_ring->last_tx_tso &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3156
		    !skb_is_gso(skb)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3157
			tx_ring->last_tx_tso = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3158
			size -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3159
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3160
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3161
		/* Workaround for premature desc write-backs
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3162
		 * in TSO mode.  Append 4-byte sentinel desc */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3163
		if (unlikely(mss && !nr_frags && size == len && size > 8))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3164
			size -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3165
		/* work-around for errata 10 and it applies
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3166
		 * to all controllers in PCI-X mode
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3167
		 * The fix is to make sure that the first descriptor of a
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3168
		 * packet is smaller than 2048 - 16 - 16 (or 2016) bytes
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3169
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3170
		if (unlikely((adapter->hw.bus_type == e1000_bus_type_pcix) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3171
		                (size > 2015) && count == 0))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3172
		        size = 2015;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3173
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3174
		/* Workaround for potential 82544 hang in PCI-X.  Avoid
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3175
		 * terminating buffers within evenly-aligned dwords. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3176
		if (unlikely(adapter->pcix_82544 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3177
		   !((unsigned long)(skb->data + offset + size - 1) & 4) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3178
		   size > 4))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3179
			size -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3180
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3181
		buffer_info->length = size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3182
		buffer_info->dma =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3183
			pci_map_single(adapter->pdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3184
				skb->data + offset,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3185
				size,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3186
				PCI_DMA_TODEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3187
		buffer_info->time_stamp = jiffies;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3188
		buffer_info->next_to_watch = i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3189
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3190
		len -= size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3191
		offset += size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3192
		count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3193
		if (unlikely(++i == tx_ring->count)) i = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3194
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3195
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3196
	for (f = 0; f < nr_frags; f++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3197
		struct skb_frag_struct *frag;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3198
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3199
		frag = &skb_shinfo(skb)->frags[f];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3200
		len = frag->size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3201
		offset = frag->page_offset;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3202
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3203
		while (len) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3204
			buffer_info = &tx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3205
			size = min(len, max_per_txd);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3206
			/* Workaround for premature desc write-backs
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3207
			 * in TSO mode.  Append 4-byte sentinel desc */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3208
			if (unlikely(mss && f == (nr_frags-1) && size == len && size > 8))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3209
				size -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3210
			/* Workaround for potential 82544 hang in PCI-X.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3211
			 * Avoid terminating buffers within evenly-aligned
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3212
			 * dwords. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3213
			if (unlikely(adapter->pcix_82544 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3214
			   !((unsigned long)(frag->page+offset+size-1) & 4) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3215
			   size > 4))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3216
				size -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3217
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3218
			buffer_info->length = size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3219
			buffer_info->dma =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3220
				pci_map_page(adapter->pdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3221
					frag->page,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3222
					offset,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3223
					size,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3224
					PCI_DMA_TODEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3225
			buffer_info->time_stamp = jiffies;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3226
			buffer_info->next_to_watch = i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3227
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3228
			len -= size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3229
			offset += size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3230
			count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3231
			if (unlikely(++i == tx_ring->count)) i = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3232
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3233
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3234
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3235
	i = (i == 0) ? tx_ring->count - 1 : i - 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3236
	tx_ring->buffer_info[i].skb = skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3237
	tx_ring->buffer_info[first].next_to_watch = i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3238
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3239
	return count;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3240
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3241
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3242
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3243
e1000_tx_queue(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3244
               int tx_flags, int count)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3245
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3246
	struct e1000_tx_desc *tx_desc = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3247
	struct e1000_buffer *buffer_info;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3248
	u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3249
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3250
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3251
	if (likely(tx_flags & E1000_TX_FLAGS_TSO)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3252
		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3253
		             E1000_TXD_CMD_TSE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3254
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3255
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3256
		if (likely(tx_flags & E1000_TX_FLAGS_IPV4))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3257
			txd_upper |= E1000_TXD_POPTS_IXSM << 8;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3258
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3259
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3260
	if (likely(tx_flags & E1000_TX_FLAGS_CSUM)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3261
		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3262
		txd_upper |= E1000_TXD_POPTS_TXSM << 8;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3263
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3264
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3265
	if (unlikely(tx_flags & E1000_TX_FLAGS_VLAN)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3266
		txd_lower |= E1000_TXD_CMD_VLE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3267
		txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3268
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3269
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3270
	i = tx_ring->next_to_use;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3271
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3272
	while (count--) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3273
		buffer_info = &tx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3274
		tx_desc = E1000_TX_DESC(*tx_ring, i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3275
		tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3276
		tx_desc->lower.data =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3277
			cpu_to_le32(txd_lower | buffer_info->length);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3278
		tx_desc->upper.data = cpu_to_le32(txd_upper);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3279
		if (unlikely(++i == tx_ring->count)) i = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3280
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3281
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3282
	tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3283
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3284
	/* Force memory writes to complete before letting h/w
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3285
	 * know there are new descriptors to fetch.  (Only
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3286
	 * applicable for weak-ordered memory model archs,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3287
	 * such as IA-64). */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3288
	wmb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3289
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3290
	tx_ring->next_to_use = i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3291
	writel(i, adapter->hw.hw_addr + tx_ring->tdt);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3292
	/* we need this if more than one processor can write to our tail
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3293
	 * at a time, it syncronizes IO on IA64/Altix systems */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3294
	mmiowb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3295
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3296
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3297
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3298
 * 82547 workaround to avoid controller hang in half-duplex environment.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3299
 * The workaround is to avoid queuing a large packet that would span
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3300
 * the internal Tx FIFO ring boundary by notifying the stack to resend
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3301
 * the packet at a later time.  This gives the Tx FIFO an opportunity to
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3302
 * flush all packets.  When that occurs, we reset the Tx FIFO pointers
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3303
 * to the beginning of the Tx FIFO.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3304
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3305
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3306
#define E1000_FIFO_HDR			0x10
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3307
#define E1000_82547_PAD_LEN		0x3E0
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3308
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3309
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3310
e1000_82547_fifo_workaround(struct e1000_adapter *adapter, struct sk_buff *skb)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3311
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3312
	u32 fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3313
	u32 skb_fifo_len = skb->len + E1000_FIFO_HDR;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3314
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3315
	skb_fifo_len = ALIGN(skb_fifo_len, E1000_FIFO_HDR);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3316
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3317
	if (adapter->link_duplex != HALF_DUPLEX)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3318
		goto no_fifo_stall_required;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3319
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3320
	if (atomic_read(&adapter->tx_fifo_stall))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3321
		return 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3322
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3323
	if (skb_fifo_len >= (E1000_82547_PAD_LEN + fifo_space)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3324
		atomic_set(&adapter->tx_fifo_stall, 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3325
		return 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3326
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3327
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3328
no_fifo_stall_required:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3329
	adapter->tx_fifo_head += skb_fifo_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3330
	if (adapter->tx_fifo_head >= adapter->tx_fifo_size)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3331
		adapter->tx_fifo_head -= adapter->tx_fifo_size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3332
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3333
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3334
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3335
#define MINIMUM_DHCP_PACKET_SIZE 282
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3336
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3337
e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3338
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3339
	struct e1000_hw *hw =  &adapter->hw;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3340
	u16 length, offset;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3341
	if (vlan_tx_tag_present(skb)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3342
		if (!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3343
			( adapter->hw.mng_cookie.status &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3344
			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3345
			return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3346
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3347
	if (skb->len > MINIMUM_DHCP_PACKET_SIZE) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3348
		struct ethhdr *eth = (struct ethhdr *) skb->data;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3349
		if ((htons(ETH_P_IP) == eth->h_proto)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3350
			const struct iphdr *ip =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3351
				(struct iphdr *)((u8 *)skb->data+14);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3352
			if (IPPROTO_UDP == ip->protocol) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3353
				struct udphdr *udp =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3354
					(struct udphdr *)((u8 *)ip +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3355
						(ip->ihl << 2));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3356
				if (ntohs(udp->dest) == 67) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3357
					offset = (u8 *)udp + 8 - skb->data;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3358
					length = skb->len - offset;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3359
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3360
					return e1000_mng_write_dhcp_info(hw,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3361
							(u8 *)udp + 8,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3362
							length);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3363
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3364
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3365
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3366
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3367
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3368
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3369
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3370
static int __e1000_maybe_stop_tx(struct net_device *netdev, int size)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3371
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3372
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3373
	struct e1000_tx_ring *tx_ring = adapter->tx_ring;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3374
2471
fc64a4b1ec1a Fixed __e1000_maybe_stop_tx().
Florian Pose <fp@igh-essen.com>
parents: 2469
diff changeset
  3375
	if (adapter->ecdev) {
fc64a4b1ec1a Fixed __e1000_maybe_stop_tx().
Florian Pose <fp@igh-essen.com>
parents: 2469
diff changeset
  3376
		return -EBUSY;
fc64a4b1ec1a Fixed __e1000_maybe_stop_tx().
Florian Pose <fp@igh-essen.com>
parents: 2469
diff changeset
  3377
	}
fc64a4b1ec1a Fixed __e1000_maybe_stop_tx().
Florian Pose <fp@igh-essen.com>
parents: 2469
diff changeset
  3378
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3379
	netif_stop_queue(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3380
	/* Herbert's original patch had:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3381
	 *  smp_mb__after_netif_stop_queue();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3382
	 * but since that doesn't exist yet, just open code it. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3383
	smp_mb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3384
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3385
	/* We need to check again in a case another CPU has just
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3386
	 * made room available. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3387
	if (likely(E1000_DESC_UNUSED(tx_ring) < size))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3388
		return -EBUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3389
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3390
	/* A reprieve! */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3391
	netif_start_queue(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3392
	++adapter->restart_queue;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3393
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3394
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3395
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3396
static int e1000_maybe_stop_tx(struct net_device *netdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3397
                               struct e1000_tx_ring *tx_ring, int size)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3398
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3399
	if (likely(E1000_DESC_UNUSED(tx_ring) >= size))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3400
		return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3401
	return __e1000_maybe_stop_tx(netdev, size);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3402
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3403
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3404
#define TXD_USE_COUNT(S, X) (((S) >> (X)) + 1 )
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3405
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3406
e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3407
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3408
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3409
	struct e1000_tx_ring *tx_ring;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3410
	unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3411
	unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3412
	unsigned int tx_flags = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3413
	unsigned int len = skb->len - skb->data_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3414
	unsigned long flags = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3415
	unsigned int nr_frags = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3416
	unsigned int mss = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3417
	int count = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3418
	int tso;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3419
	unsigned int f;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3420
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3421
	/* This goes back to the question of how to logically map a tx queue
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3422
	 * to a flow.  Right now, performance is impacted slightly negatively
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3423
	 * if using multiple tx queues.  If the stack breaks away from a
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3424
	 * single qdisc implementation, we can look at this again. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3425
	tx_ring = adapter->tx_ring;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3426
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3427
	if (unlikely(skb->len <= 0)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3428
		if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3429
			dev_kfree_skb_any(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3430
		return NETDEV_TX_OK;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3431
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3432
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3433
	/* 82571 and newer doesn't need the workaround that limited descriptor
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3434
	 * length to 4kB */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3435
	if (adapter->hw.mac_type >= e1000_82571)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3436
		max_per_txd = 8192;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3437
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3438
	mss = skb_shinfo(skb)->gso_size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3439
	/* The controller does a simple calculation to
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3440
	 * make sure there is enough room in the FIFO before
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3441
	 * initiating the DMA for each buffer.  The calc is:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3442
	 * 4 = ceil(buffer len/mss).  To make sure we don't
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3443
	 * overrun the FIFO, adjust the max buffer len if mss
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3444
	 * drops. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3445
	if (mss) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3446
		u8 hdr_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3447
		max_per_txd = min(mss << 2, max_per_txd);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3448
		max_txd_pwr = fls(max_per_txd) - 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3449
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3450
		/* TSO Workaround for 82571/2/3 Controllers -- if skb->data
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3451
		* points to just header, pull a few bytes of payload from
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3452
		* frags into skb->data */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3453
		hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3454
		if (skb->data_len && hdr_len == len) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3455
			switch (adapter->hw.mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3456
				unsigned int pull_size;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3457
			case e1000_82544:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3458
				/* Make sure we have room to chop off 4 bytes,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3459
				 * and that the end alignment will work out to
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3460
				 * this hardware's requirements
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3461
				 * NOTE: this is a TSO only workaround
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3462
				 * if end byte alignment not correct move us
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3463
				 * into the next dword */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3464
				if ((unsigned long)(skb_tail_pointer(skb) - 1) & 4)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3465
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3466
				/* fall through */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3467
			case e1000_82571:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3468
			case e1000_82572:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3469
			case e1000_82573:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3470
			case e1000_ich8lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3471
				pull_size = min((unsigned int)4, skb->data_len);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3472
				if (!__pskb_pull_tail(skb, pull_size)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3473
					DPRINTK(DRV, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3474
						"__pskb_pull_tail failed.\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3475
					dev_kfree_skb_any(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3476
					return NETDEV_TX_OK;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3477
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3478
				len = skb->len - skb->data_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3479
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3480
			default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3481
				/* do nothing */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3482
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3483
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3484
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3485
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3486
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3487
	/* reserve a descriptor for the offload context */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3488
	if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3489
		count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3490
	count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3491
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3492
	/* Controller Erratum workaround */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3493
	if (!skb->data_len && tx_ring->last_tx_tso && !skb_is_gso(skb))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3494
		count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3495
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3496
	count += TXD_USE_COUNT(len, max_txd_pwr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3497
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3498
	if (adapter->pcix_82544)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3499
		count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3500
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3501
	/* work-around for errata 10 and it applies to all controllers
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3502
	 * in PCI-X mode, so add one more descriptor to the count
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3503
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3504
	if (unlikely((adapter->hw.bus_type == e1000_bus_type_pcix) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3505
			(len > 2015)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3506
		count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3507
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3508
	nr_frags = skb_shinfo(skb)->nr_frags;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3509
	for (f = 0; f < nr_frags; f++)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3510
		count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3511
				       max_txd_pwr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3512
	if (adapter->pcix_82544)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3513
		count += nr_frags;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3514
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3515
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3516
	if (adapter->hw.tx_pkt_filtering &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3517
	    (adapter->hw.mac_type == e1000_82573))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3518
		e1000_transfer_dhcp_info(adapter, skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3519
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3520
	if (!adapter->ecdev &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3521
			!spin_trylock_irqsave(&tx_ring->tx_lock, flags)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3522
		/* Collision - tell upper layer to requeue */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3523
		return NETDEV_TX_LOCKED;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3524
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3525
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3526
	/* need: count + 2 desc gap to keep tail from touching
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3527
	 * head, otherwise try next time */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3528
	if (unlikely(e1000_maybe_stop_tx(netdev, tx_ring, count + 2))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3529
		if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3530
			spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3531
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3532
		return NETDEV_TX_BUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3533
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3534
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3535
	if (unlikely(adapter->hw.mac_type == e1000_82547)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3536
		if (unlikely(e1000_82547_fifo_workaround(adapter, skb))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3537
			if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3538
				netif_stop_queue(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3539
				mod_timer(&adapter->tx_fifo_stall_timer, jiffies + 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3540
				spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3541
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3542
			return NETDEV_TX_BUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3543
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3544
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3545
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3546
	if (unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3547
		tx_flags |= E1000_TX_FLAGS_VLAN;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3548
		tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3549
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3550
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3551
	first = tx_ring->next_to_use;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3552
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3553
	tso = e1000_tso(adapter, tx_ring, skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3554
	if (tso < 0) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3555
		if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3556
			dev_kfree_skb_any(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3557
			spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3558
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3559
		return NETDEV_TX_OK;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3560
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3561
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3562
	if (likely(tso)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3563
		tx_ring->last_tx_tso = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3564
		tx_flags |= E1000_TX_FLAGS_TSO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3565
	} else if (likely(e1000_tx_csum(adapter, tx_ring, skb)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3566
		tx_flags |= E1000_TX_FLAGS_CSUM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3567
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3568
	/* Old method was to assume IPv4 packet by default if TSO was enabled.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3569
	 * 82571 hardware supports TSO capabilities for IPv6 as well...
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3570
	 * no longer assume, we must. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3571
	if (likely(skb->protocol == htons(ETH_P_IP)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3572
		tx_flags |= E1000_TX_FLAGS_IPV4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3573
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3574
	e1000_tx_queue(adapter, tx_ring, tx_flags,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3575
	               e1000_tx_map(adapter, tx_ring, skb, first,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3576
	                            max_per_txd, nr_frags, mss));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3577
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3578
	netdev->trans_start = jiffies;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3579
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3580
	if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3581
		/* Make sure there is space in the ring for the next send. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3582
		e1000_maybe_stop_tx(netdev, tx_ring, MAX_SKB_FRAGS + 2);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3583
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3584
		spin_unlock_irqrestore(&tx_ring->tx_lock, flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3585
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3586
	return NETDEV_TX_OK;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3587
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3588
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3589
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3590
 * e1000_tx_timeout - Respond to a Tx Hang
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3591
 * @netdev: network interface device structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3592
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3593
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3594
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3595
e1000_tx_timeout(struct net_device *netdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3596
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3597
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3598
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3599
	/* Do the reset outside of interrupt context */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3600
	adapter->tx_timeout_count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3601
	schedule_work(&adapter->reset_task);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3602
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3603
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3604
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3605
e1000_reset_task(struct work_struct *work)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3606
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3607
	struct e1000_adapter *adapter =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3608
		container_of(work, struct e1000_adapter, reset_task);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3609
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3610
	e1000_reinit_locked(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3611
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3612
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3613
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3614
 * e1000_get_stats - Get System Network Statistics
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3615
 * @netdev: network interface device structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3616
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3617
 * Returns the address of the device statistics structure.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3618
 * The statistics are actually updated from the timer callback.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3619
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3620
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3621
static struct net_device_stats *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3622
e1000_get_stats(struct net_device *netdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3623
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3624
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3625
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3626
	/* only return the current stats */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3627
	return &adapter->net_stats;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3628
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3629
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3630
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3631
 * e1000_change_mtu - Change the Maximum Transfer Unit
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3632
 * @netdev: network interface device structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3633
 * @new_mtu: new value for maximum frame size
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3634
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3635
 * Returns 0 on success, negative on failure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3636
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3637
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3638
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3639
e1000_change_mtu(struct net_device *netdev, int new_mtu)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3640
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3641
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3642
	int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3643
	u16 eeprom_data = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3644
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3645
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3646
		return -EBUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3647
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3648
	if ((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3649
	    (max_frame > MAX_JUMBO_FRAME_SIZE)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3650
		DPRINTK(PROBE, ERR, "Invalid MTU setting\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3651
		return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3652
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3653
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3654
	/* Adapter-specific max frame size limits. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3655
	switch (adapter->hw.mac_type) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3656
	case e1000_undefined ... e1000_82542_rev2_1:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3657
	case e1000_ich8lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3658
		if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3659
			DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3660
			return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3661
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3662
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3663
	case e1000_82573:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3664
		/* Jumbo Frames not supported if:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3665
		 * - this is not an 82573L device
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3666
		 * - ASPM is enabled in any way (0x1A bits 3:2) */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3667
		e1000_read_eeprom(&adapter->hw, EEPROM_INIT_3GIO_3, 1,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3668
		                  &eeprom_data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3669
		if ((adapter->hw.device_id != E1000_DEV_ID_82573L) ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3670
		    (eeprom_data & EEPROM_WORD1A_ASPM_MASK)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3671
			if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3672
				DPRINTK(PROBE, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3673
			            	"Jumbo Frames not supported.\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3674
				return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3675
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3676
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3677
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3678
		/* ERT will be enabled later to enable wire speed receives */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3679
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3680
		/* fall through to get support */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3681
	case e1000_82571:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3682
	case e1000_82572:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3683
	case e1000_80003es2lan:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3684
#define MAX_STD_JUMBO_FRAME_SIZE 9234
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3685
		if (max_frame > MAX_STD_JUMBO_FRAME_SIZE) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3686
			DPRINTK(PROBE, ERR, "MTU > 9216 not supported.\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3687
			return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3688
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3689
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3690
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3691
		/* Capable of supporting up to MAX_JUMBO_FRAME_SIZE limit. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3692
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3693
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3694
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3695
	/* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3696
	 * means we reserve 2 more, this pushes us to allocate from the next
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3697
	 * larger slab size
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3698
	 * i.e. RXBUFFER_2048 --> size-4096 slab */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3699
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3700
	if (max_frame <= E1000_RXBUFFER_256)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3701
		adapter->rx_buffer_len = E1000_RXBUFFER_256;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3702
	else if (max_frame <= E1000_RXBUFFER_512)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3703
		adapter->rx_buffer_len = E1000_RXBUFFER_512;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3704
	else if (max_frame <= E1000_RXBUFFER_1024)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3705
		adapter->rx_buffer_len = E1000_RXBUFFER_1024;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3706
	else if (max_frame <= E1000_RXBUFFER_2048)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3707
		adapter->rx_buffer_len = E1000_RXBUFFER_2048;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3708
	else if (max_frame <= E1000_RXBUFFER_4096)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3709
		adapter->rx_buffer_len = E1000_RXBUFFER_4096;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3710
	else if (max_frame <= E1000_RXBUFFER_8192)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3711
		adapter->rx_buffer_len = E1000_RXBUFFER_8192;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3712
	else if (max_frame <= E1000_RXBUFFER_16384)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3713
		adapter->rx_buffer_len = E1000_RXBUFFER_16384;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3714
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3715
	/* adjust allocation if LPE protects us, and we aren't using SBP */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3716
	if (!adapter->hw.tbi_compatibility_on &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3717
	    ((max_frame == MAXIMUM_ETHERNET_FRAME_SIZE) ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3718
	     (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3719
		adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3720
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3721
	netdev->mtu = new_mtu;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3722
	adapter->hw.max_frame_size = max_frame;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3723
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3724
	if (netif_running(netdev))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3725
		e1000_reinit_locked(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3726
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3727
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3728
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3729
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3730
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3731
 * e1000_update_stats - Update the board statistics counters
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3732
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3733
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3734
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3735
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3736
e1000_update_stats(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3737
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3738
	struct e1000_hw *hw = &adapter->hw;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3739
	struct pci_dev *pdev = adapter->pdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3740
	unsigned long flags = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3741
	u16 phy_tmp;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3742
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3743
#define PHY_IDLE_ERROR_COUNT_MASK 0x00FF
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3744
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3745
	/*
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3746
	 * Prevent stats update while adapter is being reset, or if the pci
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3747
	 * connection is down.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3748
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3749
	if (adapter->link_speed == 0)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3750
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3751
	if (pci_channel_offline(pdev))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3752
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3753
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3754
	if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3755
		spin_lock_irqsave(&adapter->stats_lock, flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3756
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3757
	/* these counters are modified from e1000_tbi_adjust_stats,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3758
	 * called from the interrupt context, so they must only
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3759
	 * be written while holding adapter->stats_lock
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3760
	 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3761
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3762
	adapter->stats.crcerrs += E1000_READ_REG(hw, CRCERRS);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3763
	adapter->stats.gprc += E1000_READ_REG(hw, GPRC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3764
	adapter->stats.gorcl += E1000_READ_REG(hw, GORCL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3765
	adapter->stats.gorch += E1000_READ_REG(hw, GORCH);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3766
	adapter->stats.bprc += E1000_READ_REG(hw, BPRC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3767
	adapter->stats.mprc += E1000_READ_REG(hw, MPRC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3768
	adapter->stats.roc += E1000_READ_REG(hw, ROC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3769
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3770
	if (adapter->hw.mac_type != e1000_ich8lan) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3771
		adapter->stats.prc64 += E1000_READ_REG(hw, PRC64);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3772
		adapter->stats.prc127 += E1000_READ_REG(hw, PRC127);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3773
		adapter->stats.prc255 += E1000_READ_REG(hw, PRC255);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3774
		adapter->stats.prc511 += E1000_READ_REG(hw, PRC511);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3775
		adapter->stats.prc1023 += E1000_READ_REG(hw, PRC1023);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3776
		adapter->stats.prc1522 += E1000_READ_REG(hw, PRC1522);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3777
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3778
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3779
	adapter->stats.symerrs += E1000_READ_REG(hw, SYMERRS);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3780
	adapter->stats.mpc += E1000_READ_REG(hw, MPC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3781
	adapter->stats.scc += E1000_READ_REG(hw, SCC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3782
	adapter->stats.ecol += E1000_READ_REG(hw, ECOL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3783
	adapter->stats.mcc += E1000_READ_REG(hw, MCC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3784
	adapter->stats.latecol += E1000_READ_REG(hw, LATECOL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3785
	adapter->stats.dc += E1000_READ_REG(hw, DC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3786
	adapter->stats.sec += E1000_READ_REG(hw, SEC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3787
	adapter->stats.rlec += E1000_READ_REG(hw, RLEC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3788
	adapter->stats.xonrxc += E1000_READ_REG(hw, XONRXC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3789
	adapter->stats.xontxc += E1000_READ_REG(hw, XONTXC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3790
	adapter->stats.xoffrxc += E1000_READ_REG(hw, XOFFRXC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3791
	adapter->stats.xofftxc += E1000_READ_REG(hw, XOFFTXC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3792
	adapter->stats.fcruc += E1000_READ_REG(hw, FCRUC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3793
	adapter->stats.gptc += E1000_READ_REG(hw, GPTC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3794
	adapter->stats.gotcl += E1000_READ_REG(hw, GOTCL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3795
	adapter->stats.gotch += E1000_READ_REG(hw, GOTCH);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3796
	adapter->stats.rnbc += E1000_READ_REG(hw, RNBC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3797
	adapter->stats.ruc += E1000_READ_REG(hw, RUC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3798
	adapter->stats.rfc += E1000_READ_REG(hw, RFC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3799
	adapter->stats.rjc += E1000_READ_REG(hw, RJC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3800
	adapter->stats.torl += E1000_READ_REG(hw, TORL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3801
	adapter->stats.torh += E1000_READ_REG(hw, TORH);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3802
	adapter->stats.totl += E1000_READ_REG(hw, TOTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3803
	adapter->stats.toth += E1000_READ_REG(hw, TOTH);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3804
	adapter->stats.tpr += E1000_READ_REG(hw, TPR);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3805
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3806
	if (adapter->hw.mac_type != e1000_ich8lan) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3807
		adapter->stats.ptc64 += E1000_READ_REG(hw, PTC64);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3808
		adapter->stats.ptc127 += E1000_READ_REG(hw, PTC127);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3809
		adapter->stats.ptc255 += E1000_READ_REG(hw, PTC255);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3810
		adapter->stats.ptc511 += E1000_READ_REG(hw, PTC511);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3811
		adapter->stats.ptc1023 += E1000_READ_REG(hw, PTC1023);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3812
		adapter->stats.ptc1522 += E1000_READ_REG(hw, PTC1522);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3813
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3814
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3815
	adapter->stats.mptc += E1000_READ_REG(hw, MPTC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3816
	adapter->stats.bptc += E1000_READ_REG(hw, BPTC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3817
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3818
	/* used for adaptive IFS */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3819
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3820
	hw->tx_packet_delta = E1000_READ_REG(hw, TPT);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3821
	adapter->stats.tpt += hw->tx_packet_delta;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3822
	hw->collision_delta = E1000_READ_REG(hw, COLC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3823
	adapter->stats.colc += hw->collision_delta;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3824
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3825
	if (hw->mac_type >= e1000_82543) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3826
		adapter->stats.algnerrc += E1000_READ_REG(hw, ALGNERRC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3827
		adapter->stats.rxerrc += E1000_READ_REG(hw, RXERRC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3828
		adapter->stats.tncrs += E1000_READ_REG(hw, TNCRS);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3829
		adapter->stats.cexterr += E1000_READ_REG(hw, CEXTERR);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3830
		adapter->stats.tsctc += E1000_READ_REG(hw, TSCTC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3831
		adapter->stats.tsctfc += E1000_READ_REG(hw, TSCTFC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3832
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3833
	if (hw->mac_type > e1000_82547_rev_2) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3834
		adapter->stats.iac += E1000_READ_REG(hw, IAC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3835
		adapter->stats.icrxoc += E1000_READ_REG(hw, ICRXOC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3836
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3837
		if (adapter->hw.mac_type != e1000_ich8lan) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3838
			adapter->stats.icrxptc += E1000_READ_REG(hw, ICRXPTC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3839
			adapter->stats.icrxatc += E1000_READ_REG(hw, ICRXATC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3840
			adapter->stats.ictxptc += E1000_READ_REG(hw, ICTXPTC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3841
			adapter->stats.ictxatc += E1000_READ_REG(hw, ICTXATC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3842
			adapter->stats.ictxqec += E1000_READ_REG(hw, ICTXQEC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3843
			adapter->stats.ictxqmtc += E1000_READ_REG(hw, ICTXQMTC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3844
			adapter->stats.icrxdmtc += E1000_READ_REG(hw, ICRXDMTC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3845
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3846
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3847
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3848
	/* Fill out the OS statistics structure */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3849
	adapter->net_stats.multicast = adapter->stats.mprc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3850
	adapter->net_stats.collisions = adapter->stats.colc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3851
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3852
	/* Rx Errors */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3853
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3854
	/* RLEC on some newer hardware can be incorrect so build
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3855
	* our own version based on RUC and ROC */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3856
	adapter->net_stats.rx_errors = adapter->stats.rxerrc +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3857
		adapter->stats.crcerrs + adapter->stats.algnerrc +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3858
		adapter->stats.ruc + adapter->stats.roc +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3859
		adapter->stats.cexterr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3860
	adapter->stats.rlerrc = adapter->stats.ruc + adapter->stats.roc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3861
	adapter->net_stats.rx_length_errors = adapter->stats.rlerrc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3862
	adapter->net_stats.rx_crc_errors = adapter->stats.crcerrs;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3863
	adapter->net_stats.rx_frame_errors = adapter->stats.algnerrc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3864
	adapter->net_stats.rx_missed_errors = adapter->stats.mpc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3865
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3866
	/* Tx Errors */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3867
	adapter->stats.txerrc = adapter->stats.ecol + adapter->stats.latecol;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3868
	adapter->net_stats.tx_errors = adapter->stats.txerrc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3869
	adapter->net_stats.tx_aborted_errors = adapter->stats.ecol;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3870
	adapter->net_stats.tx_window_errors = adapter->stats.latecol;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3871
	adapter->net_stats.tx_carrier_errors = adapter->stats.tncrs;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3872
	if (adapter->hw.bad_tx_carr_stats_fd &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3873
	    adapter->link_duplex == FULL_DUPLEX) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3874
		adapter->net_stats.tx_carrier_errors = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3875
		adapter->stats.tncrs = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3876
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3877
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3878
	/* Tx Dropped needs to be maintained elsewhere */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3879
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3880
	/* Phy Stats */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3881
	if (hw->media_type == e1000_media_type_copper) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3882
		if ((adapter->link_speed == SPEED_1000) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3883
		   (!e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3884
			phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3885
			adapter->phy_stats.idle_errors += phy_tmp;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3886
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3887
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3888
		if ((hw->mac_type <= e1000_82546) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3889
		   (hw->phy_type == e1000_phy_m88) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3890
		   !e1000_read_phy_reg(hw, M88E1000_RX_ERR_CNTR, &phy_tmp))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3891
			adapter->phy_stats.receive_errors += phy_tmp;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3892
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3893
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3894
	/* Management Stats */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3895
	if (adapter->hw.has_smbus) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3896
		adapter->stats.mgptc += E1000_READ_REG(hw, MGTPTC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3897
		adapter->stats.mgprc += E1000_READ_REG(hw, MGTPRC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3898
		adapter->stats.mgpdc += E1000_READ_REG(hw, MGTPDC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3899
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3900
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3901
	if (!adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3902
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3903
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3904
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3905
void ec_poll(struct net_device *netdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3906
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3907
    struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3908
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3909
    if (jiffies - adapter->ec_watchdog_jiffies >= 2 * HZ) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3910
        e1000_watchdog((unsigned long) adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3911
        adapter->ec_watchdog_jiffies = jiffies;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3912
    }
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3913
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3914
#ifdef CONFIG_PCI_MSI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3915
	e1000_intr_msi(0, netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3916
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3917
    e1000_intr(0, netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3918
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3919
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3920
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3921
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3922
 * e1000_intr_msi - Interrupt Handler
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3923
 * @irq: interrupt number
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3924
 * @data: pointer to a network interface device structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3925
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3926
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3927
static irqreturn_t
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3928
e1000_intr_msi(int irq, void *data)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3929
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3930
	struct net_device *netdev = data;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3931
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3932
	struct e1000_hw *hw = &adapter->hw;
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
  3933
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3934
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3935
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3936
	if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3937
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3938
		int ec_work_done = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3939
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3940
		for (i = 0; i < E1000_MAX_INTR; i++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3941
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3942
			if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring,
2050
a3e59f2a8589 Changed accidentally used & operator to &&.
Florian Pose <fp@igh-essen.com>
parents: 1360
diff changeset
  3943
                            &ec_work_done, 100) &&
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3944
						!e1000_clean_tx_irq(adapter, adapter->tx_ring))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3945
#else
2050
a3e59f2a8589 Changed accidentally used & operator to &&.
Florian Pose <fp@igh-essen.com>
parents: 1360
diff changeset
  3946
			if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &&
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3947
						!e1000_clean_tx_irq(adapter, adapter->tx_ring))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3948
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3949
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3950
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3951
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3952
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3953
		u32 icr = E1000_READ_REG(hw, ICR);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3954
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3955
		/* in NAPI mode read ICR disables interrupts using IAM */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3956
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3957
		if (icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3958
			hw->get_link_status = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3959
			/* 80003ES2LAN workaround-- For packet buffer work-around on
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3960
			 * link down event; disable receives here in the ISR and reset
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3961
			 * adapter in watchdog */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3962
			if (netif_carrier_ok(netdev) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3963
			    (adapter->hw.mac_type == e1000_80003es2lan)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3964
				/* disable receives */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3965
				u32 rctl = E1000_READ_REG(hw, RCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3966
				E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3967
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3968
			/* guard against interrupt when we're going down */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3969
			if (!test_bit(__E1000_DOWN, &adapter->flags))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3970
				mod_timer(&adapter->watchdog_timer, jiffies + 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3971
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3972
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3973
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3974
		if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3975
			adapter->total_tx_bytes = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3976
			adapter->total_tx_packets = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3977
			adapter->total_rx_bytes = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3978
			adapter->total_rx_packets = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3979
			__netif_rx_schedule(netdev, &adapter->napi);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3980
		} else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3981
			e1000_irq_enable(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3982
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3983
		adapter->total_tx_bytes = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3984
		adapter->total_rx_bytes = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3985
		adapter->total_tx_packets = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3986
		adapter->total_rx_packets = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3987
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3988
		for (i = 0; i < E1000_MAX_INTR; i++)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3989
			if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3990
			   !e1000_clean_tx_irq(adapter, adapter->tx_ring)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3991
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3992
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3993
		if (likely(adapter->itr_setting & 3))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3994
			e1000_set_itr(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3995
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3996
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3997
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3998
	return IRQ_HANDLED;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  3999
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4000
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4001
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4002
 * e1000_intr - Interrupt Handler
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4003
 * @irq: interrupt number
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4004
 * @data: pointer to a network interface device structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4005
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4006
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4007
static irqreturn_t
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4008
e1000_intr(int irq, void *data)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4009
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4010
	struct net_device *netdev = data;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4011
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4012
	struct e1000_hw *hw = &adapter->hw;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4013
	u32 rctl, icr = E1000_READ_REG(hw, ICR);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4014
	int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4015
	if (unlikely(!icr))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4016
		return IRQ_NONE;  /* Not our interrupt */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4017
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4018
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4019
	/* IMS will not auto-mask if INT_ASSERTED is not set, and if it is
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4020
	 * not set, then the adapter didn't send an interrupt */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4021
	if (unlikely(hw->mac_type >= e1000_82571 &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4022
	             !(icr & E1000_ICR_INT_ASSERTED)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4023
		return IRQ_NONE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4024
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4025
	/* Interrupt Auto-Mask...upon reading ICR, interrupts are masked.  No
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4026
	 * need for the IMC write */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4027
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4028
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4029
	if (!adapter->ecdev && unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4030
		hw->get_link_status = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4031
		/* 80003ES2LAN workaround--
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4032
		 * For packet buffer work-around on link down event;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4033
		 * disable receives here in the ISR and
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4034
		 * reset adapter in watchdog
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4035
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4036
		if (netif_carrier_ok(netdev) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4037
		    (adapter->hw.mac_type == e1000_80003es2lan)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4038
			/* disable receives */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4039
			rctl = E1000_READ_REG(hw, RCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4040
			E1000_WRITE_REG(hw, RCTL, rctl & ~E1000_RCTL_EN);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4041
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4042
		/* guard against interrupt when we're going down */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4043
		if (!test_bit(__E1000_DOWN, &adapter->flags))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4044
			mod_timer(&adapter->watchdog_timer, jiffies + 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4045
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4046
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4047
	if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4048
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4049
			int ec_work_done = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4050
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4051
			for (i = 0; i < E1000_MAX_INTR; i++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4052
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4053
				if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring,
2050
a3e59f2a8589 Changed accidentally used & operator to &&.
Florian Pose <fp@igh-essen.com>
parents: 1360
diff changeset
  4054
		                    &ec_work_done, 100) &&
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4055
							!e1000_clean_tx_irq(adapter, adapter->tx_ring))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4056
#else
2050
a3e59f2a8589 Changed accidentally used & operator to &&.
Florian Pose <fp@igh-essen.com>
parents: 1360
diff changeset
  4057
				if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &&
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4058
							!e1000_clean_tx_irq(adapter, adapter->tx_ring))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4059
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4060
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4061
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4062
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4063
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4064
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4065
		if (unlikely(hw->mac_type < e1000_82571)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4066
			/* disable interrupts, without the synchronize_irq bit */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4067
			E1000_WRITE_REG(hw, IMC, ~0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4068
			E1000_WRITE_FLUSH(hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4069
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4070
		if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4071
			adapter->total_tx_bytes = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4072
			adapter->total_tx_packets = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4073
			adapter->total_rx_bytes = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4074
			adapter->total_rx_packets = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4075
			__netif_rx_schedule(netdev, &adapter->napi);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4076
		} else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4077
			/* this really should not happen! if it does it is basically a
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4078
			 * bug, but not a hard error, so enable ints and continue */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4079
			e1000_irq_enable(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4080
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4081
		/* Writing IMC and IMS is needed for 82547.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4082
		 * Due to Hub Link bus being occupied, an interrupt
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4083
		 * de-assertion message is not able to be sent.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4084
		 * When an interrupt assertion message is generated later,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4085
		 * two messages are re-ordered and sent out.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4086
		 * That causes APIC to think 82547 is in de-assertion
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4087
		 * state, while 82547 is in assertion state, resulting
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4088
		 * in dead lock. Writing IMC forces 82547 into
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4089
		 * de-assertion state.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4090
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4091
		if (hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4092
			E1000_WRITE_REG(hw, IMC, ~0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4093
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4094
		adapter->total_tx_bytes = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4095
		adapter->total_rx_bytes = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4096
		adapter->total_tx_packets = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4097
		adapter->total_rx_packets = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4098
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4099
		for (i = 0; i < E1000_MAX_INTR; i++)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4100
			if (unlikely(!adapter->clean_rx(adapter, adapter->rx_ring) &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4101
			   !e1000_clean_tx_irq(adapter, adapter->tx_ring)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4102
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4103
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4104
		if (likely(adapter->itr_setting & 3))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4105
			e1000_set_itr(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4106
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4107
		if (hw->mac_type == e1000_82547 || hw->mac_type == e1000_82547_rev_2)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4108
			e1000_irq_enable(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4109
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4110
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4111
	}
2421
bc2d4bf9cbe5 Removed trailing spaces.
Florian Pose <fp@igh-essen.com>
parents: 2050
diff changeset
  4112
1360
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4113
	return IRQ_HANDLED;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4114
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4115
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4116
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4117
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4118
 * e1000_clean - NAPI Rx polling callback
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4119
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4120
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4121
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4122
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4123
e1000_clean(struct napi_struct *napi, int budget) // EtherCAT: never called
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4124
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4125
	struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, napi);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4126
	struct net_device *poll_dev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4127
	int tx_cleaned = 0, work_done = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4128
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4129
	/* Must NOT use netdev_priv macro here. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4130
	adapter = poll_dev->priv;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4131
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4132
	/* e1000_clean is called per-cpu.  This lock protects
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4133
	 * tx_ring[0] from being cleaned by multiple cpus
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4134
	 * simultaneously.  A failure obtaining the lock means
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4135
	 * tx_ring[0] is currently being cleaned anyway. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4136
	if (spin_trylock(&adapter->tx_queue_lock)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4137
		tx_cleaned = e1000_clean_tx_irq(adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4138
						&adapter->tx_ring[0]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4139
		spin_unlock(&adapter->tx_queue_lock);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4140
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4141
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4142
	adapter->clean_rx(adapter, &adapter->rx_ring[0],
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4143
	                  &work_done, budget);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4144
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4145
	if (tx_cleaned)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4146
		work_done = budget;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4147
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4148
	/* If budget not fully consumed, exit the polling mode */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4149
	if (work_done < budget) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4150
		if (likely(adapter->itr_setting & 3))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4151
			e1000_set_itr(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4152
		netif_rx_complete(poll_dev, napi);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4153
		e1000_irq_enable(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4154
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4155
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4156
	return work_done;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4157
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4158
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4159
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4160
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4161
 * e1000_clean_tx_irq - Reclaim resources after transmit completes
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4162
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4163
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4164
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4165
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4166
e1000_clean_tx_irq(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4167
                   struct e1000_tx_ring *tx_ring)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4168
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4169
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4170
	struct e1000_tx_desc *tx_desc, *eop_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4171
	struct e1000_buffer *buffer_info;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4172
	unsigned int i, eop;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4173
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4174
	unsigned int count = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4175
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4176
	bool cleaned = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4177
	unsigned int total_tx_bytes=0, total_tx_packets=0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4178
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4179
	i = tx_ring->next_to_clean;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4180
	eop = tx_ring->buffer_info[i].next_to_watch;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4181
	eop_desc = E1000_TX_DESC(*tx_ring, eop);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4182
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4183
	while (eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4184
		for (cleaned = false; !cleaned; ) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4185
			tx_desc = E1000_TX_DESC(*tx_ring, i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4186
			buffer_info = &tx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4187
			cleaned = (i == eop);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4188
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4189
			if (cleaned) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4190
				struct sk_buff *skb = buffer_info->skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4191
				unsigned int segs, bytecount;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4192
				segs = skb_shinfo(skb)->gso_segs ?: 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4193
				/* multiply data chunks by size of headers */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4194
				bytecount = ((segs - 1) * skb_headlen(skb)) +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4195
				            skb->len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4196
				total_tx_packets += segs;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4197
				total_tx_bytes += bytecount;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4198
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4199
			e1000_unmap_and_free_tx_resource(adapter, buffer_info);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4200
			tx_desc->upper.data = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4201
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4202
			if (unlikely(++i == tx_ring->count)) i = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4203
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4204
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4205
		eop = tx_ring->buffer_info[i].next_to_watch;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4206
		eop_desc = E1000_TX_DESC(*tx_ring, eop);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4207
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4208
#define E1000_TX_WEIGHT 64
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4209
		/* weight of a sort for tx, to avoid endless transmit cleanup */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4210
		if (count++ == E1000_TX_WEIGHT) break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4211
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4212
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4213
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4214
	tx_ring->next_to_clean = i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4215
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4216
#define TX_WAKE_THRESHOLD 32
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4217
	if (!adapter->ecdev && unlikely(cleaned && netif_carrier_ok(netdev) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4218
		     E1000_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4219
		/* Make sure that anybody stopping the queue after this
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4220
		 * sees the new next_to_clean.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4221
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4222
		smp_mb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4223
		if (netif_queue_stopped(netdev)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4224
			netif_wake_queue(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4225
			++adapter->restart_queue;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4226
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4227
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4228
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4229
	if (!adapter->ecdev && adapter->detect_tx_hung) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4230
		/* Detect a transmit hang in hardware, this serializes the
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4231
		 * check with the clearing of time_stamp and movement of i */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4232
		adapter->detect_tx_hung = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4233
		if (tx_ring->buffer_info[eop].dma &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4234
		    time_after(jiffies, tx_ring->buffer_info[eop].time_stamp +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4235
		               (adapter->tx_timeout_factor * HZ))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4236
		    && !(E1000_READ_REG(&adapter->hw, STATUS) &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4237
		         E1000_STATUS_TXOFF)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4238
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4239
			/* detected Tx unit hang */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4240
			DPRINTK(DRV, ERR, "Detected Tx Unit Hang\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4241
					"  Tx Queue             <%lu>\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4242
					"  TDH                  <%x>\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4243
					"  TDT                  <%x>\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4244
					"  next_to_use          <%x>\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4245
					"  next_to_clean        <%x>\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4246
					"buffer_info[next_to_clean]\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4247
					"  time_stamp           <%lx>\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4248
					"  next_to_watch        <%x>\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4249
					"  jiffies              <%lx>\n"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4250
					"  next_to_watch.status <%x>\n",
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4251
				(unsigned long)((tx_ring - adapter->tx_ring) /
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4252
					sizeof(struct e1000_tx_ring)),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4253
				readl(adapter->hw.hw_addr + tx_ring->tdh),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4254
				readl(adapter->hw.hw_addr + tx_ring->tdt),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4255
				tx_ring->next_to_use,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4256
				tx_ring->next_to_clean,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4257
				tx_ring->buffer_info[eop].time_stamp,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4258
				eop,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4259
				jiffies,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4260
				eop_desc->upper.fields.status);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4261
			netif_stop_queue(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4262
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4263
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4264
	adapter->total_tx_bytes += total_tx_bytes;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4265
	adapter->total_tx_packets += total_tx_packets;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4266
	adapter->net_stats.tx_bytes += total_tx_bytes;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4267
	adapter->net_stats.tx_packets += total_tx_packets;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4268
	return cleaned;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4269
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4270
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4271
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4272
 * e1000_rx_checksum - Receive Checksum Offload for 82543
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4273
 * @adapter:     board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4274
 * @status_err:  receive descriptor status and error fields
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4275
 * @csum:        receive descriptor csum field
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4276
 * @sk_buff:     socket buffer with received data
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4277
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4278
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4279
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4280
e1000_rx_checksum(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4281
		  u32 status_err, u32 csum,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4282
		  struct sk_buff *skb)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4283
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4284
	u16 status = (u16)status_err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4285
	u8 errors = (u8)(status_err >> 24);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4286
	skb->ip_summed = CHECKSUM_NONE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4287
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4288
	/* 82543 or newer only */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4289
	if (unlikely(adapter->hw.mac_type < e1000_82543)) return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4290
	/* Ignore Checksum bit is set */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4291
	if (unlikely(status & E1000_RXD_STAT_IXSM)) return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4292
	/* TCP/UDP checksum error bit is set */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4293
	if (unlikely(errors & E1000_RXD_ERR_TCPE)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4294
		/* let the stack verify checksum errors */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4295
		adapter->hw_csum_err++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4296
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4297
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4298
	/* TCP/UDP Checksum has not been calculated */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4299
	if (adapter->hw.mac_type <= e1000_82547_rev_2) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4300
		if (!(status & E1000_RXD_STAT_TCPCS))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4301
			return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4302
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4303
		if (!(status & (E1000_RXD_STAT_TCPCS | E1000_RXD_STAT_UDPCS)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4304
			return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4305
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4306
	/* It must be a TCP or UDP packet with a valid checksum */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4307
	if (likely(status & E1000_RXD_STAT_TCPCS)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4308
		/* TCP checksum is good */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4309
		skb->ip_summed = CHECKSUM_UNNECESSARY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4310
	} else if (adapter->hw.mac_type > e1000_82547_rev_2) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4311
		/* IP fragment with UDP payload */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4312
		/* Hardware complements the payload checksum, so we undo it
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4313
		 * and then put the value in host order for further stack use.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4314
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4315
		__sum16 sum = (__force __sum16)htons(csum);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4316
		skb->csum = csum_unfold(~sum);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4317
		skb->ip_summed = CHECKSUM_COMPLETE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4318
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4319
	adapter->hw_csum_good++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4320
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4321
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4322
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4323
 * e1000_clean_rx_irq - Send received data up the network stack; legacy
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4324
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4325
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4326
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4327
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4328
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4329
e1000_clean_rx_irq(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4330
                   struct e1000_rx_ring *rx_ring,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4331
                   int *work_done, int work_to_do)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4332
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4333
e1000_clean_rx_irq(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4334
                   struct e1000_rx_ring *rx_ring)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4335
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4336
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4337
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4338
	struct pci_dev *pdev = adapter->pdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4339
	struct e1000_rx_desc *rx_desc, *next_rxd;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4340
	struct e1000_buffer *buffer_info, *next_buffer;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4341
	unsigned long flags;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4342
	u32 length;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4343
	u8 last_byte;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4344
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4345
	int cleaned_count = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4346
	bool cleaned = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4347
	unsigned int total_rx_bytes=0, total_rx_packets=0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4348
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4349
	i = rx_ring->next_to_clean;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4350
	rx_desc = E1000_RX_DESC(*rx_ring, i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4351
	buffer_info = &rx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4352
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4353
	while (rx_desc->status & E1000_RXD_STAT_DD) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4354
		struct sk_buff *skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4355
		u8 status;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4356
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4357
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4358
		if (*work_done >= work_to_do)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4359
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4360
		(*work_done)++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4361
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4362
		status = rx_desc->status;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4363
		skb = buffer_info->skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4364
		if (!adapter->ecdev) buffer_info->skb = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4365
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4366
		prefetch(skb->data - NET_IP_ALIGN);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4367
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4368
		if (++i == rx_ring->count) i = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4369
		next_rxd = E1000_RX_DESC(*rx_ring, i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4370
		prefetch(next_rxd);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4371
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4372
		next_buffer = &rx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4373
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4374
		cleaned = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4375
		cleaned_count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4376
		pci_unmap_single(pdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4377
		                 buffer_info->dma,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4378
		                 buffer_info->length,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4379
		                 PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4380
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4381
		length = le16_to_cpu(rx_desc->length);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4382
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4383
		if (unlikely(!(status & E1000_RXD_STAT_EOP))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4384
			/* All receives must fit into a single buffer */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4385
			E1000_DBG("%s: Receive packet consumed multiple"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4386
				  " buffers\n", netdev->name);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4387
			/* recycle */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4388
			buffer_info->skb = skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4389
			goto next_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4390
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4391
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4392
		if (!adapter->ecdev &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4393
                unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4394
			last_byte = *(skb->data + length - 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4395
			if (TBI_ACCEPT(&adapter->hw, status,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4396
			              rx_desc->errors, length, last_byte)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4397
				spin_lock_irqsave(&adapter->stats_lock, flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4398
				e1000_tbi_adjust_stats(&adapter->hw,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4399
				                       &adapter->stats,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4400
				                       length, skb->data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4401
				spin_unlock_irqrestore(&adapter->stats_lock,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4402
				                       flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4403
				length--;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4404
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4405
				/* recycle */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4406
				buffer_info->skb = skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4407
				goto next_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4408
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4409
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4410
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4411
		/* adjust length to remove Ethernet CRC, this must be
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4412
		 * done after the TBI_ACCEPT workaround above */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4413
		length -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4414
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4415
		/* probably a little skewed due to removing CRC */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4416
		total_rx_bytes += length;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4417
		total_rx_packets++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4418
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4419
		/* code added for copybreak, this should improve
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4420
		 * performance for small packets with large amounts
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4421
		 * of reassembly being done in the stack */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4422
		if (!adapter->ecdev && length < copybreak) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4423
			struct sk_buff *new_skb =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4424
			    netdev_alloc_skb(netdev, length + NET_IP_ALIGN);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4425
			if (new_skb) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4426
				skb_reserve(new_skb, NET_IP_ALIGN);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4427
				skb_copy_to_linear_data_offset(new_skb,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4428
							       -NET_IP_ALIGN,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4429
							       (skb->data -
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4430
							        NET_IP_ALIGN),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4431
							       (length +
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4432
							        NET_IP_ALIGN));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4433
				/* save the skb in buffer_info as good */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4434
				buffer_info->skb = skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4435
				skb = new_skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4436
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4437
			/* else just continue with the old one */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4438
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4439
		/* end copybreak code */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4440
		skb_put(skb, length);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4441
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4442
		/* Receive Checksum Offload */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4443
		e1000_rx_checksum(adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4444
				  (u32)(status) |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4445
				  ((u32)(rx_desc->errors) << 24),
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4446
				  le16_to_cpu(rx_desc->csum), skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4447
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4448
		if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4449
			ecdev_receive(adapter->ecdev, skb->data, length);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4450
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4451
			// No need to detect link status as
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4452
			// long as frames are received: Reset watchdog.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4453
			adapter->ec_watchdog_jiffies = jiffies;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4454
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4455
			skb->protocol = eth_type_trans(skb, netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4456
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4457
			if (unlikely(adapter->vlgrp &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4458
			   	 (status & E1000_RXD_STAT_VP))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4459
				vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4460
							 le16_to_cpu(rx_desc->special) &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4461
							 E1000_RXD_SPC_VLAN_MASK);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4462
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4463
				netif_receive_skb(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4464
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4465
#else /* CONFIG_E1000_NAPI */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4466
			if (unlikely(adapter->vlgrp &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4467
				    (status & E1000_RXD_STAT_VP))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4468
				vlan_hwaccel_rx(skb, adapter->vlgrp,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4469
						le16_to_cpu(rx_desc->special) &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4470
						E1000_RXD_SPC_VLAN_MASK);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4471
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4472
				netif_rx(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4473
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4474
#endif /* CONFIG_E1000_NAPI */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4475
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4476
		netdev->last_rx = jiffies;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4477
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4478
next_desc:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4479
		rx_desc->status = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4480
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4481
		/* return some buffers to hardware, one at a time is too slow */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4482
		if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4483
			adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4484
			cleaned_count = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4485
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4486
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4487
		/* use prefetched values */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4488
		rx_desc = next_rxd;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4489
		buffer_info = next_buffer;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4490
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4491
	rx_ring->next_to_clean = i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4492
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4493
	cleaned_count = E1000_DESC_UNUSED(rx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4494
	if (cleaned_count)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4495
		adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4496
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4497
	adapter->total_rx_packets += total_rx_packets;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4498
	adapter->total_rx_bytes += total_rx_bytes;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4499
	adapter->net_stats.rx_bytes += total_rx_bytes;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4500
	adapter->net_stats.rx_packets += total_rx_packets;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4501
	return cleaned;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4502
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4503
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4504
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4505
 * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4506
 * @adapter: board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4507
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4508
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4509
static bool
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4510
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4511
e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4512
                      struct e1000_rx_ring *rx_ring,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4513
                      int *work_done, int work_to_do)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4514
#else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4515
e1000_clean_rx_irq_ps(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4516
                      struct e1000_rx_ring *rx_ring)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4517
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4518
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4519
	union e1000_rx_desc_packet_split *rx_desc, *next_rxd;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4520
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4521
	struct pci_dev *pdev = adapter->pdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4522
	struct e1000_buffer *buffer_info, *next_buffer;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4523
	struct e1000_ps_page *ps_page;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4524
	struct e1000_ps_page_dma *ps_page_dma;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4525
	struct sk_buff *skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4526
	unsigned int i, j;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4527
	u32 length, staterr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4528
	int cleaned_count = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4529
	bool cleaned = false;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4530
	unsigned int total_rx_bytes=0, total_rx_packets=0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4531
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4532
	i = rx_ring->next_to_clean;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4533
	rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4534
	staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4535
	buffer_info = &rx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4536
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4537
	while (staterr & E1000_RXD_STAT_DD) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4538
		ps_page = &rx_ring->ps_page[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4539
		ps_page_dma = &rx_ring->ps_page_dma[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4540
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4541
		if (unlikely(*work_done >= work_to_do))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4542
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4543
		(*work_done)++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4544
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4545
		skb = buffer_info->skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4546
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4547
		/* in the packet split case this is header only */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4548
		prefetch(skb->data - NET_IP_ALIGN);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4549
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4550
		if (++i == rx_ring->count) i = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4551
		next_rxd = E1000_RX_DESC_PS(*rx_ring, i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4552
		prefetch(next_rxd);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4553
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4554
		next_buffer = &rx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4555
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4556
		cleaned = true;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4557
		cleaned_count++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4558
		pci_unmap_single(pdev, buffer_info->dma,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4559
				 buffer_info->length,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4560
				 PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4561
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4562
		if (unlikely(!(staterr & E1000_RXD_STAT_EOP))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4563
			E1000_DBG("%s: Packet Split buffers didn't pick up"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4564
				  " the full packet\n", netdev->name);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4565
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4566
			goto next_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4567
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4568
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4569
		if (unlikely(staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4570
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4571
			goto next_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4572
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4573
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4574
		length = le16_to_cpu(rx_desc->wb.middle.length0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4575
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4576
		if (unlikely(!length)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4577
			E1000_DBG("%s: Last part of the packet spanning"
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4578
				  " multiple descriptors\n", netdev->name);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4579
			if (!adapter->ecdev) dev_kfree_skb_irq(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4580
			goto next_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4581
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4582
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4583
		/* Good Receive */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4584
		skb_put(skb, length);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4585
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4586
		{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4587
		/* this looks ugly, but it seems compiler issues make it
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4588
		   more efficient than reusing j */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4589
		int l1 = le16_to_cpu(rx_desc->wb.upper.length[0]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4590
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4591
		/* page alloc/put takes too long and effects small packet
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4592
		 * throughput, so unsplit small packets and save the alloc/put*/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4593
		if (l1 && (l1 <= copybreak) && ((length + l1) <= adapter->rx_ps_bsize0)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4594
			u8 *vaddr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4595
			/* there is no documentation about how to call
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4596
			 * kmap_atomic, so we can't hold the mapping
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4597
			 * very long */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4598
			pci_dma_sync_single_for_cpu(pdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4599
				ps_page_dma->ps_page_dma[0],
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4600
				PAGE_SIZE,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4601
				PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4602
			vaddr = kmap_atomic(ps_page->ps_page[0],
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4603
			                    KM_SKB_DATA_SOFTIRQ);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4604
			memcpy(skb_tail_pointer(skb), vaddr, l1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4605
			kunmap_atomic(vaddr, KM_SKB_DATA_SOFTIRQ);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4606
			pci_dma_sync_single_for_device(pdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4607
				ps_page_dma->ps_page_dma[0],
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4608
				PAGE_SIZE, PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4609
			/* remove the CRC */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4610
			l1 -= 4;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4611
			skb_put(skb, l1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4612
			goto copydone;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4613
		} /* if */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4614
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4615
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4616
		for (j = 0; j < adapter->rx_ps_pages; j++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4617
			if (!(length= le16_to_cpu(rx_desc->wb.upper.length[j])))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4618
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4619
			pci_unmap_page(pdev, ps_page_dma->ps_page_dma[j],
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4620
					PAGE_SIZE, PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4621
			ps_page_dma->ps_page_dma[j] = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4622
			skb_fill_page_desc(skb, j, ps_page->ps_page[j], 0,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4623
			                   length);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4624
			ps_page->ps_page[j] = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4625
			skb->len += length;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4626
			skb->data_len += length;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4627
			skb->truesize += length;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4628
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4629
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4630
		/* strip the ethernet crc, problem is we're using pages now so
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4631
		 * this whole operation can get a little cpu intensive */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4632
		pskb_trim(skb, skb->len - 4);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4633
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4634
copydone:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4635
		total_rx_bytes += skb->len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4636
		total_rx_packets++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4637
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4638
		e1000_rx_checksum(adapter, staterr,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4639
				  le16_to_cpu(rx_desc->wb.lower.hi_dword.csum_ip.csum), skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4640
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4641
		if (likely(rx_desc->wb.upper.header_status &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4642
			   cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4643
			adapter->rx_hdr_split++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4644
		if (adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4645
			ecdev_receive(adapter->ecdev, skb->data, length);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4646
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4647
			skb->protocol = eth_type_trans(skb, netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4648
#ifdef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4649
			if (unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4650
				vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4651
					le16_to_cpu(rx_desc->wb.middle.vlan) &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4652
					E1000_RXD_SPC_VLAN_MASK);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4653
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4654
				netif_receive_skb(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4655
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4656
#else /* CONFIG_E1000_NAPI */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4657
			if (unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4658
				vlan_hwaccel_rx(skb, adapter->vlgrp,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4659
					le16_to_cpu(rx_desc->wb.middle.vlan) &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4660
					E1000_RXD_SPC_VLAN_MASK);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4661
			} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4662
				netif_rx(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4663
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4664
#endif /* CONFIG_E1000_NAPI */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4665
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4666
		netdev->last_rx = jiffies;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4667
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4668
next_desc:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4669
		rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4670
		if (!adapter->ecdev) buffer_info->skb = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4671
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4672
		/* return some buffers to hardware, one at a time is too slow */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4673
		if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4674
			adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4675
			cleaned_count = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4676
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4677
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4678
		/* use prefetched values */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4679
		rx_desc = next_rxd;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4680
		buffer_info = next_buffer;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4681
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4682
		staterr = le32_to_cpu(rx_desc->wb.middle.status_error);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4683
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4684
	rx_ring->next_to_clean = i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4685
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4686
	cleaned_count = E1000_DESC_UNUSED(rx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4687
	if (cleaned_count)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4688
		adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4689
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4690
	adapter->total_rx_packets += total_rx_packets;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4691
	adapter->total_rx_bytes += total_rx_bytes;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4692
	adapter->net_stats.rx_bytes += total_rx_bytes;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4693
	adapter->net_stats.rx_packets += total_rx_packets;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4694
	return cleaned;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4695
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4696
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4697
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4698
 * e1000_alloc_rx_buffers - Replace used receive buffers; legacy & extended
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4699
 * @adapter: address of board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4700
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4701
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4702
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4703
e1000_alloc_rx_buffers(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4704
                       struct e1000_rx_ring *rx_ring,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4705
		       int cleaned_count)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4706
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4707
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4708
	struct pci_dev *pdev = adapter->pdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4709
	struct e1000_rx_desc *rx_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4710
	struct e1000_buffer *buffer_info;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4711
	struct sk_buff *skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4712
	unsigned int i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4713
	unsigned int bufsz = adapter->rx_buffer_len + NET_IP_ALIGN;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4714
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4715
	i = rx_ring->next_to_use;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4716
	buffer_info = &rx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4717
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4718
	while (cleaned_count--) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4719
		skb = buffer_info->skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4720
		if (skb) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4721
			skb_trim(skb, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4722
			goto map_skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4723
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4724
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4725
		skb = netdev_alloc_skb(netdev, bufsz);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4726
		if (unlikely(!skb)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4727
			/* Better luck next round */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4728
			adapter->alloc_rx_buff_failed++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4729
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4730
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4731
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4732
		/* Fix for errata 23, can't cross 64kB boundary */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4733
		if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4734
			struct sk_buff *oldskb = skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4735
			DPRINTK(RX_ERR, ERR, "skb align check failed: %u bytes "
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4736
					     "at %p\n", bufsz, skb->data);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4737
			/* Try again, without freeing the previous */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4738
			skb = netdev_alloc_skb(netdev, bufsz);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4739
			/* Failed allocation, critical failure */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4740
			if (!skb) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4741
				dev_kfree_skb(oldskb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4742
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4743
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4744
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4745
			if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4746
				/* give up */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4747
				dev_kfree_skb(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4748
				dev_kfree_skb(oldskb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4749
				break; /* while !buffer_info->skb */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4750
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4751
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4752
			/* Use new allocation */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4753
			dev_kfree_skb(oldskb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4754
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4755
		/* Make buffer alignment 2 beyond a 16 byte boundary
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4756
		 * this will result in a 16 byte aligned IP header after
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4757
		 * the 14 byte MAC header is removed
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4758
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4759
		skb_reserve(skb, NET_IP_ALIGN);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4760
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4761
		buffer_info->skb = skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4762
		buffer_info->length = adapter->rx_buffer_len;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4763
map_skb:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4764
		buffer_info->dma = pci_map_single(pdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4765
						  skb->data,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4766
						  adapter->rx_buffer_len,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4767
						  PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4768
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4769
		/* Fix for errata 23, can't cross 64kB boundary */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4770
		if (!e1000_check_64k_bound(adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4771
					(void *)(unsigned long)buffer_info->dma,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4772
					adapter->rx_buffer_len)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4773
			DPRINTK(RX_ERR, ERR,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4774
				"dma align check failed: %u bytes at %p\n",
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4775
				adapter->rx_buffer_len,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4776
				(void *)(unsigned long)buffer_info->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4777
			if (!adapter->ecdev) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4778
				dev_kfree_skb(skb);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4779
				buffer_info->skb = NULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4780
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4781
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4782
			pci_unmap_single(pdev, buffer_info->dma,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4783
					 adapter->rx_buffer_len,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4784
					 PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4785
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4786
			break; /* while !buffer_info->skb */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4787
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4788
		rx_desc = E1000_RX_DESC(*rx_ring, i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4789
		rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4790
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4791
		if (unlikely(++i == rx_ring->count))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4792
			i = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4793
		buffer_info = &rx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4794
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4795
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4796
	if (likely(rx_ring->next_to_use != i)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4797
		rx_ring->next_to_use = i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4798
		if (unlikely(i-- == 0))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4799
			i = (rx_ring->count - 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4800
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4801
		/* Force memory writes to complete before letting h/w
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4802
		 * know there are new descriptors to fetch.  (Only
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4803
		 * applicable for weak-ordered memory model archs,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4804
		 * such as IA-64). */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4805
		wmb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4806
		writel(i, adapter->hw.hw_addr + rx_ring->rdt);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4807
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4808
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4809
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4810
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4811
 * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4812
 * @adapter: address of board private structure
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4813
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4814
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4815
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4816
e1000_alloc_rx_buffers_ps(struct e1000_adapter *adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4817
                          struct e1000_rx_ring *rx_ring,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4818
			  int cleaned_count)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4819
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4820
	struct net_device *netdev = adapter->netdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4821
	struct pci_dev *pdev = adapter->pdev;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4822
	union e1000_rx_desc_packet_split *rx_desc;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4823
	struct e1000_buffer *buffer_info;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4824
	struct e1000_ps_page *ps_page;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4825
	struct e1000_ps_page_dma *ps_page_dma;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4826
	struct sk_buff *skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4827
	unsigned int i, j;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4828
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4829
	i = rx_ring->next_to_use;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4830
	buffer_info = &rx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4831
	ps_page = &rx_ring->ps_page[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4832
	ps_page_dma = &rx_ring->ps_page_dma[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4833
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4834
	while (cleaned_count--) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4835
		rx_desc = E1000_RX_DESC_PS(*rx_ring, i);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4836
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4837
		for (j = 0; j < PS_PAGE_BUFFERS; j++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4838
			if (j < adapter->rx_ps_pages) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4839
				if (likely(!ps_page->ps_page[j])) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4840
					ps_page->ps_page[j] =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4841
						alloc_page(GFP_ATOMIC);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4842
					if (unlikely(!ps_page->ps_page[j])) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4843
						adapter->alloc_rx_buff_failed++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4844
						goto no_buffers;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4845
					}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4846
					ps_page_dma->ps_page_dma[j] =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4847
						pci_map_page(pdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4848
							    ps_page->ps_page[j],
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4849
							    0, PAGE_SIZE,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4850
							    PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4851
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4852
				/* Refresh the desc even if buffer_addrs didn't
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4853
				 * change because each write-back erases
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4854
				 * this info.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4855
				 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4856
				rx_desc->read.buffer_addr[j+1] =
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4857
				     cpu_to_le64(ps_page_dma->ps_page_dma[j]);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4858
			} else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4859
				rx_desc->read.buffer_addr[j+1] = ~cpu_to_le64(0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4860
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4861
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4862
		skb = netdev_alloc_skb(netdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4863
		                       adapter->rx_ps_bsize0 + NET_IP_ALIGN);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4864
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4865
		if (unlikely(!skb)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4866
			adapter->alloc_rx_buff_failed++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4867
			break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4868
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4869
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4870
		/* Make buffer alignment 2 beyond a 16 byte boundary
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4871
		 * this will result in a 16 byte aligned IP header after
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4872
		 * the 14 byte MAC header is removed
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4873
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4874
		skb_reserve(skb, NET_IP_ALIGN);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4875
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4876
		buffer_info->skb = skb;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4877
		buffer_info->length = adapter->rx_ps_bsize0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4878
		buffer_info->dma = pci_map_single(pdev, skb->data,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4879
						  adapter->rx_ps_bsize0,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4880
						  PCI_DMA_FROMDEVICE);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4881
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4882
		rx_desc->read.buffer_addr[0] = cpu_to_le64(buffer_info->dma);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4883
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4884
		if (unlikely(++i == rx_ring->count)) i = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4885
		buffer_info = &rx_ring->buffer_info[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4886
		ps_page = &rx_ring->ps_page[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4887
		ps_page_dma = &rx_ring->ps_page_dma[i];
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4888
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4889
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4890
no_buffers:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4891
	if (likely(rx_ring->next_to_use != i)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4892
		rx_ring->next_to_use = i;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4893
		if (unlikely(i-- == 0)) i = (rx_ring->count - 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4894
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4895
		/* Force memory writes to complete before letting h/w
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4896
		 * know there are new descriptors to fetch.  (Only
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4897
		 * applicable for weak-ordered memory model archs,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4898
		 * such as IA-64). */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4899
		wmb();
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4900
		/* Hardware increments by 16 bytes, but packet split
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4901
		 * descriptors are 32 bytes...so we increment tail
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4902
		 * twice as much.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4903
		 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4904
		writel(i<<1, adapter->hw.hw_addr + rx_ring->rdt);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4905
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4906
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4907
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4908
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4909
 * e1000_smartspeed - Workaround for SmartSpeed on 82541 and 82547 controllers.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4910
 * @adapter:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4911
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4912
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4913
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4914
e1000_smartspeed(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4915
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4916
	u16 phy_status;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4917
	u16 phy_ctrl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4918
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4919
	if ((adapter->hw.phy_type != e1000_phy_igp) || !adapter->hw.autoneg ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4920
	   !(adapter->hw.autoneg_advertised & ADVERTISE_1000_FULL))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4921
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4922
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4923
	if (adapter->smartspeed == 0) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4924
		/* If Master/Slave config fault is asserted twice,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4925
		 * we assume back-to-back */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4926
		e1000_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4927
		if (!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4928
		e1000_read_phy_reg(&adapter->hw, PHY_1000T_STATUS, &phy_status);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4929
		if (!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4930
		e1000_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4931
		if (phy_ctrl & CR_1000T_MS_ENABLE) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4932
			phy_ctrl &= ~CR_1000T_MS_ENABLE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4933
			e1000_write_phy_reg(&adapter->hw, PHY_1000T_CTRL,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4934
					    phy_ctrl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4935
			adapter->smartspeed++;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4936
			if (!e1000_phy_setup_autoneg(&adapter->hw) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4937
			   !e1000_read_phy_reg(&adapter->hw, PHY_CTRL,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4938
				   	       &phy_ctrl)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4939
				phy_ctrl |= (MII_CR_AUTO_NEG_EN |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4940
					     MII_CR_RESTART_AUTO_NEG);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4941
				e1000_write_phy_reg(&adapter->hw, PHY_CTRL,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4942
						    phy_ctrl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4943
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4944
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4945
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4946
	} else if (adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4947
		/* If still no link, perhaps using 2/3 pair cable */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4948
		e1000_read_phy_reg(&adapter->hw, PHY_1000T_CTRL, &phy_ctrl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4949
		phy_ctrl |= CR_1000T_MS_ENABLE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4950
		e1000_write_phy_reg(&adapter->hw, PHY_1000T_CTRL, phy_ctrl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4951
		if (!e1000_phy_setup_autoneg(&adapter->hw) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4952
		   !e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_ctrl)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4953
			phy_ctrl |= (MII_CR_AUTO_NEG_EN |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4954
				     MII_CR_RESTART_AUTO_NEG);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4955
			e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_ctrl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4956
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4957
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4958
	/* Restart process after E1000_SMARTSPEED_MAX iterations */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4959
	if (adapter->smartspeed++ == E1000_SMARTSPEED_MAX)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4960
		adapter->smartspeed = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4961
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4962
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4963
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4964
 * e1000_ioctl -
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4965
 * @netdev:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4966
 * @ifreq:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4967
 * @cmd:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4968
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4969
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4970
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4971
e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4972
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4973
	switch (cmd) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4974
	case SIOCGMIIPHY:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4975
	case SIOCGMIIREG:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4976
	case SIOCSMIIREG:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4977
		return e1000_mii_ioctl(netdev, ifr, cmd);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4978
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4979
		return -EOPNOTSUPP;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4980
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4981
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4982
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4983
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4984
 * e1000_mii_ioctl -
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4985
 * @netdev:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4986
 * @ifreq:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4987
 * @cmd:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4988
 **/
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4989
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4990
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4991
e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4992
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4993
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4994
	struct mii_ioctl_data *data = if_mii(ifr);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4995
	int retval;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4996
	u16 mii_reg;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4997
	u16 spddplx;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4998
	unsigned long flags;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  4999
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5000
	if (adapter->hw.media_type != e1000_media_type_copper)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5001
		return -EOPNOTSUPP;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5002
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5003
	switch (cmd) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5004
	case SIOCGMIIPHY:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5005
		data->phy_id = adapter->hw.phy_addr;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5006
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5007
	case SIOCGMIIREG:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5008
		if (adapter->ecdev || !capable(CAP_NET_ADMIN))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5009
			return -EPERM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5010
		spin_lock_irqsave(&adapter->stats_lock, flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5011
		if (e1000_read_phy_reg(&adapter->hw, data->reg_num & 0x1F,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5012
				   &data->val_out)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5013
			spin_unlock_irqrestore(&adapter->stats_lock, flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5014
			return -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5015
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5016
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5017
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5018
	case SIOCSMIIREG:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5019
		if (adapter->ecdev || !capable(CAP_NET_ADMIN))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5020
			return -EPERM;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5021
		if (data->reg_num & ~(0x1F))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5022
			return -EFAULT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5023
		mii_reg = data->val_in;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5024
		spin_lock_irqsave(&adapter->stats_lock, flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5025
		if (e1000_write_phy_reg(&adapter->hw, data->reg_num,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5026
					mii_reg)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5027
			spin_unlock_irqrestore(&adapter->stats_lock, flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5028
			return -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5029
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5030
		spin_unlock_irqrestore(&adapter->stats_lock, flags);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5031
		if (adapter->hw.media_type == e1000_media_type_copper) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5032
			switch (data->reg_num) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5033
			case PHY_CTRL:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5034
				if (mii_reg & MII_CR_POWER_DOWN)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5035
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5036
				if (mii_reg & MII_CR_AUTO_NEG_EN) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5037
					adapter->hw.autoneg = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5038
					adapter->hw.autoneg_advertised = 0x2F;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5039
				} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5040
					if (mii_reg & 0x40)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5041
						spddplx = SPEED_1000;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5042
					else if (mii_reg & 0x2000)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5043
						spddplx = SPEED_100;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5044
					else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5045
						spddplx = SPEED_10;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5046
					spddplx += (mii_reg & 0x100)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5047
						   ? DUPLEX_FULL :
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5048
						   DUPLEX_HALF;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5049
					retval = e1000_set_spd_dplx(adapter,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5050
								    spddplx);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5051
					if (retval)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5052
						return retval;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5053
				}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5054
				if (netif_running(adapter->netdev))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5055
					e1000_reinit_locked(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5056
				else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5057
					e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5058
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5059
			case M88E1000_PHY_SPEC_CTRL:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5060
			case M88E1000_EXT_PHY_SPEC_CTRL:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5061
				if (e1000_phy_reset(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5062
					return -EIO;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5063
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5064
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5065
		} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5066
			switch (data->reg_num) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5067
			case PHY_CTRL:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5068
				if (mii_reg & MII_CR_POWER_DOWN)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5069
					break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5070
				if (netif_running(adapter->netdev))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5071
					e1000_reinit_locked(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5072
				else
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5073
					e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5074
				break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5075
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5076
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5077
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5078
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5079
		return -EOPNOTSUPP;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5080
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5081
	return E1000_SUCCESS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5082
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5083
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5084
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5085
e1000_pci_set_mwi(struct e1000_hw *hw)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5086
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5087
	struct e1000_adapter *adapter = hw->back;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5088
	int ret_val = pci_set_mwi(adapter->pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5089
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5090
	if (ret_val)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5091
		DPRINTK(PROBE, ERR, "Error in setting MWI\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5092
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5093
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5094
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5095
e1000_pci_clear_mwi(struct e1000_hw *hw)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5096
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5097
	struct e1000_adapter *adapter = hw->back;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5098
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5099
	pci_clear_mwi(adapter->pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5100
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5101
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5102
int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5103
e1000_pcix_get_mmrbc(struct e1000_hw *hw)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5104
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5105
	struct e1000_adapter *adapter = hw->back;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5106
	return pcix_get_mmrbc(adapter->pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5107
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5108
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5109
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5110
e1000_pcix_set_mmrbc(struct e1000_hw *hw, int mmrbc)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5111
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5112
	struct e1000_adapter *adapter = hw->back;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5113
	pcix_set_mmrbc(adapter->pdev, mmrbc);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5114
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5115
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5116
s32
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5117
e1000_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5118
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5119
    struct e1000_adapter *adapter = hw->back;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5120
    u16 cap_offset;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5121
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5122
    cap_offset = pci_find_capability(adapter->pdev, PCI_CAP_ID_EXP);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5123
    if (!cap_offset)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5124
        return -E1000_ERR_CONFIG;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5125
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5126
    pci_read_config_word(adapter->pdev, cap_offset + reg, value);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5127
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5128
    return E1000_SUCCESS;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5129
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5130
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5131
void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5132
e1000_io_write(struct e1000_hw *hw, unsigned long port, u32 value)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5133
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5134
	outl(value, port);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5135
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5136
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5137
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5138
e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5139
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5140
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5141
	u32 ctrl, rctl;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5142
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5143
	if (!test_bit(__E1000_DOWN, &adapter->flags))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5144
		e1000_irq_disable(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5145
	adapter->vlgrp = grp;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5146
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5147
	if (grp) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5148
		/* enable VLAN tag insert/strip */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5149
		ctrl = E1000_READ_REG(&adapter->hw, CTRL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5150
		ctrl |= E1000_CTRL_VME;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5151
		E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5152
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5153
		if (adapter->hw.mac_type != e1000_ich8lan) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5154
			/* enable VLAN receive filtering */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5155
			rctl = E1000_READ_REG(&adapter->hw, RCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5156
			rctl |= E1000_RCTL_VFE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5157
			rctl &= ~E1000_RCTL_CFIEN;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5158
			E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5159
			e1000_update_mng_vlan(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5160
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5161
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5162
		/* disable VLAN tag insert/strip */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5163
		ctrl = E1000_READ_REG(&adapter->hw, CTRL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5164
		ctrl &= ~E1000_CTRL_VME;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5165
		E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5166
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5167
		if (adapter->hw.mac_type != e1000_ich8lan) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5168
			/* disable VLAN filtering */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5169
			rctl = E1000_READ_REG(&adapter->hw, RCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5170
			rctl &= ~E1000_RCTL_VFE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5171
			E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5172
			if (adapter->mng_vlan_id !=
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5173
			    (u16)E1000_MNG_VLAN_NONE) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5174
				e1000_vlan_rx_kill_vid(netdev,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5175
				                       adapter->mng_vlan_id);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5176
				adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5177
			}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5178
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5179
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5180
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5181
	if (!test_bit(__E1000_DOWN, &adapter->flags))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5182
		e1000_irq_enable(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5183
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5184
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5185
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5186
e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5187
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5188
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5189
	u32 vfta, index;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5190
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5191
	if ((adapter->hw.mng_cookie.status &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5192
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5193
	    (vid == adapter->mng_vlan_id))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5194
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5195
	/* add VID to filter table */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5196
	index = (vid >> 5) & 0x7F;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5197
	vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5198
	vfta |= (1 << (vid & 0x1F));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5199
	e1000_write_vfta(&adapter->hw, index, vfta);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5200
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5201
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5202
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5203
e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5204
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5205
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5206
	u32 vfta, index;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5207
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5208
	if (!test_bit(__E1000_DOWN, &adapter->flags))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5209
		e1000_irq_disable(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5210
	vlan_group_set_device(adapter->vlgrp, vid, NULL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5211
	if (!test_bit(__E1000_DOWN, &adapter->flags))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5212
		e1000_irq_enable(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5213
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5214
	if ((adapter->hw.mng_cookie.status &
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5215
	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5216
	    (vid == adapter->mng_vlan_id)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5217
		/* release control to f/w */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5218
		e1000_release_hw_control(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5219
		return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5220
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5221
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5222
	/* remove VID from filter table */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5223
	index = (vid >> 5) & 0x7F;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5224
	vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5225
	vfta &= ~(1 << (vid & 0x1F));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5226
	e1000_write_vfta(&adapter->hw, index, vfta);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5227
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5228
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5229
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5230
e1000_restore_vlan(struct e1000_adapter *adapter)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5231
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5232
	e1000_vlan_rx_register(adapter->netdev, adapter->vlgrp);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5233
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5234
	if (adapter->vlgrp) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5235
		u16 vid;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5236
		for (vid = 0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5237
			if (!vlan_group_get_device(adapter->vlgrp, vid))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5238
				continue;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5239
			e1000_vlan_rx_add_vid(adapter->netdev, vid);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5240
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5241
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5242
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5243
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5244
int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5245
e1000_set_spd_dplx(struct e1000_adapter *adapter, u16 spddplx)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5246
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5247
	adapter->hw.autoneg = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5248
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5249
	/* Fiber NICs only allow 1000 gbps Full duplex */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5250
	if ((adapter->hw.media_type == e1000_media_type_fiber) &&
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5251
		spddplx != (SPEED_1000 + DUPLEX_FULL)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5252
		DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5253
		return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5254
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5255
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5256
	switch (spddplx) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5257
	case SPEED_10 + DUPLEX_HALF:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5258
		adapter->hw.forced_speed_duplex = e1000_10_half;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5259
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5260
	case SPEED_10 + DUPLEX_FULL:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5261
		adapter->hw.forced_speed_duplex = e1000_10_full;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5262
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5263
	case SPEED_100 + DUPLEX_HALF:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5264
		adapter->hw.forced_speed_duplex = e1000_100_half;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5265
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5266
	case SPEED_100 + DUPLEX_FULL:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5267
		adapter->hw.forced_speed_duplex = e1000_100_full;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5268
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5269
	case SPEED_1000 + DUPLEX_FULL:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5270
		adapter->hw.autoneg = 1;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5271
		adapter->hw.autoneg_advertised = ADVERTISE_1000_FULL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5272
		break;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5273
	case SPEED_1000 + DUPLEX_HALF: /* not supported */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5274
	default:
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5275
		DPRINTK(PROBE, ERR, "Unsupported Speed/Duplex configuration\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5276
		return -EINVAL;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5277
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5278
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5279
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5280
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5281
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5282
e1000_suspend(struct pci_dev *pdev, pm_message_t state)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5283
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5284
	struct net_device *netdev = pci_get_drvdata(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5285
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5286
	u32 ctrl, ctrl_ext, rctl, status;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5287
	u32 wufc = adapter->wol;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5288
#ifdef CONFIG_PM
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5289
	int retval = 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5290
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5291
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5292
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5293
		return -EBUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5294
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5295
	netif_device_detach(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5296
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5297
	if (netif_running(netdev)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5298
		WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5299
		e1000_down(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5300
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5301
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5302
#ifdef CONFIG_PM
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5303
	retval = pci_save_state(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5304
	if (retval)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5305
		return retval;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5306
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5307
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5308
	status = E1000_READ_REG(&adapter->hw, STATUS);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5309
	if (status & E1000_STATUS_LU)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5310
		wufc &= ~E1000_WUFC_LNKC;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5311
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5312
	if (wufc) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5313
		e1000_setup_rctl(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5314
		e1000_set_rx_mode(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5315
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5316
		/* turn on all-multi mode if wake on multicast is enabled */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5317
		if (wufc & E1000_WUFC_MC) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5318
			rctl = E1000_READ_REG(&adapter->hw, RCTL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5319
			rctl |= E1000_RCTL_MPE;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5320
			E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5321
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5322
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5323
		if (adapter->hw.mac_type >= e1000_82540) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5324
			ctrl = E1000_READ_REG(&adapter->hw, CTRL);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5325
			/* advertise wake from D3Cold */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5326
			#define E1000_CTRL_ADVD3WUC 0x00100000
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5327
			/* phy power management enable */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5328
			#define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5329
			ctrl |= E1000_CTRL_ADVD3WUC |
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5330
				E1000_CTRL_EN_PHY_PWR_MGMT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5331
			E1000_WRITE_REG(&adapter->hw, CTRL, ctrl);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5332
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5333
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5334
		if (adapter->hw.media_type == e1000_media_type_fiber ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5335
		   adapter->hw.media_type == e1000_media_type_internal_serdes) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5336
			/* keep the laser running in D3 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5337
			ctrl_ext = E1000_READ_REG(&adapter->hw, CTRL_EXT);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5338
			ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5339
			E1000_WRITE_REG(&adapter->hw, CTRL_EXT, ctrl_ext);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5340
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5341
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5342
		/* Allow time for pending master requests to run */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5343
		e1000_disable_pciex_master(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5344
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5345
		E1000_WRITE_REG(&adapter->hw, WUC, E1000_WUC_PME_EN);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5346
		E1000_WRITE_REG(&adapter->hw, WUFC, wufc);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5347
		pci_enable_wake(pdev, PCI_D3hot, 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5348
		pci_enable_wake(pdev, PCI_D3cold, 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5349
	} else {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5350
		E1000_WRITE_REG(&adapter->hw, WUC, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5351
		E1000_WRITE_REG(&adapter->hw, WUFC, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5352
		pci_enable_wake(pdev, PCI_D3hot, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5353
		pci_enable_wake(pdev, PCI_D3cold, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5354
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5355
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5356
	e1000_release_manageability(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5357
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5358
	/* make sure adapter isn't asleep if manageability is enabled */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5359
	if (adapter->en_mng_pt) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5360
		pci_enable_wake(pdev, PCI_D3hot, 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5361
		pci_enable_wake(pdev, PCI_D3cold, 1);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5362
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5363
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5364
	if (adapter->hw.phy_type == e1000_phy_igp_3)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5365
		e1000_phy_powerdown_workaround(&adapter->hw);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5366
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5367
	if (netif_running(netdev))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5368
		e1000_free_irq(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5369
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5370
	/* Release control of h/w to f/w.  If f/w is AMT enabled, this
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5371
	 * would have already happened in close and is redundant. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5372
	e1000_release_hw_control(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5373
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5374
	pci_disable_device(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5375
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5376
	pci_set_power_state(pdev, pci_choose_state(pdev, state));
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5377
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5378
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5379
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5380
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5381
#ifdef CONFIG_PM
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5382
static int
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5383
e1000_resume(struct pci_dev *pdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5384
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5385
	struct net_device *netdev = pci_get_drvdata(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5386
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5387
	u32 err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5388
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5389
	if (adapter->ecdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5390
		return -EBUSY;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5391
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5392
	pci_set_power_state(pdev, PCI_D0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5393
	pci_restore_state(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5394
	if ((err = pci_enable_device(pdev))) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5395
		printk(KERN_ERR "e1000: Cannot enable PCI device from suspend\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5396
		return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5397
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5398
	pci_set_master(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5399
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5400
	pci_enable_wake(pdev, PCI_D3hot, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5401
	pci_enable_wake(pdev, PCI_D3cold, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5402
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5403
	if (netif_running(netdev) && (err = e1000_request_irq(adapter)))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5404
		return err;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5405
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5406
	e1000_power_up_phy(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5407
	e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5408
	E1000_WRITE_REG(&adapter->hw, WUS, ~0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5409
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5410
	e1000_init_manageability(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5411
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5412
	if (netif_running(netdev))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5413
		e1000_up(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5414
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5415
	if (!adapter->ecdev) netif_device_attach(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5416
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5417
	/* If the controller is 82573 and f/w is AMT, do not set
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5418
	 * DRV_LOAD until the interface is up.  For all other cases,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5419
	 * let the f/w know that the h/w is now under the control
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5420
	 * of the driver. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5421
	if (adapter->hw.mac_type != e1000_82573 ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5422
	    !e1000_check_mng_mode(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5423
		e1000_get_hw_control(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5424
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5425
	return 0;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5426
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5427
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5428
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5429
static void e1000_shutdown(struct pci_dev *pdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5430
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5431
	e1000_suspend(pdev, PMSG_SUSPEND);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5432
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5433
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5434
#ifdef CONFIG_NET_POLL_CONTROLLER
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5435
/*
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5436
 * Polling 'interrupt' - used by things like netconsole to send skbs
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5437
 * without having to re-enable interrupts. It's not called while
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5438
 * the interrupt routine is executing.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5439
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5440
static void
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5441
e1000_netpoll(struct net_device *netdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5442
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5443
	struct e1000_adapter *adapter = netdev_priv(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5444
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5445
	disable_irq(adapter->pdev->irq);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5446
	e1000_intr(adapter->pdev->irq, netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5447
	e1000_clean_tx_irq(adapter, adapter->tx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5448
#ifndef CONFIG_E1000_NAPI
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5449
	adapter->clean_rx(adapter, adapter->rx_ring);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5450
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5451
	enable_irq(adapter->pdev->irq);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5452
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5453
#endif
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5454
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5455
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5456
 * e1000_io_error_detected - called when PCI error is detected
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5457
 * @pdev: Pointer to PCI device
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5458
 * @state: The current pci conneection state
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5459
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5460
 * This function is called after a PCI bus error affecting
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5461
 * this device has been detected.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5462
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5463
static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5464
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5465
	struct net_device *netdev = pci_get_drvdata(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5466
	struct e1000_adapter *adapter = netdev->priv;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5467
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5468
	netif_device_detach(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5469
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5470
	if (netif_running(netdev))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5471
		e1000_down(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5472
	pci_disable_device(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5473
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5474
	/* Request a slot slot reset. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5475
	return PCI_ERS_RESULT_NEED_RESET;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5476
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5477
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5478
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5479
 * e1000_io_slot_reset - called after the pci bus has been reset.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5480
 * @pdev: Pointer to PCI device
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5481
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5482
 * Restart the card from scratch, as if from a cold-boot. Implementation
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5483
 * resembles the first-half of the e1000_resume routine.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5484
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5485
static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5486
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5487
	struct net_device *netdev = pci_get_drvdata(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5488
	struct e1000_adapter *adapter = netdev->priv;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5489
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5490
	if (pci_enable_device(pdev)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5491
		printk(KERN_ERR "e1000: Cannot re-enable PCI device after reset.\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5492
		return PCI_ERS_RESULT_DISCONNECT;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5493
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5494
	pci_set_master(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5495
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5496
	pci_enable_wake(pdev, PCI_D3hot, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5497
	pci_enable_wake(pdev, PCI_D3cold, 0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5498
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5499
	e1000_reset(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5500
	E1000_WRITE_REG(&adapter->hw, WUS, ~0);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5501
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5502
	return PCI_ERS_RESULT_RECOVERED;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5503
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5504
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5505
/**
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5506
 * e1000_io_resume - called when traffic can start flowing again.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5507
 * @pdev: Pointer to PCI device
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5508
 *
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5509
 * This callback is called when the error recovery driver tells us that
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5510
 * its OK to resume normal operation. Implementation resembles the
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5511
 * second-half of the e1000_resume routine.
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5512
 */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5513
static void e1000_io_resume(struct pci_dev *pdev)
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5514
{
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5515
	struct net_device *netdev = pci_get_drvdata(pdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5516
	struct e1000_adapter *adapter = netdev->priv;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5517
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5518
	e1000_init_manageability(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5519
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5520
	if (netif_running(netdev)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5521
		if (e1000_up(adapter)) {
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5522
			printk("e1000: can't bring device back up after reset\n");
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5523
			return;
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5524
		}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5525
	}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5526
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5527
	netif_device_attach(netdev);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5528
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5529
	/* If the controller is 82573 and f/w is AMT, do not set
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5530
	 * DRV_LOAD until the interface is up.  For all other cases,
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5531
	 * let the f/w know that the h/w is now under the control
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5532
	 * of the driver. */
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5533
	if (adapter->hw.mac_type != e1000_82573 ||
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5534
	    !e1000_check_mng_mode(&adapter->hw))
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5535
		e1000_get_hw_control(adapter);
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5536
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5537
}
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5538
afcea72f0040 Added e1000 driver for 2.6.26, thanks to M. Luescher.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
  5539
/* e1000_main.c */